Commit Graph

1030 Commits

Author SHA1 Message Date
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
Donald Sharp
6f94b685d0 bgpd: Abstract bgp_info retrieving/setting from info pointer
The bgp_info data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Mitch Skiba
dcc68b5e2a bgpd: Re-use TX Addpath IDs where possible
The motivation for this patch is to address a concerning behavior of
tx-addpath-bestpath-per-AS. Prior to this patch, all paths' TX ID was
pre-determined as the path was received from a peer. However, this meant
that any time the path selected as best from an AS changed, bgpd had no
choice but to withdraw the previous best path, and advertise the new
best-path under a new TX ID. This could cause significant network
disruption, especially for the subset of prefixes coming from only one
AS that were also communicated over a bestpath-per-AS session.

The patch's general approach is best illustrated by
txaddpath_update_ids. After a bestpath run (required for best-per-AS to
know what will and will not be sent as addpaths) ID numbers will be
stripped from paths that no longer need to be sent, and held in a pool.
Then, paths that will be sent as addpaths and do not already have ID
numbers will allocate new ID numbers, pulling first from that pool.
Finally, anything left in the pool will be returned to the allocator.

In order for this to work, ID numbers had to be split by strategy. The
tx-addpath-All strategy would keep every ID number "in use" constantly,
preventing IDs from being transferred to different paths. Rather than
create two variables for ID, this patch create a more generic array that
will easily enable more addpath strategies to be implemented. The
previously described ID manipulations will happen per addpath strategy,
and will only be run for strategies that are enabled on at least one
peer.

Finally, the ID numbers are allocated from an allocator that tracks per
AFI/SAFI/Addpath Strategy which IDs are in use. Though it would be very
improbable, there was the possibility with the free-running counter
approach for rollover to cause two paths on the same prefix to get
assigned the same TX ID. As remote as the possibility is, we prefer to
not leave it to chance.

This ID re-use method is not perfect. In some cases you could still get
withdraw-then-add behaviors where not strictly necessary. In the case of
bestpath-per-AS this requires one AS to advertise a prefix for the first
time, then a second AS withdraws that prefix, all within the space of an
already pending MRAI timer. In those situations a withdraw-then-add is
more forgivable, and fixing it would probably require a much more
significant effort, as IDs would need to be moved to ADVs instead of
paths.

Signed-off-by Mitchell Skiba <mskiba@amazon.com>
2018-11-10 00:16:36 +00:00
Russ White
2379dbecbd
Merge pull request #3202 from donaldsharp/evpn_dump
Evpn dump
2018-11-08 18:13:27 -05:00
Rafael Zalamena
591328ffc6
Merge pull request #3205 from donaldsharp/default
bgpd: make name of default vrf/bgp instance consistent
2018-11-07 18:48:21 -02:00
adharkar
2531163802
Merge branch 'master' into frr-bgp_cli 2018-10-31 15:54:43 -07:00
Anuradha Karuppiah
6d8c603a93 bgpd: use IP address as tie breaker if the MM seq number is the same
Same sequence number handling is specified by RFC 7432 -
[
If two (or more) PEs advertise the same MAC address with the same
sequence number but different Ethernet segment identifiers, a PE that
receives these routes selects the route advertised by the PE with the
lowest IP address as the best route.

If the PE is the originator of the MAC route and it receives the same
MAC address with the same sequence number that it generated, it will
compare its own IP address with the IP address of the remote PE and
will select the lowest IP.  If its own route is not the best one, it
will withdraw the route.
]

To implement that specification this commit uses nexthop IP as a tie
breaker between two paths of equal seq number with lower IP winning.

Now if a local path already exists with the same sequence number but higher
(local-VTEP) IP it is evicted (deleted and withdrawn from the peers) and
the winning new remote path is installed in zebra. This is existing code
and handled implicitly via evpn_route_select_install.

If a local path is rxed from zebra with the same sequence as the
current remote winner it is rejected (not installed in the bgp
routing tables) and zebra is asked to re-install the older/remote winner.
This is a race condition that can only happen if bgp's add and zebra's add
cross paths. Additional handling has been added in this commit via
evpn_cleanup_local_non_best_route to take care of the race condition.

Ticket: CM-22674
Reviewed By: CCR-7937

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2018-10-31 06:23:32 -04:00
Don Slice
5742e42b98 bgpd: make name of default vrf/bgp instance consistent
Problems were reported with the name of the default vrf and the
default bgp instance being different, creating confusion.  This
fix changes both to "default" for consistency.

Ticket: CM-21791
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: CCR-7658
Testing: manual testing and automated tests before pushing
2018-10-31 06:20:37 -04:00
Donald Sharp
6cd85474f8
Merge pull request #3121 from pguibert6WIND/flowspec_json_issue
bgpd: fill in prefix for flowspec entry when json format is requested
2018-10-24 19:41:15 -04:00
Sri Mohana Singamsetty
3c1f53dee9 bgpd:Fixing the signature of community_free function
community_free, lcommunity_free and ecommunity_free are similar type of functions. Most of the places, these three are called together. The signature of community_free is different from other two functions. Modified the community_free API signature to align with other two functions to avoid any confusion. There is no functionality impact with this and this is just to avoid any confusion.

Testing: manual testing and show commands
Signed-off-by: Sri Mohana Singamsetty msingamsetty@vmware.com
2018-10-23 09:52:32 -07:00
Philippe Guibert
625d293183 bgpd: fill in prefix for flowspec entry when json format is requested
as prefix is opaque for flowspec, and json needs to have a non empty
full of meaning value in prefix, the proposal is to encode the
displayable form of flowspec entry.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-10-23 16:07:52 +02:00
Donald Sharp
dd18c5a981 bgpd: Add Large community support to aggregate routes
Add the ability to track and support Large communities for aggregate
routes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-16 08:24:01 -04:00
Donald Sharp
3da2cc323f bgpd: Add extended community to aggregates
Add the ability to aggregate routes to handle
extended communities.  Make the actions similiar
to what we do for normal communities.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-16 08:13:03 -04:00
Vincent Bernat
aa0a10fca2 bgpd: fix IPv6 next-hop field name for routes in JSON
This may break existing clients but the original name contains two
errors.

Signed-off-by: Vincent Bernat <vincent@bernat.ch>
2018-10-15 15:08:37 +02:00
Russ White
97dc689417
Merge pull request #3142 from donaldsharp/bgp_peerhash
Bgp peerhash
2018-10-12 16:55:50 -04:00
Ameya Dharkar
37d4e0dfab bgpd: BGP JSON new fields
1. "show bgp ipv4 json"
  - Added "network" field which displays a prefix in 'prefix/prefixlen' format.

2. "show bgp ipv6 json"
  - Added "network" field which displays a prefix in 'prefix/prefixlen' format.
  - JSON does not have "prefix", "prefixLen" fields which are present in IPv4
    command. Added these fields as they are useful.

3. "show bgp ipv4/ipv6 neighbor <neighbor_addr> advertised-routes json"
  - Added "network" field.

4. "show bgp ipv4/ipv6 summary json"
  - Added "pfxSnt" for peers. This count is obtained from corresponding
    update_subgroup.

5. "show bgp neighbor json"
  - Added "sentPrefixCounter"

