+// SPDX-License-Identifier: GPL-2.0-or-later
/* Kernel communication using netlink interface.
* Copyright (C) 1999 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "zebra/rt_netlink.h"
#include "zebra/if_netlink.h"
#include "zebra/rule_netlink.h"
+#include "zebra/tc_netlink.h"
#include "zebra/netconf_netlink.h"
#include "zebra/zebra_errors.h"
{RTM_NEWTUNNEL, "RTM_NEWTUNNEL"},
{RTM_DELTUNNEL, "RTM_DELTUNNEL"},
{RTM_GETTUNNEL, "RTM_GETTUNNEL"},
+ {RTM_NEWQDISC, "RTM_NEWQDISC"},
+ {RTM_DELQDISC, "RTM_DELQDISC"},
+ {RTM_GETQDISC, "RTM_GETQDISC"},
+ {RTM_NEWTCLASS, "RTM_NEWTCLASS"},
+ {RTM_DELTCLASS, "RTM_DELTCLASS"},
+ {RTM_GETTCLASS, "RTM_GETTCLASS"},
+ {RTM_NEWTFILTER, "RTM_NEWTFILTER"},
+ {RTM_DELTFILTER, "RTM_DELTFILTER"},
+ {RTM_GETTFILTER, "RTM_GETTFILTER"},
{0}};
static const struct message rtproto_str[] = {
const struct zebra_dplane_info *zns;
- struct dplane_ctx_q ctx_list;
+ struct dplane_ctx_list_head ctx_list;
/*
* Pointer to the queue of completed contexts outbound back
* towards the dataplane module.
*/
- struct dplane_ctx_q *ctx_out_q;
+ struct dplane_ctx_list_head *ctx_out_q;
};
int netlink_config_write_helper(struct vty *vty)
return netlink_nexthop_change(h, ns_id, startup);
case RTM_DELNEXTHOP:
return netlink_nexthop_change(h, ns_id, startup);
+ case RTM_NEWQDISC:
+ case RTM_DELQDISC:
+ return netlink_qdisc_change(h, ns_id, startup);
+ case RTM_NEWTCLASS:
+ case RTM_DELTCLASS:
+ return netlink_tclass_change(h, ns_id, startup);
+ case RTM_NEWTFILTER:
+ case RTM_DELTFILTER:
+ return netlink_tfilter_change(h, ns_id, startup);
/* Messages handled in the dplane thread */
case RTM_NEWADDR:
return 1;
}
- /* Deal with errors that occur because of races in link handling. */
- if (is_cmd
- && ((msg_type == RTM_DELROUTE
- && (-errnum == ENODEV || -errnum == ESRCH))
- || (msg_type == RTM_NEWROUTE
- && (-errnum == ENETDOWN || -errnum == EEXIST)))) {
+ /*
+ * Deal with errors that occur because of races in link handling
+ * or types are not supported in kernel.
+ */
+ if (is_cmd &&
+ ((msg_type == RTM_DELROUTE &&
+ (-errnum == ENODEV || -errnum == ESRCH)) ||
+ (msg_type == RTM_NEWROUTE &&
+ (-errnum == ENETDOWN || -errnum == EEXIST)) ||
+ ((msg_type == RTM_NEWTUNNEL || msg_type == RTM_DELTUNNEL ||
+ msg_type == RTM_GETTUNNEL) &&
+ (-errnum == EOPNOTSUPP)))) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("%s: error: %s type=%s(%u), seq=%u, pid=%u",
nl->name, safe_strerror(-errnum),
bth->msgcnt = 0;
bth->zns = NULL;
- TAILQ_INIT(&(bth->ctx_list));
+ dplane_ctx_q_init(&(bth->ctx_list));
}
-static void nl_batch_init(struct nl_batch *bth, struct dplane_ctx_q *ctx_out_q)
+static void nl_batch_init(struct nl_batch *bth,
+ struct dplane_ctx_list_head *ctx_out_q)
{
/*
* If the size of the buffer has changed, free and then allocate a new
case DPLANE_OP_INTF_ADDR_ADD:
case DPLANE_OP_INTF_ADDR_DEL:
- case DPLANE_OP_INTF_NETCONFIG:
case DPLANE_OP_NONE:
return FRR_NETLINK_ERROR;
+ case DPLANE_OP_INTF_NETCONFIG:
+ return netlink_put_intf_netconfig(bth, ctx);
+
case DPLANE_OP_INTF_INSTALL:
case DPLANE_OP_INTF_UPDATE:
case DPLANE_OP_INTF_DELETE:
return netlink_put_intf_update_msg(bth, ctx);
+
+ case DPLANE_OP_TC_QDISC_INSTALL:
+ case DPLANE_OP_TC_QDISC_UNINSTALL:
+ return netlink_put_tc_qdisc_update_msg(bth, ctx);
+ case DPLANE_OP_TC_CLASS_ADD:
+ case DPLANE_OP_TC_CLASS_DELETE:
+ case DPLANE_OP_TC_CLASS_UPDATE:
+ return netlink_put_tc_class_update_msg(bth, ctx);
+ case DPLANE_OP_TC_FILTER_ADD:
+ case DPLANE_OP_TC_FILTER_DELETE:
+ case DPLANE_OP_TC_FILTER_UPDATE:
+ return netlink_put_tc_filter_update_msg(bth, ctx);
}
return FRR_NETLINK_ERROR;
}
-void kernel_update_multi(struct dplane_ctx_q *ctx_list)
+void kernel_update_multi(struct dplane_ctx_list_head *ctx_list)
{
struct nl_batch batch;
struct zebra_dplane_ctx *ctx;
- struct dplane_ctx_q handled_list;
+ struct dplane_ctx_list_head handled_list;
enum netlink_msg_status res;
- TAILQ_INIT(&handled_list);
+ dplane_ctx_q_init(&handled_list);
nl_batch_init(&batch, &handled_list);
while (true) {
nl_batch_send(&batch);
- TAILQ_INIT(ctx_list);
+ dplane_ctx_q_init(ctx_list);
dplane_ctx_list_append(ctx_list, &handled_list);
}
* RTNLGRP_XXX to a bit position for ourself
*/
groups = RTMGRP_LINK |
- RTMGRP_IPV4_ROUTE |
- RTMGRP_IPV4_IFADDR |
- RTMGRP_IPV6_ROUTE |
- RTMGRP_IPV6_IFADDR |
- RTMGRP_IPV4_MROUTE |
- RTMGRP_NEIGH |
- ((uint32_t) 1 << (RTNLGRP_IPV4_RULE - 1)) |
- ((uint32_t) 1 << (RTNLGRP_IPV6_RULE - 1)) |
- ((uint32_t) 1 << (RTNLGRP_NEXTHOP - 1));
+ RTMGRP_IPV4_ROUTE |
+ RTMGRP_IPV4_IFADDR |
+ RTMGRP_IPV6_ROUTE |
+ RTMGRP_IPV6_IFADDR |
+ RTMGRP_IPV4_MROUTE |
+ RTMGRP_NEIGH |
+ ((uint32_t) 1 << (RTNLGRP_IPV4_RULE - 1)) |
+ ((uint32_t) 1 << (RTNLGRP_IPV6_RULE - 1)) |
+ ((uint32_t) 1 << (RTNLGRP_NEXTHOP - 1)) |
+ ((uint32_t) 1 << (RTNLGRP_TC - 1));
dplane_groups = (RTMGRP_LINK |
RTMGRP_IPV4_IFADDR |
void kernel_terminate(struct zebra_ns *zns, bool complete)
{
- thread_cancel(&zns->t_netlink);
+ THREAD_OFF(zns->t_netlink);
kernel_nlsock_fini(&zns->netlink);