aboutsummaryrefslogtreecommitdiff
path: root/tests/sys/netlink
Commit message (Collapse)AuthorAgeFilesLines
* tests/netlink: Bugfix on snl_parse_errmsg_capped testK Rin44 hours1-2/+2
| | | | | | | Turn off the NETLINK_EXT_ACK flag to fix bug of snl_parse_errmsg_capped. Reviewed by: pouria Pull Request: https://github.com/freebsd/freebsd-src/pull/1660
* gre tests: Fix gcc warnings on gre netlink testsPouria Mousavizadeh Tehrani2026-02-201-7/+5
| | | | | | | | Avoid using `snl_add_msg_attr_ip` for now and directly use `snl_add_msg_attr_ip4` to silence gcc warnings. Fixes: e1e18cc12e68 Differential Revision: https://reviews.freebsd.org/D54443
* gre tests: Add required_kmods to gre netlink testPouria Mousavizadeh Tehrani2026-02-201-0/+1
| | | | | Fixes: e1e18cc12e68 Differential Revision: https://reviews.freebsd.org/D54443
* if_gre: Add netlink support with testsPouria Mousavizadeh Tehrani2026-02-182-0/+174
| | | | | | | | Migrate to new if_clone KPI and implement netlink support for gre(4). Also refactor some of the gre specific ioctls. Reviewed by: glebius, zlei Differential Revision: https://reviews.freebsd.org/D54443
* tests/netlink: fix flaky netlink_sockets:sizesGleb Smirnoff2025-09-281-2/+16
| | | | | | | | | The problem is that fullsocket() creates a socket that has both send and receive buffers full and as we process messages from the receive buffer we allow the kernel to continue processing of the send buffer and a new message may arrive while the test expects that no new messages arrive. Fix that by creating a socket that has several messages in the receive buffer, but don't have any in the send buffer.
* tests/sys/netlink: use require.kmods property instead of ad-hoc checksSiva Mahadevan2025-09-053-35/+27
| | | | | | | Signed-off-by: Siva Mahadevan <me@svmhdvn.name> Sponsored by: The FreeBSD Foundation Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1780
* netlink: Move static arrays of parsers into tests that use themJohn Baldwin2025-04-112-0/+16
| | | | | | | These are not documented as part of the API in the manpages and raise warnings on GCC in the test-includes stage. Reported by: -Wunused-variable
* tests/netlink: Assert the route scope of interface's addressesZhenlei Huang2025-03-071-5/+15
| | | | | | | | | While here, add one additional IPv4 link-local address to test_46_nofilter to cover the IPv4 RT_SCOPE_LINK case. Reviewed by: melifaro, #network MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D49226
* netlink: underscore snl_get_genl_family_info() to discourage its useGleb Smirnoff2025-01-201-1/+1
| | | | | | | | | | | | | | | This function uses already supposedly opaque struct _getfamily_attrs as the argument and it fills it with pointers to volatile memory, which makes it is unsafe for general use. While here also underscore structures that hang off the struct _getfamily_attrs. Small programs like powerd(8) and RPC daemons are converted to use snl_get_genl_mcast_group() and/or snl_get_genl_family(). The genl(1) utility was fixed not to mix its own parsers with parsers declared in netlink_snl_generic.h. Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D48480
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* tests/netlink: improve recently added netlink_socket:membershipGleb Smirnoff2024-01-111-5/+31
| | | | | | | | Change sequence of syscalls: instead of "add, delete, check, check" run sequence "add, check, delete, check". Seems to make more sense. Do minimal parsing of incoming messages: find the IPv4 address there and compare it to the original.
* tests/netlink: mark a test that requires tun(4)Gleb Smirnoff2024-01-111-0/+2
|
* tests/netlink: add minimal test for a group writerGleb Smirnoff2024-01-101-0/+49
| | | | | Subscribe a socket for RTNLGRP_IPV4_ROUTE announcements, add & delete a route and check that announcements came in.
* netlink: use protocol specific receive bufferGleb Smirnoff2024-01-021-47/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement Netlink socket receive buffer as a simple TAILQ of nl_buf's, same part of struct sockbuf that is used for send buffer already. This shaves a lot of code and a lot of extra processing. The pcb rids of the I/O queues as the socket buffer is exactly the queue. The message writer is simplified a lot, as we now always deal with linear buf. Notion of different buffer types goes away as way as different kinds of writers. The only things remaining are: a socket writer and a group writer. The impact on the network stack is that we no longer use mbufs, so a workaround from d18715475071 disappears. Note on message throttling. Now the taskqueue throttling mechanism needs to look at both socket buffers protected by their respective locks and on flags in the pcb that are protected by the pcb lock. There is definitely some room for optimization, but this changes tries to preserve as much as possible. Note on new nl_soreceive(). It emulates soreceive_generic(). It must undergo further optimization, see large comment put in there. Note on tests/sys/netlink/test_netlink_message_writer.py. This test boiled down almost to nothing with mbufs removed. However, I left it with minimal functionality (it basically checks that allocating N bytes we get N bytes) as it is one of not so many examples of ktest framework that allows to test KPIs with python. Note on Linux support. It got much simplier: Netlink message writer loses notion of Linux support lifetime, it is same regardless of process ABI. On socket write from Linux process we perform conversion immediately in nl_receive_message() and on an output conversion to Linux happens in in nl_send_one(). XXX: both conversions use M_NOWAIT allocation, which used to be the case before this change, too. Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D42524
* tests/netlink: add netlink socket buffer testGleb Smirnoff2024-01-022-1/+268
| | | | | | | | | | | | | | | | | | | | | | | | | With upcoming protocol specific socket buffer for Netlink we need some additional tests that cover basic socket operations, w/o much of actual Netlink knowledge. Following tests are performed: 1) Overflow. If an application keeps sending messages to the kernel, but doesn't read out the replies, then first the receive buffer shall fill and after that further messages from applications will be queued on the send buffer until it is filled. After that socket operations should block. However, reading from the receive buffer some data should wake up the taskqueue and the send buffer should start draining again. 2) Peek & trunc. Check that socket correctly reports amount of readable data with MSG_PEEK & MSG_TRUNC. This is typical pattern of Netlink apps. 3) Sizes. Check that zero size read doesn't affect the socket, undersize read will return one truncated message and the message is removed from the buffer. Check that large buffer will be filled in one read, without any boundaries imposed by internal representation of the buffer. Check that any meaningful read is amended with control data if requested so. Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D42525
* netlink: Add tests when adding an interface routeJose Luis Duran2023-11-281-0/+41
| | | | | | | | | | Add tests for adding a route using an interface only (without an IP address). Reviewed by: rcm Approved by: kp (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41436
* tests/netlink: mark the vlan(4) test with required moduleGleb Smirnoff2023-10-191-0/+1
|
* netlink: cope with growing requestsKristof Provost2023-10-171-1/+1
| | | | | | | | | | | | | If a request ends up growing beyong the initially allocated space the netlink functions (such as snl_add_msg_attr_u32()) will allocate a new buffer. This invalidates the header pointer we can have received from snl_create_msg_request(). Always use the hdr returned by snl_finalize_msg(). Reviewed by: melifaro MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D42223
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* netlink: fix failing TestRtNlAddIfaddrLo::test_add_6 tests.Alexander V. Chernikov2023-06-131-1/+1
| | | | | | | | | Recent netlink commit added hook for calling IPv6 code upon implicit inteface bring-up on adding first interface address. This hook handles link-local ifa addition for the loopback interface, resulting in failed assertion in the loopback tests. Fix the tests by fixing the assert.
* netlink: use netlink mbufs in the mbuf chains.Alexander V. Chernikov2023-06-022-0/+80
| | | | | | | | | Continue D40356 and switch the remaining parts of mbuf-related code to the Netlink mbufs. Reviewed By: gallatin Differential Revision: https://reviews.freebsd.org/D40368 MFC after: 2 weeks
* netlink: add snl(3) support for listing genetlink multicast groupsAlexander V. Chernikov2023-05-271-0/+39
| | | | | | Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D40282 MFC after: 2 weeks
* netlink: automatically generate broadcast for IPv4 ifa if not set.Alexander V. Chernikov2023-05-201-0/+35
| | | | MFC after: 2 weeks
* netlink: add support for adding/deleting interface addressesAlexander V. Chernikov2023-05-161-15/+571
| | | | | Differential Revision: https://reviews.freebsd.org/D40103 MFC after: 2 weeks
* testing: rename IfattrType to IfaAttrType for consistencyAlexander V. Chernikov2023-05-151-13/+13
| | | | | | | All other attribute classes are named as 'type'AttrType and 'type' int this case is ifa (interface address). MFC after: 2 weeks
* netlink: temporary skip snl(3) capped test.Alexander V. Chernikov2023-05-091-0/+2
|
* netlink: add netlink interfaces to if_cloneAlexander V. Chernikov2023-04-251-0/+3
| | | | | | | | | | | | | | This change adds netlink create/modify/dump interfaces to the `if_clone.c`. The previous attempt with storing the logic inside `netlink/route/iface_drivers.c` did not quite work, as, for example, dumping interface-specific state (like vlan id or vlan parent) required some peeking into the private interfaces. The new interfaces are added in a compatible way - callers don't have to do anything unless they are extended with Netlink. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D39032 MFC after: 1 month
* tests: split netlink.py into multiple files to impove maintainability.Alexander V. Chernikov2023-04-015-46/+43
| | | | | | | | | | This diff does not contain any functional changes. Its sole purpose is splitting netlink.py into smaller chunks. The new code simplifies the upcoming generic netlink support introduction. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D39365
* netlink: fix capped uncapped ack handling in snl(3).Alexander V. Chernikov2023-03-181-0/+126
| | | | | | Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D39144 MFC after: 2 weeks
* netlink: improve snl(3)Alexander V. Chernikov2023-03-153-27/+110
| | | | | | | | | | | | | | | Summary: * add snl_send_message() as a convenient send wrapper * add signed integer parsers * add snl_read_reply_code() to simplify operation result checks * add snl_read_reply_multi() to simplify reading multipart messages * add snl_create_genl_msg_request() * add snl_get_genl_family() to simplify family name->id resolution * add tests for some of the functionality Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D39092 MFC after: 2 weeks
* netlink: add snl(3) default parsers for routes and links.Alexander V. Chernikov2023-03-091-0/+13
| | | | | | | | | | This change adds the "default" parsers of _all_ route/link attributes exported by the kernel. It removes the need to declare similar parsers in the userland applications, simplifying their logic. Differential Revision: https://reviews.freebsd.org/D38979 MFC after: 2 weeks
* tests: add more netlink tests for neighbors/routesAlexander V. Chernikov2023-03-073-0/+77
| | | | | Differential Revision: https://reviews.freebsd.org/D38912 MFC after: 2 weeks
* netlink: fix vlan interface creationAlexander V. Chernikov2023-03-031-1/+0
| | | | MFC after: 2 weeks
* tests: add netlink large dump buffer checkAlexander V. Chernikov2023-02-202-0/+77
| | | | | Differential Revision: https://reviews.freebsd.org/D38665 MFC after: 2 weeks
* tests: fix netlink test_dump_ifaces_many test.Alexander V. Chernikov2023-02-181-4/+4
| | | | | | | | Consider only loopback interfaces when counting. Otherwise, if pf is loaded, 'pflog0' gets added to the vnet, breaking the test. MFC after: 2 weeks
* netlink: fix interface dump.Alexander V. Chernikov2023-02-161-0/+61
| | | | | | | | | | The current code missed interface addition when reallocating temporary buffer. Tweak the code to perform the reallocation first and add interface afterwards unconditionally. Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl> MFC after: 3 days
* netlink: return optional metadata with the operation result.Alexander V. Chernikov2023-02-091-0/+35
| | | | | | | | | | | | | | | Some operations like interface creation may need to return metadata - in this case, interface name - back to the caller if the operation is successful. This change implements attaching an `NLMSGERR_ATTR_COOKIE` nla to the operation reply message via `nlmsg_report_cookie()`. Additionally, on successful interface creation, interface index and interface name are returned in the `IFLA_NEW_IFINDEX` and `IFLA_IFNAME TLVs, encapsulated in the `NLMSGERR_ATTR_COOKIE`. Reviewed By: pauamma Differential Revision: https://reviews.freebsd.org/D38283 MFC after: 1 week
* netlink: allow creating sockets with SOCK_DGRAM.Alexander V. Chernikov2023-01-212-0/+34
| | | | | | | | | | Some existing applications setup Netlink socket with SOCK_DGRAM instead of SOCK_RAW. Update the manpage to clarify that the default way of creating the socket should be with SOCK_RAW. Update the code to support both SOCK_RAW and SOCK_DGRAM. Reviewed By: pauamma Differential Revision: https://reviews.freebsd.org/D38075
* netlink: fix compatibility with older netlink applications.Alexander V. Chernikov2023-01-161-0/+20
| | | | | | | | | | | | | | Some apps try to provide only the non-zero part of the required message header instead of the full one. It happens when fetching routes or interface addresses, where the first header byte is the family. This behavior is "illegal" under the "strict" Netlink socket option, however there are many applications out there doing things in the "old" way. Support this usecase by copying the provided bytes into the temporary zero-filled header and running the parser on this header instead. Reported by: Goran Mekić <meka@tilda.center>
* testing: fix skipping netlink tests if netlink module is not loaded.Alexander V. Chernikov2023-01-082-2/+2
|
* netlink: improve RTM_GETADDR handling.Alexander V. Chernikov2023-01-083-31/+149
| | | | | | | | | | | * Allow filtering by ifa_family & ifa_index. * Add common RTM_<NEW|DEL|GET>ADDR parser * Add tests verifying RTM_GETADDR filtering behaviour & output * Factor out common netlink socket test methods into NetlinkTestTemplate * Add NLMSG_DONE message handler Reviewed By: pauamma Differential Revision: https://reviews.freebsd.org/D37970
* netlink: add snl(3) - simple netlink libraryAlexander V. Chernikov2022-12-232-2/+93
| | | | | Reviewed by: bapt, pauamma Differential Revision: https://reviews.freebsd.org/D37736
* netlink: connect netlink tests to the buildAlexander V. Chernikov2022-12-161-0/+2
| | | | | Reviewed By: ngie Differential Revision: https://reviews.freebsd.org/D37708
* netlink: improve interface handlingAlexander V. Chernikov2022-12-142-0/+295
* Separate interface creation from interface modification code * Support setting some interface attributes (ifdescr, mtu, up/down, promisc) * Improve interaction with the cloners requiring to parse/write custom interface attributes * Add bitmask-based way of checking if the attribute is present in the message * Don't use multipart RTM_GETLINK replies when searching for the specific interface names * Use ENODEV instead of ENOENT in case of failed RTM_GETLINK search * Add python netlink test helpers * Add some netlink interface tests Differential Revision: https://reviews.freebsd.org/D37668