Commit Graph

4560 Commits

Author SHA1 Message Date
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
Donald Sharp
8c9769e03b bgpd: Ensure we don't crash when registering RA's
There exists a code path that the ifp can be NULL.
Prevent an accident.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-14 15:35:37 -05:00
Donald Sharp
137147c66a bgpd: Print out vrf name as well as id
The vrf_id is not enough context for people.  Use the
actual name of the vrf if you can.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-14 08:44:27 -05:00
Hiroki Shirokura
45a06b11a6 bgpd: refactor func prototype arround Prefix-SID
mp_update value isn't used by the function arround Prefix-SID.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2020-02-14 00:13:43 +00:00
Hiroki Shirokura
e5d4cda0a7 bgpd: fix Prefix-SID parsing failure case
Prefix-SID path attribute Label-index TLV (type-1) is
used by SR-MPLS. And Label-index TLV MUST ignored
if that path attribute is append on non-Labeled-unicast
UPDATE message described on [ref1].
There is a problem case exist arround this implementation.
This commit fix that.

Before this commit,
unfortunally, setting Label-Index value is skipped at somecases.
because, Label-Index TLV implementation check the AFI/SAFI pair.
by mp_update variable that is set by bgp_mp_reach_parse function.
if MP_REACH_NLRI is present after PREFIX_SID, bgp_attr_psid_sub
function can't understand AFI/SAFI pair. and the order of each
path attributes is never no-deterministic thing for receiver.[ref2]

In this commit,
I re-located checking code of AFI/SAFI pair after path-attr loop.

[ref1](https://tools.ietf.org/html/draft-ietf-idr-bgp-prefix-sid-27#section-3.2)
> The Originator SRGB TLV may only appear in a BGP Prefix-SID attribute
> attached to IPv4/IPv6 Labeled Unicast prefixes ([RFC8277]).  It MUST
> be ignored when received for other BGP AFI/SAFI combinations.

[ref2](https://tools.ietf.org/html/rfc4271#section-5)
> The sender of an UPDATE message SHOULD order path attributes within
> the UPDATE message in ascending order of attribute type.  The
> receiver of an UPDATE message MUST be prepared to handle path
> attributes within UPDATE messages that are out of order.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2020-02-14 00:13:43 +00:00
Hiroki Shirokura
38774fc5e6 bgpd: fix Prefix-SID parse error
Prefix-SID is desined to capable for TLV array.
That behaviour is important to support SR-MPLS feature
and that supported by previous PR #5418.

In that implementation, but if some additional data
(such as next BGP update message or next path attributes)
was present after Prefix-SID path attribute,
bgpd will parse that addional data as Prefix-SID TLV.

This commit fix that. before this commit, loop condition
is determed by stream is readable or not. In more correct
implementatoin, the prefix-sid boundaly should be checked
additonally. the length of Prefix-sid path attribute can
be get by bgp_attr_parse_args.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2020-02-14 00:13:43 +00:00
Mark Stapp
9df7724949
Merge pull request #5806 from ton31337/fix/remove_break_after_return
*: Remove break after return
2020-02-13 11:32:27 -05:00
Donatas Abraitis
a01bc07e1e
Merge pull request #5787 from karamalla0406/rmac_check
bgpd: RFC compliance wrt invalid RMAC, GWIP, ESI and VNI
2020-02-13 17:50:16 +02:00
Donatas Abraitis
752022670a *: Remove break after return
Just a deadcode.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-13 15:39:54 +02:00
Donatas Abraitis
229757f195 bgpd: Allow overriding ORIGIN for aggregate-address
Override ORIGIN attribute if defined.
E.g.: Cisco and Juniper set ORIGIN for aggregated address
to IGP which is not what rfc4271 says.

This enables the same behavior, optionally.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-13 11:07:40 +02:00
Sri Mohana Singamsetty
60092db3fd
Merge pull request #5798 from donaldsharp/bgp_packet_reformat
bgpd: Reformat bpacket_reformat_for_peer
2020-02-12 16:25:49 -08:00
Donald Sharp
469cbb0ffe bgpd: Further peer_sort refinements
Track the returned peer_sorted value and use it where
we can and recalculate where necessary.

This is an effort to reduce the amount of work done here.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-12 14:45:06 -05:00
Donald Sharp
bf0d28dcf7 bgpd: Create peer_sort_lookup()
The act of peer_sort() being called always set this value
even when we are just looking it up.  We need to seperate
out the idea of lookup from set.

For those places that this is immediately obvious that
this is a lookup switch over to using this function.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-12 14:45:06 -05:00
Donald Sharp
f041034e44 bgpd: Reformat bpacket_reformat_for_peer
This function was heavily indented, reformat to reduce indentation
levels a bit.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-12 12:06:07 -05:00
Donatas Abraitis
a53ca37b89 bgpd: Format properly show bgp neighbors for graceful restart stuff
Before:

```
  Graceful restart informations:
    End-of-RIB send: IPv4 Unicast
    End-of-RIB received: IPv4 Unicast
    Local GR Mode  : Helper*
    Remote GR Mode : Helper
    R bit          : False
    Timers :
     Configured Restart Time(sec)  : 120
     Received Restart Time(sec)    : 120
    IPv4 Unicast :
     F bit                 : False
     End-of-RIB Received   : Yes
     End-of-RIB Send       : Yes
     EoRSentAfterUpdate   : Yes
     Timers:
      Configured Stale Path Time(sec)        : 360
```

After:

```
  Graceful restart informations:
    End-of-RIB send: IPv4 Unicast
    End-of-RIB received: IPv4 Unicast
    Local GR Mode: Helper*
    Remote GR Mode: Helper
    R bit: False
    Timers:
      Configured Restart Time(sec): 120
      Received Restart Time(sec): 120
    IPv4 Unicast:
      F bit: False
      End-of-RIB sent: Yes
      End-of-RIB sent after update: Yes
      End-of-RIB received: Yes
      Timers:
        Configured Stale Path Time(sec): 360
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-12 11:00:45 +02:00
Kishore Aramalla
4d6784636c bgpd: support 'show ip bgp large-community" on default vrf
This command works only in the case of vrf/view.
Adding support for default VRF as well.

Signed-off-by: Kishore Aramalla <karamalla@vmware.com>
2020-02-11 12:38:25 -08:00
Kishore Aramalla
c6ec0c745a bgpd: RFC compliance wrt invalid RMAC, GWIP, ESI and VNI
A route where ESI, GW IP, MAC and Label are all zero at the same time SHOULD
be treat-as-withdraw.
Invalid MAC addresses are broadcast or multicast MAC addresses. The route
MUST be treat-as-withdraw in case of an invalid MAC address.

As FRR support Ethernet NVO Tunnels only.
Route will be withdrawn when ESI, GW IP and MAC are zero or Invalid MAC

Test cases:
1) ET-5 route with valid RMAC extended community
2) ET-5 route no RMAC extended community
3) ET-5 route with Multicast MAC in RMAC extended community
4) ET-5 route with Broadcast MAC in RMAC extended community

Signed-off-by: Kishore Aramalla <karamalla@vmware.com>
2020-02-11 12:36:50 -08:00
Quentin Young
f94ed830df
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
bgpd: Format properly `show bgp summary failed`
2020-02-11 14:45:40 -05:00
Chirag Shah
0b509723a0 bgpd: change evpn vni json field format
Change advertiseSviMacip to advertiseSviMacIp in
json output.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-02-11 11:38:26 -08:00
Chirag Shah
37ae1adbfa bgpd: readjust fields in evpn vni json cmd
1) Keep consistant field name, such as
"inKernel".
2) Keep fields order same for both outputs.

Testing Done:

TORS1# show bgp l2vpn evpn vni json
{
  "advertiseGatewayMacip":"Disabled",
  "advertiseSviMacip":"Disabled",
  "advertiseAllVnis":"Enabled",
  "flooding":"Head-end replication",
  "numVnis":8,
  "numL2Vnis":5,
  "numL3Vnis":3,
  "1002":{
    "vni":1002,
    "type":"L2",
    "inKernel":"True",
    "rd":"27.0.0.15:8",
    "originatorIp":"27.0.0.15",
    "mcastGroup":"0.0.0.0",
    "advertiseGatewayMacip":"Disabled",
    "advertiseSviMacip":"Disabled",
    "importRTs":[
      "5550:1002"
    ],
    "exportRTs":[
      "5550:1002"
    ]
  },
}

TORS1# show bgp l2vpn evpn vni 1002 json
{
  "vni":1002,
  "type":"L2",
  "inKernel":"True",
  "rd":"27.0.0.15:8",
  "originatorIp":"27.0.0.15",
  "mcastGroup":"0.0.0.0",
  "advertiseGatewayMacip":"Disabled",
  "advertiseSviMacip":"Disabled",
  "importRts":[
    "5550:1002"
  ],
  "exportRts":[
    "5550:1002"
  ]
}

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-02-11 11:11:28 -08:00
Chirag Shah
7c9cb387ff bgpd: add fields to bgp evpn vni json cmd
Bring 'show bgp l2vpn evpn vni json' inline
with 'show bgp l2vpn evpn vni <id> json' in
terms of fields.

Ticket:CM-28328
Reviewed By:
Testing Done:

TORS1# show bgp l2vpn evpn vni json
{
  "advertiseGatewayMacip":"Disabled",
  "advertiseSviMacip":"Disabled",
  "advertiseAllVnis":"Enabled",
  "flooding":"Head-end replication",
  "numVnis":8,
  "numL2Vnis":5,
  "numL3Vnis":3,
  "1002":{
    "vni":1002,
    "type":"L2",
    "inKernel":"True",
    "originatorIp":"27.0.0.15",
    "rd":"27.0.0.15:8",
    "mcastGroup":"0.0.0.0",
    "advertiseGatewayMacip":"Disabled",
    "advertiseSviMacip":"Disabled",
    "importRTs":[
      "5550:1002"
    ],
    "exportRTs":[
      "5550:1002"
    ]
  },
}

TORS1# show bgp l2vpn evpn vni 1002 json
{
  "vni":1002,
  "type":"L2",
  "kernelFlag":"Yes",
  "rd":"27.0.0.15:8",
  "originatorIp":"27.0.0.15",
  "mcastGroup":"0.0.0.0",
  "advertiseGatewayMacip":"Disabled",
  "advertiseSviMacip":"Disabled",
  "importRts":[
    "5550:1002"
  ],
  "exportRts":[
    "5550:1002"
  ]
}

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-02-11 11:11:28 -08:00
Donatas Abraitis
e91c24c8c2 bgpd: Format properly show bgp summary failed
Before:
```
Neighbor        EstdCnt DropCnt ResetTime Reason
192.168.0.1           0       0    never  Waiting for peer OPEN
```

After:
```
Neighbor        EstdCnt DropCnt ResetTime Reason
192.168.0.1           0       0     never Waiting for peer OPEN
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-11 18:05:02 +02:00
Russ White
8d61adbf07
Merge pull request #5785 from ton31337/fix/replace_gtsm_hops_to_readable_macros
bgpd: Use readable macros for peer->gtsm_hops instead of literals
2020-02-11 10:40:35 -05:00
Russ White
35f50b9305
Merge pull request #5744 from ton31337/fix/thread-as-withdraw_attributes
bgpd: Update some attributes how they are handled if malformed
2020-02-11 10:04:19 -05:00
Donatas Abraitis
724935d5a2
Merge pull request #5789 from donaldsharp/bgp_ebgp_reason
bgpd: Update failed reason to distinguish some NHT scenarios
2020-02-11 10:42:23 +02:00
Donald Sharp
1e91f1d119 bgpd: Update failed reason to distinguish some NHT scenarios
Current failed reasons for bgp when you have a peer that
is not online yet is `Waiting for NHT`, even if NHT has
succeeded.  Add some code to differentiate this.

eva# show bgp ipv4 uni summ failed
BGP router identifier 192.168.201.135, local AS number 3923 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 2, using 43 KiB of memory
Neighbor        EstdCnt DropCnt ResetTime Reason
192.168.44.1          0       0    never  Waiting for NHT
192.168.201.139       0       0    never  Waiting for Open to Succeed
Total number of neighbors 2
eva#

eva# show bgp nexthop
Current BGP nexthop cache:
 192.168.44.1 invalid, peer 192.168.44.1
  Must be Connected
  Last update: Mon Feb 10 19:05:19 2020

 192.168.201.139 valid [IGP metric 0], #paths 0, peer 192.168.201.139

So 192.168.201.139 is a peer for a connected route that has not been
created on .139, while 44.1 nexthop tracking has not succeeded yet.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-10 19:46:48 -05:00
Renato Westphal
4b08a72ed1
Merge pull request #5763 from ton31337/fix/return_without_parent
*: Remove parenthesis on return for constants
2020-02-10 18:49:06 -03:00
Sri Mohana Singamsetty
a41de4cad5
Merge pull request #5770 from ton31337/fix/remove_bgp_flag_functions
bgpd: Replace bgp_flag_* to [UN]SET/CHECK_FLAG macros
2020-02-10 08:31:59 -08:00
Donatas Abraitis
e2521429a6 bgpd: Use readable macros for peer->gtsm_hops instead of literals
Do the same way like BGP_DEFAULT_TTL

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-10 16:23:09 +02:00
Donatas Abraitis
95f7965d09 *: Remove parenthesis on return for constants
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-09 14:21:56 +02:00
Ameya Dharkar
4e72ff729d bgpd: EVPN crash because of incorrect nexthop for IPv6 prefix
RCA:
When we install IPv6 prefix imported from EVPN RT-5 in vrf, nexthop of the IPv6
route should be IPv4 mapped IPv6 address. In function
install_evpn_route_entry_in_vrf, we generate a new attribute with IPv4 mapped
IPv6 nexthop, but we use parent->attr while creating the actual route.
Thus, Ipv4 nexthop is assigned to this route.
Because of this incorrect nexthop, we observed a crash in function
update_ipv6nh_for_route_install.

Fix:
Pass the new attribute with Ipv4 mapped Ipv6 nexthop to
bgp_create_evpn_bgp_path_info

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2020-02-06 13:51:46 -08:00
Donatas Abraitis
892fedb611 bgpd: Replace bgp_flag_* to [UN]SET/CHECK_FLAG macros
Most of the code uses macros, thus let's keep the code unified.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-06 17:11:38 +02:00
Donald Sharp
8c5c49ace8 bgpd: Cleanup compile error?
For some reason we are getting a compile error around a variable I didn't
touch in the other commits.  Make it happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-06 08:23:13 -05:00
Donald Sharp
c4fb250491 bgpd: Fix up some poor formatting
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-06 07:24:53 -05:00
Donald Sharp
e26c305530 bgpd: Store data in final temp variable
There is no need to have a temp variable to then store that
data in another temporary variable.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-06 07:24:53 -05:00
Donald Sharp
af34d2da11 bgpd: bgp_nexthop_self optimize afi and new_afi handling
The new_afi and afi were being used over and over.  Switch
to the end result we want and just use that from the get go.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-06 07:24:53 -05:00
Donald Sharp
2ec802d173 bgpd: Remove prefix pointer creation
The creation of a prefix pointer is unnecessary.  Save the
prefix as part of the actual data structure.  This will
reduce the data needed by 8 bytes per nexthop stored.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-06 07:24:53 -05:00
Donald Sharp
e61f7c0a10 bgpd: show martian nexthops improve code flow
The show martian nexthops command for bgp had some strangely
duplicated code.  Refactor.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-06 07:24:53 -05:00
Donatas Abraitis
975a328e2e *: Replace s_addr 0 => INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-06 09:00:12 +02:00
Donatas Abraitis
85c58de773
Merge pull request #5761 from qlyoung/fix-bgp-gr-cruft
Fix bgp gr style
2020-02-06 08:16:25 +02:00
Donald Sharp
792465c09f
Merge pull request #5104 from opensourcerouting/route-map-nbv2
lib: migrate route map to use northbound
2020-02-05 11:54:21 -05:00
Donatas Abraitis
4ba5a9c55f bgpd: Update some attributes how they are handled if malformed
According to https://tools.ietf.org/html/rfc7606 some of the attributes
MUST be handled as "treat-as-withdraw" approach.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-05 11:01:39 +02:00
Renato Westphal
ecaeb3b697
Merge pull request #5750 from qlyoung/fix-null-after-xfree
*: don't null after XFREE; XFREE does this itself
2020-02-05 01:49:08 -03:00
Quentin Young
03ed0334e8
Merge pull request #5717 from pguibert6WIND/flowspec_issue_redistribute
Flowspec issue redistribute
2020-02-04 15:48:24 -05:00
Quentin Young
362353195a bgpd, lib: fix style from BGP GR code
This patch fixes the noncompliant style for the following commit range:

4a6e80fbf
2ba1fe695
efcb2ebbb
8c48b3b69
dc95985fe
0f0444fbd
85ef4179a
eb451ee58
2d3dd828d
9e3b51a7f
d6e3c15b6
34aa74486
6102cb7fe
d7b3cda6f
2bb5d39b1
5f9c1aa29
5cce3f054
3a75afa4b
f009ff269
cfd47646b
2986cac29
055679e91
034e185dc
794b37d52
b0965c44e
949b0f24f
63696f1d8

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-04 15:19:04 -05:00
Quentin Young
36e8dd8afb bgpd: use _RO list iter variant for gr macro
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-04 15:10:54 -05:00
Quentin Young
e1b36e132b *: remove null check before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-04 13:19:37 -05:00
Rafael Zalamena
91835f1fd2 *: fix route map integration
Add the appropriated code to bootstrap route map northbound for all
daemons.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Quentin Young
0445dc7d4e
Merge pull request #5169 from ton31337/feature/sequence_numbers_for_community_lists
bgpd: Use sequence numbers for community lists
2020-02-04 11:56:29 -05:00
Philippe Guibert
f1af8f04e7 bgpd: forge bgp flowspec packets to be sent
bgp flowspec packets are being forged correctly. There is no need to
check for bgp length, as the bgp nlri length is checked at reception.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-02-04 17:40:11 +01:00
Philippe Guibert
211ee7aa63 bgpd: when nexthop IP is available for flowspec, keep it
keep original nexthop IP address when propagating bgp updates to other
peers.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-02-04 17:40:06 +01:00
Donald Sharp
7f1ace03c7
Merge pull request #5653 from slankdev/slankdev-bgpd-support-prefix-sid-srv6-l3vpn
bgpd: additional Prefix-SID sub-types for supporting SRv6 l3vpn
2020-02-04 11:37:10 -05:00
Russ White
c7a754408e
Merge pull request #5746 from donaldsharp/bgp_sa
Coverioty sa stuff
2020-02-04 11:24:08 -05:00
Donald Sharp
a6bb6a1fe9
Merge pull request #5207 from Spantik/ZERBA_GR
Zebra: Adding GR infrastructure for clients.
2020-02-04 10:57:29 -05:00
Donald Sharp
698ba8d026 bgpd: Remove dead call to get_afi_safi_str
There is no need for a call into get_afi_safi_str for the
json side since we add it based upon the afi safi str below.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-04 08:10:52 -05:00
Donald Sharp
5f71d11c12 bgpd: Tell Coverity SA that regex cannot be NULL here
The coverity SA believes that the regex value can possibly
be NULL.  Not possible so let's make it happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-04 08:09:15 -05:00
Quentin Young
b3ba5dc7fe *: don't null after XFREE; XFREE does this itself
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-03 11:22:13 -05:00
Donald Sharp
7318ae88de bgpd: enums in switches do not need default
If you have enums handled in a switch adding a default case
makes it fun to fix when new stuff is added later.  Remove.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-31 09:59:57 -05:00
Donald Sharp
13909c4fbc bgpd: Cleanup some bad formating
Some recent commits got some bad formating.  Clean this up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-31 09:59:57 -05:00
Santosh P K
be7bbe529d lib: Adding GR capabilites encode and decode.
For Graceful restart clients have to send GR capabilities
library functions are added to encode capabilities and
also for zebra to decode client capabilities.

Co-authored-by: Santosh P K <sapk@vmware.com>
Co-authored-by: Soman K S <somanks@vmware.com>
Signed-off-by: Santosh P K <sapk@vmware.com>
2020-01-30 10:25:52 -08:00
Russ White
64d50ba4c4
Merge pull request #5210 from bisdhdh/master
bgpd:BGP Graceful Restart Per Neighbor(BGPN) Feature.
2020-01-28 11:47:09 -05:00
Chirag Shah
24882500ff bgpd: fix memory leak in evpn json outpus II
Two of the evpn show commands with json option has memory leak.
1) show bgp l2vpn evpn route vni all json
2) show bgp l2vpn evpn route esi json

Before fix:
----------
Executed 'show bgp l2vpn evpn route vni all json' multiple times
used ordinary blocks continue to increase.

Note at the time of show command capture there were 22 evpn routes
in vni evpn route table.

Memory statistics for bgpd:
System allocator statistics:
  Total heap allocated:  9152 KiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  7300 KiB
  Free small blocks:     1760 bytes
  Free ordinary blocks:  1852 KiB
  Ordinary blocks:       880
  Small blocks:          51
  Holding blocks:        0

Ticket:CM-27920
Reviewed By:
Testing Done:

After fix:
---------
Executed 'show bgp l2vpn evpn route vni all json' multiple times
Used ordinary blocks remains low.

Memory statistics for bgpd:
System allocator statistics:
  Total heap allocated:  8356 KiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  6492 KiB
  Free small blocks:     1840 bytes
  Free ordinary blocks:  1864 KiB
  Ordinary blocks:       939
  Small blocks:          52
  Holding blocks:        0

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-01-27 11:07:02 -08:00
Chirag Shah
a1df2ac599 bgpd: fix memory leak in evpn json outputs
Found memory leak in json output of evpn's route
commands.

After executing 'show bgp l2vpn evpn route type prefix json'
and 'show bgp l2vpn evpn route type macip json' few times
(6 times) with more than 600 routes in total seeing
memory footprint for bgpd continue to grow.

