]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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)

19 months agorouting: copy nexthop fib when changing existing nexthop
Alexander V. Chernikov [Fri, 13 Jan 2023 12:28:22 +0000 (12:28 +0000)]
routing: copy nexthop fib when changing existing nexthop

MFC after: 1 day

(cherry picked from commit 1b8b69508bc55a797ba344f95f05978408629e25)

19 months agogrowfs(7): clarify assumptions and limitations
Mike Karels [Thu, 5 Jan 2023 13:15:21 +0000 (07:15 -0600)]
growfs(7): clarify assumptions and limitations

Document that the growfs(7) script works only if the root file system
is in the last partition and free space immediately follows it.
Don't imply that /usr can be a separate partition, as that would
likely mean that root is not last.

Reported by: marklmi at yahoo dot com

(cherry picked from commit 8664e266d6a4573d1875ee8f4ce0cdb091171780)

19 months agogrowfs script: fix config-dependent errors
Mike Karels [Wed, 4 Jan 2023 18:25:54 +0000 (12:25 -0600)]
growfs script: fix config-dependent errors

- awk sometimes formatted swapbase as floating point, which gpart
  does not accept; force int.

- Fix typo in code for checking vm.max_swap_pages.

- While here, do not set kernel env if "gpart add" fails.

- Add "gpart show" before modification to verbose output.

Reported by: marklmi at yahoo dot com
Tested by: marklmi at yahoo dot com

(cherry picked from commit 0e2fdab227a1e02956271e5a15403d1408de1eed)

19 months agogrowfs script: fixes
Mike Karels [Mon, 26 Dec 2022 14:45:17 +0000 (08:45 -0600)]
growfs script: fixes

Cannot use single quote in comment in awk script;
add growfs_fstab to Makefile

Fixes: 4a30d7bb373c,d670a8f7c596
(cherry picked from commit 4c8a257810a69264015e4912e02f8c2c837c792e)

19 months agogrowfs(7): document addition of swap partition and growfs_fstab script
Mike Karels [Sat, 10 Dec 2022 19:40:55 +0000 (13:40 -0600)]
growfs(7): document addition of swap partition and growfs_fstab script

Add documentation of the growfs script's new ability to add a swap
partition, expanding on the previous functionality as well.  Add the
growfs_fstab helper script, which runs separately.  Add a description
of how to expand a file system a second time if swap had been added.
While here, fix a typo.

Reviewed by: pauamma
Differential Revision: https://reviews.freebsd.org/D37465

(cherry picked from commit 4e240e55d8186b44fe1bcda09b90ca7ffe65a58b)

19 months agodefault rc.conf: Add new growfs_swap_size variable
Mike Karels [Sat, 10 Dec 2022 19:40:33 +0000 (13:40 -0600)]
default rc.conf: Add new growfs_swap_size variable

Add new growfs_swap_size variable with a default value of the empty
string, along with comments on other settings.  Used by the growfs
script.

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

(cherry picked from commit af01b4722577903f91acc44f01bdcb8cdb2d65ad)

19 months agogrowfs_fstab: add new /etc/rc.d script to add swap to fstab
Mike Karels [Sat, 10 Dec 2022 19:39:59 +0000 (13:39 -0600)]
growfs_fstab: add new /etc/rc.d script to add swap to fstab

The growfs_fstab script is a helper for the growfs script to add any
new swap partition to /etc/fstab on first boot.  If growfs adds a
swap partition, it sets growfs_swap_pdev in the kenv.   In this case,
after the root file system is read/write, if there is no swap partition
in the fstab, growfs_fstab adds growfs_swap as a swap partition to the
fstab.  Also, it runs dumpon to add the swap partition  (as this
happened earlier in the startup sequence).

Discussed with: cperciva
Differential Revision: https://reviews.freebsd.org/D37463

(cherry picked from commit d670a8f7c596fd387823644c5cbf1ddee788eee4)

19 months agogrowfs script: add swap partition as well as growing root
Mike Karels [Sat, 10 Dec 2022 19:38:36 +0000 (13:38 -0600)]
growfs script: add swap partition as well as growing root