Signed-off-by: Ameya Dharkar <adharkar@vmware.org>
2018-10-11 15:35:21 -07:00
Donald Sharp
121e245d4f bgpd: Cleanup warnings issued by CI system from these changes
Modify code to cleanup warnings issued by the CI system from
this series of changes.

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:26:30 -04:00
Donald Sharp
9b6d8fcf29 bgpd: Convert binfo to path
Convert the binfo variable to path.

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

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

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Donald Sharp
360660c643 bgpd: Rename some BGP_PATH_XXX to BGP_PATH_SHOW_XXX
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Donald Sharp
825d98347d bgpd: Add ability to dump the bgp peerhash
The bgp->peerhash is a secretive bit of data that we use
to quickly lookup data about peers.  Unfortunately
since we had not way to look at it, we had no way
of knowing if it had gotten in or out of sync.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-07 20:55:52 -04:00
Ameya Dharkar
50e05855f0 bgpd: BGP JSON show commands enhancements
1. "show bgp ipv4 json"
  - Corresponding CLI has "network" field which displays a prefix in
    'prefix/prefixlen' format. Added this "network" field to JSON as well.
  - Following fields have different names in JSON and CLI.
      CLI      JSON
      metric   med
      locPrf   localPref
      path     aspath

    Added fields "metric", "locPrf" and "path" in JSON for CLI/JSON
    consistency. Older JSON fields med, localPref, aspath will be
    deprecated in future.

2. "show bgp ipv6 json"
  - Similar changes as "show bgp ipv4 json"
  - JSON does not have "prefix", "prefixLen" fields which are present in IPv4
  command. Added these fields as they are useful.

3. "show bgp ipv4/ipv6 neighbor <neighbor_addr> advertised-routes json"
  - Added "network" field.
  - Added locPrf, path fields for CLI/JSON consistency. localPref, aspath will
  be deprecated in future.

4. "show bgp ipv4/ipv6 summary json"
  - Added "pfxRcd" for CLI/JSON consistency.
    "prefixReceivedCount" will be deprecated in future.
  - Added "pfxSnt" for peers. This count is obtalned from corresponding
    update_subgroup. This needed a fix in the code where we copy fields
    for a split update_subgroup from the parent update_subgrp.
    New subgrp should inherit subgrp->scount(Count of advertized prefixes)
    of the parent subgrp.

5. "show bgp neighbor json"
  - Added "sentPrefixCounter"

6. "show bgp ipv4/ipv6 <prefix> json"
  - Added "metric" field for CLI/JSON consistency.
    "med" will be deprecated in future.

Signed-off-by: Ameya Dharkar <adharkar@vmware.org>
2018-10-05 15:06:17 -07:00
Quentin Young
cee9c03192 bgpd: complete description code for communities
When this description code was added, it was all dead code since none of
the bools that checked if the communities were present were ever changed
from 0.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-10-04 18:12:33 +00:00
Quentin Young
cf4898bc99 bgpd: fix broken show community commands
SHA c5f1e1b broke about half of the community-related show commands; fix
them

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-10-04 17:46:52 +00:00
David Lamparter
f712c6b369
Merge pull request #3113 from donaldsharp/uninited_value
bgpd: prevent uninited variable from being used.
2018-10-02 16:17:10 +02:00
Donald Sharp
11ebf4ed88 bgpd: prevent uninited variable from being used.
Valgrind reports that temp could be used uninitialized
sometimes.

Signed-off-by: Donald sharp <sharpd@cumulusnetworks.com>
2018-10-02 08:23:11 -04:00
David Lamparter
6a154c8812 *: list_delete_and_null() -> list_delete()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02 11:40:52 +02:00
Don Slice
7ce8a8e022 bgpd: solve issue entering aggregate twice
Problem reported that frr-relaod.py was not installing an aggregate
properly.  Problem was actually that frr-reload.py does the command
twice, and the second time the aggregate command was entered, it would
appear in the config but the aggregate was removed from the bgp table
and not advertised to peers.  Solved by noticing when an aggregate
was marked for deletion (info_invalid) and allowing the re-entry if
the old one was being removed.

Ticket: CM-22509
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-09-28 16:03:42 +00:00
Donald Sharp
a78beeb544 bgpd: Abstract bgp_static retrieving/setting from info pointer
The bgp_static data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-22 14:59:23 -04:00
Donald Sharp
ca2e160d7d bgpd: Abstract distance retrieving/setting from info pointer
The bgp_distance data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-22 14:59:23 -04:00
Donald Sharp
b1e62edd5e bgpd: Abstract aggregate retrieving/setting from info pointer
The aggregate data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-22 14:59:23 -04:00
Quentin Young
1c50c1c0d6 *: style for EC replacements
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:38:57 +00:00
Quentin Young
450971aa99 *: LIB_[ERR|WARN] -> EC_LIB
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:34:28 +00:00
Quentin Young
e50f7cfdbd bgpd: BGP_[WARN|ERR] -> EC_BGP
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 18:51:04 +00:00
F. Aragon
f7813c7c7f
bgpd isisd ospf6d ospfd: variable shadowing fixes
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-12 16:44:36 +02:00
Donald Sharp
29f7d0232e bgpd: Honor origin change in bgp aggregates
When the origin changed we must honor and update the aggregate
to the peer.  This code adds a bit of code to the bgp_aggregate_info_same
code to see if the origin has changed and to indicate that it has.

Fixes: #2993
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-10 10:19:03 -04:00
Don Slice
088f109866 bgpd, ospfd, pimd, zebra: Convert more use_json locations to bool
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-09-04 17:39:04 +00:00
Don Slice
9f049418bc bgpd/ospfd: make bgp and ospf json response a bit more consistent
Problem reported that some bgp and ospf json commands did not return
any json output at all if the bgp/ospf instance did not exist.
Additionally, some bgp and ospf json commands did not return any json
output if the instance existed but no neighbors were defined.  This
fix makes these commands more consistent in returning empty braces for
json output and issue a message if not using json output.  Additionally,
made the flag "use_json" a bool to make it consistent since previously,
it had been defined as an int, char, u_char, and bool at various places.

Ticket: CM-21040
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-30 12:40:18 +00:00
Christoffer
c5f1e1b240
bgp: Add documentation for IANA well-known communities
Coded as part of #2684 and most code written while participating at
BornHack@2018.

bgp_route.c: Changes regarding adding explanations for the IANA
well-known communities added in #2684

Signed-off-by: Christoffer <netravnen@gmail.com>
2018-08-24 23:57:42 +02:00
Donald Sharp
d8d084d97f bgpd: convert zlog_warns to debugs or errors
Several zlog_warns were being used to tell the end
user that bgp had detected a bug.  These all look like information
added during development that can be noted as debugs or logged
as an error situation.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-23 08:36:07 -04:00
Donald Sharp
9ab2969de8 bgpd: Remove warn to file an issue
A warn with a backtrace does not need another warn
to file an issue with Quagga, so just remove it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-23 08:35:01 -04:00
root
b2a9fc6b23 bgpd: Fix memory leak show ip bgp json
Root Cause: In the function bgp_show_table(), we are creating a
json object and a json array with the same name as “json_paths”.
First it will create a json object variable "json_paths" pointing
to the memory allocated for the json object. Then it will create
a json array for each bap node rn (if rn->info is available) with
the same name as json_paths. Because of this, json_paths which was
pointing to the memory allocated for the json object earlier, now
will be overwritten with the memory allocated for the json array.
As per the existing code, at the end of each iteration loop of bgp
node, it will deallocate the memory used by the json array and
assigned NULL to the variable json_paths. Since we don’t have the
pointer pointing to the memory allocated for json object, will be
not able to de-allocate the memory, which is a memory leak here.

Fix: Removing this json object since it is never getting used in
this function.

Testing:  Reproduced the memory leak with valgrind.
With the fix, memory leak gets resolved and checked with valgrind.

