Commit Graph

223 Commits

Author SHA1 Message Date
Sebastien Merle
31f937fb43 lib, zebra: Add SR-TE policy infrastructure to zebra
For the sake of Segment Routing (SR) and Traffic Engineering (TE)
Policies there's a need for additional infrastructure within zebra.
The infrastructure in this PR is supposed to manage such policies
in terms of installing binding SIDs and LSPs. Also it is capable of
managing MPLS labels using the label manager, keeping track of
nexthops (for resolving labels) and notifying interested parties about
changes of a policy/LSP state. Further it enables a route map mechanism
for BGP and SR-TE colors such that learned BGP routes can be mapped
onto SR-TE Policies.

This PR does not introduce any usable features by now, it is just
infrastructure for other upcoming PRs which will introduce 'pathd',
a new SR-TE daemon.

Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-08-07 11:08:49 +02:00
Donald Sharp
00aef028f6 lib: Put back applied count for route-maps
The applied count for individual sub sections of route-maps
was lost.  Put it back.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-04 10:16:14 -04:00
Donald Sharp
b34232cf86 lib, tests: Add notation about whether or not a route-map is about to be reprocessed
When you make a change to a route-map or a prefix-list it depends on, note
that the route-map needs to be reprocessed for the change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-04 10:16:09 -04:00
Donald Sharp
3eb15671ee
Merge pull request #6731 from opensourcerouting/style-string-prep
*: string coding style
2020-07-15 20:06:55 -04:00
Russ White
9a4dee5c35
Merge pull request #6736 from NaveenThanikachalam/rmap_noop
libfrr: Retain return value if the best index is found
2020-07-15 10:51:41 -04:00
Naveen Thanikachalam
1410dd3f1b libfrr: Retain ret value if the best idx is found
While iteratively looking for a best match route-map index amongst
a list of potential best match route-map indices, if a candidate
best match index is already found, disregard the value returned by
the function route_map_apply_match() if it returns either RMAP_NOOP
or RMAP_NOMATCH in the following iterations.
This is because if a best match route-map index is found then, the
return value must always be set to RMAP_MATCH.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-07-14 09:28:38 -07:00
David Lamparter
3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

  .. [#tool_style_conflicts] For example, lines over 80 characters are allowed
     for text strings to make it possible to search the code for them: please
     see `Linux kernel style (breaking long lines and strings)
     <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_
     and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00
Donald Sharp
f24db7598e
Merge pull request #6403 from NaveenThanikachalam/FRR_RMAP_FIX
lib: Fix erroneous r-map behavior
2020-07-10 08:07:04 -04:00
Rafael Zalamena
f095133583 lib: fix route map description memory leak
Route map entries are not getting a chance to call `description` string
deallocation on shutdown or when the parent entry is destroyed, so lets
add a code to handle this in the `route_map_index_delete` function.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-07-06 13:14:41 -03:00
Donatas Abraitis
c415a4dcd4 lib: Make sure route_map_dep_data is not NULL before decrementing refcount
```
2  0x00007fb9adb07a10 in core_handler (signo=11, siginfo=0x7ffe1414a630, context=<optimized out>) at lib/sigevent.c:228
        sa_default = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
        sigset = {__val = {8192, 0 <repeats 15 times>}}
3  <signal handler called>
No locals.
4  route_map_dep_update (type=RMAP_EVENT_CLIST_DELETED, rmap_name=0x55d807ddd410 "export4-as49917", dep_name=<optimized out>, dephash=0x55d807adf170) at lib/routemap.c:2750
        dep = 0x55d807d35b00
        dname = 0x55d8081ba560 "123:124"
        rname = 0x55d8081ba540 "export4-as49917"
        ret = 0
        dep_data = 0x0
        ret_dep_data = 0x0
        tmp_dep_data = {rname = 0x55d8081ba540 "export4-as49917", refcnt = 0}
5  route_map_upd8_dependency (type=RMAP_EVENT_CLIST_DELETED, arg=<optimized out>, rmap_name=0x55d807ddd410 "export4-as49917") at lib/routemap.c:2865
        upd8_hash = 0x55d807adf170
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-06-08 16:15:43 +03:00
Naveen Thanikachalam
3eca871582 lib: Fix erroneous r-map behavior
The route-map optimization is not equipped to match IPv6 next-hop
criteria while evaluating IPv4 routes with IPv6 next-hops.
Similary, it is also not equipped to match IPv4 next-hop criteria
while evaluating IPv6 routes with IPv4 next-hops.
This change addresses these issues.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-05-26 06:01:54 -07:00
David Lamparter
f4b8291fcb *: move CLI node names to cmd_node->name
And again for the name.  Why on earth would we centralize this, just so
people can forget to update it?

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:59 +02:00
David Lamparter
612c2c15d8 *: remove second parameter on install_node()
There is really no reason to not put this in the cmd_node.

And while we're add it, rename from pointless ".func" to ".config_write".

[v2: fix forgotten ldpd config_write]

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
249a771b63 *: remove cmd_node->vtysh
The only nodes that have this as 0 don't have a "->func" anyway, so the
entire thing is really just pointless.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
62b346eefa *: clean up cmd_node initializers
... and use named assignments everywhere (so I can change the struct.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
Donatas Abraitis
15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Donatas Abraitis
a8f58eb6a5 *: Use short version of bool expressions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04 15:04:23 +02:00
Donald Sharp
7f5818fbd6 *: change hash_backet to hash_bucket
It's been a year search and destroy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-28 13:59:13 -05:00
Jafar Al-Gharaibeh
4d67e75282 Revert "*: change hash_backet to hash_bucket"
This reverts commit 3895c42a2e.

LabN CI update needs to be coordinated before merging this

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2020-02-27 09:52:02 -06:00
Donald Sharp
3895c42a2e *: change hash_backet to hash_bucket
It's been a year search and destroy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-26 20:03:34 -05:00
Donald Sharp
64c0f439d2
Merge pull request #5270 from NaveenThanikachalam/rmap
lib: Optimizing route-maps
2020-02-25 09:15:49 -05:00
Rafael Zalamena
1c4eca648c lib: fix route-map coverity scan issue
Use better TAILQ free idiom to avoid coverity scan warnings. This fixes
the coverity scan issue 1491240 .

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-19 10:35:28 -03:00
Naveen Thanikachalam
2d26f094c1 lib: Optimizing route-maps - Part-3
* This commit implements the code style suggestions from Polychaeta.
* This commit also introduces a CLI to toggle the optimization and, a hidden
  CLI to display the contents of the constructed prefix tree.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-02-18 02:08:29 -08:00
Naveen Thanikachalam
819a23f9fc lib: Optimizing route-maps - Part-2
This commit introduces the logic that computes the best-match route-map index
for a given prefix.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-02-18 02:08:29 -08:00
Naveen Thanikachalam
49a08bb091 lib: Optimizing route-maps - Part-1
* This commit introduces the building blocks.
    A per-route-map prefix tree is introduced.
    This tree will consist of the prefixes defined within the prefix-lists
    that are added to the match clause of that route-map.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-02-18 02:08:14 -08:00
Donatas Abraitis
752022670a *: Remove break after return
Just a deadcode.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-13 15:39:54 +02:00
Renato Westphal
4b08a72ed1
Merge pull request #5763 from ton31337/fix/return_without_parent
*: Remove parenthesis on return for constants
2020-02-10 18:49:06 -03:00
Donatas Abraitis
95f7965d09 *: Remove parenthesis on return for constants
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-09 14:21:56 +02:00
Donald Sharp
792465c09f
Merge pull request #5104 from opensourcerouting/route-map-nbv2
lib: migrate route map to use northbound
2020-02-05 11:54:21 -05:00
Rafael Zalamena
54a35ff48b lib: fix route map northbound memory leak
Keep a list of hook contexts used by northbound so we don't lose the
pointer when free()ing the route map index entry data.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Rafael Zalamena
a162869ef0 lib: fix route map generic error output
Two fixes here:

*   Don't attempt to use `vty` pointer in vty;
*   When `vty` is unavailable output to log;

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Rafael Zalamena
2b3e4807ec lib: implement new route map CLI
Use the northbound back-end instead of the old route map CLI.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Rafael Zalamena
a7282663ef lib: export route map structures and functions
These exported items are going to be used by the new northbound CLI.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Quentin Young
b3ba5dc7fe *: don't null after XFREE; XFREE does this itself
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-03 11:22:13 -05:00
David Lamparter
1b3e9a21dd lib: make some variables static
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-13 06:22:34 +01:00
David Lamparter
364deb0487 *: make all route_map_rule_cmd const
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-30 00:38:32 +01:00
vdhingra
909f3d56ae lib: rmap dep table is not correct in case of exact-match clause
User pass the string match large-community 1 exact-match from CLI.
Now route map lib has got the string as "1 exact-match". It passes the string
to call back for compilation. BGP will parse this string and came to know
that for "1" it has to do exact match. Routemap lib has to save "1" in it’s
dependency table. Here routemap is saving this as a “1 exact-match”
which is wrong. The solution is used the compiled data.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-09-15 05:45:27 -07: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
Donald Sharp
e5b4b49e80 lib: Cleanup return codes to use enum values
A couple functions in routemap.c were returning
0/1 that were being mapped into the appropriate
enum values on the calling functions to check return
values.  This matches the return values to the actual
enum for future readability.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-03 08:19:22 -04: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
Sri Mohana Singamsetty
4b7269c42f
Merge pull request #4570 from donaldsharp/route_map_clear
lib: Add `clear route-map counters [WORD]` command
2019-06-25 10:34:11 -07:00
Donatas Abraitis
f554fda700 rmap: Minor changes in comments regarding match ip[v6] next-hop type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-06-22 09:49:33 +03:00
Donatas Abraitis
d8524fbef4 rmap: Modify cli helper text for match_ipv6_next_hop_type_cmd
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-06-22 09:29:19 +03:00
Donald Sharp
55858394f2 lib: Order show run route-map order to be alphabetical
When running `show run` of route-maps the order is basically
the order read in some fashion.  Convert the display to
always be the alphabetically sorted order.

Suggested-by: Manuel Schweizer <manuel@cloudscale.ch>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-20 15:03:05 -04:00
Donald Sharp
1fa305095a lib: Add clear route-map counters [WORD] command
This will allow the end-user to clear the counters associated
with the route-map.  Subsuquent `show route-map ..` commands
will display counters since the last clear.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-20 14:10:44 -04:00
Ameya Dharkar
e3ab8170bd Lib: Debugs for route-map code in FRR
Added a CLI "debug route-map" to enble route-map debugs

Added debugs for following triggers
1. Add/delete a route-map
2. Add/delete a sequence in route-map
3. Add/delete a match statement(dependency)
4. Update a dependency
5. Apply a route-map

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-06-11 16:17:15 -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
f232dd29c1 lib: Cleanup recent commit warn->werror issues in lib/routemap.c
The get_route_map_delete_event function should return a value
even if we never get to that part of the function.  Make sure
we know why we are here so it can be fixed appropriately in
the future.

Signed-off-by: Donald Sharp <sharpd@cumulusnetwork.com>
2019-06-03 10:44:23 -04: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
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
Mark Stapp
4ce7e912ce
Merge pull request #4352 from donaldsharp/routemap_fix_replace
lib: Fix gcc 9.1 and --enable-werror issues found
2019-05-16 11:01:20 -04:00
Donald Sharp
4255dbe9bb lib: Fix gcc 9.1 and --enable-werror issues found
Compiling FRR w/ gcc 9.1 and --enable-werror generates some
issues that need to be cleaned up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-16 09:20:12 -04:00
Quentin Young
d8b87afe7c lib: hashing functions should take const arguments
It doesn't make much sense for a hash function to modify its argument,
so const the hash input.

BGP does it in a couple places, those cast away the const. Not great but
not any worse than it was.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-14 21:23:08 +00: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
Donald Sharp
ba1707ca54 lib: in routemap.c if using a switch for an enum get rid of enum
From looking at a current PR: #4297, we see that routemap.c code
was not properly updating dependency information for some
route_map_event_t enum types.  This has lead to dependancy
information not being updated properly.  While at this time
I do not know whether or not we need to update the switch
for the missing types, I do know that if we add something in
the future we should make the person adding the code consider
this.  So let's remove all `default:` switch statement handlers
from routemap.c when switching on an enum.  Future time will
need to be spent to figure out what is needed to be done here.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-10 18:33:22 -04:00
Donald Sharp
c85711a8c9
Merge pull request #4297 from vishaldhingra/rmap
lib : Child rmap not sending an update to parent rmap,if there is an update in child rmap.
2019-05-10 09:04:59 -04:00
Naveen Thanikachalam
6c3247bd2a lib, bgpd: Disallow processing of duplicate config.
This fix aims to reduce the load on BGPD when certain
exisiting configurations are replayed.
Specifically, the fix prevents BGPD from processing
routes when the following already existing configurations
are replayed:
1) A match criteria is configured within a route-map.
2) When "call" is invoked within a route-map.
3) When a route-map is tied to a BGP neighbor.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2019-05-08 21:22:23 -07:00
vishaldhingra
5ed2e47bbd lib : Child rmap not sending an update to parent rmap,if there is an update in child rmap.
Route map library creates a hash table to save the dependency binding.
route-map LRM permit 1
call rLRM
Whenever there is change in child routemap(rLRM), it tries to
find the dependency mapping with the child route map MATCH event
and it fails.The handing of match add and match delete was missing
to get the correct dependency,here it's LRM.
This fix would correct the flow to get the correct dependency.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-05-08 20:59:15 -07: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
rgirada
4a2a09d03d lib: Implemented a cli "show route-map-unsed" to track all unsed routemaps.
Made the following changes.
1.Defined two apis in routemap-lib, one for increment and another for
  decrement the applied counter.
