]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
19 months agoLinuxKPI: iwlwifi: rtw88: rtw89: remove budget argument from netif_napi_add()
Bjoern A. Zeeb [Mon, 28 Nov 2022 15:12:58 +0000 (15:12 +0000)]
LinuxKPI: iwlwifi: rtw88: rtw89: remove budget argument from netif_napi_add()

In preparation for future updates remove the budget argument from the
netif_napi_add() in drivers and update LinuxKPI to reflect that it is
gone and only set it internally.  This required changes to the currently
committed wireless drivers based on LinuxKPI (iwlwifi, rtw88, rtw89).

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 23c73dbae7b2f64014b275643efbe92f449feaa2)

19 months agoLinuxKPI: SKB update
Bjoern A. Zeeb [Mon, 28 Nov 2022 20:54:57 +0000 (20:54 +0000)]
LinuxKPI: SKB update

- skb_reset_tail_pointer(): we do not do offsets so do a plain reset
- skb_add_rx_frag(): adjust data_len to keep track of the frag
- based on that implement skb_is_nonlinear() and skb_linearize()
- implement build_skb() and adjust linuxkpi_kfree_skb() and ddb macro.

Sponsored by: The FreeBSD Foundation (partially)

(cherry picked from commit 5504bd59a39ba0bd0014308ff1aa5d4899432a3e)

19 months agolindebugfs,rtw88,rtw89: correct module dependencies
Bjoern A. Zeeb [Sun, 25 Sep 2022 21:36:10 +0000 (21:36 +0000)]
lindebugfs,rtw88,rtw89: correct module dependencies

In f697b9432d9c7aa4c5ab5f5445ef5dc1bd40ce00 the name of the PSEUDOFS
was changed from debugsfs to lindebugfs but the in-tree consumers
were not updated now leaving the drivers not loading if compiled
with debugfs support due to missing dependencies.

(cherry picked from commit 1a2b55732ff27fba2533724a72a39d33516c9417)

19 months agortw89: import firmware for Realtek's rtw89 supported chipsets.
Bjoern A. Zeeb [Fri, 9 Sep 2022 12:52:54 +0000 (12:52 +0000)]
rtw89: import firmware for Realtek's rtw89 supported chipsets.

Import the most recent versions of the firmware images for the
rtw89 driver.

This is based on linux-firmware at 2f2f0181581d3e35bfdb9fc65f609ee9d3fbaeb7.

The license of the firmware matches the previously added rtw88(4) firmware
and you can find a copy in sys/contrib/dev/rtw89fw/LICENCE.rtlwifi_firmware.txt.

Add build infrastructure to create the .ko files but do not yet hook
it up to the build until all parts are in the tree.

Approved by: core.11 (imp) [2022-03-27]

(cherry picked from commit 866e021654cfb72c050fd228dee476fb92fa6f48)

19 months agortw89: import Realtek's rtw89 driver
Bjoern A. Zeeb [Fri, 9 Sep 2022 12:41:07 +0000 (12:41 +0000)]
rtw89: import Realtek's rtw89 driver

Import rtw89 based on wireless-testing at (tag: wt-2022-09-02)
78667a29c116c6b186a37e28cd8dd7fa9923aee8 with adjustments for FreeBSD.

For the moment this will stay disconnected from the build until the
last bits are flushed out, but this will help people with a card to
do testing and possibly help improving.

Given the lack of full license texts on non-local files this is
imported under the draft policy for handling SPDX files (D29226). [1]

Approved by: core.11 (imp) [1] [2022-03-27]

(cherry picked from commit 8e93258f2686c76b4e3b384a904d8b4413976229)

19 months agodevice_get_property: add a HANDLE case
Bjoern A. Zeeb [Thu, 29 Sep 2022 12:41:58 +0000 (12:41 +0000)]
device_get_property: add a HANDLE case

This will resolve a reference and return the appropriate handle, a node
on the simplebus or an ACPI_HANDLE for ACPI.  For now we do not try to
further abstract the return type.

Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D36793

(cherry picked from commit 99e6980fcf5e12654c3e89b97b774de807d740a4)

19 months agoEnable taking snapshots on UFS/FFS filesystems using journaled soft updates.
Kirk McKusick [Sun, 13 Nov 2022 06:56:03 +0000 (22:56 -0800)]
Enable taking snapshots on UFS/FFS filesystems using journaled soft updates.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36491

(cherry picked from commit 78f41298760509f5c2b5865b2158c801d4023363)

19 months agodma: dma.conf.5 as MLINK to dma.8
Ed Maste [Wed, 4 Jan 2023 18:47:26 +0000 (13:47 -0500)]
dma: dma.conf.5 as MLINK to dma.8

There's no separate man page for dma.conf, but the format is documented
in dma.8.

Reviewed by: bapt
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37944

(cherry picked from commit 45396fda8b73146d3980797d48704184a5aa99ff)

19 months agoiwmbtfw(8): Fix a typo in a kernel message
Gordon Bergling [Wed, 11 Jan 2023 11:22:18 +0000 (12:22 +0100)]
iwmbtfw(8): Fix a typo in a kernel message

- s/succesful/successful/

(cherry picked from commit 40bb52c89b87c1417be5ded6808bd674d512900e)

19 months agoMFV: xz 5.4.0
Xin LI [Sun, 1 Jan 2023 04:25:17 +0000 (20:25 -0800)]
MFV: xz 5.4.0

(cherry picked from commit 73ed8e77a79398eb8e7b600a0b67f286e9e5cd53)

19 months agoFix vop_readdir's ncookies handling in UFS and EXT2.
Kirk McKusick [Mon, 2 Jan 2023 03:29:43 +0000 (19:29 -0800)]
Fix vop_readdir's ncookies handling in UFS and EXT2.

Submitted by: Kusumi Tomohiro
PR:           267706

(cherry picked from commit e84e44215fe19dad4d1779d5ee0b2f2d2739f016)

19 months agomrsas(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 09:48:14 +0000 (10:48 +0100)]
mrsas(4): Fix a typo in a source code comment

- s/reqest/request/

(cherry picked from commit e018483b10e7cf2cd852406648ccaf1f159ecb8d)

19 months agotcp_rack(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 11:02:25 +0000 (12:02 +0100)]
tcp_rack(4): Fix a typo in a source code comment

- s/postion/position/

(cherry picked from commit 432a398d86972f31bd66d3fad9bdd17acf5e8d7d)

19 months agoisci(4): Fix common typos in source code comments
Gordon Bergling [Wed, 11 Jan 2023 09:45:08 +0000 (10:45 +0100)]
isci(4): Fix common typos in source code comments

- s/reuqest/request/
- s/requst/request/

(cherry picked from commit be51810f8d68937ec4e2ce05e89938bda34d8364)

19 months agotty(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 11:12:48 +0000 (12:12 +0100)]
tty(4): Fix a typo in a source code comment

- s/charaters/characters/

(cherry picked from commit a74be23c6ed766dcb1bfeeea2f18c0d176e487c0)

19 months agolibthr(3): Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 10:48:14 +0000 (11:48 +0100)]
libthr(3): Fix a typo in a source code comment

- s/extentions/extensions/

(cherry picked from commit 085a77a677b1265407456eaaf440350af8e8fd15)

