2002-12-13 21:15:29 +01:00
|
|
|
/* BGP flap dampening
|
2017-05-13 10:25:29 +02:00
|
|
|
* Copyright (C) 2001 IP Infusion Inc.
|
|
|
|
*
|
|
|
|
* This file is part of GNU Zebra.
|
|
|
|
*
|
|
|
|
* GNU Zebra is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* GNU Zebra is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "prefix.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "thread.h"
|
2015-05-20 03:03:47 +02:00
|
|
|
#include "queue.h"
|
2016-01-07 16:03:01 +01:00
|
|
|
#include "filter.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
#include "bgpd/bgpd.h"
|
|
|
|
#include "bgpd/bgp_damp.h"
|
|
|
|
#include "bgpd/bgp_table.h"
|
|
|
|
#include "bgpd/bgp_route.h"
|
|
|
|
#include "bgpd/bgp_attr.h"
|
|
|
|
#include "bgpd/bgp_advertise.h"
|
2020-12-17 22:36:22 +01:00
|
|
|
#include "bgpd/bgp_vty.h"
|
bgpd: show < ip > bgp < ipv4 | ipv6 > all
This commit
=> provides "all" option, to display the table entries for all(or specific) AFI/SAFIs.
=> Also introduced "show_flags" to avoid passing multiple arguments(use_json, wide, all)
to functions
1. show <ip> bgp <ipv4/ipv6> <all> <wide|json>
2. show <ip> bgp <ipv4/ipv6> <all> summary <json>
3. show <ip> bgp <ipv4/ipv6> <all> cidr-only <wide|json>
4. show <ip> bgp <ipv4/ipv6> <all> community <wide|json>
5. show <ip> bgp <ipv4/ipv6> <all> dampening <dampened-paths|flap-statistics|parameters> <wide|json>
6. show <ip> bgp <ipv4/ipv6> <all> neighbors A.B.C.D advertised-routes|filtered-routes|received-routes <wide|json>
show bgp all summary == show ip bgp all summary => output is same => display entries for all AFIs and for each SAFI.
show bgp ipv4 all summary == show ip bgp ipv4 all summary => output is same => display entries for each SAFI in AFI_IP
show bgp ipv6 all summary == show ip bgp ipv6 all summart => output is same => display entries for each SAFI in AFI_IP6
similarly for all other commands.
sample output
1. show <ip> bgp <ipv4/ipv6> <all> <wide|json>
router# show ip bgp all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router# show ip bgp ipv4 all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
router#
router#
router# show ip bgp ipv6 all wide
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router# show bgp all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router#
router# show bgp ipv4 all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
router#
router# show bgp ipv6 all wide
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
Router1# show bgp all dampening parameters
For address family: IPv4 Unicast
Half-life time: 15 min
Reuse penalty: 750
Suppress penalty: 2000
Max suppress time: 60 min
Max suppress penalty: 12000
For address family: IPv4 Multicast
Half-life time: 20 min
Reuse penalty: 1000
Suppress penalty: 10000
Max suppress time: 40 min
Max suppress penalty: 4000
For address family: IPv4 VPN
dampening not enabled for IPv4 VPN
For address family: IPv4 Encap
dampening not enabled for IPv4 Encap
For address family: IPv4 Labeled Unicast
dampening not enabled for IPv4 Labeled Unicast
For address family: IPv4 Flowspec
dampening not enabled for IPv4 Flowspec
For address family: IPv6 Unicast
dampening not enabled for IPv6 Unicast
For address family: IPv6 Multicast
Half-life time: 10 min
Reuse penalty: 1500
Suppress penalty: 15000
Max suppress time: 20 min
Max suppress penalty: 6000
For address family: IPv6 VPN
dampening not enabled for IPv6 VPN
For address family: IPv6 Encap
dampening not enabled for IPv6 Encap
For address family: IPv6 Labeled Unicast
dampening not enabled for IPv6 Labeled Unicast
For address family: IPv6 Flowspec
dampening not enabled for IPv6 Flowspec
For address family: L2VPN EVPN
dampening not enabled for L2VPN EVPN
router#
bgpd: all option with json-c apis used
Replaced vty_out with json-c wrapper functions for all option
support to show <ip> bgp commands
Sample output:
Router2# show bgp all json
{
"ipv4Unicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 8,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { "128.16.16.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"128.16.16.0",
"prefixLen":24,
"network":"128.16.16.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"130.130.0.0/16": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"130.130.0.0",
"prefixLen":16,
"network":"130.130.0.0\/16",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"192.168.50.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"192.168.50.0",
"prefixLen":24,
"network":"192.168.50.0\/24",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"IGP",
"nexthops":[
{
"ip":"10.10.20.3",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"200.200.200.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"200.200.200.0",
"prefixLen":24,
"network":"200.200.200.0\/24",
"metric":0,
"weight":0,
"peerId":"10.10.10.1",
"path":"1",
"origin":"IGP",
"nexthops":[
{
"ip":"10.10.10.1",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
] } }
,
"ipv4Multicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
,
"ipv4Flowspec":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
,
"ipv6Unicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 11,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { "2001:db8::2/128": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8::2",
"prefixLen":128,
"network":"2001:db8::2\/128",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"::",
"hostname":"router",
"afi":"ipv6",
"scope":"global",
"used":true
}
]
}
],"2001:db8::3/128": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8::3",
"prefixLen":128,
"network":"2001:db8::3\/128",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"incomplete",
"nexthops":[
{
"ip":"2001:db8:0:20::3",
"hostname":"router",
"afi":"ipv6",
"scope":"global"
},
{
"ip":"fe80::a00:27ff:fe76:6738",
"hostname":"router",
"afi":"ipv6",
"scope":"link-local",
"used":true
}
]
}
],"2001:db8:0:20::/64": [
{
"valid":true,
"pathFrom":"external",
"prefix":"2001:db8:0:20::",
"prefixLen":64,
"network":"2001:db8:0:20::\/64",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"incomplete",
"nexthops":[
{
"ip":"2001:db8:0:20::3",
"hostname":"router",
"afi":"ipv6",
"scope":"global"
},
{
"ip":"fe80::a00:27ff:fe76:6738",
"hostname":"router",
"afi":"ipv6",
"scope":"link-local",
"used":true
}
]
},
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8:0:20::",
"prefixLen":64,
"network":"2001:db8:0:20::\/64",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"::",
"hostname":"router",
"afi":"ipv6",
"scope":"global",
"used":true
}
]
}
] } }
,
"ipv6Multicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
}
Router2#
Signed-off-by: Madhuri Kuruganti <k.madhuri@samsung.com>
2020-07-30 17:19:09 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Global variable to access damping configuration */
|
2019-11-10 19:13:20 +01:00
|
|
|
static struct bgp_damp_config damp[AFI_MAX][SAFI_MAX];
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Utility macro to add and delete BGP dampening information to no
|
|
|
|
used list. */
|
2018-09-14 02:34:42 +02:00
|
|
|
#define BGP_DAMP_LIST_ADD(N, A) BGP_PATH_INFO_ADD(N, A, no_reuse_list)
|
|
|
|
#define BGP_DAMP_LIST_DEL(N, A) BGP_PATH_INFO_DEL(N, A, no_reuse_list)
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Calculate reuse list index by penalty value. */
|
2019-11-10 19:13:20 +01:00
|
|
|
static int bgp_reuse_index(int penalty, struct bgp_damp_config *bdc)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-13 07:06:08 +02:00
|
|
|
unsigned int i;
|
2002-12-13 21:15:29 +01:00
|
|
|
int index;
|
|
|
|
|
2020-07-27 19:38:42 +02:00
|
|
|
/*
|
|
|
|
* reuse_limit can't be zero, this is for Coverity
|
|
|
|
* to bypass division by zero test.
|
|
|
|
*/
|
|
|
|
assert(bdc->reuse_limit);
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
i = (int)(((double)penalty / bdc->reuse_limit - 1.0)
|
|
|
|
* bdc->scale_factor);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
if (i >= bdc->reuse_index_size)
|
|
|
|
i = bdc->reuse_index_size - 1;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
index = bdc->reuse_index[i] - bdc->reuse_index[0];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
return (bdc->reuse_offset + index) % bdc->reuse_list_size;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add BGP dampening information to reuse list. */
|
2019-11-10 19:13:20 +01:00
|
|
|
static void bgp_reuse_list_add(struct bgp_damp_info *bdi,
|
|
|
|
struct bgp_damp_config *bdc)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
int index;
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
index = bdi->index = bgp_reuse_index(bdi->penalty, bdc);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
bdi->prev = NULL;
|
2019-11-10 19:13:20 +01:00
|
|
|
bdi->next = bdc->reuse_list[index];
|
|
|
|
if (bdc->reuse_list[index])
|
|
|
|
bdc->reuse_list[index]->prev = bdi;
|
|
|
|
bdc->reuse_list[index] = bdi;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete BGP dampening information from reuse list. */
|
2019-11-10 19:13:20 +01:00
|
|
|
static void bgp_reuse_list_delete(struct bgp_damp_info *bdi,
|
|
|
|
struct bgp_damp_config *bdc)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
if (bdi->next)
|
|
|
|
bdi->next->prev = bdi->prev;
|
|
|
|
if (bdi->prev)
|
|
|
|
bdi->prev->next = bdi->next;
|
|
|
|
else
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->reuse_list[bdi->index] = bdi->next;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return decayed penalty value. */
|
2019-11-10 19:13:20 +01:00
|
|
|
int bgp_damp_decay(time_t tdiff, int penalty, struct bgp_damp_config *bdc)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-13 07:06:08 +02:00
|
|
|
unsigned int i;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
i = (int)((double)tdiff / DELTA_T);
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
return penalty;
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
if (i >= bdc->decay_array_size)
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
return (int)(penalty * bdc->decay_array[i]);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Handler of reuse timer event. Each route in the current reuse-list
|
|
|
|
is evaluated. RFC2439 Section 4.8.7. */
|
|
|
|
static int bgp_reuse_timer(struct thread *t)
|
|
|
|
{
|
|
|
|
struct bgp_damp_info *bdi;
|
|
|
|
struct bgp_damp_info *next;
|
|
|
|
time_t t_now, t_diff;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
struct bgp_damp_config *bdc = THREAD_ARG(t);
|
|
|
|
|
|
|
|
bdc->t_reuse = NULL;
|
|
|
|
thread_add_timer(bm->master, bgp_reuse_timer, bdc, DELTA_REUSE,
|
|
|
|
&bdc->t_reuse);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2010-01-15 14:22:10 +01:00
|
|
|
t_now = bgp_clock();
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* 1. save a pointer to the current zeroth queue head and zero the
|
|
|
|
list head entry. */
|
2019-11-10 19:13:20 +01:00
|
|
|
bdi = bdc->reuse_list[bdc->reuse_offset];
|
|
|
|
bdc->reuse_list[bdc->reuse_offset] = NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* 2. set offset = modulo reuse-list-size ( offset + 1 ), thereby
|
|
|
|
rotating the circular queue of list-heads. */
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->reuse_offset = (bdc->reuse_offset + 1) % bdc->reuse_list_size;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* 3. if ( the saved list head pointer is non-empty ) */
|
|
|
|
for (; bdi; bdi = next) {
|
2018-10-03 00:34:03 +02:00
|
|
|
struct bgp *bgp = bdi->path->peer->bgp;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
next = bdi->next;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Set t-diff = t-now - t-updated. */
|
|
|
|
t_diff = t_now - bdi->t_updated;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Set figure-of-merit = figure-of-merit * decay-array-ok
|
|
|
|
* [t-diff] */
|
2019-11-10 19:13:20 +01:00
|
|
|
bdi->penalty = bgp_damp_decay(t_diff, bdi->penalty, bdc);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Set t-updated = t-now. */
|
|
|
|
bdi->t_updated = t_now;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* if (figure-of-merit < reuse). */
|
2019-11-10 19:13:20 +01:00
|
|
|
if (bdi->penalty < bdc->reuse_limit) {
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Reuse the route. */
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_path_info_unset_flag(bdi->dest, bdi->path,
|
2018-10-03 00:15:34 +02:00
|
|
|
BGP_PATH_DAMPED);
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi->suppress_time = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (bdi->lastrecord == BGP_RECORD_UPDATE) {
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_path_info_unset_flag(bdi->dest, bdi->path,
|
2018-10-03 00:15:34 +02:00
|
|
|
BGP_PATH_HISTORY);
|
2020-03-22 05:02:18 +01:00
|
|
|
bgp_aggregate_increment(
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp, bgp_dest_get_prefix(bdi->dest),
|
2020-03-22 05:02:18 +01:00
|
|
|
bdi->path, bdi->afi, bdi->safi);
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_process(bgp, bdi->dest, bdi->afi,
|
|
|
|
bdi->safi);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
if (bdi->penalty <= bdc->reuse_limit / 2.0)
|
|
|
|
bgp_damp_info_free(bdi, 1, bdc->afi, bdc->safi);
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
2019-11-10 19:13:20 +01:00
|
|
|
BGP_DAMP_LIST_ADD(bdc, bdi);
|
2017-07-17 14:03:14 +02:00
|
|
|
} else
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Re-insert into another list (See RFC2439 Section
|
|
|
|
* 4.8.6). */
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_reuse_list_add(bdi, bdc);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A route becomes unreachable (RFC2439 Section 4.8.2). */
|
2020-03-27 00:11:58 +01:00
|
|
|
int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest,
|
2018-10-02 22:41:30 +02:00
|
|
|
afi_t afi, safi_t safi, int attr_change)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
time_t t_now;
|
2007-05-04 22:15:47 +02:00
|
|
|
struct bgp_damp_info *bdi = NULL;
|
2018-09-14 14:53:55 +02:00
|
|
|
unsigned int last_penalty = 0;
|
2019-11-10 19:13:20 +01:00
|
|
|
struct bgp_damp_config *bdc = &damp[afi][safi];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2010-01-15 14:22:10 +01:00
|
|
|
t_now = bgp_clock();
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Processing Unreachable Messages. */
|
2018-10-03 00:34:03 +02:00
|
|
|
if (path->extra)
|
|
|
|
bdi = path->extra->damp_info;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (bdi == NULL) {
|
|
|
|
/* If there is no previous stability history. */
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* RFC2439 said:
|
|
|
|
1. allocate a damping structure.
|
|
|
|
2. set figure-of-merit = 1.
|
|
|
|
3. withdraw the route. */
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi = XCALLOC(MTYPE_BGP_DAMP_INFO,
|
|
|
|
sizeof(struct bgp_damp_info));
|
2018-10-03 00:34:03 +02:00
|
|
|
bdi->path = path;
|
2020-03-27 00:11:58 +01:00
|
|
|
bdi->dest = dest;
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi->penalty =
|
|
|
|
(attr_change ? DEFAULT_PENALTY / 2 : DEFAULT_PENALTY);
|
|
|
|
bdi->flap = 1;
|
|
|
|
bdi->start_time = t_now;
|
|
|
|
bdi->suppress_time = 0;
|
|
|
|
bdi->index = -1;
|
|
|
|
bdi->afi = afi;
|
|
|
|
bdi->safi = safi;
|
2018-10-03 00:34:03 +02:00
|
|
|
(bgp_path_info_extra_get(path))->damp_info = bdi;
|
2019-11-10 19:13:20 +01:00
|
|
|
BGP_DAMP_LIST_ADD(bdc, bdi);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else {
|
|
|
|
last_penalty = bdi->penalty;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* 1. Set t-diff = t-now - t-updated. */
|
2019-11-10 19:13:20 +01:00
|
|
|
bdi->penalty = (bgp_damp_decay(t_now - bdi->t_updated,
|
|
|
|
bdi->penalty, bdc)
|
|
|
|
+ (attr_change ? DEFAULT_PENALTY / 2
|
|
|
|
: DEFAULT_PENALTY));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
if (bdi->penalty > bdc->ceiling)
|
|
|
|
bdi->penalty = bdc->ceiling;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi->flap++;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-03-27 00:11:58 +01:00
|
|
|
assert((dest == bdi->dest) && (path == bdi->path));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi->lastrecord = BGP_RECORD_WITHDRAW;
|
|
|
|
bdi->t_updated = t_now;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Make this route as historical status. */
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_path_info_set_flag(dest, path, BGP_PATH_HISTORY);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Remove the route from a reuse list if it is on one. */
|
2018-10-03 00:34:03 +02:00
|
|
|
if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)) {
|
2002-12-13 21:15:29 +01:00
|
|
|
/* If decay rate isn't equal to 0, reinsert brn. */
|
2018-04-17 22:40:09 +02:00
|
|
|
if (bdi->penalty != last_penalty && bdi->index >= 0) {
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_reuse_list_delete(bdi, bdc);
|
|
|
|
bgp_reuse_list_add(bdi, bdc);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return BGP_DAMP_SUPPRESSED;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* If not suppressed before, do annonunce this withdraw and
|
|
|
|
insert into reuse_list. */
|
2019-11-10 19:13:20 +01:00
|
|
|
if (bdi->penalty >= bdc->suppress_value) {
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_path_info_set_flag(dest, path, BGP_PATH_DAMPED);
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi->suppress_time = t_now;
|
2019-11-10 19:13:20 +01:00
|
|
|
BGP_DAMP_LIST_DEL(bdc, bdi);
|
|
|
|
bgp_reuse_list_add(bdi, bdc);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return BGP_DAMP_USED;
|
|
|
|
}
|
|
|
|
|
2020-03-27 00:11:58 +01:00
|
|
|
int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest,
|
|
|
|
afi_t afi, safi_t safi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
time_t t_now;
|
|
|
|
struct bgp_damp_info *bdi;
|
|
|
|
int status;
|
2019-11-10 19:13:20 +01:00
|
|
|
struct bgp_damp_config *bdc = &damp[afi][safi];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
if (!path->extra || !((bdi = path->extra->damp_info)))
|
2002-12-13 21:15:29 +01:00
|
|
|
return BGP_DAMP_USED;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2010-01-15 14:22:10 +01:00
|
|
|
t_now = bgp_clock();
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_path_info_unset_flag(dest, path, BGP_PATH_HISTORY);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi->lastrecord = BGP_RECORD_UPDATE;
|
2019-11-10 19:13:20 +01:00
|
|
|
bdi->penalty =
|
|
|
|
bgp_damp_decay(t_now - bdi->t_updated, bdi->penalty, bdc);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
if (!CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)
|
2019-11-10 19:13:20 +01:00
|
|
|
&& (bdi->penalty < bdc->suppress_value))
|
2002-12-13 21:15:29 +01:00
|
|
|
status = BGP_DAMP_USED;
|
2018-10-03 00:34:03 +02:00
|
|
|
else if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)
|
2019-11-10 19:13:20 +01:00
|
|
|
&& (bdi->penalty < bdc->reuse_limit)) {
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_path_info_unset_flag(dest, path, BGP_PATH_DAMPED);
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_reuse_list_delete(bdi, bdc);
|
|
|
|
BGP_DAMP_LIST_ADD(bdc, bdi);
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi->suppress_time = 0;
|
|
|
|
status = BGP_DAMP_USED;
|
|
|
|
} else
|
|
|
|
status = BGP_DAMP_SUPPRESSED;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
if (bdi->penalty > bdc->reuse_limit / 2.0)
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi->t_updated = t_now;
|
|
|
|
else
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_damp_info_free(bdi, 0, afi, safi);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
void bgp_damp_info_free(struct bgp_damp_info *bdi, int withdraw, afi_t afi,
|
|
|
|
safi_t safi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2018-10-03 00:34:03 +02:00
|
|
|
struct bgp_path_info *path;
|
2019-11-10 19:13:20 +01:00
|
|
|
struct bgp_damp_config *bdc = &damp[afi][safi];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (!bdi)
|
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
path = bdi->path;
|
|
|
|
path->extra->damp_info = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED))
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_reuse_list_delete(bdi, bdc);
|
2017-07-17 14:03:14 +02:00
|
|
|
else
|
2019-11-10 19:13:20 +01:00
|
|
|
BGP_DAMP_LIST_DEL(bdc, bdi);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_path_info_unset_flag(bdi->dest, path,
|
2018-10-03 00:15:34 +02:00
|
|
|
BGP_PATH_HISTORY | BGP_PATH_DAMPED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
[bgpd] Handle pcount as flags are changed, fixing pcount issues
2006-09-06 Paul Jakma <paul.jakma@sun.com>
* (general) Squash any and all prefix-count issues by
abstracting route flag changes, and maintaining count as and
when flags are modified (rather than relying on explicit
modifications of count being sprinkled in just the right
places throughout the code).
* bgp_route.c: (bgp_pcount_{dec,inc}rement) removed.
(bgp_pcount_adjust) new, update prefix count as
needed for a given route.
(bgp_info_{uns,s}et_flag) set/unset a BGP_INFO route status
flag, calling previous function when appropriate.
(general) Update all set/unsets of flags to use previous.
Remove pcount_{dec,inc}rement calls.
No need to unset BGP_INFO_VALID in places where
bgp_info_delete is called, it does that anyway.
* bgp_{damp,nexthop}.c: Update to use bgp_info_{un,}set_flag.
* bgp_route.h: Export bgp_info_{un,}set_flag.
Add a 'meta' BGP_INFO flag, BGP_INFO_UNUSEABLE.
Move BGP_INFO_HOLDDOWN macro to here from bgpd.h
2006-09-07 02:24:49 +02:00
|
|
|
if (bdi->lastrecord == BGP_RECORD_WITHDRAW && withdraw)
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_path_info_delete(bdi->dest, path);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
XFREE(MTYPE_BGP_DAMP_INFO, bdi);
|
|
|
|
}
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
static void bgp_damp_parameter_set(int hlife, int reuse, int sup, int maxsup,
|
|
|
|
struct bgp_damp_config *bdc)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
double reuse_max_ratio;
|
2004-10-13 07:06:08 +02:00
|
|
|
unsigned int i;
|
2002-12-13 21:15:29 +01:00
|
|
|
double j;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->suppress_value = sup;
|
|
|
|
bdc->half_life = hlife;
|
|
|
|
bdc->reuse_limit = reuse;
|
|
|
|
bdc->max_suppress_time = maxsup;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Initialize params per bgp_damp_config. */
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->reuse_index_size = REUSE_ARRAY_SIZE;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->ceiling = (int)(bdc->reuse_limit
|
|
|
|
* (pow(2, (double)bdc->max_suppress_time
|
|
|
|
/ bdc->half_life)));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Decay-array computations */
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->decay_array_size = ceil((double)bdc->max_suppress_time / DELTA_T);
|
|
|
|
bdc->decay_array = XMALLOC(MTYPE_BGP_DAMP_ARRAY,
|
|
|
|
sizeof(double) * (bdc->decay_array_size));
|
|
|
|
bdc->decay_array[0] = 1.0;
|
|
|
|
bdc->decay_array[1] =
|
|
|
|
exp((1.0 / ((double)bdc->half_life / DELTA_T)) * log(0.5));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Calculate decay values for all possible times */
|
2019-11-10 19:13:20 +01:00
|
|
|
for (i = 2; i < bdc->decay_array_size; i++)
|
|
|
|
bdc->decay_array[i] =
|
|
|
|
bdc->decay_array[i - 1] * bdc->decay_array[1];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Reuse-list computations */
|
2019-11-10 19:13:20 +01:00
|
|
|
i = ceil((double)bdc->max_suppress_time / DELTA_REUSE) + 1;
|
2002-12-13 21:15:29 +01:00
|
|
|
if (i > REUSE_LIST_SIZE || i == 0)
|
|
|
|
i = REUSE_LIST_SIZE;
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->reuse_list_size = i;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->reuse_list =
|
|
|
|
XCALLOC(MTYPE_BGP_DAMP_ARRAY,
|
|
|
|
bdc->reuse_list_size * sizeof(struct bgp_reuse_node *));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Reuse-array computations */
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->reuse_index = XCALLOC(MTYPE_BGP_DAMP_ARRAY,
|
|
|
|
sizeof(int) * bdc->reuse_index_size);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
reuse_max_ratio = (double)bdc->ceiling / bdc->reuse_limit;
|
|
|
|
j = (exp((double)bdc->max_suppress_time / bdc->half_life) * log10(2.0));
|
2002-12-13 21:15:29 +01:00
|
|
|
if (reuse_max_ratio > j && j != 0)
|
|
|
|
reuse_max_ratio = j;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->scale_factor =
|
|
|
|
(double)bdc->reuse_index_size / (reuse_max_ratio - 1);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
for (i = 0; i < bdc->reuse_index_size; i++) {
|
|
|
|
bdc->reuse_index[i] =
|
|
|
|
(int)(((double)bdc->half_life / DELTA_REUSE)
|
|
|
|
* log10(1.0
|
|
|
|
/ (bdc->reuse_limit
|
|
|
|
* (1.0
|
|
|
|
+ ((double)i / bdc->scale_factor))))
|
2002-12-13 21:15:29 +01:00
|
|
|
/ log10(0.5));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-13 07:06:08 +02:00
|
|
|
int bgp_damp_enable(struct bgp *bgp, afi_t afi, safi_t safi, time_t half,
|
|
|
|
unsigned int reuse, unsigned int suppress, time_t max)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2019-11-10 19:13:20 +01:00
|
|
|
struct bgp_damp_config *bdc = &damp[afi][safi];
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) {
|
2019-11-10 19:13:20 +01:00
|
|
|
if (bdc->half_life == half && bdc->reuse_limit == reuse
|
|
|
|
&& bdc->suppress_value == suppress
|
|
|
|
&& bdc->max_suppress_time == max)
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
bgp_damp_disable(bgp, afi, safi);
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING);
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_damp_parameter_set(half, reuse, suppress, max, bdc);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Register reuse timer. */
|
2019-11-10 19:13:20 +01:00
|
|
|
thread_add_timer(bm->master, bgp_reuse_timer, bdc, DELTA_REUSE,
|
|
|
|
&bdc->t_reuse);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
static void bgp_damp_config_clean(struct bgp_damp_config *bdc)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
/* Free decay array */
|
2019-11-10 19:13:20 +01:00
|
|
|
XFREE(MTYPE_BGP_DAMP_ARRAY, bdc->decay_array);
|
|
|
|
bdc->decay_array_size = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Free reuse index array */
|
2019-11-10 19:13:20 +01:00
|
|
|
XFREE(MTYPE_BGP_DAMP_ARRAY, bdc->reuse_index);
|
|
|
|
bdc->reuse_index_size = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Free reuse list array. */
|
2019-11-10 19:13:20 +01:00
|
|
|
XFREE(MTYPE_BGP_DAMP_ARRAY, bdc->reuse_list);
|
|
|
|
bdc->reuse_list_size = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean all the bgp_damp_info stored in reuse_list. */
|
2019-11-10 19:13:20 +01:00
|
|
|
void bgp_damp_info_clean(afi_t afi, safi_t safi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-13 07:06:08 +02:00
|
|
|
unsigned int i;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct bgp_damp_info *bdi, *next;
|
2019-11-10 19:13:20 +01:00
|
|
|
struct bgp_damp_config *bdc = &damp[afi][safi];
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->reuse_offset = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
for (i = 0; i < bdc->reuse_list_size; i++) {
|
|
|
|
if (!bdc->reuse_list[i])
|
2002-12-13 21:15:29 +01:00
|
|
|
continue;
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
for (bdi = bdc->reuse_list[i]; bdi; bdi = next) {
|
2002-12-13 21:15:29 +01:00
|
|
|
next = bdi->next;
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_damp_info_free(bdi, 1, afi, safi);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->reuse_list[i] = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
for (bdi = bdc->no_reuse_list; bdi; bdi = next) {
|
2002-12-13 21:15:29 +01:00
|
|
|
next = bdi->next;
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_damp_info_free(bdi, 1, afi, safi);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2019-11-10 19:13:20 +01:00
|
|
|
bdc->no_reuse_list = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int bgp_damp_disable(struct bgp *bgp, afi_t afi, safi_t safi)
|
|
|
|
{
|
2019-11-10 19:13:20 +01:00
|
|
|
struct bgp_damp_config *bdc = &damp[afi][safi];
|
2012-04-13 13:46:09 +02:00
|
|
|
/* If it wasn't enabled, there's nothing to do. */
|
|
|
|
if (!CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
|
|
|
|
return 0;
|
|
|
|
|
2020-07-06 18:55:03 +02:00
|
|
|
/* Cancel reuse event. */
|
|
|
|
thread_cancel(&(bdc->t_reuse));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Clean BGP dampening information. */
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_damp_info_clean(afi, safi);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Clear configuration */
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_damp_config_clean(bdc);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
UNSET_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
void bgp_config_write_damp(struct vty *vty, afi_t afi, safi_t safi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2019-11-10 19:13:20 +01:00
|
|
|
if (damp[afi][safi].half_life == DEFAULT_HALF_LIFE * 60
|
|
|
|
&& damp[afi][safi].reuse_limit == DEFAULT_REUSE
|
|
|
|
&& damp[afi][safi].suppress_value == DEFAULT_SUPPRESS
|
|
|
|
&& damp[afi][safi].max_suppress_time
|
|
|
|
== damp[afi][safi].half_life * 4)
|
|
|
|
vty_out(vty, " bgp dampening\n");
|
|
|
|
else if (damp[afi][safi].half_life != DEFAULT_HALF_LIFE * 60
|
|
|
|
&& damp[afi][safi].reuse_limit == DEFAULT_REUSE
|
|
|
|
&& damp[afi][safi].suppress_value == DEFAULT_SUPPRESS
|
|
|
|
&& damp[afi][safi].max_suppress_time
|
|
|
|
== damp[afi][safi].half_life * 4)
|
|
|
|
vty_out(vty, " bgp dampening %lld\n",
|
|
|
|
damp[afi][safi].half_life / 60LL);
|
2008-08-17 18:51:47 +02:00
|
|
|
else
|
2019-11-10 19:13:20 +01:00
|
|
|
vty_out(vty, " bgp dampening %lld %d %d %lld\n",
|
|
|
|
damp[afi][safi].half_life / 60LL,
|
|
|
|
damp[afi][safi].reuse_limit,
|
|
|
|
damp[afi][safi].suppress_value,
|
|
|
|
damp[afi][safi].max_suppress_time / 60LL);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2015-08-12 15:59:18 +02:00
|
|
|
static const char *bgp_get_reuse_time(unsigned int penalty, char *buf,
|
2019-11-10 19:13:20 +01:00
|
|
|
size_t len, afi_t afi, safi_t safi,
|
|
|
|
bool use_json, json_object *json)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
time_t reuse_time = 0;
|
2020-03-05 17:42:12 +01:00
|
|
|
struct tm tm;
|
2015-08-12 15:59:18 +02:00
|
|
|
int time_store = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
if (penalty > damp[afi][safi].reuse_limit) {
|
2002-12-13 21:15:29 +01:00
|
|
|
reuse_time = (int)(DELTA_T
|
2019-11-10 19:13:20 +01:00
|
|
|
* ((log((double)damp[afi][safi].reuse_limit
|
|
|
|
/ penalty))
|
|
|
|
/ (log(damp[afi][safi].decay_array[1]))));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
if (reuse_time > damp[afi][safi].max_suppress_time)
|
|
|
|
reuse_time = damp[afi][safi].max_suppress_time;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2020-03-05 17:42:12 +01:00
|
|
|
gmtime_r(&reuse_time, &tm);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else
|
|
|
|
reuse_time = 0;
|
|
|
|
|
2018-03-06 20:02:52 +01:00
|
|
|
/* Making formatted timer strings. */
|
2002-12-13 21:15:29 +01:00
|
|
|
if (reuse_time == 0) {
|
2015-08-12 15:59:18 +02:00
|
|
|
if (use_json)
|
|
|
|
json_object_int_add(json, "reuseTimerMsecs", 0);
|
|
|
|
else
|
|
|
|
snprintf(buf, len, "00:00:00");
|
2002-12-13 21:15:29 +01:00
|
|
|
} else if (reuse_time < ONE_DAY_SECOND) {
|
2015-08-12 15:59:18 +02:00
|
|
|
if (use_json) {
|
2020-03-05 17:42:12 +01:00
|
|
|
time_store = (3600000 * tm.tm_hour)
|
|
|
|
+ (60000 * tm.tm_min)
|
|
|
|
+ (1000 * tm.tm_sec);
|
2015-08-12 15:59:18 +02:00
|
|
|
json_object_int_add(json, "reuseTimerMsecs",
|
|
|
|
time_store);
|
|
|
|
} else
|
2020-03-05 17:42:12 +01:00
|
|
|
snprintf(buf, len, "%02d:%02d:%02d", tm.tm_hour,
|
|
|
|
tm.tm_min, tm.tm_sec);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else if (reuse_time < ONE_WEEK_SECOND) {
|
2015-08-12 15:59:18 +02:00
|
|
|
if (use_json) {
|
2020-03-05 17:42:12 +01:00
|
|
|
time_store = (86400000 * tm.tm_yday)
|
|
|
|
+ (3600000 * tm.tm_hour)
|
|
|
|
+ (60000 * tm.tm_min)
|
|
|
|
+ (1000 * tm.tm_sec);
|
2015-08-12 15:59:18 +02:00
|
|
|
json_object_int_add(json, "reuseTimerMsecs",
|
|
|
|
time_store);
|
|
|
|
} else
|
2020-03-05 17:42:12 +01:00
|
|
|
snprintf(buf, len, "%dd%02dh%02dm", tm.tm_yday,
|
|
|
|
tm.tm_hour, tm.tm_min);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else {
|
2015-08-12 15:59:18 +02:00
|
|
|
if (use_json) {
|
|
|
|
time_store =
|
2020-03-05 17:42:12 +01:00
|
|
|
(604800000 * tm.tm_yday / 7)
|
2015-08-12 15:59:18 +02:00
|
|
|
+ (86400000
|
2020-03-05 17:42:12 +01:00
|
|
|
* (tm.tm_yday - ((tm.tm_yday / 7) * 7)))
|
|
|
|
+ (3600000 * tm.tm_hour) + (60000 * tm.tm_min)
|
|
|
|
+ (1000 * tm.tm_sec);
|
2015-08-12 15:59:18 +02:00
|
|
|
json_object_int_add(json, "reuseTimerMsecs",
|
|
|
|
time_store);
|
|
|
|
} else
|
2020-03-05 17:42:12 +01:00
|
|
|
snprintf(buf, len, "%02dw%dd%02dh", tm.tm_yday / 7,
|
|
|
|
tm.tm_yday - ((tm.tm_yday / 7) * 7),
|
|
|
|
tm.tm_hour);
|
2015-08-12 15:59:18 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return buf;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path, afi_t afi,
|
|
|
|
safi_t safi, json_object *json_path)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct bgp_damp_info *bdi;
|
|
|
|
time_t t_now, t_diff;
|
|
|
|
char timebuf[BGP_UPTIME_LEN];
|
|
|
|
int penalty;
|
2019-11-10 19:13:20 +01:00
|
|
|
struct bgp_damp_config *bdc = &damp[afi][safi];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
if (!path->extra)
|
2007-05-04 22:15:47 +02:00
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* BGP dampening information. */
|
2018-10-03 00:34:03 +02:00
|
|
|
bdi = path->extra->damp_info;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* If dampening is not enabled or there is no dampening information,
|
|
|
|
return immediately. */
|
2019-11-10 19:13:20 +01:00
|
|
|
if (!bdc || !bdi)
|
2002-12-13 21:15:29 +01:00
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Calculate new penalty. */
|
2010-01-15 14:22:10 +01:00
|
|
|
t_now = bgp_clock();
|
2002-12-13 21:15:29 +01:00
|
|
|
t_diff = t_now - bdi->t_updated;
|
2019-11-10 19:13:20 +01:00
|
|
|
penalty = bgp_damp_decay(t_diff, bdi->penalty, bdc);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-05-20 03:03:48 +02:00
|
|
|
if (json_path) {
|
2015-07-22 21:35:35 +02:00
|
|
|
json_object_int_add(json_path, "dampeningPenalty", penalty);
|
|
|
|
json_object_int_add(json_path, "dampeningFlapCount", bdi->flap);
|
2015-08-12 15:59:18 +02:00
|
|
|
peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, 1,
|
|
|
|
json_path);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED)
|
|
|
|
&& !CHECK_FLAG(path->flags, BGP_PATH_HISTORY))
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_get_reuse_time(penalty, timebuf, BGP_UPTIME_LEN,
|
|
|
|
afi, safi, 1, json_path);
|
2015-05-20 03:03:48 +02:00
|
|
|
} else {
|
|
|
|
vty_out(vty,
|
|
|
|
" Dampinfo: penalty %d, flapped %d times in %s",
|
|
|
|
penalty, bdi->flap,
|
2015-08-12 15:59:18 +02:00
|
|
|
peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, 0,
|
|
|
|
json_path));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
if (CHECK_FLAG(path->flags, BGP_PATH_DAMPED)
|
|
|
|
&& !CHECK_FLAG(path->flags, BGP_PATH_HISTORY))
|
2015-05-20 03:03:48 +02:00
|
|
|
vty_out(vty, ", reuse in %s",
|
2015-08-12 15:59:18 +02:00
|
|
|
bgp_get_reuse_time(penalty, timebuf,
|
2019-11-10 19:13:20 +01:00
|
|
|
BGP_UPTIME_LEN, afi, safi, 0,
|
2015-08-12 15:59:18 +02:00
|
|
|
json_path));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-07-13 19:04:25 +02:00
|
|
|
vty_out(vty, "\n");
|
2015-05-20 03:03:48 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
const char *bgp_damp_reuse_time_vty(struct vty *vty, struct bgp_path_info *path,
|
2019-11-10 19:13:20 +01:00
|
|
|
char *timebuf, size_t len, afi_t afi,
|
|
|
|
safi_t safi, bool use_json,
|
2015-08-12 15:59:18 +02:00
|
|
|
json_object *json)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct bgp_damp_info *bdi;
|
|
|
|
time_t t_now, t_diff;
|
|
|
|
int penalty;
|
2019-11-10 19:13:20 +01:00
|
|
|
struct bgp_damp_config *bdc = &damp[afi][safi];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
if (!path->extra)
|
2007-05-04 22:15:47 +02:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* BGP dampening information. */
|
2018-10-03 00:34:03 +02:00
|
|
|
bdi = path->extra->damp_info;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* If dampening is not enabled or there is no dampening information,
|
|
|
|
return immediately. */
|
2019-11-10 19:13:20 +01:00
|
|
|
if (!bdc || !bdi)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Calculate new penalty. */
|
2010-01-15 14:22:10 +01:00
|
|
|
t_now = bgp_clock();
|
2002-12-13 21:15:29 +01:00
|
|
|
t_diff = t_now - bdi->t_updated;
|
2019-11-10 19:13:20 +01:00
|
|
|
penalty = bgp_damp_decay(t_diff, bdi->penalty, bdc);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
return bgp_get_reuse_time(penalty, timebuf, len, afi, safi, use_json,
|
|
|
|
json);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2015-03-16 17:55:29 +01:00
|
|
|
|
bgpd: show < ip > bgp < ipv4 | ipv6 > all
This commit
=> provides "all" option, to display the table entries for all(or specific) AFI/SAFIs.
=> Also introduced "show_flags" to avoid passing multiple arguments(use_json, wide, all)
to functions
1. show <ip> bgp <ipv4/ipv6> <all> <wide|json>
2. show <ip> bgp <ipv4/ipv6> <all> summary <json>
3. show <ip> bgp <ipv4/ipv6> <all> cidr-only <wide|json>
4. show <ip> bgp <ipv4/ipv6> <all> community <wide|json>
5. show <ip> bgp <ipv4/ipv6> <all> dampening <dampened-paths|flap-statistics|parameters> <wide|json>
6. show <ip> bgp <ipv4/ipv6> <all> neighbors A.B.C.D advertised-routes|filtered-routes|received-routes <wide|json>
show bgp all summary == show ip bgp all summary => output is same => display entries for all AFIs and for each SAFI.
show bgp ipv4 all summary == show ip bgp ipv4 all summary => output is same => display entries for each SAFI in AFI_IP
show bgp ipv6 all summary == show ip bgp ipv6 all summart => output is same => display entries for each SAFI in AFI_IP6
similarly for all other commands.
sample output
1. show <ip> bgp <ipv4/ipv6> <all> <wide|json>
router# show ip bgp all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router# show ip bgp ipv4 all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
router#
router#
router# show ip bgp ipv6 all wide
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router# show bgp all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router#
router# show bgp ipv4 all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
router#
router# show bgp ipv6 all wide
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
Router1# show bgp all dampening parameters
For address family: IPv4 Unicast
Half-life time: 15 min
Reuse penalty: 750
Suppress penalty: 2000
Max suppress time: 60 min
Max suppress penalty: 12000
For address family: IPv4 Multicast
Half-life time: 20 min
Reuse penalty: 1000
Suppress penalty: 10000
Max suppress time: 40 min
Max suppress penalty: 4000
For address family: IPv4 VPN
dampening not enabled for IPv4 VPN
For address family: IPv4 Encap
dampening not enabled for IPv4 Encap
For address family: IPv4 Labeled Unicast
dampening not enabled for IPv4 Labeled Unicast
For address family: IPv4 Flowspec
dampening not enabled for IPv4 Flowspec
For address family: IPv6 Unicast
dampening not enabled for IPv6 Unicast
For address family: IPv6 Multicast
Half-life time: 10 min
Reuse penalty: 1500
Suppress penalty: 15000
Max suppress time: 20 min
Max suppress penalty: 6000
For address family: IPv6 VPN
dampening not enabled for IPv6 VPN
For address family: IPv6 Encap
dampening not enabled for IPv6 Encap
For address family: IPv6 Labeled Unicast
dampening not enabled for IPv6 Labeled Unicast
For address family: IPv6 Flowspec
dampening not enabled for IPv6 Flowspec
For address family: L2VPN EVPN
dampening not enabled for L2VPN EVPN
router#
bgpd: all option with json-c apis used
Replaced vty_out with json-c wrapper functions for all option
support to show <ip> bgp commands
Sample output:
Router2# show bgp all json
{
"ipv4Unicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 8,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { "128.16.16.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"128.16.16.0",
"prefixLen":24,
"network":"128.16.16.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"130.130.0.0/16": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"130.130.0.0",
"prefixLen":16,
"network":"130.130.0.0\/16",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"192.168.50.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"192.168.50.0",
"prefixLen":24,
"network":"192.168.50.0\/24",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"IGP",
"nexthops":[
{
"ip":"10.10.20.3",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"200.200.200.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"200.200.200.0",
"prefixLen":24,
"network":"200.200.200.0\/24",
"metric":0,
"weight":0,
"peerId":"10.10.10.1",
"path":"1",
"origin":"IGP",
"nexthops":[
{
"ip":"10.10.10.1",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
] } }
,
"ipv4Multicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
,
"ipv4Flowspec":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
,
"ipv6Unicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 11,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { "2001:db8::2/128": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8::2",
"prefixLen":128,
"network":"2001:db8::2\/128",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"::",
"hostname":"router",
"afi":"ipv6",
"scope":"global",
"used":true
}
]
}
],"2001:db8::3/128": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8::3",
"prefixLen":128,
"network":"2001:db8::3\/128",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"incomplete",
"nexthops":[
{
"ip":"2001:db8:0:20::3",
"hostname":"router",
"afi":"ipv6",
"scope":"global"
},
{
"ip":"fe80::a00:27ff:fe76:6738",
"hostname":"router",
"afi":"ipv6",
"scope":"link-local",
"used":true
}
]
}
],"2001:db8:0:20::/64": [
{
"valid":true,
"pathFrom":"external",
"prefix":"2001:db8:0:20::",
"prefixLen":64,
"network":"2001:db8:0:20::\/64",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"incomplete",
"nexthops":[
{
"ip":"2001:db8:0:20::3",
"hostname":"router",
"afi":"ipv6",
"scope":"global"
},
{
"ip":"fe80::a00:27ff:fe76:6738",
"hostname":"router",
"afi":"ipv6",
"scope":"link-local",
"used":true
}
]
},
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8:0:20::",
"prefixLen":64,
"network":"2001:db8:0:20::\/64",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"::",
"hostname":"router",
"afi":"ipv6",
"scope":"global",
"used":true
}
]
}
] } }
,
"ipv6Multicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
}
Router2#
Signed-off-by: Madhuri Kuruganti <k.madhuri@samsung.com>
2020-07-30 17:19:09 +02:00
|
|
|
static int bgp_print_dampening_parameters(struct bgp *bgp, struct vty *vty,
|
|
|
|
afi_t afi, safi_t safi)
|
2015-03-16 17:55:29 +01:00
|
|
|
{
|
|
|
|
if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) {
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "Half-life time: %lld min\n",
|
2019-11-10 19:13:20 +01:00
|
|
|
(long long)damp[afi][safi].half_life / 60);
|
|
|
|
vty_out(vty, "Reuse penalty: %d\n",
|
|
|
|
damp[afi][safi].reuse_limit);
|
|
|
|
vty_out(vty, "Suppress penalty: %d\n",
|
|
|
|
damp[afi][safi].suppress_value);
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "Max suppress time: %lld min\n",
|
2019-11-10 19:13:20 +01:00
|
|
|
(long long)damp[afi][safi].max_suppress_time / 60);
|
|
|
|
vty_out(vty, "Max suppress penalty: %u\n",
|
|
|
|
damp[afi][safi].ceiling);
|
2017-07-13 19:04:25 +02:00
|
|
|
vty_out(vty, "\n");
|
2015-03-16 17:55:29 +01:00
|
|
|
} else
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "dampening not enabled for %s\n",
|
bgpd: show < ip > bgp < ipv4 | ipv6 > all
This commit
=> provides "all" option, to display the table entries for all(or specific) AFI/SAFIs.
=> Also introduced "show_flags" to avoid passing multiple arguments(use_json, wide, all)
to functions
1. show <ip> bgp <ipv4/ipv6> <all> <wide|json>
2. show <ip> bgp <ipv4/ipv6> <all> summary <json>
3. show <ip> bgp <ipv4/ipv6> <all> cidr-only <wide|json>
4. show <ip> bgp <ipv4/ipv6> <all> community <wide|json>
5. show <ip> bgp <ipv4/ipv6> <all> dampening <dampened-paths|flap-statistics|parameters> <wide|json>
6. show <ip> bgp <ipv4/ipv6> <all> neighbors A.B.C.D advertised-routes|filtered-routes|received-routes <wide|json>
show bgp all summary == show ip bgp all summary => output is same => display entries for all AFIs and for each SAFI.
show bgp ipv4 all summary == show ip bgp ipv4 all summary => output is same => display entries for each SAFI in AFI_IP
show bgp ipv6 all summary == show ip bgp ipv6 all summart => output is same => display entries for each SAFI in AFI_IP6
similarly for all other commands.
sample output
1. show <ip> bgp <ipv4/ipv6> <all> <wide|json>
router# show ip bgp all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router# show ip bgp ipv4 all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
router#
router#
router# show ip bgp ipv6 all wide
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router# show bgp all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router#
router# show bgp ipv4 all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
router#
router# show bgp ipv6 all wide
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
Router1# show bgp all dampening parameters
For address family: IPv4 Unicast
Half-life time: 15 min
Reuse penalty: 750
Suppress penalty: 2000
Max suppress time: 60 min
Max suppress penalty: 12000
For address family: IPv4 Multicast
Half-life time: 20 min
Reuse penalty: 1000
Suppress penalty: 10000
Max suppress time: 40 min
Max suppress penalty: 4000
For address family: IPv4 VPN
dampening not enabled for IPv4 VPN
For address family: IPv4 Encap
dampening not enabled for IPv4 Encap
For address family: IPv4 Labeled Unicast
dampening not enabled for IPv4 Labeled Unicast
For address family: IPv4 Flowspec
dampening not enabled for IPv4 Flowspec
For address family: IPv6 Unicast
dampening not enabled for IPv6 Unicast
For address family: IPv6 Multicast
Half-life time: 10 min
Reuse penalty: 1500
Suppress penalty: 15000
Max suppress time: 20 min
Max suppress penalty: 6000
For address family: IPv6 VPN
dampening not enabled for IPv6 VPN
For address family: IPv6 Encap
dampening not enabled for IPv6 Encap
For address family: IPv6 Labeled Unicast
dampening not enabled for IPv6 Labeled Unicast
For address family: IPv6 Flowspec
dampening not enabled for IPv6 Flowspec
For address family: L2VPN EVPN
dampening not enabled for L2VPN EVPN
router#
bgpd: all option with json-c apis used
Replaced vty_out with json-c wrapper functions for all option
support to show <ip> bgp commands
Sample output:
Router2# show bgp all json
{
"ipv4Unicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 8,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { "128.16.16.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"128.16.16.0",
"prefixLen":24,
"network":"128.16.16.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"130.130.0.0/16": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"130.130.0.0",
"prefixLen":16,
"network":"130.130.0.0\/16",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"192.168.50.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"192.168.50.0",
"prefixLen":24,
"network":"192.168.50.0\/24",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"IGP",
"nexthops":[
{
"ip":"10.10.20.3",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"200.200.200.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"200.200.200.0",
"prefixLen":24,
"network":"200.200.200.0\/24",
"metric":0,
"weight":0,
"peerId":"10.10.10.1",
"path":"1",
"origin":"IGP",
"nexthops":[
{
"ip":"10.10.10.1",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
] } }
,
"ipv4Multicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
,
"ipv4Flowspec":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
,
"ipv6Unicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 11,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { "2001:db8::2/128": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8::2",
"prefixLen":128,
"network":"2001:db8::2\/128",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"::",
"hostname":"router",
"afi":"ipv6",
"scope":"global",
"used":true
}
]
}
],"2001:db8::3/128": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8::3",
"prefixLen":128,
"network":"2001:db8::3\/128",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"incomplete",
"nexthops":[
{
"ip":"2001:db8:0:20::3",
"hostname":"router",
"afi":"ipv6",
"scope":"global"
},
{
"ip":"fe80::a00:27ff:fe76:6738",
"hostname":"router",
"afi":"ipv6",
"scope":"link-local",
"used":true
}
]
}
],"2001:db8:0:20::/64": [
{
"valid":true,
"pathFrom":"external",
"prefix":"2001:db8:0:20::",
"prefixLen":64,
"network":"2001:db8:0:20::\/64",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"incomplete",
"nexthops":[
{
"ip":"2001:db8:0:20::3",
"hostname":"router",
"afi":"ipv6",
"scope":"global"
},
{
"ip":"fe80::a00:27ff:fe76:6738",
"hostname":"router",
"afi":"ipv6",
"scope":"link-local",
"used":true
}
]
},
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8:0:20::",
"prefixLen":64,
"network":"2001:db8:0:20::\/64",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"::",
"hostname":"router",
"afi":"ipv6",
"scope":"global",
"used":true
}
]
}
] } }
,
"ipv6Multicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
}
Router2#
Signed-off-by: Madhuri Kuruganti <k.madhuri@samsung.com>
2020-07-30 17:19:09 +02:00
|
|
|
get_afi_safi_str(afi, safi, false));
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bgp_show_dampening_parameters(struct vty *vty, afi_t afi, safi_t safi,
|
|
|
|
uint8_t show_flags)
|
|
|
|
{
|
|
|
|
struct bgp *bgp;
|
|
|
|
bgp = bgp_get_default();
|
|
|
|
|
|
|
|
if (bgp == NULL) {
|
|
|
|
vty_out(vty, "No BGP process is configured\n");
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_ALL))
|
|
|
|
return bgp_print_dampening_parameters(bgp, vty, afi, safi);
|
|
|
|
|
|
|
|
if (CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_IP)
|
|
|
|
|| CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_IP6)) {
|
|
|
|
afi = CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_IP) ? AFI_IP
|
|
|
|
: AFI_IP6;
|
|
|
|
FOREACH_SAFI (safi) {
|
|
|
|
if (strmatch(get_afi_safi_str(afi, safi, true),
|
|
|
|
"Unknown"))
|
|
|
|
continue;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
bgpd: show < ip > bgp < ipv4 | ipv6 > all
This commit
=> provides "all" option, to display the table entries for all(or specific) AFI/SAFIs.
=> Also introduced "show_flags" to avoid passing multiple arguments(use_json, wide, all)
to functions
1. show <ip> bgp <ipv4/ipv6> <all> <wide|json>
2. show <ip> bgp <ipv4/ipv6> <all> summary <json>
3. show <ip> bgp <ipv4/ipv6> <all> cidr-only <wide|json>
4. show <ip> bgp <ipv4/ipv6> <all> community <wide|json>
5. show <ip> bgp <ipv4/ipv6> <all> dampening <dampened-paths|flap-statistics|parameters> <wide|json>
6. show <ip> bgp <ipv4/ipv6> <all> neighbors A.B.C.D advertised-routes|filtered-routes|received-routes <wide|json>
show bgp all summary == show ip bgp all summary => output is same => display entries for all AFIs and for each SAFI.
show bgp ipv4 all summary == show ip bgp ipv4 all summary => output is same => display entries for each SAFI in AFI_IP
show bgp ipv6 all summary == show ip bgp ipv6 all summart => output is same => display entries for each SAFI in AFI_IP6
similarly for all other commands.
sample output
1. show <ip> bgp <ipv4/ipv6> <all> <wide|json>
router# show ip bgp all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router# show ip bgp ipv4 all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
router#
router#
router# show ip bgp ipv6 all wide
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router# show bgp all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
router#
router# show bgp ipv4 all wide
For address family: IPv4 Unicast
BGP table version is 6, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 ?
*>i2.2.2.2/32 192.168.56.152 0 100 0 ?
* i10.0.2.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
* i192.168.56.0/24 192.168.56.152 0 100 0 ?
*> 0.0.0.0 0 32768 ?
*>i192.168.123.245/32 192.168.56.152 0 100 0 ?
*>i192.168.223.245/32 192.168.56.152 0 100 0 ?
Displayed 6 routes and 8 total paths
router#
router# show bgp ipv6 all wide
For address family: IPv6 Unicast
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 1
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 2001:db8::1/128 :: 0 32768 ?
*>i2001:db8::2/128 fe80::a00:27ff:fefc:2aa 0 100 0 ?
*> 2001:db8:85a3::8a2e:370:7334/128 :: 0 32768 ?
Displayed 3 routes and 3 total paths
router#
Router1# show bgp all dampening parameters
For address family: IPv4 Unicast
Half-life time: 15 min
Reuse penalty: 750
Suppress penalty: 2000
Max suppress time: 60 min
Max suppress penalty: 12000
For address family: IPv4 Multicast
Half-life time: 20 min
Reuse penalty: 1000
Suppress penalty: 10000
Max suppress time: 40 min
Max suppress penalty: 4000
For address family: IPv4 VPN
dampening not enabled for IPv4 VPN
For address family: IPv4 Encap
dampening not enabled for IPv4 Encap
For address family: IPv4 Labeled Unicast
dampening not enabled for IPv4 Labeled Unicast
For address family: IPv4 Flowspec
dampening not enabled for IPv4 Flowspec
For address family: IPv6 Unicast
dampening not enabled for IPv6 Unicast
For address family: IPv6 Multicast
Half-life time: 10 min
Reuse penalty: 1500
Suppress penalty: 15000
Max suppress time: 20 min
Max suppress penalty: 6000
For address family: IPv6 VPN
dampening not enabled for IPv6 VPN
For address family: IPv6 Encap
dampening not enabled for IPv6 Encap
For address family: IPv6 Labeled Unicast
dampening not enabled for IPv6 Labeled Unicast
For address family: IPv6 Flowspec
dampening not enabled for IPv6 Flowspec
For address family: L2VPN EVPN
dampening not enabled for L2VPN EVPN
router#
bgpd: all option with json-c apis used
Replaced vty_out with json-c wrapper functions for all option
support to show <ip> bgp commands
Sample output:
Router2# show bgp all json
{
"ipv4Unicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 8,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { "128.16.16.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"128.16.16.0",
"prefixLen":24,
"network":"128.16.16.0\/24",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"130.130.0.0/16": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"130.130.0.0",
"prefixLen":16,
"network":"130.130.0.0\/16",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"IGP",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"192.168.50.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"192.168.50.0",
"prefixLen":24,
"network":"192.168.50.0\/24",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"IGP",
"nexthops":[
{
"ip":"10.10.20.3",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
],"200.200.200.0/24": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"200.200.200.0",
"prefixLen":24,
"network":"200.200.200.0\/24",
"metric":0,
"weight":0,
"peerId":"10.10.10.1",
"path":"1",
"origin":"IGP",
"nexthops":[
{
"ip":"10.10.10.1",
"hostname":"router",
"afi":"ipv4",
"used":true
}
]
}
] } }
,
"ipv4Multicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
,
"ipv4Flowspec":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
,
"ipv6Unicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 11,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { "2001:db8::2/128": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8::2",
"prefixLen":128,
"network":"2001:db8::2\/128",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"::",
"hostname":"router",
"afi":"ipv6",
"scope":"global",
"used":true
}
]
}
],"2001:db8::3/128": [
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8::3",
"prefixLen":128,
"network":"2001:db8::3\/128",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"incomplete",
"nexthops":[
{
"ip":"2001:db8:0:20::3",
"hostname":"router",
"afi":"ipv6",
"scope":"global"
},
{
"ip":"fe80::a00:27ff:fe76:6738",
"hostname":"router",
"afi":"ipv6",
"scope":"link-local",
"used":true
}
]
}
],"2001:db8:0:20::/64": [
{
"valid":true,
"pathFrom":"external",
"prefix":"2001:db8:0:20::",
"prefixLen":64,
"network":"2001:db8:0:20::\/64",
"metric":0,
"weight":0,
"peerId":"10.10.20.3",
"path":"3",
"origin":"incomplete",
"nexthops":[
{
"ip":"2001:db8:0:20::3",
"hostname":"router",
"afi":"ipv6",
"scope":"global"
},
{
"ip":"fe80::a00:27ff:fe76:6738",
"hostname":"router",
"afi":"ipv6",
"scope":"link-local",
"used":true
}
]
},
{
"valid":true,
"bestpath":true,
"pathFrom":"external",
"prefix":"2001:db8:0:20::",
"prefixLen":64,
"network":"2001:db8:0:20::\/64",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"::",
"hostname":"router",
"afi":"ipv6",
"scope":"global",
"used":true
}
]
}
] } }
,
"ipv6Multicast":{
"vrfId": 0,
"vrfName": "default",
"tableVersion": 0,
"routerId": "128.16.16.1",
"defaultLocPrf": 100,
"localAS": 2,
"routes": { } }
}
Router2#
Signed-off-by: Madhuri Kuruganti <k.madhuri@samsung.com>
2020-07-30 17:19:09 +02:00
|
|
|
if (!CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON))
|
|
|
|
vty_out(vty, "\nFor address family: %s\n\n",
|
|
|
|
get_afi_safi_str(afi, safi, false));
|
|
|
|
|
|
|
|
bgp_print_dampening_parameters(bgp, vty, afi, safi);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
FOREACH_AFI_SAFI (afi, safi) {
|
|
|
|
if (strmatch(get_afi_safi_str(afi, safi, true),
|
|
|
|
"Unknown"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON))
|
|
|
|
vty_out(vty, "\nFor address family: %s\n",
|
|
|
|
get_afi_safi_str(afi, safi, false));
|
|
|
|
|
|
|
|
bgp_print_dampening_parameters(bgp, vty, afi, safi);
|
|
|
|
}
|
|
|
|
}
|
2015-03-16 17:55:29 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|