[Mellanox][asan] add address sanitizer support for syncd (#10266)

Why I did it
To support address sanitizer for Mellanox syncd

How I did it
/var/log/asan is mapped for syncd container (the same as for swss)
container stop() has a timeout (60s) for syncd (the same as for swss)
This is so libasan has enough time to generate a report.
added ASAN's log path to Mellanox syncd supervisord.conf
added "asan: yes" to sonic_version.yml
How to verify it
Added artificial memory leaks
Compiled with ENABLE_ASAN=y
Installed the image on DUT
Rebooted the DUT
Verified that /var/log/asan/syncd-asan.log contains the leaks

Signed-off-by: Yakiv Huryk <yhuryk@nvidia.com>
This commit is contained in:
Yakiv Huryk 2022-04-15 01:00:32 +03:00 committed by GitHub
parent 0191300b96
commit d9117d9411
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 5 deletions

View File

@ -435,9 +435,9 @@ start() {
{%- endif %}
{%- if docker_container_name == "swss" %}
-e ASIC_VENDOR={{ sonic_asic_platform }} \
{%- if enable_asan == "y" %}
-v /var/log/asan/:/var/log/asan \
{%- endif -%}
{%- if docker_container_name in ["swss", "syncd"] and enable_asan == "y" %}
-v /var/log/asan/:/var/log/asan \
{%- endif -%}
{%- if docker_container_name == "bgp" %}
-v /etc/sonic/frr/$DEV:/etc/frr:rw \
@ -499,7 +499,7 @@ stop() {
{%- elif docker_container_name == "teamd" %}
# Longer timeout of 60 sec to wait for Portchannels to be cleaned.
/usr/local/bin/container stop -t 60 $DOCKERNAME
{%- elif docker_container_name == "swss" and enable_asan == "y" %}
{%- elif docker_container_name in ["swss", "syncd"] and enable_asan == "y" %}
/usr/local/bin/container stop -t 60 $DOCKERNAME
{%- else %}
/usr/local/bin/container stop $DOCKERNAME

View File

@ -26,4 +26,6 @@ built_by: {{ built_by }}
{{ name }}: {{ version }}
{% endfor -%}
{% endif -%}
{% if ENABLE_ASAN == "y" -%}
asan: 'yes'
{% endif -%}

View File

@ -31,6 +31,9 @@ RUN apt-get update && \
libxml2 \
python-pip \
python-dev \
{%- if ENABLE_ASAN == "y" %}
libasan5 \
{%- endif %}
python-setuptools
RUN pip2 install --upgrade pip
@ -58,8 +61,12 @@ RUN apt-get clean -y && \
apt-get autoremove -y && \
rm -rf /debs
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor/"]
RUN mkdir -p /etc/supervisor/conf.d/
RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
RUN rm -f /usr/share/sonic/templates/supervisord.conf.j2
ENTRYPOINT ["/usr/local/bin/supervisord"]

View File

@ -37,3 +37,6 @@ stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running
{% if ENABLE_ASAN == "y" %}
environment=ASAN_OPTIONS="log_path=/var/log/asan/syncd-asan.log"
{% endif %}