Commit graph

308 commits

Author SHA1 Message Date
Igor Ryzhov f5eef2d5a8 lib: remove vrf-interface config when removing the VRF
If we have the following configuration:
```
vrf red
 smth
 exit-vrf
!
interface red vrf red
 smth
```
And we delete the VRF using "no vrf red" command, we end up with:
```
interface red
 smth
```
Interface config is preserved but moved to the default VRF.

This is not an expected behavior. We should remove the interface config
when the VRF is deleted.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-21 18:04:46 +03:00
Christian Hopps 3bb513c399 lib: adapt to version 2 of libyang
Compile with v2.0.0 tag of `libyang2` branch of:
https://github.com/CESNET/libyang

staticd init load time of 10k routes now 6s vs ly1 time of 150s

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-05-13 16:24:48 -04:00
Donald Sharp 458133dbc5 lib, ripd, ripngd, vtysh: Move distribute list to correct spot
Allow the `distribute-list...` command in ripd and ripngd to
work correctly.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-04 16:23:37 -04:00
David Lamparter bf8d3d6aca *: require semicolon after DEFINE_MTYPE & co
Back when I put this together in 2015, ISO C11 was still reasonably new
and we couldn't require it just yet.  Without ISO C11, there is no
"good" way (only bad hacks) to require a semicolon after a macro that
ends with a function definition.  And if you added one anyway, you'd get
"spurious semicolon" warnings on some compilers...

With C11, `_Static_assert()` at the end of a macro will make it so that
the semicolon is properly required, consumed, and not warned about.

Consistently requiring semicolons after "file-level" macros matches
Linux kernel coding style and helps some editors against mis-syntax'ing
these macros.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
Donald Sharp 2e2262fe14 ripd: Convert to using internal printf formatters
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-03-09 20:07:20 -05:00
Donald Sharp 94457bc6a8 ripd: #if 0 we know what you are up to.
rip, ripped out the #if 0 code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-28 13:40:05 -05:00
Donatas Abraitis 3a6290bdd1 *: Replace s_addr check agains 0 with INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-14 21:03:38 +02:00
Donald Sharp 1782514fb9 *: Remove route_map_object_t from the system
The route_map_object_t was being used to track what protocol we were
being called against.  But each protocol was only ever calling itself.
So we had a variable that was only ever being passed in from route_map_apply
that had to be carried against and everyone was testing if that variable
was for their own stack.

Clean up this route_map_object_t from the entire system.  We should
speed some stuff up.  Yes I know not a bunch but this will add up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-13 19:35:20 -05:00
Mark Stapp 5047884528 *: unify thread/event cancel macros
Replace all lib/thread cancel macros, use thread_cancel()
everywhere. Only the THREAD_OFF macro and thread_cancel() api are
supported. Also adjust thread_cancel_async() to NULL caller's pointer (if
present).

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-23 12:16:52 -04:00
Mark Stapp 53bb7f9bb3 ripd: replace inet_ntoa
Replace all uses of inet_ntoa, using pI4, pFX, or inet_pton.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-22 16:25:41 -04:00
Donald Sharp f42238f895 ripd: Convert to using %pFX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-17 13:39:10 -04:00
Igor Ryzhov eb6b38854f rip(ng)d: fix interfaces cleaning
rip(ng)d_instance_disable unlinks the vrf from the instance which means
that rip(ng)_interfaces_clean never works, because rip(ng)->vrf is
always NULL there. This leads to the crash #6477.

Clean interfaces before disabling the instance to fix the issue.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-09 15:14:58 +03:00
Igor Ryzhov 3704ff5608 *: move all userdata when changing node xpath
The same thing was done for interfaces in commit f7c20aa1f.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-09-24 21:05:32 +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
David Lamparter c334a16ef1
Merge pull request #6262 from qlyoung/remove-sprintf 2020-04-23 20:27:26 +02: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
Rafael Zalamena 5920b3eb38 *: replace all random() calls
Replace all `random()` calls with a function called `frr_weak_random()`
and make it clear that it is only supposed to be used for weak random
applications.

