Skip to content

Commit

Permalink
[vxlanorch]: Allow ipv6 src ip for Vxlan tunnel creation (sonic-net#896)
Browse files Browse the repository at this point in the history
* [vxlanorch]: Allow ipv6 src ip for Vxlan tunnel creation

Signed-off-by: Anish Narsian anish.narsian@microsoft.com
  • Loading branch information
anish-n authored and lguohan committed Jun 19, 2019
1 parent 407d048 commit 9778374
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 10 deletions.
19 changes: 9 additions & 10 deletions orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,26 +656,25 @@ bool VxlanTunnelOrch::addOperation(const Request& request)
SWSS_LOG_ENTER();

auto src_ip = request.getAttrIP("src_ip");
if (!src_ip.isV4())
{
SWSS_LOG_ERROR("Wrong format of the attribute: 'src_ip'. Currently only IPv4 address is supported");
return true;
}

IpAddress dst_ip;
auto attr_names = request.getAttrFieldNames();
if (attr_names.count("dst_ip") == 0)
{
dst_ip = IpAddress("0.0.0.0");
if(src_ip.isV4()) {
dst_ip = IpAddress("0.0.0.0");
} else {
dst_ip = IpAddress("::");
}
}
else
{
dst_ip = request.getAttrIP("dst_ip");
if (!dst_ip.isV4())
{
SWSS_LOG_ERROR("Wrong format of the attribute: 'dst_ip'. Currently only IPv4 address is supported");
if((src_ip.isV4() && !dst_ip.isV4()) ||
(!src_ip.isV4() && dst_ip.isV4())) {
SWSS_LOG_ERROR("Format mismatch: 'src_ip' and 'dst_ip' must be of the same family");
return true;
}
}
}

const auto& tunnel_name = request.getKeyString(0);
Expand Down
115 changes: 115 additions & 0 deletions tests/test_vnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,3 +1169,118 @@ def test_vnet_orch_3(self, dvs, testlog):
delete_vnet_entry(dvs, 'Vnet_20')
vnet_obj.check_del_vnet_entry(dvs, 'Vnet_20')

'''
Test 4 - IPv6 Vxlan tunnel test
'''
@pytest.mark.skip(reason="Failing. Under investigation")
def test_vnet_orch_4(self, dvs, testlog):
vnet_obj = self.get_vnet_obj()

tunnel_name = 'tunnel_v6'

vnet_obj.fetch_exist_entries(dvs)

create_vxlan_tunnel(dvs, tunnel_name, 'fd:2::32')
create_vnet_entry(dvs, 'Vnet3001', tunnel_name, '3001', "")

vnet_obj.check_vnet_entry(dvs, 'Vnet3001')
vnet_obj.check_vxlan_tunnel_entry(dvs, tunnel_name, 'Vnet3001', '3001')
vnet_obj.check_vxlan_tunnel(dvs, tunnel_name, 'fd:2::32')

vid = create_vlan_interface(dvs, "Vlan300", "Ethernet24", 'Vnet3001', "100.100.3.1/24")
vnet_obj.check_router_interface(dvs, 'Vnet3001', vid)

vid = create_vlan_interface(dvs, "Vlan301", "Ethernet28", 'Vnet3001', "100.100.4.1/24")
vnet_obj.check_router_interface(dvs, 'Vnet3001', vid)

create_vnet_routes(dvs, "100.100.1.1/32", 'Vnet3001', '2000:1000:2000:3000:4000:5000:6000:7000')
vnet_obj.check_vnet_routes(dvs, 'Vnet3001', '2000:1000:2000:3000:4000:5000:6000:7000', tunnel_name)

create_vnet_routes(dvs, "100.100.1.2/32", 'Vnet3001', '2000:1000:2000:3000:4000:5000:6000:7000')
vnet_obj.check_vnet_routes(dvs, 'Vnet3001', '2000:1000:2000:3000:4000:5000:6000:7000', tunnel_name)

create_vnet_local_routes(dvs, "100.100.3.0/24", 'Vnet3001', 'Vlan300')
vnet_obj.check_vnet_local_routes(dvs, 'Vnet3001')

create_vnet_local_routes(dvs, "100.100.4.0/24", 'Vnet3001', 'Vlan301')
vnet_obj.check_vnet_local_routes(dvs, 'Vnet3001')

#Create Physical Interface in another Vnet

create_vnet_entry(dvs, 'Vnet3002', tunnel_name, '3002', "")

vnet_obj.check_vnet_entry(dvs, 'Vnet3002')
vnet_obj.check_vxlan_tunnel_entry(dvs, tunnel_name, 'Vnet3002', '3002')

create_phy_interface(dvs, "Ethernet60", 'Vnet3002', "100.102.1.1/24")
vnet_obj.check_router_interface(dvs, 'Vnet3002')

create_vnet_routes(dvs, "100.100.2.1/32", 'Vnet3002', 'fd:2::34', "00:12:34:56:78:9A")
vnet_obj.check_vnet_routes(dvs, 'Vnet3002', 'fd:2::34', tunnel_name, "00:12:34:56:78:9A")

create_vnet_local_routes(dvs, "100.102.1.0/24", 'Vnet3002', 'Ethernet60')
vnet_obj.check_vnet_local_routes(dvs, 'Vnet3002')

# Test peering
create_vnet_entry(dvs, 'Vnet3003', tunnel_name, '3003', 'Vnet3004')

vnet_obj.check_vnet_entry(dvs, 'Vnet3003', ['Vnet3004'])
vnet_obj.check_vxlan_tunnel_entry(dvs, tunnel_name, 'Vnet3003', '3003')

create_vnet_entry(dvs, 'Vnet3004', tunnel_name, '3004', 'Vnet3003')

vnet_obj.check_vnet_entry(dvs, 'Vnet3004', ['Vnet3003'])
vnet_obj.check_vxlan_tunnel_entry(dvs, tunnel_name, 'Vnet3004', '3004')

create_vnet_routes(dvs, "5.5.5.10/32", 'Vnet3003', 'fd:2::35')
vnet_obj.check_vnet_routes(dvs, 'Vnet3004', 'fd:2::35', tunnel_name)

create_vnet_routes(dvs, "8.8.8.10/32", 'Vnet3004', 'fd:2::36')
vnet_obj.check_vnet_routes(dvs, 'Vnet3003', 'fd:2::36', tunnel_name)

# Clean-up and verify remove flows

delete_vnet_routes(dvs, "5.5.5.10/32", 'Vnet3003')
vnet_obj.check_del_vnet_routes(dvs, 'Vnet3003')

delete_vnet_routes(dvs, "8.8.8.10/32", 'Vnet3004')
vnet_obj.check_del_vnet_routes(dvs, 'Vnet3004')

delete_vnet_entry(dvs, 'Vnet3003')
vnet_obj.check_del_vnet_entry(dvs, 'Vnet3003')

delete_vnet_entry(dvs, 'Vnet3004')
vnet_obj.check_del_vnet_entry(dvs, 'Vnet3004')

delete_vnet_routes(dvs, "100.100.2.1/24", 'Vnet3002')
vnet_obj.check_del_vnet_routes(dvs, 'Vnet3002')

delete_vnet_local_routes(dvs, "100.102.1.0/24", 'Vnet3002')
vnet_obj.check_del_vnet_local_routes(dvs, 'Vnet3002')

delete_phy_interface(dvs, "Ethernet60", "100.102.1.1/24")
vnet_obj.check_del_router_interface(dvs, "Ethernet60")

delete_vnet_entry(dvs, 'Vnet3002')
vnet_obj.check_del_vnet_entry(dvs, 'Vnet3002')

delete_vnet_local_routes(dvs, "100.100.3.0/24", 'Vnet3001')
vnet_obj.check_del_vnet_local_routes(dvs, 'Vnet3001')

delete_vnet_local_routes(dvs, "100.100.4.0/24", 'Vnet3001')
vnet_obj.check_del_vnet_local_routes(dvs, 'Vnet3001')

delete_vnet_routes(dvs, "100.100.1.1/32", 'Vnet3001')
vnet_obj.check_del_vnet_routes(dvs, 'Vnet3001')

delete_vnet_routes(dvs, "100.100.1.2/32", 'Vnet3001')
vnet_obj.check_del_vnet_routes(dvs, 'Vnet3001')

delete_vlan_interface(dvs, "Vlan300", "100.100.3.1/24")
vnet_obj.check_del_router_interface(dvs, "Vlan300")

delete_vlan_interface(dvs, "Vlan301", "100.100.4.1/24")
vnet_obj.check_del_router_interface(dvs, "Vlan301")

delete_vnet_entry(dvs, 'Vnet3001')
vnet_obj.check_del_vnet_entry(dvs, 'Vnet3001')

0 comments on commit 9778374

Please sign in to comment.