Commit Graph

316 Commits

Author SHA1 Message Date
kh_shi
c5ca731e64 bgpd: prefer-global command not working on IPv4 peers
`set ipv6 next-hop prefer-global` is not working on IPv4 peers.
In MP-BGP, bgp routers can advertising IPv6 routes over IPv4 peers.
Remove the peer's remote address AFI type checking.

Signed-off-by: shikenghua <kh_shi@edge-core.com>
2019-09-12 10:26:26 +00: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
Donald Sharp
cda7187d27 *: Convert some route map functions to return the enum
Conver these functions:
route_map_add_match
route_map_delete_match
route_map_add_set
route_map_delete_set

To return the `enum rmap_compile_rets` and ensure all functions
that use this code handle all the enumerated possible returns.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-03 08:19:22 -04: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
Donald Sharp
9131e6e818 bgpd: Add 'no set as-path prepend last-as X' command
The `set as-path prepend last-as X` command had no, 'no' form
of the command.  Add this into the cli.

Testing:
!
route-map BLARBLE permit 10
 set as-path prepend last-as 3
!
!
router bgp 9999
 neighbor 10.50.12.118 remote-as external
 neighbor 10.50.12.118 ebgp-multihop 30
 !
 address-family ipv4 unicast
  neighbor 10.50.12.118 route-map BLARBLE in
 !
!

eva# show bgp ipv4 uni 4.4.4.4
BGP routing table entry for 4.4.4.4/32
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  10.50.12.118
  999 999 999 999
    10.50.12.118 from 10.50.12.118 (10.50.12.118)
      Origin incomplete, metric 0, valid, external, best (First path received)
      Last update: Mon Aug 26 09:47:17 2019

eva# conf
eva(config)# route-map BLARBLE permit 10
eva(config-route-map)# no set as-path prepend last-as 3
eva(config-route-map)# end
eva# clear bgp ipv4 uni *
eva# show bgp ipv4 uni 4.4.4.4
BGP routing table entry for 4.4.4.4/32
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  10.50.12.118
  999
    10.50.12.118 from 10.50.12.118 (10.50.12.118)
      Origin incomplete, metric 0, valid, external, best (First path received)
      Last update: Mon Aug 26 09:48:31 2019

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-08-26 09:49:18 -04:00
Naveen Thanikachalam
47c8fa1f87 bgpd: Optimizing route-map's processing of dependencies.
Say for eg., 256 prefix-list entries are pasted to VTYSH.
This results in BGP processing the events for several minutes.

BGPD starts a timer for 5 seconds when the first dependency configuraion
is received. On timer expiry, BGP process dependent route-maps.
After this processing, BGPD reads the configurations received in the
next 5 seconds and then re-processes the route-maps from the beginning.
This cyclic re-processing consumes time and CPU cycles.

Instead of starting a timer when the first configuration is received,
everytime a configuration is received, the existing timer is reset.
This would mean that all the configurations are read first before the timer
expires. This eliminates the cyclic re-processing.