Memory statistics for bgpd:
System allocator statistics:
  Total heap allocated:  12 MiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  8390 KiB
  Free small blocks:     1760 bytes
  Free ordinary blocks:  3762 KiB
  Ordinary blocks:       1161
  Small blocks:          51
  Holding blocks:        0

Ticket:CM-27920
Testing Done:

After fix:
excute few times,
'show bgp l2vpn evpn route type prefix json'
and 'show bgp l2vpn evpn route type macip json'
commands where used ordinary blocks (uordblks) is
in steady state.

Memory statistics for bgpd:
System allocator statistics:
  Total heap allocated:  9968 KiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  6486 KiB
  Free small blocks:     1984 bytes
  Free ordinary blocks:  3482 KiB
  Ordinary blocks:       1110
  Small blocks:          54
  Holding blocks:        0

Memory statistics for bgpd:
System allocator statistics:
  Total heap allocated:  10100 KiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  6488 KiB
  Free small blocks:     1984 bytes
  Free ordinary blocks:  3612 KiB
  Ordinary blocks:       1113
  Small blocks:          54
  Holding blocks:        0

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-01-24 12:17:17 -08:00
bisdhdh
4a6e80fbf2 bgpd: Added bgp graceful restart additional debug logs.
bgp graceful restart additional debug logs, resolved
merge conflicts.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:36:33 +05:30
bisdhdh
2ba1fe6951 bgpd: BGP Garaceful Restart debug logs.
Reorganizing bgp gr debug logs and code review comments.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:36:33 +05:30
bisdhdh
8c48b3b696 bgpd: Adding bgp peer route processing and EOR state Signalling from BGPD to Zebra.
* While the Deferral timer is running, signal route update pending
(ZEBRA_CLIENT_ROUTE_UPDATE_PENDING) from BGPD to Zebra.
* After expiry of the Deferral timer, the deferred routes are processed.
When the deferred route_list becomes empty, End-of-Rib is send to the
peer and route processing complete message (ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE)
is sent to Zebra. So that Zebra would delete any stale routes still
present in the rib.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:36:33 +05:30
bisdhdh
dc95985fe8 bgpd: Add rib-stale-time(running in Zebra).
* Added CLI commands to update rib-stale-time, running in
Cmd : "bgp gaceful-restart rib-stale-time (1-3000)".
Cmd : "no bgp gaceful-restart rib-stale-time".
* Integrating the hooks function for signalling from BGPD
to ZEBRA to ZEBRA to enable or disable GR feature in ZEBRA
depending on bgp per peer gr configuration.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:36:33 +05:30
bisdhdh
0f0444fbd8 bgpd: Adding helper caller hooks for BGPD-ZEBRA integration for GR.
*Adding helper caller hooks function for signalling from BGPD
to ZEBRA to enable or disable GR feature in ZEBRA depending
on bgp per peer gr configuration.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:36:33 +05:30
bisdhdh
85ef4179ad bgpd: Adding helper function for BGPD-ZEBRA integration for GR.
*Adding helper function for signalling from BGPD to ZEBRA to
enable or disable GR feature in ZEBRA depending on bgp per
peer gr configuration.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:36:33 +05:30
bisdhdh
2d3dd828db bgpd: Adding header files for BGPD-ZEBRA integration for GR.
Data Structures, function declaration and Macros forSignalling
from BGPD to ZEBRA to enable or disable GR feature in ZEBRA
depending on bgp per peer gr configuration.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
9e3b51a7f3 bgpd: Restarting node does not send EOR after the convergence.
*After a restarting router comes up and the bgp session is
successfully established with the peer. If the restarting
router doesn’t have any route to send, it send EOR to
the peer immediately before receiving updates from its peers.
*Instead the restarting router should send EOR, if the
selection deferral timer is not running OR count of eor received
and eor required are matches then send EOR.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
d6e3c15b62 bgpd: Added hidden CLI command to disable sending of End-of-Rib.
BGP disable EOR sending is a useful command for testing various
scenarios of BGP graceful restart.
* Added the hidden CLI command :  bgp graceful-restart disable-eor
* The CLI will not be displayed in "show running-config" and will not
  be stored in configuration file.