Use the annotation described by the Coverity Scan documentation to
ignore `random()` call warnings.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-17 20:57:43 -03:00
David Lamparter f4b8291fcb *: move CLI node names to cmd_node->name
And again for the name.  Why on earth would we centralize this, just so
people can forget to update it?

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:59 +02:00
David Lamparter 243895805a *: move CLI parent data to cmd_node->parent_node
Same as before, instead of shoving this into a big central list we can
just put the parent node in cmd_node.

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

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

[v2: fix forgotten ldpd config_write]

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

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

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
Donatas Abraitis 0d6f7fd6fd *: Replace sizeof something to sizeof(something)
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis)

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-08 21:44:53 +02:00
Mark Stapp a2700b5071 *: use gmtime_r, localtime_r exclusively
Stop using gmtime() or localtime() everywhere.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-05 13:26:16 -05:00
Donatas Abraitis 975a328e2e *: Replace s_addr 0 => INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-06 09:00:12 +02:00
Quentin Young e1b36e132b *: remove null check before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-04 13:19:37 -05:00
Renato Westphal f80ec39e52 ripd: split northbound callbacks into multiple files
Rearrange the ripd northbound callbacks as following:
* rip_nb.h: prototypes of all northbound callbacks.
* rip_nb.c: definition of all northbound callbacks and their
  associated YANG data paths.
* rip_nb_config.c: implementation of YANG configuration nodes.
* rip_nb_state.c: implementation of YANG state nodes.
* rip_nb_rpcs.c: implementation of YANG RPCs.
* rip_nb_notifications.c: implementation of YANG notifications.

This should help to keep to code more organized and easier to
maintain.

No behavior changes intended.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-10-29 21:49:14 -03: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
Russ White fe8d933c2c
Merge pull request #4564 from pguibert6WIND/misc_vrf_update_name
Misc vrf update name
2019-09-17 07:22:22 -04:00
David Lamparter 0cf6db21ec *: frr_elevate_privs -> frr_with_privs
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:18:35 +02:00
Philippe Guibert d487770793 ripd: change vrf name with bypassing nb api
ripd operational & config data may already applied and available, while
an external event requests for changing the vrf name. this change
updates the config and operational context of yang.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-08-27 17:00:24 +02:00
Philippe Guibert 100db763b7 ripd: update the default vrf name by registering to callback
if default vrf name is updated, then rip contexts based on that
hypothetical vrfname, will be enabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-08-27 15:08:50 +02:00
Michal Ruprich 0513a27153 ospfd,ripd: Enabling build with openssl
Enabling openssl library for md5 authentication in RIP and OSPF

Signed-off-by: Michal Ruprich <michalruprich@gmail.com>
2019-08-08 16:03:20 +02: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 814a25859a ripd: use MTYPE_STATIC
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-21 08:54:25 +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 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
Renato Westphal 6c4c3561fe ripd, ripngd: fix cleaning up of offset lists
We should never attempt to remove a list item in the "del" callback
of the list. This is already performed by the list_delete() function,
doing it twice leads to crashes or memory corruption.

Introduce the offset_list_free() function so that we can separate the
removal and deallocation of offset lists into separate functions,
without code duplication. offset_list_del() will be used by the
northbound callbacks to remove offset lists, while offset_list_free()
will be used by rip_clean() to clean up all RIP offset lists using
list_delete(). Do the same for ripngd.

