Skip to content

Commit ed1f164

Browse files
committed
[orchagent] Add separate next hop table and orch
**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 <[email protected]>
1 parent ebb723f commit ed1f164

17 files changed

+3870
-641
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ tests/mock_tests/tests.trs
7777
tests/test-suite.log
7878
tests/tests.log
7979
tests/tests.trs
80+
81+
# IDE files #
82+
#############
83+
.vscode

doc/swss-schema.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,29 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
159159
;Status: Mandatory
160160
key = ROUTE_TABLE:prefix
161161
nexthop = *prefix, ;IP addresses separated “,” (empty indicates no gateway)
162-
intf = ifindex? PORT_TABLE.key ; zero or more separated by “,” (zero indicates no interface)
163-
blackhole = BIT ; Set to 1 if this route is a blackhole (or null0)
162+
ifname = ifindex? PORT_TABLE.key ; zero or more separated by “,” (zero indicates no interface)
163+
weight = weight_list ; List of weights.
164+
nexthop_group = string ; index within the NEXT_HOP_GROUP_TABLE, used instead of nexthop and intf fields
165+
166+
---------------------------------------------
167+
168+
###### LABEL_ROUTE_TABLE
169+
; Defines schema for MPLS label route table attributes
170+
key = LABEL_ROUTE_TABLE:mpls_label ; MPLS label
171+
; field = value
172+
nexthop = STRING ; Comma-separated list of nexthops.
173+
ifname = STRING ; Comma-separated list of interfaces.
174+
weight = STRING ; Comma-separated list of weights.
175+
nexthop_group = string ; index within the NEXT_HOP_GROUP_TABLE, used instead of nexthop and intf fields
176+
177+
---------------------------------------------
178+
### NEXT_HOP_GROUP_TABLE
179+
;Stores a list of groups of one or more next hops
180+
;Status: Mandatory
181+
key = NEXT_HOP_GROUP_TABLE:string ; arbitrary index for the next hop group
182+
nexthop = *prefix, ;IP addresses separated “,” (empty indicates no gateway)
183+
ifname = ifindex? PORT_TABLE.key ; zero or more separated by “,” (zero indicates no interface)
184+
weight = weight_list ; List of weights.
164185

165186
---------------------------------------------
166187
### NEIGH_TABLE

orchagent/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ orchagent_SOURCES = \
3232
orchdaemon.cpp \
3333
orch.cpp \
3434
notifications.cpp \
35+
nhgorch.cpp \
3536
routeorch.cpp \
3637
neighorch.cpp \
3738
intfsorch.cpp \

orchagent/fgnhgorch.cpp

+65-65
Large diffs are not rendered by default.

orchagent/neighorch.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "directory.h"
88
#include "muxorch.h"
99
#include "subscriberstatetable.h"
10+
#include "nhgorch.h"
1011

1112
extern sai_neighbor_api_t* sai_neighbor_api;
1213
extern sai_next_hop_api_t* sai_next_hop_api;
@@ -15,6 +16,7 @@ extern PortsOrch *gPortsOrch;
1516
extern sai_object_id_t gSwitchId;
1617
extern CrmOrch *gCrmOrch;
1718
extern RouteOrch *gRouteOrch;
19+
extern NhgOrch *gNhgOrch;
1820
extern FgNhgOrch *gFgNhgOrch;
1921
extern Directory<Orch*> gDirectory;
2022
extern string gMySwitchType;
@@ -322,6 +324,7 @@ bool NeighOrch::setNextHopFlag(const NextHopKey &nexthop, const uint32_t nh_flag
322324
{
323325
case NHFLAGS_IFDOWN:
324326
rc = gRouteOrch->invalidnexthopinNextHopGroup(nexthop, count);
327+
rc &= gNhgOrch->invalidateNextHop(nexthop);
325328
break;
326329
default:
327330
assert(0);
@@ -351,6 +354,7 @@ bool NeighOrch::clearNextHopFlag(const NextHopKey &nexthop, const uint32_t nh_fl
351354
{
352355
case NHFLAGS_IFDOWN:
353356
rc = gRouteOrch->validnexthopinNextHopGroup(nexthop, count);
357+
rc &= gNhgOrch->validateNextHop(nexthop);
354358
break;
355359
default:
356360
assert(0);

orchagent/nexthopkey.h

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "ipaddress.h"
55
#include "tokenize.h"
66
#include "label.h"
7+
#include "intfsorch.h"
78

89
#define LABELSTACK_DELIMITER '+'
910
#define NH_DELIMITER '@'
@@ -32,6 +33,8 @@ struct NextHopKey
3233
NextHopKey(const std::string &str) :
3334
vni(0), mac_address(), outseg_type(SAI_OUTSEG_TYPE_SWAP)
3435
{
36+
SWSS_LOG_ENTER();
37+
3538
if (str.find(NHG_DELIMITER) != string::npos)
3639
{
3740
std::string err = "Error converting " + str + " to NextHop";
@@ -174,6 +177,12 @@ struct NextHopKey
174177
}
175178
return str;
176179
}
180+
181+
// Method to get the underlying IP/interface pair for the next hop.
182+
NextHopKey ipKey() const
183+
{
184+
return NextHopKey(ip_address, alias);
185+
}
177186
};
178187

179188
#endif /* SWSS_NEXTHOPKEY_H */

0 commit comments

Comments
 (0)