Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
64 changes: 28 additions & 36 deletions zebra/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1503,32 +1503,22 @@ static void zebra_if_netconf_update_ctx(struct zebra_dplane_ctx *ctx,
(*linkdown_set ? "ON" : "OFF"));
}

static void interface_vrf_change(enum dplane_op_e op, ifindex_t ifindex,
const char *name, uint32_t tableid,
ns_id_t ns_id)
static void interface_vrf_change(enum dplane_op_e op, struct vrf *vrf, vrf_id_t vrf_id,
const char *name, uint32_t tableid, ns_id_t ns_id)
{
struct vrf *vrf;
struct zebra_vrf *zvrf = NULL;

if (op == DPLANE_OP_INTF_DELETE) {
if (IS_ZEBRA_DEBUG_DPLANE)
zlog_debug("DPLANE_OP_INTF_DELETE for VRF %s(%u)", name,
ifindex);
zlog_debug("DPLANE_OP_INTF_DELETE for VRF %s(%u)", vrf->name, vrf->vrf_id);

vrf = vrf_lookup_by_id((vrf_id_t)ifindex);
if (!vrf) {
flog_warn(EC_ZEBRA_VRF_NOT_FOUND,
"%s(%u): vrf not found", name, ifindex);
return;
}

frrtrace(4, frr_zebra, if_vrf_change, ifindex, name, tableid, 0);
frrtrace(4, frr_zebra, if_vrf_change, vrf->vrf_id, vrf->name, vrf->data.l.table_id,
0);
vrf_delete(vrf);
} else {
if (IS_ZEBRA_DEBUG_DPLANE)
zlog_debug(
"DPLANE_OP_INTF_UPDATE for VRF %s(%u) table %u",
name, ifindex, tableid);
zlog_debug("DPLANE_OP_INTF_UPDATE for VRF %s(%u) table %u", name, vrf_id,
tableid);

/*
* For a given tableid, if there already exists a vrf and it
Expand All @@ -1540,26 +1530,24 @@ static void interface_vrf_change(enum dplane_op_e op, ifindex_t ifindex,
if (exist_id != VRF_DEFAULT || strmatch(name, VRF_DEFAULT_NAME)) {
vrf = vrf_lookup_by_id(exist_id);

if (!vrf_lookup_by_id((vrf_id_t)ifindex) && !vrf) {
flog_err(EC_ZEBRA_VRF_NOT_FOUND,
"VRF %s id %u does not exist", name,
ifindex);
if (!vrf_lookup_by_id(vrf_id) && !vrf) {
flog_err(EC_ZEBRA_VRF_NOT_FOUND, "VRF %s id %u does not exist",
name, vrf_id);
frr_exit_with_buffer_flush(-1);
}

if (vrf && strcmp(name, vrf->name)) {
flog_err(EC_ZEBRA_VRF_MISCONFIGURED,
"VRF %s id %u table id overlaps existing vrf %s(%d), misconfiguration exiting",
name, ifindex, vrf->name, vrf->vrf_id);
name, vrf_id, vrf->name, vrf->vrf_id);
frr_exit_with_buffer_flush(-1);
}
}

frrtrace(4, frr_zebra, if_vrf_change, ifindex, name, tableid, 1);
vrf = vrf_update((vrf_id_t)ifindex, name);
frrtrace(4, frr_zebra, if_vrf_change, vrf_id, name, tableid, 1);
vrf = vrf_update(vrf_id, name);
if (!vrf) {
flog_err(EC_LIB_INTERFACE, "VRF %s id %u not created",
name, ifindex);
flog_err(EC_LIB_INTERFACE, "VRF %s id %u not created", name, vrf_id);
return;
}

Expand All @@ -1580,9 +1568,7 @@ static void interface_vrf_change(enum dplane_op_e op, ifindex_t ifindex,

/* Enable the created VRF. */
if (!vrf_enable(vrf)) {
flog_err(EC_LIB_INTERFACE,
"Failed to enable VRF %s id %u", name,
ifindex);
flog_err(EC_LIB_INTERFACE, "Failed to enable VRF %s id %u", name, vrf_id);
return;
}
}
Expand Down Expand Up @@ -1976,7 +1962,6 @@ static void zebra_if_dplane_ifp_handling(struct zebra_dplane_ctx *ctx)
ns_id_t ns_id = dplane_ctx_get_ns_id(ctx);
ifindex_t ifindex = dplane_ctx_get_ifindex(ctx);
ifindex_t bond_ifindex = dplane_ctx_get_ifp_bond_ifindex(ctx);
uint32_t tableid = dplane_ctx_get_ifp_table_id(ctx);
enum zebra_iftype zif_type = dplane_ctx_get_ifp_zif_type(ctx);
struct interface *ifp;
struct zebra_ns *zns;
Expand All @@ -1992,6 +1977,8 @@ static void zebra_if_dplane_ifp_handling(struct zebra_dplane_ctx *ctx)

ifp = if_lookup_by_name_per_ns(zns, name);
if (op == DPLANE_OP_INTF_DELETE) {
struct vrf *vrf = NULL;

/* Delete interface notification from kernel */
if (ifp == NULL) {
if (IS_ZEBRA_DEBUG_EVENT)
Expand All @@ -2013,16 +2000,19 @@ static void zebra_if_dplane_ifp_handling(struct zebra_dplane_ctx *ctx)
else if (IS_ZEBRA_IF_VXLAN(ifp))
zebra_l2_vxlanif_del(ifp);

if (zif_type == ZEBRA_IF_VRF && !vrf_is_backend_netns())
vrf = ifp->vrf;

if_delete_update(&ifp);

if (zif_type == ZEBRA_IF_VRF && !vrf_is_backend_netns())
interface_vrf_change(op, ifindex, name, tableid, ns_id);
if (vrf)
interface_vrf_change(op, vrf, 0, NULL, 0, ns_id);
} else {
ifindex_t master_ifindex, bridge_ifindex, link_ifindex;
vrf_id_t vrf_id = dplane_ctx_get_ifp_vrf_id(ctx);
enum zebra_slave_iftype zif_slave_type;
uint8_t bypass;
uint64_t flags;
vrf_id_t vrf_id;
uint32_t mtu;
ns_id_t link_nsid;
struct zebra_if *zif;
Expand All @@ -2034,16 +2024,18 @@ static void zebra_if_dplane_ifp_handling(struct zebra_dplane_ctx *ctx)
uint64_t change_flags;

/* If VRF, create or update the VRF structure itself. */
if (zif_type == ZEBRA_IF_VRF && !vrf_is_backend_netns())
interface_vrf_change(op, ifindex, name, tableid, ns_id);
if (zif_type == ZEBRA_IF_VRF && !vrf_is_backend_netns()) {
uint32_t tableid = dplane_ctx_get_ifp_table_id(ctx);

interface_vrf_change(op, NULL, vrf_id, name, tableid, ns_id);
}

master_ifindex = dplane_ctx_get_ifp_master_ifindex(ctx);
zif_slave_type = dplane_ctx_get_ifp_zif_slave_type(ctx);
bridge_ifindex = dplane_ctx_get_ifp_bridge_ifindex(ctx);
bond_ifindex = dplane_ctx_get_ifp_bond_ifindex(ctx);
bypass = dplane_ctx_get_ifp_bypass(ctx);
flags = dplane_ctx_get_ifp_flags(ctx);
vrf_id = dplane_ctx_get_ifp_vrf_id(ctx);
mtu = dplane_ctx_get_ifp_mtu(ctx);
link_ifindex = dplane_ctx_get_ifp_link_ifindex(ctx);
link_nsid = dplane_ctx_get_ifp_link_nsid(ctx);
Expand Down
4 changes: 2 additions & 2 deletions zebra/zebra_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ TRACEPOINT_LOGLEVEL(frr_zebra, if_upd_ctx_dplane_result, TRACE_INFO)
TRACEPOINT_EVENT(
frr_zebra,
if_vrf_change,
TP_ARGS(ifindex_t, ifindex, const char *, name, uint32_t, tableid, uint8_t, loc),
TP_ARGS(vrf_id_t, vrf_id, const char *, name, uint32_t, tableid, uint8_t, loc),
TP_FIELDS(
ctf_integer(ifindex_t, ifindex, ifindex)
ctf_integer(vrf_id_t, vrf_id, vrf_id)
ctf_string(vrf_name, name)
ctf_integer(uint32_t, tableid, tableid)
ctf_integer(uint8_t, location, loc)
Expand Down