Skip to content

Commit

Permalink
lib,*: add vrf id to pbr rule results zapi message
Browse files Browse the repository at this point in the history
The iprule/pbr rule object has a vrf id, and zebra uses
that internally, but the vrf id isn't returned to clients
who install rules and are waiting for results. Include the
vrf_id sent by the client in the zapi result notification
message; update the existing clients so they decode the id.

Signed-off-by: Mark Stapp <[email protected]>
  • Loading branch information
Mark Stapp committed Oct 5, 2023
1 parent 3651803 commit efe8455
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -2423,10 +2423,11 @@ static int rule_notify_owner(ZAPI_CALLBACK_ARGS)
enum zapi_rule_notify_owner note;
struct bgp_pbr_action *bgp_pbra;
struct bgp_pbr_rule *bgp_pbr = NULL;
vrf_id_t vrfid;
char ifname[INTERFACE_NAMSIZ + 1];

if (!zapi_rule_notify_decode(zclient->ibuf, &seqno, &priority, &unique,
ifname, &note))
&vrfid, ifname, &note))
return -1;

bgp_pbra = bgp_pbr_action_rule_lookup(vrf_id, unique);
Expand Down
7 changes: 5 additions & 2 deletions lib/zclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -2024,23 +2024,26 @@ bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
}

bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
uint32_t *priority, uint32_t *unique, char *ifname,
uint32_t *priority, uint32_t *unique,
vrf_id_t *vrfid, char *ifname,
enum zapi_rule_notify_owner *note)
{
uint32_t prio, seq, uni;
uint32_t prio, seq, uni, vrf_id;

STREAM_GET(note, s, sizeof(*note));

STREAM_GETL(s, seq);
STREAM_GETL(s, prio);
STREAM_GETL(s, uni);
STREAM_GETL(s, vrf_id);
STREAM_GET(ifname, s, INTERFACE_NAMSIZ);

if (zclient_debug)
zlog_debug("%s: %u %u %u %s", __func__, seq, prio, uni, ifname);
*seqno = seq;
*priority = prio;
*unique = uni;
*vrfid = vrf_id;

return true;

Expand Down
3 changes: 2 additions & 1 deletion lib/zclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,8 @@ bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
enum zapi_route_notify_owner *note,
afi_t *afi, safi_t *safi);
bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
uint32_t *priority, uint32_t *unique, char *ifname,
uint32_t *priority, uint32_t *unique,
vrf_id_t *vrfid, char *ifname,
enum zapi_rule_notify_owner *note);
bool zapi_ipset_notify_decode(struct stream *s,
uint32_t *unique,
Expand Down
3 changes: 2 additions & 1 deletion pbrd/pbr_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ static int rule_notify_owner(ZAPI_CALLBACK_ARGS)
struct pbr_map_interface *pmi;
char ifname[INTERFACE_NAMSIZ + 1];
uint64_t installed;
vrf_id_t vrfid;

if (!zapi_rule_notify_decode(zclient->ibuf, &seqno, &priority, &unique,
ifname, &note))
&vrfid, ifname, &note))
return -1;

pmi = NULL;
Expand Down
1 change: 1 addition & 0 deletions zebra/zapi_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ void zsend_rule_notify_owner(const struct zebra_dplane_ctx *ctx,
stream_putl(s, dplane_ctx_rule_get_seq(ctx));
stream_putl(s, dplane_ctx_rule_get_priority(ctx));
stream_putl(s, dplane_ctx_rule_get_unique(ctx));
stream_putl(s, dplane_ctx_rule_get_vrfid(ctx));
stream_put(s, dplane_ctx_rule_get_ifname(ctx), INTERFACE_NAMSIZ);

stream_putw_at(s, 0, stream_get_endp(s));
Expand Down
7 changes: 7 additions & 0 deletions zebra/zebra_dplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -3031,6 +3031,13 @@ void dplane_ctx_rule_set_dp_flow_ptr(struct zebra_dplane_ctx *ctx,
ctx->u.rule.new.dp_flow_ptr = dp_flow_ptr;
}

vrf_id_t dplane_ctx_rule_get_vrfid(const struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);

return ctx->u.rule.new.prule.vrf_id;
}

/***********************************************************************
* PBR RULE ACCESSORS - end
**********************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions zebra/zebra_dplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ intptr_t
dplane_ctx_rule_get_old_dp_flow_ptr(const struct zebra_dplane_ctx *ctx);
void dplane_ctx_rule_set_dp_flow_ptr(struct zebra_dplane_ctx *ctx,
intptr_t dp_flow_ptr);
vrf_id_t dplane_ctx_rule_get_vrfid(const struct zebra_dplane_ctx *ctx);

/* Accessors for policy based routing iptable information */
struct zebra_pbr_iptable;
void dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx,
Expand Down

0 comments on commit efe8455

Please sign in to comment.