From 6349e49645c2845beddc3a9a7a56b6123bfa2c89 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 14 Aug 2023 15:06:30 -0400 Subject: [PATCH] zebra: Fix crashes in interface change 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 --- zebra/if_netlink.c | 8 ++++++-- zebra/interface.c | 6 ++++++ zebra/zebra_dplane.c | 30 ++++++++++++++++++++++++++++++ zebra/zebra_dplane.h | 4 ++++ zebra/zebra_l2.c | 3 ++- 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 8767b2622c..ca0a354afd 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -635,8 +635,10 @@ 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); @@ -644,8 +646,10 @@ static int netlink_bridge_vxlan_update(struct zebra_dplane_ctx *ctx, * 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; diff --git a/zebra/interface.c b/zebra/interface.c index ab2b7d2446..2157680d58 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -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)) diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index e527d93610..7b2f643080 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -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; @@ -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) diff --git a/zebra/zebra_dplane.h b/zebra/zebra_dplane.h index 79248a4ae4..c006522e01 100644 --- a/zebra/zebra_dplane.h +++ b/zebra/zebra_dplane.h @@ -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); diff --git a/zebra/zebra_l2.c b/zebra/zebra_l2.c index 39c1319f31..4f7a1cd4ce 100644 --- a/zebra/zebra_l2.c +++ b/zebra/zebra_l2.c @@ -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; ; -- 2.39.5