Signed-off-by: Sarita Patra saritap@vmware.com
2018-08-22 16:22:17 -07:00
Donald Sharp
1f063a699b
Merge pull request #2884 from opensourcerouting/assorted-20180821
assorted warning fixes
2018-08-22 08:17:32 -04:00
David Lamparter
0e70e6c89d lib/bgpd: re-fix bgp_info_extra_free()
Make the wart slightly less bad... also there is still a possible write
after free here.  This needs to be fixed again, properly, by some
structure changes.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-22 06:32:43 +02:00
Philippe Guibert
503d1ec6eb bgpd: avoid memory leak in bgp flowspec list, plus usage of bool
Avoid memory leak in bgp flowspec list.
Usage of bool parameter instead of int, to handle the number of entries
PBR.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-21 18:30:26 +02:00
Russ White
91a4566c1c
Merge pull request #2852 from donaldsharp/bgp_clean
Bgp clean
2018-08-16 11:30:03 -04:00
David Lamparter
55d3dad27c
Merge pull request #2448 from qlyoung/error-reference-cards
Error Reference Cards
2018-08-16 16:39:40 +02:00
Donald Sharp
deff24cad5 bgpd: Convert warn to debug
There exists a few places where actual debugs were being
displayed as warns.  Convert them over to debugs and
guard as appropriate.

Signed-off-by: Donald Sharp <sharpd@cumulsunetworks.com>
2018-08-16 08:24:16 -04:00
Quentin Young
af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Don Slice
14454c9fdd bgpd: implement zlog_ferr facility for enhance error messages in bgp
Signed-off-by: Don Slice <dslice@cumulusnetworks.com<
2018-08-14 20:02:05 +00:00
Pascal Mathis
89e5e9f028
bgpd: Always show CIDR mask when displaying routes
Classful networking has been obsolete for ages and there is currently an
inconsistency between `show ip route` and `show bgp`, where the first
one always displays the CIDR mask while the second one hides classful
network masks.

This commit adjusts the behavior of `show bgp` to always show the CIDR
mask for a route, even when it is classful.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-08-14 19:40:42 +02:00
Donald Sharp
0ce1ca805d *: ALLOC calls cannot fail
There is no need to check for failure of a ALLOC call
as that any failure to do so will result in a assert
happening.  So we can safely remove all of this code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
Russ White
9728f99449
Merge pull request #2788 from ton31337/fix/print_ipv6_route_if_afi
bgpd: Display `::` if AFI is IPv6, `0.0.0.0` otherwise
2018-08-07 15:58:26 -04:00
Donatas Abraitis
07d0c4ed2d bgpd: Display :: if AFI is IPv6, 0.0.0.0 otherwise
Signed-off-by: Donatas Abraitis donatas.abraitis@gmail.com
2018-08-07 15:37:57 +03:00
F. Aragon
56cb79b6d5
bgpd pimd: return check (Coverity 1472232 1472234)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-08-06 18:17:39 +02:00
Lou Berger
0751b36cd3
Merge pull request #2731 from chiragshah6/mdev
bgpd: route detail output local pref display
2018-08-03 14:12:21 -04:00
Lou Berger
f503378408
Merge pull request #2745 from adharkar/frr-filtered_route
bgpd: Show routes filtered by prefix-list in filter-routes command
2018-07-28 10:16:20 -04:00
Chirag Shah
2551bd4c89 bgpd: route detail output local pref display
Avoid displaying default configured local preference as
part of bgp route's detail output.
Local preference is for iBGP learnt route's. The value could be
default (100) or configured value (via routemap or local pref config cmd).
show bgp afi safi (brief output) does not display,
if the local pref attribute is not set.
Similarly, show bgp afi safi detail route output should display
if the the attribute is set, and should not display configured value.
This way both output would be consistent.
The configured local preference can be seen via running-config.

Ticket:CM-12769
Reviewed By:
Testing Done:

eBGP output:
show bgp ipv4 45.0.3.0/24
BGP routing table entry for 45.0.3.0/24
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  MSP1(uplink-1) MSP2(uplink-2)
  Local
    0.0.0.0 from 0.0.0.0 (27.0.0.9)
      Origin incomplete, metric 0, weight 32768, valid,sourced, bestpath-from-AS Local, best
      AddPath ID: RX 0, TX 7
      Last update: Thu Jul 26 02:10:02 2018

iBGP output:

show bgp ipv4 unicast 6.0.0.16/32
BGP routing table entry for 6.0.0.16/32
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  Local
    6.0.0.16 (metric 20) from tor-12(6.0.0.16) (6.0.0.16)
      Origin incomplete, metric 0, localpref 100, valid, internal, bestpath-from-AS Local, best
      AddPath ID: RX 0, TX 13
      Last update: Thu Jul 26 05:26:18 2018

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-07-27 15:33:26 -07:00
Ameya Dharkar
13c8e163fc bgpd: Show routes filtered by prefix-list in filter-routes command
Update:Addressed review comments

Changed "show bgp ipv4 neighbor filtered-routes"
to show routes filtered by prefx lists, distribute lists and filter lists

Closes: #2653

Signed-off-by: Ameya Dharkar adharkar@vmware.com
2018-07-27 11:23:32 -07:00
Donald Sharp
239b37bb3c bgpd: Notice when we unlock if we should NULL pointer
The bi->net pointer that is being unlocked had a commit
that removed the `bi->net = NULL;` recently.  This code
was preventing a use after free crash being experienced
in other code paths.  While commit 37e679629f was fixing
a different code path crash.

Make the parent->net pointer aware it may be locked/freed
from multiple places and to not NULL the pointer to it
unless we have actually freed the data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-27 10:02:34 -04:00
Russ White
282d51c6be
Merge pull request #2737 from vishaldhingra/master
bgpd: changes for crash seen in BGP on "no rt vpn" bug Id 2667
2018-07-27 09:05:00 -04:00
Ameya Dharkar
f99def6130 bgpd: Show routes filtered by prefix-list in filter-routes command
Changed "show bgp ipv4 neighbor <peer> filtered-routes"
to show routes filtered by prefx lists, distribute lists and filter lists

Closes: #2653

Signed-off-by: Ameya Dharkar adharkar@vmware.com
2018-07-26 14:48:05 -07:00
root
37e679629f bgpd: changes for crash seen in BGP on "no rt vpn" bug Id 2667
There is a default BGP VPN and BGP VRF instance in L3VPN configuration.
The routes are imported and exported between BGP VPN and BGP VRF.
Suppose there is one route in BGP VRF and exported to BGP VPN.
In BGP VPN there is bgp_info struct with bgp_info_extra struct has parent pointer pointing to the bgp_info of BGP VRF.
We take the lock for bgp_node and bgp_info of BGP VRF in the context of BGP VPN.
bgp_info has a back pointer to bgp_node via net.

Now when we have done "no rd vpn" in BGP VRF then in bgp_info_extra_free we have to free the parent resources.
In this context only unlocking is required. It should not set the BGP VRF (bgp_info->net) to NULL.

