Commit Graph

3994 Commits

Author SHA1 Message Date
Chirag Shah
a363b4b49b lib: increase the size of northbound max module
Increase the size of frr_yang_module_info
macro to accomodate bgp module list.

root@bharat:~/stash/frr# egrep "xpath" bgpd/bgp_nb.c | wc -l
1150

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Chirag Shah
bc8c00cca1 *: add bgp yang files into makefiles
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Stephen Worley
7403e15561 lib: remove nexthop_same_firsthop() api
Remove the nexthop_same_firsthop() api and just call nexthop_same().
Not entirely sure why we were using this function in the first place,
but now we are just marking dupes with it so lets just call a
common function and avoid issues.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-10-02 17:25:36 -04:00
Igor Ryzhov
d7b86ae4fe vtysh: dynamically generate the list of daemons for commands
Some daemons were actually missing from the static definitions: nhrpd,
babeld, eigrpd and bfdd.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-02 15:06:27 +03:00
Quentin Young
2fec17cd04 lib: fix zapi_nexthop_update_decode error rc
This function returns true on success and false otherwise. Returning -1
on error is equivalent to returning true.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-30 18:22:33 -04:00
Stephen Worley
2173535298 lib,zebra,sharpd: add code for backup proto-NHs but disabled
Add the zapi code for encoding/decoding of backup nexthops for when
we are ready for it, but disable it for now so that we revert
to the old way with them.

When zebra gets a proto-NHG with a backup in it, we early fail and
tell the upper level proto. In this case sharpd. Sharpd then reverts
to the old way of installation with the route.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
c6ce9334b5 lib,sharpd: align zapi NHG apis a bit
Align the zapi NHG apis to be more consistent with the zapi_route
apis. Add a struct zapi_nhg to use for encodings as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
3509dd49c0 lib: add doc to clear-up hash_iterate multi deletion
Add some header documentation to make it clear that you
cannot delete more than one item during each iteration.
Doing so could cause memory corruption for next pointer
if its also deleted from the table.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
391c7a3b18 lib: add proto NHG Notif header to log command types
Add the proto Nexthop Group Notify Owner header to
the log command types for string conversion.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
ff9aca4f8d lib,zebra,sharpd: clang format
Clang format for NHG API and sharpd patches.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
2c7819b9d4 lib,zebra: fixup NHG notify zapi messaging
Make the message parameters align better with other zapi
notifications and change the ID to correctly be a uint32.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
cc6a0d7d80 Revert "lib,sharpd,pbrd: set installable nhg command"
This reverts commit 1844f45e30913b27cfd875036f865a0edadcf244.
2020-09-28 12:40:59 -04:00
Stephen Worley
b36bedd2c3 lib: add logging for ZEBRA_NHG_ADD[DEL]
Add logging info for the new zapi ZEBRA_NHG_ADD[DEL]
message types. With this patch, they are logged properly
when debugs are turned on.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
0de1db8f3b lib,sharpd,pbrd: set installable nhg command
Add a command `set installable` that allows configured nexthop
groups to be treated as separate/installable objects in the RIB.

A callback needs to be implemented per daemon to handle installing
the NHG into the rib via zapi when this command is set. This
patch includes the implementation for sharpd.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
54c6fa8e0a lib,doc: add onlink flag to nexthop group config
Add an `onlink` flag to nexthop group configuration.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
e90284d77f lib: add onlink flag to zapi_nh conversion helper
Add setting the onlink flag to the zapi_nh conversion
helper function so that we can set the onlink flag with
it when passing down NHGs from upper level protos.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
54c89c9377 zebra: NHG ID bounds macros
Determine the NHG ID spacing and lower bound with ZEBRA_ROUTE_MAX
in macros.

Directly set the upperbound to be the lower 28bits of the uint32_t ID
space (the top 4 are reserved for l2-NHGs). Round that number down
a bit to make it more even.