* When enabled, EOR will not be sent to peer

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
Signed-off-by: Soman K S <somanks@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
34aa744869 bgpd: BGP-GR peer router restart-time should be reset.
When the peer router's gr mode had changed from helper/restart
to disable. The local bgp gr router should reset the peer
router's restart-time stored.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
6102cb7fe4 bgpd: Fix for Helper node doesn't set R-bit in OPEN message after the reload.
BGP Helper node doesn't set R-bit in OPEN message after the
restart or reload of the BGP router.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
d7b3cda6f7 bgpd: BGP tcp session failed to apply GR configuration on the transferred
bgp tcp connection.

When the BGP peer is configured between two bgp routes  both routers would create
peer structure , when they receive each other’s open message. In this event both
speakers, open duplicate TCP sessions and send OPEN messages on each socket
simultaneously, the BGP Identifier is used to resolve which socket should be closed.
If BGP GR is enabled the old tcp session is dumped and the new session is retained.
So while this transfer of connection is happening, if all the bgp gr config
is not migrated to the new connection, the new bgp gr mode will never get applied.
Fix Summary:
1.  Replicate GR configuration from the old session to the new session in bgp_accept().
2.  Replicate GR configuration from stub to full-fledged peer in bgp_establish().
3.  Disable all NSF flags, clear stale routes (if present), stop  restart & stale timers
    (if they are running) when the bgp GR mode is changed to “Disabled”.
