bgpd: efficient NLRI packing for AFs != ipv4-unicast
ISSUE:
Currently, for non-ipv4-unicast address families where prefixes are
encoded in MP_REACH/MP_UNREACH attributes, BGP ends up sending one
prefix per UPDATE message. This is quite inefficient. The patch
addresses the issue.
PATCH:
We introduce a scratch buffer in the peer structure that stores the
MP_REACH/MP_UNREACH attributes for non-ipv4-unicast families. This
enables us to encode multiple prefixes. In the end, the two buffers
are merged to create the UPDATE packet.
Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
[DL: removed no longer existing bgp_packet_withdraw prototype]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 88d13ed..6a21b11 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -832,6 +832,7 @@
peer->ibuf = stream_new (BGP_MAX_PACKET_SIZE);
peer->obuf = stream_fifo_new ();
peer->work = stream_new (BGP_MAX_PACKET_SIZE);
+ peer->scratch = stream_new (BGP_MAX_PACKET_SIZE);
bgp_sync_init (peer);
@@ -1272,8 +1273,10 @@
stream_fifo_free (peer->obuf);
if (peer->work)
stream_free (peer->work);
+ if (peer->scratch)
+ stream_free(peer->scratch);
peer->obuf = NULL;
- peer->work = peer->ibuf = NULL;
+ peer->work = peer->scratch = peer->ibuf = NULL;
/* Local and remote addresses. */
if (peer->su_local)