Commit Graph

109 Commits

Author SHA1 Message Date
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
Stephen Worley
bce03323a8 pbrd: separate set * and no set * commands
Separate out the `set *` and `no set *` commands into
different DEFPYs to make the logic of the code easier to
read.

Further, allow non-exlpicit no commands.

So `no set nexthop`, `no set nexthop-group`, and
`no set vrf` will now work without having to specify
anymore data. Before you had to match what was already
there explicitly.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-04-09 13:45:22 -04:00
Stephen Worley
f143cffac2 pbrd: implement set * and match * config replacement
Implement the ability to replace any existing `set *` or
`match` with another one or adding more config without having
to first delete the original config already there.

Before, we needed to constantly execute a `no` command for everything
to remove the rule before making changes to it. With this
patch, you can replace configs on individual sequences much
easier.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-04-09 13:45:14 -04:00
Stephen Worley
f3f2c78add pbrd: convert gotos in set vrf command to returns
We were doing a bunch of gotos in the set vrf configcode.
The code got complex enough that just returning is easier to read.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-03-19 14:30:42 -04:00
Stephen Worley
9bf1b0f74a pbrd: properly handle duplicate set vrf XX configs
Properly handle the case where we are sent the same `set vrf`
configs for a pbr map repeatedly. If we are sent the same
config, we return successfully without doing anyting.

If the config is different and its not a [no], then return failure
as we did before since we don't support atomic replace yet.

Before, we would fail anytime even if the config sent was the same
as is already there. This would cause frr-reload to mark as a
failure when it tried to re-apply the same config.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-03-19 12:32:13 -04:00
Stephen Worley
b246eb8a8d pbrd: unconfigure table range
Implement the [no] version of `pbr table range`. We had the command
but were doing nothing with it.

This just calls the set_table_range API again using the defaults.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-02-25 12:53:45 -05:00
Stephen Worley
1ce24b9b88 pbrd: use yes/no for pbr map validity vty output
Change the pbr map validity state to indicate yes/no
rather than 1/0 in the `show pbr map` command.

Humans aren't robots, so don't use binary.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-06 14:04:02 -05:00
Stephen Worley
b740126d97 pbrd: use spaces in show pbr map vty output
We were using a mix of spaces and tabsin show pbr map vty output.
Tabs can be inconsistent depending on the system settings.
Using spaces is a safer option for more consistent output.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-06 14:04:02 -05:00
Stephen Worley
add5e0a4cf pbrd: make vty nexthop/nexthop-group output consistent
The vty output for pbr maps with a nexthop-group was not
consistent with those configured with an individual nexthop.
Fix that so its easier for users to read.

alfred# show pbr map
  pbr-map TEST1 valid: 1
    Seq: 222 rule: 521
        Installed: yes Reason: Valid
        SRC Match: 2.2.2.2/32
        Nexthop-Group: blue
                Installed: yes Tableid: 10000
    Seq: 333 rule: 632
        Installed: yes Reason: Valid
        SRC Match: 3.3.3.3/32
        Nexthop-Group: blue
                Installed: yes Tableid: 10000
    Seq: 444 rule: 743
        Installed: yes Reason: Valid
        SRC Match: 4.4.4.4/32
        Nexthop-Group: blue
                Installed: yes Tableid: 10000
    Seq: 555 rule: 854
        Installed: yes Reason: Valid
        SRC Match: 5.5.5.5/32
        Nexthop-Group: red
                Installed: yes Tableid: 10001
    Seq: 666 rule: 965
        Installed: yes Reason: Valid
        SRC Match: 6.6.6.6/32
        nexthop 1.1.1.1
                Installed: yes Tableid: 10002
alfred#

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-06 14:04:02 -05:00
Stephen Worley
3259cde637 pbrd: make show pbr map detail actually work
The `detail` keyword was doing literally nothing. Changed the
default show to be a bit more user friendly and detail
to give the information you might would need for
debugging.

