Skip to content

Commit 23da0d2

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 e1eb60a commit 23da0d2

16 files changed

+3838
-604
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
@@ -31,6 +31,7 @@ orchagent_SOURCES = \
3131
orchdaemon.cpp \
3232
orch.cpp \
3333
notifications.cpp \
34+
nhgorch.cpp \
3435
routeorch.cpp \
3536
neighorch.cpp \
3637
intfsorch.cpp \

orchagent/fgnhgorch.cpp

+66-66
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;
@@ -285,6 +287,7 @@ bool NeighOrch::setNextHopFlag(const NextHopKey &nexthop, const uint32_t nh_flag
285287
{
286288
case NHFLAGS_IFDOWN:
287289
rc = gRouteOrch->invalidnexthopinNextHopGroup(nexthop, count);
290+
rc &= gNhgOrch->invalidateNextHop(nexthop);
288291
break;
289292
default:
290293
assert(0);
@@ -314,6 +317,7 @@ bool NeighOrch::clearNextHopFlag(const NextHopKey &nexthop, const uint32_t nh_fl
314317
{
315318
case NHFLAGS_IFDOWN:
316319
rc = gRouteOrch->validnexthopinNextHopGroup(nexthop, count);
320+
rc &= gNhgOrch->validateNextHop(nexthop);
317321
break;
318322
default:
319323
assert(0);

orchagent/nexthopkey.h

+12
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 NH_DELIMITER '@'
910
#define NHG_DELIMITER ','
@@ -24,6 +25,8 @@ struct NextHopKey
2425
NextHopKey(const IpAddress &ip, const std::string &alias) : ip_address(ip), alias(alias), vni(0), mac_address() {}
2526
NextHopKey(const std::string &str)
2627
{
28+
SWSS_LOG_ENTER();
29+
2730
if (str.find(NHG_DELIMITER) != string::npos)
2831
{
2932
std::string err = "Error converting " + str + " to NextHop";
@@ -33,16 +36,19 @@ struct NextHopKey
3336
std::string ip_str;
3437
if (label_delimiter != std::string::npos)
3538
{
39+
SWSS_LOG_INFO("Labeled next hop");
3640
label_stack = LabelStack(str.substr(0, label_delimiter));
3741
ip_str = str.substr(label_delimiter+1);
3842
}
3943
else
4044
{
45+
SWSS_LOG_INFO("Unlabeled next hop");
4146
ip_str = str;
4247
}
4348
auto keys = tokenize(ip_str, NH_DELIMITER);
4449
vni = 0;
4550
mac_address = MacAddress();
51+
4652
if (keys.size() == 1)
4753
{
4854
ip_address = keys[0];
@@ -63,6 +69,7 @@ struct NextHopKey
6369
throw std::invalid_argument(err);
6470
}
6571
}
72+
6673
NextHopKey(const std::string &str, bool overlay_nh)
6774
{
6875
if (str.find(NHG_DELIMITER) != string::npos)
@@ -137,6 +144,11 @@ struct NextHopKey
137144
{
138145
return (ip_address.getV4Addr() == 0);
139146
}
147+
148+
NextHopKey ipKey() const
149+
{
150+
return NextHopKey(ip_address, alias);
151+
}
140152
};
141153

142154
#endif /* SWSS_NEXTHOPKEY_H */

0 commit comments

Comments
 (0)