]> git.proxmox.com Git - mirror_frr.git/commitdiff
staticd: Fix nht to include SAFI_MULTICAST
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 4 Jan 2019 14:42:11 +0000 (09:42 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 4 Jan 2019 14:48:10 +0000 (09:48 -0500)
The nexthop tracking was correctly registering the nexthops in
the SAFI_UNICAST table, but we need to apply them to the
SAFI_MULTICAST mroute information( if any ) as well.

donna.cumulusnetworks.com# conf t
donna.cumulusnetworks.com(config)# ip mroute 230.0.4.0/24 192.168.210.50
donna.cumulusnetworks.com(config)# end
donna.cumulusnetworks.com# show ip rpf
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route

C>* 10.0.2.0/24 is directly connected, enp0s3, 00:08:28
C>* 192.168.209.0/24 is directly connected, enp0s8, 00:08:28
C>* 192.168.210.0/24 is directly connected, enp0s9, 00:08:28
S>* 230.0.4.0/24 [1/0] via 192.168.210.50, enp0s9, 00:07:56
S>* 230.0.5.0/24 [1/0] via 192.168.210.50, enp0s9, 00:07:17

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
staticd/static_nht.c

index 44f7fb79da8d45eb6fba677a93078d1d9cb6941e..38fd53a1f2a75818dc4230d7cf5b892d0d19b7d9 100644 (file)
 #include "static_zebra.h"
 #include "static_nht.h"
 
-void static_nht_update(struct prefix *p, uint32_t nh_num, afi_t afi,
-                      vrf_id_t nh_vrf_id)
+static void static_nht_update_safi(struct prefix *p, uint32_t nh_num,
+                                  afi_t afi, safi_t safi, struct vrf *vrf,
+                                  vrf_id_t nh_vrf_id)
 {
        struct route_table *stable;
        struct static_route *si;
        struct static_vrf *svrf;
        struct route_node *rn;
-       struct vrf *vrf;
        bool orig;
        bool reinstall;
 
-       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
-               svrf = vrf->info;
-               if (!svrf)
-                       continue;
+       svrf = vrf->info;
+       if (!svrf)
+               return;
 
-               stable = static_vrf_static_table(afi, SAFI_UNICAST, svrf);
-               if (!stable)
-                       continue;
+       stable = static_vrf_static_table(afi, safi, svrf);
+       if (!stable)
+               return;
 
-               for (rn = route_top(stable); rn; rn = route_next(rn)) {
-                       reinstall = false;
-                       for (si = rn->info; si; si = si->next) {
-                               if (si->nh_vrf_id != nh_vrf_id)
-                                       continue;
+       for (rn = route_top(stable); rn; rn = route_next(rn)) {
+               reinstall = false;
+               for (si = rn->info; si; si = si->next) {
+                       if (si->nh_vrf_id != nh_vrf_id)
+                               return;
 
-                               if (si->type != STATIC_IPV4_GATEWAY
-                                   && si->type != STATIC_IPV4_GATEWAY_IFNAME
-                                   && si->type != STATIC_IPV6_GATEWAY
-                                   && si->type != STATIC_IPV6_GATEWAY_IFNAME)
-                                       continue;
+                       if (si->type != STATIC_IPV4_GATEWAY
+                           && si->type != STATIC_IPV4_GATEWAY_IFNAME
+                           && si->type != STATIC_IPV6_GATEWAY
+                           && si->type != STATIC_IPV6_GATEWAY_IFNAME)
+                               return;
 
-                               orig = si->nh_valid;
-                               if (p->family == AF_INET
-                                   && p->u.prefix4.s_addr
-                                              == si->addr.ipv4.s_addr)
-                                       si->nh_valid = !!nh_num;
+                       orig = si->nh_valid;
+                       if (p->family == AF_INET
+                           && p->u.prefix4.s_addr == si->addr.ipv4.s_addr)
+                               si->nh_valid = !!nh_num;
 
-                               if (p->family == AF_INET6
-                                   && memcmp(&p->u.prefix6, &si->addr.ipv6, 16)
-                                              == 0)
-                                       si->nh_valid = !!nh_num;
+                       if (p->family == AF_INET6
+                           && memcmp(&p->u.prefix6, &si->addr.ipv6, 16) == 0)
+                               si->nh_valid = !!nh_num;
 
-                               if (orig != si->nh_valid)
-                                       reinstall = true;
+                       if (orig != si->nh_valid)
+                               reinstall = true;
 
-                               if (reinstall) {
-                                       static_zebra_route_add(
-                                               rn, si, vrf->vrf_id,
-                                               SAFI_UNICAST, true);
-                                       reinstall = false;
-                               }
+                       if (reinstall) {
+                               static_zebra_route_add(rn, si, vrf->vrf_id,
+                                                      safi, true);
+                               reinstall = false;
                        }
                }
        }
 }
+
+void static_nht_update(struct prefix *p, uint32_t nh_num, afi_t afi,
+                      vrf_id_t nh_vrf_id)
+{
+
+       struct vrf *vrf;
+
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
+               static_nht_update_safi(p, nh_num, afi, SAFI_UNICAST,
+                                      vrf, nh_vrf_id);
+               static_nht_update_safi(p, nh_num, afi, SAFI_MULTICAST,
+                                      vrf, nh_vrf_id);
+       }
+}