Commit Graph

4777 Commits

Author SHA1 Message Date
Donatas Abraitis
70d400cefa
Merge pull request #7114 from donaldsharp/tip_count
bgpd: Avoid memset when tip hash is empty
2020-09-17 15:10:13 +03:00
Donatas Abraitis
893774e324
Merge pull request #7108 from qlyoung/remove-double-holdtimer-cancel
bgpd: remove extra hold-timer reset
2020-09-17 15:08:49 +03:00
Donald Sharp
3584c85e92 bgpd: Avoid memset when tip hash is empty
The tip hash is only used when we are dealing with
evpn.  In bgp_nexthop_self we are doing a memset
irrelevant of whether we will ever find data.  Yes
hash_lookup will return pretty quickly.

Modify the code to avoid doing a memset in the case
where the tip hash is empty as that we know we'll
never find anything.  With full BGP feeds this
small memset does take some time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-16 17:48:15 -04:00
Quentin Young
765b07d9ff bgpd: remove extra hold-timer reset
Handler function doesn't need to reset the hold timer, this is done
during the FSM update.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-15 20:15:08 -04:00
Quentin Young
84f22ecc05 bgpd: fix ecom leak handling l3vni update
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-09-15 16:06:58 -07:00
Donatas Abraitis
a849a3fe07 bgpd: Create separate udpate-group when using maximum-prefix-out command
This is needed to avoid mangling update-group which is used for many peers.

Sent prefix count is managed by update-groups.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-09-15 21:57:52 +03:00
Jafar Al-Gharaibeh
d1ca950e40
Merge pull request #7090 from dslicenc/comm-list-replace
bgpd: correct community-list replace logic
2020-09-14 10:42:10 -05:00
Mark Stapp
cfa2115d02
Merge pull request #7093 from donaldsharp/pbr_flapping
Pbr flapping
2020-09-14 08:13:48 -04:00
Igor Ryzhov
a1d3a2a626 bgpd: remove deprecated commands
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-09-13 23:57:09 +03:00
Don Slice
96e2fd256a bgpd: correct community-list replace logic
Problem rerported that if you enter an existing community list
sequence number with new community information, the entire community
list would be deleted.  This commit fixes the replace logic to do
the right thing.

Ticket: CM-30555
Signed-off-by: Don Slice <dslice@nvidia.com>
2020-09-12 06:17:32 -07:00
Donald Sharp
58a1d24924 bgpd, lib, pbrd, zebra: Pass by ifname
When installing rules pass by the interface name across
zapi.

This is being changed because we have a situation where
if you quickly create/destroy ephermeal interfaces under
linux the upper level protocol may be trying to add
a rule for a interface that does not quite exist
at the moment.  Since ip rules actually want the
interface name ( to handle just this sort of situation )
convert over to passing the interface name and storing
it and using it in zebra.

Ticket: CM-31042
Signed-off-by: Stephen Worley <sworley@nvidia.com>
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-11 20:04:45 -04:00
Pat Ruddy
b0610ff727 bgp: remove duplicate command installs
[no_]neighbor_nexthop_self_cmd & [no_]neighbor_nexthop_self_force_cmd
have duplicate install_element actions on the EVPN_NODE. This causes
duplicate command log errors which are caught by topotests. Remove
these.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-09-11 18:26:24 +02:00
Philippe Guibert
c2ca3e25a6 bgpd: sanity check when updating nexthop from bgp to zebra
nexthop may sometimes not be passed through zebra, like for onlink
messages.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-09-11 18:26:23 +02:00
Philippe Guibert
6179d0d125 bgpd: evpn nexthop can be changed by default
There can be cases where evpn traffic is not meshed across various
endpoints, but sent to a central pe. For this situation, add the
configuration knobs to force nexthop attribute. Upon that change,
nexthop unchanged attribute is automatically disabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-09-11 18:25:12 +02:00
Donatas Abraitis
a68b613b09
Merge pull request #6827 from maduri111/bgpd-show-bgp-all
bgpd: show <ip> bgp <ipv4/ipv6> all
2020-09-10 15:11:14 +03:00
Donatas Abraitis
28a54742ca
Merge pull request #7031 from dslicenc/global-bgp-update-delay
Global bgp update delay
2020-09-08 21:43:51 +03:00
Don slice
d70583f78d bgpd: add global config for update-delay
Enhancement to update-delay configuration to allow setting globally
rather than per-instance.  Setting the update-delay is allowed either
per-vrf or globally, but not both at the same time.

Ticket: CM-31096
Signed-off-by: Don Slice <dslice@nvidia.com>
2020-09-08 04:27:01 -07:00
Donatas Abraitis
8336c896fd bgpd: Add neighbor <neigh> shutdown rtt command
This would be useful in cases with lots of peers and shutdown them
automatically if RTT goes above the specified limit.

A host with 512 or more IPv6 addresses has a higher latency due to
ipv6_addr_label(). This method tries to pick the best candidate address
fo outgoing connection and literally increases processing latency.

```
Samples: 28  of event 'cycles', Event count (approx.): 22131542
  Children      Self  Command  Shared Object      Symbol
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] entry_SYSCALL_64_fastpath
  +  100.00%     0.00%  ping6    [unknown]          [.] 0x0df0ad0b8047022a
  +  100.00%     0.00%  ping6    libc-2.17.so       [.] __sendto_nocancel
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] sys_sendto
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] SYSC_sendto
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] sock_sendmsg
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] inet_sendmsg
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] rawv6_sendmsg
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] ip6_dst_lookup_flow
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] ip6_dst_lookup_tail
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] ip6_route_get_saddr
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] ipv6_dev_get_saddr
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] __ipv6_dev_get_saddr
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] ipv6_get_saddr_eval
  +  100.00%     0.00%  ping6    [kernel.kallsyms]  [k] ipv6_addr_label
  +  100.00%   100.00%  ping6    [kernel.kallsyms]  [k] __ipv6_addr_label
  +    0.00%     0.00%  ping6    [kernel.kallsyms]  [k] schedule
```

This is how it works:

```
~# vtysh -c 'show bgp neigh 192.168.0.2 json' | jq '."192.168.0.2".estimatedRttInMsecs'
9
~# tc qdisc add dev eth1 root netem delay 120ms
~# vtysh -c 'show bgp neigh 192.168.0.2 json' | jq '."192.168.0.2".estimatedRttInMsecs'
89
~# vtysh -c 'show bgp neigh 192.168.0.2 json' | jq '."192.168.0.2".estimatedRttInMsecs'
null
~# vtysh -c 'show bgp neigh 192.168.0.2 json' | jq '."192.168.0.2".lastResetDueTo'
"Admin. shutdown"
```

Warning message:
bgpd[14807]: 192.168.0.2 shutdown due to high round-trip-time (200ms > 150ms)

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-09-07 22:30:19 +03:00
Donatas Abraitis
e410d56307 bgpd: Update RTT on KEEPALIVE message
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-09-07 17:25:57 +03:00
Donatas Abraitis
b164e7645d
Merge pull request #7040 from qlyoung/fix-evpn-attribute-hash-error
bgpd: modify attr fields before hash insert
2020-09-05 15:47:38 +03:00
Donatas Abraitis
5266cab359
Merge pull request #7037 from volta-networks/fix_traps_bgp
Fix bgpBackwardTransition traps
2020-09-05 08:28:19 +03:00
Donatas Abraitis
1da90d136a
Merge pull request #7054 from qlyoung/fix-bgp-mplsvpn-nlri-missing-length-checks
bgpd: fix mplsvpn nlri garbage heap read
2020-09-05 08:17:15 +03:00
Renato Westphal
dcdaabcede
Merge pull request #7046 from qlyoung/fix-various-integer-issues
Fix various integer signedness / overflow issues
2020-09-04 22:33:48 -03:00
Renato Westphal
c7b5a0ae3a
Merge pull request #7055 from qlyoung/fix-bgp-localpref-overflow
bgpd: fix asserting read of localpref
2020-09-04 18:56:46 -03:00
Donatas Abraitis
08194f561e
Merge pull request #6589 from NaveenThanikachalam/gr_fixes
bgpd: GR fixes
2020-09-04 18:39:26 +03:00
Donatas Abraitis
f6af4aecf4
Merge pull request #6826 from pjdruddy/bgp-auth-vrf-frr
Bgp auth vrf frr
2020-09-04 16:03:47 +03:00
Quentin Young
763a5d3c2d bgpd: use stream_rewind_getp() to remove overflow
Passing a negative argument to a size_t parameter creates an overflow
condition

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-03 14:23:57 -04:00
Quentin Young
ad61f7780e bgpd: fix asserting read of localpref
Attribute may not be long enough to contain a localpref value, resulting
in an assert on stream size. Gracefully handle this case instead.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-03 14:10:33 -04:00
Quentin Young
506dbcc86b bgpd: fix mplsvpn nlri garbage heap read
NLRI parsing for mpls vpn was missing several length checks that could
easily result in garbage heap reads past the end of nlri->packet.

Convert the whole function to use stream APIs for automatic bounds
checking...

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-03 14:06:30 -04:00
Madhuri Kuruganti
96f3485cdb 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-09-03 20:26:07 +05:30
Quentin Young
e9faf4be72 bgpd: make flag values explicitly unsigned
When using these flag #defines, by default their types are integers but
they are always used in conjunction with unsigned integers, which
introduces some implicit conversions that really ought to be avoided.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-02 16:54:41 -04:00
Quentin Young
1e9be514b3 bgpd: modify attr fields before hash insert
bgp_attr_intern(attr) takes an attribute, duplicates it, and inserts it
into the attribute hash table, returning the inserted attr. This is done
when processing a bgp update. We store the returned attribute in the
path info struct. However, later on we modify one of the fields of the
attribute. This field is inspected by attrhash_cmp, the function that
allows the hash table to select the correct item from the hash chain for
a given key when doing a lookup on an item. By modifying the field after
it's been inserted, we open the possibility that two items in the same
chain that at insertion time were differential by attrhash_cmp becomes
equal according to that function. When performing subsequent hash
lookups, it is then indeterminate which of the equivalent items the hash
table will select from the chain (in practice it is the first one but
this may not be the one we want). Thus, it is illegal to modify
data used by a hash comparison function after inserting that data into
a hash table.

In fact this is occurring for attributes. We insert two attributes that
hash to the same key and thus end up in the same hash chain. Then we
modify one of them such that the two items now compare equal. Later one
we want to release the second item from the chain before XFREE()'ing it,
but since the two items compare equal we get the first item back, then
free the second one, which constitutes two bugs, the first being the
wrong attribute removed from the hash table and the second being a
dangling pointer stored in the hash table.

To rectify this we need to perform any modifications to an attr before
it is inserted into the table, i.e., before calling bgp_attr_intern().
This patch does that by moving the sole modification to the attr that
occurs after the insert (that I have seen) before that call.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-02 13:16:35 -04:00
David Schweizer
c163f2971b
bgpd: set/unset bgpd no-rib option at runtime
* Added vtysh cli commands and functions to set/unset bgp daemons no-rib
  option during runtime and withdraw/announce routes in bgp instances
  RIB from/to Zebra.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-09-02 18:20:08 +02:00
Babis Chalios
05e68acc75 bgpd: fix invocation of bgpTrapBackwardTransition
The bgpTrapBackwardTransition callback was being called only during
bgp_stop and only under the condition that peer status was Established.
The MIB defines that the event should be generated for every transition
of the BGP FSM from a higher to a lower state.

Signed-off-by: Babis Chalios <mail@bchalios.io>
2020-09-02 15:30:22 +02:00
Pat Ruddy
2734ff6bd8 bgpd: do not clear password if peer is dynamic
When deleting a dynamic peer, unsetting md5 password would cause
it to be unset on the listener allowing unauthenticated connections
from any peer in the range.
Check for dynamic peers in peer delete and avoid this.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-09-01 09:42:39 +01:00
Pat Ruddy
a4faae3aac bgpd: associate listener with the appropriate bgp instance
When setting authentication on a BGP peer in a VRF the listener is
looked up from a global list. However there is no check that the
listener is the one associated with the VRF being configured. This
can result in the wrong listener beiong configured with a password,
leaving the intended listener in an open authentication state.
To simplify this lookup stash a pointer to the bgp instance in
the listener on creating (in the same way as is done for NS-based
VRFS).

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-09-01 09:42:26 +01:00
Pat Ruddy
e37e1e27e4 bgpd: do not unregister for prefix nexthop updates if nh exists
since the addition of srte_color to the comparison for bgp nexthops
it is possible to have several nexthops per prefix but since zebra
only sores a per prefix registration we should not unregister for
nh notifications for a prefix unti all the nexthops for that prefix
have been deleted. Otherwise we can get into a deadlock situation
where BGP thinks we have registered but we have unregistered from zebra.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-08-31 09:11:47 +00:00
Renato Westphal
545aeef1d1 bgpd: extend the NHT code to understand SR-TE colors
Extend the NHT code so that only the affected BGP routes are affected
whenever an SR-policy is updated on zebra.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-31 09:11:03 +00:00
Sebastien Merle
ef3e0d0476 bgpd: Add support for SR-TE Policies in route-maps
Example configuration:
    route-map SET_SR_POLICY permit 10
     set sr-te color 1
     !
    router bgp 1
     bgp router-id 1.1.1.1
     neighbor 2.2.2.2 remote-as 1
     neighbor 2.2.2.2 update-source lo
     address-family ipv4 unicast
      neighbor 2.2.2.2 next-hop-self
      neighbor 2.2.2.2 route-map SET_SR_POLICY in
     exit-address-family
     !
    !
Learned BGP routes from 2.2.2.2 are mapped to the SR-TE Policy
which is uniquely determined by the BGP nexthop (2.2.2.2 in this
case) and the SR-TE color in the route-map.

Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Co-authored-by: Sebastien Merle <sebastien@netdef.org>
Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-08-31 09:09:12 +00:00
Renato Westphal
f663c5819c bgpd: convert NHT code to use rb-trees instead of routing tables
Fist, routing tables aren't the most appropriate data structure
to store nexthops and imported routes since we don't need to do
longest prefix matches with that information.

Second, by converting the NHT code to use rb-trees, we can index
the nexthops using additional information, not only the destination
address.  This will be useful later to index bgpd's nexthops by
both destination and SR-TE color.