4.  Disable R-bit in cap, if it is not set the received open message.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
2bb5d39b14 bgpd: show BGP GR Neighbor mode as “NotApplicable”,when local mode is “Disable”.
BGP GR Neighbor mode is showing the default string as “NotRecieved”,
as the bgp gr neighbour capability was not processed,
since the local mode is “Disable”.
However now it would be changed to  “NotApplicable”.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
5f9c1aa29e bgpd: Fix for BGP core when connected routes are redistributed
& GR is enabled.

When GR with deferral is enabled and connected routes are
distributed then in one race condition route node gets added
in to both deferred queue and work queue. If deferred queue
gets processed first then it ends up delete only flag while
leaving the entry in the work queue as it is. When a new update
comes for the same route node next time from peer then it hits
assert. Assert check is added to ensure we don’t add to work queue
again while it is already present.
So, check before adding in to deferred queue if it is already present
in work queue and bail if so.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
5cce3f0544 bgpd: Adding BGP GR change mode config apply on notification sent & received.
* Changing GR mode on a router needs a session reset from the
SAME router to negotiate new GR capability.
* The present GR implementation needs a session reset after every
new BGP GR mode change.
* When BGP session reset happens due to sending or receiving BGP
notification after changing BGP GR mode, there is no need of
explicit session reset.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
3a75afa4b9 bgpd: Adding BGP GR Neighbour mode show, when local mode is “Disable”.
* BGP GR Neighbour mode in show command would show as
“NotApplicable”, when local mode is “Disable”. As the bgp
gr neighbour capability was not processed, since the local mode
is “Disable”.
* Minor changes in show Selection Deferral Time.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
f009ff2697 bgpd: Adding Selection Deferral Timer handler changes.
* Selection Deferral Timer for Graceful Restart.
* Added selection deferral timer handling function.
* Route marking as selection defer when update message is received.
* Staggered processing of routes which are pending best selection.
* Fix for multi-path test case.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
cfd47646b3 bgpd: Adding changes for Selection Deferral Timer config cmd
and DS.