alfred# show pbr map
  pbr-map TEST1 valid: 1
    Seq: 222 rule: 521
    Installed: yes Reason: Valid
        SRC Match: 2.2.2.2/32
        Nexthop-Group: blue(10000) Installed: yes
    Seq: 333 rule: 632
    Installed: yes Reason: Valid
        SRC Match: 3.3.3.3/32
        Nexthop-Group: blue(10000) Installed: yes
    Seq: 444 rule: 743
    Installed: yes Reason: Valid
        SRC Match: 4.4.4.4/32
        Nexthop-Group: blue(10000) Installed: yes
    Seq: 555 rule: 854
    Installed: yes Reason: Valid
        SRC Match: 5.5.5.5/32
        Nexthop-Group: red(10001) Installed: yes
    Seq: 666 rule: 965
    Installed: yes Reason: Valid
        SRC Match: 6.6.6.6/32
     nexthop 1.1.1.1
        Installed: yes Tableid: 10002
alfred# show pbr map detail
  pbr-map TEST1 valid: 1
    Seq: 222 rule: 521
    Installed: 1(1) Reason: Valid
        SRC Match: 2.2.2.2/32
        Nexthop-Group: blue(10000) Installed: 1(1)
    Seq: 333 rule: 632
    Installed: 1(2) Reason: Valid
        SRC Match: 3.3.3.3/32
        Nexthop-Group: blue(10000) Installed: 1(1)
    Seq: 444 rule: 743
    Installed: 1(3) Reason: Valid
        SRC Match: 4.4.4.4/32
        Nexthop-Group: blue(10000) Installed: 1(1)
    Seq: 555 rule: 854
    Installed: 1(4) Reason: Valid
        SRC Match: 5.5.5.5/32
        Nexthop-Group: red(10001) Installed: 1(1)
    Seq: 666 rule: 965
    Installed: 1(5) Reason: Valid
        SRC Match: 6.6.6.6/32
     nexthop 1.1.1.1
        Installed: 1(1) Tableid: 10002
alfred#

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-06 14:04:02 -05:00
Stephen Worley
1eaa836128 pbrd: refactor vty map show output into functions
Refactor the pbr_map and pbr_map_sequence vty output
into some functions to make the code a bit easier to read.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-06 14:04:02 -05:00
Stephen Worley
5d0e49c4fc pbrd: make vty match * code more readable
Make the vty match src|dst|mark code a bit more readable
in its conditonal logic.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-03 16:59:21 -05:00
Stephen Worley
47f94d175a pbrd: Add newlines in set nexthop* vty output
We were missing some newlines in handling vty outputs
for the `set nexthop*` commands. Add them in there.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-03 15:56:00 -05:00
Stephen Worley
6c4c9a6cc7 pbrd: use dst string in match dst-ip vty description
The vty description for the `set match dst-ip` command was
using "src ip" in its description. Change it to use "dst ip".

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-03 15:56:00 -05:00
Stephen Worley
46b0382056 pbrd: don't silently fail on atomic match MARK change attempts
Also don't silently fail when we attempt to atomically change
a match MARK to a new one.

We would overwrite the frist one but never actually install it.

Change it to explicitly fail if a config is already present for
now.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-03 15:56:00 -05:00
Stephen Worley
0dcff6f463 pbrd: don't silently fail on atomic match IP change attempts
Currently pbrd does not support the abilitity to make atomic
changes to a config.

ex)
`match src-ip 1.1.1.1/32`
`match src-ip 1.1.1.0/24`

We would overwrite the first one but never actually install it.

In the `set nexthop commands` we explicitly fail if there is
already a `set nexthop` config present. This patch extends the
match src/dest-ip configs to do the same.

In the future we should make all these commands atomic but for
now its better to not fail silently at the very least.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-03 15:56:00 -05:00
Stephen Worley
be3b67b5ef pbrd: Add set vrf NAME and set vrf unchanged
`set vrf NAME` allows the pbr map to point to an arbitrary vrf table.

`set vrf unchanged` will use the interface's vrf for table lookup.

Further, add functionality for pbr to respond to interface events
such as interface vrf changes & interface creation/deletion.

Ex)
ubuntu_nh# show pbr map
  pbr-map TEST valid: 1
    Seq: 1 rule: 300 Installed: 3(1) Reason: Valid
        SRC Match: 3.3.3.3/32
        VRF Unchanged (use interface vrf)
  pbr-map TEST2 valid: 1
    Seq: 2 rule: 301 Installed: 3(2) Reason: Valid
        SRC Match: 4.4.4.4/32
        VRF Lookup: vrf-red

