From: Hans Dedecker Date: Thu, 13 Nov 2014 15:57:57 +0000 (+0000) Subject: netifd: Remove superfluous system_if_resolve calls X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=commitdiff_plain;h=b3a698e7b6c099203dcb4227a21813948b176e3b netifd: Remove superfluous system_if_resolve calls 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 --- 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;