]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: Remove non-vrf based ifindex lookup
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 10 Mar 2017 20:45:28 +0000 (15:45 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 15 Mar 2017 14:26:53 +0000 (10:26 -0400)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
23 files changed:
lib/bfd.c
lib/if.c
lib/if.h
lib/zclient.c
nhrpd/netlink_arp.c
nhrpd/nhrp_interface.c
nhrpd/nhrp_packet.c
nhrpd/nhrp_route.c
ospf6d/ospf6_interface.c
ospfd/ospf_packet.c
ospfd/ospf_vty.c
pimd/pim_iface.c
pimd/pim_pim.c
pimd/pim_rpf.c
pimd/pim_ssmpingd.c
pimd/pim_zlookup.c
ripngd/ripngd.c
zebra/if_sysctl.c
zebra/irdp_packet.c
zebra/kernel_socket.c
zebra/rt_netlink.c
zebra/zebra_mpls.c
zebra/zebra_rib.c

index a5edaea21756626c24e8572bf9f4541fa76845dd..b651a05a097cec5f4428833ddeee78e6cddaa73b 100644 (file)
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -293,7 +293,7 @@ bfd_get_peer_info (struct stream *s, struct prefix *dp, struct prefix *sp,
   /* Lookup index. */
   if (ifindex != 0)
     {
-      ifp = if_lookup_by_index_vrf (ifindex, vrf_id);
+      ifp = if_lookup_by_index (ifindex, vrf_id);
       if (ifp == NULL)
         {
          if (bfd_debug)
index f25be591d9ebfa17393bcf5b1e5eb8860d6ab6a3..84489f9e425e96094e7dc972766d50687f070428 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -239,7 +239,7 @@ if_add_hook (int type, int (*func)(struct interface *ifp))
 
 /* Interface existance check by index. */
 struct interface *
-if_lookup_by_index_vrf (ifindex_t ifindex, vrf_id_t vrf_id)
+if_lookup_by_index (ifindex_t ifindex, vrf_id_t vrf_id)
 {
   struct listnode *node;
   struct interface *ifp;
@@ -252,18 +252,12 @@ if_lookup_by_index_vrf (ifindex_t ifindex, vrf_id_t vrf_id)
   return NULL;
 }
 
-struct interface *
-if_lookup_by_index (ifindex_t ifindex)
-{
-  return if_lookup_by_index_vrf (ifindex, VRF_DEFAULT);
-}
-
 const char *
 ifindex2ifname_vrf (ifindex_t ifindex, vrf_id_t vrf_id)
 {
   struct interface *ifp;
 
-  return ((ifp = if_lookup_by_index_vrf (ifindex, vrf_id)) != NULL) ?
+  return ((ifp = if_lookup_by_index (ifindex, vrf_id)) != NULL) ?
         ifp->name : "unknown";
 }
 
@@ -1188,7 +1182,7 @@ ifaddr_ipv4_lookup (struct in_addr *addr, ifindex_t ifindex)
       return ifp;
     }
   else
-    return if_lookup_by_index(ifindex);
+    return if_lookup_by_index(ifindex, VRF_DEFAULT);
 }
 #endif /* ifaddr_ipv4_table */
 
index 32e5d92a97996a4f2f259de7482ee14472c70b96..6afce9dda6172bae9a2b31876b0d03d54c402eb6 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -390,7 +390,6 @@ struct nbr_connected
 /* Prototypes. */
 extern int if_cmp_name_func (char *, char *);
 extern struct interface *if_create (const char *name, int namelen);
-extern struct interface *if_lookup_by_index (ifindex_t);
 extern struct interface *if_lookup_exact_address (void *matchaddr, int family);
 extern struct connected *if_lookup_address (void *matchaddr, int family);
 extern struct interface *if_lookup_prefix (struct prefix *prefix);
@@ -399,7 +398,7 @@ extern void if_update_vrf (struct interface *, const char *name, int namelen,
                                 vrf_id_t vrf_id);
 extern struct interface *if_create_vrf (const char *name, int namelen,
                                 vrf_id_t vrf_id);
-extern struct interface *if_lookup_by_index_vrf (ifindex_t, vrf_id_t vrf_id);
+extern struct interface *if_lookup_by_index (ifindex_t, vrf_id_t vrf_id);
 extern struct interface *if_lookup_exact_address_vrf (void *matchaddr, int family,
                                 vrf_id_t vrf_id);
 extern struct connected *if_lookup_address_vrf (void *matchaddr, int family,
index 859751deb8a761698f7c34d470d0e5f8b03a7a0a..990bf7906ecb9d2fb3898931d93376886e98a825 100644 (file)
@@ -1153,7 +1153,7 @@ zebra_interface_link_params_read (struct stream *s)
 
   ifindex = stream_getl (s);
 
-  struct interface *ifp = if_lookup_by_index (ifindex);
+  struct interface *ifp = if_lookup_by_index (ifindex, VRF_DEFAULT);
 
   if (ifp == NULL)
     {
@@ -1302,7 +1302,7 @@ zebra_interface_address_read (int type, struct stream *s, vrf_id_t vrf_id)
   ifindex = stream_getl (s);
 
   /* Lookup index. */
-  ifp = if_lookup_by_index_vrf (ifindex, vrf_id);
+  ifp = if_lookup_by_index (ifindex, vrf_id);
   if (ifp == NULL)
     {
       zlog_warn ("INTERFACE_ADDRESS_%s: Cannot find IF %u in VRF %d",
@@ -1396,7 +1396,7 @@ zebra_interface_nbr_address_read (int type, struct stream *s, vrf_id_t vrf_id)
   ifindex = stream_getl (s);
 
   /* Lookup index. */
-  ifp = if_lookup_by_index_vrf (ifindex, vrf_id);
+  ifp = if_lookup_by_index (ifindex, vrf_id);
   if (ifp == NULL)
     {
       zlog_warn ("INTERFACE_NBR_%s: Cannot find IF %u in VRF %d",
@@ -1447,7 +1447,7 @@ zebra_interface_vrf_update_read (struct stream *s, vrf_id_t vrf_id,
   ifindex = stream_getl (s);
 
   /* Lookup interface. */
-  ifp = if_lookup_by_index_vrf (ifindex, vrf_id);
+  ifp = if_lookup_by_index (ifindex, vrf_id);
   if (ifp == NULL)
     {
       zlog_warn ("INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d",
index a418ecabd3013f50e85704f621b190fecb182bb6..76419a7ff1e12094e7fcfcf04e0d49756cadf119 100644 (file)
@@ -75,7 +75,7 @@ static void netlink_neigh_msg(struct nlmsghdr *msg, struct zbuf *zb)
                }
        }
 
-       ifp = if_lookup_by_index(ndm->ndm_ifindex);
+       ifp = if_lookup_by_index(ndm->ndm_ifindex, VRF_DEFAULT);
        if (!ifp || sockunion_family(&addr) == AF_UNSPEC)
                return;
 
@@ -185,7 +185,7 @@ static void netlink_log_indication(struct nlmsghdr *msg, struct zbuf *zb)
        if (!pkthdr || !in_ndx || !zbuf_used(&pktpl))
                return;
 
-       ifp = if_lookup_by_index(htonl(*in_ndx));
+       ifp = if_lookup_by_index(htonl(*in_ndx), VRF_DEFAULT);
        if (!ifp)
                return;
 
index 4ac612d3adb5558b47b0876a7801531fbccd0b55..052b9c1e83464ec4a62ad8402cc33d995fb3fea8 100644 (file)
@@ -127,7 +127,7 @@ static void nhrp_interface_update_nbma(struct interface *ifp)
                        if (saddr.s_addr)
                                sockunion_set(&nbma, AF_INET, (u_char *) &saddr.s_addr, sizeof(saddr.s_addr));
                        else if (!nbmaifp && nifp->linkidx != IFINDEX_INTERNAL)
-                               nbmaifp = if_lookup_by_index(nifp->linkidx);
+                          nbmaifp = if_lookup_by_index(nifp->linkidx, VRF_DEFAULT);
                }
                break;
        default:
index 5d2866a67e36aed5402cf04f4729d21751a5b259..36dbdfd7772d1589dfa88884b22c3d1ed5b3b2e5 100644 (file)
@@ -290,7 +290,7 @@ static int nhrp_packet_recvraw(struct thread *t)
                goto err;
        }
 
-       ifp = if_lookup_by_index(ifindex);
+       ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
        if (!ifp) goto err;
 
        p = nhrp_peer_get(ifp, &remote_nbma);
index 8d066eeaefbb44d0bb5c721ff43fe793d0152222..69c55e305869de8c9577e257523ce48e20a12a15 100644 (file)
@@ -198,7 +198,7 @@ int nhrp_route_read(int cmd, struct zclient *zclient, zebra_size_t length, vrf_i
                for (i = 0; i < ifindex_num; i++) {
                        ifindex = stream_getl(s);
                        if (i == 0 && ifindex != IFINDEX_INTERNAL)
-                               ifp = if_lookup_by_index(ifindex);
+                          ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
                }
        }
        if (CHECK_FLAG(message, ZAPI_MESSAGE_DISTANCE))
index 8998799cf6c998154bbd34f35d2743e2846f0226..62c77e6f875312046181f67ed84219e818d66670 100644 (file)
@@ -69,7 +69,7 @@ ospf6_interface_lookup_by_ifindex (ifindex_t ifindex)
   struct ospf6_interface *oi;
   struct interface *ifp;
 
-  ifp = if_lookup_by_index (ifindex);
+  ifp = if_lookup_by_index (ifindex, VRF_DEFAULT);
   if (ifp == NULL)
     return (struct ospf6_interface *) NULL;
 
index a0cc367cd73c92eecfd9157428bc0c75e65031c9..d09e0f7d802d5598956df1000d48097c3b44a101 100644 (file)
@@ -35,6 +35,7 @@
 #include "sockopt.h"
 #include "checksum.h"
 #include "md5.h"
+#include "vrf.h"
 
 #include "ospfd/ospfd.h"
 #include "ospfd/ospf_network.h"
@@ -2218,7 +2219,7 @@ ospf_recv_packet (int fd, struct interface **ifp, struct stream *ibuf)
 
   ifindex = getsockopt_ifindex (AF_INET, &msgh);
   
-  *ifp = if_lookup_by_index (ifindex);
+  *ifp = if_lookup_by_index (ifindex, VRF_DEFAULT);
 
   if (ret != ip_len)
     {
index ce4bc9dfaa5e3ec4f1c7f46e80fc574e9dbec990..33fc0bf52538f4142695f8cf3a3d9ca0f7c78c55 100644 (file)
@@ -7948,7 +7948,7 @@ show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
         if (or->type == OSPF_DESTINATION_NETWORK)
           for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
             {
-              if (if_lookup_by_index(path->ifindex))
+              if (if_lookup_by_index(path->ifindex, VRF_DEFAULT))
                 {
                   if (path->nexthop.s_addr == 0)
                     vty_out (vty, "%24s   directly attached to %s%s",
@@ -7998,7 +7998,7 @@ show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
                   
                   for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
                     {
-                     if (if_lookup_by_index(path->ifindex))
+                     if (if_lookup_by_index(path->ifindex, VRF_DEFAULT))
                        {
                          if (path->nexthop.s_addr == 0)
                            vty_out (vty, "%24s   directly attached to %s%s",
@@ -8047,7 +8047,7 @@ show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
 
         for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
           {
-            if (if_lookup_by_index(path->ifindex))
+            if (if_lookup_by_index(path->ifindex, VRF_DEFAULT))
               {
                 if (path->nexthop.s_addr == 0)
                   vty_out (vty, "%24s   directly attached to %s%s",
index 94ee07a0e5fe031399a71bbf003ae74319d06645..def72c29f8963d65e24848eb8c0c7252ede9a293 100644 (file)
@@ -1028,7 +1028,7 @@ int pim_if_find_vifindex_by_ifindex(ifindex_t ifindex)
   struct pim_interface *pim_ifp;
   struct interface *ifp;
 
-  ifp = if_lookup_by_index_vrf (ifindex, VRF_DEFAULT);
+  ifp = if_lookup_by_index (ifindex, VRF_DEFAULT);
   if (!ifp || !ifp->info)
     return -1;
   pim_ifp = ifp->info;
index 471d8aa39e232fda505f993dbaf098448b8a40fe..f82687245d77364dec15ca7998e9bae202a3c02f 100644 (file)
@@ -331,7 +331,7 @@ static int pim_sock_read(struct thread *t)
        if (!inet_ntop(AF_INET, &to.sin_addr, to_str , sizeof(to_str)))
          sprintf(to_str, "<to?>");
 
-       recv_ifp = if_lookup_by_index(ifindex);
+       recv_ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
        if (recv_ifp) {
          zassert(ifindex == (int) recv_ifp->ifindex);
        }
index ff8a6054cf05b18719101ec0e8445a73dcb318bd..56e01dc0e707148b2c48d084e8686a0a61976745 100644 (file)
@@ -106,7 +106,7 @@ int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr, int nei
     {
       first_ifindex = nexthop_tab[i].ifindex;
 
-      ifp = if_lookup_by_index(first_ifindex);
+      ifp = if_lookup_by_index(first_ifindex, VRF_DEFAULT);
       if (!ifp)
         {
           if (PIM_DEBUG_ZEBRA)
index 035408333218e9c0383dcde21c5823b9c00f1f6e..76b327ab071210a9714107581400af0867a8adfc 100644 (file)
@@ -24,6 +24,7 @@
 #include "log.h"
 #include "memory.h"
 #include "sockopt.h"
+#include "vrf.h"
 
 #include "pimd.h"
 #include "pim_ssmpingd.h"
@@ -259,7 +260,7 @@ static int ssmpingd_read_msg(struct ssmpingd_sock *ss)
     return -1;
   }
 
-  ifp = if_lookup_by_index(ifindex);
+  ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
 
   if (buf[0] != PIM_SSMPINGD_REQUEST) {
     char source_str[INET_ADDRSTRLEN];
index 7ec31c7d50a16d738c88fe3b0b1cfdba1d2e056b..f77990ab5ab81faa3b7e05ec34f850ce65e330aa 100644 (file)
@@ -253,7 +253,7 @@ static int zclient_read_nexthop(struct zclient *zlookup,
       nexthop_tab[num_ifindex].nexthop_addr.family = AF_INET6;
       stream_get (&nexthop_tab[num_ifindex].nexthop_addr.u.prefix6, s, 16);
       nexthop_tab[num_ifindex].ifindex = stream_getl (s);
-      nbr = pim_neighbor_find_if (if_lookup_by_index_vrf (nexthop_tab[num_ifindex].ifindex, VRF_DEFAULT));
+      nbr = pim_neighbor_find_if (if_lookup_by_index (nexthop_tab[num_ifindex].ifindex, VRF_DEFAULT));
       if (nbr)
         {
           nexthop_tab[num_ifindex].nexthop_addr.family = AF_INET;
index 108da21c115964ba26c90ea89db824ec16d9ded5..8e98f5b0ef8fb26850a31c1386e113726fd2a29e 100644 (file)
@@ -1348,7 +1348,7 @@ ripng_read (struct thread *thread)
     }
 
   packet = (struct ripng_packet *) STREAM_DATA (ripng->ibuf);
-  ifp = if_lookup_by_index (ifindex);
+  ifp = if_lookup_by_index (ifindex, VRF_DEFAULT);
 
   /* RIPng packet received. */
   if (IS_RIPNG_DEBUG_EVENT)
index 8326f0e396cd8d8f9dc2f629f3e32209d7689b68..c62d9926a251f989a2bc2f85a71847f275190d1f 100644 (file)
@@ -80,7 +80,7 @@ ifstat_update_sysctl (void)
       ifm = (struct if_msghdr *) buf;
       if (ifm->ifm_type == RTM_IFINFO)
        {
-         ifp = if_lookup_by_index (ifm->ifm_index);
+         ifp = if_lookup_by_index (ifm->ifm_index, VRF_DEFAULT);
          if (ifp)
            ifp->stats = ifm->ifm_data;
        }
index c9c32ce311d553d8c3ba058a0a27b9004df2c89d..4c58b6b35d26e28bef530138af7f9edbfc36030b 100644 (file)
@@ -238,7 +238,7 @@ int irdp_read_raw(struct thread *r)
  
   if (ret < 0) zlog_warn ("IRDP: RX Error length = %d", ret);
 
-  ifp = if_lookup_by_index(ifindex);
+  ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
   if(! ifp ) return ret;
 
   zi= ifp->info;
index 1bb85a31abdb9345362f6a2f1cb81b458b8adc27..20de52c11ab00edccc3922f7dd446c19546cc249 100644 (file)
@@ -324,7 +324,7 @@ ifan_read (struct if_announcemsghdr *ifan)
 {
   struct interface *ifp;
   
-  ifp = if_lookup_by_index (ifan->ifan_index);
+  ifp = if_lookup_by_index (ifan->ifan_index, VRF_DEFAULT);
   
   if (ifp)
     assert ( (ifp->ifindex == ifan->ifan_index) 
@@ -460,7 +460,7 @@ ifm_read (struct if_msghdr *ifm)
    * messages, such as up/down status changes on NetBSD, do not include a
    * sockaddr_dl).
    */
-  if ( (ifp = if_lookup_by_index (ifm->ifm_index)) != NULL )
+  if ( (ifp = if_lookup_by_index (ifm->ifm_index, VRF_DEFAULT)) != NULL )
     {
       /* we have an ifp, verify that the name matches as some systems,
        * eg Solaris, have a 1:many association of ifindex:ifname
@@ -723,7 +723,7 @@ ifam_read (struct ifa_msghdr *ifam)
   /* Allocate and read address information. */
   ifam_read_mesg (ifam, &addr, &mask, &brd, ifname, &ifnlen);
   
-  if ((ifp = if_lookup_by_index(ifam->ifam_index)) == NULL)
+  if ((ifp = if_lookup_by_index(ifam->ifam_index, VRF_DEFAULT)) == NULL)
     {
       zlog_warn ("%s: no interface for ifname %s, index %d", 
                  __func__, ifname, ifam->ifam_index);
@@ -1099,7 +1099,7 @@ rtm_write (int message,
       msg.rtm.rtm_inits |= RTV_HOPCOUNT;
     }
 
-  ifp = if_lookup_by_index (index);
+  ifp = if_lookup_by_index (index, VRF_DEFAULT);
 
   if (gate && (message == RTM_ADD || message == RTM_CHANGE))
     msg.rtm.rtm_flags |= RTF_GATEWAY;
index 6ac13144962dac11ab0ec4ec78e3198858fd6c20..a544593dd65afad9edf4bcd59477d37df560a6a2 100644 (file)
@@ -465,13 +465,13 @@ netlink_route_change_read_multicast (struct sockaddr_nl *snl, struct nlmsghdr *h
       strcpy (gbuf, inet_ntoa (m->sg.grp));
       for (count = 0; count < oif_count; count++)
        {
-         ifp = if_lookup_by_index_vrf (oif[count], vrf);
+         ifp = if_lookup_by_index (oif[count], vrf);
          char temp[256];
 
          sprintf (temp, "%s ", ifp->name);
          strcat (oif_list, temp);
        }
-      ifp = if_lookup_by_index_vrf (iif, vrf);
+      ifp = if_lookup_by_index (iif, vrf);
       zlog_debug ("MCAST %s (%s,%s) IIF: %s OIF: %s jiffies: %lld",
                  nl_msg_type_to_str(h->nlmsg_type), sbuf, gbuf, ifp->name, oif_list, m->lastused);
     }
index 56a6ca7afa0bcf8904473bec1c02622d6e2f01d8..55a2745b532268eecbf5fe649fb8ab4760196d9a 100644 (file)
@@ -291,7 +291,7 @@ nhlfe_nexthop_active (zebra_nhlfe_t *nhlfe)
       case NEXTHOP_TYPE_IPV6_IFINDEX:
         if (IN6_IS_ADDR_LINKLOCAL (&nexthop->gate.ipv6))
           {
-            ifp = if_lookup_by_index (nexthop->ifindex);
+            ifp = if_lookup_by_index (nexthop->ifindex, VRF_DEFAULT);
             if (ifp && if_is_operative(ifp))
               SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
             else
index f9734fdf7d12ad5f5800c81b079c91917d0169fb..76c32c39718b0c0a8f8821780314466d8e19bae4 100644 (file)
@@ -272,7 +272,7 @@ rib_nexthop_ipv4_ifindex_add (struct rib *rib, struct in_addr *ipv4,
   if (src)
     nexthop->src.ipv4 = *src;
   nexthop->ifindex = ifindex;
-  ifp = if_lookup_by_index (nexthop->ifindex);
+  ifp = if_lookup_by_index (nexthop->ifindex, VRF_DEFAULT);
   /*Pending: need to think if null ifp here is ok during bootup?
     There was a crash because ifp here was coming to be NULL */
   if (ifp)
@@ -388,7 +388,7 @@ nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set,
    */
   if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK))
     {
-      ifp = if_lookup_by_index (nexthop->ifindex);
+      ifp = if_lookup_by_index (nexthop->ifindex, VRF_DEFAULT);
       if (ifp && connected_is_unnumbered(ifp))
        {
          if (if_is_operative(ifp))
@@ -938,7 +938,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib,
   switch (nexthop->type)
     {
     case NEXTHOP_TYPE_IFINDEX:
-      ifp = if_lookup_by_index_vrf (nexthop->ifindex, rib->vrf_id);
+      ifp = if_lookup_by_index (nexthop->ifindex, rib->vrf_id);
       if (ifp && if_is_operative(ifp))
        SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
       else
@@ -965,7 +965,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib,
        family = AFI_IP6;
       if (IN6_IS_ADDR_LINKLOCAL (&nexthop->gate.ipv6))
        {
-         ifp = if_lookup_by_index_vrf (nexthop->ifindex, rib->vrf_id);
+         ifp = if_lookup_by_index (nexthop->ifindex, rib->vrf_id);
          if (ifp && if_is_operative(ifp))
            SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
          else