Add the ability to create a swap partition in the course of growing
the root file system on first boot, enabling by default.  The default
rules are: add swap if the disk is at least 15 GB (decimal), and the
existing root is less than 40% of the disk.  The default size is 10%
of the disk, but is limited by the memory size.  The limit is twice
memory size up to 4 GB, 8 GB up to 8 GB memory, and memory size over
8 GB memory. Swap size is clamped at vm.swap_maxpages/2 as well.
The new swap partition is labeled as "growfs_swap".

The default behavior can be overridden by setting growfs_swap_size in
/etc/rc.conf or in the kernel environment, with kenv taking priority.
A value of 0 inhibits the addition of swap, an empty value specifies
the default, and other values indicate a swap size in bytes.

By default, addition of swap is inhibited if a swap partition is found
in the output of the sysctl kern.geom.conftxt before the current root
partition, usually meaning that there is another disk present.
Swap space is not added if one is already present in /etc/fstab.

The root partition is read-only when growfs runs, so /etc/fstab can
not be modified.  That step is handled by a new growfs_fstab script,
added in a separate commit.  Set the value "growfs_swap_pdev" in kenv
to indicate that this should be done, as well as for internal use.

There is optional verbose output meant for debugging; it can only be
enabled by modifying the script (in two places, for sh and awk).
This should be removed before release, after testing on -current.

Discussed with: cperciva
Reviewed by: imp (previous version)
Differential Revision: https://reviews.freebsd.org/D37462

(cherry picked from commit 4a30d7bb373c08f42f953b9cd1e793e236b4cd92)

19 months agoMFC growfs script change from August 2021:
Scott Long [Tue, 17 Aug 2021 21:50:18 +0000 (21:50 +0000)]
MFC growfs script change from August 2021:

- Fix the growfs rc script to cope with diskid labels.
- Fix a warning in growfs. gpart commit is supposed to be called on disk
  device.
- Silence a gpart commit warning in growfs.

Submitted by: loos
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D31587
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 045001075ed18295288176211456dde3df7faf46)

19 months agolibc: Fix build with WITHOUT_MACHDEP_OPTIMIZATIONS=YES set.
Gleb Popov [Tue, 10 Jan 2023 10:17:01 +0000 (13:17 +0300)]
libc: Fix build with WITHOUT_MACHDEP_OPTIMIZATIONS=YES set.

Test Plan: `make buildword WITHOUT_MACHDEP_OPTIMIZATIONS=YES` on 14-CURRENT and 13-STABLE

Reviewed by: emaste

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

PR: 266900
(cherry picked from commit 016e46fd869ebf9891ca4b2cf1d22b337717a8c8)

19 months agoGEOM: Remove redundant NULL pointer check before g_free()
Zhenlei Huang [Wed, 28 Dec 2022 15:34:09 +0000 (23:34 +0800)]
GEOM: Remove redundant NULL pointer check before g_free()

Reviewed by: melifaro, pjd, imp
Approved by: kp (mentor)
Differential Revision: https://reviews.freebsd.org/D37779

(cherry picked from commit bd5d9037c5dd79390faf8ee37eecd99e1c378bf0)

19 months agogeom_part: Fix potential integer overflow when checking size of the table
Zhenlei Huang [Wed, 21 Dec 2022 01:04:30 +0000 (09:04 +0800)]
geom_part: Fix potential integer overflow when checking size of the table

`hdr_entries` and `hdr_entsz` are both uint32_t as defined in UEFI spec.
Current spec does not have upper limit of the number of partition
entries and the size of partition entry, it is potential that malicious
or corrupted GPT header read from untrusted source contains large size of
entry number or size.

