From: Donald Sharp Date: Sat, 11 Mar 2017 12:34:21 +0000 (-0500) Subject: lib: Refactor if_get_by_name_len to be VRF aware X-Git-Tag: frr-3.1-dev~31^2~6 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=07a112a1dc224df494490872894250fea12e8797;p=matthieu%2Ffrr.git lib: Refactor if_get_by_name_len to be VRF aware Signed-off-by: Donald Sharp --- diff --git a/lib/if.c b/lib/if.c index 3deec8025b..2e929ac755 100644 --- 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) diff --git a/lib/if.h b/lib/if.h index aeb3d340ee..f8e89d2cfb 100644 --- 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); diff --git a/lib/zclient.c b/lib/zclient.c index 2a4816625e..620cd6bc4e 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -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); diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index 2393e0f9c5..5333f0331e 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -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++; } diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c index 339e00b22c..dbc4109913 100644 --- a/zebra/if_ioctl_solaris.c +++ b/zebra/if_ioctl_solaris.c @@ -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; diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index fee7bce1cd..7212ed6f26 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -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);