Thursday, April 26, 2018

Mininet/Containernet Problem: Exception: Error creating interface pair (s2-eth5,s3-eth1): RTNETLINK answers: File exists

If you did not shut down the previous running mininet/containernet network (e.g. if you lose your connection to remote server), you will got the following error when you try to rerun your mininet network

Traceback (most recent call last):
  File "./mynet.py", line 31, in <module>
    net.addLink(d2, s1)
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 403, in addLink
  File "build/bdist.linux-x86_64/egg/mininet/link.py", line 430, in __init__
  File "build/bdist.linux-x86_64/egg/mininet/link.py", line 474, in makeIntfPair
  File "build/bdist.linux-x86_64/egg/mininet/util.py", line 202, in makeIntfPair
Exception: Error creating interface pair (d2-eth0,s1-eth2): RTNETLINK answers: File exists

In order to solve the problem, you need to clean up the previous running topology by using the following command

sudo mn -c

It will clean up all your cache. It will be something like this

$ sudo mn -c
*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes
killall controller ofprotocol ofdatapath ping nox_core lt-nox_core ovs-openflowd ovs-controller udpbwtest mnexec ivs 2> /dev/null
killall -9 controller ofprotocol ofdatapath ping nox_core lt-nox_core ovs-openflowd ovs-controller udpbwtest mnexec ivs 2> /dev/null
pkill -9 -f "sudo mnexec"
*** Removing junk from /tmp
rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log
*** Removing old X11 tunnels
*** Removing excess kernel datapaths
ps ax | egrep -o 'dp[0-9]+' | sed 's/dp/nl:/'
***  Removing OVS datapaths
ovs-vsctl --timeout=1 list-br
ovs-vsctl --if-exists del-br s1 -- --if-exists del-br s2 -- --if-exists del-br s3
ovs-vsctl --timeout=1 list-br
*** Removing all links of the pattern foo-ethX
ip link show | egrep -o '([-_.[:alnum:]]+-eth[[:digit:]]+)'
( ip link del s2-eth1;ip link del s1-eth3;ip link del s1-eth3;ip link del s2-eth1;ip link del s3-eth1;ip link del s2-eth2;ip link del s2-eth2;ip link del s3-eth1;ip link del s1-eth1 ) 2> /dev/null
ip link show
*** Killing stale mininet node processes
pkill -9 -f mininet:
*** Shutting down stale tunnels
pkill -9 -f Tunnel=Ethernet
pkill -9 -f .ssh/mn
rm -f ~/.ssh/mn/*
***  Removing SAP NAT rules
*** Cleanup complete.

No comments: