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 /zebra | |
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 'zebra')
-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 |
4 files changed, 16 insertions, 6 deletions
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); |