[swss] Enhance ARP Update to Call Sonic Cfggen Once (#5398)

This PR limited the number of calls to sonic-cfggen to one call
per iteration instead of current 3 calls per iteration.

The PR also installs jq on host for future scripts if needed.

signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
This commit is contained in:
Tamer Ahmed 2020-09-18 18:44:23 -07:00 committed by GitHub
parent f18b612ff9
commit 2de3afaf35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 26 additions and 10 deletions

View File

@ -315,7 +315,8 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
python-pip \ python-pip \
python3-pip \ python3-pip \
cron \ cron \
haveged haveged \
jq
if [[ $CONFIGURED_ARCH == amd64 ]]; then if [[ $CONFIGURED_ARCH == amd64 ]]; then

View File

@ -59,7 +59,7 @@ RUN apt-get clean -y && \
rm -rf /debs rm -rf /debs
COPY ["files/arp_update", "/usr/bin"] COPY ["files/arp_update", "/usr/bin"]
COPY ["arp_update.conf", "/usr/share/sonic/templates/"] COPY ["arp_update.conf", "files/arp_update_vars.j2", "/usr/share/sonic/templates/"]
COPY ["enable_counters.py", "/usr/bin"] COPY ["enable_counters.py", "/usr/bin"]
COPY ["docker-init.sh", "orchagent.sh", "swssconfig.sh", "/usr/bin/"] COPY ["docker-init.sh", "orchagent.sh", "swssconfig.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]

View File

@ -0,0 +1,5 @@
{
"interface": "{% for (name, prefix) in INTERFACE|pfx_filter %}{% if prefix|ipv6 %}{{ name }} {% endif %}{% endfor %}",
"pc_interface" : "{% for (name, prefix) in PORTCHANNEL_INTERFACE|pfx_filter %}{% if prefix|ipv6 %}{{ name }} {% endif %}{% endfor %}",
"vlan" : "{% if VLAN %}{{ VLAN.keys() | join(' ') }}{% endif %}"
}

View File

@ -7,12 +7,13 @@
# Send gratuitous ARP/NDP requests to VLAN member neighbors to refresh # Send gratuitous ARP/NDP requests to VLAN member neighbors to refresh
# the ipv4/ipv6 neighbors state. # the ipv4/ipv6 neighbors state.
ARP_UPDATE_VARS_FILE="/usr/share/sonic/templates/arp_update_vars.j2"
while /bin/true; do while /bin/true; do
# find L3 interfaces which are UP, send ipv6 multicast pings # find L3 interfaces which are UP, send ipv6 multicast pings
echo "{% for (name, prefix) in INTERFACE|pfx_filter %} {{name}} {% endfor %}" > /tmp/intf_tmp.j2 ARP_UPDATE_VARS=$(sonic-cfggen -d -t ${ARP_UPDATE_VARS_FILE})
INTERFACE=`sonic-cfggen -d -t /tmp/intf_tmp.j2` INTERFACE=$(echo $ARP_UPDATE_VARS | jq -r '.interface')
echo "{% for (name, prefix) in PORTCHANNEL_INTERFACE|pfx_filter %} {{name}} {% endfor %}" > /tmp/pc_intf_tmp.j2 PC_INTERFACE=$(echo $ARP_UPDATE_VARS | jq -r '.pc_interface')
PC_INTERFACE=`sonic-cfggen -d -t /tmp/pc_intf_tmp.j2`
ALL_INTERFACE="$INTERFACE $PC_INTERFACE" ALL_INTERFACE="$INTERFACE $PC_INTERFACE"
for intf in $ALL_INTERFACE; do for intf in $ALL_INTERFACE; do
@ -23,7 +24,7 @@ while /bin/true; do
fi fi
done done
VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'` VLAN=$(echo $ARP_UPDATE_VARS | jq -r '.vlan')
for vlan in $VLAN; do for vlan in $VLAN; do
# generate a list of arping commands: # generate a list of arping commands:
# arping -q -w 0 -c 1 -i <VLAN interface> <IP 1>; # arping -q -w 0 -c 1 -i <VLAN interface> <IP 1>;

View File

@ -23,7 +23,8 @@ $(DOCKER_SONIC_P4)_DEPENDS += $(QUAGGA)
# endif # endif
$(DOCKER_SONIC_P4)_FILES += $(CONFIGDB_LOAD_SCRIPT) \ $(DOCKER_SONIC_P4)_FILES += $(CONFIGDB_LOAD_SCRIPT) \
$(ARP_UPDATE_SCRIPT) $(ARP_UPDATE_SCRIPT) \
$(ARP_UPDATE_VARS_TEMPLATE)
$(DOCKER_SONIC_P4)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE) $(DOCKER_SONIC_P4)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE)
SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_P4) SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_P4)

View File

@ -16,6 +16,7 @@ RUN apt-get install -y net-tools \
ethtool \ ethtool \
tcpdump \ tcpdump \
ifupdown \ ifupdown \
jq \
bridge-utils \ bridge-utils \
python-ply \ python-ply \
libqt5core5a \ libqt5core5a \
@ -78,6 +79,7 @@ COPY ["start.sh", "orchagent.sh", "config_bm.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/configdb-load.sh", "/usr/bin/"] COPY ["files/configdb-load.sh", "/usr/bin/"]
COPY ["files/arp_update", "/usr/bin"] COPY ["files/arp_update", "/usr/bin"]
COPY ["files/arp_update_vars.j2", "/usr/share/sonic/templates/"]
RUN echo "docker-sonic-p4" > /etc/hostname RUN echo "docker-sonic-p4" > /etc/hostname
RUN touch /etc/quagga/zebra.conf RUN touch /etc/quagga/zebra.conf

