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/bgpd.c | |
parent | 5de5bbf107f9eacb8d8265f8c0b925b2aed21878 (diff) |
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/bgpd.c')
-rw-r--r-- | bgpd/bgpd.c | 104 |
1 files changed, 47 insertions, 57 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 3a12a27c..f4c8f762 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -504,11 +504,10 @@ bgp_default_local_preference_unset (struct bgp *bgp) return 0; } -/* Peer comparison function for sorting. */ static int peer_cmp (struct peer *p1, struct peer *p2) { - return sockunion_cmp (&p1->su, &p2->su); + return sockunion_cmp (&p1->su, &p2->su); } int @@ -684,8 +683,11 @@ peer_new () peer = XMALLOC (MTYPE_BGP_PEER, sizeof (struct peer)); memset (peer, 0, sizeof (struct peer)); + peer->fd = &peer->fd_local; + /* Set default value. */ - peer->fd = -1; + peer->fd_local = -1; + peer->fd_accept = -1; peer->v_start = BGP_INIT_START_TIMER; peer->v_connect = BGP_DEFAULT_CONNECT_RETRY; peer->v_asorig = BGP_DEFAULT_ASORIGINATE; @@ -769,19 +771,6 @@ peer_create (union sockunion *su, struct bgp *bgp, as_t local_as, return peer; } -/* Make accept BGP peer. Called from bgp_accept (). */ -struct peer * -peer_create_accept (struct bgp *bgp) -{ - struct peer *peer; - - peer = peer_new (); - peer->bgp = bgp; - listnode_add_sort (bgp->peer, peer); - - return peer; -} - /* Change peer's AS number. */ void peer_as_change (struct peer *peer, as_t as) @@ -1810,9 +1799,8 @@ peer_lookup (struct bgp *bgp, union sockunion *su) LIST_LOOP (bgp->peer, peer, nn) { - if (sockunion_same (&peer->su, su) - && ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER)) - return peer; + if (sockunion_same (&peer->su, su)) + return peer; } return NULL; } @@ -1831,27 +1819,25 @@ peer_lookup_with_open (union sockunion *su, as_t remote_as, LIST_LOOP (bgp->peer, peer, nn) { - if (sockunion_same (&peer->su, su) - && ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER)) - { - if (peer->as == remote_as - && peer->remote_id.s_addr == remote_id->s_addr) - return peer; - if (peer->as == remote_as) - *as = 1; - } + if (sockunion_same (&peer->su, su)) + { + if (peer->as == remote_as + && peer->remote_id.s_addr == remote_id->s_addr) + return peer; + if (peer->as == remote_as) + *as = 1; + } } LIST_LOOP (bgp->peer, peer, nn) { - if (sockunion_same (&peer->su, su) - && ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER)) - { - if (peer->as == remote_as - && peer->remote_id.s_addr == 0) - return peer; - if (peer->as == remote_as) - *as = 1; - } + if (sockunion_same (&peer->su, su)) + { + if (peer->as == remote_as + && peer->remote_id.s_addr == 0) + return peer; + if (peer->as == remote_as) + *as = 1; + } } return NULL; } @@ -2278,22 +2264,24 @@ peer_ebgp_multihop_set (struct peer *peer, int ttl) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP) - sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); + if (*peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP) + sockopt_ttl (peer->su.sa.sa_family, *peer->fd, + peer->ttl); } else { group = peer->group; LIST_LOOP (group->peer, peer, nn) - { - if (peer_sort (peer) == BGP_PEER_IBGP) - continue; + { + if (peer_sort (peer) == BGP_PEER_IBGP) + continue; - peer->ttl = group->conf->ttl; + peer->ttl = group->conf->ttl; - if (peer->fd >= 0) - sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); - } + if (*peer->fd >= 0) + sockopt_ttl (peer->su.sa.sa_family, + *peer->fd, peer->ttl); + } } return 0; } @@ -2314,22 +2302,24 @@ peer_ebgp_multihop_unset (struct peer *peer) if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP) - sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); + if (*peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP) + sockopt_ttl (peer->su.sa.sa_family, + *peer->fd, peer->ttl); } else { group = peer->group; LIST_LOOP (group->peer, peer, nn) - { - if (peer_sort (peer) == BGP_PEER_IBGP) - continue; - - peer->ttl = 1; - - if (peer->fd >= 0) - sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); - } + { + if (peer_sort (peer) == BGP_PEER_IBGP) + continue; + + peer->ttl = 1; + + if (*peer->fd >= 0) + sockopt_ttl (peer->su.sa.sa_family, + *peer->fd, peer->ttl); + } } return 0; } |