Skip to content

Commit

Permalink
Added new attributes for Vnet and Vxlan ecmp configurations. (sonic-n…
Browse files Browse the repository at this point in the history
…et#2584)

* added support for monitoring, primary and adv_prefix and overlay_dmac.

Signed-off-by: siqbal1486 <[email protected]>

Signed-off-by: siqbal1486 <[email protected]>
  • Loading branch information
siqbal1986 authored Jan 11, 2023
1 parent b6bbc3e commit 8857f92
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
23 changes: 21 additions & 2 deletions orchagent/vnetorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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());
Expand All @@ -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<VNetVrfObject>(vnet_name, vnet_info, attrs);
create = true;

Expand Down Expand Up @@ -1917,7 +1922,9 @@ bool VNetRouteOrch::handleTunnel(const Request& request)
vector<string> vni_list;
vector<IpAddress> monitor_list;
string profile = "";

vector<IpAddress> primary_list;
string monitoring;
swss::IpPrefix adv_prefix;
for (const auto& name: request.getAttrFieldNames())
{
if (name == "endpoint")
Expand All @@ -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());
Expand Down
15 changes: 14 additions & 1 deletion orchagent/vnetorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -59,6 +61,7 @@ struct VNetInfo
set<string> peers;
string scope;
bool advertise_prefix;
swss::MacAddress overlay_dmac;
};

typedef map<VR_TYPE, sai_object_id_t> vrid_list_t;
Expand Down Expand Up @@ -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<sai_attribute_t>&) = 0;
Expand Down Expand Up @@ -121,6 +125,11 @@ class VNetObject
return advertise_prefix_;
}

swss::MacAddress getOverlayDMac() const
{
return overlay_dmac_;
}

virtual ~VNetObject() noexcept(false) {};

private:
Expand All @@ -129,6 +138,7 @@ class VNetObject
uint32_t vni_;
string scope_;
bool advertise_prefix_;
swss::MacAddress overlay_dmac_;
};

struct nextHop
Expand Down Expand Up @@ -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 },
},
{ }
};
Expand Down
24 changes: 18 additions & 6 deletions tests/test_vnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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,
Expand Down Expand Up @@ -2364,15 +2376,15 @@ 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')

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"])
Expand Down

0 comments on commit 8857f92

Please sign in to comment.