Skip to content

Commit

Permalink
zebra: Move pw status settting until after we get results
Browse files Browse the repository at this point in the history
Currently the pw code sets the status of the pw for install
and uninstall immediately when notifying the dplane.  This
is incorrect in that we do not actually know the status at
this point in time.  When we get the result is when to set
the status.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Oct 4, 2024
1 parent 842009f commit 6bc59d3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
28 changes: 23 additions & 5 deletions zebra/zebra_pw.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ static void zebra_pw_install(struct zebra_pw *pw)
zebra_pw_install_failure(pw, PW_NOT_FORWARDING);
return;
}

if (pw->status != PW_FORWARDING)
zebra_pw_update_status(pw, PW_FORWARDING);
}

static void zebra_pw_uninstall(struct zebra_pw *pw)
Expand All @@ -188,9 +185,30 @@ static void zebra_pw_uninstall(struct zebra_pw *pw)
/* ignore any possible error */
hook_call(pw_uninstall, pw);
dplane_pw_uninstall(pw);
}

void zebra_pw_handle_dplane_results(struct zebra_dplane_ctx *ctx)
{
struct zebra_pw *pw;
struct zebra_vrf *vrf;
enum dplane_op_e op;

if (zebra_pw_enabled(pw))
zebra_pw_update_status(pw, PW_NOT_FORWARDING);
op = dplane_ctx_get_op(ctx);
if (op != DPLANE_OP_PW_INSTALL)
return;

vrf = zebra_vrf_lookup_by_id(dplane_ctx_get_vrf(ctx));
pw = zebra_pw_find(vrf, dplane_ctx_get_ifname(ctx));

if (dplane_ctx_get_status(ctx) != ZEBRA_DPLANE_REQUEST_SUCCESS) {
if (pw)
zebra_pw_install_failure(pw, dplane_ctx_get_pw_status(ctx));
} else {
if (op == DPLANE_OP_PW_INSTALL && pw->status != PW_FORWARDING)
zebra_pw_update_status(pw, PW_FORWARDING);
else if (op == DPLANE_OP_PW_UNINSTALL && zebra_pw_enabled(pw))
zebra_pw_update_status(pw, PW_NOT_FORWARDING);
}
}

/*
Expand Down
1 change: 1 addition & 0 deletions zebra/zebra_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void zebra_pw_init_vrf(struct zebra_vrf *);
void zebra_pw_exit_vrf(struct zebra_vrf *);
void zebra_pw_terminate(void);
void zebra_pw_vty_init(void);
void zebra_pw_handle_dplane_results(struct zebra_dplane_ctx *ctx);

#ifdef __cplusplus
}
Expand Down
25 changes: 1 addition & 24 deletions zebra/zebra_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4890,29 +4890,6 @@ void rib_close_table(struct route_table *table)
}
}

/*
* Handler for async dataplane results after a pseudowire installation
*/
static void handle_pw_result(struct zebra_dplane_ctx *ctx)
{
struct zebra_pw *pw;
struct zebra_vrf *vrf;

/* The pseudowire code assumes success - we act on an error
* result for installation attempts here.
*/
if (dplane_ctx_get_op(ctx) != DPLANE_OP_PW_INSTALL)
return;

if (dplane_ctx_get_status(ctx) != ZEBRA_DPLANE_REQUEST_SUCCESS) {
vrf = zebra_vrf_lookup_by_id(dplane_ctx_get_vrf(ctx));
pw = zebra_pw_find(vrf, dplane_ctx_get_ifname(ctx));
if (pw)
zebra_pw_install_failure(pw,
dplane_ctx_get_pw_status(ctx));
}
}

/*
* Handle results from the dataplane system. Dequeue update context
* structs, dispatch to appropriate internal handlers.
Expand Down Expand Up @@ -5019,7 +4996,7 @@ static void rib_process_dplane_results(struct event *thread)

case DPLANE_OP_PW_INSTALL:
case DPLANE_OP_PW_UNINSTALL:
handle_pw_result(ctx);
zebra_pw_handle_dplane_results(ctx);
break;

case DPLANE_OP_SYS_ROUTE_ADD:
Expand Down

0 comments on commit 6bc59d3

Please sign in to comment.