-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdpctl-cmds
executable file
·70 lines (64 loc) · 2.49 KB
/
dpctl-cmds
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
# commands for path setup from ee->leaf101-spine12-leaf102->p6p2
# dpctl unix:/tmp/leaf101 flow-mod table=0,cmd=add in_port=2 apply:output=1
# dpctl unix:/tmp/leaf101 flow-mod table=0,cmd=add in_port=1 apply:output=2
# dpctl unix:/tmp/leaf102 flow-mod table=0,cmd=add in_port=1 apply:output=3
# dpctl unix:/tmp/leaf102 flow-mod table=0,cmd=add in_port=3 apply:output=1
# dpctl unix:/tmp/spine12 flow-mod table=0,cmd=add in_port=2 apply:output=1
# dpctl unix:/tmp/spine12 flow-mod table=0,cmd=add in_port=1 apply:output=2
# for priority, matching on vlans - dpctl man page is terribly out of sync with CpQD's dpctl.
# we resort to looking at their dpctl header files, utilities/dpctl.h.
# https://github.com/CPqD/ofsoftswitch13/blob/8d3df820f7487f541b3f5862081a939aad76d8b5/utilities/dpctl.h
#
# dpctl unix:/tmp/leaf101 flow-mod table=0,cmd=add,prio=4096 in_port=2,vlan_vid=100 apply:output=4
#
# convenience functions:
#
# ports <switch>: list port-names to port number for a switch
# vlan <switch> <inport> <outport>: call dpctl for vlan-matching flowmod addition (high priority)
# pass <switch> <inport> <outport>: call dpctl for all-matching flowmod addition (low priority)
ports () {
dpctl unix:/tmp/${1} port-desc | sed -ne 's:.*no="\([0-9]*\).*name="\(.*eth[0-9]\).*:\2 \1: p'
}
vlan () {
dpctl unix:/tmp/${1} flow-mod table=0,cmd=add,prio=65000 in_port=${2},vlan_vid=${4} apply:output=${3}
}
pass () {
dpctl unix:/tmp/${1} flow-mod table=0,cmd=add in_port=${2} apply:output=${3}
}
ip () {
dpctl unix:/tmp/${1} flow-mod table=0,cmd=add,prio=65000 in_port=${2},eth_type=0x800,ip_src=${4},ip_dst=${5} apply:output=${3}
}
SITE=$1
if [ $SITE = "co1" ]; then
vlan leaf101 1 4 100
vlan leaf101 4 1 100
vlan leaf101 1 4 200
vlan leaf101 4 1 200
pass leaf101 4 3
pass leaf101 3 4
pass spine12 1 2
pass spine12 2 1
ip leaf102 1 3 192.168.4.1 192.168.4.2
ip leaf102 3 1 192.168.4.2 192.168.4.1
ip leaf102 1 4 192.168.4.1 192.168.4.3
ip leaf102 4 1 192.168.4.3 192.168.4.1
elif [ $SITE = "co2" ]; then
vlan leaf201 1 4 100
vlan leaf201 4 1 100
pass leaf201 4 2
pass leaf201 2 4
pass spine22 1 2
pass spine22 2 1
ip leaf202 1 3 192.168.4.2 192.168.4.1
ip leaf202 3 1 192.168.4.1 192.168.4.2
elif [ $SITE = "co3" ]; then
vlan leaf301 3 4 200
vlan leaf301 4 3 200
pass leaf301 4 1
pass leaf301 1 4
pass spine32 1 2
pass spine32 2 1
ip leaf302 2 3 192.168.4.3 192.168.4.1
ip leaf302 3 2 192.168.4.1 192.168.4.3
fi