Skip to content

Commit

Permalink
[baseimage]: Change the loopback mask from /8 to /16 (#5353)
Browse files Browse the repository at this point in the history
As per the VOQ HLDs, internal networking between the linecards and supervisor is required within a chassis.
Allocating 127.X/16 subnets for private communication within a chassis is a good candidate.
It doesn't require any external IP allocation as well as ensure that the traffic will not leave the chassis.

References:
sonic-net/SONiC#622
sonic-net/SONiC#639

**- How I did it**

Changed the `interfaces.j2` file to add `127.0.0.1/16` as the `lo` ip address.
Then once the interface is up, the post-up command removes the `127.0.0.1/8` ip address.
The order in which the netmask change is made matters for `127.0.0.1` to be reachable at all times.

**- How to verify it**

```
root@sonic:~# ip address show dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/16 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
```

Co-authored-by: Baptiste Covolato <[email protected]>
  • Loading branch information
Staphylo and Nakrez authored Sep 15, 2020
1 parent 15f5d47 commit 9bf4b0a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ iface mgmt
# The loopback network interface for mgmt VRF that is required for applications like NTP
up ip link add lo-m type dummy
up ip link set dev lo-m master mgmt
up ip addr add 127.0.0.1/8 dev lo-m
up ip addr add 127.0.0.1/16 dev lo-m
up ip link set lo-m up
down ip link delete dev lo-m
{% endif %}
Expand All @@ -22,6 +22,9 @@ iface mgmt
# The loopback network interface
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.255.0.0
post-up ip addr del 127.0.0.1/8 dev lo
{% endblock loopback %}
{% block mgmt_interface %}

Expand Down
3 changes: 3 additions & 0 deletions src/sonic-config-engine/tests/sample_output/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# The loopback network interface
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.255.0.0
post-up ip addr del 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down
5 changes: 4 additions & 1 deletion src/sonic-config-engine/tests/sample_output/mvrf_interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ iface mgmt
# The loopback network interface for mgmt VRF that is required for applications like NTP
up ip link add lo-m type dummy
up ip link set dev lo-m master mgmt
up ip addr add 127.0.0.1/8 dev lo-m
up ip addr add 127.0.0.1/16 dev lo-m
up ip link set lo-m up
down ip link delete dev lo-m
# The loopback network interface
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.255.0.0
post-up ip addr del 127.0.0.1/8 dev lo

# The management network interface
auto eth0
Expand Down

0 comments on commit 9bf4b0a

Please sign in to comment.