The function pf_map_addr() and source tracking operate on a single
address family. This made sense before introducing address family
translation. When combining af-to with route-to or with sticky-address,
the next-hop or the NAT address are of different address family than
the source address. For example in NAT64 scenaro an IPv6 source address
is translated to an IPv4 address and routed over IPv4 gateway.
Make source nodes dual-AF, that is have a separate source AF and
redirection AF. Store route AF in struct pf_kstate, export it to pfctl.
When loading rules with redirection pools with pfctl store address
family of each address. When printing states don't deduce next-hop's
address family from af-to, use the one stored in state.
Reviewed by: kp
Approved by: kp
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D51659
There are scenarios where we can end up looking up an interface by its scope and
turn up an interface that doesn't have IPv6 enabled on it. If that happens we
could end up dereferencing a NULL pointer accessing ifp->if_afdata[AF_INET6].
Check for this.
One such scenario is if a firewall rewrites a destination address to a
link-local address, with an embedded scope for such an interface. Attach a test
case which provokes this.
PR: 288263
Reported by: Robert Morris <rtm@lcs.mit.edu>
Reviewed by: zlei
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D51500
Disallow this:
ifconfig bridge0 create
ifconfig bridge0.1 create
ifconfig bridge0 addm bridge0.1
Also disallow this:
ifconfig vlan1 create
ifconfig bridge0 create
ifconfig bridge0 addm vlan1
ifconfig vlan1 vlan 1 vlandev bridge0
Firstly, this panics due to trying to take BRIDGE_LOCK recursively.
Secondly, even if it worked, it could cause packet forwarding loops.
Reviewed by: des
Differential Revision: https://reviews.freebsd.org/D51310
"ifconfig gif0 ether" doesn't return any output, so this wasn't
correctly checking the MTU on the gif interface. Remove "ether".
Reviewed by: zlei, kp
Differential Revision: https://reviews.freebsd.org/D51245
Both tests rely on ports 77 and 7777 to be available
and thus cannot be run concurrently. This is a temporary
measure to ensure that they don't conflict with each other.
In the future, these should be rewritten to wait until the
necessary ports are available, or deterministically select a
free port instead.
Signed-off-by: Siva Mahadevan <me@svmhdvn.name>
Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/1790
These test cases are variants of the 4in4 and 6in6 tests wherein the
server interface has an alias assigned and the client is configured to
connect to the alias rather than the primary address.
Reviewed by: kp
MFC after: 1 month
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D51499
All of these are passing consistently in the latest CI environment
in 15 back-to-back test runs.
Signed-off-by: Siva Mahadevan <me@svmhdvn.name>
PR: 260458, 260459, 260460, 264805
Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/1788
Use the standard required_kmods reporting mechanism to notify Kyua of
which kernel modules are required.
MFC after: 2 weeks
Sponsored by: ConnectWise
Reviewed by: Siva Mahadevan <me@svmhdvn.name>
Pull Request: https://github.com/freebsd/freebsd-src/pull/1783
That's not supported:
> /usr/local/lib/python3.11/site-packages/scapy/sendrecv.py:726: SyntaxWarning: 'iface' has no effect on L3 I/O sr1().
Sponsored by: Rubicon Communications, LLC ("Netgate")
The PFNL_CMD_CLR_ADDRS command returns a PF_T_NBR_DELETED, not a PF_TS_NZEO.
Handle this correctly.
While here add a test case to verify we return the expected counts when adding
or flushing addresses to/from a table.
PR: 288353
Sponsored by: Rubicon Communications, LLC ("Netgate")
This function has always been dead. It isn't needed, since ctladm will
automatically load the module, if needed.
MFC after: 2 weeks
Sponsored by: ConnectWise
Previously the googletest tests would skip themselves if /dev/fuse could
not be found. But that information would not be passed to Kyua.
Instead it would think that they had passed. Also, the atf-sh test
would previously fail if the fusefs module weren't loaded. Now both
tests will correctly report their requirements to Kyua.
Note that fusefs's googletest tests still require that the
mac_bsdextended(4) module _not_ be loaded, but Kyua has no way to report
such a requirement.
MFC after: 2 weeks
Sponsored by: ConnectWise
Reviewed by: Siva Mahadevan <me@svmhdvn.name>
Pull Request: https://github.com/freebsd/freebsd-src/pull/1782
The mbuf:inet6_in_mbuf_len test sometimes fails because it encountered
unexpected extra packets. These turn out to be MLD packets, so block these
packets on the host with pf so they don't disturb what we're actually trying
to test.
Reviewed by: igoro
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D51408
We failed to verify that the packet was long enough for the provided IPv6 packet
length. This could result in us walking off the end of the mbuf and panicing.
PR: 288224
Reported by: Robert Morris <rtm@lcs.mit.edu>
Tested by: Robert Morris <rtm@lcs.mit.edu>
Reviewed by: emaste
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D51324
Raw sockets have a separate check for this in rip6_bind() that was
missed in the previous change. This fixes e.g. 'ping -S' using an
anycast address.
Fixes: ca4b046105 ("netinet6: allow binding to anycast addresses")
Reviewed by: tuexen, kevans, des (previous version)
Approved by: kevans (mentor)
Differential Revision: https://reviews.freebsd.org/D50438
In FreeBSD each redirection pool (struct pf_kpool) consists of multiple
hosts (struct pf_addr_wrap). In OpenBSD that is not the case, and a
round-robin pool having a table as a host loops infinitely only over
that single table.
In FreeBSD once all addresses from a table are returned the pool must
iterate to the next host. Add a custom flag to have pfr_pool_get() break
its loop once it reaches the last index. Use this flag in round-robin
pools. When changing pool's host set index to 0 to always start
iterating each table from beginning.
Reviewed by: kp
Approved by: kp
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D50779
When pf_map_addr() fails, for example for a NAT pool, we expect packet will
not be forwarded. The error returned by pf_map_addr() has been ignored in
pf_map_addr_sn(), though, causing packets being forwarded without NAT
applied. Catch the error, return the error to caller, let the caller handle
error counters for route-to pools just like it does for NAT pools. Add
tests for NAT and route-to rules.
Improve logging by not hardcoding function name and use __func__
instead.
Reviewed by: kp
Approved by: kp
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D50763
This is both more logical and more useful than EINVAL.
While here, also check for VBAD and return EBADF in that case. This can
happen if the underlying filesystem got forcibly unmounted after the
directory was opened. Previously, this would also have returned EINVAL,
which wasn't right but wasn't wrong either; however, ENOTDIR would not
be appropriate.
MFC after: never
Sponsored by: Klara, Inc.
Reviewed by: kevans, kib
Differential Revision: https://reviews.freebsd.org/D51209
This removes knowledge of the implementation of if_epair.
Makes it easier to modify if_epair in future commits.
Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D51205
Create a state with an rtableid (i.e. fib) that doesn't exist on the receiving
side. This used to not be handled, and could provoke panics. Create such a
situation to ensure we still don't panic.
PR: 287981
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
A vlan interface on top of a bridge will act as a layer 3 port for
bridge traffic on that vlan, sometimes called an "SVI". This allows
the host to send/receive traffic on that vlan without having to create
a separate epair(4) and vlan(4) to tag and untag the traffic.
Reviewed by: zlei, kp, des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50504
The new ifconfig options 'tagged', '+tagged' and '-tagged' allow the
vlan access list of a bridge interface to be configured:
- Incoming tagged frames will be dropped if the vlan tag isn't in the
interface's access list.
- Outgoing frames will be dropped if the vlan tag isn't in the
interface's access list (e.g., for BUM traffic).
This has no effect if vlan filtering is not enabled on the interface.
Since we now add a tag to untagged frames at ingress, remove the
vlan argument from bridge_vfilter_out() and use VLANTAGOF instead.
Reviewed by: des, kp, adrian
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50503
When vlan filtering is enabled, add or remove tags as required to allow
ports with different configurations to communicate:
- When receiving an untagged frame, insert a new tag based on the
interface's configured untagged vlan.
- When sending a tagged frame, and the frame's vlan id matches the
outgoing interface's configured untagged vlan, strip the tag.
Since we now set the vlan id in the mbuf, remove the vlan argument to
bridge_forward() and bridge_broadcast() and take it from VLANTAGOF
instead.
Add tests for the new functionality.
Reviewed by: kp, des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50500
Add two new bridge(4) interface options, 'vlanfilter' and 'untagged':
# ifconfig bridge0 vlanfilter ix0
# ifconfig bridge0 -vlanfilter ix0
# ifconfig bridge0 untagged ix0 20
# ifconfig bridge0 -untagged ix0
Setting 'vlanfilter' causes the bridge to filter ingress and egress
traffic on that interface based on the frame's VLAN, rather than simply
passing all frames. By default, an interface is not permitted on any
VLANs, so all frames will be dropped.
Setting 'untagged' allows the interface to send and receive untagged
traffic in the given VLAN, allowing two (or more) interfaces in the
same VLAN to communicate with each other, but not with any other
interface.
Setting 'untagged' on an interface automatically enables 'vlanfilter'
as well. The untagged VLAN may be removed using the '-untagged'
option, but this does not disable VLAN filtering automatically.
Tagged frames may not be sent or received on a port with VLAN filtering
enabled.
Update bridge.4 to document this change, and also add an overview of the
existing vlan/.1q support in if_bridge.
Basic tests for the new functionality are included.
Bump __FreeBSD_version for struct ibfreq ABI change.
Reviewed by: kevans, kp
Approved by: kevans (mentor)
Differential Revision: https://reviews.freebsd.org/D49993
Upgrade the FUSE API from protocol 7.33 to 7.35.
Add support for FOPEN_NOFLUSH, introduced in 7.35.
Also, reduce diffs vis-a-vis upstream by factoring out an ioctl type, a
change missed in d5e3cf41e8.
Signed-off-by: Claudiu I. Palincas <mscotty@protonmail.ch>
Reviewed by: asomers
Pull Request: https://github.com/freebsd/freebsd-src/pull/1744
Allow pf to limit packets to a specified maximum size. This applies to all
packets, and if reassembly is enabled, looks at the reassembled size, not the
size of individual fragments.
Sponsored by: Rubicon Communications, LLC ("Netgate")
The test relies on being able to assign the same interface address to
two different tap interfaces; it then removes one of the addresses,
which at one point would trigger a kernel panic.
Since 361a8395f0 it is not possible to assign an address multiple
times this way, so the test fails. Just mark it as expected to fail for
now: if the kernel's behaviour here changes again, this test might be a
useful seatbelt.
MFC after: 2 weeks
When pf(4) forwards incoming packets with route-to or reply-to,
decrement the time-to-live or hop-limit field to prevent routing
loops. Sending an ICMP time exceeded error makes traceroute work.
For outgoing packets ip_forward() has already done this.
OK visa@ sashan@
Add a test case for the above, and fix the nat64 tests to account for the nat64
router now decrementing the TTL.
Obtained from: OpenBSD, bluhm <bluhm@openbsd.org>, 18421856bb
Sponsored by: Rubicon Communications, LLC ("Netgate")
New +/- syntax in wg(8) allows us to add or remove just a single
allowed-ip rather than forcing replacement or weird tricks to do an
atomic removal. Ensure that it works now that we've added kernel
support for it.
Reviewed by: ivy
Differential Revision: https://reviews.freebsd.org/D50449
For SCTP we create states for all combinations of endpoints, to allow multihoming to work.
Malicious users could abuse this to fill our state table more easily
than they otherwise could, because we create states between all
combinations of endpoints. Limit this to no more than 8 extra endpoints
for each side of the connection.
MFC after: 2 weeks
Sponsored by: Orange Business Services