Signed-off-by: Petr Machata <petrm(a)mellanox.com>
---
recipes/switchdev/ipip-006-gre-decap.py | 18 +-----------------
recipes/switchdev/ipip_common.py | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/recipes/switchdev/ipip-006-gre-decap.py
b/recipes/switchdev/ipip-006-gre-decap.py
index 6ea8fe1..4beec67 100644
--- a/recipes/switchdev/ipip-006-gre-decap.py
+++ b/recipes/switchdev/ipip-006-gre-decap.py
@@ -12,26 +12,10 @@ from lnst.Controller.Task import ctl
from TestLib import TestLib, vrf, dummy, gre
from ipip_common import ping_test, encap_route, \
add_forward_route, connect_host_ifaces, \
- test_ip, ipv4, ipv6
+ test_ip, ipv4, ipv6, refresh_addrs
from time import sleep
import logging
-def refresh_addrs(m, iface):
- # A device loses IPv6 address when changing VRF, which we normally work
- # around with doing a reset of the device. But for VLAN devices, reset
- # removes and recreates them in default VRF. So instead reset the addresses
- # by hand.
- m.run("ip a flush dev %s" % iface.get_devname())
-
- # Down/up cycle to get a new link-local address so that IPv6 neighbor
- # discovery works.
- m.run("ip l set dev %s down" % iface.get_devname())
- m.run("ip l set dev %s up" % iface.get_devname())
-
- # Now reassign the fixed addresses.
- for ip, mask in iface.get_ips().get_val():
- m.run("ip a add dev %s %s/%s" % (iface.get_devname(), ip, mask))
-
def do_task(ctl, hosts, ifaces, aliases):
m1, m2, sw = hosts
(m1_if1_10, m1_if1_20,
diff --git a/recipes/switchdev/ipip_common.py b/recipes/switchdev/ipip_common.py
index c1b07c1..15c2124 100644
--- a/recipes/switchdev/ipip_common.py
+++ b/recipes/switchdev/ipip_common.py
@@ -73,3 +73,19 @@ def add_forward_route(m, vrf, remote_ip, via=ipv4(test_ip(99, 2,
[]))):
def connect_host_ifaces(sw, if_o, vrf_o, if_u, vrf_u):
sw.run("ip l set dev %s master %s" % (if_o.get_devname(), vrf_o))
sw.run("ip l set dev %s master %s" % (if_u.get_devname(), vrf_u))
+
+def refresh_addrs(m, iface):
+ # A device loses IPv6 address when changing VRF, which we normally work
+ # around with doing a reset of the device. But for VLAN devices, reset
+ # removes and recreates them in default VRF. So instead reset the addresses
+ # by hand.
+ m.run("ip a flush dev %s" % iface.get_devname())
+
+ # Down/up cycle to get a new link-local address so that IPv6 neighbor
+ # discovery works.
+ m.run("ip l set dev %s down" % iface.get_devname())
+ m.run("ip l set dev %s up" % iface.get_devname())
+
+ # Now reassign the fixed addresses.
+ for ip, mask in iface.get_ips().get_val():
+ m.run("ip a add dev %s %s/%s" % (iface.get_devname(), ip, mask))
--
2.4.11