PR: 266548
Reviewed by: oshogbo, cem, imp, markj
Approved by: kp (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D36709

(cherry picked from commit 2e543af13ab3746c7626c53293c007c8747eff9d)

19 months agowg: Use NET_EPOCH_DRAIN_CALLBACKS macro
Zhenlei Huang [Wed, 28 Dec 2022 15:28:15 +0000 (23:28 +0800)]
wg: Use NET_EPOCH_DRAIN_CALLBACKS macro

Reviewed by: jhb, kp
Approved by: kp (mentor)
Differential Revision: https://reviews.freebsd.org/D37734

(cherry picked from commit f948cb717f50f3f53e0f76d9eb2bd36bc278cb3b)

19 months agoIntroduce and use the NET_EPOCH_DRAIN_CALLBACKS() macro
Zhenlei Huang [Fri, 29 Jul 2022 13:02:39 +0000 (15:02 +0200)]
Introduce and use the NET_EPOCH_DRAIN_CALLBACKS() macro

Reviewed by: melifao, kp
Approved by: kp (mentor)
Differential Revision: https://reviews.freebsd.org/D35968

(cherry picked from commit 150486f6a940947fa7a7c6db357c3f92d07a955f)

19 months agoif_me: Use dedicated network privilege
Zhenlei Huang [Sat, 15 Oct 2022 15:05:36 +0000 (17:05 +0200)]
if_me: Use dedicated network privilege

Separate if_me privileges from if_gif.

Reviewed by: kp
Approved by: kp (mentor)
Differential Revision: https://reviews.freebsd.org/D36691

(cherry picked from commit 43f8c763cdeea29f95b6f0eebce3ad80dd210c7a)

19 months agoif_vxlan(4): Correct the statistic for output bytes
Zhenlei Huang [Fri, 7 Oct 2022 11:37:12 +0000 (13:37 +0200)]
if_vxlan(4): Correct the statistic for output bytes

The vxlan interface encapsulates the Ethernet frame by prepending IP/UDP
and vxlan headers. For statistics, only the payload, i.e. the
encapsulated (inner) frame should be counted.

Event: Aberdeen Hackathon 2022
Reviewed by: kp
Approved by: kp (mentor)
Differential Revision: https://reviews.freebsd.org/D36855

(cherry picked from commit de1ea2d5171ec53acd69f93821b9507267ee44b7)

19 months agoif_vxlan(4): Add missing statistic for input packets
Zhenlei Huang [Wed, 5 Oct 2022 10:38:30 +0000 (12:38 +0200)]
if_vxlan(4): Add missing statistic for input packets

Event: Aberdeen hackathon 2022
Reviewed by: bryanv, kp
Approved by: kp (mentor)
Differential Revision: https://reviews.freebsd.org/D36841

(cherry picked from commit 1fc839f48921919dea386966e0ce4f20c26dcecf)

19 months agovxlan: Add support for socket ioctls SIOC[SG]TUNFIB
Zhenlei Huang [Fri, 8 Jul 2022 18:12:14 +0000 (18:12 +0000)]
vxlan: Add support for socket ioctls SIOC[SG]TUNFIB

Submitted by: Luiz Amaral <email@luiz.eng.br>
PR: 244004
Reviewed by: gbe (manpages), melifaro, pauamma (manpages)
Approved by: kp (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D32820

(cherry picked from commit 7f7a804ae077a0c43d8c3f1444f90bdfb841c6b1)

19 months agoiwlwifi.4: typo fixed
Maxim Konovalov [Thu, 22 Sep 2022 22:35:16 +0000 (22:35 +0000)]
iwlwifi.4: typo fixed

PR: 266554
(cherry picked from commit 7e58c8aa8245192176ac12961272bcb19dfaeb91)

19 months agomotd: Fix Questions List address
Danilo G. Baio [Wed, 24 Nov 2021 00:49:14 +0000 (21:49 -0300)]
motd: Fix Questions List address

Following mailing lists migration from Mailman to Mlmmj.

https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/
-->
https://lists.freebsd.org/subscription/freebsd-questions

Adding a short link (as we already have for Faq and Handbook), so all
links can be indented the same way.

Reviewed by: imp (earlier version)
Approved by: lwhsu
Differential Revision: https://reviews.freebsd.org/D33101

(cherry picked from commit ec80eab8a16acc358895fd01d822799189948ad0)

19 months agoAdd new rc: machine_id to generate /etc/machine-id
Tobias C. Berner [Sat, 17 Dec 2022 09:18:03 +0000 (10:18 +0100)]
Add new rc: machine_id to generate /etc/machine-id

This new default-enabled rc will generate a /etc/machine-id file if it
does not exist, and pre-fill it with a newly generated UUID of version 4
[2].

The file is generated in /var/db/machine-id and symlinked to
/etc/machine-id to allow for read-only root partitions.

This file is amongst other things used by libraries like GLib.

Bump FreeBSD version 1400076 to be able to easily add support for older
version of FreeBSD via a package.

Bump FreeBSD version 1301511 to be able to easily add support for older
version of FreeBSD via a package.

[1] Linux machine-id(5): https://www.man7.org/linux/man-pages/man5/machine-id.5.html
[2] f176fe8e7f638e585afcd2f4dd52a522c4648f63

Approved by: bapt
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37722

(cherry picked from commit 62a149bf621947fb7475c64b1ff04fe19fe16b29)

19 months agobin/uuidgen: add support for v4 uuids
Tobias C. Berner [Wed, 14 Dec 2022 05:59:36 +0000 (06:59 +0100)]
bin/uuidgen: add support for v4 uuids

The version 4 UUID is meant for generating UUIDs from truly-random or
pseudo-random numbers. [1]

bin/uuidgen gained the new flag '-r' to create version 4 UUID.

[1] RFC 4122, https://www.rfc-editor.org/rfc/rfc4122#section-4.4

Reviewed by: pstef
Approved by: bapt
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37695

(cherry picked from commit f176fe8e7f638e585afcd2f4dd52a522c4648f63)

19 months agossh: remove note about local change to [Use]PrivilegeSeparation
Ed Maste [Mon, 12 Dec 2022 22:00:13 +0000 (17:00 -0500)]
ssh: remove note about local change to [Use]PrivilegeSeparation

We documented "[Use]PrivilegeSeparation defaults to sandbox" as one of
our modifications to ssh's server-side defaults, but this is not (any
longer) a difference from upstream.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit a752e011a862f9256b8a3b36d73ee1bbbcaf7a9b)

