Commit Graph

4777 Commits

Author SHA1 Message Date
Donald Sharp
d6bbfefe14 bgpd: Remove awful test of strmatch + get_afi_safi_str
Remove awful test of a strmatch against a call to get_afi_safi_str.
These are the easy ones as that the real decision point is/was
underneath this test.  This is just duplicate expensive testing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-17 16:49:20 -05:00
Donald Sharp
3742de8d68 bgpd: Use the header
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-17 16:42:33 -05:00
Donald Sharp
7d0d37de0c bgpd: Somewhat optimize string returns
There is no need for a cascading series of if statements
for the afi.  Clean it up slightly

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-17 16:39:35 -05:00
Russ White
a1333d8e47
Merge pull request #7735 from ton31337/fix/move_to_options_bgp_master_extra_zebra_data
bgpd: Use bgp master flags for send extra data to zebra
2020-12-15 07:14:17 -05:00
Donatas Abraitis
3a6290bdd1 *: Replace s_addr check agains 0 with INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-14 21:03:38 +02:00
Donatas Abraitis
ec0acb8052 bgpd: Use bgp master flags for send extra data to zebra
root@exit1-debian-9:~/frr# vtysh -c 'conf' -c 'bgp send-extra-data zebra'
root@exit1-debian-9:~/frr# vtysh -c 'show run' | grep send-extra
root@exit1-debian-9:~/frr# vtysh -c 'conf' -c 'no bgp send-extra-data zebra'
root@exit1-debian-9:~/frr# vtysh -c 'show run' | grep send-extra
no bgp send-extra-data zebra

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-14 20:33:41 +02:00
Patrick Ruddy
c2dba6e5b8
Merge pull request #7726 from chiragshah6/mdev
bgpd: fix evpn route-map vni filter at origin
2020-12-14 16:28:09 +00:00
Donatas Abraitis
219218d964
Merge pull request #7664 from donaldsharp/global_bgp_wait
Global bgp wait
2020-12-14 10:28:02 +02:00
Chirag Shah
5bbd2cc1e6 bgpd: fix evpn route-map vni filter at origin
evpn route-map match (filter) on vni is not working
at the origin of the routes.

evpn match vni route checks for encap type as vxlan.
the source route attribute is not set with vxlan encap
thus the match filter wouldn't work.

Ticket:CM-32554
Reviewed By:CCR-11056
Testing Done:

At source have match vni plus set statement in route-map.
Validate the origin of the route's outbound correctly sets
the 'set' statment based on match vni filter.

At origin:
route-map RM-EVPN-TE-Matches permit 10
 match evpn vni 4001
  set large-community 10:10:119

Receiving end:

Route [5]:[0]:[24]:[78.41.1.0] VNI 4001
5550
  27.0.0.15 from TORS1(downlink-5) (27.0.0.15)
    Origin incomplete, metric 0, valid, external, bestpath-from-AS 5550, best (First path received)
    Extended Community: RT:5550:4001 ET:8 Rmac:00:02:00:00:00:4d
    Large Community: 10:10:119    <--- Large community stamped
    Last update: Thu Dec 10 22:19:26 2020

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-12-12 14:08:16 -08:00
Donald Sharp
f23e82838b
Merge pull request #7716 from ton31337/fix/print_string_for_afi_safi_mp_bgp
bgpd: Print afi/safi as strings for some zlog_debug outputs
2020-12-11 20:40:25 -05:00
Donatas Abraitis
2adac2562a bgpd: Do not send BGP UPDATE if the route actually not changed
Reference: https://www.cmand.org/communityexploration

                     --y2--
                    /  |   \
  c1 ---- x1 ---- y1   |   z1
                    \  |   /
                     --y3--

1. z1 announces 192.168.255.254/32 to y2, y3.
2. y2 and y3 tags this prefix at ingress with appropriate
communities 65004:2 (y2) and 65004:3 (y3).
3. x1 filters all communities at the egress to c1.
4. Shutdown the link between y1 and y2.
5. y1 will generate a BGP UPDATE message regarding the next-hop change.
6. x1 will generate a BGP UPDATE message regarding community change.

