Commit graph

1800 commits

Author SHA1 Message Date
Kristof Provost
ac92792bbd pfctl: clear statistic for specified addresses
The ioctl DIOCRCLRASTATS provides the functionality of clearing stats
not only for the whole table for for addresses stored in that table. The
functionality was missing from pfctl, though. Add it now.

PR:		282877
Obtained from:	OpenBSD, kirill <kirill@openbsd.org>, e496dff3a7
MFC after:	3 weeks

(cherry picked from commit 6463b6b59152fb1695bbe0de78f6e2675c5a765a)
2024-12-14 11:03:27 +01:00
Mark Johnston
da44138dc2 unix: Add support for atomically setting the socket mode
With this patch, it is possible to call fchmod() on a unix socket prior
to binding it to the filesystem namespace, so that the mode is set
atomically.  Without this, one has to call chmod() after bind(), leaving
a window where threads can connect to the socket with the default mode.
After bind(), fchmod() reverts to failing with EINVAL.

This interface is copied from Linux.

The behaviour of fstat() is unmodified, i.e., it continues to return the
mode as set by soo_stat().

PR:		282393
Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D47361

(cherry picked from commit bfd03046d18776ea70785ca1ef36dfc60822de3b)
2024-12-03 01:03:26 +00:00
Mark Johnston
9917a1357c fibs_test: Run in a jail
These tests assume exclusive use of one or more FIBs and so can't be run
in parallel.  Running them in a VNET jail sidesteps this problem.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield

(cherry picked from commit a079f2b52aae74b5469f18dcbef1aff680b80282)
2024-11-28 14:38:17 +00:00
Mark Johnston
08d0ebe560 pf: Let rdr rules modify the src port if doing so would avoid a conflict
If NAT rules cause inbound connections to different external IPs to be
mapped to the same internal IP, and some application uses the same
source port for multiple such connections, rdr translation may result in
conflicts that cause some of the connections to be dropped.

Address this by letting rdr rules detect state conflicts and modulate
the source port to avoid them.

Reviewed by:	kp, allanjude
MFC after:	3 months
Sponsored by:	Klara, Inc.
Sponsored by:	Modirum
Differential Revision:	https://reviews.freebsd.org/D44488

(cherry picked from commit 9897a66923a3e79c22fcbd4bc80afae9eb9f277c)
2024-11-20 21:41:09 +00:00
Tom Jones
f5b3ce0d75 pf: Correct SPDX identifier
Pointed out by: Mike Karels <karels@FreeBSD.org>

(cherry picked from commit 3db693f7da8a1aaf0a8887e7791ebb5d67c7a2d9)
2024-11-20 21:41:09 +00:00
Tom Jones
30d4069253 pf: Add a TCP rdr test on IPv6
Reviewed by:    kp
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision: https://reviews.freebsd.org/D42105

(cherry picked from commit b9870ba93ea90a12f5a5727c80f7958b17f9afcc)
2024-11-20 21:41:08 +00:00
Mark Johnston
8635c1ad51 shm: Respect PROT_MAX when creating private mappings
We were previously unconditionally adding PROT_WRITE to the maxprot of
private mapping (because a private mapping can be written even if the
fd is read-only), but this might violate the user's PROT_MAX request.

While here, rename cap_maxprot to max_maxprot.  This is the intersection
of the maximum protections imposed by capsicum rights on the fd (not
really relevant for private mappings) and the user-required maximum
protections (which were not being obeyed).  In particular, cap_maxprot
is a misnomer after the introduction of PROT_MAX.

Add some regression test cases.  mmap__maxprot_shm fails without this
patch.

Note: Capsicum's CAP_MMAP_W is a bit ambiguous.  Should it be required
in order to create writeable private mappings?  Currently it is, even
though such mappings don't permit writes to the object referenced by the
fd.

Reported by:	brooks
Reviewed by:	brooks
MFC after:	1 month
Fixes:		c7841c6b8e ("Relax restrictions on private mappings of POSIX shm objects.")
Differential Revision:	https://reviews.freebsd.org/D46741

