From 8c0a24c14ed9d0ee504463de9d8b8be9da5b5628 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Mon, 11 Mar 2019 16:31:44 -0400 Subject: [PATCH] zebra: Add new nexthops to the interface nexthop hash entry list When we get a new nexthop and find the interface associated with it, add this nexthop to the interface's zebra interface info nexthop hash entry list. Signed-off-by: Stephen Worley --- zebra/rt_netlink.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 7b38dd8bed..73260ee18b 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -2096,17 +2096,18 @@ enum zebra_dplane_result kernel_route_update(struct zebra_dplane_ctx *ctx) * * @tb: Netlink RTA data * @family: Address family in the nhmsg + * @ifp: Interface connected - this should be NULL, we fill it in * @ns_id: Namspace id * * Return: New nexthop */ static struct nexthop netlink_nexthop_process_nh(struct rtattr **tb, unsigned char family, + struct interface **ifp, ns_id_t ns_id) { struct nexthop nh = {0}; void *gate = NULL; - struct interface *ifp = NULL; int if_index; size_t sz; @@ -2138,9 +2139,9 @@ static struct nexthop netlink_nexthop_process_nh(struct rtattr **tb, nh.ifindex = if_index; - ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id), nh.ifindex); + *ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id), nh.ifindex); if (ifp) { - nh.vrf_id = ifp->vrf_id; + nh.vrf_id = (*ifp)->vrf_id; } else { flog_warn( EC_ZEBRA_UNKNOWN_INTERFACE, @@ -2223,6 +2224,7 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) /* nexthop group id */ uint32_t id; unsigned char family; + struct interface *ifp = NULL; struct nhmsg *nhm = NULL; /* struct for nexthop group abstraction */ struct nexthop_group nhg = {0}; @@ -2290,7 +2292,8 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) * This is a true new nexthop, so we need * to parse the gateway and device info */ - nh = netlink_nexthop_process_nh(tb, family, ns_id); + nh = netlink_nexthop_process_nh(tb, family, &ifp, + ns_id); } @@ -2310,6 +2313,12 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) nhe = zebra_nhg_find(&nhg, nh.vrf_id, id); if (nhe) { nhe->is_kernel_nh = true; + if (ifp) { + /* Add the nhe to the interface's list + * of connected nhe's + */ + nhe_connected_add(ifp, nhe); + } } else { return -1; } -- 2.39.5