summaryrefslogtreecommitdiff
path: root/staticd/static_nb_config.c
AgeCommit message (Collapse)Author
2025-03-27Revert "staticd: Fix crash that occurs when modifying an SRv6 SID"Donatas Abraitis
This reverts commit c80c2b2a4226640464a38f8ee9f8b2b4be8bd094.
2025-03-24staticd: Fix crash that occurs when modifying an SRv6 SIDCarmine Scarpitta
When the user modifies an SRv6 SID and then removes all SIDs, staticd crashes: ``` 2025/03/23 08:37:22.691860 STATIC: lib/memory.c:74: mt_count_free(): assertion (mt->n_alloc) failed STATIC: Received signal 6 at 1742715442 (si_addr 0x8200007cf0); aborting... STATIC: zlog_signal+0x390 fcc704a844b8 ffffd7450390 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: core_handler+0x1f8 fcc704b79990 ffffd7450590 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: ---- signal ---- STATIC: ? fcc705c008f8 ffffd74507a0 linux-vdso.so.1 (mapped at 0xfcc705c00000) STATIC: pthread_key_delete+0x1a0 fcc70458f1f0 ffffd7451a00 /lib/aarch64-linux-gnu/libc.so.6 (mapped at 0xfcc704510000) STATIC: raise+0x1c fcc70454a67c ffffd7451ad0 /lib/aarch64-linux-gnu/libc.so.6 (mapped at 0xfcc704510000) STATIC: abort+0xe4 fcc704537130 ffffd7451af0 /lib/aarch64-linux-gnu/libc.so.6 (mapped at 0xfcc704510000) STATIC: _zlog_assert_failed+0x3c4 fcc704c407c8 ffffd7451c40 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: mt_count_free+0x12c fcc704a93c74 ffffd7451dc0 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: qfree+0x28 fcc704a93fa0 ffffd7451e70 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: static_srv6_sid_free+0x1c adc1df8fa544 ffffd7451e90 /usr/lib/frr/staticd (mapped at 0xadc1df8a0000) STATIC: delete_static_srv6_sid+0x14 adc1df8faafc ffffd7451eb0 /usr/lib/frr/staticd (mapped at 0xadc1df8a0000) STATIC: list_delete_all_node+0x104 fcc704a60eec ffffd7451ed0 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: list_delete+0x8c fcc704a61054 ffffd7451f00 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: static_srv6_cleanup+0x20 adc1df8fabdc ffffd7451f20 /usr/lib/frr/staticd (mapped at 0xadc1df8a0000) STATIC: sigint+0x40 adc1df8be544 ffffd7451f30 /usr/lib/frr/staticd (mapped at 0xadc1df8a0000) STATIC: frr_sigevent_process+0x148 fcc704b79460 ffffd7451f40 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: event_fetch+0x1c4 fcc704bc0834 ffffd7451f60 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: frr_run+0x650 fcc704a5d230 ffffd7452080 /usr/lib/frr/libfrr.so.0 (mapped at 0xfcc704800000) STATIC: main+0x1d0 adc1df8be75c ffffd7452270 /usr/lib/frr/staticd (mapped at 0xadc1df8a0000) STATIC: __libc_init_first+0x7c fcc7045373fc ffffd74522b0 /lib/aarch64-linux-gnu/libc.so.6 (mapped at 0xfcc704510000) STATIC: __libc_start_main+0x98 fcc7045374cc ffffd74523c0 /lib/aarch64-linux-gnu/libc.so.6 (mapped at 0xfcc704510000) STATIC: _start+0x30 adc1df8be0f0 ffffd7452420 /usr/lib/frr/staticd (mapped at 0xadc1df8a0000) ``` Tracking this down, the crash occurs because every time we modify a SID, staticd executes some callbacks to modify the SID and finally it calls `apply_finish`, which re-adds the SID to the list `srv6_sids`. This leads to having the same SID multiple times in the `srv6_sids` list. When we delete all SIDs, staticd attempts to deallocate the same SID multiple times, which leads to the crash. This commit fixes the issue by moving the code that adds the SID to the list from the `apply_finish` callback to the `create` callback. This ensures that the SID is inserted into the list only once, when it is created. For all subsequent modifications, the SID is modified but not added to the list. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com> (cherry picked from commit 6037ea350c98fbce60d0a287720cd4e60f7a21ec)
2025-01-28staticd: fix botched staticd YANG for dst-srcDavid Lamparter
The staticd YANG conversion completely f*cked up dst-src routes. Stupidly enough, the correct thing is much simpler as seen by the amount of deletes in this commit. This does, unfortunately, involve a rather annoying YANG edge case with what should reasonably be an optional leaf as part of a list key, which is not possible. It uses `::/0` as unconditional filler instead, since that is semantically correct. The `test_yang_mgmt` topotest needed to be adjusted after this to add `src-prefix='::/0'`. Fixes: 88fa5104a04a ("staticd : Configuration northbound implementation") Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-18staticd: Add Northbound APIs for SRv6Yuqing Zhao
Add Northbound APIs to create/modify/destroy an SRv6 SID Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
2024-02-02staticd: fix NB dependency hackIgor Ryzhov
Currently, staticd configuration is tightly coupled with VRF existence. Because of that, it has to use a hack in NB infrastructure to create a VRF configuration when at least one static route is configured for this VRF. This hack is incompatible with mgmtd, because mgmtd doesn't execute configuration callbacks. Because of that, the configuration may become out of sync between mgmtd and staticd. There are two main cases: 1. Create static route in a VRF. The VRF data node will be created automatically in staticd by the NB hack, but not in mgmtd. 2. Delete VRF which has some static routes configured. The static route configuration will be deleted from staticd by the NB hack, but not from mgmtd. To fix the problem, decouple configuration of static routes from VRF configuration. Now it is possible to configure static routes even if the VRF doesn't exist yet. Once the VRF is created, staticd applies all the preconfigured routes. This change also fixes the problem with static routes being preserved in the system when staticd "control-plane-protocol" container is deleted but the VRF is still configured. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-02staticd: fix nexthops without interfaceIgor Ryzhov
When interface is not set in "ip route" command, CLI passes "(null)" as an interface name instead of an empty string. The actual code in turn uses "nh->ifname[0] != 0" to check if the interface name was set. Fix the problem by changing the "(null)" string into an empty string when populating the nexthop structure. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-02Revert "staticd: Accept full blackhole typed keywords for ip_route_cmd"Igor Ryzhov
This reverts commit 76b2bc97e73874d882d5cf021972cfca84656cef. This change is wrong for several reasons: - it is backwards incompatible - previously it was always possible to create blackhole/reject routes using shortened versions of the words and it suddenly became impossible if there's an interface in the system with the same name - it uses operational data for validation which is prohibited - it doesn't really solve the problem with inability to create routes using interface names like `bla` or `rej`
2023-12-06Merge pull request #14922 from louis-6wind/fix-bfd-static-sourceRafael Zalamena
staticd: fix changing to source auto in bfd monitor
2023-12-01staticd: fix changing to source auto in bfd monitorLouis Scalbert
When monitoring a static route with BFD multi-hop, the source IP can be either configured or retrieved from NextHop-Tracking (NHT). After removing a configured source, the source is supposed to be retrieved from NHT but it remains to the previous value. This is problematic if the user desires to fix the configuration of a incorrect source IP. For example, theses two commands results in the incorrect state: > ip route 10.0.0.0/24 10.1.0.1 bfd multi-hop source 10.2.2.2 > ip route 10.0.0.0/24 10.1.0.1 bfd multi-hop When removing the source, BFD is unable to find the source from NHT via bfd_nht_update() were called. Force zebra to resend the information to BFD by unregistering and registering again NHT. The (...)/frr-nexthops/nexthop northbound apply_finish function will trigger a call to static_install_nexthop() that does a call to static_zebra_nht_register(nh, true); Fixes: b7ca809d1c ("lib: BFD automatic source selection") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-11-29lib: all: remove './' from xpath 22% speedupChristian Hopps
fixes #8299 Signed-off-by: Christian Hopps <chopps@labn.net>
2023-09-20Merge pull request #14089 from dmytroshytyi-6WIND/srv6_multiple_segs_sidsRuss White
bgpd,doc,lib,sharpd,staticd,yang,zebra: SRv6 multiple segs SIDs
2023-09-20staticd: northbound srv6 hooks for segs stack yang modelDmytro Shytyi
Provive hooks for srv6 segs SIDs stack yang model. Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-09-20staticd: Check against NULL before dereferencing vrfDonatas Abraitis
If VRF is not found by the given name, validate it and return an error. Fixes: 76b2bc97e738 ("staticd: Accept full blackhole typed keywords for ip_route_cmd") Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-25staticd: Accept full blackhole typed keywords for ip_route_cmdDonatas Abraitis
Before this patch we allow entering next-hop interface address as any string. Like, we can type: `ip route 10.10.10.10/32 bla`, but this will create a blackhole route instead of using an interface `bla`. The same is with reject. After the patch: ``` $ vtysh -c 'con' -c 'ip route 10.10.10.100/32 bla' ERROR: SET_CONFIG request failed, Error: nexthop interface name must be (reject, blackhole) $ ip link show dev bla 472: bla: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 link/ether fa:45:bd:f1:f8:f0 brd ff:ff:ff:ff:ff:ff $ vtysh -c 'sh run | include ip route' $ vtysh -c 'con' -c 'ip route 10.10.10.100/32 blac' $ vtysh -c 'sh run | include ip route' ip route 10.10.10.100/32 blackhole $ vtysh -c 'con' -c 'no ip route 10.10.10.100/32 blac' $ vtysh -c 'sh run | include ip route' $ vtysh -c 'con' -c 'ip route 10.10.10.100/32 blackhole' $ vtysh -c 'sh run | include ip route' ip route 10.10.10.100/32 blackhole $ vtysh -c 'con' -c 'no ip route 10.10.10.100/32 blackhole' $ vtysh -c 'sh run | include ip route' $ vtysh -c 'con' -c 'ip route 10.10.10.100/32 Null0' $ vtysh -c 'sh run | include ip route' ip route 10.10.10.100/32 Null0 $ vtysh -c 'con' -c 'no ip route 10.10.10.100/32 Null0' $ vtysh -c 'sh run | include ip route' $ ``` Signed-off-by: Donatas Abraitis <donatas@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>
2023-01-13staticd: BFD integration northbound supportRafael Zalamena
Implement all BFD integration northbound callbacks and integrate BFD with `staticd` route installation procedure. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-11-25staticd: Do not crash when modifying an existing static route with colorDonatas Abraitis
``` $ vtysh -c 'conf' -c 'ip route 192.168.0.0/32 192.168.10.65 color 123' $ vtysh -c 'show ip route 192.168.0.0/32 json' | jq '."192.168.0.0/32"[0].nexthops[0].srteColor' 123 $ vtysh -c 'conf' -c 'ip route 192.168.0.0/32 192.168.10.65' $ vtysh -c 'show ip route 192.168.0.0/32 json' | jq '."192.168.0.0/32"[0].nexthops[0].srteColor' 0 ``` Before this patch: ``` STATIC: Received signal 6 at 1666938633 (si_addr 0x4e1a, PC 0x7f295139c438); aborting... STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(zlog_backtrace_sigsafe+0x70) [0x7f29519ef0a0] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(zlog_signal+0xec) [0x7f29519ef28c] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0xccee2) [0x7f2951a1aee2] STATIC: /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390) [0x7f2951742390] STATIC: /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38) [0x7f295139c438] STATIC: /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7f295139e03a] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(_zlog_assert_failed+0xe6) [0x7f2951a46766] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0xae7ee) [0x7f29519fc7ee] STATIC: /home/u1/mGIT/frr-master/staticd/.libs/lt-staticd(routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_ STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0xaf264) [0x7f29519fd264] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0xafb4f) [0x7f29519fdb4f] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(nb_candidate_commit_apply+0x33) [0x7f29519fde33] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(nb_candidate_commit+0x9e) [0x7f29519fdf6e] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0xb0469) [0x7f29519fe469] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0xb3055) [0x7f2951a01055] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(nb_cli_apply_changes+0xd8) [0x7f2951a01358] STATIC: /home/u1/mGIT/frr-master/staticd/.libs/lt-staticd() [0x407ec2] STATIC: /home/u1/mGIT/frr-master/staticd/.libs/lt-staticd() [0x40a307] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0x74923) [0x7f29519c2923] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(cmd_execute_command+0xe4) [0x7f29519c2aa4] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(cmd_execute+0xc9) [0x7f29519c2c49] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0xe4184) [0x7f2951a32184] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0xe4436) [0x7f2951a32436] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(+0xe6fcc) [0x7f2951a34fcc] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(thread_call+0x98) [0x7f2951a2cc28] STATIC: /home/u1/mGIT/frr-master/lib/.libs/libfrr.so.0(frr_run+0xe8) [0x7f29519e7518] STATIC: /home/u1/mGIT/frr-master/staticd/.libs/lt-staticd(main+0xda) [0x40572a] STATIC: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f2951387840] STATIC: /home/u1/mGIT/frr-master/staticd/.libs/lt-staticd(_start+0x29) [0x4058e9] STATIC: in thread vtysh_read scheduled from lib/vty.c:2710 vty_event() ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-08staticd: When changing the underlying nh ensure it is reinstalledDonald Sharp
There exists some nexthop attributes that are not the unique part of the nexthop and if you change the static route with those values then the route is not being updated in zebra with the new values: Example of brokenness: eva# conf eva(config)# ip route 1.2.3.9/32 192.168.119.1 enp39s0 label 16020 eva(config)# do show ip route 1.2.3.9 Routing entry for 1.2.3.9/32 Known via "static", distance 1, metric 0, best Last update 00:00:05 ago * 192.168.119.1, via enp39s0, label 16020, weight 1 eva(config)# ip route 1.2.3.9/32 192.168.119.1 enp39s0 label 16040 eva(config)# do show ip route 1.2.3.9 Routing entry for 1.2.3.9/32 Known via "static", distance 1, metric 0, best Last update 00:00:12 ago * 192.168.119.1, via enp39s0, label 16020, weight 1 Fixed behavior: eva# conf eva(config)# ip route 1.2.3.10/32 192.168.119.1 enp39s0 label 16020 eva(config)# do show ip route 1.2.3.10 Routing entry for 1.2.3.10/32 Known via "static", distance 1, metric 0, best Last update 00:00:04 ago * 192.168.119.1, via enp39s0, label 16020, weight 1 eva(config)# ip route 1.2.3.10/32 192.168.119.1 enp39s0 label 16040 eva(config)# do show ip route 1.2.3.10 Routing entry for 1.2.3.10/32 Known via "static", distance 1, metric 0, best Last update 00:00:01 ago * 192.168.119.1, via enp39s0, label 16040, weight 1 I've gone through most of the items in staticd that can change the nexthop Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-17staticd: reject route config with too many nexthopsMark Stapp
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>
2022-02-17staticd: fix spelling in an error messageMark Stapp
whitespace change to fix a typo. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2021-08-31staticd: convert typedef to enumIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-09staticd: replace NB checks with assertIgor Ryzhov
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>
2021-07-09staticd: simplify the northbound codeIgor Ryzhov
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>
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-04-23*: make sure `config.h` or `zebra.h` is firstDavid Lamparter
`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>
2021-03-03staticd: forbid blackhole and non-blackhole nexthops in a single routeIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-17staticd: fix nexthop creation and installationIgor Ryzhov
Currently, staticd creates a VRF for the nexthop it is trying to install. Later, when this nexthop is deleted, the VRF stays in the system and can not be deleted by the user because "no vrf" command doesn't work for this VRF because it was not created through northbound code. There is no need to create the VRF. Just set nh_vrf_id to VRF_UNKNOWN when the VRF doesn't exist. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-17staticd: fix nexthop validationIgor Ryzhov
When checking for local connected address used as a nexthop gateway, we should check nexthop VRF, not route VRF. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-01-19Merge pull request #7863 from chiragshah6/mdevRuss White
[yang,staticd]: remove when condition from static nexthop om
2021-01-13staticd: handle when condition check in nb callbacksChirag Shah
At present, libyang validate api takes longer time to complete for a transaction to complete if the same config is re-applied. For instance if set of static routes are reapplied the config completion takes longer than it took initial time. One of the solution is to remove when statement from staticd nexthop yang OM. When condition adds peformance toll on libyang's validate api. The same when condition checks are done in frr northbound validation phase (which are must faster). With this change, if the same static routes are configured agian and again, the time to completion does not go up and perfomance does not degrade. Ticket:CM-32530 Testing Done: Configure 400 static routes across two vrfs and keep re-applying them. The time to complete the config remains in few seconds. Before: root@bharat:~/stash/frr4# time vtysh -f static_route_cfg real 0m19.877s user 0m0.263s sys 0m0.014s After: root@bharat:~/stash/frr4# time vtysh -f static_route_cfg real 0m3.857s user 0m0.239s sys 0m0.034s Co-developed-by: VishalDhingra <vdhingra@vmware.com> Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-01-12staticd: Backend cofiguration code to fix table-id problemvdhingra
problem: table-id gets overwritten for a given route. RCA: table-id was getting overwritten from the NB layer, So route was getting installed with the latest table-id. Fix: make the table-id as the key in the NB layer. This will program the route in zebra correctly. - Removed the table-id modify callbacks. - Moved the validate and apply table-id changes to path-list creation issue #7347 Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2020-08-31staticd : Added the warning log for route when VRF is not ready.vdhingra
During the yangification of staticd, refactoring of code around static_hold_route data struct has been done, In this context warning log message when VRF is not ready had been removed. This should not be removed, adding it back. I have missed one MPLS validation too, adding it back. Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2020-08-12staticd: add support for SR PoliciesSebastien Merle
Configuration example: ip route 9.9.9.9/32 6.6.6.6 color 123 The SR Policy to be chosen is uniquely identified by the policy endpoint (6.6.6.6) and the SR-TE color (123). Traffic will be augmented with an MPLS label stack according to the active candidate path of that particular policy. Co-authored-by: GalaxyGorilla <sascha@netdef.org> Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-07-16staticd: Added afi-safi as a key in route-listvdhingra
To address the ip mroute command there is a need to add safi as a key. So adding the afi-safi-type identityref as a key. Signed-off-by: VishalDhingra <vdhingra@vmware.com>
2020-07-16staticd : Configuration northbound implementationvdhingra
1. Modifies the data structs to make the distance, tag and table-id property of a route, i.e created a hireachical data struct to save route and nexthop information. 2. Backend northbound implementation Signed-off-by: VishalDhingra <vdhingra@vmware.com>