Commit graph

92 commits

Author SHA1 Message Date
Mark Stapp a2acd59afd ripng: clean up -Wshadow compiler warnings
Clean up -Wshadow compiler warnings.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
anlan_cs b580c52698 *: remove ZEBRA_INTERFACE_VRF_UPDATE
Currently when one interface changes its VRF, zebra will send these messages to
all daemons in *order*:
    1) `ZEBRA_INTERFACE_DELETE` ( notify them delete from old VRF )
    2) `ZEBRA_INTERFACE_VRF_UPDATE` ( notify them move from old to new VRF )
    3) `ZEBRA_INTERFACE_ADD` ( notify them added into new VRF )

When daemons deal with `VRF_UPDATE`, they use
`zebra_interface_vrf_update_read()->if_lookup_by_name()`
to check the interface exist or not in old VRF. This check will always return
*NULL* because `DELETE` ( deleted from old VRF ) is already done, so can't
find this interface in old VRF.

Send `VRF_UPDATE` is redundant and unuseful. `DELETE` and `ADD` are enough,
they will deal with RB tree, so don't send this `VRF_UPDATE` message when
vrf changes.

Since all daemons have good mechanism to deal with changing vrf, and don't
use this `VRF_UPDATE` mechanism.  So, it is safe to completely remove
all the code with `VRF_UPDATE`.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2023-10-07 10:06:39 +08:00
Donatas Abraitis 6c5ffa8896 ripngd: Make sure we do not overuse higher values for ECMP count
Use a minimum value of a CLI version and a value of Zebra capabilities.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-23 09:29:02 +03:00
Donatas Abraitis 57aedde6ef ripng: Implement allow-ecmp X command
A port of ripd implementation for ripngd implemented by 75fce4645a.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-23 09:29:01 +03:00
Donald Sharp cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
David Lamparter a243d1db93 *: convert zclient callbacks to table
This removes a giant `switch { }` block from lib/zclient.c and
harmonizes all zclient callback function types to be the same (some had
a subset of the args, some had a void return, now they all have
ZAPI_CALLBACK_ARGS and int return.)

Apart from getting rid of the giant switch, this is a minor security
benefit since the function pointers are now in a `const` array, so they
can't be overwritten by e.g. heap overflows for code execution anymore.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-20 13:28:46 +02:00
Donald Sharp 26a3ffd60e bgpd, lib, ripngd: Add agg_node_get_prefix
Modify code to use lookup function agg_node_get_prefix()
as the abstraction layer.  When we rework bgp_node to
bgp_dest this will allow us to greatly limit the amount
of work needed to do that.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-24 07:51:41 -04:00
Donald Sharp 2afebed21f ripngd: Fix redistribute/no redistribute rinse repeat commands
ripngd was using zclient_redistribute for installation but not
for removal.  As such the lib/zclient.c was not properly tracking
add/removal.  I think it would be best to just let ripng to track
this instead of zclient.

Fixes: #5599
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-31 18:48:54 -05: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
Quentin Young 121f9dee7c *: use ZAPI_CALLBACK_ARGS macro for zapi handlers
This macro:
- Marks ZAPI callbacks for readability
- Standardizes argument names
- Makes it simple to add ZAPI arguments in the future
- Ensures proper types
- Looks better
- Shortens function declarations

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-03 20:57:35 +00: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
Donald Sharp 9fb2b87997 isisd, ospf6d, ripngd: Do not allow v6 LL's to be redist connected in
The rib process of handling routes has been unified a bit more
and as a result v6 LL routes are now showing up as a result
of a `redistribute connected`.  Doing anything with these
routes is a policy decision that should be enforced by the
individual routing daemons not by zebra.  As such add a bit
of code to isisd, ripngd and opsf6d to handle them.  The bgp daemon
already handles this situation.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:22:22 -04:00
Ruben Kerkhof 4d762f2607 Treewide: use ANSI function definitions
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2019-01-24 11:21:59 +01: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 dde7b15b83 ripngd: 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.

* RIPng VRF instances can be configured even when the corresponding
  VRF doesn't exist. And a RIPng VRF instance isn't deleted when
  the corresponding VRF is deleted. For this to work, implement the
  ripng_instance_enable() and ripng_instance_disable() functions
  that are called to enable/disable RIPng routing instances when
  necessary. A RIPng 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 ripng_instances rb-tree (global variable).

* Add a vrf pointer to the ripng 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
  ripng->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 5c84b9a581 ripngd: remove the ripng global variable
This is the last step to make ripngd ready for multi-instance
support.

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

In preparation for the next commits (VRF support), add a "vrd_id"
member to the ripng structure, and use ripng->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 a9caf6e939 ripngd: simplify cleaning up of routing instance
* Call ripng_clean() only when RIPng is configured, this way we can
  remove one indentation level from this function.
* ripng_redistribute_clean() is only called on shutdown, so there's
  no need to call ripng_redistribute_withdraw() there since the RIPng
  table is already cleaned up elsewhere.
