Skip to content

Commit 645a9e4

Browse files
committed
*: Fix up improper handling of nexthops for nexthop tracking
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 <[email protected]>
1 parent 0aef4e4 commit 645a9e4

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

lib/zclient.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,7 @@ static bool zapi_nexthop_update_decode(struct stream *s, struct prefix *match,
23742374
STREAM_GETW(s, nhr->instance);
23752375
STREAM_GETC(s, nhr->distance);
23762376
STREAM_GETL(s, nhr->metric);
2377-
STREAM_GETC(s, nhr->nexthop_num);
2377+
STREAM_GETW(s, nhr->nexthop_num);
23782378

23792379
for (i = 0; i < nhr->nexthop_num; i++) {
23802380
if (zapi_nexthop_decode(s, &(nhr->nexthops[i]), 0, 0) != 0)

pimd/pim_zlookup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,
193193

194194
distance = stream_getc(s);
195195
metric = stream_getl(s);
196-
nexthop_num = stream_getc(s);
196+
nexthop_num = stream_getw(s);
197197

198198
if (nexthop_num < 1 || nexthop_num > router->multipath) {
199199
if (PIM_DEBUG_PIM_NHT_DETAIL)

staticd/static_zebra.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct static_nht_data {
4343
vrf_id_t nh_vrf_id;
4444

4545
uint32_t refcount;
46-
uint8_t nh_num;
46+
uint16_t nh_num;
4747
bool registered;
4848
};
4949

zebra/zapi_msg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static int zsend_nexthop_lookup_mrib(struct zserv *client, struct ipaddr *addr,
647647
{
648648
struct stream *s;
649649
unsigned long nump;
650-
uint8_t num;
650+
uint16_t num;
651651
struct nexthop *nexthop;
652652

653653
/* Get output stream. */
@@ -667,19 +667,19 @@ static int zsend_nexthop_lookup_mrib(struct zserv *client, struct ipaddr *addr,
667667
/* remember position for nexthop_num */
668668
nump = stream_get_endp(s);
669669
/* reserve room for nexthop_num */
670-
stream_putc(s, 0);
670+
stream_putw(s, 0);
671671
nhg = rib_get_fib_nhg(re);
672672
for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
673673
if (rnh_nexthop_valid(re, nexthop))
674674
num += zserv_encode_nexthop(s, nexthop);
675675
}
676676

677677
/* store nexthop_num */
678-
stream_putc_at(s, nump, num);
678+
stream_putw_at(s, nump, num);
679679
} else {
680680
stream_putc(s, 0); /* distance */
681681
stream_putl(s, 0); /* metric */
682-
stream_putc(s, 0); /* nexthop_num */
682+
stream_putw(s, 0); /* nexthop_num */
683683
}
684684

685685
stream_putw_at(s, 0, stream_get_endp(s));

zebra/zebra_rnh.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ int zebra_send_rnh_update(struct rnh *rnh, struct zserv *client,
11411141
struct stream *s = NULL;
11421142
struct route_entry *re;
11431143
unsigned long nump;
1144-
uint8_t num;
1144+
uint16_t num;
11451145
struct nexthop *nh;
11461146
struct route_node *rn;
11471147
int ret;
@@ -1212,7 +1212,7 @@ int zebra_send_rnh_update(struct rnh *rnh, struct zserv *client,
12121212
stream_putl(s, re->metric);
12131213
num = 0;
12141214
nump = stream_get_endp(s);
1215-
stream_putc(s, 0);
1215+
stream_putw(s, 0);
12161216

12171217
nhg = rib_get_fib_nhg(re);
12181218
for (ALL_NEXTHOPS_PTR(nhg, nh))
@@ -1240,13 +1240,13 @@ int zebra_send_rnh_update(struct rnh *rnh, struct zserv *client,
12401240
}
12411241
}
12421242

1243-
stream_putc_at(s, nump, num);
1243+
stream_putw_at(s, nump, num);
12441244
} else {
12451245
stream_putc(s, 0); // type
12461246
stream_putw(s, 0); // instance
12471247
stream_putc(s, 0); // distance
12481248
stream_putl(s, 0); // metric
1249-
stream_putc(s, 0); // nexthops
1249+
stream_putw(s, 0); // nexthops
12501250
}
12511251
stream_putw_at(s, 0, stream_get_endp(s));
12521252

zebra/zebra_srte.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,
145145
stream_putc(s, nhlfe->distance);
146146
stream_putl(s, 0); /* metric - not available */
147147
nump = stream_get_endp(s);
148-
stream_putc(s, 0);
148+
stream_putw(s, 0);
149149
}
150150

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

156156
num++;
157157
}
158-
stream_putc_at(s, nump, num);
158+
stream_putw_at(s, nump, num);
159159
stream_putw_at(s, 0, stream_get_endp(s));
160160

161161
client->nh_last_upd_time = monotime(NULL);

0 commit comments

Comments
 (0)