import pytest
import pyroute2
import struct
+import socket
+import fcntl
import time
from .namespaces import Namespace
idx = ipr.link_lookup(ifname=name)[0]
ipr.link('del', index=idx)
- def nomaster(self, name):
+ def unbridge(self, bridgename, name):
ipr = pyroute2.IPRoute()
idx = ipr.link_lookup(ifname=name)[0]
- ipr.link('set', index=idx, master=0)
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
+ ifr = struct.pack("16si", b"br42", idx)
+ fcntl.ioctl(s,
+ 0x89a3, # SIOCBRDELIF
+ ifr)
+ s.close()
@pytest.fixture
with namespaces(1):
out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
assert out['lldp.eth0.port.descr'] == 'eth1'
- # Remove from bridge
- links.nomaster('eth0')
+ # Remove from bridge. We don't use netlink because we wouldn't
+ # get the wanted effect: we also get a RTM_NEWLINK by doing
+ # that. Only the bridge ioctl() would prevent that.
+ links.unbridge('br42', 'eth0')
time.sleep(1)
# Check if we still have eth0
out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")