]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: fallback to ioctl(SIOCBRDELBR) if netlink RTM_DELLINK fails
authorLaine Stump <laine@laine.org>
Wed, 26 Aug 2015 03:19:03 +0000 (23:19 -0400)
committerLaine Stump <laine@laine.org>
Fri, 28 Aug 2015 20:39:30 +0000 (16:39 -0400)
commit97d26e470d5be2f1178cedfea212c5983afd7b30
treede8cd4ade29b6429c8243556fe17e0a04b3fbb12
parent66dcb4093750aabd637607a1202cb9b9c15f1298
util: fallback to ioctl(SIOCBRDELBR) if netlink RTM_DELLINK fails

commit 09778e09 switched from using ioctl(SIOCBRDELBR) for bridge
device deletion to using a netlink RTM_DELLINK message, which is the
more modern way to delete a bridge (and also doesn't require the
bridge to be ~IFF_UP to succeed). However, although older kernels
(e.g. 2.6.32, in RHEL6/CentOS6) support deleting *some* link types
with RTM_NEWLINK, they don't support deleting bridges, and there is no
compile-time way to figure this out.

This patch moves the body of the SIOCBRDELBR version of
virNetDevBridgeDelete() into a static function, calls the new function
from the original, and also calls the new function from the
RTM_DELLINK version if the RTM_DELLINK message generates an EOPNOTSUPP
error. Since RTM_DELLINK is done from the subordinate function
virNetlinkDelLink, which is also called for other purposes (deleting a
macvtap interface), a function pointer called "fallback" has been
added to the arglist of virNetlinkDelLink() - if that arg != NULL, the
provided function will be called when (and only when) RTM_DELLINK
fails with EOPNOTSUPP.

Resolves:  https://bugzilla.redhat.com/show_bug.cgi?id=1252780 (part 2)
src/util/virnetdevbridge.c
src/util/virnetdevmacvlan.c
src/util/virnetlink.c
src/util/virnetlink.h