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
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
static void bgp_reuselist_add(struct reuselist *list,
|
|
|
|
struct bgp_damp_info *info)
|
|
|
|
{
|
2021-08-02 12:01:18 +02:00
|
|
|
struct reuselist_node *new_node;
|
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
assert(info);
|
2021-08-02 12:01:18 +02:00
|
|
|
new_node = XCALLOC(MTYPE_BGP_DAMP_REUSELIST, sizeof(*new_node));
|
|
|
|
new_node->info = info;
|
|
|
|
SLIST_INSERT_HEAD(list, new_node, entry);
|
2020-11-02 16:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bgp_reuselist_del(struct reuselist *list,
|
2021-08-02 12:01:18 +02:00
|
|
|
struct reuselist_node **node)
|
2020-11-02 16:30:01 +01:00
|
|
|
{
|
2021-08-02 12:01:18 +02:00
|
|
|
if ((*node) == NULL)
|
|
|
|
return;
|
|
|
|
assert(list && node && *node);
|
|
|
|
SLIST_REMOVE(list, (*node), reuselist_node, entry);
|
|
|
|
XFREE(MTYPE_BGP_DAMP_REUSELIST, (*node));
|
|
|
|
*node = NULL;
|
2020-11-02 16:30:01 +01:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
static void bgp_reuselist_switch(struct reuselist *source,
|
2021-08-02 12:01:18 +02:00
|
|
|
struct reuselist_node *node,
|
2020-11-02 16:30:01 +01:00
|
|
|
struct reuselist *target)
|
|
|
|
{
|
2021-08-02 12:01:18 +02:00
|
|
|
assert(source && target && node);
|
|
|
|
SLIST_REMOVE(source, node, reuselist_node, entry);
|
|
|
|
SLIST_INSERT_HEAD(target, node, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bgp_reuselist_free(struct reuselist *list)
|
|
|
|
{
|
|
|
|
struct reuselist_node *rn;
|
|
|
|
|
|
|
|
assert(list);
|
|
|
|
while ((rn = SLIST_FIRST(list)) != NULL)
|
|
|
|
bgp_reuselist_del(list, &rn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct reuselist_node *bgp_reuselist_find(struct reuselist *list,
|
|
|
|
struct bgp_damp_info *info)
|
|
|
|
{
|
|
|
|
struct reuselist_node *rn;
|
|
|
|
|
|
|
|
assert(list && info);
|
|
|
|
SLIST_FOREACH (rn, list, entry) {
|
|
|
|
if (rn->info == info)
|
|
|
|
return rn;
|
|
|
|
}
|
|
|
|
return NULL;
|
2020-11-02 16:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bgp_damp_info_unclaim(struct bgp_damp_info *bdi)
|
|
|
|
{
|
2021-08-02 12:01:18 +02:00
|
|
|
struct reuselist_node *node;
|
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
assert(bdi && bdi->config);
|
2021-08-02 12:01:18 +02:00
|
|
|
if (bdi->index == BGP_DAMP_NO_REUSE_LIST_INDEX) {
|
|
|
|
node = bgp_reuselist_find(&bdi->config->no_reuse_list, bdi);
|
|
|
|
if (node)
|
|
|
|
bgp_reuselist_del(&bdi->config->no_reuse_list, &node);
|
|
|
|
} else {
|
|
|
|
node = bgp_reuselist_find(&bdi->config->reuse_list[bdi->index],
|
|
|
|
bdi);
|
|
|
|
if (node)
|
|
|
|
bgp_reuselist_del(&bdi->config->reuse_list[bdi->index],
|
|
|
|
&node);
|
|
|
|
}
|
2020-11-02 16:30:01 +01:00
|
|
|
bdi->config = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bgp_damp_info_claim(struct bgp_damp_info *bdi,
|
|
|
|
struct bgp_damp_config *bdc)
|
|
|
|
{
|
|
|
|
assert(bdc && bdi);
|
|
|
|
if (bdi->config == NULL) {
|
|
|
|
bdi->config = bdc;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bgp_damp_info_unclaim(bdi);
|
|
|
|
bdi->config = bdc;
|
|
|
|
bdi->afi = bdc->afi;
|
|
|
|
bdi->safi = bdc->safi;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct bgp_damp_config *get_active_bdc_from_pi(struct bgp_path_info *pi,
|
|
|
|
afi_t afi, safi_t safi)
|
|
|
|
{
|
|
|
|
if (!pi)
|
|
|
|
return NULL;
|
|
|
|
if (CHECK_FLAG(pi->peer->af_flags[afi][safi],
|
|
|
|
PEER_FLAG_CONFIG_DAMPENING))
|
|
|
|
return &pi->peer->damp[afi][safi];
|
|
|
|
if (peer_group_active(pi->peer))
|
|
|
|
if (CHECK_FLAG(pi->peer->group->conf->af_flags[afi][safi],
|
|
|
|
PEER_FLAG_CONFIG_DAMPENING))
|
|
|
|
return &pi->peer->group->conf->damp[afi][safi];
|
|
|
|
if (CHECK_FLAG(pi->peer->bgp->af_flags[afi][safi],
|
|
|
|
BGP_CONFIG_DAMPENING))
|
|
|
|
return &pi->peer->bgp->damp[afi][safi];
|
|
|
|
return NULL;
|
|
|
|
}
|
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;
|
2020-11-02 16:30:01 +01:00
|
|
|
unsigned int index;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
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
|
|
|
{
|
2020-11-02 16:30:01 +01:00
|
|
|
bgp_damp_info_claim(bdi, bdc);
|
|
|
|
bdi->index = bgp_reuse_index(bdi->penalty, bdc);
|
|
|
|
bgp_reuselist_add(&bdc->reuse_list[bdi->index], bdi);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete BGP dampening information from reuse list. */
|
2021-07-28 23:14:31 +02:00
|
|
|
static void bgp_reuse_list_delete(struct bgp_damp_info *bdi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2020-11-02 16:30:01 +01:00
|
|
|
bgp_damp_info_unclaim(bdi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bgp_no_reuse_list_add(struct bgp_damp_info *bdi,
|
|
|
|
struct bgp_damp_config *bdc)
|
|
|
|
{
|
|
|
|
bgp_damp_info_claim(bdi, bdc);
|
|
|
|
bdi->index = BGP_DAMP_NO_REUSE_LIST_INDEX;
|
|
|
|
bgp_reuselist_add(&bdc->no_reuse_list, bdi);
|
|
|
|
}
|
|
|
|
|
2021-08-02 12:01:18 +02:00
|
|
|
static void bgp_no_reuse_list_delete(struct bgp_damp_info *bdi,
|
|
|
|
struct bgp_damp_config *bdc)
|
2020-11-02 16:30:01 +01:00
|
|
|
{
|
2021-08-02 12:01:18 +02:00
|
|
|
struct reuselist_node *rn;
|
|
|
|
|
|
|
|
assert(bdc && bdi);
|
|
|
|
if (bdi->config == NULL) {
|
|
|
|
bgp_damp_info_unclaim(bdi);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bdi->config = NULL;
|
|
|
|
rn = bgp_reuselist_find(&bdc->no_reuse_list, bdi);
|
|
|
|
bgp_reuselist_del(&bdc->no_reuse_list, &rn);
|
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)
|
|
|
|
{
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_config *bdc = THREAD_ARG(t);
|
2002-12-13 21:15:29 +01:00
|
|
|
struct bgp_damp_info *bdi;
|
2020-11-02 16:30:01 +01:00
|
|
|
struct reuselist plist;
|
2021-08-02 12:01:18 +02:00
|
|
|
struct reuselist_node *node;
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp *bgp;
|
2002-12-13 21:15:29 +01:00
|
|
|
time_t t_now, t_diff;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
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
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
/* 1. save a pointer to the current queue head and zero the list head
|
|
|
|
* list head entry. */
|
|
|
|
assert(bdc->reuse_offset < bdc->reuse_list_size);
|
|
|
|
plist = bdc->reuse_list[bdc->reuse_offset];
|
2021-07-30 15:48:36 +02:00
|
|
|
SLIST_INIT(&bdc->reuse_list[bdc->reuse_offset]);
|
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;
|
2020-11-02 16:30:01 +01:00
|
|
|
assert(bdc->reuse_offset < 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 ) */
|
2021-08-02 12:01:18 +02:00
|
|
|
while ((node = SLIST_FIRST(&plist)) != NULL) {
|
|
|
|
bdi = node->info;
|
2020-11-02 16:30:01 +01:00
|
|
|
bgp = bdi->path->peer->bgp;
|
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
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
if (bdi->penalty <= bdc->reuse_limit / 2.0) {
|
2021-08-02 12:01:06 +02:00
|
|
|
bgp_damp_info_free(bdi, bdc, 1, bdi->afi,
|
|
|
|
bdi->safi);
|
2021-08-02 12:01:18 +02:00
|
|
|
bgp_reuselist_del(&plist, &node);
|
2020-11-02 16:30:01 +01:00
|
|
|
} else {
|
2021-08-02 12:01:18 +02:00
|
|
|
node->info->index =
|
|
|
|
BGP_DAMP_NO_REUSE_LIST_INDEX;
|
|
|
|
bgp_reuselist_switch(&plist, node,
|
2020-11-02 16:30:01 +01:00
|
|
|
&bdc->no_reuse_list);
|
|
|
|
}
|
|
|
|
} else {
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Re-insert into another list (See RFC2439 Section
|
|
|
|
* 4.8.6). */
|
2020-11-02 16:30:01 +01:00
|
|
|
bdi->index = bgp_reuse_index(bdi->penalty, bdc);
|
2021-08-02 12:01:18 +02:00
|
|
|
bgp_reuselist_switch(&plist, node,
|
2020-11-02 16:30:01 +01:00
|
|
|
&bdc->reuse_list[bdi->index]);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2021-07-30 15:48:36 +02:00
|
|
|
assert(SLIST_EMPTY(&plist));
|
2020-11-02 16:30:01 +01:00
|
|
|
|
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;
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_config *bdc;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
bdc = get_active_bdc_from_pi(path, afi, safi);
|
|
|
|
if (!bdc)
|
|
|
|
return BGP_DAMP_USED;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
t_now = bgp_clock();
|
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;
|
2020-11-02 16:30:01 +01:00
|
|
|
bdi->index = BGP_DAMP_NO_REUSE_LIST_INDEX;
|
2002-12-13 21:15:29 +01:00
|
|
|
bdi->afi = afi;
|
|
|
|
bdi->safi = safi;
|
2018-10-03 00:34:03 +02:00
|
|
|
(bgp_path_info_extra_get(path))->damp_info = bdi;
|
2020-11-02 16:30:01 +01:00
|
|
|
bgp_no_reuse_list_add(bdi, bdc);
|
2002-12-13 21:15:29 +01:00
|
|
|
} else {
|
2021-08-02 12:01:26 +02:00
|
|
|
bgp_damp_info_claim(bdi, bdc);
|
2002-12-13 21:15:29 +01:00
|
|
|
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. */
|
2020-11-02 16:30:01 +01:00
|
|
|
if (bdi->penalty != last_penalty) {
|
2021-07-28 23:14:31 +02:00
|
|
|
bgp_reuse_list_delete(bdi);
|
2019-11-10 19:13:20 +01:00
|
|
|
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;
|
2021-08-02 12:01:18 +02:00
|
|
|
bgp_no_reuse_list_delete(bdi, bdc);
|
2019-11-10 19:13:20 +01:00
|
|
|
bgp_reuse_list_add(bdi, bdc);
|
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;
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_config *bdc;
|
|
|
|
|
|
|
|
bdc = get_active_bdc_from_pi(path, afi, safi);
|
|
|
|
assert(bdc);
|
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);
|
2021-07-28 23:14:31 +02:00
|
|
|
bgp_reuse_list_delete(bdi);
|
2020-11-02 16:30:01 +01:00
|
|
|
bgp_no_reuse_list_add(bdi, bdc);
|
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;
|
2021-07-30 15:50:05 +02:00
|
|
|
else {
|
|
|
|
bgp_damp_info_unclaim(bdi);
|
2021-08-02 12:01:06 +02:00
|
|
|
bgp_damp_info_free(bdi, bdc, 0, afi, safi);
|
2021-07-30 15:50:05 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2021-08-02 12:01:06 +02:00
|
|
|
void bgp_damp_info_free(struct bgp_damp_info *bdi, struct bgp_damp_config *bdc,
|
|
|
|
int withdraw, afi_t afi, safi_t safi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2021-08-02 12:01:06 +02:00
|
|
|
assert(bdc && bdi);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-07-30 15:50:37 +02:00
|
|
|
if (bdi->path == NULL) {
|
|
|
|
XFREE(MTYPE_BGP_DAMP_INFO, bdi);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-29 10:11:15 +02:00
|
|
|
bdi->path->extra->damp_info = NULL;
|
|
|
|
bgp_path_info_unset_flag(bdi->dest, bdi->path,
|
2018-10-03 00:15:34 +02:00
|
|
|
BGP_PATH_HISTORY | BGP_PATH_DAMPED);
|
2021-07-29 10:11:15 +02:00
|
|
|
if (bdi->lastrecord == BGP_RECORD_WITHDRAW && withdraw)
|
|
|
|
bgp_path_info_delete(bdi->dest, bdi->path);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
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,
|
2020-11-02 16:30:01 +01:00
|
|
|
bdc->reuse_list_size * sizeof(struct reuselist));
|
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
|
|
|
{
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_config *bdc = &bgp->damp[afi][safi];
|
2019-11-10 19:13:20 +01:00
|
|
|
|
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);
|
2020-11-02 16:30:01 +01:00
|
|
|
bdc->afi = afi;
|
|
|
|
bdc->safi = safi;
|
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;
|
|
|
|
}
|
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
/* Clean all the bgp_damp_info stored in reuse_list and no_reuse_list. */
|
2020-11-03 07:36:31 +01:00
|
|
|
void bgp_damp_info_clean(struct bgp *bgp, struct bgp_damp_config *bdc,
|
|
|
|
afi_t afi, safi_t safi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_info *bdi;
|
2021-08-02 12:01:18 +02:00
|
|
|
struct reuselist_node *rn;
|
2020-11-02 16:30:01 +01:00
|
|
|
struct reuselist *list;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
bdc->reuse_offset = 0;
|
|
|
|
for (i = 0; i < bdc->reuse_list_size; ++i) {
|
|
|
|
list = &bdc->reuse_list[i];
|
2021-08-02 12:01:18 +02:00
|
|
|
while ((rn = SLIST_FIRST(list)) != NULL) {
|
|
|
|
bdi = rn->info;
|
2020-11-03 07:36:31 +01:00
|
|
|
if (bdi->lastrecord == BGP_RECORD_UPDATE) {
|
|
|
|
bgp_aggregate_increment(bgp, &bdi->dest->p,
|
|
|
|
bdi->path, bdi->afi,
|
|
|
|
bdi->safi);
|
|
|
|
bgp_process(bgp, bdi->dest, bdi->afi,
|
|
|
|
bdi->safi);
|
|
|
|
}
|
2021-08-02 12:01:18 +02:00
|
|
|
bgp_reuselist_del(list, &rn);
|
2021-08-02 12:01:06 +02:00
|
|
|
bgp_damp_info_free(bdi, bdc, 1, afi, safi);
|
2020-11-02 16:30:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-02 12:01:18 +02:00
|
|
|
while ((rn = SLIST_FIRST(&bdc->no_reuse_list)) != NULL) {
|
|
|
|
bdi = rn->info;
|
|
|
|
bgp_reuselist_del(&bdc->no_reuse_list, &rn);
|
2021-08-02 12:01:06 +02:00
|
|
|
bgp_damp_info_free(bdi, bdc, 1, afi, safi);
|
2021-07-30 15:50:05 +02:00
|
|
|
}
|
2020-11-02 16:30:01 +01:00
|
|
|
|
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
|
|
|
|
2021-08-02 12:01:18 +02:00
|
|
|
/* Free reuse list array. */
|
|
|
|
for (i = 0; i < bdc->reuse_list_size; ++i)
|
|
|
|
bgp_reuselist_free(&bdc->reuse_list[i]);
|
|
|
|
|
2019-11-10 19:13:20 +01:00
|
|
|
XFREE(MTYPE_BGP_DAMP_ARRAY, bdc->reuse_list);
|
|
|
|
bdc->reuse_list_size = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
THREAD_OFF(bdc->t_reuse);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
/* Disable route flap dampening for a bgp instance.
|
|
|
|
*
|
|
|
|
* Please note that this function also gets used to free memory when deleting a
|
|
|
|
* bgp instance.
|
|
|
|
*/
|
2002-12-13 21:15:29 +01:00
|
|
|
int bgp_damp_disable(struct bgp *bgp, afi_t afi, safi_t safi)
|
|
|
|
{
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_config *bdc;
|
|
|
|
|
|
|
|
bdc = &bgp->damp[afi][safi];
|
|
|
|
if (!bdc)
|
|
|
|
return 0;
|
|
|
|
|
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. */
|
2020-11-02 16:30:01 +01:00
|
|
|
thread_cancel(&bdc->t_reuse);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Clean BGP dampening information. */
|
2020-11-03 07:36:31 +01:00
|
|
|
bgp_damp_info_clean(bgp, bdc, afi, safi);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
UNSET_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING);
|
2020-11-02 16:30:01 +01:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
void bgp_config_write_damp(struct vty *vty, struct bgp *bgp, afi_t afi,
|
|
|
|
safi_t safi)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_config *bdc;
|
|
|
|
|
|
|
|
bdc = &bgp->damp[afi][safi];
|
|
|
|
if (bdc->half_life == DEFAULT_HALF_LIFE * 60
|
|
|
|
&& bdc->reuse_limit == DEFAULT_REUSE
|
|
|
|
&& bdc->suppress_value == DEFAULT_SUPPRESS
|
|
|
|
&& bdc->max_suppress_time == bdc->half_life * 4)
|
2019-11-10 19:13:20 +01:00
|
|
|
vty_out(vty, " bgp dampening\n");
|
2020-11-02 16:30:01 +01:00
|
|
|
else if (bdc->half_life != DEFAULT_HALF_LIFE * 60
|
|
|
|
&& bdc->reuse_limit == DEFAULT_REUSE
|
|
|
|
&& bdc->suppress_value == DEFAULT_SUPPRESS
|
|
|
|
&& bdc->max_suppress_time == bdc->half_life * 4)
|
|
|
|
vty_out(vty, " bgp dampening %lld\n", bdc->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",
|
2020-11-02 16:30:01 +01:00
|
|
|
bdc->half_life / 60LL, bdc->reuse_limit,
|
|
|
|
bdc->suppress_value, bdc->max_suppress_time / 60LL);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
static const char *bgp_get_reuse_time(struct bgp_damp_config *bdc,
|
|
|
|
unsigned int penalty, char *buf,
|
|
|
|
size_t len, 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
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
if (penalty > bdc->reuse_limit) {
|
2002-12-13 21:15:29 +01:00
|
|
|
reuse_time = (int)(DELTA_T
|
2020-11-02 16:30:01 +01:00
|
|
|
* ((log((double)bdc->reuse_limit / penalty))
|
|
|
|
/ (log(bdc->decay_array[1]))));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
if (reuse_time > bdc->max_suppress_time)
|
|
|
|
reuse_time = bdc->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;
|
|
|
|
|
|
|
|
/* Making formatted timer strings. */
|
|
|
|
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
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
void bgp_damp_info_vty(struct vty *vty, struct bgp *bgp,
|
|
|
|
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;
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_config *bdc = &bgp->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))
|
2020-11-02 16:30:01 +01:00
|
|
|
bgp_get_reuse_time(bdc, penalty, timebuf,
|
|
|
|
BGP_UPTIME_LEN, 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",
|
2020-11-02 16:30:01 +01:00
|
|
|
bgp_get_reuse_time(bdc, penalty, timebuf,
|
|
|
|
BGP_UPTIME_LEN, 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
|
|
|
}
|
|
|
|
|
2020-11-02 16:30:01 +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;
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_config *bdc;
|
|
|
|
|
|
|
|
bdc = get_active_bdc_from_pi(path, afi, safi);
|
|
|
|
if (!bdc)
|
|
|
|
return NULL;
|
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. */
|
2021-06-11 17:14:27 +02:00
|
|
|
if (!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
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
return bgp_get_reuse_time(bdc, penalty, timebuf, len, use_json, json);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2015-03-16 17:55:29 +01:00
|
|
|
|
2020-11-02 16:30:01 +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
|
|
|
{
|
2020-11-02 16:30:01 +01:00
|
|
|
struct bgp_damp_config *bdc;
|
2015-03-16 17:55:29 +01:00
|
|
|
if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) {
|
2020-11-02 16:30:01 +01:00
|
|
|
bdc = &bgp->damp[afi][safi];
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "Half-life time: %lld min\n",
|
2020-11-02 16:30:01 +01:00
|
|
|
(long long)bdc->half_life / 60);
|
|
|
|
vty_out(vty, "Reuse penalty: %d\n", bdc->reuse_limit);
|
|
|
|
vty_out(vty, "Suppress penalty: %d\n", bdc->suppress_value);
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "Max suppress time: %lld min\n",
|
2020-11-02 16:30:01 +01:00
|
|
|
(long long)bdc->max_suppress_time / 60);
|
|
|
|
vty_out(vty, "Max suppress penalty: %u\n", bdc->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,
|
bgpd: add terse display option on show bgp summary
Add a terse option to show bgp summary to shorten output.
Do not show the following information about the BGP
instances: the number of RIB entries, the table version and the used memory.
The "terse" option can be used in combination with the "remote-as", "neighbor",
"failed" and "established" filters, and with the "wide" option as well.
Before patch:
ubuntu# show bgp summary remote-as 123456
IPv4 Unicast Summary (VRF default):
BGP router identifier X.X.X.X, local AS number XXX vrf-id 0
BGP table version 0
RIB entries 3, using 552 bytes of memory
Peers 5, using 3635 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.200.200.2 4 123456 81432 4 0 56092 0 00:00:13 572106 0 N/A
Displayed neighbors 1
Total number of neighbors 4
IPv6 Unicast Summary (VRF default):
BGP router identifier X.X.X.X, local AS number XXX vrf-id 0
BGP table version 0
RIB entries 3, using 552 bytes of memory
Peers 5, using 3635 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
% No matching neighbor
Total number of neighbors 5
After patch:
ubuntu# show bgp summary remote-as 123456 terse
IPv4 Unicast Summary (VRF default):
BGP router identifier X.X.X.X, local AS number XXX vrf-id 0
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.200.200.2 4 123456 81432 4 0 56092 0 00:00:13 572106 0 N/A
Displayed neighbors 1
Total number of neighbors 4
IPv6 Unicast Summary (VRF default):
BGP router identifier X.X.X.X, local AS number XXX vrf-id 1
% No matching neighbor
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2021-05-12 18:54:11 +02:00
|
|
|
uint16_t show_flags)
|
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
|
|
|
{
|
|
|
|
struct bgp *bgp;
|
|
|
|
|
2020-11-02 16:30:01 +01:00
|
|
|
bgp = bgp_get_default();
|
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 (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;
|
|
|
|
}
|
2020-11-02 16:30:01 +01:00
|
|
|
|
|
|
|
void bgp_peer_damp_enable(struct peer *peer, afi_t afi, safi_t safi,
|
|
|
|
time_t half, unsigned int reuse,
|
|
|
|
unsigned int suppress, time_t max)
|
|
|
|
{
|
|
|
|
struct bgp_damp_config *bdc;
|
|
|
|
|
|
|
|
if (!peer)
|
|
|
|
return;
|
|
|
|
bdc = &peer->damp[afi][safi];
|
|
|
|
if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_CONFIG_DAMPENING)) {
|
|
|
|
if (bdc->half_life == half && bdc->reuse_limit == reuse
|
|
|
|
&& bdc->suppress_value == suppress
|
|
|
|
&& bdc->max_suppress_time == max)
|
|
|
|
return;
|
|
|
|
bgp_peer_damp_disable(peer, afi, safi);
|
|
|
|
}
|
|
|
|
SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_CONFIG_DAMPENING);
|
|
|
|
bgp_damp_parameter_set(half, reuse, suppress, max, bdc);
|
|
|
|
bdc->afi = afi;
|
|
|
|
bdc->safi = safi;
|
|
|
|
thread_add_timer(bm->master, bgp_reuse_timer, bdc, DELTA_REUSE,
|
|
|
|
&bdc->t_reuse);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable route flap dampening for a peer.
|
|
|
|
*
|
|
|
|
* Please note that this function also gets used to free memory when deleting a
|
|
|
|
* peer or peer group.
|
|
|
|
*/
|
|
|
|
void bgp_peer_damp_disable(struct peer *peer, afi_t afi, safi_t safi)
|
|
|
|
{
|
|
|
|
struct bgp_damp_config *bdc;
|
|
|
|
|
|
|
|
if (!peer_af_flag_check(peer, afi, safi, PEER_FLAG_CONFIG_DAMPENING))
|
|
|
|
return;
|
|
|
|
bdc = &peer->damp[afi][safi];
|
|
|
|
if (!bdc)
|
|
|
|
return;
|
2020-11-03 07:36:31 +01:00
|
|
|
bgp_damp_info_clean(peer->bgp, bdc, afi, safi);
|
2020-11-02 16:30:01 +01:00
|
|
|
UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_CONFIG_DAMPENING);
|
|
|
|
}
|
|
|
|
|
|
|
|
void bgp_config_write_peer_damp(struct vty *vty, struct peer *peer, afi_t afi,
|
|
|
|
safi_t safi)
|
|
|
|
{
|
|
|
|
struct bgp_damp_config *bdc;
|
|
|
|
|
|
|
|
bdc = &peer->damp[afi][safi];
|
|
|
|
if (bdc->half_life == DEFAULT_HALF_LIFE * 60
|
|
|
|
&& bdc->reuse_limit == DEFAULT_REUSE
|
|
|
|
&& bdc->suppress_value == DEFAULT_SUPPRESS
|
|
|
|
&& bdc->max_suppress_time == bdc->half_life * 4)
|
|
|
|
vty_out(vty, " neighbor %s dampening\n", peer->host);
|
|
|
|
else if (bdc->half_life != DEFAULT_HALF_LIFE * 60
|
|
|
|
&& bdc->reuse_limit == DEFAULT_REUSE
|
|
|
|
&& bdc->suppress_value == DEFAULT_SUPPRESS
|
|
|
|
&& bdc->max_suppress_time == bdc->half_life * 4)
|
|
|
|
vty_out(vty, " neighbor %s dampening %lld\n", peer->host,
|
|
|
|
bdc->half_life / 60LL);
|
|
|
|
else
|
|
|
|
vty_out(vty, " neighbor %s dampening %lld %d %d %lld\n",
|
|
|
|
peer->host, bdc->half_life / 60LL, bdc->reuse_limit,
|
|
|
|
bdc->suppress_value, bdc->max_suppress_time / 60LL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bgp_print_peer_dampening_parameters(struct vty *vty,
|
|
|
|
struct peer *peer, afi_t afi,
|
|
|
|
safi_t safi, bool use_json,
|
|
|
|
json_object *json)
|
|
|
|
{
|
|
|
|
struct bgp_damp_config *bdc;
|
|
|
|
|
|
|
|
if (!peer)
|
|
|
|
return;
|
|
|
|
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_CONFIG_DAMPENING)) {
|
|
|
|
bdc = &peer->damp[afi][safi];
|
|
|
|
if (!bdc)
|
|
|
|
return;
|
|
|
|
if (use_json) {
|
|
|
|
json_object_int_add(json, "halfLifeSecs",
|
|
|
|
bdc->half_life);
|
|
|
|
json_object_int_add(json, "reusePenalty",
|
|
|
|
bdc->reuse_limit);
|
|
|
|
json_object_int_add(json, "suppressPenalty",
|
|
|
|
bdc->suppress_value);
|
|
|
|
json_object_int_add(json, "maxSuppressTimeSecs",
|
|
|
|
bdc->max_suppress_time);
|
|
|
|
json_object_int_add(json, "maxSuppressPenalty",
|
|
|
|
bdc->ceiling);
|
|
|
|
} else {
|
|
|
|
vty_out(vty, "Half-life time: %lld min\n",
|
|
|
|
(long long)bdc->half_life / 60);
|
|
|
|
vty_out(vty, "Reuse penalty: %d\n", bdc->reuse_limit);
|
|
|
|
vty_out(vty, "Suppress penalty: %d\n",
|
|
|
|
bdc->suppress_value);
|
|
|
|
vty_out(vty, "Max suppress time: %lld min\n",
|
|
|
|
(long long)bdc->max_suppress_time / 60);
|
|
|
|
vty_out(vty, "Max suppress penalty: %u\n",
|
|
|
|
bdc->ceiling);
|
|
|
|
vty_out(vty, "\n");
|
|
|
|
}
|
|
|
|
} else if (!use_json)
|
|
|
|
vty_out(vty, "neighbor dampening not enabled for %s\n",
|
|
|
|
get_afi_safi_str(afi, safi, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
void bgp_show_peer_dampening_parameters(struct vty *vty, struct peer *peer,
|
|
|
|
afi_t afi, safi_t safi, bool use_json)
|
|
|
|
{
|
|
|
|
json_object *json;
|
|
|
|
|
|
|
|
if (use_json) {
|
|
|
|
json = json_object_new_object();
|
|
|
|
json_object_string_add(json, "addressFamily",
|
|
|
|
get_afi_safi_str(afi, safi, false));
|
|
|
|
bgp_print_peer_dampening_parameters(vty, peer, afi, safi, true,
|
|
|
|
json);
|
|
|
|
vty_out(vty, "%s\n",
|
|
|
|
json_object_to_json_string_ext(
|
|
|
|
json, JSON_C_TO_STRING_PRETTY));
|
|
|
|
json_object_free(json);
|
|
|
|
} else {
|
|
|
|
vty_out(vty, "\nFor address family: %s\n",
|
|
|
|
get_afi_safi_str(afi, safi, false));
|
|
|
|
bgp_print_peer_dampening_parameters(vty, peer, afi, safi, false,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|