root@ubuntu_nh:/home# ip rule show
0:      from all lookup local
300:    from 3.3.3.3 iif dummy2 lookup main
300:    from 3.3.3.3 iif dummyVRF lookup 1111
301:    from 4.4.4.4 iif dummy1 lookup 1111
301:    from 4.4.4.4 iif dummy3 lookup 1111

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com-
2019-11-21 16:59:42 -05:00
Donald Sharp
63265b5c1f *: Convert prefix_free to double pointer
Have the prefix_free code take a double pointer to free the data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-02 16:13:44 -04:00
Stephen Worley
cb254f41c0 pbrd: Don't track ipv6 link locals
Don't bother tracking ipv6 link locals to determine if a map
should be installed. Every interface has a route of `fe80::/64`
so its just going to return the arbitrarily first one it finds
when it resolves it and hands it back to us.

Instead, just track the interface we specify along with it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-07 18:29:01 -04:00
Igor Ryzhov
e429a2a0cc *: fix missing VRF autocompletions
Current autocompletion works only for simple "vrf NAME" case.

This commit expands it also for the following cases:
- "nexthop-vrf NAME" in staticd
- usage of $varname in many daemons

All daemons are updated to use single varname "$vrf_name".

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2019-09-24 19:51:46 +03:00
Marcin Matląg
95a9fe025a pbrd: initial fwmark support for pbr matches #4460
Adds support to specify marks in pbr-map match clause.
Marks should be provided as decimal (unsigned int).

Currently supported on Linux only. Attempting to configure
marks on other platform will result in:

"pbr marks are not supported on this platform"

Signed-off-by: Marcin Matlag <marcin.matlag@gmail.com>
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2019-09-03 15:30:10 -05:00
Stephen Worley
50d8965075 lib: Private api for nexthop_group manipulation
Add a file that exposes functions which modify nexthop groups.
Nexthop groups are techincally immutable but there are a
few special cases where we need direct access to add/remove
nexthops after the group has been made. This file provides a
way to expose those functions in a way that makes it clear
this is a private/hidden api.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25 22:58:48 -04:00
Donald Sharp
17f8c65202 pbrd: Allow autocompletion for pbr-map PBRMAP
Allow the end user to auto-complete the pbr-map name.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-05 06:51:08 -04:00
Donald Sharp
868ee86cec lib, pbrd, sharpd, vtysh: Add autocompletion for 'nexthop-group'
Add some auto-completion for the nexthop-group command

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-05 06:33:00 -04:00
Donald Sharp
8d39ebf675
Merge pull request #3776 from opensourcerouting/pbrd-interface-nexthops
pbrd: add support for interface nexthops
2019-03-22 03:45:48 -04:00
Renato Westphal
220c5830e7 pbrd: add missing newline at the end of warning message
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-20 23:04:12 -03:00
Renato Westphal
7dce96f0e4 lib, pbrd: fix indentation of a few commands
When displaying the running configuration, we should use a single
space to indent commands when necessary (and not two spaces).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-14 22:57:39 -02:00
Renato Westphal
9c0fd85360 pbrd: change the "set nexthop" command to accept interface nexthops
In addition to nexthop groups, pbrd also supports the "set nexthop"
command to specify the nexthop of a PBR map. This adds convenience
when multiple nexthops aren't necessary.

Change this command to support interface nexthops (without IP
addresses) like nexthop groups do. At the end of the command, call
pbr_nht_nexthop_interface_update() otherwise the interface nexthop
won't be validated until we receive an interface up/down notification
from zebra through the zapi protocol.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-14 22:57:39 -02:00
Donald Sharp
6eb499b031 pbrd: If changing policy on an interface be careful what you ask for
When changing policy on an interface, only delete the old_pbrm
if it is different than the current, this covers the case:

current config:
int swp1
  pbr-policy DONNA

To a config entered of:

int swp1
  pbr-policy EVA

Additionally there is no need to reinstall if we enter the same
pbr-policy two times in a row.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-12 19:21:28 -05:00
Renato Westphal
91e5b43ab4 lib, vtysh: fix inconsistent interface commands in vtysh
The definition of the interface commands in vtysh.c were outdated.
Currently, all daemons that call if_cmd_init() will have the "no interface
IFNAME" command and the "[no] description" commands as well, so there's
no need to define exceptions for these commands anymore.

To fix this, make extract.pl parse the if.c file so that vtysh can get the
interface commands from there automatically. Only the "interface IFNAME
[vrf NAME]" must be kept in vtysh.c because it changes the vty node and
thus needs special treatment.

