summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Walton <dwalton76@gmail.com>2014-09-30 14:53:10 -0700
committerTimo Teräs <timo.teras@iki.fi>2015-06-04 11:30:09 +0300
commite101cddf66298ee6a7c5b6dd31907fb19fb468cb (patch)
tree15f39552156769dde5e91d42050b07da5c60d36c
parent81545b477d5baf93087773a1ffafe8e145f21ada (diff)
downloadquagga-e101cddf66298ee6a7c5b6dd31907fb19fb468cb.tar.bz2
quagga-e101cddf66298ee6a7c5b6dd31907fb19fb468cb.tar.xz
bgpd-add-peer-group-timers.patch
BGP: Add support for timer commands with peer-group syntax The peer-groups parser is missing advertisement-interval and 'timers connect' Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Timo Teräs <timo.teras@iki.fi>
-rw-r--r--bgpd/bgp_vty.c28
-rw-r--r--bgpd/bgpd.c104
2 files changed, 105 insertions, 27 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 62331635..4c35f9cb 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -3369,7 +3369,7 @@ peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
struct peer *peer;
u_int32_t connect;
- peer = peer_lookup_vty (vty, ip_str);
+ peer = peer_and_group_lookup_vty (vty, ip_str);
if (! peer)
return CMD_WARNING;
@@ -3392,9 +3392,9 @@ peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
DEFUN (neighbor_timers_connect,
neighbor_timers_connect_cmd,
- NEIGHBOR_CMD "timers connect <0-65535>",
+ NEIGHBOR_CMD2 "timers connect <0-65535>",
NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
+ NEIGHBOR_ADDR_STR2
"BGP per neighbor timers\n"
"BGP connect timer\n"
"Connect timer\n")
@@ -3404,10 +3404,10 @@ DEFUN (neighbor_timers_connect,
DEFUN (no_neighbor_timers_connect,
no_neighbor_timers_connect_cmd,
- NO_NEIGHBOR_CMD "timers connect",
+ NO_NEIGHBOR_CMD2 "timers connect",
NO_STR
NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
+ NEIGHBOR_ADDR_STR2
"BGP per neighbor timers\n"
"BGP connect timer\n")
{
@@ -3416,10 +3416,10 @@ DEFUN (no_neighbor_timers_connect,
ALIAS (no_neighbor_timers_connect,
no_neighbor_timers_connect_val_cmd,
- NO_NEIGHBOR_CMD "timers connect <0-65535>",
+ NO_NEIGHBOR_CMD2 "timers connect <0-65535>",
NO_STR
NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
+ NEIGHBOR_ADDR_STR2
"BGP per neighbor timers\n"
"BGP connect timer\n"
"Connect timer\n")
@@ -3432,7 +3432,7 @@ peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
struct peer *peer;
u_int32_t routeadv = 0;
- peer = peer_lookup_vty (vty, ip_str);
+ peer = peer_and_group_lookup_vty (vty, ip_str);
if (! peer)
return CMD_WARNING;
@@ -3449,9 +3449,9 @@ peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
DEFUN (neighbor_advertise_interval,
neighbor_advertise_interval_cmd,
- NEIGHBOR_CMD "advertisement-interval <0-600>",
+ NEIGHBOR_CMD2 "advertisement-interval <0-600>",
NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
+ NEIGHBOR_ADDR_STR2
"Minimum interval between sending BGP routing updates\n"
"time in seconds\n")
{
@@ -3460,10 +3460,10 @@ DEFUN (neighbor_advertise_interval,
DEFUN (no_neighbor_advertise_interval,
no_neighbor_advertise_interval_cmd,
- NO_NEIGHBOR_CMD "advertisement-interval",
+ NO_NEIGHBOR_CMD2 "advertisement-interval",
NO_STR
NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
+ NEIGHBOR_ADDR_STR2
"Minimum interval between sending BGP routing updates\n")
{
return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
@@ -3471,10 +3471,10 @@ DEFUN (no_neighbor_advertise_interval,
ALIAS (no_neighbor_advertise_interval,
no_neighbor_advertise_interval_val_cmd,
- NO_NEIGHBOR_CMD "advertisement-interval <0-600>",
+ NO_NEIGHBOR_CMD2 "advertisement-interval <0-600>",
NO_STR
NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
+ NEIGHBOR_ADDR_STR2
"Minimum interval between sending BGP routing updates\n"
"time in seconds\n")
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 4de854e4..b92a89ea 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -908,6 +908,7 @@ static void
peer_as_change (struct peer *peer, as_t as)
{
bgp_peer_sort_t type;
+ struct peer *conf;
/* Stop peer. */
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
@@ -932,10 +933,17 @@ peer_as_change (struct peer *peer, as_t as)
peer->local_as = peer->bgp->as;
/* Advertisement-interval reset */
- if (peer_sort (peer) == BGP_PEER_IBGP)
- peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
+ conf = NULL;
+ if (peer->group)
+ conf = peer->group->conf;
+
+ if (conf && CHECK_FLAG (conf->config, PEER_CONFIG_ROUTEADV))
+ peer->v_routeadv = conf->routeadv;
else
- peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
+ if (peer_sort (peer) == BGP_PEER_IBGP)
+ peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
+ else
+ peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
/* TTL reset */
if (peer_sort (peer) == BGP_PEER_IBGP)
@@ -1454,10 +1462,13 @@ peer_group2peer_config_copy (struct peer_group *group, struct peer *peer,
peer->v_connect = BGP_DEFAULT_CONNECT_RETRY;
/* advertisement-interval reset */
- if (peer_sort (peer) == BGP_PEER_IBGP)
- peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
+ if (CHECK_FLAG (conf->config, PEER_CONFIG_ROUTEADV))
+ peer->v_routeadv = conf->routeadv;
else
- peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
+ if (peer_sort (peer) == BGP_PEER_IBGP)
+ peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
+ else
+ peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
/* password apply */
if (conf->password && !peer->password)
@@ -1815,10 +1826,13 @@ peer_group_bind (struct bgp *bgp, union sockunion *su,
if (first_member)
{
/* Advertisement-interval reset */
- if (peer_sort (group->conf) == BGP_PEER_IBGP)
- group->conf->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
- else
- group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
+ if (! CHECK_FLAG (group->conf->config, PEER_CONFIG_ROUTEADV))
+ {
+ if (peer_sort (group->conf) == BGP_PEER_IBGP)
+ group->conf->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
+ else
+ group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
+ }
/* ebgp-multihop reset */
if (peer_sort (group->conf) == BGP_PEER_IBGP)
@@ -3296,6 +3310,9 @@ peer_timers_unset (struct peer *peer)
int
peer_timers_connect_set (struct peer *peer, u_int32_t connect)
{
+ struct peer_group *group;
+ struct listnode *node, *nnode;
+
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
@@ -3309,12 +3326,26 @@ peer_timers_connect_set (struct peer *peer, u_int32_t connect)
/* Set value to timer setting. */
peer->v_connect = connect;
+ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
+ return 0;
+
+ /* peer-group member updates. */
+ group = peer->group;
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
+ {
+ SET_FLAG (peer->config, PEER_CONFIG_CONNECT);
+ peer->connect = connect;
+ peer->v_connect = connect;
+ }
return 0;
}
int
peer_timers_connect_unset (struct peer *peer)
{
+ struct peer_group *group;
+ struct listnode *node, *nnode;
+
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
@@ -3325,12 +3356,26 @@ peer_timers_connect_unset (struct peer *peer)
/* Set timer setting to default value. */
peer->v_connect = BGP_DEFAULT_CONNECT_RETRY;
- return 0;
+ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
+ return 0;
+
+ /* peer-group member updates. */
+ group = peer->group;
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
+ {
+ UNSET_FLAG (peer->config, PEER_CONFIG_CONNECT);
+ peer->connect = 0;
+ peer->v_connect = BGP_DEFAULT_CONNECT_RETRY;
+ }
+ return 0;
}
int
peer_advertise_interval_set (struct peer *peer, u_int32_t routeadv)
{
+ struct peer_group *group;
+ struct listnode *node, *nnode;
+
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
@@ -3341,12 +3386,27 @@ peer_advertise_interval_set (struct peer *peer, u_int32_t routeadv)
peer->routeadv = routeadv;
peer->v_routeadv = routeadv;
+ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
+ return 0;
+
+ /* peer-group member updates. */
+ group = peer->group;
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
+ {
+ SET_FLAG (peer->config, PEER_CONFIG_ROUTEADV);
+ peer->routeadv = routeadv;
+ peer->v_routeadv = routeadv;
+ }
+
return 0;
}
int
peer_advertise_interval_unset (struct peer *peer)
{
+ struct peer_group *group;
+ struct listnode *node, *nnode;
+
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
@@ -3357,6 +3417,22 @@ peer_advertise_interval_unset (struct peer *peer)
peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
else
peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
+
+ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
+ return 0;
+
+ /* peer-group member updates. */
+ group = peer->group;
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
+ {
+ UNSET_FLAG (peer->config, PEER_CONFIG_ROUTEADV);
+ peer->routeadv = 0;
+
+ if (peer->sort == BGP_PEER_IBGP)
+ peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
+ else
+ peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
+ }
return 0;
}
@@ -4904,7 +4980,8 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
VTY_NEWLINE);
/* advertisement-interval */
- if (CHECK_FLAG (peer->config, PEER_CONFIG_ROUTEADV))
+ if (CHECK_FLAG (peer->config, PEER_CONFIG_ROUTEADV) &&
+ ! peer_group_active (peer))
vty_out (vty, " neighbor %s advertisement-interval %d%s",
addr, peer->v_routeadv, VTY_NEWLINE);
@@ -4914,7 +4991,8 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
vty_out (vty, " neighbor %s timers %d %d%s", addr,
peer->keepalive, peer->holdtime, VTY_NEWLINE);
- if (CHECK_FLAG (peer->config, PEER_CONFIG_CONNECT))
+ if (CHECK_FLAG (peer->config, PEER_CONFIG_CONNECT) &&
+ ! peer_group_active (peer))
vty_out (vty, " neighbor %s timers connect %d%s", addr,
peer->connect, VTY_NEWLINE);