Signed-off-by: vishaldhingra vdhingra@vmware.com
2018-07-25 05:27:05 -07:00
Philippe Guibert
63a0b7a9f1 bgpd: display more than one FS entre per IP
because the IP destination criterium may match several entries, the show
command may return more than one entry.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-24 12:17:57 +02:00
Philippe Guibert
c26edcda4e bgpd: flowspec pbr entries listed on the bgp information entry
Because one flowspec entry can create 1-N bgp pbr entries, the list is
now updated and visible. Also, because the bgp_extra structure is used,
this list is flushed when the bgp_extra structure is deleted.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-24 12:17:57 +02:00
Ameya Dharkar
d0086e8e39 bgpd: Changes to BGP show json commands
Added localRouterID to "show bgp neighbor json"
Added json O/P to "show bgp [AFI] community <community>"

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2018-07-19 13:46:46 -07:00
Pascal Mathis
3f54c705ec
bgpd: Cleanup of bgp daemon code
This commit removes various parts of the bgpd implementation code which
are unused/useless, e.g. unused functions, unused variable
initializations, unused structs, ...

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-07-07 22:51:13 +02:00
Quentin Young
32ec4bc474
Merge pull request #2602 from pacovn/PVS-Studio_element_overflow
bgpd zebra: element overflow (PVS-Studio)
2018-07-05 17:49:49 -04:00
F. Aragon
b575a12c87
bgpd lib ospfd pimd ripngd: null chk (PVS-Studio)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-07-03 15:39:50 +02:00
F. Aragon
a85297a7c9
bgpd zebra: element overflow (PVS-Studio)
The warning given by PVS-Studio is related to per-element overflow (there is
no real overflow, because of how elements are mapped in the union). This
same warning is typically reported by Coverity, too.

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-07-02 19:06:54 +02:00
Donald Sharp
6a527b2fc1 bgpd: Fix some build issues from removing HAVE_CUMULUS
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-28 20:57:36 -04:00
Donald Sharp
e093d9d57b bgpd: Remove HAVE_CUMULUS from evpn commands
In order to make EVPN behavior work without special casing
the code, bring the evpn commands under HAVE_CUMULUS into
the fold.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-28 20:18:17 -04:00
Quentin Young
dfc5d40e91
Merge pull request #2519 from pacovn/Coverity_1399238_Logically_dead_code
bgpd: dead code (Coverity 1399238)
2018-06-21 14:20:48 -04:00
paco
990f4f9112
bgpd: null check (Coverity 1455380)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-21 18:51:52 +02:00
paco
d87ff2ddf4
bgpd: dead code (Coverity 1399238)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-21 17:22:55 +02:00
Pascal Mathis
1f2263be24
bgpd: Fix crash when showing filtered routes
This commit fixes the issue mentioned in #2419, which is caused by a
double-free. The problem of the current implementation is that
*bgp_input_modifier* already frees the passed attributes under specific
circumstances, which can then lead to a double-free as *bgp_attr_undup*
does not check if the attributes are set to NULL.

As it is not transparent to the function caller if the attributes get
freed or not and the similar function *bgp_output_modifier* also does
not flush the passed attributes, the line has been removed altogether.

All callers of *bgp_input_modifier* already deal by themself with
freeing/flushing/unduping BGP attributes, so it is safe to remove.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-15 00:08:46 +02:00
Chirag Shah
80ced71057 bgpd: Fix bgpd crash in evpn vni route-map
When evpn configured wiht route-map with vni which is not
configured. Upon receiving evpn routes (i.e Type-2, Type-3),
route-map match will be triggered. Since there is no l2vni
exists in db, some of the member fields in bgp_info (i.e.
dummy_info_extra) are passed uninitialized to evpn filter match cb.
This results in inaccessible memory causes crash.

Fix is to memset the bgp_info prior to passing to evpn filter cb.
In evpn vni filter cb, ensure to have NULL check for member filed
of the bgp_info.

memset bgp_info at few places where it is passed to route_match.

Ticket:CM-21335
Reviewed By:
Testing Done:

Configure route-map with not configured l2vni
Simulate to learn l2vpn type-2, 3 route

Restart frr.service with below config
address-family l2vpn evpn
  neighbor fear route-map EVPN_VNI out

route-map EVPN_VNI deny 10
 match evpn vni 140010

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-06-13 10:14:24 -07:00
Donald Sharp
c93a3b77e6 bgpd: Move extra free code and fix a bug.
The bgp_info_extra_free code was the correct place to free
up data associated with the bgp_info pointer when we are
deleting the bgp_info node.

Additionally, if we have a parent pointer, we may not have a net
pointer.  So make sure we do.

Finally clean up the bgp_info_extra_free code so it is a bit
easier to read.  Use variables instead of multiple level
of casting.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-12 15:12:48 -04:00
paco
11f9b4505c
bgpd: OoB access (Coverity 1469897, 1469893)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-11 19:07:13 +02:00
Russ White
c96dfcb980
Merge pull request #2385 from donaldsharp/SA_SA_SA
Some small clang 6.0 cleanups
2018-06-08 06:57:30 -04:00
Russ White
06a4faa7e4
Merge pull request #2349 from donaldsharp/aggregate_stuff
Aggregate stuff
2018-06-08 06:42:24 -04:00
Donald Sharp
ff44f57014 bgpd, lib, ospf6d, vtysh: fix possible snprintf possible truncation
With a new version of clang 6.0, the compiler is detecting more
issues where we may be possibly be truncating the output string.
Fix by increasing the size of the output string to make the compiler
happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-07 19:51:13 -04:00
Lou Berger
7348e571b7
Merge pull request #2335 from donaldsharp/bgp_memory_hooliganism
Bgp memory leaks and crashes?
2018-06-07 06:05:38 -04:00
Donald Sharp
f273fef13f bgpd: Collapse bgp_aggregate_add into bgp_aggregate_route
These two functions are functionally the same, except
bgp_aggregate_route is meant to handle the addition and
deletion of routes, while aggregate_add is meant for all of them.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-06 13:33:19 -04:00
Donald Sharp
eaaf8adb7c bgpd: Allow bgp to know when to actually add/delete agg route
The aggregated route was being sent in updates to peers every
time a route changed that we were aggregating.  Modify
the code such that we only send aggregated route updates
if we actually have something different to tell the peer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-06 13:13:00 -04:00
Donald Sharp
3b7db17342 bgpd: Move bgp_aggregate_delete to a better location
The function bgp_aggregate_delete function was forward
declared and not static.  Move it so we can clean that
up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-06 12:46:14 -04:00
Donald Sharp
c701010e1f bgpd: Seperate out install/removal of aggregate from delete function
This is a transitional commit, to get us where we want to go.
Seperate out the install/removal of the aggregate route from
the bgp_aggregate_delete and bgp_aggregate_route functions.

In the future we'll write a bit of code to determine if the
aggregate add has actually changed any information we care
about.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-06 12:44:07 -04:00
Donald Sharp
3624ac8106 bgpd: Dissallow useless aggregation commands from the cli
We were allowing useless aggregation commands (/32 and /128).
These were being silently accepted and nvgenned and then
just ignored.

When a user enters a value that should be rejected tell
them and reject.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 13:22:11 -04:00
Donald Sharp
cb28a7a514 bgpd: first variable is set but never used.
For the bgp_aggregate_route function it is
set but never used.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:56:46 -04:00
Donald Sharp
c2ff8b3ec9 bgpd: rework bgp_aggregate_route
Make bgp_aggregate_route easier to read.  It was indented so many
levels that it was extremely hard to figure out what it was doing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:55:13 -04:00
Donald Sharp
4c80d4ccba bgpd: Remove AGGREGATE_NEXTHOP_CHECK as it's been unused
The #define AGGREGATE_NEXTHOP_CHECK has not been used
for a very very long time.  Since this is effectively
dead code, let's remove it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:55:13 -04:00
Donald Sharp
b89a6450ba bgpd: Trust the bgp_table_top_nolock for aggregates
The safi passed in to short-circuit the aggregate lookup
adds code complexity and little speed improvements for
the case where we actually may have aggregates configured!
Since bgp_table_top_nolock() actually tells us if there
are any aggregates installed and safely returns if there
is nothing to do, trust it.  As that we know for those
safi's were we don't want to have, we dissallow the
creation via the cli anyways.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:55:13 -04:00
Donald Sharp
09990cddff bgpd: Cleanup bgp_aggregate_set/unset to not worry about safi so much
The bgp_aggregate_set/unset functions are only called from the cli
invocations which control what AFI/SAFI we are looking at.  Tests
for safi are unimportant.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 12:55:13 -04:00
Russ White
ebb46153b0
Merge pull request #2245 from donaldsharp/type_4
Support EVPN Type 4 Routes
2018-06-01 16:00:14 -04:00
Donald Sharp
21d88ef761 bgpd: Lock originating bgp pointer for vrf route leaking
There exists cases where we will attempt to hard delete
the bgp instance( say a `no router bgp` is issued )
when we have vrf route leaking.  If we do have this
lock the bgp instance of the originator and do not
let it be deleted out from under us until we are
finished processing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-31 09:43:07 -04:00
Donald Sharp
122eebd85a bgpd: Fix memory use after free
We were immediately using memory after it was freed.  Fix.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-31 09:43:07 -04:00
Donald Sharp
a9bafa95d0 bgpd: Notice when peer_clear fails
Issue Found by Coverity Scan.  When we call peer_clear we
are checking the return code in every other call.  Add
a bit of extra code to notice the failure and note it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-30 09:37:03 -04:00
Donald Sharp
2bb9eff45f bgpd, lib: Cleanup CI warnings from system
Make the CI system happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-30 07:48:21 -04:00
mitesh
50f74cf131 *: support for evpn type-4 route
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-05-30 07:48:20 -04:00
Jafar Al-Gharaibeh
f7fba3423b
Merge pull request #2248 from ppmathis/enhancement/bgp-adjacent-routes
bgpd: Improve show commands for adjacent routes (advertised/received-routes)
2018-05-27 12:53:33 -04:00
Don Slice
9e6e6f46ee bgpd: additional neighbor message improvement
Added improved error message text to other places that could also
encounter the same condition.  In testing found that in certain
case, duplicate error messages were previously issued.  This fix
also removes the duplicates.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-05-24 10:58:37 -04:00
Donald Sharp
7c82b3120e bgpd: Fix crash on shutdown
There exists code paths where the rn was being used after free.
This eliminates these code paths.

