Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebra: netlink FPM interface using zebra data plane #5510

Merged
merged 21 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e57a3fa
zebra: generalize netlink route talk function
rzalamena Nov 29, 2019
9266b31
zebra: simplify some netlink debug messages
rzalamena Nov 29, 2019
b9c8751
zebra: simplify netlink_route_multipath
rzalamena Dec 2, 2019
f78fe8f
zebra: export netlink function and change return
rzalamena Dec 4, 2019
f73a846
zebra: dataplane context reset and init apis
Dec 10, 2019
d35f447
zebra: data plane plugin for FPM netlink
rzalamena Dec 4, 2019
018e77b
zebra: data plane FPM RIB walk code
rzalamena Dec 4, 2019
d4d4ec1
zebra: adapt and export rmac netlink functions
rzalamena Dec 9, 2019
bda10ad
zebra: data plane FPM RMAC walk code
rzalamena Dec 9, 2019
3bdd7fc
zebra: CLI commands for new FPM interface
rzalamena Dec 10, 2019
6cc059c
zebra: implement FPM counters
rzalamena Dec 11, 2019
a179ba3
zebra: simplify FPM buffer full detection
rzalamena Dec 11, 2019
ad4d102
zebra: improve FPM output buffer handling
rzalamena Dec 12, 2019
ba803a2
zebra: queue data plane context for FPM
rzalamena Dec 12, 2019
edfeff4
zebra: use atomic operations in FPM
rzalamena Dec 17, 2019
c871e6c
build: fix data plane FPM netlink module
rzalamena Jan 3, 2020
770a8d2
zebra: fix style on data plane FPM module
rzalamena Jan 8, 2020
f2a0ba3
zebra: data plane FPM add support RMAC VNI
rzalamena Jan 13, 2020
a50404a
zebra: fix some formatting/style issues
rzalamena Feb 10, 2020
e5e444d
zebra: hide verbose data plane FPM log messages
rzalamena Feb 11, 2020
9d5c326
zebra: fix hash_backet typo in data plane FPM
rzalamena Mar 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
zebra: dataplane context reset and init apis
Add a public reset api, so a context can be reset and reused;
add apis to init a context for a route or mac update.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
  • Loading branch information
