Unable to move sublvan into new netns
Closed this issue · 2 comments
I am trying to create a VLAN sub-interface with an associated macvlan passthru interface to move into a new netns using pyroute2. I am able to successfully create both the vlan and sub-interface, but I am only able to move the VLAN interface into the new netns. Here is example code:
def createVLAN():
extra_create_params = {}
extra_create_params['macvlan_mode'] = 'passthru'
ipdb = IPDB()
parent_if = ipdb.create(ifname="eth1.3700",
kind='vlan',
link=ipdb.interfaces.get("eth1"),
vlan_protocol=0x8100,#0x88a8
vlan_id=3700
)
parent_if.up().commit()
child_if = ipdb.create(ifname="host_eth1.3700",
kind='macvlan',
link="eth1.3700",
**extra_create_params
)
nl=NetNS("test")
child_if.net_ns_fd = "test"
child_if.up().commit()
nl.release()
ipdb.release()
def createSubVLAN():
extra_create_params = {}
extra_create_params['macvlan_mode'] = 'passthru'
ipdb = IPDB()
parent_if = ipdb.create(ifname="eth1.3700.8",
kind='vlan',
link=ipdb.interfaces.get("eth1.3700"),
vlan_protocol=0x8100,
vlan_id=8
)
parent_if.up().commit()
child_if = ipdb.create(ifname="host_eth1.3700.8",
kind='macvlan',
link="eth1.3700.8",
**extra_create_params
)
child_if.net_ns_fd = "test"
child_if.up().commit()
if __name__ == "__main__":
createVLAN()
createSubVLAN()
The results of the script are:
Traceback (most recent call last):
File "./test.py", line 108, in <module>
createSubVLAN()
File "./test.py", line 103, in createSubVLAN
child_if.up().commit()
File "/usr/local/lib/python2.7/dist-packages/pyroute2/ipdb/interfaces.py", line 572, in commit
self.nl.link('add', **request)
File "/usr/local/lib/python2.7/dist-packages/pyroute2/iproute.py", line 1310, in link
msg_flags=msg_flags)
File "/usr/local/lib/python2.7/dist-packages/pyroute2/netlink/nlsocket.py", line 804, in nlm_request
return do_try()
File "/usr/local/lib/python2.7/dist-packages/pyroute2/netlink/nlsocket.py", line 783, in do_try
callback=callback)
File "/usr/local/lib/python2.7/dist-packages/pyroute2/netlink/nlsocket.py", line 648, in get
raise msg['header']['error']
pyroute2.netlink.exceptions.NetlinkError: (34, 'Numerical result out of range')
Am I missing something when moving the VLAN sub-interface into the new netns that is different from the VLAN interface?
I tried with 0x8100 and 0x88a8 as the VLAN protocol and double checked the creation of the sub-interface from issue #361
Hey,
You're seeing this error because the interface's name is too long; it's 16 characters but the maximum allowed by the kernel is 15.
I tried your code and with a shorter interface name, it seems to work.
Ah, yes, that works. Thank you!