From 8857f926aa5c1788dd587e768e8c6c1f69305f01 Mon Sep 17 00:00:00 2001 From: siqbal1986 Date: Wed, 11 Jan 2023 13:21:27 -0800 Subject: [PATCH] Added new attributes for Vnet and Vxlan ecmp configurations. (#2584) * added support for monitoring, primary and adv_prefix and overlay_dmac. Signed-off-by: siqbal1486 Signed-off-by: siqbal1486 --- orchagent/vnetorch.cpp | 23 +++++++++++++++++++++-- orchagent/vnetorch.h | 15 ++++++++++++++- tests/test_vnet.py | 24 ++++++++++++++++++------ 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/orchagent/vnetorch.cpp b/orchagent/vnetorch.cpp index 645abdd204b6..708dcde4ce5a 100644 --- a/orchagent/vnetorch.cpp +++ b/orchagent/vnetorch.cpp @@ -429,6 +429,7 @@ bool VNetOrch::addOperation(const Request& request) uint32_t vni=0; string tunnel; string scope; + swss::MacAddress overlay_dmac; for (const auto& name: request.getAttrFieldNames()) { @@ -460,6 +461,10 @@ bool VNetOrch::addOperation(const Request& request) { advertise_prefix = request.getAttrBool("advertise_prefix"); } + else if (name == "overlay_dmac") + { + overlay_dmac = request.getAttrMacAddress("overlay_dmac"); + } else { SWSS_LOG_INFO("Unknown attribute: %s", name.c_str()); @@ -486,7 +491,7 @@ bool VNetOrch::addOperation(const Request& request) if (it == std::end(vnet_table_)) { - VNetInfo vnet_info = { tunnel, vni, peer_list, scope, advertise_prefix }; + VNetInfo vnet_info = { tunnel, vni, peer_list, scope, advertise_prefix, overlay_dmac }; obj = createObject(vnet_name, vnet_info, attrs); create = true; @@ -1917,7 +1922,9 @@ bool VNetRouteOrch::handleTunnel(const Request& request) vector vni_list; vector monitor_list; string profile = ""; - + vector primary_list; + string monitoring; + swss::IpPrefix adv_prefix; for (const auto& name: request.getAttrFieldNames()) { if (name == "endpoint") @@ -1942,6 +1949,18 @@ bool VNetRouteOrch::handleTunnel(const Request& request) { profile = request.getAttrString(name); } + else if (name == "primary") + { + primary_list = request.getAttrIPList(name); + } + else if (name == "monitoring") + { + monitoring = request.getAttrString(name); + } + else if (name == "adv_prefix") + { + adv_prefix = request.getAttrIpPrefix(name); + } else { SWSS_LOG_INFO("Unknown attribute: %s", name.c_str()); diff --git a/orchagent/vnetorch.h b/orchagent/vnetorch.h index 4f63764a0ee2..9c950c265f5e 100644 --- a/orchagent/vnetorch.h +++ b/orchagent/vnetorch.h @@ -34,6 +34,8 @@ const request_description_t vnet_request_description = { { "guid", REQ_T_STRING }, { "scope", REQ_T_STRING }, { "advertise_prefix", REQ_T_BOOL}, + { "overlay_dmac", REQ_T_MAC_ADDRESS}, + }, { "vxlan_tunnel", "vni" } // mandatory attributes }; @@ -59,6 +61,7 @@ struct VNetInfo set peers; string scope; bool advertise_prefix; + swss::MacAddress overlay_dmac; }; typedef map vrid_list_t; @@ -86,7 +89,8 @@ class VNetObject peer_list_(vnetInfo.peers), vni_(vnetInfo.vni), scope_(vnetInfo.scope), - advertise_prefix_(vnetInfo.advertise_prefix) + advertise_prefix_(vnetInfo.advertise_prefix), + overlay_dmac_(vnetInfo.overlay_dmac) { } virtual bool updateObj(vector&) = 0; @@ -121,6 +125,11 @@ class VNetObject return advertise_prefix_; } + swss::MacAddress getOverlayDMac() const + { + return overlay_dmac_; + } + virtual ~VNetObject() noexcept(false) {}; private: @@ -129,6 +138,7 @@ class VNetObject uint32_t vni_; string scope_; bool advertise_prefix_; + swss::MacAddress overlay_dmac_; }; struct nextHop @@ -282,6 +292,9 @@ const request_description_t vnet_route_description = { { "mac_address", REQ_T_STRING }, { "endpoint_monitor", REQ_T_IP_LIST }, { "profile", REQ_T_STRING }, + { "primary", REQ_T_IP_LIST }, + { "monitoring", REQ_T_STRING }, + { "adv_prefix", REQ_T_IP_PREFIX }, }, { } }; diff --git a/tests/test_vnet.py b/tests/test_vnet.py index 9aba590ec10d..6b4fc175a322 100644 --- a/tests/test_vnet.py +++ b/tests/test_vnet.py @@ -140,11 +140,11 @@ def delete_vnet_local_routes(dvs, prefix, vnet_name): time.sleep(2) -def create_vnet_routes(dvs, prefix, vnet_name, endpoint, mac="", vni=0, ep_monitor="", profile=""): - set_vnet_routes(dvs, prefix, vnet_name, endpoint, mac=mac, vni=vni, ep_monitor=ep_monitor, profile=profile) +def create_vnet_routes(dvs, prefix, vnet_name, endpoint, mac="", vni=0, ep_monitor="", profile="", primary="", monitoring="", adv_prefix=""): + set_vnet_routes(dvs, prefix, vnet_name, endpoint, mac=mac, vni=vni, ep_monitor=ep_monitor, profile=profile, primary=primary, monitoring=monitoring, adv_prefix=adv_prefix) -def set_vnet_routes(dvs, prefix, vnet_name, endpoint, mac="", vni=0, ep_monitor="", profile=""): +def set_vnet_routes(dvs, prefix, vnet_name, endpoint, mac="", vni=0, ep_monitor="", profile="", primary="", monitoring="", adv_prefix=""): conf_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) attrs = [ @@ -163,6 +163,15 @@ def set_vnet_routes(dvs, prefix, vnet_name, endpoint, mac="", vni=0, ep_monitor= if profile: attrs.append(('profile', profile)) + if primary: + attrs.append(('primary', primary)) + + if monitoring: + attrs.append(('monitoring', monitoring)) + + if adv_prefix: + attrs.append(('adv_prefix', adv_prefix)) + tbl = swsscommon.Table(conf_db, "VNET_ROUTE_TUNNEL") fvs = swsscommon.FieldValuePairs(attrs) tbl.set("%s|%s" % (vnet_name, prefix), fvs) @@ -317,7 +326,7 @@ def delete_phy_interface(dvs, ifname, ipaddr): time.sleep(2) -def create_vnet_entry(dvs, name, tunnel, vni, peer_list, scope="", advertise_prefix=False): +def create_vnet_entry(dvs, name, tunnel, vni, peer_list, scope="", advertise_prefix=False, overlay_dmac=""): conf_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) @@ -333,6 +342,9 @@ def create_vnet_entry(dvs, name, tunnel, vni, peer_list, scope="", advertise_pre if advertise_prefix: attrs.append(('advertise_prefix', 'true')) + if overlay_dmac: + attrs.append(('overlay_dmac', overlay_dmac)) + # create the VXLAN tunnel Term entry in Config DB create_entry_tbl( conf_db, @@ -2364,7 +2376,7 @@ def test_vnet_orch_17(self, dvs, testlog): vnet_obj.fetch_exist_entries(dvs) create_vxlan_tunnel(dvs, tunnel_name, '9.9.9.9') - create_vnet_entry(dvs, 'Vnet17', tunnel_name, '10009', "") + create_vnet_entry(dvs, 'Vnet17', tunnel_name, '10009', "", overlay_dmac="22:33:33:44:44:66") vnet_obj.check_vnet_entry(dvs, 'Vnet17') vnet_obj.check_vxlan_tunnel_entry(dvs, tunnel_name, 'Vnet17', '10009') @@ -2372,7 +2384,7 @@ def test_vnet_orch_17(self, dvs, testlog): vnet_obj.check_vxlan_tunnel(dvs, tunnel_name, '9.9.9.9') vnet_obj.fetch_exist_entries(dvs) - create_vnet_routes(dvs, "100.100.1.1/32", 'Vnet17', '9.0.0.1,9.0.0.2,9.0.0.3', ep_monitor='9.1.0.1,9.1.0.2,9.1.0.3') + create_vnet_routes(dvs, "100.100.1.1/32", 'Vnet17', '9.0.0.1,9.0.0.2,9.0.0.3', ep_monitor='9.1.0.1,9.1.0.2,9.1.0.3', primary ='9.0.0.1',monitoring='custom', adv_prefix='100.100.1.1/27') # default bfd status is down, route should not be programmed in this status vnet_obj.check_del_vnet_routes(dvs, 'Vnet17', ["100.100.1.1/32"])