Finally, make pimd and pbrd display interface descriptions on "sh run"
when they are configured.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-08-13 18:59:31 -03:00
Quentin Young
a4044dc10d pbrd: add logging messages when out of table id's
* Add log messages to indicate when we have run out of table IDs
* Increase minimum range size to 1000 to reduce risk of hitting this

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-13 20:00:58 +00:00
Quentin Young
8c28c034dc pbrd, lib: move PBR_STR def. to lib
Per request

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-13 16:22:01 +00:00
Quentin Young
24a21176ce pbrd: use PBR_STR
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-12 20:28:04 +00:00
Quentin Young
ef18ed6e93 pbrd: remove json options
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-12 20:27:30 +00:00
Quentin Young
7bec514c7e pbrd: allow configurable table id range
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-12 19:51:12 +00:00
Donald Sharp
06210d1f40 pbrd: Fix compilation warn -> error
The buffer size was insufficiently sized to hold the
entirety of the data being passed in.

Modify the nht code to use a bit bigger buffer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-15 13:52:02 -04:00
Donald Sharp
9a55f79a26 pbrd, vtysh: Limit range to actual 1-700
The range for sequence numbers needs to be limited
by the range we have currently choosen for rule
ranges.

Ticket: CM-20562
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
Donald Sharp
29d5a14634 pbrd: Fix nearly impossible truncation
Since we are writing into the name field which is PBR_MAP_NAMELEN
size, we are expecting this to field to be at max 100 bytes.
Newer compilers understand that the %s portion may be up to
100 bytes( because of the size of the string.  The %u portion
is expected to be 10 bytes.  So in `theory` there are situations
where we might truncate.  The reality this is never going to
happen( who is going to create a nexthop group name that is
over say 30 characters? ).  As such we are expecting the
calling function to subtract 10 from the size_t l before
we pass it in to get around this new gcc fun.

Fixes: #2163
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-02 20:14:36 -04:00
Donald Sharp
10a00758a7 pbrd: Fix a couple SA issues
1) addr will never be non-null because of the way we build the cli
at this point in time, but the SA system does not understand this,
add a bread crumb for it.

2) Fix a possible memory leak of the pbr_ifp

3) Fix possible integer overflow when bit shifting.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-23 22:09:33 -04:00
Russ White
5998141e07
Merge pull request #2051 from donaldsharp/PBRD_EXTRA
Pbrd extra
2018-04-20 07:54:30 -04:00
Quentin Young
d64169679f pbrd: remove pbr-policy resource leak
Removing a non-existent pbr-policy caused a pbr_interface to leak.

Coverity #1467829

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-18 12:16:19 -04:00
Quentin Young
5f504f14a9 pbrd: remove unsafe string copy
A user could overflow the pbr_ifp->mapname buffer by entering a pbr-map
name longer than 100 characters.

Coverity #1467821
Coverity #1467821

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-18 12:16:19 -04:00
Quentin Young
e14f43ccae pbrd: move debug vty into pbr_vty.c
Dev docs say that CLI goes in _vty.c files

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-17 18:43:47 -04:00
Donald Sharp
37c606ffbf pbrd, zebra: Fix multiple pbr-policy install
Somewhere along the way the ability to install multiple
pbr-policys for the same pbr-map was lost.

Add this back.  There is a limitation in that we are limited
to 64 interfaces per pbr-policy.

Ticket: CM-20429
Signed-off-by: Donald Sharp sharpd@cumulusnetworks.com>
2018-04-17 18:43:46 -04:00
Donald Sharp
cafec8da4f lib, pbrd: Do not allow v6 LL nexthops to be specified without an interface.
Prevent the creation of a v6 LL nexthop that does not include an interface
for proper resolution.

Ticket: CM-20276
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17 18:40:17 -04:00
Don Slice
49027ce856 pbrd: adjust/remove the rule correctly when dst and/or src removed
When the last match criteria was removed (dst-ip or src-ip), we were
not deleting the rule correctly for ipv6. This fix retains the
needed src-ip/dst-ip during the pbr_send_pbr_map process so the
appropriate information is available for the rule delete.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
a1b7005bf4 pbrd: Remove table and rule range commands
Since PBR is meant to be for small deployments, allowing
end users to arbitrarily change rule and table ranges
without some more careful thought on what is going on
and how to do it, sets us up for issues.

At this time remove these knobs.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
3a9210c220 pbrd: Indicate command failure a bit better
When a command is attempted to be configed and it
fails to be installed, indicate via vtysh return
codes that we did not accept the command

