|
| 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 |
0 commit comments