This is a fallout from the ripd/ripngd northbound conversion.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-19 16:09:50 -03:00
Renato Westphal 338b8e914a *: setting the socket send/recv buffer sizes doesn't need elevated privs
The less code running under elevated privileges the better.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-08 13:11:28 -03:00
Renato Westphal 8f88441d71 Merge remote-tracking branch 'frr/master' into rip-vrf
Merge commit to solve a bunch of conflicts with other PRs that were
merged in the previous weeks.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-03-29 11:32:21 -03:00
Renato Westphal fe39eb421e
Merge pull request #3877 from qlyoung/remove-strncpy
Remove strncpy
2019-03-01 17:06:29 -03:00
Quentin Young 5c84f23817 ripd: strncpy -> strlcpy
strncpy is a byte copy function not a string copy function

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-26 20:50:17 +00:00
Philippe Guibert aec0d75667 eigrp, rip, ripng, lib: unlink if_rmap from vrf
an interface rmap context can be created from a custom name string,
instead of a vrf. This ability permits to handle several instances of
interface route map in the same vrf. The naming convention will be
transparent on what the name is for in the daemon code.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-02-19 21:11:37 +01:00
Philippe Guibert 4b23867cad lib, rip, ripng, eigrp: rework if_rmap context
so as to handle ri/ripng/eigrp multiple instances, the need is to
encapsulate if_rmap hash table into a container context self to each
instance. This work then reviews the if_rmap api, mainly by adding a
if_rmap_ctx context, that is passed for each exchange between library
and the daemon.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-02-19 21:11:13 +01:00
rgirada 6f54377b8e ripd,ripngd: Added changes to track route-map usage in rip,ripng
Updated the routemap applied counter wherever  route map
attached/detached  to a redistribution list.

Signed-off-by: RajeshGirada <rgirada@vmware.com>
2019-02-04 05:14:31 -08:00
Renato Westphal f9120f719a ripd, ripngd: change how we keep track of redistribution configuration
ripd and ripngd were leveraging the zclient code to keep track of
the redistribute configuration, which is what most daemons do. The
problem, however, is that the zclient code uses VRF IDs to identify
VRFs, and VRF IDs are unknown until a VRF is enabled (information
received from zebra). This means we can't configure a redistribute
command on a RIP instance when the corresponding VRF is disabled
(doing so leads to a null-dereference crash right now in both ripd
and ripngd).

To fix this, change the rip/ripng data structures so that they
keep track of the full redistribute configuration and not only the
route-map and metric associated to each command. This is similar
to what bgpd and ospfd are doing to solve the same problem. In the
future the zclient code and all daemons need to be refactored to
consolidate the handling of redistribute configuration in a single
place to reduce code duplication. One of the most important changes
to do is to use VRF names and not VRF IDs to identify VRFs.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal ae7b826a23 ripd: add VRF support
* Turn the "instance" YANG presence-container into a YANG list keyed
  by the new "vrf" leaf. This is a backward incompatible change but
  this should be ok for now.

* RIP VRF instances can be configured even when the corresponding
  VRF doesn't exist. And a RIP VRF instance isn't deleted when
  the corresponding VRF is deleted. For this to work, implement the
  rip_instance_enable() and rip_instance_disable() functions that are
  called to enable/disable RIP routing instances when necessary. A
  RIP routing instance can be enabled only when the corresponding
  VRF is enabled (this information comes from zebra and depends on
  the underlying VRF backend). Routing instances are stored in the new
  rip_instances rb-tree (global variable).

* Add a vrf pointer to the rip structure instead of storing vrf_id
  only. This is much more convenient than using vrf_lookup_by_id()
  every time we need to get the vrf pointer from the VRF ID. The
  rip->vrf pointer is updated whenever the VRF enable/disable hooks
  are called.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 9852be711c ripd: failure to create a socket shouldn't be a fatal error
The ripd code can handle this error just fine (e.g. reject the
configuration transaction), there's no need to exit when a socket
fails to be created.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal e35356af91 ripd: switch from sendto() to sendmsg()
For unknown reasons, the IP_MULTICAST_IF sockoption doesn't
seem to work when the given socket is bound to a VRF device on
Linux. Switch from sendto() to sendmsg() so that we can specify the
outgoing interface of multicast packets using IP_PKTINFO ancillary
data. This also makes ripd more consistent with ripngd, which also
uses sendmsg() to send packets on the wire.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 045c5389c2 ripd: remove the rip global variable
This is the last step to make ripd ready for multi-instance support.

Remove the rip global variable and add a "rip" parameter to all
functions that need to know the RIP instance they are working
on. On some functions, retrieve the RIP instance from the interface
variable when it exists (this assumes interfaces can pertain to
one RIP instance at most, which is ok for VRF support).

In preparation for the next commits (VRF support), add a "vrd_id"
member to the rip structure, and use rip->vrf_id instead of
VRF_DEFAULT wherever possible.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 711915d2cd ripd: clear list of peers when RIP is deconfigured
This is an old standing bug where the list of RIP peers wasn't
cleared after deconfiguring RIP, which caused the existing peers
to still be present on a newly configured RIP instance (except when
the timed out after ~3 minutes). Fix this.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 2826309c11 ripd: move "rip_distance_table" to the rip structure
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal c08a21077f ripd: move global counters to the rip structure
The only sideeffect of this change is that these counters will be
reset when RIP is deconfigured and then configured again, but this
shouldn't be a problem as the RIP MIB isn't specific about this.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 241987a816 ripd: remove dead code
None of these variables or functions were being used since the
initial revision ~16 years ago. It's safe to say we can remove
them now.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 3f21c8c4cb ripd: move "rip_offset_list_master" to the rip structure
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 29e897ad33 ripd: move "peer_list" to the rip structure
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 5a29c0d5c4 ripd: move "Vrip_passive_nondefault" to the rip structure
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 1205fdc482 ripd: move "rip_enable_network" to the rip structure
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal ca04690261 ripd: move "rip_enable_interface" to the rip structure
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal 2d2eaa1366 ripd: simplify cleaning up of routing instance
* Call rip_clean() only when RIP is configured, this way we can
  remove one indentation level from this function.
* rip_redistribute_clean() is only called on shutdown, so there's
  no need to call rip_redistribute_withdraw() there since the RIP
  table is already cleaned up elsewhere.
* There's no need to clean up the "rip->neighbor" nodes manually before
  calling route_table_finish().
* Deallocate the rip structure only at the end of the function. This
  prepares the ground for the next commits where all global variables
  will be moved to the rip structure.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Philippe Guibert 03a38493f8 lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-28 18:18:40 +01:00
Renato Westphal cf6ef36996 ripd, ripngd: fix memleaks when deleting routing instance
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-12-17 08:19:48 -02:00
Renato Westphal fe339c9560 ripd: implement two YANG notifications
Implement the 'authentication-failure' and 'authentication-type-failure'
notifications defined in the frr-ripd YANG module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 1137aef48f ripd: implement the 'clear-rip-route' YANG RPC
This command deletes all received routes from the RIP routing table.
It should be used with caution as it can create black holes in the
network until RIP reconverges. Very useful to make automated testing
(e.g. ANVL) more predictable, since the internal state of ripd can be
cleared after each test.

Implement the command using a YANG RPC so that it can be executed by
other northbound clients in addition to the CLI.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal bc1bdde2f6 ripd: fix SIGHUP handling
We can now leverage the new northbound API to perform a full configuration
reload in ripd without the need for external help (i.e. frr-reload.py).

When vty_read_config() is called with the 'config' parameter set to
NULL, it performs a new configuration transaction where the running
configuration is *replaced* by the provided configuration file. With that
said, we don't need to do anything other than calling this function in
the SIGHUP handler of all FRR daemons. If a daemon hasn't been converted
to the new northbound model, vty_read_config() will simply *merge*
the configuration file into the running configuration.

The calls to rip_clean() and rip_reset() in the SIGUP handler were
changing configuration variables directly, bypassing the northbound
layer. Configuration variables should be changed only by the northbound
callbacks, and failure to respect that inevitably leads to inconsistencies
and crashes. Fix this.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal c1b7e58eda ripd: no need to use qobj anymore to keep track of "router rip"
Now that "router rip" and all underlying commands were converted to the
new northbound model, there's no need to use the qobj infrastructure to
keep track of the 'rip' global variable anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 90eff9dafe ripd: retrofit the 'version' command to the new northbound model
Trivial conversion.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal b745780b5f ripd: retrofit the 'timer basic' command to the new northbound model
Trivial conversion. Use the northbound 'apply_finish()' callback so
we'll call rip_event() only once even if we change the three RIP timers
at the same time.