19 months agovr(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 09:51:34 +0000 (10:51 +0100)]
vr(4): Fix a typo in a source code comment

- s/reuqest/request/

(cherry picked from commit 70182a0cfb4bed3515cb7bcb2c5cde75bb61d069)

19 months agoice: Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 09:50:32 +0000 (10:50 +0100)]
ice: Fix a typo in a source code comment

- s/reqest/requests/

(cherry picked from commit b6f9c6aadc686cf5a890afe16e26a0082fa25c87)

19 months agoi386: Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 10:29:23 +0000 (11:29 +0100)]
i386: Fix a typo in a source code comment

- s/betwen/between/

(cherry picked from commit 77a863b6c217f3c143e1a8514a0fe409d5936c0f)

19 months agotcp_hpts: Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 10:33:29 +0000 (11:33 +0100)]
tcp_hpts: Fix a typo in a source code comment

- s/subract/subtract/

(cherry picked from commit d68f15420528e11f69a7bda365608581bfc34e64)

19 months agoahci(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 09:46:58 +0000 (10:46 +0100)]
ahci(4): Fix a typo in a source code comment

- s/reqests/requests/

(cherry picked from commit bc9228749c2ab31192a17ef01cfb363480144cdc)

19 months agocxgbe(4): Fix a few common typos in source code comments
Gordon Bergling [Wed, 11 Jan 2023 09:53:07 +0000 (10:53 +0100)]
cxgbe(4): Fix a few common typos in source code comments

- s/Reqests/Requests/

(cherry picked from commit f273b4561386b8df7d4ea7b7b176bf9df298e1d7)

19 months agomvs(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 09:49:22 +0000 (10:49 +0100)]
mvs(4): Fix a typo in a source code comment

- s/reqests/requests/

(cherry picked from commit f272a059a40aee4eda44294bc5dfdf0bd7e5c02d)

19 months agolibiscsiutil: Fix a typo in a source code comment
Gordon Bergling [Wed, 11 Jan 2023 10:52:55 +0000 (11:52 +0100)]
libiscsiutil: Fix a typo in a source code comment

- s/sesion/session/

(cherry picked from commit 29b36af9981e7f194abe68b0359448846c021cd6)

19 months agorouting: unbreak the build of a bunch of kernels
Mateusz Guzik [Thu, 11 Aug 2022 21:50:37 +0000 (21:50 +0000)]
routing: unbreak the build of a bunch of kernels

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit f73e4f6c5817bf6bbf8b34c656b7a7acf6c87e47)

19 months agoUpdate rtsock_l3 test after 2fe5a79425c79f7b828acd91da66d97230925fc8
Alex Richardson [Wed, 21 Apr 2021 09:58:34 +0000 (10:58 +0100)]
Update rtsock_l3 test after 2fe5a79425c79f7b828acd91da66d97230925fc8

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)

19 months agorouting: add missed RIB_WUNLOCK in the add_route_flags().
Alexander V. Chernikov [Fri, 30 Dec 2022 15:54:06 +0000 (15:54 +0000)]
routing: add missed RIB_WUNLOCK in the add_route_flags().

MFC after: 2 weeks

(cherry picked from commit 06e879593a445dd785d531a06fb19ab68076985b)

19 months agoroute: allow RTM_CHANGE notifications in rt_routemsg().
Alexander V. Chernikov [Thu, 15 Dec 2022 10:39:06 +0000 (10:39 +0000)]
route: allow RTM_CHANGE notifications in rt_routemsg().

MFC after: 2 weeks

(cherry picked from commit 3636a967f310e3380ff7d8d63728ca9e7a5b6ce2)

19 months agorouting: provide dedicated function for nhgrp creation and linking.
Alexander V. Chernikov [Fri, 2 Dec 2022 17:58:03 +0000 (17:58 +0000)]
routing: provide dedicated function for nhgrp creation and linking.

There is a need to store client metadata in nexthops and nexthop groups.
This metadata is immutable and participate in nhop/nhg comparison.

Nexthops KPI already supports its: nexthop creation pattern is
```
nhop_alloc()
nhop_set_...()
...
nhop_get_nhop()
```

This change provides a similar pattern for the nexthop groups.
Specifically, it adds nhgrp_alloc(), nhgrp_get_nhgrp() and
nhgrp_set_uidx().

MFC after: 2 weeks

(cherry picked from commit 42f8123a4fa8354f07e3ebce1d3b6c2def7db5a3)

19 months agonetinet: pass cred instead of the curthread to ifaddr manipulation funcs.
Alexander V. Chernikov [Mon, 26 Sep 2022 12:07:18 +0000 (12:07 +0000)]
netinet: pass cred instead of the curthread to ifaddr manipulation funcs.

Pass the credentials directly to the functions, so non-ioctl kernel
 users can also performan address manipulations.

MFC after: 2 weeks

(cherry picked from commit f375bf0e6f0bc6bce3e5b3c6adabc465be2665d0)

19 months agorouting: constantify nh/nhg argument in <nhop|nhgrp>_get_origin().
Alexander V. Chernikov [Thu, 8 Sep 2022 10:21:25 +0000 (10:21 +0000)]
routing: constantify nh/nhg argument in <nhop|nhgrp>_get_origin().

MFC after: 1 month

(cherry picked from commit e7624170772d28c89e841b817634666bbc658ffd)

19 months agorouting: add abitity to set the protocol that installed route/nexthop.
Alexander V. Chernikov [Thu, 8 Sep 2022 09:05:53 +0000 (09:05 +0000)]
routing: add abitity to set the protocol that installed route/nexthop.

Routing daemons such as bird need to know if they install certain route
 so they can clean it up on startup, as a form of achieving consistent
 state during the crash recovery.
Currently they use combination of routing flags (RTF_PROTO1) to detect
 these routes when interacting via route(4) rtsock protocol.
Netlink protocol has a special "rtm_protocol" field that is filled and
 checked by the route originator. To prepare for the upcoming netlink
 introduction, add ability to record origing to both nexthops and
 nexthop groups via <nhop|nhgrp>_<get|set>_origin() KPI. The actual
 calls will be used in the followup commits.

MFC after: 1 month

(cherry picked from commit 000250be0d2dc7a241f1c9b9c27d941af781ca46)

19 months agonetinet6: call lle_event eventhandler after updating state
Alexander V. Chernikov [Mon, 5 Sep 2022 12:57:20 +0000 (12:57 +0000)]
netinet6: call lle_event eventhandler after updating state

Fix nd6_na_input() eventhandler call: run eventhandler after lle
 state transition.

Old behaviour (as seen by event handler):
 * fe80::5054:ff:fe8c:63e9 dev vtnet0 lladdr 52:54:00:8c:63:e9 INCOMPLETE
New behaviour:
* fe80::5054:ff:fe8c:63e9 dev vtnet0 lladdr 52:54:00:8c:63:e9 REACHABLE

MFC after: 2 weeks

(cherry picked from commit db98b4205093a6ee201ce0b8d83c77d5b730d7cb)

19 months agorouting: allow logging framework to be used outside of the subsystem
Alexander V. Chernikov [Mon, 5 Sep 2022 10:44:27 +0000 (10:44 +0000)]
routing: allow logging framework to be used outside of the subsystem

MFC after: 2 weeks

(cherry picked from commit 4bccbf03d81b2bafb93c1674eaa2f70e7226a25a)

19 months agorouting: constantify @rc in rib_decompose_notification().
Alexander V. Chernikov [Mon, 29 Aug 2022 18:10:21 +0000 (18:10 +0000)]
routing: constantify @rc in rib_decompose_notification().

Clarify the @rc immutability by explicitly marking @rc const.

MFC after: 2 weeks

(cherry picked from commit 177f04d57fbdb1c18ed845e19cc9b902c8b65312)

19 months agorouting: improve multiline debug
Alexander V. Chernikov [Mon, 29 Aug 2022 15:14:49 +0000 (15:14 +0000)]
routing: improve multiline debug

Add IF_DEBUG_LEVEL() macro to ensure all debug output preparation
 is run only if the current debug level is sufficient. Consistently
 use it within routing subsystem.

MFC after: 2 weeks

(cherry picked from commit 578a99c939b6f7a774f399fc7b64ee956c4ae200)

19 months agorouting: extend nhop(9) kpi
Alexander V. Chernikov [Mon, 29 Aug 2022 14:38:25 +0000 (14:38 +0000)]
routing: extend nhop(9) kpi

* add nhop_get_unlinked() used to prepare referenced but not
 linked nexthop, that can later be used as a clone source.
* add nhop_check_gateway() to check for allowed address family
  combinations between the rib family and neighbor family (useful
  for 4o6 or direct routes)
* add nhop_set_upper_family() to allow copying IPv6 nexthops to
 IPv4 rib.
* add rt_get_rnd() wrapper, returning both nexthop/group and its
 weight attached to the rtentry.
* Add CHT_SLIST_FOREACH_SAFE(), allowing to delete items during
  iteration.

MFC after: 2 weeks

(cherry picked from commit fe05d1dd0fdf7c8d09b9aad4ff74c44b7c90db80)

19 months agorouting: fix rib_add_route_px()
Alexander V. Chernikov [Mon, 29 Aug 2022 12:23:06 +0000 (12:23 +0000)]
routing: fix rib_add_route_px()

Fix panic in newly-added rib_add_route_px() by removin unlocked
 prefix lookup.

MFC after: 2 weeks

(cherry picked from commit c24a8f19c5d554b828908e7dacf1855cd4ee21f3)

19 months agorouting: add ability to store opaque indentifiers in nhops/nhgs
Alexander V. Chernikov [Mon, 29 Aug 2022 12:20:24 +0000 (12:20 +0000)]
routing: add ability to store opaque indentifiers in nhops/nhgs

This is a pre-requisite for the direct nexthop/nexhop group operations
 via netlink.

MFC after: 2 weeks

(cherry picked from commit db4ca19002c05d0bf83e85a5402005c9162aeee9)

19 months agorouting: make rib_add_redirect() use new nhop-based KPI
Alexander V. Chernikov [Tue, 9 Aug 2022 11:45:59 +0000 (11:45 +0000)]
routing: make rib_add_redirect() use new nhop-based KPI

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D36169

(cherry picked from commit 6d4f6e4c704d17084144ac3fe0c8507015f1357f)

19 months agorouting: add rib_add_default_route() wrapper
Alexander V. Chernikov [Tue, 9 Aug 2022 13:34:28 +0000 (13:34 +0000)]
routing: add rib_add_default_route() wrapper

Multiple consumers in the kernel space want to install IPv4 or IPv6
 default route. Provide convenient wrapper to simplify the code
 inside the customers.

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D36167

(cherry picked from commit d8b2693414ae5cebdbd4c64c9559275c4baff11e)

19 months agonetlink: add AF_NETLINK / PF_NETLINK definitions
Alexander V. Chernikov [Fri, 12 Aug 2022 13:45:49 +0000 (13:45 +0000)]
netlink: add AF_NETLINK / PF_NETLINK definitions

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D36174
MFC after: 1 weeks

(cherry picked from commit a4b8c6d9d50ec03f490587854ec82c9790193f46)

19 months agonetinet6: simplify defrouter_select_fib()
Alexander V. Chernikov [Fri, 12 Aug 2022 11:43:14 +0000 (11:43 +0000)]
netinet6: simplify defrouter_select_fib()

* factor out underlying llentry check into a separate function and use it consistently
* enter epoch once instead of per-router enter/exit
* don't execute body with fibnum = `RT_ALL_FIBS`

Differential Revision: https://reviews.freebsd.org/D35523
MFC after: 2 weeks

(cherry picked from commit 9d16275c65bfe0f577e6f97397e024a33169acc9)

19 months agortsock: subscribe to ifnet eventhandlers instead of direct calls.
Alexander V. Chernikov [Thu, 11 Aug 2022 20:09:45 +0000 (20:09 +0000)]
rtsock: subscribe to ifnet eventhandlers instead of direct calls.

Stop treating rtsock as a "special" consumer and use already-provided
 ifaddr arrival/departure notifications.

MFC after: 2 weeks

Test Plan:
```
21:05 [0] m@devel0 route -n monitor

-> ifconfig vtnet0.2 create

got message of size 24 on Tue Aug  9 21:05:44 2022
RTM_IFANNOUNCE: interface arrival/departure: len 24, if# 3, what: arrival

got message of size 168 on Tue Aug  9 21:05:54 2022
RTM_IFINFO: iface status change: len 168, if# 3, link: up, flags:<BROADCAST,RUNNING,SIMPLEX,MULTICAST>

-> ifconfig vtnet0.2 destroy

got message of size 24 on Tue Aug  9 21:05:54 2022
RTM_IFANNOUNCE: interface arrival/departure: len 24, if# 3, what: departure

```

Reviewed By: glebius
Differential Revision: https://reviews.freebsd.org/D36095
MFC after: 2 weeks

(cherry picked from commit d8b42ddcac5cb86af679968d09c45c9a7cc3e4fb)

19 months agonetinet6: allow ND entries creation for all directly-reachable
Alexander V. Chernikov [Wed, 10 Aug 2022 11:51:58 +0000 (11:51 +0000)]
netinet6: allow ND entries creation for all directly-reachable
destinations.

The current assumption is that kernel-handled rtadv prefixes along with
 the interface address prefixes are the only prefixes considered in
 the ND neighbor eligibility code.
Change this by allowing any non-gatewaye routes to be eligible. This
 will allow DHCPv6-controlled routes to be correctly handled by
 the ND code.
Refactor nd6_is_new_addr_neighbor() to enable more deterministic
 performance in "found" case and remove non-needed
 V_rt_add_addr_allfibs handling logic.

Reviewed By: kbowling
Differential Revision: https://reviews.freebsd.org/D23695
MFC after: 1 month

(cherry picked from commit f998535a66b986f51dd65b5153d1a580d50ddfbe)

19 months agotests: add routing tests for switching between same prefixes
Alexander V. Chernikov [Sat, 6 Aug 2022 10:36:12 +0000 (10:36 +0000)]
tests: add routing tests for switching between same prefixes

Differential Revision: https://reviews.freebsd.org/D36055
MFC after: 2 weeks

(cherry picked from commit 7064c94a02af2f8665636a8594557b9e93ad71bf)

19 months agonet: constantify radix.c functions
Alexander V. Chernikov [Thu, 28 Jul 2022 13:04:43 +0000 (13:04 +0000)]
net: constantify radix.c functions

Mark dst/mask public API functions fields as const to clearly
 indicate that these parameters are not modified or stored in
 the datastructure.

Differential Revision: https://reviews.freebsd.org/D35971
MFC after: 2 weeks

(cherry picked from commit 97ffaff85968d09f2319156cb0ef56743667db6e)

19 months agondp(8): add structured output formatting via libxo
Alexander V. Chernikov [Mon, 4 Jul 2022 08:05:58 +0000 (08:05 +0000)]
ndp(8): add structured output formatting via libxo

Differential Revision: https://reviews.freebsd.org/D35677
MFC after: 2 weeks

(cherry picked from commit e1c7783e220b6120ddc116ff2e09f228d8475bfd)

19 months agonetinet6: simplify selectroute()
Alexander V. Chernikov [Mon, 4 Jul 2022 18:05:38 +0000 (18:05 +0000)]
netinet6: simplify selectroute()

Effectively selectroute() addresses two different cases:
 providing interface info for multicast destinations and providing
 nexthop data for unicast ones. Current implementation intertwines
 handling of both cases, especially in the error handling part.
Factor out all route lookup logic in a separate function,
 lookup_route() to simplify the code.
Ensure consistent KPI: no error means *retifp is set and otherwise.

Differential Revision: https://reviews.freebsd.org/D35711
MFC after: 2 weeks

(cherry picked from commit 2756774c3f537bc566362ef424d992092fb6fc87)

19 months agonetinet6: factor out cached route lookups from selectroute().
Alexander V. Chernikov [Mon, 4 Jul 2022 15:56:56 +0000 (15:56 +0000)]
netinet6: factor out cached route lookups from selectroute().

Currently selectroute() contains two nearly-identical versions of
 the route lookup logic - one for original destination and another
for the case when IPV6_NEXTHOP option was set on the socket.

Factor out handling these route lookups in a separation function to
 improve readability.
This change also fixes handling of link-local IPV6_NEXTHOPs.

Differential Revision: https://reviews.freebsd.org/D35710
MFC after: 2 weeks

(cherry picked from commit 81a235ecde893a666e3cfac503068d9ea1bb013c)

19 months agonetinet6: add ip6_output() scope tests
Alexander V. Chernikov [Thu, 7 Jul 2022 13:08:35 +0000 (13:08 +0000)]
netinet6: add ip6_output() scope tests

Differential Revision: https://reviews.freebsd.org/D35742

(cherry picked from commit 78d11a350853188921b84c83e32d14c8a6aa16fa)

19 months agonetinet6: add ip6_output() tests.
Alexander V. Chernikov [Thu, 7 Jul 2022 10:09:28 +0000 (10:09 +0000)]
netinet6: add ip6_output() tests.

Differential Revision: https://reviews.freebsd.org/D35708

(cherry picked from commit ce414d02c1a0b4a3a68da99348b9962700742d44)

19 months agotesting: add ability to specify multi-vnet topologies in the pytest framework.
Alexander V. Chernikov [Thu, 7 Jul 2022 10:05:06 +0000 (10:05 +0000)]
testing: add ability to specify multi-vnet topologies in the pytest framework.

Notable amount of tests related to the packet IO require two VNET jails
 for proper testing and avoiding side effects for the host system.
Additionally, it is often required to run actions in the jails seme-sequentially
- waiting for the listener initialisation can be an example of such
  dependency.

This change extends pytest vnet framework to allow defining multi-vnet
 multi-epair topologies in declarative style, without any need to bother
 about jail or repair names. All jail creation/teardown, interface
 creation/teardown and address assignments are handled automatically.

Example:

TOPOLOGY = {
  "vnet1": {"ifaces": ["if1", "if2", "if3"]},
  "vnet2": {"ifaces": ["if1", "if2", "if3"]},
  "if1": {"prefixes6": [("2001:db8:a::1/64", "2001:db8:a::2/64")]},
  "if2": {"prefixes6": [("2001:db8:b::1/64", "2001:db8:b::2/64")]},
  "if3": {"prefixes6": [("2001:db8:c::1/64", "2001:db8:c::2/64")]},
}
def vnet2_handler(self, vnet, obj_map, pipe):
  ss = VerboseSocketServer("::", self.DEFAULT_PORT)
  pipe.send("READY")

def test_output6_base(self):
  self.wait_object(second_vnet.pipe)

The definitions above will create 2 vnets ("jail_test_output6_base",
 "jail_test_output6_base_2"), 3 epairs, attached to both first and
 second jails, set up the IP addresses for each epair, spawn another
 process for vnet2_handler and pass control to vnet2_handler and
 test_output6_base. Both processes can pass objects between each
 other using pre-created pipes.

Differential Revision: https://reviews.freebsd.org/D35708

(cherry picked from commit cfc9cf9baf474618daad9f5d5f7c74e66acafbd3)

19 months agotesting: provide meaningful error when pytest is not available
Alexander V. Chernikov [Wed, 6 Jul 2022 19:55:48 +0000 (19:55 +0000)]
testing: provide meaningful error when pytest is not available

atf format does not provide any way of signalling any error message
 back to the atf runner when listing tests. Work this around by
 reporting "__test_cases_list_pytest_binary_not_found__" test instead.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D35721

(cherry picked from commit 2bfd8b5b9419b0ceb3dd0295fdf413d32969e5b2)

19 months agotesting: pass ATF vars to pytest via env instead of arguments.
Alexander V. Chernikov [Tue, 28 Jun 2022 10:49:41 +0000 (10:49 +0000)]
testing: pass ATF vars to pytest via env instead of arguments.

This change is a continuation of 9c42645a1e4d workaround.
Apparently pytest argument parser is not happy when parsing values
 with spaces or just more than one --atf-var argument.
Switch wrapper to send these kv pairs as env variables. Specifically,
 use _ATF_VAR_key=value format to distinguish from the other vars.

Add the `atf_vars` fixture returning all passed kv pairs as a dict.

Reviewed by: lwhsu
Differential Revision: https://reviews.freebsd.org/D35625
MFC after: 2 weeks

(cherry picked from commit 513ce835b55831d343185e03a51efa2901405ac8)

19 months agotesting: workaround pytest parser bug in pytest-atf-wrapper.
Alexander V. Chernikov [Mon, 27 Jun 2022 15:52:25 +0000 (15:52 +0000)]
testing: workaround pytest parser bug in pytest-atf-wrapper.

Reviewed by: lwhsu, kp
Differential Revision: https://reviews.freebsd.org/D35614
MFC after: 2 weeks

(cherry picked from commit 9c42645a1e4d6695730187aef0f1494394503624)

19 months agotesting: move atf-pytest-wrapper to /usr/libexec
Alexander V. Chernikov [Sun, 26 Jun 2022 11:46:37 +0000 (11:46 +0000)]
testing: move atf-pytest-wrapper to /usr/libexec

