Skip to content

Commit

Permalink
Re-add 127.0.0.1/8 when bringing down the interfaces (#15080)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
saiarcot895 authored and mssonicbld committed Jun 16, 2023
1 parent c1a7677 commit 8195e33
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo
{% endblock loopback %}
{% block mgmt_interface %}

Expand Down
1 change: 1 addition & 0 deletions src/sonic-config-engine/tests/sample_output/py2/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth1
Expand Down
1 change: 1 addition & 0 deletions src/sonic-config-engine/tests/sample_output/py3/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ iface lo inet loopback
netmask 255.255.0.0
scope host
post-up ip addr del 127.0.0.1/8 dev lo
down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down

0 comments on commit 8195e33

Please sign in to comment.