Skip to content

Commit 74264d9

Browse files
Yakiv-Hurykpull[bot]
authored andcommitted
[asan] add address sanitizer support to docker-sonic-vs (sonic-net#10470)
- Why I did it To support docker-sonic-vs image with ASAN. - How I did it 1. Made the supervisord.conf a template 2. Added the 'log_path' environment variable for ASAN-enabled daemons 3. Added supervisord.conf.j2 generation and ASAN lib to the docker-sonic-vs/Dockerfile.j2 - How to verify it 1. Made a build with ENABLE_ASAN=y 2. Run the tests, checked ASAN reports Signed-off-by: Yakiv Huryk <[email protected]>
1 parent 2373ca9 commit 74264d9

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

platform/vs/docker-sonic-vs/Dockerfile.j2

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ RUN apt-get install -y net-tools \
6666
gir1.2-glib-2.0 \
6767
libdbus-1-3 \
6868
libgirepository-1.0-1 \
69+
{%- if ENABLE_ASAN == "y" %}
70+
libasan5 \
71+
{%- endif %}
6972
libsystemd0
7073

7174
# Install redis-server
@@ -160,7 +163,7 @@ RUN sed -ri 's/^(save .*$)/# \1/g;
160163
161164
COPY ["50-default.conf", "/etc/rsyslog.d/"]
162165
COPY ["start.sh", "orchagent.sh", "files/update_chassisdb_config", "/usr/bin/"]
163-
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
166+
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"]
164167
COPY ["files/configdb-load.sh", "/usr/bin/"]
165168
COPY ["files/arp_update", "/usr/bin/"]
166169
COPY ["files/buffers_config.j2", "files/qos_config.j2", "files/arp_update_vars.j2", "files/copp_cfg.j2", "/usr/share/sonic/templates/"]
@@ -179,6 +182,10 @@ COPY ["hwsku.json", "/usr/share/sonic/device/x86_64-kvm_x86_64-r0/Force10-S6000/
179182
COPY ["hwsku.json", "/usr/share/sonic/device/x86_64-kvm_x86_64-r0/brcm_gearbox_vs/"]
180183
COPY ["hwsku.json", "/usr/share/sonic/device/x86_64-kvm_x86_64-r0/Mellanox-SN2700/"]
181184
185+
RUN mkdir -p /etc/supervisor/conf.d/
186+
RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
187+
RUN rm -f /usr/share/sonic/templates/supervisord.conf.j2
188+
182189
# Workaround the tcpdump issue
183190
RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump
184191

platform/vs/docker-sonic-vs/supervisord.conf renamed to platform/vs/docker-sonic-vs/supervisord.conf.j2

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ autostart=false
4242
autorestart=false
4343
stdout_logfile=syslog
4444
stderr_logfile=syslog
45+
{% if ENABLE_ASAN == "y" %}
46+
environment=ASAN_OPTIONS="log_path=/var/log/asan/syncd-asan.log"
47+
{% endif %}
4548

4649
[program:gbsyncd]
4750
command=/usr/bin/syncd -s -p /usr/share/sonic/hwsku/pai.profile -x /usr/share/sonic/hwsku/context_config.json -g 1
@@ -67,6 +70,9 @@ autostart=false
6770
autorestart=false
6871
stdout_logfile=syslog
6972
stderr_logfile=syslog
73+
{% if ENABLE_ASAN == "y" %}
74+
environment=ASAN_OPTIONS="log_path=/var/log/asan/portsyncd-asan.log"
75+
{% endif %}
7076

7177
[program:orchagent]
7278
command=/usr/bin/orchagent.sh
@@ -75,6 +81,9 @@ autostart=false
7581
autorestart=false
7682
stdout_logfile=syslog
7783
stderr_logfile=syslog
84+
{% if ENABLE_ASAN == "y" %}
85+
environment=ASAN_OPTIONS="log_path=/var/log/asan/orchagent-asan.log"
86+
{% endif %}
7887

7988
[program:coppmgrd]
8089
command=/usr/bin/coppmgrd
@@ -83,6 +92,9 @@ autostart=false
8392
autorestart=false
8493
stdout_logfile=syslog
8594
stderr_logfile=syslog
95+
{% if ENABLE_ASAN == "y" %}
96+
environment=ASAN_OPTIONS="log_path=/var/log/asan/coppmgrd-asan.log"
97+
{% endif %}
8698

8799
[program:neighsyncd]
88100
command=/usr/bin/neighsyncd
@@ -91,6 +103,9 @@ autostart=false
91103
autorestart=false
92104
stdout_logfile=syslog
93105
stderr_logfile=syslog
106+
{% if ENABLE_ASAN == "y" %}
107+
environment=ASAN_OPTIONS="log_path=/var/log/asan/neighsyncd-asan.log"
108+
{% endif %}
94109

95110
[program:teamsyncd]
96111
command=/usr/bin/teamsyncd
@@ -99,6 +114,9 @@ autostart=false
99114
autorestart=false
100115
stdout_logfile=syslog
101116
stderr_logfile=syslog
117+
{% if ENABLE_ASAN == "y" %}
118+
environment=ASAN_OPTIONS="log_path=/var/log/asan/teamsyncd-asan.log"
119+
{% endif %}
102120

103121
[program:vlanmgrd]
104122
command=/usr/bin/vlanmgrd
@@ -107,6 +125,9 @@ autostart=false
107125
autorestart=false
108126
stdout_logfile=syslog
109127
stderr_logfile=syslog
128+
{% if ENABLE_ASAN == "y" %}
129+
environment=ASAN_OPTIONS="log_path=/var/log/asan/vlanmgrd-asan.log"
130+
{% endif %}
110131

111132
[program:intfmgrd]
112133
command=/usr/bin/intfmgrd
@@ -115,6 +136,9 @@ autostart=false
115136
autorestart=false
116137
stdout_logfile=syslog
117138
stderr_logfile=syslog
139+
{% if ENABLE_ASAN == "y" %}
140+
environment=ASAN_OPTIONS="log_path=/var/log/asan/intfmgrd-asan.log"
141+
{% endif %}
118142

119143
[program:portmgrd]
120144
command=/usr/bin/portmgrd
@@ -123,6 +147,9 @@ autostart=false
123147
autorestart=false
124148
stdout_logfile=syslog
125149
stderr_logfile=syslog
150+
{% if ENABLE_ASAN == "y" %}
151+
environment=ASAN_OPTIONS="log_path=/var/log/asan/portmgrd-asan.log"
152+
{% endif %}
126153

127154
[program:teammgrd]
128155
command=/usr/bin/teammgrd
@@ -131,6 +158,9 @@ autostart=false
131158
autorestart=false
132159
stdout_logfile=syslog
133160
stderr_logfile=syslog
161+
{% if ENABLE_ASAN == "y" %}
162+
environment=ASAN_OPTIONS="log_path=/var/log/asan/teammgrd-asan.log"
163+
{% endif %}
134164

135165
[program:zebra]
136166
command=/usr/lib/frr/zebra -A 127.0.0.1 -s 90000000 -M fpm
@@ -163,6 +193,9 @@ autostart=false
163193
autorestart=false
164194
stdout_logfile=syslog
165195
stderr_logfile=syslog
196+
{% if ENABLE_ASAN == "y" %}
197+
environment=ASAN_OPTIONS="log_path=/var/log/asan/fpmsyncd-asan.log"
198+
{% endif %}
166199

167200
[program:arp_update]
168201
command=/usr/bin/arp_update
@@ -179,6 +212,9 @@ autostart=false
179212
autorestart=false
180213
stdout_logfile=syslog
181214
stderr_logfile=syslog
215+
{% if ENABLE_ASAN == "y" %}
216+
environment=ASAN_OPTIONS="log_path=/var/log/asan/buffermgrd-asan.log"
217+
{% endif %}
182218

183219
[program:vrfmgrd]
184220
command=/usr/bin/vrfmgrd
@@ -187,6 +223,9 @@ autostart=false
187223
autorestart=false
188224
stdout_logfile=syslog
189225
stderr_logfile=syslog
226+
{% if ENABLE_ASAN == "y" %}
227+
environment=ASAN_OPTIONS="log_path=/var/log/asan/vrfmgrd-asan.log"
228+
{% endif %}
190229

191230
[program:restore_neighbors]
192231
command=/usr/bin/restore_neighbors.py
@@ -205,6 +244,9 @@ autostart=false
205244
autorestart=false
206245
stdout_logfile=syslog
207246
stderr_logfile=syslog
247+
{% if ENABLE_ASAN == "y" %}
248+
environment=ASAN_OPTIONS="log_path=/var/log/asan/nbrmgrd-asan.log"
249+
{% endif %}
208250

209251
[program:vxlanmgrd]
210252
command=/usr/bin/vxlanmgrd
@@ -213,6 +255,9 @@ autostart=false
213255
autorestart=false
214256
stdout_logfile=syslog
215257
stderr_logfile=syslog
258+
{% if ENABLE_ASAN == "y" %}
259+
environment=ASAN_OPTIONS="log_path=/var/log/asan/vxlanmgrd-asan.log"
260+
{% endif %}
216261

217262
[program:sflowmgrd]
218263
command=/usr/bin/sflowmgrd
@@ -221,6 +266,9 @@ autostart=false
221266
autorestart=false
222267
stdout_logfile=syslog
223268
stderr_logfile=syslog
269+
{% if ENABLE_ASAN == "y" %}
270+
environment=ASAN_OPTIONS="log_path=/var/log/asan/sflowmgrd-asan.log"
271+
{% endif %}
224272

225273
[program:natmgrd]
226274
command=/usr/bin/natmgrd
@@ -229,6 +277,9 @@ autostart=false
229277
autorestart=false
230278
stdout_logfile=syslog
231279
stderr_logfile=syslog
280+
{% if ENABLE_ASAN == "y" %}
281+
environment=ASAN_OPTIONS="log_path=/var/log/asan/natmgrd-asan.log"
282+
{% endif %}
232283

233284
[program:natsyncd]
234285
command=/usr/bin/natsyncd
@@ -237,6 +288,9 @@ autostart=false
237288
autorestart=false
238289
stdout_logfile=syslog
239290
stderr_logfile=syslog
291+
{% if ENABLE_ASAN == "y" %}
292+
environment=ASAN_OPTIONS="log_path=/var/log/asan/natsyncd-asan.log"
293+
{% endif %}
240294

241295
[program:fdbsyncd]
242296
command=/usr/bin/fdbsyncd
@@ -245,6 +299,9 @@ autostart=false
245299
autorestart=false
246300
stdout_logfile=syslog
247301
stderr_logfile=syslog
302+
{% if ENABLE_ASAN == "y" %}
303+
environment=ASAN_OPTIONS="log_path=/var/log/asan/fdbsyncd-asan.log"
304+
{% endif %}
248305

249306
[program:tunnelmgrd]
250307
command=/usr/bin/tunnelmgrd
@@ -253,3 +310,6 @@ autostart=false
253310
autorestart=false
254311
stdout_logfile=syslog
255312
stderr_logfile=syslog
313+
{% if ENABLE_ASAN == "y" %}
314+
environment=ASAN_OPTIONS="log_path=/var/log/asan/tunnelmgrd-asan.log"
315+
{% endif %}

0 commit comments

Comments
 (0)