diff options
| author | Stephen Worley <sworley@cumulusnetworks.com> | 2019-10-09 19:50:13 -0400 | 
|---|---|---|
| committer | Stephen Worley <sworley@cumulusnetworks.com> | 2019-10-09 20:24:31 -0400 | 
| commit | d5c65bf1a2b43d97e19e169223d8a33269bc6625 (patch) | |
| tree | 543831bbc4aa6e90c786cffe7c5639732002590b /zebra | |
| parent | 9685b1e414118391825ad56faa8879d279eebeb6 (diff) | |
*: Cleanup interface creation apis
Cleanup the interface creation apis to make it more
clear what they are doing.
Make it explicit that the creation via name/ifindex will
only add it to the appropriate list.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'zebra')
| -rw-r--r-- | zebra/if_netlink.c | 7 | ||||
| -rw-r--r-- | zebra/kernel_socket.c | 2 | 
2 files changed, 4 insertions, 5 deletions
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 35cb3a6f5f..4e9b093610 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -606,7 +606,6 @@ 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 = NULL;  	zns = zebra_ns_lookup(ns_id);  	ifi = NLMSG_DATA(h); @@ -690,7 +689,6 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)  	if (tb[IFLA_LINK])  		link_ifindex = *(ifindex_t *)RTA_DATA(tb[IFLA_LINK]); -	vrf = vrf_get(vrf_id, NULL);  	/* 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 @@ -699,8 +697,9 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)  	 */  	ifp = if_get_by_ifindex(ifi->ifi_index, vrf_id);  	set_ifindex(ifp, ifi->ifi_index, zns); /* add it to ns struct */ -	strlcpy(ifp->name, name, sizeof(ifp->name)); -	IFNAME_RB_INSERT(vrf, ifp); + +	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; diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 60fbbcc059..f5aca2341d 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -643,7 +643,7 @@ int ifm_read(struct if_msghdr *ifm)  		if (ifp == NULL) {  			/* Interface that zebra was not previously aware of, so  			 * create. */ -			ifp = if_create(ifname, VRF_DEFAULT); +			ifp = if_create_name(ifname, VRF_DEFAULT);  			if (IS_ZEBRA_DEBUG_KERNEL)  				zlog_debug("%s: creating ifp for ifindex %d",  					   __func__, ifm->ifm_index);  | 