2.Added a  new configuration “show route-map-unused” to track all unused
  routemaps.
3.called the corresponding route map update api when a route map attached
  or detached from any redistribution list.

Signed-off-by: RajeshGirada <rgirada@vmware.com>
2019-02-04 05:04:23 -08:00
David Lamparter
064518517c Merge branch 'pull/3197'
...with a nit fix

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-23 12:31:25 +02:00
Renato Westphal
4cfecc3ea9 lib: fix the "no match ipv6 next-hop type" command
Trivial NULL pointer dereference bug.

Fixes the following crash:
bgpd aborted: vtysh -c "configure terminal" -c "route-map RMAP permit 1" -c "no match ipv6 next-hop type"

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-20 12:39:05 -03:00
Donald Sharp
74df8d6d9d *: Replace hash_cmp function return value to a bool
The ->hash_cmp and linked list ->cmp functions were sometimes
being used interchangeably and this really is not a good
thing.  So let's modify the hash_cmp function pointer to return
a boolean and convert everything to use the new syntax.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-19 13:14:45 -04:00
Donatas Abraitis
1de2762153 bgpd: Check if route-map really exists before applying to the peer
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2018-10-11 10:56:12 +03: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
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
279b060775 lib: Allow some usage statistics for route-maps
Keep track of how often route-maps are applied and
how often each clause of a route-map is applied.