Co-authored-by: Sebastien Merle <sebastien@netdef.org>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-31 09:09:05 +00:00
Donald Sharp
ff35a11676
Merge pull request #7001 from ton31337/fix/deadcode_bgp_show_all_instances_neighbors_vty
bgpd: Remove a deadcode freeing JSON in bgp_show_all_instances_neighbors_vty
2020-08-26 09:27:12 -04:00
Rafael Zalamena
0856cc337f
Merge pull request #6903 from ton31337/fix/prevent_null_pointer_dereference_for_aspath
bgpd: Reuse bgp_adj_in for attr to avoid null dereference under aspath
2020-08-26 10:07:53 -03:00
Donald Sharp
c6d41e93e0
Merge pull request #5799 from pguibert6WIND/flowspec_ipv6
Flowspec ipv6
2020-08-26 08:26:46 -04:00
Donatas Abraitis
3e78a6ce5b bgpd: Remove a deadcode freeing JSON in bgp_show_all_instances_neighbors_vty
json = NULL; is set in a loop above and here we are trying to check and
free the object again which is never be reached.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-08-26 08:46:28 +03:00
Donald Sharp
92b79e9655
Merge pull request #6983 from achernavin22/bgp_def_route_rt_map_no_match
bgpd: withdraw default route when route-map has no match
2020-08-25 15:32:33 -04:00
Donald Sharp
b86a57c965
Merge pull request #6986 from achernavin22/bgp_reset_sess_if_ebgp_multihop
bgpd: reset session if ebgp-multihop is set and no session established
2020-08-25 15:29:24 -04:00
Russ White
e3dcd431cd
Merge pull request #6938 from opensourcerouting/bgp-instance-shutdown
bgpd: BGP instance administrative shutdown
2020-08-25 10:31:01 -04:00
Alexander Chernavin
3557ed3d32 bgpd: reset session if ebgp-multihop is set and no session established
If you configure eBGP on loopbacks, you might miss setting the
ebgp-multihop option. Given that, the session will not be established
because of this. Now, the session is in Active state. When you update
your config afterwards and set the ebgp-multihop option to the
appropriate value, the session will still be in Active state. In fact,
it will be stuck in Active state and only services restart will help.

With this change, when set the ebgp-multihop option and no session was
established, reset the session.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
2020-08-25 09:51:22 -04:00
Alexander Chernavin
f52a961ac8 bgpd: withdraw default route when route-map has no match
If you advertise a default route (via default-originate) only if some
prefix is present in the BGP RIB (route-map specified) and this prefix
becomes unavailable, the default route keeps being advertised.

With this change, when we iterate over the BGP RIB to check if we can
advertise the default route, skip unavailable prefixes.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
2020-08-25 07:24:13 -04:00
Russ White
de4fa7efe5
Merge pull request #6959 from patrasar/bgp_collision_issue
bgpd: Fix BGP session stuck in OpenConfirm state
2020-08-25 07:15:34 -04:00
David Schweizer
9ddf4b8180
bgpd: alias for bgp no shutdown cmd
* Reverted back to using an ALIAS definition for the negated bgp
  shutdown command with a concatenated message string.
* Unified cli command descriptions for bgp shutdown commands.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-24 18:16:49 +02:00
David Schweizer
dc5291cbc7
bgpd: minor fix for shutdown cli commands
* Changed command description string to use "Remove" instead of
  "Disable" to prevent user confusion due to double negation.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-24 13:33:39 +02:00
David Schweizer
1b6e7a8874
bgpd: additional no bgp shutdown cli command
* Added a "no bgp shutdown message MSG..." cli command for ease of use
  with copy/paste. Because of current limitations with DEFPY/ALIAS and
  the message string concatenation, a new command instead of an ALIAS
  had to be implemented.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-24 08:12:16 +02:00
Donatas Abraitis
f41b045981 bgpd: Honor route-maps when forcing maximum-prefix for filtered routes
This will check route-maps as well, not only prefix-lists, access-lists, and
filter-lists.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-08-22 18:30:54 +03:00
Philippe Guibert
c24ceb896e bgpd: fix Dereference of null pointer in flowspec
a dereference of null pointer exists in current flowspec code, with
prefix pointer. check validity of pointer before going ahead.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
4371bf9110 bgpd: remove warnings related to line too longs in bgp code
remove warnings related to line too long in bgp code.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
7659ad686a bgpd: do not forget to set the size of community val length
because ecommunity structure can host both ext community and ipv6 ext
community, do not forget to set the unit_size field.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
a973d4c440 bgpd: remove sprintf() usage on flowspec
flowspec is being removed from remaining sprintf() calls.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
c6423c3153 bgp, zebra: add some alignments with remarks from community
align the code to remarks from community.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
34540b0d7f bgpd: fill in local ecommunity context with ecom unit length
because the same extended community can be used for storing ipv6 and
ipv4 et communities, the unit length must be stored. do not forget to
set the standard value in bgp evpn.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
f2ead0a540 bgpd: fallback proto icmp/v6 to appropriate l3 filter
if match protocol is icmp, then this protocol will be filtered with afi
= ipv4. however, if afi = ipv6, then the icmp protocol will fall back to
icmpv6.
note that this patch has also been done to simplify the policy routing,
as BGP will only handle TCP/UDP/ICMP(v4 or v6) protocols.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
173ebf4784 bgpd: limit policy routing with flowlabel, fragment, and prefix offset
the following 3 options are not supported in current implementation of
policy routing. for that, inform the user that the flowspec entry is
invalid when attempting to use :
- prefix offset with src, or dst ipv6 address ( see [1])
- flowlabel value - limitation due to [0]
- fragment ( implementation not done today).

[0] https://bugzilla.netfilter.org/show_bug.cgi?id=1375
[1] https://bugzilla.netfilter.org/show_bug.cgi?id=1373

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
8f24218710 bgpd: support for flowspec interface list per address-family
in addition to ipv4 flowspec, ipv6 flowspec address family can configure
its own list of interfaces to monitor. this permits filtering the policy
routing only on some interfaces.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
9a659715df bgpd: support for bgp ipv6 ext community, and flowspec redirect ipv6
rfc 5701 is supported. it is possible to configure in bgp vpn, a list of
route target with ipv6 external communities to import. it is to be noted
that this ipv6 external community has been developed only for matching a
bgp flowspec update with same ipv6 ext commmunity.
adding to this, draft-ietf-idr-flow-spec-v6-09 is implemented regarding
the redirect ipv6 option.

Practically, under bgp vpn, under ipv6 unicast, it is possible to
configure : [no] rt6 redirect import <IPV6>:<AS> values.

An incoming bgp update with fs ipv6 and that option matching a bgp vrf,
will be imported in that bgp vrf.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
a60b7031f9 bgp, zebra: add family attribute to ipset and iptable context
in order to create appropriate policy route, family attribute is stored
in ipset and iptable zapi contexts. This commit also adds the flow label
attribute in iptables, for further usage.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
f01e580fc0 bgpd: support for redirect ipv6 simpson method
this commit supports [0] where ipv6 address is encoded in nexthop
attribute of nlri, and not in bgp redirect ip extended community. the
community contains only duplicate information or not.
Adding to this, because an action or a rule needs to apply to either
ipv4 or ipv6 flow, modify some internal structures so as to be aware of
which flow needs to be filtered. This work is needed when an ipv6
flowspec rule without ip addresses is mentioned, we need to know which
afi is served. Also, this work will be useful when doing redirect VRF.

[0] draft-simpson-idr-flowspec-redirect-02.txt

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
4088180002 bgpd, lib: support for flow_label flowspec type
in ipv6 flowspec, a new type is defined to be able to do filtering rules
based on 20 bits flow label field as depicted in [0]. The change include
the decoding by flowspec, and the addition of a new attribute in policy
routing rule, so that the data is ready to be sent to zebra.
The commit also includes a check on fragment option, since dont fragment
bit does not exist in ipv6, the value should always be set to 0,
otherwise the flowspec rule becomes invalid.

[0] https://tools.ietf.org/html/draft-ietf-idr-flow-spec-v6-09

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
9cec412162 bgpd: ipv6 flowspec address decoding and validation
as per [0], ipv6 adress format introduces an ipv6 offset that needs to
be extracted too. The change include the validation, decoding for
further usage with policy-routing and decoding for dumping.

[0] https://tools.ietf.org/html/draft-ietf-idr-flow-spec-v6-09

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
1840384bae bgpd: flowspec code support for ipv6
until now, the assumption was done in bgp flowspec code that the
information contained was an ipv4 flowspec prefix. now that it is
possible to handle ipv4 or ipv6 flowspec prefixes, that information is
stored in prefix_flowspec attribute. Also, some unlocking is done in
order to process ipv4 and ipv6 flowspec entries.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Sarita Patra
6c4d8732e9 bgpd: Fix BGP session stuck in OpenConfirm state
Issue:
1. Initially BGP start listening to socket.
2. Start timer expires and BGP tries to connect to peer and moved
   to Idle->connect (lets say peer datastructre X)
3. Connect for X succeeds and hence moved from idle ->connect with
   FD-x.
4. A incoming connection is accepted and a new peer datastructure Y
   is created with FD-y moves from idle->Active state.
5. Peer datastercture Y FD-y sends out OPEN and moves to
   Active->Opensent state.
6. Peer datastrcture Y FD-y receives OPEN and moved from Opensent->
   Openconfirm state.
7. Meanwhile on peer datastrcture X FD-x sends out a OPEN message
   and moved from connect->Opensent.
8. For peer datastrcture Y FD-y keep alive is received and it is
   moved from OpenConfirm->Established.
9. In this case peer datastructure Y FD-y is a accepted connection
   so we try to copy all its parameter to peer datastructure X and
   delete Y.
10. During this process TCP connection for the accepted connection
    (FD-y) goes down and hence get remote address and port fails.
11. With this failure bgp_stop function for both peer datastrure X
    and peer datastructure Y is called.
12. By this time all the parameters include state for datastrcture
    for X and Y are exchanged. Peer Y FD-y when it entered this
    function had state OpenConfirm still which has been moved to peer
    datastrcture X.
13. In bgp_stop it will stop all the timers and take action only if
    peer is in established state. Now that peer datastrcture X and Y
    are not in established state (in this function) it will simply
    close all timers and close the socket and assigns socket for both
    the peer datastrcture to -1.
14. Peer datastrcture Y will be deleted as it is a datastrcture created
    due to accept of connection where as peer datastrcture X will be held
    as it is created with configuration.
15. Now peer datastrcture X now holds a state of OpenConfirm without any
    timers running.
16. With this any new incoming connection will never be able to establish
    as there is config connection X which is stuck in OpenConfirm.

Fix:
 While transferring the peer datastructure Y FD-y (accepted connection)
 to the peer datastructure X, if TCP connection for FD-y goes down, then
 1. Call fsm event bgp_stop for X (do cleanup with bgp_stop and move the
    state to Idle) and
 2. Call fsm event bgp_stop for Y (do cleanup with bgp_stop and gets deleted
    since it is an accept connection).

Signed-off-by: Sarita Patra <saritap@vmware.com>
2020-08-20 23:36:22 -07:00
Sarita Patra
4533dc6a4e bgpd: Don't stop hold timer in OpenConfirm State
Issue:

1. Initially BGP start listening to socket.
2. Start timer expires and BGP tries to connect to peer and moved
   to Idle->connect (lets say peer datastructre X)
3. Peer datastrcture Y FD-X receives OPEN and moved from Opensent->
   Openconfirm state and start the hold timer.
4. In the OpenConfirm state, the hold timer is stopped. So peer X
   waits for Keepalive message from peer. If the Keepalive message
   is not received, then it will be in OpenConfirm state for
   indefinite time.
5. Due to this it neither close the existing connection nor it will
   accept any connection from peer.

Fix:
In the OpenConfirm state, don't stop the hold timer.
 1. Upon receipt of a neighbor’s Keepalive, the state is moved to
    Established.
 2. But If the hold timer expires, a stop event occurs, the state
    is moved to Idle.
This is as per RFC.

Signed-off-by: Sarita Patra <saritap@vmware.com>
2020-08-20 23:35:47 -07:00
David Schweizer
736b68f33a
bgpd: minor fix and code style compliance
* Applied style suggestions by automated compliance check.
* Fixed function bgp_shutdown_enable to use immutable message string.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-20 16:50:21 +02:00
Rafael Zalamena
be8d09f125
Merge pull request #6924 from AnuradhaKaruppiah/mem-fixes
bgpd: fixes for problems found during EVPN fuzzing
2020-08-20 14:12:51 +00:00
Quentin Young
54c1ad9802
Merge pull request #6949 from ton31337/fix/sizeof_for_bgp_dump_attr_inbgp_attr_malformed
bgpd: Use sizeof() in bgp_dump_attr()
2020-08-19 14:00:01 -04:00
Renato Westphal
dbe45aa733
Merge pull request #6941 from donaldsharp/bgp_json_crash
bgpd: Prevent crash when displaying json of a vrf all command
2020-08-19 12:08:44 -03:00
Donatas Abraitis
99ab4d233d bgpd: Use sizeof() in bgp_dump_attr()
Missed this in 5022c8331d

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-08-19 15:57:26 +03:00
Renato Westphal
4fe5bc8c62
Merge pull request #6943 from ton31337/fix/replace_sizeof_instead_of_constant_for_bgp_dump_attr
bgpd: Use sizeof() in bgp_dump_attr()
2020-08-19 07:36:13 -03:00
Donatas Abraitis
5022c8331d bgpd: Use sizeof() in bgp_dump_attr()
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-08-18 21:43:07 +03:00
Donald Sharp
121067e9c5 bgpd: Prevent crash when displaying json of a vrf all command
When iterating over a `show ip bgp vrf all neighbors json` command
bgp is crashing.

The json variable was being double freed.  When freeing it, set it
to NULL and then check to make sure it exists before we free.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-18 13:54:03 -04:00
Russ White
48f8e0fdde
Merge pull request #6929 from donaldsharp/bgp_relax_do_not_do_it
bgpd: Actually respect RFC 6286 for router_id
2020-08-18 11:23:52 -04:00
Donald Sharp
b5c2113e47 bgpd: Actually respect RFC 6286 for router_id
The RFC states:
      The BGP Identifier is a 4-octet, unsigned, non-zero integer that
      should be unique within an AS.  The value of the BGP Identifier
      for a BGP speaker is determined on startup and is the same for
      every local interface and every BGP peer.

We were going slightly beyond this and ensuring that the address
was a specific range of addresses which is no longer relevant.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-17 13:52:19 -04:00
David Schweizer
1e12ebbca3
bgpd: fix for BGP instance shutdown CLI error.
* Replaced alias for bgp shutdown command with separate regular command
  to prevent internal CLI errors.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-17 17:43:57 +02:00
David Schweizer
f80e35b602
bgpd: minor fix for BGP instance shutdown.
* Fixed missing first word due to wrong start field of string
  concatenation issue.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-17 12:03:27 +02:00
David Schweizer
8389c83aa1
bgpd: enhancement of bgp administrative shutdown
* Added message to RFC 8203 peer notification about BGP instance
  shutdown.
* Added informational log message to instance shutdown enable/disable
  functions.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-17 11:45:02 +02:00
Quentin Young
e121d83163 bgpd: fix bad heap reads in type-2 nlri parsing
Various forms of corrupt packets could trigger reads of garbage heap.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-08-15 08:24:59 -07:00
David Schweizer
e03f1f184f
bgpd: peer restart after shutdown fix.
* Peers are now automatically restarted by the reconnect timer instead
  of a ManualStart event after lifting the administrative shutdown.
* Question of when to log what remains.
* Compiles and works as intended now.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-14 13:27:07 +02:00
David Schweizer
cb9196e77a
bgpd: bgp instance administrative shutdown.
* Fixed integration in FSM and packet handling.
* Added CLI "show" output, incl. JSON.
* For review and testing only.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-14 10:23:34 +02:00
David Schweizer
bfb602e2ff
bgpd: removal of double statement.
This fix removes an unnecessary second occurrence of a statement.

Signed-off-by: David Schweizer <david.schweizer@davischw.ch>
2020-08-14 06:50:40 +02:00
David Schweizer
9cf5943257
bgpd: bgp instance administrative shutdown.
* Changes allow administratively shutting down all peers of a BGP
  instance.
* New CLI commands "[no] bgp shutdown" in vty shell.
* For review and testing only.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-13 17:52:49 +02:00
Donatas Abraitis
599f7b330d bgpd: Dump attributes before returning from bgp_attr_malformed()
This would be handy for situations when a notification was sent, but it's
absolutely not clear who triggered that.

Just in case dumping all attributes under the debug mode would help finding
the _bad_ attribute.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-08-13 18:42:31 +03:00
Donatas Abraitis
40bb2ccffa bgpd: Reuse bgp_adj_in for attr to avoid null dereference under aspath
Passing "&attr" to "bgp_input_filter", which dereferences null "attr.aspath".

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-08-12 07:00:07 +03:00
Russ White
c6dc339540
Merge pull request #6801 from ton31337/feature/force_maximum-prefix_for_filtered_routes
bgpd: Add a knob to force maximum-prefix even for filtered routes
2020-08-11 11:52:05 -04:00
Donatas Abraitis
84a98cedfb
Merge pull request #6877 from opensourcerouting/misc-docstring-fix
bgpd,lib: add missing doc strings
2020-08-09 21:49:03 +03:00
Lou Berger
d90c483c90 bgpd: suppress new libyang_1.0 related loss reports
Signed-off-by: Lou Berger <lberger@labn.net>
2020-08-08 17:56:18 -04:00
Rafael Zalamena
28673973b7 bgpd: fix missing doc string in evpn
Add the missing EVPN doc string in the show command.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-07 14:32:58 -03:00
Donald Sharp
cd211e2049
Merge pull request #6875 from opensourcerouting/bgpd-fsm-legacy-cleanup
bgpd: fsm legacy thread reset cleanup
2020-08-07 12:44:48 -04:00
Donatas Abraitis
940bb755fc
Merge pull request #6872 from vincentbernat/fix/bgp4mib-vrf
bgpd: implement bgpPeerTable accross VRFs
2020-08-07 18:04:47 +03:00
David Schweizer
392721e8b9
bgpd: fsm legacy thread reset cleanup
* Removed old timer thread resets, since this has been taken care of
  after execution of the threads by the thread_fetch function in
  lib/thread.c for quite some time now.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-08-07 14:03:48 +02:00
Vincent Bernat
5544311562 bgpd: implement bgpPeerTable accross VRFs
Currently, bgpPeerTable only looks the default BGP instance. Most
vendors return all the available peers in this table. This commit
exposes all BGP instances.

The other tables are unchanged as it doesn't make sense to expose
routes from random VRFs into a single table. Vendors are using SNMP
contexts for that but we don't have support for it. Therefore, do
nothing.

Fix #6077

Signed-off-by: Vincent Bernat <vincent@bernat.ch>
2020-08-06 18:04:44 +02:00
Anuradha Karuppiah
2ff12693b1 bgpd, lib: move EVPN route type def to lib and use it in the prefix macros
Use route names instead of route type number in the EVPN prefix
macros.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
9e0c2fd182 bgpd, zebra: remove strcpy, strlen and sprintf calls
Replace with safe copy functions - strlcpy, strlcat, strnlen and
snprintf.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
5e4d4c8aa4 bgpd: local path changes to display the SYNC info
Sample output -
root@torm-11:mgmt:~# net show bgp l2vpn evpn route vni 1000 mac 00:00:00:00:00:11
BGP routing table entry for [2]:[0]:[48]:[00:00:00:00:00:11]
Paths: (5 available, best #5)
  Not advertised to any peer
  Route [2]:[0]:[48]:[00:00:00:00:00:11] VNI 1000
  Imported from 27.0.0.16:14:[2]:[0]:[48]:[00:00:00:00:00:11], VNI 1000
  4435 5551
    27.0.0.16 from spine-2(swp4) (27.0.0.14)
      ESI 03:00:00:00:00:01:11:00:00:01 local-es
      Origin IGP, valid, external
      Extended Community: RT:5551:1000 RT:5551:4001 ET:8 Rmac:00:02:00:00:00:2d
      Last update: Fri Mar 27 02:26:35 2020

>>>>>>>>>>>>>>>>>>>> SNIP >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

  Route [2]:[0]:[48]:[00:00:00:00:00:11] VNI 1000/4001
  Local
    27.0.0.15 from 0.0.0.0 (27.0.0.15)
      ESI 03:00:00:00:00:01:11:00:00:01 local-es peer-info: (active MM: 0) >>>
      Origin IGP, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (EVPN local ES path)
      Extended Community: ET:8 RT:5550:1000 RT:5550:4001 Rmac:00:02:00:00:00:25
      Last update: Fri Mar 27 02:26:35 2020

Displayed 5 paths for requested prefix
root@torm-11:mgmt:~#

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
9c7edc03b8 bgpd: Type-2/MAC-IP SYNC route handling
SYNC routes are paths rxed from a local-ES peer. These routes result in
the installation of local dataplane entries i.e. with access port as
destination (vs. the remote-VTEP destination that results in the packet
being sent via the VxLAN overlay).

If a SYNC path is selected as the best path it is always turned around
into a local path which immediately lowers the status of the SYNC path
to non-best. However we need to keep track of the highest MM seq-number
and peer activity to continue advertising the local path. In order to
do that we need information from the "second-best" SYNC path to be
bubbled up to the local best path. This "SYNC" info is then consolidated
and sent to zebra which is responsible for the MM handling and local
path management.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
d071f23715 bgpd: evpn path selection changes for MAC-IP SYNC route handling
When a SYNC route i.e. a route with a local ES as destination is
rxed on a switch (say L11) from an ES peer (say L12) a local
MAC/neigh entry is created on L11 with the local access port
as dest port.

Creation of the local entry triggers a local path advertisement from
L11. This could be a "locally-active" path or a "locally-inactive"
path. Inactive paths are advertised with the proxy bit.

To ensure that the local entry is not deleted by a SYNC route it is
given absolute precedence over peer-paths.

If there are two non-local paths with the same dest ES and same MM
seq number the non-proxy path is preferred. This is done to ensure
that we don't lose track of the peer-activity.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
7904e9fdfa bgpd: extended-community and attrs for MAC-IP SYNC route handling
A new proxy flag has been added to the already existing NA extended
community to allow proxy advertisment of a local host by a VTEP that is
yet to indpendently establish local reachability.
Reference: draft-rbickhart-evpn-ip-mac-proxy-adv

The extendend mac-mobility sequence number needs to be synced across
the ES peers. However we cannot let a ES-peer path win over a local
path on the same ES. To accomplish that some parameters such as the
MM seq number are bubbled up from the non-best path to the local path.
This mechanism is explained further in the path-selection patch.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Donald Sharp
e75e57491b lib, bgpd: Remove unused variable from structure
The `struct evpn_ead_addr` structure had a prefix length
associated with it.  This value was only ever set never
used.  Remove this from our system.  The other
nice thing about this change is that it puts back
the sizeof struct route_node to 192 bytes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
b5e140c85c bgpd: CLI changes for EAD routes and ES/ES-EVI display
1. Sample ES display
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
torm-11# sh bgp l2vpn evpn es
ES Flags: L local, R remote, I inconsistent
VTEP Flags: E ESR/Type-4, A active nexthop
ESI                            Flags RD                    #VNIs    VTEPs
03:00:00:00:00:01:11:00:00:01  LR    27.0.0.15:15          10       27.0.0.16(EA)
03:00:00:00:00:01:22:00:00:02  LR    27.0.0.15:16          10       27.0.0.16(EA)
03:00:00:00:00:01:22:00:00:03  LR    27.0.0.15:17          10       27.0.0.16(EA)
03:00:00:00:00:02:11:00:00:01  R     -                     10       27.0.0.17(A),27.0.0.18(A)
03:00:00:00:00:02:22:00:00:02  R     -                     10       27.0.0.17(A),27.0.0.18(A)
03:00:00:00:00:02:22:00:00:03  R     -                     10       27.0.0.17(A),27.0.0.18(A)
torm-11#

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

2. Sample ES-EVI display
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
torm-11# sh bgp l2vpn evpn es-evi
Flags: L local, R remote, I inconsistent
VTEP-Flags: E EAD-per-ES, V EAD-per-EVI
VNI      ESI                            Flags VTEPs
1005     03:00:00:00:00:01:11:00:00:01  LR    27.0.0.16(EV)
1005     03:00:00:00:00:01:22:00:00:02  LR    27.0.0.16(EV)
1005     03:00:00:00:00:01:22:00:00:03  LR    27.0.0.16(EV)
1005     03:00:00:00:00:02:11:00:00:01  R     27.0.0.17(EV),27.0.0.18(EV)
1005     03:00:00:00:00:02:22:00:00:02  R     27.0.0.17(EV),27.0.0.18(EV)
1005     03:00:00:00:00:02:22:00:00:03  R     27.0.0.17(EV),27.0.0.18(EV)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

3. Sample EAD route display
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
torm-11# sh bgp l2vpn evpn route type ead
BGP table version is 19, local router ID is 27.0.0.15
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
EVPN type-1 prefix: [4]:[ESI]:[EthTag]:[IPlen]:[VTEP-IP]
EVPN type-2 prefix: [2]:[EthTag]:[MAClen]:[MAC]:[IPlen]:[IP]
EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:[OrigIP]
EVPN type-4 prefix: [4]:[ESI]:[IPlen]:[OrigIP]
EVPN type-5 prefix: [5]:[EthTag]:[IPlen]:[IP]

   Network          Next Hop            Metric LocPrf Weight Path
                    Extended Community
Route Distinguisher: 27.0.0.15:5
*> [1]:[0]:[03:00:00:00:00:01:11:00:00:01]:[128]:[0.0.0.0]
                    27.0.0.15                          32768 i
                    ET:8 RT:5550:1009
*> [1]:[0]:[03:00:00:00:00:01:22:00:00:02]:[128]:[0.0.0.0]
                    27.0.0.15                          32768 i
                    ET:8 RT:5550:1009
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
c44ab6f1f3 bgpd: support for Ethernet Segments and Type-1/EAD routes
This is the base patch that brings in support for Type-1 routes.
It includes support for -
- Ethernet Segment (ES) management
- EAD route handling
- MAC-IP (Type-2) routes with a non-zero ESI i.e. Aliasing for
  active-active multihoming
- Initial infra for consistency checking. Consistency checking
  is a fundamental feature for active-active solutions like MLAG.
  We will try to levarage the info in the EAD-ES/EAD-EVI routes to
  detect inconsitencies in access config across VTEPs attached to
  the same Ethernet Segment.

Functionality Overview -
========================
1. Ethernet segments are created in zebra and associated with
access VLANs. zebra sends that info as ES and ES-EVI objects to BGP.
2. BGP advertises EAD-ES and EAD-EVI routes for the locally attached
ethernet segments.
3. Similarly BGP processes EAD-ES and EAD-EVI routes from peers
and translates them into ES-VTEP objects which are then sent to zebra
as remote ESs.
4. Each ES in zebra is associated with a list of active VTEPs which
is then translated into a L2-NHG (nexthop group). This is the ES
"Alias" entry
5. MAC-IP routes with a non-zero ESI use the alias entry created in
(4.) to forward traffic i.e. a MAC-ECMP is done to these remote-ES
destinations.

EAD route management (route table and key) -
============================================
1. Local EAD-ES routes
a. route-table: per-ES route-table
key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP)
b. route-table: per-VNI route-table
Not added
c. route-table: global route-table
key: {RD=ES-RD, ESI, ET=0xffffffff)

2. Remote EAD-ES routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP)
c. route-table: global route-table
key: {RD=ES-RD, ESI, ET=0xffffffff)

3. Local EAD-EVI routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=0, ESI, ET=0, VTEP-IP)
c. route-table: global route-table
key: {RD=L2-VNI-RD, ESI, ET=0)

4. Remote EAD-EVI routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=0, ESI, ET=0, VTEP-IP)
c. route-table: global route-table
key: {RD=L2-VNI-RD, ESI, ET=0)

Please refer to bgp_evpn_mh.h for info on how the data-structures are
organized.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
0a50c24813 bgpd: attr changes for EAD routes
Add ESI as an inline attribute field along with the other EVPN
attributes. This may be re-worked when the rest of the EVPN
attributes find a new home.

Some cleanup has been done to get rid of stale/unused references
to ESI. And also to consolidate duplicate definitions of ES ID
types.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
4248407b6d bgpd: extended community for EAD routes
1. EAD routes require support for ESI_LABEL extended community. The
primary info in this EC is a flags the specifies if the ES is
Single-active or active-acive.
2. Also fixed up ES_IMPORT_RT string. Support was added a long time
ago for ESR/Type-4 routes but it has not really been exercised for
MH functionality till now.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
17f8343cad bgpd: new memory types for MH
Objects needed for Ethernet Segment management

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
526533981b bgpd: debug flags for MH
Filters for MH debug logs

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
185fb14a41 bgpd: pull the multihoming code out to a separate file
Re-org only; no other code changes. This is being done to make maintanence
of MH functionality (which will have more code added to it) easy.

The code moved here was originally committed via -
'commit 50f74cf131 ("*: support for evpn type-4 route")'

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Pat Ruddy
bd23c84036 evpn-netns: Revert PR5077, has been re-worked post-refactor
Revert "zebra: support for macvlan interfaces"

This reverts commit bf69e212fd.

Revert "doc: add some documentation about bgp evpn netns support"

This reverts commit 89b97c33d7.

Revert "zebra: dynamically detect vxlan link interfaces in other netns"

This reverts commit de0ebb2540.

Revert "bgpd: sanity check when updating nexthop from bgp to zebra"

This reverts commit ee9633ed87.

Revert "lib, zebra: reuse and adapt ns_list walk functionality"

This reverts commit c4d466c830.

Revert "zebra: local mac entries populated in correct netnamespace"

This reverts commit 4042454891.

Revert "zebra: when parsing local entry against dad, retrieve config"

This reverts commit 3acc394bc5.

Revert "bgpd: evpn nexthop can be changed by default"

This reverts commit a2342a2412.

Revert "zebra: zvni_map_to_vlan() adaptation for all namespaces"

This reverts commit db81d18647.

Revert "zebra: add ns_id attribute to mac structure"

This reverts commit 388d5b438e.

Revert "zebra: bridge layer2 information records ns_id where bridge is"

This reverts commit b5b453a2d6.

Revert "zebra, lib: new API to get absolute netns val from relative netns val"

This reverts commit b6ebab34f6.

Revert "zebra, lib: store relative default ns id in each namespace"

This reverts commit 9d3555e06c.

Revert "zebra, lib: add an internal API to get relative default nsid in other ns"

This reverts commit 97c9e7533b.

Revert "zebra: map vxlan interface to bridge interface with correct ns id"

This reverts commit 7c990878f2.

Revert "zebra: fdb and neighbor table are read for all zns"

This reverts commit f8ed2c5420.

Revert "zebra: zvni_map_to_svi() adaptation for other network namespaces"

This reverts commit 2a9dccb647.

Revert "zebra: display interface slave type"

This reverts commit fc3141393a.

Revert "zebra: zvni_from_svi() adaptation for other network namespaces"

This reverts commit 6fe516bd4b.

Revert "zebra: importation of bgp evpn rt5 from vni with other netns"

This reverts commit 28254125d0.

Revert "lib, zebra: update interface name at netlink creation"

