Commit Graph

4560 Commits

Author SHA1 Message Date
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
vivek
650b05119d bgpd: Add link bandwidth extended community definition
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
Quentin Young
43aa596538 bgpd: display ingress packet queue size
In the past, we always displayed the number of buffered ingress packets
as zero because there was no packet buffering in the input path and
therefore never any queue size to report. They're buffered now so we can
display something meaningful instead of 0.

Also change the inq / outq lookups to be atomic, since they can be
modified elsewhere. These should still compile down to an unfenced word
read but it's good to be explicit.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-30 15:07:57 -04:00
Sri Mohana Singamsetty
a326a812b3
Merge pull request #6107 from ton31337/fix/unset_prefix_out_flag
bgpd: Unset PEER_FLAG_MAX_PREFIX_OUT for `no neighbor maximum-prefix-…
2020-03-29 19:52:41 -07:00
Sri Mohana Singamsetty
05dd25c23a
Merge pull request #6104 from donaldsharp/bgp_rr_fixup
Bgp rr fixup
2020-03-29 11:47:12 -07:00
Donatas Abraitis
ae00326adc bgpd: Unset PEER_FLAG_MAX_PREFIX_OUT for no neighbor maximum-prefix-out
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-29 19:16:16 +03:00
David Lamparter
566bdaf68c *: fix format string warnings
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
David Lamparter
07ef3e34ae lib: prepare for plugin-based frr_format check
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
Donald Sharp
99819027b1 bgpd: When acting as a RR server do not modify nexthop
https://lists.frrouting.org/pipermail/frog/2020-March/000776.html

It was pointed out that we are not properly passing the nexthop
through and instead we were replacing the nexthop as a Route Server
with our own.

https://tools.ietf.org/html/rfc4456#section-4

10.  Implementation Considerations
   Care should be taken to make sure that none of the BGP path
   attributes defined above can be modified through configuration when
   exchanging internal routing information between RRs and Clients and
   Non-Clients.  Their modification could potentially result in routing
   loops.
   In addition, when a RR reflects a route, it SHOULD NOT modify the
   following path attributes: NEXT_HOP, AS_PATH, LOCAL_PREF, and MED.
   Their modification could potentially result in routing loops.

Modify the code such that when FRR is instructed to act as a
Route-Server to pass through the nexthop.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-28 14:04:24 -04:00
Sri Mohana Singamsetty
0298bb01bb
Merge pull request #6085 from donaldsharp/bgp_node_get_prefix
Bgp node get prefix
2020-03-26 19:07:36 -07:00
Donald Sharp
b54892e0ea bgpd: Convert users of rn->p to use accessor function
Add new function `bgp_node_get_prefix()` and modify
the bgp code base to use it.

This is prep work for the struct bgp_dest rework.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-26 16:25:16 -04:00
Donald Sharp
5f040085ba lib, bgpd: Another round of struct const prefix cleanup
Cleanup another set of functions that need to respect the
const'ness of a prefix.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-26 16:22:00 -04:00
Donald Sharp
52a44d64b5 bgpd: Refactor vnc_import_bgp_redist_table
This function is heavily indented and hard to read
Make it easier to read.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-26 16:22:00 -04:00
Donatas Abraitis
87c8213108 bgpd: Show that prefix is malformed if aggregated by 0
Show if this malformed under `show [ip] bgp <prefix>`:
 ```
eva# sh ip bgp 103.79.124.0/22
BGP routing table entry for 103.79.124.0/22
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.201.136
  64539 15096 6939 7545 7545 136001, (aggregated by 0(malformed) 0.0.0.0)
    192.168.201.136 from 192.168.201.136 (192.168.201.136)
      Origin IGP, valid, external, best (First path received)
      Last update: Thu Mar 26 10:02:07 2020
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-26 16:06:34 +02:00
Donatas Abraitis
0f2a703d5e bgpd: Print readable error message when parsing AGGREGATOR attribute
Having a full feed this leads to unknown. You can't point which prefix or
aspath has this malforming behavior.

Printing just `[EC 33554434] AGGREGATOR attribute is BGP_AS_ZERO(0)` isn't
enough, you can't directly pin-point where is the problem.

Additionally print at least aspath here:
```
[EC 33554434] AGGREGATOR AS number is 0 for aspath: 65000 65031
```

