summaryrefslogtreecommitdiffstats
path: root/ripd/ripd.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* ripd: split northbound callbacks into multiple filesRenato Westphal2019-10-301-8/+1
| | | | | | | | | | | | | | | | | | 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>
* ripd: use MTYPE_STATICDavid Lamparter2019-06-211-1/+3
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* ripd, ripngd: fix cleaning up of offset listsRenato Westphal2019-04-191-0/+1
| | | | | | | | | | | | | | | | | 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>
* Merge remote-tracking branch 'frr/master' into rip-vrfRenato Westphal2019-03-291-1/+4
|\ | | | | | | | | | | | | 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>
| * lib, rip, ripng, eigrp: rework if_rmap contextPhilippe Guibert2019-02-191-2/+4
| | | | | | | | | | | | | | | | | | | | 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>
* | ripd, ripngd: change how we keep track of redistribution configurationRenato Westphal2019-01-181-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | ripd: make YANG operational-data VRF aware tooRenato Westphal2019-01-181-0/+1
| | | | | | | | | | | | | | Move the "state" container into the "instance" list and adapt the code accordingly. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | ripd: add VRF supportRenato Westphal2019-01-181-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* | ripd: remove the rip global variableRenato Westphal2019-01-181-47/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | ripd: clear list of peers when RIP is deconfiguredRenato Westphal2019-01-181-0/+1
| | | | | | | | | | | | | | | | | | 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>
* | ripd: move "rip_distance_table" to the rip structureRenato Westphal2019-01-181-2/+0
| | | | | | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | ripd: move global counters to the rip structureRenato Westphal2019-01-181-4/+9
| | | | | | | | | | | | | | | | 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>
* | ripd: remove dead codeRenato Westphal2019-01-181-6/+0
| | | | | | | | | | | | | | | | 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>
* | ripd: move "rip_offset_list_master" to the rip structureRenato Westphal2019-01-181-2/+5
| | | | | | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | ripd: move "peer_list" to the rip structureRenato Westphal2019-01-181-3/+5
| | | | | | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | ripd: move "Vrip_passive_nondefault" to the rip structureRenato Westphal2019-01-181-1/+3
| | | | | | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | ripd: move "rip_enable_network" to the rip structureRenato Westphal2019-01-181-0/+3
| | | | | | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | ripd: move "rip_enable_interface" to the rip structureRenato Westphal2019-01-181-0/+3
|/ | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib, rip, ripng, babel, eigrp: add ctx pointer to distribute apiPhilippe Guibert2018-12-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | 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>
* ripd: remove leftovers from the old sighup handlerRenato Westphal2018-12-031-3/+0
| | | | | | | | Commit bc1bdde2f6 removed the rip_reset() function but didn't remove other functions that were only called by rip_reset(). Remove them now (dead code). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ripd: implement two YANG notificationsRenato Westphal2018-10-271-0/+4
| | | | | | | Implement the 'authentication-failure' and 'authentication-type-failure' notifications defined in the frr-ripd YANG module. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ripd: implement the 'clear-rip-route' YANG RPCRenato Westphal2018-10-271-0/+1
| | | | | | | | | | | | | 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>
* ripd: implement northbound callbacks to fetch neighbor informationRenato Westphal2018-10-271-0/+1
| | | | | | | | | Support for fetching operational data is experimental at this point. Locks must be introduced to ensure the peer_list global variable won't be modified while we're iterating asynchronously over it (or iterating from a separate pthread). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ripd: fix SIGHUP handlingRenato Westphal2018-10-271-1/+0
| | | | | | | | | | | | | | | | | | | | | 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>
* ripd: retrofit all RIP interface commands to the new northbound modelRenato Westphal2018-10-271-3/+2
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ripd: no need to use qobj anymore to keep track of "router rip"Renato Westphal2018-10-271-4/+0
| | | | | | | | 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>
* ripd: retrofit the 'timer basic' command to the new northbound modelRenato Westphal2018-10-271-8/+4
| | | | | | | | | | | 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>
* ripd: retrofit the 'route' command to the new northbound modelRenato Westphal2018-10-271-3/+0
| | | | | | | | 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>
* ripd: retrofit the 'redistribute' commands to the new northbound modelRenato Westphal2018-10-271-3/+5
| | | | | | | | | | | | | | | | 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>
* ripd: retrofit the 'passive-interface' command to the new northbound modelRenato Westphal2018-10-271-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* ripd: retrofit the 'offset-list' command to the new northbound modelRenato Westphal2018-10-271-8/+24
| | | | | | | | | | | | | | 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>
* ripd: retrofit the 'network' command to the new northbound modelRenato Westphal2018-10-271-0/+5
| | | | | | | | | 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>
* ripd: retrofit the 'neighbor' command to the new northbound modelRenato Westphal2018-10-271-0/+2
| | | | | | | | | | | | | | | | 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>
* ripd: retrofit the 'distance source' commands to the new northbound modelRenato Westphal2018-10-271-0/+12
| | | | | | | | | | | | | | | | | | | 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>
* ripd: retrofit the 'default-metric' command to the new northbound modelRenato Westphal2018-10-271-4/+1
| | | | | | | | | 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>
* ripd: retrofit the 'default-information' command to the new northbound modelRenato Westphal2018-10-271-4/+0
| | | | | | | | | | | | 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>
* ripd: retrofit the 'allow-ecmp' command to the new northbound modelRenato Westphal2018-10-271-1/+3
| | | | | | | 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>
* ripd: retrofit the 'router rip' command to the new northbound modelRenato Westphal2018-10-271-0/+3
| | | | | | | | | | | | | | | | * 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>
* yang, ripd: add 'frr-ripd.yang' and associated stub callbacksRenato Westphal2018-10-271-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | Introduce frr-ripd.yang, which defines a model for managing the FRR ripd daemon. Also add frr-route-types.yang which defines typedefs for FRR route types. Update the 'frr_yang_module_info' array of ripd with the new 'frr-ripd' module. Add two new files (rip_cli.[ch]) which should contain all ripd commands converted to the new northbound model. Centralizing all commands in a single place will facilitate the process of moving the CLI to a separate program in the future. Add automatically generated stub callbacks in rip_northbound.c. These callbacks will be implemented gradually in the following commits. Add example JSON/XML ripd configurations in yang/examples/. Add the confd.frr-ripd.yang YANG module with annotations specific to the ConfD daemon. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* *: use C99 standard fixed-width integer typesQuentin Young2018-03-271-32/+32
| | | | | | | | | | | | | | | | | | | | | | 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>
* *: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger2018-03-061-5/+3
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* ripd: Allow rip_redistribute_add to know the nexthop typeDonald Sharp2017-11-161-3/+5
| | | | | | | | | Allow rip_redistribute_add to receive and properly store the nexthop type passed up from zebra. Additionally display the different nexthop types appropriately. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* ripd: Convert to using 'struct nexthop' for nexthop informationDonald Sharp2017-11-161-4/+2
| | | | | | | | | | | RIP is not using the nexthop data structure and as such when it does not fully understand when it receives some of the more exotic nexthop types what to do with it. This is the start of a series of commits to allow RIP to start understanding and properly displaying information about different nexthop types. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* ripd: Make 'struct zebra_privs_t' availableDonald Sharp2017-10-241-0/+2
| | | | Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-245/+236
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* ripd: Fix zclient cleanup on shutdownDonald Sharp2017-06-301-0/+1
| | | | Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: make consistent & update GPLv2 file headersDavid Lamparter2017-05-151-4/+3
| | | | | | | | | | | 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>
* *: remove THREAD_ON macros, add nullity checkQuentin Young2017-05-091-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way thread.c is written, a caller who wishes to be able to cancel a thread or avoid scheduling it twice must keep a reference to the thread. Typically this is done with a long lived pointer whose value is checked for null in order to know if the thread is currently scheduled. The check-and-schedule idiom is so common that several wrapper macros in thread.h existed solely to provide it. This patch removes those macros and adds a new parameter to all thread_add_* functions which is a pointer to the struct thread * to store the result of a scheduling call. If the value passed is non-null, the thread will only be scheduled if the value is null. This helps with consistency. A Coccinelle spatch has been used to transform code of the form: if (t == NULL) t = thread_add_* (...) to the form thread_add_* (..., &t) The THREAD_ON macros have also been transformed to the underlying thread.c calls. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: snmp: convert into modulesDavid Lamparter2017-03-251-1/+0
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: use hooks for sending SNMP trapsDavid Lamparter2017-03-251-2/+5
| | | | | | | This means there are no ties into the SNMP code anymore other than the init call at startup. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>