Skip to content

Commit

Permalink
[orchagent] Add separate next hop table and orch
Browse files Browse the repository at this point in the history
**What I did**
Added a new next hop group table to APP_DB, and orchagent support
to use this as an alternative to including next hop information in
the route table

**Why I did it**
Improves performance and occupancy usage when using the new table

**How I verified it**
Extended SWSS unit tests to cover new code, and ran existing tests

Signed-off-by: Thomas Cappleman <thomas.cappleman@metaswitch.com>
  • Loading branch information
TACappleman committed Apr 9, 2021
1 parent 89e2044 commit df41c2c
Show file tree
Hide file tree
Showing 17 changed files with 3,891 additions and 610 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ tests/mock_tests/tests.trs
tests/test-suite.log
tests/tests.log
tests/tests.trs

# IDE files #
#############
.vscode
25 changes: 23 additions & 2 deletions doc/swss-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,29 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
;Status: Mandatory
key = ROUTE_TABLE:prefix
nexthop = *prefix, ;IP addresses separated “,” (empty indicates no gateway)
intf = ifindex? PORT_TABLE.key ; zero or more separated by “,” (zero indicates no interface)
blackhole = BIT ; Set to 1 if this route is a blackhole (or null0)
ifname = ifindex? PORT_TABLE.key ; zero or more separated by “,” (zero indicates no interface)
weight = weight_list ; List of weights.
nexthop_group = string ; index within the NEXT_HOP_GROUP_TABLE, used instead of nexthop and intf fields

---------------------------------------------

###### LABEL_ROUTE_TABLE
; Defines schema for MPLS label route table attributes
key = LABEL_ROUTE_TABLE:mpls_label ; MPLS label
; field = value
nexthop = STRING ; Comma-separated list of nexthops.
ifname = STRING ; Comma-separated list of interfaces.
weight = STRING ; Comma-separated list of weights.
nexthop_group = string ; index within the NEXT_HOP_GROUP_TABLE, used instead of nexthop and intf fields

---------------------------------------------
### NEXT_HOP_GROUP_TABLE
;Stores a list of groups of one or more next hops
;Status: Mandatory
key = NEXT_HOP_GROUP_TABLE:string ; arbitrary index for the next hop group
nexthop = *prefix, ;IP addresses separated “,” (empty indicates no gateway)
ifname = ifindex? PORT_TABLE.key ; zero or more separated by “,” (zero indicates no interface)
weight = weight_list ; List of weights.

---------------------------------------------
### NEIGH_TABLE
Expand Down
1 change: 1 addition & 0 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ orchagent_SOURCES = \
orchdaemon.cpp \
orch.cpp \
notifications.cpp \
nhgorch.cpp \
routeorch.cpp \
neighorch.cpp \
intfsorch.cpp \
Expand Down
132 changes: 66 additions & 66 deletions orchagent/fgnhgorch.cpp

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "directory.h"
#include "muxorch.h"
#include "subscriberstatetable.h"
#include "nhgorch.h"