Overall the full table has only 6 such malformed prefixes:
```
aspath: 64539 15096 6939 45430 45458
aspath: 64539 15096 6939 1299 3257 34984 34984 34984 34984 34984 51174
aspath: 64539 15096 6939 286 34984 16135 16135 {16135}
aspath: 64539 15096 6939 7545 7545 136001
aspath: 64539 15096 6939 6762 3269 20746
aspath: 64539 15096 6939 7018 3379
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-26 16:06:00 +02:00
Lou Berger
8678d6387c *: use the current project name (FRRouting)
Signed-off-by: Lou Berger <lberger@labn.net>
2020-03-25 17:38:56 -04:00
Donald Sharp
42984e1bd4
Merge pull request #6087 from opensourcerouting/log-kill-tabs
*: remove tabs and linefeeds from log messages
2020-03-25 06:30:38 -04:00
Russ White
9d7bc42a49
Merge pull request #6081 from dslicenc/import-vrf-routemap
bgpd: clean up import vrf route-map command
2020-03-24 15:57:28 -04:00
David Lamparter
63efca0e95 *: remove line breaks from log messages
Line break at the end of the message is implicit for zlog_* and flog_*,
don't put it in the string.  Mid-message line breaks are currently
unsupported.  (LF is "end of message" in syslog.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-03-24 19:43:18 +01:00
Don Slice
ae6a6fb4e5 bgpd: clean up import vrf route-map command
Problem seen that if "import vrf route-map RMAP" was entered
without any vrfs being imported, the configuration was displayed
as "route-map vpn import RMAP". Additionally, if "import vrf
route-map" was entered without specifying a route-map name,
the command was accepted and the word "route-map" would be
treated as a vrf name.  This fix resolves both of those issues
and also allows deleting the "import vrf route-map" line without
providing the route-map name.

Ticket: CM-28821
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2020-03-24 12:54:10 +00:00
Donald Sharp
26a3ffd60e bgpd, lib, ripngd: Add agg_node_get_prefix
Modify code to use lookup function agg_node_get_prefix()
as the abstraction layer.  When we rework bgp_node to
bgp_dest this will allow us to greatly limit the amount
of work needed to do that.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-24 07:51:41 -04:00
Donald Sharp
5a1ae2c237 bgpd: Rework code to use const struct prefix
Future work needs the ability to specify a
const struct prefix value.  Iterate into
bgp a bit to get this started.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-24 07:51:41 -04:00
Donald Sharp
1a4189d4a1 bgpd, isisd, lib: Make key values const for skiplist
Make some key values const for the skiplist code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-24 07:33:13 -04:00
Donald Sharp
cb9f254c01 bgpd: Make bgp_debug_bestpath take a struct bgp_node
Defer the grabbing of the prefix for as long as is possible.
This is a long term rework of how we access the `struct bgp_node`
to only use accessor functions.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-24 07:33:13 -04:00
Sri Mohana Singamsetty
865a8f8611
Merge pull request #6073 from donaldsharp/is_default
More `const struct prefix` work
2020-03-23 10:54:33 -07:00
Donald Sharp
1be1693edf bgpd, lib: More constification of various code
More second order effects of cleaning up rn usage
in bgp.  Sprinkle the fairy const's all over the place.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-23 08:41:17 -04:00
Donald Sharp
b8685f9bea bgpd: Add some const struct prefix for a couple more functions
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-23 08:10:55 -04:00
Sri Mohana Singamsetty
544955aa78
Merge pull request #6070 from donaldsharp/bgp_const_struct_work
bgpd: More `const struct prefix` work
2020-03-22 17:32:31 -07:00
Sri Mohana Singamsetty
8034b3c837
Merge pull request #6051 from ton31337/fix/bool_stuff_bgp_clist
bgpd: Convert some community related functions to bool type
2020-03-22 17:32:09 -07:00
Donald Sharp
bd494ec5ed bgpd: More const struct prefix work
Modify more code to use `const struct prefix` throughout
bgp.  This is all prep work for adding an accessor function
for bgp_node to get the prefix and reduce all the places that
code needs to be touched when we get that work done.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-22 14:50:46 -04:00
Donald Sharp
99a088e7b8 bgpd: Modify bgp_node_XXX calls to use const struct prefix
Tell the compiler that the prefix is being used for lookups
and it will never change.

Setup for future work.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-21 21:44:48 -04:00
Donatas Abraitis
3dc339cdc2 bgpd: Convert lots of int type functions to bool/void
Some were converted to bool, where true/false status is needed.
Converted to void only those, where the return status was only false or true.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-21 14:59:18 +02:00
Sri Mohana Singamsetty
925c7db1da
Merge pull request #6023 from vivek-cumulus/strip_rts_for_vrf_route_leak
bgpd: Strip route targets during VRF-to-VRF route leaking
2020-03-20 18:11:06 -07:00
Sri Mohana Singamsetty
94baa16307
Merge pull request #6040 from vivek-cumulus/evpn_advertise_map_allow_sets
Allow 'sets' in EVPN advertise route-map
2020-03-20 18:10:35 -07:00
Donald Sharp
8398b5d5d2 bgpd: Convert status defines to enum
Convert some status defines for the fsm to an enum
so that we cannot mix and match them in the future.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-20 18:07:13 -04:00
Donald Sharp
d1060698b4 bgpd: Convert #define of bgp fsm events to an enum
In PR #6052 which fixes issue #5963 the bgp fsm events
were confused with the bgp fsm status leading
to a bug.  Let's start separating those out
so these types of failures cannot just
easily occur.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-20 18:01:53 -04:00
Josh Cox
fd2e2db680 bgpd: Fixed snmp and bmp 'just Established' test.
It was previously comparing an fsm event variable with an fsm status constant.
This fixes issue #5963.

Signed-off-by: Josh Cox <josh.cox@pureport.com>
2020-03-19 18:04:47 -04:00
vivek
e34291b86a bgpd: Allow EVPN advertise route-map to modify attributes
Ensure that the EVPN advertise route-map is applied on a copy of the
original path_info and associated attribute, so that if the route-map
has SET clauses, they can operate properly. This closely follows
the model already in use in other route-map application code.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-19 14:21:23 -07:00
vivek
d69a76ac1a bgpd: Reverse route-map check for consistency
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-19 14:21:23 -07:00
Donatas Abraitis
88f1c94718 bgpd: Convert some community related functions to bool type
They return 0/1, hence changing the return type to bool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-19 23:04:21 +02:00
Quentin Young
9c23deece2
Merge pull request #6045 from rubenk/bgpd-use-correct-format-specifier
bgpd: use the right format specifier
2020-03-19 13:55:04 -04:00
Quentin Young
cbbd3b30ba
Merge pull request #5755 from slankdev/bgpd-fix-prefix-sid-parse-error
bgpd: fix Prefix-SID parse error
2020-03-19 12:28:36 -04:00
Ruben Kerkhof
cc92ee388c bgpd: use the right format specifier
Fixes:
/Library/Developer/CommandLineTools/usr/bin/make  all-am
  CC       bgpd/bgp_attr.o
bgpd/bgp_attr.c:2664:5: warning: format specifies type 'unsigned char' but the argument has type 'uint16_t' (aka 'unsigned short') [-Wformat]
                                length, STREAM_READABLE(peer->curr));
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./lib/log.h:94:50: note: expanded from macro 'flog_err'
        zlog_err("[EC %" PRIu32 "] " format, ferr_id, ##__VA_ARGS__)
                                     ~~~~~~             ^~~~~~~~~~~
1 warning generated.

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-19 14:00:20 +01:00
vivek
e8bfa90eaa bgpd: Strip Route Targets during VRF-to-VRF route leak
During VRF-to-VRF route leaking, strip any extraneous route targets. This
ensures that source-VRF-specific route targets or route targets that are
internally assigned for the VRF-to-VRF route leaking don't get attached
to the route in the target VRF.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
2020-03-18 20:39:32 -07:00
vivek
003bc27547 bgpd: Make strip extcommunity handle multiple extcommunities
Extended communities like the BGP Route Target can be present multiple
times in a route's path attribute. Ensure that the strip function for a
particular extended community (type and subtype) handles this and
strips all occurrences.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
2020-03-18 20:39:32 -07:00
Quentin Young
27f83b0b18
Merge pull request #6028 from mjstapp/fix_func_macros
bgpd,zebra: replace some more FUNCTION macros with __func__
2020-03-18 11:53:58 -04:00
Mark Stapp
0767b4f34e bgpd,zebra: replace some more FUNCTION macros
Replace some remaining __FUNCTION__ macros with __func__,
now that we're trying to converge that way.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-18 08:13:32 -04:00
Donatas Abraitis
8577bb71f9
Merge pull request #5945 from pguibert6WIND/match_rmap_ipv4
bgpd: support for match ip address next-hop address command
2020-03-18 11:22:19 +02:00
Donatas Abraitis
b7eed4f5fd
Merge pull request #5992 from pguibert6WIND/bgp_bfd_reset_with_remote
bgpd: reset bfd session when bgp comes up
2020-03-18 11:19:59 +02:00
Donatas Abraitis
5910f7f1b0
Merge pull request #6022 from vivek-cumulus/refine_multiaccess_check
bgpd: Refine multiaccess check for next hop resetting
2020-03-18 10:47:27 +02:00
Donatas Abraitis
974ac286f1
Merge pull request #6013 from donaldsharp/bgp_reason_it
bgpd: Fix certain code paths that reset reason code
2020-03-18 10:37:02 +02:00
vivek
a3b7253990 bgpd: Refine multiaccess check for next hop resetting
A BGP update-group is dynamically created to group together a set of peers
such that any BGP updates can be formed just once for the entire group and
only the next hop attribute may need to be modified when the update is sent
out to each peer in the group. The update formation code attempts to
determine as much as possible if the next hop will be set to our own IP
address for every peer in the group. This helps to avoid additional checks
at the point of sending the update (which happens on a per-peer basis) and
also because some other attributes may/could vary depending on whether the
next hop is set to our own IP or not. Resetting the next hop to our own IP
address is the most common behavior for EBGP peerings in the absence of
other user-configured or internal (e.g., for l2vpn/evpn) settings and
peerings on a shared subnet.

The code had a flaw in the multiaccess check to see if there are peers in
the update group which are on a shared subnet as the next hop of the path
being announced - the source peer could itself be in the same update group
and cause the check to give an incorrect result. Modify the check to skip
the source peer so that the check is more accurate.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
2020-03-17 19:59:52 -07:00
Philippe Guibert
be7735b382 bgpd: support for match ip address next-hop address command
this command is missing, compared with 'match ipv6 next-hop' command
available. Adding it by taking into account the backward compatible
effect when supposing that some people have configured acls with name
being an ipv4 address.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-17 21:55:42 +01:00
Donald Sharp
19ea4cec4e bgpd: Fix certain code paths that reset reason code
The bgp reason code was being reset in bgp_best_selection
by rerunning bgp_path_info_cmp multiple times under certain
receiving patterns of data from peers.

This is the debugs that show this issue:
2020/03/16 19:17:22.523780 BGP: 2001:20:1:1::6 rcvd UPDATE w/ attr: nexthop 20.1.1.6, origin i, metric 600, community 1000:1006, path 20
2020/03/16 19:17:22.523819 BGP: 2001:20:1:1::6 rcvd 20.10.0.6/32 IPv4 unicast
2020/03/16 19:17:22.556168 BGP: 20.1.1.6 rcvd UPDATE w/ attr: nexthop 20.1.1.6, origin i, metric 500, community 1000:1006, path 20
2020/03/16 19:17:22.556209 BGP: 20.1.1.6 rcvd 20.10.0.6/32 IPv4 unicast
2020/03/16 19:17:22.572358 BGP: bgp_process_main_one: p=20.10.0.6/32 afi=IPv4, safi=unicast start
2020/03/16 19:17:22.572408 BGP: 20.10.0.6/32: Comparing path 2001:20:1:1::6 flags 0x410 with path 20.1.1.6 flags 0x410
2020/03/16 19:17:22.572415 BGP: 20.10.0.6/32: path 2001:20:1:1::6 loses to path 20.1.1.6 due to MED 600 > 500
2020/03/16 19:17:22.572422 BGP: 20.10.0.6/32: path 20.1.1.6 is the bestpath from AS 20
2020/03/16 19:17:22.572429 BGP: 20.10.0.6/32: path 20.1.1.6 is the initial bestpath
2020/03/16 19:17:22.572435 BGP: bgp_best_selection: pi 0x5627187c66c0 dmed
2020/03/16 19:17:22.572441 BGP: 20.10.0.6/32: After path selection, newbest is path 20.1.1.6 oldbest was NONE
2020/03/16 19:17:22.572447 BGP: 20.10.0.6/32: path 20.1.1.6 is the bestpath, add to the multipath list
2020/03/16 19:17:22.572453 BGP: 20.10.0.6/32: path 2001:20:1:1::6 has the same nexthop as the bestpath, skip it
2020/03/16 19:17:22.572460 BGP: 20.10.0.6/32: starting mpath update, newbest 20.1.1.6 num candidates 1 old-mpath-count 0 old-cum-bw u0
2020/03/16 19:17:22.572466 BGP: 20.10.0.6/32: comparing candidate 20.1.1.6 with existing mpath NONE
2020/03/16 19:17:22.572473 BGP: 20.10.0.6/32: New mpath count (incl newbest) 1 mpath-change NO all_paths_lb 0 cum_bw u0

Effectively if BGP receives 2 paths it could end up running bgp_path_info_cmp multiple times
and in some situations overwrite the reason selected the first time through.

In this example path selection is run and the MED is the reason for the choice.
Then in bgp_best_selection is run again this time clearing new_select
to NULL before calling path selection for the first time. This second
call into path selection resets the reason, since it is only passing in one
path.  So save the last reason selected and restore in this case.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-17 15:48:17 -04:00
Russ White
047315df42
Merge pull request #5954 from ton31337/feature/rfc7607
bgpd: Proscribe the use of AS 0 (zero)
2020-03-17 10:27:35 -04:00
Russ White
987ae129bc
Merge pull request #5848 from ton31337/feature/show_rpki_prefix_asn
bgpd: Show RPKI prefixes filtered by ASN
2020-03-17 10:12:22 -04:00
Donatas Abraitis
33d022bcf6 bgpd: Proscribe the use of AS 0 (zero)
Implements https://tools.ietf.org/html/rfc7607

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-17 13:31:23 +02:00
Santosh P K
9a07d32e71
Merge pull request #5998 from donaldsharp/more_spelling
More spelling
2020-03-16 23:46:53 +05:30
Donatas Abraitis
3893aeeea3 bgpd: Add subcodes for BGP Finite State Machine Error
Implement https://tools.ietf.org/html/rfc6608

I used python scapy library to send a notification message in OpenSent state:
```
send(IP(dst="192.168.0.1")/TCP(sport=sp,
							dport=179,
							seq=rec.ack,
							ack=rec.seq + 1,
							flags=0x18)/BGPHeader(type=3)/BGPNotification(error_code=4,
														error_subcode=0))
