Fix ARP issues in vLB and vPKTGEN 57/7657/1
authorMarco Platania <platania@research.att.com>
Tue, 15 Aug 2017 20:58:44 +0000 (16:58 -0400)
committerMarco Platania <platania@research.att.com>
Tue, 15 Aug 2017 20:58:44 +0000 (16:58 -0400)
- Retrieve vLB and vPKTGEN's MAC address in Heat template
- Assign those MAC addresses to VPP tap interfaces

Change-Id: Ib4e5d4981031328ca8dc54bd7e5b0031c7f41846
Issue-ID: UCA-34
Signed-off-by: Marco Platania <platania@research.att.com>
heat/vLB/base_vlb_openstack.yaml
vnfs/vLB/scripts/v_dns_install.sh
vnfs/vLB/scripts/v_lb_init.sh
vnfs/vLB/scripts/v_lb_install.sh
vnfs/vLB/scripts/v_packetgen_for_dns_demo_init.sh
vnfs/vLB/scripts/v_packetgen_install.sh

index a99afb8..fa4fea0 100644 (file)
@@ -121,6 +121,10 @@ parameters:
     type: string
     label: vDNS name
     description: Name of the vDNS
+  vpg_name_0:
+    type: string
+    label: vPKTGEN name
+    description: Name of the vPKTGEN
   vnf_id:
     type: string
     label: VNF ID
@@ -265,6 +269,7 @@ resources:
             __vlb_private_net_cidr__: { get_param: vlb_private_net_cidr }
             __onap_private_net_cidr__: { get_param: onap_private_net_cidr }
             __pktgen_private_net_cidr__: { get_param: pktgen_private_net_cidr }
+            __pktgen_mac__: { get_attr: [vpg_private_0_port, mac_address] }
             __cloud_env__: { get_param: cloud_env }
           template: |
             #!/bin/bash
@@ -286,6 +291,7 @@ resources:
             echo "__vlb_private_net_cidr__" > /opt/config/vlb_private_net_cidr.txt
             echo "__pktgen_private_net_cidr__" > /opt/config/pktgen_private_net_cidr.txt
             echo "__onap_private_net_cidr__" > /opt/config/onap_private_net_cidr.txt
+            echo "__pktgen_mac__" > /opt/config/pktgen_mac.txt
             echo "__cloud_env__" > /opt/config/cloud_env.txt
 
             # Download and run install script
@@ -395,6 +401,7 @@ resources:
             __demo_artifacts_version__: { get_param: demo_artifacts_version }
             __install_script_version__: { get_param: install_script_version }
             __pg_int__: { get_param: pg_int }
+            __vlb_mac__: { get_attr: [vlb_private_2_port, mac_address] }
             __cloud_env__: { get_param: cloud_env }
           template: |
             #!/bin/bash
@@ -411,6 +418,7 @@ resources:
             echo "__demo_artifacts_version__" > /opt/config/demo_artifacts_version.txt
             echo "__install_script_version__" > /opt/config/install_script_version.txt
             echo "__pg_int__" > /opt/config/pg_int.txt
+            echo "__vlb_mac__" > /opt/config/vlb_mac.txt
             echo "__cloud_env__" > /opt/config/cloud_env.txt
 
             # Download and run install script
index 19dc047..84d7a01 100644 (file)
@@ -42,9 +42,6 @@ then
        echo "    address $IP" >> /etc/network/interfaces
        echo "    netmask $NETMASK" >> /etc/network/interfaces
        echo "    mtu $MTU" >> /etc/network/interfaces
-
-       ifup eth1
-       ifup eth2
 fi
 
 # Download required dependencies
@@ -54,7 +51,6 @@ apt-get install -y wget openjdk-8-jdk bind9 bind9utils bind9-doc apt-transport-h
 sleep 1
 
 # Download vDNS demo code for DNS Server
-mkdir /opt/config
 mkdir /opt/FDclient
 cd /opt
 
index 3c816c8..9223e04 100755 (executable)
@@ -39,17 +39,9 @@ FAKE_HWADDR1=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null | hexdump
 FAKE_HWADDR2=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 ":%02X"')
 GW=$(route -n | grep "^0.0.0.0" | awk '{print $2}')
 PKTGEN_IPADDR=$(cat /opt/config/pktgen_ipaddr.txt)
+PKTGEN_MAC=$(cat /opt/config/pktgen_mac.txt)
 VIP=$(cat /opt/config/vip.txt)
 
-while [ $(ping -c 1 $PKTGEN_IPADDR | grep received | cut -d" " -f4) != 1 ]; 
-do
-       echo "Wait";
-       sleep 1;
-done
-
-sleep 3
-PKTGEN_MAC=$(arp -n | grep -w $PKTGEN_IPADDR | tr -s ' ' | cut -d' ' -f3)
-
 ifconfig eth3 down
 ifconfig eth3 hw ether $FAKE_HWADDR1
 ip addr flush dev eth3
index 9d4a0c9..6c093c0 100644 (file)
@@ -51,10 +51,6 @@ then
        echo "    address $IP" >> /etc/network/interfaces
        echo "    netmask $NETMASK" >> /etc/network/interfaces
        echo "    mtu $MTU" >> /etc/network/interfaces
-
-       ifup eth1
-       ifup eth2
-       ifup eth3
 fi
 
 # Download required dependencies
index 86f0b00..c38d2ba 100644 (file)
@@ -33,6 +33,7 @@ IPADDR1=$(ifconfig eth1 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d'
 HWADDR1=$(ifconfig eth1 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
 FAKE_HWADDR1=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 ":%02X"')
 VLB_IPADDR=$(cat /opt/config/vlb_ipaddr.txt)
+VLB_MAC=$(cat /opt/config/vlb_mac.txt)
 GW=$(route -n | grep "^0.0.0.0" | awk '{print $2}')
 
 ifconfig eth1 down
@@ -53,16 +54,7 @@ sleep 1
 ifconfig br0 hw ether $HWADDR1
 ifconfig br0 $IPADDR1 netmask $IPADDR1_MASK
 route add default gw $GW
-
-#Adding static arp entry for VPP so that it will be able to send packets to default GW
-while [ $(ping -c 1 $VLB_IPADDR | grep received | cut -d" " -f4) != 1 ]; 
-do
-       echo "Wait";
-       sleep 1;
-done
-
-sleep 3
-VLB_MAC=$(arp -n | grep -w $VLB_IPADDR | tr -s ' ' | cut -d' ' -f3)
+sleep 1
 vppctl set ip arp tap-0 $VLB_IPADDR $VLB_MAC
 
 # Install packet streams
index 50d4fce..0f8014f 100644 (file)
@@ -6,6 +6,14 @@ DEMO_ARTIFACTS_VERSION=$(cat /opt/config/demo_artifacts_version.txt)
 INSTALL_SCRIPT_VERSION=$(cat /opt/config/install_script_version.txt)
 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
 
+# Convert Network CIDR to Netmask
+cdr2mask () {
+       # Number of args to shift, 255..255, first non-255 byte, zeroes
+       set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
+       [ $1 -gt 1 ] && shift $1 || shift
+       echo ${1-0}.${2-0}.${3-0}.${4-0}
+}
+
 # OpenStack network configuration
 if [[ $CLOUD_ENV == "openstack" ]]
 then