25a0ce5eb1
Implement infrastructure that allows enabling address sanitizer for docker containers. Enable address sanitizer for SWSS container. - Why I did it To add a possibility to compile SONiC applications with address sanitizer (ASAN). ASAN is a memory error detector for C/C++. It finds: 1. Use after free (dangling pointer dereference) 2. Heap buffer overflow 3. Stack buffer overflow 4. Global buffer overflow 5. Use after return 6. Use after the scope 7. Initialization order bugs 8. Memory leaks - How I did it By adding new ENABLE_ASAN configuration option. - How to verify it By default ASAN is disabled and the SONiC image is not affected. When ASAN is enabled it inspects all allocation, deallocation, and memory usage that the application does in run time. To verify whether the application has memory errors tests that trigger memory usage of the application should be run. Ideally, the whole regression tests should be run. Memory leaks reports will be placed in /var/log/asan/ directory of SONiC host OS. Signed-off-by: Oleksandr Ivantsiv <oivantsiv@nvidia.com>
41 lines
1.4 KiB
Django/Jinja
Executable File
41 lines
1.4 KiB
Django/Jinja
Executable File
#!/usr/bin/env bash
|
|
|
|
mkdir -p /etc/swss/config.d/
|
|
mkdir -p /etc/supervisor/
|
|
mkdir -p /etc/supervisor/conf.d/
|
|
|
|
CFGGEN_PARAMS=" \
|
|
-d \
|
|
{% if ENABLE_ASAN == "y" %}
|
|
-a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" \
|
|
{% endif %}
|
|
-y /etc/sonic/constants.yml \
|
|
-t /usr/share/sonic/templates/switch.json.j2,/etc/swss/config.d/switch.json \
|
|
-t /usr/share/sonic/templates/vxlan.json.j2,/etc/swss/config.d/vxlan.json \
|
|
-t /usr/share/sonic/templates/ipinip.json.j2,/etc/swss/config.d/ipinip.json \
|
|
-t /usr/share/sonic/templates/ports.json.j2,/etc/swss/config.d/ports.json \
|
|
-t /usr/share/sonic/templates/vlan_vars.j2 \
|
|
-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
|
|
"
|
|
VLAN=$(sonic-cfggen $CFGGEN_PARAMS)
|
|
|
|
# Executed platform specific initialization tasks.
|
|
if [ -x /usr/share/sonic/platform/platform-init ]; then
|
|
/usr/share/sonic/platform/platform-init
|
|
fi
|
|
|
|
# Executed HWSKU specific initialization tasks.
|
|
if [ -x /usr/share/sonic/hwsku/hwsku-init ]; then
|
|
/usr/share/sonic/hwsku/hwsku-init
|
|
fi
|
|
|
|
# Start arp_update and NDP proxy daemon when VLAN exists
|
|
if [ "$VLAN" != "" ]; then
|
|
cp /usr/share/sonic/templates/arp_update.conf /etc/supervisor/conf.d/
|
|
cp /usr/share/sonic/templates/ndppd.conf /etc/supervisor/conf.d/
|
|
fi
|
|
|
|
exec /usr/local/bin/supervisord
|