Fixes: CM-21019
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-18 20:40:24 -04:00
Pascal Mathis
b755861b95
bgpd: Fix memleak, adapt adv- to recv-routes code
This commit tries to adapt a similar codeflow within the `show bgp [afi]
[safi] neighbor <neighbor> advertised-routes` command compared to its
`received-routes` and `filtered-routes` opponents. Some branching code
has been restructured to achieve this.

Additionally, this commit fixes a memory leak within `received-routes`
(and `filtered-routes`, although the issue has been present before the
previous commit!) where the previous implementation forgot to
deduplicate the BGP attributes.

When a user called `<...> received-routes route-map <RM-TEST>` and that
routemap changed any AS path or community parameters, the duplicated
memory for these parameters was never freed. This has been fixed by
ensuring to call `bgp_attr_undup()` accordingly.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-16 22:20:44 +02:00
Pascal Mathis
6392aaa654
bgpd: Implement new adjacent route show commands
This commit changes the behavior of `show bgp [afi] [safi] neighbor
<neighbor> received-routes [json]` to return all received prefixes
instead of filtering rejected/denied prefixes.

Compared to Cisco and Juniper products, this is the usual way how this
command is supposed to work, as `show bgp [afi] [safi] neighbor
<neighbor> routes` will already return all accepted prefixes.

Additionally, the new command `show bgp [afi] [safi] neighbor <neighbor>
filtered-routes` has been added, which returns a list of all prefixes
that got filtered away, so it can be roughly described as a subset of
"received prefixes - accepted prefixes".

As the already available `filtered_count` variable inside
`show_adj_route` has not been used before, the last output line
summarizing the amount of prefixes found was extended to also mention
the amount of filtered prefixes if present.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-16 21:13:47 +02:00
Martin Winter
c7e35331e3
Merge pull request #2240 from donaldsharp/ubuntu_bull
Ubuntu 18.04 fixes
2018-05-16 08:36:21 -07:00
Donald Sharp
430892165e bgpd: Prevent possible uninited variable.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-15 13:57:40 -04:00
Pascal Mathis
8d9b8ed99d
bgpd: Improve JSON support for large communities
The current implementation of building JSON output is greatly different
for large communities compared to standard communities. This is mainly
noticeable by the missing 'list' attribute, which usually offers an
array of all communities present on a BGP route.

This commit adds the missing functionality of properly returning a
'list' attribute in JSON output and also tries a similar approach like
the standard communities are using to implement this feature.

Additionally, the 'format' specifier has been completely removed from
large communities string/JSON rendering, as the official RFC8092 specifies that
there is only one canonical representation:

> The canonical representation of BGP Large Communities is three
> separate unsigned integers in decimal notation in the following
> order: Global Administrator, Local Data 1, Local Data 2. Numbers
> MUST NOT contain leading zeros; a zero value MUST be represented with
> a single zero. Each number is separated from the next by a single
> colon. For example: 64496:4294967295:2, 64496:0:0.

As the 'format' specifier has not been used/checked and only one
canonical representation exists per today, there was no reason to keep
the 'format' parameter in the function signature.

Last but not least, the struct attribute 'community_entry.config' is no
longer being used for large communities and instead 'lcommunity_str' is
being called to maintain a similar approach to standard communities.

As a side effect, this also fixed a memory leak inside 'community_entry_free'
which did not free the allocated memory for the 'config' attribute when
dealing with a large community.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-13 19:37:51 +02:00
Russ White
0231e11c1a
Merge pull request #2214 from donaldsharp/pointer_counting
More bgp fixes
2018-05-12 06:38:57 -04:00
Russ White
71ef4ee49a
Merge pull request #2132 from donaldsharp/missed_stuff
Missed stuff
2018-05-12 06:18:15 -04:00
vivek
528cd74fd3 bgpd: Update parent entry's refcount for imported routes
Imported routes in a VRF routing table have a reference to their parent
route entry which resides in the EVPN or IPVPN routing table. Ensure that
this reference uses appropriate locking so that the parent entry doesn't
get freed prematurely.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit 13cb6b22ba9d558b1b4a1e8752f63f13242462a7)

Conflicts:
	bgpd/bgp_mplsvpn.c

Ticket: CM-20471
Testing Done:
a) Ran vrf_route_leak tests without fix and hit crash, ran twice with fix
and did not see the crash.
b) Ran evpn-smoke and ensured there were no new failures.
2018-05-11 08:02:05 -04:00
Russ White
ae57fcbfef
Merge pull request #2137 from mkanjari/evpn-addr-change
*: change struct evpn_addr to include a union of all evpn route types
2018-05-08 19:50:33 -04:00
Donald Sharp
3518f35264 bgpd, lib, zebra: Cleanup formatting issues found
Cleanup the formating issues found.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
Mitesh Kanjariya
ace295a90d bgpd: enable neighbor-nexthop-self for l2vpn evpn address family
In the FRR implementation of EVPN,
eBGP leaf-spine peering for EVPN is fully supported by allowing
the next hop to be propagated and not rewritten at each hop.
There are other changes also related to route import to facilitate this.
However, propagating the next hop is not correct in some cases.
Specifically, if the DC is comprised of multiple PODs
with distinct intra-POD and inter-POD VxLAN tunnels,
EVPN routes received from an adjacent POD by a border/exit leaf
must be propagated into the local POD with the next hop rewritten (to self).

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
Mitesh Kanjariya
2b659f3329 bgpd: modify route install/withdraw logic for evpn type-5 routes in vrf
We install type-5 routes as ipv4/ipv6 unicast routes in the vrf table.
along with these routes, we also install the RMAC
and the nexthop Neigh entries.
There might be scenarios were the bestpath has changed and
we are now pointing to a new nexthop with a different RMAC.
As per BGP logic, we just send an update for the route and the nexthop
is replaced. However, this causes problem because the RMAC and neigh entry
corresponding to the previous nexthop are still lingering in the system.
We need to clear those entries for proper functoning.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
Mitesh Kanjariya
7e4ed18ef5 bgpd: apply advertise ipv4 unicast route-map while advertising type-5 routes
A newly added ipv4/ipv6 route in BGP RIB might be advertised as type-5 EVPN route.
The user might have configured a route-map for advertising type-5 routes.
We need to apply this route-map while advertising ipv4/ipv6 routes as type-5.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
mitesh
3714a3853c *: change struct evpn_addr to include a union of all evpn route types
EVPN prefix depends on the EVPN route type.
Currently, in FRR we have a prefix_evpn/evpn_addr which relates to a evpn prefix.
We need to convert this to encompass an union of various EVPN route-types.

