Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to import BMP information from a separate BGP instance #17639

Merged
merged 23 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c5ce29a
bgpd: bmp, rename bmp->targets->bgp with peer->bgp
pguibert6WIND Sep 23, 2024
2a60986
bgpd: add 'bmp import-vrf-view' command
pguibert6WIND Sep 19, 2024
c2c95b2
bgpd: bmp, rework the bmp_route_update() function
pguibert6WIND Sep 19, 2024
c032d53
bgpd: bmp, handle imported bgp instances for route updates
pguibert6WIND Sep 20, 2024
f8a6933
bgpd: bmp, handle imported bgp instances for peer up/down events
pguibert6WIND Nov 7, 2024
ee605d8
bgpd: bmp, handle imported bgp instances in bmp_process
pguibert6WIND Sep 20, 2024
b1ebe54
bgpd: bmp, handle imported bgp instances in bmp_mirror
pguibert6WIND Sep 20, 2024
841ae62
bgpd: bmp, handle imported bgp instances in bmp_send_peerup()
pguibert6WIND Sep 23, 2024
5fda10f
bgpd: bmp, handle imported bgp instances for bmp statistics
pguibert6WIND Sep 23, 2024
f52e963
topotests: bgp_bmp, add test for import-vrf-view service
pguibert6WIND Oct 28, 2024
3e63abf
bgpd: bmp, fix memory leak in peer messages
pguibert6WIND Dec 17, 2024
b68b4aa
bgpd: modify bmp_bgp_update_vrf_status() API
pguibert6WIND Nov 7, 2024
ab31e96
bgpd, topotests: bmp, add loc-rib peer up event for imported bgp
pguibert6WIND Dec 19, 2024
2bd5cd1
bgpd, topotests: bmp imported bgp, add loc-rib peer up support when r…
pguibert6WIND Dec 19, 2024
6289171
bgpd, topotests: bmp imported bgp, add loc-rib peer up support when v…
pguibert6WIND Dec 19, 2024
ca7699f
bgpd, topotests: bmp, send peer down when unconfiguring imported vrf
pguibert6WIND Nov 12, 2024
6c7b2ab
bgpd, topotests: bmp imported bgp, send peer up events when config pa…
pguibert6WIND Dec 2, 2024
3e05ba0
bgpd: fix access to invalid memory zone
pguibert6WIND Dec 19, 2024
d34fe66
bgpd: rework bmp end of rib processing
pguibert6WIND Dec 16, 2024
b79574b
bgpd: add sync for monitored afi/safi of imported bgps
pguibert6WIND Nov 11, 2024
ffdb4cd
bgpd: bmp, handle imported bgp instances in bmp end of rib
pguibert6WIND Dec 3, 2024
51cedaa
topotests: bmp, test syncro for pre/post-policy of imported bgps
pguibert6WIND Nov 12, 2024
9f2932d
doc: add bmp import-vrf-view on the bmp user guide
pguibert6WIND Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading