Commit Graph

303 Commits

Author SHA1 Message Date
Donald Sharp
b219dda129 lib: Convert usage of strings to %pFX and %pRN
Convert over to using the %pFX and %pRN modifiers
to output strings to allow us to consolidate on
one standard for printing prefixes.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-17 13:39:10 -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
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
Pat Ruddy
bd23c84036 evpn-netns: Revert PR5077, has been re-worked post-refactor
Revert "zebra: support for macvlan interfaces"

This reverts commit bf69e212fd.

Revert "doc: add some documentation about bgp evpn netns support"

This reverts commit 89b97c33d7.

Revert "zebra: dynamically detect vxlan link interfaces in other netns"

This reverts commit de0ebb2540.

Revert "bgpd: sanity check when updating nexthop from bgp to zebra"

This reverts commit ee9633ed87.

Revert "lib, zebra: reuse and adapt ns_list walk functionality"

This reverts commit c4d466c830.

Revert "zebra: local mac entries populated in correct netnamespace"

This reverts commit 4042454891.

Revert "zebra: when parsing local entry against dad, retrieve config"

This reverts commit 3acc394bc5.

Revert "bgpd: evpn nexthop can be changed by default"

This reverts commit a2342a2412.

Revert "zebra: zvni_map_to_vlan() adaptation for all namespaces"

This reverts commit db81d18647.

Revert "zebra: add ns_id attribute to mac structure"

This reverts commit 388d5b438e.

Revert "zebra: bridge layer2 information records ns_id where bridge is"

This reverts commit b5b453a2d6.

Revert "zebra, lib: new API to get absolute netns val from relative netns val"

This reverts commit b6ebab34f6.

Revert "zebra, lib: store relative default ns id in each namespace"

This reverts commit 9d3555e06c.

Revert "zebra, lib: add an internal API to get relative default nsid in other ns"

This reverts commit 97c9e7533b.

Revert "zebra: map vxlan interface to bridge interface with correct ns id"

This reverts commit 7c990878f2.

Revert "zebra: fdb and neighbor table are read for all zns"

This reverts commit f8ed2c5420.

Revert "zebra: zvni_map_to_svi() adaptation for other network namespaces"

This reverts commit 2a9dccb647.

Revert "zebra: display interface slave type"

This reverts commit fc3141393a.

Revert "zebra: zvni_from_svi() adaptation for other network namespaces"

This reverts commit 6fe516bd4b.

Revert "zebra: importation of bgp evpn rt5 from vni with other netns"

This reverts commit 28254125d0.

Revert "lib, zebra: update interface name at netlink creation"

This reverts commit 1f7a68a2ff.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-08-05 06:46:12 -07:00
Renato Westphal
b855e95fd3 lib: introduce configuration back-off timer for YANG-modeled commands
When using the default CLI mode, the northbound layer needs to create
a separate transaction to process each YANG-modeled command since
they are supposed to be applied immediately (there's no candidate
configuration nor the "commit" command like in the transactional
CLI). The problem is that configuration transactions have an overhead
associated to them, in big part because of the use of some heavy
libyang functions like `lyd_validate()` and `lyd_diff()`. As of
now this overhead is substantial and doesn't scale well when large
numbers of transactions need to be performed in sequence.

As an example, loading 50k prefix-lists using a single transaction
takes about 2 seconds on a modern CPU. Loading the same 50k
prefix-lists using 50k transactions can take more than an hour
to complete (which is unacceptable by any standard). To fix this
problem, some heavy optimization work needs to be done on libyang and
on the FRR northbound itself too (e.g. perform partial configuration
diffs whenever possible).  This, however, should be a long term
effort since these optimizations shouldn't be trivial to implement
and we're far from having the performance numbers we need.

In the meanwhile, this commit introduces a simple but efficient
workaround to alleviate the issue. In short, a new back-off timer
was introduced in the CLI to monitor and detect when too many
YANG-modeled commands are being received at the same time. When
a certain threshold is reached (100 YANG-modeled commands within
one second), the northbound starts to group all subsequent commands
into a single large transaction, which allows them to be processed
much faster (e.g. seconds and not hours).  It's essentially a
protection mechanism that creates dynamically-sized transactions
when necessary to prevent performance issues from happening. This
mechanism is enabled both when parsing configuration files and when
reading commands from a terminal.

The downside of this optimization is that, if several YANG-modeled
commands are grouped into the same transaction and at least one of
them fails, the whole transaction is rejected. This is undesirable
since users don't expect transactional behavior when that's not
enabled explicitly. To minimize this issue, the CLI will log all
commands that were rejected whenever that happens, to make the
user aware of what happened and have enough information to fix
the problem. Commands that fail due to parsing errors or CLI-level
validations in general are rejected separately.