* Added config commands and data structures for deferral timer
configuration and processing.
Cmd : bgp graceful-restart select-defer-time (0-3600)
Cmd : no bgp graceful-restart select-defertime (0-3600)

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
Signed-off-by: Soman K S <somanks@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
2986cac299 bgpd: Adding BGP GR Per Neighbor show commands.
* Added new show command to show the graceful restart
information for each neighbor.
Cmd: show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart
* Changes to show neighbors commands for displaying
graceful restart information.
Cmd :show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
055679e915 bgpd: Adding BGP GR Per Neighbor config commands.
* Added configuration commands for enabling and disabling graceful restart
per neighbour.
Cmd : neighbor A.B.C.D graceful-restart
Cmd : no neighbor A.B.C.D graceful-restart
Cmd : neighbor A.B.C.D graceful-restart-helper
Cmd : no neighbor A.B.C.D graceful-restart-helper
Cmd : neighbor A.B.C.D graceful-restart-disable
Cmd : no neighbor A.B.C.D graceful-restart-disable
* Added configuration commands for disabling graceful restart at the global
Level.
Cmd : bgp graceful-restart disable
Cmd : no  bgp graceful-restart disable

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
034e185dc6 bgpd: BGP GR advertise capabilities in the open message.
* Changes to the capability sending function to advertise
graceful restart capability in the bgp OPEN message.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
794b37d521 bgpd: Adding BGP GR Global & Per Neighbour FSM changes
* Added FSM for peer and global configuration for graceful restart
 * Added debug option BGP_GRACEFUL_RESTART for logs specific to
 graceful restart processing

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
b0965c44e9 bgpd: BGP Graceful Restart Per Neighbor(BGPN), DS & header files.
This pr contains all the header files changes for BGP GR per Neighbour(BGPN)
feature.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
Donatas Abraitis
fa7f9d61eb
Merge pull request #5656 from pguibert6WIND/import_evpn_entries
bgpd: import evpn entries with nexthop self attribute
2020-01-22 10:21:59 +02:00
Donatas Abraitis
fde246e835 bgpd: Add an option to limit outgoing prefixes
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-01-17 16:20:28 +02:00
Quentin Young
aba5353c17 bgpd: fix memory leak when parsing capabilities
Duplicated domain name capability messages cause memory leak. The amount
of leaked memory is proportional to the size of the duplicated
capabilities. This bug was introduced in 2015.

