aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/vnet/uri/tcp-setup.sh
blob: e0b01588fe97f6bc16b5ca3bffe0b26c8a4ec7d3 (plain)
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
#!/usr/bin/env bash

function topo_setup
{
  ip netns add vppns1
  ip link add veth_vpp1 type veth peer name vpp1
  ip link set dev vpp1 up
  ip link set dev veth_vpp1 up netns vppns1

  ip netns exec vppns1                          \
  bash -c "
    ip link set dev lo up
    ip addr add 6.0.1.2/24 dev veth_vpp1
  "

  ethtool --offload  vpp1 rx off tx off
  ip netns exec vppns1 ethtool --offload veth_vpp1 rx off tx off

}

function topo_clean
{
  ip link del dev veth_vpp1 &> /dev/null
  ip netns del vppns1 &> /dev/null
}

if [ "$1" == "clean" ] ; then
  topo_clean
    exit 0
else
  topo_setup
fi

# to test connectivity do:
# sudo ip netns exec vppns1 telnet 6.0.1.1 1234
# to push traffic to the server
# dd if=/dev/zero bs=1024K count=512 | nc 6.0.1.1
# to listen for incoming connection from vpp
# nc -l 1234