19 months agoCirrus-CI: add `gpart show` to setup script
Ed Maste [Sun, 1 Jan 2023 18:58:56 +0000 (13:58 -0500)]
Cirrus-CI: add `gpart show` to setup script

GCP instances have stopped resizing the UFS root filesystem.  The 14.x
snapshot image built from b1ef176eb528 works while c89209c674f2 fails.
Discovered via testing a WIP branch in Cirrus-CI that uses
`image: family/freebsd-14-0-snap`.

Add `gpart show` to the setup script to confirm that the partition
size (as set by Cirrus config / GCP) took effect and to help when
investigating any similar issue in the future.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 170d10421a4280475c301c98d02abadc5e14dad8)

19 months agounionfs: implement VOP_SET_TEXT/VOP_UNSET_TEXT
Jason A. Harmening [Tue, 21 Dec 2021 23:51:51 +0000 (15:51 -0800)]
unionfs: implement VOP_SET_TEXT/VOP_UNSET_TEXT

The implementation simply passes the text ref to the appropriate
underlying vnode.  Without this, the default [un]set_text
implementation will only manage the text ref on the unionfs vnode,
causing it to be out of sync with the underlying filesystems and
potentially allowing corruption of executable file contents.
On INVARIANTS kernels, it also readily produces a panic on process
termination because the VM object representing the executable mapping
is backed by the underlying vnode, not the unionfs vnode.

PR: 251342
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D33611

(cherry picked from commit 9e891d43f586e91541bd61fb12550de296d76fd9)

19 months agoreadelf: match GNU readelf formatting
Ed Maste [Tue, 13 Dec 2022 20:07:46 +0000 (15:07 -0500)]
readelf: match GNU readelf formatting

GNU readelf emits a blank line before, and uses single quotes around the
symbol table name, in each "Symbol table 'name' contains ## entries"
header.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37746

(cherry picked from commit 766145637dd5f1316c2ac4a20956e1b17bf8df42)