This reverts commit 1f7a68a2ff.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-08-05 06:46:12 -07:00
Rafael Zalamena
70335e0a8c doc: improve neighbor shutdown
Add more neighbor shutdown documentation and reference the RFC.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-04 18:47:54 -03:00
Kaushik
92d6f76988 lib,zebra,bgpd: Fix for nexthop as IPv4 mapped IPv6 address
Added a macro to validate the v4 mapped v6 address.
Modified bgp receive & send updates for v4 mapped v6 address as
nexthop and installing it as recursive nexthop in RIB.
Minor change in fpm while sending the routes for nexthop as
v4 mapped v6 address.

Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-08-03 23:24:04 -07:00
Donald Sharp
f20ce998fb bgpd: Add bestpath-routes to neighbor command
Add the ability to list the bestpath-routes to the
`show bgp afi safi neighbor X` command.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-03 10:34:14 -04:00
Donald Sharp
2f9bc755fd bgpd: Abstract the header inclusion for show_adj_route
Cut-n-paste code can go away.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-03 10:34:14 -04:00
Donald Sharp
7e3d96323b bgpd: Add to neighbor prefix-counts the count of best path selected
When we have a prefix that has been selected, note that that
particular flag has been set and give that information to the
end user.

eva# show bgp ipv4 uni neighbors 192.168.161.131 prefix-counts
Prefix counts for 192.168.161.131, IPv4 Unicast
PfxCt: 814246

Counts from RIB table walk:

              Adj-in: 0
              Damped: 0
             Removed: 0
             History: 0
               Stale: 0
               Valid: 814246
             All RIB: 814246
       PfxCt counted: 814246
 PfxCt Best Selected: 0
             Useable: 814246
eva# show bgp ipv4 uni neighbors 192.168.161.2 prefix-counts
Prefix counts for 192.168.161.2, IPv4 Unicast
PfxCt: 814070

Counts from RIB table walk:

              Adj-in: 0
              Damped: 0
             Removed: 0
             History: 0
               Stale: 0
               Valid: 814070
             All RIB: 814070
       PfxCt counted: 814070
 PfxCt Best Selected: 814070
             Useable: 814070

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-07-31 10:06:39 -04:00
Quentin Young
25ee44b522
Merge pull request #6732 from opensourcerouting/printfrr-prep
*: preparations for printfrr coccinelle run
2020-07-29 14:29:34 -04:00
Russ White
4f08132ae9
Merge pull request #6808 from ton31337/fix/dampening_reuse_limit_assert
bgpd: Bypass SA tests regarding division by zero for reuse_limit in dampening
2020-07-28 06:20:29 -04:00
Rafael Zalamena
5a1ac9688f
Merge pull request #6805 from ton31337/fix/dead_code
bgpd: Remove peer_afc_set()
2020-07-27 18:35:20 -03:00
Donatas Abraitis
3ec5c50019 bgpd: Bypass SA tests regarding division by zero for reuse_limit in dampening
reuse_limit can't be zero basically, Coverity just does not know how the
value comes in.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-27 20:38:42 +03:00
Donatas Abraitis
dfbd3ae378 bgpd: Remove peer_afc_set()
Dead code.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-27 17:16:32 +03:00
Donald Sharp
5f140efeef bgpd: Deref after null check in bgp_evpn_vty.c
Coverity has noticed that we are using bgp_evpn after
we have already NULL checked it one time.  Add an assert
to make Coverity happy here, if we get to this point
something terrible has happened.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-07-27 07:10:41 -04:00
Donald Sharp
7b3a380531 bgpd: Prevent Null pointer usage
Coverity rightly points out that bgp_table_top might return
NULL and immediately deref'ing it might be a problem.
Add a bit of safety.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-07-27 06:59:45 -04:00
Donald Sharp
3130e28686 bgpd: Comment out dead code for future
I wanted to preserve the old code flow to see what might
be needed in the future in commit:
23ca3269da

Coverity doesn't like dead code.  So let's comment it out.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-07-27 06:54:23 -04:00
Donatas Abraitis
9cbd06e0f8 bgpd: Add a knob to force maximum-prefix even for filtered routes
If _force_ is set, then ALL prefixes are counted for maximum instead of
accepted only. This is useful for cases where an inbound filter is applied,
but you want maximum-prefix to act on ALL (including filtered) prefixes.

For instance, we have a configuration like:

neighbor r1 maximum-prefix 10
neighbor r1 prefix-list custom in
!
ip prefix-list custom seq 1 permit 10.0.0.0/24
ip prefix-list custom seq 2 permit 10.0.1.0/24

This will accept only 2 prefixes and discard all others instead of
shutting down the session when 10 is reached.

With this new knob (force), we will count all received prefixes and shutdown
the session when 10 is reached.

The bigger problem is when you have lots of peers with full feed and such a
configuration like in an example.

This is kinda re-ordering of how to treat filter vs. maximum-prefix.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-26 23:16:37 +03:00
Quentin Young
7d1d2517ea
Merge pull request #6796 from russellb/bgp-debug-newline
bgpd: Add missing newline to a log message
2020-07-24 19:09:36 -04:00
Russell Bryant
81bf7425ba bgpd: Add missing newline to a log message
While checking my BGP debugging settings at the console, I noticed
this message was missing a newline.  Add it to be consistent with the
other similar messages.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
2020-07-24 08:20:26 -04:00
Donatas Abraitis
d2b4eeb1fb
Merge pull request #6793 from maduri111/bgpd-wide
bgpd: wide option
2020-07-24 08:42:26 +03:00
Quentin Young
bd6cec43c3
Merge pull request #6243 from pguibert6WIND/flowspec_some_regression_seen
Flowspec some regression seen
2020-07-23 11:26:00 -04:00
Madhuri Kuruganti
ae2488324e bgpd: wide option
Signed-off-by: Madhuri Kuruganti <k.madhuri@samsung.com>
2020-07-23 19:18:11 +05:30
Quentin Young
65b86778c1
Merge pull request #6711 from GalaxyGorilla/bfd_isis_profiles
Add BFD profiles for IS-IS
2020-07-21 14:45:31 -04:00
David Lamparter
eae0446618
Merge pull request #6745 from ton31337/fix/handle_bgp_vrf_all_statistics_crash 2020-07-21 08:01:22 +02:00
Philippe Guibert
026b0e3b6f bgpd: flowspec pbr entries list display fix
the pbr entries list was not terminated with a carriage return and a
parenthesis.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-17 17:07:18 +02:00
Donald Sharp
7cc27d418f bgpd: Remove memset from bgp_zebra_announce
During perf testing of receiving and installing 7.5 million
routes into zebra it was noticed that memset in bgp_zebra_announce
was taking ~11% of the runtime.  With this change bgp_zebra_announce
now no longer has any appreciable time spent in memset as reported
by perf.  In addition bgp_zebra_announce run time in perf was
reduced by a composite amount.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-07-17 10:07:17 -04:00
Donatas Abraitis
deee0dd830
Merge pull request #6519 from RichardWu-Hebut/master
bgpd: Fix the bug that BGP MRAI does not work.
2020-07-16 16:49:08 +03:00
Donatas Abraitis
5290ceab0c bgpd: Show the instance name when displaying statistics
```
exit1-debian-9# sh ip bgp vrf all statistics json
{
  "ipv4Unicast":[
    {
      "instance":"VRF default",
      "totalAdvertisements":2,
      "totalPrefixes":2,
      "averagePrefixLength":24,
      "unaggregateablePrefixes":2,
      "maximumAggregateablePrefixes":0,
      "bgpAggregateAdvertisements":0,
      "addressSpaceAdvertised":512,
      "%announced":1.1920928955078125e-05,
      "\/8equivalent":3.0517578125e-05,
      "\/24equivalent":2,
      "advertisementsWithPaths":2,
      "longestAsPath":0,
      "averageAsPathLengthHops":0,
      "largestAsPath":0,
      "averageAsPathSizeBytes":0,
      "highestPublicAsn":0
    },
    {
      "instance":"VRF testas",
      "totalAdvertisements":0,
      "totalPrefixes":0,
      "averagePrefixLength":0,
      "unaggregateablePrefixes":0,
      "maximumAggregateablePrefixes":0,
      "bgpAggregateAdvertisements":0,
      "addressSpaceAdvertised":0,
      "%announced":0,
      "\/8equivalent":0,
      "\/24equivalent":0,
      "advertisementsWithPaths":0,
      "longestAsPath":0,
      "averageAsPathLengthHops":0,
      "largestAsPath":0,
      "averageAsPathSizeBytes":0,
      "highestPublicAsn":0
    }
  ]
}
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-15 21:36:32 +03:00
Donatas Abraitis
71f1613a3f bgpd: Do not crash if bgp argument is NULL for bgp_table_stats()
```
(gdb) bt
0  0x00007f45a6f0a781 in raise () from /lib/x86_64-linux-gnu/libc.so.6
1  0x00007f45a6ef455b in abort () from /lib/x86_64-linux-gnu/libc.so.6
2  0x00007f45a7781920 in core_handler (signo=11, siginfo=0x7fffac7b84b0, context=<optimized out>) at lib/sigevent.c:228
3  <signal handler called>
4  0x000055a4133c0f32 in bgp_table_stats (vty=vty@entry=0x55a415acb240, bgp=0x0, afi=AFI_IP, safi=SAFI_UNICAST, json_array=json_array@entry=0x0) at bgpd/bgp_route.c:11412
5  0x000055a4133c13fb in show_ip_bgp_afi_safi_statistics (self=<optimized out>, vty=0x55a415acb240, argc=6, argv=<optimized out>) at bgpd/bgp_route.c:10749
6  0x00007f45a773917d in cmd_execute_command_real (vline=vline@entry=0x55a415ab7e10, vty=vty@entry=0x55a415acb240, cmd=cmd@entry=0x0, filter=FILTER_RELAXED)
    at lib/command.c:909
7  0x00007f45a773afdf in cmd_execute_command (vline=vline@entry=0x55a415ab7e10, vty=vty@entry=0x55a415acb240, cmd=0x0, vtysh=vtysh@entry=0) at lib/command.c:968
8  0x00007f45a773b135 in cmd_execute (vty=vty@entry=0x55a415acb240, cmd=cmd@entry=0x55a415ace950 "show ip bgp vrf all statistics", matched=matched@entry=0x0,
    vtysh=vtysh@entry=0) at lib/command.c:1122
9  0x00007f45a7794d62 in vty_command (vty=vty@entry=0x55a415acb240, buf=0x55a415ace950 "show ip bgp vrf all statistics") at lib/vty.c:526
10 0x00007f45a7794fb6 in vty_execute (vty=vty@entry=0x55a415acb240) at lib/vty.c:1293
11 0x00007f45a7797804 in vtysh_read (thread=<optimized out>) at lib/vty.c:2126
12 0x00007f45a778f641 in thread_call (thread=thread@entry=0x7fffac7bb040) at lib/thread.c:1550
13 0x00007f45a775b6d8 in frr_run (master=0x55a415542820) at lib/libfrr.c:1098
14 0x000055a4133815d6 in main (argc=10, argv=0x7fffac7bb2a8) at bgpd/bgp_main.c:509
```

"show ip bgp vrf all statistics" should show statistics for all VRFs if "all"
is specified.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-15 21:36:27 +03:00
Quentin Young
1d4cfa5de1 Revert "Rpki Encapsulation"
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-07-14 15:38:20 -04:00
Quentin Young
1f30402b92
Merge pull request #5015 from pguibert6WIND/rpki_vrf_encapsulation
Rpki Encapsulation
2020-07-14 11:52:47 -04:00
David Lamparter
1b78780b69 bgpd: pre-fix coccinelle hang points
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 11:27:41 +02:00
David Lamparter
6cde4b4552 *: remove PRI[udx](8|16|32)
These are completely pointless and break coccinelle string replacements.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --pri8-16-32 `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:43:40 +02:00
Naveen Thanikachalam
77b34214ea bgpd: GR fixes
1) When a session comes up for a peer and if the peer has not adverised
   the GR capabilities, BGP sends a request to Zebra to clear any
   stale routes that might exist from that peer.
2) When OPEN message is received from the peer, clear the previously
   advertised GR capability by the peer, if the lastest received
   OPEN message does not contain the GR capability.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-07-14 01:39:39 -07:00
