summaryrefslogtreecommitdiff
path: root/lib/stream.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-05-19 18:03:47 -0700
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-05-19 18:03:47 -0700
commit3f9c7369f7112d87007b87a5faaa61cdd5e24c39 (patch)
tree2a9f7a8368ea0468932fbb2fd755f8aa92f7a3d9 /lib/stream.c
parent759a13f3ccad95e2717871b803729d49be18d995 (diff)
BGP: Add dynamic update group support
This patch implements the 'update-groups' functionality in BGP. This is a function that can significantly improve BGP performance for Update generation and resultant network convergence. BGP Updates are formed for "groups" of peers and then replicated and sent out to each peer rather than being formed for each peer. Thus major BGP operations related to outbound policy application, adj-out maintenance and actual Update packet formation are optimized. BGP update-groups dynamically groups peers together based on configuration as well as run-time criteria. Thus, it is more flexible than update-formation based on peer-groups, which relies on operator configuration. [Note that peer-group based update formation has been introduced into BGP by Cumulus but is currently intended only for specific releases.] From 11098af65b2b8f9535484703e7f40330a71cbae4 Mon Sep 17 00:00:00 2001 Subject: [PATCH] updgrp commits
Diffstat (limited to 'lib/stream.c')
-rw-r--r--lib/stream.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/stream.c b/lib/stream.c
index 0fc3c3b118..cc5898a6db 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -401,6 +401,21 @@ stream_getl_from (struct stream *s, size_t from)
return l;
}
+/* Copy from stream at specific location to destination. */
+void
+stream_get_from (void *dst, struct stream *s, size_t from, size_t size)
+{
+ STREAM_VERIFY_SANE(s);
+
+ if (!GETP_VALID (s, from + size))
+ {
+ STREAM_BOUND_WARN (s, "get from");
+ return;
+ }
+
+ memcpy (dst, s->data + from, size);
+}
+
u_int32_t
stream_getl (struct stream *s)
{
@@ -709,6 +724,38 @@ stream_put_in_addr (struct stream *s, struct in_addr *addr)
return sizeof (u_int32_t);
}
+/* Put in_addr at location in the stream. */
+int
+stream_put_in_addr_at (struct stream *s, size_t putp, struct in_addr *addr)
+{
+ STREAM_VERIFY_SANE(s);
+
+ if (!PUT_AT_VALID (s, putp + 4))
+ {
+ STREAM_BOUND_WARN (s, "put");
+ return 0;
+ }
+
+ memcpy (&s->data[putp], addr, 4);
+ return 4;
+}
+
+/* Put in6_addr at location in the stream. */
+int
+stream_put_in6_addr_at (struct stream *s, size_t putp, struct in6_addr *addr)
+{
+ STREAM_VERIFY_SANE(s);
+
+ if (!PUT_AT_VALID (s, putp + 16))
+ {
+ STREAM_BOUND_WARN (s, "put");
+ return 0;
+ }
+
+ memcpy (&s->data[putp], addr, 16);
+ return 16;
+}
+
/* Put prefix by nlri type format. */
int
stream_put_prefix (struct stream *s, struct prefix *p)