#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
#include "bgpd/bgp_dump.h"
+#include "bgpd/bgp_bmp.h"
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_errors.h"
*/
static void bgp_packet_add(struct peer *peer, struct stream *s)
{
- pthread_mutex_lock(&peer->io_mtx);
- stream_fifo_push(peer->obuf, s);
- pthread_mutex_unlock(&peer->io_mtx);
+ frr_with_mutex(&peer->io_mtx) {
+ stream_fifo_push(peer->obuf, s);
+ }
}
static struct stream *bgp_update_packet_eor(struct peer *peer, afi_t afi,
if (bgp_debug_neighbor_events(peer))
zlog_debug("send End-of-RIB for %s to %s",
- afi_safi_print(afi, safi), peer->host);
+ get_afi_safi_str(afi, safi, false), peer->host);
s = stream_new(BGP_MAX_PACKET_SIZE);
struct stream *s;
/* Lock I/O mutex to prevent other threads from pushing packets */
- pthread_mutex_lock(&peer->io_mtx);
+ frr_mutex_lock_autounlock(&peer->io_mtx);
/* ============================================== */
/* Allocate new stream. */
stream_fifo_push(peer->obuf, s);
bgp_write_notify(peer);
-
- /* ============================================== */
- pthread_mutex_unlock(&peer->io_mtx);
}
/*
"%s [FSM] Update packet received under status %s",
peer->host,
lookup_msg(bgp_status_msg, peer->status, NULL));
- bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, 0);
+ bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
+ BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
}
if (peer->nsf[afi][safi])
bgp_clear_stale_route(peer, afi, safi);
- zlog_info("%%NOTIFICATION: rcvd End-of-RIB for %s from %s in vrf %s",
- afi_safi_print(afi, safi), peer->host,
- vrf ? vrf->name : VRF_DEFAULT_NAME);
- }
+ zlog_info(
+ "%s: rcvd End-of-RIB for %s from %s in vrf %s",
+ __func__, get_afi_safi_str(afi, safi, false),
+ peer->host, vrf ? vrf->name : VRF_DEFAULT_NAME);
+ }
}
/* Everything is done. We unintern temporary structures which
"%s [Error] Route refresh packet received under status %s",
peer->host,
lookup_msg(bgp_status_msg, peer->status, NULL));
- bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, 0);
+ bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
+ BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
}
< 5) {
zlog_info("%s ORF route refresh length error",
peer->host);
- bgp_notify_send(peer, BGP_NOTIFY_CEASE, 0);
+ bgp_notify_send(peer, BGP_NOTIFY_CEASE,
+ BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
}
* length. */
if (pnt + 3 > end) {
zlog_info("%s Capability length error", peer->host);
- bgp_notify_send(peer, BGP_NOTIFY_CEASE, 0);
+ bgp_notify_send(peer, BGP_NOTIFY_CEASE,
+ BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
}
action = *pnt;
&& action != CAPABILITY_ACTION_UNSET) {
zlog_info("%s Capability Action Value error %d",
peer->host, action);
- bgp_notify_send(peer, BGP_NOTIFY_CEASE, 0);
+ bgp_notify_send(peer, BGP_NOTIFY_CEASE,
+ BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
}
/* Capability length check. */
if ((pnt + hdr->length + 3) > end) {
zlog_info("%s Capability length error", peer->host);
- bgp_notify_send(peer, BGP_NOTIFY_CEASE, 0);
+ bgp_notify_send(peer, BGP_NOTIFY_CEASE,
+ BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
}
"%s [Error] Dynamic capability packet received under status %s",
peer->host,
lookup_msg(bgp_status_msg, peer->status, NULL));
- bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, 0);
+ bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
+ BGP_NOTIFY_SUBCODE_UNSPECIFIC);
return BGP_Stop;
}
bgp_size_t size;
char notify_data_length[2];
- pthread_mutex_lock(&peer->io_mtx);
- {
+ frr_with_mutex(&peer->io_mtx) {
peer->curr = stream_fifo_pop(peer->ibuf);
}
- pthread_mutex_unlock(&peer->io_mtx);
if (peer->curr == NULL) // no packets to process, hmm...
return 0;
if (fsm_update_result != FSM_PEER_TRANSFERRED
&& fsm_update_result != FSM_PEER_STOPPED) {
- pthread_mutex_lock(&peer->io_mtx);
- {
+ frr_with_mutex(&peer->io_mtx) {
// more work to do, come back later
if (peer->ibuf->count > 0)
thread_add_timer_msec(
bm->master, bgp_process_packet, peer, 0,
&peer->t_process_packet);
}
- pthread_mutex_unlock(&peer->io_mtx);
}
return 0;