]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Switch 'struct in_addr' to 'struct prefix' in pim_zlookup.h
authorDonald Sharp <sharpd@cumulusnetwroks.com>
Fri, 2 Sep 2016 14:56:29 +0000 (10:56 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:08 +0000 (20:26 -0500)
This is setup code to allow us to receive v6 addresses from
a nexthop lookup from zebra.  This will allow us to work
with unnumbered interfaces.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_rpf.c
pimd/pim_zlookup.c
pimd/pim_zlookup.h

index da5f16240a966b21ef2cac95eb064e6f2f353538..928629b0cf18a09b66f0fa4dcd6fd52755279895 100644 (file)
@@ -91,7 +91,7 @@ int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr)
   if (PIM_DEBUG_ZEBRA) {
     char nexthop_str[100];
     char addr_str[100];
-    pim_inet4_dump("<nexthop?>", nexthop_tab[0].nexthop_addr, nexthop_str, sizeof(nexthop_str));
+    pim_addr_dump("<nexthop?>", &nexthop_tab[0].nexthop_addr, nexthop_str, sizeof(nexthop_str));
     pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
     zlog_debug("%s %s: found nexthop %s for address %s: interface %s ifindex=%d metric=%d pref=%d",
               __FILE__, __PRETTY_FUNCTION__,
@@ -103,7 +103,7 @@ int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr)
 
   /* update nextop data */
   nexthop->interface              = ifp;
-  nexthop->mrib_nexthop_addr      = nexthop_tab[0].nexthop_addr;
+  nexthop->mrib_nexthop_addr      = nexthop_tab[0].nexthop_addr.u.prefix4;
   nexthop->mrib_metric_preference = nexthop_tab[0].protocol_distance;
   nexthop->mrib_route_metric      = nexthop_tab[0].route_metric;
 
index 7234790fabff0aad6d45ac5458008e601cb3e36a..c2160d8d9dd5564728bd97ce2133c018b21730cc 100644 (file)
@@ -241,17 +241,18 @@ static int zclient_read_nexthop(struct zclient *zlookup,
     switch (nexthop_type) {
     case NEXTHOP_TYPE_IFINDEX:
     case NEXTHOP_TYPE_IPV4_IFINDEX:
+      nexthop_tab[num_ifindex].nexthop_addr.family = AF_INET;
       if (nexthop_type == NEXTHOP_TYPE_IPV4_IFINDEX) {
        if (length < 4) {
          zlog_err("%s: socket %d short input expecting nexthop IPv4-addr: len=%d",
                   __func__, zlookup->sock, length);
          return -8;
        }
-       nexthop_tab[num_ifindex].nexthop_addr.s_addr = stream_get_ipv4(s);
+       nexthop_tab[num_ifindex].nexthop_addr.u.prefix4.s_addr = stream_get_ipv4(s);
        length -= 4;
       }
       else {
-       nexthop_tab[num_ifindex].nexthop_addr.s_addr = PIM_NET_INADDR_ANY;
+       nexthop_tab[num_ifindex].nexthop_addr.u.prefix4.s_addr = PIM_NET_INADDR_ANY;
       }
       nexthop_tab[num_ifindex].ifindex           = stream_getl(s);
       nexthop_tab[num_ifindex].protocol_distance = distance;
@@ -259,7 +260,8 @@ static int zclient_read_nexthop(struct zclient *zlookup,
       ++num_ifindex;
       break;
     case NEXTHOP_TYPE_IPV4:
-      nexthop_tab[num_ifindex].nexthop_addr.s_addr = stream_get_ipv4(s);
+      nexthop_tab[num_ifindex].nexthop_addr.family = AF_INET;
+      nexthop_tab[num_ifindex].nexthop_addr.u.prefix4.s_addr = stream_get_ipv4(s);
       length -= 4;
       nexthop_tab[num_ifindex].ifindex             = 0;
       nexthop_tab[num_ifindex].protocol_distance   = distance;
@@ -268,7 +270,7 @@ static int zclient_read_nexthop(struct zclient *zlookup,
        char addr_str[100];
        char nexthop_str[100];
        pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-       pim_inet4_dump("<nexthop?>", nexthop_tab[num_ifindex].nexthop_addr, nexthop_str, sizeof(nexthop_str));
+       pim_addr_dump("<nexthop?>", &nexthop_tab[num_ifindex].nexthop_addr, nexthop_str, sizeof(nexthop_str));
        zlog_debug("%s %s: zebra returned recursive nexthop %s for address %s",
                   __FILE__, __PRETTY_FUNCTION__,
                   nexthop_str, addr_str);
@@ -354,7 +356,7 @@ zclient_lookup_nexthop (struct pim_zlookup_nexthop nexthop_tab[],
   for (lookup = 0; lookup < max_lookup; ++lookup) {
     int num_ifindex;
     int first_ifindex;
-    struct in_addr nexthop_addr;
+    struct prefix nexthop_addr;
 
     num_ifindex = zclient_lookup_nexthop_once(nexthop_tab,
                                              PIM_NEXTHOP_IFINDEX_TAB_SIZE, addr);
@@ -398,7 +400,7 @@ zclient_lookup_nexthop (struct pim_zlookup_nexthop nexthop_tab[],
        }
 
        /* use last address as nexthop address */
-       nexthop_tab[0].nexthop_addr = addr;
+       nexthop_tab[0].nexthop_addr.u.prefix4 = addr;
 
        /* report original route metric/distance */
        nexthop_tab[0].route_metric = route_metric;
@@ -412,7 +414,7 @@ zclient_lookup_nexthop (struct pim_zlookup_nexthop nexthop_tab[],
       char addr_str[100];
       char nexthop_str[100];
       pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-      pim_inet4_dump("<nexthop?>", nexthop_addr, nexthop_str, sizeof(nexthop_str));
+      pim_addr_dump("<nexthop?>", &nexthop_addr, nexthop_str, sizeof(nexthop_str));
       zlog_debug("%s %s: lookup=%d/%d: zebra returned recursive nexthop %s for address %s dist=%d met=%d",
                __FILE__, __PRETTY_FUNCTION__,
                lookup, max_lookup, nexthop_str, addr_str,
@@ -420,7 +422,7 @@ zclient_lookup_nexthop (struct pim_zlookup_nexthop nexthop_tab[],
                nexthop_tab[0].route_metric);
     }
 
-    addr = nexthop_addr; /* use nexthop addr for recursive lookup */
+    addr = nexthop_addr.u.prefix4; /* use nexthop addr for recursive lookup */
 
   } /* for (max_lookup) */
 
index 4dea5750c5673a7223c6d0507c08262402c321e4..ce85c8eba9dab8f753b552cda9c8f59ae0a6eeb9 100644 (file)
@@ -29,7 +29,7 @@
 #define PIM_NEXTHOP_LOOKUP_MAX (3) /* max. recursive route lookup */
 
 struct pim_zlookup_nexthop {
-  struct in_addr nexthop_addr;
+  struct prefix  nexthop_addr;
   ifindex_t      ifindex;
   uint32_t       route_metric;
   uint8_t        protocol_distance;