diff options
author | Mark Stapp <mjs.ietf@gmail.com> | 2021-09-08 21:58:04 +0200 |
---|---|---|
committer | Mark Stapp <mjs.ietf@gmail.com> | 2021-09-14 17:07:30 +0200 |
commit | c6f55fb28f188b59383987f413d802e09c8bce8a (patch) | |
tree | 1ab7efc6931a5cfc88d8bafc6d7cda2fb2c1fb15 /zebra/if_netlink.c | |
parent | zebra: use the dataplane to read netlink intf addr changes (diff) | |
download | frr-c6f55fb28f188b59383987f413d802e09c8bce8a.tar.xz frr-c6f55fb28f188b59383987f413d802e09c8bce8a.zip |
zebra: intf address handler is platform-neutral
Move the handler for incoming interface address events
to a neutral source file - it's not netlink-specific and
shouldn't have been in a netlink file.
Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
Diffstat (limited to 'zebra/if_netlink.c')
-rw-r--r-- | zebra/if_netlink.c | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index d554b02c6..8c528913e 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -1662,114 +1662,6 @@ int netlink_interface_addr_dplane(struct nlmsghdr *h, ns_id_t ns_id, return 0; } -/* - * Handle an interface addr event based on info in a dplane context object. - * This runs in the main pthread, using the info in the context object to - * modify an interface. - */ -int netlink_interface_addr_ctx(struct zebra_dplane_ctx *ctx) -{ - int ret = -1; - struct interface *ifp; - uint8_t flags = 0; - const char *label = NULL; - ns_id_t ns_id; - struct zebra_ns *zns; - uint32_t metric = METRIC_MAX; - ifindex_t ifindex; - const struct prefix *addr, *dest = NULL; - enum dplane_op_e op; - - op = dplane_ctx_get_op(ctx); - ns_id = dplane_ctx_get_ns_id(ctx); - - zns = zebra_ns_lookup(ns_id); - if (zns == NULL) { - /* No ns - deleted maybe? */ - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("%s: can't find zns id %u", __func__, ns_id); - goto done; - } - - ifindex = dplane_ctx_get_ifindex(ctx); - - ifp = if_lookup_by_index_per_ns(zns, ifindex); - if (ifp == NULL) { - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("%s: can't find ifp at nsid %u index %d", - __func__, ns_id, ifindex); - goto done; - } - - addr = dplane_ctx_get_intf_addr(ctx); - - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("%s: %s: ifindex %u, addr %pFX", __func__, - dplane_op2str(op), ifindex, addr); - - /* Is there a peer or broadcast address? */ - dest = dplane_ctx_get_intf_dest(ctx); - if (dest->prefixlen == 0) - dest = NULL; - - if (dplane_ctx_intf_is_connected(ctx)) - SET_FLAG(flags, ZEBRA_IFA_PEER); - - /* Flags. */ - if (dplane_ctx_intf_is_secondary(ctx)) - SET_FLAG(flags, ZEBRA_IFA_SECONDARY); - - /* Label? */ - if (dplane_ctx_intf_has_label(ctx)) - label = dplane_ctx_get_intf_label(ctx); - - if (label && strcmp(ifp->name, label) == 0) - label = NULL; - - metric = dplane_ctx_get_intf_metric(ctx); - - /* Register interface address to the interface. */ - if (addr->family == AF_INET) { - if (op == DPLANE_OP_INTF_ADDR_ADD) - connected_add_ipv4( - ifp, flags, &addr->u.prefix4, addr->prefixlen, - dest ? &dest->u.prefix4 : NULL, label, metric); - else if (CHECK_FLAG(flags, ZEBRA_IFA_PEER)) { - /* Delete with a peer address */ - connected_delete_ipv4(ifp, flags, &addr->u.prefix4, - addr->prefixlen, - &dest->u.prefix4); - } else - connected_delete_ipv4(ifp, flags, &addr->u.prefix4, - addr->prefixlen, NULL); - } - - if (addr->family == AF_INET6) { - if (op == DPLANE_OP_INTF_ADDR_ADD) { - connected_add_ipv6(ifp, flags, &addr->u.prefix6, - dest ? &dest->u.prefix6 : NULL, - addr->prefixlen, label, metric); - } else - connected_delete_ipv6(ifp, &addr->u.prefix6, NULL, - addr->prefixlen); - } - - /* - * Linux kernel does not send route delete on interface down/addr del - * so we have to re-process routes it owns (i.e. kernel routes) - */ - if (op != DPLANE_OP_INTF_ADDR_ADD) - rib_update(RIB_UPDATE_KERNEL); - - ret = 0; - -done: - /* We're responsible for the ctx object */ - dplane_ctx_fini(&ctx); - - return ret; -} - int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) { int len; |