Skip to content

Commit

Permalink
Merge pull request #17639 from pguibert6WIND/bmp_import_vrf_view
Browse files Browse the repository at this point in the history
Ability to import BMP information from a separate BGP instance
  • Loading branch information
riw777 authored Jan 14, 2025
2 parents ba4122d + 9f2932d commit b4619da
Show file tree
Hide file tree
Showing 21 changed files with 1,691 additions and 190 deletions.
801 changes: 614 additions & 187 deletions bgpd/bgp_bmp.c

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions bgpd/bgp_bmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct bmp_mirrorq {
uint8_t data[0];
};

enum {
enum bmp_afi_state {
BMP_AFI_INACTIVE = 0,
BMP_AFI_NEEDSYNC,
BMP_AFI_SYNC,
Expand Down Expand Up @@ -148,6 +148,7 @@ struct bmp {
uint64_t syncpeerid;
afi_t syncafi;
safi_t syncsafi;
struct bgp *sync_bgp;
};

/* config & state for an active outbound connection. When the connection
Expand Down Expand Up @@ -195,6 +196,9 @@ struct bmp_listener {
int sock;
};

/* config for imported bgp instances */
PREDECL_SORTLIST_UNIQ(bmp_imported_bgps);

/* bmp_targets - plural since it may contain multiple bmp_listener &
* bmp_active items. If they have the same config, BMP session should be
* put in the same targets since that's a bit more effective.
Expand All @@ -206,6 +210,7 @@ struct bmp_targets {

struct bmp_bgp *bmpbgp;
struct bgp *bgp;
bool bgp_request_sync[AFI_MAX][SAFI_MAX];
char *name;

struct bmp_listeners_head listeners;
Expand Down Expand Up @@ -238,6 +243,8 @@ struct bmp_targets {
struct bmp_qhash_head locupdhash;
struct bmp_qlist_head locupdlist;

struct bmp_imported_bgps_head imported_bgps;

uint64_t cnt_accept, cnt_aclrefused;

bool stats_send_experimental;
Expand Down Expand Up @@ -274,6 +281,14 @@ enum bmp_vrf_state {
vrf_state_up = 1,
};

struct bmp_imported_bgp {
struct bmp_imported_bgps_item bib;
struct bmp_targets *targets;
char *name;
enum bmp_vrf_state vrf_state;
bool bgp_request_sync[AFI_MAX][SAFI_MAX];
};

struct bmp_bgp {
struct bmp_bgph_item bbi;

Expand All @@ -289,7 +304,8 @@ struct bmp_bgp {
size_t mirror_qsizelimit;
};

extern bool bmp_bgp_update_vrf_status(struct bmp_bgp *bmpbgp, enum bmp_vrf_state force);
extern bool bmp_bgp_update_vrf_status(enum bmp_vrf_state *vrf_state, struct bgp *bgp,
enum bmp_vrf_state force);

enum {
/* RFC7854 - 10.8 */
Expand Down
3 changes: 2 additions & 1 deletion bgpd/bgp_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ TRACEPOINT_LOGLEVEL(frr_bgp, bmp_mirror_packet, TRACE_INFO)
TRACEPOINT_EVENT(
frr_bgp,
bmp_eor,
TP_ARGS(afi_t, afi, safi_t, safi, uint8_t, flags, uint8_t, peer_type_flag),
TP_ARGS(afi_t, afi, safi_t, safi, uint8_t, flags, uint8_t, peer_type_flag, bgp),
TP_FIELDS(
ctf_integer(afi_t, afi, afi)
ctf_integer(safi_t, safi, safi)
ctf_integer(uint8_t, flags, flags)
ctf_integer(uint8_t, peer_type_flag, peer_type_flag)
ctf_string(bgp, bgp->name_pretty)
)
)

Expand Down
5 changes: 5 additions & 0 deletions doc/user/bmp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,8 @@ associated with a particular ``bmp targets``:

All BGP neighbors are included in Route Mirroring. Options to select
a subset of BGP sessions may be added in the future.

.. clicmd:: bmp import-vrf-view VRF_OR_VIEW_NAME

Perform Route Mirroring and Route Monitoring from an other BGP
instance.
34 changes: 34 additions & 0 deletions tests/topotests/bgp_bmp/bmp1import/bmp-update-loc-rib-step1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"loc-rib": {
"update": {
"172.31.0.77/32": {
"as_path": "",
"bgp_nexthop": "192.168.1.3",
"bmp_log_type": "update",
"ip_prefix": "172.31.0.77/32",
"is_filtered": false,
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.0.1",
"peer_distinguisher": "444:1",
"peer_type": "loc-rib instance",
"policy": "loc-rib"
},
"2001::1125/128": {
"afi": 2,
"as_path": "",
"bmp_log_type": "update",
"ip_prefix": "2001::1125/128",
"is_filtered": false,
"nxhp_ip": "192:167::3",
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.0.1",
"peer_distinguisher": "555:1",
"peer_type": "loc-rib instance",
"policy": "loc-rib",
"safi": 1
}
}
}
}
34 changes: 34 additions & 0 deletions tests/topotests/bgp_bmp/bmp1import/bmp-update-loc-rib-step2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"loc-rib": {
"update": {
"172.31.0.77/32": {
"as_path": "",
"bgp_nexthop": "192.168.1.3",
"bmp_log_type": "update",
"ip_prefix": "172.31.0.77/32",
"is_filtered": false,
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.0.1",
"peer_distinguisher": "666:22",
"peer_type": "loc-rib instance",
"policy": "loc-rib"
},
"2001::1125/128": {
"afi": 2,
"as_path": "",
"bmp_log_type": "update",
"ip_prefix": "2001::1125/128",
"is_filtered": false,
"nxhp_ip": "192:167::3",
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.0.1",
"peer_distinguisher": "666:22",
"peer_type": "loc-rib instance",
"policy": "loc-rib",
"safi": 1
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"post-policy": {
"update": {
"172.31.0.77/32": {
"as_path": "",
"bgp_nexthop": "192.168.1.3",
"bmp_log_type": "update",
"ip_prefix": "172.31.0.77/32",
"ipv6": false,
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.1.3",
"peer_distinguisher": "444:1",
"peer_ip": "192.168.1.3",
"peer_type": "route distinguisher instance",
"policy": "post-policy"
},
"2001::1125/128": {
"afi": 2,
"as_path": "",
"bmp_log_type": "update",
"ip_prefix": "2001::1125/128",
"ipv6": true,
"nxhp_ip": "192:167::3",
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.1.3",
"peer_distinguisher": "555:1",
"peer_ip": "192:167::3",
"peer_type": "route distinguisher instance",
"policy": "post-policy",
"safi": 1
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"post-policy": {
"update": {
"172.31.0.77/32": {
"as_path": "",
"bgp_nexthop": "192.168.1.3",
"bmp_log_type": "update",
"ip_prefix": "172.31.0.77/32",
"ipv6": false,
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.1.3",
"peer_distinguisher": "666:22",
"peer_ip": "192.168.1.3",
"peer_type": "route distinguisher instance",
"policy": "post-policy"
},
"2001::1125/128": {
"afi": 2,
"as_path": "",
"bmp_log_type": "update",
"ip_prefix": "2001::1125/128",
"ipv6": true,
"nxhp_ip": "192:167::3",
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.1.3",
"peer_distinguisher": "666:22",
"peer_ip": "192:167::3",
"peer_type": "route distinguisher instance",
"policy": "post-policy",
"safi": 1
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"pre-policy": {
"update": {
"172.31.0.77/32": {
"as_path": "",
"bgp_nexthop": "192.168.1.3",
"bmp_log_type": "update",
"ip_prefix": "172.31.0.77/32",
"ipv6": false,
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.1.3",
"peer_distinguisher": "444:1",
"peer_ip": "192.168.1.3",
"peer_type": "route distinguisher instance",
"policy": "pre-policy"
},
"2001::1125/128": {
"afi": 2,
"as_path": "",
"bmp_log_type": "update",
"ip_prefix": "2001::1125/128",
"ipv6": true,
"nxhp_ip": "192:167::3",
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.1.3",
"peer_distinguisher": "555:1",
"peer_ip": "192:167::3",
"peer_type": "route distinguisher instance",
"policy": "pre-policy",
"safi": 1
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"pre-policy": {
"update": {
"172.31.0.77/32": {
"as_path": "",
"bgp_nexthop": "192.168.1.3",
"bmp_log_type": "update",
"ip_prefix": "172.31.0.77/32",
"ipv6": false,
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.1.3",
"peer_distinguisher": "666:22",
"peer_ip": "192.168.1.3",
"peer_type": "route distinguisher instance",
"policy": "pre-policy"
},
"2001::1125/128": {
"afi": 2,
"as_path": "",
"bmp_log_type": "update",
"ip_prefix": "2001::1125/128",
"ipv6": true,
"nxhp_ip": "192:167::3",
"origin": "IGP",
"peer_asn": 65501,
"peer_bgp_id": "192.168.1.3",
"peer_distinguisher": "666:22",
"peer_ip": "192:167::3",
"peer_type": "route distinguisher instance",
"policy": "pre-policy",
"safi": 1
}
}
}
}
28 changes: 28 additions & 0 deletions tests/topotests/bgp_bmp/bmp1import/bmp-withdraw-loc-rib-step1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"loc-rib": {
"withdraw": {
"172.31.0.77/32": {
"bmp_log_type": "withdraw",
"ip_prefix": "172.31.0.77/32",
"is_filtered": false,
"peer_asn": 65501,
"peer_bgp_id": "192.168.0.1",
"peer_distinguisher": "444:1",
"peer_type": "loc-rib instance",
"policy": "loc-rib"
},
"2001::1125/128": {
"afi": 2,
"bmp_log_type": "withdraw",
"ip_prefix": "2001::1125/128",
"is_filtered": false,
"peer_asn": 65501,
"peer_bgp_id": "192.168.0.1",
"peer_distinguisher": "555:1",
"peer_type": "loc-rib instance",
"policy": "loc-rib",
"safi": 1
}
}
}
}
34 changes: 34 additions & 0 deletions tests/topotests/bgp_bmp/bmp1import/bmp-withdraw-loc-rib-step2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"loc-rib": {
"withdraw": {
"172.31.0.15/32": {
"afi": 1,
"bmp_log_type": "withdraw",
"ip_prefix": "172.31.0.15/32",
"is_filtered": false,
"label": 0,
"peer_asn": 65501,
"peer_bgp_id": "192.168.0.1",
"peer_distinguisher": "0:0",
"peer_type": "loc-rib instance",
"policy": "loc-rib",
"rd": "444:2",
"safi": 128
},
"2001::1111/128": {
"afi": 2,
"bmp_log_type": "withdraw",
"ip_prefix": "2001::1111/128",
"is_filtered": false,
"label": 0,
"peer_asn": 65501,
"peer_bgp_id": "192.168.0.1",
"peer_distinguisher": "0:0",
"peer_type": "loc-rib instance",
"policy": "loc-rib",
"rd": "555:2",
"safi": 128
}
}
}
}
Loading

0 comments on commit b4619da

Please sign in to comment.