Signed-off-by: NaveenThanikachalam nthanikachal@vmware.com
2019-08-12 00:51:46 -07:00
Quentin Young
8c79e94636
Merge pull request #4705 from ton31337/fix/set_comm-list_delete_into_config
bgpd: Strip `delete` keyword when looking up for large communities
2019-08-05 16:53:45 -04:00
Sri Mohana Singamsetty
b7655d8476
Merge pull request #4713 from ton31337/fix/set_comm-list_delete_into_config_memcpy
bgpd: Strip `delete` keyword when looking up for communities
2019-08-01 21:19:43 -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
Donatas Abraitis
60762f8f19 bgpd: Strip delete keyword when looking up for communities
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-07-19 15:56:58 +03:00
Donatas Abraitis
caa5af30e1 bgpd: Strip delete keyword when looking up for lcommunities
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-07-19 15:48:44 +03:00
Quentin Young
4bb3fb0920
Merge pull request #4609 from ton31337/fix/show_set_comm-list_delete
bgpd: Show `delete` sub-option for `set [l]comm-list <list> delete`
2019-07-09 11:25:10 -04:00
Donald Sharp
2e59405f4c bgpd: extend bgp routemap prefix-list to flowspec entries
Some code to cleanup bgp routemap.c a bit.
Addint to this, if a bgp flowspec entry contains a destination IP address,
then the ip address is compared against the prefix-list referenced into
the route-map used.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Donald Sharp <sharpd@cumulunetworks.com>
2019-07-08 08:36:45 +02:00
Quentin Young
2951a7a4c2 *: s/TRUE/true/, s/FALSE/false/
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-07-01 17:26:05 +00:00
Donatas Abraitis
4cae22692d bgpd: Show delete sub-option for set [l]comm-list <list> delete
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-06-27 08:05:12 +03:00
vishaldhingra
03ff9a1410 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 2 : CLI related changes for match clause

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-06-19 04:37:51 -07: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
b2eea7a00e
Merge pull request #4345 from NaveenThanikachalam/route_map_dep
lib: Changes made to dependencies of a route-map do not take effect dynamically.
2019-06-03 09:19:59 -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
Naveen Thanikachalam
e2c8d6ce90 lib: Changes made to dependencies of a r-map do not take effect.
Say, more than one sequence of a route-map uses the same named entity
in its match clause. After that entity is removed from any one of the
route-map sequences, any further changes made to that entity doesn't
dynamically take effect.
A reference counter, that allows the named entity to keep a count of
the route-maps dependent on it,  has been introduced to address this issue.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2019-05-31 10:05:19 -07:00
Donald Sharp
9c61cec7e3
Merge pull request #4315 from lkrishnamoor/route_map_3rd_state
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
2019-05-30 21:25:18 -04: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
Quentin Young
552d6491f0 bgpd: remove strcpy, strcat
Replace with strlcpy, strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29 18:02:57 +00:00
Donald Sharp
db77a5018d bgpd: Routemap processing was testing for an impossible flag
The flag PEER_FLAG_RSERVER_CLIENT is never set on peer->flags
and as such testing the flag for not being set will never
cause the if statement to be not entered.