To avoid sending duplicate BGP UPDATE messages we should make sure
we send only actual route updates. In this example, x1 will skip
BGP UPDATE to c1 because the actual route is the same
(filtered communities - nothing changes).

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-11 14:51:05 +02:00
Donatas Abraitis
adf086ec58 bgpd: Print afi/safi as strings when handling update/withdraw in zlog_debug
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-11 11:44:38 +02:00
Donatas Abraitis
c386cdd8c9 bgpd: Print afi/safi as strings when handling capability in zlog_debug
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-11 11:41:30 +02:00
Donald Sharp
9acb67cbf8 bgpd: Add global bgp suppress-fib-pending command
On top of the recent `bgp suppress-fib-pending which
was at a BGP_NODE level, add this command at the CONFIG_NODE
level as well and allow the command to apply to all instances
of bgp running.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-10 12:59:14 -05:00
Russ White
101ad544fa
Merge pull request #7678 from donaldsharp/aspath_to_zebra
Aspath to zebra
2020-12-10 10:38:14 -05:00
Chirag Shah
1c00fb274c bgpd: local routes use non-default distance
Use user provided AD for local routes (aggregate).

 address-family ipv4 unicast
  distance bgp 20 200 210
  network 47.2.2.8/30
  aggregate-address 51.1.0.0/16

Testing Done:

Before aggr route uses default 200 AD even user provided local AD.
B>* 51.1.0.0/16 [200/0] unreachable (blackhole), weight 1, 00:01:14

After:
B>* 51.1.0.0/16 [210/0] unreachable (blackhole), weight 1, 00:00:01

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-12-09 16:28:17 -08:00
Donald Sharp
e46723a50e bgpd, zebra: Add ability for bgp to send AS-Path information to zebra
Add a bit of code to allow bgp to send the AS-Path associated with
the route being installed to zebra so it can be displayed and
used as part of the `show ip route A` command in zebra.

eva# show ip route 20.0.0.0/11
Routing entry for 20.0.0.0/11
  Known via "bgp", distance 20, metric 0, best
  Last update 00:00:00 ago
  * 192.168.161.1, via enp39s0, weight 1
    AS-Path: 60000 64539 15096 6939 8075

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-08 09:07:21 -05:00
Chirag Shah
801bb996a4 bgpd: fix distance for aggregate route
bgp aggregate address installs route with self peer which
can have peer->su of unspecifed type.
bgp_distance_apply bailed out as it fails to parse
sockunion2hostprefix for af type unspec.

config:
 address-family ipv4 unicast
  aggregate-address 50.1.0.0/16 summary-only

Testing Done:

Before:
B>* 50.1.0.0/16 [20/0] unreachable (blackhole), weight 1, 00:00:02

After:
B>* 50.1.0.0/16 [200/0] unreachable (blackhole), weight 1, 00:01:28

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-12-07 08:31:04 -08:00
Donatas Abraitis
00c106648f bgpd: Handle IPv6 prefixes with IPv4 nexthops for zebra
Prevent from crashing as well here:

```
(gdb) bt
0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
1  0x00007ff54ec5242a in __GI_abort () at abort.c:89
2  0x00007ff54ffb1dd5 in core_handler (signo=11, siginfo=0x7fff189328f0, context=<optimized out>) at lib/sigevent.c:255
3  <signal handler called>
4  update_ipv6nh_for_route_install (api_nh=0x7fff1893309c, is_evpn=<optimized out>, best_pi=0x55c18854f220,
    pi=0x55c18854f220, ifindex=0, nexthop=0x0, nh_bgp=0x55c18850db20, nh_othervrf=<optimized out>) at bgpd/bgp_zebra.c:1099
5  bgp_zebra_announce (dest=dest@entry=0x55c188553020, p=p@entry=0x55c188553020, info=info@entry=0x55c18854f220,
    bgp=bgp@entry=0x55c18850db20, afi=afi@entry=AFI_IP6, safi=safi@entry=SAFI_UNICAST) at bgpd/bgp_zebra.c:1381
6  0x000055c1858ffa3a in bgp_process_main_one (bgp=0x55c18850db20, dest=0x55c188553020, afi=AFI_IP6, safi=SAFI_UNICAST)
    at bgpd/bgp_route.c:2908
7  0x000055c1858ffbbe in bgp_process_wq (wq=<optimized out>, data=0x55c1885550a0) at bgpd/bgp_route.c:3017
8  0x00007ff54ffca560 in work_queue_run (thread=0x7fff189373e0) at lib/workqueue.c:291
9  0x00007ff54ffc0a91 in thread_call (thread=thread@entry=0x7fff189373e0) at lib/thread.c:1681
10 0x00007ff54ff8b978 in frr_run (master=0x55c187caaed0) at lib/libfrr.c:1110
11 0x000055c1858a165b in main (argc=6, argv=0x7fff18937648) at bgpd/bgp_main.c:523
```

```
5  bgp_zebra_announce (dest=dest@entry=0x55c188553020, p=p@entry=0x55c188553020, info=info@entry=0x55c18854f220,
    bgp=bgp@entry=0x55c18850db20, afi=afi@entry=AFI_IP6, safi=safi@entry=SAFI_UNICAST) at bgpd/bgp_zebra.c:1381
        ifindex = 0
        nexthop = 0x0
        nh_weight = 0
