Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/test-exercises.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
- name: Run PTF Tests
run: |
cd exercises/basic
mkdir -p logs
make test
# Retain logs in case runs fail
- name: Upload Logs
Expand Down
44 changes: 44 additions & 0 deletions bin/veth_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright 2017 Andy Fingerhut

# This script was originally copied from the location below, then
# modified:
#
# https://github.com/p4lang/behavioral-model/blob/master/tools/veth_setup.sh

for idx in 0 1 2 3 4 5 6 7 8; do
intf0="veth$(($idx*2))"
intf1="veth$(($idx*2+1))"
if ! ip link show $intf0 &> /dev/null; then
ip link add name $intf0 type veth peer name $intf1
ip link set dev $intf0 up
ip link set dev $intf1 up

# Set the MTU of these interfaces to be larger than default of
# 1500 bytes, so that P4 behavioral-model testing can be done
# on jumbo frames.
ip link set $intf0 mtu 9500
ip link set $intf1 mtu 9500
############################################################
# ifconfig is deprecated, and no longer installed by default
# in Ubuntu Linux minimal installs starting with Ubuntu 18.04
# LTS.
#ifconfig $intf0 mtu 9500 up
#ifconfig $intf1 mtu 9500 up
############################################################

# Disable IPv6 on the interfaces, so that the Linux kernel
# will not automatically send IPv6 MDNS, Router Solicitation,
# and Multicast Listener Report packets on the interface,
# which can make P4 program debugging more confusing.
#
# Testing indicates that we can still send IPv6 packets across
# such interfaces, both from scapy to simple_switch, and from
# simple_switch out to scapy sniffing.
#
# https://superuser.com/questions/356286/how-can-i-switch-off-ipv6-nd-ra-transmissions-in-linux
sysctl -q net.ipv6.conf.${intf0}.disable_ipv6=1
sysctl -q net.ipv6.conf.${intf1}.disable_ipv6=1
fi
done
16 changes: 16 additions & 0 deletions bin/veth_teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright 2019 Andy Fingerhut
#

# This script was copied from the location below, for convenience of
# p4-guide users:
#
# https://github.com/p4lang/behavioral-model/blob/master/tools/veth_teardown.sh

for idx in 0 1 2 3 4 5 6 7 8; do
intf="veth$(($idx*2))"
if ip link show $intf &> /dev/null; then
ip link delete $intf type veth
fi
done
2 changes: 1 addition & 1 deletion exercises/basic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ TOPO = pod-topo/topology.json

include ../../utils/Makefile

test:
test: dirs
./runptf.sh
22 changes: 3 additions & 19 deletions exercises/basic/runptf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,9 @@
# Tests run against the solution P4 program.

set -e
BINDIR=$(realpath ../../bin)

# ---- veth setup ----
echo "Creating veth interfaces..."
for i in 0 1 2 3 4 5 6 7; do
intf0="veth$(( i * 2 ))"
intf1="veth$(( i * 2 + 1 ))"
if ! ip link show $intf0 &>/dev/null; then
sudo ip link add name $intf0 type veth peer name $intf1
sudo ip link set dev $intf0 up
sudo ip link set dev $intf1 up
sudo sysctl -q net.ipv6.conf.$intf0.disable_ipv6=1
sudo sysctl -q net.ipv6.conf.$intf1.disable_ipv6=1
fi
done
sudo "${BINDIR}"/veth_setup.sh

set -x

Expand Down Expand Up @@ -71,12 +60,7 @@ sudo pkill --signal 9 --list-name simple_switch

echo ""
echo "Cleaning up veth interfaces..."
for i in 0 1 2 3 4 5 6 7; do
intf0="veth$(( i * 2 ))"
if ip link show $intf0 &>/dev/null; then
sudo ip link del $intf0
fi
done
sudo "${BINDIR}"/veth_teardown.sh

echo ""
echo "Verifying no simple_switch_grpc processes remain..."
Expand Down
Loading