Conversely setting update to 0 and then testing if (update && ...
will always cause another if statement to be never called, remove
it as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-17 07:29:47 -04:00
Donald Sharp
097b5973d3 bgpd, lib, ospf6d, ospfd, pimd, zebra: Rework routemap event callback
The route_map_event_hook callback was passing the `route_map_event_t`
to each individual interested party.  No-one is ever using this data
so let's cut to the chase a bit and remove the pass through of data.
This is considered ok in that the routemap.c code came this way
originally and after 15+ years no-one is using this functionality.
Nor do I see any `easy` way to do anything useful with this data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-10 18:43:21 -04:00
Quentin Young
5dbb0a7b2a build: fix Lua build
Each of Lua's major versions are incompatible with each other. Ubuntu,
at least, does not provide a single liblua.so or /usr/include/lua; all
SOs and headers are versioned, e.g. liblua5.3.so and
/usr/include/lua5.3. There's already an m4 macro in the GNU collection
to handle this situation, so let's use that.

This allows building with Lua enabled to work on platforms other than
Fedora.

* Move lib/lua.[ch] -> lib/frrlua.[ch] to prevent path conflicts
* Fix configure.ac search for proper CPP and linker flags
* Add Lua include path to AM_CPPFLAGS
* Update vtysh/extract.pl.in

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-10 16:08:32 +00:00
Sri Mohana Singamsetty
2b38c97fe1
Merge pull request #3909 from AnuradhaKaruppiah/l3-vni-0
bgpd: prevent type-5 route creation if bgp_vrf->l3_vni is 0
2019-03-11 12:05:30 -07:00
David Lamparter
0ff3b1118b
Merge pull request #3855 from donaldsharp/bgp_clist_sa
bgpd: Cleanup cli for [l]community_delete functions
2019-03-06 16:02:01 +01:00
Anuradha Karuppiah
456a4697e5 bgpd: prevent type-5 route creation if bgp_vrf->l3_vni is 0
After a router reboot the L3 network via it converges before the L2
network. This is because MLAG intentionally holds down bridge-access
and vxlan-network ports for some time (MLAG init-delay) to prevent traffic
from switching to a router that is not fully ready. This also means that
routes (from vrf-peering sessions) that qualify for evpn type-5
advertisments are available long before the L3-VNI is available for that
tenant VRF. In these windows bgpd was adding these evpn-type-5 routes with
a L3-VNI of 0 (which was not fixed up after the L3-VNI became available) -

BGP routing table entry for 100.0.0.1:2:[5]:[0]:[0]:[32]:[200.1.1.1]
Paths: (1 available, best #1)
  Advertised to non peer-group peers:
  MSP1(uplink-1) MSP2(uplink-2)
  Route [5]:[0]:[0]:[32]:[200.1.1.1] VNI 0 >>>>>>>>
  65001 65535
    36.0.0.9 from 0.0.0.0 (27.0.0.9)
      Origin incomplete, metric 0, valid, sourced, local, bestpath-from-AS 65001, best
      Extended Community: ET:8 RT:5544:4001 Rmac:44:38:39:ff:ff:01
      AddPath ID: RX 0, TX 327
      Last update: Wed Feb 27 18:37:10 2019

Fix is to defer creating type-5 routes till the L3-VNI is available for
that tenant VRF (this was already being done for most cases; fixup takes
care of some that missed the check).

Ticket: CM-24022

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-03-05 10:40:26 -08: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
Quentin Young
76f0146890 *: do not check XMALLOC / XCALLOC for null ret
They never return NULL

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:44 +00:00
Donald Sharp
a5dc3899a6 bgpd: Cleanup cli for [l]community_delete functions
The community_delete and lcommunity_delete functionality was
creating a special string that needed to be specially parsed.
Remove all this string creation and just pass the pertinent
data into the appropriate functions.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-23 19:27:09 -05:00
Donald Sharp
c393504595 bgpd: Fix compile warning -> error
The struct prefix *prefix is really a const struct prefix *
This was causing compile warns->errors on some compilers

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-22 10:50:14 -05:00
Chirag Shah
1dcc9e5bdb bgpd: vrl source-vrf route map filter
For VRF route leak, enable route map filter based
on "source-vrf" check.

Implemented match filter rule for "source-vrf" which
compares leaked routes original vrf_id (where it leaked from)
during importing into target VRF.

Ticket:CM-23776
Reviewed By:
Testing Done:

Configure vrf route leak from vrf1 to vrf2,
configure import vrf under vrf2 along with route-map
with source-vrf filter.
Add and remove source-vrf filter and checked routes
were added and removed to vrf2 table via vpn (default) table.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-02-19 07:24:19 -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
Nitin Soni
2686df6ad8 bgpd: route-map fails to filter type-5 routes
Route-map filtering is based on the value of
"bgp->adv_cmd_rmap[afi][safi].map". For example, we advertise routes in
bgp_evpn_advertise_type5_routes() based on the value of
"bgp->adv_cmd_rmap[afi][safi].map". This variable gets populated in vty
handler bgp_evpn_advertise_type5. This variable will not get populated
if we have not yet applied the route-map configuration. The fix is to
correctly populate "bgp->adv_cmd_rmap[afi][safi].map" in
bgp_route_map_process_update() if it has not been populated before.

Ticket: CM-23263
Signed-off-by: Nitin Soni <nsoni@cumulusnetworks.com>
Reviewed-by: CCR-8163
2019-01-24 01:43:48 -08: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
Donald Sharp
e9a223ac31 bgpd: Use struct rmap_community when we use community_list_lookup
The community_list_lookup function is being changed in a future
commit.  As such we want to use the `struct rmap_community` data
structure for storing compiled information about communities,ecommunities
or lcommunities.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-08 20:20:34 -05:00
Donald Sharp
76a20aa982 bgpd: Allow shortened 'no set large-community' and 'no set large-comm-list'
These two commands previously required the whole original command but
we should allow the user to shorten out this since the data at the
end is not required to figure out what to delete.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-19 07:30:01 -05:00
Donald Sharp
4db5ee8ea3 bgpd: Allow no set extcommunity [rt|soo]
The ability to shorten the extended community commands for routemaps
upon removal should be allowed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-19 07:23:41 -05:00
Donald Sharp
2929de9ecd bgpd: Allow 'no set community`
Allow user to enter `no set community` to remove the community
set for the route-map.

Fixes: #3491
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-19 07:09:44 -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
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
c983710570 bgpd: Cleanup bgp_route_map_process_update to be readable
Cleanup the bgp_route_map_process_update code to be a bit
easier to read as that it approached the right side of the
80 column limit a whole bunch and became hard to read.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donald Sharp
96f10e1edc bgpd: Fix missed usage of bgp_static_get_node_info()
Fix the missed usage of bgp_static_get_node_info and also
cleanup the function around it that was using it to make
it a bit more readable.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-16 09:43:35 -05:00
Donatas Abraitis
499ceb3dce bgpd: Optionally remove AS number when using no set as-path exclude
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2018-11-15 21:57:34 +02:00
Donald Sharp
093e3f23f6 bgpd, lib, vtysh, zebra: Convert to using CMD_VNI_RANGE
For the vni range use a macro to keep track of it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-31 06:23:32 -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
Donald Sharp
77f4dfb9b0 bgpd: Dissallow v6 routes from setting a v4 nexthop
Do not allow a v6 route to set a v4 nexthop via a routemap.
As that this will crash bgp.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-19 20:43:47 -04:00
Donald Sharp
2b67b6f15a bgpd: Prep commit to cleanup indentation
Signed-off-by: Donald Sharp <sahrpd@cumulusnetworks.com>
2018-10-19 20:38:03 -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
David Lamparter
a762cf08c0
Merge pull request #3102 from ton31337/feature/match_blackhole_nexthops
bgpd: Match routes by type under route-maps
2018-10-02 11:29:59 +02:00
Donatas Abraitis
61ad901e57 bgpd: Match routes by type under route-maps
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2018-10-02 10:57:45 +03:00
Donald Sharp
1d7c7ace3c bgpd: Add lua match command
Please note this is a Proof of Concept and not actually something
that is ready to commit at this point.  The file tools/lua.scr
contains some documentation on how we expect it to work currently.
Additionally not all bgp values have been hooked up into the
ability to lua script yet.

There is still significant work to be done here:

1) Add the ability to pass in more data and to adjust the return values
as appropriate.

To set it up:

1) copy tools/lua.scr into /etc/frr (or whereever the config
directory is )