extern sai_neighbor_api_t* sai_neighbor_api;
extern sai_next_hop_api_t* sai_next_hop_api;
Expand All @@ -15,6 +16,7 @@ extern PortsOrch *gPortsOrch;
extern sai_object_id_t gSwitchId;
extern CrmOrch *gCrmOrch;
extern RouteOrch *gRouteOrch;
extern NhgOrch *gNhgOrch;
extern FgNhgOrch *gFgNhgOrch;
extern Directory<Orch*> gDirectory;
extern string gMySwitchType;
Expand All @@ -31,7 +33,7 @@ NeighOrch::NeighOrch(DBConnector *appDb, string tableName, IntfsOrch *intfsOrch,
SWSS_LOG_ENTER();

m_fdbOrch->attach(this);

if(gMySwitchType == "voq")
{
//Add subscriber to process VOQ system neigh
Expand Down Expand Up @@ -149,10 +151,12 @@ bool NeighOrch::hasNextHop(const NextHopKey &nexthop)
return m_syncdNextHops.find(nexthop) != m_syncdNextHops.end();
}

bool NeighOrch::addNextHop(NextHopKey &nexthop)
bool NeighOrch::addNextHop(const NextHopKey &const_nexthop)
{
SWSS_LOG_ENTER();

NextHopKey nexthop = {const_nexthop.ip_address, const_nexthop.alias};

Port p;
if (!gPortsOrch->getPort(nexthop.alias, p))
{
Expand Down Expand Up @@ -283,6 +287,7 @@ bool NeighOrch::setNextHopFlag(const NextHopKey &nexthop, const uint32_t nh_flag
{
case NHFLAGS_IFDOWN:
rc = gRouteOrch->invalidnexthopinNextHopGroup(nexthop, count);
rc &= gNhgOrch->invalidateNextHop(nexthop);
break;
default:
assert(0);
Expand Down Expand Up @@ -312,6 +317,7 @@ bool NeighOrch::clearNextHopFlag(const NextHopKey &nexthop, const uint32_t nh_fl
{
case NHFLAGS_IFDOWN:
rc = gRouteOrch->validnexthopinNextHopGroup(nexthop, count);
rc &= gNhgOrch->validateNextHop(nexthop);
break;
default:
assert(0);
Expand Down Expand Up @@ -371,10 +377,12 @@ bool NeighOrch::ifChangeInformNextHop(const string &alias, bool if_up)
return rc;
}

bool NeighOrch::removeNextHop(NextHopKey& nexthop)
bool NeighOrch::removeNextHop(const NextHopKey& const_nexthop)
{
SWSS_LOG_ENTER();

NextHopKey nexthop = {const_nexthop.ip_address, const_nexthop.alias};

if(m_intfsOrch->isRemoteSystemPortIntf(nexthop.alias))
{
//For remote system ports kernel nexthops are always on inband. Change the key
Expand Down Expand Up @@ -874,7 +882,7 @@ bool NeighOrch::removeNeighbor(const NeighborEntry &neighborEntry, bool disable)

NeighborUpdate update = { neighborEntry, MacAddress(), false };
notify(SUBJECT_TYPE_NEIGH_CHANGE, static_cast<void *>(&update));

if(gMySwitchType == "voq")
{
//Sync the neighbor to delete from the CHASSIS_APP_DB
Expand Down
4 changes: 2 additions & 2 deletions orchagent/neighorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class NeighOrch : public Orch, public Subject, public Observer
~NeighOrch();

bool hasNextHop(const NextHopKey&);
bool addNextHop(NextHopKey&);
bool removeNextHop(NextHopKey&);
bool addNextHop(const NextHopKey&);
bool removeNextHop(const NextHopKey&);

sai_object_id_t getNextHopId(const NextHopKey&);
sai_object_id_t getLocalNextHopId(const NextHopKey&);
Expand Down
12 changes: 12 additions & 0 deletions orchagent/nexthopkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "ipaddress.h"
#include "tokenize.h"
#include "label.h"
#include "intfsorch.h"

#define NH_DELIMITER '@'
#define NHG_DELIMITER ','
Expand All @@ -23,6 +24,8 @@ struct NextHopKey
NextHopKey(const IpAddress &ip, const std::string &alias) : ip_address(ip), alias(alias), vni(0), mac_address() {}
NextHopKey(const std::string &str)
{
SWSS_LOG_ENTER();

if (str.find(NHG_DELIMITER) != string::npos)
{
std::string err = "Error converting " + str + " to NextHop";
Expand All @@ -32,16 +35,19 @@ struct NextHopKey
std::string ip_str;
if (label_delimiter != std::string::npos)
{
SWSS_LOG_INFO("Labeled next hop");
label_stack = LabelStack(str.substr(0, label_delimiter));
ip_str = str.substr(label_delimiter+1);
}
else
{
SWSS_LOG_INFO("Unlabeled next hop");
ip_str = str;
}
auto keys = tokenize(ip_str, NH_DELIMITER);
vni = 0;
mac_address = MacAddress();

if (keys.size() == 1)
{
ip_address = keys[0];
Expand All @@ -62,6 +68,7 @@ struct NextHopKey
throw std::invalid_argument(err);
}
}

NextHopKey(const std::string &str, bool overlay_nh)
{
if (str.find(NHG_DELIMITER) != string::npos)
Expand Down Expand Up @@ -136,6 +143,11 @@ struct NextHopKey
{
return (ip_address.getV4Addr() == 0);
}

NextHopKey ipKey() const
{
return NextHopKey(ip_address, alias);
}
};

#endif /* SWSS_NEXTHOPKEY_H */
Loading

0 comments on commit df41c2c

Please sign in to comment.