This change showed that `show route-map` was outputting
odd data so fix that output and add in the applied
times too.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-25 15:02:51 -04:00
Naveen Thanikachalam
fdf823db55 lib: Trigger callbacks to re-evaluate route-map clauses when "call" CLI is executed.
When the "call" CLI is executed from with-in a route-map that is already in use,
there is a need to get the route-map clients to re-evalute the clauses defined
by both the parent route-map, as well as the child route-map.
The existing callbacks, add_hook() and delete_hook() can be used by the lib to
inform the clients when the "call" is configured and unconfigured.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2018-09-20 22:07:29 -07: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
Donald Sharp
040c7c3a9f lib: Convert routemap.c to use new error-code subsystem
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-06 20:50:58 +00:00
Quentin Young
78b1bb5ff3 lib: sort route-maps for display
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-30 21:22:22 +00:00
Donald Sharp
1fae5ff24f lib: routemap.c trust backet->data
The backet->data cannot be NULL, no need to check for it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-15 17:53:09 -04: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
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
69f0272083 lib: Don't expose a function that is never used
route_map_clear_updated is only used by routemap.c,
don't expose it too be used by the outside world.

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
Donald Sharp
e4694d0dcf lib: Convert true/false values to bool
route_maps are using some int's as true/false so
let's convert them over to a bool.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-28 19:52:41 -04: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
Donald Sharp
ae2158fecf lib: Fix nexthop reading to work better
Fixes: #1404
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-06 11:20:40 -05:00
Donald Sharp
bd74dc610a lib: Hash creation cleanup
1) Some hash key functions where converting pointers
directly to a 32 bit value via downcasting.  Pointers
are 64 bit on a majority of our platforms.

