|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright 2021-present Open Networking Foundation |
| 3 | +# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 |
| 4 | + |
| 5 | +set -ex |
| 6 | + |
| 7 | +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" |
| 8 | + |
| 9 | +# From: |
| 10 | +# https://github.com/p4lang/behavioral-model/blob/master/tools/veth_setup.sh |
| 11 | + |
| 12 | +for idx in 0 1 2 3 4 5 6 7 8; do |
| 13 | + intf0="veth$((idx * 2))" |
| 14 | + intf1="veth$((idx * 2 + 1))" |
| 15 | + if ! ip link show $intf0 &> /dev/null; then |
| 16 | + ip link add name $intf0 type veth peer name $intf1 |
| 17 | + ip link set dev $intf0 up |
| 18 | + ip link set dev $intf1 up |
| 19 | + |
| 20 | + # Set the MTU of these interfaces to be larger than default of |
| 21 | + # 1500 bytes, so that P4 behavioral-model testing can be done |
| 22 | + # on jumbo frames. |
| 23 | + # Note: ifconfig is deprecated, and no longer installed by |
| 24 | + # default in Ubuntu Linux minimal installs starting with |
| 25 | + # Ubuntu 18.04. The ip command is installed in Ubuntu |
| 26 | + # versions since at least 16.04, and probably older versions, |
| 27 | + # too. |
| 28 | + ip link set $intf0 mtu 9500 |
| 29 | + ip link set $intf1 mtu 9500 |
| 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 net.ipv6.conf.${intf0}.disable_ipv6=1 |
| 42 | + sysctl net.ipv6.conf.${intf1}.disable_ipv6=1 |
| 43 | + fi |
| 44 | +done |
| 45 | + |
| 46 | +stratum_bmv2 \ |
| 47 | + -bmv2_log_level=trace \ |
| 48 | + -chassis_config_file="${DIR}"/chassis_config.txt \ |
| 49 | + -cpu_port=255 \ |
| 50 | + -device_id=1 \ |
| 51 | + -external-stratum-urls=0.0.0.0:28000 \ |
| 52 | + -forwarding_pipeline_configs_file=/dev/null \ |
| 53 | + -initial_pipeline=/root/dummy.json \ |
| 54 | + -local_stratum_url=localhost:28000 \ |
| 55 | + -log_dir="${DIR}"/log/ \ |
| 56 | + -logtostderr=true \ |
| 57 | + -persistent_config_dir=/tmp/ \ |
| 58 | + -write_req_log_file="${DIR}"/log/p4rt-write-reqs.log \ |
| 59 | + &> "${DIR}"/log/stratum_bmv2.log |
0 commit comments