[swss]: Wait for vlan intf to start ndppd (#10119)

- Use the `wait_for_link.sh` script to delay ndppd start until after the VLAN interface is ready
- Avoids issue where ndppd tries to change interface attributes before the interface is ready
This commit is contained in:
Lawrence Lee 2022-03-02 16:23:56 -08:00 committed by GitHub
parent 1740beb1f2
commit 4d2a55d373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View File

@ -18,9 +18,12 @@ CFGGEN_PARAMS=" \
-t /usr/share/sonic/templates/ndppd.conf.j2,/etc/ndppd.conf \
-t /usr/share/sonic/templates/critical_processes.j2,/etc/supervisor/critical_processes \
-t /usr/share/sonic/templates/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf
-t /usr/share/sonic/templates/wait_for_link.sh.j2,/usr/bin/wait_for_link.sh \
"
VLAN=$(sonic-cfggen $CFGGEN_PARAMS)
chmod +x /usr/bin/wait_for_link.sh
# Executed platform specific initialization tasks.
if [ -x /usr/share/sonic/platform/platform-init ]; then
/usr/share/sonic/platform/platform-init

View File

@ -6,4 +6,15 @@ autorestart=unexpected
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=vlanmgrd:running
dependent_startup_wait_for=wait_for_link:exited
[program:wait_for_link]
command=/usr/bin/wait_for_link.sh
priority=7
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=swssconfig:exited

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
VLAN_TABLE_PREFIX="VLAN_TABLE"
function wait_until_iface_ready
{
TABLE_PREFIX=$1
IFACE=$2
echo "Waiting until interface $IFACE is ready..."
# Wait for the interface to come up
# (i.e., interface is present in STATE_DB and state is "ok")
while true; do
RESULT=$(sonic-db-cli STATE_DB HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null)
if [ x"$RESULT" == x"ok" ]; then
break
fi
sleep 1
done
echo "Interface ${IFACE} is ready!"
}
# Wait for all interfaces to be up and ready
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
wait_until_iface_ready ${VLAN_TABLE_PREFIX} {{ name }}
{% endfor %}