Commit Graph

4560 Commits

Author SHA1 Message Date
Donald Sharp
1664b41119 Revert "bgpd: allow bestpath to handle mutliple locally-originated paths"
This reverts commit 82a843fa3d.
2020-10-06 10:43:09 -04:00
Donald Sharp
82a843fa3d bgpd: allow bestpath to handle mutliple locally-originated paths
Current code in bgp bestpath selection would accept the newest
locally originated path as the best path.  Making the selection
non-deterministic.  Modify the code to always come to the
same bestpath conclusion when you have multiple locally originated
paths in bestpath selection.

Before:

eva# conf
eva(config)# router bgp 323
eva(config-router)# address-family ipv4 uni
eva(config-router-af)# redistribute connected
eva(config-router-af)# network 192.168.161.0/24
eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0
BGP routing table entry for 192.168.161.0/24
Paths: (2 available, best #1, table default)
  Not advertised to any peer
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (Origin)
      Last update: Wed Sep 16 15:03:03 2020
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin incomplete, metric 0, weight 32768, valid, sourced
      Last update: Wed Sep 16 15:02:52 2020
eva(config-router-af)# no redistribute connected
eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0
BGP routing table entry for 192.168.161.0/24
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (First path received)
      Last update: Wed Sep 16 15:03:03 2020
eva(config-router-af)#  redistribute connected
eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0
BGP routing table entry for 192.168.161.0/24
Paths: (2 available, best #2, table default)
  Not advertised to any peer
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin incomplete, metric 0, weight 32768, valid, sourced
      Last update: Wed Sep 16 15:03:32 2020
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (Origin)
      Last update: Wed Sep 16 15:03:03 2020
eva(config-router-af)#

Notice the route choosen depends on order received

Fixed behavior:

eva# conf
eva(config)# router bgp 323
eva(config-router)# address-family ipv4 uni
eva(config-router-af)# redistribute connected
eva(config-router-af)# network 192.168.161.0/24
eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0
BGP routing table entry for 192.168.161.0/24
Paths: (2 available, best #1, table default)
  Not advertised to any peer
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (Origin)
      Last update: Wed Sep 16 15:03:03 2020
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin incomplete, metric 0, weight 32768, valid, sourced
      Last update: Wed Sep 16 15:02:52 2020
eva(config-router-af)# no redistribute connected
eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0
BGP routing table entry for 192.168.161.0/24
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (First path received)
      Last update: Wed Sep 16 15:03:03 2020
eva(config-router-af)#  redistribute connected
eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0
BGP routing table entry for 192.168.161.0/24
Paths: (2 available, best #2, table default)
  Not advertised to any peer
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin incomplete, metric 0, weight 32768, valid, sourced
      Last update: Wed Sep 16 15:03:32 2020
  Local
    0.0.0.0(eva) from 0.0.0.0 (192.168.161.245)
      Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (Origin)
      Last update: Wed Sep 16 15:03:03 2020
eva(config-router-af)#

Ticket: CM-31490
Found-by: Trey Aspelund <taspelund@nvidia.com>
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-06 10:34:32 -04:00
Mark Stapp
082de39e71 bgpd: fix SA warnings in bgp northbound
Fix a couple of new SA warnings in the new bgp northbound.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-06 08:18:59 -04:00
Rafael Zalamena
6aabb15dd7 bgpd: aggregate address matching-MED-only
Add code to handle MED matching:

- When MED matches act as normal.

- When MED doesn't match do the following:

  * Uninstall the aggregate route
  * Unsuppress routes (if using summary-only)

- When MED didn't match, but now matches:

  * Install the aggregate route
  * Suppress all routes (if using summary-only)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-10-06 06:42:12 -03:00
Rafael Zalamena
554b3b1021 bgpd: simplify aggregate address commands
Use `DEFPY` instead of `DEFUN` to remove duplicated code.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-10-04 21:34:36 -03:00
Chirag Shah
4b63e358bc bgpd: no router bgp check candidate config
For `no router bgp` without ASN check candidate
config for default bgp instance presence to avoid
failure from checking backend db where bgp instance
may not be created.
This situation can be seen in transactional cli mode
with following config.

bharat(config)# router bgp 101
bharat(config-router)# exit
bharat(config)# no router bgp
% No BGP process is configured
bharat(config)# no router bgp
% No BGP process is configured
bharat(config)#

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:38 -07:00
Chirag Shah
5e42cb2fb0 bgpd: move router bgp nb callback
move `router bgp` nb callback at `bgp` node level
to have access to bgp context at neighbor and peer-group
level and align create/destroy callbacks call during
no router bgp.

Earlier `no router bgp` is performed first global destroy
callback is called which essentially removes `bgp context`
then it calls to remove (parallel nodes) neighbor and peer-group
which does not have access to bgp context.
Moving router bgp at bgp solves this destroy callback ordering issue.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:38 -07:00
Chirag Shah
87ce25646b bgpd: correct bgp global context
Move bgp (router bgp) context at "bgp" node
level from (instead of) "global" level.
This change allows access of bgp context at neighbor
and peer-group node levels.

    +--rw bgp   <--- (store `struct bgp` at bgp node xpath)
       +--rw global!
       |    ...
       |  +--rw afi-safis
       |    ...
       +--rw neighbors
       |  +--rw neighbor* [remote-address]
       |    ...
       |  |  +--rw afi-safis
       |    ...
       |  +--rw unnumbered-neighbor* [interface]
       |    ...
       +--rw peer-groups
          +--rw peer-group* [peer-group-name]
            ...

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:38 -07:00
Chirag Shah
906ebeec98 bgpd: shorten northbound callback names
Omit routing protocol augment name from callbacks name.

(Omitted: routing_control_plane_protocols_control_plane_protocol_)

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:38 -07:00
Chirag Shah
374069da83 bgpd: register nb routing hook
On bgpd bootstrap register routing hook which ensures
only single bgp named instance created per vrf routing
hierarchy.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Chirag Shah
ff8a8a7ac1 bgpd: convert global config to transactional cli
Convert global congigurations clis to transactional
clis using northbound plugin callbacks.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Chirag Shah
e4a464160d bgpd: register northbound callbacks to bootstrap
Register bgpd northbound callbacks to bgp daemon
bootstrap.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Chirag Shah
a1950c80a5 bgpd: bgp northbound callbacks prototypes
This commit contains splitting of auto-generated bgp northbound callbacks
into separate files.
Include the files into bgp makefile.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Chirag Shah
bc8c00cca1 *: add bgp yang files into makefiles
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Igor Ryzhov
d7b86ae4fe vtysh: dynamically generate the list of daemons for commands
Some daemons were actually missing from the static definitions: nhrpd,
babeld, eigrpd and bfdd.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-02 15:06:27 +03:00
Quentin Young
6c83ddedcf *: make failure to decode nht update an error
This should never happen; no need to debug guard it and it's not a
warning, if this isn't working then NHT is not working at all.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-30 18:37:15 -04:00
Donald Sharp
e587774b74
Merge pull request #7039 from opensourcerouting/bgp-norib-runtime
bgpd: set/unset no-rib option at runtime
2020-09-29 13:42:02 -04:00
Donatas Abraitis
557a306434
Merge pull request #7178 from taspelund/bgp_timers
bgpd: Use bgp instance's default keepalive interval if < (holdtime/3)
2020-09-28 09:44:21 +03:00
Donatas Abraitis
6b1ffbdb0d
Merge pull request #7182 from donaldsharp/bgp_static_32s
bgpd: Allow bgp static routes to use /32's
2020-09-26 20:07:49 +03:00
Donatas Abraitis
f969a2d613
Merge pull request #7171 from dslicenc/bgp-rid-update
bgpd: allow derived router-id update if previously 0x0
2020-09-26 19:58:00 +03:00
Donald Sharp
e8442016a8 bgpd: Allow bgp static routes to use /32's
If you are including a network statement of a /32
then the current bgp martian checks will match the /32
together.

Problem:
!
router bgp 3235
 neighbor 192.168.161.2 remote-as external
 neighbor 192.168.161.131 remote-as external
 !
 address-family ipv4 unicast
  network 10.10.3.11/32
  network 192.168.161.0/24
  no neighbor 192.168.161.2 activate
  neighbor 192.168.161.2 route-map BLUE in
 exit-address-family
!
eva# show bgp ipv4 uni
BGP table version is 1, local router ID is 10.10.3.11, vrf id 0
Default local pref 100, local AS 3235
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.10.3.11/32    0.0.0.0(eva)             0         32768 i
*> 192.168.161.0/24 0.0.0.0(eva)             0         32768 i
Displayed  2 routes and 2 total paths
eva# show bgp import-check-table
Current BGP import check cache:
 192.168.161.0 valid [IGP metric 0], #paths 1
  if enp39s0
  Last update: Fri Sep 25 08:00:42 2020
 10.10.3.11 valid [IGP metric 0], #paths 1
  if lo
  Last update: Fri Sep 25 08:00:42 2020
eva# show bgp ipv4 uni summ
BGP router identifier 10.10.3.11, local AS number 3235 vrf-id 0
BGP table version 1
RIB entries 3, using 576 bytes of memory
Peers 1, using 21 KiB of memory
Neighbor                 V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
janelle(192.168.161.131) 4      60000        69        70        0    0    0 00:03:21            0        1
Total number of neighbors 1

When we are deciding that a nexthop is valid there is not much point in checking
that a static route has a martian nexthop or not, since we self derived it already.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-25 09:58:28 -04:00
Trey Aspelund
7aa4fd5ba7 bgpd: Use bgp instance's default keepalive interval if < (holdtime/3)
bgp->default_keepalive was not considered when setting
peer->v_keepalive, causing the effective keepalive interval to
always be (holdtime/3), even when default_keepalive < (holdtime/3).
This ensures that the default_keepalive is used when it's set and
is < (holdtime/3).

Signed-off-by: Trey Aspelund <taspelund@cumulusnetworks.com>
(cherry picked from commit d8bf8c6128f2e493d473148213bd663a500c7f73)
2020-09-25 09:46:54 -04:00
Don Slice
3c2a1ad1f0 bgpd: allow derived router-id update if previously 0x0
Problem found that if a router-id was not defined or derived
initially, the bgp->router_id would be set to 0x0 and used
for determining auto-rd values. When bgp received a subsequent
router-id update from zebra, bgp would not completely process
the update since it was treated as updating an already derived
router-id with a new value, which is not desired.  This also
could leave the auto rd/rt inforamation missing or invalid in
some cases.  This fix allows updating the derived router-id if
the previous value was 0/0.

Ticket: CM-31441
Signed-off-by: Don Slice <dslice@nvidia.com>
2020-09-24 08:31:33 -07:00
Donald Sharp
df3aa24066 bgpd: Remove dest variable from route_out_vty_flowspec
The dest variable was never really used.  Just remove
from the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-24 08:20:24 -04:00
Donald Sharp
9f1f03ec30 bgpd: pbra is already derefed in all paths to this spot
The pbra variable is already derefed in all paths to this spot
and as such we cannot be NULL at this point.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-24 08:16:57 -04:00
Donald Sharp
8da920d3c0 bgpd: Ensure we do integer size promotions
When doing multiplication of (int) * (uint_8t) we can
have overflow and end up in a weird state.  Intentionally
upgrade the type then do the math.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-24 08:07:12 -04:00
Mark Stapp
b6033bd1c1
Merge pull request #7067 from donaldsharp/remove_solaris
Remove solaris
2020-09-22 17:04:19 -04:00
Donald Sharp
cae8bc967c *: Remove solaris from FRR
The Solaris code has gone through a deprecation cycle.  No-one
has said anything to us and worse of all we don't have any test
systems running Solaris to know if we are making changes that
are breaking on Solaris.  Remove it from the system so
we can clean up a bit.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-21 10:02:20 -04:00
vivek
05bd726cfe bgpd: Implement BGP-wide configuration for graceful shutdown
Add support for a BGP-wide setting to enter and exit graceful shutdown.
This will apply to all BGP peers across all BGP instances. Per-instance
configuration is disallowed if the BGP-wide setting is in effect.

Signed-off-by: Vivek Venkatraman <vivek@nvidia.com>
2020-09-19 20:38:14 -07:00
vivek
637e5ba492 bgpd: Define function to check if performing graceful shutdown
Signed-off-by: Vivek Venkatraman <vivek@nvidia.com>
2020-09-19 12:50:46 -07:00
Donald Sharp
1f79037b72
Merge pull request #7036 from ton31337/fix/do_not_allow_setting_maximum-prefix-out_global
bgpd: maximum-prefix-out command fixes
2020-09-19 08:32:02 -04:00
Russ White
0a6e6613d7
Merge pull request #7089 from pguibert6WIND/netns-refactor
Netns refactor
2020-09-18 11:02:30 -04:00
Quentin Young
f8dcd38ddb bgpd: rename bgp_fsm_event_update
This function is poorly named; it's really used to allow the FSM to
decide the next valid state based on whether a peer has valid /
reachable nexthops as determined by NHT or BFD.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-17 12:45:37 -04:00
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