]> git.proxmox.com Git - mirror_frr.git/blobdiff - eigrpd/eigrp_zebra.c
Merge pull request #3517 from qlyoung/doc-exclude-snmptrap
[mirror_frr.git] / eigrpd / eigrp_zebra.c
index 95d97cf97f28aab9f2b61953ecc28c46ace387a6..29bd23b5141dc4212e7587fe63c3f793e814ea57 100644 (file)
@@ -94,6 +94,19 @@ static int eigrp_router_id_update_zebra(int command, struct zclient *zclient,
        return 0;
 }
 
+static int eigrp_zebra_route_notify_owner(int command, struct zclient *zclient,
+                                         zebra_size_t length, vrf_id_t vrf_id)
+{
+       struct prefix p;
+       enum zapi_route_notify_owner note;
+       uint32_t table;
+
+       if (!zapi_route_notify_decode(zclient->ibuf, &p, &table, &note))
+               return -1;
+
+       return 0;
+}
+
 static void eigrp_zebra_connected(struct zclient *zclient)
 {
        zclient_send_reg_requests(zclient, VRF_DEFAULT);
@@ -101,9 +114,11 @@ static void eigrp_zebra_connected(struct zclient *zclient)
 
 void eigrp_zebra_init(void)
 {
-       zclient = zclient_new(master);
+       struct zclient_options opt = {.receive_notify = false};
 
-       zclient_init(zclient, ZEBRA_ROUTE_EIGRP, 0);
+       zclient = zclient_new(master, &opt);
+
+       zclient_init(zclient, ZEBRA_ROUTE_EIGRP, 0, &eigrpd_privs);
        zclient->zebra_connected = eigrp_zebra_connected;
        zclient->router_id_update = eigrp_router_id_update_zebra;
        zclient->interface_add = eigrp_interface_add;
@@ -114,6 +129,7 @@ void eigrp_zebra_init(void)
        zclient->interface_address_delete = eigrp_interface_address_delete;
        zclient->redistribute_route_add = eigrp_zebra_read_route;
        zclient->redistribute_route_del = eigrp_zebra_read_route;
+       zclient->route_notify_owner = eigrp_zebra_route_notify_owner;
 }
 
 
@@ -148,15 +164,16 @@ static int eigrp_interface_add(int command, struct zclient *zclient,
                               zebra_size_t length, vrf_id_t vrf_id)
 {
        struct interface *ifp;
+       struct eigrp_interface *ei;
 
        ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
 
-       assert(ifp->info);
+       if (!ifp->info)
+               return 0;
 
-       if (!EIGRP_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), type)) {
-               SET_IF_PARAM(IF_DEF_PARAMS(ifp), type);
-               IF_DEF_PARAMS(ifp)->type = eigrp_default_iftype(ifp);
-       }
+       ei = ifp->info;
+
+       ei->params.type = eigrp_default_iftype(ifp);
 
        eigrp_if_update(ifp);
 
@@ -168,7 +185,6 @@ static int eigrp_interface_delete(int command, struct zclient *zclient,
 {
        struct interface *ifp;
        struct stream *s;
-       struct route_node *rn;
 
        s = zclient->ibuf;
        /* zebra_interface_state_read () updates interface structure in iflist
@@ -188,12 +204,10 @@ static int eigrp_interface_delete(int command, struct zclient *zclient,
                        ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
                        ifp->metric, ifp->mtu);
 
-       for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn))
-               if (rn->info)
-                       eigrp_if_free((struct eigrp_interface *)rn->info,
-                                     INTERFACE_DOWN_BY_ZEBRA);
+       if (ifp->info)
+               eigrp_if_free(ifp->info, INTERFACE_DOWN_BY_ZEBRA);
 
-       ifp->ifindex = IFINDEX_INTERNAL;
+       if_set_index(ifp, IFINDEX_INTERNAL);
        return 0;
 }
 
@@ -225,8 +239,6 @@ static int eigrp_interface_address_delete(int command, struct zclient *zclient,
        struct connected *c;
        struct interface *ifp;
        struct eigrp_interface *ei;
-       struct route_node *rn;
-       struct prefix p;
 
        c = zebra_interface_address_read(command, zclient->ibuf, vrf_id);
 
@@ -241,17 +253,9 @@ static int eigrp_interface_address_delete(int command, struct zclient *zclient,
        }
 
        ifp = c->ifp;
-       p = *c->address;
-       p.prefixlen = IPV4_MAX_PREFIXLEN;
-
-       rn = route_node_lookup(IF_OIFS(ifp), &p);
-       if (!rn) {
-               connected_free(c);
+       ei = ifp->info;
+       if (!ei)
                return 0;
-       }
-
-       assert(rn->info);
-       ei = rn->info;
 
        /* Call interface hook functions to clean up */
        eigrp_if_free(ei, INTERFACE_DOWN_BY_ZEBRA);
@@ -265,8 +269,6 @@ static int eigrp_interface_state_up(int command, struct zclient *zclient,
                                    zebra_size_t length, vrf_id_t vrf_id)
 {
        struct interface *ifp;
-       struct eigrp_interface *ei;
-       struct route_node *rn;
 
        ifp = zebra_interface_if_lookup(zclient->ibuf);
 
@@ -314,12 +316,8 @@ static int eigrp_interface_state_up(int command, struct zclient *zclient,
                zlog_debug("Zebra: Interface[%s] state change to up.",
                           ifp->name);
 
-       for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
-               if ((ei = rn->info) == NULL)
-                       continue;
-
-               eigrp_if_up(ei);
-       }
+       if (ifp->info)
+               eigrp_if_up(ifp->info);
 
        return 0;
 }
@@ -328,8 +326,6 @@ static int eigrp_interface_state_down(int command, struct zclient *zclient,
                                      zebra_size_t length, vrf_id_t vrf_id)
 {
        struct interface *ifp;
-       struct eigrp_interface *ei;
-       struct route_node *node;
 
        ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
 
@@ -340,11 +336,8 @@ static int eigrp_interface_state_down(int command, struct zclient *zclient,
                zlog_debug("Zebra: Interface[%s] state change to down.",
                           ifp->name);
 
-       for (node = route_top(IF_OIFS(ifp)); node; node = route_next(node)) {
-               if ((ei = node->info) == NULL)
-                       continue;
-               eigrp_if_down(ei);
-       }
+       if (ifp->info)
+               eigrp_if_down(ifp->info);
 
        return 0;
 }
@@ -357,8 +350,7 @@ static struct interface *zebra_interface_if_lookup(struct stream *s)
        stream_get(ifname_tmp, s, INTERFACE_NAMSIZ);
 
        /* And look it up. */
-       return if_lookup_by_name_len(
-               ifname_tmp, strnlen(ifname_tmp, INTERFACE_NAMSIZ), VRF_DEFAULT);
+       return if_lookup_by_name(ifname_tmp, VRF_DEFAULT);
 }
 
 void eigrp_zebra_route_add(struct prefix *p, struct list *successors)
@@ -385,6 +377,7 @@ void eigrp_zebra_route_add(struct prefix *p, struct list *successors)
                if (count >= MULTIPATH_NUM)
                        break;
                api_nh = &api.nexthops[count];
+               api_nh->vrf_id = VRF_DEFAULT;
                if (te->adv_router->src.s_addr) {
                        api_nh->gate.ipv4 = te->adv_router->src;
                        api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;