-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharp_announce_conf.sh
executable file
·63 lines (59 loc) · 2.23 KB
/
arp_announce_conf.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
#!/bin/bash
#
# Copyright (c) 2019 Mellanox Technologies. All rights reserved.
#
# This Software is licensed under one of the following licenses:
#
# 1) under the terms of the "Common Public License 1.0" a copy of which is
# available from the Open Source Initiative, see
# http://www.opensource.org/licenses/cpl.php.
#
# 2) under the terms of the "The BSD License" a copy of which is
# available from the Open Source Initiative, see
# http://www.opensource.org/licenses/bsd-license.php.
#
# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
# copy of which is available from the Open Source Initiative, see
# http://www.opensource.org/licenses/gpl-license.php.
#
# Licensee has the right to choose one of the above licenses.
#
# Redistributions of source code must retain the above copyright
# notice and one of the license notices.
#
# Redistributions in binary form must reproduce both the above copyright
# notice, one of the license notices in the documentation
# and/or other materials provided with the distribution.
#
# Author: Michael Berezin <[email protected]>
#
if [[ debug == "$1" ]]; then
INSTRUMENTING=yes # any non-null will do
shift
fi
echodbg () {
[[ "$INSTRUMENTING" ]] && builtin echo $@
}
DEVS=$1
if [ -z "$DEVS" ] ; then
DEVS=$(ls /sys/class/infiniband/)
fi
for dev in $DEVS ; do
#echo -e "dev=$dev"
for port in $(ls /sys/class/infiniband/$dev/ports/) ; do
#echo -e " port=$port"
ll=$(cat /sys/class/infiniband/$dev/ports/$port/link_layer);
#echo -e " ll=$ll"
if [ $ll = "Ethernet" ] ; then
ndev=$(cat /sys/class/infiniband/$dev/ports/$port/gid_attrs/ndevs/0)
link_st=$(ip -f inet link show $ndev | grep "state UP")
if [ -n "$link_st" ] ; then
echo "device $dev port $port ==> $ndev (Up) : ARP announce/ignore config"
sysctl -w net.ipv4.conf.$ndev.arp_announce=1
sysctl -w net.ipv4.conf.$ndev.arp_ignore=2
else
echo "device $dev port $port ==> $ndev (Down) : no config"
fi
fi
done #port
done #dev