5 odl_mac1=`ip a show dev odl_vpp1 | grep "link/ether" | awk '{print $2}'`
6 echo "set ip arp host-vpp1_rtr 6.0.3.100 $odl_mac1" | nc 0 5002
8 odl_mac2=`ip a show dev odl_vpp2 | grep "link/ether" | awk '{print $2}'`
9 echo "set ip arp host-vpp2_rtr 6.0.3.100 $odl_mac1" | nc 0 5003
11 mac=`echo "sh hard host-rtr_vpp1" | nc 0 5004 | grep 'Ethernet address' | awk '{print $3}'`
12 echo "set ip arp host-vpp1_rtr 6.0.3.2 $mac" | nc 0 5002
14 mac=`echo "sh hard host-vpp2_rtr" | nc 0 5003 | grep 'Ethernet address' | awk '{print $3}'`
15 echo "set ip arp host-rtr_vpp2 6.0.5.1 $mac" | nc 0 5004
18 function rtr_two_iface_clean {
19 echo "Clearing all VPP instances.."
24 echo "Cleaning RTR topology.."
25 ip netns exec vpp1-rtr-ns ifconfig vppbr1 down
26 ip netns exec vpp1-rtr-ns brctl delbr vppbr1
27 ip netns exec vpp2-rtr-ns ifconfig vppbr2 down
28 ip netns exec vpp2-rtr-ns brctl delbr vppbr2
29 ip link del dev vpp1 &> /dev/null
30 ip link del dev vpp2 &> /dev/null
31 ip link del dev vpp1_rtr &> /dev/null
32 ip link del dev rtr1_vpp1 &> /dev/null
33 ip link del dev vpp2_rtr &> /dev/null
34 ip link del dev rtr_vpp2 &> /dev/null
35 ip link del dev odl_vpp1 &> /dev/null
36 ip link del dev odl_vpp2 &> /dev/null
38 ip netns del vpp1-ns &> /dev/null
39 ip netns del vpp2-ns &> /dev/null
40 ip netns del vpp1-rtr-ns &> /dev/null
41 ip netns del vpp2-rtr-ns &> /dev/null
46 function rtr_two_iface_setup {
50 ip netns add vpp1-rtr-ns
51 ip netns add vpp2-rtr-ns
53 # create pair interfaces between vpp[1|2], rtr and odl
54 ip link add veth_vpp1_rtr type veth peer name vpp1_rtr
55 ip link add veth_rtr_vpp1 type veth peer name rtr_vpp1
56 ip link add veth_vpp2_rtr type veth peer name vpp2_rtr
57 ip link add veth_rtr_vpp2 type veth peer name rtr_vpp2
58 ip link add veth_odl_vpp1 type veth peer name odl_vpp1
59 ip link add veth_odl_vpp2 type veth peer name odl_vpp2
61 # enable peer interfaces
62 ip link set dev vpp1_rtr up
63 ip link set dev rtr_vpp1 up
64 ip link set dev vpp2_rtr up
65 ip link set dev rtr_vpp2 up
66 ip link set dev odl_vpp1 up
67 ip link set dev odl_vpp2 up
69 # enable veth interfaces and set them in the appropriate ip ns
70 ip link set dev veth_vpp1_rtr up netns vpp1-rtr-ns
71 ip link set dev veth_rtr_vpp1 up netns vpp1-rtr-ns
72 ip link set dev veth_vpp2_rtr up netns vpp2-rtr-ns
73 ip link set dev veth_rtr_vpp2 up netns vpp2-rtr-ns
74 ip link set dev veth_odl_vpp1 up netns vpp1-rtr-ns
75 ip link set dev veth_odl_vpp2 up netns vpp2-rtr-ns
78 ip netns exec vpp1-rtr-ns brctl addbr vppbr1
79 ip netns exec vpp1-rtr-ns brctl addif vppbr1 veth_vpp1_rtr
80 ip netns exec vpp1-rtr-ns brctl addif vppbr1 veth_rtr_vpp1
81 ip netns exec vpp1-rtr-ns brctl addif vppbr1 veth_odl_vpp1
82 ip netns exec vpp1-rtr-ns ifconfig vppbr1 up
85 ip netns exec vpp2-rtr-ns brctl addbr vppbr2
86 ip netns exec vpp2-rtr-ns brctl addif vppbr2 veth_vpp2_rtr
87 ip netns exec vpp2-rtr-ns brctl addif vppbr2 veth_rtr_vpp2
88 ip netns exec vpp2-rtr-ns brctl addif vppbr2 veth_odl_vpp2
89 ip netns exec vpp2-rtr-ns ifconfig vppbr2 up
92 ip link add veth_vpp1 type veth peer name vpp1
93 ip link set dev vpp1 up
94 ip link set dev veth_vpp1 up netns vpp1-ns
96 ip netns exec vpp1-ns \
99 ip addr add 6.0.2.2/24 dev veth_vpp1
100 ip addr add 6:0:2::2/64 dev veth_vpp1
101 ip route add 6.0.4.0/24 via 6.0.2.1
102 ip route add 6:0:4::0/64 via 6:0:2::1
106 ip link add veth_vpp2 type veth peer name vpp2
107 ip link set dev vpp2 up
108 ip link set dev veth_vpp2 up netns vpp2-ns
110 ip netns exec vpp2-ns \
112 ip link set dev lo up
113 ip addr add 6.0.4.4/24 dev veth_vpp2
114 ip addr add 6:0:4::4/64 dev veth_vpp2
115 ip route add 6.0.2.0/24 via 6.0.4.1
116 ip route add 6:0:2::0/64 via 6:0:4::1
120 ip addr add 6.0.3.100/24 dev odl_vpp1
121 ip addr add 6:0:3::100/64 dev odl_vpp1
122 ethtool --offload odl_vpp1 rx off tx off
125 ip addr add 6.0.5.100/24 dev odl_vpp2
126 ip addr add 6:0:5::100/64 dev odl_vpp2
127 ethtool --offload odl_vpp2 rx off tx off
129 # generate config files
130 ./scripts/generate_config.py ${VPP_LITE_CONF} ${CFG_METHOD}
137 echo "* Selected configuration method: $CFG_METHOD"
138 if [ "$CFG_METHOD" == "cli" ] ; then
139 echo "exec ${VPP_LITE_CONF}/vpp1.cli" | nc 0 5002
140 echo "exec ${VPP_LITE_CONF}/vpp2.cli" | nc 0 5003
141 echo "exec ${VPP_LITE_CONF}/vpp3.cli" | nc 0 5004
142 elif [ "$CFG_METHOD" == "vat" ] ; then
143 ${VPP_API_TEST} chroot prefix vpp1 script in ${VPP_LITE_CONF}/vpp1.vat
144 ${VPP_API_TEST} chroot prefix vpp2 script in ${VPP_LITE_CONF}/vpp2.vat
145 ${VPP_API_TEST} chroot prefix vpp3 script in ${VPP_LITE_CONF}/vpp3.vat
148 echo "=== Invalid configuration method selected!"
149 echo "=== To resolve this set env variable CFG_METHOD to vat or cli."
152 post_curl "add-mapping" ${ODL_CONFIG_FILE1}
153 post_curl "add-mapping" ${ODL_CONFIG_FILE2}