Skip to content

Commit

Permalink
zebra: Fix crashes in interface change
Browse files Browse the repository at this point in the history
Upon some internal testing some crashes were found.  This fixes
the several crashes and normalizes the code to be closer in
it's execution pre and post changes to use the data plane.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Aug 17, 2023
1 parent 77014da commit 6349e49
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
8 changes: 6 additions & 2 deletions zebra/if_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,17 +635,21 @@ static int netlink_bridge_vxlan_update(struct zebra_dplane_ctx *ctx,
struct bridge_vlan_info *vinfo;
struct zebra_dplane_bridge_vlan_info bvinfo;

if (!af_spec)
if (!af_spec) {
dplane_ctx_set_ifp_no_afspec(ctx);
return 0;
}

netlink_bridge_vxlan_vlan_vni_map_update(ctx, af_spec);

/* There is a 1-to-1 mapping of VLAN to VxLAN - hence
* only 1 access VLAN is accepted.
*/
netlink_parse_rtattr_nested(aftb, IFLA_BRIDGE_MAX, af_spec);
if (!aftb[IFLA_BRIDGE_VLAN_INFO])
if (!aftb[IFLA_BRIDGE_VLAN_INFO]) {
dplane_ctx_set_ifp_no_bridge_vlan_info(ctx);
return 0;
}

vinfo = RTA_DATA(aftb[IFLA_BRIDGE_VLAN_INFO]);
bvinfo.flags = vinfo->flags;
Expand Down
6 changes: 6 additions & 0 deletions zebra/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1848,9 +1848,15 @@ static void interface_bridge_vxlan_update(struct zebra_dplane_ctx *ctx,
struct zebra_if *zif = ifp->info;
const struct zebra_dplane_bridge_vlan_info *bvinfo;

if (dplane_ctx_get_ifp_no_afspec(ctx))
return;

if (IS_ZEBRA_VXLAN_IF_SVD(zif))
interface_bridge_vxlan_vlan_vni_map_update(ctx, ifp);

if (dplane_ctx_get_ifp_no_bridge_vlan_info(ctx))
return;

bvinfo = dplane_ctx_get_ifp_bridge_vlan_info(ctx);

if (!(bvinfo->flags & DPLANE_BRIDGE_VLAN_INFO_PVID))
Expand Down
30 changes: 30 additions & 0 deletions zebra/zebra_dplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ struct dplane_intf_info {
bool startup;
uint8_t family;
struct zebra_vxlan_vni_array *vniarray;
bool no_bvinfo_avail;
bool no_afspec_avail;
struct zebra_dplane_bridge_vlan_info bvinfo;
struct zebra_dplane_bridge_vlan_info_array *bvarray;

Expand Down Expand Up @@ -1355,6 +1357,34 @@ dplane_ctx_get_ifp_vxlan_vni_array(const struct zebra_dplane_ctx *ctx)
return ctx->u.intf.vniarray;
}

void dplane_ctx_set_ifp_no_afspec(struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);

ctx->u.intf.no_afspec_avail = true;
}

bool dplane_ctx_get_ifp_no_afspec(const struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);

return ctx->u.intf.no_afspec_avail;
}

void dplane_ctx_set_ifp_no_bridge_vlan_info(struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);

ctx->u.intf.no_bvinfo_avail = true;
}

bool dplane_ctx_get_ifp_no_bridge_vlan_info(struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);

return ctx->u.intf.no_bvinfo_avail;
}

void dplane_ctx_set_ifp_bridge_vlan_info(
struct zebra_dplane_ctx *ctx,
struct zebra_dplane_bridge_vlan_info *bvinfo)
Expand Down
4 changes: 4 additions & 0 deletions zebra/zebra_dplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ struct zebra_dplane_bridge_vlan_info {
uint16_t flags;
uint16_t vid;
};
void dplane_ctx_set_ifp_no_afspec(struct zebra_dplane_ctx *ctx);
bool dplane_ctx_get_ifp_no_afspec(const struct zebra_dplane_ctx *ctx);
void dplane_ctx_set_ifp_no_bridge_vlan_info(struct zebra_dplane_ctx *ctx);
bool dplane_ctx_get_ifp_no_bridge_vlan_info(struct zebra_dplane_ctx *ctx);
void dplane_ctx_set_ifp_bridge_vlan_info(
struct zebra_dplane_ctx *ctx,
struct zebra_dplane_bridge_vlan_info *bvinfo);
Expand Down
3 changes: 2 additions & 1 deletion zebra/zebra_l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ void zebra_l2_vxlanif_update_access_vlan(struct interface *ifp,
assert(zif);

/* This would be called only in non svd case */
assert(IS_ZEBRA_VXLAN_IF_VNI(zif));
if (!IS_ZEBRA_VXLAN_IF_VNI(zif))
return;

old_access_vlan = zif->l2info.vxl.vni_info.vni.access_vlan;
;
Expand Down

0 comments on commit 6349e49

Please sign in to comment.