Skip to content

VNet/Vxlan delete handling#766

Merged
prsunny merged 6 commits intosonic-net:masterfrom
prsunny:vnet_del
Feb 7, 2019
Merged

VNet/Vxlan delete handling#766
prsunny merged 6 commits intosonic-net:masterfrom
prsunny:vnet_del

Conversation

@prsunny
Copy link
Copy Markdown
Collaborator

@prsunny prsunny commented Jan 24, 2019

What I did
Delete handling for VNet Routes, NH tunnels and VNets

Why I did it
To support deletion scenarios

How I verified it
Tested on DUT. VS test case would be added subsequently

Details if related
Based on design sonic-net/SONiC#324

Copy link
Copy Markdown
Collaborator

@marian-pritsak marian-pritsak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments


VNetVrfObject::VNetVrfObject(const std::string& vnet, string& tunnel, set<string>& peer,
vector<sai_attribute_t>& attrs) : VNetObject(tunnel, peer)
VNetVrfObject::VNetVrfObject(const std::string& vnet, string& tunnel, set<string>& peer, uint32_t vni,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is worth considering grouping all these parameters into a single struct VnetInfo?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed


if (!vxlan_orch->removeVxlanTunnelMap(vrf_obj->getTunnelName(), vrf_obj->getVni()))
{
SWSS_LOG_ERROR("VNET '%s' map delete failed", vnet_name.c_str());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SWSS_LOG_ERROR("VNET '%s' map delete failed", vnet_name.c_str()); [](start = 16, length = 65)

why no return false here?

return true;
}

bool subnet = (!nh.ips.getSize())?true:false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subnet [](start = 9, length = 6)

->isSubnet

throw std::runtime_error("Route add failed");
throw std::runtime_error("Route update failed");
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is else condition? do we need to print warning, log, ???

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else case is handled by the Bitmap implementation. So it is left intentionally.

if (!doRouteTask<VNetVrfObject>(vnet_name, ip_pfx, nh, op))
{
throw std::runtime_error("Route add failed");
throw std::runtime_error("Route update failed");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw std::runtime_error("Route update failed"); [](start = 10, length = 50)

it looks to me it is dangerous to crash here. what if the nexthop interface is not created yet in the doRouteTask.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the routeorch.cpp, it does not throw error, if add or delete route fails.


In reply to: 253250419 [](ancestors = 253250419)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just retry.


In reply to: 253250430 [](ancestors = 253250430,253250419)

return (routes_.size() + tunnels_.size());
}

bool VNetVrfObject::getRouteNH(IpPrefix& ipPrefix, nextHop& nh)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> getRouteNexthop

return true;
}

sai_object_id_t VNetVrfObject::getNextHop(tunnelEndpoint& endp)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getNextHop [](start = 31, length = 10)

-> getTunnelNexthop

return nh_id;
}

bool VNetVrfObject::removeNextHop(tunnelEndpoint& endp)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removeTunnelNexthop


if (!vxlan_orch->removeNextHopTunnel(tun_name, endp.ip, endp.mac, endp.vni))
{
SWSS_LOG_ERROR("VNET %s NH remove failed for '%s'", vnet_name_.c_str(), endp.ip.to_string().c_str());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NH [](start = 32, length = 2)

-> tunnel nexthop

auto tunnel_obj = getVxlanTunnel(tunnelName);

//Delete request for the nh tunnel id
return tunnel_obj->removeNHTunnel(ipAddr, macAddress, vni);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removeNHTunnel [](start = 23, length = 14)

since it is already a tunnel object, you do not need tunnel in the function name. -> removeNexthop

return ids_.tunnel_encap_id;
}

void updateNHTunnel(IpAddress& ipAddr, MacAddress macAddress, uint32_t vni, sai_object_id_t nh_id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> updateNexthop

@lguohan
Copy link
Copy Markdown
Contributor

lguohan commented Feb 2, 2019

sai_status_t status = sai_route_api->create_route_entry(&route_entry, 1, &route_attr);

we should probably increase the crm counter.

     if (route_entry.destination.addr_family == SAI_IP_ADDR_FAMILY_IPV4)

823 {
824 gCrmOrch->incCrmResUsedCounter(CrmResourceType::CRM_IPV4_ROUTE);
825 }
826 else
827 {
828 gCrmOrch->incCrmResUsedCounter(CrmResourceType::CRM_IPV6_ROUTE);
829 }


Refers to: orchagent/vnetorch.cpp:484 in 91d77df. [](commit_id = 91d77df, deletion_comment = False)

@prsunny prsunny merged commit 6d5424d into sonic-net:master Feb 7, 2019
@prsunny prsunny deleted the vnet_del branch March 19, 2020 01:33
EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
Added breakout subcommand in config command

Signed-off-by: Sangita Maity <[email protected]>
oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-swss that referenced this pull request Mar 1, 2023
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
* Route/NH and VNet delete handling

* Handle VNET Route with Nexthop IP, fix route remove

* Address review comments, increment CRM counters,
jianyuewu pushed a commit to jianyuewu/sonic-swss that referenced this pull request Dec 24, 2025
…et#766)

This is to support adding custom observers to the swss logger.
With restartLogger, now applications could start logger with the following lines:

linkToDb(demoDb, myCustomPrioNotify, defaultPrio);
restartLogger()
Signed-off-by: Longxiang Lyu [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants