Skip to content

Instantly share code, notes, and snippets.

@vcgomes
Created February 20, 2020 22:14
Show Gist options
  • Save vcgomes/4c111e3174bde291ab1192d78272c854 to your computer and use it in GitHub Desktop.
Save vcgomes/4c111e3174bde291ab1192d78272c854 to your computer and use it in GitHub Desktop.
taprio veth + namespaces test
#!/bin/sh
ip netns add namespace1
ip netns add namespace2
ip link add veth1 numtxqueues 4 numrxqueues 4 type veth peer name br-veth1
ip link add veth2 numtxqueues 4 numrxqueues 4 type veth peer name br-veth2
ip link set veth1 netns namespace1
ip link set veth2 netns namespace2
ip netns exec namespace1 ip addr add 192.168.1.11/24 dev veth1
ip netns exec namespace2 ip addr add 192.168.1.12/24 dev veth2
ip link add name br1 type bridge
ip link set br1 up
ip link set br-veth1 up
ip link set br-veth2 up
ip netns exec namespace1 ip link set veth1 up
ip netns exec namespace2 ip link set veth2 up
ip link set br-veth1 master br1
ip link set br-veth2 master br1
bridge link show br1
ip addr add 192.168.1.10/24 brd + dev br1
IFACE=veth1
i=$((`date +%s%N` + 37000000000 + (2 * 60 * 1000000000)))
BASE_TIME=$(($i - ($i % 1000000000)))
BATCH_FILE=taprio.batch
cat > $BATCH_FILE <<EOF
qdisc replace dev $IFACE parent root handle 100 taprio \\
num_tc 3 \\
map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \\
queues 1@0 1@1 2@2 \\
base-time $BASE_TIME \\
sched-entry S 01 300000 \\
sched-entry S 02 300000 \\
sched-entry S 04 400000 \\
clockid CLOCK_TAI
EOF
ip netns exec namespace1 tc -batch $BATCH_FILE
echo "Base time: $BASE_TIME"
echo "Configuration saved to: $BATCH_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment