Commit Graph

1030 Commits

Author SHA1 Message Date
Quentin Young
761ed66524 bgpd: fix bad bounds check for addpath in nlri
If a peer advertised capability addpath in their OPEN, but sent us an
UPDATE without an ADDPATH, we overflow a heap buffer.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-11-24 02:48:11 -05:00
Ameya Dharkar
41a28a265b bgpd: Do not perform "connected" check for EVPN nexthop
This changeset follows the PR
https://github.com/FRRouting/frr/pull/5334

Above PR adds nexthop tracking support for EVPN RT-5 nexthops.
This route is marked VALID only if the BGP route has a valid nexthop.

If the EVPN peer is an EBGP pee and "disable_connected_check" flag is not set,
"connected" check is performed for the EVPN nexthop.
But, usually EVPN nexthop is not the BGP peering address, but the VTEP address.
Also, NEXTHOP_UNCHANGED flag is enabled by default for EVPN.
As a result, in a common deployment for EVPN, EVPN nexthop is not connected.

Thus, adding a fix to remove the "connected" check for EVPN nexthops.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-11-22 15:48:37 -08:00
Donald Sharp
6d24b7cc08 bgpd: Prevent possible SA thinking we'll divide by zero
The half and reuse variables can never be 1 but the
SA systems we have do not know this and think it is possible.
Provide the kick in the snarples that the SA needs to know
this is not true.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-21 19:41:48 -05:00
bisdhdh
949b0f24fa bgpd: Implementing a hash table for connected address - ipv4/ipv6
* IPv6 routes received via a ibgp session with one of its own interface as
nexthop are getting installed in the BGP table.
*A common table to be implemented should take cares of both
ipv4 and ipv6 connected addresses.

Signed-off-by: Biswajit Sadhu sadhub@vmware.com
2019-11-20 01:23:11 +05:30
Juergen Werner
54317cbae5 bgpd: Special handling for 2-level routing tables
The command `show ip bgp ipv4|ipv6 vpn neighbors <ip> prefix-counts`
caused a segfault, because the 2-level routing was not accounted for.

Signed-off-by: Juergen Werner <juergen@opensourcerouting.org>
2019-11-19 17:41:04 +01:00
Sri Mohana Singamsetty
6580da9f54
Merge pull request #5257 from ton31337/fix/update_rib_on_bgp_distance_changes
bgpd: Reflect the distance in RIB when it is changed for an arbitrary afi/safi
2019-11-19 08:35:57 -08:00
Lakshman Krishnamoorthy
62e43fd7a8 bgpd: Bug fix in "show bgp l2vpn evpn X:X::X:X/M"
The CLI was not parsing prefix format of ipv6 address.
This fixes the bug: https://github.com/FRRouting/frr/issues/5322

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-11-18 18:20:21 -08:00
Donatas Abraitis
839bdd0f45
Merge pull request #5334 from adharkar/frr-master-nexthop_check
bgpd: Add nexthop of received EVPN RT-5 for nexthop tracking
2019-11-18 09:57:01 +02: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
Lakshman Krishnamoorthy
196c6b092d bgpd: route-map support for evpn RD filter
With this code change, we can now filter evpn routes based on RD using the
match statement: "match evpn rd XX"

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-11-14 13:40:25 -08:00
Donatas Abraitis
fb29348a19 bgpd: Reject routes having AS_SET or AS_CONFED_SET
This is the first step towards eliminating AS_SET and AS_CONFED_SET types
and obsolete them in the future.

More information:
https://datatracker.ietf.org/doc/html/draft-ietf-idr-deprecate-as-set-confed-set-02

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-11-14 19:19:04 +02:00
Donatas Abraitis
8b54bc30f0 tests: Test if distance bgp (1-255) (1-255) (1-255) works
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-11-14 10:13:02 +02:00
Donatas Abraitis
a935f597fc bgpd: Rework BGP dampening to be per AFI/SAFI
Before we had:

!
router bgp 65031
 bgp dampening 1 2 3 4
!

exit2-debian-9(config)# router bgp 65031
exit2-debian-9(config-router)# address-family ipv4 multicast
exit2-debian-9(config-router-af)# bgp dampening 5 6 7 8
exit2-debian-9(config-router-af)# end
exit2-debian-9# show running-config

!
router bgp 65031
 bgp dampening 1 2 3 4
!

After fix:

!
router bgp 65031
 neighbor 192.168.1.2 remote-as 100
 !
 address-family ipv4 unicast
  bgp dampening 1 2 3 4
 exit-address-family
 !
 address-family ipv4 multicast
  bgp dampening 5 6 7 8
 exit-address-family
!

exit2-debian-9# show ip bgp ipv4 unicast dampening parameters
Half-life time: 1 min
Reuse penalty: 2
Suppress penalty: 3
Max suppress time: 4 min
Max suppress penalty: 32

exit2-debian-9# show ip bgp ipv4 multicast dampening parameters
Half-life time: 5 min
Reuse penalty: 6
Suppress penalty: 7
Max suppress time: 8 min
Max suppress penalty: 18

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-11-11 09:52:40 +02:00
Russ White
a049e601ec
Merge pull request #5281 from bisdhdh/bgpv4-over-v6-1
BGPD: Prevent IPv6-LL being fwd to IBGP peers not on same link.
2019-11-06 14:03:52 -05:00
bisdhdh
63696f1d89 BGPD: Prevent IPv6-LL being fwd to IBGP peers not on same link.
Prevent IPv6 Link-local address being forward to IBGP peer,
which are not directly connected.

R1----IPV6-unnumbered-EBGP-------R2-----IPV6-IBGP-----R3

Configure route-map to set preferred global address on and apply
route-map-IN on R2 for R1-R2 session. Now check on R3's BGP and
RIB table has route nexthop as R1 link-local address, which is
not correct.

As of now we clear link-local address info from mp_nexthop_global,
only if mp_nexthop_global is populated with link-local address.

We should do it even if route-map is configured boz forwarding
link-local address from one link scope to another is violation of
the standards.

Signed-off-by: Biswajit Sadhu sadhub@vmware.com
2019-11-05 11:17:47 +05:30
Donald Sharp
63265b5c1f *: Convert prefix_free to double pointer
Have the prefix_free code take a double pointer to free the data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-02 16:13:44 -04:00
Donatas Abraitis
a612fb77d5 bgpd: Reflect the distance in RIB when it is changed for an arbitrary afi/safi
debian-9# show ip route 192.168.255.2/32 longer-prefixes
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B>* 192.168.255.2/32 [20/0] via 192.168.0.1, eth1, 00:15:22
debian-9# conf
debian-9(config)# router bgp 100
debian-9(config-router)# address-family ipv4
debian-9(config-router-af)# distance bgp 123 123 123
debian-9(config-router-af)# do show ip route 192.168.255.2/32 longer-prefixes
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B>* 192.168.255.2/32 [123/0] via 192.168.0.1, eth1, 00:00:09
debian-9(config-router-af)# no distance bgp
debian-9(config-router-af)# do show ip route 192.168.255.2/32 longer-prefixes
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B>* 192.168.255.2/32 [20/0] via 192.168.0.1, eth1, 00:00:02
debian-9(config-router-af)#

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-10-31 09:53:18 +02:00
Rafael Zalamena
2b31007ca2 bgpd: expose sender side AS path loop detection
The sender side AS path loop detection code was implemented since the
import of Quagga code, however it was always disabled by a `ifdef`
guard.

Lets allow the user to decide whether or not to enable this feature on
run-time.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-10-29 16:29:09 -03:00
Donald Sharp
50f450bd53
Merge pull request #4941 from ton31337/fix/do_not_include_nexthop_dash_dash
bgpd: Do not send next-hop as :: in MP_REACH_NLRI if no link-local ex…
2019-10-29 09:37:04 -04:00
Donald Sharp
22df2d8aaf bgpd: Logically dead code
SAFI_EVPN and SAFI_MPLSVPN have been excluded by previous
if statements.  This code is dead.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25 20:42:21 -04:00
Russ White
12bea6d575
Merge pull request #4850 from lkrishnamoor/show_cli
bgpd: Adding new bgp evpn cli's for ip-prefix lookup
2019-10-18 21:30:37 -04:00
Renato Westphal
dfd7b62ddd
Merge pull request #5172 from donaldsharp/sa_clean_and_clean
Sa clean and clean
2019-10-17 23:14:31 -03:00
Russ White
718804149e
Merge pull request #5078 from lkrishnamoor/advertise-routes
bgpd: Fix "show bgp l2vpn evpn neighbors x.x.x.x advertised-routes json"
2019-10-16 15:05:23 -04:00
Donald Sharp
401b063670 bgpd: In redistribution aspath cannot be NULL
Coverity has found a path where the attr.aspath may be NULL.

assert that the aspath is non-null so we can make this go away.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-16 13:38:29 -04:00
Donald Sharp
05864da791 bgpd: struct bgp_path_info *->attr must not be NULL
We make the assumption that ->attr is not NULL throughout
the code base.  We are totally inconsistent about application
of this though.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-16 13:38:29 -04:00
Russ White
e9f66ba9af
Merge pull request #5156 from donaldsharp/soft_reconfig_the_peer
bgpd: Soft reconfig-in should find the right bgp_path_info
2019-10-15 11:37:07 -04:00
Donald Sharp
d7d158892a bgpd: Soft reconfig-in should find the right bgp_path_info
When using soft reconfiguration inbound we are storing packet
data on the side for replaying when necessary.  The problem here
is that we are just grabbing the first bgp_path_info and using
that as the base.  What happens when we have soft-reconfig turned
on with multiple bgp_path_info's for a path?  This was introduced
in commit 8692c50652, yes back
in 2012!  I would argue, though, that it was just broken
in a different way before this.

Choose the correct bgp_path_info that corresponds to the peer
we received the data from for rethinking.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-15 09:31:20 -04:00
Donald Sharp
a51743300c bgpd: Be careful about displaying vni's as labels.
When a type 2/3 or 5 route is received, verified and the
resulting route generated is pushed into the appropriate vrf
the vni's associated with the route are also passed in.
This is showing up as a Remote label when you dump
the route in bgp:

BGP routing table entry for 0.0.0.0/0^M
Paths: (1 available, best #1, table third)
   Advertised to non peer-group peers:
   10.10.120.22
   42001 42005 42006 42055
     10.10.120.22 from 10.10.120.22 (10.10.255.193)
       Origin IGP, valid, external, bestpath-from-AS 42001, best
       Remote label: 62750
       AddPath ID: RX 0, TX 2
       Last update: Fri Oct 11 12:59:56 2019

The `Remote label: 62750` is the mpls label version of the
vni passed in.  This is meaningless and confusing to the end
user.  Do not display this information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-14 21:17:16 -04:00
Russ White
adca8385ae
Merge pull request #5131 from donaldsharp/extra_clean
bgpd: When creating extra from stack ensure it is zero'ed out
2019-10-11 07:24:39 -04:00
Philippe Guibert
1276ce3833 bgpd: withdraw fib entry on appropriate table identifier
There are cases where the table identifier is set on a bgp entry, mainly
due to route-map, and associate fib entry needs to be removed.
This change encompasses also the route-map reconfiguration that leads to
removing the previous entry, whereas bgp update had been triggered (
this happens when software inbound reconfiguration is handled).

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-10-10 16:06:51 +02:00
Donald Sharp
b8694ef44c bgpd: When creating extra from stack ensure it is zero'ed out
BGP code assumes that the extra data is zero'ed out.  Ensure that we
are not leaving any situation that the data on the stack is actually all
0's when we pass it around as a pointer later.

Please note in issue #5025, Lou reported a different valgrind
issue, which is not the same issue:

==7313== Conditional jump or move depends on uninitialised value(s)
==7313== at 0x181F9F: subgroup_announce_check (bgp_route.c:1555)
==7313== by 0x1A112B: subgroup_announce_table (bgp_updgrp_adv.c:641)
==7313== by 0x1A1340: subgroup_announce_route (bgp_updgrp_adv.c:704)
==7313== by 0x1A13E3: subgroup_coalesce_timer (bgp_updgrp_adv.c:331)
==7313== by 0x4EBA615: thread_call (thread.c:1531)
==7313== by 0x4E8AC37: frr_run (libfrr.c:1052)
==7313== by 0x1429E0: main (bgp_main.c:486)
==7313==
==7313== Conditional jump or move depends on uninitialised value(s)
==7313== at 0x201C0E: rfapi_vty_out_vncinfo (rfapi_vty.c:429)
==7313== by 0x18D0D6: route_vty_out (bgp_route.c:7481)
==7313== by 0x18DD76: bgp_show_table (bgp_route.c:9365)
==7313== by 0x1930C4: bgp_show_table_rd (bgp_route.c:9471)
==7313== by 0x1932A3: bgp_show (bgp_route.c:9510)
==7313== by 0x193E68: show_ip_bgp_json (bgp_route.c:10284)
==7313== by 0x4E6D024: cmd_execute_command_real.isra.2 (command.c:1072)
==7313== by 0x4E6F51E: cmd_execute_command (command.c:1131)
==7313== by 0x4E6F686: cmd_execute (command.c:1285)
==7313== by 0x4EBF9C4: vty_command (vty.c:516)
==7313== by 0x4EBFB9F: vty_execute (vty.c:1285)
==7313== by 0x4EC250F: vtysh_read (vty.c:2119)
==7313==

that is causing the actual crash.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-10 09:03:56 -04:00
Donatas Abraitis
a0a87037ac bgpd: Use uint32_t for maximum-prefix
Currently we have unsigned long which is not what we defined
in CLI (1-4294967295).

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-10-04 15:46:21 +03:00
Lakshman Krishnamoorthy
dc387b0fea bgpd: Fixing "show bgp l2vpn evpn neighbors x.x.x.x advertised-routes json
Display output from adj_out instead of the rib table.

Also fixes crash for the json output. RCA: prefix is written to json object
using inet_ntop. But, this api returns null buffer for AF_EVPN address family
(it works only for AF_INET and AF_INET6).  This null buffer is then deref'd
by json-object-to string api.

Full output shown in PR: https://github.com/FRRouting/frr/pull/5078
Crash issue: https://github.com/FRRouting/frr/issues/5010

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-09-27 12:04:13 -07:00
Lakshman Krishnamoorthy
44c6974748 bgpd: Adding new bgp evpn cli's for ip-prefix lookup
Implement CLIs for the following, to filter for a prefix within
evpn type 5 route
1) show bgp l2vpn evpn A.B.C.D
2) show bgp l2vpn evpn A.B.C.D json
3) show bgp l2vpn evpn A.B.C.D/M
4) show bgp l2vpn evpn A.B.C.D/M json
5) show bgp l2vpn evpn X:X::X:X
6) show bgp l2vpn evpn X:X::X:X json
7) show bgp l2vpn evpn X:X::X:X/M
8) show bgp l2vpn evpn X:X::X:X/M json

Sample output provided here: https://github.com/FRRouting/frr/pull/4850

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-09-27 10:58:46 -07:00
Donald Sharp
cb70bd5638
Merge pull request #5067 from ton31337/fix/no_aggregate-address_command_for_route-map
bgpd: Accept no aggregate-address <IP> route-map <RMAP> commands
2019-09-26 17:40:41 -04:00
Donald Sharp
961f406493
Merge pull request #5070 from ton31337/fix/aggregate-address_for_ipv6_summary-only_missreading
bgpd: aggregate-address X:X::X:X/M summary-only was missreading config
2019-09-26 17:39:09 -04:00
Donatas Abraitis
273fae13b2 bgpd: aggregate-address X:X::X:X/M summary-only was missreading config
Entering:
aggregate-address 2a02:4780::/48 summary-only

Will transform this to:
aggregate-address 2a02:4780::/48 summary-only route-map summary-only

This patch fixes that.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-09-26 21:47:55 +03:00
Donald Sharp
cf40d0528e bgpd: aggregate-address A.B.C.D A.B.C.D summary-only was missreading config
The `aggregate-address 30.0.5.0 255.255.255.0 summary-only` command
was missreading the inputed data and translating it into:

`aggregate-address 30.0.5.0/24 summary-only route-map summary-only`

This is not quite correct.  Fix this behavior:

donna.cumulusnetworks.com# conf
donna.cumulusnetworks.com(config)# router bgp
donna.cumulusnetworks.com(config-router)# aggregate-address 30.0.5.0 255.255.255.0 summary-only
donna.cumulusnetworks.com(config-router)# do show run
Building configuration...

Current configuration:
!
frr version 7.3-dev
frr defaults datacenter
hostname donna.cumulusnetworks.com
log file /var/log/frr/frr.log
no ipv6 forwarding
frr version 7.2-dev
!
router bgp 500
 neighbor 192.168.209.1 remote-as external
 neighbor 192.168.209.1 ebgp-multihop 255
 neighbor 192.168.210.1 remote-as external
 !
 address-family ipv4 unicast
  network 192.168.9.0/24
  network 192.168.10.0/24
  aggregate-address 30.0.5.0/24 summary-only
 exit-address-family
!

Issue: #5054
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-26 12:40:19 -04:00
Donatas Abraitis
b84da0db76 bgpd: Accept no aggregate-address <IP> route-map <RMAP> commands
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-09-26 17:35:25 +03:00
vdhingra
ef51a7d8d4 bgpd : route agg. with aspath attribute is consuming lot of cycles.
While configuring aggregate route prepare the hash table first,
then prepare the aggregated aspath value just like lcomm,
ecomm and standard community.

Signed-off-by: vishaldhingra<vdhingra@vmware.com>
2019-09-24 02:54:19 -07:00
vdhingra
4edd83f91b bgpd : route agg. with ecomm attribute is consuming lot of cycles.
While configuring aggregate route prepare the hash table first,
then prepare the aggregated ecomm value and then do the
unique sort once for ecommunity.

Signed-off-by: vishaldhingra<vdhingra@vmware.com>
2019-09-24 02:54:19 -07:00
vdhingra
21fec67453 bgpd : route agg. with comm attr is consuming lot of cycles.
While configuring aggregate route prepare the hash table
first, then prepare the aggregated standard comm value
and then do the unique sort once for standard community.

Signed-off-by: vishaldhingra<vdhingra@vmware.com>
2019-09-24 02:54:19 -07:00
vdhingra
f1eb1f0526 bgpd : route agg. with lcomm attribute is consuming lot of cycles.
While configuring aggregate route prepare the hash table first,
then prepare the aggregated lcomm value and then do the unique
sort once for large community.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-09-24 02:53:51 -07:00
Donald Sharp
7b7d48e586 bgpd: Create set distance XXX command for routemaps
Allow bgp to set a local Administrative distance to use
for installing routes into the rib.

Example:
!
router bgp 9323
 bgp router-id 1.2.3.4
 neighbor enp0s8 interface remote-as external
 !
 address-family ipv4 unicast
  neighbor enp0s8 route-map DISTANCE in
 exit-address-family
!
route-map DISTANCE permit 10
 set distance 153
!
line vty
!
end
eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B   0.0.0.0/0 [153/0] via fe80::a00:27ff:fe84:c2d6, enp0s8, 00:00:06
K>* 0.0.0.0/0 [0/100] via 10.0.2.2, enp0s3, 00:06:31
B>* 1.1.1.1/32 [153/0] via fe80::a00:27ff:fe84:c2d6, enp0s8, 00:00:06
B>* 1.1.1.2/32 [153/0] via fe80::a00:27ff:fe84:c2d6, enp0s8, 00:00:06
B>* 1.1.1.3/32 [153/0] via fe80::a00:27ff:fe84:c2d6, enp0s8, 00:00:06
C>* 10.0.2.0/24 is directly connected, enp0s3, 00:06:31
K>* 169.254.0.0/16 [0/1000] is directly connected, enp0s3, 00:06:31
eva#

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-13 16:43:16 -04:00
Donatas Abraitis
0606039c19 bgpd: Use defined constants for NHLEN instead of numeric values
This is better in cases when you need to find specific pattern and/or
replacing.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-09-13 11:43:44 +03:00
Lou Berger
ccc13acc0f
Merge pull request #4866 from ton31337/feature/apply_route-map_for_aggregate-address
bgpd: Apply route-map for aggregate-address
2019-09-10 11:59:10 -04:00
Donatas Abraitis
c728d02764 bgpd: Do not send next-hop as :: in MP_REACH_NLRI if no link-local exists
This is the unusual case when you have global IPv6 address and no link-local
on interface attached. Like here:

eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
 link/ether 08:00:27:65:c6:82 brd ff:ff:ff:ff:ff:ff
 inet6 2a02:4780:face::1/64 scope global
    valid_lft forever preferred_lft forever

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-09-10 18:11:58 +03:00
Donatas Abraitis
20894f50bd bgpd: Apply route-map for aggregate-address command
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-08-28 16:45:21 +03:00
Dinesh G Dutt
5cb5f4d04d bgpd: Eliminate all incorrect formulations of afi/safi in JSON
In a number of places, the JSON output had invalid key names for
AFI/SAFI. For example, the key name in JSON was "IPv4 Unicast" which
is invalid as a JSON Key name. Many JSON tools such as those used in
Ansible, jq etc. all fail to parse the output in these scenarios. The
valid name is ipv4Unicast. There's already a routine afi_safi_json()
defined to handle this change, but it was not consistently called.
The non-JSON version was called afi_safi_print() and it merely returned
the CLI version of the string, didn't print anything.

This patch deals with this issue by:
   - Renaming afi_safi_print to get_afi_safi_str()
   - get_afi_safi_str takes an additional param, for_json which if true
     will return the JSON-valid string
   - Renaming afi_safi_json to get_afi_safi_json_str()
   - Creating a new routine get_afi_safi_vty_str() for printing to vty
   - Consistently using get_afi_safi_str() with the appropriate for_json
     value

Signed-off-by: Dinesh G Dutt <5016467+ddutt@users.noreply.github.com>
2019-08-27 14:05:39 +00:00
Dinesh Dutt
d7325ee773 bgpd: Display the imported route information for EVPN routes
For IPv4/v6 unicast routes that have been imported from EVPN Prefix
routes, display the information about where the route has been imported
from allowing for easy tracing of how a FIB/RIB entry got populated.

Signed-off-by: Dinesh G Dutt <5016467+ddutt@users.noreply.github.com>
2019-08-14 19:27:56 +00:00
Naveen Thanikachalam
dfb6fd1dd1 bgpd: Assertion failed during shutdown.
A race condition causes the failure.
The function "make_info()" sets the path info's peer to
bgp instance's "peer_self" which is created when BGP is first
configured and deleted only when BGP is brought down completely.
A race condition causes the bgp instances's "peer_self" to be
removed before the routes are being pulled off from the aggregate
address.

If the bgp instance's "peer_self" is NULL or, if BGP is being deleted,
the aggregate route must not be reinstalled.

Signed-off-by: NaveenThanikachalam nthanikachal@vmware.com
2019-08-11 03:56:12 -07:00
Dinesh Dutt
dcc1615e1b bgpd: Display received and advertised EVPN routes from neighbors
"show bgp l2vpn evpn neighbors <neighbor> [advertised-routes|routes]' did
not work due to various bugs. First, the command only accepted IPv4
addresses as valid neighbor ID, thereby rejecting unnumbered BGP and IPv6
neighbor address. Second, the SAFI was hardcoded to MPLS_VPN even though
we were passing the safi. Third, "all" made no sense in the command context
and to make the command uniform across all address families, I removed the
"all" keyword from the command.

Signed-off-by: Dinesh G Dutt <ddps4u@gmail.com>
2019-08-08 04:17:26 +00:00
Russ White
40236bf7c7
Merge pull request #4750 from dslicenc/bgp-remove-replace-as
bgpd: stop removing and replacing private asn if it matches the peer
2019-07-30 11:12:56 -04:00
Don Slice
bf26b80eba bgpd: stop removing and replacing private asn if it matches the peer
Problems reported that if multiple peers have "remove-private-AS
replace-AS" with each other and all are using private asns, the as-path
gets hosed and continues to grow when a prefix is removed.  This fix
disallows removing and replacing the private asn if it matches the
peer's ASN so that normal as-path loop prevention will operate correctly.

Ticket: CM-25489
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-07-29 12:27:03 -07:00
Lakshman Krishnamoorthy
82b692c0cb bgpd: Route-map VNI in-filter filters out all the routes for EVPN
Issue1: When a vni in-filter eg:"neighbor X.X.X.X route-map RM-VNI-FILTER in"
is configured under evpn address-family, all the received routes are dropped
regardless of whether the route has a matching vni or not.
(Where RM-VNI-FILTER contains "match evpn vni 100")

Issue2: Routes with 2 labels are not filtered correctly

Issue3: This filter should not get applied for MPLS routes. For MPLS routes,
we need route-map to handle a 3rd state besides match/nomatch called: noop.

Fix1: The handler bgp_update() that services the received route ignored the
route's label while deciding whether to filter it or not.
As part of the fix, the handler now uses the label info to make the
decision about whether to filter the route or not.

Fix2: route_match_vni() now tries to match both the labels within the route

Fix3: route_match_vni() should return noop when it encounters an mpls based
route. For this, route_map library should handle this 3rd state: RMAP_NOOP.

Related fix : Extract tunnel type
This fix relies on PR 4314 #4314 to extract the tunnel type from bgp extended
communities. The information about the route's tunnel type (vxlan or mpls)
is needed to apply "match evpn vni xx" rule.  This rule is applicable to
vxlan routes, and should exit safely for mpls based evpn routes.

Signed-off-by: Lakshman Krishnamoorthy lkrishnamoor@vmware.com
2019-07-22 08:08:25 -07:00
Lakshman Krishnamoorthy
b68885f9b7 lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP

Traditionally route map MATCH rule apis  were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:

State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away

State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH

We require a 3rd state because of the following situation:

The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.

Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"

With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.

As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-07-22 08:08:13 -07:00
David Lamparter
4a11bf2c09 bgpd: add a hook before bgp_process()
BMP uses this to get notified about any changes to prefixes, at which
point it schedules its own processing to happen later.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-03 16:54:09 +02:00
David Lamparter
b4d46cc9b1 bgpd: count some per-peer stats (for BMP)
These counters are accessible through BMP and may be useful to monitor
bgpd.  A CLI to show them could also be added if people are interested.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-03 16:53:12 +02:00
Biswajit Sadhu
29c8d9da62 bgpd: 'show bgp ipv6 neighbors <X::Y> prefix-counts' prefix-count is
not getting displayed.

Neighbour prefix-count is not getting displayed with IPV6 neighbours
and displays the o/p “ % No such neighbor or address family ”.
However, I observed it is working fine for IPV4 neighbour.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2019-07-01 22:09:57 -07:00
Quentin Young
878918edaa
Merge pull request #4522 from LabNConsulting/working/master/issue4479
bgpd: address issue #4479 crash during instance removal
2019-06-25 11:45:19 -04:00
Sri Mohana Singamsetty
06dbe9ec34
Merge pull request #4544 from chiragshah6/mdev
bgpd: print ecom in evpn route output
2019-06-25 08:45:04 -07:00
Donald Sharp
6d9ed6df1b
Merge pull request #4331 from patrasar/bgp_cli_fix
bgpd : add prefix-length in show ip bgp neighbor advertised routes key
2019-06-21 19:42:19 -04:00
Chirag Shah
6f214dd377 bgpd: print ecom in evpn route output
EVPN route's extended community include
important informations like Mobility sequence,
router mac, and RT values, include the ecomm
in evpn brief output.

Ticket:CM-25353
Testing Done:

Validated in evpn deployment with routes.

TOR#show bgp l2vpn evpn route
...
   Network          Next Hop            Metric LocPrf Weight Path
                    Extended Community

Route Distinguisher: 27.0.0.11:3
*> [2]:[0]:[0]:[48]:[00:02:00:00:00:04]:[128]:[fe80::202:ff:fe00:4]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 ET:8 ND:Router Flag
*  [2]:[0]:[0]:[48]:[00:02:00:00:00:36]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 RT:5546:4003 ET:8 MM:0, sticky MAC Rmac:44:38:39:ff:ff:01
*> [2]:[0]:[0]:[48]:[00:02:00:00:00:36]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 RT:5546:4003 ET:8 MM:0, sticky MAC Rmac:44:38:39:ff:ff:01
*  [3]:[0]:[32]:[36.0.0.11]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 ET:8
*> [3]:[0]:[32]:[36.0.0.11]
                    36.0.0.11                              0 4435 5546 i
                    RT:5546:1008 ET:8

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-06-21 14:21:38 -07:00
vishaldhingra
36a206db61 bgpd : Support for exact-match in match clause for lcommunity
FRR has a provision to give exact-match in match clause for
standard community, but this option is missing for lcommunity.

Part 3 : show related changes for match clause

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-06-19 04:42:48 -07:00
Donald Sharp
3e461df2ea
Merge pull request #4260 from vishaldhingra/lcomm
bgpd: Added the as-set option for IPV6 agg. route
2019-06-18 20:45:57 -04:00
Lou Berger
f4c713ae04 bgpd: handle additional events occuring during instance shutdown
Signed-off-by: Lou Berger <lberger@labn.net>
2019-06-18 11:54:52 +00:00
Donald Sharp
7ec5e2bf70
Merge pull request #4514 from opensourcerouting/warnings-20190612
*: kill more warnings
2019-06-17 15:19:42 -04:00
vishaldhingra
5101feceae bgpd: Added the as-set option for IPV6 agg. route
FRR has no option for the as-set for aggregate route
under IPV6 address family. Added the command to
configure the as-set option for IPV6.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-06-17 01:32:30 -07:00
David Lamparter
2618a52ed3 *: config.h or zebra.h is the first #include
This is mostly relevant for Solaris, where config.h sets up some #define
that affect overall header behaviour, so it needs to be before anything
else.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 13:35:33 +02:00
David Lamparter
899e4095d1 bgpd: fix clang format warning
... by simplifying the code to use %pI6 instead.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 13:35:28 +02:00
Sarita Patra
1608ff7715 bgpd : add prefix-length in show ip bgp neighbor advertised routes key
Issue:
ip route 15.1.1.0/24 10.112.158.15
ip route 15.1.1.0/32 10.112.158.15
Brought up ebgp session between two FRR routers and
redistributed static routes via BGP and verfied the advertising
routes in the peer.

Verify the command "show ip  bgp neighbors <neighbor address>
advertised-routes json". It only shows 15.1.1.0/32 route details.

Root casue:
For both the routes "15.1.1.0/24" and "15.1.1.0/32" the advertised
routes key is the prefix i.e. "15.1.1.0".

Fix:
Modify the key to prefix/prefix-length.

Signed-off-by: Sarita Patra <saritap@vmware.com>
2019-06-11 07:56:15 -07:00
Soman K S
9f822fa2db bgpd: Process core when bgp instance is deleted
* When the bgp is being deleted and routes are in clear workqueue
  and new aggregate address being allocated
* Added flag BGP_FLAG_DELETE_IN_PROGRESS in bgp structure to
  bgp instance is being  deleted
* When adding aggregate route check this flag and  peer_self is valid

Signed-off-by: Soman K S <somanks@vmware.com>
2019-06-11 06:20:09 -07:00
Russ White
488d9e864b
Merge pull request #3555 from pguibert6WIND/bgp_wording_vrf_table
bgpd: use the wording vrf instead of table
2019-06-04 09:14:37 -04:00
Donald Sharp
6fed481c85
Merge pull request #4455 from lkrishnamoor/revert
Revert of PR 4078 and PR 4315
2019-06-04 07:41:09 -04:00
Lakshman Krishnamoorthy
2789041a46 Revert of PR 4078 and PR 4315
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-03 15:43:02 -07:00
Donald Sharp
d8a9922d58 bgpd: Remove BGP_OPT_CONFIG_CISCO
The BGP_OPT_CONFIG_CISCO command could no longer be set
as such remove it from the system as a viable option to
be used.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-03 15:06:16 -04:00
Lakshman Krishnamoorthy
e241544469 bgpd: Filtering received EVPN routes based on VNI does not work
Issue1: When "neighbor X.X.X.X route-map RM-VNI-FILTER in" is configured under evpn address-family,
all the received routes are dropped regardless of whether the route has a matching vni or not.

Issue2: Routes with 2 labels are not filtered correctly

Issue3: Interpreting the label based on tunnel type, vxlan was not done correctly.
Vxlan label has 24 bits, whereas, MPLS label is 20 bits long

Fix1: The handler bgp_update() that services the received route ignored the route's label while deciding whether to filter it or not. As part of the fix, the handler now uses the label info to make the decision about whether to filter the route or not.

Fix2: route_match_vni() now tries to match both the labels within the route, not just the one.

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-05-31 10:22:11 -07:00
Lakshman Krishnamoorthy
eadd168781 lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP

Traditionally route map MATCH rule apis  were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:

Action: Apply route-map match and return the result (RMAP_MATCH/RMAP_NOMATCH)
State1: Receveived RMAP_MATCH
THEN: If Routemap type is PERMIT, execute other rules if applicable,
otherwise we PERMIT!
Else: If Routemap type is DENY, we DENYMATCH right away

State2: Received RMAP_NOMATCH, continue on to next route-map, otherwise,
return DENYMATCH by default if nothing matched.

With reference to PR 4078 (https://github.com/FRRouting/frr/pull/4078),
we require a 3rd state because of the following situation:

The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.

Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"

With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP (or another enum) to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.

Question: Do we repurpose an existing enum RMAP_OKAY or RMAP_ERROR
as the 3rd state (or create a new enum like RMAP_NOOP)?
RMAP_OKAY and RMAP_ERROR are used to return the result of set cmd.

We chose to go with RMAP_NOOP (but open to ideas),
as a way to bypass the rmap filter

As a result we have a 3rd state:
State3: Received RMAP_NOOP
Then, proceed to other route-map, otherwise return RMAP_PERMITMATCH by default.

Signed-off-by:Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-05-30 11:21:28 -07:00
Russ White
4c02c06489
Merge pull request #4377 from ton31337/feature/show_fqdn_in_show_ip_bgp
bgpd: Show FQDN in `show [ip] bgp` output
2019-05-28 07:53:20 -04:00
Donatas Abraitis
25b5da8d50 bgpd: Show FQDN in show [ip] bgp output
We already show this information in `show [ip] bgp <prefix`, thus why don't
show it in global output. It's very handy when using at scale and to see
the whole picture instead of resolving neighbor manually.

It will show FQDN only if `bgp default show-hostname` is toggled.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-05-21 11:28:20 +03:00
David Lamparter
a74879b20e bgpd: fix compiler warning in reason2str
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-20 23:45:34 +02:00
Sri Mohana Singamsetty
02f4c3ab5b
Merge pull request #4349 from donaldsharp/bgp_reason
Bgp reason
2019-05-17 09:51:17 -07:00
Russ White
fca8283e71
Merge pull request #4219 from bisdhdh/biswajitfrr_5
bgpd: Implement 3rd party nexthop for ebgp ipv6 sender, when nexthop matches IPV6 address of the neighbor.
2019-05-16 10:36:02 -04:00
Donald Sharp
0dc8ee7062 bgpd: Display best path selection reason
As part of detailed bgp route detail, include the
reason why a route was selected as best path.

robot# show bgp ipv4 uni 223.255.254.0
BGP routing table entry for 223.255.254.0/24
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  annie(192.168.201.136)
  64539 15096 6939 7473 3758 55415
    192.168.201.136 from annie(192.168.201.136) (192.168.201.136)
      Origin IGP, valid, external, bestpath-from-AS 64539, best (First path received)
      Last update: Wed May 15 21:15:48 2019

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-15 21:47:51 -04:00
Donald Sharp
fdf81fa028 bgpd: Store reason why bestpath was choosen
Store in bgp_node the reason why we choose a particular
best path over another.  At this point we do not do
anything other than just store this data when we make
the decision.  Future commits will display it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-15 21:17:52 -04:00
Donald Sharp
f08b5ca0d9 bgpd: Switch data structure passing to route_vty_out_detail
Instead of just passing in the prefix, pass in the particular
bgp_node we are using.

This is setup for a future commit to use this data.
The long term goal is to collect data about why
a particular bgp_path_info was selected as best and
to display that reason.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-15 21:17:52 -04:00
Lakshman Krishnamoorthy
14f51ebaac bgpd: json cli output for bgp evpn overlay
This diff provides implementation for the cli:
"show bgp l2vpn evpn all overlay json"

Sample output after this change:
leaf-1# sh bgp l2vpn evpn all overlay json
{
  "bgpTableVersion":1,
  "bgpLocalRouterId":"10.100.0.1",
  "defaultLocPrf":100,
  "localAS":65000,
  "10.101.1.4:5":{
    "rd":"10.101.1.4:5",
    "[5]:[0]:[32]:[101.101.101.101]":{
      "prefix":"[5]:[0]:[32]:[101.101.101.101]",
      "prefixLen":288,
      "paths":[
        {
          "valid":true,
          "bestpath":true,
          "pathFrom":"external",
          "nexthop":{
            "ip":"10.100.0.2",
            "afi":"ipv4"
          },
          "overlay":{
            "esi":"00:00:00:00:00:00:00:00:00:00",
            "gw":"0.0.0.0",
            "rmac":"ea:47:79:75:22:1b"
          }
        },
        {
          "valid":true,
          "pathFrom":"external",
          "nexthop":{
            "ip":"10.100.0.2",
            "afi":"ipv4"
          },
          "overlay":{
            "esi":"00:00:00:00:00:00:00:00:00:00",
            "gw":"0.0.0.0",
            "rmac":"ea:47:79:75:22:1b"
          }
        }
      ]
    }
  },

...
...
}

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-05-11 09:47:10 -07:00
Ameya Dharkar
778048bf70 bgpd: BGP debug for route-map apply
Display a debug message while sending a BGP route if the route is filtered by a
route-map.
Debug for incoming filtered route is already present.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-05-10 13:34:08 -07:00
Donatas Abraitis
a8b72dc69e bgpd: Move inbound policy check outside bgp_input_modifier()
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-05-10 17:01:39 +03:00
Biswajit Sadhu
1c42b2e9a1 Merge branch 'master' of https://github.com/frrouting/frr 2019-05-07 03:28:55 -07:00
Donald Sharp
5e76ce5069
Revert "bgpd: Prevent IPv6 routes received via a ibgp session with own ip as nexthop " 2019-05-02 07:15:39 -04:00
Russ White
f4b4d16123
Merge pull request #4192 from bisdhdh/biswajitfrr_4
bgpd: Prevent IPv6 routes received via a ibgp session with own ip as nexthop
2019-05-01 18:12:07 -04:00
Faicker Mo
faf6559a00 bpgd: Add the end of newline of show bgp table json output
Signed-off-by: Faicker Mo <faicker.mo@ucloud.cn>
2019-04-29 17:28:42 +08:00
Biswajit Sadhu
737af8857a bgpd: Prevent the ebgp ipv6 sender from changing of nexthop in a special case.
Prevent the ebgp sender from changing the nexthop( which is same as the ebgp neighbour ipv6 address),
while sending updates to its ipv6 neighbor.So,if the nexthop of the ipv6 route is same as the ipv6
neighbour address do not change the next hop to your own ip.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2019-04-27 04:27:21 -07:00
Russ White
798b3c3469
Merge pull request #4140 from ton31337/fix/do_not_send_notification_again_with_invalid_nlri
bgpd: Do not send UPDATE message with maximum-prefix
2019-04-25 18:43:10 -04:00
Quentin Young
9237bd1807
Merge pull request #4184 from ton31337/fix/documentation_for_as-path_regexp
doc: Specify allowed chars in bgp regular expressions
2019-04-24 11:54:35 -04:00
Donatas Abraitis
513386b57f bgpd: Do not send UPDATE message with maximum-prefix
When using maximum-prefix and count is overflow BGP
sends UPDATE message:

Apr 15 20:45:06 exit1-debian-9 bgpd[9818]: 192.168.0.2 [Error] Error parsing NLRI
Apr 15 20:45:06 exit1-debian-9 bgpd[9818]: %NOTIFICATION: sent to neighbor 192.168.0.2 3/10 (UPDATE Message Error/Invalid Network Field) 0 bytes

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-04-24 14:51:06 +03:00
Biswajit Sadhu
2f6197b044 bgpd: Prevent IPv6 routes received via a ibgp session with own ip as nexthop
Prevent IPv6 routes received via a ibgp session with one of its own interface
ip as nexthop from getting installed in the BGP table.

Implemented IPV6 HASH table, where we need to add any ipv6 address as they
gets configured and delete them from the HASH table as the ipv6 addresses
get unconfigured. The above hash table is used to verify if any route learned
via BGP has nexthop which is equal to one of its its connected ipv6 interface.

Signed-off-by: Biswajit Sadhu sadhub@vmware.com
2019-04-24 00:40:01 -07:00
Donatas Abraitis
a818ea74e6 doc: Specify allowed chars in bgp regular expressions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-04-23 22:35:20 +03:00
Sri Mohana Singamsetty
48db712fa5
Merge pull request #4163 from chiragshah6/evpn_dev2
bgpd: instance delete unimport evpn routes
2019-04-23 09:10:13 -07:00
Donatas Abraitis
c39008533c bgpd: Validate as-path in show bgp regexp
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-04-23 11:25:35 +03:00
Chirag Shah
1b7bb74761 bgpd: instance delete unimport evpn routes
EVPN routes (type-2/type-5) are imported from
default bgp instance (where they are learnt) to
non-default vrf instance.

When a bgp instance (default) is deleted,
unimport evpn routes from vrfs.

In absence of unimport, the imported routes in vrf
has parent path info points to default instance's path
info which is no longer valid (if instance is deleted).
When accessing parent path info leads to a crash
in non-default vrf instance.

The bgp instance is not cleaned up when
'no router bgp ASN' is performed, the instance's
reference count remains for evpn imported routes.

Ticket:CM-24484
Reviewed By:

Testing Done:
Validated via learning EVPN type-2/type-5 routes in symmetric
routing scenario.
The routes are imported to VRFs based on corresponding
L3VNI. When the default instance is removed, the evpn routes
are cleaned up from the VRF instance.

TURTLE(config)# do show bgp vrf vrf3 ipv4 unicast

   Network          Next Hop            Metric LocPrf Weight Path
*> 70.1.0.0/16      0.0.0.0                            32768 i
s  70.1.1.24/32     110.0.0.2                              0 65100 65002 i
s>                  110.0.0.2                              0 65100 65002 i
s  70.1.1.43/32     110.0.0.4                              0 65100 65004 i
s>                  110.0.0.4                              0 65100 65004 i

TURTLE(config)# no router bgp 65050
TURTLE(config)# do show bgp vrf vrf3 ipv4 unicast
No BGP prefixes displayed, 0 exist

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-04-18 09:13:55 -07:00
Lou Berger
817489896f
Merge pull request #3762 from pguibert6WIND/do_not_alloc_lists_fs_by_def
bgpd: do not allocate lists on fs entries of bgp entries.
2019-04-16 11:24:48 -04:00
Donald Sharp
9591da2653 bgpd: Remove extra alloc function bgp_path_info_new
The bgp_path_info_new function whenever it was called
pretty much duplicated the info_make function call.  So
convert over to using it and remove the bgp_path_info_new
function so people are not tempted.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-06 20:10:52 -04:00
Donald Sharp
ea8b228286 bgpd: pi->peer assignment exists no need for null check
The creation of a new `struct bgp_path_info` requires a legitimate
peer being passed in for creation.  There exists no code paths
where this is not true.  As such checking pi->peer for null convinces
SA that it might happen.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-06 20:10:52 -04:00
Renato Westphal
9c14ec7217 bgpd: fix "show bgp statistics" for the VPN safi
In order to iterate over MPLS VPN routes, it's necessary to use
two nested loops (the outer loop iterates over the MPLS VPN RDs,
and the inner loop iterates over the VPN routes from that RD).

The bgp_table_stats_walker() function wasn't giving this special
treatment to the MPLS VPN safi as it should, which was leading to
crashes and malfunctioning. Fix this.

Signed-off-by: Renato Westphal <renatowestphal@gmail.com>
2019-03-30 01:09:23 -03:00
Renato Westphal
b1ec871ab1 bgpd: remove unused variable
pinum (renamed from rinum) was never used for anything useful since
the initial revision ~17 years ago. Get rid of it.

Signed-off-by: Renato Westphal <renatowestphal@gmail.com>
2019-03-30 01:09:23 -03:00
Emanuele Di Pascale
c512a6429c bgpd: fix show bgp labeled_unicast
while labeled_unicast routes should be fetched in the
unicast table, we cannot set the safi to SAFI_UNICAST
else the peer afc checks and subgroup retrieval will fail

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-03-28 19:04:26 +01:00
Philippe Guibert
3e3708cbd3 bgpd: do not allocate lists on fs entries of bgp entries.
bgp entries in bgp_extra_path structure will be allocated as lists, only
when needed, that is to say when bgp fs entries will be received and
installed on the underlying system.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-03-28 16:57:59 +01:00
Sri Mohana Singamsetty
f05d888049
Merge pull request #3892 from vivek-cumulus/evpn_vrf_route_leak
Leaking of EVPN-based IPv4 and IPv6 routes between VRFs
2019-03-15 10:27:13 -07:00
David Lamparter
d3b05897ed
Merge pull request #3869 from qlyoung/cocci-fixes
Assorted Coccinelle fixes
2019-03-06 15:54:44 +01:00
Chirag Shah
5c14a19182 bgpd: router mac same as self supress bgp update
bgp update can contain router mac address same as one of SVIs
mac address, during processing of evpn route in bpg_update()
check for the flag is set and filter the route from installing.
This check is done prior to attribute lookup or storing in database.

Parse check and set is done once during attribute parse
because all the NLRIs containing evpn prefix
(type-2/type-5) will have same exntended community applicable.

Ticket:CM-23674
Reviewed By:CCR-8336
Testing Done:

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-03-04 09:56:13 -08:00
Donald Sharp
3d47101da7
Merge pull request #3743 from NaveenThanikachalam/2990_New
bgpd: Address performance issues in BGP route aggregation.
2019-03-01 09:54:10 -05:00
Naveen Thanikachalam
fc96884124 bgpd: Code to remove the bottleneck in aggregation.
The code that causes the bottleneck has been written generically to
handle the below two cases:
a) When a new aggregate-address is configured.
b) When new routes, that can be aggregated under an existing
aggregate-address, are received.
This change optimizes the code that handles case-(b).

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2019-02-28 20:22:41 -08:00
Naveen Thanikachalam
e00d800877 bgpd: Code to handle BGP aggregate's as-path.
With this commit:
1) 'struct bgp_aggregate' is moved to bgp_route.h from bgp_route.c
2) Hashes to accommodate the as-path, communities, extended-communities and
   large-communities attributes of all the routes aggregated by an
   aggregate route is introduced in 'struct bgp_aggregate'.
3) Place-holders for the aggregate route's as-path, communities,
   extended-communities and large-communities attributes are introduced in
   'struct bgp_aggregate'.
4) The code to manage the as-path of the routes that are aggregatable under
   a configured aggregate-address is introduced.
5) The code to compute the aggregate-route's as-path is introduced.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2019-02-28 20:22:30 -08:00
Mark Stapp
fd2d11fb27
Merge pull request #3876 from qlyoung/fmt-fixes
style fixes...
2019-02-28 15:16:16 -05:00
vivek
f106e3a72d bgpd: Allow EVPN-sourced routes to be leaked back into EVPN
Refine check on whether a route can be injected into EVPN to allow
EVPN-sourced routes to be injected back into another instance.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-28 16:01:38 +00:00
vivek
c27ee4c4e4 bgpd: Fix EVPN advertise route-map application
When a IPv4 or IPv6 route that was formerly allowed by the route-map
to be injected into EVPN gets an updated set of attributes that now
causes it to be filtered, the route needs to be pulled out of EVPN.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-27 08:19:06 +00:00
Quentin Young
dbd587dabc bgpd: fix style for 0f19a8
:|

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-26 19:21:22 +00:00
Quentin Young
0a22ddfbb1 *: remove null check before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:46 +00:00
Tim Bray
e3b78da875 *: Rename backet to bucket
Presume typo from original author

Signed-off-by: Tim Bray <tim@kooky.org>
2019-02-25 16:22:36 +00:00
Renato Westphal
6291837764 bgpd: fix null pointer dereference bug
If path->net is NULL in the bgp_path_info_free() function, then
bgpd would crash in bgp_addpath_free_info_data() with the following
backtrace:

 (gdb) bt
 #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
 #1  0x00007ff7b267a42a in __GI_abort () at abort.c:89
 #2  0x00007ff7b39c1ca0 in core_handler (signo=11, siginfo=0x7ffff66414f0, context=<optimized out>) at lib/sigevent.c:249
 #3  <signal handler called>
 #4  idalloc_free_to_pool (pool_ptr=pool_ptr@entry=0x0, id=3) at lib/id_alloc.c:368
 #5  0x0000560096246688 in bgp_addpath_free_info_data (d=d@entry=0x560098665468, nd=0x0) at bgpd/bgp_addpath.c:100
 #6  0x00005600961bb522 in bgp_path_info_free (path=0x560098665400) at bgpd/bgp_route.c:252
 #7  bgp_path_info_unlock (path=0x560098665400) at bgpd/bgp_route.c:276
 #8  0x00005600961bb719 in bgp_path_info_reap (rn=rn@entry=0x5600986b2110, pi=pi@entry=0x560098665400) at bgpd/bgp_route.c:320
 #9  0x00005600961bf4db in bgp_process_main_one (safi=SAFI_MPLS_VPN, afi=AFI_IP, rn=0x5600986b2110, bgp=0x560098587320) at bgpd/bgp_route.c:2476
 #10 bgp_process_wq (wq=<optimized out>, data=0x56009869b8f0) at bgpd/bgp_route.c:2503
 #11 0x00007ff7b39d5fcc in work_queue_run (thread=0x7ffff6641e10) at lib/workqueue.c:294
 #12 0x00007ff7b39ce3b1 in thread_call (thread=thread@entry=0x7ffff6641e10) at lib/thread.c:1606
 #13 0x00007ff7b39a3538 in frr_run (master=0x5600980795b0) at lib/libfrr.c:1011
 #14 0x000056009618a5a3 in main (argc=3, argv=0x7ffff6642078) at bgpd/bgp_main.c:481

Add a null-check protection to fix this problem.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-20 23:04:12 -03:00
David Lamparter
cbcaac3fb1
Merge pull request #3746 from ton31337/feature/rfc_8212
bgpd: Implement RFC8212
2019-02-19 13:54:23 +01:00
Donatas Abraitis
9dac9fc80e bgpd: Implement RFC8212
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-02-17 23:17:00 +02:00
Anuradha Karuppiah
27f28ccced bgpd: display label as part of the PMSI tunnel attribute
root@TORS1:~# net show bgp l2vpn evpn route rd 27.0.0.15:4 type multicast
EVPN type-2 prefix: [2]:[ESI]:[EthTag]:[MAClen]:[MAC]
EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:[OrigIP]
EVPN type-5 prefix: [5]:[ESI]:[EthTag]:[IPlen]:[IP]

BGP routing table entry for 27.0.0.15:4:[3]:[0]:[32]:[27.0.0.15]
Paths: (1 available, best #1)
  Advertised to non peer-group peers:
  MSP1(uplink-1) MSP2(uplink-2)
  Route [3]:[0]:[32]:[27.0.0.15] VNI 1003
  Local
    27.0.0.15 from 0.0.0.0 (27.0.0.15)
      Origin IGP, weight 32768, valid, sourced, local, bestpath-from-AS Local, best
      Extended Community: ET:8 RT:5550:1003
      AddPath ID: RX 0, TX 10
      Last update: Thu Feb  7 00:17:24 2019
      PMSI Tunnel Type: Ingress Replication, label: 1003 >>>>>>>>>>>>>

Displayed 1 prefixes (1 paths) with this RD (of requested type)
root@TORS1:~#

Ticket: CM-23790

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-02-12 13:06:52 -08:00
rgirada
b4897fa524 bgpd: Added changes to track route-map usage
Made changes and updated the routemap applied counter in the following flows.
1.Increment when route map attached to a list.
2.Decrement when route map removed / modified from a  list.
3.Increment/decrement when route map create/delete callback triggered.
4.Besides ,This counter need not be updated when a route map is got updated.
  i.e changing/adding a match value to the existing routemap.

In BGP , same update api called for all three add/delete/update operation .
But this counter have to be updated only for routemap addition.
Addressed this specific change by identifying the routemap operation based
on routemap pointer.

Signed-off-by: RajeshGirada <rgirada@vmware.com>
2019-02-04 05:27:56 -08:00
Donald Sharp
2b697c3d47
Merge pull request #3414 from pguibert6WIND/iprule_any_flowspec_handling_2
Iprule any flowspec handling
2019-01-29 14:01:38 -05:00
Nitin Soni
8ba7105057 bgpd: fix valgrind flagged errors
Executed some evpn related tests with valgrind and saw some errors
related to uninitialized memory and overlapping memcpy. This commit
fixes those.

Ticket: CM-21218
Signed-off-by: Nitin Soni <nsoni@cumulusnetworks.com>
Reviewed-by: CCR-8249
2019-01-29 06:29:57 -08:00
Philippe Guibert
ce3c06147c bgpd: display the list of iprules attached to a fs entry
the list of iprules is displayed in the 'show bgp ipv4 flowspec detail'
The list of iprules is displayed, only if it is installed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-01-29 14:15:10 +01:00
Philippe Guibert
c7d14ba67c bgpd: do not crash when removing ip vpn entries
when removing bgp instance, the parsing of rm->info contexts must be
protected. Also, the main level of hierarchy of rds must not be
allocated more than once.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-01-21 17:37:05 +01:00
Lou Berger
07f451afef
Merge pull request #3532 from donaldsharp/community_list_speedup
bgp Community list speedup
2019-01-15 10:05:20 -05:00
Renato Westphal
1c4213d862
Merge pull request #3198 from donaldsharp/mac_rejection
Mac rejection
2019-01-10 11:21:18 -02:00
Donald Sharp
e237b0d211 bgpd: Further refine hash lookup to store hash value
Further refine the previous commit to store the hash value in
both the `struct community_list` as well as the `struct rmap_community`
structures.  This allows us to know a priori what our hash value
is.  This change cuts another couple of seconds of convergence
off to ~55 seconds and further reduces cpu load of bgp:

   16      40061.706    433732       92    330102      129   1242965 RWTEX TOTAL

Down from ~43 seconds previously.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-08 20:24:13 -05:00
Philippe Guibert
b84060bbed bgpd: use the wording vrf instead of table
in bgp, even if the main vrf implementation relies on tables, the fact
is some vrf implementation rely on network namespaces, and then the
table used is the default table from the network namespace. Use the
wording vrf instead of table.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-01-07 10:26:54 +01:00
Renato Westphal
79bc257a1d bgpd: fix parsing of community number in the "show bgp community" command
Fixes #3545.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-02 19:32:15 -02:00
Anton Degtyarev
57592a53b5 bgpd, zebra: auto assign labels from label pool to regular prefixes in BGP labeled unicast
This commit is the last missing piece to complete BGP LU support in bgpd. To this moment, bgpd (and zebra) supported auto label assignment only for prefixes leaked from VRFs to vpn and for MPLS SR prefixes. This adds auto label assignment to other routes types in bgpd. The following enhancements have been made:
* bgp_route.c:bgp_process_main_one() now sets implicit-null local_label to all local, aggregate and redistributed routes.
* bgp_route.c:bgp_process_main_one() now will request a label from the label pool for any prefix that loses the label for some reason (for example, when the static label assignment config is removed)
* bgp_label.c:bgp_reg_dereg_for_label() now requests labels from label pool for routes which have no associated label index
* zebra_mpls.c:zebra_mpls_fec_register() now expects both label and label_index from the calling function, one of which must be set to MPLS_INVALID_LABEL or MPLS_INVALID_LABEL_INDEX, based on this it will decide how to register the provided FEC.

Signed-off-by: Anton Degtyarev <anton@cumulusnetworks.com>
2018-12-20 15:28:52 +03:00
Renato Westphal
9e7367db49
Merge pull request #3500 from pguibert6WIND/missing_default_vrf_name
bgpd: nexthop vrf name set to default vrf
2018-12-18 10:44:12 -02:00
Martin Winter
f26be30a4b
Merge pull request #3279 from adharkar/frr-default_local
bgpd: Display default local preference and local AS for BGP show commands
2018-12-18 10:46:58 +01:00
Philippe Guibert
03a6facfd3 bgpd: bgp default vrf in show route naming change
Default vrf name has been changed in show route. Because the default vrf
name can be configured in zebra, the default vrf name in bgp is changed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-17 18:57:22 +01:00
Philippe Guibert
4d97eea630 bgpd: nexthop vrf name set to default vrf
if default vrf is not Default, then nexthop vrf name returned may be
"Default", which is not the correct name of default vrf. change it
accordingly.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-17 17:44:02 +01:00
Donald Sharp
4e802e662e bgpd: Add code to reject mac's and to rescan table
Add some code that will reject local mac's from
being installed and add some code that will cause
a rescan when we have a local mac change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.
2018-12-12 16:11:45 -05:00
Donald Sharp
8cb687c2cb bgpd: Fix soft clear for evpn routes
When you have configured soft reconfiguration inbound
for evpn allow it to notice and send in the evpn data
as appropriate.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-12 16:10:30 -05:00
Lou Berger
9bdb632c68
Merge pull request #3093 from donaldsharp/bgp_node_continued
Bgp node continued
2018-12-11 11:13:25 -05:00
Donald Sharp
a79c04e7fe bgpd: Convert adj_out to a RB tree
The adj_out data structure is a linked list of adjacencies
1 per update group.  In a large scale env where we are
not using peer groups, this list lookup starts to become
rather costly.  Convert to a better data structure for this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-07 10:26:00 -05:00
Ameya Dharkar
01eced229d bgpd: Display default local preference and local AS for BGP show commands
1. "show bgp ipv4/ipv6 [json]"
2. "show bgp ipv4/ipv6 neighbor <peer> routes [json]"
3. "show bgp ipv4/ipv6 neighbors <peer> advertised-routes [json]"

In the above show commands, when a BGP path is displayed, we do not display the
local preference if it is EBGP route. Route calculation assumes the default
local preference. But, we can change the default local preference using
configuration in FRR. In this case, user should know the default local
preference value that is being used in the route calculation. Thus, adding a
new field 'default local preferece' in the show commands where a BGP path is
displayed.

When a BGP path is displayed in the above show commands, as-path does not
include the local AS. So, user has to execute another show command to display
the local-AS. To avoid this, adding a new field local-AS to above show commands.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2018-12-05 11:38:13 -08:00
Philippe Guibert
a2e219fe2e bgpd: reuse bgp_path_info_extra_free() routing in rfapi
rfapi code should use bgp_path_info_extra_free() routine.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-05 15:09:35 +01:00
Donald Sharp
5b00b40eec bgpd: Cleanup bgp_distance_set|get function names
The bgp_distance_set_node_info and bgp_distance_get_node_info
function names were slightly backwards lets fix them up
to bgp_node_get_bgp_distance_info and bgp_node_set_bgp_distance_info

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donald Sharp
5a8ba9fc0a bgpd: Cleanup bgp_static_set|get function names
The bgp_static_set_node_info and bgp_static_get_node_info
function names were slightly backwards rename to
bgp_node_get_bgp_static_info and bgp_node_set_bgp_static_info

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donald Sharp
b613a9183f bgpd: Cleanup bgp_aggregate_set|get function names
The bgp_aggregate_set_node_info and bgp_aggregate_get_node_info
functions names were slightly backwards, rename to
bgp_node_get_bgp_aggregate_info and bgp_node_set_bgp_aggregate_info

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donald Sharp
67009e2200 bgpd: Abstract bgp_table retrieving/setting from info pointer
Convert the set/get of bgp_table's from the info pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00