Move pytest wrapper to the collection of the other atf wrappers
 in libexec. It solves the problem of combining bits & pieces from
 bsd.test.mk and bgs.prog.mk to address "test binary, but not the
 suite binary".

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D35604
MFC after: 2 weeks

(cherry picked from commit 924226fba12cc9a228c73b956e1b7fa24c60b055)

19 months agorouting: fix debug headers added in 6fa8ed43ee0c #2.
Alexander V. Chernikov [Sun, 26 Jun 2022 07:26:53 +0000 (07:26 +0000)]
routing: fix debug headers added in 6fa8ed43ee0c #2.

Move debug declaration out of COMPAT_FREEBSD32 in rtsock.c

MFC after: 2 weeks

(cherry picked from commit 33a0803f000fc52a50465a65d3e8b64168557ecf)

19 months agorouting: fix debug headers added in 6fa8ed43ee0c.
Alexander V. Chernikov [Sat, 25 Jun 2022 23:05:25 +0000 (23:05 +0000)]
routing: fix debug headers added in 6fa8ed43ee0c.

- move debug headers out of COMPAT_FREEBSD32 in rtsock.c
- remove accidentally-added LOG_ defines from syslog.h

MFC after: 2 weeks

(cherry picked from commit 0e87bab6b44b6cc12d25fd46954ee10121ee38fc)

19 months agorouting: fix syslog include for rtsock.c
Alexander V. Chernikov [Sat, 25 Jun 2022 22:08:10 +0000 (22:08 +0000)]
routing: fix syslog include for rtsock.c

MFC after: 2 weeks

(cherry picked from commit 76179e400a035e3981a30908997430713a90903c)

19 months agorouting: add tests/sys/net/routing to mtree
Alexander V. Chernikov [Sat, 25 Jun 2022 21:13:48 +0000 (21:13 +0000)]
routing: add tests/sys/net/routing to mtree

MFC after: 2 weeks

(cherry picked from commit 9a75209d2bdcdc040a865c48d555f95740568373)

19 months agorouting: fix crash when RTM_CHANGE results in no-op for the multipath
Alexander V. Chernikov [Sat, 25 Jun 2022 19:32:59 +0000 (19:32 +0000)]
routing: fix crash when RTM_CHANGE results in no-op for the multipath
route.

Reporting logic assumed there is always some nhop change for every
 successful modification operation. Explicitly check that the changed
 nexthop indeed exists when reporting back to userland.

MFC after: 2 weeks
Reported by: Claudio Jeker <claudio.jeker@klarasystems.com>
Tested by: Claudio Jeker <claudio.jeker@klarasystems.com>

(cherry picked from commit c260d5cd8e364ad448ba714d9f851976c6f8da51)

19 months agorouting: add multipath pytest tests
Alexander V. Chernikov [Sat, 25 Jun 2022 19:25:38 +0000 (19:25 +0000)]
routing: add multipath pytest tests

Differential Revision: https://reviews.freebsd.org/D31084

(cherry picked from commit bd03f10a6018a68cb1800f6db01b7552c39784bb)

19 months agotesting: Add basic atf support to pytest.
Alexander V. Chernikov [Sat, 25 Jun 2022 19:01:45 +0000 (19:01 +0000)]
testing: Add basic atf support to pytest.

Implementation consists of the pytest plugin implementing ATF format and
a simple C++ wrapper, which reorders the provided arguments from ATF format
to the format understandable by pytest. Each test has this wrapper specified
after the shebang. When kyua executes the test, wrapper calls pytest, which
loads atf plugin, does the work and returns the result. Additionally, a
separate python "package", `/usr/tests/atf_python` has been added to collect
code that may be useful across different tests.

Current limitations:
* Opaque metadata passing via X-Name properties. Require some fixtures to write
* `-s srcdir` parameter passed by the runner is ignored.
* No `atf-c-api(3)` or similar - relying on pytest framework & existing python libraries
* No support for `atf_tc_<get|has>_config_var()` & `atf_tc_set_md_var()`.
 Can be probably implemented with env variables & autoload fixtures

Differential Revision: https://reviews.freebsd.org/D31084
Reviewed by: kp, ngie

(cherry picked from commit 8eb2bee6c0f4957c6c1cea826e59cda4d18a2a64)

19 months agonetinet6: perform out-of-bounds check for loX multicast statistics
Alexander V. Chernikov [Mon, 4 Jul 2022 20:03:06 +0000 (20:03 +0000)]
netinet6: perform out-of-bounds check for loX multicast statistics

Currently, some per-mbuf multicast statistics is stored in
 the per-interface ip6stat.ip6s_m2m[] array of size 32 (IP6S_M2MMAX).
Check that loopback ifindex falls within 0.. IP6S_M2MMAX-1 range to
 avoid silent data corruption. The latter cat happen with large
 number of VNETs.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D35715
MFC after: 2 weeks

(cherry picked from commit 0ed72537857bfb6ac6d19b0852a52288db79b8b0)

19 months agonetinet6: fix SIOCSPFXFLUSH_IN6 by skipping manually-configured prefixes
Alexander V. Chernikov [Tue, 23 Aug 2022 16:19:50 +0000 (16:19 +0000)]
netinet6: fix SIOCSPFXFLUSH_IN6 by skipping manually-configured prefixes

Summary:
Currently netinet6/ code allocates IPv6 prefixes (nd_prefix) for
 both manually-assigned addresses and advertised prefixes. As a result,
 prefixes from manually-assigned prefixes can be seen in `ndp -p` list
 and be cleared via `ndp -P`. The latter relies on the SIOCSPFXFLUSH_IN6
 ioctl to clear to prefix list.
The original intent of the SIOCSPFXFLUSH_IN6 was to clear prefixes
 originated from the advertising routers:

```
1998-09-02  JINMEI, Tatuya  <jinmei@isl.rdc.toshiba.co.jp>
* nd6.c (nd6_ioctl): added 2 new ioctls; SIOCSRTRFLUSH_IN6 and
SIOCSPFXFLUSH_IN6. The former is to flush all default routers
in the default router list, and the latter is to flush all the
prefixes and the addresses derived from them in the prefix list.
```

Restore the intent by marking prefixes derived from the RA messages
with newly-added ndpr_flags.ra_derived flag and skip prefixes not marked
 with such flag during deletion and listing.

Differential Revision: https://reviews.freebsd.org/D36312
MFC after: 2 weeks

(cherry picked from commit 8036234c72c9361711e867cc1a0c6a7fe0babd84)

19 months agorouting: install prefix and loopback routes using new nhop-based KPI.
Alexander V. Chernikov [Mon, 8 Aug 2022 19:24:26 +0000 (19:24 +0000)]
routing: install prefix and loopback routes using new nhop-based KPI.

Construct the desired hexthops directly instead of using the
 "translation" layer in form of filling rt_addrinfo data.
Simplify V_rt_add_addr_allfibs handling by using recently-added
 rib_copy_route() to propagate the routes to the non-primary address
 fibs.

Differential Revision: https://reviews.freebsd.org/D36166

(cherry picked from commit a1b59379db7d879551118b921f6e9692b4bf200c)

19 months agorouting: fix panic for p2p interfaces after 800c68469ba6.
Alexander V. Chernikov [Wed, 3 Aug 2022 08:21:08 +0000 (08:21 +0000)]
routing: fix panic for p2p interfaces after 800c68469ba6.