```

Reproduce:

```
~# echo "announce route 2a02:4780:1::abdc/128 next-hop 192.168.0.2" > /run/exabgp.in
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-04 17:37:36 +02:00
Donald Sharp
06f16b2c25 bgpd: Let's actually track if the nh was updated
In bgp_zebra_announce when iterating over multipath
we were checking to ensure that the nexthop was updated
but never initially clearing the nh_updated variable.
Thus leading to a situation where we could crash.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-04 08:01:31 -05:00
Donatas Abraitis
3cc92134a3
Merge pull request #7349 from opensourcerouting/bgp-delayopen
bgpd: RFC 4271 optional session attribute DelayOpenTimer
2020-12-03 08:26:44 +02:00
Donald Sharp
d0bd9877b8
Merge pull request #7589 from pguibert6WIND/show_bgp_summary_desc
Show bgp summary desc
2020-12-02 12:18:07 -05:00
Quentin Young
fa22080d22 build: HAVE_LUA -> HAVE_SCRIPTING
And also guard all scripting-related stuff with HAVE_SCRIPTING.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
b4becb063f bgpd: update routemap scripting example
- Change from "match command <foo>" to "match script <script>"
- Use new scripting API

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
9e47ee98a3 lib: cleanup / refactor scripting foo
- fix 'struct lua_State'
- change includes to library style
- rename encoder funcs to look like lua_push* funcs
- fix erroneous doc comment on prefix encoder
- remove unused (and broken) convenience func

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-12-01 18:37:14 -05:00
Quentin Young
0fe6a43d90 lib: move bgp routemap stuff out of frrlua.[ch]
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Quentin Young
f937164459 lib: remove frrlua_initialize
This was toy code used for testing purposes. Code calling Lua should be
very explicit about what is loaded into the Lua state. Also, the
allocator used is exactly the same allocator used by default w/
luaL_newstate().

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Quentin Young
6021965926 lib: clean up frrlua.[ch]
* Use frrlua_* prefix to differentiate from Lua builtins
* Allow frrlua_initialize to pass an empty script
* Fixup naming of table accessors
* Fixup naming of prefix -> table encoder
* Fixup BGP routemap code to new function names
* Fix includes for frrlua.h
* Clean up doc comments

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Donatas Abraitis
bbb46eb5ae bgpd: Show best path reason in JSON output for show bgp command
exit1-debian-9# show ip bgp json
{
 "vrfId": 0,
 "vrfName": "default",
 "tableVersion": 2,
 "routerId": "192.168.255.1",
 "defaultLocPrf": 100,
 "localAS": 65000,
 "routes": { "172.16.255.254/32": [
  {
    "valid":true,
    "bestpath":true,
    "selectionReason":"First path received",
    "pathFrom":"external",
    "prefix":"172.16.255.254",
    "prefixLen":32,
    "network":"172.16.255.254\/32",
    "metric":0,
    "weight":0,
    "peerId":"192.168.255.2",
    "path":"65001",
    "origin":"incomplete",
    "nexthops":[
      {
        "ip":"192.168.255.2",
        "hostname":"exit1-debian-9",
        "afi":"ipv4",
        "used":true
      }
    ]
  }
],"192.168.255.0/24": [
  {
    "valid":true,
    "bestpath":true,
    "selectionReason":"First path received",
    "pathFrom":"external",
    "prefix":"192.168.255.0",
    "prefixLen":24,
    "network":"192.168.255.0\/24",
    "metric":0,
    "weight":0,
    "peerId":"192.168.255.2",
    "path":"65001",
    "origin":"incomplete",
    "nexthops":[
      {
        "ip":"192.168.255.2",
        "hostname":"exit1-debian-9",
        "afi":"ipv4",
        "used":true
      }
    ]
  }
] }  }

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-01 22:36:05 +02:00
Philippe Guibert
aa72bd7e7f bgpd: add peer description for each afi/safi line in show summary
For each afi/safi of 'show bgp summary', display the peer description
each time needed. This information is useful, for instance in the case
of a device connected with multiple peers.
The topotest all_protocol_startup is changed accordingly.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-12-01 08:06:37 +00:00
Donald Sharp
142d6a1e61
Merge pull request #7600 from pjdruddy/evpn-mh-sa
bgpd: correctly store allocated ES struct
2020-11-25 16:30:29 -05:00
Pat Ruddy
f61fbf216b bgpd: correctly store allocated ES struct
in the rare situation where we allocate the ES during the path link
we fail to check/store the allocated ES pointer thus leading to a
NULL dereference later in the function.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-11-25 18:23:13 +00:00
Quentin Young
8395c1f865 bgpd: remove unused, uninitialized sockunion
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-11-25 12:51:52 -05:00
Donald Sharp
f286bcf5fc
Merge pull request #7594 from ton31337/feature/show_pfxSnt_for_show_bgp_summary
bgpd: Show pfxSnt in JSON output for show bgp summary even if not established
2020-11-25 07:02:13 -05:00
Patrick Ruddy
ad88608a36
Merge pull request #7502 from AnuradhaKaruppiah/evpn-mh-irb
evpn-mh: support for symmetric routing
2020-11-25 09:57:56 +00:00
Donatas Abraitis
a616dd1fa0 bgpd: Show pfxSnt in JSON output for show bgp summary even if not established
spine1-debian-9# show ip bgp summary json
{
"ipv4Unicast":{
  "routerId":"192.168.3.2",
  "as":200,
  "vrfId":0,
  "vrfName":"default",
  "tableVersion":4,
  "ribCount":1,
  "ribMemory":184,
  "peerCount":1,
  "peerMemory":23384,
  "peers":{
    "192.168.0.1":{
      "hostname":"exit1-debian-9",
      "remoteAs":100,
      "version":4,
      "msgRcvd":5,
      "msgSent":6,
      "tableVersion":0,
      "outq":0,
      "inq":0,
      "peerUptime":"00:00:09",
      "peerUptimeMsec":9000,
      "peerUptimeEstablishedEpoch":1606206209,
      "pfxRcd":0,
      "pfxSnt":0,
      "state":"Idle (Admin)",
      "connectionsEstablished":1,
      "connectionsDropped":1,
      "idType":"ipv4"
    }
  },
  "failedPeers":1,
  "totalPeers":1,
  "dynamicPeers":0,
  "bestPath":{
    "multiPathRelax":"false"
  }
}
}

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-11-25 08:50:28 +02:00
Anuradha Karuppiah
a92764da0b bgpd: enable L3NHG installation for EVPN host routes by default
L3NHG allows for fast failover of routed traffic (from remote-rack
to local-rack).

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-24 11:06:08 -08:00
Anuradha Karuppiah
2867823e49 bgpd: add a config knob to enable use of L3 NHG for EVPN host routes
Sample config -
vtysh -c "conf t"  -c "router bgp <N>" -c "address-family l2vpn evpn" -c "use-es-l3nhg"

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-24 11:06:08 -08:00
Anuradha Karuppiah
8bcb09a18c bgpd: Use L3NHGs for symmetric IRB host routes
Two L3 next groups are installed per-VRF per-ES for v4 and v6. These
NHGs are used as an indirect destination for symmetric IRB host routes.

