Skip to content

Commit 45f0a10

Browse files
committed
zebra: Add ctx to netlink message parsing
Add the initial step of passing in a dplane context to reading route netlink messages. This code will be run in two contexts: a) The normal pthread for reading netlink messages from the kernel b) The dplane_fpm_nl pthread. The goal of this commit is too just allow a) to work b) will be filled in in the future. Effectively everything should still be working as it should pre this change. We will just possibly allow the passing of the context around( but not used ) Signed-off-by: Donald Sharp <sharpd@nvidia.com>
1 parent f935122 commit 45f0a10

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

zebra/rt_netlink.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,9 @@ static uint8_t parse_multipath_nexthops_unicast(ns_id_t ns_id,
692692
}
693693

694694
/* Looking up routing table by netlink interface. */
695-
static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
696-
int startup)
695+
int netlink_route_change_read_unicast_internal(struct nlmsghdr *h,
696+
ns_id_t ns_id, int startup,
697+
struct zebra_dplane_ctx *ctx)
697698
{
698699
int len;
699700
struct rtmsg *rtm;
@@ -768,9 +769,8 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
768769

769770
selfroute = is_selfroute(rtm->rtm_protocol);
770771

771-
if (!startup && selfroute
772-
&& h->nlmsg_type == RTM_NEWROUTE
773-
&& !zrouter.asic_offloaded) {
772+
if (!startup && selfroute && h->nlmsg_type == RTM_NEWROUTE &&
773+
!zrouter.asic_offloaded && !ctx) {
774774
if (IS_ZEBRA_DEBUG_KERNEL)
775775
zlog_debug("Route type: %d Received that we think we have originated, ignoring",
776776
rtm->rtm_protocol);
@@ -988,8 +988,8 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
988988
}
989989
}
990990
if (nhe_id || ng)
991-
rib_add_multipath(afi, SAFI_UNICAST, &p, &src_p, re, ng,
992-
startup);
991+
dplane_rib_add_multipath(afi, SAFI_UNICAST, &p, &src_p,
992+
re, ng, startup, ctx);
993993
else {
994994
/*
995995
* I really don't see how this is possible
@@ -1004,6 +1004,13 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
10041004
XFREE(MTYPE_RE, re);
10051005
}
10061006
} else {
1007+
if (ctx) {
1008+
zlog_err(
1009+
"%s: %pFX RTM_DELROUTE received but received a context as well",
1010+
__func__, &p);
1011+
return 0;
1012+
}
1013+
10071014
if (nhe_id) {
10081015
rib_delete(afi, SAFI_UNICAST, vrf_id, proto, 0, flags,
10091016
&p, &src_p, NULL, nhe_id, table, metric,
@@ -1028,7 +1035,14 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
10281035
}
10291036
}
10301037

1031-
return 0;
1038+
return 1;
1039+
}
1040+
1041+
static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
1042+
int startup)
1043+
{
1044+
return netlink_route_change_read_unicast_internal(h, ns_id, startup,
1045+
NULL);
10321046
}
10331047

10341048
static struct mcast_route_data *mroute = NULL;

zebra/rt_netlink.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ netlink_put_lsp_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
122122
extern enum netlink_msg_status
123123
netlink_put_pw_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
124124

125+
int netlink_route_change_read_unicast_internal(struct nlmsghdr *h,
126+
ns_id_t ns_id, int startup,
127+
struct zebra_dplane_ctx *ctx);
128+
125129
#ifdef NETLINK_DEBUG
126130
const char *nlmsg_type2str(uint16_t type);
127131
const char *af_type2str(int type);

zebra/zebra_dplane.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6301,6 +6301,17 @@ kernel_dplane_process_ipset_entry(struct zebra_dplane_provider *prov,
63016301
dplane_provider_enqueue_out_ctx(prov, ctx);
63026302
}
63036303

6304+
void dplane_rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
6305+
struct prefix_ipv6 *src_p, struct route_entry *re,
6306+
struct nexthop_group *ng, int startup,
6307+
struct zebra_dplane_ctx *ctx)
6308+
{
6309+
if (!ctx)
6310+
rib_add_multipath(afi, safi, p, src_p, re, ng, startup);
6311+
else {
6312+
}
6313+
}
6314+
63046315
/*
63056316
* Kernel provider callback
63066317
*/

zebra/zebra_dplane.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,16 @@ void zebra_dplane_pre_finish(void);
10811081
void zebra_dplane_finish(void);
10821082
void zebra_dplane_shutdown(void);
10831083

1084+
/*
1085+
* decision point for sending a routing update through the old
1086+
* straight to zebra master pthread or through the dplane to
1087+
* the master pthread for handling
1088+
*/
1089+
void dplane_rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
1090+
struct prefix_ipv6 *src_p, struct route_entry *re,
1091+
struct nexthop_group *ng, int startup,
1092+
struct zebra_dplane_ctx *ctx);
1093+
10841094
#ifdef __cplusplus
10851095
}
10861096
#endif

0 commit comments

Comments
 (0)