diff options
author | paul <paul> | 2004-02-17 19:45:10 +0000 |
---|---|---|
committer | paul <paul> | 2004-02-17 19:45:10 +0000 |
commit | 6ad23f05e36e743b89fc5a9a41e3db7eccb917fb (patch) | |
tree | 522a8914b6aefe124c2e972481e89f408110ef3c /bgpd/bgp_fsm.c | |
parent | 5de5bbf107f9eacb8d8265f8c0b925b2aed21878 (diff) | |
download | quagga-6ad23f05e36e743b89fc5a9a41e3db7eccb917fb.tar.bz2 quagga-6ad23f05e36e743b89fc5a9a41e3db7eccb917fb.tar.xz |
2004-02-17 Paul Jakma <paul@dishone.st>
* bgpd.h: (bgp_peer) add fd_local and fd_accept
file descriptor's, fd becomes a pointer to one of these.
* bgpd.c: (global) adjust for fact that fd is now a pointer.
(peer_create_accept) removed.
* bgp_route.c: (global) adjust for change of peer fd to pointer
* bgp_packet.c: (bgp_collision_detect) adjust and remove the
"replace with other peer" hack.
* bgp_network.c: (bgp_accept) Remove the dummy peer hack.
Update peer->fd_accept instead.
(global) Adjust fd references - now a pointer.
* bgp_fsm.c: (global) adjust peer fd to pointer.
(bgp_connection_stop) new function, to stop connection.
(global) adjust everything which closed peer fd to use
bgp_connection_stop().
Diffstat (limited to 'bgpd/bgp_fsm.c')
-rw-r--r-- | bgpd/bgp_fsm.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 3d8e9576..ac25f151 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,6 +307,21 @@ 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) @@ -367,12 +382,8 @@ bgp_stop (struct peer *peer) stream_reset (peer->work); stream_fifo_clean (peer->obuf); - /* Close of file descriptor. */ - if (peer->fd >= 0) - { - close (peer->fd); - peer->fd = -1; - } + /* Close of connections. */ + bgp_connection_stop (peer); /* Connection information. */ if (peer->su_local) @@ -386,7 +397,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; @@ -477,13 +488,13 @@ bgp_stop_with_error (struct peer *peer) int bgp_connect_success (struct peer *peer) { - if (peer->fd < 0) + if (peer->fd_local < 0) { zlog_err ("bgp_connect_success peer's fd is negative value %d", - peer->fd); + peer->fd_local); return -1; } - BGP_READ_ON (peer->t_read, bgp_read, peer->fd); + BGP_READ_ON (peer->t_read, bgp_read, peer->fd_local); /* bgp_getsockname (peer); */ @@ -521,29 +532,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; |