diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index bed0ee6f2..35dd01c7a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -73,15 +73,15 @@ jobs: - name: run python tests run: testing/python_test test_fot - name: setup fot stack - run: bin/setup_stack devices 5 skip-conn-check dhcp fot + run: bin/setup_stack devices 5 faux-mac-prefix "9a:99:57:1e" skip-conn-check dhcp fot - name: run fot integration tests run: timeout 20m bin/run_test_set fot - name: setup vxlan stack - run: bin/setup_stack devices 5 skip-conn-check dhcp fot vxlan + run: bin/setup_stack devices 5 faux-mac-prefix "9a:99:57:1e" skip-conn-check dhcp fot vxlan - name: run vxlan integration tests run: timeout 20m bin/run_test_set fot - name: setup dts - run: bin/setup_stack devices 5 skip-conn-check dhcp fot dts localhost + run: bin/setup_stack devices 5 faux-mac-prefix "9a:99:57:1e" skip-conn-check dhcp fot dts localhost - name: run dts integration tests run: timeout 20m bin/run_test_set fot - name: post-run logs diff --git a/bin/run_controller b/bin/run_controller index 19a4dc978..4d6a9b77d 100755 --- a/bin/run_controller +++ b/bin/run_controller @@ -116,7 +116,7 @@ if [ -n "$gauge_prom_pt" ]; then fi forch_port="-p 500$faucet_id:9019" -docker_envs="--env RUN_MODE=$run_mode" +docker_envs="--env RUN_MODE=$run_mode --env CLEAN_MAC_PREFIX=$CLEAN_MAC_PREFIX" if [[ -n $vxlan ]]; then # Extract the local src IP address that can be used as return address. diff --git a/bin/run_faux b/bin/run_faux index 422887cb9..4d1f0c9ef 100755 --- a/bin/run_faux +++ b/bin/run_faux @@ -2,13 +2,16 @@ ROOT=$(realpath $(dirname $0)/..) postfix= -intf_mac=9a:02:57:1e:8f:00 docker_args= container_prefix=forch-faux image=forch/faux net_opt=--net=none port_num=0 +source bin/stack_functions +set_faux_mac_prefix + +intf_mac=$FAUX_MAC_PREFIX:8f:00 cd $ROOT # If the first argument is a number, then it's a port designation. @@ -22,10 +25,9 @@ if [ $# -gt 0 ] && [ $(($1)) -gt 0 -o "$1" == 0 ]; then mac_port_num=$port_num fi postfix=-$port_num - intf_mac=9a:02:57:1e:$(printf %02x $mac_prefix):$(printf %02x $mac_port_num) + intf_mac=$FAUX_MAC_PREFIX:$(printf %02x $mac_prefix):$(printf %02x $mac_port_num) shift fi - FAUX_ARGS="$*" # Check that image exists so docker doesn't pull down random one from dockerhub @@ -42,14 +44,14 @@ fi docker_args="$docker_args -e LOCAL_IF=$realintf -e FAUX_NUM=$port_num" -cid=$(docker run -d --privileged --name $CONTAINER --hostname $CONTAINER $net_opt $docker_args $image ./start_faux $FAUX_ARGS) +cid=$(docker run -d --privileged --name $CONTAINER --hostname $CONTAINER $net_opt $docker_args $image ./start_faux $FAUX_ARGS "faux-mac-prefix=$FAUX_MAC_PREFIX" ) pid=$(docker inspect --format="{{ .State.Pid }}" $cid) intf=faux$postfix echo Removing old interface $intf sudo ip link del $intf 2>/dev/null || true -echo Adding new interface to $pid... +echo Adding new interface $intf_mac to $pid... sudo ip link add $intf type veth peer name faux-eth0 addr $intf_mac netns $pid sudo ip link set $intf up diff --git a/bin/setup_scale b/bin/setup_scale index 6fb66f28b..34929050b 100755 --- a/bin/setup_scale +++ b/bin/setup_scale @@ -40,6 +40,7 @@ if [ -n "$1" ]; then fi source bin/stack_functions +set_faux_mac_prefix ########################################################### diff --git a/bin/setup_stack b/bin/setup_stack index abf09cfdc..086da8d3a 100755 --- a/bin/setup_stack +++ b/bin/setup_stack @@ -27,6 +27,11 @@ if [ "$1" == "devices" ]; then shift 2 fi +if [ "$1" == "faux-mac-prefix" ]; then + export FAUX_MAC_PREFIX="$2" + shift 2 +fi + if [ "$1" == "switches" ]; then switches=$2 shift 2 @@ -89,6 +94,7 @@ fi rm -rf tcpdump # Clean out directory source bin/stack_functions +set_faux_mac_prefix ########################################################### @@ -173,6 +179,9 @@ if [ -z "$remote" ]; then cp topo/$mode/forch/* $container_inst/forch/ cp topo/$mode/faucet/* $container_inst/faucet/ + + find $container_inst/ -name *.yaml -exec sed -i "s/$DEFAULT_MAC_PREFIX/$FAUX_MAC_PREFIX/" {} \; + docker kill $container || true if [ -n "$fot" ]; then diff --git a/bin/stack_functions b/bin/stack_functions index 475972993..17afe7ac8 100644 --- a/bin/stack_functions +++ b/bin/stack_functions @@ -119,6 +119,23 @@ function add_oeth { sudo ovs-vsctl add-port $br_a $iface_a -- set interface $iface_a ofport_request=$pt_a } +function set_faux_mac_prefix { + export DEFAULT_MAC_PREFIX="9a:02:57:1e" + export DEFAULT_CLEAN_MAC_PREFIX="9a02571e" + if [ -z $FAUX_MAC_PREFIX ]; then + FAUX_MAC_PREFIX=$DEFAULT_MAC_PREFIX + fi + + correct_mac_prefix=`echo $FAUX_MAC_PREFIX | egrep '([0-9a-zA-Z]{2}:){3}[0-9a-zA-Z]{2}'` + if [ -z $correct_mac_prefix ]; then + echo "$FAUX_MAC_PREFIX is an invalid mac prefix. FAUX_MAC_PREFIX should be in the format 'XX:XX:XX:XX'" + false + fi + CLEAN_MAC_PREFIX=`echo $FAUX_MAC_PREFIX | sed 's/://g'` + export FAUX_MAC_PREFIX=$FAUX_MAC_PREFIX + export CLEAN_MAC_PREFIX=$CLEAN_MAC_PREFIX +} + function add_faux { switch=$1 port=$2 diff --git a/controller/bin/controller_go b/controller/bin/controller_go index 87c430744..f168eb537 100755 --- a/controller/bin/controller_go +++ b/controller/bin/controller_go @@ -83,6 +83,10 @@ else ifconfig data0 up fi +if [ -n "$CLEAN_MAC_PREFIX" ]; then + bin/rename_site_config $CLEAN_MAC_PREFIX +fi + echo Forch config cat $FORCH_CONFIG diff --git a/controller/bin/rename_site_config b/controller/bin/rename_site_config new file mode 100755 index 000000000..35e0ba817 --- /dev/null +++ b/controller/bin/rename_site_config @@ -0,0 +1,9 @@ +#!/bin/sh + +default_mac_prefix="9a02571e" + +if [ "$1" != $default_mac_prefix ]; then + for f in `find /site/mac_addrs/ -name "$default_mac_prefix*"`; do + cp -r $f `echo $f | sed -e "s/$default_mac_prefix/$1/g"` + done +fi diff --git a/etc/start_faux b/etc/start_faux index c38d56e82..0eb3ea200 100755 --- a/etc/start_faux +++ b/etc/start_faux @@ -17,11 +17,13 @@ for option in $*; do done IFACE=faux-eth0 +FAUX_MAC_PREFIX="${options['faux-mac-prefix']}" PREFIX=$(($FAUX_NUM/256 + 1)) SUFFIX=$(($FAUX_NUM%256)) IPADDR=192.168.$PREFIX.$SUFFIX GATEWAY=192.168.1.0 +echo $FAUX_MAC_PREFIX while ! ip link show $IFACE; do sleep 2 done @@ -42,7 +44,7 @@ else ip route add default via $GATEWAY fi -if [ -n "${option[ping]}" ]; then +if [ -n "${options[ping]}" ]; then ping -c 10 $GATEWAY & fi @@ -52,8 +54,8 @@ ip route if [ -n "${options[dnsmasq]}" ]; then echo Configuring dnsmasq... echo dhcp-range=192.168.1.10,192.168.1.255 >> /etc/dnsmasq.conf - echo dhcp-host=9a:02:57:1e:8f:01,192.168.1.1 >> /etc/dnsmasq.conf - echo dhcp-host=9a:02:57:1e:8f:02,192.168.1.2 >> /etc/dnsmasq.conf + echo dhcp-host=$FAUX_MAC_PREFIX:8f:01,192.168.1.1 >> /etc/dnsmasq.conf + echo dhcp-host=$FAUX_MAC_PREFIX:8f:02,192.168.1.2 >> /etc/dnsmasq.conf dnsmasq --log-facility=/tmp/dnsmasq.log --log-dhcp fi diff --git a/etc/test_fot.out b/etc/test_fot.out index 885a33058..3595d71cf 100644 --- a/etc/test_fot.out +++ b/etc/test_fot.out @@ -8,9 +8,9 @@ Device 04 log count 0 275 100 274 -9a02571e8f01: [] -9a02571e8f02: [] -9a02571e8f03: ['9a02571e8f03:hold:DaqException'] -9a02571e8f05: ['9a02571e8f05:hold:DaqException'] +9a99571e8f01: [] +9a99571e8f02: [] +9a99571e8f03: ['9a99571e8f03:hold:DaqException'] +9a99571e8f05: ['9a99571e8f05:hold:DaqException'] 5 packets transmitted, 5 received, 0% packet loss, XXX 5 packets transmitted, 0 received, XX errors, 100% packet loss, XXX diff --git a/testing/test_fot b/testing/test_fot index 25b91e9fc..25cd118b8 100755 --- a/testing/test_fot +++ b/testing/test_fot @@ -76,30 +76,30 @@ vlan=$($YQ '.dps."nz-kiwi-t2sw1".interfaces."1".native_vlan' $BEHAVIORAL_CONFIG) echo $(( (vlan > 271) + (vlan > 276) )) | tee -a $TEST_RESULTS echo $(( (vlan > 271) + (vlan > 276) )) | tee -a $TEST_RESULTS -monitor_daq_log "Send device result 9a:02:57:1e:8f:01 passed" -monitor_daq_log "Send device result 9a:02:57:1e:8f:02 failed" -monitor_daq_log "Target device 9a02571e8f03 test hold running" -monitor_daq_log "Target device 9a02571e8f05 test hold running" +monitor_daq_log "Send device result 9a:99:57:1e:8f:01 passed" +monitor_daq_log "Send device result 9a:99:57:1e:8f:02 failed" +monitor_daq_log "Target device 9a99571e8f03 test hold running" +monitor_daq_log "Target device 9a99571e8f05 test hold running" echo `timestamp` stopping forch-faux-3 docker stop forch-faux-3 # Remove device 3 to generate port-down event. -log_count=$(fgrep "9a:02:57:1e:8f:04" $DAQ_BASE/cmdrun.log | wc -l) +log_count=$(fgrep "9a:99:57:1e:8f:04" $DAQ_BASE/cmdrun.log | wc -l) echo Device 04 log count $log_count | tee -a $TEST_RESULTS report_vlans -monitor_forch_log "Device 9a:02:57:1e:8f:04 is entering operational state from unauthenticated state" +monitor_forch_log "Device 9a:99:57:1e:8f:04 is entering operational state from unauthenticated state" # Check if it's running in client/server or server/client mode and adjust expectations accordingly. sserv_mode=$(fgrep ssserv $DAQ_BASE/cmdrun.log | wc -l) if [[ $sserv_mode == 0 ]]; then - monitor_daq_log "Remaining target sets: \[9a02571e8f05\]" + monitor_daq_log "Remaining target sets: \[9a99571e8f05\]" expected_timeouts=0 # Device 8f:05 doesn't timeout in this mode, so add artificial result for later on. - echo "9a02571e8f05: ['9a02571e8f05:hold:DaqException']" | sudo tee -a $DAQ_BASE/result.log + echo "9a99571e8f05: ['9a99571e8f05:hold:DaqException']" | sudo tee -a $DAQ_BASE/result.log else - monitor_forch_log "Device 9a:02:57:1e:8f:03 disconnected" + monitor_forch_log "Device 9a:99:57:1e:8f:03 disconnected" monitor_daq_log "Remaining target sets: \[\]" expected_timeouts=2 fi diff --git a/topo/dva/forch/behaviors.yaml b/topo/dva/forch/behaviors.yaml index 10ba4f6ea..7105f0903 100644 --- a/topo/dva/forch/behaviors.yaml +++ b/topo/dva/forch/behaviors.yaml @@ -1,5 +1,5 @@ device_mac_behaviors: - "9A:02:57:1E:8F:01": + "9a:02:57:1e:8f:01": segment: INFRA role: hello_world.foo.bar#bazqux@quuxquuz123 "02:03:04:00:00:03":