(cherry picked from commit 33c2c58f0a3db0a6d3996fa14ac7967274678771)
2024-11-04 15:38:35 +00:00
Alan Somers
d3459fe7f7 zfsd: replace vdevs with the AUX faulted state
Without this patch, vdevs faulted via AUX state would not be replaced
once the appropriate drive is replaced.  ZFS does not internally use
that state, but a drive can be manually forced into such a state with a
command like zinject.

Submitted by:	Goran Mekić <meka@tilda.center>
Sponsored by:	ConnectWise
Differential Revision: https://reviews.freebsd.org/D46866

(cherry picked from commit 618ae939b7f95a197a0518cbb390a572bb90c6d0)
2024-10-31 08:00:32 -06:00
Kristof Provost
df88800a03 pf tests: disable epsv for the ftp proxy test
The update to py-twisted 24.7.0 broke EPSV mode in twisted's ftp server.
Work around this by disabling EPSV (and thus using PASV).

PR:		282154
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 9cd6ab45a44607ea862c8bbb2ebaa8a7521178ff)
2024-10-21 14:51:36 +02:00
Kristof Provost
f3586d2693 netpfil tests: skip checksum verification in pft_ping.py
From scapy 2.6.0 it now removes (sets to None) the IP checksum in its defrag
code. We typically ask for IPv4 or IPv6 defragmentation, which causes check
function failures.

Just skip the checksum verificiation here, because we're going to notice
incorrect checksums even if the tests don't directly verify it.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 6b8096fa5f6f81e2959cbb2ca857c4e134273da2)
2024-10-21 14:51:36 +02:00
Mark Johnston
794fd74ab8 tests: Add some test cases for SO_SPLICE
Reviewed by:	gallatin
MFC after:	3 months
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D46412

(cherry picked from commit 877cf210c08b99aa532107e176b372de58579493)
2024-10-17 15:48:37 +00:00
Mark Johnston
9e6ff43535 netinet tests: Make some tests more reliable when run in parallel
Many of the modified tests add epair interfaces to the host, though most
of the tests themselves run in a VNET jail.  scapy in particular becomes
unhappy when the list of interfaces changes as it is running, so, to
improve reliability of parallel test runs, isolate tests which add
epairs to the host.

Also serialize arp tests, as they examine the dmesg as part of the test.

The list of modified tests is not exhaustive, it was determined by
running the test suite with parallelization enabled and looking at
failures.  It may be easier to just automatically enable VNET jailing of
all netinet tests, but let's be more particular for now.

Reviewed by:	kp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D46606

(cherry picked from commit b103fc49ae160fdce221c2fffa98dde9bc0ff3b0)

Approved by:    kp (mentor), markj (mentor)
2024-10-17 13:45:45 +00:00
Kristof Provost
0e2a3e1da9 if_ovpn tests: allow these tests to run in parallel
Now that kyua can isolate tests in their own vnets we can run these tests in
parallel.

Reviewed by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46600

(cherry picked from commit a05decec2d194821f8bf5c8f2ae72063de0c87a8)

Approved by:    kp (mentor), markj (mentor)
2024-10-17 13:45:35 +00:00
Kristof Provost
c5fc967cf1 netpfil tests: run in parallel
Run these tests in their own (vnet) jail so we don't have to worry about IP
range or jail name conflicts.

Reviewed by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46040

(cherry picked from commit 4f752a1583dc97d166caae7f844bf42715e99978)

Approved by:    kp (mentor), markj (mentor)
2024-10-17 13:45:29 +00:00
Mark Johnston
81da8e39f7 geli tests: Work around a missing MFC
The test assumes commit 96950419f15510287080c557174e0d8409f06956, but
that was never MFCed to stable branches, resulting in a broken test.

