From: Ondrej Zajicek Date: Tue, 3 Dec 2024 17:48:20 +0000 (+0100) Subject: Merge commit '5205ff97448cc34cf7334e90172c28eb48f227f2' into thread-next X-Git-Tag: v3.0.0~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abc43c097ad4eaf092374ca72ee214cd7d26d223;p=thirdparty%2Fbird.git Merge commit '5205ff97448cc34cf7334e90172c28eb48f227f2' into thread-next --- abc43c097ad4eaf092374ca72ee214cd7d26d223 diff --cc proto/bmp/bmp.c index 05c718254,1af101ae4..51b04f5d3 --- a/proto/bmp/bmp.c +++ b/proto/bmp/bmp.c @@@ -543,10 -511,10 +515,9 @@@ bmp_route_monitor_msg_serialize(struct } static void - bmp_peer_up_notif_msg_serialize(buffer *stream, const bool is_peer_global, - const u32 peer_as, const u32 peer_bgp_id, const bool as4_support, - const ip_addr local_addr, const ip_addr remote_addr, const u16 local_port, - const u16 remote_port, const adata *sent_msg, const adata *recv_msg) + bmp_peer_up_notif_msg_serialize(buffer *stream, const struct bmp_peer_hdr_info *peer, + const ip_addr local_addr, const u16 local_port, const u16 remote_port, - const byte *sent_msg, const size_t sent_msg_length, - const byte *recv_msg, const size_t recv_msg_length) ++ const adata *sent_msg, const adata *recv_msg) { const size_t data_size = BMP_PER_PEER_HDR_SIZE + BMP_PEER_UP_NOTIF_MSG_FIX_SIZE + @@@ -930,33 -854,43 +896,35 @@@ bmp_send_peer_up_notif_msg(struct bmp_p { ASSERT(p->started); - const int rem_as = ea_get_int(bgp, &ea_bgp_rem_as, 0); - const int rem_id = ea_get_int(bgp, &ea_bgp_rem_id, 0); - const bool is_global_instance_peer = bmp_is_peer_global_instance(bgp); - const struct birdsock *sk = bmp_get_birdsock_ext(bgp); - if (!sk) - { - log(L_WARN "%s: No BGP socket", p->p.name); - return; - } - + struct bmp_peer_hdr_info peer = { - .address = bgp->remote_ip, - .as = bgp->remote_as, - .id = bgp->remote_id, ++ .address = ea_get_ip(bgp, &ea_bgp_rem_ip, IPA_NONE), ++ .as = ea_get_int(bgp, &ea_bgp_rem_as, 0), ++ .id = ea_get_int(bgp, &ea_bgp_rem_id, 0), + .global = bmp_is_peer_global_instance(bgp), + .policy = false, // Hardcoded pre-policy Adj-RIB-In + .timestamp = 0, // No timestamp provided + }; buffer payload = bmp_default_buffer(p); - bmp_peer_up_notif_msg_serialize(&payload, is_global_instance_peer, - rem_as, rem_id, 1, - sk->saddr, sk->daddr, sk->sport, sk->dport, tx_data, rx_data); - bmp_peer_up_notif_msg_serialize(&payload, &peer, sk->saddr, sk->sport, sk->dport, - tx_data, tx_data_size, rx_data, rx_data_size); ++ bmp_peer_up_notif_msg_serialize(&payload, &peer, sk->saddr, sk->sport, sk->dport, tx_data, rx_data); bmp_schedule_tx_packet(p, payload.start, payload.pos - payload.start); } static void bmp_route_monitor_put_update(struct bmp_proto *p, struct bmp_stream *bs, byte *data, size_t length, btime timestamp) { - struct bgp_proto *bgp = bs->bgp; + ea_list *bgp = bs->bgp; - const byte *start = bmp_route_monitor_msg_serialize(p, - bmp_is_peer_global_instance(bgp), - bmp_stream_policy(bs), - ea_get_int(bgp, &ea_bgp_rem_as, 0), - ea_get_int(bgp, &ea_bgp_rem_id, 0), - true, - ea_get_ip(bgp, &ea_bgp_rem_ip, IPA_NONE), - data, - length, - timestamp - ); + struct bmp_peer_hdr_info peer = { - .address = bgp->remote_ip, - .as = bgp->remote_as, - .id = bgp->remote_id, ++ .address = ea_get_ip(bgp, &ea_bgp_rem_ip, IPA_NONE), ++ .as = ea_get_int(bgp, &ea_bgp_rem_as, 0), ++ .id = ea_get_int(bgp, &ea_bgp_rem_id, 0), + .global = bmp_is_peer_global_instance(bgp), + .policy = bmp_stream_policy(bs), + .timestamp = timestamp, + }; + + const byte *start = bmp_route_monitor_msg_serialize(p, &peer, data, length); bmp_schedule_tx_packet(p, start, (data - start) + length); } @@@ -1006,29 -932,20 +974,29 @@@ bmp_send_peer_down_notif_msg(struct bmp { ASSERT(p->started); - //const struct bgp_caps *remote_caps = bmp_get_bgp_remote_caps_ext(bgp); - int remote_caps = ea_get_int(bgp, &ea_bgp_as4_session, 0); - const struct bgp_caps *remote_caps = bmp_get_bgp_remote_caps_ext(bgp); ++ int as4_session = ea_get_int(bgp, &ea_bgp_as4_session, 0); + int in_state = ea_get_int(bgp, &ea_bgp_in_conn_state, 0); + int out_state = ea_get_int(bgp, &ea_bgp_out_conn_state, 0); + int in_as4 = ea_get_int(bgp, &ea_bgp_as4_in_conn, 0); + int out_as4 = ea_get_int(bgp, &ea_bgp_as4_out_conn, 0); + + if (in_state && in_as4) - remote_caps = in_as4; ++ as4_session = in_as4; + else if (out_state && out_as4) - remote_caps = out_as4; ++ as4_session = out_as4; + + struct bmp_peer_hdr_info peer = { - .address = bgp->remote_ip, - .as = bgp->remote_as, - .id = bgp->remote_id, ++ .address = ea_get_ip(bgp, &ea_bgp_rem_ip, IPA_NONE), ++ .as = ea_get_int(bgp, &ea_bgp_rem_as, 0), ++ .id = ea_get_int(bgp, &ea_bgp_rem_id, 0), + .global = bmp_is_peer_global_instance(bgp), + .policy = false, // Hardcoded pre-policy Adj-RIB-In - .no_as4 = remote_caps ? !remote_caps->as4_support : !bgp->as4_session, ++ .no_as4 = !as4_session, + .timestamp = 0, // No timestamp provided + }; - bool is_global_instance_peer = bmp_is_peer_global_instance(bgp); buffer payload = bmp_default_buffer(p); - bmp_peer_down_notif_msg_serialize( - &payload, - is_global_instance_peer, - ea_get_int(bgp, &ea_bgp_rem_as, 0), - ea_get_int(bgp, &ea_bgp_rem_id, 0), - remote_caps, - *((ip_addr *) ea_get_adata(bgp, &ea_bgp_rem_ip)->data), - info - ); + bmp_peer_down_notif_msg_serialize(&payload, &peer, info); bmp_schedule_tx_packet(p, payload.start, payload.pos - payload.start); }