summaryrefslogtreecommitdiffhomepage
path: root/system-linux.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2014-06-18 07:41:14 +0000
committerSteven Barth <steven@midlink.org>2014-06-18 13:01:20 +0200
commit55b39e8c0a650146ebb416d0656b271e409eff2b (patch)
tree5aac5b2b926e0c01b6cfcc82d1270504dec11014 /system-linux.c
parent24388f1ff259ba4eb69a6ce45e3c64b98f041c6b (diff)
netifd: Fix macvlan delete via netlink
Fix macvlan delete via netlink as netlink attribute IFLA_IFNAME data size was incorrect (size reject by the kernel) and NLM_F_REQUEST flag was missing. In addition some minor improvements (attribute IFLA_INFO_KIND can be left out as RTM_DELLINK does not require the attribute) Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/system-linux.c b/system-linux.c
index ea71f65..4d0f4c9 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -691,7 +691,7 @@ 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_INET };
+ struct ifinfomsg iim = { .ifi_family = AF_UNSPEC, };
int ifindex = system_if_resolve(dev);
int i, rv;
static const struct {
@@ -716,13 +716,13 @@ 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(msg, IFLA_IFNAME, IFNAMSIZ, macvlan->ifname);
+ nla_put_string(msg, IFLA_IFNAME, macvlan->ifname);
nla_put_u32(msg, IFLA_LINK, ifindex);
if (!(linkinfo = nla_nest_start(msg, IFLA_LINKINFO)))
goto nla_put_failure;
- nla_put(msg, IFLA_INFO_KIND, strlen("macvlan"), "macvlan");
+ nla_put_string(msg, IFLA_INFO_KIND, "macvlan");
if (!(data = nla_nest_start(msg, IFLA_INFO_DATA)))
goto nla_put_failure;
@@ -754,20 +754,19 @@ nla_put_failure:
int system_macvlan_del(struct device *macvlan)
{
struct nl_msg *msg;
- struct ifinfomsg iim;
-
- iim.ifi_family = AF_INET;
- iim.ifi_index = 0;
+ struct ifinfomsg iim = {
+ .ifi_family = AF_UNSPEC,
+ .ifi_index = 0,
+ };
- msg = nlmsg_alloc_simple(RTM_DELLINK, 0);
+ msg = nlmsg_alloc_simple(RTM_DELLINK, NLM_F_REQUEST);
if (!msg)
return -1;
nlmsg_append(msg, &iim, sizeof(iim), 0);
- nla_put(msg, IFLA_INFO_KIND, strlen("macvlan"), "macvlan");
- nla_put(msg, IFLA_IFNAME, sizeof(macvlan->ifname), macvlan->ifname);
+ nla_put_string(msg, IFLA_IFNAME, macvlan->ifname);
system_rtnl_call(msg);