This is a direct commit to stable/14.
2024-10-15 13:35:59 +00:00
Kristof Provost
ff5a685270 if_vlan: handle VID conflicts
If we fail to change the vlan id we have to undo the removal (and vlan id
change) in the error path. Otherwise we'll have removed the vlan object from the
hash table, and have the wrong vlan id as well. Subsequent modification attempts
will then try to remove an entry which doesn't exist, and panic.

Undo the vlan id modification if the insertion in the hash table fails, and
re-insert it under the original vlan id.

PR:		279195
Reviewed by:	zlei
MFC atfer:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D45285

(cherry picked from commit bdd12889eaa64032b3d09ef47e9a6f7081863378)
2024-10-11 12:04:09 +02:00
Alan Somers
cf2ed0edae fusefs: fix an uninitialized memory access in fuse_vnop_deallocate
If the FUSE_GETATTR issued to query a file's size during
fuse_vnop_deallocate failed for any reason, then fuse_vnop_deallocate
would attempt to destroy an uninitialized fuse_dispatcher struct, with a
crash the likely result.  This bug only affects FUSE file systems that
implement FUSE_FALLOCATE, and is unlikely to be seen on those that don't
disable attribute caching.

Reported by:	Coverity Scan
CID:		1505308

(cherry picked from commit f93a50d69df2e996ff1d4f793d0dcb9de655ebdc)
2024-10-10 12:48:39 -06:00
Mark Johnston
20191b71ba src.conf: Add a MK_ZFS_TESTS knob
The in-tree ZFS test suite is somewhat outdated and I see a number of
failures there.  I tend to think that we want to integrate the OpenZFS
test suite somehow, replacing the legacy one, though it's also possible
to run that as a separate test suite.

In any case, if one wants to run the OpenZFS test suite separately, it's
useful to be able to disable installation of the legacy ZFS test suite,
so let's provide a src.conf option to do that.

Reviewed by:	asomers
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D46476

(cherry picked from commit 24affded3d4ec5fafb6b22f773ec1e20d73b9b03)
2024-09-20 11:39:16 +00:00
Mark Johnston
6f636541a3 capsicum tests: Serialize functional tests
The test suite runs the same tests twice, as different users, and these
can trample over each other when run in parallel, causing spurious test
failures.

MFC after:	1 week

(cherry picked from commit 41ece3c036bda3d4da321989ee59d0555c10d603)
2024-09-20 11:39:16 +00:00
Mark Johnston
246f922d63 ggate tests: Use unique ports among tests
This helps avoid failures when running tests in parallel.

MFC after:	1 week

(cherry picked from commit b5d3f8252fe8b74249ed49e87981d190c3ec3d05)
2024-09-20 11:39:16 +00:00
Alan Somers
4bb8e26c26 fusefs: fix two bugs regarding _PC_MIN_HOLE_SIZE
Background:

If a user does pathconf(_, _PC_MIN_HOLE_SIZE) on a fusefs file system,
the kernel must actually issue a FUSE_LSEEK operation in order to
determine whether the server supports it.  We cache that result, so we
only have to send FUSE_LSEEK the first time that _PC_MIN_HOLE_SIZE is
requested on any given mountpoint.

Problem 1:

Unlike fpathconf, pathconf operates on files that may not be open.  But
FUSE_LSEEK requires the file to be open.  As described in PR 278135,
FUSE_LSEEK cannot be sent for unopened files, causing _PC_MIN_HOLE_size
to wrongly report EINVAL.  We never noticed that before because the
fusefs test suite only uses fpathconf, not pathconf.  Fix this bug by
opening the file if necessary.

Problem 2:

On a completely sparse file, with no data blocks at all, FUSE_LSEEK with
SEEK_DATA would fail to ENXIO.  That's correct behavior, but
fuse_vnop_pathconf wrongly interpreted that as "FUSE_LSEEK not
supported".  Fix the interpretation.

PR:		278135
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D44618

