Skip to content

Commit 8195e33

Browse files
saiarcot895mssonicbld
authored andcommitted
Re-add 127.0.0.1/8 when bringing down the interfaces (#15080)
* Re-add 127.0.0.1/8 when bringing down the interfaces With #5353, 127.0.0.1/16 was added to the lo interface, and then 127.0.0.1/8 was removed. However, when bringing down the lo interface, like during a config reload, 127.0.0.1/16 gets removed, but 127.0.0.1/8 isn't added back to the interface. This means that there's a period of time where 127.0.0.1 is not available at all, and services that need to connect to 127.0.01 (such as for redis DB) will fail. To fix this, when going down, add 127.0.0.1/8. Add this address before the existing configuration gets removed, so that 127.0.0.1 is available at all times. Note that running `ifdown lo` doesn't actually bring down the loopback interface; the interface always stays "physically" up. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
1 parent c1a7677 commit 8195e33

19 files changed

Lines changed: 19 additions & 0 deletions

files/image_config/interfaces/interfaces.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +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
2930
{% endblock loopback %}
3031
{% block mgmt_interface %}
3132

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +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
1314

1415
# The management network interface
1516
auto eth0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +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
1314

1415
# The management network interface
1516
auto eth0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +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
1314

1415
# The management network interface
1516
auto eth0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +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
1314

1415
# The management network interface
1516
auto eth0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +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
1314

1415
# The management network interface
1516
auto eth0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +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
1314

1415
# The management network interface
1516
auto eth0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +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
2223

2324
# The management network interface
2425
auto eth0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +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
2223

2324
# The management network interface
2425
auto eth0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +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
1314

1415
# The management network interface
1516
auto eth1

0 commit comments

Comments
 (0)