summaryrefslogtreecommitdiff
path: root/ripd/rip_cli.c
AgeCommit message (Collapse)Author
2024-08-08ripd: fix show run output for distribute-listIgor Ryzhov
CLI show callbacks should be defined in frr_ripd_cli_info instead of frr_ripd_info, because only the former is loaded by mgmtd and only its callbacks are getting called for config output. Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2024-04-22ripd: convert RPC commands to mgmtdIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-03-09ripd: fix "clear ip rip" commandIgor Ryzhov
mgmtd doesn't support YANG RPCs yet, so this command must go directly to ripd. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-03-06ripd: fix missing "exit" for "router rip"Igor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-26ripd: ripd convert to mgmtdChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-24Merge pull request #15196 from idryzhov/nb-leaf-listDonald Sharp
lib: remove leaf-list xpath hack from northbound
2024-01-23lib: remove leaf-list xpath hack from northboundIgor Ryzhov
Currently, when editing a leaf-list, `nb_candidate_edit` expects to receive it's xpath without a predicate and the value in a separate argument, and then creates the full xpath. This hack is complicated, because it depends on the operation and on the caller being a backend or not. Instead, let's require to always include the predicate in a leaf-list xpath. Update all the usages in the code accordingly. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-22ripd: use correct autocompletion for distribute-list commandsIgor Ryzhov
Currently, we always use access-list autocompletion, even if configuring prefix-lists. We should differentiate. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-22ripd: use new distribute-list northbound code.Christian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-22lib: enable multiple instance support with distribute listsChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-29lib: all: remove './' from xpath 22% speedupChristian Hopps
fixes #8299 Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-23ripd: Use argv_find to avoid buffer overflow when parsing allow-ecmp argsDonatas Abraitis
==13211==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000af158 at pc 0x55d48c5f1e38 bp 0x7fffd8a713d0 sp 0x7fffd8a713c0 READ of size 8 at 0x6020000af158 thread T0 #0 0x55d48c5f1e37 in rip_allow_ecmp ripd/rip_cli.c:98 #1 0x7f2ec125aa0f in cmd_execute_command_real lib/command.c:990 #2 0x7f2ec125ae90 in cmd_execute_command lib/command.c:1049 #3 0x7f2ec125b406 in cmd_execute lib/command.c:1217 #4 0x7f2ec137ca36 in vty_command lib/vty.c:551 #5 0x7f2ec137ce52 in vty_execute lib/vty.c:1314 #6 0x7f2ec1384f9e in vtysh_read lib/vty.c:2223 #7 0x7f2ec137041b in event_call lib/event.c:1995 #8 0x7f2ec12b54bf in frr_run lib/libfrr.c:1204 #9 0x55d48c5f0f32 in main ripd/rip_main.c:171 #10 0x7f2ec0ad9c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) #11 0x55d48c5f1349 in _start (/usr/lib/frr/ripd+0x3b349) 0x6020000af158 is located 0 bytes to the right of 8-byte region [0x6020000af150,0x6020000af158) allocated by thread T0 here: #0 0x7f2ec18ccb40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) #1 0x7f2ec12d2e41 in qmalloc lib/memory.c:100 #2 0x7f2ec125a815 in cmd_execute_command_real lib/command.c:955 #3 0x7f2ec125ae90 in cmd_execute_command lib/command.c:1049 #4 0x7f2ec125b406 in cmd_execute lib/command.c:1217 #5 0x7f2ec137ca36 in vty_command lib/vty.c:551 #6 0x7f2ec137ce52 in vty_execute lib/vty.c:1314 #7 0x7f2ec1384f9e in vtysh_read lib/vty.c:2223 #8 0x7f2ec137041b in event_call lib/event.c:1995 #9 0x7f2ec12b54bf in frr_run lib/libfrr.c:1204 #10 0x55d48c5f0f32 in main ripd/rip_main.c:171 #11 0x7f2ec0ad9c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: heap-buffer-overflow ripd/rip_cli.c:98 in rip_allow_ecmp Shadow bytes around the buggy address: 0x0c048000ddd0: fa fa fd fa fa fa fd fa fa fa fd fd fa fa fd fa 0x0c048000dde0: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fd 0x0c048000ddf0: fa fa fd fa fa fa fd fd fa fa fd fd fa fa fd fd 0x0c048000de00: fa fa fd fa fa fa fd fd fa fa 00 03 fa fa fd fa 0x0c048000de10: fa fa fd fa fa fa 00 00 fa fa fd fa fa fa 00 03 =>0x0c048000de20: fa fa 00 03 fa fa fd fa fa fa 00[fa]fa fa fa fa 0x0c048000de30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c048000de40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c048000de50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c048000de60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c048000de70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==13211==ABORTING Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-04ripd: Implement `allow-ecmp X` commandDonatas Abraitis
Allow setting an arbitrary number of paths to be installed instead of ALL. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-04-19ripd: support BFD integrationRenato Westphal
Implement RIP peer monitoring with BFD. RFC 5882 Generic Application of Bidirectional Forwarding Detection (BFD), Section 10.3 Interactions with RIP. Co-authored-by: Renato Westphal <renato@opensourcerouting.org> Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26build, vtysh: extract vtysh commands from .xrefDavid Lamparter
Rather than running selected source files through the preprocessor and a bunch of perl regex'ing to get the list of all DEFUNs, use the data collected in frr.xref. This not only eliminates issues we've been having with preprocessor failures due to nonexistent header files, but is also much faster. Where extract.pl would take 5s, this now finishes in 0.2s. And since this is a non-parallelizable build step towards the end of the build (dependent on a lot of other things being done already), the speedup is actually noticeable. Also files containing CLI no longer need to be listed in `vtysh_scan` since the .xref data covers everything. `#ifndef VTYSH_EXTRACT_PL` checks are equally obsolete. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-06-13*: Use autocomplete for route-maps under commands that require itDonatas Abraitis
For example: ``` donatas-laptop# show bgp ipv4 unicast neighbors 127.0.0.2 advertised-routes route-map ? RMAP_NAME Name of the route map testas2 testas donatas-laptop(config)# router bgp donatas-laptop(config-router)# address-family ipv4 donatas-laptop(config-router-af)# redistribute connected route-map ? RMAP_NAME Pointer to route-map entries testas2 testas donatas-laptop(config-router-af)# network 192.168.0.0/23 route-map ? RMAP_NAME Name of the route map testas2 testas ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2021-10-31lib: Add autocomplete for access-listsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-13lib: northbound cli show/cmd functions must not modify data nodesIgor Ryzhov
To ensure this, add a const modifier to functions' arguments. Would be great do this initially and avoid this large code change, but better late than never. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-02northbound: KISS always batch yang config (file read), it's fasterChristian Hopps
The backoff code assumed that yang operations always completed quickly. It checked for > 100 YANG modeled commands happening in under 1 second to enable batching. If 100 yang modeled commands always take longer than 1 second batching is never enabled. This is the exact opposite of what we want to happen since batching speeds the operations up. Here are the results for libyang2 code without and with batching. | action | 1K rts | 2K rts | 1K rts | 2K rts | 20k rts | | | nobatch | nobatch | batch | batch | batch | | Add IPv4 | .881 | 1.28 | .703 | 1.04 | 8.16 | | Add Same IPv4 | 28.7 | 113 | .590 | .860 | 6.09 | | Rem 1/2 IPv4 | .376 | .442 | .379 | .435 | 1.44 | | Add Same IPv4 | 28.7 | 113 | .576 | .841 | 6.02 | | Rem All IPv4 | 17.4 | 71.8 | .559 | .813 | 5.57 | (IPv6 numbers are basically the same as iPv4, a couple percent slower) Clearly we need this. Please note the growth (1K to 2K) w/o batching is non-linear and 100 times slower than batched. Notes on code: The use of the new `nb_cli_apply_changes_clear_pending` is to commit any pending changes (including the current one). This is done when the code would not correctly handle a single diff that included the current changes with possible following changes. For example, a "no" command followed by a new value to replace it would be merged into a change, and the code would not deal well with that. A good example of this is BGP neighbor peer-group changing. The other use is after entering a router level (e.g., "router bgp") where the follow-on command handlers expect that router object to now exists. The code eventually needs to be cleaned up to not fail in these cases, but that is for future NB cleanup. Signed-off-by: Christian Hopps <chopps@labn.net>
2021-05-13lib: adapt to version 2 of libyangChristian Hopps
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-04lib, ripd, ripngd, vtysh: Move distribute list to `correct` spotDonald Sharp
Allow the `distribute-list...` command in ripd and ripngd to work correctly. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-05*: add errmsg to nb rpcChirag Shah
Display human readable error message in northbound rpc transaction failure. In case of vtysh nb client, the error message will be displayed to user. Testing: bharat# clear evpn dup-addr vni 1002 ip 11.11.11.11 Error type: generic error Error description: Requested IP's associated MAC aa:aa:aa:aa:aa:aa is still in duplicate state Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-08-03*: introduce DEFPY_YANG & friendsRenato Westphal
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>
2019-12-12ripd, ripngd: Free up list after call into nb_cli_rpcDonald Sharp
We have a clear memory leak after running `clear ip rip` Fix this. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-29ripd: split northbound callbacks into multiple filesRenato Westphal
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-07-01ripd: fix problems with the "ip rip authentication" commandRenato Westphal
libyang-0.16-r3 doesn't allow the creation of data nodes if their corresponding "when" statement (if any) resolves to false. This change broke the "ip rip authentication" command. This commit adapts this command so that it's not affected by the new libyang stricter validation checks. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-04Merge pull request #3548 from opensourcerouting/rip-vrfDonald Sharp
rip(ng)d: add VRF support
2019-03-29Merge remote-tracking branch 'frr/master' into rip-vrfRenato Westphal
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-02ripd: fix removal of configured passive interfacesRenato Westphal
libyang-0.16-rc3 fixed a bug [1] in which data would be auto-deleted when it shouldn't. The problem is that the "no passive-interface" command was relying on that wrong behavior, so the command was affected when the libyang bug was fixed. Adapt the command to do the right thing in order to get rid of the problem (regardless of the libyang version being used). "passive-interface default" still has problems though, but that will be addressed separetely in the future. Fixes #3870. [1] https://github.com/CESNET/libyang/commit/8af82206908 Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-11libs, rip, isis: change northbound operation enum to DESTROYMark Stapp
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-01-18ripd: fix unsetting of authentication passwordRenato Westphal
Regression introduced by commit a6233bfc. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18ripd: add vrf input parameter to the "clear-rip-route" RPCRenato Westphal
Description of the new parameter (adapted from the ietf-rip module): "VRF name identifying a specific RIP instance. This leaf is optional for the rpc. If it is specified, the rpc will clear all routes in the specified RIP instance; if it is not specified, the rpc will clear all routes in all RIP instances."; Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18ripd: add VRF supportRenato Westphal
* 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>
2018-12-03ripd: fix minor issues from the northbound conversionRenato Westphal
* Always apply the mask of IPv4 prefixes (user data) in the northbound callbacks, we shouldn't assume the northbound plugins will do that for us. * Fix a bug in the "distance" command introduced by commit a6233bfcb3b. * Remove unnecessary check in the ripd_instance_redistribute_route_map_delete() function and reset the route-map's map pointer for safety as well. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26lib, ripd: rework API for converted CLI commandsRenato Westphal
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-26ripd: fix display of the "distance" commandRenato Westphal
When displaying a configuration using the "with-defaults" option, do not display "distance 0" when the "distance" command is not configured. The range of accepted values is (1-255), so "distance 0" isn't a valid command. In this case, display "no distance". Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27ripd: implement the 'clear-rip-route' YANG RPCRenato Westphal
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-27ripd: retrofit all RIP interface commands to the new northbound modelRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27ripd: retrofit the 'version' command to the new northbound modelRenato Westphal
Trivial conversion. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27ripd: retrofit the 'timer basic' command to the new northbound modelRenato Westphal
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-27ripd: retrofit the 'route' command to the new northbound modelRenato Westphal
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-27ripd: retrofit the 'redistribute' commands to the new northbound modelRenato Westphal
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-27ripd: retrofit the 'passive-interface' command to the new northbound modelRenato Westphal
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-27ripd: retrofit the 'offset-list' command to the new northbound modelRenato Westphal
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-27ripd: retrofit the 'network' command to the new northbound modelRenato Westphal
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-27ripd: retrofit the 'neighbor' command to the new northbound modelRenato Westphal
Make rip_neighbor_add() and rip_neighbor_delete() return northbound error codes since their return values are used as the return value of some northbound callbacks. These functions shouldn't fail in normal conditions because the northbound layer guarantees it will never call the 'create' or 'delete' callback more than once for the same object. Hence any failure in those functions would indicate an internal inconsistency that needs to be investigated (by returning NB_ERR the northbound will log a detailed error message indicating the xpath of the object, the event and the callback where the error happened). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27ripd: retrofit the 'distance source' commands to the new northbound modelRenato Westphal
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-27ripd: retrofit the 'distance' command to the new northbound modelRenato Westphal
Trivial conversion. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27ripd: retrofit the 'default-metric' command to the new northbound modelRenato Westphal
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>