Convert the timers to uint32_t to match their representation in the
YANG model.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 4068787842 ripd: retrofit the 'route' command to the new northbound model
Trivial conversion. Remove the rip->route routing table and associated
code because this variable was used only to show the running
configuration.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 908f002092 ripd: retrofit the 'redistribute' commands to the new northbound model
Trivial conversion. As usual, combine multiple DEFUNs into a single
DEFPY for simplicity.

As a bonus of the northbound conversion, this commit fixes the
redistribution of certain protocols into ripd. The 'redist_type' array
used by the "redistribute" commands was terribly outdated, which was
preventing the CLI to parse correctly certain protocols like isis
and babel.

Remove the route_map hooks installed by rip_route_map_init() since they
were redundant (rip_init() already takes care of that).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 44f2f852a1 ripd: retrofit the 'passive-interface' command to the new northbound model
In ripd, the "passive-interface default" command has the following
behavior:
* All interfaces are converted to the passive mode;
* The "passive-interface IFNAME" command becomes a no-operation and
  "passive-interface IFNAME" statements are removed from the running
  configuration.
* The "no passive-interface IFNAME" can be used to remove interfaces
  from the passive mode.

This command was modeled using the following YANG data nodes in the
frr-ripd module:

  leaf passive-default {
    type boolean;
    default "false";
    description
      "Control whether interfaces are in the passive mode
       by default or not.";
  }
  leaf-list passive-interface {
    when "../passive-default = 'false'";
    type string {
      length "1..16";
    }
    description
      "A list of interfaces where the sending of RIP packets
       is disabled.";
  }
  leaf-list non-passive-interface {
    when "../passive-default = 'true'";
    type string {
      length "1..16";
    }
    description
      "A list of interfaces where the sending of RIP packets
       is enabled.";
  }

The 'when' statements guarantee that the list of passive interfaces
is cleared when the "passive-interface default" command is entered
(likewise, they guarantee that the list of non-passive interfaces is
cleared when the "passive-interface default" command is removed). This
matches exactly the behavior we want to model.

Finally, move the 'passive_default' global variable into the
'rip' structure where it belongs. This fixed the bug where the
"passive-interface default" command was being retained after a "no router
rip" + "router rip".

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 8c942f6506 ripd: retrofit the 'offset-list' command to the new northbound model
Remove the rip_offset_list_set() and rip_offset_list_unset() functions
since they set/unset multiple configuration options at the same time. The
northbound callbacks need to set/unset configuration options individually.

The frr-ripd YANG module models the "offset-list" command using a list
keyed by the 'interface' and 'direction' leafs. One important detail is
that the IFNAME parameter is optional, and when it's not present it means
we want to match all interfaces. This is modeled using an interface name
of '*' since key lists are mandatory by definition in YANG.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 3d7a1be850 ripd: retrofit the 'network' command to the new northbound model
The frr-ripd YANG module models the ripd "network" command using two
separate leaf-lists for simplicity: one leaf-list for interfaces and
another leaf-list for actual networks. In the 'cli_show' callbacks,
display the "network" command for entries of both leaf-lists.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 23b23d8c27 ripd: retrofit the 'distance source' commands to the new northbound model
The "distance (1-255) A.B.C.D/M [WORD]" command was modeled using a
YANG list, which makes it a little bit more complicated to convert to
the new northbound model.

The rip_distance_set() and rip_distance_unset() functions were removed
since they set/unset multiple configuration options at the same time. The
northbound callbacks need to set/unset configuration options individually.

When a distance list is created, use yang_dnode_set_entry() to store
a pointer in the configuration node, and retrieve this pointer in the
other callbacks using yang_dnode_get_entry().