This diff handles the necessary code changes to adopt the new struct evpn_addr.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-05-02 17:49:17 -07:00
Russ White
d437ae815d
Merge pull request #2073 from pguibert6WIND/bgp_fs_pbr
Bgp Flowspec Policy Based Routing
2018-05-02 18:54:11 -04:00
Philippe Guibert
45918cfb97 bgpd: add function handling flowspec entries to pass to zebra
Add a policy-route API to handle flowspec entry.
The entry is analysed, converted, and
selected if it is possible to inject the flowspec entry in local policy
routing entries.
redirect IP and redirect VRF actions are handled. The former extracts
the IPv4 address to redirect traffic to. The latter calculates the
matching VRF to redirect traffic to.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-30 11:56:23 +02:00
G. Paul Ziemba
9df8b37c72 bgpd: when showing routes, add nexthop vrf and announce-self flag
As part of recent vpn-vrf leaking changes, it is now possible for a
route to refer to a nexthop in a different vrf. There is also a new
route flag that means "when announcing this route, indicate myself
as the next-hop."

route_vty_out(): nexthops are appended with:

    "@VRFID" (where VRFID is the numerical vrf id) when different from
    the route's vrf;

    "<" when the route's BGP_INFO_ANNC_NH_SELF is set

This change also shows the route table's vrf id in the table header.

route_vty_out_detail(): show nexthop's vrf and announce-nh-self flag if
appropriate.

Both functions are also augmented to add json elements nhVrfId, nhVrfName,
and announceNexthopSelf as appropriate.

The intent of these changes is to make it easier to understand/debug
the relationship between a route and its nexthops.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-04-27 17:34:43 -07:00
Donald Sharp
13b7e7f007 bgpd: Prevent vrf 2 vrf route leaking from going offbox.
The vrf 2 vrf route leaking auto-derives RD and RT and
installs the routes into the appropriate vpn table.
These routes when a operator configured ipv[4|6] vpn
neighbors were showing up off box.  The RD and RT
values choosen are localy significant but globaly
useless and may cause confusion.

Put a special bit of code in to notice that we
should not be advertising these routes off box.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-25 12:41:17 -04:00
Quentin Young
988258b427 bgpd: move attr display into checked block
Here we have a block conditional on the nullity of a pointer, followed
by a dereferennce of the same pointer. Move the deref into the
conditional block.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-13 17:17:42 -04:00
Donald Sharp
c66faab1ca bgpd: Fix another aspath %d that should be %u
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-12 21:11:39 -04:00
Philippe Guibert
026b914a40 bgpd: the nexthop IP is displayed for FS entries.
Most presumably, the nexthop IP is present, only when ECOM redirect IP
is present. The nexthop is displayed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-09 11:04:14 +02:00
G. Paul Ziemba
960035b2d9 bgpd: nexthop tracking with labels for vrf-vpn leaking
Routes that have labels must be sent via a nexthop that also has labels.
This change notes whether any path in a nexthop update from zebra contains
labels. If so, then the nexthop is valid for routes that have labels.

If a nexthop update has no labeled paths, then any labeled routes
referencing the nexthop are marked not valid.

Add a route flag BGP_INFO_ANNC_NH_SELF that means "advertise myself
as nexthop when announcing" so that we can track our notion of the
nexthop without revealing it to peers.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-04-04 10:00:23 -07:00
Lou Berger
ce7b915214
Merge pull request #1993 from vivek-cumulus/evpn-fixes
Evpn fixes
2018-04-04 11:57:00 -04:00
Philippe Guibert
98a9dbc7ed bgpd: enhance show bgp ipv4 flowspec <IP>
This command gives detail about a FS entry which contains an IP that
matches one of the rules of the FS entry. The output is the same output
as when one does show bgp ipv4 flowspec detail

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-30 14:01:06 +02:00
Philippe Guibert
d33fc23bf8 bgpd: support for json in show bgp ipv4 flowspec commands
The json format is returd when requested from the two commands:
- show bgp ipv4 flowspec
- show bgp ipv4 flowspec detail

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-30 14:01:06 +02:00
Philippe Guibert
dba3c1d3fb bgpd: support for show bgp ipv4 flowspec
The show bgp ipv4 flowspec routine is made available, displays the
flowspec rules contained in the BGP FIB database, as well as the actions
to be done on those rules. Two routines are available:
show bgp ipv4 flowspec
show bgp ipv4 flowspec detail

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-30 14:01:05 +02:00
Philippe Guibert
f77af2c3f2 bgpd: disable aggregation for flowspec entries
Flowspec entries do not need aggregation feature.
Actually, all flowspec entries are unique.
So, some check is done against aggregate functionalities in the code.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-30 14:00:47 +02:00
vivek
884930764f bgpd: Fix use of ROUTE_IMPORTED for EVPN
Ensure that only EVPN routes are flagged as such when installing into or
withdrawing from zebra, the earlier check broke L3VPN or VRF route-leaked
routes. Also, fix an incorrect check related to imported routes in path
selection.

Updates: bgpd: Use BGP_ROUTE_IMPORTED for EVPN [vivek]
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-03-30 00:24:00 +00:00
Quentin Young
d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Philippe Guibert
2d6e6d36d7
Merge pull request #1915 from vivek-cumulus/evpn-ipv6-external-routing
EVPN IPv6 external routing
2018-03-27 17:32:06 +02:00
vivek
568e10ca58 bgpd: Use BGP instance to derive the VRF for route uninstall
When uninstalling routes from zebra, ensure that the BGP instance for
which processing is being done is used to derive the VRF. It is incorrect
to derive the VRF from the peer when dealing with scenarios like VRF route
leaking, EVPN symmetric/external routing etc., where the peer which sourced
the route could belong to a different VRF.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Mitesh Kanjariya <mitesh@cumulusnetworks.com>

Ticket: CM-18413
Reviewed By: CCR-6778
Testing Done: Manual testing of BGP route withdraw/delete, bgp-min
2018-03-21 16:37:24 -04:00
Donald Sharp
3103e8d22f bgpd: Fix peer withdrawal and route leaking for vpn's and vrf's
When a peer is removed the routes are withdrawn via bgp_process_main_one
As such we need to put a bit of code in to handle this situation
for the vpn/vrf route leaking code.

I think this code path is also called for when a vrf's route is
changed and I believe we will end up putting a bit more code
here to handle the nexthop changes.

I've also started trying to document the bgp_process_main_one
function a bit better.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-21 16:37:24 -04:00
vivek
90f4f482c8 bgpd: Use BGP_ROUTE_IMPORTED for EVPN
Set EVPN routes imported into a VRF to (sub)type BGP_ROUTE_IMPORTED and
use this for passing appropriate information to zebra. This is needed
because relying on the Router MAC for this purpose was incorrect and
impacted routing to/from external destinations, particularly for IPv6.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-03-16 23:22:17 +00:00
Donald Sharp
dc38e9ce00 bgpd: Clean up peer status checking for a received nlri
In bgp_update_receive the first thing we do is establish
that the peer->status is Established.  We then do a bunch
of work and call bgp_nlri_parse where we break out for
each address family.  Each AFI is then checking for
being peer->status is Established again.  There is no
point in checking this again.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-16 09:12:55 -04:00
paulzlabn
3f1224cd1a
Merge branch 'master' into working/master/bgp-vpn-vrf-leaking 2018-03-14 13:31:58 -07:00
vivek
88fbc36fcb bgpd: Fix warning
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-03-13 19:42:41 +00:00
vivek
b7d08f5ab5 bgpd: Fix enum, use API for log string
Suggested-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-03-13 18:14:26 +00:00
vivek
783e95b8e8 Merge branch 'master' of https://github.com/frrouting/frr into pmsi-parse-display 2018-03-13 17:50:08 +00:00
Mitesh Kanjariya
9bb3ca515b
Merge branch 'master' into type5-default-originate 2018-03-12 14:47:28 -07:00
vivek
7d39cd191c Merge branch 'master' of https://github.com/frrouting/frr into pmsi-parse-display
Conflicts:
	bgpd/bgp_attr.c
