diff options
author | Felix Fietkau <nbd@nbd.name> | 2022-02-01 11:58:44 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2022-02-01 12:52:41 +0100 |
commit | 88af2f1bc6ace86c37f4fa66f852cfec9b604254 (patch) | |
tree | 16a56e66185adb8a0aa0ba8d9d30d5c267ee6ba9 | |
parent | 85c3548069a751f0b854b5816db6ee7142aec07b (diff) | |
download | netifd-88af2f1bc6ace86c37f4fa66f852cfec9b604254.tar.gz |
system-linux: delete bridge devices using netlink
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r-- | system-linux.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/system-linux.c b/system-linux.c index a242f75..f4d9e73 100644 --- a/system-linux.c +++ b/system-linux.c @@ -755,9 +755,27 @@ static int system_rtnl_call(struct nl_msg *msg) return nl_wait_for_ack(sock_rtnl); } +static int system_link_del(const char *ifname) +{ + 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, ifname); + return system_rtnl_call(msg); +} + int system_bridge_delbr(struct device *bridge) { - return ioctl(sock_ioctl, SIOCBRDELBR, bridge->ifname); + return system_link_del(bridge->ifname); } static int system_bridge_if(const char *bridge, struct device *dev, int cmd, void *data) @@ -1419,24 +1437,6 @@ int system_link_netns_move(struct device *dev, int netns_fd, const char *target_ return system_rtnl_call(msg); } -static int system_link_del(const char *ifname) -{ - 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, ifname); - return system_rtnl_call(msg); -} - int system_macvlan_del(struct device *macvlan) { return system_link_del(macvlan->ifname); |