Mark Stapp authored and rzalamena committed Apr 14, 2020
commit f73a84672dc2a190dbef6a6625da998846ef1d95
175 changes: 107 additions & 68 deletions zebra/zebra_dplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ static enum zebra_dplane_result pw_update_internal(struct zebra_pw *pw,
static enum zebra_dplane_result intf_addr_update_internal(
const struct interface *ifp, const struct connected *ifc,
enum dplane_op_e op);
static enum zebra_dplane_result mac_update_internal(
mjstapp marked this conversation as resolved.
Show resolved Hide resolved
static enum zebra_dplane_result mac_update_common(
enum dplane_op_e op, const struct interface *ifp,
const struct interface *br_ifp,
vlanid_t vid, const struct ethaddr *mac,
Expand Down Expand Up @@ -445,23 +445,15 @@ void dplane_enable_sys_route_notifs(void)
}

/*
* Free a dataplane results context.
* Clean up dependent/internal allocations inside a context object
*/
static void dplane_ctx_free(struct zebra_dplane_ctx **pctx)
static void dplane_ctx_free_internal(struct zebra_dplane_ctx *ctx)
{
if (pctx == NULL)
return;

DPLANE_CTX_VALID(*pctx);

/* TODO -- just freeing memory, but would like to maintain
* a pool
*/

/* Some internal allocations may need to be freed, depending on
/*
* Some internal allocations may need to be freed, depending on
* the type of info captured in the ctx.
*/
switch ((*pctx)->zd_op) {
switch (ctx->zd_op) {
case DPLANE_OP_ROUTE_INSTALL:
case DPLANE_OP_ROUTE_UPDATE:
case DPLANE_OP_ROUTE_DELETE:
Expand All @@ -470,45 +462,45 @@ static void dplane_ctx_free(struct zebra_dplane_ctx **pctx)
case DPLANE_OP_ROUTE_NOTIFY:

/* Free allocated nexthops */
if ((*pctx)->u.rinfo.zd_ng.nexthop) {
if (ctx->u.rinfo.zd_ng.nexthop) {
/* This deals with recursive nexthops too */
nexthops_free((*pctx)->u.rinfo.zd_ng.nexthop);
nexthops_free(ctx->u.rinfo.zd_ng.nexthop);

(*pctx)->u.rinfo.zd_ng.nexthop = NULL;
ctx->u.rinfo.zd_ng.nexthop = NULL;
}

/* Free backup info also (if present) */
if ((*pctx)->u.rinfo.backup_ng.nexthop) {
if (ctx->u.rinfo.backup_ng.nexthop) {
/* This deals with recursive nexthops too */
nexthops_free((*pctx)->u.rinfo.backup_ng.nexthop);
nexthops_free(ctx->u.rinfo.backup_ng.nexthop);

(*pctx)->u.rinfo.backup_ng.nexthop = NULL;
ctx->u.rinfo.backup_ng.nexthop = NULL;
}

if ((*pctx)->u.rinfo.zd_old_ng.nexthop) {
if (ctx->u.rinfo.zd_old_ng.nexthop) {
/* This deals with recursive nexthops too */
nexthops_free((*pctx)->u.rinfo.zd_old_ng.nexthop);
nexthops_free(ctx->u.rinfo.zd_old_ng.nexthop);

(*pctx)->u.rinfo.zd_old_ng.nexthop = NULL;
ctx->u.rinfo.zd_old_ng.nexthop = NULL;
}

if ((*pctx)->u.rinfo.old_backup_ng.nexthop) {
if (ctx->u.rinfo.old_backup_ng.nexthop) {
/* This deals with recursive nexthops too */
nexthops_free((*pctx)->u.rinfo.old_backup_ng.nexthop);
nexthops_free(ctx->u.rinfo.old_backup_ng.nexthop);

(*pctx)->u.rinfo.old_backup_ng.nexthop = NULL;
ctx->u.rinfo.old_backup_ng.nexthop = NULL;
}

break;

case DPLANE_OP_NH_INSTALL:
case DPLANE_OP_NH_UPDATE:
case DPLANE_OP_NH_DELETE: {
if ((*pctx)->u.rinfo.nhe.ng.nexthop) {
if (ctx->u.rinfo.nhe.ng.nexthop) {
/* This deals with recursive nexthops too */
nexthops_free((*pctx)->u.rinfo.nhe.ng.nexthop);
nexthops_free(ctx->u.rinfo.nhe.ng.nexthop);

(*pctx)->u.rinfo.nhe.ng.nexthop = NULL;
ctx->u.rinfo.nhe.ng.nexthop = NULL;
}
break;
}
Expand All @@ -521,7 +513,7 @@ static void dplane_ctx_free(struct zebra_dplane_ctx **pctx)
zebra_nhlfe_t *nhlfe, *next;

/* Free allocated NHLFEs */
for (nhlfe = (*pctx)->u.lsp.nhlfe_list; nhlfe; nhlfe = next) {
for (nhlfe = ctx->u.lsp.nhlfe_list; nhlfe; nhlfe = next) {
next = nhlfe->next;

zebra_mpls_nhlfe_del(nhlfe);
Expand All @@ -530,30 +522,30 @@ static void dplane_ctx_free(struct zebra_dplane_ctx **pctx)
/* Clear pointers in lsp struct, in case we're cacheing
* free context structs.
*/
(*pctx)->u.lsp.nhlfe_list = NULL;
(*pctx)->u.lsp.best_nhlfe = NULL;
ctx->u.lsp.nhlfe_list = NULL;
ctx->u.lsp.best_nhlfe = NULL;

break;
}

case DPLANE_OP_PW_INSTALL:
case DPLANE_OP_PW_UNINSTALL:
/* Free allocated nexthops */
if ((*pctx)->u.pw.nhg.nexthop) {
if (ctx->u.pw.nhg.nexthop) {
/* This deals with recursive nexthops too */
nexthops_free((*pctx)->u.pw.nhg.nexthop);
nexthops_free(ctx->u.pw.nhg.nexthop);

(*pctx)->u.pw.nhg.nexthop = NULL;
ctx->u.pw.nhg.nexthop = NULL;
}
break;

case DPLANE_OP_ADDR_INSTALL:
case DPLANE_OP_ADDR_UNINSTALL:
/* Maybe free label string, if allocated */
if ((*pctx)->u.intf.label != NULL &&
(*pctx)->u.intf.label != (*pctx)->u.intf.label_buf) {
free((*pctx)->u.intf.label);
(*pctx)->u.intf.label = NULL;
if (ctx->u.intf.label != NULL &&
ctx->u.intf.label != ctx->u.intf.label_buf) {
free(ctx->u.intf.label);
ctx->u.intf.label = NULL;
}
break;

Expand All @@ -567,10 +559,40 @@ static void dplane_ctx_free(struct zebra_dplane_ctx **pctx)
case DPLANE_OP_NONE:
break;
}
}

/*
* Free a dataplane results context.
*/
static void dplane_ctx_free(struct zebra_dplane_ctx **pctx)
{
if (pctx == NULL)
return;

DPLANE_CTX_VALID(*pctx);

/* TODO -- just freeing memory, but would like to maintain
* a pool
*/

/* Some internal allocations may need to be freed, depending on
* the type of info captured in the ctx.
*/
dplane_ctx_free_internal(*pctx);

XFREE(MTYPE_DP_CTX, *pctx);
}

/*
* Reset an allocated context object for re-use. All internal allocations are
* freed and the context is memset.
*/
void dplane_ctx_reset(struct zebra_dplane_ctx *ctx)
{
dplane_ctx_free_internal(ctx);
memset(ctx, 0, sizeof(*ctx));
}

/*
* Return a context block to the dplane module after processing
*/
Expand Down Expand Up @@ -2470,8 +2492,8 @@ enum zebra_dplane_result dplane_mac_add(const struct interface *ifp,
enum zebra_dplane_result result;

/* Use common helper api */
result = mac_update_internal(DPLANE_OP_MAC_INSTALL, ifp, bridge_ifp,
vid, mac, vtep_ip, sticky);
result = mac_update_common(DPLANE_OP_MAC_INSTALL, ifp, bridge_ifp,
vid, mac, vtep_ip, sticky);
return result;
}

Expand All @@ -2487,41 +2509,25 @@ enum zebra_dplane_result dplane_mac_del(const struct interface *ifp,
enum zebra_dplane_result result;

/* Use common helper api */
result = mac_update_internal(DPLANE_OP_MAC_DELETE, ifp, bridge_ifp,
vid, mac, vtep_ip, false);
result = mac_update_common(DPLANE_OP_MAC_DELETE, ifp, bridge_ifp,
vid, mac, vtep_ip, false);
return result;
}

/*
* Common helper api for MAC address/vxlan updates
* Public api to init an empty context - either newly-allocated or
* reset/cleared - for a MAC update.
*/
static enum zebra_dplane_result
mac_update_internal(enum dplane_op_e op,
const struct interface *ifp,
const struct interface *br_ifp,
vlanid_t vid,
const struct ethaddr *mac,
struct in_addr vtep_ip,
bool sticky)
void dplane_mac_init(struct zebra_dplane_ctx *ctx,
const struct interface *ifp,
const struct interface *br_ifp,
vlanid_t vid,
const struct ethaddr *mac,
struct in_addr vtep_ip,
bool sticky)
{
enum zebra_dplane_result result = ZEBRA_DPLANE_REQUEST_FAILURE;
int ret;
struct zebra_dplane_ctx *ctx = NULL;
struct zebra_ns *zns;

if (IS_ZEBRA_DEBUG_DPLANE_DETAIL) {
char buf1[ETHER_ADDR_STRLEN], buf2[PREFIX_STRLEN];

zlog_debug("init mac ctx %s: mac %s, ifp %s, vtep %s",
dplane_op2str(op),
prefix_mac2str(mac, buf1, sizeof(buf1)),
ifp->name,
inet_ntop(AF_INET, &vtep_ip, buf2, sizeof(buf2)));
}

ctx = dplane_ctx_alloc();

ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
ctx->zd_vrf_id = ifp->vrf_id;

Expand All @@ -2539,6 +2545,39 @@ mac_update_internal(enum dplane_op_e op,
ctx->u.macinfo.mac = *mac;
ctx->u.macinfo.vid = vid;
ctx->u.macinfo.is_sticky = sticky;
}

/*
* Common helper api for MAC address/vxlan updates
*/
static enum zebra_dplane_result
mac_update_common(enum dplane_op_e op,
const struct interface *ifp,
const struct interface *br_ifp,
vlanid_t vid,
const struct ethaddr *mac,
struct in_addr vtep_ip,
bool sticky)
{
enum zebra_dplane_result result = ZEBRA_DPLANE_REQUEST_FAILURE;
int ret;
struct zebra_dplane_ctx *ctx = NULL;

if (IS_ZEBRA_DEBUG_DPLANE_DETAIL) {
char buf1[ETHER_ADDR_STRLEN], buf2[PREFIX_STRLEN];

zlog_debug("init mac ctx %s: mac %s, ifp %s, vtep %s",
dplane_op2str(op),
prefix_mac2str(mac, buf1, sizeof(buf1)),
ifp->name,
inet_ntop(AF_INET, &vtep_ip, buf2, sizeof(buf2)));
}

ctx = dplane_ctx_alloc();
ctx->zd_op = op;

/* Common init for the ctx */
dplane_mac_init(ctx, ifp, br_ifp, vid, mac, vtep_ip, sticky);

/* Enqueue for processing on the dplane pthread */
ret = dplane_update_enqueue(ctx);
Expand Down
15 changes: 15 additions & 0 deletions zebra/zebra_dplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ TAILQ_HEAD(dplane_ctx_q, zebra_dplane_ctx);
/* Allocate a context object */
struct zebra_dplane_ctx *dplane_ctx_alloc(void);

/*
* Reset an allocated context object for re-use. All internal allocations are
* freed.
*/
void dplane_ctx_reset(struct zebra_dplane_ctx *ctx);

/* Return a dataplane results context block after use; the caller's pointer will
* be cleared.
*/
Expand Down Expand Up @@ -451,6 +457,15 @@ enum zebra_dplane_result dplane_mac_del(const struct interface *ifp,
const struct ethaddr *mac,
struct in_addr vtep_ip);

/* Helper api to init an empty or new context for a MAC update */
void dplane_mac_init(struct zebra_dplane_ctx *ctx,
const struct interface *ifp,
const struct interface *br_ifp,
vlanid_t vid,
const struct ethaddr *mac,
struct in_addr vtep_ip,
bool sticky);

/*
* Enqueue evpn neighbor updates for the dataplane.
*/
Expand Down