19 months agohms(4): Disable vendor usage page button support
Vladimir Kondratyev [Sat, 24 Dec 2022 09:01:20 +0000 (12:01 +0300)]
hms(4): Disable vendor usage page button support

for all devices except Kensington Slimblade Trackball as it brokes
some other devices like Contour Rollermouse Red

Add a quirk for it as well.

(cherry picked from commit 0661cf74e6e5dbd585c4a5a3e621d915bb6787d3)

19 months agoums(4): Disable vendor usage page button support
Vladimir Kondratyev [Sat, 24 Dec 2022 09:01:20 +0000 (12:01 +0300)]
ums(4): Disable vendor usage page button support

for all devices except Kensington Slimblade Trackball as it brokes
some other devices like Contour Rollermouse Red

Add a quirk for it as well.

(cherry picked from commit ab4f740bc59e3ba2948bcc4e03bd6125b1dae36f)

19 months agoLinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end)
Vladimir Kondratyev [Sat, 24 Dec 2022 09:01:20 +0000 (12:01 +0300)]
LinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end)

in seqcount_mutex_t case with removal of extraneous mutex lock/unlock
calls and addition of missing critical section.
While here strip one inline wrap layer to reduce code size.

Fixes startup lockup of i915kms after update to drm-kmod v5.12

(cherry picked from commit 68f08e26e2797707c76f8c6423baa41b25dd9df4)

19 months agolinuxkpi: Add `seqcount_mutex_t` support in <linux/seqlock.h>
Jean-Sébastien Pédron [Thu, 1 Dec 2022 13:58:27 +0000 (14:58 +0100)]
linuxkpi: Add `seqcount_mutex_t` support in <linux/seqlock.h>

To achieve that, the header uses the C11 type generic selection keyboard
_Generic() because the macros are supposed to work with seqcount_t
and seqcount_mutex_t.

(cherry picked from commit 18e411233722088400624f21b66eb6687ebe8861)

19 months agomount_nullfs.8: Bump .Dd for file mounts update.
Ceri Davies [Mon, 19 Dec 2022 18:58:39 +0000 (18:58 +0000)]
mount_nullfs.8: Bump .Dd for file mounts update.

(cherry picked from commit 8183df7f0046fd67a747e5278448c5ee3dc6b30f)

19 months agoDon't allow stacking of file mounts
Doug Rabson [Tue, 6 Dec 2022 13:24:55 +0000 (13:24 +0000)]
Don't allow stacking of file mounts

Reviewed by:    mjg, kib
Tested by:      pho

(cherry picked from commit 71e9be1bd54cf54de6fa273af71468e790ccdf47)

19 months agoAllow realpath to work for file mounts
Doug Rabson [Sun, 4 Dec 2022 15:53:07 +0000 (15:53 +0000)]
Allow realpath to work for file mounts

For file mounts, the directory vnode is not available from namei and this
prevents the use of vn_fullpath_hardlink. In this case, we can use the
vnode which was covered by the file mount with vn_fullpath.

This also disallows file mounts over files with link counts greater than
one to ensure a deterministic path to the mount point.

Reviewed by:    mjg, kib
Tested by:      pho

(cherry picked from commit a1d74b2dab78d56582126b4944b435d00747f601)

19 months agoAdd support for mounting single files in nullfs
Doug Rabson [Wed, 23 Nov 2022 14:51:13 +0000 (14:51 +0000)]
Add support for mounting single files in nullfs

The main use-case for this is to support mounting config files and
secrets into OCI containers. My current workaround copies the files into
the container which is messy and risks secrets leaking into container
images if the cleanup fails.

This adds a VFCF flag to indicate whether the filesystem supports file
mounts and allows fspath to be either a directory or a file if the flag
is set.

Test Plan:
$ sudo mkdir -p /mnt
$ sudo touch /mnt/foo
$ sudo mount -t nullfs /COPYRIGHT /mnt/foo

Reviewed by:    mjg, kib
Tested by:      pho

(cherry picked from commit 521fbb722c33663cf00a83bca70ad7cb790687b3)

