-
Notifications
You must be signed in to change notification settings - Fork 27
[Dynamic Neighbor]: add patch to support dynamic neighbor configuration. #14
Changes from 2 commits
706b450
e336deb
0461308
19f3be2
fa8d894
c21cb39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -439,6 +439,17 @@ bgp_stop (struct peer *peer) | |
safi_t safi; | ||
char orf_name[BUFSIZ]; | ||
|
||
if (peer_dynamic_neighbor(peer) && | ||
!(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) | ||
{ | ||
if (BGP_DEBUG (events, EVENTS)) | ||
{ | ||
zlog_debug("%s (dynamic neighbor) deleted", peer->host); | ||
} | ||
peer_delete (peer); | ||
return -1; | ||
} | ||
|
||
/* Can't do this in Clearing; events are used for state transitions */ | ||
if (peer->status != Clearing) | ||
{ | ||
|
@@ -588,6 +599,17 @@ bgp_stop_with_error (struct peer *peer) | |
if (peer->v_start >= (60 * 2)) | ||
peer->v_start = (60 * 2); | ||
|
||
if (peer_dynamic_neighbor(peer)) | ||
{ | ||
if (BGP_DEBUG (events, EVENTS)) | ||
{ | ||
zlog_debug ("%s (dynamic neighbor) deleted", peer->host); | ||
} | ||
|
||
peer_delete (peer); | ||
return -1; | ||
} | ||
|
||
bgp_stop (peer); | ||
|
||
return 0; | ||
|
@@ -609,6 +631,17 @@ bgp_stop_with_notify (struct peer *peer, u_char code, u_char sub_code) | |
return -1; | ||
} | ||
|
||
if (peer_dynamic_neighbor(peer)) | ||
{ | ||
if (BGP_DEBUG (events, EVENTS)) | ||
{ | ||
zlog_debug ("%s (dynamic neighbor) deleted", peer->host); | ||
} | ||
|
||
peer_delete (peer); | ||
return -1; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should move into bgp_stop() |
||
|
||
/* Clear start timer value to default. */ | ||
peer->v_start = BGP_INIT_START_TIMER; | ||
|
||
|
@@ -656,6 +689,17 @@ bgp_connect_success (struct peer *peer) | |
static int | ||
bgp_connect_fail (struct peer *peer) | ||
{ | ||
if (peer_dynamic_neighbor(peer)) | ||
{ | ||
if (BGP_DEBUG (events, EVENTS)) | ||
{ | ||
zlog_debug ("%s (dynamic neighbor) deleted", peer->host); | ||
} | ||
|
||
peer_delete (peer); | ||
return -1; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move into bgp_stop(). |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same code 4 times. Probably it's better to introduce a static function here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code is used to provide log info if debug_event is enabled. They are not exactly the same. So adding more detailed log info now for better troubleshooting. |
||
bgp_stop (peer); | ||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,6 +220,7 @@ bgp_accept (struct thread *thread) | |
|
||
peer1 = peer_lookup (NULL, &su); | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably it's better to remove it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Have updated accordingly. |
||
/* | ||
* Close incoming connection from directly connected EBGP peers until we receive | ||
interface_up message from zebra | ||
|
@@ -243,14 +244,32 @@ bgp_accept (struct thread *thread) | |
|
||
if (BGP_DEBUG (events, EVENTS)) | ||
zlog_debug ("[Event] BGP connection from host %s", inet_sutop (&su, buf)); | ||
|
||
|
||
if (! peer1) | ||
{ | ||
peer1 = peer_lookup_dynamic_neighbor (NULL, &su); | ||
if (peer1) | ||
{ | ||
/* Dynamic neighbor has been created, let it proceed */ | ||
peer1->fd = bgp_sock; | ||
bgp_fsm_change_status(peer1, Active); | ||
BGP_TIMER_OFF(peer1->t_start); /* created in peer_create() */ | ||
|
||
if (peer_active (peer1)) | ||
BGP_EVENT_ADD (peer1, TCP_connection_open); | ||
|
||
return 0; | ||
} | ||
} | ||
|
||
/* Check remote IP address */ | ||
if (! peer1 || peer1->status == Idle) | ||
{ | ||
if (BGP_DEBUG (events, EVENTS)) | ||
{ | ||
if (! peer1) | ||
zlog_debug ("[Event] BGP connection IP address %s is not configured", | ||
zlog_debug ("[Event] BGP connection IP address %s rejected - not configured" | ||
" and not valid for dynamic", | ||
inet_sutop (&su, buf)); | ||
else | ||
zlog_debug ("[Event] BGP connection IP address %s is Idle state", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this logic can be merged into bgp_stop() as bgp_stop already has similar logic. We should enable code re-use.