[OpenWrt-Devel] [PATCH 2/4] netifd: Remove superfluous system_if_resolve calls

Hans Dedecker dedeckeh at gmail.com
Thu Nov 13 08:35:48 EST 2014


Don't resolve the ifindex of the parent device again
when adding vlandev and macvlan devices as the ifindex
has already been resolved.

Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
---
 system-linux.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/system-linux.c b/system-linux.c
index 6a6028c..01c3deb 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -760,7 +760,6 @@ int system_macvlan_add(struct device *macvlan, struct device *dev, struct macvla
 	struct nl_msg *msg;
 	struct nlattr *linkinfo, *data;
 	struct ifinfomsg iim = { .ifi_family = AF_UNSPEC, };
-	int ifindex = system_if_resolve(dev);
 	int i, rv;
 	static const struct {
 		const char *name;
@@ -772,9 +771,6 @@ int system_macvlan_add(struct device *macvlan, struct device *dev, struct macvla
 		{ "passthru", MACVLAN_MODE_PASSTHRU },
 	};
 
-	if (ifindex == 0)
-		return -ENOENT;
-
 	msg = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
 
 	if (!msg)
@@ -785,7 +781,7 @@ int system_macvlan_add(struct device *macvlan, struct device *dev, struct macvla
 	if (cfg->flags & MACVLAN_OPT_MACADDR)
 		nla_put(msg, IFLA_ADDRESS, sizeof(cfg->macaddr), cfg->macaddr);
 	nla_put_string(msg, IFLA_IFNAME, macvlan->ifname);
-	nla_put_u32(msg, IFLA_LINK, ifindex);
+	nla_put_u32(msg, IFLA_LINK, dev->ifindex);
 
 	if (!(linkinfo = nla_nest_start(msg, IFLA_LINKINFO)))
 		goto nla_put_failure;
@@ -877,12 +873,8 @@ int system_vlandev_add(struct device *vlandev, struct device *dev, struct vlande
 	struct nl_msg *msg;
 	struct nlattr *linkinfo, *data;
 	struct ifinfomsg iim = { .ifi_family = AF_UNSPEC };
-	int ifindex = system_if_resolve(dev);
 	int rv;
 
-	if (ifindex == 0)
-		return -ENOENT;
-
 	msg = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
 
 	if (!msg)
@@ -890,7 +882,7 @@ int system_vlandev_add(struct device *vlandev, struct device *dev, struct vlande
 
 	nlmsg_append(msg, &iim, sizeof(iim), 0);
 	nla_put_string(msg, IFLA_IFNAME, vlandev->ifname);
-	nla_put_u32(msg, IFLA_LINK, ifindex);
+	nla_put_u32(msg, IFLA_LINK, dev->ifindex);
 	
 	if (!(linkinfo = nla_nest_start(msg, IFLA_LINKINFO)))
 		goto nla_put_failure;
-- 
1.7.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list