Skip to content

Commit e66cb47

Browse files
authored
[sonic-buildimage] Changes to make network specific sysctl common for both host and docker namespace (#4838)
* [sonic-buildimage] Changes to make network specific sysctl common for both host and docker namespace (in multi-npu). This change is triggered with issue found in multi-npu platforms where in docker namespace net.ipv6.conf.all.forwarding was 0 (should be 1) because of which RS/RA message were triggered and link-local router were learnt. Beside this there were some other sysctl.net.ipv6* params whose value in docker namespace is not same as host namespace. So to make we are always in sync in host and docker namespace created common file that list all sysctl.net.* params and used both by host and docker namespace. Any change will get applied to both namespace. Signed-off-by: Abhishek Dosi <[email protected]> * Address Review Comments and made sure to invoke augtool only one and do string concatenation of all set commands * Address Review Comments.
1 parent 243268f commit e66cb47

File tree

6 files changed

+58
-51
lines changed

6 files changed

+58
-51
lines changed

build_debian.sh

+11-46
Original file line numberDiff line numberDiff line change
@@ -389,61 +389,26 @@ rm /files/lib/systemd/system/rsyslog.service/Service/ExecStart/arguments
389389
set /files/lib/systemd/system/rsyslog.service/Service/ExecStart/arguments/1 -n
390390
"
391391

392-
## Config sysctl
393392
sudo mkdir -p $FILESYSTEM_ROOT/var/core
393+
394+
# Config sysctl
394395
sudo augtool --autosave "
395396
set /files/etc/sysctl.conf/kernel.core_pattern '|/usr/bin/coredump-compress %e %t %p'
396-
397397
set /files/etc/sysctl.conf/kernel.softlockup_panic 1
398398
set /files/etc/sysctl.conf/kernel.panic 10
399399
set /files/etc/sysctl.conf/vm.panic_on_oom 2
400400
set /files/etc/sysctl.conf/fs.suid_dumpable 2
401+
" -r $FILESYSTEM_ROOT
401402

402-
set /files/etc/sysctl.conf/net.ipv4.conf.default.forwarding 1
403-
set /files/etc/sysctl.conf/net.ipv4.conf.all.forwarding 1
404-
set /files/etc/sysctl.conf/net.ipv4.conf.eth0.forwarding 0
405-
406-
set /files/etc/sysctl.conf/net.ipv4.conf.default.arp_accept 0
407-
set /files/etc/sysctl.conf/net.ipv4.conf.default.arp_announce 0
408-
set /files/etc/sysctl.conf/net.ipv4.conf.default.arp_filter 0
409-
set /files/etc/sysctl.conf/net.ipv4.conf.default.arp_notify 0
410-
set /files/etc/sysctl.conf/net.ipv4.conf.default.arp_ignore 0
411-
set /files/etc/sysctl.conf/net.ipv4.conf.all.arp_accept 0
412-
set /files/etc/sysctl.conf/net.ipv4.conf.all.arp_announce 1
413-
set /files/etc/sysctl.conf/net.ipv4.conf.all.arp_filter 0
414-
set /files/etc/sysctl.conf/net.ipv4.conf.all.arp_notify 1
415-
set /files/etc/sysctl.conf/net.ipv4.conf.all.arp_ignore 2
416-
417-
set /files/etc/sysctl.conf/net.ipv4.neigh.default.base_reachable_time_ms 1800000
418-
set /files/etc/sysctl.conf/net.ipv6.neigh.default.base_reachable_time_ms 1800000
419-
set /files/etc/sysctl.conf/net.ipv4.neigh.default.gc_thresh1 1024
420-
set /files/etc/sysctl.conf/net.ipv6.neigh.default.gc_thresh1 1024
421-
set /files/etc/sysctl.conf/net.ipv4.neigh.default.gc_thresh2 2048
422-
set /files/etc/sysctl.conf/net.ipv6.neigh.default.gc_thresh2 2048
423-
set /files/etc/sysctl.conf/net.ipv4.neigh.default.gc_thresh3 4096
424-
set /files/etc/sysctl.conf/net.ipv6.neigh.default.gc_thresh3 4096
425-
426-
set /files/etc/sysctl.conf/net.ipv6.conf.default.forwarding 1
427-
set /files/etc/sysctl.conf/net.ipv6.conf.all.forwarding 1
428-
set /files/etc/sysctl.conf/net.ipv6.conf.eth0.forwarding 0
429-
430-
set /files/etc/sysctl.conf/net.ipv6.conf.default.accept_dad 0
431-
set /files/etc/sysctl.conf/net.ipv6.conf.all.accept_dad 0
432-
set /files/etc/sysctl.conf/net.ipv6.conf.eth0.accept_dad 0
433-
434-
set /files/etc/sysctl.conf/net.ipv6.conf.default.keep_addr_on_down 1
435-
set /files/etc/sysctl.conf/net.ipv6.conf.all.keep_addr_on_down 1
436-
set /files/etc/sysctl.conf/net.ipv6.conf.eth0.keep_addr_on_down 1
437-
438-
set /files/etc/sysctl.conf/net.ipv4.tcp_l3mdev_accept 1
439-
set /files/etc/sysctl.conf/net.ipv4.udp_l3mdev_accept 1
440-
441-
set /files/etc/sysctl.conf/net.core.rmem_max 2097152
442-
set /files/etc/sysctl.conf/net.core.wmem_max 2097152
443-
444-
set /files/etc/sysctl.conf/net.core.somaxconn 512
403+
sysctl_net_cmd_string=""
404+
while read line; do
405+
[[ "$line" =~ ^#.*$ ]] && continue
406+
sysctl_net_conf_key=`echo $line | awk -F '=' '{print $1}'`
407+
sysctl_net_conf_value=`echo $line | awk -F '=' '{print $2}'`
408+
sysctl_net_cmd_string=$sysctl_net_cmd_string"set /files/etc/sysctl.conf/$sysctl_net_conf_key $sysctl_net_conf_value"$'\n'
409+
done < files/image_config/sysctl/sysctl-net.conf
445410

446-
" -r $FILESYSTEM_ROOT
411+
sudo augtool --autosave "$sysctl_net_cmd_string" -r $FILESYSTEM_ROOT
447412

448413
## docker Python API package is needed by Ansible docker module
449414
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install 'docker==4.1.0'

dockers/docker-database/Dockerfile.j2

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ COPY ["docker-database-init.sh", "/usr/local/bin/"]
4040
COPY ["database_config.json.j2", "/usr/share/sonic/templates/"]
4141
COPY ["database_global.json.j2", "/usr/share/sonic/templates/"]
4242
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
43+
COPY ["files/sysctl-net.conf", "/etc/sysctl.d/"]
4344
COPY ["critical_processes", "/etc/supervisor"]
4445

4546
ENTRYPOINT ["/usr/local/bin/docker-database-init.sh"]

files/build_templates/docker_image_ctl.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function postStartAction()
9191
{
9292
{%- if docker_container_name == "database" %}
9393
if [ "$DEV" ]; then
94-
docker exec -i database$DEV sysctl -w net.ipv6.conf.all.disable_ipv6=0
94+
docker exec -i database$DEV sysctl --system -e
9595
link_namespace $DEV
9696
fi
9797

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# All the sysctl for ipv4/ipv6 network.
2+
# Same will be used in host or docker namespace
3+
# It should be provided as key=value format for parsing
4+
net.ipv6.conf.all.disable_ipv6=0
5+
net.ipv4.conf.default.forwarding=1
6+
net.ipv4.conf.all.forwarding=1
7+
net.ipv4.conf.eth0.forwarding=0
8+
net.ipv4.conf.default.arp_accept=0
9+
net.ipv4.conf.default.arp_announce=0
10+
net.ipv4.conf.default.arp_filter=0
11+
net.ipv4.conf.default.arp_notify=0
12+
net.ipv4.conf.default.arp_ignore=0
13+
net.ipv4.conf.all.arp_accept=0
14+
net.ipv4.conf.all.arp_announce=1
15+
net.ipv4.conf.all.arp_filter=0
16+
net.ipv4.conf.all.arp_notify=1
17+
net.ipv4.conf.all.arp_ignore=2
18+
net.ipv4.neigh.default.base_reachable_time_ms=1800000
19+
net.ipv6.neigh.default.base_reachable_time_ms=1800000
20+
net.ipv4.neigh.default.gc_thresh1=1024
21+
net.ipv6.neigh.default.gc_thresh1=1024
22+
net.ipv4.neigh.default.gc_thresh2=2048
23+
net.ipv6.neigh.default.gc_thresh2=2048
24+
net.ipv4.neigh.default.gc_thresh3=4096
25+
net.ipv6.neigh.default.gc_thresh3=4096
26+
net.ipv6.conf.default.forwarding=1
27+
net.ipv6.conf.all.forwarding=1
28+
net.ipv6.conf.eth0.forwarding=0
29+
net.ipv6.conf.default.accept_dad=0
30+
net.ipv6.conf.all.accept_dad=0
31+
net.ipv6.conf.eth0.accept_dad=0
32+
net.ipv6.conf.default.keep_addr_on_down=1
33+
net.ipv6.conf.all.keep_addr_on_down=1
34+
net.ipv6.conf.eth0.keep_addr_on_down=1
35+
net.ipv4.tcp_l3mdev_accept=1
36+
net.ipv4.udp_l3mdev_accept=1
37+
net.core.rmem_max=2097152
38+
net.core.wmem_max=2097152
39+
net.core.somaxconn=512

rules/docker-database.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ $(DOCKER_DATABASE)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
2424

2525
$(DOCKER_DATABASE)_BASE_IMAGE_FILES += redis-cli:/usr/bin/redis-cli
2626
$(DOCKER_DATABASE)_BASE_IMAGE_FILES += monit_database:/etc/monit/conf.d
27-
$(DOCKER_DATABASE)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
27+
$(DOCKER_DATABASE)_FILES += $(SYSCTL_NET_CONFIG) $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)

rules/scripts.mk

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ $(QOS_CONFIG_TEMPLATE)_PATH = files/build_templates
1414
SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT = supervisor-proc-exit-listener
1515
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)_PATH = files/scripts
1616

17+
SYSCTL_NET_CONFIG = sysctl-net.conf
18+
$(SYSCTL_NET_CONFIG)_PATH = files/image_config/sysctl
19+
1720
SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
1821
$(ARP_UPDATE_SCRIPT) \
1922
$(BUFFERS_CONFIG_TEMPLATE) \
2023
$(QOS_CONFIG_TEMPLATE) \
21-
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
22-
23-
24+
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) \
25+
$(SYSCTL_NET_CONFIG)

0 commit comments

Comments
 (0)