summaryrefslogtreecommitdiff
path: root/zebra/if_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/if_netlink.c')
-rw-r--r--zebra/if_netlink.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index 15645d024d..1c6c70ae84 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -423,8 +423,7 @@ static uint32_t get_iflink_speed(struct interface *interface, int *error)
/* use ioctl to get IP address of an interface */
frr_with_privs(&zserv_privs) {
sd = vrf_socket(PF_INET, SOCK_DGRAM, IPPROTO_IP,
- interface->vrf_id,
- NULL);
+ interface->vrf->vrf_id, NULL);
if (sd < 0) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("Failure to read interface %s speed: %d %s",
@@ -435,7 +434,7 @@ static uint32_t get_iflink_speed(struct interface *interface, int *error)
return 0;
}
/* Get the current link state for the interface */
- rc = vrf_ioctl(interface->vrf_id, sd, SIOCETHTOOL,
+ rc = vrf_ioctl(interface->vrf->vrf_id, sd, SIOCETHTOOL,
(char *)&ifdata);
}
if (rc < 0) {
@@ -972,17 +971,9 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
link_nsid = ns_id_get_absolute(ns_id, link_nsid);
}
- /* Add interface.
- * We add by index first because in some cases such as the master
- * interface, we have the index before we have the name. Fixing
- * back references on the slave interfaces is painful if not done
- * this way, i.e. by creating by ifindex.
- */
- ifp = if_get_by_ifindex(ifi->ifi_index, vrf_id);
+ ifp = if_get_by_name(name, vrf_id, NULL);
set_ifindex(ifp, ifi->ifi_index, zns); /* add it to ns struct */
- if_set_name(ifp, name);
-
ifp->flags = ifi->ifi_flags & 0x0000fffff;
ifp->mtu6 = ifp->mtu = *(uint32_t *)RTA_DATA(tb[IFLA_MTU]);
ifp->metric = 0;
@@ -1292,11 +1283,22 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ifp = if_lookup_by_index_per_ns(zns, ifa->ifa_index);
if (ifp == NULL) {
- flog_err(
- EC_LIB_INTERFACE,
- "netlink_interface_addr can't find interface by index %d",
- ifa->ifa_index);
- return -1;
+ if (startup) {
+ /* During startup, failure to lookup the referenced
+ * interface should not be an error, so we have
+ * downgraded this condition to warning, and we permit
+ * the startup interface state retrieval to continue.
+ */
+ flog_warn(EC_LIB_INTERFACE,
+ "%s: can't find interface by index %d",
+ __func__, ifa->ifa_index);
+ return 0;
+ } else {
+ flog_err(EC_LIB_INTERFACE,
+ "%s: can't find interface by index %d",
+ __func__, ifa->ifa_index);
+ return -1;
+ }
}
/* Flags passed through */
@@ -1803,10 +1805,10 @@ 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_id, NULL);
} else {
/* pre-configured interface, learnt now */
- if (ifp->vrf_id != vrf_id)
+ if (ifp->vrf->vrf_id != vrf_id)
if_update_to_new_vrf(ifp, vrf_id);
}
@@ -1832,6 +1834,8 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
/* Update link. */
zebra_if_update_link(ifp, link_ifindex, ns_id);
+ ifp->ll_type =
+ netlink_to_zebra_link_type(ifi->ifi_type);
netlink_interface_update_hw_addr(tb, ifp);
/* Inform clients, install any configured addresses. */
@@ -1858,13 +1862,13 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
netlink_proc_dplane_if_protodown(ifp->info,
!!protodown);
}
- } else if (ifp->vrf_id != vrf_id) {
+ } else if (ifp->vrf->vrf_id != vrf_id) {
/* VRF change for an interface. */
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"RTM_NEWLINK vrf-change for %s(%u) vrf_id %u -> %u flags 0x%x",
- name, ifp->ifindex, ifp->vrf_id, vrf_id,
- ifi->ifi_flags);
+ name, ifp->ifindex, ifp->vrf->vrf_id,
+ vrf_id, ifi->ifi_flags);
if_handle_vrf_change(ifp, vrf_id);
} else {
@@ -1899,6 +1903,8 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
/* Update link. */
zebra_if_update_link(ifp, link_ifindex, ns_id);
+ ifp->ll_type =
+ netlink_to_zebra_link_type(ifi->ifi_type);
netlink_interface_update_hw_addr(tb, ifp);
if (if_is_no_ptm_operative(ifp)) {