View File

@ -41,6 +41,7 @@ endif
$(DOCKER_SONIC_VS)_FILES += $(CONFIGDB_LOAD_SCRIPT) \ $(DOCKER_SONIC_VS)_FILES += $(CONFIGDB_LOAD_SCRIPT) \
$(ARP_UPDATE_SCRIPT) \ $(ARP_UPDATE_SCRIPT) \
$(ARP_UPDATE_VARS_TEMPLATE) \
$(BUFFERS_CONFIG_TEMPLATE) \ $(BUFFERS_CONFIG_TEMPLATE) \
$(QOS_CONFIG_TEMPLATE) \ $(QOS_CONFIG_TEMPLATE) \
$(SONIC_VERSION) \ $(SONIC_VERSION) \

View File

@ -131,7 +131,7 @@ COPY ["start.sh", "orchagent.sh", "files/remove_chassisdb_config", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/configdb-load.sh", "/usr/bin/"] COPY ["files/configdb-load.sh", "/usr/bin/"]
COPY ["files/arp_update", "/usr/bin/"] COPY ["files/arp_update", "/usr/bin/"]
COPY ["files/buffers_config.j2", "files/qos_config.j2", "/usr/share/sonic/templates/"] COPY ["files/buffers_config.j2", "files/qos_config.j2", "files/arp_update_vars.j2", "/usr/share/sonic/templates/"]
COPY ["files/sonic_version.yml", "/etc/sonic/"] COPY ["files/sonic_version.yml", "/etc/sonic/"]
COPY ["database_config.json", "/etc/default/sonic-db/"] COPY ["database_config.json", "/etc/default/sonic-db/"]
COPY ["hostname.j2", "/usr/share/sonic/templates/"] COPY ["hostname.j2", "/usr/share/sonic/templates/"]

View File

@ -33,4 +33,4 @@ $(DOCKER_ORCHAGENT)_RUN_OPT += -v /var/log/swss:/var/log/swss:rw
$(DOCKER_ORCHAGENT)_BASE_IMAGE_FILES += swssloglevel:/usr/bin/swssloglevel $(DOCKER_ORCHAGENT)_BASE_IMAGE_FILES += swssloglevel:/usr/bin/swssloglevel
$(DOCKER_ORCHAGENT)_BASE_IMAGE_FILES += monit_swss:/etc/monit/conf.d $(DOCKER_ORCHAGENT)_BASE_IMAGE_FILES += monit_swss:/etc/monit/conf.d
$(DOCKER_ORCHAGENT)_FILES += $(ARP_UPDATE_SCRIPT) $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) $(DOCKER_ORCHAGENT)_FILES += $(ARP_UPDATE_SCRIPT) $(ARP_UPDATE_VARS_TEMPLATE) $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)

View File

@ -1,6 +1,7 @@
#DPKG FRK #DPKG FRK
$(ARP_UPDATE_SCRIPT)_CACHE_MODE := none $(ARP_UPDATE_SCRIPT)_CACHE_MODE := none
$(ARP_UPDATE_VARS_TEMPLATE)_CACHE_MODE := none
$(CONFIGDB_LOAD_SCRIPT)_CACHE_MODE := none $(CONFIGDB_LOAD_SCRIPT)_CACHE_MODE := none
$(BUFFERS_CONFIG_TEMPLATE)_CACHE_MODE := none $(BUFFERS_CONFIG_TEMPLATE)_CACHE_MODE := none
$(UPDATE_PROC_VARIABLES_SCRIPT)_CACHE_MODE := none $(UPDATE_PROC_VARIABLES_SCRIPT)_CACHE_MODE := none

View File

@ -2,6 +2,9 @@
ARP_UPDATE_SCRIPT = arp_update ARP_UPDATE_SCRIPT = arp_update
$(ARP_UPDATE_SCRIPT)_PATH = files/scripts $(ARP_UPDATE_SCRIPT)_PATH = files/scripts
ARP_UPDATE_VARS_TEMPLATE = arp_update_vars.j2
$(ARP_UPDATE_VARS_TEMPLATE)_PATH = files/build_templates
CONFIGDB_LOAD_SCRIPT = configdb-load.sh CONFIGDB_LOAD_SCRIPT = configdb-load.sh
$(CONFIGDB_LOAD_SCRIPT)_PATH = files/scripts $(CONFIGDB_LOAD_SCRIPT)_PATH = files/scripts
@ -22,6 +25,7 @@ $(RM_CHASSISDB_CONFIG_SCRIPT)_PATH = files/scripts
SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \ SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
$(ARP_UPDATE_SCRIPT) \ $(ARP_UPDATE_SCRIPT) \
$(ARP_UPDATE_VARS_TEMPLATE) \
$(BUFFERS_CONFIG_TEMPLATE) \ $(BUFFERS_CONFIG_TEMPLATE) \
$(QOS_CONFIG_TEMPLATE) \ $(QOS_CONFIG_TEMPLATE) \
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) \ $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) \