Skip to content

Commit

Permalink
Fix potentially not having any loopback address on lo interface (soni…
Browse files Browse the repository at this point in the history
…c-net#16490)

In sonic-net#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 <sarcot@microsoft.com>
  • Loading branch information
saiarcot895 authored and mssonicbld committed Sep 21, 2023
1 parent 7ea54f5 commit 290afad
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +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
pre-down ip addr add 127.0.0.1/8 dev lo
{% endblock loopback %}
{% block mgmt_interface %}

Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/sample_output/py2/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth1
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/sample_output/py3/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-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,7 +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
pre-down ip addr add 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down

0 comments on commit 290afad

Please sign in to comment.