diff options
-rw-r--r-- | lib/if.c | 22 | ||||
-rw-r--r-- | lib/if.h | 4 | ||||
-rw-r--r-- | lib/zclient.c | 3 | ||||
-rw-r--r-- | ospf6d/ospf6_top.c | 3 | ||||
-rw-r--r-- | ospfd/ospf_vty.c | 6 | ||||
-rw-r--r-- | zebra/if_ioctl.c | 5 | ||||
-rw-r--r-- | zebra/if_ioctl_solaris.c | 3 | ||||
-rw-r--r-- | zebra/if_netlink.c | 11 | ||||
-rw-r--r-- | zebra/kernel_socket.c | 3 |
9 files changed, 38 insertions, 22 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); diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 40c612381..5cd657259 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -654,9 +654,10 @@ DEFUN (ospf6_interface_area, struct ospf6_interface *oi; struct interface *ifp; uint32_t area_id; + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); /* find/create ospf6 interface */ - ifp = if_get_by_name(argv[idx_ifname]->arg, VRF_DEFAULT); + ifp = if_get_by_name(argv[idx_ifname]->arg, vrf); oi = (struct ospf6_interface *)ifp->info; if (oi == NULL) oi = ospf6_interface_create(ifp); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 631465fb2..a2444c9ea 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -457,13 +457,14 @@ DEFUN (ospf_passive_interface, int ret; struct ospf_if_params *params; struct route_node *rn; + struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); if (strmatch(argv[1]->text, "default")) { ospf_passive_interface_default(ospf, OSPF_IF_PASSIVE); return CMD_SUCCESS; } if (ospf->vrf_id != VRF_UNKNOWN) - ifp = if_get_by_name(argv[1]->arg, ospf->vrf_id); + ifp = if_get_by_name(argv[1]->arg, vrf); if (ifp == NULL) { vty_out(vty, "interface %s not found.\n", (char *)argv[1]->arg); @@ -529,6 +530,7 @@ DEFUN (no_ospf_passive_interface, struct ospf_if_params *params; int ret; struct route_node *rn; + struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); if (strmatch(argv[2]->text, "default")) { ospf_passive_interface_default(ospf, OSPF_IF_ACTIVE); @@ -536,7 +538,7 @@ DEFUN (no_ospf_passive_interface, } if (ospf->vrf_id != VRF_UNKNOWN) - ifp = if_get_by_name(argv[2]->arg, ospf->vrf_id); + ifp = if_get_by_name(argv[2]->arg, vrf); if (ifp == NULL) { vty_out(vty, "interface %s not found.\n", (char *)argv[2]->arg); diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index 8bec25635..6f664601e 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -54,6 +54,7 @@ static int interface_list_ioctl(void) struct interface *ifp; int n; int lastlen; + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); /* Normally SIOCGIFCONF works with AF_INET socket. */ sock = socket(AF_INET, SOCK_DGRAM, 0); @@ -110,7 +111,7 @@ static int interface_list_ioctl(void) unsigned int size; ifreq = (struct ifreq *)((caddr_t)ifconf.ifc_req + n); - ifp = if_get_by_name(ifreq->ifr_name, VRF_DEFAULT); + ifp = if_get_by_name(ifreq->ifr_name, vrf); if_add_update(ifp); size = ifreq->ifr_addr.sa_len; if (size < sizeof(ifreq->ifr_addr)) @@ -120,7 +121,7 @@ static int interface_list_ioctl(void) } #else for (n = 0; n < ifconf.ifc_len; n += sizeof(struct ifreq)) { - ifp = if_get_by_name(ifreq->ifr_name, VRF_DEFAULT); + ifp = if_get_by_name(ifreq->ifr_name, vrf); if_add_update(ifp); ifreq++; } diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c index 8b539a904..1ed75bfa5 100644 --- a/zebra/if_ioctl_solaris.c +++ b/zebra/if_ioctl_solaris.c @@ -59,6 +59,7 @@ static int interface_list_ioctl(int af) int n; size_t needed, lastneeded = 0; char *buf = NULL; + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); frr_elevate_privs(&zserv_privs) { sock = socket(af, SOCK_DGRAM, 0); @@ -156,7 +157,7 @@ calculate_lifc_len: && (*(lifreq->lifr_name + normallen) != ':')) normallen++; - ifp = if_get_by_name(lifreq->lifr_name, VRF_DEFAULT); + ifp = if_get_by_name(lifreq->lifr_name, vrf); if (lifreq->lifr_addr.ss_family == AF_INET) ifp->flags |= IFF_IPV4; diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index df8d4bfe1..4b998bcdc 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -598,6 +598,7 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup) ifindex_t link_ifindex = IFINDEX_INTERNAL; ifindex_t bond_ifindex = IFINDEX_INTERNAL; struct zebra_if *zif; + struct vrf *vrf; zns = zebra_ns_lookup(ns_id); ifi = NLMSG_DATA(h); @@ -677,12 +678,14 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup) if (vrf_is_backend_netns()) vrf_id = (vrf_id_t)ns_id; + vrf = vrf_lookup_by_id(vrf_id); + /* If linking to another interface, note it. */ if (tb[IFLA_LINK]) link_ifindex = *(ifindex_t *)RTA_DATA(tb[IFLA_LINK]); /* Add interface. */ - ifp = if_get_by_name(name, vrf_id); + ifp = if_get_by_name(name, vrf); set_ifindex(ifp, ifi->ifi_index, zns); ifp->flags = ifi->ifi_flags & 0x0000fffff; ifp->mtu6 = ifp->mtu = *(uint32_t *)RTA_DATA(tb[IFLA_MTU]); @@ -1109,6 +1112,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) ifindex_t link_ifindex = IFINDEX_INTERNAL; uint8_t old_hw_addr[INTERFACE_HWADDR_MAX]; struct zebra_if *zif; + struct vrf *vrf; zns = zebra_ns_lookup(ns_id); ifi = NLMSG_DATA(h); @@ -1209,6 +1213,9 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) } if (vrf_is_backend_netns()) vrf_id = (vrf_id_t)ns_id; + + vrf = vrf_lookup_by_id(vrf_id); + if (ifp == NULL || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) { /* Add interface notification from kernel */ @@ -1222,7 +1229,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) if (ifp == NULL) { /* unknown interface */ - ifp = if_get_by_name(name, vrf_id); + ifp = if_get_by_name(name, vrf); } else { /* pre-configured interface, learnt now */ if (ifp->vrf_id != vrf_id) diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 156ce5072..9e1593a12 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -435,6 +435,7 @@ static void rtm_flag_dump(int flag) static int ifan_read(struct if_announcemsghdr *ifan) { struct interface *ifp; + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); ifp = if_lookup_by_index(ifan->ifan_index, VRF_DEFAULT); @@ -450,7 +451,7 @@ static int ifan_read(struct if_announcemsghdr *ifan) __func__, ifan->ifan_index, ifan->ifan_name); /* Create Interface */ - ifp = if_get_by_name(ifan->ifan_name, VRF_DEFAULT); + ifp = if_get_by_name(ifan->ifan_name, vrf); if_set_index(ifp, ifan->ifan_index); if_get_metric(ifp); |