-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for generating interface configuration in /etc/network/in…
…terfaces for multiple management interfaces (#11204) * [Interfaces] Modify template to support multiple management interfaces * Modify minigraph to process interfaces in sorted order Signed-off-by: Ubuntu <gechen@gechen-sonic-dev.d0r25nej54guppclip4gpy5b5a.jx.internal.cloudapp.net> * Add UT minigraph Signed-off-by: Ubuntu <gechen@gechen-sonic-dev.d0r25nej54guppclip4gpy5b5a.jx.internal.cloudapp.net> * make case insensitve comparison Signed-off-by: George Chen <gechen@microsoft.com> * Use natural sort Signed-off-by: George Chen <gechen@microsoft.com> Co-authored-by: Ubuntu <gechen@gechen-sonic-dev.d0r25nej54guppclip4gpy5b5a.jx.internal.cloudapp.net>
- Loading branch information
Showing
6 changed files
with
1,132 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/sonic-config-engine/tests/sample_output/py2/two_mgmt_interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# | ||
# =============== Managed by SONiC Config Engine DO NOT EDIT! =============== | ||
# generated from /usr/share/sonic/templates/interfaces.j2 using sonic-cfggen | ||
# file: /etc/network/interfaces | ||
# | ||
# The loopback network interface | ||
auto lo | ||
iface lo inet loopback | ||
address 127.0.0.1 | ||
netmask 255.255.0.0 | ||
scope host | ||
post-up ip addr del 127.0.0.1/8 dev lo | ||
|
||
# The management network interface | ||
auto eth1 | ||
auto eth0 | ||
iface eth1 inet static | ||
address 10.0.10.100 | ||
netmask 255.255.255.0 | ||
network 10.0.10.0 | ||
broadcast 10.0.10.255 | ||
########## management network policy routing rules | ||
# management port up rules | ||
up ip -4 route add default via 10.0.10.1 dev eth1 table default metric 201 | ||
up ip -4 route add 10.0.10.0/24 dev eth1 table default | ||
up ip -4 rule add pref 32765 from 10.0.10.100/32 table default | ||
# management port down rules | ||
pre-down ip -4 route delete default via 10.0.10.1 dev eth1 table default | ||
pre-down ip -4 route delete 10.0.10.0/24 dev eth1 table default | ||
pre-down ip -4 rule delete pref 32765 from 10.0.10.100/32 table default | ||
iface eth0 inet static | ||
address 10.0.0.100 | ||
netmask 255.255.255.0 | ||
network 10.0.0.0 | ||
broadcast 10.0.0.255 | ||
########## management network policy routing rules | ||
# management port up rules | ||
up ip -4 route add default via 10.0.0.1 dev eth0 table default metric 201 | ||
up ip -4 route add 10.0.0.0/24 dev eth0 table default | ||
up ip -4 rule add pref 32765 from 10.0.0.100/32 table default | ||
# management port down rules | ||
pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table default | ||
pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table default | ||
pre-down ip -4 rule delete pref 32765 from 10.0.0.100/32 table default | ||
iface eth1 inet6 static | ||
address 2603:10e2:0:abcd::8 | ||
netmask 64 | ||
network 2603:10e2:0:abcd:: | ||
broadcast 2603:10e2:0:abcd:ffff:ffff:ffff:ffff | ||
########## management network policy routing rules | ||
# management port up rules | ||
up ip -6 route add default via 2603:10e2:0:abcd::1 dev eth1 table default metric 201 | ||
up ip -6 route add 2603:10e2:0:abcd::/64 dev eth1 table default | ||
up ip -6 rule add pref 32765 from 2603:10e2:0:abcd::8/128 table default | ||
# management port down rules | ||
pre-down ip -6 route delete default via 2603:10e2:0:abcd::1 dev eth1 table default | ||
pre-down ip -6 route delete 2603:10e2:0:abcd::/64 dev eth1 table default | ||
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:abcd::8/128 table default | ||
iface eth0 inet6 static | ||
address 2603:10e2:0:2902::8 | ||
netmask 64 | ||
network 2603:10e2:0:2902:: | ||
broadcast 2603:10e2:0:2902:ffff:ffff:ffff:ffff | ||
########## management network policy routing rules | ||
# management port up rules | ||
up ip -6 route add default via 2603:10e2:0:2902::1 dev eth0 table default metric 201 | ||
up ip -6 route add 2603:10e2:0:2902::/64 dev eth0 table default | ||
up ip -6 rule add pref 32765 from 2603:10e2:0:2902::8/128 table default | ||
# management port down rules | ||
pre-down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table default | ||
pre-down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default | ||
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:2902::8/128 table default | ||
# | ||
source /etc/network/interfaces.d/* | ||
# | ||
|
76 changes: 76 additions & 0 deletions
76
src/sonic-config-engine/tests/sample_output/py3/two_mgmt_interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# | ||
# =============== Managed by SONiC Config Engine DO NOT EDIT! =============== | ||
# generated from /usr/share/sonic/templates/interfaces.j2 using sonic-cfggen | ||
# file: /etc/network/interfaces | ||
# | ||
# The loopback network interface | ||
auto lo | ||
iface lo inet loopback | ||
address 127.0.0.1 | ||
netmask 255.255.0.0 | ||
scope host | ||
post-up ip addr del 127.0.0.1/8 dev lo | ||
|
||
# The management network interface | ||
auto eth0 | ||
auto eth1 | ||
iface eth0 inet static | ||
address 10.0.0.100 | ||
netmask 255.255.255.0 | ||
network 10.0.0.0 | ||
broadcast 10.0.0.255 | ||
########## management network policy routing rules | ||
# management port up rules | ||
up ip -4 route add default via 10.0.0.1 dev eth0 table default metric 201 | ||
up ip -4 route add 10.0.0.0/24 dev eth0 table default | ||
up ip -4 rule add pref 32765 from 10.0.0.100/32 table default | ||
# management port down rules | ||
pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table default | ||
pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table default | ||
pre-down ip -4 rule delete pref 32765 from 10.0.0.100/32 table default | ||
iface eth0 inet6 static | ||
address 2603:10e2:0:2902::8 | ||
netmask 64 | ||
network 2603:10e2:0:2902:: | ||
broadcast 2603:10e2:0:2902:ffff:ffff:ffff:ffff | ||
########## management network policy routing rules | ||
# management port up rules | ||
up ip -6 route add default via 2603:10e2:0:2902::1 dev eth0 table default metric 201 | ||
up ip -6 route add 2603:10e2:0:2902::/64 dev eth0 table default | ||
up ip -6 rule add pref 32765 from 2603:10e2:0:2902::8/128 table default | ||
# management port down rules | ||
pre-down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table default | ||
pre-down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default | ||
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:2902::8/128 table default | ||
iface eth1 inet static | ||
address 10.0.10.100 | ||
netmask 255.255.255.0 | ||
network 10.0.10.0 | ||
broadcast 10.0.10.255 | ||
########## management network policy routing rules | ||
# management port up rules | ||
up ip -4 route add default via 10.0.10.1 dev eth1 table default metric 201 | ||
up ip -4 route add 10.0.10.0/24 dev eth1 table default | ||
up ip -4 rule add pref 32765 from 10.0.10.100/32 table default | ||
# management port down rules | ||
pre-down ip -4 route delete default via 10.0.10.1 dev eth1 table default | ||
pre-down ip -4 route delete 10.0.10.0/24 dev eth1 table default | ||
pre-down ip -4 rule delete pref 32765 from 10.0.10.100/32 table default | ||
iface eth1 inet6 static | ||
address 2603:10e2:0:abcd::8 | ||
netmask 64 | ||
network 2603:10e2:0:abcd:: | ||
broadcast 2603:10e2:0:abcd:ffff:ffff:ffff:ffff | ||
########## management network policy routing rules | ||
# management port up rules | ||
up ip -6 route add default via 2603:10e2:0:abcd::1 dev eth1 table default metric 201 | ||
up ip -6 route add 2603:10e2:0:abcd::/64 dev eth1 table default | ||
up ip -6 rule add pref 32765 from 2603:10e2:0:abcd::8/128 table default | ||
# management port down rules | ||
pre-down ip -6 route delete default via 2603:10e2:0:abcd::1 dev eth1 table default | ||
pre-down ip -6 route delete 2603:10e2:0:abcd::/64 dev eth1 table default | ||
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:abcd::8/128 table default | ||
# | ||
source /etc/network/interfaces.d/* | ||
# | ||
|
Oops, something went wrong.