(cherry picked from commit 6efba04df3f8c77b9b12f1df3e5124a7249b82fc)
2024-09-19 14:27:41 -06:00
Alan Somers
e2217f8097 ctl: add tests for PREVENT ALLOW MEDIUM REMOVAL
Sponsored by:	Axcient
Reviewed by:    emaste, markj
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1409

(cherry picked from commit e234a72bb8c0e8e25ea8a879582e85bb2e09f096)
2024-09-19 14:24:02 -06:00
Alan Somers
37357ba28a ctl: add tests for START STOP UNIT
Sponsored by:	Axcient
Reviewed by:	emaste, markj
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1409

(cherry picked from commit fe1755fa6bb4039c1e00f5226c473a024685005b)
2024-09-19 14:23:59 -06:00
Alan Somers
e9329a869c ctl: add some ATF tests for READ BUFFER
Reviewed by:	Pierre Pronchery <pierre@freebsdfoundation.org>
Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Axcient

(cherry picked from commit 60d717baf2144cf344ec9b47d715ce837b5d46d4)
2024-09-04 15:00:20 +00:00
Kristof Provost
4909bd69dd pf tests: ensure that neighbour discovery works as expected
Also check repeated calls.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit d154dc21130b607d7903f276dd6d463b990f33f7)
2024-09-04 10:38:15 +02:00
Kristof Provost
485bd16308 pf: cope with SCTP port re-use
Some SCTP implementations will abort connections and then later re-use the same
port numbers (i.e. both src and dst) for a new connection, before pf has fully
purged the old connection.

Apply the same hack we already have for similarly misbehaving TCP
implementations and forcibly remove the old state so we can create a new one.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 82e021443a76b1f210cfb929a495185179606868)
2024-08-27 10:09:10 +02:00
Christos Margiolis
6ab8b418dc sound tests: Add SNDSTIOC_ADD_USER_DEVS test
Test whether the SNDSTIOC_ADD_USER_DEVS IOCTL (registers a userland
device to /dev/sndstat) works properly.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D46228

(cherry picked from commit 2668e76d6e764c5c361156ffa3d39eb02ce8e5d9)
2024-08-26 16:52:02 +03:00
Kristof Provost
09d61b28a0 vnet tests: verify that we can load if_epair and if_bridge
We're going to start running many of the vnet tests in nested jails (so they
can run in parallel). That means the tests won't be able to load kernel modules,
which we commonly do for if_epair and if_bridge.

Just assume that all vnet tests need this, because so many of them do that we
don't want to manually annotate all of them.
This is essentially a no-op on non-nested tests.

Do the same for the python test framework.

While here also have pflog_init actually call pft_init. While having pflog
loaded implies we have pf too pft_init also checks for vimage support, and now
for if_epair.

Reviewed by:	markj
MFC after:	1 month
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46039

(cherry picked from commit ae8d58814089308028046ac80aeeb9cbb784bd0a)
2024-08-22 21:01:33 +02:00
Kristof Provost
145f5005ae pf tests: ensure temporary files end up in the atf working directory
Many of the tests create temporary files. pid files, log files, tcpdump
captures, ... We should take care to ensure they're stored in the temporary
working directory Kyua creates rather than in the root directory.

This ensures there are no conflicts between simultaneously running tests, and
also keeps the root directory clean.

MFC after:	1 month
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit b0fcf4d5222bfdbbc0e2af2b14f0d73704706aa0)
2024-08-22 21:01:33 +02:00
Kristof Provost
46c4fc50d3 pf: invert direction for inner icmp state lookups
(e.g. traceroute with icmp)
ok henning, jsing

Also extend the test case to cover this scenario.

PR:		280701
Obtained from:	OpenBSD
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 89f6723288b0d27d3f14f93e6e83f672fa2b8aca)
2024-08-20 17:15:10 +02:00
Kristof Provost
3455a02b5a pf tests: ensure that traceroutes using ICMP work
PR:		280701
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 34063cb714602972b6d985ad747fc8f66a8daae1)
2024-08-20 17:15:10 +02:00
Mark Johnston
58f9c14235 ktrace tests: Add a test case for handling of exec+setuid binaries
MFC after:	1 week

