From efb6ab1bab7c94c15a0c0cae6ae6936163cefa05 Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 16 Mar 2017 00:08:56 -0700 Subject: [PATCH] [orchagent]: Add ARP update script to maintain VLAN neighbors - Extend ARP reachable time to 30min - Add arping to docker-swss - Add arp_update script to routinely probe neighbors Signed-off-by: Shuotian Cheng --- build_debian.sh | 2 ++ dockers/docker-orchagent/Dockerfile.j2 | 4 ++-- dockers/docker-orchagent/arp_update | 17 +++++++++++++++++ dockers/docker-orchagent/start.sh | 5 +++++ dockers/docker-orchagent/supervisord.conf | 7 +++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100755 dockers/docker-orchagent/arp_update diff --git a/build_debian.sh b/build_debian.sh index d2eaa43b3c46..014deec23dbf 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -232,6 +232,8 @@ set /files/etc/sysctl.conf/net.ipv4.conf.all.arp_filter 0 set /files/etc/sysctl.conf/net.ipv4.conf.all.arp_notify 1 set /files/etc/sysctl.conf/net.ipv4.conf.all.arp_ignore 2 +set /files/etc/sysctl.conf/net.ipv4.neigh.default.base_reachable_time_ms 1800000 + set /files/etc/sysctl.conf/net.ipv6.conf.default.forwarding 1 set /files/etc/sysctl.conf/net.ipv6.conf.all.forwarding 1 set /files/etc/sysctl.conf/net.ipv6.conf.eth0.forwarding 0 diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index ae67807d6eb9..e4e155163076 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -RUN apt-get install -f -y ifupdown libdbus-1-3 libdaemon0 libjansson4 +RUN apt-get install -f -y ifupdown arping libdbus-1-3 libdaemon0 libjansson4 ## Install redis-tools dependencies ## TODO: implicitly install dependencies @@ -26,7 +26,7 @@ debs/{{ deb }}{{' '}} RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -COPY ["start.sh", "orchagent.sh", "swssconfig.sh", "/usr/bin/"] +COPY ["arp_update", "start.sh", "orchagent.sh", "swssconfig.sh", "/usr/bin/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["ipinip.json.j2", "/usr/share/sonic/templates/"] COPY ["mirror.json.j2", "/usr/share/sonic/templates/"] diff --git a/dockers/docker-orchagent/arp_update b/dockers/docker-orchagent/arp_update new file mode 100755 index 000000000000..8291818e50fb --- /dev/null +++ b/dockers/docker-orchagent/arp_update @@ -0,0 +1,17 @@ +#!/bin/bash +# +# usage: +# arp_update: Send gratuitous ARP requests to VLAN member neighbors to refresh +# the neighbors state. + +VLAN=`sonic-cfggen -m /etc/sonic/minigraph.xml -v 'minigraph_vlans.keys() | join(" ")'` +for vlan in $VLAN; do + # generate a list of arping commands: + # arping -q -w 0 -c 1 -i ; + # arping -q -w 0 -c 1 -i ; + # ... + arpingcmd="sed -e 's/ / -i /' -e 's/^/arping -q -w 0 -c 1 /' -e 's/$/;/'" + ipcmd="ip -4 neigh show | grep $vlan | cut -d ' ' -f 1,3 | $arpingcmd" + + eval `eval $ipcmd` +done diff --git a/dockers/docker-orchagent/start.sh b/dockers/docker-orchagent/start.sh index 823e6ce4c5e4..40ef66441c02 100755 --- a/dockers/docker-orchagent/start.sh +++ b/dockers/docker-orchagent/start.sh @@ -32,3 +32,8 @@ supervisorctl start neighsyncd supervisorctl start swssconfig +# Start arp_update when VLAN exists +VLAN=`sonic-cfggen -m /etc/sonic/minigraph.xml -v 'minigraph_vlans.keys() | join(" ")'` +if [ "$VLAN" != "" ]; then + supervisorctl start arp_update +fi diff --git a/dockers/docker-orchagent/supervisord.conf b/dockers/docker-orchagent/supervisord.conf index 02c07188c61d..770fda701029 100644 --- a/dockers/docker-orchagent/supervisord.conf +++ b/dockers/docker-orchagent/supervisord.conf @@ -59,3 +59,10 @@ autorestart=false stdout_logfile=syslog stderr_logfile=syslog +[program:arp_update] +command=bash -c "/usr/bin/arp_update && sleep 300" +priority=8 +autostart=false +autorestart=true +stdout_logfile=syslog +stderr_logfile=syslog