Reported by: cy
MFC after: 1 month

(cherry picked from commit 08bb0873ca88be777e1fc8dd9d374e4da938be65)

19 months agorouting: add rib_match_gw() helper
Alexander V. Chernikov [Fri, 12 Aug 2022 09:31:21 +0000 (09:31 +0000)]
routing: add rib_match_gw() helper

Finish 02e05b8faec1:
* add gateway matcher function that can be used in rib_del_route_px()
 or any rib_walk-family functions. It will be used in the upcoming
 migration to the new KPI
* rename gw_fulter_func to match_gw_one() to better signal the
 function purpose / semantic.

MFC after: 1 month

(cherry picked from commit 730bfa28057405b44a0b55a4dc35cdc42144ff6d)

19 months agorouting: fix non-debug build
Mateusz Guzik [Thu, 11 Aug 2022 14:12:59 +0000 (14:12 +0000)]
routing: fix non-debug build

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 69077c81e5949b8107b74b220dc0fbd20a84faf4)

19 months agorouting: populate fibs with interface routes after growing net.fibs.
Alexander V. Chernikov [Sun, 7 Aug 2022 20:26:19 +0000 (20:26 +0000)]
routing: populate fibs with interface routes after growing net.fibs.

Currently it is possible to extend number of fibs in runtime, but this
 functionality is of limited use when net.add_addrs_all_fibs is
 non-zero, as the routing tables are created empty.

This change automatically populate newly-created fibs with the kernel-originated
 interface routes (filtered by RTF_PINNED flag) if net.add_addrs_all_fibs
 is set.

```
-> sysctl net.add_addr_allfibs=1
net.add_addr_allfibs: 0 -> 1
-> sysctl net.fibs
net.fibs: 2
-> sysctl net.fibs=3
net.fibs: 2 -> 3

BEFORE:
-> setfib 2 netstat -rn
Routing tables (fib: 2)

AFTER:
-> setfib 2 netstat -rn
Routing tables (fib: 2)

Internet:
Destination        Gateway            Flags     Netif Expire
10.0.0.0/24        link#1             U        vtnet0
10.0.0.5           link#1             UHS         lo0
127.0.0.1          link#2             UH          lo0

Internet6:
Destination                       Gateway                       Flags     Netif Expire
::1                               link#2                        UHS         lo0
2a01:4f9:3a:fa00::/64             link#1                        U        vtnet0
2a01:4f9:3a:fa00:5054:ff:fe15:4a3b link#1                       UHS         lo0
fe80::%vtnet0/64                  link#1                        U        vtnet0
fe80::5054:ff:fe15:4a3b%vtnet0    link#1                        UHS         lo0
fe80::%lo0/64                     link#2                        U           lo0
fe80::1%lo0                       link#2                        UHS         lo0
```

Differential Revision: https://reviews.freebsd.org/D36075
MFC after: 1 month

(cherry picked from commit 40503b792f7ecb9fcb349b2519036f85fa62fb4c)

19 months agorouting: fixup empty mask prefix handling after 2ce553854cbd.
Alexander V. Chernikov [Thu, 11 Aug 2022 11:41:42 +0000 (11:41 +0000)]
routing: fixup empty mask prefix handling after 2ce553854cbd.

MFC after: 1 month

(cherry picked from commit 02e05b8faec1ea79d3fa2deee7fb55f1bdddfbc1)

19 months agorouting: fix build warning without ROUTE_MPATH
Alexander V. Chernikov [Thu, 11 Aug 2022 09:46:28 +0000 (09:46 +0000)]
routing: fix build warning without ROUTE_MPATH

Reported by: Gary Jennejohn <garyj@gmx.de>
MFC after: 1 month

(cherry picked from commit 258828d03b9f8414043c112fab97e9e9730560dc)

19 months agorouting: fix build without ROUTE_MPATH
Alexander V. Chernikov [Wed, 10 Aug 2022 20:44:43 +0000 (20:44 +0000)]
routing: fix build without ROUTE_MPATH

MFC after: 1 month

(cherry picked from commit 685866bbe13da2b9c5d108036c29f07a4c7cd04f)

19 months agorouting: move rtentry and subscription code out of route_ctl.c
Alexander V. Chernikov [Mon, 8 Aug 2022 13:54:17 +0000 (13:54 +0000)]
routing: move rtentry and subscription code out of route_ctl.c

route_ctl.c size has grown considerably since initial introduction.
Factor out non-relevant parts:
* all rtentry logic, such as creation/destruction and accessors
 goes to net/route/route_rtentry.c
* all rtable subscription logic goes to net/route/route_subscription.c

Differential Revision: https://reviews.freebsd.org/D36074
MFC after: 1 month

(cherry picked from commit 5c4d2252d771ae226a7174b6bad279ffb2599798)

19 months agorouting: add rib_<add|del>_route_px() functions operating with nexthops.
Alexander V. Chernikov [Thu, 4 Aug 2022 14:55:30 +0000 (14:55 +0000)]
routing: add rib_<add|del>_route_px() functions operating with nexthops.

This change adds public KPI to work with routes using pre-created
 nexthops, instead of using data from addrinfo structures. These
 functions will be later used for adding/deleting kernel-originated
 routes and upcoming netlink protocol.

As a part of providing this KPI, low-level route addition code has been
 reworked to provide more control over route creation or change.
 Specifically, a number of operation flags
 (RTM_F_<CREATE|EXCL|REPLACE|APPEND>) have been added, defining the
 desired behaviour the the route already exists (or not exists). This
 change required some changes in the multipath addition code, resulting
 in moving this code to route_ctl.c, rendering mpath_ctl.c empty.

Differential Revision: https://reviews.freebsd.org/D36073
MFC after: 1 month

(cherry picked from commit 2ce553854cbd04595d99e1cfbc9c12a87dde7906)

19 months agorouting: split nexthop creation and rtentry creation.
Alexander V. Chernikov [Thu, 4 Aug 2022 12:35:31 +0000 (12:35 +0000)]
routing: split nexthop creation and rtentry creation.

This change is required for the upcoming introduction of the next
 nexhop-based operations KPI, as it will create rtentry and nexthops
 at different stages of route table modification.

Differential Revision: https://reviews.freebsd.org/D36072
MFC after: 2 weeks

(cherry picked from commit 66230639ce311c9fbc3a92e7039b8577a7577b6e)

19 months agorouting: refactor #2
Alexander V. Chernikov [Wed, 3 Aug 2022 08:20:40 +0000 (08:20 +0000)]
routing: refactor #2

* Use same filter func (rib_filter_f_t) for nexhtop groups to
 simplify callbacks.
* simplify conditional route deletion & remove the need to pass
 rt_addrinfo to the low-level deletion functions
* speedup rib_walk_del() by removing an additional per-prefix lookup

Differential Revision: https://reviews.freebsd.org/D36071
MFC after: 1 month

(cherry picked from commit dedeec1143385b0c7436d360170d8d99b2d0fa18)

19 months agorouting: refactor control cmds #1
Alexander V. Chernikov [Tue, 2 Aug 2022 12:44:20 +0000 (12:44 +0000)]
routing: refactor control cmds #1

