diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-02-11 14:49:12 +0100 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2019-06-11 17:10:47 +0200 |
commit | 4c634658a6aaf835eff892f7ac959aef9f0c59c8 (patch) | |
tree | 592d73567658aa3f75a52907ca2856debb0f9c8e /lib | |
parent | Merge pull request #4482 from opensourcerouting/warnings-20190606 (diff) | |
download | frr-4c634658a6aaf835eff892f7ac959aef9f0c59c8.tar.xz frr-4c634658a6aaf835eff892f7ac959aef9f0c59c8.zip |
ospf, ospf6d, zebra, lib: change if_get_by_name prototype with vrf
vrf pointer is used as reference when calling if_get_by_name() function.
this will permit to create interfaces with an unknown vrf_id, since it
is only necessary to get the vrf structure to store the interfaces.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/if.c | 22 | ||||
-rw-r--r-- | lib/if.h | 4 | ||||
-rw-r--r-- | lib/zclient.c | 3 |
3 files changed, 16 insertions, 13 deletions
@@ -419,29 +419,29 @@ size_t if_lookup_by_hwaddr(const uint8_t *hw_addr, size_t addrsz, /* Get interface by name if given name interface doesn't exist create one. */ -struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id) +struct interface *if_get_by_name(const char *name, struct vrf *vrf) { struct interface *ifp; switch (vrf_get_backend()) { case VRF_BACKEND_UNKNOWN: case VRF_BACKEND_NETNS: - ifp = if_lookup_by_name(name, vrf_id); + ifp = if_lookup_by_name(name, vrf->vrf_id); if (ifp) return ifp; - return if_create(name, vrf_id); + return if_create(name, vrf->vrf_id); case VRF_BACKEND_VRF_LITE: ifp = if_lookup_by_name_all_vrf(name); if (ifp) { - if (ifp->vrf_id == vrf_id) + if (ifp->vrf_id == vrf->vrf_id) return ifp; /* If it came from the kernel or by way of zclient, * believe it and update the ifp accordingly. */ - if_update_to_new_vrf(ifp, vrf_id); + if_update_to_new_vrf(ifp, vrf->vrf_id); return ifp; } - return if_create(name, vrf_id); + return if_create(name, vrf->vrf_id); } return NULL; @@ -631,12 +631,12 @@ void if_dump_all(void) * if not: * - no idea, just get the name in its entirety. */ -static struct interface *if_sunwzebra_get(const char *name, vrf_id_t vrf_id) +static struct interface *if_sunwzebra_get(const char *name, struct vrf *vrf) { struct interface *ifp; char *cp; - if ((ifp = if_lookup_by_name(name, vrf_id)) != NULL) + if ((ifp = if_lookup_by_name(name, vrf->vrf_id)) != NULL) return ifp; /* hunt the primary interface name... */ @@ -644,7 +644,7 @@ static struct interface *if_sunwzebra_get(const char *name, vrf_id_t vrf_id) if (cp) *cp = '\0'; - return if_get_by_name(name, vrf_id); + return if_get_by_name(name, vrf); } #endif /* SUNOS_5 */ @@ -1343,9 +1343,9 @@ static int lib_interface_create(enum nb_event event, vrf = vrf_lookup_by_name(vrfname); assert(vrf); #ifdef SUNOS_5 - ifp = if_sunwzebra_get(ifname, vrf->vrf_id); + ifp = if_sunwzebra_get(ifname, vrf); #else - ifp = if_get_by_name(ifname, vrf->vrf_id); + ifp = if_get_by_name(ifname, vrf); #endif /* SUNOS_5 */ nb_running_set_entry(dnode, ifp); break; @@ -34,6 +34,8 @@ extern "C" { DECLARE_MTYPE(IF) DECLARE_MTYPE(CONNECTED_LABEL) +struct vrf; + /* Interface link-layer type, if known. Derived from: * * net/if_arp.h on various platforms - Linux especially. @@ -493,7 +495,7 @@ size_t if_lookup_by_hwaddr(const uint8_t *hw_addr, size_t addrsz, by a '\0' character: */ extern struct interface *if_lookup_by_name_all_vrf(const char *ifname); extern struct interface *if_lookup_by_name(const char *ifname, vrf_id_t vrf_id); -extern struct interface *if_get_by_name(const char *ifname, vrf_id_t vrf_id); +extern struct interface *if_get_by_name(const char *ifname, struct vrf *vrf); extern void if_set_index(struct interface *ifp, ifindex_t ifindex); /* Delete the interface, but do not free the structure, and leave it in the diff --git a/lib/zclient.c b/lib/zclient.c index e9b4f5a58..c5d4e0daf 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1461,12 +1461,13 @@ struct interface *zebra_interface_add_read(struct stream *s, vrf_id_t vrf_id) { struct interface *ifp; char ifname_tmp[INTERFACE_NAMSIZ]; + struct vrf *vrf = vrf_lookup_by_id(vrf_id); /* Read interface name. */ stream_get(ifname_tmp, s, INTERFACE_NAMSIZ); /* Lookup/create interface by name. */ - ifp = if_get_by_name(ifname_tmp, vrf_id); + ifp = if_get_by_name(ifname_tmp, vrf); zebra_interface_if_set_value(s, ifp); |