Again, this proposed workaround is intended to be temporary. The
goal is to provided a quick fix to issues like #6658 while we work
on better long-term solutions.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-03 15:17:03 -03:00
Renato Westphal
ca77b518bd *: introduce DEFPY_YANG & friends
DEFPY_YANG will allow the CLI to identify which commands are
YANG-modeled or not before executing them. This is going to be
useful for the upcoming configuration back-off timer work that
needs to commit pending configuration changes before executing a
command that isn't YANG-modeled.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-03 15:17:03 -03: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
Igor Ryzhov
a2719d0e88 zebra: show interfaces from all VRFs in "show interface ..." commands
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-06-22 10:09:35 +03:00
Santosh P K
57dd2f0097
Merge pull request #6414 from opensourcerouting/nb-error-handling
NB context + enhanced error handling
2020-06-10 22:47:07 +05:30
Quentin Young
f7c20aa1fd lib: move all userdata when changing node xpath
All userdata pointers need to be rekeyed to their new xpaths, not just
the one associated with the dnode being moved.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-06-04 20:24:52 -04:00
Renato Westphal
10bdc68f0c *: convert northbound callbacks to new error handling model
The northbound configuration callbacks should now print error
messages to the provided buffer (args->errmsg) instead of logging
them directly.  This will allow the northbound layer to forward the
error messages to the northbound clients in addition to logging them.

NOTE: many callbacks are returning errors without providing any
error message. This needs to be fixed long term.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:54 -03:00
Stephen Worley
3dab0aea06
Merge pull request #6426 from pguibert6WIND/update_ifname_before_hook
Update ifname before hook
2020-05-19 13:58:48 -04:00
Emanuele Di Pascale
5eb567edc8 lib: fix bandwidth multiplier for link param
in the CLI we state that the bandwidth of a link is
in Megabits per second, but when converting it to
Bytes per second for TE purposes we were treating
it as Kilobits. Fix the conversion error.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-05-19 17:08:04 +02:00
Philippe Guibert
1f7a68a2ff lib, zebra: update interface name at netlink creation
the interface name was not present in the hook in charge of updating the
interface context to the registered hook service. For that, update the
name before informing it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-19 16:02:12 +02:00
Renato Westphal
0b7005375f lib: constify a few parameters of helper functions
Parameters should be const whenever possible to improve code
readability and remove the need to cast away the constness of
const arguments.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-30 11:27:20 +02:00
Donald Sharp
967ebd2431
Merge pull request #6279 from opensourcerouting/nb-cb-args
*: change the signature of the northbound callbacks to be  more flexible
2020-04-24 08:09:16 -04:00
Renato Westphal
60ee8be107 *: change the signature of the northbound callbacks to be more flexible
Having a fixed set of parameters for each northbound callback isn't a
good idea since it makes it difficult to add new parameters whenever
that becomes necessary, as several hundreds or thousands of existing
callbacks need to be updated accordingly.

To remediate this issue, this commit changes the signature of all
northbound callbacks to have a single parameter: a pointer to a
'nb_cb_x_args' structure (where x is different for each type
of callback). These structures encapsulate all real parameters
(both input and output) the callbacks need to have access to. And
adding a new parameter to a given callback is as simple as adding
a new field to the corresponding 'nb_cb_x_args' structure, without
needing to update any instance of that callback in any daemon.

This commit includes a .cocci semantic patch that can be used to
update old code to the new format automatically.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-23 10:14:32 -03:00
Quentin Young
772270f3b6 *: sprintf -> snprintf
Replace sprintf with snprintf where straightforward to do so.

- sprintf's into local scope buffers of known size are replaced with the
  equivalent snprintf call
- snprintf's into local scope buffers of known size that use the buffer
  size expression now use sizeof(buffer)
- sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp
  buffer followed by strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Chirag Shah
83ed00f1df lib: remove gcc 4.x workaround for nb structure
Remove gcc 4.x workaround for variable size array as gcc
check moved to header file.

In lib/northbound.h : struct frr_yang_module_info made
size 1000 for gcc 4.x, where maximum 1000 nodes can fit.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:48:57 -07:00
Chirag Shah
4e0a7355c2 lib: add interface operational northbound callback
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:26:36 -07:00
Quentin Young
67f8158620 lib: handle failure to change ifindex
This fixes a theoretical bug that could occur when trying to change an
ifindex on an interface to that of an existing interface. We would
remove the interface from the ifindex tree, and change the ifindex, but
when we tried to reinsert the interface, the insert would fail. It was
impossible to know if this failed due to the insertion / deletion macros
capturing the result value of the underlying BSD tree macros. So we
would effectively delete the interface.

