summaryrefslogtreecommitdiff
path: root/proto/bgp/packets.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2023-06-08 04:56:41 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2023-06-08 05:03:15 +0200
commite8838d930cd5c875f32aa2b7da5d84995b14ccac (patch)
tree4cb70981a898dd1d294e6074399a76a6ab679537 /proto/bgp/packets.c
parent0799fc99abb523432bc3f903f6a32eafbe37d043 (diff)
BMP: Support multiple instances of BMP protocol
Add internal BMP functions with plicit bmp_proto *p as first argument, which allows using TRACE() macro. Keep list of BMP instances and call internal functions. Old BMP functions are wrappers that call internal functions for all enabled BMP instances. Extract End-of-RIB mark into separate function. Based on patch from Michal Zagorski <mzagorsk@akamai.com>. Thanks!
Diffstat (limited to 'proto/bgp/packets.c')
-rw-r--r--proto/bgp/packets.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c
index 63ff955b..0338a887 100644
--- a/proto/bgp/packets.c
+++ b/proto/bgp/packets.c
@@ -2473,11 +2473,10 @@ bgp_bmp_prepare_bgp_hdr(byte *buf, const u16 msg_size, const u8 msg_type)
}
void
-bgp_rte_update_in_notify(struct channel *C, const net_addr *n,
- const struct rte *new, const struct rte_src *src)
+bgp_bmp_encode_rte(struct bgp_channel *c, struct bmp_proto *bmp, const net_addr *n,
+ const struct rte *new, const struct rte_src *src)
{
-// struct bgp_proto *p = (void *) C->proto;
- struct bgp_channel *c = (void *) C;
+// struct bgp_proto *p = (void *) c->c.proto;
byte buf[BGP_MAX_EXT_MSG_LENGTH];
byte *pkt = buf + BGP_HEADER_LENGTH;
@@ -2507,7 +2506,7 @@ bgp_rte_update_in_notify(struct channel *C, const net_addr *n,
return;
bgp_bmp_prepare_bgp_hdr(buf, end - buf, PKT_UPDATE);
- bmp_route_monitor_put_update_in_pre_msg(buf, end - buf);
+ bmp_route_monitor_put_update_in_pre_msg(bmp, buf, end - buf);
}
#endif /* CONFIG_BMP */
@@ -2614,6 +2613,14 @@ bgp_create_mp_end_mark(struct bgp_channel *c, byte *buf)
}
byte *
+bgp_create_end_mark_(struct bgp_channel *c, byte *buf)
+{
+ return (c->afi == BGP_AF_IPV4) ?
+ bgp_create_ip_end_mark(c, buf):
+ bgp_create_mp_end_mark(c, buf);
+}
+
+static byte *
bgp_create_end_mark(struct bgp_channel *c, byte *buf)
{
struct bgp_proto *p = (void *) c->c.proto;
@@ -2621,9 +2628,7 @@ bgp_create_end_mark(struct bgp_channel *c, byte *buf)
BGP_TRACE(D_PACKETS, "Sending END-OF-RIB");
p->stats.tx_updates++;
- return (c->afi == BGP_AF_IPV4) ?
- bgp_create_ip_end_mark(c, buf):
- bgp_create_mp_end_mark(c, buf);
+ return bgp_create_end_mark_(c, buf);
}
static inline void