Commit Graph

107 Commits

Author SHA1 Message Date
Donatas Abraitis
2dbe669bdf :* Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 09:07:41 +03:00
David Lamparter
56ca3b5b3a bgpd: add %pBD for printing struct bgp_dest *
`%pRN` is not appropriate anymore.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-10-17 08:52:35 -04:00
Quentin Young
6c83ddedcf *: make failure to decode nht update an error
This should never happen; no need to debug guard it and it's not a
warning, if this isn't working then NHT is not working at all.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-30 18:37:15 -04:00
Quentin Young
f8dcd38ddb bgpd: rename bgp_fsm_event_update
This function is poorly named; it's really used to allow the FSM to
decide the next valid state based on whether a peer has valid /
reachable nexthops as determined by NHT or BFD.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-17 12:45:37 -04:00
Pat Ruddy
e37e1e27e4 bgpd: do not unregister for prefix nexthop updates if nh exists
since the addition of srte_color to the comparison for bgp nexthops
it is possible to have several nexthops per prefix but since zebra
only sores a per prefix registration we should not unregister for
nh notifications for a prefix unti all the nexthops for that prefix
have been deleted. Otherwise we can get into a deadlock situation
where BGP thinks we have registered but we have unregistered from zebra.

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

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

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

Co-authored-by: Sebastien Merle <sebastien@netdef.org>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-31 09:09:05 +00:00
Philippe Guibert
1840384bae bgpd: flowspec code support for ipv6
until now, the assumption was done in bgp flowspec code that the
information contained was an ipv4 flowspec prefix. now that it is
possible to handle ipv4 or ipv6 flowspec prefixes, that information is
stored in prefix_flowspec attribute. Also, some unlocking is done in
order to process ipv4 and ipv6 flowspec entries.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Kaushik
92d6f76988 lib,zebra,bgpd: Fix for nexthop as IPv4 mapped IPv6 address
Added a macro to validate the v4 mapped v6 address.
Modified bgp receive & send updates for v4 mapped v6 address as
nexthop and installing it as recursive nexthop in RIB.
Minor change in fpm while sending the routes for nexthop as
v4 mapped v6 address.

Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-08-03 23:24:04 -07:00
Donald Sharp
9bcb3eef54 bgp: rename bgp_node to bgp_dest
This is the bulk part extracted from "bgpd: Convert from `struct
bgp_node` to `struct bgp_dest`".  It should not result in any functional
change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-06-23 17:32:52 +02:00
Sri Mohana Singamsetty
089116f8e6
Merge pull request #6456 from ton31337/fix/set_ipv6_ll_if_zero
bgpd: Use IPv6 LL address as nexthop if global was set to ::/LL
2020-06-02 09:08:05 -07:00
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
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
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
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
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
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
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
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
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
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
Chirag Shah
65f803e80a bgpd: skip ra for blackhole nexthop type
bgp nexthop cache update triggers RA for global ipv6
nexthop update.
In case of blackhole route type the outgoing interface
information is NULL which leads to bgpd crash.

Skip sending RA for blackhole nexthop type.

Ticket:CM-27299
Reviewed By:
Testing Done:

Configure bgp neighbor over global ipv6 address.
Configure static blackhole route with prefix includes
connected ipv6 global address.
Upon link flap, zebra sends nexthop update to bgp.
Bgp nexthop cache skips sending RA for blackhole nexthop type.

router bgp 65002
 bgp router-id 91.189.93.190
 ...
 neighbor 2001:67c:1360::b peer-group internal

static route:
ipv6 route 2001:67c:1360::/48 Null0 254

iface rowlink.4010
        address 91.189.93.190/32
        address 2001:67c:1360::a/128

Trigger ifdown rowlink.4010; ifup rowlink.4010

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-12-29 22:16:51 -08:00
Ameya Dharkar
7c312383ba bgpd: Add nexthop of received EVPN RT-5 for nexthop tracking
Problem statement:
When IPv4/IPv6 prefixes are received in BGP, bgp_update function registers the
nexthop of the route with nexthop tracking module. The BGP route is marked as
valid only if the nexthop is resolved.

Even for EVPN RT-5, route should be marked as valid only if the the nexthop is
resolvable.

Code changes:
1. Add nexthop of EVPN RT-5 for nexthop tracking. Route will be marked as valid
only if the nexthop is resolved.
2. Only the valid EVPN routes are imported to the vrf.
3. When nht update is received in BGP, make sure that the EVPN routes are
imported/unimported based on the route becomes valid/invalid.

Testcases:
1. At rtr-1, advertise EVPN RT-5 with a nexthop 10.100.0.2.
10.100.0.2 is resolved at rtr-2 in default vrf.
At rtr-2, remote EVPN RT-5 should be marked as valid and should be imported into
vrfs.

2. Make the nexthop 10.100.0.2 unreachable at rtr-2
Remote EVPN RT-5 should be marked as invalid and should be unimported from the
vrfs. As this code change deals with EVPN type-5 routes only, other EVPN routes
should be valid.

3. At rtr-2, add a static route to make nexthop 10.100.0.2 reachable.
EVPN RT-5 should again become valid and should be imported into the vrfs.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-11-15 10:15:14 -08:00
Donald Sharp
a5f271c635
Merge pull request #5299 from ton31337/fix/remove_dead_code
bgpd: Remove not used bgp_find_nexthop() function
2019-11-11 07:57:09 -05:00
Donatas Abraitis
a78d1c77fe bgpd: Remove not used bgp_find_nexthop() function
Seems like a dead code.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-11-08 15:04:29 +02:00
Donald Sharp
8c1a4c1041 bgpd: use bgp->name_pretty in debugs and add vrf to some output
Recently had a case where I was attempting to debug a nexthop tracking
issue across multiple bgp vrf's and since the setup vrf's in it with
overlapping address ranges, it became real fun real fast to track
vrf data associated.  Add a bit of code to allow us to figure out
what vrf we are in when we print out debug messages.

Look through the rest of the code and find debugs where we are
not using bgp->name_pretty and switch it over.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-07 07:20:41 -05:00
Quentin Young
2951a7a4c2 *: s/TRUE/true/, s/FALSE/false/
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-07-01 17:26:05 +00:00
Stephen Worley
78fba41bd8 lib,zebra,bgpd: Remove nexthop_same_no_recurse()
The functions nexthop_same() does not check the resolved
nexthops so I don't think this function is even needed
anymore.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Philippe Guibert
fc04a6778e bgpd: improve reconnection mechanism by cancelling connect timers
if bfd comes back up, and a bgp reconnection is in progress, theorically
it should be necessary to wait for the end of the reconnection process.
however, since that reconnection process may take some time, update the
fsm by cancelling the connect timer. This done, one just have to call
the start timer.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-04-18 16:11:51 +02:00
Chirag Shah
1eb6c3eae6 *: do not register nexthop 0.0.0.0 to nht
Avoid tracking 0.0.0.0/32 nexthop with RIB.

When routes are aggregated,
the originate of the route becomes self.
Do not track nexthop self (0.0.0.0) with rib.

Ticket: CM-24248
Testing Done:

Before fix-

tor-11# show ip nht vrf all

VRF blue:
0.0.0.0
 unresolved
 Client list: bgp(fd 16)

VRF default:

VRF green:

VRF magenta:
0.0.0.0
 unresolved
 Client list: bgp(fd 16)

After fix-

tor-11# show ip nht vrf all

VRF blue:

VRF default:

VRF green:

VRF magenta:

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-04-03 11:17:57 -07:00
Donald Sharp
e6cc3dc98b
Merge pull request #3415 from pguibert6WIND/flowspec_support_nh_tracking
Flowspec support nh tracking
2019-01-09 15:41:16 -05:00
Philippe Guibert
0378bcaad6 bgpd: flowspec redirect IP info is retrieved into nh tracking
redirect IP nh of flowspec entry is retrieved so that the nexthop
IP information is injected into the nexthop tracking, and is associated
to the bgp_path structure. This permits validating or unvalidating the
bgp_path for injection in zebra or not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-28 18:10:26 +01:00
Lou Berger
9bdb632c68
Merge pull request #3093 from donaldsharp/bgp_node_continued
Bgp node continued
2018-12-11 11:13:25 -05:00
F. Aragon
32fbbd9c7d
bgpd: null check (Coverity 1475469)
Null check of 'rn' returned by bgp_node_lookup() because it could be
deferenced afterwards into bgp_nexthop_get_node_info()

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-11-20 12:51:27 +01:00
Donald Sharp
5b8d32bd58 bgpd: Cleanup bgp_nexthop_set|get function names
The bgp_nexthop_set_node_info and bgp_nexthop_get_node_info
function names were slightly backwards, rename to bgp_node_set and get

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donald Sharp
1ea03b905d bgpd: Late registration of Extended Nexthop should allow RA's to happen
When we have a late registration of the Extended Nexthop capability
for BGP and the peer already has nexthop information stored, go
through and enable RA on the important interfaces.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-07 14:11:45 -05:00
Donald Sharp
1ee0a2df0d bgpd: Allow registration of nexthops after zebra connection
If we attempt to register nexthops before we have the zebra
connection, they will not be installed.  After we have noticed
that we are up, re-install them.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-31 06:31:41 -04:00
Donald Sharp
bb4ef1aec8 bgpd: Add some debugs to note when we are not talking to zebra
Allow some debug notification when we are unable to talk
to zebra due to the connection not being there yet.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-31 06:31:41 -04:00
Donald Sharp
7f040da1a1 bgpd: Fix crash when using v4 route w/ v6 nexthop
Recent changes to the nht code in bgp caused us to actually
keep a true count of v6 nexthop paths when using v4 over v6.
This change introduced a race condition on shutdown on who
got to the bnc cache first( the v4 table or not ).  Effectively
we were allowing the continued existence of the path->nexthop
pointing to the freed bnc.  This was especially true when
we had route leaking.   So when we free the bnc make sure
we clean up the path->nexthop variables pointing at it too.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-17 11:27:30 -04:00
Donald Sharp
40381db785 bgpd: Rename various variable names to something more appropriate
ri -> pi
bi -> bpi
info -> path
info -> rmap_path ( for routemap applications )

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:26:30 -04:00
Donald Sharp
18ee831031 bgpd: Convert all bgp_info_XXX functions to bgp_path_XXX functions
Rename all bgp_info_XXX functions to bgp_path_XXX functions

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Donald Sharp
4b7e606625 bgpd: Convert struct bgp_info to struct bgp_path_info
Do a straight conversion of `struct bgp_info` to `struct bgp_path_info`.
This commit will setup the rename of variables as well.

This is being done because `struct bgp_info` is not descriptive
of what this data actually is.  It is path information for routes
that we keep to build the actual routes nexthops plus some extra
information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Donald Sharp
1defdda8e8 bgpd: Convert BGP_INFO_XXX to BGP_PATH_XXX
Search and replace all BGP_INFO_XXX to BGP_PATH_XXX

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Don Slice
687a2b5dcc bgpd: allow nht registration on ipv6 link-local addresses
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Testing Done: bgp-smoke completed with no new failures

While testing 5549 support using global addresses, discovered that
ipv6 nexthop tracking thru a route-reflector didn't work.  Since
the next-hop used for remote nexthops resolves to the link-local
of the route-reflector, we need to track it in order to react to
interface down events.  Also tripped over a crash in certain cases
which is also resolved in this fix.
2018-10-03 12:24:57 +00:00
Russ White
82977e243a
Merge pull request #3020 from donaldsharp/global_5549
Allow v6 global addresses to be nexthops for v4 addresses in bgp
2018-09-24 09:55:50 -04:00
Donald Sharp
14315f2d69 bgpd: Abstract bgp_nexthop_cache retrieving/setting from info pointer
The bgp_nexthop_cache data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-22 15:03:01 -04:00
Donald Sharp
6137a77dce bgpd: Extend RFC 5549 metaphor a bit more
Currently we only support RFC 5549 in bgp via
using the `neighbor swp1 interface remote-as ...`
command.  This causes the extended capability
data to be traded as part of the open message.
Additionally at that point in time we notify
zebra to turn on the RA code for that interface
so that the zebra trick of turning the v6 nexthop
into a 169.254.0.1 nexthop and adding a neighbor
entry works.

This code change does 2 things:

1) Modify bgp to pass the extended capability
if we are attempting to establish a v4/unicast
session over a v6 peer.  In the past we limited
this to just the LL based peer.

2) Modify the nexthop tracking code to notice
when it receives nexthop data about the global v6
peer to turn on RA code on those interfaces we will
be using.  This will allow the v4 route with a v6
nexthop received in zebra to auto translate this
correctly.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-18 20:53:22 -04:00