The 'rip_distance' structure was moved to ripd.h so that it can be used
in the rip_northbound.c file.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 7f8a9cbab7 ripd: retrofit the 'distance' command to the new northbound model
Trivial conversion.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 282ae30c4a ripd: retrofit the 'default-metric' command to the new northbound model
Trivial conversion.

rip->default_metric was converted to an uint8_t to match the way it's
defined in the YANG module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 0b0609ba35 ripd: retrofit the 'default-information' command to the new northbound model
Trivial conversion.

'rip->default_information_route_map' was removed since it wasn't being
used anywhere.

'rip->default_information' was removed too because it was being used only
to display the running configuration and thus is not necessary anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal edbf59d209 ripd: retrofit the 'allow-ecmp' command to the new northbound model
Trivial conversion. The rip->ecmp variable was converted to a boolean to
match the way it's defined in the YANG module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
Renato Westphal 8c9226c216 ripd: retrofit the 'router rip' command to the new northbound model
* Implement the northbound callbacks associated to the
  '/frr-ripd:ripd/instance' YANG path (the code is mostly a copy and paste
  from the original "router rip" DEFUNs);
* Move rip_create_socket() out of rip_create() since creating a socket
  is an error-prone operation and thus needs to be performed separately
  during the NB_EV_PREPARE phase;
* On rip_create(), fetch the defaults from the frr-ripd YANG model;
* Convert the "[no] router rip" CLI commands to be dumb wrappers around
  the northbound callbacks;
* On config_write_rip(), write logic to call all 'cli_show' northbound
  callbacks defined under the '/frr-ripd:ripd/instance' YANG path.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
David Lamparter 0437e10517 *: spelchek
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-25 20:10:57 +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
Quentin Young 1c50c1c0d6 *: style for EC replacements
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:38:57 +00: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
Quentin Young 993c8024ff ripd: RIP_[ERR|WARN] -> EC_RIP
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:14:28 +00:00
F. Aragon dc7204b775
pimd ripd ripngd: variable shadowing fixes
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-12 12:55:31 +02:00
David Lamparter 633fc9b133 *: frr_elevate_privs whitespace fixes
(... and one superfluous variable removed)

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
David Lamparter 01b9e3fd0d *: use frr_elevate_privs() (1/2: coccinelle)
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
Quentin Young 09c866e34d *: rename ferr_zlog -> flog_err_sys
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp 518e377f39 ripd: Add RIP_ERR_XXX to move from zlog_err to zlog_ferr
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp 77cbe4a1b3 ripd: Convert zlog_err to zlog_ferr for LIB_ERR_XXX
For those errors that can be traced to LIB_ERR_XXX
convert to using those in ripd.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young aad95a7dc2 ripd: re-add check for rip_create fail
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
Donald Sharp 0ce1ca805d *: ALLOC calls cannot fail
There is no need to check for failure of a ALLOC call
as that any failure to do so will result in a assert
happening.  So we can safely remove all of this code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
lyq140 558c6842f7 ripd: fix packet sending in authenticate mode
fix a bug when sending packets.
in authenticate mode but without any string,
no packet should send.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
2018-08-06 14:14:00 +08:00
lyq140 ac000da998 ripd: fix packet sending
fix a bug when sending a rip packet.
in authenticate mode but without any string,
no packet should send.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
2018-08-06 10:46:58 +08:00
lyq140 c4efb22479 ripd: null check key
Fix ripd crash of null pointer.
when authenticate a rip packet,
the key pointer or the key string pointer may be null,
the code have to return then.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
2018-08-01 20:48:36 +08:00
lyq140 e65e227f28 ripd: null check the key string
This fix a crash of  null pointer.
when we don't add a key string or delete it,
the key is not null but key string is null,
so the code have to return.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
2018-08-01 12:03:24 +08:00
paco 0961ea934f
ripd: out-of-bounds read (Coverity 1399295)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-22 19:16:52 +02:00
Donald Sharp b260862317 ripd: Intentionally ignore return from rip_send_packet
Coverity SA has noticed that we are not ignoring the return
codes from rip_send_packet in one case.  Since we do not care
let the system know we don't.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 10:42:05 -04:00