2018-03-10 04:14:17 +00:00
G. Paul Ziemba
ddb5b4880b bgpd: vpn-vrf route leaking
- add "debug bgp vpn label" CLI
    - improved debug messages for "debug bgp bestpath"
    - send vrf label to zebra after zebra informs bgpd of vrf_id
    - withdraw vrf_label from zebra if zebra informs bgpd that vrf_id is disabled
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-09 16:42:40 -05:00
G. Paul Ziemba
e0207895f7 bgpd: some more debug info when 'debug updates out' is set
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-09 16:40:36 -05:00
Mitesh Kanjariya
7b1bf203ca
Merge branch 'master' into type5-default-originate 2018-03-06 13:48:33 -08:00
Lou Berger
996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
vivek
052ea98b43 bgpd: Fix warnings
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-03-04 06:56:19 +00:00
vivek
7fd077aadd bgpd: Parse PMSI Tunnel Attribute and display
Received PMSI tunnel attributes (in EVPN type-3 route) were not recognized.
Parse them and display the tunnel type when looking at routes. Note that
the only tunnel type currently supported is ingress replication (IR). A
warning message will be logged if the received tunnel type is something
else, but the attribute is otherwise ignored.

Updates: a21bd7a (bgpd: add PMSI_TUNNEL_ATTRIBUTE to EVPN IMET routes)
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-03-04 03:28:50 +00:00
Mitesh Kanjariya
fdf19f06f2 bgpd: allow advertise-subnet cmd without enabling advertise ipv4 unicast
Type-5 routes can be useful in multiple scenarios such as advertise-subnet,
default-originate etc. Currently, the code has a restriction that to allow
advertising type-5 routes, user has to first enable advertise ipvX command.
This restriction is not necessary and should be removed.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-22 17:23:07 -08:00
Mitesh Kanjariya
f487dcaf74
Merge branch 'master' into evpn-bug-fixes 2018-02-21 00:36:58 -08:00
Martin Winter
74a75bdbad
Merge pull request #1701 from donaldsharp/zapi_vrf_label
Zapi vrf label
2018-02-13 19:05:42 -08:00
G. Paul Ziemba
d316210b65 whitespace/comment fixes per qlyoung
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-02-09 13:14:22 -08:00
G. Paul Ziemba
a4d82a8adc bgpd: ran indent.py on some files prior to bgp vpn-vrf leaking changes
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-02-09 10:22:50 -08:00
G. Paul Ziemba
9386b58830 bgpd: json route table brace counting
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-02-09 09:39:32 -08:00
vivek
25f2ca5307 bgpd: Ensure EVPN routes are not injected back into EVPN
EVPN type-2 and type-5 routes received with a L3 VNI and corresponding RTs
are installed into the appropriate BGP RIB. Ensure that these routes are not
re-injected back into EVPN as type-5 routes when type-5 advertisement is
enabled; only regular IPv4 routes (and IPv6 routes in future) in the RIB
should be injected into EVPN.

As a benefit of this change, no longer restrict that EVPN type-5 routes
should be non-host routes - i.e., allow /32 IPv4 routes (and /128 IPv6
routes in future).

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>

Ticket: CM-19456
Reviewed By: CCR-7117
Testing Done:
1. Manual replication of problem and verification of fix
2. evpn-min
2018-02-08 23:02:05 -08:00
Donald Sharp
70e98a7fe7 *: Make code use a consisten definition of labels
Turns out we had 3 different ways to define labels
all of them overlapping with the same meanings.
Consolidate to 1.  This one choosen is consistent
naming wise with what the *bsd and linux kernels
use.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 20:31:37 -05:00
mitesh
317f1fe02f zebra/bgpd: fix compilation issues
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-01-23 16:30:40 -08:00
vivek
2f69f6d368 bgpd: Use source route's path attributes for type-5 routes
When an IPv4 or IPv6 unicast route is injected into EVPN as a type-5 route
(upon user configuration), ensure that the source route (best path)'s path
attributes are used to build the EVPN type-5 route. This will result in
correct AS_PATH and ORIGIN attributes for the type-5 route so that it doesn't
appear that all type-5 routes are locally sourced. This is necessary to
ensure that external paths (IPv4 or IPv6 from EBGP peer) are preferred over
internal EVPN paths, if both exist.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>

Ticket: CM-19051
Reviewed By: CCR-7009
Testing Done: Verify failed scenario
2018-01-23 16:24:39 -08:00
Mitesh Kanjariya
31310b25f2 bgpd: advertise VNI subnet
In EVPN symmetric routing, not all subnets are presents everywhere.
We have multiple scenarios where a host might not get learned locally.
1. GARP miss
2. SVI down/up
3. Silent host

We need a mechanism to resolve such hosts. In order to achieve this,
we will be advertising a subnet route from a box and that box will help
in resolving the ARP to such hosts.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-01-23 15:58:53 -08:00
Mitesh Kanjariya
b57ba6d2a8 bgpd: carry two MPLS labels in EVPN NLRIs
When doing symmetric routing,
EVPN type-2 (MACIP) routes need to be advertised with two labels (VNIs)
the first being the L2 VNI (identifying the VLAN) and
the second being the L3 VNI (identifying the VRF).
The receive processing needs to handle one or two labels too.

Ticket: CM-18489
Review: CCR-6949
Testing: manual and bgp/evpn/mpls smoke

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-01-23 15:58:53 -08:00
Renato Westphal
75869e4ad5
Merge pull request #1656 from ak503/bgp
bgp: small fix for write to 'address-family l2vpn evpn' configuration
2018-01-22 17:03:58 -02:00
Philippe Guibert
a8bf7d9c9e bgpd: fix compilation issue with bgpd
Changes due to the change of vrf_id_t moved from 16 bits to 32 bits.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-01-22 13:52:24 +01:00
Donald Sharp
00711784cb
Merge pull request #1630 from LabNConsulting/working/master/pr1629-no-json
bgpd: fix reporting of no vpn routes (no json)
2018-01-19 07:59:34 -05:00
dturlupov
7bcc8dac13 bgp: small fix for write to 'address-family l2vpn evpn' configuration 2018-01-19 10:53:32 +03:00
Russ White
df294c8f2d
Merge pull request #1632 from dwalton76/bgpd-localas-allowasin
BGP "allowas-in" should accept AS paths with "local-as"
2018-01-16 13:48:46 -05:00
Daniel Walton
c4368918e4 BGP "allowas-in" should accept AS paths with "local-as"
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

For issue #1548
2018-01-12 15:31:16 +00:00
Lou Berger
0136788cd3 bgpd: fix summary line reporting routes with RDs (no json case)
Signed-off-by: Lou Berger <lberger@labn.net>
2018-01-12 08:45:48 -05:00
Mitesh Kanjariya
9bb77a5b3d
Merge branch 'master' into evpn-symmetric-routing 2018-01-11 09:00:23 -08:00
Donald Sharp
8356e9b7b0 bgpd: fix failing to compile on 32 bit systems
-Werror=sign-compare is failing with signed/unsigned usage
in the conditional expression.