19 months agoAdd vn_path_to_global_path_hardlink
Doug Rabson [Fri, 2 Dec 2022 14:09:31 +0000 (14:09 +0000)]
Add vn_path_to_global_path_hardlink

This is similar to vn_path_to_global_path but allows for regular files
which may not be present in the cache.

Reviewed by:    mjg, kib
Tested by:      pho

(cherry picked from commit 78d35459a2586da024ac18e8768b44893c7184e7)

19 months agoAdd support for mounting single files in nullfs
Doug Rabson [Mon, 7 Nov 2022 16:56:09 +0000 (16:56 +0000)]
Add support for mounting single files in nullfs

My main use-case for this is to support mounting config files and secrets
into OCI containers. My current workaround copies the files into the
container which is messy and risks secrets leaking into container images
if the cleanup fails.

Reviewed by: mjg, kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D37478

(cherry picked from commit a3f714c4ff8cf3754520f330abe783aa6a06dcdb)

19 months agosyslog: fix PID of forking process
Eugene Grosbein [Tue, 3 Jan 2023 08:53:47 +0000 (15:53 +0700)]
syslog: fix PID of forking process

Do not cache PID for a process that does not fabricate it,
calls openlog() before forking and does not call exec() thereafter.

PR: 268666
Fixes: e9ae9fa93745669b7dd0341d333257ad6cfe8e37
Tested by: kp

(cherry picked from commit 2ce3ef55035093cac7839e71e9ff91f5562ebc29)

19 months agonetwork.subr: Add missing brace
Cy Schubert [Wed, 14 Dec 2022 21:36:23 +0000 (13:36 -0800)]
network.subr: Add missing brace

PR: 268378
Submitted by: jyoung15@gmail.com
Reported by: jyoung15@gmail.com

(cherry picked from commit 87061d3bffd1becd643b0ba9dc6f0a7699efbb39)

19 months agosqlite3: Vendor import of sqlite3 3.40.0
Cy Schubert [Mon, 28 Nov 2022 00:03:49 +0000 (16:03 -0800)]
sqlite3: Vendor import of sqlite3 3.40.0

Changes at https://www.sqlite.org/releaselog/3_40_0.html

Obtained from:  https://www.sqlite.org/2022/sqlite-autoconf-3400000.tar.gz

(cherry picked from commit ac50343d44f8dff1efe667b4713de4b1351a19e1)

19 months agonetmap: several typo fixes
Vincenzo Maffione [Fri, 2 Apr 2021 07:01:20 +0000 (07:01 +0000)]
netmap: several typo fixes

No functional changes intended.

(cherry picked from commit 45c67e8f6b56b9744f01142747fadf291fe3fad2)

19 months agopkt-gen: Allow limiting received packets
Allan Jude [Mon, 17 May 2021 23:04:08 +0000 (23:04 +0000)]
pkt-gen: Allow limiting received packets

Makes pkg-gen quit after having received N packets, the same way it
already supports doing for sent packets.

Reviewed by: vmaffione
Sponsored by: Klara Inc.
MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D30266

(cherry picked from commit 20d684ecc9d7d9128774f2e3c287058868f48bb0)

netmap: pkt-gen: fix compilation issue

Remove stray characters preventing the source code from being
compiled.

Fixes: 20d684ecc9d7 ("pkt-gen: Allow limiting received packets").
Submitted by: ar_semihalf.com
Reviewed by: vmaffione
Differential Revision: <https://reviews.freebsd.org/D###>

(cherry picked from commit 950cf4a29a8e11962cf4672311f685af590c106e)

19 months agonetmap: drop compatibility FreeBSD code
Vincenzo Maffione [Sat, 24 Dec 2022 14:31:14 +0000 (14:31 +0000)]
netmap: drop compatibility FreeBSD code

Netmap users on FreeBSD are not supposed to import code from the
github netmap repository anymore. They should use the code that
is available in the src repo. We can therefore drop the compatibility
code.

MFC after: 7 days

(cherry picked from commit 3da494d3246e30a19d2107c8bb8a293ffd5a9da6)