Convert all former lower_bound calls to just use the macro.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
6c67f41f9e zebra,lib: command to only install proto-based nexthops
Add a command/functionality to only install proto-based nexthops.
That is nexthops owned/created by upper level protocols, not ones
implicitly created by zebra.

There are some scenarios where you would not want zebra to be
arbitrarily installing nexthop groups and but you still want
to use ones you have control over via lib/nexthop_group config
and an upper level protocol.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
0885b1e3d9 zebra: implement protocol NHG Add/Del
Implement the underlying zebra functionality to Add/Del an
internal zebra and kernel NHG.

These NHGs are managed by the upperlevel protocols that send them
down via zapi messaging.

They are not put into the overall zebra NHG hash table and only
put into to the ID table. Therefore, different protos cannot
and will not share NHGs.

The proto is also set appropriately when sent to the kernel.

Expand the separation of Zebra hashed/shared/created NHGs and
proto created and mangaged NHGs.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
27141ea94e lib, zebra: Add ability to send down a nhgid over route install
Modify the send down of a route to use the nexthop group id
if we have one associated with the route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
2f35a820bf lib, zebra: Add ZAPI_NHG_ADD|DELETE
Add the ability to send a NHG from an upper level protocol down to
zebra.  ZAPI_NHG_ADD encompasses both the addition and replace
semantics ( If the id passed down does not exist yet, it's Add,
else it's a replace ).

Effectively zebra will take this nhg passed down save the nhg
in the id hash for nhg's and then create the appropriate nhg's
and finally install them into the linux kernel.  Notification
will be the ZAPI_NHG_NOTIFY_OWNER zapi message for normal
success/failure messaging to the installing protocol.

This work is being done to allow us to work with EVPN MH
which needs the ability to modify NHG's that BGP will own
and operate on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
224b3c8a79 lib: Add the ability to grab a nhg starting id
Add new function zclient_get_nhg_start that will allow an
upper level protocol to get a starting point for it's own
nhg space.  Give each protocol a space of 50 million.
zebra will own the space from 0 - 199999999 because
of SYSTEM, KERNEL and CONNECT route types.

This is the start of some work that will allow upper
level protocols to install and maintain their own NHG's.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
7895c3bc4f lib: Tell the compiler we don't care about the return code
When calling yang_snodes_iterate_subtree we don't care about
the return code.  So explicitly say we don't care so that
SA tools can be on the same page as us.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-24 07:52:20 -04:00
Mark Stapp
ccda0eadac
Merge pull request #7155 from donaldsharp/TRAP
Offload/Trap
2020-09-23 16:06:37 -04:00
Donatas Abraitis
0ce5baaab1
Merge pull request #7018 from gouault6wind/show_ip_route
Clean up in vrf management
2020-09-23 08:45:09 +03:00
Mark Stapp
b6033bd1c1
Merge pull request #7067 from donaldsharp/remove_solaris
Remove solaris
2020-09-22 17:04:19 -04:00
Donald Sharp
5a3cf85391 lib, zebra: Add ability to read kernel notice of TRAP/OFFLOAD
The linux kernel is getting RTM_F_TRAP and RTM_F_OFFLOAD for
kernel routes that have an underlying asic offload.  Write the
code to receive these notifications from the linux kernel and
to store that data for display about the routes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-22 15:57:43 -04:00
Donald Sharp
cae8bc967c *: Remove solaris from FRR
The Solaris code has gone through a deprecation cycle.  No-one
has said anything to us and worse of all we don't have any test
systems running Solaris to know if we are making changes that
are breaking on Solaris.  Remove it from the system so
we can clean up a bit.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-21 10:02:20 -04:00
Igor Ryzhov
2f272cb409 lib: don't execute command if pre-processing hook has failed
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-09-21 16:12:29 +03:00
Igor Ryzhov
511942ba37 lib: fix regcomp error processing
* use actual error code instead of "false"
 * add missing new line

Before:
```
nfware# show interface | include (a]
% Regex compilation error: Success% Bad regexp '(a]'
% Unknown command: show interface | include (a]
```

After:
```
nfware# show interface | include (a]
% Regex compilation error: Unmatched ( or \(
% Bad regexp '(a]'
% Unknown command: show interface | include (a]
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-09-21 15:35:56 +03:00
Christophe Gouault
1eb92f06c4 vrf: VRF_DEFAULT must be 0, remove useless code
Code was added in the past to support a value of VRF_DEFAULT different
from 0. This option was abandoned, the default vrf id is always 0.

Remove this code, this will simplify the code and improve performance
(use a constant value instead of a function that performs tests).

Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
2020-09-21 10:17:35 +02:00
Christophe Gouault
7c1119cb7a lib: optimize vrf_id_to_name(VRF_DEFAULT) case
vrf_id_to_name() looks up in a RB_TREE to find the VRF entry, then
reads the name.

Avoid it for VRF_DEFAULT, which always exists and for which the
translation is straightforward.

Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
2020-09-21 10:07:56 +02:00
Donald Sharp
0b8125588a
Merge pull request #7069 from opensourcerouting/fix-set-metric
lib: fix the "set metric" route-map command
2020-09-19 08:06:36 -04:00
Donald Sharp
3baa7b4c8e
Merge pull request #7079 from opensourcerouting/nested-yang-augmentations
lib: better support for nested YANG augmentations
2020-09-18 20:43:20 -04:00
Russ White
0a6e6613d7
Merge pull request #7089 from pguibert6WIND/netns-refactor
Netns refactor
2020-09-18 11:02:30 -04:00
Donald Sharp
0a822f99bf lib: Remove debug associated with vrf_get
The vrf_get function is called throughout the code base
so much so that when you turn on vrf debugging it eclipses
everything else to a degree that is completely unreasonable.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-18 07:14:55 -04:00
Donald Sharp
c7384cf86a lib: Add vrf name to vrf debugs
The vrf name was not being printed out in some vrf debugs.  Add
this data in so people don't have to remember the vrf id.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-17 20:17:14 -04:00
Donald Sharp
0cbee799d5 lib: Actually call nexthop_group_disable_vrf
When the nexthop-groups were added to FRR for some
reason the call to nexthop_group_disable_vrf was
not added although it was written.

Add it in.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-17 20:13:44 -04:00
Donald Sharp
32e3ca2bcc
Merge pull request #7103 from opensourcerouting/sysrepo-fixes
lib: sysrepo plugin fixes
2020-09-16 20:34:53 -04:00
Quentin Young
7ffcd8bd2d lib: set threadmaster name to 'default' if none
And also include the name of the threadmaster in its event hash name.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-15 20:16:56 -04:00
Renato Westphal
bbeaa0333c lib: simplify handling of the sysrepo startup configuration
In the new Sysrepo, all SR_EV_ENABLED notifications are followed by
SR_EV_DONE notifications (assuming no errors occur), so there's no
need to special case the SR_EV_ENABLED event anymore (e.g. do full
transactions in one step).

While here, add a few more guarded debug messages to facilitate
troubleshooting.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-15 16:00:07 -03:00
Renato Westphal
7dac19f7de lib: fix handling of deleted nodes in the sysrepo plugin
Make the sysrepo plugin ignore the deletion of configuration
nodes that don't exist anymore instead of logging an error and
rejecting the changes. This is necessary because Sysrepo delivers
delete notifications for all nodes of a deleted data tree instead
of delivering a single delete notification of the top-level subtree
node (which would suffice for the northbound layer).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-15 15:56:53 -03:00
Renato Westphal
88e635ee63 lib: postpone the sysrepo plugin initialization
From Sysrepo's documentation:
"Note: do not use fork() after creating a connection. Sysrepo
internally stores PID of every created connection and this way a
mismatch of PID and connection is created".

Introduce a new "frr_very_late_init" hook in libfrr that is only
called after the daemon is forked (when the '-d' option is used)
and after the configuration is read. This way we can initialize
the sysrepo plugin correctly even when the daemon is daemonized,
and after the Sysrepo CLI commands are processed (only "debug
northbound client sysrepo" for now).

Fixes #7062

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-15 15:55:55 -03:00
Mark Stapp
cfa2115d02
Merge pull request #7093 from donaldsharp/pbr_flapping
Pbr flapping
2020-09-14 08:13:48 -04:00
Donald Sharp
43373bea5a
Merge pull request #7091 from opensourcerouting/nb-leafrefs
lib: fix crashes with leafrefs that point to non-implemented modules
2020-09-12 09:29:33 -04:00
Donald Sharp
58a1d24924 bgpd, lib, pbrd, zebra: Pass by ifname
When installing rules pass by the interface name across
zapi.

This is being changed because we have a situation where
if you quickly create/destroy ephermeal interfaces under
linux the upper level protocol may be trying to add
a rule for a interface that does not quite exist
at the moment.  Since ip rules actually want the
interface name ( to handle just this sort of situation )
convert over to passing the interface name and storing
it and using it in zebra.

Ticket: CM-31042
Signed-off-by: Stephen Worley <sworley@nvidia.com>
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-11 20:04:45 -04:00
Renato Westphal
beb91114ec
Merge pull request #6789 from volta-networks/feat_ldp_igp_sync
ldpd: Add support for LDP-IGP Synchronization
2020-09-11 15:55:04 -03:00
Renato Westphal
8a923b4851 lib: better support for nested YANG augmentations
Change the way the YANG schema node iteration functions work so that
the northbound layer won't have issues with more complex YANG modules
that contain multiple levels of YANG augmentations or modules that
augment themselves indirectly (by augmenting groupings).

Summary of the changes:
* Change the yang_snodes_iterate_subtree() function to always follow
  augmentations and add an optional "module" parameter to narrow down
  the iteration to nodes of a single module (which is necessary in
  some cases). Also, remove the YANG_ITER_ALLOW_AUGMENTATIONS flag
  as it's no longer necessary.
* Change yang_snodes_iterate_all() to do a DFS iteration on the resolved
  YANG data hierarchy instead of iterating over each module and their
  augmentations sequentially.

Reported-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-11 15:46:40 -03:00
Renato Westphal
f267201bf5 lib: fix crashes with leafrefs that point to non-implemented modules
Whenever libyang loads a module that contains a leafref, it will
also implicitly load the module of the referring node if it's
not loaded already. That makes sense as otherwise it wouldn't be
possible to validate the leafref value correctly.

The problem is that loading a module implicitly violates the
assumption of the northbound layer that all loaded modules
are implemented (i.e. they have a northbound node associated
to each schema node). This means that loading a module that
isn't implemented can lead to crashes as the "priv" pointer
of schema nodes is no longer guaranteed to be valid. To fix this
problem, add a few null checks to ignore data nodes associated
to non-implemented modules.

The side effect of this change is harmless. If a daemon receives
configuration it doesn't support (e.g. BFD peers on staticd),
that configuration will be stored but otherwise ignored. This can
only happen when using a northbound client like gRPC, as the CLI
will never send to a daemon a command it doesn't support. This
minor problem should go away in the long run as FRR migrates to
a centralized management model, at which point the YANG-modeled
configuration of all daemons will be maintained in a single place.

Finally, update some daemons to stop implementing YANG modules
they don't need to (i.e. revert 1b741a01c and a74b47f5).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-11 14:42:35 -03:00
Philippe Guibert
2961d0601c lib, zebra: reuse and adapt ns_list walk functionality
the walk routine is used by vxlan service to identify some contexts in
each specific network namespace, when vrf netns backend is used. that
walk mechanism is extended with some additional paramters to the walk
routine.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-09-11 18:26:23 +02:00
David Schweizer
12488d7c8d
lib: fix negating set metric route-map command
Changed negating set metric route-map command to be usable in
conjunction with the affirming command.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2020-09-10 09:14:58 +02:00
Renato Westphal
add39cde9d lib: fix the "set metric" route-map command
The "set metric" command wasn't processing metric additions and
subtractions (using + and -) correctly. Fix those problems.

Also, remove the "+metric" and "-metric" options since they don't
work and don't make any sense (they could be interpreted as unitary
increments/decrements but that was never supported).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-09 14:53:26 -03:00
Karen Schoener
24e7c5c897 lib: adding support for LDP IGP Sync feature
Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-09-09 11:12:02 -04:00
Karen Schoener
e1894ff70f ldpd: Adding support for LDP IGP Synchronization
Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-09-09 10:45:41 -04:00
Mark Stapp
000ce30ee5
Merge pull request #7047 from qlyoung/fix-zlog-target-null-deref
lib: fix possible null dereference in zlog
2020-09-08 15:25:08 -04:00
Quentin Young
589b5e4802 lib: fix possible null dereference in zlog
In some cases one or both of the zlog targets in use here can be null,
we need to check for that.

Interestingly it appears we don't crash even when this is the case.
Undefined behavior ftw

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-08 11:43:40 -04:00
Renato Westphal
dcdaabcede
Merge pull request #7046 from qlyoung/fix-various-integer-issues
Fix various integer signedness / overflow issues
2020-09-04 22:33:48 -03:00
Renato Westphal
4c13526b07
Merge pull request #6971 from volta-networks/fix_ldp_no_config
ldpd: Fix issue when starting up LDP with no configuration.
2020-09-04 16:39:16 -03:00
lynne
955357174f ldpd: Fix issue when starting up LDP with no configuration.
LDP would mark all routes as learned on a non-ldp interface.  Then
when LDP was configured the labels were not updated correctly.  This
commit fixes issues 6841 and 6842.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
2020-09-04 09:24:47 -04:00
Quentin Young
06cf2c0c36 lib: add stream_rewind_getp()
stream_forward_getp() cannot be used with negative numbers due to the
size_t argument, we'll end up doing overflow arithmetic.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-03 14:23:54 -04:00
Mark Stapp
f845960b3f lib: remove unused stream_get_data api
Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-09-03 12:37:55 -04:00
Santosh P K
371ded520b
Merge pull request #6987 from Niral-Networks/acl_fix
lib, ospf : Fix when redist is performed with route-map using access-list
2020-09-03 09:51:21 +05:30
Quentin Young
e6464fdc18 lib: remove overflow arithmetic from hash stats
Signed values get converted to unsigned for addition, so when the value
to adjust a stats variable for hash tables was negative this resulted in
overflow arithmetic, which we generally don't want.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-02 16:54:41 -04:00
Quentin Young
e117b7c528 lib: explicitly cast -1 to uid_t
We should be explicit about what's happening here

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-02 16:54:38 -04:00
Donald Sharp
842b9211ac
Merge pull request #6997 from opensourcerouting/cisco-acl-name
lib,yang: allow cisco access lists to use names plus fixes
2020-09-02 08:26:57 -04:00
Russ White
edec686a2a
Merge pull request #7016 from donaldsharp/pbr_vrf_is_burf
Pbr vrf is burf
2020-09-01 10:31:20 -04:00
Renato Westphal
1bd4306909 lib: silence overly verbose CLI warning
When not using the transactional CLI mode, do not display a
warning when a YANG-modeled commmand doesn't perform any effective
configuration change.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-31 11:59:54 -03:00
Kaushik
1eb17c771b lib : Fix when redist is performed with route-map using access-list.
1. Added new API for add/delete acl with route map notify.

Co-authored-by: harios <hari@niralnetworks.com>
Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-08-31 04:25:10 -07:00
Donald Sharp
e7ff02539c lib: Note old ifindex on shutdown
If we have an interface configured in a daemon on shutdown
store the old ifindex value for retrieval on when it is
possibly recreated.

This is especially important for nexthop groups as that we
had at one point in time the ability to restore the
configuration but it was lost when we started deleting
all deleted interfaces.  We need the nexthop group subsystem
to also mark that it has configured an interface.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-28 07:51:06 -04:00
Donald Sharp
a251884bff lib: Allow nexthop simple display to take an alternate ifp name
The nexthop_group_write_nexthop_simple function outputs the
interface name, because we've stored the ifindex.  The problem
is that there are ephermeal interfaces in linux that can be
destroyed/recreated.  Allow us to keep that data and do something
a bit smarter to allow show run's and other show commands to continue
to work when the interface is deleted.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-28 07:51:06 -04:00
Stephen Worley
7992452008 lib: break up show nexthop API a bit for reuse
Not everything cares about the vrf and backup info. Break
up the API to add a simple version to just write gateway/interface
info.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-08-27 16:13:48 -04:00
Rafael Zalamena
0ed507dda0 lib: refactory cisco access list net wildcard
Wildcards bits have the opposite representation of a network mask,
example:

192.168.0.0/24 has the following netmask 255.255.0.0 and the wildcard
representation is 0.0.255.255.

To avoid future confusion lets put those definitions into a macro so we
know for sure which form to use.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-26 12:50:07 -03:00
Donald Sharp
c6d41e93e0
Merge pull request #5799 from pguibert6WIND/flowspec_ipv6
Flowspec ipv6
2020-08-26 08:26:46 -04:00
Rafael Zalamena
070783e693 lib: fix a crash in zebra style access list
When removing an IPv4 prefix configuration the wrong amount of bytes
will be read from `struct prefix_ipv4` from `DEFPY`, so lets use the
proper function for this.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-25 10:35:46 -03:00
Rafael Zalamena
4204c59a99 lib: remove ambiguous cisco command
When configuring a access list rule with type `any` it is now ambiguous
between cisco and zebra because both have the same syntax, so lets
remove the cisco command to avoid that.

YANG users will not notice this change.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-25 10:35:46 -03:00
Rafael Zalamena
4859a57e11 lib: fix filter extended address assignment
`nb_cli_enqueue_change` just points to the string values passed in
parameter, so we must use different strings for different function
calls (at least until `nb_cli_apply_changes`).

While here fix a variable name typo/copy paste error on destination host
case.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-25 10:35:46 -03:00
Rafael Zalamena
59ed102f96 lib: allow cisco typed rules to use names
The restriction was already lift at the YANG model level, now lets
unlock the CLI as well.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-25 10:35:46 -03:00
Donald Sharp
bcbd5081e7
Merge pull request #6976 from achernavin22/rip_tools_key_chain_reloading
lib, tools: fix reloading of key sub-context in key chains
2020-08-25 07:54:55 -04:00
Russ White
4a61502028
Merge pull request #6962 from mjstapp/fix_zapi_nh_sort
lib: zapi nexthop sort fixes
2020-08-25 07:13:46 -04:00
Renato Westphal
f4c3f7f60f
Merge pull request #6963 from chiragshah6/mdev
*: record northbound transaction based on control flag
2020-08-24 16:22:21 -03:00
Alexander Chernavin
deb95b373f lib, tools: fix reloading of key sub-context in key chains
When you add a key chain in the RIP configuration file and reload the
configurations via the frr-reload.py script, the script will fail and
the key chain will not appear in the running configuration. The reason
is that frr-reload.py doesn't recognize key as a sub-context.

Before this change, keys were generated this way:

    key chain test
     key 2
      key-string 123
     key 3
      key-string 456

With this change, keys will be generated this way:

    key chain test
     key 2
      key-string 123
     exit
     key 3
      key-string 456
     exit

This will allow frr-reload.py to see the key sub-context and correctly
reload them.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
2020-08-24 09:54:55 -04:00
Philippe Guibert
4088180002 bgpd, lib: support for flow_label flowspec type
in ipv6 flowspec, a new type is defined to be able to do filtering rules
based on 20 bits flow label field as depicted in [0]. The change include
the decoding by flowspec, and the addition of a new attribute in policy
routing rule, so that the data is ready to be sent to zebra.
The commit also includes a check on fragment option, since dont fragment
bit does not exist in ipv6, the value should always be set to 0,
otherwise the flowspec rule becomes invalid.

[0] https://tools.ietf.org/html/draft-ietf-idr-flow-spec-v6-09

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
e4552d667a lib: add family attribute for flowspec prefix structure
to recognize whether a flowspec prefix has been carried out by
ipv4 flowspec or ipv6 flowspec ( actually, the hypothesis is that only
ipv4 flowspec is supported), then a new attribute should contain the
family value: AF_INET or AF_INET6. That value will be further used in
the BGP flowspec code.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Chirag Shah
390a886277 *: record transaction based on control flag
In case of config rollback is enabled,
record northbound transaction based on a control flag.
The actual frr daemons would set the flag to true via
nb_init from frr_init.
This will allow test daemon to bypass recording
transacation to db.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-08-20 14:12:04 -07:00
Mark Stapp
38fd3eda40 lib: zapi nexthop sort fixes
The sorting for zapi nexthops in zapi routes needs to match
the sorting of nexthops done in zebra. Ensure all zapi_nexthop
attributes are included in the sort.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-08-20 14:50:38 -04:00
Chirag Shah
6a7fb29c19 lib: add yang modules to native module list
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-08-20 11:46:20 -07:00
Renato Westphal
24ed137c20 lib: adapt plugin to use new Sysrepo version
Sysrepo recently underwent a complete rewrite, where some substantial
architectural changes were made (the most important one being the
extinction of the sysrepod daemon). While most of the existing API
was preserved, quite a few backward-incompatible changes [1] were
introduced (mostly simplifications). This commit adapts our sysrepo
northbound plugin to those API changes in order for it to be compatible
with the latest Sysrepo version.

Additional notes:
* The old Sysrepo version is EOL and not supported anymore.
* The new Sysrepo version requires libyang 1.x.

Closes #6936

[1] https://github.com/sysrepo/sysrepo/blob/devel/CHANGES

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-20 11:53:46 -03:00
Rafael Zalamena
be8d09f125
Merge pull request #6924 from AnuradhaKaruppiah/mem-fixes
bgpd: fixes for problems found during EVPN fuzzing
2020-08-20 14:12:51 +00:00
Renato Westphal
0d206e9d85
Merge pull request #6945 from qlyoung/nb-more-messages
More gRPC logging + errmsg for no changes
2020-08-19 20:14:05 -03:00
Quentin Young
5bfb669b37 lib: fill nb errmsg when no changes during prep
During the prep phase to apply a northbound commit, if no changes were
detected make sure we fill the error message buffer to explain this.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-08-19 14:24:32 -04:00
Mark Stapp
cfc0a51f96
Merge pull request #6939 from sworleys/NH-Vrf-Del
lib: fix crash in show nexthop when vrf deleted
2020-08-19 12:15:56 -04:00
Quentin Young
1058646261 lib: add better zlogging to gRPC Commit RPC
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-08-18 16:31:03 -04:00
Stephen Worley
c40e980601 lib: fix crash in show nexthop when vrf deleted
Fix a crash where if we issue a show run after a vrf has been
deleted we would crash here due to not null checking.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-08-18 14:54:50 -04:00
Philippe Guibert
b1cc23b2cd zebra, lib: new API to get absolute netns val from relative netns val
when receiving a netlink API for an interface in a namespace, this
interface may come with LINK_NSID value, which means that the interface
has its link in an other namespace. Unfortunately, the link_nsid value
is self to that namespace, and there is a need to know what is its
associated nsid value from the default namespace point of view.
The information collected previously on each namespace, can then be
compared with that value to check if the link belongs to the default
namespace or not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-18 09:25:06 -07:00
Philippe Guibert
20f4b2b071 zebra, lib: store relative default ns id in each namespace
to be able to retrieve the network namespace identifier for each
namespace, the ns id is stored in each ns context. For default
namespace, the netns id is the same as that value.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-18 09:25:06 -07:00
Philippe Guibert
2d4e4d39b7 zebra, lib: add an internal API to get relative default nsid in other ns
as remind, the netns identifiers are local to a namespace. that is to
say that for instance, a vrf <vrfx> will have a netns id value in one
netns, and have an other netns id value in one other netns.
There is a need for zebra daemon to collect some cross information, like
the LINK_NETNSID information from interfaces having link layer in an
other network namespace. For that, it is needed to have a global
overview instead of a relative overview per namespace.
The first brick of this change is an API that sticks to netlink API,
that uses NETNSA_TARGET_NSID. from a given vrf vrfX, and a new vrf
created vrfY, the API returns the value of nsID from vrfX, inside the
new vrf vrfY.
The brick also gets the ns id value of default namespace in each other
namespace. An additional value in ns.h is offered, that permits to
retrieve the default namespace context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-18 09:25:06 -07:00
Philippe Guibert
07509878e3 zebra: importation of bgp evpn rt5 from vni with other netns
With vrf-lite mechanisms, it is possible to create layer 3 vnis by
creating a bridge interface in default vr, by creating a vxlan interface
that is attached to that bridge interface, then by moving the vxlan
interface to the wished vrf.
With vrf-netns mechanism, it is slightly different since bridged
interfaces can not be separated in different network namespaces. To make
it work, the setup consists in :
- creating a vxlan interface on default vrf.
- move the vxlan interface to the wished vrf ( with an other netns)
- create a bridge interface in the wished vrf
- attach the vxlan interface to that bridged interface

from that point, if BGP is enabled to advertise vnis in default vrf,
then vxlan interfaces are discovered appropriately in other vrfs,
provided that the link interface still resides in the vrf where l2vpn is
advertised.
to import ipv4 entries from a separate vrf, into the l2vpn, the
configuration of vni in the dedicated vrf + the advertisement of ipv4
entries in bgp vrf will import the entries in the bgp l2vpn.

the modification consists in parsing the vxlan interfaces in all network
namespaces, where the link resides in the same network namespace as the
bgp core instance where bgp l2vpn is enabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-18 09:25:06 -07:00
Quentin Young
4adddf0a29 lib: add STREAM_FORWARD_[GET|ENDP]
Safe stream macros for adjusting buffer pointers

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-08-15 08:24:54 -07:00
Renato Westphal
0fe5b904b7 lib: don't ignore error messages generated during the commit apply phase
While a configuration transaction can't be rejected once it reaches
the APPLY phase, we should allow NB callbacks to generate error
or warning messages when a configuration change is being applied.
That should be useful, for example, to return warnings back to
the user informing that the applied configuration has some kind of
inconsistency or is missing something in order to be effectively
activated. The infrastructure for this was already present, but the
northbound layer was ignoring all errors/warnings generated during
the apply/abort phases instead of returning them to the user. This
commit changes that.

In the gRPC plugin, extend the Commit() RPC adding a new
"error_message" field to the response type. This is necessary to
allow errors/warnings to be returned even when the commit operation
succeeds (since grpc::Status::OK doesn't support error messages
like the other status codes).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-14 21:37:14 -03:00
Donald Sharp
40ce7a4203
Merge pull request #6889 from opensourcerouting/isisd-assorted-fixes
isisd minor fixes and enhancements
2020-08-14 12:50:03 -04:00