* [files]: Add allow-hotplug stanza to interfaces files - start interface <interface_name> when the kernel detects a hotplug event from the interface ref: https://www.debian.org/doc/manuals/debian-reference/ch05.en.html * [interfaces]: Combine vlan_interfaces and lag_interfaces file and add allow-hotplug 1. Remove vlan_interfaces and lag_interfaces file and members in teamd.j2 2. Add all interfaces to /etc/network/interfaces file 3. Add allow-hotplug stanza 4. Add up <command> to automatically add interfaces to VLAN and LAG 5. Add unique_name filter to minigraph.py to remove duplicate interface names 6. Add brctl to base image 7. Update sonic-swss submodule Signed-off-by: Shuotian Cheng <shuche@microsoft.com>
95 lines
3.4 KiB
Django/Jinja
95 lines
3.4 KiB
Django/Jinja
#
|
|
{% block banner %}
|
|
# =============== Managed by SONiC Config Engine DO NOT EDIT! ===============
|
|
# generated from /usr/share/sonic/templates/interfaces.j2 using sonic-cfggen
|
|
# file: /etc/network/interfaces
|
|
#
|
|
{% endblock banner %}
|
|
{% block loopback %}
|
|
# The loopback network interface
|
|
auto lo
|
|
iface lo inet loopback
|
|
# Use command 'ip addr list dev lo' to check all addresses
|
|
{% for minigraph_lo_interface in minigraph_lo_interfaces %}
|
|
iface lo {{ 'inet' if minigraph_lo_interface['addr'] | ipv4 else 'inet6' }} static
|
|
address {{ minigraph_lo_interface['addr'] }}
|
|
netmask {{ minigraph_lo_interface['mask'] }}
|
|
#
|
|
{% endfor %}
|
|
{% endblock loopback %}
|
|
{% block mgmt_interface %}
|
|
# The management network interface
|
|
auto eth0
|
|
{% if minigraph_mgmt_interface['addr'] %}
|
|
iface eth0 inet static
|
|
address {{ minigraph_mgmt_interface['addr'] }}
|
|
netmask {{ minigraph_mgmt_interface['mask'] }}
|
|
########## management network policy routing rules
|
|
# management port up rules
|
|
up ip route add default via {{ minigraph_mgmt_interface['gwaddr'] }} dev eth0 table default
|
|
up ip rule add from {{ minigraph_mgmt_interface['addr'] }}/32 table default
|
|
# management port down rules
|
|
down ip route delete default via {{ minigraph_mgmt_interface['gwaddr'] }} dev eth0 table default
|
|
down ip rule delete from {{ minigraph_mgmt_interface['addr'] }}/32 table default
|
|
{# TODO: COPP policy type rules #}
|
|
{% else %}
|
|
iface eth0 inet dhcp
|
|
{% endif %}
|
|
#
|
|
{% endblock mgmt_interface %}
|
|
{% block front_panel_interfaces %}
|
|
# The switch front panel interfaces
|
|
{% for interface in minigraph_interfaces %}
|
|
auto {{ interface['alias'] }}
|
|
allow-hotplug {{ interface['alias'] }}
|
|
iface {{ interface['alias'] }} {{ 'inet' if interface['addr'] | ipv4 else 'inet6' }} static
|
|
address {{ interface['addr'] }}
|
|
netmask {{ interface['mask'] }}
|
|
#
|
|
{% endfor %}
|
|
{% for vlan_interface in minigraph_vlan_interfaces|unique_name %}
|
|
{% for interface in vlan_interface['members'] %}
|
|
auto {{ interface }}
|
|
allow-hotplug {{ interface }}
|
|
iface {{ interface }} inet manual
|
|
pre-up ifconfig {{ interface }} up
|
|
post-up brctl addif {{ vlan_interface['name'] }} {{ interface }}
|
|
post-down ifconfig {{ interface }} down
|
|
#
|
|
{% endfor %}
|
|
{% endfor %}
|
|
# Add || true to suppress the error when docker-teamd starts after docker-swss
|
|
{% for pc_interface in minigraph_portchannel_interfaces|unique_name %}
|
|
{% for interface in pc_interface['members'] %}
|
|
{% if pc_interface['name'] not in pc_set %}
|
|
auto {{ interface }}
|
|
allow-hotplug {{ interface }}
|
|
iface {{ interface }} inet manual
|
|
pre-up teamdctl {{ pc_interface['name'] }} port add {{ interface }} || true
|
|
post-down ifconfig {{ interface }} down
|
|
#
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{% endblock front_panel_interfaces %}
|
|
{% block vlan_interfaces %}
|
|
{% for vlan_interface in minigraph_vlan_interfaces %}
|
|
auto {{ vlan_interface['name'] }}
|
|
allow-hotplug {{ vlan_interface['name'] }}
|
|
iface {{ vlan_interface['name'] }} {{ 'inet' if vlan_interface['addr'] | ipv4 else 'inet6' }} static
|
|
address {{ vlan_interface['addr'] }}
|
|
netmask {{ vlan_interface['mask'] }}
|
|
#
|
|
{% endfor %}
|
|
{% endblock vlan_interfaces %}
|
|
{% block pc_interfaces %}
|
|
{% for pc_interface in minigraph_portchannel_interfaces %}
|
|
auto {{ pc_interface['name'] }}
|
|
allow-hotplug {{ pc_interface['name'] }}
|
|
iface {{ pc_interface['name'] }} {{ 'inet' if pc_interface['addr'] | ipv4 else 'inet6' }} static
|
|
address {{ pc_interface['addr'] }}
|
|
netmask {{ pc_interface['mask'] }}
|
|
#
|
|
{% endfor %}
|
|
{% endblock pc_interfaces %}
|