David Lamparter
3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

  .. [#tool_style_conflicts] For example, lines over 80 characters are allowed
     for text strings to make it possible to search the code for them: please
     see `Linux kernel style (breaking long lines and strings)
     <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_
     and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00
Donatas Abraitis
939a97f485 bgpd: Add "hostname" in JSON output for show bgp family outputs
This adds hostname regardless if `bgp default show-hostname` enabled or not.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-13 16:35:30 +03:00
Donatas Abraitis
aef999a28f bgpd: Show the real next-hop address in addition to hostname in show bgp
It's hard to cope with cases when next-hop is changed/unchanged or
peers are non-direct.

It would be better to show the hostname and nexthop IP address (both)
under `show bgp` to quickly identify the source and the real next-hop
of the route.

If `bgp default show-nexthop-hostname` is toggled the output looks like:
```
spine1-debian-9# show bgp
BGP table version is 1, local router ID is 2.2.2.2, vrf id 0
Default local pref 100, local AS 65002
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
*  2a02:4780::/64   fe80::a00:27ff:fe09:f8a3(exit1-debian-9)
                                             0             0 65001 ?

spine1-debian-9# show ip bgp
BGP table version is 5, local router ID is 2.2.2.2, vrf id 0
Default local pref 100, local AS 65002
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
*> 10.255.255.0/24  192.168.0.1(exit1-debian-9)
                                             0             0 65001 ?
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-13 16:35:29 +03:00
GalaxyGorilla
4affdba79e *: add BFD profile support for IS-IS
BFD profiles can now be used on the interface level like this:

	interface eth1
	  ip router isis 1
          isis bfd
          isis bfd profile default

Here the 'default' profile needs to be specified as usual in the
bfdd configuration.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2020-07-10 11:28:43 +00:00
Donatas Abraitis
10b49f1450 bgpd: Add command to show only established sessions
```
exit1-debian-9# show bgp summary

IPv4 Unicast Summary:
BGP router identifier 192.168.0.1, local AS number 100 vrf-id 0
BGP table version 8
RIB entries 15, using 2880 bytes of memory
Peers 2, using 43 KiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
192.168.0.2     4        200        10         6        0    0    0 00:00:35            8        8
2a02:4780::2    4          0         0         1        0    0    0    never       Active        0

Total number of neighbors 2
exit1-debian-9# show bgp summary established

IPv4 Unicast Summary:
BGP router identifier 192.168.0.1, local AS number 100 vrf-id 0
BGP table version 8
RIB entries 15, using 2880 bytes of memory
Peers 2, using 43 KiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
192.168.0.2     4        200        10         6        0    0    0 00:00:39            8        8

Total number of neighbors 2
exit1-debian-9# show bgp summary failed

IPv4 Unicast Summary:
BGP router identifier 192.168.0.1, local AS number 100 vrf-id 0
BGP table version 8
RIB entries 15, using 2880 bytes of memory
Peers 2, using 43 KiB of memory

Neighbor        EstdCnt DropCnt ResetTime Reason
2a02:4780::2          0       0     never Waiting for peer OPEN

Total number of neighbors 2
exit1-debian-9#
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-09 16:10:20 +03:00
Russ White
4267c07425
Merge pull request #6628 from adharkar/frr-master-evpn_rt
bgpd: Incorrect auto-RT formed when L3VNI is not configured
2020-07-05 16:07:10 -04:00
Donald Sharp
d0e2053724
Merge pull request #6669 from ton31337/fix/large-community-list-set_sequence
bgpd: Actually find the sequence number for large-community-list
2020-07-03 07:47:28 -04:00
Pat Ruddy
6f8c9c111e bgpd: detect change of RT for L3VPN routes
If the RT changes on a L3VPN route then any leak of this route into
a VRF should be withdrawn.
Extend existing EVPN check for RT change to cover L3VPN routes.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-07-02 21:22:48 +01:00
Donald Sharp
7799deeed6
Merge pull request #6437 from opensourcerouting/bfd-profiles-bgp
bfdd,bgpd: profiles integration support
2020-07-02 12:22:44 -04:00
Donald Sharp
681a198380
Merge pull request #6667 from ton31337/fix/bool_return_bgpd
bgpd: Return bool type for ecommunity_add_val and subgroup_announce_check
2020-07-02 09:32:09 -04:00
Donald Sharp
63aaee3629
Merge pull request #6590 from streambinder/master
bgpd: bmp: add support for L2VPN/EVPN routes
2020-07-02 07:56:08 -04:00
Donatas Abraitis
947073e397 bgpd: Actually find the sequence number for large-community-list
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-02 11:39:40 +03:00
Donatas Abraitis
e236900335 bgpd: Return bool type for ecommunity_add_val and subgroup_announce_check
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-02 11:08:29 +03:00
Philippe Guibert
76ddd87e88 bgpd: change rtr_is_ integer to bool format
bool format suits better for rtr_is_running and rtr_is_stopped values.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
9dcfdf2c4f bgpd: add vrf name on some logs from rpki
this extra trace will help to understand which rpki context is
triggered.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
0feaf64785 bgpd: validation of bgp routes with rpki done on according vrf
the validation of rpki routes will impact the matching bgp instance.
Until now, the rpki was triggering validation of all bgp entries.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
fd1be68353 bgpd: add hook for running-config per vrf rpki config
rpki config can be displayed in the 'show running-config'.
there is a fix to be done yet, this is related to the order of rpki per
vrf configuration. actually, the output is not saveable in the
running-config since the rpki commands are swapped. this prevents from
running rpki config at startup.
That commit also changes the identation, since rpki configure node was
with one extra space. reducing this, and add the changes for vrf
configuration too.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
4a42034fa8 bgpd: duplicate config commands into rpki-vrf subnode
rpki vrf subnode is instantiated under the vrf subnode.
It it to be noted that this commit contains a change in vtysh.
Actually, the output of bgp daemon from show running-config is extracted
in vtysh, and reengineered ( hence the vtysh_config.c change done). This
permits having a subnode under vrf sub node.
Also, add vrf node support to bgpd, as rpki command can not be found
under vrf node.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
2224b36a30 bgpd: rpki show commande equipped with vrfname parameter
it is possible to dump rpki commands per vrf context.
also, rpki start/stop commands are also appended with vrfname parameter.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
c06cad2bd6 bgpd: use rtrlib callback for socket creation
this commit change introduces a callback function pointer that rtrlib
calls. this permits to create the socket and initialising the socket
with the right information, in the right vrf. Adding to this, rpki uses
a hook to be triggered when a vrf is enabled/disabled. in this way,
start mechanisms will be triggered only when vrf is available, and stop
mechanism will be  done upon vrf disable event.
Adding to this, the cache structure contains a back pointer to the rpki
vrf structure. this is done to retrieve the vrf where the cache points
to.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
044307285b bgpd: add a hook to inform a vrf is enabled/disabled
this hook can be used by plugins like rpki.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
157f6f4861 bgpd: ability to remove rpki contexts from vty
rpki context can be removed by doing 'no rpki' command from configure
node. this work allows to allocate the associated rpki_vrf context when
entering in rpki node, instead of at the initialisation step.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
38bf60cb23 bgpd: suppress availability from rpki command under enable node
this command may conflict with the same command available under vrf
subnode.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
743453433f bgpd: encapsulate rpki attributes in a context
this work is a preparatory work so that rpki can have per-vrf contexts.
the work consists in allocating a rpki_vrf structure with all inside:
rtr_config, cache, etc..
This work is also necessary in the long term support with yang
northboundapi. Indeed, there may be highly possible that yang context
for rpki be defined per core instance.
That work also instantiates a list of rpki_vrf, though only one instance
is created.
That work also introduces a vrfname field attribute that is set to null
for now , and stands for default vrf where rpki is configured on.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
fed3793b6a bgpd: link rpki debug with bgp debugging hook
rpki debugging is linked with standard bgp debugging facilities.
- debug rpki is dumped in running-config if the command is executed from
configure terminal.
- show debugging indicated whether rpki debug is enabled or not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
aa31aef359 bgpd: add hooks for displaying debug information of a plugin
when a plugin is attached, some debugs may be attached to that plugin.
For that, add one hook that is interacting with vty: a boolean indicates
what the usage is for: either for impacting the 'show running-config',
or for impacting the 'show debugging' command.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
f3517f58f1 bgpd: running-config rpki indicates only non default values
the show running-config rpki was displaying systematically the default
values, when at least one cache server was configured. now, if the rpki
configuration has been changed, either because of a new cache server, or
because of a change in the default settings, then the associated
configuration is dumped in the 'show running-config' command.
adding to this, to permit user to dump the settings values, the command
'show rpki configuration' dumps the values whatever default or not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
416d0484c0 bgpd: missing rpki expire-interval in show running-config
a missing command expire-interval was not present in show
running-config.
append it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
f9dea02e96 bgpd: missing rpki retry-interval in show running-config
show running-config did not display rpki retry-interval. fixes this.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
b5b9dcae9c bgpd: avoid crash when calling show rpki-table
if ssh cache servers are configured, then show rpki-table is looking at
the tcp server context. Fix this by checking the server cache type, and
also display the ssh context if this is configured.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
bd32bb8058 bgpd: remove double spaces with rpki running config & ssh
remove double spaces when doing show running-config.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Philippe Guibert
7d177be5b0 bgpd: notify user that pub key file may be overriden
currently, private and public key files must differ with the suffix
keywork : '.pub'. If it is not the case, the pub key is ignored.
Inform user for that.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-07-02 08:17:51 +02:00
Donald Sharp
db45f64dd2 bgpd: peer_af_flag_modify_vty assumes 1 flag at a time
We have a bunch of code in bgp_vty.c that was passing
to peer_af_flag_modify_vty more than 1 flag at a time.
This was causing the underlying routines to get the
flags wrong.  In order to prevent this convert all the
places where we send multiple flags down to this function
to individual flag changes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-07-01 15:48:27 -04:00
streambinder
87102aa005 bgpd: bmp: add support for L2VPN/EVPN routes
Co-authored-by: giacomo270197 <gcasoni@hotmail.it>
Signed-off-by: streambinder <posta@davidepucci.it>
2020-06-30 14:37:00 +02:00
Philippe Guibert
39edabac97 bgpd: add maximum-paths vty command to ipv4 lu node
add maximum-paths vty command to ipv4 lu node.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-06-27 22:53:04 +02:00
Donald Sharp
0ce2d6ba13
Merge pull request #6630 from opensourcerouting/bgp-node-dest-rename
bgp: rename bgp_node to bgp_dest
2020-06-25 09:14:18 -04:00
Donald Sharp
23ca3269da bgpd: Have bgp ignore SIGHUP at the moment
SIGHUP is ostensibly supposed to reload configuration
from a fresh slate.  This is currently horribly broken
so much so that bgp just crashes.  I see no point
in trying to make this work considering the yang
work coming down the pike.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-06-24 20:15:12 -04:00
Richard Wu
b10b6d5272 bgpd: Fix the bug that BGP MRAI does not work.
Issue: bgp_process_writes will be called when the fd is writable.
       And it will bgp_generate_updgrp_packets to generate the
       update packets no matter MRAI is set or not.
Fix:   bgp_generate_updgrp_packets thread will return without sending
       any update when MRAI timer is still running.

Signed-off-by: Richard Wu <wutong23@baidu.com>
2020-06-24 16:30:12 +08:00
Donald Sharp
9bcb3eef54 bgp: rename bgp_node to bgp_dest
This is the bulk part extracted from "bgpd: Convert from `struct
bgp_node` to `struct bgp_dest`".  It should not result in any functional
change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-06-23 17:32:52 +02:00
Ameya Dharkar
ebdc9e64c3 bgpd: Incorrect auto-RT formed when L3VNI is not configured
We use ASN:VNI format to calculate auto RT for L3VNI.
When L3VNI is not configured, if we delete the configured RT, incorrect auto-RT
value is generated as VRF VNI is 0.

Fix:
Do not configure auto-RT if L3VNI is not configured.

Trigger:
1. Delete L3VNI
2. Delete configured RT.

Before fix:

dev# sh bgp vrf vrf-blue vni
BGP VRF: vrf-blue
  Local-Ip: 10.100.0.1
  L3-VNI: 0
  Rmac: 00:00:00:00:00:00
  VNI Filter: none
  L2-VNI List:

  Export-RTs:
  RT:101:0
  Import-RTs:
  RT:101:0
  RD: 10.100.0.1:2

After fix:

dev# sh bgp vrf vrf-blue vni
BGP VRF: vrf-blue
  Local-Ip: 10.100.0.1
  L3-VNI: 0
  Rmac: 00:00:00:00:00:00
  VNI Filter: none
  L2-VNI List:

  Export-RTs:

  Import-RTs:

  RD: 10.100.0.1:2

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2020-06-22 16:38:48 -07:00
Donatas Abraitis
b099a5c866 bgpd: Do not treat the route as martian for static BGP routes
If we have something like:
```
ip route 1.1.1.0/24 Null0
!
router bgp 100
 no bgp ebgp-requires-policy
 neighbor 192.168.0.2 remote-as 200
 !
 address-family ipv4 unicast
  network 1.1.1.0/24
  redistribute connected
 exit-address-family
!
line vty
!
```

1.1.1.0/24 is not advertised due to martian nexthop (0.0.0.0). It starts
working only when we use `redistribute static`.

By checking if it's a BGP static route we able to announce
1.1.1.0/24 with `network 1.1.1.0/24` without redistribute even when
`bgp import-check` is enabled.

Disabling `bgp import-check` works as well, but it's enabled by default
since 7.4.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-06-22 16:23:24 +03:00
Jafar Al-Gharaibeh
68f9d353ee
Merge pull request #6613 from donaldsharp/monotonic_mononity
bgpd: Use time since epoch for timestamps for bmp updates
2020-06-18 23:47:40 -05:00
Donald Sharp
02cee15823 bgpd: Use time since epoch for timestamps for bmp updates
RFC states that time should be in seconds since the epoch.
The code was using system uptime in seconds.

Fixes: #6549
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-06-18 15:56:44 -04:00
Rafael Zalamena
4aa283cd4e bgpd: attempt to fix test convergence failure
Don't reset BFD peer on BGP session establishment.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-18 16:51:13 -03:00
Philippe Guibert
9b222c1f1a
Merge pull request #6577 from rtrlib/2020-06-12-master-fixes
bgpd: rpki fixes (master)
2020-06-17 09:09:02 +02:00
Marcel Röthke
bac31cb885 bgpd: fix rpki revalidation for invalid announcements
Announcements that are marked as invalid were previously not revalidated.
This was fixed by replacing the range lookup with a subtree lookup.

Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
2020-06-15 18:22:37 +02:00
Donald Sharp
d0874d195d bgpd: Allow extending peer timeout in rare case
Currently the I/O pthread handles incoming/outgoing data
communication with all peers.  There is no attempt at modifying
the hold timers.  It's sole goal is to read/write data to appropriate
channels.  All this data is handled as *events* on the master pthread
in BGP.   The problem is that if the master pthread is extremely busy
then any packet read that would be treated as a keepalive event may
happen after the hold timer pops, due to the way thread events are handled
in lib/thread.c.

In a last gap attempt, if we notice that we have incoming data
to proceses on the input Queue, slightly delay the hold timer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-06-15 10:35:50 -04:00
Donatas Abraitis
3ddd699401 bgpd: Use constants for nexthop length instead of just numbers
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-06-13 20:36:59 +03:00
Marcel Röthke
a633498e0b bgpd: preinitialize rtrlib tr structures
The tr_*_config structs were previously not pre initialized because
every field is initialized explicitly. But future rtrlib version will
introduce additional fields. Preinitialising the entire struct will
ensure forward compatibility.

Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
2020-06-13 13:44:39 +02:00
Don Slice
1995cb77bf bgpd: remove extcommunity attribute on leaked route if empty
Problem reported where bgp sessions were being torn down for ibgp
peers with the reason being optional attribute error.  Found that
when a route was leaked, the RTs were stripped but the actual
EXTCOMMUNUNITY attribute was not cleared so an empty ecommunity
attribute stayed in the bgp table and was sent in updates.

Ticket: CM-30000
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2020-06-11 04:19:34 -07:00
Donald Sharp
5c83709171
Merge pull request #6550 from ton31337/fix/bgp_dampening_vty_bug
bgpd: Duplicate `bgp dampening ...` stuff
2020-06-10 08:12:01 -04:00
Donald Sharp
2d8c1bc235
Merge pull request #5323 from opensourcerouting/filter-nb
lib: migrate FRR filter to northbound
2020-06-10 06:59:32 -04:00
Donatas Abraitis
ef5f4b2373 bgpd: Allow setting dampening for more address families
Until now, it was possible to set only for ipv4 unicast/multicast.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-06-10 10:23:18 +03:00
Donatas Abraitis
8a4e7fe661 bgpd: Print dampening configuration per AF, not per neighbor
This caused duplicate `bgp dampening ...` to be printed per neighbor.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-06-10 10:23:16 +03:00
Quentin Young
90a6646c01
Merge pull request #6332 from kssoman/fix
bgpd: Avoid extra copy of received data to buffer
2020-06-09 13:09:19 -04:00
Russ White
e5f51bc579
Merge pull request #6536 from NaveenThanikachalam/gr
bgpd: Update GR flags when peer is bound to group
2020-06-09 07:40:27 -04:00
Naveen Thanikachalam
0c0b85b502 bgpd: Update GR flags when peer is bound to group
When a peer is bound to a peer-group, the GR flags set on the
peer are over-written.
Update the GR flags for the peer after it has been bound to a
peer-group.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-06-09 02:08:51 -07:00
Rafael Zalamena
c2aab69336 *: add filter northbound support
Allow all daemons to work with filter northbound.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:31:26 -03:00
Donald Sharp
409148f62a bgpd: Actually find the sequence number for bgp extcommunity-list...
The code in the bgp extcommunity-list function was using
argv_find to get the correct idx.  The problem was that
we had already done argv_finds before and idx was non-zero
thus having us always set the seq pointer to what was last
looked up.  This causes us to pass in a value to the
underlying function and it would just wisely ignore it
causing a seq number of 0.

We would then write this seq number of 0 and then immediately
reject it on read in again.  BOO!

Actually handle argv_find the way it was meant to be.

Ticket:CM-29926
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-06-04 13:25:11 -04:00
Rafael Zalamena
58a4278e92
Merge pull request #6503 from donaldsharp/bgp_routemap_crash
bgpd: Fix crash in `match ip next-hop address` command
2020-06-02 15:28:53 -03:00
Donald Sharp
17ac51eb01 bgpd: Fix crash in match ip next-hop address command
When issuing the command `match ip next-hop address`
bgp would crash.  This is because the no form of the
command was making the address optional and we would
try to read data we should not be.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-06-02 12:23:09 -04:00
Sri Mohana Singamsetty
089116f8e6
Merge pull request #6456 from ton31337/fix/set_ipv6_ll_if_zero
bgpd: Use IPv6 LL address as nexthop if global was set to ::/LL
2020-06-02 09:08:05 -07:00
Chirag Shah
e67df34d25 bgpd: move advertise-vni-all above vni config
Move config 'advertise-vni-all' above all evpn
configuration as vni specific confi commands
have check for advertise-vni-all enabled first.

Ticket: CM-29312
Reviewed By:
Testing Done:

router bgp 5650
...
advertise-all-vni
vni 1002
 route-target import 55500:10002
 route-target export 55500:10002
exit-vni
...

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-06-01 23:18:09 -07:00
Quentin Young
2f9db11bd8 bgpd: avoid spamming bgp_accept() on bad vrf sock
bgp_accept() gets called over and over again when a VRF device is
deleted out from under a bgp listener socket that is bound to it.
Prevent this by noting the error and cancelling ourselves, allowing the
vrf status code to clean up the mess when it receives word about the
change from Zebra.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-05-31 04:28:30 -04:00
Donatas Abraitis
e0281c9f2f
Merge pull request #6484 from kaloom/master
bgpd: Fix "malformed communities" for accept-own-nexthop
2020-05-31 10:33:57 +03:00
Donald Sharp
450696226d bgpd: Improve connection rejection messages
Try to give a bit more useful data about where we
think the connection is trying to come in from.
Hopefully this will let us debug connection issues
a bit faster in cases where there are config issues.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-30 15:44:54 -04:00
Soman K S
7c9d82cdd5 bgpd: Avoid extra copy of received data to buffer
When received packet is processed in bgp_process_reads(), the data
is copied to static buffer and then copied to stream buffer.
The data can be copied directly to stream buffer which will avoid extra memcpy

Signed-off-by: kssoman <somanks@gmail.com>
2020-05-30 13:53:45 +05:30
Rafael Zalamena
95a99382cb bgpd: fix crash on daemon exit
Don't attempt to send BFD daemon a message to remove the peer
registration on daemon exit, otherwise we'll access a dangling
interface pointer and we'll crash.

This crash was not previosly possible because the function that built
the message was passing the interface pointer but not using it due to
the exit condition.

In `lib/bfd.c`:

```
void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info,
		      int family, void *dst_ip, void *src_ip, char *if_name,
		      int ttl, int multihop, int cbit, int command,
		      int set_flag, vrf_id_t vrf_id)
{
	struct bfd_session_arg args = {};
	size_t addrlen;

	/* Individual reg/dereg messages are suppressed during shutdown. */
	if (CHECK_FLAG(bfd_gbl.flags, BFD_GBL_FLAG_IN_SHUTDOWN)) {
		if (bfd_debug)
			zlog_debug(
				"%s: Suppressing BFD peer reg/dereg messages",
				__func__);
		return;
	}
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-29 17:48:14 -03:00
Rafael Zalamena
68286f9619 bgpd: command to remove profile configuration
To remove a BFD profile without removing the BFD configuration just call
`neighbor <A.B.C.D|X:X::X:X|WORD> bfd`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-29 17:48:14 -03:00
Rafael Zalamena
02012befe8 bgpd: support BFD profiles configuration
Allow BGP to use the new API to configure BFD session profiles. Now it
is possible to preconfigure BFD sessions without needing to create the
peers.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-29 17:48:14 -03:00
Appu Joseph
68f36a94da bgpd: Fix "malformed communities" for accept-own-nexthop
"set community accept-own-nexthop" returns "malformed communities"
error. This is because the token matching hits an earlier "accept-own"
and leaves "-nexthop" as a separate token to be processed.
Reorder the switch cases so that both are processed correctly.

Signed-off-by: Appu Joseph <apjo@kaloom.com>
2020-05-29 14:36:07 -04:00
Donald Sharp
e2d409a88b bgpd: Use THREAD_CANCEL instead of thread_cancel
We are crashing in thread_cancel on shutdown because
the thread pointer is NULL.  Use the more appropriate
THREAD_CANCEL macro

Ticket: CM-29873
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-28 16:51:11 -04:00
Russ White
eeec40ba69
Merge pull request #6375 from adharkar/frr-master-l3vni_label
bgpd: EVPN RT-2 advertised with 2 labels for prefix-routes-only config
2020-05-26 12:14:16 -04:00
Sri Mohana Singamsetty
06fba5cb4c
Merge pull request #6463 from vivek-cumulus/evpn_extend_nht
bgpd: Extend EVPN next hop tracking for additional EVPN routes
2020-05-26 08:18:29 -07:00
Russ White
e3d230af81
Merge pull request #6458 from vivek-cumulus/bgp_nht_command_enhance
bgpd: Enhance BGP NHT show commands
2020-05-26 07:32:12 -04:00
vivek
e11329ca4c bgpd: Extend EVPN next hop tracking for additional EVPN routes
Extend the next hop tracking for type-2 and type-3 EVPN routes also.

Updates: "bgpd: Add nexthop of received EVPN RT-5 for nexthop tracking"
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-25 23:00:49 -07:00
vivek
0139efe084 bgpd: During NHT change evaluation, skip inappropriate paths
When there is a NHT change and the paths dependent on that NHT are being
evaluated, skip those that are marked for removal or as history.

When a route gets withdrawn, its valid flag is cleared and it is flagged
for removal; in the case of an EVPN route, it is also unimported from
VRFs (L2 and/or L3). bgp_process is then scheduled. Under rare timing
conditions, an NHT update for the route's next hop may arrive right after,
and if routes flagged for removal are not skipped, they may not only be
incorrectly marked as valid but also re-imported in the case of EVPN,
which will be a serious error.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-25 14:17:12 -07:00
vivek
34ea39b65a bgpd: Check NHT change for triggering EVPN import or unimport
Ensure that only if there is a change to the path's validity based
on the NHT update, EVPN import or unimport is invoked.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-25 14:15:37 -07:00
vivek
9e15d76adf bgpd: Enhance NHT path evaluation debugs
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-25 14:10:12 -07:00
vivek
5f0c5ec85d bgpd: Minor tweaks to EVPN route-import debugs
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-25 14:06:10 -07:00
vivek
5d76a53dfc bgpd: Enhance BGP NHT show commands
Display next hop resolution information, whether the "detail" option is
specified or not as it is quite fundamental and only minimally increases
the output.

Introduce option to look at a specific NHT entry, which will also show
the paths associated with that entry.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-25 13:57:53 -07:00
Donatas Abraitis
606fdbb1fa bgpd: Use IPv6 LL address as nexthop if global was set to ::/LL
This happens between Bird and FRR. Maybe others as well, dunno.

Bird sends ::(fe80::1588) and we have a nexthop as :: which is inaccessible:

```
BGP routing table entry for fdff:b87d:f5b0::/48
Paths: (1 available, no best path)
  Not advertised to any peer
  4242421588 4242422547 4242422601 4242423605
    :: (inaccessible) from fe80::1588 (172.20.16.140)
    (fe80::1588) (used)
      Origin IGP, invalid, external
      Last update: Mon May 25 14:27:02 2020
```

bgpd[9554]: fe80::1588 went from OpenConfirm to Established
bgpd[9554]: fe80::1588 [FSM] Timer (routeadv timer expire)
bgpd[9554]: fe80::1588 rcvd UPDATE w/ attr: , origin i, mp_nexthop ::(fe80::1588)
bgpd[9554]: fe80::1588 rcvd UPDATE wlen 0 attrlen 120 alen 0
bgpd[9554]: fe80::1588 rcvd fda9:26a9:1c47:2d42::/64 IPv6 unicast
bgpd[9554]: Allocated bnc ::/128(VRF default) peer 0x0
bgpd[9554]: bgp_update(0.0.0.0): NH unresolved
bgpd[9554]: fe80::1588 rcvd fda9:26a9:1c47:d42::/64 IPv6 unicast

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-05-25 17:37:10 +03:00
Donald Sharp
2fc593e95c
Merge pull request #6321 from ton31337/fix/configuration_for_labeled_in_place
bgpd: Make sure network/aggregate-address commands lay down under lab…
2020-05-21 07:58:11 -04:00
Mark Stapp
be7e1fa3c9 bgpd: remove duplicate cli command installation
Clean up a few lines of cli command installation; remove a
duplicate; follow the command grouping pattern better.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-05-20 08:25:49 -04:00
Donatas Abraitis
a6943f9dab
Merge pull request #5077 from pguibert6WIND/vxlan_link
BGP EVPN vrf netns backend
2020-05-19 09:12:38 +03:00
Philippe Guibert
ee9633ed87 bgpd: sanity check when updating nexthop from bgp to zebra
nexthop may sometimes not be passed through zebra, like for onlink
messages.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-18 14:11:03 +02:00
Philippe Guibert
a2342a2412 bgpd: evpn nexthop can be changed by default
There can be cases where evpn traffic is not meshed across various
endpoints, but sent to a central pe. For this situation, remove the
nexthop unchanged default behaviour for bgp evpn. Also add route
reflector commands to bgp evpn node.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-18 14:11:03 +02:00
vivek
9514b37def bgpd: Free non-best paths also during table cleanup
Non-best paths (path info structures) also need to be freed during
table cleanup not only to release their memory but to also ensure
any linkages are updated correctly. One such example is for EVPN
where there is a link between the imported path info (in a L2 or
L3 vrf instance) and its parent path info.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-15 14:32:38 -07:00
Sri Mohana Singamsetty
2465055e31
Merge pull request #6377 from ton31337/fix/bgpd_statistics
bgpd: Use default AFI_IP6/SAFI_UNICAST when displaying statistics
2020-05-14 10:00:07 -07:00
Sri Mohana Singamsetty
02b89bdca2
Merge pull request #6334 from ton31337/fix/labeled_unicast_table_scount
bgpd: Set a proper SAFI for labaled-unicast when looking for scount
2020-05-12 08:31:42 -07:00
Donald Sharp
0feba3716e bgpd: really remove the no ip as-path... command
We had already removed the `ip as-path..` command
to have `bgp as-path` but for some reason a `no ip as-path..`
command ALIAS was still around.  Kill with extreme prejudice.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-11 08:45:11 -04:00
Donatas Abraitis
ec76a1d174 bgpd: Use default AFI_IP6/SAFI_UNICAST when displaying statistics
Without specifying a default afi/safi we get a segfault:

```
(gdb) frame 4
bgp_table_stats (..., afi=32724, safi=SAFI_UNICAST, ...
11349		if (!bgp->rib[afi][safi]) {
(gdb)
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-05-09 21:33:51 +03:00
Ameya Dharkar
10f70510b9 bgpd: EVPN RT-2 advertised with 2 labels for prefix-routes-only config
L3VNI is configured with "prefix-routes-only" flag. Even in this case,
intermittently, we observed that local EVPN MACIP routes are installed and
advertised with 2 labels and 2 export RTs.

This is a sequencing issue. Consider following case where L2VNI 200 and L3VNI
1000 are configured for tenant vrf vrf-blue.

Bug is observed for following sequence of events:
1. vrf-blue BGP instance is created.
2. L2VNI is created in bgp for vni 200. It is linked to the tenant vrf vrf-blue
in function bgpevpn_link_to_l3vni.
Following code sets "VNI_FLAG_USE_TWO_LABELS" flag for vni 200 as L3VNI is not
yet attached to vrf-blue BGP instance.

/* check if we are advertising two labels for this vpn */
if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY))
	SET_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS);

2. Now L3VNI is attached to vrf-blue BGP instance. In this case, we set
BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY flag for vrf-blue but we do not clear
VNI_FLAG_USE_TWO_LABELS flag set on the corresponding L2VNIs.

This fix resolves following 2 issues observed above.
1. When L2VNI is created in BGP, flag VNI_FLAG_USE_TWO_LABELS should not be set
for this VNI if BGP vrf is not attached to any L3VNI.
2. When L3VNI is attached to the BGP vrf, set "VNI_FLAG_USE_TWO_LABELS" flag
if "prefix-routes-only" is not for the vrf.

UT cases:
1. Flap "prefix-routes-only" config for a vrf.
2. Test following triggers for vrfs with and without "prefix-routes-only"
   - Flap L2VNI from kernel.
   - Flap L3VNI from kernel.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2020-05-08 21:10:10 -07:00
Donald Sharp
ad36d216b1 bgpd: bgp bestpath bandwidth should not be a legal command
The `bgp bestpath bandwidth` command should not be a legal
command.  Pull out the `no` form to allow this.  Allow
`no bgp bestpath bandwidth` to work as we would expect.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-07 10:03:31 -04:00
Donatas Abraitis
cbfc39df11 bgpd: Ignore aggregator attribute if it's malformed (0.0.0.0)
This is not the attribute involved in path selection and by rfc7606 it should
be just ignored.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-05-06 12:55:55 +03:00
Donatas Abraitis
6ded3e181b bgpd: Use slightly modified version of error message if AS path contains 0
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-05-06 12:55:13 +03:00
Quentin Young
794c2b2d73
Merge pull request #6350 from pureport/fix/bgp_double_community_free
bgpd: Check to ensure community attributes exist before freeing them
2020-05-05 17:39:28 -04:00
Josh Cox
2c15754ea3 bgpd: Check to ensure community attributes exist before freeing them
Community attributes might have been removed by an inbound route map, so we
should check to ensure they still exist before trying to free them.
This fixes a segfault described in issue #6345.

Signed-off-by: Josh Cox <josh.cox@pureport.com>
2020-05-05 15:59:38 -04:00
Donatas Abraitis
d55811ccb2 bgpd: Set a proper SAFI for labaled-unicast when looking for scount
The problem is that peer_af_array returns NULL when SAFI is changed to
unicast. We use unicast table, but peer is created and activated under
labeled-unicast, hence we should lookup with a proper SAFI id.

Without this patch peer_af_find() returns NULL and we can't show
PfxSnt in `show bgp summary`.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-05-05 22:27:01 +03:00
Donatas Abraitis
d3ada36668 bgpd: Show "(Policy)" under PfxRcd/PfxSnt when eBGP policy is in use
It could be hard to notice when eBGP policy is missing in `show bgp summary`.

This adds more sugar to the output:

Normal:
```
 MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
      10        0    0    0 00:02:07            6        8
```
When rfc8212 is enabled (default since 7.4) - OUTBOUND:
```
 MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
      13        0    0    0 00:04:56            6 (Policy)
```
INBOUND:
```
 MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
      19        0    0    0 00:06:27     (Policy)        2
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-05-03 21:49:46 +03:00
Donald Sharp
68cecc3b69 bgpd: Ensure that we have a ifp pointer
It is possible that the if_lookup_by_index() call will return
a NULL value and calling zclient_send_interface_radv_req.  Just
test that we have a valid interface pointer.

Found by Coverity

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-30 11:16:28 -04:00
Donatas Abraitis
fb985e0c7e bgpd: Make sure network/aggregate-address commands lay down under labeled safi
unicast and labeled-unicast share the same table, but configuration should
be visible for both independently. Without this fix it confuses a bit
because when you enter `network 10.0.0.0/24` under labeled-unicast it's
written in unicast family block.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-30 17:01:10 +03:00
Russ White
37d6afef2a
Merge pull request #6303 from dslicenc/stop-enhe-ras
bgpd: turn off RAs when numbered peers are deleted
2020-04-29 11:09:58 -04:00
Donald Sharp
62282e8379 bgpd,tests: Modify import-check to require underlying prefixes to exist
Modify the import-check command to require the underlying prefix
to exist in the rib.  General consensus is that this is the correct
behavior.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-28 15:57:53 -04:00
Lou Berger
3b548ddc33
Merge pull request #6295 from ton31337/feature/show_bgp_afi_safi_sntpfx
bgpd: Show PfxSnt for `show bgp <afi> <safi>` command
2020-04-28 11:34:13 -04:00
David Lamparter
80833111f0 bgpd: fix typo
o.O

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-28 11:11:26 +02:00
Don Slice
b3a3290e23 bgpd: turn off RAs when numbered peers are deleted
Problem reported that in many circumstances, RAs created in the
process of bringing up numbered IPv6 peers with extended-nexthop
capability enabled (for ipv4 over ipv6) were not stopped on the
interface when those peers were deleted.  Found several circumstances
where this occurred and fix them in this patch.

Ticket: CM-26875
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2020-04-27 17:49:41 +00:00
David Lamparter
94cfb0692e build: make clippy Makefile rules nicer
These are easy to get subtly wrong, and doing so can cause
nondeterministic failures when racing in parallel builds.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:52:41 +02:00
David Lamparter
2768748b88 build: use VPATH for vtysh_scan
No need to put $(top_srcdir) everywhere.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:30:01 +02:00
Donatas Abraitis
db92d22638 bgpd: Show PfxSnt for show bgp <afi> <safi> command
JSON output was already in, just printing in CLI as well.

```
root@exit1-debian-9:~# vtysh -c 'show bgp ipv4 summary'

IPv4 Unicast Summary:
BGP router identifier 10.10.10.1, local AS number 65001 vrf-id 0
BGP table version 100003
RIB entries 200005, using 37 MiB of memory
Peers 1, using 21 KiB of memory

... MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
...      64       157        0    0    0 00:01:18            0   100003

Total number of neighbors 1
```

JSON:

```
root@exit1-debian-9:~# vtysh -c 'show bgp ipv4 summary json' \ |
> jq '.ipv4Unicast.peers."192.168.0.2".pfxSnt'
100003
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-24 15:35:19 +03:00
Donatas Abraitis
9da4aaa36d Revert "bgpd: Show PfxSnt for show bgp <afi> <safi> command"
This reverts commit 776e7cf5ce.
2020-04-24 10:00:13 +03:00
Sri Mohana Singamsetty
7a54a2caf7
Merge pull request #6277 from ton31337/feature/show_bgp_afi_safi_sndpfx
bgpd: Show PfxSnt for `show bgp <afi> <safi>` command
2020-04-23 20:20:07 -07:00
David Lamparter
c334a16ef1
Merge pull request #6262 from qlyoung/remove-sprintf 2020-04-23 20:27:26 +02:00
Stephen Worley
e17316e56b
Merge pull request #6184 from kssoman/route
bgpd: When static default route is present in RIB and advertised to p…
2020-04-23 11:10:59 -04:00
Donatas Abraitis
776e7cf5ce bgpd: Show PfxSnt for show bgp <afi> <safi> command
JSON output was already in, just printing in CLI as well.

```
root@exit1-debian-9:~# vtysh -c 'show bgp ipv4 summary'

IPv4 Unicast Summary:
BGP router identifier 10.10.10.1, local AS number 65001 vrf-id 0
BGP table version 100003
RIB entries 200005, using 37 MiB of memory
Peers 1, using 21 KiB of memory

... MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
...      64       157        0    0    0 00:01:18            0   100003

Total number of neighbors 1
```

JSON:

```
root@exit1-debian-9:~# vtysh -c 'show bgp ipv4 summary json' \ |
> jq '.ipv4Unicast.peers."192.168.0.2".pfxSnt'
100003
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-23 11:48:14 +03:00
Soman K S
f55c9a4653 bgpd: Configuring default-originate withdraws default route
Issue:
Configuring default-originate when static default route is previously
advertised results in withdrawal of the route.

Fix :
Delete the adj-out entry for the previously advertised static
default route without sending explicit withdraw message.

Signed-off-by: kssoman <somanks@gmail.com>
2020-04-22 22:34:12 +05:30
Quentin Young
86ac1facf3
Merge pull request #6242 from pguibert6WIND/flowspec_nlri_too_big
bgpd: handle fs nlri over 240 bytes
2020-04-22 13:02:50 -04:00
Philippe Guibert
3255e756a2 bgpd: handle fs nlri over 240 bytes
the nlri flowspec above 240 bytes size was not handled.
Over 240 bytes, the length is 2 bytes length, and a calculation must be
done to obtain the real length. This commit handles it appropriately.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-04-22 12:12:03 +02:00
Donatas Abraitis
4c60e50f7f
Merge pull request #6191 from NaveenThanikachalam/ibgp_connected
bgpd: Enforce self-next-hop check in next-hop update.
2020-04-21 23:16:03 +03:00
Quentin Young
4ced1a2cb3 bgpd, isis, tools: style fixen
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:15:35 -04:00
Quentin Young
2b7165e76f *: use appropriate buffer sizes, specifiers
- Fix 1 byte overflow when showing GR info in bgpd
- Use PATH_MAX for path buffers
- Use unsigned specifiers for uint16_t's in zebra pbr

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Quentin Young
fc746f1c01 *: manually remove some more sprintf
Take care of some more complicated cases by hand

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Quentin Young
772270f3b6 *: sprintf -> snprintf
Replace sprintf with snprintf where straightforward to do so.

- sprintf's into local scope buffers of known size are replaced with the
  equivalent snprintf call
- snprintf's into local scope buffers of known size that use the buffer
  size expression now use sizeof(buffer)
- sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp
  buffer followed by strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Donald Sharp
73f079b589
Merge pull request #6261 from ton31337/fix/allow_nhlen_32
bgpd: Do not discard an UPDATE if the global nexthop is set to ::
2020-04-20 16:10:07 -04:00
Donald Sharp
2d3d652178
Merge pull request #6251 from opensourcerouting/cs-ignore
*: make coverity scan ignore random() calls
2020-04-20 16:08:37 -04:00
Donatas Abraitis
0355b41d84 bgpd: Do not discard an UPDATE if the global nexthop is set to ::
When we receive an UPDATE with MP_NEXTHOP len as 32 bytes, we shouldn't
check if the global (1st) nexthop is unspecified.

Peering between bird and FRRouting we receive from Bird something like:
```
rcvd UPDATE w/ attr: , origin i, mp_nexthop ::(fe80::a00:27ff:fe09:f8a3)
```
The link-local (2nd) nexthop is valid and validated later in the code.

Before it was marked:
```
IPv6 unicast -- DENIED due to: martian or self next-hop;
```

After it's a valid prefix:
```
spine1-debian-9# show bgp
BGP table version is 0, local router ID is 2.2.2.2, vrf id 0
Default local pref 100, local AS 65002
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
   2a02:4780::/64   fe80::a00:27ff:fe09:f8a3
                                                           0 65001 i

Displayed  1 routes and 1 total paths
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-20 18:59:15 +03:00
Donatas Abraitis
7f972cd8dc bgpd: Use true/false for reject_as_sets
Just remove MACROS and use true/false.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-20 12:59:52 +03:00
Donald Sharp
8b1e4f30ba
Merge pull request #6164 from ton31337/feature/rfc8212_enabled_traditional_profile
bgpd: Enable rfc8212 by default except datacenter profile
2020-04-18 15:06:04 -04:00
Rafael Zalamena
5920b3eb38 *: replace all random() calls
Replace all `random()` calls with a function called `frr_weak_random()`
and make it clear that it is only supposed to be used for weak random
applications.

Use the annotation described by the Coverity Scan documentation to
ignore `random()` call warnings.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-17 20:57:43 -03:00
Sri Mohana Singamsetty
bece779c79
Merge pull request #6240 from ton31337/fix/null_bnc_bgp_show_hostname
bgpd: Add a sanitify check for bgp_nexthop_cache against NULL
2020-04-16 20:17:40 -07:00
Donald Sharp
a83014ccd6
Merge pull request #6247 from FRRouting/nb_conversions
Merge nb_converions branch to master
2020-04-16 19:39:14 -04:00
Donald Sharp
2ff99507ad
Merge pull request #6135 from opensourcerouting/cli-node-cleanup
*: clean up the mess that is CLI command nodes
2020-04-16 19:24:56 -04:00
Quentin Young
edf7eff077
Merge pull request #6239 from ton31337/fix/uint8_t_to_bool_for_any
bgpd, lib: Use bool instead of uint8_t for community/prefix-list "any"
2020-04-16 15:40:03 -04:00
Donatas Abraitis
45facd9c66
Merge pull request #5913 from taspelund/evpn_route_type_int
bgpd: Allow 'show bgp l2vpn evpn route type' to use RT number in addition to existing keywords
2020-04-16 22:28:19 +03:00
Chirag Shah
6fd8972aef *: include vrf northbound module in init
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:00:15 -07:00
Santosh P K
09133ff4f7
Merge pull request #5451 from opensourcerouting/rcu-log
logging subsystem rewrite
2020-04-16 20:23:44 +05:30
Donatas Abraitis
eb91f8d6d7 bgpd: Add a sanitify check for bgp_nexthop_cache against NULL
In real world sometimes happens that bgp_nexthop_cache is NULL. Avoid
segfaulting when using `show [ip] bgp ...` CLI commands.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-16 16:13:01 +03:00
Donatas Abraitis
d3f6c580a8 bgpd, lib: Use bool instead of uint8_t for community/prefix-list "any"
That's only 0/1, useful to use just a bool for that.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-16 15:27:51 +03:00
David Lamparter
791ded4a62 *: add ->node_exit to struct cmd_node
Rather than doing a f*gly hack for the RPKI code, let's do an on-exit
hook in cmd_node.  Also allows replacing some special-casing in the vty
code.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:54:03 +02:00
David Lamparter
f4b8291fcb *: move CLI node names to cmd_node->name
And again for the name.  Why on earth would we centralize this, just so
people can forget to update it?

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:59 +02:00
David Lamparter
243895805a *: move CLI parent data to cmd_node->parent_node
Same as before, instead of shoving this into a big central list we can
just put the parent node in cmd_node.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
612c2c15d8 *: remove second parameter on install_node()
There is really no reason to not put this in the cmd_node.

And while we're add it, rename from pointless ".func" to ".config_write".

[v2: fix forgotten ldpd config_write]

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
249a771b63 *: remove cmd_node->vtysh
The only nodes that have this as 0 don't have a "->func" anyway, so the
entire thing is really just pointless.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
62b346eefa *: clean up cmd_node initializers
... and use named assignments everywhere (so I can change the struct.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
Donatas Abraitis
2ba93fd65b bgpd: Show hostname in show [ip] bgp ... only if nexthop is connected
The problem is when using kinda such topologies:
(192.168.1.1/32) r1 <-- eBGP --> r2 <-- iBGP --> r3

Looking at r3's nexthop for 192.168.1.1/32 we have it as r2, but really
it MUST be r1.

Checking if the nexthop is connected solves the problem even for cases
when route-reflectors are used.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-16 10:36:59 +03:00
Donatas Abraitis
bc2c9ae68c bgpd: Validate all large communities if specified more per line
```
(config)# bgp large-community-list standard FRR-1 permit 1:1:1:1
% Malformed community-list value
(config)# bgp large-community-list standard FRR-1 permit 1:1:1 1:2
% Malformed community-list value
(config)# bgp large-community-list standard FRR-1 permit 1:1:1 1:2 3:3:2
% Malformed community-list value
(config)# bgp large-community-list standard FRR-1 permit 1:1:1 1:2 3:3:2 0:0:0
% Malformed community-list value
(config)# bgp large-community-list standard FRR-1 permit 0:0:1231321231414
% Malformed community-list value
(config)# bgp large-community-list standard FRR-1 permit 1:1:1 1:2:3 3:3:2 0:0:
% Malformed community-list value
(config)# bgp large-community-list standard FRR-1 permit 1:1:1 1:2:3 3:3:2 0:2:3
(config)# bgp large-community-list standard FRR-1 permit 1:1:1 1:2:3 3:3:2
(config)#
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-15 18:21:24 +03:00
Trey Aspelund
8937a1e613 bgpd: Add int args to show bgp evpn route type
This adds numeric keywords to 'show bgp l2vpn evpn route type'.

Signed-off-by: Trey Aspelund <taspelund@cumulusnetworks.com>
2020-04-14 20:36:12 -04:00
Trey Aspelund
f2562d3ac1 bgpd: Fix typos in show bgp evpn route type
This fixes unnecessary whitespaces and makes capitalization
match for route type help strings.

Signed-off-by: Trey Aspelund <taspelund@cumulusnetworks.com>
2020-04-14 19:06:01 -04:00
Donald Sharp
b9ba7ed533
Merge pull request #5812 from pguibert6WIND/bgp_stats_all
Bgp stats all
2020-04-14 14:36:21 -04:00
Donatas Abraitis
1d3fdccfe1 bgpd: Enable rfc8212 by default except datacenter profile
Some competitive vendors like Cisco, Bird, OpenBGPD,
Nokia already have this by default enabled.

The list is here: https://github.com/bgp/RFC8212

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-14 16:01:46 +03:00
Donatas Abraitis
2dbe3fa97b bgpd: Replace 0 to false for bool assignment in bgp_update_martian_nexthop()
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-13 20:39:31 +03:00
Mark Stapp
f9dfa64797
Merge pull request #6209 from donaldsharp/true_false
bgpd: bools use `true/false` not `TRUE/FALSE`
2020-04-13 12:17:19 -04:00
Donald Sharp
cded3b7232 bgpd: bools use true/false not TRUE/FALSE
Who knows where these values were coming from.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-13 08:08:48 -04:00
Naveen Thanikachalam
e7cbe5e599 bgpd: Force self-next-hop check in next-hop update.
Problem Description:
=====================
+--+                                            +--+
|R1|-(192.201.202.1)----iBGP----(192.201.202.2)-|R2|
+--+                                            +--+

Routes on R2:
=============
S>* 202.202.202.202/32 [1/0] via 192.201.78.1, ens256, 00:40:48
Where, the next-hop network, 192.201.78.0/24, is a directly connected network address.
C>* 192.201.78.0/24 is directly connected, ens256, 00:40:48

Configurations on R1:
=====================
!
router bgp 201
 bgp router-id 192.168.0.1
 neighbor 192.201.202.2 remote-as 201
!

Configurations on R2:
=====================
!
ip route 202.202.202.202/32 192.201.78.1
!
router bgp 201
 bgp router-id 192.168.0.2
 neighbor 192.201.202.1 remote-as 201
 !
 address-family ipv4 unicast
  redistribute static
 exit-address-family
!

Step-1:
=======
R1 receives the route 202.202.202.202/32 from R2.
R1 installs the route in its BGP RIB.

Step-2:
=======
On R1, a connected interface address is added.
The address is the same as the next-hop of the BGP route received from R2 (192.201.78.1).

Point of Failure:
=================
R1 resolves the BGP route even though the route's next-hop is its own connected address.
Even though this appears to be a misconfiguration it would still be better to safeguard the code against it.

Fix:
====
When BGP receives a connected route from Zebra, it processes the
routes for the next-hop update.
While doing so, BGP must ignore routes whose next-hop address matches
the address of the connected route for which Zebra sent the next-hop update
message.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-04-11 07:26:33 -07:00
Quentin Young
293d5cb3c0
Merge pull request #6176 from NaveenThanikachalam/memleaks
bgpd: Fixes for memory leaks.
2020-04-10 13:55:52 -04:00
Naveen Thanikachalam
74a630b606 bgpd: Fixes for memory leaks.
This commit addresses the memory leaks when certain BGP JSON
show commands are executed

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-04-08 20:27:49 -07:00
vivek
3b0c17e1d4 bgpd: Trigger EVPN type-5 injection upon link-bandwidth change
Ensure that upon a link-bandwidth change - for e.g., due to change in
the number of multipaths - EVPN type-5 route injection is triggered.
In the absence of this, the proper link-bandwidth is not updated in
EVPN type-5 routes originated by the router.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-04-08 19:12:09 -07:00
vivek
87b42e3b22 bgpd: Fix overflow in bandwidth calc
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-04-08 19:12:00 -07:00
David Lamparter
2ee1e4b1ba
Merge pull request #6175 from ton31337/fix/avoid_same_type_typecasting
*: Do not cast to the same type
2020-04-08 22:44:53 +02:00
Donatas Abraitis
11400e739e bgpd: Use COMMUNITY_SIZE instead of just 4
Easier to maintain and read.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-08 18:09:25 +03:00
Donatas Abraitis
c4efd0f423 *: Do not cast to the same type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-08 17:15:06 +03:00
Philippe Guibert
9ab0cf5830 bgpd: take into account code style recommendations.
take into account polychaeta tips ono code style.
also, take into account miscellaneous code style recommandations like
braces usage.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-04-08 08:56:52 +02:00
Renato Westphal
c446af503e
Merge pull request #6180 from mjstapp/fix_bgp_ecomm_sa
bgpd: clean up SA warning in bgp_ecommunity.c
2020-04-07 23:00:06 -03:00
Mark Stapp
83ac8d129a bgpd: clean up SA warning in bgp_ecommunity.c
Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-07 12:56:43 -04:00
Russ White
a6c322ab18
Merge pull request #6173 from ton31337/fix/treat-as-withdraw_community
bgpd: Treat-as-withdraw if [el]community length is zero
2020-04-07 11:42:01 -04:00
Donatas Abraitis
6680b5508c bgpd: Treat-as-withdraw if [el]community length is zero
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-07 10:08:16 +03:00
Donatas Abraitis
7611871dfc
Merge pull request #6167 from qlyoung/fix-cluster-list-uaf
bgpd: treat 0-length cluster_list as withdraw
2020-04-07 09:47:28 +03:00
Quentin Young
33ba22c248 bgpd: treat 0-length cluster_list as withdraw
See source comment...

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-06 12:30:35 -04:00
David Lamparter
f728a3bb99
Merge pull request #6158 from qlyoung/fix-cluster-list-uaf
bgpd: fix multiple bugs with cluster_list attrs
2020-04-06 17:38:27 +02:00
David Lamparter
e53181264a
Merge pull request #6155 from qlyoung/fix-unsigned-cmp-lt-zero
bgpd, zebra: don't compare unsigned < 0
2020-04-06 17:37:11 +02:00
Quentin Young
628565c73d bgpd: fix multiple bugs with cluster_list attrs
Multiple different issues causing mostly UAFs but maybe other more
subtle things.

- Cluster lists were the only attributes whose pointers were not being
  NULL'd when freed, resulting in heap UAF
- When performing an insert into the cluster hash, our temporary struct
  used for hash_get() was inconsistent with our hash keying and
  comparison functions. In the case of a zero length cluster list, the
  ->length field is 0 and the ->list field is NULL. When performing an
  insert, we set the ->list field regardless of whether the length is 0.
  This resulted in the two cluster lists hashing equal but not comparing
  equal. Later, when removing one of them from the hash before freeing
  it, because the key matched and the comparison succeeded (because it
  was set to NULL *after* the search but *before* inserting into the
  hash) we would sometimes release the duplicated copy of the struct,
  and then free the one that remained in the hash table. Later accesses
  constitute UAF. This is fixed by making sure the fields used for the
  existence check match what is actually inserted into the hash when
  that check fails.

This patch also makes cluster_unintern static, because it should be.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-05 20:55:02 -04:00
Sri Mohana Singamsetty
70ecc066e7
Merge pull request #6105 from vivek-cumulus/bgp_link_bandwidth_unequal_cost_multipath
Unequal cost multipath (a.ka. weighted ECMP) with BGP link-bandwidth
2020-04-05 11:41:42 -07:00
Sri Mohana Singamsetty
2ebae25d08
Merge pull request #6143 from ton31337/fix/remove_prefixReceivedCount
bgpd: Remove `prefixReceivedCount` from JSON
2020-04-05 11:41:04 -07:00
Quentin Young
f22ed884c1 bgpd: fix memcmp(null, *) when parsing bgp attrs
My first patch for this only fixed the memcmp(NULL, NULL) case.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-05 01:02:42 -04:00
Quentin Young
1e03d6bc76 bgpd, zebra: don't compare unsigned < 0
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-04 23:26:19 -04:00
David Lamparter
cd05906c41
Merge pull request #6071 from ton31337/feature/rfc6286
bgpd: Add support for Autonomous-System-Wide Unique BGP Identifier
2020-04-03 15:16:59 +02:00
Donatas Abraitis
6f5dc2e508 bgpd: Remove prefixReceivedCount from JSON
This is already covered by pfxRcd. Removed due to consistency
between CLI and JSON.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-03 16:16:06 +03:00
Sri Mohana Singamsetty
dba3453515
Merge pull request #6130 from ton31337/fix/remove_some_redundant_attributes_from_json
bgpd: Remove deprecated JSON fields for `show bgp ... json`
2020-04-02 16:17:24 -07:00
David Lamparter
4c1458b595 bgpd, ospfd, ospf6d: long is not bool :(
... Oops ...

(for context, the defaults code originally didn't have a dedicated
"bool" variant and just used long for bools...  I derp'd this when
adding bool as a separate case :( )

Reported-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-02 21:16:04 +02:00
Quentin Young
49e5a4a0b8 bgpd: #if ENABLE_BGP_VNC -> #ifdef ENABLE_BGP_VNC
This macro is undefined if vnc is disabled, and while it defaults to 0,
this is still wrong and causes issues with -Werror

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-01 15:05:26 -04:00
Donatas Abraitis
0fbac0b478 bgpd: Remove deprecated JSON fields for show bgp ... json
med --------> metric
localPref --> locPrf
aspath -----> path

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-01 17:02:30 +03:00
David Lamparter
149e0bafd6 lib/log: add valgrind suppression for zlog
These bits of memory are intentionally kept alive at exit so logging
still works.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-01 06:53:26 +02:00
David Lamparter
0bdeb5e58d lib: rewrite zlog lock-free & TLS-buffered
This is a full rewrite of the "back end" logging code.  It now uses a
lock-free list to iterate over logging targets, and the targets
themselves are as lock-free as possible.  (syslog() may have a hidden
internal mutex in the C library;  the file/fd targets use a single
write() call which should ensure atomicity kernel-side.)

Note that some functionality is lost in this patch:
- Solaris printstack() backtraces are ditched (unlikely to come back)
- the `log-filter` machinery is gone (re-added in followup commit)
- `terminal monitor` is temporarily stubbed out.  The old code had a
  race condition with VTYs going away.  It'll likely come back rewritten
  and with vtysh support.
- The `zebra_ext_log` hook is gone.  Instead, it's now much easier to
  add a "proper" logging target.

v2: TLS buffer to get some actual performance

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-01 06:53:26 +02:00
Donatas Abraitis
036937f042 bgpd: Correct two comments typos for bgp_collision_detect()
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-31 17:54:40 +03:00
Donatas Abraitis
787c30209f bgpd: Add support for Autonomous-System-Wide Unique BGP Identifier
Implement https://tools.ietf.org/html/rfc6286

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-31 17:14:56 +03:00
David Lamparter
83b27fdaab
Merge pull request #6093 from LabNConsulting/working/lb/no-birds
*: use the current project name (FRRouting)
2020-03-31 15:10:17 +02:00
Philippe Guibert
1471864374 bgpd: add show bgp l2vpn evpn statistics [json] support
add show bgp l2vpn evpn statistics [json] support.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-31 14:38:15 +02:00
Philippe Guibert
6c9d22e223 bgpd: review the hierarchy for bgp statistics in json format
- each statistics is encapsulated into concatenated "<afi><safi>" value.
- the json encoding for floating and double values is using json api
double api. this change is done for bgp statistics.
- the lines over 80 characters have been handled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-31 14:38:15 +02:00
Philippe Guibert
4265b26111 bgpd: new vty command to dump all bgp per vrf statistics
this command is a shortcut to facilitate the extraction of statistics
for all afi/safi related to one bgp instance.
the command is: show bgp [vrf XX] statistics-all [json]

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-31 14:38:15 +02:00
Philippe Guibert
b9f4d96f23 bgpd: permit to get statistics for other bgp safis
safis that use a route distinguisher in bgp tables, and as such
introduce a two level hierarchy on the bgp table, must be made available
to statistics too.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-31 14:38:15 +02:00
Philippe Guibert
893cccd057 bgpd: add json support for show bgp statistics command
add json support for show bgp statistics command.
The title of the stats entry is aggregated without spaces.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-31 14:38:15 +02:00
vivek
feca4f1e67 bgpd: Ensure RMAC extended community is unique
The BGP Router MAC extended community should be unique and not occur
multiple times. In a VRF-to-VRF route-leak scenario where EVPN routes
from a source VRF are leaked into the target VRF and then injected
back into EVPN from the target VRF, the resulting route had more than
one RMAC. With this fix, the resulting route will have only the
target VRF's RMAC.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:32 -07:00
vivek
fab92da7ca bgpd: Allow generating EVPN type-5 routes with existing extended community
The EVPN advertise route-map may generate extended communities for an IPv4
or IPv6 route injected into EVPN as type-5. If so, allow for it and add
to it.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-30 20:12:32 -07:00
vivek
4c13ffe471 bgpd: Add support for non-transitive link-bandwidth
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:32 -07:00
vivek
f7e1c681f4 bgpd: Implement options for link bandwidth handling
Support configurable options to control how link bandwidth is handled
by the receiver. The default behavior is to automatically honor the
link bandwidths received and use it to perform a weighted ECMP BUT only
if all paths in the multipath have associated link bandwidth; if one or
more paths do not have link bandwidth, normal ECMP is performed among
the multipaths. This behavior is as recommended by
https://tools.ietf.org/html/draft-ietf-idr-link-bandwidth.

The additional options available are to (a) completely ignore any link
bandwidth (i.e., weighted ECMP is effectively disabled), (b) skip paths
in the multipath which do not have link bandwidth and perform weighted
ECMP among the other paths (if at least some paths have the bandwidth)
or (c) use a default weight (value chosen is 1) for the paths which
do not have link bandwidth.

The command syntax is
bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
7b651a321e bgpd: Announce cumulative link bandwidth to EBGP peers
When announcing ourselves as the next hop (e.g., to EBGP peers), if the
best path has the link bandwidth extended community and it is transitive,
change the value of the link bandwidth to the cumulative downstream
bandwidth (sum of the link bandwidths of all our multipaths) as this
makes the most sense. It is also implied by
https://tools.ietf.org/html/draft-mohanty-bess-ebgp-dmz. Of course, do
not override the link bandwidth if it has been specified by policy.

Note: Transitive extended communities will be automatically passed along
to EBGP peers; this commit is updating the value that is announced to
something that is the most appropriate.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
b1875e656c bgpd: Additional options for generating link bandwidth
Implement the code to handle the other route-map options to generate
the link bandwidth, namely, to use the cumulative bandwidth or to
base this on the number of multipaths. In the latter case, a reference
bandwidth is internally chosen - the implementation uses a value of
1 Gbps.

These additional options mean that the prefix may need to be advertised
if there is a link bandwidth change, which is a new criteria. Define a
new path (change) flag to support this and implement the advertisement.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
f6ca545a21 bgpd: Ensure link bandwidth extcommunity is not repeated
The BGP link bandwidth extended community must not be repeated. If the
attribute already carries this and the route-map specifies a new value,
the implementation will honor the policy configuration and overwrite
the existing values.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
1207a5bc9b bgpd: Ability to add/update unique extended communities
Certain extended communities cannot be repeated. An example is the
BGP link bandwidth extended community. Enhance the extended community
add function to ensure uniqueness, if requested.

Note: This commit does not change the lack of uniqueness for any of
the already-supported extended communities. Many of them such as the
BGP route target can obviously be present multiple times. Others like
the Router's MAC should most probably be present only once. The portions
of the code which add these may already be structured such that duplicates
do not arise.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
4e30bc2bfe bgpd: Install multipath routes with weights
Perform weighted ECMP if the multipaths have link bandwidth. This involves
assigning weights to each of the next hops associated with the prefix based
on the link bandwidth of the corresponding path as a factor of the total
(cumulative) link bandwidth for the prefix. The weight values used are
between 1 and 100. Weights are assigned only if all paths in the multipath
have link bandwidth, otherwise any bandwidths are ignored and regular
ECMP is performed. This is as recommended in
https://tools.ietf.org/html/draft-ietf-idr-link-bandwidth

A subsequent commit will implement additional (user-configurable) behaviors.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
42d436cf01 bgpd: Track link bandwidth during multipath calc
During multipath update, track the cumulative link bandwidth
as well as update flags appropriately.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
50346a989f bgpd: Add link-bandwidth fields for multipath calc
Introduce fields in the multipath structure for link bandwidth handling.
In the process, the mp_count field is changed to a uint16 as that is the
value set anyway.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
d901dc13cb bgpd: Check and extract link bandwidth value
Extract link bandwidth value into attribute from the extended
community, if present.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
7e3ebfd107 bgpd: Display link bandwidth extended community
Additional extended community definitions and display of link-bandwidth
extended community.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
ca9ac3effc bgpd: Add link bandwidth route-map commands
Implement route-map option to set the link-bandwidth extended
community. The command is of the form:

set extcommunity bandwidth <(1-26214400)|cumulative|num-multipaths>
[non-transitive]

The options available are to specify the actual bandwidth value in
Mbps, base it on the cumulative downstream bandwidth or base it on
the number of multipaths. The last option is based on
https://tools.ietf.org/html/draft-mohanty-bess-ebgp-dmz. Further,
in alignment with the use case described in this IETF draft, the
extended community is encoded as transitive by default. There is an
option available to specify that it should be non-transitive.

The link-bandwidth itself is carried in bytes per second as specifed in
https://tools.ietf.org/html/draft-ietf-idr-link-bandwidth

Note: This commit only handles the processing for bandwidth specifed
as a value; subsequent commits will handle the processing of the other
options.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00