Instead of failing on insert, we just check if the prospective ifindex
already exists and return -1 if it does.

Macros have been changed to statement expressions so the result can be
checked, and bubbled up.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
3b55aba195 lib: remove unnecessary null checks
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Renato Westphal
dc397e4c0a lib: consolidate flexible array hack in a single place
Old gcc versions (< 5.x) have a bug that prevents C99 flexible
arrays from working properly on shared libraries.

We already have a hack in place to work around this problem, but it
needs to be replicated in every declaration of a frr_yang_module_info
variable within libfrr. This clearly isn't a good solution if we
consider that many more libfrr YANG modules are about to come in
the future.

This commit introduces a different workaround that operates within
the northbound layer itself, such that implementers of libfrr YANG
modules won't need to worry about this problem anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-03 22:34:55 -03:00
Donatas Abraitis
8fa77bc6f4 *: Remove tests for some XFREE-family functions
XFREE() covers that.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-11 18:16:23 +02:00
Donald Sharp
a94fbcca24 lib: Add vrf name to outputs/debugs
Add some additional output/debug to code to allow
us to see the vrf name instead of just the vrf id.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-14 08:41:42 -05:00
Donald Sharp
ac2914d326 lib: Format according to our standard
A couple of functions needed to be reformated.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-14 08:15:33 -05: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
Quentin Young
e33d7b6a03 lib: fix ifindex comparison overflow
Very small (negative!) ifindexes, when subtracted, can overflow.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-01-03 19:25:38 -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
Mahdi Varasteh
ced28861d4 lib: fixes invalid running_entry when VRF is changed
we just unset the entry from old node and add it to the new one