To hit this, a BGP OPEN message must contain multiple FQDN capabilities.
Memory is leaked when the hostname portion of the capability is of
length 0, but the domainname portion is not, for any of the duplicated
capabilities beyond the first one.

https://tools.ietf.org/html/draft-walton-bgp-hostname-capability-00

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-01-16 12:50:27 -05:00
Donatas Abraitis
394e862fda
Merge pull request #5664 from mitch-skiba/addpath-adj-out
bgpd: add addpath ID to adj_out tree sort
2020-01-16 06:52:21 +02:00
Donatas Abraitis
3b1c9f84c6
Merge pull request #5666 from donaldsharp/more_nhg_fixes
bgpd, ospfd, zebra: Do not use 0 as VRF_DEFAULT
2020-01-15 20:38:54 +02:00
Mitchell Skiba
3373d7e7ff bgpd: add addpath ID to adj_out tree sort
When withdrawing addpaths, adj_lookup was called to find the path that
needed to be withdrawn. It would lookup in the RB tree based on subgroup
pointer alone, often find the path with the wrong addpath ID, and return
null.  Only the path highest in the tree sent to the subgroup could be
found, thus withdrawn.

Adding the addpath ID to the sort criteria for the RB tree allows us to
simplify the logic for adj_lookup, and address this problem. We are able
to remove the logic around non-addpath subgroups because the addpath ID
is consistently 0 for non-addpath adj_outs, so special logic to skip
matching the addpath ID isn't required.  (As a side note, addpath will
also never use ID 0, so there won't be any ambiguity when looking at the
structure content.)

Signed-off-by: Mitchell Skiba <mskiba@amazon.com>
2020-01-15 10:12:44 -08:00
Donald Sharp
946de1b95a bgpd, ospfd, zebra: Do not use 0 as VRF_DEFAULT
Explicitly spell out what we are trying to do.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-15 08:29:36 -05:00
David Lamparter
429576883e doc: rename man pages to frr-*
The vrrpd one conflicts with the standalone vrrpd package; also we're
installing daemons to /usr/lib/frr on some systems so they're not on
PATH.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-01-15 14:05:11 +01:00
Hiroki Shirokura
e496b42030 bgpd: prefix-sid srv6 l3vpn service tlv
bgpd already supports BGP Prefix-SID path attribute and
there are some sub-types of Prefix-SID path attribute.
This commits makes bgpd to support additional sub-types.
sub-Type-4 and sub-Type-5 for construct the VPNv4 SRv6 backend
with vpnv4-unicast address family.
This path attributes is already supported by Ciscos IOS-XR and NX-OS.

Prefix-SID sub-Type-4 and sub-Type-5 is defined on following
IETF-drafts.

Supports(A-part-of):
- https://tools.ietf.org/html/draft-dawra-idr-srv6-vpn-04
- https://tools.ietf.org/html/draft-dawra-idr-srv6-vpn-05

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2020-01-15 18:20:35 +09:00
Chirag Shah
a779978810 bgpd: debug convert to snprintf
Change sprintf to snprintf

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-01-10 11:15:36 -08:00
Chirag Shah
d8744f7247 bgpd: add rmac field in route_add debug
For evpn routes, nexthop and RMAC fileds are synced
in route add to zebra.

In case of EVPN routes display RMAC field in route add
debug log.

Reviewed By:CCR-9381
Testing Done:

BGP:   nhop [1]: 27.0.0.11 if 30 VRF 26   RMAC 00:02:00:00:00:2e

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-01-10 11:15:36 -08:00
Donald Sharp
571ea93a70
Merge pull request #5410 from ton31337/feature/bgp_default-route_with_route-map_set
bgpd: An ability to set attributes for default-originate via route-map
2020-01-09 08:39:32 -05:00
Hiroki Shirokura
770df5fd80 bgpd: extended nexthop capability for vpnv4-unicast
This commit makes bgpd to support VPNv4's extended
nexthop capability for bgp-capability negotiation
when BGP open messaging.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2020-01-09 09:53:04 +09:00
Donatas Abraitis
f20b3184b8
Merge pull request #5418 from qlyoung/fix-bgp-prefix-sid-missing-boundscheck
bgpd: fix missing bounds checks for psid attr
2020-01-08 21:59:07 +02:00
Philippe Guibert
d846e91701 bgpd: import evpn entries with nexthop self attribute
import epvn entries with nexthop self attribute.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-01-08 18:18:58 +01:00