-
Notifications
You must be signed in to change notification settings - Fork 13
/
common-ecmp.sh
126 lines (109 loc) · 3.13 KB
/
common-ecmp.sh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
require_interfaces NIC NIC2
require_module dummy
function config_vxlan() {
echo "config vxlan dev"
ip link add vxlan1 type vxlan id $id dev $NIC dstport $dst_port || fail "Failed to config vxlan"
ip link set vxlan1 up
ip addr add ${local_ip}/24 dev $NIC
tc qdisc add dev vxlan1 ingress
}
function config_ports() {
set_lag_port_select_mode "queue_affinity"
config_sriov 2
config_sriov 2 $NIC2
enable_switchdev
enable_switchdev $NIC2
# need to unbind vfs to create/destroy vf lag
unbind_vfs
unbind_vfs $NIC2
}
function deconfig_ports() {
# need to unbind vfs to create/destroy vf lag
unbind_vfs
unbind_vfs $NIC2
restore_lag_port_select_mode
# disabling sriov will cause a syndrome when destroying vf lag that we need
# to be lag master. instead just move to legacy.
enable_legacy $NIC2
}
function dmesg_chk() {
local tst="$1"
local emsg="$2"
local a
sleep 0.7
a=`dmesg | tail -n6 | grep -m1 -e "$tst"`
if [ $? -ne 0 ]; then
err $emsg
return 1
else
success2 $a
return 0
fi
}
function is_vf_lag_active() {
dmesg_chk "lag map:* port 1:1 port 2:2" "vf lag is not active"
}
out_dev=dummy9
dev1=$NIC
dev2=$NIC2
dev1_ip=48.2.10.60
dev2_ip=48.1.10.60
n1=48.2.10.1
n2=48.1.10.1
n_mac="e4:1d:2d:31:eb:08"
function config_multipath_route() {
log "config multipath route"
# create out_dev if not already exists.
if [ ! -e /sys/class/net/$out_dev ]; then
ip l add dev $out_dev type dummy || err "Failed to create dummy interface"
fi
ifconfig $out_dev $local_ip/24 up
ifconfig $dev1 $dev1_ip/24 up
ifconfig $dev2 $dev2_ip/24 up
ip r r $net nexthop via $n1 dev $dev1 nexthop via $n2 dev $dev2
ip n del $n1 dev $dev1 &>/dev/null
ip n del $n2 dev $dev2 &>/dev/null
ip n del $remote_ip dev $dev1 &>/dev/null
ip n del $remote_ip dev $dev2 &>/dev/null
ip n add $n1 dev $dev1 lladdr $n_mac
ip n add $n2 dev $dev2 lladdr $n_mac
is_vf_lag_active || return 1
return 0
}
function cleanup_multipath() {
ip r d $net &>/dev/null
ifconfig $NIC down
ifconfig $NIC2 down
ip addr flush dev $NIC
ip addr flush dev $NIC2
ip link del dev dummy9 &>/dev/null
ip link del dev vxlan1 &> /dev/null
ip n del ${remote_ip} dev $NIC &>/dev/null
ip n del ${remote_ip6} dev $NIC &>/dev/null
}
function no_encap_rules() {
local i=$1
local a
mlxdump -d $PCI fsdump --type FT --gvmi=$i --no_zero > /tmp/port$i || err "mlxdump failed"
a=`cat /tmp/port$i | tr -d ' ' | grep "action:0x1c"`
if [ -z "$a" ]; then
success2 "No encap rule on port$i"
else
err "Didn't expect an encap rule on port$i"
fi
}
function look_for_encap_rules() {
local ports=$@
local i
local a
for i in $ports ; do
mlxdump -d $PCI fsdump --type FT --gvmi=$i --no_zero > /tmp/port$i || err "mlxdump failed"
a=`cat /tmp/port$i | tr -d ' ' | grep "action:0x1c"`
if [ -z "$a" ]; then
err "Cannot find encap rule in port$i"
else
success2 "Found encap rule on port$i"
fi
done
}