summaryrefslogtreecommitdiff
path: root/proto/bgp
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
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')
-rw-r--r--proto/bgp/bgp.c2
-rw-r--r--proto/bgp/bgp.h6
-rw-r--r--proto/bgp/packets.c21
3 files changed, 18 insertions, 11 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index 17c503c4..54da2253 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -1715,7 +1715,7 @@ bgp_init(struct proto_config *CF)
P->rte_igp_metric = bgp_rte_igp_metric;
#ifdef CONFIG_BMP
- P->rte_update_in_notify = bgp_rte_update_in_notify;
+ P->rte_update_in_notify = bmp_route_monitor_update_in_notify;
#endif
p->cf = cf;
diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
index 5f8f183d..861f831a 100644
--- a/proto/bgp/bgp.h
+++ b/proto/bgp/bgp.h
@@ -631,11 +631,13 @@ struct rte *bgp_rte_modify_stale(struct rte *r, struct linpool *pool);
u32 bgp_rte_igp_metric(struct rte *);
void bgp_rt_notify(struct proto *P, struct channel *C, net *n, rte *new, rte *old);
int bgp_preexport(struct channel *, struct rte *);
-void bgp_rte_update_in_notify(struct channel *C, const net_addr *n, const struct rte *new, const struct rte_src *src);
int bgp_get_attr(const struct eattr *e, byte *buf, int buflen);
void bgp_get_route_info(struct rte *, byte *buf);
int bgp_total_aigp_metric_(rte *e, u64 *metric, const struct adata **ad);
+struct bmp_proto;
+void 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);
+
#define BGP_AIGP_METRIC 1
#define BGP_AIGP_MAX U64(0xffffffffffffffff)
@@ -664,8 +666,8 @@ const char * bgp_error_dsc(unsigned code, unsigned subcode);
void bgp_log_error(struct bgp_proto *p, u8 class, char *msg, unsigned code, unsigned subcode, byte *data, unsigned len);
void bgp_update_next_hop(struct bgp_export_state *s, eattr *a, ea_list **to);
+byte *bgp_create_end_mark_(struct bgp_channel *c, byte *buf);
-byte * bgp_create_end_mark(struct bgp_channel *c, byte *buf);
/* Packet types */
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