-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dualtor-aa] add test to verify iptables nat rules for mux port (#14919)
Covers test gap #11436 which is raised to cover this issue sonic-net/sonic-host-services#95. The test will check nat rules and make sure vlan ip to mux cable soc_ip snat is correct, and in the case of multivlan, only vlan ip of the vlan as soc_ip is used.
- Loading branch information
Showing
10 changed files
with
421 additions
and
44 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
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
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
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,73 @@ | ||
{% set vms=vm_topo_config['vm'].keys() | sort %} | ||
{% set vms_number = vms | length %} | ||
{% set dut_index = testbed_facts['duts_map'][inventory_hostname]|int %} | ||
<IPInterfaces> | ||
{% if (card_type is not defined or card_type != 'supervisor') and (vm_topo_config['topo_type'] != 'wan') %} | ||
{% for index in range(vms_number) %} | ||
{% if vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int] is not none %} | ||
<IPInterface> | ||
<Name i:nil="true"/> | ||
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %} | ||
<AttachTo>PortChannel{{ '10' + ((index+1) |string) }}</AttachTo> | ||
{% else %} | ||
<AttachTo>{{ port_alias[vm_topo_config['vm'][vms[index]]['interface_indexes'][dut_index|int][0]] }}</AttachTo> | ||
{% endif %} | ||
<Prefix>{{ vm_topo_config['vm'][vms[index]]['bgp_ipv4'][dut_index|int] }}/{{ vm_topo_config['vm'][vms[index]]['ipv4mask'][dut_index|int] }}</Prefix> | ||
</IPInterface> | ||
<IPInterface> | ||
<Name i:Name="true"/> | ||
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %} | ||
<AttachTo>PortChannel{{ '10' + ((index+1) |string) }}</AttachTo> | ||
{% else %} | ||
<AttachTo>{{ port_alias[vm_topo_config['vm'][vms[index]]['interface_indexes'][dut_index|int][0]] }}</AttachTo> | ||
{% endif %} | ||
<Prefix>{{ vm_topo_config['vm'][vms[index]]['bgp_ipv6'][dut_index|int] }}/{{ vm_topo_config['vm'][vms[index]]['ipv6mask'][dut_index|int] }}</Prefix> | ||
</IPInterface> | ||
{% endif %} | ||
{% endfor %} | ||
{% if 'tor' in vm_topo_config['dut_type'] | lower %} | ||
{% for vlan, vlan_param in vlan_configs.items() %} | ||
<IPInterface> | ||
<Name i:nil="true"/> | ||
<AttachTo>{{ vlan }}</AttachTo> | ||
<Prefix>{{ vlan_param['prefix'] }}</Prefix> | ||
</IPInterface> | ||
{%if 'secondary_subnet' in vlan_param %} | ||
<IPInterface> | ||
<Name i:nil="true"/> | ||
<AttachTo>{{ vlan }}</AttachTo> | ||
<Prefix>{{ vlan_param['secondary_subnet'] }}</Prefix> | ||
</IPInterface> | ||
{% endif %} | ||
{% endfor %} | ||
{% for vlan, vlan_param in vlan_configs.items() %} | ||
{% if 'prefix_v6' in vlan_param %} | ||
<IPInterface> | ||
<Name i:nil="true"/> | ||
<AttachTo>{{ vlan }}</AttachTo> | ||
<Prefix>{{ vlan_param['prefix_v6'] }}</Prefix> | ||
</IPInterface> | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
{% elif vm_topo_config['topo_type'] == 'wan' and 'wan_dut_configuration' in vm_topo_config %} | ||
{% for ifname, params in vm_topo_config['wan_dut_configuration'][dut_index|int]['interfaces'].items() %} | ||
{% if ifname.startswith('PortChannel') %} | ||
{% if 'ipv4' in params %} | ||
<IPInterface> | ||
<Name i:nil="true"/> | ||
<AttachTo>{{ ifname }}</AttachTo> | ||
<Prefix>{{ params['ipv4'] }}</Prefix> | ||
</IPInterface> | ||
{% endif %} | ||
{% if 'ipv6' in params %} | ||
<IPInterface> | ||
<Name i:Name="true"/> | ||
<AttachTo>{{ ifname }}</AttachTo> | ||
<Prefix>{{ params['ipv6'] }}</Prefix> | ||
</IPInterface> | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
</IPInterfaces> |
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,67 @@ | ||
{% if mux_cable_facts is defined and mux_cable_facts %} | ||
{% if dual_tor_facts is defined and 'cables' in dual_tor_facts %} | ||
{% for cable in dual_tor_facts['cables'] %} | ||
{% set intf_index = port_alias.index(cable['dut_intf'])|string %} | ||
<DeviceDataPlaneInfo> | ||
<IPSecTunnels /> | ||
<LoopbackIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"> | ||
<a:LoopbackIPInterface> | ||
<ElementType>LoopbackInterface</ElementType> | ||
<Name>HostIP</Name> | ||
<AttachTo>Loopback0</AttachTo> | ||
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux"> | ||
<b:IPPrefix>{{ mux_cable_facts[intf_index]['server_ipv4'] }}</b:IPPrefix> | ||
</a:Prefix> | ||
<a:PrefixStr>{{ mux_cable_facts[intf_index]['server_ipv4'] }}</a:PrefixStr> | ||
</a:LoopbackIPInterface> | ||
<a:LoopbackIPInterface> | ||
<ElementType>LoopbackInterface</ElementType> | ||
<Name>HostIP1</Name> | ||
<AttachTo>Loopback0</AttachTo> | ||
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux"> | ||
<b:IPPrefix>{{ mux_cable_facts[intf_index]['server_ipv6'] }}</b:IPPrefix> | ||
</a:Prefix> | ||
<a:PrefixStr>{{ mux_cable_facts[intf_index]['server_ipv6'] }}</a:PrefixStr> | ||
</a:LoopbackIPInterface> | ||
{% if 'soc_ipv4' in mux_cable_facts[intf_index] %} | ||
<a:LoopbackIPInterface> | ||
<ElementType>LoopbackInterface</ElementType> | ||
<Name>SoCHostIP0</Name> | ||
<AttachTo>Servers{{ loop.index - 1 }}SOC</AttachTo> | ||
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux"> | ||
<b:IPPrefix>{{ mux_cable_facts[intf_index]['soc_ipv4'] }}</b:IPPrefix> | ||
</a:Prefix> | ||
<a:PrefixStr>{{ mux_cable_facts[intf_index]['soc_ipv4'] }}</a:PrefixStr> | ||
</a:LoopbackIPInterface> | ||
{% endif %} | ||
{% if 'soc_ipv6' in mux_cable_facts[intf_index] %} | ||
<a:LoopbackIPInterface> | ||
<ElementType>LoopbackInterface</ElementType> | ||
<Name>SoCHostIP1</Name> | ||
<AttachTo>Servers{{ loop.index - 1 }}SOC</AttachTo> | ||
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux"> | ||
<b:IPPrefix>{{ mux_cable_facts[intf_index]['soc_ipv6'] }}</b:IPPrefix> | ||
</a:Prefix> | ||
<a:PrefixStr>{{ mux_cable_facts[intf_index]['soc_ipv6'] }}</a:PrefixStr> | ||
</a:LoopbackIPInterface> | ||
{% endif %} | ||
</LoopbackIPInterfaces> | ||
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution" /> | ||
<ManagementVIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution" /> | ||
<MplsInterfaces /> | ||
<MplsTeInterfaces /> | ||
<RsvpInterfaces /> | ||
<Hostname>Servers{{ loop.index - 1 }}</Hostname> | ||
<PortChannelInterfaces /> | ||
<SubInterfaces /> | ||
<VlanInterfaces /> | ||
<IPInterfaces /> | ||
<DataAcls /> | ||
<AclInterfaces /> | ||
<NatInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution" /> | ||
<DownstreamSummaries /> | ||
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution" /> | ||
</DeviceDataPlaneInfo> | ||
{% endfor %} | ||
{% endif %} | ||
{% endif %} |
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,35 @@ | ||
<VlanInterfaces> | ||
{% if 'tor' in vm_topo_config['dut_type'] | lower %} | ||
{% for vlan, vlan_param in vlan_configs.items() %} | ||
<VlanInterface> | ||
<Name>{{ vlan }}</Name> | ||
{% set vlan_intf_str=';'.join(vlan_param['intfs'] + vlan_param['portchannels']) %} | ||
<AttachTo>{{ vlan_intf_str }}</AttachTo> | ||
<NoDhcpRelay>False</NoDhcpRelay> | ||
<StaticDHCPRelay>0.0.0.0/0</StaticDHCPRelay> | ||
{% if 'type' in vlan_param %} | ||
{% if vlan_param['type']|lower == 'tagged'%} | ||
<Type>Tagged</Type> | ||
{% else %} | ||
<Type i:nil="true"/> | ||
{% endif %} | ||
{% endif %} | ||
{% set dhcp_servers_str=';'.join(dhcp_servers) %} | ||
<DhcpRelays>{{ dhcp_servers_str }}</DhcpRelays> | ||
{% if dhcpv6_servers is defined %} | ||
{% set dhcpv6_servers_str=';'.join(dhcpv6_servers) %} | ||
<Dhcpv6Relays>{{ dhcpv6_servers_str }}</Dhcpv6Relays> | ||
{% endif %} | ||
<VlanID>{{ vlan_param['id'] }}</VlanID> | ||
<Tag>{{ vlan_param['tag'] }}</Tag> | ||
<Subnets>{{ vlan_param['prefix'] | ipaddr('network') }}/{{ vlan_param['prefix'] | ipaddr('prefix') }}</Subnets> | ||
{% if 'secondary_subnet' in vlan_param %} | ||
<SecondarySubnets>{{ vlan_param['secondary_subnet'] | ipaddr('network') }}/{{ vlan_param['secondary_subnet'] | ipaddr('secondary_subnet') }}<SecondarySubnets> | ||
{% endif %} | ||
{% if 'mac' in vlan_param %} | ||
<MacAddress>{{ vlan_param['mac'] }}</MacAddress> | ||
{% endif %} | ||
</VlanInterface> | ||
{% endfor %} | ||
{% endif %} | ||
</VlanInterfaces> |
Oops, something went wrong.