[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:
parent
2140daa680
commit
fae4c4bfcc
@ -301,7 +301,8 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
|
|||||||
ipmitool \
|
ipmitool \
|
||||||
ndisc6 \
|
ndisc6 \
|
||||||
makedumpfile \
|
makedumpfile \
|
||||||
conntrack
|
conntrack \
|
||||||
|
jq
|
||||||
|
|
||||||
|
|
||||||
if [[ $CONFIGURED_ARCH == amd64 ]]; then
|
if [[ $CONFIGURED_ARCH == amd64 ]]; then
|
||||||
|
@ -63,7 +63,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/"]
|
||||||
|
5
files/build_templates/arp_update_vars.j2
Normal file
5
files/build_templates/arp_update_vars.j2
Normal 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 %}"
|
||||||
|
}
|
@ -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>;
|
||||||
|
@ -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)
|
||||||
|
@ -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 \
|
||||||
@ -79,6 +80,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
|
||||||
|
|
||||||
|
@ -34,6 +34,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)
|
||||||
|
@ -106,7 +106,7 @@ COPY ["start.sh", "orchagent.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/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/"]
|
||||||
|
|
||||||
|
@ -35,4 +35,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)
|
||||||
|
@ -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
|
||||||
|
|
||||||
@ -19,6 +22,7 @@ $(SYSCTL_NET_CONFIG)_PATH = files/image_config/sysctl
|
|||||||
|
|
||||||
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) \
|
||||||
|
Loading…
Reference in New Issue
Block a user