summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_updgrp_packet.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2020-01-17 15:04:18 +0100
committerDonatas Abraitis <donatas.abraitis@gmail.com>2020-01-17 15:20:28 +0100
commitfde246e8353af2c870c1ec833a63f6cc7f8d8144 (patch)
treeabfdc9717cf2710571a47856bfda153772d4e680 /bgpd/bgp_updgrp_packet.c
parentdoc: Add some words about `neighbor <X> maximum-prefix-out` cmd (diff)
downloadfrr-fde246e8353af2c870c1ec833a63f6cc7f8d8144.tar.xz
frr-fde246e8353af2c870c1ec833a63f6cc7f8d8144.zip
bgpd: Add an option to limit outgoing prefixes
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'bgpd/bgp_updgrp_packet.c')
-rw-r--r--bgpd/bgp_updgrp_packet.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 9329c8d89..39eb06528 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -744,6 +744,22 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
addpath_tx_id = adj->addpath_tx_id;
path = adv->pathi;
+ /* Check if we need to add a prefix to the packet if
+ * maximum-prefix-out is set for the peer.
+ */
+ if (CHECK_FLAG(peer->af_flags[afi][safi],
+ PEER_FLAG_MAX_PREFIX_OUT)
+ && subgrp->scount >= peer->pmax_out[afi][safi]) {
+ if (BGP_DEBUG(update, UPDATE_OUT)
+ || BGP_DEBUG(update, UPDATE_PREFIX)) {
+ zlog_debug(
+ "%s reached maximum prefix to be send (%" PRIu32
+ ")",
+ peer->host, peer->pmax_out[afi][safi]);
+ }
+ goto next;
+ }
+
space_remaining = STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))
- BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed =
@@ -894,7 +910,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
subgrp->scount++;
adj->attr = bgp_attr_intern(adv->baa->attr);
-
+next:
adv = bgp_advertise_clean_subgroup(subgrp, adj);
}