* Deallocate the ripng 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 ripng structure.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:15:41 -02:00
Renato Westphal b874133870 ripngd: fix SIGHUP handling
Now that all ripngd commands were converted to the new northbound
model, the ripngd SIGHUP handler is capable of doing a full
configuration reload just by calling the vty_read_config()
function. Nothing else should be done in the SIGHUP handler.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-12-03 13:47:58 -02:00
Renato Westphal db2038c782 ripngd: 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 ripngd. 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.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-12-03 13:47:58 -02:00
Donald Sharp 26f63a1ec6 *: Replace zclient_new with zclient_new_notify
It's been a year since we added the new optional parameters
to instantiation.  Let's switch over to the new name.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-12 09:16:23 -05:00
Donald Sharp fe08ba7e11 bgpd, ripngd: Convert to using new agg_table/route
Switch bgp and ripngd to use the new aggregate table and
route data structures.  This was mainly a search and replace
operation.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-30 17:47:59 -04:00
Quentin Young d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Donald Sharp 4a7371e9e2 *: Track vrfs per nexthop not per route entry
Track the vfrs on a per nexthop basis instead
of on a per route entry basis.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 19:35:53 -05:00
Donald Sharp d5b2119cb4 *: Send/receive the nexthop vrf_id
Modify the code to send and receive to/from zebra
the nexthops vrf_id.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:22:07 -05:00
Donald Sharp e1a1880de3 *: Make zapi route install Notifications optional
Allow the higher level protocol to specify if it would
like to receive notifications about it's routes that
it has installed.

I've purposely made it part of zclient_new_notify because
we need to track the routes on a per daemon basis only.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:09:35 -05:00
Donald Sharp 342213eac0 *: Modify zclient_init to require privs data
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-23 18:12:29 -04:00
Renato Westphal a74e593b35 *: fix segfault when sending more than MULTIPATH_NUM nexthops
This is a fallout from PR #1022 (zapi consolidation). In the early days,
the client daemons would allocate enough memory to send all nexthops
to zebra.  Then zebra would add all nexthops to the RIB and respect
MULTIPATH_NUM only when installing the routes in the kernel. Now things
are different and the client daemons can send at most MULTIPATH_NUM
nexthops to zebra, and failure to respect that will result in a buffer
overflow. The MULTIPATH_NUM limit in the new zebra API is a small price
we pay to avoid allocating memory for each route sent to zebra.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 11:21:09 -03:00
Renato Westphal 744899219f *: use zapi_route to send/receive redistributed routes as well
Some differences compared to the old API:
* Now the redistributed routes are sent using address-family
  independent messages (ZEBRA_REDISTRIBUTE_ROUTE_ADD and
  ZEBRA_REDISTRIBUTE_ROUTE_DEL). This allows us to unify the ipv4/ipv6
  zclient callbacks in the client daemons and thus remove a lot of
  duplicate code;

* Now zebra sends all nexthops of the redistributed routes to the client
  daemons, not only the first one. This shouldn't have any noticeable
  performance implications and will allow us to remove an ugly exception
  we had for ldpd (which needs to know all nexthops of the redistributed
  routes). The other client daemons can simply ignore the nexthops if
  they want or consult just the first one (e.g. ospfd/ospf6d/ripd/ripngd).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 20:25:45 -03:00
Renato Westphal c9fb3e233e ripd/ripngd: use the new API to send routes to zebra
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 18:58:35 -03:00
Renato Westphal 34b054ba6d *: remove leftovers from "router zebra"
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 17:45:17 -03:00
Renato Westphal d00061ea32 *: reduce excessive indentation in a few places
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 17:45:17 -03:00
David Lamparter 9d303b37d7 Revert "*: reindent pt. 2"
This reverts commit c14777c6bf.

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

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

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

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

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 13:07:30 +02:00
Daniel Walton f1a05de982 vtysh: return non-zero for configuration failures
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

This allows frr-reload.py (or anything else that scripts via vtysh)
to know if the vtysh command worked or hit an error.
2017-07-13 19:56:08 +00:00
David Lamparter 5c7571d43f *: ditch vty_outln(), part 1 of 2
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13 20:29:22 +02:00
Donald Sharp 7feb9237dc ripngd: Fix zclient cleanup on shutdown
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-30 10:32:01 -04:00
Quentin Young 96ade3ed77 *: use vty_outln
Saves 400 lines

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:31:28 +00:00
David Lamparter 896014f4bc *: make consistent & update GPLv2 file headers
The FSF's address changed, and we had a mixture of comment styles for
the GPL file header.  (The style with * at the beginning won out with
580 to 141 in existing files.)

Note: I've intentionally left intact other "variations" of the copyright
header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 16:37:41 +02:00
Christian Franke 81a164e2d9 *: read and ignore srcdest routes on ZAPI
Since zebra might be sending srcdest routes down to the various daemons,
they need to understand the presence of the field at the very least.
Sadly, that's also the best we can do at this point since none of the
protocols has support for handling srcdest routes.  The only consistent
thing to do is to ignore them throughout.

If an administrator wants to have the srcdest route as non-srcdest in a
protocol, setting a non-srcdest static route (possibly blackhole) is
probably the best way to go.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-30 13:47:04 +01:00
David Lamparter d75f3b00e7 lib: send ZAPI IPv6 source prefix
This introduces ZAPI_MESSAGE_SRCPFX, and if set adds a source prefix
field to ZAPI IPv6 route messages sent from daemons to zebra.  The
function calls all have a new prefix_ipv6 * argument specifying the
source, or NULL.  All daemons currently supply NULL.

Zebra support for processing the field was added in the previous patch,
however, zebra does not do anything useful with the value yet.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-30 13:47:04 +01:00
Donald Sharp 40d1cbfbb3 *: Fix redistribute issue
Somewhere in the past we switched from
using the auto-generated redistribute statements
to a non-generated version.  This caused us to
loose new protocols to redistribute as they are
added.  Put it back.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-27 15:52:12 -05:00
Quentin Young b84aadae44 Merge branch 'master' into fix-proto_redistnum 2017-01-06 19:44:46 -05:00
Donald Sharp 3b14d86eed Merge remote-tracking branch 'origin/stable/2.0' 2017-01-06 09:58:21 -05:00