From 0a9705a1e07c1d8176fd21f8f1bde2a9a155331b Mon Sep 17 00:00:00 2001 From: Stephane Poignant Date: Thu, 15 Dec 2022 14:53:48 +0100 Subject: [PATCH] bgpd: Add support for flowspec prefixes in bgp_packet_mpattr_prefix_size Currently, bgp_packet_mpattr_prefix_size (bgpd/bgp_attr.c:3978) always returns zero for Flowspec prefixes. This is because, for flowspec prefixes, the prefixlen attribute of the prefix struct is always set to 0, and the actual length is bytes is set inside the flowspec_prefix struct instead (see lib/prefix.h:293 and lib/prefix.h:178). Because of this, with a large number of flowspec NLRIs, bgpd ends up building update messages that exceed the maximum size and cause the peer to drop the connection (bgpd/bgp_updgrp_packet.c:L719). The proposed change allows the bgp_packet_mpattr_prefix_size to return correct result for flowspec prefixes. Signed-off-by: Stephane Poignant --- bgpd/bgp_attr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 06fff41378..337a82b945 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -3986,6 +3986,8 @@ size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi, else if (afi == AFI_L2VPN && safi == SAFI_EVPN) size += 232; // TODO: Maximum possible for type-2, type-3 and // type-5 + else if (safi == SAFI_FLOWSPEC) + size = ((struct prefix_fs *)p)->prefix.prefixlen; return size; } -- 2.39.5