```

Logs from FRR:
```
%NOTIFICATION: sent to neighbor 192.168.0.2 5/1 (Neighbor Events Error/Receive Unexpected Message in OpenSent State) 0 bytes
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-16 09:22:22 +02:00
Donald Sharp
2089dd80c0 bgpd: Fix spelling mistakes found by debian packaging
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-13 19:10:28 -04:00
Donatas Abraitis
02334bb228 bgpd: Show RPKI prefixes filtered by ASN
```
spine1-debian-9# show rpki
  as-number         Lookup by ASN in prefix table
  cache-connection  Show to which RPKI Cache Servers we have a connection
  cache-server      SHOW configured cache server
  prefix            Lookup IP prefix and optionally ASN in prefix table
  prefix-table      Show validated prefixes which were received from RPKI Cache
spine1-debian-9# show rpki as-number 47583
2.57.88.0                                   23 -  23        47583
2.57.91.0                                   24 -  24        47583
2.57.90.0                                   24 -  24        47583
5.183.8.0                                   22 -  24        47583
31.170.164.0                                23 -  23        47583
31.170.165.0                                24 -  24        47583
31.170.164.0                                24 -  24        47583
31.170.166.0                                23 -  23        47583
31.170.160.0                                22 -  22        47583
31.220.16.0                                 24 -  24        47583
...
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-13 20:03:41 +02:00
Philippe Guibert
fe0c4ed7ba bgpd: reset bfd session when bgp comes up
This scenario has been seen against microtik virtual machine with
bfd enabled. When remote microtik bgp reestablishes the bgp session
after a bgp reset, the bgp establishment comes first, then bfd is
initialising.
The second point is true for microtik, but not for frrouting, as the
frrouting, when receiving bfd down messages, is not at init state.
Actually, bfd state is up, and sees the first bfd down packet from
bfd as an issue. Consequently, the BGP session is cleared.
The fix consists in resetting the BFD session, only if bfd status is
considered as up, once BGP comes up.
That permits to align state machines of both local and remote bfd.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-13 16:38:33 +01:00
Donald Sharp
302f6c891b
Merge pull request #5991 from pguibert6WIND/bfd_corner_bgp_update_source
bgpd: upon reconfiguration or bgp exchange failure, stop bfd.
2020-03-12 13:31:22 -04:00
Sri Mohana Singamsetty
9766604161
Merge pull request #5827 from donaldsharp/missed_upstreaming
Missed upstreaming
2020-03-12 09:27:26 -07:00
Sri Mohana Singamsetty
10ac2238b1
Merge pull request #5979 from ton31337/fix/convert_to_bool_some_functions
bgpd: Convert type int functions to bool which return 0/1 only
2020-03-12 09:26:21 -07:00
Mark Stapp
864aa5a1cc
Merge pull request #5981 from ton31337/fix/not_necessary_checks
*: Remove tests for some XFREE-family functions
2020-03-12 09:45:55 -04:00
Philippe Guibert
7b3ec88871 bgpd: upon reconfiguration or bgp exchange failure, stop bfd.
When bgp is updated with local source, the bgp session is reset; bfd
also must be reset. The bgp_stop() handler handles all kind of
unexpected failures, so the placeholder to deregister from bfd should be
ok, providing that when bgp establishes, a similar function in bgp will
recreate bfd context.
Note that the bfd session is not reset on one specific case, where BFD
down event is the last reset. In that case, we must let BFD to monitor
the link.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-12 13:42:48 +01:00
Sri Mohana Singamsetty
40963e96de
Merge pull request #5952 from ton31337/fix/no_need_for_if_in_filter_override
bgpd: Do not check for a maximum for peer->filter_override
2020-03-11 12:21:58 -07:00
Donatas Abraitis
8fa77bc6f4 *: Remove tests for some XFREE-family functions
XFREE() covers that.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-11 18:16:23 +02:00
Donatas Abraitis
3967f0a857 bgpd: Convert type int functions to bool which return 0/1 only
This is only for bgp_aspath.[ch]

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-11 17:09:47 +02:00
Donatas Abraitis
7b26b14467
Merge pull request #5962 from donaldsharp/whichafisafi
bgpd: When deleting an afi/safi and we fail give more detail
2020-03-11 11:18:02 +02:00
Donatas Abraitis
03d15b1073
Merge pull request #5957 from pguibert6WIND/two_bfd_fixes
Two bfd fixes
2020-03-11 11:17:32 +02:00
Donald Sharp
601837df84 bgpd: When deleting an afi/safi and we fail give more detail
It would be nice to know which afi/safi we couldn't delete
on a peer in the flog message.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-10 14:54:18 -04:00
Ruben Kerkhof
1e20238af5 treewide: fix some issues found with -Werror=undef
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-10 16:53:13 +01:00
vivek
67bd620c9d bgpd: Fix router-id update handling for route-leaking
If the default BGP instance is importing routes from another instance and
the latter has a router-id update, the update handler needs to handle the
default instance in a special way.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Chirag Shah <chirag@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>

Ticket: CM-26007
Reviewed By: CCR-9108
Testing Done: Detailed verification in 3.x
2020-03-10 10:02:43 -04:00
vivek
087a1c6ce0 bgpd: Ensure NHT registration is not attempted for peer-group
Ensure that the late registration for NHT done for IPv4 route exchange
over IPv6 GUA peering is not attempted for peer-groups, only for peers.

Fixes: "bgpd: Late registration of Extended Nexthop"
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-10 10:02:43 -04:00
Donald Sharp
2a0e69ae3c bgpd: Add 'show bgp listeners' command for diagnostics
Add a command to display listen sockets and the vrf that they
are associated with.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-10 09:59:56 -04:00
Philippe Guibert
bd540576af bgpd: reset bfd session when bgp comes up
This scenario has been seen against microtik virtual machine with bfd
enabled. When remote microtik bgp reestablishes the bgp session after a
bgp reset, the bgp establishment comes first, then bfd is initialising.
The second point is true for microtik, but not for frrouting, as the
frrouting, when receiving bfd down messages, is not at init state.
Actually, bfd state is up, and sees the first bfd down packet from bfd
as an issue. Consequently, the BGP session is cleared.
The fix consists in resetting the BFD session, once BGP comes up. That
permits to align state machines of both local and remote bfd.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-10 14:40:31 +01:00
Philippe Guibert
e7db872b81 bgpd: upon reconfiguration or bgp exchange failure, stop bfd.
When bgp is updated with local source, the bgp session is reset; bfd
also must be reset. The bgp_stop() handler handles all kind of
unexpected failures, so the placeholder to deregister from bfd should be
ok, providing that when bgp establishes, a similar function in bgp will
recreate bfd context.
Note that the bfd session is not reset on one specific case, where BFD
down event is the last reset. In that case, we must let BFD to monitor
the link.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-10 14:40:31 +01:00
Donatas Abraitis
73b1082ed9 bgpd: Do not check for a maximum for peer->filter_override
FILTER_MAX is 2, RMAP_MAX is 2. No point here.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-10 11:29:48 +02:00
Quentin Young
8c85ca283b bgpd: fix 'no nexthop vpn export'
ALIAS without parameters against DEFPY w/ required parameters doesn't
work

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-09 14:55:37 -04:00
Donald Sharp
a9c5346c29
Merge pull request #5937 from ton31337/fix/sizeof
*: Replace `sizeof something` to sizeof(something)
2020-03-08 20:01:10 -04:00
Donatas Abraitis
0d6f7fd6fd *: Replace sizeof something to sizeof(something)
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis)

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-08 21:44:53 +02:00
Ruben Kerkhof
01feb0907f bgpd: remove unused variable
This fixes a linking issue on Fedora Rawhide:
/usr/bin/ld: bgpd/libbgp.a(bgp_flowspec.o):/home/ruben/src/frr/./bgpd/bgp_attr_evpn.h:37: multiple definition of `eth_tag_id'; bgpd/bgp_btoa-bgp_btoa.o:/home/ruben/src/frr/./bgpd/bgp_attr_evpn.h:37: first defined here
collect2: error: ld returned 1 exit status

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-07 23:19:13 +01:00
Donald Sharp
5e81f5dd1a *: Finish off the __PRETTY_FUNCTION__ to __func__
FINISH IT

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-06 09:23:22 -05:00
Donatas Abraitis
9c37fcddda
Merge pull request #5920 from qlyoung/fix-srv6-repeated-attr-memleak
Fix srv6 repeated attr memleak + uninitialized refcnt
2020-03-06 15:29:11 +02:00
Quentin Young
5d2724ec25
Merge pull request #5916 from mjstapp/fix_gmtime
*: use gmtime_r exclusively
2020-03-05 17:38:13 -05:00
Quentin Young
498897d8d8
Merge pull request #5918 from ton31337/fix/__func__everywhere
__func__ everywhere
2020-03-05 17:37:03 -05:00
Quentin Young
340594a929 bgpd: properly initialize SRv6 attributes
We were using XMALLOC for these, and only initializing the refcount to 0
on one of them. Let's just use XCALLOC instead...

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-05 16:15:32 -05:00
Quentin Young
b502ca1165 bgpd: correctly handle repeated SRv6 attributes
Repeating SRv6 attributes N times leaks (N-1)*32 bytes of memory.

