Skip to content

Commit 68b6535

Browse files
committed
[fpmsyncd]: Add PIC context and VPN route support
Add support for parsing and processing PIC Context and VPN Route information, supplementing related tables and entries. Signed-off-by: Yuqing Zhao <[email protected]>
1 parent e0b2ac6 commit 68b6535

File tree

4 files changed

+795
-56
lines changed

4 files changed

+795
-56
lines changed

fpmsyncd/fpmlink.cpp

+23-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using namespace std;
1212
void netlink_parse_rtattr(struct rtattr **tb, int max, struct rtattr *rta,
1313
int len)
1414
{
15-
while (RTA_OK(rta, len))
15+
while (RTA_OK(rta, len))
1616
{
1717
if (rta->rta_type <= max)
1818
{
@@ -33,6 +33,11 @@ void netlink_parse_rtattr(struct rtattr **tb, int max, struct rtattr *rta,
3333
rta = RTA_NEXT(rta, len);
3434
}
3535
}
36+
void netlink_parse_rtattr_nested(struct rtattr **tb, int max,
37+
const struct rtattr *rta)
38+
{
39+
netlink_parse_rtattr(tb, max, (struct rtattr *)RTA_DATA(rta), (int)RTA_PAYLOAD(rta));
40+
}
3641

3742
bool FpmLink::isRawProcessing(struct nlmsghdr *h)
3843
{
@@ -54,7 +59,7 @@ bool FpmLink::isRawProcessing(struct nlmsghdr *h)
5459
}
5560

5661
len = (int)(h->nlmsg_len - NLMSG_LENGTH(sizeof(struct rtmsg)));
57-
if (len < 0)
62+
if (len < 0)
5863
{
5964
return false;
6065
}
@@ -71,19 +76,19 @@ bool FpmLink::isRawProcessing(struct nlmsghdr *h)
7176
else
7277
{
7378
/* This is a multipath route */
74-
int len;
79+
int len;
7580
struct rtnexthop *rtnh = (struct rtnexthop *)RTA_DATA(tb[RTA_MULTIPATH]);
7681
len = (int)RTA_PAYLOAD(tb[RTA_MULTIPATH]);
7782
struct rtattr *subtb[RTA_MAX + 1];
78-
79-
for (;;)
83+
84+
for (;;)
8085
{
8186
if (len < (int)sizeof(*rtnh) || rtnh->rtnh_len > len)
8287
{
8388
break;
8489
}
8590

86-
if (rtnh->rtnh_len > sizeof(*rtnh))
91+
if (rtnh->rtnh_len > sizeof(*rtnh))
8792
{
8893
memset(subtb, 0, sizeof(subtb));
8994
netlink_parse_rtattr(subtb, RTA_MAX, RTNH_DATA(rtnh),
@@ -101,7 +106,7 @@ bool FpmLink::isRawProcessing(struct nlmsghdr *h)
101106
}
102107

103108
len -= NLMSG_ALIGN(rtnh->rtnh_len);
104-
rtnh = RTNH_NEXT(rtnh);
109+
rtnh = RTNH_NEXT(rtnh);
105110
}
106111
}
107112

@@ -281,7 +286,17 @@ void FpmLink::processFpmMessage(fpm_msg_hdr_t* hdr)
281286
/* EVPN Type5 Add route processing */
282287
processRawMsg(nl_hdr);
283288
}
284-
else if(nl_hdr->nlmsg_type == RTM_NEWNEXTHOP || nl_hdr->nlmsg_type == RTM_DELNEXTHOP)
289+
else if(nl_hdr->nlmsg_type == RTM_NEWSRV6VPNROUTE || nl_hdr->nlmsg_type == RTM_DELSRV6VPNROUTE)
290+
{
291+
/* rtnl api dont support RTM_NEWNEXTHOP/RTM_DELNEXTHOP yet. Processing as raw message*/
292+
processRawMsg(nl_hdr);
293+
}
294+
else if(nl_hdr->nlmsg_type == RTM_NEWNEXTHOP || nl_hdr->nlmsg_type == RTM_DELNEXTHOP)
295+
{
296+
/* rtnl api dont support RTM_NEWNEXTHOP/RTM_DELNEXTHOP yet. Processing as raw message*/
297+
processRawMsg(nl_hdr);
298+
}
299+
else if(nl_hdr->nlmsg_type == RTM_NEWPICCONTEXT || nl_hdr->nlmsg_type == RTM_DELPICCONTEXT)
285300
{
286301
/* rtnl api dont support RTM_NEWNEXTHOP/RTM_DELNEXTHOP yet. Processing as raw message*/
287302
processRawMsg(nl_hdr);

fpmsyncd/fpmlink.h

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
#define RTM_NEWSRV6LOCALSID 1000
1919
#define RTM_DELSRV6LOCALSID 1001
20+
#define RTM_NEWPICCONTEXT 2000
21+
#define RTM_DELPICCONTEXT 2001
22+
#define RTM_NEWSRV6VPNROUTE 3000
23+
#define RTM_DELSRV6VPNROUTE 3001
2024

2125
namespace swss {
2226

0 commit comments

Comments
 (0)