Ticket: CM-20216
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
5e44f18ff1 pbrd: Do not use vrf_frame for pbrms display
When displaying a pbr map sequence for a show run do not use the
vty_frame construct.  We should display the config even if we
do not have much to display.

Ticket: CM-20196
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
8ee9738bbc pbrd: Reduce range so we cannot go over the vrf rule
The linux kernel puts the vrf rule at 1000, since pbr
rules need to be before this rule, don't allow us to go
beyond.

Ticket: CM-19946
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
1c33fb1dbb pbrd: Prevent crash from partially configured interface
If an interface is in the process of coming up or
partially deconfigured, prevent pbrd from crashing

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
b8eb036fb2 pbrd: If we get the same prefix safely ignore
If the match src-ip or dst-ip command entered has already
been received and it's the same prefix, we are done and
do not need to do anything more.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Quentin Young
57cdafc411 lib, pbrd: rm extra space when displaying nexthop
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
e042a421d1 pbrd: Only allow one nexthop group or nexthop at a time
When we are entering 'set nexthop' and 'set nexthop-group'
ensure that the cli only allows one of these to happen
at a time.

Ticket: CM-20125
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
b13e5ad68a pbrd: Remove pbr_events
The pbr_events.c file was a mistake in that it overly complicated
the code and made it hard to think about what was happening.

Remove all the events and just do the work where needed.

Additionally rethink the sending of the pbr map to
zebra and only send one notification at a time instead
of having the sending function attempt to figure out
what to do.

Clean up some of the no form of commands to make them
work properly.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
d37653864b pbrd: Cleanup CI warnings
There are a bunch of CI warnings that need to be cleaned up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Donald Sharp
e5c83d9b31 pbrd: Add PBR to FRR
This is an implementation of PBR for FRR.

This implemenation uses a combination of rules and
tables to determine how packets will flow.

PBR introduces a new concept of 'nexthop-groups' to
specify a group of nexthops that will be used for
ecmp.  Nexthop-groups are specified on the cli via:

nexthop-group DONNA
  nexthop 192.168.208.1
  nexthop 192.168.209.1
  nexthop 192.168.210.1
!

PBR sees the nexthop-group and installs these as a default
route with these nexthops starting at table 10000
robot# show pbr nexthop-groups
Nexthop-Group: DONNA Table: 10001 Valid: 1 Installed: 1
	Valid: 1  nexthop 192.168.209.1
	Valid: 1  nexthop 192.168.210.1
	Valid: 1  nexthop 192.168.208.1

I have also introduced the ability to specify a table
in a 'show ip route table XXX' to see the specified tables.

robot# show ip route table 10001
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR,
       > - selected route, * - FIB route

F>* 0.0.0.0/0 [0/0] via 192.168.208.1, enp0s8, 00:14:25
  *                 via 192.168.209.1, enp0s9, 00:14:25
  *                 via 192.168.210.1, enp0s10, 00:14:25

PBR tracks PBR-MAPS via the pbr-map command:

!
pbr-map EVA seq 10
  match src-ip 4.3.4.0/24
  set nexthop-group DONNA
!
pbr-map EVA seq 20
  match dst-ip 4.3.5.0/24
  set nexthop-group DONNA
!

pbr-maps can have 'match src-ip <prefix>' and 'match dst-ip <prefix>'
to affect decisions about incoming packets.  Additionally if you
only have one nexthop to use for a pbr-map you do not need
to setup a nexthop-group and can specify 'set nexthop XXXX'.

To apply the pbr-map to an incoming interface you do this:

interface enp0s10
 pbr-policy EVA
!

When a pbr-map is applied to interfaces it can be installed
into the kernel as a rule:

[sharpd@robot frr1]$ ip rule show
0:	from all lookup local
309:	from 4.3.4.0/24 iif enp0s10 lookup 10001
319:	from all to 4.3.5.0/24 iif enp0s10 lookup 10001
1000:	from all lookup [l3mdev-table]
32766:	from all lookup main
32767:	from all lookup default

[sharpd@robot frr1]$ ip route show table 10001
default proto pbr metric 20
	nexthop via 192.168.208.1 dev enp0s8 weight 1
	nexthop via 192.168.209.1 dev enp0s9 weight 1
	nexthop via 192.168.210.1 dev enp0s10 weight 1

The linux kernel now will use the rules and tables to properly
apply these policies.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00