Fix it!

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-05 16:15:01 -05:00
Mark Stapp
a2700b5071 *: use gmtime_r, localtime_r exclusively
Stop using gmtime() or localtime() everywhere.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-05 13:26:16 -05:00
Donatas Abraitis
15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Quentin Young
fbb0740683
Merge pull request #5911 from ton31337/fix/no_check_if_assert
bgpd: Remove a test and return statement after assert
2020-03-05 13:16:30 -05:00
Donatas Abraitis
ce089777d4 bgpd: Remove a test and return statement after assert
No need to check if the variable is NULL and return after assert.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04 20:19:12 +02:00
Donatas Abraitis
08c2d52ae1 *: Use true/false instead of 1/0 when assigning variable for bool type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04 18:49:36 +02:00
Donatas Abraitis
a8f58eb6a5 *: Use short version of bool expressions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04 15:04:23 +02:00
Donald Sharp
22d4e6c0ac
Merge pull request #5899 from Spantik/clear_bgp_bug
BGPD: Cores when cleared with doppelganger.
2020-03-03 13:16:01 -05:00
Ruben Kerkhof
61bfbd5119 bgpd: fix typo in 'show bgp neighbors' output
And fix a typo in a comment while we're at it

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-03 16:47:14 +01:00
Santosh P K
c368171c04 BGPD: Cores when cleared with doppelganger.
RCA: When doppelganger still around and clear bgp is issued
there are chances of peer getting deleted and next pointer
is a  freed peer pointer.

