Skip to content

Commit 810cd74

Browse files
authored
Some small fixups and rearrangements to previous commit (#732)
Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
1 parent 3fc94e2 commit 810cd74

File tree

5 files changed

+64
-21
lines changed

5 files changed

+64
-21
lines changed

.github/workflows/test-exercises.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
- name: Run PTF Tests
3232
run: |
3333
cd exercises/basic
34-
mkdir -p logs
3534
make test
3635
# Retain logs in case runs fail
3736
- name: Upload Logs

bin/veth_setup.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
# Copyright 2017 Andy Fingerhut
4+
5+
# This script was originally copied from the location below, then
6+
# modified:
7+
#
8+
# https://github.com/p4lang/behavioral-model/blob/master/tools/veth_setup.sh
9+
10+
for idx in 0 1 2 3 4 5 6 7 8; do
11+
intf0="veth$(($idx*2))"
12+
intf1="veth$(($idx*2+1))"
13+
if ! ip link show $intf0 &> /dev/null; then
14+
ip link add name $intf0 type veth peer name $intf1
15+
ip link set dev $intf0 up
16+
ip link set dev $intf1 up
17+
18+
# Set the MTU of these interfaces to be larger than default of
19+
# 1500 bytes, so that P4 behavioral-model testing can be done
20+
# on jumbo frames.
21+
ip link set $intf0 mtu 9500
22+
ip link set $intf1 mtu 9500
23+
############################################################
24+
# ifconfig is deprecated, and no longer installed by default
25+
# in Ubuntu Linux minimal installs starting with Ubuntu 18.04
26+
# LTS.
27+
#ifconfig $intf0 mtu 9500 up
28+
#ifconfig $intf1 mtu 9500 up
29+
############################################################
30+
31+
# Disable IPv6 on the interfaces, so that the Linux kernel
32+
# will not automatically send IPv6 MDNS, Router Solicitation,
33+
# and Multicast Listener Report packets on the interface,
34+
# which can make P4 program debugging more confusing.
35+
#
36+
# Testing indicates that we can still send IPv6 packets across
37+
# such interfaces, both from scapy to simple_switch, and from
38+
# simple_switch out to scapy sniffing.
39+
#
40+
# https://superuser.com/questions/356286/how-can-i-switch-off-ipv6-nd-ra-transmissions-in-linux
41+
sysctl -q net.ipv6.conf.${intf0}.disable_ipv6=1
42+
sysctl -q net.ipv6.conf.${intf1}.disable_ipv6=1
43+
fi
44+
done

bin/veth_teardown.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
# Copyright 2019 Andy Fingerhut
4+
#
5+
6+
# This script was copied from the location below, for convenience of
7+
# p4-guide users:
8+
#
9+
# https://github.com/p4lang/behavioral-model/blob/master/tools/veth_teardown.sh
10+
11+
for idx in 0 1 2 3 4 5 6 7 8; do
12+
intf="veth$(($idx*2))"
13+
if ip link show $intf &> /dev/null; then
14+
ip link delete $intf type veth
15+
fi
16+
done

exercises/basic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ TOPO = pod-topo/topology.json
44

55
include ../../utils/Makefile
66

7-
test:
7+
test: dirs
88
./runptf.sh

exercises/basic/runptf.sh

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
# Tests run against the solution P4 program.
44

55
set -e
6+
BINDIR=$(realpath ../../bin)
67

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

2110
set -x
2211

@@ -71,12 +60,7 @@ sudo pkill --signal 9 --list-name simple_switch
7160

7261
echo ""
7362
echo "Cleaning up veth interfaces..."
74-
for i in 0 1 2 3 4 5 6 7; do
75-
intf0="veth$(( i * 2 ))"
76-
if ip link show $intf0 &>/dev/null; then
77-
sudo ip link del $intf0
78-
fi
79-
done
63+
sudo "${BINDIR}"/veth_teardown.sh
8064

8165
echo ""
8266
echo "Verifying no simple_switch_grpc processes remain..."

0 commit comments

Comments
 (0)