Signed-off-by: Mahdi Varasteh <mahdy.varasteh@gmail.com>
2019-12-10 08:38:45 +03:30
David Lamparter
fa751d15a0 lib: gcc 4.x workaround v2 for frr_interface_info
The previous workaround only works for -O0, at higher optimization
levels gcc reorders the statements in the file global scope which breaks
the asm statement :(.

Fixes: #4563
Fixes: #5074
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-30 00:38:32 +01:00
David Lamparter
50db10a162 lib: add gcc 4.x workaround for frr_interface_info
gcc 4.x does not properly support structs with variable length array
members.  Specifically, for global variables, it completely ignores the
array, coming up with a size much smaller than what is correct.  This is
broken for both sizeof() as well as ELF object size.

This breaks for frr_interface_info since this variable is in some cases
copy relocated by the linker.  (The linker does this to make the address
of the variable a "constant" for the main program.)  This copying uses
the ELF object size, thereby copying only the non-array part of the
struct.

Breakage ensues...

(This fix is a bit ugly, but it's limited to very old gcc, and it's
better than changing the array to "nodes[1000]" and wasting memory...)

Fixes: #4563
Fixes: #5074
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-26 17:14:03 +01:00
Donald Sharp
f609709a58 lib, ospfd, zebra: Convert interface_delete to take double pointer
When free'ing the interface pointer, set it to NULL.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-02 16:13:44 -04:00
Donald Sharp
721c08573a *: Convert connected_free to a double pointer
Set the connected pointer to set the pointer to NULL.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-02 16:13:44 -04: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
Ghasem Naddaf
457ea8d4bc vrrpd: only count ipv4 addresses on check start
Signed-off-by: Ghasem Naddaf <ghasem.naddaf@gmail.com>
2019-10-29 11:02:15 -07:00
Donald Sharp
68a4422da4 lib: vrf lookup may be NULL
The vrf lookup may be NULL, so let's protect against this.
Found in coverity

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-24 18:44:48 -04:00
Stephen Worley
d5c65bf1a2 *: Cleanup interface creation apis
Cleanup the interface creation apis to make it more
clear what they are doing.

Make it explicit that the creation via name/ifindex will
only add it to the appropriate list.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-09 20:24:31 -04:00
Stephen Worley
9685b1e414 lib: Don't add/del from name tree if name isnt set
If the name has not been set yet (we were only passed the
ifindex in some cases like with master/slave timings) then
do not add/del it from the ifname rb tree on the vrf struct.

Doing so causes duplicate entries on the tree and infinte loops
can happen when iterating over it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-09 20:09:49 -04:00
Russ White
9898a2fb34
Merge pull request #5009 from donaldsharp/interface_deletion
lib, zebra: Allow for interface deletion when kernel event happens
2019-09-30 07:46:19 -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
Donald Sharp
26f8f6fe7f lib: delete interface if you can in upper level protocol
In an upper level protocol, delete the interface on notification
about deletion.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
3c3c325203 *: Convert zapi->interface_delete to ifp callback
Convert the callback of the interface_delete to the new
ifp callback.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
b0b69e59f4 *: Convert interface_down to interface down callback
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
ddbf3e6060 *: Convert from ->interface_up to the interface callback
For all the places we have a zclient->interface_up convert
them to use the interface ifp_up callback instead.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
ef7bd2a3d5 *: Switch all zclient->interface_add to interface create callback
Switch the zclient->interface_add functionality to have everyone
use the interface create callback in lib/if.c

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
138c5a7450 *: Add infrastructure to support zapi interface callbacks
Start the conversion to allow zapi interface callbacks to be
controlled like vrf creation/destruction/change callbacks.

This will allow us to consolidate control into the interface.c
instead of having each daemon read the stream and react accordingly.
This will hopefully reduce a bunch of cut-n-paste stuff

Create 4 new callback functions that will be controlled by
lib/if.c

create -> A upper level protocol receives an interface creation event
The ifp is brand spanking newly created in the system.
up -> A upper level protocol receives a interface up event
This means the interface is up and ready to go.
down -> A upper level protocol receives a interface down
destroy -> A upper level protocol receives a destroy event
This means to delete the pointers associated with it.

At this point this is just boilerplate setup for future commits.
There is no new functionality.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
1d311a05c9 lib, zebra: Allow for interface deletion when kernel event happens
When zebra gets a callback from the kernel that an interface has
actually been deleted *and* the end users has not configured
the interface, then allow for deletion of the interface from zebra.

This is especially important in a docker environment where containers
and their veth interfaces are treated as ephermeal.  FRR can quickly
have an inordinate amount of interfaces sitting around that are
not in the kernel and we have no way to clean them up either.

My expectation is that this will cause a second order crashes
in upper level protocols, but I am not sure how to catch these
and fix them now ( suggestions welcome ).  There are too many
use patterns and order based events that I cannot know for certain
that we are going to see any at all, until someone sees this problem
as a crash :(  I do not recommend that this be put in the current
stabilization branch and allow this to soak in master for some time
first.

Testing:

sharpd@donna ~/frr4> sudo ip link add vethdj type veth peer name vethjd
sharpd@donna ~/frr4> sudo ip link add vethaa type veth peer name vethab
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
vethaa          down    default
vethab          down    default
vethdj          down    default
vethjd          down    default
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo ip link set vethaa up
sharpd@donna ~/frr4> sudo ip link set vethab up
sharpd@donna ~/frr4> sudo ip link del vethdj
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
vethaa          up      default
vethab          up      default
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo ip link del vethaa
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo ip link add vethaa type veth peer name vethab
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
vethaa          down    default
vethab          down    default
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo vtysh -c "show run"
Building configuration...

Current configuration:
!
frr version 7.2-dev
frr defaults datacenter
hostname donna.cumulusnetworks.com
log stdout
no ipv6 forwarding
!
ip route 192.168.3.0/24 192.168.209.1
ip route 192.168.4.0/24 blackhole
ip route 192.168.5.0/24 192.168.209.1
ip route 192.168.6.0/24 192.168.209.1
ip route 192.168.7.0/24 99.99.99.99 nexthop-vrf EVA
ip route 192.168.8.0/24 192.168.209.1
ip route 4.5.6.7/32 12.13.14.15
!
interface dummy1
 ip address 12.13.14.15/32
!
interface vethaa
 description FROO
!
line vty
!
end
sharpd@donna ~/frr4> sudo ip link del vethaa
sharpd@donna ~/frr4> sudo vtysh -c "show int brief"
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
dummy1          down    default
enp0s3          up      default         10.0.2.15/24
enp0s8          up      default         192.168.209.2/24
enp0s9          up      default         192.168.210.2/24
enp0s10         up      default         192.168.212.4/24
lo              up      default         10.22.89.38/32
vethaa          down    default
virbr0          up      default         192.168.122.1/24
virbr0-nic      down    default

sharpd@donna ~/frr4> sudo vtysh -c "show run"
Building configuration...

Current configuration:
!
frr version 7.2-dev
frr defaults datacenter
hostname donna.cumulusnetworks.com
log stdout
no ipv6 forwarding
!
ip route 192.168.3.0/24 192.168.209.1
ip route 192.168.4.0/24 blackhole
ip route 192.168.5.0/24 192.168.209.1
ip route 192.168.6.0/24 192.168.209.1
ip route 192.168.7.0/24 99.99.99.99 nexthop-vrf EVA
ip route 192.168.8.0/24 192.168.209.1
ip route 4.5.6.7/32 12.13.14.15
!
interface dummy1
 ip address 12.13.14.15/32
!
interface vethaa
 description FROO
!
line vty
!
end

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Quentin Young
f88647ef75 lib: add oper data cbs for ifaces
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-09-18 19:42:47 +00:00
Renato Westphal
8685be73e0 Revert "lib: introduce a read-write lock for northbound configurations"
Adding a lock to protect the global running configuration doesn't
help much since the FRR daemons are not prepared to process
configuration changes in a pthread that is not the main one (a
whole lot of new protections would be necessary to prevent race
conditions).

This means the lock added by commit 83981138 only adds more
complexity for no benefit. Remove it now to simplify the code.

All northbound clients, including the gRPC one, should either run
in the main pthread or use synchronization primitives to process
configuration transactions in the main pthread.

This reverts commit 83981138fe.
2019-09-18 14:35:10 -03:00
Donald Sharp
dd7c916952
Merge pull request #4880 from ddutt/master
lib: Make if_lookup_by_index understand if VRF is backed by netns or not
2019-08-26 14:08:08 -04:00
Dinesh G Dutt
47b474b57e lib: Make if_lookup_by_index understand if VRF is backed by netns or not
FRR has two implementations of VRF, one backed by netns and the other by
the proper VRF implementation in the Linux kernel. In certain places, the
code assumes that a VRF is netns and so lookups fail. One example of this
is in IPv6 RA code. This causes functionality such as Unnumbered BGP to
fail. To fix this, this patch makes if_lookup_by_index handle the
behavior based on the backend, similar to if_get_by_index. For the two
places in if.c that were calling if_lookup_by_index to be specific to
the VRF, I renamed the existing code, if_lookup_by_ifindex and made it a
static function that is never exposed or called by any routine outside of
if.c.

Signed-off-by: Dinesh G Dutt <5016467+ddutt@users.noreply.github.com>
2019-08-26 12:38:28 +00:00
Renato Westphal
3923b6e309 lib: fix a couple more doc comments
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-08-21 11:41:14 -03:00
Dinesh G Dutt
ea7ec26162 zebra: Ensure master's ifname is known, even if slave comes up first
In if_netlink.c, when an interface structure, ifp, is first created,
its possible for the master to come up after the slave interface does.
This means, the slave interface has no way to display the master's ifname
in show outputs. To fix this, we need to allow creation by ifindex instead
of by ifname so that this issue is handled.

Signed-off-by: Dinesh G Dutt<5016467+ddutt@users.noreply.github.com>
2019-08-13 16:29:40 +00:00
Donald Sharp
a36898e755
Revert "Ospf missing interface handling 2" 2019-06-23 19:46:39 -04:00
Donald Sharp
a12bb225a6
Merge pull request #3775 from pguibert6WIND/ospf_missing_interface_handling_2
Ospf missing interface handling 2
2019-06-22 13:35:45 -04:00
David Lamparter
eaf58ba906 lib: use MTYPE_STATIC
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-21 08:54:25 +02:00
David Lamparter
53280f9327 *: fix northbound initializer warning on OpenBSD
For some reason, the compiler on OpenBSD on our CI boxes doesn't like
struct initializers with ".a.b = x, .a.c = y", generating a warning
about overwritten initializers...

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 00:05:03 +02:00
Philippe Guibert
a41c4e1b1f *: change interface structure, from vrf_id to vrf
Field vrf_id is replaced by the pointer of the struct vrf *.
For that all other code referencing to (interface)->vrf_id is replaced.
This work should not change the behaviour.
It is just a continuation work toward having an interface API handling
vrf pointer only.

some new generic functions are created in vrf:
vrf_to_id, vrf_to_name,

a zebra function is also created:
zvrf_info_lookup

an ospf function is also created:
ospf_lookup_by_vrf

it is to be noted that now that interface has a vrf pointer, some more
optimisations could be thought through all the rest of the code. as
example, many structure store the vrf_id. those structures could get
the exact vrf structure if inherited from an interface vrf context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 14:10:28 +02:00
Philippe Guibert
da85f5e038 lib, bgpd, ospfd, pimd, zebra, rip, ripng, bfd: change if_update_to_new_vrf() api
vrf_id parameter is replaced with struct vrf * parameter. It is
needed to create vrf structure before entering in the fuction.
an error is generated in case the vrf parameter is missing.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
921a85ba8c zebra, ifp: on netlink discovery, anticipate the vrf creation
there may be cases where the vrf is yet allocated from the vty, and the
discovery process did not make the relationship between the vrf_id and
the name of the vrf. For instance, by parsing an interface belonging to
vrf-id X, it is not sure that vrf-id X and vrfname XX are talking about
the same vrf. For that, lets allocate the vrf, and lets try to detect
there is a duplicate case in vrf, so that the merge can be done without
any impact for the user.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
8205b1b455 zebra, lib: upon entering interface, create vrf context
the interface search is based on vrfs. As at startup, some interfaces
may be configured, there is need to have vrfs contexts present. A macro
is being appended with an extra parameter that permits create a vrf and
return the context. This macro is also used by some show routines, but
will not create vrfs, because that extra parameter will be set to false,
on that case.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
ac6c2a11a6 lib: create interface upon accessing interface NB API.
Upon accessing interface NB API, the interface is created, if the vrf
is available. the commit does not change the behaviour, since at this
commit, this is not yet possible to have vrf contexts, while zebra did
not connect to daemons. However, that commit adds some work, so that it
will be possible to work on a vrf context, without having the vrf_id
completely resolved. for instance, if we suppose a vrf is created by
command 'vrf TOTO' in the starting configuration of a daemon, then 'interface
TITI vrf TOTO' will permit to create interface TITI within vrf TOTO.

the macro VRF_GET_INSTANCE will return the vrf context, if available or
not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
f11e98eca3 *: change if_lookup_by_name() api with vrf
the vrf_id parameter is replaced by struct vrf * parameter.
this impacts most of the daemons that look for an interface based on the
name and the vrf identifier.
Also, it fixes 2 lookup calls in zebra and sharpd, where the vrf_id was
ignored until now.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:54 +02:00
Philippe Guibert
e9c199a6c1 lib, ospfd, pimd, zebra: change if_create() api with vrf
if_create() takes as input a vrf poiter instead of the vrf_id parameter.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11 17:10:47 +02:00
Philippe Guibert
4c634658a6 ospf, ospf6d, zebra, lib: change if_get_by_name prototype with vrf
vrf pointer is used as reference when calling if_get_by_name() function.
this will permit to create interfaces with an unknown vrf_id, since it
is only necessary to get the vrf structure to store the interfaces.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11 17:10:47 +02:00
Quentin Young
667179cae4 lib: add function to get iface link-local
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
dad18a2fd7 vrrpd: add initial macvlan support
* Search for macvlan interfaces with the appropriate name and MAC
  address when starting up a new VRRP instance
* Split VRRP socket into two; one for Tx, one for Rx
* Bind Tx socket to the macvlan subinterface so our VRRP advertisements
  go out with the correct MAC address
* Send ARP requests from this macvlan subinterface
* Improve error messaging

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Renato Westphal
83981138fe lib: introduce a read-write lock for northbound configurations
The upcoming gRPC-based northbound plugin will run on a separate
pthread, and it will need to have access to the running configuration
global variable.  Introduce a rw-lock to control concurrent access
to the running configuration. Add the lock inside the "nb_config"
structure so that it can be used to protect candidate configurations
as well (this might be necessary depending on the threading scheme
of future northbound plugins).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-26 18:04:22 -03:00
Donald Sharp
8f19bc1c69
Merge pull request #3786 from mjstapp/dplane_intf
zebra: async interface address programming
2019-04-22 15:29:02 -04:00
Mark Stapp
6339042cb9 libs: use const in some interface flag accessors
Use const in several interface struct flag accessors (that just
test flags.)

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-22 13:49:27 -04:00
Renato Westphal
ccd43ada17 lib: rework management of user pointers in the northbound layer
Introduce a hash table to keep track of user pointers associated
to configuration entries. The previous strategy was to embed
the user pointers inside libyang data nodes, but this solution
incurred a substantial performance overhead. The user pointers
embedded in candidate configurations could be lost while the
configuration was being edited, so they needed to be regenerated
before the candidate could be committed.  This was done by the
nb_candidate_restore_priv_pointers() function, which was extremely
expensive for large configurations. The new hash table solves this
performance problem.

The yang_dnode_[gs]et_entry() functions were renamed and moved from
yang.[ch] to northbound.[ch], which is a more appropriate place
for them. This patch also introduces the nb_running_unset_entry()
function, the counterpart of nb_running_set_entry() (unsetting
user pointers was done automatically before, now it needs to be
done manually).

As a consequence of these changes, we shouldn't need support for
libyang private pointers anymore (-DENABLE_LYD_PRIV=ON). But it's
probably a good idea to keep requiring this feature as we might
need it in the future for other things (e.g. disable configuration
settings without removing them).

Fixes #4136.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-18 11:56:45 -03:00
Donald Sharp
3393df5cf1 lib: Fixup IFF_OUT_LOG macro to make SA happy
The IFF_OUT_LOG macro is using BUFSIZE, which is the sizeof(logbuf)
but for some reason 8.0 clang SA is not happy with it.  Just
make it happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-06 20:10:52 -04:00
Donald Sharp
f61f266a0e
Merge pull request #3548 from opensourcerouting/rip-vrf
rip(ng)d: add VRF support
2019-04-04 19:24:14 -04:00
Quentin Young
c17faa4b10 lib: reduce exported var symbols
Don't need these in our DSO tables

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-04-03 20:34:18 +00:00
Renato Westphal
6a3fdeecf1 lib, ripd, ripngd: rename remaining delete northbound callbacks
PR #3622 renamed the "delete" northbound callback to "destroy" in
order to make the libfrr headers compatible with C++. This commit
renames a few functions that still use "delete" instead of "destroy"
in their names.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-03-29 11:32:33 -03:00
Donald Sharp
c9146c85a0
Merge pull request #3772 from pguibert6WIND/vrf_backend_unknown
Vrf backend unknown
2019-03-25 08:13:16 -04: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
Mark Stapp
95ce849b58 libs, rip, isis: change northbound operation enum to DESTROY
Change the northbound lib operation from DELETE to DESTROY;
make the required changes in the users of the northbound, in
the cli, rip, ripng, and isis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11 15:49:49 -02:00
Mark Stapp
d01b92fd75 libs, daemons: changes to permit c++ compilation
Some misc changes to resolve some c++ compilation errors.
The goal is only to permit an external module - a plugin,
for example - to see frr headers, not to support or encourage
contributions in c++. The changes include: avoiding use
of keywords like 'new', 'delete'; cleaning up implicit
type-casting from 'void *' in several places.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11 15:49:49 -02:00
Philippe Guibert
b0b97a7f61 lib: handling vrf backend unknown case
on interface search algorithm, at initialisation, when reading config
file, the vrf backend may not be yet known ( because zebra did not sync
yet with daemon). For that, avoid searching interface name in a separate
vrf. This change of behaviour is induced because the assumption is done
that at config startup, the user is not wrong with the interface
configuration to use. Every usage of vrf_get_backend() should then be
wisely adapted in order to handle that init state.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-02-11 13:48:12 +01:00
Philippe Guibert
72261ecd22 lib: interface handling where zebra not yet ready
other daemons need to sync with zebra to get to know which vrf backend
is available. in that time, there may be interface configuration
available. in that specific case, the vrf backend returned is not known.
A specific return value is sent back. This will be useful to know which
specific algorithm to apply.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-02-11 13:47:04 +01:00
Renato Westphal
a6233bfcb3 lib, ripd: rework API for converted CLI commands
When editing the candidate configuration, the northbound must ensure
that either all changes made by a command are accepted or none are.
This is done to prevent inconsistent states where only parts of a
command are applied in the event any error happens.

The previous API for converted commands, the nb_cli_cfg_change()
function, required callers to pass an array containing all changes
that needed to be applied in the candidate configuration. The
problem with this API is that it was very inconvenient for complex
commands, which change different configuration options depending
on several factors.  This required users to manipulate the array
of configuration changes using low-level primitives, making it
complicated to implement some commands.

To solve this problem, introduce a new API based on the two following
functions:
- nb_cli_enqueue_change()
- nb_cli_apply_changes()

The first function is used to enqueue configuration changes, one
at time. Then the nb_cli_apply_changes() function is used to apply
all the enqueued configuration changes.

To implement this, a static-sized array was allocated in the "vty"
structure, along with a counter of enqueued changes. This eliminates
the need to declare an array of configuration changes in every
converted CLI command, simplifying things quite considerably.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26 15:57:23 -02:00
Renato Westphal
25c780a32a lib: make yang_dnode_get_entry() more flexible
Add the "abort_if_not_found" parameter to the yang_dnode_get_entry()
function instead of always aborting when an user pointer is not
found.  This will make it possible, for example, to use this function
during the validation phase of a configuration transaction. Callers
will only need to check if the function returned NULL or not,
since new configuration objects (if any) won't be created until
the NB_EV_APPLY phase of the transaction.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26 15:53:15 -02:00
Renato Westphal
8f90d89ba9 lib: retrofit interface commands to the new northbound model
The frr-interface YANG module models interfaces using a YANG list keyed
by the interface name and the interface VRF. Interfaces can't be keyed
only by their name since interface names might not be globally unique
when the netns VRF backend is in use. When using the VRF-Lite backend,
however, interface names *must* be globally unique. In this case, we need
to validate the uniqueness of interface names inside the appropriate
northbound callback since this constraint can't be expressed in the
YANG language. We must also ensure that only inactive interfaces can be
removed, among other things we need to validate in the northbound layer.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal
a4bed468f9 yang, lib: add 'frr-interface.yang' and associated stub callbacks
Introduce frr-interface.yang, which defines a model for managing FRR
interfaces.

Update the 'frr_yang_module_info' array of all daemons that will
implement this module.

Add automatically generated stub callbacks in if.c. These callbacks will
be implemented in the following commit.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02: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
Donald Sharp
b1cc6da84f lib: Allow useful display of default vrf name
When entering a interface name and you fat-finger it
actually display some useful information about the vrf
we are in.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-22 12:10:02 -04:00
Quentin Young
e8275c22b4
Merge pull request #3040 from pacovn/static_analysis__drop_const_1
bgpd isisd ldpd lib: const drop fixes (SA)
2018-09-17 15:25:49 -04:00
F. Aragon
36de6e0e1e
bgpd isisd ldpd lib: const drop fixes (SA)
Can be detected with e.g. ./configure CFLAGS=-Wcast-qual CC=clang

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-17 19:38:59 +02: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
Russ White
88f47ef365
Merge pull request #2944 from thbtcllt/master
fix zebra crash when a vrf interface changes with netns implementation for vrf
2018-09-11 11:33:27 -04:00
David Lamparter
ae9eebcaeb *: fix some solaris warnings
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:30:42 +02:00
Thibaut Collet
379eb245f6 lib/if.c: fix CLANG warning
Fix CLANG warning:
Report for if.c | 2 issues
===============================================
< WARNING: else is not generally useful after a break or return
< #390: FILE: /tmp/f1-28557/if.c:390:

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
2018-08-30 16:29:06 +02:00
Thibaut Collet
ee2f2c23ca zebra: fix crash when interface vrf changes
This crash occurs only with netns implementation.
vrf meaning is different regarging its implementation (netns or
vrf-lite)

- With vrf-lite implementation vrf is a property of the interface that
  can be changed as the speed or the state (iproute2 command: "ip link
  set dev IF_NAME master VRF_NAME"). All interfaces of the system are in
  the same netns and so interface name is unique.
- With netns implementation vrf is a characteristic of the interface
  that CANNOT be changed: it is the id of the netns where the interface
  is located. To change the vrf of an interface (iproute2 command to
  move an interface "ip netns exec VRF_NAME1 ip link set dev IF_NAME
  netns VRF_NAME2") the interface is deleted from the old vrf and
  created in the new vrf.
  Interface name is not unique, the same name can be present in the
  different netns (typically the lo interface) and search of interface
  must be done by the tuple (interface name, netns id).

Current tests on the vrf implementation (vrf-lite or netns) are not
sufficient. In some cases (for example when an interface is moved from
a vrf X to the default vrf and then move back to VRF X) we can have a
corruption message and then a crash of zebra.

To avoid this corruption test on the vrf implementation, needed when an
interface changes, has been rewritten:
- For all interface changes except deletion the if_get_by_name function,
  that checks if an interface exists and creates or updates it if
  needed, is changed:
    * The vrf-lite implementation is unchanged: search of the interface
      is based only on the name and update the vrf-id if needed.
    * The netns implementation search of the interface is based on the
      (name, vrf-id) tuple and interface is created if not found, the
      vrf-id is never updated.
- deletion of an interface (reception of a RTM_DELLINK netlink message):
    * The vrf-lite implementation is unchanged: the interface
      information are cleared and the interface is moved to the default
      vrf if it does not belong to (to allow vrf deletion)
    * The netns implementation is changed: only the interface
      information are cleared and the interface stays in its vrf to
      avoid conflict with interface with the same name in the default
      vrf.

This implementation reverts (partially or totally):
commit 393ec5424e ("zebra: fix missing node attribute set in ifp")
commit e9e9b1150f ("lib: create interface even if name is the same")
commit 9373219c67 ("zebra: improve logs when replacing interface to an
other netns")
Fixes: b53686c52a ("zebra: delete interface that disappeared")

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-30 14:37:59 +02:00
Don Slice
fec4ca191e zebra: if multiple connecteds, select loopback or vrf if present
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-23 18:49:48 +00:00
Donald Sharp
03548ae818 lib: Convert debug to error situation
This debug should be moved to an error situation since it's a
developmental escape that needs to be fixed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-23 08:36:07 -04:00
Philippe Guibert
3d4c0b49da lib: change vrf_is_mapped_on_netns API
The function handles not a vrf pointer instead of a vrf_id value.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-22 09:19:04 +02:00
Donald Sharp
4d43f68aeb lib, zebra: Add LIB_ERR_INTERFACE
Add a error type that allows us to track bad interface states.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00: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