(cherry picked from commit 3852a5a226509551e72c13bce443707f80e863ce)
2024-08-15 14:29:49 +00:00
Mark Johnston
cb2657c962 netinet6 tests: Add a regression test for default router handling
This serves as a regression test for commit a48df53e4249.

Reviewed by:	bz, allanjude
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Bell Tower Integration
Differential Revision:	https://reviews.freebsd.org/D46136

(cherry picked from commit feda329622bc77ab64ae5f0bf852743f4a037616)
2024-08-08 19:11:34 +00:00
Ed Maste
f06d322e9d Remove "All Rights Reserved" from FreeBSD Foundation copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 5c2bc3db201a4fe8d7911cf816bea104d5dc2138)
2024-08-06 15:39:53 -04:00
Mark Johnston
014b6c341d ktrace tests: Add a missing mode in open(O_CREAT)
MFC after:	1 week

(cherry picked from commit 9cc67e43610e34a692398a65adcc5e8846e84250)
2024-08-06 16:40:51 +00:00
Kristof Provost
3e1f815655 pf tests: ensure we don't confuse different ICMP types
When creating a state for ICMP (v4 or v6) packets we only used the ID, which
means that we could confuse different ICMP types. For example, if we allowed
neighbour discovery but not ICMPv6 echo requests an ND packet could create a
state that the echo request would match.

Test that this is now fixed.

Reported by:	Enrico Bassetti <e.bassetti@tudelft.nl>
MFC after:	1 day
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit b9f0dbc3d006e0b904ee4275d54459f4edd65bb8)
2024-07-31 09:39:53 +02:00
Mark Johnston
bed96ef09d socket tests: Serialize sonewconn_overflow
It relies on being able inspect the dmesg buffer to see whether the
kernel logged certain messages.  If it's interleaved with tests that
generate large amounts of console output (e.g., GELI tests), then it can
fail spuriously.

MFC after:	2 weeks

(cherry picked from commit ab27e232b14c07317642a2e4c546c9b71bd9c00b)
2024-07-30 15:55:32 +00:00
Mark Johnston
fb8670d3f8 gnop tests: Serialize
Some of these tests make use of test disk devices, but then they can't
run in parallel.

MFC after:	2 weeks

(cherry picked from commit dc8357de606aa65fc1c35a43d4a5f1d706164ddb)
2024-07-30 15:55:32 +00:00
Christos Margiolis
22be802cf8 sound tests: Add sndstat nvlist ATF test
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D45901

(cherry picked from commit 95eb4b873b6a8b527c5bd78d7191975dfca38998)
2024-07-29 18:34:54 +03:00
Kristof Provost
4f5440f2ab pf tests: fix sctp:timeout test
The test body somehow wound up in the cleanup function.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit fe0c82a603ce069786ee81604315f499fd965546)
2024-07-25 10:23:31 +02:00
Kristof Provost
5acd8ff566 pf tests: test setting and retrieving timeout values
(cherry picked from commit 8ed5170c66ec4914e90c2f3657227ceb9e35193f)
2024-07-25 10:23:29 +02:00
Mark Johnston
b14a491283 ktls: Fix races that can lead to double initialization
ktls_enable_rx() and ktls_enable_tx() have checks to return EALREADY if
the socket already has KTLS enabled.  However, these are done without
any locks held and nothing blocks concurrent attempts to set the socket
option.  I believe the worst outcome of the race is leaked memory.

Fix the problem by rechecking under the sockbuf lock.  While here, unify
the locking protocol for sb_tls_info: require both the sockbuf and
socket I/O locks in order to enable KTLS.  This means that either lock
is sufficient for checking whether KTLS is enabled in a given sockbuf,
which simplifies some refactoring further down the road.