2) Create a route-map match command:
!
router bgp 55
 neighbor 10.50.11.116 remote-as external
 !
 address-family ipv4 unicast
  neighbor 10.50.11.116 route-map TEST in
 exit-address-family
!
route-map TEST permit 10
 match command mooey
!

3) In the lua.scr file make sure that you have a function
named 'mooey' ( as the above example does ):

function mooey ()
   zlog_debug(string.format("Family: %d: %s %d ifindex: %d aspath: %s localpref: %d",
                            prefix.family, prefix.route,
			    nexthop.metric, nexthop.ifindex, nexthop.aspath, nexthop.localpref))

   nexthop.metric =  33
   nexthop.localpref = 13
   return 3
end

This example script modifies the metric and localpref currently.  I've also provided
a zlog_debug function in lua to allow some simple debugging.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-26 21:21:23 -04: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
8619629ada lib, bgpd, ospf6d, ospfd, pimd: Allow finish to cleanup a bit more
When calling route_map_finish, every place that we do we must
first set the deletion event to NULL, or we will create an infinite
loop, if we are using the delayed route-map application code.
As such we might as well just make the route_map_finish code
do this work, as that there is really no viable alternative here
and route_map_finish should only be called on shutdown.

This fixes an infinite loop in zebra on shutdown when there
are route-maps.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-03 08:22:45 -04:00
Mark Stapp
123214efb8 libs, daemons: use const in route-map apply
Use 'const prefix *' in route-map apply apis; led to some
corresponding changes in several daemons.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-07-23 10:34:35 -04:00
Philippe Guibert
d54600fa83 bgpd: ability to set vpnv4 nexthop with route-map
Ability to set nexthop IP pointer with route-map.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-10 15:22:13 +02:00
Russ White
96be948bcd
Merge pull request #2495 from pacovn/fixme_all_digit
bgpd, lib, ospfd, zebra: all_digit moved to frrstr
2018-06-20 07:38:19 -04:00
Donald Sharp
46a69f10c0 bgpd, lib, zebra: Remove unnecessary return
The route_map_walk_update_list callback function
never uses the return code, so just remove it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-19 21:22:46 -04:00
Donald Sharp
7096e93875 bgpd, lib, pimd: Remove unused variable.
route_map_mark_updated has a `int del_later` variable
that is passed in but never used.  Just remove it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-19 20:44:15 -04:00
paco
5d5ba0185d
bgpd, lib, ospfd, zebra: all_digit moved to frrstr
This solves a pending FIXME

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-19 17:59:53 +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
Pascal Mathis
09cd98ebee
bgpd: Improve route-map matching for INET(6) AF
While the current implementation does pay attention to the AF
(inet/inet6) when comparing the IPv4/v6 address against an address-list
/ prefix-list inside a route-map, the AF check is being done rather
late, which leads to CPU cycles being wasted due to unnecessary list
lookups / address matching.

