<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/dev/wg, branch stable/14</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>kern: wg: add support for removing Allowed-IPs</title>
<updated>2025-07-21T02:12:59+00:00</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2025-06-26T02:57:02+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=684dd4e8c0085f4e64016a44d4cd699b2fc29681'/>
<id>684dd4e8c0085f4e64016a44d4cd699b2fc29681</id>
<content type='text'>
This was recently added to Linux to improve incremental update support,
as you could previously add Allowed-IPs but not remove without replacing
the whole set (and thus, potentially disrupting existing traffic).

Removal is incredibly straightforward; we'll find it in p_aips first
to ensure that it's actually valid for this peer, then we'll delete it
from the radix tree before we remove the corresponding p_aips entry.

Reviewed by:	Jason A. Donenfeld, jhb

(cherry picked from commit d15d610fac97df4fefed3f14b31dcfbdcec65bf9)
(cherry picked from commit d1ac3e245f084ee0637bde9a446687621358c418)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This was recently added to Linux to improve incremental update support,
as you could previously add Allowed-IPs but not remove without replacing
the whole set (and thus, potentially disrupting existing traffic).

Removal is incredibly straightforward; we'll find it in p_aips first
to ensure that it's actually valid for this peer, then we'll delete it
from the radix tree before we remove the corresponding p_aips entry.

Reviewed by:	Jason A. Donenfeld, jhb

(cherry picked from commit d15d610fac97df4fefed3f14b31dcfbdcec65bf9)
(cherry picked from commit d1ac3e245f084ee0637bde9a446687621358c418)
</pre>
</div>
</content>
</entry>
<entry>
<title>kern: wg: split address/mask construction out of wg_aip_add()</title>
<updated>2025-07-21T02:12:28+00:00</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2025-06-26T02:57:02+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=d0b6c358e7486ac560f99f9dfb8166f1f5d014e4'/>
<id>d0b6c358e7486ac560f99f9dfb8166f1f5d014e4</id>
<content type='text'>
We'll re-use these in a future wg_aip_del() to perfectly reconstruct
what we expect to find in a_addr/a_mask.

Reviewed by:	ivy, markj (both earlier version), Aaron LI, jhb

(cherry picked from commit 2475a3dab0d5c5614e303c0022a834f725e2a078)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We'll re-use these in a future wg_aip_del() to perfectly reconstruct
what we expect to find in a_addr/a_mask.

Reviewed by:	ivy, markj (both earlier version), Aaron LI, jhb

(cherry picked from commit 2475a3dab0d5c5614e303c0022a834f725e2a078)
</pre>
</div>
</content>
</entry>
<entry>
<title>kern: wg: refactor out some repetitive bits in allowed-ip config</title>
<updated>2025-07-21T02:12:28+00:00</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2025-06-26T02:57:02+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=1cacf672e3ee3719b72534347cf7d5ce69cf716f'/>
<id>1cacf672e3ee3719b72534347cf7d5ce69cf716f</id>
<content type='text'>
The only difference in the wg_aip_add() call after IP validation is the
address family.  Just pull that out into a variable and avoid the two
different callsites for wg_aip_add().  A future change will add a new
call for each case to remove an address from the peer, so it's nice to
avoid needing to repeat the logic for two different branches.

Reviewed by:	Aaron LI, Jason A. Donenfeld, ivy, jhb, markj

(cherry picked from commit ba2607ae7dff17957d9e62ccd567ba716c168e77)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The only difference in the wg_aip_add() call after IP validation is the
address family.  Just pull that out into a variable and avoid the two
different callsites for wg_aip_add().  A future change will add a new
call for each case to remove an address from the peer, so it's nice to
avoid needing to repeat the logic for two different branches.

Reviewed by:	Aaron LI, Jason A. Donenfeld, ivy, jhb, markj

(cherry picked from commit ba2607ae7dff17957d9e62ccd567ba716c168e77)
</pre>
</div>
</content>
</entry>
<entry>
<title>wg: Improve wg_peer_alloc() to simplify the calling</title>
<updated>2025-04-26T03:19:47+00:00</updated>
<author>
<name>Aaron LI</name>
<email>aly@aaronly.me</email>
</author>
<published>2025-04-18T00:30:11+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=ba560cd8fba390334fd543c4f0190b72794cc6fe'/>
<id>ba560cd8fba390334fd543c4f0190b72794cc6fe</id>
<content type='text'>
Move the necessary extra logics (i.e., noise_remote_enable() and
TAILQ_INSERT_TAIL()) from wg_ioctl_set() to wg_peer_alloc(), and thus
make it easier to be called.  Actually, the updated version is more
asymmetric to wg_peer_destroy() and thus less likely to be misused.
Meanwhile, rename it to wg_peer_create() to look more consistent with
wg_peer_destroy().

