peer->last_reset = PEER_DOWN_BFD_DOWN;
/* rfc9384 */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_BFD_DOWN);
if (!bmpbgp)
return 0;
- if (peer->connection.status == Deleted) {
+ if (peer->connection->status == Deleted) {
bbpeer = bmp_bgp_peer_find(peer->qobj_node.nid);
if (bbpeer) {
XFREE(MTYPE_BMP_OPEN, bbpeer->open_rx);
}
/* Check if this peer just went to Established */
- if ((peer->connection.ostatus != OpenConfirm) ||
+ if ((peer->connection->ostatus != OpenConfirm) ||
!(peer_established(peer)))
return 0;
if (peer->doppelganger &&
- (peer->doppelganger->connection.status != Deleted)) {
+ (peer->doppelganger->connection->status != Deleted)) {
bbpeer = bmp_bgp_peer_get(peer);
bbdopp = bmp_bgp_peer_find(peer->doppelganger->qobj_node.nid);
if (bbdopp) {
bgp_dump_all.type);
bgp_dump_common(obuf, peer, 1); /* force this in as4speak*/
- stream_putw(obuf, peer->connection.ostatus);
- stream_putw(obuf, peer->connection.status);
+ stream_putw(obuf, peer->connection->ostatus);
+ stream_putw(obuf, peer->connection->status);
/* Set length. */
bgp_dump_set_size(obuf, MSG_PROTOCOL_BGP4MP);
if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
continue;
- if (peer->connection.status != Established)
+ if (peer->connection->status != Established)
continue;
if (CHECK_FLAG(peer->af_flags[afi][safi],
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s: peer transfer %p fd %d -> %p fd %d)",
- from_peer->host, from_peer, from_peer->connection.fd,
- peer, peer->connection.fd);
+ from_peer->host, from_peer, from_peer->connection->fd,
+ peer, peer->connection->fd);
- bgp_writes_off(&peer->connection);
- bgp_reads_off(&peer->connection);
- bgp_writes_off(&from_peer->connection);
- bgp_reads_off(&from_peer->connection);
+ bgp_writes_off(peer->connection);
+ bgp_reads_off(peer->connection);
+ bgp_writes_off(from_peer->connection);
+ bgp_reads_off(from_peer->connection);
/*
* Before exchanging FD remove doppelganger from
EVENT_OFF(from_peer->t_delayopen);
EVENT_OFF(from_peer->t_connect_check_r);
EVENT_OFF(from_peer->t_connect_check_w);
- EVENT_OFF(from_peer->connection.t_process_packet);
+ EVENT_OFF(from_peer->connection->t_process_packet);
/*
* At this point in time, it is possible that there are packets pending
* on various buffers. Those need to be transferred or dropped,
* otherwise we'll get spurious failures during session establishment.
*/
- frr_with_mutex (&peer->connection.io_mtx,
- &from_peer->connection.io_mtx) {
- fd = peer->connection.fd;
- peer->connection.fd = from_peer->connection.fd;
- from_peer->connection.fd = fd;
+ frr_with_mutex (&peer->connection->io_mtx,
+ &from_peer->connection->io_mtx) {
+ fd = peer->connection->fd;
+ peer->connection->fd = from_peer->connection->fd;
+ from_peer->connection->fd = fd;
- stream_fifo_clean(peer->connection.ibuf);
- stream_fifo_clean(peer->connection.obuf);
+ stream_fifo_clean(peer->connection->ibuf);
+ stream_fifo_clean(peer->connection->obuf);
/*
* this should never happen, since bgp_process_packet() is the
}
// copy each packet from old peer's output queue to new peer
- while (from_peer->connection.obuf->head)
- stream_fifo_push(peer->connection.obuf,
+ while (from_peer->connection->obuf->head)
+ stream_fifo_push(peer->connection->obuf,
stream_fifo_pop(
- from_peer->connection.obuf));
+ from_peer->connection->obuf));
// copy each packet from old peer's input queue to new peer
- while (from_peer->connection.ibuf->head)
- stream_fifo_push(peer->connection.ibuf,
+ while (from_peer->connection->ibuf->head)
+ stream_fifo_push(peer->connection->ibuf,
stream_fifo_pop(
- from_peer->connection.ibuf));
+ from_peer->connection->ibuf));
- ringbuf_wipe(peer->connection.ibuf_work);
- ringbuf_copy(peer->connection.ibuf_work,
- from_peer->connection.ibuf_work,
- ringbuf_remain(from_peer->connection.ibuf_work));
+ ringbuf_wipe(peer->connection->ibuf_work);
+ ringbuf_copy(peer->connection->ibuf_work,
+ from_peer->connection->ibuf_work,
+ ringbuf_remain(from_peer->connection->ibuf_work));
}
peer->as = from_peer->as;
peer->v_gr_restart = from_peer->v_gr_restart;
peer->cap = from_peer->cap;
peer->remote_role = from_peer->remote_role;
- status = peer->connection.status;
- pstatus = peer->connection.ostatus;
+ status = peer->connection->status;
+ pstatus = peer->connection->ostatus;
last_evt = peer->last_event;
last_maj_evt = peer->last_major_event;
- peer->connection.status = from_peer->connection.status;
- peer->connection.ostatus = from_peer->connection.ostatus;
+ peer->connection->status = from_peer->connection->status;
+ peer->connection->ostatus = from_peer->connection->ostatus;
peer->last_event = from_peer->last_event;
peer->last_major_event = from_peer->last_major_event;
- from_peer->connection.status = status;
- from_peer->connection.ostatus = pstatus;
+ from_peer->connection->status = status;
+ from_peer->connection->ostatus = pstatus;
from_peer->last_event = last_evt;
from_peer->last_major_event = last_maj_evt;
peer->remote_id = from_peer->remote_id;
(CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER)
? "accept"
: ""),
- peer->host, peer->connection.fd,
- from_peer->connection.fd);
+ peer->host, peer->connection->fd,
+ from_peer->connection->fd);
BGP_EVENT_ADD(peer, BGP_Stop);
BGP_EVENT_ADD(from_peer, BGP_Stop);
return NULL;
}
- if (from_peer->connection.status > Active) {
+ if (from_peer->connection->status > Active) {
if (bgp_getsockname(from_peer) < 0) {
flog_err(EC_LIB_SOCKET,
"%%bgp_getsockname() failed for %s from_peer %s fd %d (peer fd %d)",
PEER_STATUS_ACCEPT_PEER)
? "accept"
: ""),
- from_peer->host, from_peer->connection.fd,
- peer->connection.fd);
+ from_peer->host, from_peer->connection->fd,
+ peer->connection->fd);
bgp_stop(from_peer);
from_peer = NULL;
}
if (from_peer)
bgp_replace_nexthop_by_peer(from_peer, peer);
- bgp_reads_on(&peer->connection);
- bgp_writes_on(&peer->connection);
- event_add_event(bm->master, bgp_process_packet, &peer->connection, 0,
- &peer->connection.t_process_packet);
+ bgp_reads_on(peer->connection);
+ bgp_writes_on(peer->connection);
+ event_add_event(bm->master, bgp_process_packet, peer->connection, 0,
+ &peer->connection->t_process_packet);
return (peer);
}
afi_t afi;
safi_t safi;
- switch (peer->connection.status) {
+ switch (peer->connection->status) {
case Idle:
/* First entry point of peer's finite state machine. In Idle
status start timer is on unless peer is shutdown or peer is
/* stop the DelayOpenTimer if it is running */
EVENT_OFF(peer->t_delayopen);
- assert(!peer->connection.t_write);
- assert(!peer->connection.t_read);
+ assert(!peer->connection->t_write);
+ assert(!peer->connection->t_read);
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [FSM] Timer (connect timer expire)", peer->host);
* for systems where we are heavily loaded for one
* reason or another.
*/
- inq_count = atomic_load_explicit(&peer->connection.ibuf->count,
+ inq_count = atomic_load_explicit(&peer->connection->ibuf->count,
memory_order_relaxed);
if (inq_count)
BGP_TIMER_ON(peer->t_holdtime, bgp_holdtime_timer,
if (CHECK_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV))
bgp_update_restarted_peers(peer);
}
- if (peer->connection.ostatus == Established &&
+ if (peer->connection->ostatus == Established &&
bgp_update_delay_active(peer->bgp)) {
/* Adjust the update-delay state to account for this flap.
NOTE: Intentionally skipping adjusting implicit_eors or
}
/* Preserve old status and change into new status. */
- peer->connection.ostatus = peer->connection.status;
- peer->connection.status = status;
+ peer->connection->ostatus = peer->connection->status;
+ peer->connection->status = status;
/* Reset received keepalives counter on every FSM change */
peer->rtt_keepalive_rcv = 0;
/* Fire backward transition hook if that's the case */
- if (peer->connection.ostatus == Established &&
- peer->connection.status != Established)
+ if (peer->connection->ostatus == Established &&
+ peer->connection->status != Established)
hook_call(peer_backward_transition, peer);
/* Save event that caused status change. */
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s fd %d went from %s to %s", peer->host,
- peer->connection.fd,
- lookup_msg(bgp_status_msg, peer->connection.ostatus,
+ peer->connection->fd,
+ lookup_msg(bgp_status_msg, peer->connection->ostatus,
NULL),
- lookup_msg(bgp_status_msg, peer->connection.status,
+ lookup_msg(bgp_status_msg, peer->connection->status,
NULL));
}
}
/* Can't do this in Clearing; events are used for state transitions */
- if (peer->connection.status != Clearing) {
+ if (peer->connection->status != Clearing) {
/* Delete all existing events of the peer */
BGP_EVENT_FLUSH(peer);
}
bgp_keepalives_off(peer);
/* Stop read and write threads. */
- bgp_writes_off(&peer->connection);
- bgp_reads_off(&peer->connection);
+ bgp_writes_off(peer->connection);
+ bgp_reads_off(peer->connection);
EVENT_OFF(peer->t_connect_check_r);
EVENT_OFF(peer->t_connect_check_w);
EVENT_OFF(peer->t_delayopen);
/* Clear input and output buffer. */
- frr_with_mutex (&peer->connection.io_mtx) {
- if (peer->connection.ibuf)
- stream_fifo_clean(peer->connection.ibuf);
- if (peer->connection.obuf)
- stream_fifo_clean(peer->connection.obuf);
+ frr_with_mutex (&peer->connection->io_mtx) {
+ if (peer->connection->ibuf)
+ stream_fifo_clean(peer->connection->ibuf);
+ if (peer->connection->obuf)
+ stream_fifo_clean(peer->connection->obuf);
- if (peer->connection.ibuf_work)
- ringbuf_wipe(peer->connection.ibuf_work);
+ if (peer->connection->ibuf_work)
+ ringbuf_wipe(peer->connection->ibuf_work);
if (peer->curr) {
stream_free(peer->curr);
}
/* Close of file descriptor. */
- if (peer->connection.fd >= 0) {
- close(peer->connection.fd);
- peer->connection.fd = -1;
+ if (peer->connection->fd >= 0) {
+ close(peer->connection->fd);
+ peer->connection->fd = -1;
}
/* Reset capabilities. */
/* Received ORF prefix-filter */
peer->orf_plist[afi][safi] = NULL;
- if ((peer->connection.status == OpenConfirm) ||
+ if ((peer->connection->status == OpenConfirm) ||
peer_established(peer)) {
/* ORF received prefix-filter pnt */
snprintf(orf_name, sizeof(orf_name), "%s.%d.%d",
struct peer *peer;
peer = EVENT_ARG(thread);
- assert(!CHECK_FLAG(peer->connection.thread_flags,
+ assert(!CHECK_FLAG(peer->connection->thread_flags,
PEER_THREAD_READS_ON));
- assert(!CHECK_FLAG(peer->connection.thread_flags,
+ assert(!CHECK_FLAG(peer->connection->thread_flags,
PEER_THREAD_WRITES_ON));
- assert(!peer->connection.t_read);
- assert(!peer->connection.t_write);
+ assert(!peer->connection->t_read);
+ assert(!peer->connection->t_write);
EVENT_OFF(peer->t_connect_check_r);
EVENT_OFF(peer->t_connect_check_w);
/* Check file descriptor. */
slen = sizeof(status);
- ret = getsockopt(peer->connection.fd, SOL_SOCKET, SO_ERROR,
+ ret = getsockopt(peer->connection->fd, SOL_SOCKET, SO_ERROR,
(void *)&status, &slen);
/* If getsockopt is fail, this is fatal error. */
add read thread for reading open message. */
static enum bgp_fsm_state_progress bgp_connect_success(struct peer *peer)
{
- if (peer->connection.fd < 0) {
+ if (peer->connection->fd < 0) {
flog_err(EC_BGP_CONNECT, "%s peer's fd is negative value %d",
- __func__, peer->connection.fd);
+ __func__, peer->connection->fd);
return bgp_stop(peer);
}
if (bgp_getsockname(peer) < 0) {
flog_err_sys(EC_LIB_SOCKET,
"%s: bgp_getsockname(): failed for peer %s, fd %d",
- __func__, peer->host, peer->connection.fd);
+ __func__, peer->host, peer->connection->fd);
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
- bgp_fsm_error_subcode(peer->connection.status));
- bgp_writes_on(&peer->connection);
+ bgp_fsm_error_subcode(peer->connection->status));
+ bgp_writes_on(peer->connection);
return BGP_FSM_FAILURE;
}
*/
bgp_nht_interface_events(peer);
- bgp_reads_on(&peer->connection);
+ bgp_reads_on(peer->connection);
if (bgp_debug_neighbor_events(peer)) {
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
static enum bgp_fsm_state_progress
bgp_connect_success_w_delayopen(struct peer *peer)
{
- if (peer->connection.fd < 0) {
+ if (peer->connection->fd < 0) {
flog_err(EC_BGP_CONNECT, "%s: peer's fd is negative value %d",
- __func__, peer->connection.fd);
+ __func__, peer->connection->fd);
return bgp_stop(peer);
}
if (bgp_getsockname(peer) < 0) {
flog_err_sys(EC_LIB_SOCKET,
"%s: bgp_getsockname(): failed for peer %s, fd %d",
- __func__, peer->host, peer->connection.fd);
+ __func__, peer->host, peer->connection->fd);
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
- bgp_fsm_error_subcode(peer->connection.status));
- bgp_writes_on(&peer->connection);
+ bgp_fsm_error_subcode(peer->connection->status));
+ bgp_writes_on(peer->connection);
return BGP_FSM_FAILURE;
}
*/
bgp_nht_interface_events(peer);
- bgp_reads_on(&peer->connection);
+ bgp_reads_on(peer->connection);
if (bgp_debug_neighbor_events(peer)) {
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
}
}
- assert(!peer->connection.t_write);
- assert(!peer->connection.t_read);
- assert(!CHECK_FLAG(peer->connection.thread_flags,
+ assert(!peer->connection->t_write);
+ assert(!peer->connection->t_read);
+ assert(!CHECK_FLAG(peer->connection->thread_flags,
PEER_THREAD_WRITES_ON));
- assert(!CHECK_FLAG(peer->connection.thread_flags,
+ assert(!CHECK_FLAG(peer->connection->thread_flags,
PEER_THREAD_READS_ON));
status = bgp_connect(peer);
case connect_success:
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [FSM] Connect immediately success, fd %d",
- peer->host, peer->connection.fd);
+ peer->host, peer->connection->fd);
BGP_EVENT_ADD(peer, TCP_connection_open);
break;
readable or writable. */
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [FSM] Non blocking connect waiting result, fd %d",
- peer->host, peer->connection.fd);
- if (peer->connection.fd < 0) {
+ peer->host, peer->connection->fd);
+ if (peer->connection->fd < 0) {
flog_err(EC_BGP_FSM, "%s peer's fd is negative value %d",
- __func__, peer->connection.fd);
+ __func__, peer->connection->fd);
return BGP_FSM_FAILURE;
}
/*
* unused event in that function.
*/
event_add_read(bm->master, bgp_connect_check, peer,
- peer->connection.fd, &peer->t_connect_check_r);
+ peer->connection->fd, &peer->t_connect_check_r);
event_add_write(bm->master, bgp_connect_check, peer,
- peer->connection.fd, &peer->t_connect_check_w);
+ peer->connection->fd, &peer->t_connect_check_w);
break;
}
return BGP_FSM_SUCCESS;
static enum bgp_fsm_state_progress bgp_fsm_open(struct peer *peer)
{
/* If DelayOpen is active, we may still need to send an open message */
- if ((peer->connection.status == Connect) ||
- (peer->connection.status == Active))
+ if ((peer->connection->status == Connect) ||
+ (peer->connection->status == Active))
bgp_open_send(peer);
/* Send keepalive and make keepalive timer */
{
flog_err(EC_BGP_FSM, "%s [FSM] unexpected packet received in state %s",
peer->host,
- lookup_msg(bgp_status_msg, peer->connection.status, NULL));
+ lookup_msg(bgp_status_msg, peer->connection->status, NULL));
return bgp_stop_with_notify(peer, BGP_NOTIFY_FSM_ERR,
bgp_fsm_error_subcode(
- peer->connection.status));
+ peer->connection->status));
}
/* Hold timer expire. This is error of BGP connection. So cut the
}
if (peer->doppelganger &&
- (peer->doppelganger->connection.status != Deleted)) {
+ (peer->doppelganger->connection->status != Deleted)) {
if (bgp_debug_neighbor_events(peer))
zlog_debug(
"[Event] Deleting stub connection for peer %s",
peer->host);
- if (peer->doppelganger->connection.status > Active)
+ if (peer->doppelganger->connection->status > Active)
bgp_notify_send(peer->doppelganger, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_COLLISION_RESOLUTION);
else
flog_err(EC_BGP_FSM,
"%s [FSM] Ignoring event %s in state %s, prior events %s, %s, fd %d",
peer->host, bgp_event_str[peer->cur_event],
- lookup_msg(bgp_status_msg, peer->connection.status, NULL),
+ lookup_msg(bgp_status_msg, peer->connection->status, NULL),
bgp_event_str[peer->last_event],
- bgp_event_str[peer->last_major_event], peer->connection.fd);
+ bgp_event_str[peer->last_major_event], peer->connection->fd);
return BGP_FSM_SUCCESS;
}
flog_err(EC_BGP_FSM,
"%s [FSM] Unexpected event %s in state %s, prior events %s, %s, fd %d",
peer->host, bgp_event_str[peer->cur_event],
- lookup_msg(bgp_status_msg, peer->connection.status, NULL),
+ lookup_msg(bgp_status_msg, peer->connection->status, NULL),
bgp_event_str[peer->last_event],
- bgp_event_str[peer->last_major_event], peer->connection.fd);
+ bgp_event_str[peer->last_major_event], peer->connection->fd);
return bgp_stop(peer);
}
if (!peer)
return;
- switch (peer->connection.status) {
+ switch (peer->connection->status) {
case Idle:
if (has_valid_nexthops)
BGP_EVENT_ADD(peer, BGP_Start);
dyn_nbr = peer_dynamic_neighbor(peer);
/* Logging this event. */
- next = FSM[peer->connection.status - 1][event - 1].next_state;
+ next = FSM[peer->connection->status - 1][event - 1].next_state;
- if (bgp_debug_neighbor_events(peer) && peer->connection.status != next)
+ if (bgp_debug_neighbor_events(peer) && peer->connection->status != next)
zlog_debug("%s [FSM] %s (%s->%s), fd %d", peer->host,
bgp_event_str[event],
- lookup_msg(bgp_status_msg, peer->connection.status,
+ lookup_msg(bgp_status_msg, peer->connection->status,
NULL),
lookup_msg(bgp_status_msg, next, NULL),
- peer->connection.fd);
+ peer->connection->fd);
peer->last_event = peer->cur_event;
peer->cur_event = event;
/* Call function. */
- if (FSM[peer->connection.status - 1][event - 1].func)
- ret = (*(FSM[peer->connection.status - 1][event - 1].func))(
+ if (FSM[peer->connection->status - 1][event - 1].func)
+ ret = (*(FSM[peer->connection->status - 1][event - 1].func))(
peer);
if (ret >= BGP_FSM_SUCCESS) {
}
/* If status is changed. */
- if (next != peer->connection.status) {
+ if (next != peer->connection->status) {
bgp_fsm_change_status(peer, next);
/*
"%s [FSM] Failure handling event %s in state %s, prior events %s, %s, fd %d, last reset: %s",
peer->host, bgp_event_str[peer->cur_event],
lookup_msg(bgp_status_msg,
- peer->connection.status, NULL),
+ peer->connection->status, NULL),
bgp_event_str[peer->last_event],
bgp_event_str[peer->last_major_event],
- peer->connection.fd,
+ peer->connection->fd,
peer_down_str[peer->last_reset]);
bgp_stop(peer);
bgp_fsm_change_status(peer, Idle);
/* Macro for BGP read, write and timer thread. */
#define BGP_TIMER_ON(T, F, V) \
do { \
- if ((peer->connection.status != Deleted)) \
+ if ((peer->connection->status != Deleted)) \
event_add_timer(bm->master, (F), peer, (V), &(T)); \
} while (0)
#define BGP_EVENT_ADD(P, E) \
do { \
- if ((P)->connection.status != Deleted) \
+ if ((P)->connection->status != Deleted) \
event_add_event(bm->master, bgp_event, (P), (E), NULL); \
} while (0)
event_cancel_async(fpt->master, &connection->t_write, NULL);
EVENT_OFF(peer->t_generate_updgrp_packets);
- UNSET_FLAG(peer->connection.thread_flags, PEER_THREAD_WRITES_ON);
+ UNSET_FLAG(peer->connection->thread_flags, PEER_THREAD_WRITES_ON);
}
void bgp_reads_on(struct peer_connection *connection)
return;
}
- event_add_read(fpt->master, bgp_process_reads, peer, connection->fd,
- &connection->t_read);
+ event_add_read(fpt->master, bgp_process_reads, connection,
+ connection->fd, &connection->t_read);
if (added_pkt)
event_add_event(bm->master, bgp_process_packet, connection, 0,
&connection->t_process_packet);
peer1 = peer_lookup_dynamic_neighbor(bgp, &su);
if (peer1) {
/* Dynamic neighbor has been created, let it proceed */
- peer1->connection.fd = bgp_sock;
+ peer1->connection->fd = bgp_sock;
/* Set the user configured MSS to TCP socket */
if (CHECK_FLAG(peer1->flags, PEER_FLAG_TCP_MSS))
* Established and then the Clearing_Completed event is generated. Also,
* block incoming connection in Deleted state.
*/
- if (peer1->connection.status == Clearing ||
- peer1->connection.status == Deleted) {
+ if (peer1->connection->status == Clearing ||
+ peer1->connection->status == Deleted) {
if (bgp_debug_neighbor_events(peer1))
zlog_debug("[Event] Closing incoming conn for %s (%p) state %d",
- peer1->host, peer1, peer1->connection.status);
+ peer1->host, peer1,
+ peer1->connection->status);
close(bgp_sock);
return;
}
if (bgp_debug_neighbor_events(peer1))
zlog_debug("[Event] connection from %s fd %d, active peer status %d fd %d",
inet_sutop(&su, buf), bgp_sock,
- peer1->connection.status, peer1->connection.fd);
+ peer1->connection->status, peer1->connection->fd);
if (peer1->doppelganger) {
/* We have an existing connection. Kill the existing one and run
peer->doppelganger = peer1;
peer1->doppelganger = peer;
- peer->connection.fd = bgp_sock;
+ peer->connection->fd = bgp_sock;
frr_with_privs(&bgpd_privs) {
vrf_bind(peer->bgp->vrf_id, bgp_sock, bgp_get_bound_name(peer));
}
if (bgp_update_address(ifp, &peer->su, &addr))
return -1;
- ret = sockunion_bind(peer->connection.fd, &addr, 0, &addr);
+ ret = sockunion_bind(peer->connection->fd, &addr, 0, &addr);
}
/* Source is specified with IP address. */
if (peer->update_source)
- ret = sockunion_bind(peer->connection.fd, peer->update_source,
+ ret = sockunion_bind(peer->connection->fd, peer->update_source,
0, peer->update_source);
return ret;
/* BGP try to connect to the peer. */
int bgp_connect(struct peer *peer)
{
- assert(!CHECK_FLAG(peer->connection.thread_flags,
+ assert(!CHECK_FLAG(peer->connection->thread_flags,
PEER_THREAD_WRITES_ON));
- assert(!CHECK_FLAG(peer->connection.thread_flags,
+ assert(!CHECK_FLAG(peer->connection->thread_flags,
PEER_THREAD_READS_ON));
ifindex_t ifindex = 0;
}
frr_with_privs(&bgpd_privs) {
/* Make socket for the peer. */
- peer->connection.fd =
+ peer->connection->fd =
vrf_sockunion_socket(&peer->su, peer->bgp->vrf_id,
bgp_get_bound_name(peer));
}
- if (peer->connection.fd < 0) {
+ if (peer->connection->fd < 0) {
peer->last_reset = PEER_DOWN_SOCKET_ERROR;
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s: Failure to create socket for connection to %s, error received: %s(%d)",
return -1;
}
- set_nonblocking(peer->connection.fd);
+ set_nonblocking(peer->connection->fd);
/* Set the user configured MSS to TCP socket */
if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS))
- sockopt_tcp_mss_set(peer->connection.fd, peer->tcp_mss);
+ sockopt_tcp_mss_set(peer->connection->fd, peer->tcp_mss);
- bgp_socket_set_buffer_size(peer->connection.fd);
+ bgp_socket_set_buffer_size(peer->connection->fd);
/* Set TCP keepalive when TCP keepalive is enabled */
- bgp_update_setsockopt_tcp_keepalive(peer->bgp, peer->connection.fd);
+ bgp_update_setsockopt_tcp_keepalive(peer->bgp, peer->connection->fd);
- if (bgp_set_socket_ttl(peer, peer->connection.fd) < 0) {
+ if (bgp_set_socket_ttl(peer, peer->connection->fd) < 0) {
peer->last_reset = PEER_DOWN_SOCKET_ERROR;
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s: Failure to set socket ttl for connection to %s, error received: %s(%d)",
return -1;
}
- sockopt_reuseaddr(peer->connection.fd);
- sockopt_reuseport(peer->connection.fd);
+ sockopt_reuseaddr(peer->connection->fd);
+ sockopt_reuseport(peer->connection->fd);
#ifdef IPTOS_PREC_INTERNETCONTROL
frr_with_privs(&bgpd_privs) {
if (sockunion_family(&peer->su) == AF_INET)
- setsockopt_ipv4_tos(peer->connection.fd, bm->tcp_dscp);
+ setsockopt_ipv4_tos(peer->connection->fd, bm->tcp_dscp);
else if (sockunion_family(&peer->su) == AF_INET6)
- setsockopt_ipv6_tclass(peer->connection.fd,
+ setsockopt_ipv6_tclass(peer->connection->fd,
bm->tcp_dscp);
}
#endif
if (!BGP_PEER_SU_UNSPEC(peer))
bgp_md5_set(peer);
- bgp_md5_set_connect(peer->connection.fd, &peer->su, prefixlen,
+ bgp_md5_set_connect(peer->connection->fd, &peer->su, prefixlen,
peer->password);
}
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [Event] Connect start to %s fd %d", peer->host,
- peer->host, peer->connection.fd);
+ peer->host, peer->connection->fd);
/* Connect to the remote peer. */
- return sockunion_connect(peer->connection.fd, &peer->su,
+ return sockunion_connect(peer->connection->fd, &peer->su,
htons(peer->port), ifindex);
}
peer->su_remote = NULL;
}
- peer->su_local = sockunion_getsockname(peer->connection.fd);
+ peer->su_local = sockunion_getsockname(peer->connection->fd);
if (!peer->su_local)
return -1;
- peer->su_remote = sockunion_getpeername(peer->connection.fd);
+ peer->su_remote = sockunion_getpeername(peer->connection->fd);
if (!peer->su_remote)
return -1;
uint32_t holdtime;
intmax_t sendholdtime;
- frr_with_mutex (&peer->connection.io_mtx) {
+ frr_with_mutex (&peer->connection->io_mtx) {
/* if the queue is empty, reset the "last OK" timestamp to
* now, otherwise if we write another packet immediately
* after it'll get confused
*/
- if (!stream_fifo_count_safe(peer->connection.obuf))
+ if (!stream_fifo_count_safe(peer->connection->obuf))
peer->last_sendq_ok = monotime(NULL);
- stream_fifo_push(peer->connection.obuf, s);
+ stream_fifo_push(peer->connection->obuf, s);
delta = monotime(NULL) - peer->last_sendq_ok;
* let's stop adding to the outq if we are
* already at the limit.
*/
- if (peer->connection.obuf->count >= bm->outq_limit) {
+ if (peer->connection->obuf->count >= bm->outq_limit) {
bgp_write_proceed_actions(peer);
return;
}
bpacket_queue_advance_peer(paf);
}
} while (s && (++generated < wpq) &&
- (peer->connection.obuf->count <= bm->outq_limit));
+ (peer->connection->obuf->count <= bm->outq_limit));
if (generated)
- bgp_writes_on(&peer->connection);
+ bgp_writes_on(peer->connection);
bgp_write_proceed_actions(peer);
}
/* Add packet to the peer. */
bgp_packet_add(peer, s);
- bgp_writes_on(&peer->connection);
+ bgp_writes_on(peer->connection);
}
/*
/* Add packet to the peer. */
bgp_packet_add(peer, s);
- bgp_writes_on(&peer->connection);
+ bgp_writes_on(peer->connection);
}
/*
* Writes NOTIFICATION message directly to a peer socket without waiting for
* the I/O thread.
*
- * There must be exactly one stream on the peer->connection.obuf FIFO, and the
+ * There must be exactly one stream on the peer->connection->obuf FIFO, and the
* data within this stream must match the format of a BGP NOTIFICATION message.
* Transmission is best-effort.
*
- * @requires peer->connection.io_mtx
+ * @requires peer->connection->io_mtx
* @param peer
* @return 0
*/
struct stream *s;
/* There should be at least one packet. */
- s = stream_fifo_pop(peer->connection.obuf);
+ s = stream_fifo_pop(peer->connection->obuf);
if (!s)
return;
* socket is in nonblocking mode, if we can't deliver the NOTIFY, well,
* we only care about getting a clean shutdown at this point.
*/
- ret = write(peer->connection.fd, STREAM_DATA(s), stream_get_endp(s));
+ ret = write(peer->connection->fd, STREAM_DATA(s), stream_get_endp(s));
/*
* only connection reset/close gets counted as TCP_fatal_error, failure
/* Disable Nagle, make NOTIFY packet go out right away */
val = 1;
- (void)setsockopt(peer->connection.fd, IPPROTO_TCP, TCP_NODELAY,
+ (void)setsockopt(peer->connection->fd, IPPROTO_TCP, TCP_NODELAY,
(char *)&val, sizeof(val));
/* Retrieve BGP packet type. */
bool hard_reset = bgp_notify_send_hard_reset(peer, code, sub_code);
/* Lock I/O mutex to prevent other threads from pushing packets */
- frr_mutex_lock_autounlock(&peer->connection.io_mtx);
+ frr_mutex_lock_autounlock(&peer->connection->io_mtx);
/* ============================================== */
/* Allocate new stream. */
bgp_packet_set_size(s);
/* wipe output buffer */
- stream_fifo_clean(peer->connection.obuf);
+ stream_fifo_clean(peer->connection->obuf);
/*
* If possible, store last packet for debugging purposes. This check is
peer->last_reset = PEER_DOWN_NOTIFY_SEND;
/* Add packet to peer's output queue */
- stream_fifo_push(peer->connection.obuf, s);
+ stream_fifo_push(peer->connection->obuf, s);
bgp_peer_gr_flags_update(peer);
BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(peer->bgp,
/* Add packet to the peer. */
bgp_packet_add(peer, s);
- bgp_writes_on(&peer->connection);
+ bgp_writes_on(peer->connection);
}
/*
/* Add packet to the peer. */
bgp_packet_add(peer, s);
- bgp_writes_on(&peer->connection);
+ bgp_writes_on(peer->connection);
}
/* RFC1771 6.8 Connection collision detection. */
* states. Note that a peer GR is handled by closing the existing
* connection upon receipt of new one.
*/
- if (peer_established(peer) || peer->connection.status == Clearing) {
+ if (peer_established(peer) || peer->connection->status == Clearing) {
bgp_notify_send(new, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_COLLISION_RESOLUTION);
return -1;
}
- if ((peer->connection.status != OpenConfirm) &&
- (peer->connection.status != OpenSent))
+ if ((peer->connection->status != OpenConfirm) &&
+ (peer->connection->status != OpenSent))
return 0;
/*
* Side effects
* ------------
* - May send NOTIFY messages
- * - May not modify peer->connection.status
+ * - May not modify peer->connection->status
* - May not call bgp_event_update()
*/
return BGP_Stop;
}
}
- peer->rtt = sockopt_tcp_rtt(peer->connection.fd);
+ peer->rtt = sockopt_tcp_rtt(peer->connection->fd);
return Receive_OPEN_message;
}
bgp_update_implicit_eors(peer);
- peer->rtt = sockopt_tcp_rtt(peer->connection.fd);
+ peer->rtt = sockopt_tcp_rtt(peer->connection->fd);
/* If the peer's RTT is higher than expected, shutdown
* the peer automatically.
flog_err(EC_BGP_INVALID_STATUS,
"%s [FSM] Update packet received under status %s",
peer->host,
- lookup_msg(bgp_status_msg, peer->connection.status,
+ lookup_msg(bgp_status_msg, peer->connection->status,
NULL));
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
- bgp_fsm_error_subcode(peer->connection.status));
+ bgp_fsm_error_subcode(peer->connection->status));
return BGP_Stop;
}
flog_err(EC_BGP_INVALID_STATUS,
"%s [Error] Route refresh packet received under status %s",
peer->host,
- lookup_msg(bgp_status_msg, peer->connection.status,
+ lookup_msg(bgp_status_msg, peer->connection->status,
NULL));
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
- bgp_fsm_error_subcode(peer->connection.status));
+ bgp_fsm_error_subcode(peer->connection->status));
return BGP_Stop;
}
flog_err(EC_BGP_NO_CAP,
"%s [Error] Dynamic capability packet received under status %s",
peer->host,
- lookup_msg(bgp_status_msg, peer->connection.status,
+ lookup_msg(bgp_status_msg, peer->connection->status,
NULL));
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
- bgp_fsm_error_subcode(peer->connection.status));
+ bgp_fsm_error_subcode(peer->connection->status));
return BGP_Stop;
}
fsm_update_result = 0;
/* Guard against scheduled events that occur after peer deletion. */
- if (peer->connection.status == Deleted ||
- peer->connection.status == Clearing)
+ if (connection->status == Deleted || connection->status == Clearing)
return;
unsigned int processed = 0;
lua_setfield(L, -2, "remote_id");
lua_pushinaddr(L, &peer->local_id);
lua_setfield(L, -2, "local_id");
- lua_pushstring(L, lookup_msg(bgp_status_msg, peer->connection.status,
+ lua_pushstring(L, lookup_msg(bgp_status_msg, peer->connection->status,
NULL));
lua_setfield(L, -2, "state");
lua_pushstring(L, peer->desc ? peer->desc : "");
case BGPPEERIDENTIFIER:
return SNMP_IPADDRESS(peer->remote_id);
case BGPPEERSTATE:
- return SNMP_INTEGER(peer->connection.status);
+ return SNMP_INTEGER(peer->connection->status);
case BGPPEERADMINSTATUS:
*write_method = write_bgpPeerTable;
#define BGP_PeerAdmin_stop 1
oid index[sizeof(oid) * IN_ADDR_SIZE];
/* Check if this peer just went to Established */
- if ((peer->connection.ostatus != OpenConfirm) ||
+ if ((peer->connection->ostatus != OpenConfirm) ||
!(peer_established(peer)))
return 0;
else
return SNMP_INTEGER(BGP_PEER_ADMIN_STATUS_RUNNING);
case BGP4V2_PEER_STATE:
- return SNMP_INTEGER(peer->connection.status);
+ return SNMP_INTEGER(peer->connection->status);
case BGP4V2_PEER_DESCRIPTION:
if (peer->desc)
return SNMP_STRING(peer->desc);
* with aspath containing AS_SET or AS_CONFED_SET.
*/
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_AS_SETS_REJECT;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
* with aspath containing AS_SET or AS_CONFED_SET.
*/
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_AS_SETS_REJECT;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY);
/* v6only flag changed. Reset bgp seesion */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_V6ONLY_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
peer_notify_unconfig(peer);
peer_delete(peer);
- if (other && other->connection.status != Deleted) {
+ if (other && other->connection->status != Deleted) {
peer_notify_unconfig(other);
peer_delete(other);
}
atomic_size_t outq_count, inq_count;
outq_count =
atomic_load_explicit(&peer->connection
- .obuf->count,
+ ->obuf
+ ->count,
memory_order_relaxed);
inq_count =
atomic_load_explicit(&peer->connection
- .ibuf->count,
+ ->ibuf
+ ->count,
memory_order_relaxed);
json_object_int_add(
json_object_string_add(
json_peer, "state",
lookup_msg(bgp_status_msg,
- peer->connection.status,
+ peer->connection->status,
NULL));
else if (CHECK_FLAG(
peer->sflags,
json_object_string_add(
json_peer, "state",
lookup_msg(bgp_status_msg,
- peer->connection.status,
+ peer->connection->status,
NULL));
/* BGP peer state */
atomic_size_t outq_count, inq_count;
outq_count =
atomic_load_explicit(&peer->connection
- .obuf->count,
+ ->obuf
+ ->count,
memory_order_relaxed);
inq_count =
atomic_load_explicit(&peer->connection
- .ibuf->count,
+ ->ibuf
+ ->count,
memory_order_relaxed);
vty_out(vty, "4");
vty_out(vty, " %12s",
lookup_msg(bgp_status_msg,
peer->connection
- .status,
+ ->status,
NULL));
vty_out(vty, " %8u", 0);
/* Status. */
json_object_string_add(json_neigh, "bgpState",
lookup_msg(bgp_status_msg,
- p->connection.status, NULL));
+ p->connection->status, NULL));
if (peer_established(p)) {
time_t uptime;
json_object_int_add(json_neigh,
"bgpTimerUpEstablishedEpoch",
epoch_tbuf);
- } else if (p->connection.status == Active) {
+ } else if (p->connection->status == Active) {
if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE))
json_object_string_add(json_neigh, "bgpStateIs",
"passive");
/* Configured and Synced tcp-mss value for peer */
if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) {
- sync_tcp_mss = sockopt_tcp_mss_get(p->connection.fd);
+ sync_tcp_mss = sockopt_tcp_mss_get(p->connection->fd);
json_object_int_add(json_neigh, "bgpTcpMssConfigured",
p->tcp_mss);
json_object_int_add(json_neigh, "bgpTcpMssSynced",
/* Status. */
vty_out(vty, " BGP state = %s",
- lookup_msg(bgp_status_msg, p->connection.status, NULL));
+ lookup_msg(bgp_status_msg, p->connection->status, NULL));
if (peer_established(p))
vty_out(vty, ", up for %8s",
peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN,
0, NULL));
- else if (p->connection.status == Active) {
+ else if (p->connection->status == Active) {
if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE))
vty_out(vty, " (passive)");
else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT))
/* Configured and synced tcp-mss value for peer */
if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) {
- sync_tcp_mss = sockopt_tcp_mss_get(p->connection.fd);
+ sync_tcp_mss = sockopt_tcp_mss_get(p->connection->fd);
vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss);
vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss);
}
/* Packet counts. */
atomic_size_t outq_count, inq_count;
- outq_count = atomic_load_explicit(&p->connection.obuf->count,
+ outq_count = atomic_load_explicit(&p->connection->obuf->count,
memory_order_relaxed);
- inq_count = atomic_load_explicit(&p->connection.ibuf->count,
+ inq_count = atomic_load_explicit(&p->connection->ibuf->count,
memory_order_relaxed);
json_object_int_add(json_stat, "depthInq",
notify_out, notify_in, update_out, update_in,
keepalive_out, keepalive_in, refresh_out, refresh_in,
dynamic_cap_out, dynamic_cap_in;
- outq_count = atomic_load_explicit(&p->connection.obuf->count,
+ outq_count = atomic_load_explicit(&p->connection->obuf->count,
memory_order_relaxed);
- inq_count = atomic_load_explicit(&p->connection.ibuf->count,
+ inq_count = atomic_load_explicit(&p->connection->ibuf->count,
memory_order_relaxed);
open_out = atomic_load_explicit(&p->open_out,
memory_order_relaxed);
json_object_int_add(json_neigh, "authenticationEnabled",
1);
- if (p->connection.t_read)
+ if (p->connection->t_read)
json_object_string_add(json_neigh, "readThread", "on");
else
json_object_string_add(json_neigh, "readThread", "off");
- if (CHECK_FLAG(p->connection.thread_flags,
+ if (CHECK_FLAG(p->connection->thread_flags,
PEER_THREAD_WRITES_ON))
json_object_string_add(json_neigh, "writeThread", "on");
else
vty_out(vty, "Peer Authentication Enabled\n");
vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n",
- p->connection.t_read ? "on" : "off",
- CHECK_FLAG(p->connection.thread_flags,
+ p->connection->t_read ? "on" : "off",
+ CHECK_FLAG(p->connection->thread_flags,
PEER_THREAD_WRITES_ON)
? "on"
: "off",
- p->connection.fd);
+ p->connection->fd);
}
if (p->notify.code == BGP_NOTIFY_OPEN_ERR
PEER_STATUS_PREFIX_OVERFLOW))
peer_status = "Idle (PfxCt)";
else
- peer_status = lookup_msg(bgp_status_msg,
- peer->connection.status,
- NULL);
+ peer_status =
+ lookup_msg(bgp_status_msg,
+ peer->connection->status,
+ NULL);
dynamic = peer_dynamic_neighbor(peer);
void bgp_session_reset(struct peer *peer)
{
if (peer->doppelganger &&
- (peer->doppelganger->connection.status != Deleted) &&
+ (peer->doppelganger->connection->status != Deleted) &&
!(CHECK_FLAG(peer->doppelganger->flags, PEER_FLAG_CONFIG_NODE)))
peer_delete(peer->doppelganger);
npeer = (n) ? listgetdata(n) : NULL;
if (peer->doppelganger &&
- (peer->doppelganger->connection.status != Deleted) &&
+ (peer->doppelganger->connection->status != Deleted) &&
!(CHECK_FLAG(peer->doppelganger->flags, PEER_FLAG_CONFIG_NODE))) {
if (peer->doppelganger == npeer)
/* nnode and *nnode are confirmed to be non-NULL here */
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
IPV4_ADDR_COPY(&peer->local_id, id);
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_RID_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
if (peer->sort != BGP_PEER_IBGP)
continue;
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_CLID_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
if (peer->sort != BGP_PEER_IBGP)
continue;
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_CLID_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
if (ptype == BGP_PEER_EBGP) {
peer->local_as = as;
if (BGP_IS_VALID_STATE_FOR_NOTIF(
- peer->connection.status)) {
+ peer->connection->status)) {
peer->last_reset =
PEER_DOWN_CONFED_ID_CHANGE;
bgp_notify_send(
if (ptype == BGP_PEER_EBGP)
peer->local_as = as;
if (BGP_IS_VALID_STATE_FOR_NOTIF(
- peer->connection.status)) {
+ peer->connection->status)) {
peer->last_reset =
PEER_DOWN_CONFED_ID_CHANGE;
bgp_notify_send(
if (peer_sort(peer) != BGP_PEER_IBGP) {
peer->local_as = bgp->as;
if (BGP_IS_VALID_STATE_FOR_NOTIF(
- peer->connection.status)) {
+ peer->connection->status)) {
peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
peer->local_as = bgp->as;
(void)peer_sort(peer);
if (BGP_IS_VALID_STATE_FOR_NOTIF(
- peer->connection.status)) {
+ peer->connection->status)) {
peer->last_reset =
PEER_DOWN_CONFED_PEER_CHANGE;
bgp_notify_send(
peer->local_as = bgp->confed_id;
(void)peer_sort(peer);
if (BGP_IS_VALID_STATE_FOR_NOTIF(
- peer->connection.status)) {
+ peer->connection->status)) {
peer->last_reset =
PEER_DOWN_CONFED_PEER_CHANGE;
bgp_notify_send(
{
bgp_peer_connection_buffers_free(connection);
pthread_mutex_destroy(&connection->io_mtx);
+
+ memset(connection, 0, sizeof(struct peer_connection));
+ XFREE(MTYPE_BGP_PEER, connection);
}
-static void bgp_peer_connection_new(struct peer *peer,
- struct peer_connection *connection)
+struct peer_connection *bgp_peer_connection_new(struct peer *peer)
{
+ struct peer_connection *connection;
+
+ connection = XCALLOC(MTYPE_BGP_PEER, sizeof(struct peer_connection));
+
connection->peer = peer;
connection->fd = -1;
*/
connection->ibuf_work =
ringbuf_new(BGP_MAX_PACKET_SIZE * BGP_READ_PACKET_MAX);
+
+ connection->status = Idle;
+ connection->ostatus = Idle;
+
+ return connection;
}
static void peer_free(struct peer *peer)
afi_t afi;
safi_t safi;
- assert(peer->connection.status == Deleted);
+ assert(peer->connection->status == Deleted);
QOBJ_UNREG(peer);
* but just to be sure..
*/
bgp_timer_set(peer);
- bgp_reads_off(&peer->connection);
- bgp_writes_off(&peer->connection);
+ bgp_reads_off(peer->connection);
+ bgp_writes_off(peer->connection);
event_cancel_event_ready(bm->master, peer);
FOREACH_AFI_SAFI (afi, safi)
EVENT_OFF(peer->t_revalidate_all[afi][safi]);
- assert(!peer->connection.t_write);
- assert(!peer->connection.t_read);
+ assert(!peer->connection->t_write);
+ assert(!peer->connection->t_read);
BGP_EVENT_FLUSH(peer);
- bgp_peer_connection_free(&peer->connection);
-
/* Free connected nexthop, if present */
if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)
&& !peer_dynamic_neighbor(peer))
if (peer->as_pretty)
XFREE(MTYPE_BGP, peer->as_pretty);
+ bgp_peer_connection_free(peer->connection);
+
bgp_unlock(peer->bgp);
stream_free(peer->last_reset_cause);
/* Allocate new peer. */
peer = XCALLOC(MTYPE_BGP_PEER, sizeof(struct peer));
+ /* Create buffers. */
+ peer->connection = bgp_peer_connection_new(peer);
+
/* Set default value. */
peer->v_start = BGP_INIT_START_TIMER;
peer->v_connect = bgp->default_connect_retry;
- peer->connection.status = Idle;
- peer->connection.ostatus = Idle;
peer->cur_event = peer->last_event = peer->last_major_event = 0;
peer->bgp = bgp_lock(bgp);
peer = peer_lock(peer); /* initial reference */
bgp_peer_gr_init(peer);
/* Create buffers. */
- bgp_peer_connection_new(peer, &peer->connection);
+ peer->connection = bgp_peer_connection_new(peer);
/* Get service port number. */
sp = getservbyname("bgp", "tcp");
/* Stop peer. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_REMOTE_AS_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
}
- if (peer->connection.status == OpenSent ||
- peer->connection.status == OpenConfirm) {
+ if (peer->connection->status == OpenSent ||
+ peer->connection->status == OpenConfirm) {
peer->last_reset = PEER_DOWN_AF_ACTIVATE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
* activation.
*/
other = peer->doppelganger;
- if (other && (other->connection.status == OpenSent ||
- other->connection.status == OpenConfirm)) {
+ if (other && (other->connection->status == OpenSent ||
+ other->connection->status == OpenConfirm)) {
other->last_reset = PEER_DOWN_AF_ACTIVATE;
bgp_notify_send(other, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
struct listnode *pn;
int accept_peer;
- assert(peer->connection.status != Deleted);
+ assert(peer->connection->status != Deleted);
bgp = peer->bgp;
accept_peer = CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER);
bgp_soft_reconfig_table_task_cancel(bgp, NULL, peer);
bgp_keepalives_off(peer);
- bgp_reads_off(&peer->connection);
- bgp_writes_off(&peer->connection);
+ bgp_reads_off(peer->connection);
+ bgp_writes_off(peer->connection);
event_cancel_event_ready(bm->master, peer);
FOREACH_AFI_SAFI (afi, safi)
EVENT_OFF(peer->t_revalidate_all[afi][safi]);
- assert(!CHECK_FLAG(peer->connection.thread_flags,
+ assert(!CHECK_FLAG(peer->connection->thread_flags,
PEER_THREAD_WRITES_ON));
- assert(!CHECK_FLAG(peer->connection.thread_flags,
+ assert(!CHECK_FLAG(peer->connection->thread_flags,
PEER_THREAD_READS_ON));
assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON));
void peer_notify_unconfig(struct peer *peer)
{
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
}
return;
}
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
}
for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
other = peer->doppelganger;
- if (other && other->connection.status != Deleted) {
+ if (other && other->connection->status != Deleted) {
other->group = NULL;
peer_notify_unconfig(other);
} else
bgp_zebra_terminate_radv(bgp, peer);
peer_delete(peer);
- if (other && other->connection.status != Deleted) {
+ if (other && other->connection->status != Deleted) {
other->group = NULL;
peer_delete(other);
}
peer_delete(peer);
- if (other && other->connection.status != Deleted) {
+ if (other && other->connection->status != Deleted) {
other->group = NULL;
peer_delete(other);
}
SET_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE);
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_RMAP_BIND;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
/* Bring down peers, so corresponding routes are purged. */
for (ALL_LIST_ELEMENTS(bgp->peer, node, next, peer)) {
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
else
/* If we're resetting session, we've to delete both peer struct
*/
if ((peer->doppelganger) &&
- (peer->doppelganger->connection.status != Deleted) &&
+ (peer->doppelganger->connection->status != Deleted) &&
(!CHECK_FLAG(peer->doppelganger->flags,
PEER_FLAG_CONFIG_NODE)))
peer_delete(peer->doppelganger);
BGP_ROUTE_REFRESH_NORMAL);
else {
if ((peer->doppelganger) &&
- (peer->doppelganger->connection.status != Deleted) &&
+ (peer->doppelganger->connection->status != Deleted) &&
(!CHECK_FLAG(peer->doppelganger->flags,
PEER_FLAG_CONFIG_NODE)))
peer_delete(peer->doppelganger);
}
if (BGP_IS_VALID_STATE_FOR_NOTIF(
- peer->connection.status)) {
+ peer->connection->status)) {
char *msg = peer->tx_shutdown_message;
size_t msglen;
uint8_t msgbuf[BGP_ADMIN_SHUTDOWN_MSG_LEN + 1];
peer->v_start = BGP_INIT_START_TIMER;
BGP_EVENT_ADD(peer, BGP_Stop);
}
- } else if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ } else if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
if (flag == PEER_FLAG_DYNAMIC_CAPABILITY)
peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
else if (flag == PEER_FLAG_PASSIVE)
continue;
/* send a RFC 4486 notification message if necessary */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
if (msg) {
size_t datalen = strlen(msg);
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
if (peer->sort != BGP_PEER_IBGP) {
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(
+ peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
peer->ttl = group->conf->ttl;
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(
+ peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
peer->ttl = ttl;
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
peer->ttl = BGP_DEFAULT_TTL;
- if (peer->connection.fd >= 0) {
+ if (peer->connection->fd >= 0) {
if (BGP_IS_VALID_STATE_FOR_NOTIF(
- peer->connection.status))
+ peer->connection->status))
bgp_notify_send(
peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
/* Check if handling a regular peer. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
member->update_source = NULL;
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status)) {
member->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send(member, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
/* Check if handling a regular peer. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
XFREE(MTYPE_PEER_UPDATE_SOURCE, member->update_if);
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status)) {
member->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send(member, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
/* Check if handling a regular peer. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
XFREE(MTYPE_PEER_UPDATE_SOURCE, member->update_if);
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status)) {
member->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send(member, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
/* Check if handling a regular peer. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
/* Send notification or stop peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) {
peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
XFREE(MTYPE_BGP, member->change_local_as_pretty);
/* Send notification or stop peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status)) {
member->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
bgp_notify_send(member, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
/* Check if handling a regular peer. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
member->password = XSTRDUP(MTYPE_PEER_PASSWORD, password);
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status))
bgp_notify_send(member, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
/* Check if handling a regular peer. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
XFREE(MTYPE_PEER_PASSWORD, member->password);
/* Send notification or reset peer depending on state. */
- if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status))
bgp_notify_send(member, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
peer->gtsm_hops = gtsm_hops;
- if (peer->connection.fd >= 0)
+ if (peer->connection->fd >= 0)
sockopt_minttl(peer->su.sa.sa_family,
- peer->connection.fd,
+ peer->connection->fd,
MAXTTL + 1 - gtsm_hops);
- if ((peer->connection.status < Established) &&
+ if ((peer->connection->status < Established) &&
peer->doppelganger &&
- (peer->doppelganger->connection.fd >= 0))
+ (peer->doppelganger->connection->fd >= 0))
sockopt_minttl(peer->su.sa.sa_family,
- peer->doppelganger->connection.fd,
+ peer->doppelganger->connection->fd,
MAXTTL + 1 - gtsm_hops);
} else {
group = peer->group;
* no session then do nothing (will get
* handled by next connection)
*/
- if (gpeer->connection.fd >= 0 &&
+ if (gpeer->connection->fd >= 0 &&
gpeer->gtsm_hops != BGP_GTSM_HOPS_DISABLED)
sockopt_minttl(gpeer->su.sa.sa_family,
- gpeer->connection.fd,
+ gpeer->connection->fd,
MAXTTL + 1 -
gpeer->gtsm_hops);
- if ((gpeer->connection.status < Established) &&
+ if ((gpeer->connection->status < Established) &&
gpeer->doppelganger &&
- (gpeer->doppelganger->connection.fd >= 0))
+ (gpeer->doppelganger->connection->fd >= 0))
sockopt_minttl(gpeer->su.sa.sa_family,
gpeer->doppelganger
- ->connection.fd,
+ ->connection->fd,
MAXTTL + 1 - gtsm_hops);
}
}
if (peer->sort == BGP_PEER_EBGP)
ret = peer_ebgp_multihop_unset(peer);
else {
- if (peer->connection.fd >= 0)
+ if (peer->connection->fd >= 0)
sockopt_minttl(peer->su.sa.sa_family,
- peer->connection.fd, 0);
+ peer->connection->fd, 0);
- if ((peer->connection.status < Established) &&
+ if ((peer->connection->status < Established) &&
peer->doppelganger &&
- (peer->doppelganger->connection.fd >= 0))
+ (peer->doppelganger->connection->fd >= 0))
sockopt_minttl(peer->su.sa.sa_family,
- peer->doppelganger->connection.fd,
+ peer->doppelganger->connection->fd,
0);
}
} else {
if (peer->sort == BGP_PEER_EBGP)
ret = peer_ebgp_multihop_unset(peer);
else {
- if (peer->connection.fd >= 0)
+ if (peer->connection->fd >= 0)
sockopt_minttl(peer->su.sa.sa_family,
- peer->connection.fd, 0);
+ peer->connection->fd, 0);
- if ((peer->connection.status < Established) &&
+ if ((peer->connection->status < Established) &&
peer->doppelganger &&
- (peer->doppelganger->connection.fd >= 0))
+ (peer->doppelganger->connection->fd >= 0))
sockopt_minttl(peer->su.sa.sa_family,
peer->doppelganger
- ->connection.fd,
+ ->connection->fd,
0);
}
}
return 0;
peer->v_start = BGP_INIT_START_TIMER;
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_ADMIN_RESET);
else
if (!peer->afc[afi][safi])
return BGP_ERR_AF_UNCONFIGURED;
- peer->rtt = sockopt_tcp_rtt(peer->connection.fd);
+ peer->rtt = sockopt_tcp_rtt(peer->connection->fd);
if (stype == BGP_CLEAR_SOFT_OUT || stype == BGP_CLEAR_SOFT_BOTH) {
/* Clear the "neighbor x.x.x.x default-originate" flag */
peer->host);
peer->shut_during_cfg = false;
- if (peer_active(peer) && peer->connection.status != Established) {
- if (peer->connection.status != Idle)
+ if (peer_active(peer) &&
+ peer->connection->status != Established) {
+ if (peer->connection->status != Idle)
BGP_EVENT_ADD(peer, BGP_Stop);
BGP_EVENT_ADD(peer, BGP_Start);
}
peer);
continue;
}
- if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))
+ if (BGP_IS_VALID_STATE_FOR_NOTIF(
+ peer->connection->status))
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
}
#define PEER_THREAD_WRITES_ON (1U << 0)
#define PEER_THREAD_READS_ON (1U << 1)
};
+extern struct peer_connection *bgp_peer_connection_new(struct peer *peer);
extern void bgp_peer_connection_buffers_free(struct peer_connection *connection);
/* BGP neighbor structure. */
* time to consolidate between the two, we'll solidify
* into the connection variable being used.
*/
- struct peer_connection connection;
+ struct peer_connection *connection;
int ttl; /* TTL of TCP connection to the peer. */
int rtt; /* Estimated round-trip-time from TCP_INFO */
static inline bool peer_established(struct peer *peer)
{
- return peer->connection.status == Established;
+ return peer->connection->status == Established;
}
static inline bool peer_dynamic_neighbor(struct peer *peer)
* Fill in BGP peer structure
*/
rfd->peer = peer_new(bgp);
- rfd->peer->connection.status = Established; /* keep bgp core happy */
+ rfd->peer->connection->status = Established; /* keep bgp core happy */
- bgp_peer_connection_buffers_free(&rfd->peer->connection);
+ bgp_peer_connection_buffers_free(rfd->peer->connection);
{ /* base code assumes have valid host pointer */
char buf[INET6_ADDRSTRLEN];
* Same setup as in rfapi_open()
*/
vncHD1VR.peer = peer_new(bgp);
- vncHD1VR.peer->connection.status =
+ vncHD1VR.peer->connection->status =
Established; /* keep bgp core happy */
bgp_peer_connection_buffers_free(
- &vncHD1VR.peer->connection);
+ vncHD1VR.peer->connection);
/* base code assumes have valid host pointer */
vncHD1VR.peer->host =
bgp.asnotation = t->segment->asnotation;
peer.curr = stream_new(BGP_MAX_PACKET_SIZE);
- peer.connection.obuf = stream_fifo_new();
+ peer.connection = bgp_peer_connection_new(&peer);
+ peer.connection->obuf = stream_fifo_new();
peer.bgp = &bgp;
peer.host = (char *)"none";
- peer.connection.fd = -1;
+ peer.connection->fd = -1;
peer.cap = t->cap;
peer.max_packet_size = BGP_STANDARD_MESSAGE_MAX_PACKET_SIZE;
parse_test(peer, &opt_params[i++], OPT_PARAM);
SET_FLAG(peer->cap, PEER_CAP_DYNAMIC_ADV);
- peer->connection.status = Established;
+ peer->connection = bgp_peer_connection_new(peer);
+ peer->connection->status = Established;
i = 0;
while (dynamic_cap_msgs[i].name)
peer = peer_create_accept(bgp);
peer->host = (char *)"foo";
- peer->connection.status = Established;
+ peer->connection = bgp_peer_connection_new(peer);
+ peer->connection->status = Established;
peer->curr = stream_new(BGP_MAX_PACKET_SIZE);
ifp.ifindex = 0;
}
SET_FLAG(peer->cap, PEER_CAP_DYNAMIC_ADV);
- peer->connection.status = Established;
+ peer->connection = bgp_peer_connection_new(peer);
+ peer->connection->status = Established;
- peer->connection.fd = open(argv[1], O_RDONLY | O_NONBLOCK);
+ peer->connection->fd = open(argv[1], O_RDONLY | O_NONBLOCK);
t.arg = peer;
- peer->connection.t_read = &t;
+ peer->connection->t_read = &t;
// printf("bgp_read_packet returns: %d\n", bgp_read(&t));
}