summaryrefslogtreecommitdiff
path: root/zebra/kernel_socket.c
AgeCommit message (Collapse)Author
2022-09-23Merge pull request #11997 from sri-mohan1/sri-zebra-dbg1Donatas Abraitis
zebra: changes for code maintainability
2022-09-23zebra: changes for code maintainabilitysri-mohan1
these changes are for improving the code maintainability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-17zebra: No need for a rib_delete before a rib_addDonald Sharp
In kernel_socket.c, the code is deleting and then adding the route back in on a change operation. This just translates too two re's, one for deletion and one for addition. The deletion will just be ignored. Let's not do the extra deletion. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-11zebra: add empty placeholders for tc via BSD socketSiger Yang
This commit adds unimplemented updating functions for traffic control via BSD socket. Signed-off-by: Siger Yang <siger.yang@outlook.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-07-01zebra: handle FreeBSD routing socket ENOBUFSRafael Zalamena
This is a slightly modified version of Hiroki Sato's version: https://github.com/hrs-allbsd/frr/commit/9ca79c941fd84322199994a2aed267b23d39c86a Handle the `ENOBUFS` on a OS basis since it could have been implemented differently (OpenBSD for an example uses `RTM_DESYNC`). Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-05-11*: Properly use memset() when zeroingDonatas Abraitis
Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-25Merge pull request #10867 from donaldsharp/ifp_use_after_freeDavid Lamparter
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-24zebra: When handling unprocessed messages from kernel print usable stringDonald Sharp
Add new debug output to show the string of the message type that is currently unhandled: 2022-03-24 18:30:15.284 [DEBG] zebra: [V3NSB-BPKBD] Kernel: 2022-03-24 18:30:15.284 [DEBG] zebra: [HDTM1-ENZNM] Kernel: message seq 792 2022-03-24 18:30:15.284 [DEBG] zebra: [MJD4M-0AAAR] Kernel: pid 594488, rtm_addrs {DST,GENMASK} 2022-03-24 18:30:15.285 [DEBG] zebra: [GRDRZ-0N92S] Unprocessed RTM_type: RTM_NEWMADDR(d) Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-09zebra: add boilerplate protodown updates for *bsdStephen Worley
Add boilerplate for someone to come and add protdown updates for bsd platforms if it ever exists. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-02-28Merge pull request #10672 from donaldsharp/bsd_zebra_graceful_restart_cleanupJafar Al-Gharaibeh
Bsd zebra graceful restart cleanup
2022-02-28zebra: Get zebra graceful restart working when restarting on *BSDDonald Sharp
Upon restart zebra reads in the kernel state. Under linux there is a mechanism to read the route and convert the protocol to the correct internal FRR protocol to allow the zebra graceful restart efforts to work properly. Under *BSD I do not see a mechanism to convey the original FRR protocol into the kernel and thus back out of it. Thus when zebra crashes ( or restarts ) the routes read back in are kernel routes and are effectively lost to the system and FRR cannot remove them properly. Why? Because FRR see's kernel routes as routes that it should not own and in general the admin distance for those routes will be a better one than the admin distance from a routing protocol. This is even worse because when the graceful restart timer pops and rib_sweep is run, FRR becomes out of sync with the state of the kernel forwarding on *BSD. On restart, notice that the route is a self route that there is no way to know it's originating protocol. In this case let's set the protocol to ZEBRA_ROUTE_STATIC and set the admin distance to 255. This way when an upper level protocol reinstalls it's route the general zebra graceful restart code still works. The high admin distance allows the code to just work in a way that is graceful( HA! ) The drawback here is that the route shows up as a static route for the time the system is doing it's work. FRR could introduce *another* route type but this seems like a bad idea and the STATIC route type is loosely analagous to the type of route it has become. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-27zebra: Allow *BSD to specify a receive buffer sizeDonald Sharp
End operator is reporting that they are receiving buffer overruns when attempting to read from the kernel receive socket. It is possible to adjust this size to more modern levels especially for when the system is under load. Modify the code base so that *BSD operators can use the zebra `-s XXX` option to specify a read buffer. Additionally setup the default receive buffer size on *BSD to be 128k instead of the 8k so that FRR does not run into this issue again. Fixes: #10666 Signed-off-by: Donald Sharp <sharpd@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-02-11zebra: make netlink object hash threadsafeMark Stapp
The recently-added hashtable of nlsock objects needs to be thread-safe: it's accessed from the main and dplane pthreads. Add a mutex for it, use wrapper apis when accessing it. Add a per-OS init/terminate api so we can do init that's not per-vrf or per-namespace. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-07zebra: Fix ships in the night issueDonald Sharp
When using wait for install there exists situations where zebra will issue several route change operations to the kernel but end up in a state where we shouldn't be at the end due to extra data being received. Example: a) zebra receives from bgp a route change, installs sends the route to the kernel. b) zebra receives a route deletion from bgp, removes the struct route entry and then sends to the kernel a deletion. c) zebra receives an asynchronous notification that (a) succeeded but we treat this as a new route. This is the ships in the night problem. In this case if we receive notification from the kernel about a route that we know nothing about and we are not in startup and we are doing asic offload then we can ignore this update. Ticket: #2563300 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-11*: Cleanup some documentation from quagga->frrDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
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>
2021-09-14zebra: use the dataplane to read netlink intf addr changesMark Stapp
Read incoming interface address change notifications in the dplane pthread; enqueue the events to the main pthread for processing. This is netlink-only for now - the bsd kernel socket path remains unchanged. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-09-14zebra: replace sockunion2str in kernel_socket.cMark Stapp
Use the frr format spec instead. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-07-20zebra: Mark some bsd interface prefixes as SECONDARYDonald Sharp
Notice when a ip address on a bsd interface is considered an alias, let's mark the connected prefix we generate as a SECONDARY. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-07-01*: Replace IPV4_MAX_PREFIXLEN to IPV4_MAX_BITLENDonatas Abraitis
Just drop IPV4_MAX_PREFIXLEN at all, no need keeping both. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01*: Replace IPV6_MAX_PREFIXLEN to IPV6_MAX_BITLENDonatas Abraitis
Just drop IPV6_MAX_PREFIXLEN at all, no need keeping both. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-03-22zebra: kill zebra_memory.h, use MTYPE_STATICDavid Lamparter
This one also needed a bit of shuffling around, but MTYPE_RE is the only one left used across file boundaries now. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-12-11Revert "zebra: When shutting down an interface immediately notify about rnh"Donald Sharp
This reverts commit 0aaa722883245c2109d9856ca0656749860fc579.
2020-10-29zebra: Consolidate on 32 bits as the flag size for route flagsDonald Sharp
When we get a route for installation via any method we should consolidate on 32 bits as the flag size, since we have actually more than 8 bits of data to bass around. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-05BSD: Add whitespace between declaration and codeRoy Marples
Signed-off-by: Roy Marples <roy@marples.name>
2020-10-04BSD: Detect route(4) overflowsRoy Marples
NetBSD and DragonFlyBSD support reporting of route(4) overflows by setting the socket option SO_RERROR. This is handled the same as on Linux by exiting with a -1 error code. Signed-off-by: Roy Marples <roy@marples.name>
2020-09-22Merge pull request #7067 from donaldsharp/remove_solarisMark Stapp
Remove solaris
2020-09-21*: Remove solaris from FRRDonald Sharp
The Solaris code has gone through a deprecation cycle. No-one has said anything to us and worse of all we don't have any test systems running Solaris to know if we are making changes that are breaking on Solaris. Remove it from the system so we can clean up a bit. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-20zebra: Allow FreeBSD to set and delete addresses from an interfaceDonald Sharp
This series of events: $ sudo ifconfig lo0 add 4.4.4.4/32 $ sudo ifconfig lo0 inet 4.4.4.4/32 delete would end up leaving the 4.4.4.4/32 address on the interface under freebsd. This all boils down to the fact that the interface is not considered connected yet we have a destination. If the destination is the same and we are not connected ignore it on freebsd. I am sure there are other fun scenarios that someone will have to squirrel out. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-08-28zebra: When shutting down an interface immediately notify about rnhDonald Sharp
Imagine a situation where a interface is bouncing up/down. The interface comes up and daemons like pbr will get a nht tracking callback for a connected interface up and will install the routes down to zebra. At this same time the interface can go down. But since zebra is busy handling route changes ( from pbr ) it has not read the netlink message and can get into a situation where the route resolves properly and then we attempt to install it into the kernel( which is rejected ). If the interface bounces back up fast at this point, the down then up netlink message will be read and create two route entries off the connected route node. Zebra will then enqueue both route entries for future processing. After this processing happens the down/up is collapsed into an up and nexthop tracking sees no changes and does not inform any upper level protocol( in this case pbr ) that nexthop tracking has changed. So pbr still believes the nexthops are good but the routes are not installed since pbr has taken no action. Fix this by immediately running rnh when we signal a connected route entry is scheduled for removal. This should cause upper level protocols to get a rnh notification for the small amount of time that the connected route was bouncing around like a madman. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-12lib, zebra: add support for sending ARP requestsJakub Urbańczyk
We can make the Linux kernel send an ARP/NDP request by adding a neighbour with the 'NUD_INCOMPLETE' state and the 'NTF_USE' flag. This commit adds new dataplane operation as well as new zapi message to allow other daemons send ARP/NDP requests. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10zebra: remove old kernel one-update-at-a-time apiJakub Urbańczyk
The old one is replaced by the api that is suitable for the batching. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10zebra: prepare dplane for batchingJakub Urbańczyk
Extend kernel interface to allow the data plane to send many kernel updates at once. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-07-14*: un-split strings across linesDavid Lamparter
Remove mid-string line breaks, cf. workflow doc: .. [#tool_style_conflicts] For example, lines over 80 characters are allowed for text strings to make it possible to search the code for them: please see `Linux kernel style (breaking long lines and strings) <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_ and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_. Scripted commit, idempotent to running: ``` python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'` ``` Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-24*: remove line breaks from log messagesDavid Lamparter
Line break at the end of the message is implicit for zlog_* and flog_*, don't put it in the string. Mid-message line breaks are currently unsupported. (LF is "end of message" in syslog.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-03-08*: Replace `sizeof something` to sizeof(something)Donatas Abraitis
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis) Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-04zebra: Use shorthand operator in ifm_read()Donatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-10-25zebra: Use nexthop object id on route deleteStephen Worley
When we receive a route delete from the kernel and it contains a nexthop object id, use that to match against route gateways with instead of explicit nexthops. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Update rib_add to take a nexthop IDStephen Worley
Add a parameter to the rib_add function so that it takes a nexthop ID from the kernel if one is passed along with the route. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-09*: Cleanup interface creation apisStephen Worley
Cleanup the interface creation apis to make it more clear what they are doing. Make it explicit that the creation via name/ifindex will only add it to the appropriate list. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-09-03*: frr_elevate_privs -> frr_with_privsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-23Revert "Ospf missing interface handling 2"Donald Sharp
2019-06-12*: change if_lookup_by_name() api with vrfPhilippe Guibert
the vrf_id parameter is replaced by struct vrf * parameter. this impacts most of the daemons that look for an interface based on the name and the vrf identifier. Also, it fixes 2 lookup calls in zebra and sharpd, where the vrf_id was ignored until now. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11lib, ospfd, pimd, zebra: change if_create() api with vrfPhilippe Guibert
if_create() takes as input a vrf poiter instead of the vrf_id parameter. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11ospf, ospf6d, zebra, lib: change if_get_by_name prototype with vrfPhilippe Guibert
vrf pointer is used as reference when calling if_get_by_name() function. this will permit to create interfaces with an unknown vrf_id, since it is only necessary to get the vrf structure to store the interfaces. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-29zebra: fix maybe-uninitialized pointerQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29zebra: fix unused variable on OmniOSQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>