Skip to content

Commit f207a9b

Browse files
authored
Fix potentially not having any loopback address on lo interface (#16490)
In #15080, there was a command added to re-add 127.0.0.1/8 to the lo interface when the networking configuration is being brought down. However, the trigger for that command is `down`, which, looking at ifupdown2 configuration files, runs immediately after 127.0.0.1/16 is removed. This means there may be a period of time where there are no loopback addresses assigned to the lo interface, and redis commands will fail. Fix this by changing this to pre-down, which should run well before 127.0.0.1/16 is removed, and should always leave lo with a loopback address. Signed-off-by: Saikrishna Arcot <[email protected]>
1 parent 82dd4d4 commit f207a9b

19 files changed

+19
-19
lines changed

files/image_config/interfaces/interfaces.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ iface lo inet loopback
2626
netmask 255.255.0.0
2727
scope host
2828
post-up ip addr del 127.0.0.1/8 dev lo
29-
down ip addr add 127.0.0.1/8 dev lo
29+
pre-down ip addr add 127.0.0.1/8 dev lo
3030
{% endblock loopback %}
3131
{% block mgmt_interface %}
3232

src/sonic-config-engine/tests/sample_output/py2/interfaces

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py2/interfaces_nomgmt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py2/interfaces_nomgmt_ztp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py2/interfaces_nomgmt_ztp_inband

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py2/interfaces_nomgmt_ztp_inband_ip

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py2/interfaces_nomgmt_ztp_ip

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py2/mvrf_interfaces

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ iface lo inet loopback
1919
netmask 255.255.0.0
2020
scope host
2121
post-up ip addr del 127.0.0.1/8 dev lo
22-
down ip addr add 127.0.0.1/8 dev lo
22+
pre-down ip addr add 127.0.0.1/8 dev lo
2323

2424
# The management network interface
2525
auto eth0

src/sonic-config-engine/tests/sample_output/py2/mvrf_interfaces_nomgmt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ iface lo inet loopback
1919
netmask 255.255.0.0
2020
scope host
2121
post-up ip addr del 127.0.0.1/8 dev lo
22-
down ip addr add 127.0.0.1/8 dev lo
22+
pre-down ip addr add 127.0.0.1/8 dev lo
2323

2424
# The management network interface
2525
auto eth0

src/sonic-config-engine/tests/sample_output/py2/two_mgmt_interfaces

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth1

src/sonic-config-engine/tests/sample_output/py3/interfaces

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py3/interfaces_nomgmt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py3/interfaces_nomgmt_ztp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py3/interfaces_nomgmt_ztp_inband

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py3/interfaces_nomgmt_ztp_inband_ip

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py3/interfaces_nomgmt_ztp_ip

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

src/sonic-config-engine/tests/sample_output/py3/mvrf_interfaces

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ iface lo inet loopback
1919
netmask 255.255.0.0
2020
scope host
2121
post-up ip addr del 127.0.0.1/8 dev lo
22-
down ip addr add 127.0.0.1/8 dev lo
22+
pre-down ip addr add 127.0.0.1/8 dev lo
2323

2424
# The management network interface
2525
auto eth0

src/sonic-config-engine/tests/sample_output/py3/mvrf_interfaces_nomgmt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ iface lo inet loopback
1919
netmask 255.255.0.0
2020
scope host
2121
post-up ip addr del 127.0.0.1/8 dev lo
22-
down ip addr add 127.0.0.1/8 dev lo
22+
pre-down ip addr add 127.0.0.1/8 dev lo
2323

2424
# The management network interface
2525
auto eth0

src/sonic-config-engine/tests/sample_output/py3/two_mgmt_interfaces

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ iface lo inet loopback
1010
netmask 255.255.0.0
1111
scope host
1212
post-up ip addr del 127.0.0.1/8 dev lo
13-
down ip addr add 127.0.0.1/8 dev lo
13+
pre-down ip addr add 127.0.0.1/8 dev lo
1414

1515
# The management network interface
1616
auto eth0

0 commit comments

Comments
 (0)