mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-27 15:23:39 +00:00
bgpd: fix loc-rib open message should use router-id
When forging BMP open message, the BGP router-id of tx open message of the BMP LOC-RIB peer up message is always set to 0.0.0.0, whatever the configured value of 'bgp router-id'. Actually, when forging a peer up LOC-RIB message, the BGP router-id value should be taken from the main BGP instance, and not from the peer bgp identifier. Fix this by refreshing the router-id whenever a peer up loc-rib message should be sent. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
baf4c1a78f
commit
2a143041f8
@ -56,6 +56,7 @@ static int bmp_route_update_bgpbmp(struct bmp_targets *bt, afi_t afi, safi_t saf
|
|||||||
static void bmp_send_all_bgp(struct peer *peer, bool down);
|
static void bmp_send_all_bgp(struct peer *peer, bool down);
|
||||||
static struct bmp_imported_bgp *bmp_imported_bgp_find(struct bmp_targets *bt, char *name);
|
static struct bmp_imported_bgp *bmp_imported_bgp_find(struct bmp_targets *bt, char *name);
|
||||||
static void bmp_stats_per_instance(struct bgp *bgp, struct bmp_targets *bt);
|
static void bmp_stats_per_instance(struct bgp *bgp, struct bmp_targets *bt);
|
||||||
|
static void bmp_bgp_peer_vrf(struct bmp_bgp_peer *bbpeer, struct bgp *bgp);
|
||||||
|
|
||||||
DEFINE_MGROUP(BMP, "BMP (BGP Monitoring Protocol)");
|
DEFINE_MGROUP(BMP, "BMP (BGP Monitoring Protocol)");
|
||||||
|
|
||||||
@ -551,9 +552,12 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)
|
|||||||
|
|
||||||
bbpeer = bmp_bgp_peer_find(peer->qobj_node.nid);
|
bbpeer = bmp_bgp_peer_find(peer->qobj_node.nid);
|
||||||
|
|
||||||
if (bbpeer && bbpeer->open_tx)
|
if (bbpeer && bbpeer->open_tx) {
|
||||||
|
if (is_locrib)
|
||||||
|
/* update bgp id each time peer up LOC-RIB message is to be sent */
|
||||||
|
bmp_bgp_peer_vrf(bbpeer, peer->bgp);
|
||||||
stream_put(s, bbpeer->open_tx, bbpeer->open_tx_len);
|
stream_put(s, bbpeer->open_tx, bbpeer->open_tx_len);
|
||||||
else {
|
} else {
|
||||||
stream_put(s, dummy_open, sizeof(dummy_open));
|
stream_put(s, dummy_open, sizeof(dummy_open));
|
||||||
zlog_warn("bmp: missing TX OPEN message for peer %s",
|
zlog_warn("bmp: missing TX OPEN message for peer %s",
|
||||||
peer->host);
|
peer->host);
|
||||||
@ -2209,6 +2213,8 @@ static void bmp_bgp_peer_vrf(struct bmp_bgp_peer *bbpeer, struct bgp *bgp)
|
|||||||
struct peer *peer = bgp->peer_self;
|
struct peer *peer = bgp->peer_self;
|
||||||
uint16_t send_holdtime;
|
uint16_t send_holdtime;
|
||||||
as_t local_as;
|
as_t local_as;
|
||||||
|
struct stream *s;
|
||||||
|
size_t open_len;
|
||||||
|
|
||||||
if (CHECK_FLAG(peer->flags, PEER_FLAG_TIMER))
|
if (CHECK_FLAG(peer->flags, PEER_FLAG_TIMER))
|
||||||
send_holdtime = peer->holdtime;
|
send_holdtime = peer->holdtime;
|
||||||
@ -2221,8 +2227,8 @@ static void bmp_bgp_peer_vrf(struct bmp_bgp_peer *bbpeer, struct bgp *bgp)
|
|||||||
else
|
else
|
||||||
local_as = peer->local_as;
|
local_as = peer->local_as;
|
||||||
|
|
||||||
struct stream *s = bgp_open_make(peer, send_holdtime, local_as);
|
s = bgp_open_make(peer, send_holdtime, local_as, &peer->local_id);
|
||||||
size_t open_len = stream_get_endp(s);
|
open_len = stream_get_endp(s);
|
||||||
|
|
||||||
bbpeer->open_rx_len = open_len;
|
bbpeer->open_rx_len = open_len;
|
||||||
if (bbpeer->open_rx)
|
if (bbpeer->open_rx)
|
||||||
@ -2230,6 +2236,10 @@ static void bmp_bgp_peer_vrf(struct bmp_bgp_peer *bbpeer, struct bgp *bgp)
|
|||||||
bbpeer->open_rx = XMALLOC(MTYPE_BMP_OPEN, open_len);
|
bbpeer->open_rx = XMALLOC(MTYPE_BMP_OPEN, open_len);
|
||||||
memcpy(bbpeer->open_rx, s->data, open_len);
|
memcpy(bbpeer->open_rx, s->data, open_len);
|
||||||
|
|
||||||
|
stream_free(s);
|
||||||
|
|
||||||
|
s = bgp_open_make(peer, send_holdtime, local_as, &bgp->router_id);
|
||||||
|
open_len = stream_get_endp(s);
|
||||||
bbpeer->open_tx_len = open_len;
|
bbpeer->open_tx_len = open_len;
|
||||||
if (bbpeer->open_tx)
|
if (bbpeer->open_tx)
|
||||||
XFREE(MTYPE_BMP_OPEN, bbpeer->open_tx);
|
XFREE(MTYPE_BMP_OPEN, bbpeer->open_tx);
|
||||||
|
@ -637,7 +637,8 @@ void bgp_keepalive_send(struct peer *peer)
|
|||||||
bgp_writes_on(peer->connection);
|
bgp_writes_on(peer->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stream *bgp_open_make(struct peer *peer, uint16_t send_holdtime, as_t local_as)
|
struct stream *bgp_open_make(struct peer *peer, uint16_t send_holdtime, as_t local_as,
|
||||||
|
struct in_addr *id)
|
||||||
{
|
{
|
||||||
struct stream *s = stream_new(BGP_STANDARD_MESSAGE_MAX_PACKET_SIZE);
|
struct stream *s = stream_new(BGP_STANDARD_MESSAGE_MAX_PACKET_SIZE);
|
||||||
bool ext_opt_params = false;
|
bool ext_opt_params = false;
|
||||||
@ -650,7 +651,7 @@ struct stream *bgp_open_make(struct peer *peer, uint16_t send_holdtime, as_t loc
|
|||||||
stream_putw(s, (local_as <= BGP_AS_MAX) ? (uint16_t)local_as
|
stream_putw(s, (local_as <= BGP_AS_MAX) ? (uint16_t)local_as
|
||||||
: BGP_AS_TRANS);
|
: BGP_AS_TRANS);
|
||||||
stream_putw(s, send_holdtime); /* Hold Time */
|
stream_putw(s, send_holdtime); /* Hold Time */
|
||||||
stream_put_in_addr(s, &peer->local_id); /* BGP Identifier */
|
stream_put_in_addr(s, id); /* BGP Identifier */
|
||||||
|
|
||||||
/* Set capabilities */
|
/* Set capabilities */
|
||||||
if (CHECK_FLAG(peer->flags, PEER_FLAG_EXTENDED_OPT_PARAMS)) {
|
if (CHECK_FLAG(peer->flags, PEER_FLAG_EXTENDED_OPT_PARAMS)) {
|
||||||
@ -705,7 +706,7 @@ void bgp_open_send(struct peer_connection *connection)
|
|||||||
else
|
else
|
||||||
local_as = peer->local_as;
|
local_as = peer->local_as;
|
||||||
|
|
||||||
s = bgp_open_make(peer, send_holdtime, local_as);
|
s = bgp_open_make(peer, send_holdtime, local_as, &peer->local_id);
|
||||||
|
|
||||||
/* Dump packet if debug option is set. */
|
/* Dump packet if debug option is set. */
|
||||||
/* bgp_packet_dump (s); */
|
/* bgp_packet_dump (s); */
|
||||||
|
@ -49,7 +49,8 @@ DECLARE_HOOK(bgp_packet_send,
|
|||||||
|
|
||||||
/* Packet send and receive function prototypes. */
|
/* Packet send and receive function prototypes. */
|
||||||
extern void bgp_keepalive_send(struct peer *peer);
|
extern void bgp_keepalive_send(struct peer *peer);
|
||||||
extern struct stream *bgp_open_make(struct peer *peer, uint16_t send_holdtime, as_t local_as);
|
extern struct stream *bgp_open_make(struct peer *peer, uint16_t send_holdtime, as_t local_as,
|
||||||
|
struct in_addr *id);
|
||||||
extern void bgp_open_send(struct peer_connection *connection);
|
extern void bgp_open_send(struct peer_connection *connection);
|
||||||
extern void bgp_notify_send(struct peer_connection *connection, uint8_t code,
|
extern void bgp_notify_send(struct peer_connection *connection, uint8_t code,
|
||||||
uint8_t sub_code);
|
uint8_t sub_code);
|
||||||
|
Loading…
Reference in New Issue
Block a user