From 51a76614a30476c6b6d42d30dff790add047008f Mon Sep 17 00:00:00 2001 From: zhenggen-xu Date: Fri, 9 Nov 2018 17:06:09 -0800 Subject: [PATCH] Restore neighbor table to kernel during system warm-reboot (#2213) * Restore neighbor table to kernel during system warm-reboot Added a service: "restore_neighbors" to restore neighbor table into kernel during system warm reboot. The service is started by supervisord in swss docker when the docker is started. In case system warm reboot is enabled, it will try to restore the neighbor table from appDB into kernel through netlink API calls and update the neighbor table by sending arp/ns requests to all neighbor entries, then it sets the stateDB flag for neighsyncd to continue the reconciliation process. -- Added tcpdump python-scapy debian package into orchagent and vs dockers. -- Added python module: pyroute2 netifaces into orchagent and vc dockers. -- Workarounded tcpdump issue in the vs docker Signed-off-by: Zhenggen Xu * Move the restore_neighbors.py to sonic-swss submodule Made changes to makefiles accordingly Make dockerfile.j2 changes and supervisord config changes Add python monotonic lib for time access Signed-off-by: Zhenggen Xu * Added PYTHON_SWSSCOMMON as swss runtime dependency Signed-off-by: Zhenggen Xu --- dockers/docker-fpm-frr/Dockerfile.j2 | 2 +- dockers/docker-fpm-quagga/Dockerfile.j2 | 2 +- dockers/docker-orchagent/Dockerfile.j2 | 8 ++++++-- dockers/docker-orchagent/start.sh | 2 ++ dockers/docker-orchagent/supervisord.conf | 11 +++++++++++ dockers/docker-teamd/Dockerfile.j2 | 2 +- platform/vs/docker-sonic-vs/Dockerfile.j2 | 9 ++++++++- platform/vs/docker-sonic-vs/supervisord.conf | 10 ++++++++++ rules/swss.mk | 2 +- 9 files changed, 41 insertions(+), 7 deletions(-) diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index f1cddbd0c4..d0fd6f53d6 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -10,7 +10,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update # Install required packages -RUN apt-get install -y libdbus-1-3 libdaemon0 libjansson4 libc-ares2 iproute +RUN apt-get install -y libdbus-1-3 libdaemon0 libjansson4 libc-ares2 iproute libpython2.7 {% if docker_fpm_frr_debs.strip() -%} # Copy locally-built Debian package dependencies diff --git a/dockers/docker-fpm-quagga/Dockerfile.j2 b/dockers/docker-fpm-quagga/Dockerfile.j2 index 3981935a84..f048e27894 100644 --- a/dockers/docker-fpm-quagga/Dockerfile.j2 +++ b/dockers/docker-fpm-quagga/Dockerfile.j2 @@ -10,7 +10,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update # Install required packages -RUN apt-get install -y libdbus-1-3 libdaemon0 libjansson4 +RUN apt-get install -y libdbus-1-3 libdaemon0 libjansson4 libpython2.7 {% if docker_fpm_quagga_debs.strip() -%} # Copy locally-built Debian package dependencies diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index 61cb094ba7..4fcbe08ab7 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -8,15 +8,19 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -RUN apt-get install -f -y ifupdown arping libdbus-1-3 libdaemon0 libjansson4 +RUN apt-get install -f -y ifupdown arping libdbus-1-3 libdaemon0 libjansson4 libpython2.7 -RUN apt-get install -f -y ndisc6 +RUN apt-get install -f -y ndisc6 tcpdump python-scapy ## Install redis-tools dependencies ## TODO: implicitly install dependencies RUN apt-get -y install libjemalloc1 RUN apt-get install -y libelf1 libmnl0 +RUN pip install setuptools +RUN pip install pyroute2==0.5.3 netifaces==0.10.7 +RUN pip install monotonic==1.5 + COPY \ {% for deb in docker_orchagent_debs.split(' ') -%} debs/{{ deb }}{{' '}} diff --git a/dockers/docker-orchagent/start.sh b/dockers/docker-orchagent/start.sh index cf78850451..3c436aa1dd 100755 --- a/dockers/docker-orchagent/start.sh +++ b/dockers/docker-orchagent/start.sh @@ -19,6 +19,8 @@ supervisorctl start rsyslogd supervisorctl start orchagent +supervisorctl start restore_neighbors + supervisorctl start portsyncd supervisorctl start intfsyncd diff --git a/dockers/docker-orchagent/supervisord.conf b/dockers/docker-orchagent/supervisord.conf index 71748ad4fb..13806a83ff 100644 --- a/dockers/docker-orchagent/supervisord.conf +++ b/dockers/docker-orchagent/supervisord.conf @@ -116,3 +116,14 @@ autostart=false autorestart=false stdout_logfile=syslog stderr_logfile=syslog + +[program:restore_neighbors] +command=/usr/bin/restore_neighbors.py +priority=15 +autostart=false +autorestart=false +startsecs=0 +startretries=0 +stdout_logfile=syslog +stderr_logfile=syslog + diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index f18ff9eabb..cb749ccf8e 100644 --- a/dockers/docker-teamd/Dockerfile.j2 +++ b/dockers/docker-teamd/Dockerfile.j2 @@ -8,7 +8,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -RUN apt-get install -f -y libdbus-1-3 libdaemon0 libjansson4 +RUN apt-get install -f -y libdbus-1-3 libdaemon0 libjansson4 libpython2.7 ## Install redis-tools dependencies ## TODO: implicitly install dependencies diff --git a/platform/vs/docker-sonic-vs/Dockerfile.j2 b/platform/vs/docker-sonic-vs/Dockerfile.j2 index ece8f8d91c..71caf92e53 100644 --- a/platform/vs/docker-sonic-vs/Dockerfile.j2 +++ b/platform/vs/docker-sonic-vs/Dockerfile.j2 @@ -45,11 +45,15 @@ RUN apt-get install -y net-tools \ libmnl0 \ logrotate \ apt-utils \ - psmisc + psmisc \ + tcpdump \ + python-scapy RUN pip install setuptools RUN pip install py2_ipaddress RUN pip install six +RUN pip install pyroute2==0.5.3 netifaces==0.10.7 +RUN pip install monotonic==1.5 {% if docker_sonic_vs_debs.strip() -%} # Copy locally-built Debian package dependencies @@ -87,6 +91,9 @@ COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["files/configdb-load.sh", "/usr/bin/"] COPY ["files/arp_update", "/usr/bin"] +# Workaround the tcpdump issue +RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump + RUN echo "docker-sonic-vs" > /etc/hostname RUN touch /etc/quagga/zebra.conf diff --git a/platform/vs/docker-sonic-vs/supervisord.conf b/platform/vs/docker-sonic-vs/supervisord.conf index 088684293c..c4ec73b41f 100644 --- a/platform/vs/docker-sonic-vs/supervisord.conf +++ b/platform/vs/docker-sonic-vs/supervisord.conf @@ -154,3 +154,13 @@ autostart=false autorestart=false stdout_logfile=syslog stderr_logfile=syslog + +[program:restore_neighbors] +command=/usr/bin/restore_neighbors.py +priority=19 +autostart=false +autorestart=false +startsecs=0 +startretries=0 +stdout_logfile=syslog +stderr_logfile=syslog diff --git a/rules/swss.mk b/rules/swss.mk index c3f50e617e..429eb63ae8 100644 --- a/rules/swss.mk +++ b/rules/swss.mk @@ -4,7 +4,7 @@ SWSS = swss_1.0.0_amd64.deb $(SWSS)_SRC_PATH = $(SRC_PATH)/sonic-swss $(SWSS)_DEPENDS += $(LIBSAIREDIS_DEV) $(LIBSAIMETADATA_DEV) $(LIBTEAM_DEV) \ $(LIBTEAMDCT) $(LIBTEAM_UTILS) $(LIBSWSSCOMMON_DEV) -$(SWSS)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA) $(LIBTEAM) $(LIBSWSSCOMMON) +$(SWSS)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA) $(LIBTEAM) $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) SONIC_DPKG_DEBS += $(SWSS) SWSS_DBG = swss-dbg_1.0.0_amd64.deb