Fix: Pass address of nnode to get next safe peer pointer.

Signed-off-by: Santosh P K <sapk@vmware.com>
2020-03-03 06:32:48 -08:00
Sri Mohana Singamsetty
200334ecbb
Merge pull request #5855 from ton31337/fix/allow_using_add_sub_for_local-preference
bgpd: Allow using add/subtract for local-preference in route-maps
2020-03-02 09:40:34 -08:00
Donald Sharp
7f5818fbd6 *: change hash_backet to hash_bucket
It's been a year search and destroy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-28 13:59:13 -05:00
Donatas Abraitis
3684eb4360 bgpd: Allow using add/subtract for local-preference in route-maps
We already have a generic support for add/sub in route-maps. It's already
handled in route_value_compile().

Just convert to string (allow passing (-) minus sign) - works like expected.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-28 14:03:46 +02:00
Donald Sharp
5ca840a3e1 bgpd: Cleanup indentation in bgp_route_refresh_receive
Some code in bgp_route_refresh_receive was spread across several
lines because of an end of line commit.  Move comment to a place
to allow better formating.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-27 10:04:37 -05:00
Donald Sharp
94f7f37d54 bgpd: agg_node_lookup not unlocking
SA has found a case where we did a table lookup of a rn( and
associated lock of that node ) where we did not unlock it.