This and the follow-up routing-related changes target to remove or
 reduce `struct rt_addrinfo` usage and use recently-landed nhop(9)
 KPI instead.
Traditionally `rt_addrinfo` structure has been used to propagate all necessary
information between the protocol/rtsock and a routing layer. Many
functions inside routing subsystem uses it internally. However, using
this structure became somewhat complicated, as there are too many ways
of specifying a single state and verifying data consistency is hard.
For example, arerouting flgs consistent with mask/gateway sockaddr pointers?
Is mask really a host mask? Are sockaddr "valid" (e.g. properly zeroed, masked,
have proper length)? Are they mutable? Is the suggested interface specified
 by the interface index embedded into the sockadd_dl gateway, or passed
 as RTAX_IFP parameter, or directly provided by rti_ifp or it needs to
 be derived from the ifa?
These (and other similar) questions have to be considered every time when
 a function has `rt_addrinfo` pointer as an argument.

The new approach is to bring more control back to the protocols and
construct the desired routing objects themselves - in the end, it's the
protocol/subsystem who knows the desired outcome.

This specific diff changes the following:
* add explicit basic low-level radix operations:
 add_route() (renamed from add_route_nhop())
 delete_route() (factored from change_route_nhop())
 change_route() (renamed from change_route_nhop)
* remove "info" parameter from change_route_conditional() as a part
 of reducing rt_addrinfo usage in the internal KPIs
* add lookup_prefix_rt() wrapper for doing re-lookups after
 RIB lock/unlock

Differential Revision: https://reviews.freebsd.org/D36070
MFC after: 2 weeks

(cherry picked from commit 0d60e88b41fe1c090f9b28ea133d0787827f84fc)

19 months agofib_algo: set vnet when destroying algo instance
Alexander V. Chernikov [Sat, 6 Aug 2022 12:44:44 +0000 (12:44 +0000)]
fib_algo: set vnet when destroying algo instance

Reported by: Konrad KrÄ™ciwilk <konrad.kreciwilk@korbank.pl>
MFC after: 2 weeks

(cherry picked from commit 93dd3adac7d84528c4ba4b0c3992931a38dbbc24)

19 months agorouting: remove duplicate error message after 5c23343b8c0c.
Alexander V. Chernikov [Thu, 4 Aug 2022 09:51:38 +0000 (09:51 +0000)]
routing: remove duplicate error message after 5c23343b8c0c.

MFC after: 2 weeks

(cherry picked from commit d46b000eccc99217097ef77572294e60c9fbaf83)

19 months agoroute: fix NOIP builds
Mateusz Guzik [Wed, 3 Aug 2022 21:23:32 +0000 (21:23 +0000)]
route: fix NOIP builds

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 412bdb5a4630eb74c8aa288e60693771c1e16310)

19 months agorouting: refactor private KPI
Alexander V. Chernikov [Mon, 1 Aug 2022 10:02:12 +0000 (10:02 +0000)]
routing: refactor private KPI
* Make nhgrp_get_nhops() return const struct weightened_nhop to
 indicate that the list is immutable
* Make nhgrp_get_group() return the actual group, instead of
 group+weight.

MFC after: 2 weeks

(cherry picked from commit ae6bfd12c8c887b323d623c6c21d29f25622d42d)

19 months agorouting: convert remnants of DPRINTF to FIB_CTL_LOG().
Alexander V. Chernikov [Fri, 29 Jul 2022 17:41:16 +0000 (17:41 +0000)]
routing: convert remnants of DPRINTF to FIB_CTL_LOG().

Convert the last remaining pieces of old-style debug messages
 to the new debugging framework.

Differential Revision: https://reviews.freebsd.org/D35994
MFC after: 2 weeks

(cherry picked from commit 5c23343b8c0cc018f06a4a2cb2d911770bdc8ee2)

19 months agorouting: add nhop(9) kpi.
Alexander V. Chernikov [Fri, 29 Jul 2022 12:32:27 +0000 (12:32 +0000)]
routing: add nhop(9) kpi.

Differential Revision: https://reviews.freebsd.org/D35985
MFC after: 1 month

(cherry picked from commit 800c68469ba6a0a9972129777bed71e1c2b50a87)

19 months agorouting: remove info argument from add/change_route_nhop().
Alexander V. Chernikov [Thu, 28 Jul 2022 13:41:11 +0000 (13:41 +0000)]
routing: remove info argument from add/change_route_nhop().

Currently, rt_addrinfo(info) serves as a main "transport" moving
 state between various functions inside the routing subsystem.
As all of the fields are filled in directly by the customers, it
 is problematic to maintain consistency, resulting in repeated checks
 inside many functions. Additionally, there are multiple ways of
 specifying the same value (RTAX_IFP vs rti_ifp / rti_ifa) and so on.
With the upcoming nhop(9) kpi it is possible to store all of the
 required state in the nexthops in the consistent fashion, reducing the
 need to use "info" in the KPI calls.
Finally, rt_addrinfo structure format was derived from the rtsock wire
 format, which is different from other kernel routing users or netlink.

This cleanup simplifies upcoming nhop(9) kpi and netlink introduction.

Reviewed by: zlei.huang@gmail.com
Differential Revision: https://reviews.freebsd.org/D35972
MFC after: 2 weeks

(cherry picked from commit 29029b06a6f7fd51c34c9db88cc98a6653ee5046)

19 months agotcp: virtualise net.inet.tcp.msl sysctl.
Alexander V. Chernikov [Sat, 4 Dec 2021 22:02:44 +0000 (22:02 +0000)]
tcp: virtualise net.inet.tcp.msl sysctl.

VNET teardown waits 2*MSL (60 seconds by default) before expiring
 tcp PCBs. These PCBs holds references to nexthops, which, in turn,
 reference ifnets. This chain results in VNET interfaces being destroyed
 and moved to default VNET only after 60 seconds.
Allow tcp_msl to be set in jail by virtualising net.inet.tcp.msl sysctl,
 permitting more predictable VNET tests outcomes.

MFC after: 1 week
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D33270

(cherry picked from commit c2c8e360d8c0b8712158d334686d88f052aef819)

19 months agorouting: move route expiration time to its nexthop
Alexander V. Chernikov [Thu, 28 Jul 2022 12:18:19 +0000 (12:18 +0000)]
routing: move route expiration time to its nexthop

Expiration time is actually a path property, not a route property.
Move its storage to nexthop to simplify upcoming nhop(9) KPI changes
 and netlink introduction.

Differential Revision: https://reviews.freebsd.org/D35970
MFC after: 2 weeks

(cherry picked from commit 2717e958df537b2885fdf42635d7b9dc793719b2)

19 months agorouting: add debug printing helpers for rtentry and RTM* cmds.
Alexander V. Chernikov [Sun, 31 Jul 2022 09:00:42 +0000 (09:00 +0000)]
routing: add debug printing helpers for rtentry and RTM* cmds.

MFC after: 2 weeks

(cherry picked from commit 27f107e1b434aae073a0bffebdf426125e7d83aa)

