-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-topo.sh
More file actions
executable file
·40 lines (30 loc) · 1.09 KB
/
create-topo.sh
File metadata and controls
executable file
·40 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# include helper.bash file: used to provide some common function across testing scripts
source "${BASH_SOURCE%/*}/../libs/helpers.bash"
# function cleanup: is invoked each time script exit (with or without errors)
function cleanup {
set +e
delete_veth 2
}
trap cleanup ERR
# Enable verbose output
set -x
cleanup
# Makes the script exit, at first error
# Errors are thrown by commands returning not 0 value
set -e
# Create two network namespaces and veth pairs
create_veth 2
# Get MAC address using ifconfig
mac1=$(sudo ip netns exec ns1 ifconfig veth1_ | grep ether | awk '{print $2}')
mac2=$(sudo ip netns exec ns2 ifconfig veth2_ | grep ether | awk '{print $2}')
# Update ARP table ns1
sudo ip netns exec ns1 arp -s 10.0.0.2 $mac2
# Update ARP table ns2
sudo ip netns exec ns2 arp -s 10.0.0.1 $mac1
sudo ip netns exec ns1 ./xdp_loader -i veth1_
sudo ip netns exec ns2 ./xdp_loader -i veth2_
# Disable RX and TX checksumming
# This is needed to avoid checksum errors when using XDP
sudo ip netns exec ns1 ethtool -K veth1_ rx off tx off
sudo ip netns exec ns2 ethtool -K veth2_ rx off tx off