Difference between revisions of "VPP/Pure L3 Between Namespaces with /32s"
From fd.io
< VPP
(→Verify) |
(→Verify) |
||
Line 42: | Line 42: | ||
do | do | ||
PINGIP=10.10.1.$((${j}+1)) | PINGIP=10.10.1.$((${j}+1)) | ||
+ | PINGHNAME=host${INDEX} | ||
if [ ${PINGIP} != ${IP} ]; then | if [ ${PINGIP} != ${IP} ]; then | ||
+ | echo "Pinging from ${HNAME} to ${PINGHNAME} | ||
sudo ip netns exec ${HNAME} ping -c 1 10.10.1.$((${j}+1)) | sudo ip netns exec ${HNAME} ping -c 1 10.10.1.$((${j}+1)) | ||
fi | fi |
Revision as of 01:30, 29 August 2017
Setup
INDECES=(1 2) for i in ${INDECES[@]} do INDEX=${i};HNAME=host${INDEX};IP=10.10.1.$((${INDEX}+1));IPGW=10.10.1.1 #Create namespace sudo ip netns add ${HNAME} sudo ip link add name vpp2${HNAME} type veth peer name ${HNAME} sudo ip link set ${HNAME} netns ${HNAME} sudo ip link sudo ip netns exec ${HNAME} ip link MACADDR=$(sudo ip netns exec ${HNAME} ip link show dev ${HNAME} | grep link | awk '{print $2}') echo "MACADDR: ${MACADDR}" sudo ip netns exec ${HNAME} tcpdump -i ${HNAME} -w /tmp/tcpdump-${HNAME}.libpcap & sudo ip netns exec ${HNAME} ip addr add ${IP}/32 dev ${HNAME} sudo ip netns exec ${HNAME} ip addr show ${HNAME} sudo ip link set dev vpp2${HNAME} up sudo vppctl create host-interface name vpp2${HNAME} sudo vppctl show hardware sudo vppctl trace add af-packet-input 100 sudo vppctl ip route add ${IP}/32 via ${IP} host-vpp2${HNAME} sudo vppctl show ip fib ${IP}/32 sudo vppctl set interface ip address host-vpp2${HNAME} 127.0.0.$((${INDEX}+1))/32 sudo vppctl set ip arp host-vpp2${HNAME} ${IP} ${MACADDR} sudo vppctl set int state host-vpp2${HNAME} up VPP_MACADDRESS=$(sudo vppctl show hardware host-vpp2${HNAME} | grep "Ethernet address" | awk '{print $3}') sudo ip netns exec ${HNAME} ip neigh add ${IPGW} lladdr ${VPP_MACADDRESS} dev ${HNAME} sudo ip netns exec ${HNAME} ip link set dev ${HNAME} up sudo ip netns exec ${HNAME} ip route add ${IPGW} dev ${HNAME} scope link sudo ip netns exec ${HNAME} ip route add default via ${IPGW} dev ${HNAME} sudo ip netns exec ${HNAME} ip route done
Verify
for i in ${INDECES[@]} do INDEX=${i};HNAME=host${INDEX};IP=10.10.1.$((${INDEX}+1));IPGW=10.10.1.1 for j in ${INDECES[@]} do PINGIP=10.10.1.$((${j}+1)) PINGHNAME=host${INDEX} if [ ${PINGIP} != ${IP} ]; then echo "Pinging from ${HNAME} to ${PINGHNAME} sudo ip netns exec ${HNAME} ping -c 1 10.10.1.$((${j}+1)) fi done done sudo vppctl show trace for i in ${INDECES[@]} do INDEX=${i};HNAME=host${INDEX};IP=10.10.1.$((${INDEX}+1));IPGW=10.10.1.1 sudo tcpdump -r /tmp/tcpdump-${HNAME}.libpcap -e done
Cleanup
sudo ip netns exec ${HNAME} ip link del dev ${HNAME} ps -ef | grep /tmp/tcpdump-${HNAME}.libpcap | awk '{print $2}' | xargs sudo kill sudo service vpp restart