19 months agorouting: hide notify_add and notify_del behind ROUTE_MPATH
Mateusz Guzik [Mon, 4 Jul 2022 08:38:13 +0000 (08:38 +0000)]
routing: hide notify_add and notify_del behind ROUTE_MPATH

Fixes a warn about unused routines without the option.

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit db4b40213a084809cc062605043f5e536ee3aa92)

19 months agorouting: simplify decompose_change_notification().
Alexander V. Chernikov [Mon, 27 Jun 2022 17:29:03 +0000 (17:29 +0000)]
routing: simplify decompose_change_notification().

The function's goal is to compare old/new nhop/nexthop group for the route
 and decompose it into the series of RTM_ADD/RTM_DELETE single-nhop
 events, calling specified callback for each event.
Simplify it by properly leveraging the fact that both old/new groups
 are sorted nhop-# ascending.

Tested by: Claudio Jeker<claudio.jeker@klarasystems.com>
Differential Revision: https://reviews.freebsd.org/D35598
MFC after: 2 weeks

(cherry picked from commit 8010b7a78a3af66dda1c74373499794af9ffd35f)

19 months agorouting: actually sort nexthops in nhgs by their index
Alexander V. Chernikov [Mon, 27 Jun 2022 17:19:50 +0000 (17:19 +0000)]
routing: actually sort nexthops in nhgs by their index

Nexthops in the nexthop groups needs to be deterministically sorted
 by some their property to simplify reporting cost when changing
 large nexthop groups.

Fix reporting by actually sorting next hops by their indices (`wn_cmp_idx()`).
As calc_min_mpath_slots_fast() has an assumption that next hops are sorted
using their relative weight in the nexthop groups, it needs to be
addressed as well. The latter sorting is required to quickly determine the
layout of the next hops in the actual forwarding group. For example,
what's the best way to split the traffic between nhops with weights
19,31 and 47 if the maximum nexthop group width is 64?
It is worth mentioning that such sorting is only required during nexthop
group creation and is not used elsewhere. Lastly, normally all nexthop
are of the same weight. With that in mind, (a) use spare 32 bytes inside
`struct weightened_nexthop` to avoid another memory allocation and
(b) use insertion sort to sort the nexthop weights.

Reported by: thj
Tested by: Claudio Jeker<claudio.jeker@klarasystems.com>
Differential Revision: https://reviews.freebsd.org/D35599
MFC after: 2 weeks

(cherry picked from commit 76f1ab8eff9ede509906e539c10373db44528690)

19 months agorouting: fix debug headers added in 6fa8ed43ee0c.
Alexander V. Chernikov [Sat, 25 Jun 2022 23:05:25 +0000 (23:05 +0000)]
routing: fix debug headers added in 6fa8ed43ee0c.

- move debug headers out of COMPAT_FREEBSD32 in rtsock.c
- remove accidentally-added LOG_ defines from syslog.h

MFC after: 2 weeks

(cherry picked from commit 0e87bab6b44b6cc12d25fd46954ee10121ee38fc)

19 months agorouting: improve debugging.
Alexander V. Chernikov [Sat, 25 Jun 2022 19:53:31 +0000 (19:53 +0000)]
routing: improve debugging.

Use unified guidelines for the severity across the routing subsystem.
Update severity for some of the already-used messages to adhere the
guidelines.
Convert rtsock logging to the new FIB_ reporting format.

MFC after: 2 weeks

(cherry picked from commit 6fa8ed43ee0ca43cf170f52b57fcad562f97baba)

19 months agorouting: fix RTM_CHANGE nhgroup updates.
Alexander V. Chernikov [Sat, 25 Jun 2022 18:54:37 +0000 (18:54 +0000)]
routing: fix RTM_CHANGE nhgroup updates.

RTM_CHANGE operates on a single component of the multipath route (e.g. on a single nexthop).
Search of this nexthop is peformed by iterating over each component from multipath (nexthop)
 group, using check_info_match_nhop. The problem with the current code that it incorrectly
 assumes that `check_info_match_nhop()` returns true value on match, while in reality it
 returns an error code on failure). Fix this by properly comparing the result with 0.
Additionally, the followup code modified original necthop group instead of a new one.
Fix this by targetting new nexthop group instead.

Reported by: thj
Tested by: Claudio Jeker <claudio.jeker@klarasystems.com>
Differential Revision: https://reviews.freebsd.org/D35526
MFC after: 2 weeks

(cherry picked from commit c38da70c28a886cc31a2f009baa79deb7fceec88)

19 months agonet/route: Use __diagused for variables only used in KASSERT().
John Baldwin [Wed, 13 Apr 2022 23:08:19 +0000 (16:08 -0700)]
net/route: Use __diagused for variables only used in KASSERT().

(cherry picked from commit 2174f0f2f25310308f92743da849fee32c65db8a)

19 months agounlink_nhgrp: Remove write-only variable.
John Baldwin [Wed, 6 Apr 2022 23:45:27 +0000 (16:45 -0700)]
unlink_nhgrp: Remove write-only variable.

Possibly one could assert that ret should always be 0 here (that is,
that there was always an index found in the bitmask).  That should be
true since a bitmask index is allocated before the nhgrp is inserted
in the ctl->gr_head list in link_nhgrp.

(cherry picked from commit 371c917b0b450d1944bf0ea18afdfc158af08f2e)

19 months agochange_mpath_route: Remove write-only nh variable.
John Baldwin [Wed, 6 Apr 2022 23:45:28 +0000 (16:45 -0700)]
change_mpath_route: Remove write-only nh variable.

While here, cleanup the style of the function prologue by moving an
assignment out of the middle of two variable declaration blocks.

(cherry picked from commit f7236dd0684e0a523f2b19b187b5ae3b558de4f2)

19 months agorouting: improve debug logging
Alexander V. Chernikov [Wed, 22 Jun 2022 15:04:17 +0000 (15:04 +0000)]
routing: improve debug logging

Use standard logging (FIB_XX_LOG) across nhg code instead of using
 old-style DPRINTFs.
 Add debug object printer for nhgs (`nhgrp_print_buf`).

Example:

```
Jun 19 20:17:09 devel2 kernel: [nhgrp] inet.0 nhgrp_ctl_alloc_default: multipath init done
Jun 19 20:17:09 devel2 kernel: [nhg_ctl] inet.0 alloc_nhgrp: num_nhops: 2, compiled_nhop: 2

Jun 19 20:17:26 devel2 kernel: [nhg_ctl] inet.0 alloc_nhgrp: num_nhops: 3, compiled_nhop: 3
Jun 19 20:17:26 devel2 kernel: [nhg_ctl] inet.0 destroy_nhgrp: destroying nhg#0/sz=2:[#6:1,#5:1]
```

Differential Revision: https://reviews.freebsd.org/D35525
MFC after: 2 weeks

(cherry picked from commit 5d6894bd66e15bb7cf7c6ee2337ce86dfd0b2f7e)

19 months agonetstat: print path weight when showing routes in structured output.
Alexander V. Chernikov [Mon, 20 Jun 2022 08:59:15 +0000 (08:59 +0000)]
netstat: print path weight when showing routes in structured output.

Differential Revision: https://reviews.freebsd.org/D35530
MFC after: 2 weeks

(cherry picked from commit c8f34118ac8207660385f99b78e8daa03ec2408f)