aboutsummaryrefslogtreecommitdiff
path: root/tests/sys/net/routing
Commit message (Collapse)AuthorAgeFilesLines
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-232-2/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in main: (cherry picked from commit d0b2dbfa0ecf)
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-236-12/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit b3e7694832e8)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-256-6/+6
| | | | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* routing: fix panic when adding an interface route to the p2p interfaceAlexander V. Chernikov2023-04-081-0/+39
| | | | | | | | without and inet/inet6 addresses attached. MFC after: 3 days (cherry picked from commit badcb3fd5710a511e35ac3afd724ef68c77614b7)
* Update rtsock_l3 test after 2fe5a79425c79f7b828acd91da66d97230925fc8Alex Richardson2023-01-132-20/+27
| | | | | | | | | | | Two of these tests now pass. Looking at Jenkins to find the first commit where this behaviour changed indicates that 2fe5a79425c79f7b828acd91da66d97230925fc8 is the most likely cause. Reviewed By: melifaro Differential Revision: https://reviews.freebsd.org/D28886 (cherry picked from commit 67f2f67fc8ce8484066e95dabac5af892888fca1)
* tests: add routing tests for switching between same prefixesAlexander V. Chernikov2023-01-132-0/+82
| | | | | | | Differential Revision: https://reviews.freebsd.org/D36055 MFC after: 2 weeks (cherry picked from commit 7064c94a02af2f8665636a8594557b9e93ad71bf)
* routing: add multipath pytest testsAlexander V. Chernikov2023-01-132-0/+272
| | | | | | Differential Revision: https://reviews.freebsd.org/D31084 (cherry picked from commit bd03f10a6018a68cb1800f6db01b7552c39784bb)
* Improve debugging output on routing tests failure.Alexander V. Chernikov2021-04-261-1/+31
| | | | | | | | | | | | Most of the routing tests create per-test VNET, making it harder to repeat the failure with CLI tools. Provide an additional route/nexthop data on failure. Differential Revision: https://reviews.freebsd.org/D29957 Reviewed by: kp MFC after: 2 weeks (cherry picked from commit bddae5c8a64dc6b292198945cbe676bb2158d438)
* Fix typo in rtsock_common.hAlexander V. Chernikov2021-04-261-1/+1
| | | | | | MFC after: 3 days (cherry picked from commit 37c0f4a2077739e735732374d67525cf6de36d21)
* tests/sys/net/routing: XFAIL the two failing testsAlex Richardson2021-04-101-0/+6
| | | | | | | | | | | | | | They have been failing for 1.5 months and the patch to fix them is stuck in review so mark them as XFAIL for now to get Jenkins back to green. To be reverted when https://reviews.freebsd.org/D28886 (or similar) is commited. Reviewed By: kp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D29528 (cherry picked from commit 83532eb68cd06a3517bb7b5e5a34afcf798de914)
* Fix dst/netmask handling in routing socket code.Alexander V. Chernikov2021-03-101-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Traditionally routing socket code did almost zero checks on the input message except for the most basic size checks. This resulted in the unclear KPI boundary for the routing system code (`rtrequest*` and now `rib_action()`) w.r.t message validness. Multiple potential problems and nuances exists: * Host bits in RTAX_DST sockaddr. Existing applications do send prefixes with hostbits uncleared. Even `route(8)` does this, as they hope the kernel would do the job of fixing it. Code inside `rib_action()` needs to handle it on its own (see `rt_maskedcopy()` ugly hack). * There are multiple way of adding the host route: it can be DST without netmask or DST with /32(/128) netmask. Also, RTF_HOST has to be set correspondingly. Currently, these 2 options create 2 DIFFERENT routes in the kernel. * no sockaddr length/content checking for the "secondary" fields exists: nothing stops rtsock application to send sockaddr_in with length of 25 (instead of 16). Kernel will accept it, install to RIB as is and propagate to all rtsock consumers, potentially triggering bugs in their code. Same goes for sin_port, sin_zero, etc. The goal of this change is to make rtsock verify all sockaddr and prefix consistency. Said differently, `rib_action()` or internals should NOT require to change any of the sockaddrs supplied by `rt_addrinfo` structure due to incorrectness. To be more specific, this change implements the following: * sockaddr cleanup/validation check is added immediately after getting sockaddrs from rtm. * Per-family dst/netmask checks clears host bits in dst and zeros all dst/netmask "secondary" fields. * The same netmask checking code converts /32(/128) netmasks to "host" route case (NULL netmask, RTF_HOST), removing the dualism. * Instead of allowing ANY "known" sockaddr families (0<..<AF_MAX), allow only actually supported ones (inet, inet6, link). * Automatically convert `sockaddr_sdl` (AF_LINK) gateways to `sockaddr_sdl_short`. Reported by: Guy Yur <guyyur at gmail.com> Reviewed By: donner Differential Revision: https://reviews.freebsd.org/D28668 (cherry picked from commit 2fe5a79425c79f7b828acd91da66d97230925fc8)
* Split rtinit() into multiple functions.Alexander V. Chernikov2021-01-161-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rtinit[1]() is a function used to add or remove interface address prefix routes, similar to ifa_maintain_loopback_route(). It was intended to be family-agnostic. There is a problem with this approach in reality. 1) IPv6 code does not use it for the ifa routes. There is a separate layer, nd6_prelist_(), providing interface for maintaining interface routes. Its part, responsible for the actual route table interaction, mimics rtenty() code. 2) rtinit tries to combine multiple actions in the same function: constructing proper route attributes and handling iterations over multiple fibs, for the non-zero net.add_addr_allfibs use case. It notably increases the code complexity. 3) dstaddr handling. flags parameter re-uses RTF_ flags. As there is no special flag for p2p connections, host routes and p2p routes are handled in the same way. Additionally, mapping IFA flags to RTF flags makes the interface pretty messy. It make rtinit() to clash with ifa_mainain_loopback_route() for IPV4 interface aliases. 4) rtinit() is the last customer passing non-masked prefixes to rib_action(), complicating rib_action() implementation. 5) rtinit() coupled ifa announce/withdrawal notifications, producing "false positive" ifa messages in certain corner cases. To address all these points, the following has been done: * rtinit() has been split into multiple functions: - Route attribute construction were moved to the per-address-family functions, dealing with (2), (3) and (4). - funnction providing net.add_addr_allfibs handling and route rtsock notificaions is the new routing table inteface. - rtsock ifa notificaion has been moved out as well. resulting set of funcion are only responsible for the actual route notifications. Side effects: * /32 alias does not result in interface routes (/32 route and "host" route) * RTF_PINNED is now set for IPv6 prefixes corresponding to the interface addresses Differential revision: https://reviews.freebsd.org/D28186
* Fix route flags update during RTM_CHANGE.Alexander V. Chernikov2020-10-041-11/+111
| | | | | | | | | | | | | | | | | | | Nexthop lookup was not consireding rt_flags when doing structure comparison, which lead to an original nexthop selection when changing flags. Fix the case by adding rt_flags field into comparison and rearranging nhop_priv fields to allow for efficient matching. Fix `route change X/Y flags` case - recent changes disallowed specifying RTF_GATEWAY flag without actual gateway. It turns out, route(8) fills in RTF_GATEWAY by default, unless -interface flag is specified. Fix regression by clearing RTF_GATEWAY flag instead of failing. Fix route flag reporting in RTM_CHANGE messages by explicitly updating rtm_flags after operation competion. Add IPv4/IPv6 tests for flag-only route changes. Notes: svn path=/head/; revision=366424
* build: provide a default WARNS for all in-tree buildsKyle Evans2020-09-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The current default is provided in various Makefile.inc in some top-level directories and covers a good portion of the tree, but doesn't cover parts of the build a little deeper (e.g. libcasper). Provide a default in src.sys.mk and set WARNS to it in bsd.sys.mk if that variable is defined. This lets us relatively cleanly provide a default WARNS no matter where you're building in the src tree without breaking things outside of the tree. Crunchgen has been updated as a bootstrap tool to work on this change because it needs r365605 at a minimum to succeed. The cleanup necessary to successfully walk over this change on WITHOUT_CLEAN builds has been added. There is a supplemental project to this to list all of the warnings that are encountered when the environment has WARNS=6 NO_WERROR=yes: https://warns.kevans.dev -- this project will hopefully eventually go away in favor of CI doing a much better job than it. Reviewed by: emaste, brooks, ngie (all earlier version) Reviewed by: emaste, arichardson (depend-cleanup.sh change) Differential Revision: https://reviews.freebsd.org/D26455 Notes: svn path=/head/; revision=365887
* Add test for checking RTF_HOST and RTAX_NETMASK inconsistency.Alexander V. Chernikov2020-08-221-1/+25
| | | | | | | | | | | | RTF_HOST indicates whether route is a host route (netmask is empty or /{32,128}). Check that if netmask is empty and host route is not specified, kernel returns an error. Differential Revision: https://reviews.freebsd.org/D26155 Notes: svn path=/head/; revision=364489
* Use static inline for iface_{setup,delete}_addr in tests/sys/net/routing.Dimitry Andric2020-08-081-2/+2
| | | | | | | | | | | | | | | | | | | | | This fixes possible link errors, similar to: ld: error: undefined symbol: iface_setup_addr >>> referenced by test_rtsock_l3.c:111 (tests/sys/net/routing/test_rtsock_l3.c:111) >>> test_rtsock_l3.o:(presetup_ipv4) >>> referenced by test_rtsock_l3.c:79 (tests/sys/net/routing/test_rtsock_l3.c:79) >>> test_rtsock_l3.o:(presetup_ipv6) >>> referenced by test_rtsock_l3.c:512 (tests/sys/net/routing/test_rtsock_l3.c:512) >>> test_rtsock_l3.o:(atfu_rtm_change_v4_gw_success_body) >>> referenced 10 more times In C (not C++), 'naked' inline is almost always a mistake. Either use static inline (this is appropriate for most cases), or extern inline. MFC after: 3 days Notes: svn path=/head/; revision=364050
* Skip routing regression tests depending on if_epair if this module isn't ↵Olivier Cochard2020-04-173-30/+7
| | | | | | | | | | | installed. Approved by: melifaro Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D24468 Notes: svn path=/head/; revision=360045
* Add routing tests verifying basic RTM_CHANGE functionality.Alexander V. Chernikov2020-04-024-62/+350
| | | | | | | | MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D24239 Notes: svn path=/head/; revision=359579
* Switch rtsock tests to per-test jails and epair interfaces.Alexander V. Chernikov2020-03-297-23/+218
| | | | | | | | | | | | | | | Many rtsock tests verify the ordering of the kernel messages for the particular event. In order to avoid flaky tests due to the other tests running, switch all tests to use personal vnet-enabled jails. This removes all clashes on the IP addresses and brings back the ability to run these tests simultaneously. Reported by: olivier Reviewed by: olivier Differential Revision: https://reviews.freebsd.org/D24182 Notes: svn path=/head/; revision=359420
* Remove trailing whitespaceLi-Wen Hsu2020-02-163-7/+7
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357996
* * Fix flaking lle tests by filtering out non-relevant rtsock messages.Alexander V. Chernikov2020-02-121-77/+24
| | | | | | | | | | * Consistently use RTM_DECLARE_ROOT_TEST() macro. * Temporarily remove iftype validation from IPv6 lle notifications. Reported by: kp Notes: svn path=/head/; revision=357843
* tests: Routing tests overwrote net testsKristof Provost2020-01-251-1/+1
| | | | | | | | | | | The routing subdirectory installed into the same directory as the test tests, which caused them to overwrite the net Kyuafile. As a result these tests were not executed. X-MFC-With: r356146 Notes: svn path=/head/; revision=357113
* Bring back redirect route expiration.Alexander V. Chernikov2020-01-221-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Redirect (and temporal) route expiration was broken a while ago. This change brings route expiration back, with unified IPv4/IPv6 handling code. It introduces net.inet.icmp.redirtimeout sysctl, allowing to set an expiration time for redirected routes. It defaults to 10 minutes, analogues with net.inet6.icmp6.redirtimeout. Implementation uses separate file, route_temporal.c, as route.c is already bloated with tons of different functions. Internally, expiration is implemented as an per-rnh callout scheduled when route with non-zero rt_expire time is added or rt_expire is changed. It does not add any overhead when no temporal routes are present. Callout traverses entire routing tree under wlock, scheduling expired routes for deletion and calculating the next time it needs to be run. The rationale for such implemention is the following: typically workloads requiring large amount of routes have redirects turned off already, while the systems with small amount of routes will not inhibit large overhead during tree traversal. This changes also fixes netstat -rn display of route expiration time, which has been broken since the conversion from kread() to sysctl. Reviewed by: bz MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D23075 Notes: svn path=/head/; revision=356984
* Include human-readable list of rtm flags along with bitmask in error messagesAlexander V. Chernikov2020-01-102-3/+21
| | | | | | | | | for rtsock tests. MFC after: 2 weeks Notes: svn path=/head/; revision=356596
* Fix rtsock route message generation for interface addresses.Alexander V. Chernikov2020-01-073-26/+646
| | | | | | | | | Reviewed by: olivier MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D22974 Notes: svn path=/head/; revision=356473
* Add userland tests for route table/lltable rtsock operations.Alexander V. Chernikov2019-12-286-0/+2204
MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D22860 Notes: svn path=/head/; revision=356146