Skip to content

Commit dc69dd3

Browse files
tahmed-devsanthosh-kt
authored andcommitted
[interfaces] Reduce Calls to SONiC Cfggen (sonic-net#5174)
Calls to sonic-cfggen is CPU expensive. This PR reduces calls to sonic-cfggen to one call during startup when running interfaces- config. singed-off-by: Tamer Ahmed <[email protected]>
1 parent e1b1568 commit dc69dd3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

files/image_config/interfaces/interfaces-config.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ else
1818
echo "{ \"ZTP_DHCP_DISABLED\" : \"true\" }" > /tmp/ztp_input.json
1919
fi
2020

21-
# Create /e/n/i file for existing and active interfaces
22-
sonic-cfggen -d -j /tmp/ztp_input.json -t /usr/share/sonic/templates/interfaces.j2 > /etc/network/interfaces
21+
# Create /e/n/i file for existing and active interfaces, dhcp6 sytcl.conf and dhclient.conf
22+
CFGGEN_PARAMS=" \
23+
-d -j /tmp/ztp_input.json \
24+
-t /usr/share/sonic/templates/interfaces.j2,/etc/network/interfaces \
25+
-t /usr/share/sonic/templates/90-dhcp6-systcl.conf.j2,/etc/sysctl.d/90-dhcp6-systcl.conf \
26+
-t /usr/share/sonic/templates/dhclient.conf.j2,/etc/dhcp/dhclient.conf \
27+
"
28+
sonic-cfggen $CFGGEN_PARAMS
2329

2430
[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid
2531
[ -f /var/run/dhclient6.eth0.pid ] && kill `cat /var/run/dhclient6.eth0.pid` && rm -f /var/run/dhclient6.eth0.pid
@@ -28,11 +34,9 @@ for intf_pid in $(ls -1 /var/run/dhclient*.Ethernet*.pid 2> /dev/null); do
2834
[ -f ${intf_pid} ] && kill `cat ${intf_pid}` && rm -f ${intf_pid}
2935
done
3036

31-
sonic-cfggen -d -j /tmp/ztp_input.json -t /usr/share/sonic/templates/90-dhcp6-systcl.conf.j2 > /etc/sysctl.d/90-dhcp6-systcl.conf
3237
# Read sysctl conf files again
3338
sysctl -p /etc/sysctl.d/90-dhcp6-systcl.conf
3439

35-
sonic-cfggen -d -j /tmp/ztp_input.json -t /usr/share/sonic/templates/dhclient.conf.j2 > /etc/dhcp/dhclient.conf
3640
systemctl restart networking
3741

3842
# Clean-up created files

0 commit comments

Comments
 (0)