Using L3NHGs allows for efficient failover of an ES (similar to the
use of L2NHGs) i.e. when an ES goes down the number of dataplane
updates are limited to 2xN (where N is the number of tenant VRFs
associated with the ES) instead of updating all host-routes behind the
ES.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-24 11:06:08 -08:00
Anuradha Karuppiah
229587fb46 bgpd: commands to display L3 NHGs and MAC-IP paths linked to an ES
Sample output -
===============
torm-11# sh bgp l2vpn evpn es-vrf
ES-VRF Flags: A Active
ESI                            VRF             Flags IPv4-NHG IPv6-NHG Ref
03:44:38:39:ff:ff:01:00:00:01  vrf3            A     1        0        2
03:44:38:39:ff:ff:01:00:00:01  vrf2            A     6        0        4
03:44:38:39:ff:ff:01:00:00:01  vrf1            A     7        0        4
03:44:38:39:ff:ff:01:00:00:02  vrf3            A     2        0        2
03:44:38:39:ff:ff:01:00:00:02  vrf2            A     4        0        4
03:44:38:39:ff:ff:01:00:00:02  vrf1            A     8        0        4

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-24 11:06:08 -08:00
Anuradha Karuppiah
6348981a60 bgpd: use L3NHG while installing EVPN host routes in zebra
Host routes imported into the VRF can have a destination ES (per-VRF)
which is set up as a L3NHG for efficient failover.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-24 11:06:08 -08:00
Anuradha Karuppiah
26c03e43fb bgpd: Handle ES VTEP add/del to a host route
1. MAC-IP routes in the VPN routing table are linked to the
destination ES for efficient handling for remote ES link flaps.
2. Only MAC-IP paths whose nexthops are active (added via EAD-ES)
are imported into the VRF routing table.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-24 11:06:08 -08:00
Anuradha Karuppiah
c589d84746 bgpd: L3NHG infrastructure for host routes in EVPN
ES-VRF entries are maintained for the purpose of L3-NHG creation -
1. Each ES-EVI entry is associated with a tenant VRF. This associaton
triggers the creation of an ES-VRF entry.
2. Type-2/MAC-IP routes are imported into a tenant VRF and programmed as
a /32 or host route entry in the dataplane. If the destination of
the host route is a remote-ES the route is programmed with the
corresponding (keyed in by {vrf,ES-id}) L3-NHG.
3. The reason for this indirection (route->L3-NHG, L3-NHG->list-of-VTEPs)
is to avoid route updates to the dplane when a remote-ES link flaps i.e.
instead of updating all the dependent routes the NHG's contents are
updated. This reduces the amount of dataplane updates (fewer nhg updates vs.
route updates) allowing for a faster failover.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-24 11:06:08 -08:00
Anuradha Karuppiah
bbc57c6cfa bgpd: skip VRF import of MAC-IP routes that belong to locally attached hosts
Local attached hosts are routed via the access ports using the neigh and
fdb/MAC dplane entries.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-11-24 10:22:48 -08:00
Donatas Abraitis
0e1f8ab575 bgpd: Add peerState field into JSON output for show bgp summary
vtysh -c 'show bgp summary json' | \
> jq '.ipv4Unicast.peers."192.168.0.2".peerState'
"Passive"

