]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Add new nexthops to the interface nexthop hash entry list
authorStephen Worley <sworley@cumulusnetworks.com>
Mon, 11 Mar 2019 20:31:44 +0000 (16:31 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:37 +0000 (11:13 -0400)
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 <sworley@cumulusnetworks.com>
zebra/rt_netlink.c

index 7b38dd8bede03d7e39eca09bcd04a51ae80575f1..73260ee18be4fa75aa073c98865ef436007c0402 100644 (file)
@@ -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;
                        }