summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2014-06-18 13:28:39 +0200
committerSteven Barth <steven@midlink.org>2014-06-18 13:28:39 +0200
commit65cab45660dd0b234b663a39a133c64271f667b7 (patch)
tree3e2064d9cca615dc055a2cb767df8a952515b4ef
parentcd23fd6bf7983741b9a72bea78749278716248ec (diff)
downloadnetifd-65cab45660dd0b234b663a39a133c64271f667b7.tar.gz
linux: unify functions to delete links
Signed-off-by: Steven Barth <steven@midlink.org>
-rw-r--r--system-linux.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/system-linux.c b/system-linux.c
index af54bfd..8f612c9 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -791,7 +791,7 @@ nla_put_failure:
return -ENOMEM;
}
-int system_macvlan_del(struct device *macvlan)
+static int system_link_del(struct device *dev)
{
struct nl_msg *msg;
struct ifinfomsg iim = {
@@ -805,12 +805,13 @@ int system_macvlan_del(struct device *macvlan)
return -1;
nlmsg_append(msg, &iim, sizeof(iim), 0);
+ nla_put_string(msg, IFLA_IFNAME, dev->ifname);
+ return system_rtnl_call(msg);
+}
- nla_put_string(msg, IFLA_IFNAME, macvlan->ifname);
-
- system_rtnl_call(msg);
-
- return 0;
+int system_macvlan_del(struct device *macvlan)
+{
+ return system_link_del(macvlan);
}
static int system_vlan(struct device *dev, int id)
@@ -896,24 +897,7 @@ nla_put_failure:
int system_vlandev_del(struct device *vlandev)
{
- struct nl_msg *msg;
- struct ifinfomsg iim = {
- .ifi_family = AF_UNSPEC,
- .ifi_index = 0,
- };
-
- msg = nlmsg_alloc_simple(RTM_DELLINK, NLM_F_REQUEST);
-
- if (!msg)
- return -1;
-
- nlmsg_append(msg, &iim, sizeof(iim), 0);
-
- nla_put_string(msg, IFLA_IFNAME, vlandev->ifname);
-
- system_rtnl_call(msg);
-
- return 0;
+ return system_link_del(vlandev);
}
static void