vtysh -c 'show bgp summary json' | \
> jq '.ipv4Unicast.peers."192.168.0.2".state'
"Established"

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-11-24 16:04:45 +02:00
Donatas Abraitis
0b34518c56 Revert "bgpd: identify passive connections in JSON summary"
This reverts commit 266ae3aa53.
2020-11-24 15:32:35 +02:00
Donatas Abraitis
9bcab3130b
Merge pull request #7577 from donaldsharp/datacenter_stuff
Datacenter stuff
2020-11-24 10:02:39 +02:00
Donatas Abraitis
4f3e4669f0
Merge pull request #7565 from vishaldhingra/bgp_nb
bgpd: sh running config is not considering values provided via -e for max-paths
2020-11-21 22:19:53 +02:00
Donald Sharp
50121ac041 bgpd: Remove restriction on certain connection types under HAVE_CUMULUS
Current code when we are establishing a peering relationship when
under the HAVE_CUMULUS block will dissallow v4/v6 connections if
we do not have v4/v6 addresses applied.  This restriction is
a bit harsh and should be allowed but warned against.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-20 13:47:14 -05:00
Donald Sharp
708b805361 bgpd: Cleanup rpki indentation
Rework a couple functions to allow the indentation to be a bit
cleaner.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-20 08:44:25 -05:00
vdhingra
00908b7a8a bgpd: sh running config is not considering values provided via -e for max-paths
problem
1. run the bgp with -e1 option
2. c t
   router bgp 100
3. show running config
    !
     address-family ipv6 multicast
      maximum-paths 1
      maximum-paths ibgp 1
     exit-address-family
    !
address families should not dump maximum-paths if there
value is same as value provided at run time.

fix
if the maxpaths_ebgp value is same as multipath_num global
object, don't dump maximum-paths.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2020-11-20 02:32:18 -08:00
Donald Sharp
cf36334c6f
Merge pull request #7544 from andylemin/master
bgpd: added bmp read check to detect broken sessions
2020-11-19 19:24:42 -05:00
Donatas Abraitis
53a85efa51
Merge pull request #7554 from donaldsharp/sockunion2hostprefix_watch_returns
bgpd, lib, nhrpd, zebra: verify return of sockunion2hostprefix
2020-11-19 11:26:02 +02:00
Donald Sharp
db2e92360c
Merge pull request #7467 from ton31337/fix/bgpd_null_dereference
bgpd: Check if peer is not NULL before calling peer_as_change()
2020-11-18 18:13:04 -05:00
Mark Stapp
abed797ef5
Merge pull request #7556 from donaldsharp/memory_shenanigans
Memory shenanigans
2020-11-18 17:31:03 -05:00
Mark Stapp
84c709bc6e
Merge pull request #7555 from idryzhov/cppcheck-fixes
fix a couple of issues found by cppcheck
2020-11-18 14:29:25 -05:00
Donald Sharp
6a37bfb7e5 bgpd: Prevent ecommunity_ecom2str memory leak
We were allocating but never freeing memory associated with the
ecommunity_ecom2str allocation.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-18 12:50:48 -05:00
Donald Sharp
b9d4546253 bgpd: Do not leak vname if we find the match
If we are attempting to store the bgp name for route
leaking and we find a match do not leak the memory.

