Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions orchagent/p4orch/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ p4orch_tests_SOURCES = $(ORCHAGENT_DIR)/orch.cpp \
fake_crmorch.cpp \
fake_flexcounterorch.cpp \
fake_flowcounterrouteorch.cpp \
fake_routeorch.cpp \
fake_dbconnector.cpp \
fake_producertable.cpp \
fake_consumerstatetable.cpp \
Expand Down
24 changes: 24 additions & 0 deletions orchagent/p4orch/tests/fake_routeorch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
extern "C" {
#include <sai.h>
#include <saistatus.h>
}


#include "ipaddress.h"
#include "ipaddresses.h"
#include "ipprefix.h"

#include "orch.h"

class RouteOrch
{
public:
RouteOrch();

void addLinkLocalRouteToMe(sai_object_id_t vrf_id, swss::IpPrefix linklocal_prefix);
void delLinkLocalRouteToMe(sai_object_id_t vrf_id, swss::IpPrefix linklocal_prefix);
};

RouteOrch::RouteOrch() {};
void RouteOrch::addLinkLocalRouteToMe(sai_object_id_t vrf_id, swss::IpPrefix linklocal_prefix) {};
void RouteOrch::delLinkLocalRouteToMe(sai_object_id_t vrf_id, swss::IpPrefix linklocal_prefix) {};
2 changes: 2 additions & 0 deletions orchagent/p4orch/tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern "C"
#include "mock_sai_virtual_router.h"
#include "p4orch.h"
#include "portsorch.h"
#include "routeorch.h"
#include "sai_serialize.h"
#include "switchorch.h"
#include "vrforch.h"
Expand Down Expand Up @@ -52,6 +53,7 @@ CrmOrch *gCrmOrch;
P4Orch *gP4Orch;
VRFOrch *gVrfOrch;
FlowCounterRouteOrch *gFlowCounterRouteOrch;
RouteOrch *gRouteOrch;
SwitchOrch *gSwitchOrch;
Directory<Orch *> gDirectory;
swss::DBConnector *gAppDb;
Expand Down
13 changes: 13 additions & 0 deletions orchagent/vrforch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "sai.h"
#include "macaddress.h"
#include "orch.h"
#include "routeorch.h"
#include "request_parser.h"
#include "vrforch.h"
#include "vxlanorch.h"
Expand All @@ -22,6 +23,7 @@ extern sai_object_id_t gSwitchId;

extern Directory<Orch*> gDirectory;
extern PortsOrch* gPortsOrch;
extern RouteOrch* gRouteOrch;
extern FlowCounterRouteOrch* gFlowCounterRouteOrch;

bool VRFOrch::addOperation(const Request& request)
Expand Down Expand Up @@ -108,6 +110,12 @@ bool VRFOrch::addOperation(const Request& request)
vrf_table_[vrf_name].ref_count = 0;
vrf_id_table_[router_id] = vrf_name;
gFlowCounterRouteOrch->onAddVR(router_id);
if (gRouteOrch != nullptr) {
IpPrefix default_link_local_prefix("fe80::/10");
gRouteOrch->addLinkLocalRouteToMe(router_id, default_link_local_prefix);
SWSS_LOG_NOTICE("Created link local ipv6 route %s to cpu for VRF '%s'",
default_link_local_prefix.to_string().c_str(), vrf_name.c_str());
}
if (vni != 0)
{
SWSS_LOG_INFO("VRF '%s' vni %d add", vrf_name.c_str(), vni);
Expand Down Expand Up @@ -170,6 +178,11 @@ bool VRFOrch::delOperation(const Request& request)
return false;

sai_object_id_t router_id = vrf_table_[vrf_name].vrf_id;
// Delete link-local routes before removing VRF
if (gRouteOrch != nullptr) {
IpPrefix default_link_local_prefix("fe80::/10");
gRouteOrch->delLinkLocalRouteToMe(router_id, default_link_local_prefix);
}
sai_status_t status = sai_virtual_router_api->remove_virtual_router(router_id);
if (status != SAI_STATUS_SUCCESS)
{
Expand Down
Loading