]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
tests: fix previous testcase to fail without previous commit
authorVincent Bernat <vincent@bernat.im>
Fri, 15 Sep 2017 21:20:28 +0000 (23:20 +0200)
committerVincent Bernat <vincent@bernat.im>
Fri, 15 Sep 2017 21:20:28 +0000 (23:20 +0200)
Only the bridge ioctl can trigger this bug.

tests/integration/fixtures/network.py
tests/integration/test_interfaces.py

index 87d1610dc45dc41e368010045d037caf097902d8..aa2a85c392298cb244ae920e36b4fc5d1f76f546 100644 (file)
@@ -1,6 +1,8 @@
 import pytest
 import pyroute2
 import struct
+import socket
+import fcntl
 import time
 from .namespaces import Namespace
 
@@ -134,10 +136,15 @@ class LinksFactory(object):
         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
index 9788f6e8c4df1fba936b17113d2bfbffd25264e8..22cb0792c5a2c5f228739b7fabb8806163c70654 100644 (file)
@@ -27,8 +27,10 @@ def test_remove_bridge(lldpd, lldpcli, namespaces, links):
     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")