summaryrefslogtreecommitdiff
path: root/system-linux.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2014-06-18 05:55:44 +0000
committerSteven Barth <steven@midlink.org>2014-06-18 13:01:14 +0200
commit24388f1ff259ba4eb69a6ce45e3c64b98f041c6b (patch)
tree15305892d3cf5603f62a685b8d4d3f9027a954e6 /system-linux.c
parent6e70adc5eca0dc1cc52a5838e86d937efdf8a38c (diff)
downloadnetifd-24388f1ff259ba4eb69a6ce45e3c64b98f041c6b.tar.gz
netifd: Fix vlan delete via netlink
Fix vlan delete via netlink as netlink attribute IFLA_IFNAME data size was incorrect. In addition some minor improvements. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/system-linux.c b/system-linux.c
index f4721cc..ea71f65 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -808,7 +808,7 @@ 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_INET };
+ struct ifinfomsg iim = { .ifi_family = AF_UNSPEC };
int ifindex = system_if_resolve(dev);
int rv;
@@ -821,14 +821,13 @@ int system_vlandev_add(struct device *vlandev, struct device *dev, struct vlande
return -1;
nlmsg_append(msg, &iim, sizeof(iim), 0);
- nla_put(msg, IFLA_IFNAME, IFNAMSIZ, vlandev->ifname);
+ nla_put_string(msg, IFLA_IFNAME, vlandev->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("vlan"), "vlan");
-
+ nla_put_string(msg, IFLA_INFO_KIND, "vlan");
if (!(data = nla_nest_start(msg, IFLA_INFO_DATA)))
goto nla_put_failure;
@@ -859,20 +858,19 @@ nla_put_failure:
int system_vlandev_del(struct device *vlandev)
{
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("vlan"), "vlan");
- nla_put(msg, IFLA_IFNAME, sizeof(vlandev->ifname), vlandev->ifname);
+ nla_put_string(msg, IFLA_IFNAME, vlandev->ifname);
system_rtnl_call(msg);