mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 22:50:14 +00:00
zebra: add intf accessors for dplane contexts
Add a few more setters for interface data in dplane contexts. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
This commit is contained in:
parent
bcfce7ad52
commit
971bad8481
@ -1108,6 +1108,21 @@ vrf_id_t dplane_ctx_get_vrf(const struct zebra_dplane_ctx *ctx)
|
||||
return ctx->zd_vrf_id;
|
||||
}
|
||||
|
||||
/* In some paths we have only a namespace id */
|
||||
void dplane_ctx_set_ns_id(struct zebra_dplane_ctx *ctx, ns_id_t nsid)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
ctx->zd_ns_info.ns_id = nsid;
|
||||
}
|
||||
|
||||
ns_id_t dplane_ctx_get_ns_id(const struct zebra_dplane_ctx *ctx)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
return ctx->zd_ns_info.ns_id;
|
||||
}
|
||||
|
||||
bool dplane_ctx_is_from_notif(const struct zebra_dplane_ctx *ctx)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
@ -1154,6 +1169,13 @@ ifindex_t dplane_ctx_get_ifindex(const struct zebra_dplane_ctx *ctx)
|
||||
return ctx->zd_ifindex;
|
||||
}
|
||||
|
||||
void dplane_ctx_set_ifindex(struct zebra_dplane_ctx *ctx, ifindex_t ifindex)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
ctx->zd_ifindex = ifindex;
|
||||
}
|
||||
|
||||
void dplane_ctx_set_type(struct zebra_dplane_ctx *ctx, int type)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
@ -1669,6 +1691,13 @@ uint32_t dplane_ctx_get_intf_metric(const struct zebra_dplane_ctx *ctx)
|
||||
return ctx->u.intf.metric;
|
||||
}
|
||||
|
||||
void dplane_ctx_set_intf_metric(struct zebra_dplane_ctx *ctx, uint32_t metric)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
ctx->u.intf.metric = metric;
|
||||
}
|
||||
|
||||
/* Is interface addr p2p? */
|
||||
bool dplane_ctx_intf_is_connected(const struct zebra_dplane_ctx *ctx)
|
||||
{
|
||||
@ -1691,6 +1720,27 @@ bool dplane_ctx_intf_is_broadcast(const struct zebra_dplane_ctx *ctx)
|
||||
return (ctx->u.intf.flags & DPLANE_INTF_BROADCAST);
|
||||
}
|
||||
|
||||
void dplane_ctx_intf_set_connected(struct zebra_dplane_ctx *ctx)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
ctx->u.intf.flags |= DPLANE_INTF_CONNECTED;
|
||||
}
|
||||
|
||||
void dplane_ctx_intf_set_secondary(struct zebra_dplane_ctx *ctx)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
ctx->u.intf.flags |= DPLANE_INTF_SECONDARY;
|
||||
}
|
||||
|
||||
void dplane_ctx_intf_set_broadcast(struct zebra_dplane_ctx *ctx)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
ctx->u.intf.flags |= DPLANE_INTF_BROADCAST;
|
||||
}
|
||||
|
||||
const struct prefix *dplane_ctx_get_intf_addr(
|
||||
const struct zebra_dplane_ctx *ctx)
|
||||
{
|
||||
@ -1699,6 +1749,14 @@ const struct prefix *dplane_ctx_get_intf_addr(
|
||||
return &(ctx->u.intf.prefix);
|
||||
}
|
||||
|
||||
void dplane_ctx_set_intf_addr(struct zebra_dplane_ctx *ctx,
|
||||
const struct prefix *p)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
prefix_copy(&(ctx->u.intf.prefix), p);
|
||||
}
|
||||
|
||||
bool dplane_ctx_intf_has_dest(const struct zebra_dplane_ctx *ctx)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
@ -1711,10 +1769,15 @@ const struct prefix *dplane_ctx_get_intf_dest(
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
if (ctx->u.intf.flags & DPLANE_INTF_HAS_DEST)
|
||||
return &(ctx->u.intf.dest_prefix);
|
||||
else
|
||||
return NULL;
|
||||
return &(ctx->u.intf.dest_prefix);
|
||||
}
|
||||
|
||||
void dplane_ctx_set_intf_dest(struct zebra_dplane_ctx *ctx,
|
||||
const struct prefix *p)
|
||||
{
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
prefix_copy(&(ctx->u.intf.dest_prefix), p);
|
||||
}
|
||||
|
||||
bool dplane_ctx_intf_has_label(const struct zebra_dplane_ctx *ctx)
|
||||
@ -1731,6 +1794,35 @@ const char *dplane_ctx_get_intf_label(const struct zebra_dplane_ctx *ctx)
|
||||
return ctx->u.intf.label;
|
||||
}
|
||||
|
||||
void dplane_ctx_set_intf_label(struct zebra_dplane_ctx *ctx, const char *label)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
DPLANE_CTX_VALID(ctx);
|
||||
|
||||
if (ctx->u.intf.label && ctx->u.intf.label != ctx->u.intf.label_buf)
|
||||
free(ctx->u.intf.label);
|
||||
|
||||
ctx->u.intf.label = NULL;
|
||||
|
||||
if (label) {
|
||||
ctx->u.intf.flags |= DPLANE_INTF_HAS_LABEL;
|
||||
|
||||
/* Use embedded buffer if it's adequate; else allocate. */
|
||||
len = strlen(label);
|
||||
|
||||
if (len < sizeof(ctx->u.intf.label_buf)) {
|
||||
strlcpy(ctx->u.intf.label_buf, label,
|
||||
sizeof(ctx->u.intf.label_buf));
|
||||
ctx->u.intf.label = ctx->u.intf.label_buf;
|
||||
} else {
|
||||
ctx->u.intf.label = strdup(label);
|
||||
}
|
||||
} else {
|
||||
ctx->u.intf.flags &= ~DPLANE_INTF_HAS_LABEL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Accessors for MAC information */
|
||||
vlanid_t dplane_ctx_mac_get_vlan(const struct zebra_dplane_ctx *ctx)
|
||||
{
|
||||
|
@ -63,6 +63,12 @@ zebra_dplane_info_from_zns(struct zebra_dplane_info *zns_info,
|
||||
#endif /* NETLINK */
|
||||
}
|
||||
|
||||
/*
|
||||
* Notify dplane when namespaces are enabled and disabled. The dplane
|
||||
* needs to start and stop reading incoming events from the ns.
|
||||
*/
|
||||
void zebra_dplane_ns_enable(struct zebra_ns *zns, bool enabled);
|
||||
|
||||
/*
|
||||
* Result codes used when returning status back to the main zebra context.
|
||||
*/
|
||||
@ -284,6 +290,7 @@ void dplane_ctx_set_dest(struct zebra_dplane_ctx *ctx,
|
||||
const char *dplane_ctx_get_ifname(const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_set_ifname(struct zebra_dplane_ctx *ctx, const char *ifname);
|
||||
ifindex_t dplane_ctx_get_ifindex(const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_set_ifindex(struct zebra_dplane_ctx *ctx, ifindex_t ifindex);
|
||||
|
||||
/* Retrieve last/current provider id */
|
||||
uint32_t dplane_ctx_get_provider(const struct zebra_dplane_ctx *ctx);
|
||||
@ -306,6 +313,10 @@ uint32_t dplane_ctx_get_old_seq(const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_set_vrf(struct zebra_dplane_ctx *ctx, vrf_id_t vrf);
|
||||
vrf_id_t dplane_ctx_get_vrf(const struct zebra_dplane_ctx *ctx);
|
||||
|
||||
/* In some paths we have only a namespace id */
|
||||
void dplane_ctx_set_ns_id(struct zebra_dplane_ctx *ctx, ns_id_t nsid);
|
||||
ns_id_t dplane_ctx_get_ns_id(const struct zebra_dplane_ctx *ctx);
|
||||
|
||||
bool dplane_ctx_is_from_notif(const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_set_notif_provider(struct zebra_dplane_ctx *ctx,
|
||||
uint32_t id);
|
||||
@ -441,17 +452,26 @@ dplane_ctx_get_pw_backup_nhg(const struct zebra_dplane_ctx *ctx);
|
||||
|
||||
/* Accessors for interface information */
|
||||
uint32_t dplane_ctx_get_intf_metric(const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_set_intf_metric(struct zebra_dplane_ctx *ctx, uint32_t metric);
|
||||
/* Is interface addr p2p? */
|
||||
bool dplane_ctx_intf_is_connected(const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_intf_set_connected(struct zebra_dplane_ctx *ctx);
|
||||
bool dplane_ctx_intf_is_secondary(const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_intf_set_secondary(struct zebra_dplane_ctx *ctx);
|
||||
bool dplane_ctx_intf_is_broadcast(const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_intf_set_broadcast(struct zebra_dplane_ctx *ctx);
|
||||
const struct prefix *dplane_ctx_get_intf_addr(
|
||||
const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_set_intf_addr(struct zebra_dplane_ctx *ctx,
|
||||
const struct prefix *p);
|
||||
bool dplane_ctx_intf_has_dest(const struct zebra_dplane_ctx *ctx);
|
||||
const struct prefix *dplane_ctx_get_intf_dest(
|
||||
const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_set_intf_dest(struct zebra_dplane_ctx *ctx,
|
||||
const struct prefix *p);
|
||||
bool dplane_ctx_intf_has_label(const struct zebra_dplane_ctx *ctx);
|
||||
const char *dplane_ctx_get_intf_label(const struct zebra_dplane_ctx *ctx);
|
||||
void dplane_ctx_set_intf_label(struct zebra_dplane_ctx *ctx, const char *label);
|
||||
|
||||
/* Accessors for MAC information */
|
||||
vlanid_t dplane_ctx_mac_get_vlan(const struct zebra_dplane_ctx *ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user