summaryrefslogtreecommitdiff
path: root/bgpd/bgp_fsm.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_fsm.c')
-rw-r--r--bgpd/bgp_fsm.c51
1 files changed, 20 insertions, 31 deletions
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index ac25f151..3d8e9576 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -292,7 +292,7 @@ bgp_routeadv_timer (struct thread *thread)
peer->synctime = time (NULL);
- BGP_WRITE_ON (peer->t_write, bgp_write, *peer->fd);
+ BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
BGP_TIMER_ON (peer->t_routeadv, bgp_routeadv_timer,
peer->v_routeadv);
@@ -307,21 +307,6 @@ bgp_uptime_reset (struct peer *peer)
peer->uptime = time (NULL);
}
-void
-bgp_connection_stop (struct peer *peer)
-{
- if (peer->fd_local >= 0)
- {
- close (peer->fd_local);
- peer->fd_local = -1;
- }
- if (peer->fd_accept >= 0)
- {
- close (peer->fd_accept);
- peer->fd_accept = -1;
- }
-}
-
/* Administrative BGP peer stop event. */
int
bgp_stop (struct peer *peer)
@@ -382,8 +367,12 @@ bgp_stop (struct peer *peer)
stream_reset (peer->work);
stream_fifo_clean (peer->obuf);
- /* Close of connections. */
- bgp_connection_stop (peer);
+ /* Close of file descriptor. */
+ if (peer->fd >= 0)
+ {
+ close (peer->fd);
+ peer->fd = -1;
+ }
/* Connection information. */
if (peer->su_local)
@@ -397,7 +386,7 @@ bgp_stop (struct peer *peer)
XFREE (MTYPE_SOCKUNION, peer->su_remote);
peer->su_remote = NULL;
}
-
+
/* Clear remote router-id. */
peer->remote_id.s_addr = 0;
@@ -488,13 +477,13 @@ bgp_stop_with_error (struct peer *peer)
int
bgp_connect_success (struct peer *peer)
{
- if (peer->fd_local < 0)
+ if (peer->fd < 0)
{
zlog_err ("bgp_connect_success peer's fd is negative value %d",
- peer->fd_local);
+ peer->fd);
return -1;
}
- BGP_READ_ON (peer->t_read, bgp_read, peer->fd_local);
+ BGP_READ_ON (peer->t_read, bgp_read, peer->fd);
/* bgp_getsockname (peer); */
@@ -532,29 +521,29 @@ bgp_start (struct peer *peer)
{
case connect_error:
if (BGP_DEBUG (fsm, FSM))
- plog_info (peer->log, "%s [FSM] Connect error", peer->host);
+ plog_info (peer->log, "%s [FSM] Connect error", peer->host);
BGP_EVENT_ADD (peer, TCP_connection_open_failed);
break;
case connect_success:
if (BGP_DEBUG (fsm, FSM))
- plog_info (peer->log, "%s [FSM] Connect immediately success",
- peer->host);
+ plog_info (peer->log, "%s [FSM] Connect immediately success",
+ peer->host);
BGP_EVENT_ADD (peer, TCP_connection_open);
break;
case connect_in_progress:
/* To check nonblocking connect, we wait until socket is
readable or writable. */
if (BGP_DEBUG (fsm, FSM))
- plog_info (peer->log, "%s [FSM] Non blocking connect waiting result",
- peer->host);
- if (*peer->fd < 0)
+ plog_info (peer->log, "%s [FSM] Non blocking connect waiting result",
+ peer->host);
+ if (peer->fd < 0)
{
zlog_err ("bgp_start peer's fd is negative value %d",
- *peer->fd);
+ peer->fd);
return -1;
}
- BGP_READ_ON (peer->t_read, bgp_read, *peer->fd);
- BGP_WRITE_ON (peer->t_write, bgp_write, *peer->fd);
+ BGP_READ_ON (peer->t_read, bgp_read, peer->fd);
+ BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
break;
}
return 0;