Fixes: #1593
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-04 05:45:28 -05:00
Don Slice
e2a86ad9b4 bgpd: convert network statements from DEFUN to DEFPY
Problems reported with inconsistent use of parameters for bgp network
statements.  Converted 12 DEFUNs to 2 DEFPY statements, making the
parameter use consistent with the exception of keeping the "backdoor"
keywork ipv4 only.  Also verified that if a route-map or label-index
is specified in the "no" case it matches what had been previously
defined. Manual testing looks good and bgp-smoke will be performed
before pushing.

Ticket: CM-16860
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: CCR-7056
2017-12-21 19:07:56 +00:00
Rafael Zalamena
e492e668b6
Merge pull request #1553 from donaldsharp/bgp_json_routes
bgpd: Speedup vtysh handling of 'show bgp afi safi json' display
2017-12-19 14:49:59 -02:00
Donald Sharp
449feb8ef9 bgpd: Fix double free
The json code was freeing json_paths and then
turning around and free'ing it again.  Newer
versions of json-c have started to assert
this bad behavior.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-19 08:20:30 -05:00
Mitesh Kanjariya
5424b7bad8 bgpd: advertise/withdraw new added/deleted type-5 routes
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:08 -08:00
Donald Sharp
23b2a7ef52 bgpd: Speedup vtysh handling of 'show bgp afi safi json' display
When bgp has a metric butt-load of routes w/ ecmp, this command
can take an inordinate amount of time to run and complete via
vtysh.

Converting the bgp route output in this case back to not
using the json pretty-print drops ~2 minutes of runtime
off.

It is assumed that if users would like pretty output they
can run it through an appropriate tool via a pipe command.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-14 09:31:26 -05:00
Donald Sharp
06b9f471ab bgpd: Fixup buffer sizes for prefix_rd2str
The prefix_rd2str uses a buffer size of RD_ADDRSTRLEN.
Modify the code to consistently use this for all of BGP.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-11 12:39:16 -05:00
Donald Sharp
ff6566f3ef bgpd: Cleanup SA error in ignoring return from function
Ignoring the return from argv_find_and_parse_afi
makes the SA system assume that you could pass a AFI_MAX
value to bgp_show_route.  Which in turn would cause
an array out of bounds read.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-11 08:42:51 -05:00
Donald Sharp
f46d8e1ed0 bgpd: Free up changes to attr that the speculative route-map applied
So we have the ability to apply speculative route-maps to
neighbor display to see what the changes would look like
via some show commands.  When we do this we make a
shallow copy of the attr data structure and then pass
it around for applying the routemap.  After we've applied
this route-map and displayed it we really need to clean
up memory that the route-map application applied.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 08:21:56 -05:00
Donald Sharp
0f672529d8 bgpd: Store original route-map type for the peer
When we are applying an experimental route-map type
to a peer( as part of a show command ) save and
restore the peer's ->rmap_type.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 08:21:56 -05:00
Donald Sharp
b787157a52 bgpd: When we don't have a route-map to apply don't apply the original
When we display the advertised-routes and we don't have a route-map
to apply do not re-apply the route-map.  This does two things:

1) Fixes a display issue with the show command.
2) More importantly stops leaking memory like a sieve for when
   you have a full bgp table.

Fixes: #1345
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 08:21:56 -05:00
Donald Sharp
924c3f6ae9 bgpd: Cleanup indentation a tiny bit
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 08:21:52 -05:00
Renato Westphal
fcaae8e4ec
Merge pull request #1474 from qlyoung/foreach_afi_safi
bgpd: use FOREACH_AFI_SAFI where possible
2017-11-22 13:54:30 -02:00
Quentin Young
05c7a1cc93
bgpd: use FOREACH_AFI_SAFI where possible
Improves consistency and readability.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-21 13:02:06 -05:00
Renato Westphal
859dd94575
Merge pull request #1452 from donaldsharp/rip_nexthops
Blackhole Fixups for bgp and rip
2017-11-21 14:05:19 -02:00
Donald Sharp
8cc8456317 bgpd: Fix json output in some situations
This commit fixes a bug where json output would display
',,,,,,,' because we were deciding to not display information
about some routes due to a selection criteria.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-17 12:53:54 -05:00
Donald Sharp
a69ea8aeac bgpd: Only build json for community when needed
Building a communities json object every time is
both expensive and memory wasteful.  Modify
code to only build the json object when needed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-17 09:04:26 -05:00
Donald Sharp
68e1a55bb1 bgpd: Only create json for aspath if needed
The creation of the json object for the aspath
is both memory intensive and expensive to
create.  Only create the json object when
it is needed and stash it for further usage
at that point.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-16 20:46:37 -05:00
Donald Sharp
9de1f7ff13 bgpd: Allow bgp to understand the different nexthop types
When BGP is being redistributed prefixes, allow it to
understand the nexthop type.

This fixes the issue where a blackhole route was being interpreted
to having a nexthop of 1.0.0.0( ruh-roh!!! ).  This broke
downstream neighbors as that they would receive a 1.0.0.0 nexthop,
which is bad, very very bad.

This commit sets us up for the future where we can match
a route-map against a nexthop type.  In that bgp is
now at least nominally paying attention to the type.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-16 08:45:28 -05:00
Lou Berger
e1541bf66e bgpd: fun with whitespace conventions
Signed-off-by: Lou Berger <lberger@labn.net>
2017-11-07 12:05:09 -05:00
Lou Berger
02a82b47b3 bgpd: allow for vpn->vrf imports
ignore nexthop checks for RFAPI imported routes (as is self)
      note: NHT is still updated

Signed-off-by: Lou Berger <lberger@labn.net>
2017-10-31 11:06:17 -04:00
Donald Sharp
66f80d74d6 bgpd: Cleanup some json output in bgp_route.c
Cleanup the displayed json output to be a bit prettier
to look at.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-27 11:32:17 -04:00
Renato Westphal
cbb65f5ef5 *: fix coverity warnings - error handling issues
Ignore the return value of some functions in the places we know they
can't fail, and other small fixes.

Regarding the change in bgpd/rfapi/rfapi_rib.c, asserting that
rfapiRaddr2Qprefix() didn't fail is the common idiom inside the rfapi
code.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 19:30:30 -02:00
Renato Westphal
cbdb74116f bgpd: remove 'network' commands from the BGP_IPV6L node
These commands don't belong in the BGP_IPV6L_NODE node anymore. A similar
change was done for BGP_IPV4L_NODE in commit 9bedbb1e5.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-09 20:15:14 -03:00
Donald Sharp
445c24803d bgpd: Fixup json with RouteDistinguishers
The json option for displaying a bgp table
with route Distinguishers in it was not properly
working.  This code cleans this issue up.

Additionally attempt to make the code a bit
easier to read and handle.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:12:00 -04:00
Donald Sharp
98ce9a06b4 bgpd: Cleanup bgp_show_table to be easier on the eyes
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:11:49 -04:00
Lou Berger
1ae44dfcba bgpd: unify 'show bgp' with RD with normal unicast bgp show
Signed-off-by: Lou Berger <lberger@labn.net>
2017-10-05 10:11:49 -04:00
Vincent JARDIN
04d14c8be1 scan-build: fix warning
Do not change the implementation, just fix scan-build/clang warning.
2017-10-02 09:14:03 +02:00
Lou Berger
2d9c2ae397 Merge pull request #1261 from dwalton76/bgpd-4byte-display
bgpd: fix 4-byte AS display in bestpath-from-AS
2017-09-28 17:50:19 -04:00
Renato Westphal
67c0a9206c Merge pull request #1180 from dwalton76/ipv6-static-route-null0
Ipv6 static route null0
2017-09-27 13:42:53 -03:00