Please note this is probably not really going to happen
ever.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-18 12:10:22 -05:00
Igor Ryzhov
65f18319c0 lib: fix macro style
We prefer semicolon in the actual code instead of macro elsewhere in the
code.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-11-18 19:14:03 +03:00
Donald Sharp
0154d8ce45 bgpd, lib, nhrpd, zebra: verify return of sockunion2hostprefix
The return from sockunion2hostprefix tells us if the conversion
succeeded or not.  There are places in the code where we
always assume that it just `works`, since it can fail
notice and try to do the right thing.

Please note that failure of this function for most cases
of sockunion2hostprefix is highly highly unlikely as that
the sockunion was already created and tested elsewhere
it's just that this function can fail.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-18 11:04:27 -05:00
Mark Stapp
926bc58f78
Merge pull request #7478 from donaldsharp/buffer
Buffer
2020-11-18 08:30:47 -05:00
Donatas Abraitis
151c9d9ec6
Merge pull request #7548 from vincentbernat/feature/json-passive
bgpd: identify passive connections in JSON summary
2020-11-18 08:39:28 +02:00
Vincent Bernat
266ae3aa53 bgpd: identify passive connections in JSON summary
When using non JSON output, passive connections are marked with:

    BGP state = Active (passive)

However, such an information is not available in JSON output. This
commit adds that. It also adds "Active (NSF passive)" flag, like the
regular output.

Signed-off-by: Vincent Bernat <vincent@bernat.ch>
2020-11-17 20:29:31 +01:00
Chirag Shah
232c75cd03 bgpd: convert to yang modeled nbr cmds
Convert to (DEFUN_YANG) yang modeled neighbor configuration
commands to count them in batched execution as part of backoff timer
introduced as part of PR # 6727

These configuration commands already converted transactional cli
but missed to mark them as (DEFUN_YANG).

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-11-17 08:31:34 -08:00
Donald Sharp
a08ccc5e31
Merge pull request #7541 from ton31337/fix/hardcoded_function_names
bgpd: Use __func__ instead of hardcoded strings for some functions
2020-11-17 09:28:09 -05:00
Andy Lemin
8252b47710 bgpd: added bmp read check to detect broken sessions
Signed-off-by: Andy Lemin <andy@lemin.io>
2020-11-18 00:24:59 +11:00
Donald Sharp
399ef80cc3
Merge pull request #7540 from ton31337/fix/typo
*: Replace typo (supress => suppress)
2020-11-17 08:13:17 -05:00
Russ White
2bd9d50ca1
Merge pull request #7523 from donaldsharp/route_map_object_t
*: Remove route_map_object_t from the system
2020-11-17 07:16:12 -05:00
Donatas Abraitis
84c320dc01 bgpd: Use __func__ instead of hardcoded strings for some functions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-11-17 13:32:15 +02:00
Donatas Abraitis
7c98d487b8 *: Replace typo (supress => suppress)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-11-17 12:13:38 +02:00
Donatas Abraitis
7de5a4d9e0 bgpd: Make sure path->attr is not NULL before dereferencing
Null-checking "path->attr" suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-11-17 08:27:51 +02:00
Donatas Abraitis
e5c317bcfa
Merge pull request #7526 from donaldsharp/i_am_a_robot_wumpalump
Cleanup on Aisle 5: Memory leaks, Uninited data and code snarfles
2020-11-16 17:32:30 +02:00
Donatas Abraitis
3dbaf077d4
Merge pull request #7461 from donaldsharp/attribute_setget
Attribute setget
2020-11-16 12:20:40 +02:00
Donatas Abraitis
9d96143b50
Merge pull request #7514 from donaldsharp/respect_e
bgpd: Respect `-e X` value for multipath
2020-11-16 08:57:50 +02:00
Donatas Abraitis
4b18f17437
Merge pull request #7525 from donaldsharp/dest_lock
bgpd: Fix missed unlocks
2020-11-16 08:51:55 +02:00
Donald Sharp
7cfdb48554 *: Convert all usage of zclient_send_message to new enum
The `enum zclient_send_status` enum needs to be extended
throughout the code base to use the new states and
to fix up places where we tested against the return
value being non zero.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 15:04:52 -05:00
Donald Sharp
8a3f8f2e4a bgpd, lib, sharpd: Add enum for zclient_send_message return
Add a `enum zclient_send_status` for appropriate handling
of return codes from zclient_send_message.  Touch all the places
where we handle this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 14:50:17 -05:00
Donald Sharp
db71415b41 bgpd, lib: Indicate when we are buffering instead of immediately sending down ZAPI
When FRR sends data over the ZAPI protocol from the upper levels to zebra, indicate
to the calling functions that we have started buffering data to be sent if the
socket is full underneath it.

