summaryrefslogtreecommitdiffstats
path: root/lib/stream.c
diff options
context:
space:
mode:
authorPradosh Mohapatra <pmohapat@cumulusnetworks.com>2014-01-15 07:57:57 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2014-06-03 15:08:32 +0200
commit8c71e481dae11b7ae3f1ef561a989624b2ae84b6 (patch)
tree4c13b76e1b9aedc45ad9b086be972ba4999ada03 /lib/stream.c
parentbgpd: don't compare next-hop to router-id (diff)
downloadfrr-8c71e481dae11b7ae3f1ef561a989624b2ae84b6.tar.xz
frr-8c71e481dae11b7ae3f1ef561a989624b2ae84b6.zip
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>
Diffstat (limited to 'lib/stream.c')
-rw-r--r--lib/stream.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/stream.c b/lib/stream.c
index ccd4623ff..9a6fcbcf2 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -154,6 +154,25 @@ stream_dup (struct stream *s)
return (stream_copy (new, s));
}
+struct stream *
+stream_dupcat (struct stream *s1, struct stream *s2, size_t offset)
+{
+ struct stream *new;
+
+ STREAM_VERIFY_SANE (s1);
+ STREAM_VERIFY_SANE (s2);
+
+ if ( (new = stream_new (s1->endp + s2->endp)) == NULL)
+ return NULL;
+
+ memcpy (new->data, s1->data, offset);
+ memcpy (new->data + offset, s2->data, s2->endp);
+ memcpy (new->data + offset + s2->endp, s1->data + offset,
+ (s1->endp - offset));
+ new->endp = s1->endp + s2->endp;
+ return new;
+}
+
size_t
stream_resize (struct stream *s, size_t newsize)
{