summaryrefslogtreecommitdiffstats
path: root/staticd (follow)
Commit message (Collapse)AuthorAgeFilesLines
* staticd: redo VRF_DEFAULT NHT registers on connectDavid Lamparter2022-04-241-0/+3
| | | | | | | | | | | Other VRFs get VRF_ADD notifications from zebra which triggers static_fixup_vrf_ids, but since the default VRF is implicit we need to make that same call on connect. This should fix problems with staticd being started before (or concurrent with and thus racing) zebra. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* staticd: merge NHT register & update, reorganizeDavid Lamparter2022-04-243-56/+39
| | | | | | | | | nh_update is only called in two places and both precede a matching follow-up nht_register call. Fold the update into register, and make register do the right thing™ for all cases (i.e. update refcounts as needed, and retry zebra NHT registration if it failed before). Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* staticd: use double pointer for NHT decrefDavid Lamparter2022-04-241-18/+26
| | | | | | | Since this is a free()-type function, clear the caller's pointer to NULL to aid static analysis and prevent UAF bugs. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* staticd: minor refactor NHT register codeDavid Lamparter2022-04-241-51/+39
| | | | | | | | | Put static_nexthop -> prefix code into a small helper, remove extra prefix variable, and grab AFI from prefix. This commit should not result in any functional change. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: Fix spelling of IntefaceDonald Sharp2022-04-021-1/+1
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* staticd: track nexthops per-SAFIDavid Lamparter2022-03-273-34/+40
| | | | | | | This stops intermixing SAFI_UNICAST NHT into SAFI_MULTICAST static routes. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* staticd: use inline prefix in NHT dataDavid Lamparter2022-03-271-14/+10
| | | | | | No need to waste malloc overhead on this. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* staticd: use typesafe static_nht_hashDavid Lamparter2022-03-271-55/+76
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: add SAFI argument to zclient_send_rnhDavid Lamparter2022-03-271-2/+2
| | | | | | Just pushing that SAFI_UNICAST up 1 level to the caller. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: When matching against a nexthop send and process what it matched againstDonald Sharp2022-03-121-7/+8
| | | | | | | | | | | | | | | | | | Currently the nexthop tracking code is only sending to the requestor what it was requested to match against. When the nexthop tracking code was simplified to not need an import check and a nexthop check in b8210849b8ac1abe2d5d9a5ab2459abfde65efa5 for bgpd. It was not noticed that a longer prefix could match but it would be seen as a match because FRR was not sending up both the resolved route prefix and the route FRR was asked to match against. This code change causes the nexthop tracking code to pass back up the matched requested route (so that the calling protocol can figure out which one it is being told about ) as well as the actual prefix that was matched to. Fixes: #10766 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* Merge pull request #10678 from donaldsharp/staticd_make_check_fixJafar Al-Gharaibeh2022-02-282-1/+1
|\ | | | | staticd: Fix `make check` failures
| * staticd: Fix `make check` failuresDonald Sharp2022-02-282-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent commit: abc246e19345cbd2bc74c7dc50dac0b9cf2addf8 Has broken `make check` with recently new compilers: /usr/bin/ld: staticd/libstatic.a(static_nb_config.o): warning: relocation against `zebra_ecmp_count' in read-only section `.text' CCLD tests/bgpd/test_peer_attr CCLD tests/bgpd/test_packet /usr/bin/ld: staticd/libstatic.a(static_zebra.o): in function `static_zebra_capabilities': /home/sharpd/frr5/staticd/static_zebra.c:208: undefined reference to `zebra_ecmp_count' /usr/bin/ld: staticd/libstatic.a(static_zebra.o): in function `static_zebra_route_add': /home/sharpd/frr5/staticd/static_zebra.c:418: undefined reference to `zebra_ecmp_count' /usr/bin/ld: staticd/libstatic.a(static_nb_config.o): in function `static_nexthop_create': /home/sharpd/frr5/staticd/static_nb_config.c:174: undefined reference to `zebra_ecmp_count' /usr/bin/ld: /home/sharpd/frr5/staticd/static_nb_config.c:175: undefined reference to `zebra_ecmp_count' /usr/bin/ld: warning: creating DT_TEXTREL in a PIE collect2: error: ld returned 1 exit status make: *** [Makefile:8679: tests/lib/test_grpc] Error 1 make: *** Waiting for unfinished jobs.... Essentially the newly introduced variable zebra_ecmp_count is not available in the libstatic.a compiled and make check has code that compiles against it. The fix is to just move the variable to the library. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | staticd: Don't register existing nexthop to zebraXiao Liang2022-02-281-6/+11
|/ | | | | | | | Zebra sends a nexthop-update message on registeration, which will cause existing routes to be reconfigured even no changes actually happened. Don't register the nexthop again if it's already done. Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
* staticd: reject route config with too many nexthopsMark Stapp2022-02-172-1/+10
| | | | | | | | Restrict the number of nexthops for a route to the compiled-in limit. Be careful with the zapi route struct's array of nexthops too. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
* staticd: capture zebra's advertised ECMP limitMark Stapp2022-02-173-1/+3
| | | | | | Capture the ECMP limit advertised by zebra (via zapi). Signed-off-by: Mark Stapp <mstapp@nvidia.com>
* staticd: fix spelling in an error messageMark Stapp2022-02-171-1/+1
| | | | | | whitespace change to fix a typo. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
* staticd: small cleanupanlan_cs2022-01-312-12/+1
| | | | | | Two small cleanups, just remove duplication. Signed-off-by: anlan_cs <vic.lan@pica8.com>
* *: rework renaming the default VRFIgor Ryzhov2021-12-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, it is possible to rename the default VRF either by passing `-o` option to zebra or by creating a file in `/var/run/netns` and binding it to `/proc/self/ns/net`. In both cases, only zebra knows about the rename and other daemons learn about it only after they connect to zebra. This is a problem, because daemons may read their config before they connect to zebra. To handle this rename after the config is read, we have some special code in every single daemon, which is not very bad but not desirable in my opinion. But things are getting worse when we need to handle this in northbound layer as we have to manually rewrite the config nodes. This approach is already hacky, but still works as every daemon handles its own NB structures. But it is completely incompatible with the central management daemon architecture we are aiming for, as mgmtd doesn't even have a connection with zebra to learn from it. And it shouldn't have it, because operational state changes should never affect configuration. To solve the problem and simplify the code, I propose to expand the `-o` option to all daemons. By using the startup option, we let daemons know about the rename before they read their configs so we don't need any special code to deal with it. There's an easy way to pass the option to all daemons by using `frr_global_options` variable. Unfortunately, the second way of renaming by creating a file in `/var/run/netns` is incompatible with the new mgmtd architecture. Theoretically, we could force daemons to read their configs only after they connect to zebra, but it means adding even more code to handle a very specific use-case. And anyway this won't work for mgmtd as it doesn't have a connection with zebra. So I had to remove this option. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* staticd: remove unnecessary function callIgor Ryzhov2021-11-231-7/+0
| | | | | | | When the VRF interface is coming up, we don't need to fixup VRF ids - it was already done in static_vrf_enable when the interface was created. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* *: cleanup ifp->vrf_idIgor Ryzhov2021-11-224-18/+7
| | | | | | | Since f60a1188 we store a pointer to the VRF in the interface structure. There's no need anymore to store a separate vrf_id field. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* *: clean up ifp-by-local-address function(s)David Lamparter2021-11-172-10/+6
| | | | | | | | | | | | | Most users of if_lookup_address_exact only cared about whether the address is any local address. Split that off into a separate function. For the users that actually need the ifp - which I'm about to add a few of - change it to prefer returning interfaces that are UP. (Function name changed due to slight change in behavior re. UP state, to avoid possible bugs from this change.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: Convert quagga_signal_X to frr_signal_XDonald Sharp2021-11-111-1/+1
| | | | | | | Naming functions/data structures more appropriately for the project we are actually in. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* Merge pull request #9854 from opensourcerouting/zapi-call-tableRuss White2021-10-261-5/+9
|\ | | | | *: convert zclient callbacks to table
| * *: convert zclient callbacks to tableDavid Lamparter2021-10-201-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge pull request #9824 from idryzhov/nb-cli-const-lyd-nodeDonald Sharp2021-10-252-16/+24
|\ \ | |/ |/| lib: northbound cli show/cmd functions must not modify data nodes
| * lib: northbound cli show/cmd functions must not modify data nodesIgor Ryzhov2021-10-132-16/+24
| | | | | | | | | | | | | | | | 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>
* | *: Add resolve via default flagDonald Sharp2021-09-271-1/+1
|/
* staticd: output config using NB callbacks instead of operational dataIgor Ryzhov2021-08-314-142/+307
| | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* staticd: convert typedef to enumIgor Ryzhov2021-08-314-14/+16
| | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* Merge pull request #9496 from idryzhov/vrf-cmd-init-unused-argDavid Lamparter2021-08-271-1/+1
|\ | | | | lib: remove unused argument from vrf_cmd_init
| * lib: remove unused argument from vrf_cmd_initIgor Ryzhov2021-08-261-1/+1
| | | | | | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* | Merge pull request #9331 from idryzhov/explicit-exitChristian Hopps2021-08-261-1/+1
|\ \ | |/ |/| *: explicitly print "exit" at the end of every node config
| * *: explicitly print "exit" at the end of every node configIgor Ryzhov2021-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a possibility that the same line can be matched as a command in some node and its parent node. In this case, when reading the config, this line is always executed as a command of the child node. For example, with the following config: ``` router ospf network 193.168.0.0/16 area 0 ! mpls ldp discovery hello interval 111 ! ``` Line `mpls ldp` is processed as command `mpls ldp-sync` inside the `router ospf` node. This leads to a complete loss of `mpls ldp` node configuration. To eliminate this issue and all possible similar issues, let's print an explicit "exit" at the end of every node config. This commit also changes indentation for a couple of existing exit commands so that all existing commands are on the same level as their corresponding node-entering commands. Fixes #9206. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* | *: Drop `break` after using frr_help_exit() in switch/caseDonatas Abraitis2021-08-251-1/+0
|/ | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* staticd: warn on attempted delete of non-existent routeWesley Coakley2021-08-191-1/+2
| | | | Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
* staticd: replace NB checks with assertIgor Ryzhov2021-08-092-16/+1
| | | | | | | | If there's no route table in a VRF, it's a hard bug - staticd will crash on any subsequent action with this route anyway. So let's assert the existence of a route table instead of returning an unrecoverable error. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* Merge pull request #9023 from idryzhov/static-nbDonald Sharp2021-08-056-372/+134
|\ | | | | staticd: simplify the northbound code
| * staticd: simplify the northbound codeIgor Ryzhov2021-07-096-372/+134
| | | | | | | | | | | | | | Add a couple of back pointers to static route/path/nexthop structures to simplify the NB code and save ~200 lines. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* | staticd: fix late initialization of blackhole typeanlan_cs2021-07-101-3/+4
|/ | | | | | | | If a static route is added to a not-yet-existing VRF, the blackhole type is not initialized. Initialization must be done before the VRF existence check. Signed-off-by: anlan_cs <anlan_cs@tom.com>
* *: Replace 4/16 integers to IPV4_MAX_BYTELEN/IPV6_MAX_BYTELENDonatas Abraitis2021-07-011-1/+2
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* tests: add grpc unit testChristian Hopps2021-06-068-1/+70
| | | | | | | | Test uses staticd which required some C++ header protections. Additionally, the test also runs in the ubuntu20 docker container as grpc is supported there by the packaging system. Signed-off-by: Christian Hopps <chopps@labn.net>
* Merge pull request #8740 from mjstapp/fix_static_retIgor Ryzhov2021-05-281-3/+2
|\ | | | | staticd: return meaningful status in cli error path
| * staticd: return SUCCESS when deleting non-existent routeMark Stapp2021-05-271-3/+2
| | | | | | | | | | | | | | | | Return SUCCESS if trying to delete route that doesn't exist. This was always staticd's behavior before the northbound conversion. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* | staticd: fix distance processingIgor Ryzhov2021-05-252-6/+59
|/ | | | | | | | | | | | When the user adds the route + nexthop pair that already exists with a different distance, we should replace it instead of adding a new one. Likewise, when the user wants to delete the route + nexthop pair without explicitly entering the distance, we should delete the route. Fixes #8695. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* lib: adapt to version 2 of libyangChristian Hopps2021-05-133-41/+2
| | | | | | | | | 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>
* *: make sure `config.h` or `zebra.h` is firstDavid Lamparter2021-04-232-0/+4
| | | | | | | | | | | | `config.h` has all the defines from autoconf, which may include things that switch behavior of other included headers (e.g. _GNU_SOURCE enabling prototypes for additional functions.) So, the first include in any `.c` file must be either `config.h` (with the appropriate guard) or `zebra.h` (which includes `config.h` first thing.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: remove *.conf.sample filesQuentin Young2021-04-092-6/+0
| | | | | | | | | | Most of these are many, many years out of date. All of them vary randomly in quality. They show up by default in packages where they aren't really useful now that we use integrated config. Remove them. The useful ones have been moved to the docs. Signed-off-by: Quentin Young <qlyoung@nvidia.com>
* *: modify VRF_CONFIGURED flag only in VRF NB layerIgor Ryzhov2021-03-283-32/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to fix the crash reproduced by the following steps: * ip link add red type vrf table 1 Creates VRF. * vtysh -c "conf" -c "vrf red" Creates VRF NB node and marks VRF as configured. * ip route 1.1.1.0/24 2.2.2.2 vrf red * no ip route 1.1.1.0/24 2.2.2.2 vrf red (or similar l3vni set/unset in zebra) Marks VRF as NOT configured. * ip link del red VRF is deleted, because it is marked as not configured, but NB node stays. Subsequent attempt to configure something in the VRF leads to a crash because of the stale pointer in NB layer. Fixes #8357. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* staticd: kill static_memory.h, use MTYPE_STATICDavid Lamparter2021-03-227-122/+68
| | | | | | | This one needed a move of zebra_stable_node_cleanup() from static_vrf.c to static_routes.c. But it seems to actually make sense there. Signed-off-by: David Lamparter <equinox@diac24.net>
* *: require semicolon after FRR_DAEMON_INFO & co.David Lamparter2021-03-171-1/+1
| | | | | | ... again ... Signed-off-by: David Lamparter <equinox@diac24.net>