]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Refactor if_get_by_name_len to be VRF aware
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 11 Mar 2017 12:34:21 +0000 (07:34 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 15 Mar 2017 14:41:07 +0000 (10:41 -0400)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/if.c
lib/if.h
lib/zclient.c
zebra/if_ioctl.c
zebra/if_ioctl_solaris.c
zebra/kernel_socket.c

index 3deec8025ba8884fcfccfb63ff1069eb090dc773..2e929ac75581d70b0cf472432fc6eb20121b4bd9 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -436,7 +436,7 @@ if_get_by_name (const char *name, vrf_id_t vrf_id)
 }
 
 struct interface *
-if_get_by_name_len_vrf (const char *name, size_t namelen, vrf_id_t vrf_id, int vty)
+if_get_by_name_len (const char *name, size_t namelen, vrf_id_t vrf_id, int vty)
 {
   struct interface *ifp;
   struct vrf *vrf;
@@ -476,12 +476,6 @@ if_get_by_name_len_vrf (const char *name, size_t namelen, vrf_id_t vrf_id, int v
   return (if_create (name, namelen, vrf_id));
 }
 
-struct interface *
-if_get_by_name_len (const char *name, size_t namelen)
-{
-  return if_get_by_name_len_vrf (name, namelen, VRF_DEFAULT, 0);
-}
-
 /* Does interface up ? */
 int
 if_is_up (struct interface *ifp)
@@ -690,9 +684,9 @@ if_sunwzebra_get (const char *name, size_t nlen, vrf_id_t vrf_id)
   
   /* Wont catch seperator as last char, e.g. 'foo0:' but thats invalid */
   if (seppos < nlen)
-    return if_get_by_name_len_vrf (name, seppos, vrf_id, 1);
+    return if_get_by_name_len (name, seppos, vrf_id, 1);
   else
-    return if_get_by_name_len_vrf (name, nlen, vrf_id, 1);
+    return if_get_by_name_len (name, nlen, vrf_id, 1);
 }
 #endif /* SUNOS_5 */
 
@@ -728,7 +722,7 @@ DEFUN (interface,
 #ifdef SUNOS_5
   ifp = if_sunwzebra_get (ifname, sl, vrf_id);
 #else
-  ifp = if_get_by_name_len_vrf (ifname, sl, vrf_id, 1);
+  ifp = if_get_by_name_len (ifname, sl, vrf_id, 1);
 #endif /* SUNOS_5 */
 
   if (!ifp)
index aeb3d340eef4e6145775206a2763bf669f71e197..f8e89d2cfbbd7459648d11c64da73c6b7e96a00c 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -413,11 +413,9 @@ extern struct interface *if_get_by_name (const char *ifname,
 /* For these 2 functions, the namelen argument should be the precise length
    of the ifname string (not counting any optional trailing '\0' character).
    In most cases, strnlen should be used to calculate the namelen value. */
-extern struct interface *if_get_by_name_len(const char *ifname,size_t namelen);
-
 extern struct interface *if_lookup_by_name_len(const char *ifname,
                                                size_t namelen, vrf_id_t vrf_id);
-extern struct interface *if_get_by_name_len_vrf(const char *ifname,
+extern struct interface *if_get_by_name_len(const char *ifname,
                                size_t namelen, vrf_id_t vrf_id, int vty);
 
 
index 2a4816625e0f8da6002ae35e188ea15df5898e79..620cd6bc4e61704c9392c1138b8df855e6eead68 100644 (file)
@@ -1066,9 +1066,9 @@ zebra_interface_add_read (struct stream *s, vrf_id_t vrf_id)
   stream_get (ifname_tmp, s, INTERFACE_NAMSIZ);
 
   /* Lookup/create interface by name. */
-  ifp = if_get_by_name_len_vrf (ifname_tmp,
-                                strnlen (ifname_tmp, INTERFACE_NAMSIZ),
-                                vrf_id, 0);
+  ifp = if_get_by_name_len (ifname_tmp,
+                            strnlen (ifname_tmp, INTERFACE_NAMSIZ),
+                            vrf_id, 0);
 
   zebra_interface_if_set_value (s, ifp);
 
index 2393e0f9c5f5f3ccd6712f74271375b19816920e..5333f0331ed064403d64455caaaf9e7cb8da5d0a 100644 (file)
@@ -110,7 +110,8 @@ interface_list_ioctl (void)
       ifreq = (struct ifreq *)((caddr_t) ifconf.ifc_req + n);
       ifp = if_get_by_name_len(ifreq->ifr_name,
                               strnlen(ifreq->ifr_name,
-                                      sizeof(ifreq->ifr_name)));
+                                      sizeof(ifreq->ifr_name)),
+                               VRF_DEFAULT, 0);
       if_add_update (ifp);
       size = ifreq->ifr_addr.sa_len;
       if (size < sizeof (ifreq->ifr_addr))
@@ -123,7 +124,8 @@ interface_list_ioctl (void)
     {
       ifp = if_get_by_name_len(ifreq->ifr_name,
                               strnlen(ifreq->ifr_name,
-                                      sizeof(ifreq->ifr_name)));
+                                      sizeof(ifreq->ifr_name)),
+                               VRF_DEFAULT, 0);
       if_add_update (ifp);
       ifreq++;
     }
index 339e00b22cc21d89ab3b2d07c1c90b32665d6897..dbc4109913819c7f23492152635498a2d1f0cb8f 100644 (file)
@@ -170,7 +170,7 @@ calculate_lifc_len:     /* must hold privileges to enter here */
              && ( *(lifreq->lifr_name + normallen) != ':') )
         normallen++;
       
-      ifp = if_get_by_name_len(lifreq->lifr_name, normallen);
+      ifp = if_get_by_name_len(lifreq->lifr_name, normallen, VRF_DEFAULT, 0);
 
       if (lifreq->lifr_addr.ss_family == AF_INET)
         ifp->flags |= IFF_IPV4;
index fee7bce1cd2b0fcda6f390927665b59de910134f..7212ed6f26b60895e12ba124a4020917c6d90a3a 100644 (file)
@@ -341,7 +341,8 @@ ifan_read (struct if_announcemsghdr *ifan)
       /* Create Interface */
       ifp = if_get_by_name_len(ifan->ifan_name,
                               strnlen(ifan->ifan_name,
-                                      sizeof(ifan->ifan_name)));
+                                      sizeof(ifan->ifan_name)),
+                               VRF_DEFAULT, 0);
       ifp->ifindex = ifan->ifan_index;
 
       if_get_metric (ifp);