This commit checks the address family of a prefix right inside the
`route_match_ip(v6)_` functions before looking up any address- and/or
prefix-list, which should improve performance.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-15 19:44:06 +02: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
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
paulzlabn
3f1224cd1a
Merge branch 'master' into working/master/bgp-vpn-vrf-leaking 2018-03-14 13:31:58 -07:00
Mitesh Kanjariya
9bb3ca515b
Merge branch 'master' into type5-default-originate 2018-03-12 14:47:28 -07: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
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
Mitesh Kanjariya
6fb219da87 bgpd: provide a match clause to match EVPN default route
A Border Leaf can originate a default route
for all the leafs within the POD.
However, we do not want to advertise this route outside the POD.
Therefore, we provide an option
to filter a EVPN type5 default route through a route-map.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-22 17:42:07 -08:00
Mitesh Kanjariya
53c84f7800 bgpd: Policy to control which RIB routes are injected into EVPN
FRR/CL provides the means for injecting regular (IPv4) routes
from the BGP RIB into EVPN as type-5 routes.
This needs to be enhanced to allow selective injection.
This can be achieved by adding a route-map option
for the "advertise ipv4/ipv6 unicast" command.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-12 16:02:15 -08:00
Donald Sharp
420016643c
Merge pull request #1735 from LabNConsulting/working/master/pre-vpn-vrf-leak-indenting
Working/master/pre vpn vrf leak indenting
2018-02-10 09:24:40 -05:00
Renato Westphal
1a6219e1a3
Merge pull request #1700 from mkanjari/evpn-symm-routing-enhancements-2.0
EVPN Symmetric routing enhancements 2.0
2018-02-09 21:20:27 -02: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
mitesh
d4ef18b6a7 bgpd: match evpn route type command should use '<>' instead of '{}'
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-05 13:56:12 -08:00
Mitesh Kanjariya
33c2ff625e bgpd: support for filtering EVPN routes based on route-types.
In many situations, it is desirable to only exchange EVPN routes of a particular type.
For e.g., a common deployment scenario for large DCs
is to sub-divide the DC into multiple PODs with full host mobility within a POD
(i.e., all subnets provisioned on all leaf switches within the POD)
but only do prefix-based routing across PODs.
This can be achieved by only exchanging EVPN type-5 routes across PODs.

Implement a policy to filter EVPN routes based on route type.