Unlock the node before moving on to the next one.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-27 09:41:58 -05:00
Donald Sharp
1bb379bf4e bgpd: Cleanup set but unused variables
There existed some variables set but never used.  Clean this up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-27 09:41:58 -05:00
Russ White
5e34d224ea
Merge pull request #5783 from ton31337/fix/bad_formatting_bgpd_gr
bgpd: Format properly `show bgp neighbors` for graceful restart stuff
2020-02-25 11:01:27 -05:00
Donatas Abraitis
8cf0a20551
Merge pull request #5768 from donaldsharp/bgp_nexthop
Bgp nexthop
2020-02-20 10:05:53 +02:00
Donatas Abraitis
40b0108887
Merge pull request #5788 from karamalla0406/large_comm
bgpd: support 'show ip bgp large-community" on default vrf
2020-02-19 21:03:59 +01:00
Donald Sharp
3dbe2b6061 bgpd: Add a better breadcrumb for when bgp is missconfiged
Currently During bgp open collision resolution if both
the router-id's are the same, we correctly follow
the RFC and close the connection.  The problem is of course
that there is no notification of the error in configuration
to the end user other than a subtle open debug message.

Explicitly call out the miss-configuration as an error message
as that this miss-config took several hours of debugging to notice.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-19 10:52:14 -05:00
Donald Sharp
1a21da6b01
Merge pull request #5802 from ton31337/feature/aggregate-address_origin_override
bgpd: Allow overriding ORIGIN for aggregate-address
2020-02-19 08:38:31 -05:00
Donatas Abraitis
0bdcc3e3ef
Merge pull request #5809 from donaldsharp/vrf_name
Print out vrf name as well as id
2020-02-19 14:23:32 +01:00
Sri Mohana Singamsetty
dea8e5f275
Merge pull request #5801 from donaldsharp/bgp_peer_sort
Bgp peer sort
2020-02-17 21:39:37 -08:00
Sri Mohana Singamsetty
e661b88e62
Merge pull request #5790 from chiragshah6/mdev
bgpd: format fields to bgp evpn vni json cmds
2020-02-17 21:39:16 -08:00
Donald Sharp
4765870ee7
Merge pull request #5807 from ton31337/fix/do_not_show_failed_if_shutdown
bgpd: Show the real reason why the peer is failed
2020-02-17 09:29:28 -05:00
Jafar Al-Gharaibeh
b5a3c5ef9f
Merge pull request #5815 from donaldsharp/feb_sa_stuff
bgpd: Fix up a couple of new SA issues found
2020-02-16 23:41:55 -06:00
Donald Sharp
bed8d78bae bgpd: Add a couple more spaces for output on MsgRcvd and MsgSent
annie# show bgp ipv4 uni summ
BGP router identifier 192.168.201.136, local AS number 64539 vrf-id 0
BGP table version 22458946
RIB entries 1458006, using 178 MiB of memory
Peers 4, using 68 KiB of memory

Neighbor               V         AS MsgRcvd MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd
45.33.5.119            4          0       0       0        0    0    0    never       Active
65.19.134.122          4      15096 4611832  108292        0    0    0 6d22h55m       800670
107.13.46.23           4          0       0       0        0    0    0    never      Connect
robot(192.168.201.139) 4      64540 11159975 11365599        0    0    0 05w2d05h      Connect

Total number of neighbors 4

On very busy systems The column output for MsgRcvd and MsgSent can quickly move past 7 columns.
Add a couple more to allow for even display.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-16 20:38:13 -05:00
Donatas Abraitis
07d1e5d99d bgpd: Show the real reason why the peer is failed
If the peer was shutdown locally, it doesn't show up as admin. shutdown.
Instead it's treated as "Waiting for peer OPEN".

The same applies to when the peer reaches maximum-prefix count.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-14 23:23:52 +02:00
Donald Sharp
69337c345e bgpd: Use the enum properly in a switch for rpki commands
During route-map processing we return an enum, the rpki
code was doing some extra gyrations that were unnecessary.
Simplify.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-14 15:38:38 -05:00