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 May 25, 2021
1 parent ebb723f commit b433ea3
Show file tree
Hide file tree
Showing 17 changed files with 3,869 additions and 641 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 @@ -32,6 +32,7 @@ orchagent_SOURCES = \
orchdaemon.cpp \
orch.cpp \
notifications.cpp \
nhgorch.cpp \
routeorch.cpp \
neighorch.cpp \
intfsorch.cpp \
Expand Down
130 changes: 65 additions & 65 deletions orchagent/fgnhgorch.cpp

Large diffs are not rendered by default.

4 changes: 4 additions & 0 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 Down Expand Up @@ -322,6 +324,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 @@ -351,6 +354,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
8 changes: 8 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 LABELSTACK_DELIMITER '+'
#define NH_DELIMITER '@'
Expand Down Expand Up @@ -32,6 +33,8 @@ struct NextHopKey
NextHopKey(const std::string &str) :
vni(0), mac_address(), outseg_type(SAI_OUTSEG_TYPE_SWAP)
{
SWSS_LOG_ENTER();

if (str.find(NHG_DELIMITER) != string::npos)
{
std::string err = "Error converting " + str + " to NextHop";
Expand Down Expand Up @@ -174,6 +177,11 @@ struct NextHopKey
}
return str;
}

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

#endif /* SWSS_NEXTHOPKEY_H */
Loading

0 comments on commit b433ea3

Please sign in to comment.