Reviewed by:	aly_aaronly.me (diff), markj
Obtained from:	DragonflyBSD 902964ab24ba (with some changes)

(cherry picked from commit 7121e9414f294d116caeadd07ebd969136d3a631)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move the necessary extra logics (i.e., noise_remote_enable() and
TAILQ_INSERT_TAIL()) from wg_ioctl_set() to wg_peer_alloc(), and thus
make it easier to be called.  Actually, the updated version is more
asymmetric to wg_peer_destroy() and thus less likely to be misused.
Meanwhile, rename it to wg_peer_create() to look more consistent with
wg_peer_destroy().

Reviewed by:	aly_aaronly.me (diff), markj
Obtained from:	DragonflyBSD 902964ab24ba (with some changes)

(cherry picked from commit 7121e9414f294d116caeadd07ebd969136d3a631)
</pre>
</div>
</content>
</entry>
<entry>
<title>kern: wg: remove overly-restrictive address family check</title>
<updated>2025-03-15T02:52:02+00:00</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2025-03-04T19:57:34+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=7215aed7974cc4b7d3197ca5e5fcf545d3a28c0f'/>
<id>7215aed7974cc4b7d3197ca5e5fcf545d3a28c0f</id>
<content type='text'>
IPv4 packets can be routed via an IPv6 nexthop, so the handling of the
parsed address family is more strict than it needs to be.  If we have a
valid header that matches a known peer, then we have no reason to
decline the packet.

Convert it to an assertion that it matches the destination as viewed by
the stack below it, instead.  `dst` may be the gateway instead of the
destination in the case of a nexthop, so the `af` assignment must be
switched to use the destination in all cases.

Add a test case that approximates a setup like in the PR and
demonstrates the issue.

PR:		284857
Reviewed by:	markj (earlier version), zlei

(cherry picked from commit 2bef0d54f74dad6962ef7d1dfa407e95cb4fb4ad)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
IPv4 packets can be routed via an IPv6 nexthop, so the handling of the
parsed address family is more strict than it needs to be.  If we have a
valid header that matches a known peer, then we have no reason to
decline the packet.

Convert it to an assertion that it matches the destination as viewed by
the stack below it, instead.  `dst` may be the gateway instead of the
destination in the case of a nexthop, so the `af` assignment must be
switched to use the destination in all cases.

Add a test case that approximates a setup like in the PR and
demonstrates the issue.

PR:		284857
Reviewed by:	markj (earlier version), zlei

(cherry picked from commit 2bef0d54f74dad6962ef7d1dfa407e95cb4fb4ad)
</pre>
</div>
</content>
</entry>
<entry>
<title>wg: Implement if_transmit unconditionally</title>
<updated>2024-07-02T13:19:28+00:00</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2024-06-16T17:33:45+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=a9a57c843264ae1fecf8f0b63f95edbca2496819'/>
<id>a9a57c843264ae1fecf8f0b63f95edbca2496819</id>
<content type='text'>
Commit bf454ca88bdf made wg_transmit() defined only when "device netmap"
is configured, as if_wg's if_transmit implementation should never be
called otherwise, but this breaks a requirement that interfaces
implement both or neither of if_transmit and if_qflush.

Restore the old behaviour of unconditionally defining wg_transmit().  It
contains an assertion that the interface is in netmap mode.

Reported by:	peterj
MFC after:	2 weeks
Fixes:	bf454ca88bdf ("wg: Add netmap support")

(cherry picked from commit 5515e8874a8d85a8d961fca64c494dfc1bea4bd0)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit bf454ca88bdf made wg_transmit() defined only when "device netmap"
is configured, as if_wg's if_transmit implementation should never be
called otherwise, but this breaks a requirement that interfaces
implement both or neither of if_transmit and if_qflush.

Restore the old behaviour of unconditionally defining wg_transmit().  It
contains an assertion that the interface is in netmap mode.

Reported by:	peterj
MFC after:	2 weeks
Fixes:	bf454ca88bdf ("wg: Add netmap support")

(cherry picked from commit 5515e8874a8d85a8d961fca64c494dfc1bea4bd0)
</pre>
</div>
</content>
</entry>
<entry>
<title>wg: Add netmap support</title>
<updated>2024-05-20T13:42:35+00:00</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2024-04-20T16:01:28+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=160e7a4c16ebbec4211a941a706778daf8ea62bd'/>
<id>160e7a4c16ebbec4211a941a706778daf8ea62bd</id>
<content type='text'>
When in netmap (emulated) mode, wireguard interfaces prepend or strip a
dummy ethernet header when interfacing with netmap.  The netmap
application thus sees unencrypted, de-encapsulated frames with a fixed
header.

