Skip to content

Commit

Permalink
*: Fix up improper handling of nexthops for nexthop tracking
Browse files Browse the repository at this point in the history
Currently FRR needs to send a uint16_t value for the number
of nexthops as well it needs the ability to properly decode
all of this.  Find and handle all the places that this happens.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Oct 15, 2024
1 parent 0aef4e4 commit 645a9e4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/zclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ static bool zapi_nexthop_update_decode(struct stream *s, struct prefix *match,
STREAM_GETW(s, nhr->instance);
STREAM_GETC(s, nhr->distance);
STREAM_GETL(s, nhr->metric);
STREAM_GETC(s, nhr->nexthop_num);
STREAM_GETW(s, nhr->nexthop_num);

for (i = 0; i < nhr->nexthop_num; i++) {
if (zapi_nexthop_decode(s, &(nhr->nexthops[i]), 0, 0) != 0)
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_zlookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,

distance = stream_getc(s);
metric = stream_getl(s);
nexthop_num = stream_getc(s);
nexthop_num = stream_getw(s);

if (nexthop_num < 1 || nexthop_num > router->multipath) {
if (PIM_DEBUG_PIM_NHT_DETAIL)
Expand Down
2 changes: 1 addition & 1 deletion staticd/static_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct static_nht_data {
vrf_id_t nh_vrf_id;

uint32_t refcount;
uint8_t nh_num;
uint16_t nh_num;
bool registered;
};

Expand Down
8 changes: 4 additions & 4 deletions zebra/zapi_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ static int zsend_nexthop_lookup_mrib(struct zserv *client, struct ipaddr *addr,
{
struct stream *s;
unsigned long nump;
uint8_t num;
uint16_t num;
struct nexthop *nexthop;

/* Get output stream. */
Expand All @@ -667,19 +667,19 @@ static int zsend_nexthop_lookup_mrib(struct zserv *client, struct ipaddr *addr,
/* remember position for nexthop_num */
nump = stream_get_endp(s);
/* reserve room for nexthop_num */
stream_putc(s, 0);
stream_putw(s, 0);
nhg = rib_get_fib_nhg(re);
for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
if (rnh_nexthop_valid(re, nexthop))
num += zserv_encode_nexthop(s, nexthop);
}

/* store nexthop_num */
stream_putc_at(s, nump, num);
stream_putw_at(s, nump, num);
} else {
stream_putc(s, 0); /* distance */
stream_putl(s, 0); /* metric */
stream_putc(s, 0); /* nexthop_num */
stream_putw(s, 0); /* nexthop_num */
}

stream_putw_at(s, 0, stream_get_endp(s));
Expand Down
8 changes: 4 additions & 4 deletions zebra/zebra_rnh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ int zebra_send_rnh_update(struct rnh *rnh, struct zserv *client,
struct stream *s = NULL;
struct route_entry *re;
unsigned long nump;
uint8_t num;
uint16_t num;
struct nexthop *nh;
struct route_node *rn;
int ret;
Expand Down Expand Up @@ -1212,7 +1212,7 @@ int zebra_send_rnh_update(struct rnh *rnh, struct zserv *client,
stream_putl(s, re->metric);
num = 0;
nump = stream_get_endp(s);
stream_putc(s, 0);
stream_putw(s, 0);

nhg = rib_get_fib_nhg(re);
for (ALL_NEXTHOPS_PTR(nhg, nh))
Expand Down Expand Up @@ -1240,13 +1240,13 @@ int zebra_send_rnh_update(struct rnh *rnh, struct zserv *client,
}
}

stream_putc_at(s, nump, num);
stream_putw_at(s, nump, num);
} else {
stream_putc(s, 0); // type
stream_putw(s, 0); // instance
stream_putc(s, 0); // distance
stream_putl(s, 0); // metric
stream_putc(s, 0); // nexthops
stream_putw(s, 0); // nexthops
}
stream_putw_at(s, 0, stream_get_endp(s));

Expand Down
4 changes: 2 additions & 2 deletions zebra/zebra_srte.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,
stream_putc(s, nhlfe->distance);
stream_putl(s, 0); /* metric - not available */
nump = stream_get_endp(s);
stream_putc(s, 0);
stream_putw(s, 0);
}

zapi_nexthop_from_nexthop(&znh, nhlfe->nexthop);
Expand All @@ -155,7 +155,7 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,

num++;
}
stream_putc_at(s, nump, num);
stream_putw_at(s, nump, num);
stream_putw_at(s, 0, stream_get_endp(s));

client->nh_last_upd_time = monotime(NULL);
Expand Down

0 comments on commit 645a9e4

Please sign in to comment.