2) Some hashes were being created with 256 entries,
downsize the hash creation size to more appropriate
values.

3) Add hash names to hash creation so we can watch
the hash via 'show debugging hashtable'

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-05 14:33:01 -04: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
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
David Lamparter
9d303b37d7 Revert "*: reindent pt. 2"
This reverts commit c14777c6bf.

clang 5 is not widely available enough for people to indent with.  This
is particularly problematic when rebasing/adjusting branches.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-22 14:52:33 +02:00
whitespace / reindent
c14777c6bf
*: reindent pt. 2
w/ clang 5

* reflow comments
* struct members go 1 per line
* binpack algo was adjusted
2017-07-17 15:26:02 -04:00
whitespace / reindent
d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
David Lamparter
2d8270596a Merge remote-tracking branch 'frr/master' into newline-redux
Lots of conflicts from CMD_WARNING_CONFIG_FAILED...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 13:07:30 +02:00
David Lamparter
61b7d449bd *: remove VTYNL, part 3 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:03 +02:00
David Lamparter
181039f3d7 *: ditch vty_outln(), part 2 of 2
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:19:58 +02:00
Daniel Walton
f1a05de982 vtysh: return non-zero for configuration failures
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

This allows frr-reload.py (or anything else that scripts via vtysh)
to know if the vtysh command worked or hit an error.
2017-07-13 19:56:08 +00:00
David Lamparter
5c7571d43f *: ditch vty_outln(), part 1 of 2
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13 20:29:22 +02:00
Quentin Young
dfd19ccc3a
*: update hash_create(), hash_create_size()
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-01 19:18:37 -04:00
Quentin Young
8e25c8ce2f *: rebase vty_outln() -> master
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:38:59 +00:00
Quentin Young
1318e7c841 *: s/VTY_NEWLINE/VTYNL/g
Should be able to fit more vty_out onto one line now

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:34:54 +00:00
Quentin Young
96ade3ed77 *: use vty_outln
Saves 400 lines

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:31:28 +00:00
Russ White
5bee21f37c Merge pull request #735 from qlyoung/fix-routemap
Fix routemap
2017-06-29 11:06:52 -04:00
Quentin Young
facfee22f5 *: remove VTY_GET_*
CLI validates input tokens, so there's no need to do it in handler
functions anymore.

spatch follows
----------------

@getull@
expression v;
expression str;
@@
<...
- VTY_GET_ULL(..., v, str)
+ v = strtoull (str, NULL, 10)
...>

@getul@
expression v;
expression str;
@@
<...
- VTY_GET_ULONG(..., v, str)
+ v = strtoul (str, NULL, 10)
...>

@getintrange@
expression name;
expression v;
expression str;
@@
<...
- VTY_GET_INTEGER_RANGE(name, v, str, ...)
+ v = strtoul (str, NULL, 10)
...>

@getint@
expression v;
expression str;
@@
<...
- VTY_GET_INTEGER(..., v, str)
+ v = strtoul (str, NULL, 10)
...>

@getv4@
expression v;
expression str;
@@
<...
- VTY_GET_IPV4_ADDRESS(..., v, str)
+ inet_aton (str, &v)
...>

@getv4pfx@
expression v;
expression str;
@@
<...
- VTY_GET_IPV4_PREFIX(..., v, str)
+ str2prefix_ipv4 (str, &v)
...>

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-27 19:04:41 +00:00