In this mode, netmap hooks the if_input and if_transmit routines of the
ifnet.  Packets from the host TX ring are handled by wg_if_input(),
which simply hands them to the netisr layer; packets which would
otherwise be tunneled are intercepted in wg_output() and placed in the
host RX ring.

The "physical" TX ring is processed by wg_transmit(), which behaves
identically to wg_output() when netmap is not enabled, and packets
appear in the "physical" RX ring by hooking wg_deliver_in().

Reviewed by:	vmaffione
MFC after:	1 month
Sponsored by:	Klara, Inc.
Sponsored by:	Zenarmor
Differential Revision:	https://reviews.freebsd.org/D43460

(cherry picked from commit bf454ca88bdf4acfa873386e876ff5e772e6a830)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When in netmap (emulated) mode, wireguard interfaces prepend or strip a
dummy ethernet header when interfacing with netmap.  The netmap
application thus sees unencrypted, de-encapsulated frames with a fixed
header.

In this mode, netmap hooks the if_input and if_transmit routines of the
ifnet.  Packets from the host TX ring are handled by wg_if_input(),
which simply hands them to the netisr layer; packets which would
otherwise be tunneled are intercepted in wg_output() and placed in the
host RX ring.

The "physical" TX ring is processed by wg_transmit(), which behaves
identically to wg_output() when netmap is not enabled, and packets
appear in the "physical" RX ring by hooking wg_deliver_in().

Reviewed by:	vmaffione
MFC after:	1 month
Sponsored by:	Klara, Inc.
Sponsored by:	Zenarmor
Differential Revision:	https://reviews.freebsd.org/D43460

(cherry picked from commit bf454ca88bdf4acfa873386e876ff5e772e6a830)
</pre>
</div>
</content>
</entry>
<entry>
<title>bpf: Make BPF interop consistent with if_loop</title>
<updated>2024-05-08T13:06:15+00:00</updated>
<author>
<name>Seth Hoffert</name>
<email>seth.hoffert@gmail.com</email>
</author>
<published>2023-10-22T14:12:45+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=3f6515c20f381d6e136c8c322eadc69fd0e6c4aa'/>
<id>3f6515c20f381d6e136c8c322eadc69fd0e6c4aa</id>
<content type='text'>
The pseudo_AF_HDRCMPLT check is already being done in if_loop and
just needed to be ported over to if_ic, if_wg, if_disc, if_gif,
if_gre, if_me, if_tuntap and ng_iface.  This is needed in order to
allow these interfaces to work properly with e.g., tcpreplay.

PR:		256587
Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/876

(cherry picked from commit 2cb0fce24d64039090dc9243cdf0715ee80c91b1)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The pseudo_AF_HDRCMPLT check is already being done in if_loop and
just needed to be ported over to if_ic, if_wg, if_disc, if_gif,
if_gre, if_me, if_tuntap and ng_iface.  This is needed in order to
allow these interfaces to work properly with e.g., tcpreplay.

PR:		256587
Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/876

(cherry picked from commit 2cb0fce24d64039090dc9243cdf0715ee80c91b1)
</pre>
</div>
</content>
</entry>
<entry>
<title>wg: uma_zcreate() does not fail</title>
<updated>2024-05-02T13:25:08+00:00</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2024-04-23T16:19:08+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=bff26fe7aa07173729bff549a00cc355bc977baf'/>
<id>bff26fe7aa07173729bff549a00cc355bc977baf</id>
<content type='text'>
No functional change intended.

MFC after:	1 week

(cherry picked from commit b6a0ed7c78dd45937e404706620467bef61c308d)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
No functional change intended.

MFC after:	1 week

(cherry picked from commit b6a0ed7c78dd45937e404706620467bef61c308d)
</pre>
</div>
</content>
</entry>
<entry>
<title>wg: Use ENETUNREACH when transmitting to a non-existent peer</title>
<updated>2024-04-15T14:05:13+00:00</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2024-04-01T17:20:55+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=14148b5c5cd602f57a7536fe295632173939380e'/>
<id>14148b5c5cd602f57a7536fe295632173939380e</id>
<content type='text'>
The old errno value used is specifically for Capsicum and shouldn't be
co-opted in this way.  It has special handling in the generic syscall
layer (see syscallret()).  OpenBSD returns ENETUNREACH in this case;
let's do the same thing.

Reviewed by:	kevans, imp
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D44582

(cherry picked from commit 63613e3ba1e188e9fece43e1613bd697f04b345e)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The old errno value used is specifically for Capsicum and shouldn't be
co-opted in this way.  It has special handling in the generic syscall
layer (see syscallret()).  OpenBSD returns ENETUNREACH in this case;
let's do the same thing.

Reviewed by:	kevans, imp
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D44582

(cherry picked from commit 63613e3ba1e188e9fece43e1613bd697f04b345e)
</pre>
</div>
</content>
</entry>
</feed>