Ticket: CM-19394
Review: CCR-7139
Testing: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-01-25 17:26:36 -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
Donald Sharp
116e176d99 bgpd, zebra: Use sscanf return value
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-04 21:28:19 -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
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
a633d869cc bgpd: XMALLOC usage causes borken assumption in route_match_peer_free
The usage of XMALLOC for route_match_peer_compile causes
the pc->interface to be non-NULL.  The code assumes that
pc->interface will be NULL.

Ticket: CM-18824
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-14 19:53:46 -05:00
Donald Sharp
7aacfd1b46 bgpd: Allow 'match peer' for all route-map types
There are multiple places that we use route-maps in bgp
There is no need to limit the route-map 'match peer ...' command
to just import and export route-map types.  I see need for
using this in table-maps as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25 09:24:53 -04:00
Donald Sharp
8c3433e490 bgpd: Allow peer interface name to match
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25 09:24:53 -04:00
Donald Sharp
b9269f8282 bgpd: Note routemap information even if peer not activated.
If upon bgp startup we have this config:

router bgp 64540
 neighbor 192.168.201.134 remote-as external
 !
 address-family ipv4 unicast
  no neighbor 192.168.201.134 activate
  neighbor 192.168.201.134 route-map NEXTHOP in
 exit-address-family

The route-map map pointer for the incoming(or outgoing)
filter was not being saved due to a pre-mature optimization
of not handling the routemap callback if the peer is not
activated.  The function that handles the peers route-maps
is making sure that the peer is in established state
before attempting to actually apply anything so just
call it to set the map pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-20 09:56:12 -04:00
Daniel Walton
d114b977e9 *: support keywords that begin with uppercase letter
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

VARIABLE tokens must be all uppercase, this allows us to support WORD
tokens that begin with an uppercase letter.  The "Null0" keyword is an
example of where this is needed.

The only VARIABLE we had that wasn't already all uppercase was
ASN:nn_or_IP-address:nn
2017-09-14 18:07:30 +00:00
Renato Westphal
5ba345ccb2 Merge pull request #1047 from dwalton76/bgpd-draft-ietf-grow-bgp-gshut-10
bgpd: implement draft-ietf-grow-bgp-gshut-10
2017-09-05 10:20:49 -03:00
Nigel Kukard
4265a53eba bgpd: Fixed potential memory leak if additive is false
The else portion of the IF dups the lc, but doesn't free old

Signed-off-by: Nigel Kukard <nkukard@lbsd.net>
2017-08-31 23:39:53 +00:00
Nigel Kukard
f24804f401 bgpd: Fixed potential memory leak if additive is false in normal communities
The else portion of the IF dups the community, but doesn't free old

Signed-off-by: Nigel Kukard <nkukard@lbsd.net>
2017-08-31 23:39:53 +00:00
Nigel Kukard
770817b408 bgpd: Fixed typo in comment
Signed-off-by: Nigel Kukard <nkukard@lbsd.net>
2017-08-31 23:39:53 +00:00
Daniel Walton
7f32323620 bgpd: implement draft-ietf-grow-bgp-gshut-10
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-08-25 18:27:49 +00:00
Donald Sharp
9ca25fedba *: Add RMAP_COMPILE_SUCCESS to enum
Add the RMAP_COMPILE_SUCCESS and switch over to using it.
Refactoring allows a removal of a if statement to just
use the switch statement already in place.  Additionally
the reworking cleans up memory freeing in a couple of spots.
In one spot we no longer will leak memory too.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-25 10:48:30 -04:00
Renato Westphal
0af35d90a1 *: fix assorted issues detected by Coverity Scan
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-24 21:49:39 -03:00
Quentin Young
cca30ba8a9
bgpd: add no set ip next-hop unchanged
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-10 12:55:32 -04:00
Quentin Young
89602edb31
lib, bgpd: fix set ip next-hop peer-address
This bgp-specific command had its positive form defined only in bgpd and
its negative form defined only in lib, which broke the whole rule for
other daemons.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-10 12:31:47 -04:00