Skip to content

Commit 6fe9092

Browse files
committed
zebra: zebra crash for zapi stream
Issue: If static route is created with a BGP route as nexthop, which recursively resolves over 512 ECMP v6 nexthops, zapi nexthop encode fails, as there is not enough memory allocated for stream. This causes assert/core dump in zebra. Right now we allocate fixed memory of ZEBRA_MAX_PACKET_SIZ size. Fix: 1)Dynamically calculate required memory size for the stream 2)try to optimize memory usage Testing: No crash happens anymore with the fix zebra: zebra crash for zapi stream Issue: If static route is created with a BGP route as nexthop, which recursively resolves over 512 ECMP v6 nexthops, zapi nexthop encode fails, as there is not enough memory allocated for stream. This causes assert/core dump in zebra. Right now we allocate fixed memory of ZEBRA_MAX_PACKET_SIZ size. Fix: 1)Dynamically calculate required memory size for the stream 2)try to optimize memory usage Testing: No crash happens anymore with the fix r1# r1# sharp install routes 2100:cafe:: nexthop 2001:db8::1 1000 r1# r2# conf r2(config)# ipv6 route 2503:feca::100/128 2100:cafe::1 r2(config)# exit r2# Signed-off-by: Soumya Roy <[email protected]>
1 parent 4de0f16 commit 6fe9092

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

zebra/zebra_rnh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ int zebra_send_rnh_update(struct rnh *rnh, struct zserv *client,
11501150
re = rnh->state;
11511151

11521152
/* Get output stream. */
1153-
s = stream_new(ZEBRA_MAX_PACKET_SIZ);
1153+
s = stream_new_expandable(ZEBRA_MAX_PACKET_SIZ);
11541154

11551155
zclient_create_header(s, ZEBRA_NEXTHOP_UPDATE, vrf_id);
11561156

0 commit comments

Comments
 (0)