]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd - Fix rpf lookup to what it was originally
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 19 Aug 2016 17:25:20 +0000 (13:25 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:07 +0000 (20:26 -0500)
I tried to be smart and skirt around rpf lookup if I knew
the incoming interface.  This turns out to be not necessarily
a good thing because we can easily have asymetrical routing.

This fix removes the attempt to cache the ifp we received
the incoming packet on and just lets the lookup work like
it should.

Additionally it removes the weird hardcoding of the rpf
interface from the register stuff.

Ticket: CM-12530
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
reb

pimd/pim_cmd.c
pimd/pim_mroute.c
pimd/pim_register.c
pimd/pim_rp.c
pimd/pim_rpf.c
pimd/pim_rpf.h
pimd/pim_upstream.c
pimd/pim_zebra.c

index ba2d4a063bd580fe2ed02280626fb913012439c8..bd3a85abb04ef498c2a4b24d64ea9d3e4b93626f 100644 (file)
@@ -2347,7 +2347,7 @@ DEFUN (show_ip_rib,
     return CMD_WARNING;
   }
 
-  if (pim_nexthop_lookup(&nexthop, addr, NULL)) {
+  if (pim_nexthop_lookup(&nexthop, addr)) {
     vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s",
            addr_str, VTY_NEWLINE);
     return CMD_WARNING;
index e678b87cc7e2c15b7b5b38a48aa14a767b2389eb..a17a8b1006669863a69255f2fceb78ea88e1fcb0 100644 (file)
@@ -358,7 +358,7 @@ pim_mroute_msg_wrvifwhole (int fd, struct interface *ifp, const char *buf)
        {
          struct pim_nexthop source;
          //No if channel, but upstream we are at the RP.
-         pim_nexthop_lookup (&source, up->upstream_register, NULL);
+         pim_nexthop_lookup (&source, up->upstream_register);
          pim_register_stop_send(source.interface, &sg, up->upstream_register);
          //Send S bit down the join.
          up->sptbit = PIM_UPSTREAM_SPTBIT_TRUE;
index 439bb577c9a0e49450847a28f1eadb97d547607c..4cc4a2703c8fe7d081d7fa2e14c82fba370e50ac 100644 (file)
@@ -326,12 +326,10 @@ pim_register_recv (struct interface *ifp,
         upstream->upstream_register = src_addr;
        pim_rp_set_upstream_addr (&upstream->upstream_addr, sg.src, sg.grp);
        pim_nexthop_lookup (&upstream->rpf.source_nexthop,
-                           upstream->upstream_addr, NULL);
-       upstream->rpf.source_nexthop.interface = ifp;
+                           upstream->upstream_addr);
        upstream->sg.src = sg.src;
        upstream->rpf.rpf_addr = upstream->rpf.source_nexthop.mrib_nexthop_addr;
 
-       //pim_upstream_switch (upstream, PIM_UPSTREAM_PRUNE);
        upstream->join_state = PIM_UPSTREAM_PRUNE;
 
       }
index 0af7a991ee254fc909c540d045f82f8d9723357a..84de87076446f81eea5920c2a0cd80cfd372ff1c 100644 (file)
@@ -262,7 +262,7 @@ pim_rp_setup (void)
 
   for (ALL_LIST_ELEMENTS_RO (qpim_rp_list, node, rp_info))
     {
-      if (pim_nexthop_lookup (&rp_info->rp.source_nexthop, rp_info->rp.rpf_addr, NULL) != 0)
+      if (pim_nexthop_lookup (&rp_info->rp.source_nexthop, rp_info->rp.rpf_addr) != 0)
         {
           zlog_err ("Unable to lookup nexthop for rp specified");
           ret++;
@@ -358,7 +358,7 @@ pim_rp_g (struct in_addr group)
 
   if (rp_info)
     {
-      pim_nexthop_lookup(&rp_info->rp.source_nexthop, rp_info->rp.rpf_addr, NULL);
+      pim_nexthop_lookup(&rp_info->rp.source_nexthop, rp_info->rp.rpf_addr);
       return (&rp_info->rp);
     }
 
index 15b00d8d060a11715aa088a91e87a56f9f731455..e81e262cd6c8367a3c951403b59b04435fd8abfa 100644 (file)
@@ -37,8 +37,7 @@
 
 static struct in_addr pim_rpf_find_rpf_addr(struct pim_upstream *up);
 
-int pim_nexthop_lookup(struct pim_nexthop *nexthop,
-                      struct in_addr addr, struct interface *incoming)
+int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr)
 {
   struct pim_zlookup_nexthop nexthop_tab[PIM_NEXTHOP_IFINDEX_TAB_SIZE];
   int num_ifindex;
@@ -47,46 +46,38 @@ int pim_nexthop_lookup(struct pim_nexthop *nexthop,
 
   memset (nexthop_tab, 0, sizeof (struct pim_zlookup_nexthop) * PIM_NEXTHOP_IFINDEX_TAB_SIZE);
 
-  if (!incoming)
-    {
-      num_ifindex = zclient_lookup_nexthop(nexthop_tab,
-                                          PIM_NEXTHOP_IFINDEX_TAB_SIZE,
-                                          addr, PIM_NEXTHOP_LOOKUP_MAX);
-      if (num_ifindex < 1) {
-       char addr_str[100];
-       pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-       zlog_warn("%s %s: could not find nexthop ifindex for address %s",
-                 __FILE__, __PRETTY_FUNCTION__,
-                 addr_str);
-       return -1;
-      }
-
-      first_ifindex = nexthop_tab[0].ifindex;
-
-      if (num_ifindex > 1) {
-       char addr_str[100];
-       pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-       zlog_info("%s %s: FIXME ignoring multiple nexthop ifindex'es num_ifindex=%d for address %s (using only ifindex=%d)",
-                 __FILE__, __PRETTY_FUNCTION__,
-                 num_ifindex, addr_str, first_ifindex);
-       /* debug warning only, do not return */
-      }
-
-      ifp = if_lookup_by_index(first_ifindex);
-      if (!ifp) {
-       char addr_str[100];
-       pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-       zlog_warn("%s %s: could not find interface for ifindex %d (address %s)",
-                 __FILE__, __PRETTY_FUNCTION__,
-                 first_ifindex, addr_str);
-       return -2;
-      }
-    }
-  else
-    {
-      ifp = incoming;
-      first_ifindex = ifp->ifindex;
-    }
+  num_ifindex = zclient_lookup_nexthop(nexthop_tab,
+                                      PIM_NEXTHOP_IFINDEX_TAB_SIZE,
+                                      addr, PIM_NEXTHOP_LOOKUP_MAX);
+  if (num_ifindex < 1) {
+    char addr_str[100];
+    pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
+    zlog_warn("%s %s: could not find nexthop ifindex for address %s",
+             __FILE__, __PRETTY_FUNCTION__,
+             addr_str);
+    return -1;
+  }
+
+  first_ifindex = nexthop_tab[0].ifindex;
+
+  if (num_ifindex > 1) {
+    char addr_str[100];
+    pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
+    zlog_info("%s %s: FIXME ignoring multiple nexthop ifindex'es num_ifindex=%d for address %s (using only ifindex=%d)",
+             __FILE__, __PRETTY_FUNCTION__,
+             num_ifindex, addr_str, first_ifindex);
+    /* debug warning only, do not return */
+  }
+
+  ifp = if_lookup_by_index(first_ifindex);
+  if (!ifp) {
+    char addr_str[100];
+    pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
+    zlog_warn("%s %s: could not find interface for ifindex %d (address %s)",
+             __FILE__, __PRETTY_FUNCTION__,
+             first_ifindex, addr_str);
+    return -2;
+  }
 
   if (!ifp->info) {
     char addr_str[100];
@@ -131,9 +122,7 @@ static int nexthop_mismatch(const struct pim_nexthop *nh1,
     (nh1->mrib_route_metric != nh2->mrib_route_metric);
 }
 
-enum pim_rpf_result pim_rpf_update(struct pim_upstream *up,
-                                  struct in_addr *old_rpf_addr,
-                                  struct interface *incoming)
+enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct in_addr *old_rpf_addr)
 {
   struct in_addr      save_rpf_addr;
   struct pim_nexthop  save_nexthop;
@@ -142,8 +131,7 @@ enum pim_rpf_result pim_rpf_update(struct pim_upstream *up,
   save_nexthop  = rpf->source_nexthop; /* detect change in pim_nexthop */
   save_rpf_addr = rpf->rpf_addr;       /* detect change in RPF'(S,G) */
 
-  if (pim_nexthop_lookup(&rpf->source_nexthop,
-                        up->upstream_addr, incoming)) {
+  if (pim_nexthop_lookup(&rpf->source_nexthop, up->upstream_addr)) {
     return PIM_RPF_FAILURE;
   }
 
index 86c33c2e4571bda5c77072a3ad80a2107fca7fef..ab16039a29fa8ef77941d3a86048eb25ee84374d 100644 (file)
 #include "pim_upstream.h"
 #include "pim_neighbor.h"
 
-int pim_nexthop_lookup(struct pim_nexthop *nexthop,
-                      struct in_addr addr, struct interface *incoming);
-enum pim_rpf_result pim_rpf_update(struct pim_upstream *up,
-                                  struct in_addr *old_rpf_addr,
-                                  struct interface *incoming);
+int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr);
+enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct in_addr *old_rpf_addr);
 
 #endif /* PIM_RPF_H */
index bd6677d47d856e8b60e13b4e6ff5a6cf1994b8e4..37b900688e57d1bfa7be7a366d2b6710a420284d 100644 (file)
@@ -463,13 +463,13 @@ static struct pim_upstream *pim_upstream_new(struct prefix_sg *sg,
   up->channel_oil                = NULL;
   up->sptbit                     = PIM_UPSTREAM_SPTBIT_FALSE;
 
-  up->rpf.source_nexthop.interface                = 0;
+  up->rpf.source_nexthop.interface                = NULL;
   up->rpf.source_nexthop.mrib_nexthop_addr.s_addr = PIM_NET_INADDR_ANY;
   up->rpf.source_nexthop.mrib_metric_preference   = qpim_infinite_assert_metric.metric_preference;
   up->rpf.source_nexthop.mrib_route_metric        = qpim_infinite_assert_metric.route_metric;
   up->rpf.rpf_addr.s_addr                         = PIM_NET_INADDR_ANY;
 
-  rpf_result = pim_rpf_update(up, 0, incoming);
+  rpf_result = pim_rpf_update(up, 0);
   if (rpf_result == PIM_RPF_FAILURE) {
     XFREE(MTYPE_PIM_UPSTREAM, up);
     return NULL;
index f710fc20c952662047484ef13531241d6231dd47..94cd6589323a257d50200a236bc6a7a90c497b23 100644 (file)
@@ -333,7 +333,7 @@ static void scan_upstream_rpf_cache()
     struct in_addr      old_rpf_addr;
     enum pim_rpf_result rpf_result;
 
-    rpf_result = pim_rpf_update(up, &old_rpf_addr, NULL);
+    rpf_result = pim_rpf_update(up, &old_rpf_addr);
     if (rpf_result == PIM_RPF_FAILURE)
       continue;