Make the behaviour similar for both IPv4 and IPv6. Also add
the corresponding tests.
PR: 294733
Differential Revision: https://reviews.freebsd.org/D56618
(cherry picked from commit 2872268c7f6d473aae9b02ebb5d2c24fc2cff9b1)
After D46183 the KBI was changed and this made the upgrade procedure
to 15.0+ version a bit difficult, because the old binary can not load
firewall rules when the new kernel is loaded.
This commit adds the sbin/ipfw15 binary that uses new KBI, and then
original sbin/ipfw can detect new KBI and run the new binary instead.
PR: 291562
Reviewed by: jhb, glebius
Fixes: 4a77657cbc
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D54763
Also fix the corresponding tests.
PR: 263240
Differential Revision: https://reviews.freebsd.org/D57010
(cherry picked from commit 6eba055fcf5b0bbfbebcac59f5982d13815001b0)
* Don't iterate over each string three times; once is enough.
* Reject control characters (anything below space) in addition to the
double quote and backslash.
* If an unsafe character is encountered, discard the string instead of
rejecting the entire lease.
* If backslashes are encountered in the file name option, convert them
to forward slashes instead of rejecting the option.
* Tweak the warning messages a bit. Looking through the rest of the
code, it seems to me that notes generally end with a period while
warnings generally don't.
Approved by: so
Security: FreeBSD-EN-26:11.dhclient
Fixes: 8008e4b88daf ("dhclient: Check for unexpected characters in some DHCP server options")
PR: 294886
MFC after: 1 week
Reviewed by: brooks, markj
Differential Revision: https://reviews.freebsd.org/D56740
(cherry picked from commit 873a195ba63575e46686cfd6ea9670a0ca340fa0)
(cherry picked from commit 2f9478ad42c442c49a7eff60227148bf2b90b48c)
When the number of DHCP options exceeds a threshold, script_set_env()
will reallocate the environment, stored as an array of pointers. The
calculation of the array size failed to multiply by the pointer size,
resulting in a smaller than expected buffer which admits out-of-bounds
writes.
Approved by: so
Security: FreeBSD-SA-26:15.dhclient
Security: CVE-2026-42511
Reported by: Joshua Rogers of AISLE Research Team (https://aisle.com/)
Some options are written directly to the lease file, which may be parsed
by subsequent dhclient invocations. We must make sure that a malicious
server can't control the "medium" field of a lease definition, otherwise
they can achieve RCE by injecting one into the lease file, whereupon it
will be passed to dhclient-script, which passes it through eval.
Approved by: so
Security: FreeBSD-SA-26:12.dhclient
Security: CVE-2026-42511
Reported by: Joshua Rogers of AISLE Research Team (https://aisle.com/)
PF configuration files can contains many things.
Using the new page characters (i.e. ^L, \014) to mark the beginning
of parts is useful because many editors such as emacs and vim has
facilities to jump next/previous ones.
PR: 86635
MFC after: 2 weeks
Submitted by: MOROHOSHI Akihiko <moro@remus.dti.ne.jp>
Submitted by: Simon Wollwage <rootnode+freebsd@wollwage.com>
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit fc353e5e61fadd6ef618948f417f96381c08239c)
Previously, setting an interface FIB to some invalid value would result
in a warning being printed, but the ifconfig command would exit with
status 0, but this is wrong.
Add a little regression test.
Reviewed by: pouria, zlei, melifaro
MFC after: 2 weeks
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D54918
(cherry picked from commit 2ea85a622bcba92a7b58901d6a6e945df3022c4e)
The rtnetlink(4) RTM_GETADDR does not list link level addresses, thus
the correct match for interfaces that have a link level address should
be based on what was returned by RTM_GETLINK.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D41586
(cherry picked from commit 6f3947be2a)
When matching interfaces for being Ethernet, use same trick that
the link module does - pass if_type through convert_iftype().
That restores historicaly behaviour of listing lagg(4) ports.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D41585
(cherry picked from commit 31016aa0be)
This affects only ifconfig(8) compiled WITHOUT_NETLINK_SUPPORT, which
is not the default.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D41584
Fixes: d1cd0344f7
(cherry picked from commit 24a81a968d)
Set `ifr->ifr_name` to display gre options
for the interface.
Reviewed by: glebius, zlei
Approved by: glebius (mentor)
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D55099
(cherry picked from commit c2ba906fa63982d7aa799466d83716d39fe91d2b)
By default, when ifconfig shows a v6 address derived from a
router-advertised prefix, it shows the initial preferred and valid
lifetimes. When -L is specified, it is supposed to show the remaining
lifetimes, but this was broken in the conversion to netlink.
Fix that, and add a regression test which validates ifconfig output
before and after a short-lived address expires.
Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: melifaro, allanjude, Seyed Pouria Mousavizadeh Tehrani
Fixes: 4c91a5dfe4 ("ifconfig: make interface and address listing use Netlink as transport")
MFC after: 2 weeks
Sponsored by: OPNsense
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D54294
(cherry picked from commit df6861d755c8f72380ae7fb8df535b27eba8c0be)
A mark set with "setmark" keyword is intended to be "sticky"
and documented as such but in fact it is not yet,
as current implementation lacks "sticky" feature
and its implementation will be not MFC'd, most probably.
Correct the manual page until the implementation improved.
Discussed with: Boris Lytochkin <lytboris@gmail.com> (author)
(cherry picked from commit a7b8a5d37bcb0009297962137bfb6c6570e5af12)
(cherry picked from commit 9fdf49e8a501047b61a615ab1b4b133159ad76e1)
ESP is "Encapsulating Security Payload",
not "Encapsulated Security Payload".
This patch fixes all the place in the tree I could find
with `grep -i encapsulated security`.
MFC after: 3 days
Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D53769
(cherry picked from commit 15afd75e67102f81c37adbf11966e48685bd7be7)
All of the do_cmd() calls are in dummynet.c and specify the socket
option at compile time; none of these removed cases are used in ipfw
after the v3 work.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53378
(cherry picked from commit 0e2e0fb955adf15a217949bc4cc337d53d2c7259)
(cherry picked from commit 6b1e5d4d20)
IP_DUMMYNET_GET is no longer used in ipfw(1).
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53348
(cherry picked from commit 28e52dea96809c7904e498759ee1f79bda929a82)
(cherry picked from commit 73c105268c)
The failed allocation in the error pertains to IP_FW_XADD, not
IP_FW_ADD.
Reviewed by: ae
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53359
(cherry picked from commit 498e56142660c8dd864c878e820252358c9a15cf)
(cherry picked from commit c22437c8b5)
Dummynet v3 switched to IP_DUMMYNET3 but did not update these
warnings/errors.
Fixes: cc4d3c30ea ("Bring in the most recent version of ipfw and dummynet, developed")
Sponsored by: The FreeBSD Foundation
Differential Revision: sbin/ipfw/ipfw2.c
(cherry picked from commit 1f95a517880bae5fc0a9fe4463a8f2ec36ed734a)
(cherry picked from commit a5dd21c7dd)
This follows the commit 4cdc1f5421, which introduces the IFCAP_HWSTATS
capability.
Fixes: 4cdc1f5421 There are some high performance NICs that count statistics in hardware
MFC after: 3 days
(cherry picked from commit 595acb29a35f36a4fc08b89d3a476f16c1d108b4)
(cherry picked from commit 6bcce275a5)
Historically this capability is IFCAP_NOMAP but it was renamed to
IFCAP_MEXTPG. Catch up with the change 3f43ada98c.
PR: 289545
Fixes: 3f43ada98c Catch up with 6edfd179c8: mechanically rename IFCAP_NOMAP to IFCAP_MEXTPG
MFC after: 3 days
(cherry picked from commit 5017fdb728811fd3e15d7151524378f49a49aee1)
(cherry picked from commit 5f472754ba)
Some options (in particular, -g) are processed immediately upon being
parsed. This will produce the wrong result in combination with -j since
we only attach to the jail after we're done parsing arguments. Solve
this by attaching to the jail immediately when -j is encountered. The
downside is that e.g. `ifconfig -j foo -j bar` would previously attach
to jail “bar”, whereas now it will attempt to attach to jail “foo”, and
if successful, attempt to attach to jail “bar” within jail “foo”. This
may be considered a feature.
PR: 289134
MFC after: 1 week
Reviewed by: zlei
Differential Revision: https://reviews.freebsd.org/D52501
(cherry picked from commit 18fd1443d205aed6be22966125a4820f77571948)
When sending UDP packets:
* compute the checksum in the correct order. This only has an impact
if the length of the payload is odd.
* don't send packet with a checksum of zero, use 0xffff instead as
required.
When receiving UDP packets:
* don't do any computations when the checksum is zero.
* compute the checksum in the correct order. This only has an impact
if the length of the payload is odd.
* when computing the checksum, store the pseudo header checksum
* if the checksum is computed as zero, use 0xffff instead.
* also accept packets, when the checksum in the packet is the pseudo
header checksum.
The last point fixes a problem when the DHCP client runs in a VM,
the DHCP server runs on the host serving the VM and the network
interface supports transmit checksum offloading. Since dhclient
doesn't use UDP sockets but bpf devices to read the packets, the
checksum will be incorrect and only contain the checksum of the
pseudo header.
PR: 263229
Reviewed by: markj, Timo Völker
Tested by: danilo
Differential Revision: https://reviews.freebsd.org/D52394
(cherry picked from commit 187ee62c71f2be62870f26ae98de865e330121be)
If the user specified a prefix length with either the internal or
external prefix, we'd jump to check_prefix where we'd dereference p
which was most likely uninitialized.
Instead, store the various prefix lengths separately and check them
all after the loop.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50597
(cherry picked from commit 64bc9ac8cd)
Add an optional "vlan <n>" argument to the bridge static and deladdr
commands to allow addresses to be added to / removed from a particular
vlan. No changes to if_bridge are required as the kernel API already
supports this, it just wasn't exposed in ifconfig.
Add tests for the new functionality, and improve the test for the
existing "static" command.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D51243
(cherry picked from commit 3650722abf)
This is like get_val() but takes an ether_vlanid_t* and ensures the
value is a valid VLAN ID. This avoids redundant comparisons and
casting when parsing VLAN IDs.
Reviewed by: des
Differential Revision: https://reviews.freebsd.org/D51548
(cherry picked from commit 287a5fdcd3)
Add a new type of command, DEF_CMD_VARG, which takes an (argc, argv)
pair instead of a fixed number of arguments. This allows commands
to do their own argument parsing and accept a variable number of
arguments.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D51243
(cherry picked from commit 7d4a177efc)
and the macro EN_SWABIPS.
The macro EN_SWABIPS is identical to IFF_LINK0 (also historically
IFF_LLC0) and we already have the parameter link0 to toggle IFF_LINK0.
These were inherited from 386BSD 0.1 and have never been used since
the very first FreeBSD release.
Reviewed by: adrian, #network
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51368
(cherry picked from commit 8632e4e73a)
This is a small oversight in the transition to netlink; the non-netlink
implementation would explicitly flush its stdout as necessary to avoid
apparent long stalls in output when we end up fully-buffered. Adjust
the netlink implementation to do the same. This was noticed while
trying to triage failures in the wg-quick script.
Commit message by kevans, patch by author.
PR: 278265
Fixes: 091fec1188 ("route: switch transport protocol [...]")
Approved by: so
Security: FreeBSD-EN-25:14.route
(cherry picked from commit 97b61b22ed)
(cherry picked from commit dd695839efd80fe81143cd6c7a552c30df8448f6)
This change produced by melifaro and the commit is concerted with him
as he is pretty busy IRL these days.
The change restores performance of /sbin/ifconfig utility
for non-listing case after it switched from rtsock to netlink(4) API
in FreeBSD 14+.
PR: 287872
(cherry picked from commit b1b17432aa)
Start dealing with Element ID Extension present (IE T=255) and start
parsing elemants from the Element ID Extension set.
Namely (partially) decode HE_CAPA, HE_OPER, MU_EDCA_PARAM_SET,
and as well as SUP_OP_CLASS.
For length reasons also rename UNKNOWN_ELEMID_%d to ELEMID_%d.
Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D50678
(cherry picked from commit a2a15732eb)
instead of accepting any character as a delimiter, only accept ':', '.'
and '-', and only permit a single delimiter in an address.
this prevents accepting bizarre addresses like:
ifconfig epair2a link 10.1.2.200/28
... which is particularly problematic on an INET6-only system, in which
case ifconfig defaults to the 'link' family, meaning that:
ifconfig epair2a 10.1.2.200/28
... changes the Ethernet address of the interface.
bump __FreeBSD_version so link_addr() consumers can detect the change.
Reviewed by: kp, des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D49936
(cherry picked from commit a121509041)
Note-from-OPNsense: not bumping the FreeBSD version for stable/25.7
The node unicast key (PTK) uses a key index of (-1) and printing
a 64k number does not look great. Factor out printing the key
number into a buffer and use 'ucast' for the node unicast key.
Hope is that this will be useful for the future as well when we
will have more/different keys possibly.
Looks like (with -vk):
AES-CCM 2:128-bit <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> rsc 0 tsc 0 rx
AES-CCM 3:128-bit <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> rsc 0 tsc 0 rx
AES-GCM ucast:128-bit <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> rsc 0 tsc 0 tx+rx
Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D50555
(cherry picked from commit 164bf9ffbe)
Add a variable when querying the BSSID so we can later use it rather
than losing the "data" buffer.
When printing key information also query the node unicast key if in
STA mode (the key for the BSSID). Do not error in case we fail.
This is helpful for debugging mostly; was also useful when testing
GCMP support.
Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D50554
(cherry picked from commit e277735ce0)
While we currently do not print the STA unicast key (PTK) we will not
see this but it is for fullness and in preparations for follow-up
hanges.
Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D50553
(cherry picked from commit 54ad06cad1)
We don't support setting netmask or broadcast address for INET6
addresses, and trying to do crashes ifconfig. Handle this the
same way as af_link, by rejecting attempts to configure these
parameters.
PR: 286910
Reported by: Hayzam Sherif <hayzam@alchemilla.io>
MFC after: 3 days
Reviewed by: zlei, kevans, des, cy
Approved by: kevans (mentor)
Differential Revision: https://reviews.freebsd.org/D50413
(cherry picked from commit 59ee9260e6)
ifconfig tests: remove incorrect #!
Fixes: 59ee9260e6 ("ifconfig: reject netmask and broadcast for inet6")
Reviewed by: des
Differential Revision: https://reviews.freebsd.org/D50566
(cherry picked from commit 6ab70fbec4)