Also add a call back function `zebra_buffer_write_ready` that we can call
when an upper level protocol's socket buffer has been drained.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 14:50:17 -05:00
Donald Sharp
91ebf12cb9 bgpd: Convert attr->vnc_subtlvs to use accessor functions
Add a get/set accessor functions and use them.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 09:49:14 -05:00
Donald Sharp
6c924775b5 bgpd: Convert attr->evpn_overlay to accessor functions
Convert usage of the attr->evpn_overlay to get/set functionality.
Future commits will allow us to abstract this data to when
we actually need it for the `struct attr`.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 09:49:14 -05:00
Donald Sharp
779fee9303 bgpd: Abstract attr->cluster to accessor/set functions
Abstract the access of `attr->cluster` to appropriate
accessor/set functionality.

Future commits will allow us to move this data around
to make `struct attr` smaller.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 09:44:47 -05:00
Donald Sharp
04fb21e22e bgpd: Convert attr->transit to use accessor functions
Convert the `struct attr`->transit variable to use
accessor functions.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 09:44:47 -05:00
Donald Sharp
d04ac434f0 bgpd: Convert ipv6_ecommunity to use accessor functions
Convert the `struct attr`->ipv6_ecommunity to use
accessor functions. We'll be able to reduce memory
usage in the `struct bgp_attr` by doing this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 09:44:47 -05:00
Donald Sharp
2a3f51cf6b bgpd: Add accessor for bgp_attr.pmsi_tnl_type
Add an accessor for the bgp_attr.pmsi_tnl_type to allow
us to abstract where it is.  Every attribute is paying
the price of this bit of data as part of `struct bgp_attr`
In the future we'll move it elsewhere.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 09:44:47 -05:00
Donald Sharp
df7d4670ea bgpd: Allow NULL to be passed in for ecommunity_free
Allow some cleanup of if statements to just make
ecommunity_free() check this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 09:39:25 -05:00
Donald Sharp
ff3bf9a436 bgpd: Free aggr_suppresors list on extra deletion
When we delete the bgp_path_info_extra data structure free
the aggr_suppressors data structure that was left dangling.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-14 19:16:57 -05:00
Donald Sharp
f18ba3cd18 bgpd, lib, staticd, tests: Convert to using FOREACH_AFI_SAFI
Move the FOREACH_AFI_SAFI macro from bgpd.h to zebra.h( GLOBAL's YOUALL )

Then convert all the places that have the two level for loop to
iterate over all afi/safis

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-14 18:53:03 -05:00
Donald Sharp
3d1c148b07 bgpd: If using filters free up name on peer deletion
FRR was not properly deleting the aname and cnmae
memory that was allocated if bgp is using filters.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-14 18:35:21 -05:00
Donald Sharp
6bdbcbf12f bgpd: print prefix instead of unininted buf
The recent change to use %pFX missed a code path
where we were displaying a buf that was uninited.
Display the prefix as intended.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-14 18:18:58 -05:00
Donald Sharp
35fb444b7a bgpd: on debug esi was not properly setup
There exists a code path where the esi would be passed
to a debug without the esi being setup with any values
causing us to display what ever is on the stack.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-14 18:17:58 -05:00
Donald Sharp
4f28b2b59e bgpd: When showing a lcommunity free alloced memory
We are temporarily allocing memory to show lcommunity
information.  We then immediately drop it.  Account for
that memory properly.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-14 16:29:16 -05:00
Donald Sharp
dc52beced1 bgpd: Fix missed unlocks
When iterating over the bgp_dest table, using this pattern:

	for (dest = bgp_table_top(table); dest;
	     dest = bgp_route_next(dest)) {

If the code breaks or returns in the middle we will not have
properly unlocked the node as that bgp_table_top locks the top
dest and bgp_route_next locks the next dest and unlocks the old
dest.

From code inspection I have found a bunch of places that
we either return in the middle of or a break is issued.

Add appropriate unlocks.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-14 15:32:49 -05:00
Donald Sharp
1782514fb9 *: Remove route_map_object_t from the system
The route_map_object_t was being used to track what protocol we were
being called against.  But each protocol was only ever calling itself.
So we had a variable that was only ever being passed in from route_map_apply
that had to be carried against and everyone was testing if that variable
was for their own stack.

Clean up this route_map_object_t from the entire system.  We should
speed some stuff up.  Yes I know not a bunch but this will add up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-13 19:35:20 -05:00
Donald Sharp
76bd07b688 bgpd: Respect -e X value for multipath
When entering values for maximum-path if the user
has entered a value to respect from the bgp cli `-e X`
that is the maximum value we should use when accepting
values from the user.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-12 16:45:28 -05:00
Mark Stapp
28f66de2ed bgpd: fix SA warning
Fix a coverity warning about an obscure path involving labels.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-11-12 16:27:31 -05:00
Mark Stapp
a6aa46cc1e
Merge pull request #7481 from donaldsharp/memory_options_are_long
bgpd: Shorten some `show memory` strings
2020-11-12 10:17:22 -05:00
Santosh P K
9b936c5c36
Merge pull request #4770 from kssoman/fib
Advertise FIB installed routes to bgp peers
2020-11-12 18:59:24 +05:30
Donald Sharp
2a99175f8d bgpd: Shorten some show memory strings
Some of the `show memory` strings in bgp are longer than the
columns we have allocated for it.  Shorten some strings to
make them fit and have the output pleasing to the eye.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-12 07:23:37 -05:00
Pat Ruddy
1bfd9dccd6 bgpd: withdraw any exported routes when deleting a vrf
When a BGP vrf instance is deleted, the routes it exported into the
main VPN table are not deleted and they remain as stale routes
attached to an unknown bgp instance. When the new vrf instance comes
along, it imports these routes from the main table and thus we see
duplicatesalongside its own identical routes.
The solution is to call the unexport logic when a BGP vrf instance is
being deleted.

problem example
---------------
volta1# sh bgp vrf VRF-a ipv4 unicast
BGP table version is 4, local router ID is 18.0.0.1, vrf id 5
Default local pref 100, local AS 567
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
*> 7.0.0.6/32       7.0.0.5@0<              10    100      0 ?
*> 7.0.0.8/32       18.0.0.8                 0             0 111 ?
*> 18.0.0.0/24      18.0.0.8                 0             0 111 ?
*> 56.0.0.0/24      7.0.0.5@0<               0    100      0 ?
Displayed  4 routes and 4 total paths
volta1# conf t
volta1(config)# no router bgp 567 vrf VRF-a
volta1(config)#
volta1(config)# router bgp 567 vrf VRF-a
volta1(config-router)#  bgp router-id 18.0.0.1
volta1(config-router)#  no bgp ebgp-requires-policy
volta1(config-router)#  no bgp network import-check
volta1(config-router)#  neighbor 18.0.0.8 remote-as 111
volta1(config-router)#  !
volta1(config-router)#  address-family ipv4 unicast
volta1(config-router-af)#   label vpn export 12345
volta1(config-router-af)#   rd vpn export 567:111
volta1(config-router-af)#   rt vpn both 567:100
volta1(config-router-af)#   export vpn
volta1(config-router-af)#   import vpn
volta1(config-router-af)#  exit-address-family
volta1(config-router)# !
volta1(config-router)# end
volta1# sh bgp vrf VRF-a ipv4 unicast
BGP table version is 4, local router ID is 18.0.0.1, vrf id 5
Default local pref 100, local AS 567
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
*> 7.0.0.6/32       7.0.0.5@0<              10    100      0 ?
*  7.0.0.8/32       18.0.0.8                 0             0 111 ?
*>                  18.0.0.8@-<              0             0 111 ?
*  18.0.0.0/24      18.0.0.8                 0             0 111 ?
*>                  18.0.0.8@-<              0             0 111 ?
*> 56.0.0.0/24      7.0.0.5@0<               0    100      0 ?
Displayed  4 routes and 6 total paths

@- routes indicating unknown bgp instance are imported

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-11-11 15:10:22 +00:00
Donald Sharp
49201fe505
Merge pull request #7491 from volta-networks/fix_ebgp_mhop_reset
bgpd: avoid needless ebgp-multihop session reset
2020-11-10 18:50:10 -05:00