summaryrefslogtreecommitdiff
path: root/zebra/interface.c
AgeCommit message (Collapse)Author
2022-10-17lib,zebra: do not enable link-params when a link-params command failsLouis Scalbert
A given interface has no enabled link-params context. If a link-params configuration command fails, the link-params is wrongly enabled: > r4(config-link-params)# no enable > r4(config-link-params)# delay > (0-16777215) Average delay in micro-second as decimal (0...16777215) > r4(config-link-params)# delay 50 min 300 max 500 > Average delay should be comprise between Min (300) and Max (500) delay > r4(config-link-params)# do sh run zebra > (...) > interface eth-rt1 > link-params > enable > exit-link-params link-params are enabled if and only if the interface structure has a valid link_params pointer. Before checking the command validity, if_link_params_get() is called to retrieve the link-params pointer. However, this function initializes the pointer if it is NULL. Only use if_link_params_get() to retrieve the pointer to avoid confusion. In command setting functions, initialize the link_params pointer if needed only after the validation of the command. Fixes: 16f1b9e ("Update Traffic Engineering Support for OSPFD") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-08-11zebra: add tc netlink and dplane opsSiger Yang
This commit implements necessary netlink encoders for traffic control including QDISC, TCLASS and TFILTER, and adds basic dplane operations. Co-authored-by: Stephen Worley <sworley@nvidia.com> Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-08-08zebra: Don't install connected routes multiple times into FRRDonald Sharp
When moving an interface between vrf's we do not need to install the connected routes multiple times. eva# show ip route vrf all Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued, r - rejected, b - backup t - trapped, o - offload failure VRF BLUE: C>* 4.5.6.7/32 is directly connected, dummy7, 00:00:10 VRF default: K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:00:10 C>* 192.168.119.0/24 is directly connected, enp39s0, 00:00:10 eva# exit sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo ip link add GREEN type vrf table 11000 sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo ip link set GREEN up sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo ip link set dummy7 master GREEN sharpd@eva ~/f/t/topotests (multiple_connected_installs)> vtysh Hello, this is FRRouting (version 8.4-dev). Copyright 1996-2005 Kunihiro Ishiguro, et al. eva# show ip route vrf all Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued, r - rejected, b - backup t - trapped, o - offload failure VRF GREEN: C>* 4.5.6.7/32 is directly connected, dummy7, 00:00:05 VRF default: K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:01:03 C>* 192.168.119.0/24 is directly connected, enp39s0, 00:01:03 eva# exit sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo ip link set dummy7 nomaster sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo vtysh -c "show ip route vrf all" Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued, r - rejected, b - backup t - trapped, o - offload failure VRF default: K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:03:22 C>* 4.5.6.7/32 is directly connected, dummy7, 00:00:08 C>* 192.168.119.0/24 is directly connected, enp39s0, 00:03:22 sharpd@eva ~/f/t/topotests (multiple_connected_installs)> @ 11 0:-* 5h50m 0.06 24x1.9GHz 31.4G26% 426G70% 2022-08-08 13:49:24 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-08zebra: Add a `mpls enable` interface node commandDonald Sharp
Allow individual interfaces to turn on/off the mpls subsystem for it in linux. sharpd@eva:~/frr9$ sudo sysctl -a | grep enp39s0 | grep mpls net.mpls.conf.enp39s0.input = 0 sharpd@eva:~/frr9$ vtysh -c "conf" -c "int enp39s0" -c "mpls enable" sharpd@eva:~/frr9$ sudo sysctl -a | grep enp39s0 | grep mpls net.mpls.conf.enp39s0.input = 1 sharpd@eva:~/frr9$ vtysh -c "conf" -c "int enp39s0" -c "no mpls enable" sharpd@eva:~/frr9$ sudo sysctl -a | grep enp39s0 | grep mpls net.mpls.conf.enp39s0.input = 0 sharpd@eva:~/frr9$ Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-08zebra: Notice when an interface is turned on w/ mpls and enable mpls subsystemDonald Sharp
Currently when FRR starts up it queries the kernel to see if mpls is turned on. If not FRR does not enable zebra's mpls subsection. If at a later time mpls is turned on, let's notice that an interface now is enabled for mpls( thus implying that all the bits and bobs in the kernel are now setup properly ). a) convert mpls_enabled to a bool b) abstract a new function zebra_mpls_turned_on and call it when FRR notices that an interface now has mpls enabled. c) mpls_processq_init cannot fail, so actually notice that and don't have special code to detect a failure. New results: sharpd@eva ~> vtysh -c "show zebra" OS Linux(5.10.0-12-amd64) ECMP Maximum 128 v4 Forwarding On v6 Forwarding On MPLS Off EVPN Off Kernel socket buffer size 90000000 VRF l3mdev Available ASIC offload Unavailable RA Compiled in RFC 5549 BGP is not using Kernel NHG Available v4 All LinkDown Routes Off v4 Default LinkDown Routes Off v6 All LinkDown Routes Off v6 Default LinkDown Routes Off v4 All MC Forwarding On v4 Default MC Forwarding Off v6 All MC Forwarding On v6 Default MC Forwarding Off Route Route Neighbor LSP LSP VRF Installs Removals Updates Installs Removals default 26 7 0 0 0 <turn on mpls_iptunnel and mpls_router modules in the kernel and then do this>: sharpd@eva ~> sudo sysctl -w net.mpls.conf.enp39s0.input=1 [sudo] password for sharpd: net.mpls.conf.enp39s0.input = 1 sharpd@eva ~> vtysh -c "show zebra" OS Linux(5.10.0-12-amd64) ECMP Maximum 128 v4 Forwarding On v6 Forwarding On MPLS On EVPN Off Kernel socket buffer size 90000000 VRF l3mdev Available ASIC offload Unavailable RA Compiled in RFC 5549 BGP is not using Kernel NHG Available v4 All LinkDown Routes Off v4 Default LinkDown Routes Off v6 All LinkDown Routes Off v6 Default LinkDown Routes Off v4 All MC Forwarding On v4 Default MC Forwarding Off v6 All MC Forwarding On v6 Default MC Forwarding Off Route Route Neighbor LSP LSP VRF Installs Removals Updates Installs Removals default 26 7 0 0 0 sharpd@eva ~> I am doing this work because FRR keeps having operators not know about how to properly use mpls. Let's make FRR behave a bit better in this weird edge case. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-08zebra: Add IF_ZEBRA_DATA_X defineDonald Sharp
There are 2 defines IF_ZEBRA_MULTICAST_X and IF_ZEBRA_SHUTDOWN_X macros that do the same thing. Combine into one. Future commits will use the IF_ZEBRA_DATA_X macro as well. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-29zebra: make rib_process_dplane_results own ctx freeingDonald Sharp
The rib_process_dplane_results function was having each sub function handler process the results and then free the ctx. Lot's of functionality that needs to remember to free the context. Let's just free it in the main loop. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-27zebra: Add ability for netconf dplane to handle global valuesDonald Sharp
Add the ability for the netconf dplane code to handle the global NETCONFA_IFINDEX_DEFAULT and NETCONF_IFINDEX_ALL values. Then store our interested values when we get them from the kernel as well as being able to display them to the end operator. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-27zebra: Pass afi received for netconf updatesDonald Sharp
When Zebra receives the netconf update an afi is passed let's seperate that out and track the v4/v6 specific data to save and store appropriately. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-27zebra: mc_forwarding was being sent but not retrieved across dataplaneDonald Sharp
The mc_forwarding status for an interface was being sent but not properly retrieved on the zebra master side of the dplane. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23zebra: Add interface sysctl ignore on linkdown statusDonald Sharp
Add the ability to decode the ignore on linkdown nexthop status for an interface. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16zebra: Move where zebra marks a nhg as uninstalled in fibDonald Sharp
Currently the code is marking the nhg as uninstalled but not causing that to flood up to the dependent nhgs: nhg 3 is a group of 1/2 1 -> interface A 2 -> interface B Suppose A goes down, old code would mark nhg 1 as !VALID and !INSTALLED. Suppose B then goes down, old code would mark nhg 2 as !VALID and !INSTALLED But would not mark nhg 3 as !VALID and !INSTALLED (sort of assuming that it would just be cleaned up by NHG refcounts ). I would prefer that the code is pedantic about nhg 3 actually being removed from the system. This code moves the setting of !INSTALLED into zebra_nhg.c where it really belongs. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-15zebra: On linux let interface data come in through netlink messagingDonald Sharp
Consolidate on linux to using the netlink api for gathering all data about a interface. Leave this interface alone in the meantime for other OS's. This also has the side effect of reducing the amount of work being done on linux in that FRR was handling shut/no shut events 2 times. Once for the ioctl question asked and once for the netlink message received. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-21zebra: clean up rtadv integrationDavid Lamparter
Move a few things into places they actually belong, and reduce the number of places we have `#ifdev HAVE_RTADV`. Just overall code prettification. ... I had actually done this quite a while ago while doing some other random hacking and thought it more useful to not be sitting on it on my disk... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-05-06zebra/interface.c: allow link-param delay min <= avg <= maxG. Paul Ziemba
RFC 7471 Section 4.2.7: It is possible for min delay and max delay to be the same value. Prior to this change, the code required min < avg < max. This change allows min == avg and avg == max. test case: interface eth-rt1 link-params delay 8000 min 8000 max 8000 Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2022-04-19*: Fix spelling of accidentlyDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-24zebra: Fix use after deletion event in freebsdDonald Sharp
In the FreeBSD code if you delete the interface and it has no configuration, the ifp pointer will be deleted from the system *but* zebra continues to dereference the just freed pointer. ==58624== Invalid read of size 1 ==58624== at 0x48539F3: strlcpy (in /usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so) ==58624== by 0x2B0565: ifreq_set_name (ioctl.c:48) ==58624== by 0x2B0565: if_get_flags (ioctl.c:416) ==58624== by 0x2B2D9E: ifan_read (kernel_socket.c:455) ==58624== by 0x2B2D9E: kernel_read (kernel_socket.c:1403) ==58624== by 0x499F46E: thread_call (thread.c:2002) ==58624== by 0x495D2B7: frr_run (libfrr.c:1196) ==58624== by 0x2B40B8: main (main.c:471) ==58624== Address 0x6baa7f0 is 64 bytes inside a block of size 432 free'd ==58624== at 0x484ECDC: free (in /usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so) ==58624== by 0x4953A64: if_delete (if.c:283) ==58624== by 0x2A93C1: if_delete_update (interface.c:874) ==58624== by 0x2B2DF3: ifan_read (kernel_socket.c:453) ==58624== by 0x2B2DF3: kernel_read (kernel_socket.c:1403) ==58624== by 0x499F46E: thread_call (thread.c:2002) ==58624== by 0x495D2B7: frr_run (libfrr.c:1196) ==58624== by 0x2B40B8: main (main.c:471) ==58624== Block was alloc'd at ==58624== at 0x4851381: calloc (in /usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so) ==58624== by 0x496A022: qcalloc (memory.c:116) ==58624== by 0x49546BC: if_new (if.c:164) ==58624== by 0x49546BC: if_create_name (if.c:218) ==58624== by 0x49546BC: if_get_by_name (if.c:603) ==58624== by 0x2B1295: ifm_read (kernel_socket.c:628) ==58624== by 0x2A7FB6: interface_list (if_sysctl.c:129) ==58624== by 0x2E99C8: zebra_ns_enable (zebra_ns.c:127) ==58624== by 0x2E99C8: zebra_ns_init (zebra_ns.c:214) ==58624== by 0x2B3FF2: main (main.c:401) ==58624== Zebra needs to pass back whether or not the ifp pointer was freed when if_delete_update is called and it should then check in ifan_read as well as ifm_read that the ifp pointer is still valid for use. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-09zebra: use SET/UNSET/CHECK/COND in protodown codeStephen Worley
Use the SET/UNSET/CHECK/COND macros for flag bifields where appropriate throught the protodown code base. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: clear dplane flags on failure for protodownStephen Worley
Make sure we clear our dplane flags for SET/UNSET on failure so that we try again. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: simplify reason code printing in showStephen Worley
Simplify the code for printing the reason codes via show command. Just remove the trailing comma last before printing. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: cleanup protodown api logsStephen Worley
Cleanup the logs in the api for setting protodown on/off that zapi and others use. Make them more useful to a user parsing them after an issue. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: extern setting protodown reason directlyStephen Worley
Extern the api for setting the protodown reason code bitfield directly. Some places may want to completely update the bitfield with more than one reason at a time. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: only clear pd_reason on shutdown/sweepStephen Worley
Only clear protodown reason on shutdown/sweep, retain protodown state. This is to retain traditional and expected behavior with daemons like vrrpd setting protodown. They expet it to be set on shutdown and retained on bring up to prevent traffic from being dropped. We must cleanup our reason code though to prevent us from blocking others. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: remove old protodown dplane pathStephen Worley
Remove the old protodown dplane path install on the main thread. This is now dead code. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: use a macro for check protodownStephen Worley
Add a helper macro for checking if interface is protodown, typing this out is annoying. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: clear protodown_rc on shutdown and sweepStephen Worley
Add functionality to clear any reason code set on shutdown of zebra when we are freeing the interface, in case a bad client didn't tell us to clear it when the shutdown. Also, in case of a crash or failure to do the above, clear reason on startup if it is set. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: add enum set/unset states for queingStephen Worley
Add enums for set/unset of prodown state to handle the mainthread knowing an update is already queued without actually marking it as complete. This is to make the logic confirm a bit more with other parts of the code where we queue dplane updates and not update our internal structs until success callback is received. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09zebra: add support for protodown reason codeStephen Worley
Add support for setting the protodown reason code. https://github.com/torvalds/linux/commit/829eb208e80d6db95c0201cb8fa00c2f9ad87faf These patches handle all our netlink code for setting the reason. For protodown reason we only set `frr` as the reason externally but internally we have more descriptive reasoning available via `show interface IFNAME`. The kernel only provides a bitwidth of 32 that all userspace programs have to share so this makes the most sense. Since this is new functionality, it needs to be added to the dplane pthread instead. So these patches, also move the protodown setting we were doing before into the dplane pthread. For this, we abstract it a bit more to make it a general interface LINK update dplane API. This API can be expanded to support gernal link creation/updating when/if someone ever adds that code. We also move a more common entrypoint for evpn-mh and from zapi clients like vrrpd. They both call common code now to set our internal flags for protodown and protodown reason. Also add debugging code for dumping netlink packets with protodown/protodown_reason. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09Merge pull request #10662 from chiragshah6/evpn_dev1Russ White
zebra: netlink protodown event handling for vxlan device
2022-03-08zebra: shutdown doesn't uninstall zebra's NHGsMark Stapp
When an interface goes down, it signals any related NHGs to re-validate themselves. During zebra shutdown, ensure we remove any NHGs we've installed. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-03-02zebra: Prevent installation of connected multiple timesDonald Sharp
With recent changes to interface up mechanics in if_netlink.c FRR was receiving as many as 4 up events for an interface on ifdown/ifup events. This was causing timing issues in FRR based upon some fun timings. Remove this from happening. Ticket: CM-31623 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-28zebra: Limit speed lookup to at most 4 minutesDonald Sharp
There exists some interface types that are slow on startup to fully register their link speed. Especially those that are working with an asic backend. The speed_update timer associated with each interface would keep trying if the system returned a MAX_UINT32 as the speed. This speed means both unknown or there is none under linux. Since some interface types are slow on startup let's modify FRR to try for at most 4 minutes and give up trying on those interfaces where we never get any useful data. Why 4 minutes? I wanted to balance the time associated with slow interfaces coming up with those that will never give us a value. So I choose 4 minutes as a good ballpark of time to keep trying Why not track all those interfaces and just not attempt to do the speed lookup? I would prefer to not keep track of these as that I do not know all the interface types, nor do I wish to keep programming as new ones come in. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-25zebra: use dataplane to read interface NETCONF infoMark Stapp
Use the dataplane to query and read interface NETCONF data; add netconf-oriented data to the dplane context object, and add accessors for it. Add handler for incoming update processing. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-25zebra: include mpls enabled status in interface outputMark Stapp
Add mpls status to the zebra interface struct; include mpls status in show interface output. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-23*: Change thread->func to return void instead of intDonald Sharp
The int return value is never used. Modify the code base to just return a void instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-28zebra: Make Router Advertisement warnings show up once every 6 hoursDonald Sharp
RA packets are pretty chatty and when there is a warning from a missconfiguration on the network, the log file gets filed up with warnings. Modify the code in rtadv.c to only spit out the warning in these cases at most every 6 hours. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-24*: do not print vrf name for interface config when using vrf-liteIgor Ryzhov
VRF name should not be printed in the config since 574445ec. The update was done for NB config output but I missed it for regular vty output. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-20lib, zebra: Add ability to tell thread system to ignore late timersDonald Sharp
Add a thread_ignore_late_timer(struct thread *thread) function that allows thread.c to ignore when timers are late to the party. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-29Merge pull request #10124 from ton31337/feature/vty_jsonIgor Ryzhov
2021-11-27*: Remove redundand braces for single statement blocksDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25zebra: Convert vty_out to vty_json for JSONDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25*: Remove unused variablesDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25zebra: Replace prefix2str for JSON to %pFXDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-22*: cleanup ifp->vrf_idIgor Ryzhov
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>
2021-11-19Merge pull request #10074 from opensourcerouting/assorted-20211116Igor Ryzhov
lib/vtysh/ospf6d: assorted small bits
2021-11-18zebra: Replace inet_ntop to %pI4/6 for JSON outputsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-16lib: rework vty_check_node_for_xpath_decrementDavid Lamparter
...by having a flag in struct cmd_node rather than hardcoding it in `lib/command.c`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-11-11*: Rename quagga_timestamp with frr_timestampDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-27Merge pull request #9837 from idryzhov/cleanup-if-by-name-vrf-allRuss White
*: fix usage of if_lookup_by_name_all_vrf
2021-10-19lib: allow to create interfaces in non-existing VRFsIgor Ryzhov
It allows FRR to read the interface config even when the necessary VRFs are not yet created and interfaces are in "wrong" VRFs. Currently, such config is rejected. For VRF-lite backend, we don't care at all about the VRF of the inactive interface. When the interface is created in the OS and becomes active, we always use its actual VRF instead of the configured one. So there's no need to reject the config. For netns backend, we may have multiple interfaces with the same name in different VRFs. So we care about the VRF of inactive interfaces. And we must allow to preconfigure the interface in a VRF even before it is moved to the corresponding netns. From now on, we allow to create multiple configs for the same interface name in different VRFs and the necessary config is applied once the OS interface is moved to the corresponding netns. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>