Note that the SOLISTENING() check can go away because
SOCK_IO_RECV_LOCK() atomically locks the socket buffer and checks
whether the socket is a listening socket.  This changes the returned
errno value, so update a test which checks it.

Reviewed by:	gallatin
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45674

(cherry picked from commit 163cdf6a32b9a0f84226a70101d143c10707336f)
2024-07-23 09:01:30 -04:00
Mark Johnston
c1dd895406 sched tests: Avoid underflow when maxcpuid == 0
MFC after:	1 week

(cherry picked from commit 5b98bd30686a358b2a20728a4a6b5cecb7e28dc9)
2024-07-21 20:55:27 -04:00
Gleb Smirnoff
5a676edf9b netpfil tests: disable ICMPv6 rate limiting in the test jail
The dummynet test uses flood ping as source of traffic, so the rate
limiting of ICMP replies broke the test.

Fixes:	32aeee8ce7e72738fff236ccd5629d55035458f8
(cherry picked from commit 75d15e893b14188b83c5fb5e4979fa21c557934f)
2024-06-26 12:48:44 +08:00
Kristof Provost
f930830284 pf tests: test longer anchor names
PR:		279225
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 8b28ec3861d5b3e9fd8a60dbfda13059a5301281)
2024-06-18 09:59:02 +02:00
Alan Somers
27b1954250 fusefs: make the tests more robust to changes to maxphys
Remove assumptions in two test cases that maxphys won't be huge.

Reported by:	kib
Sponsored by:	Axcient

(cherry picked from commit b2792a300ddb8d8334b234fe7744f5141cc96103)
2024-06-13 12:15:58 -06:00
Gleb Smirnoff
57a32d76f6 tests/fusefs: fix all tests that depend on kern.maxphys
The tests try to read kern.maxphys sysctl into int value, while
unsigned long is required.  Not sure when this was broken, seems like
since cd85379104.

Reviewed by:		asomers
Differential Revision:	https://reviews.freebsd.org/D45053

(cherry picked from commit e9b411d273336647e61704213964b995952a44fd)
2024-06-13 12:15:51 -06:00
Kristof Provost
357d111ef7 pf tests: make ether:dummynet test a little more robust
Allow slightly more bandwidth, but cause ping to give up sooner.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 1c5b886e111663d3c7e30beddae9c10445f620d4)
2024-06-11 08:05:38 +02:00
Kristof Provost
c3fe41b3a3 vnet tests: check for if_bridge.ko
A number of tests create a bridge, but did not check if if_bridge.ko is loaded.

We usually get away with that, because `ifconfig bridge create` autoloads the
module, but if we run the tests in a jail (e.g. because of kyua's upcoming
execenv.jail.params feature) we can't load the module and these tests can fail.

Check if the module is loaded, skip the test if it is not.

Reviewed by:	markj
MFC after:	1 week
Event:		Kitchener-Waterloo Hackathon 202406
Differential Revision:	https://reviews.freebsd.org/D45487

(cherry picked from commit 480ad4055314efbfff7eedbb34272031d836ba89)
2024-06-11 08:03:23 +02:00
Zhenlei Huang
c9188db6f9 ifconfig: Redo fix vlan/vlanproto reconfiguration
When the if_vlan(4) interface has not been fully configured, i.e., a
bare interface without a physical interface associated with it,
retrieving the current settings of it and unconditionally overwriting
`params` will result in losing vlandev settings in `params`. That will
lead to failing to associate the if_vlan(4) interface with the requested
physical interface and the false report 'both vlan and vlandev must be
specified'.

Fix that by checking if the vlan interface has been fully configured.

The basic VLAN test is slightly modified to cover this case.

PR:		279181
Reviewed by:	kp
Tested by:	Mike Tancsa <mike@sentex.net>
Fixes:		b82b8055ad ifconfig: fix vlan/vlanproto reconfiguration
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45283

(cherry picked from commit 76df3c57a0abfd24652bfa33982ba136d9d0575b)
2024-05-25 00:03:02 +08:00