aboutsummaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2020-12-09 20:13:12 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2020-12-09 20:13:12 +0000
commit21f5dc86d356acdf4ce173f19f46edc5dbb00f01 (patch)
tree67b34c36cd8269fc26e6125252e36797ff3844f7 /sbin/ifconfig
parentee47a12a490f89226ae736f92d8578ec1ca3b157 (diff)
downloadsrc-21f5dc86d356acdf4ce173f19f46edc5dbb00f01.tar.gz
src-21f5dc86d356acdf4ce173f19f46edc5dbb00f01.zip
Fix bug in ifconfig preventing proper VLAN creation.
Detection of interface type by filter must happen before detection of interface type by prefix. Else the following sequence of commands will try to create a LAGG interface instead of a VLAN interface, which accidentially worked previously, because the date pointed to by the ifr_data pointer was not parsed by VLAN create ioctl(2). This is a regression after r368229, because the VLAN creation now parses the ifr_data field. How to reproduce: # ifconfig lagg0 create # ifconfig lagg0.256 create Differential Revision: https://reviews.freebsd.org/D27521 Reviewed by: kib@ and kevans@ Reported by: raul.munoz@custos.es Sponsored by: Mellanox Technologies // NVIDIA Networking
Notes
Notes: svn path=/head/; revision=368492
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/ifclone.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/sbin/ifconfig/ifclone.c b/sbin/ifconfig/ifclone.c
index 268cc0a28180..ad39bd43757a 100644
--- a/sbin/ifconfig/ifclone.c
+++ b/sbin/ifconfig/ifclone.c
@@ -128,32 +128,32 @@ ifclonecreate(int s, void *arg)
{
struct ifreq ifr;
struct clone_defcb *dcp;
- clone_callback_func *clone_cb = NULL;
memset(&ifr, 0, sizeof(ifr));
(void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (clone_cb == NULL) {
- /* Try to find a default callback */
+ /* Try to find a default callback by filter */
+ SLIST_FOREACH(dcp, &clone_defcbh, next) {
+ if (dcp->clone_mt == MT_FILTER &&
+ dcp->ifmatch(ifr.ifr_name) != 0)
+ break;
+ }
+
+ if (dcp == NULL) {
+ /* Try to find a default callback by prefix */
SLIST_FOREACH(dcp, &clone_defcbh, next) {
- if ((dcp->clone_mt == MT_PREFIX) &&
- (strncmp(dcp->ifprefix, ifr.ifr_name,
- strlen(dcp->ifprefix)) == 0)) {
- clone_cb = dcp->clone_cb;
+ if (dcp->clone_mt == MT_PREFIX &&
+ strncmp(dcp->ifprefix, ifr.ifr_name,
+ strlen(dcp->ifprefix)) == 0)
break;
- }
- if ((dcp->clone_mt == MT_FILTER) &&
- dcp->ifmatch(ifr.ifr_name)) {
- clone_cb = dcp->clone_cb;
- break;
- }
}
}
- if (clone_cb == NULL) {
+
+ if (dcp == NULL || dcp->clone_cb == NULL) {
/* NB: no parameters */
ioctl_ifcreate(s, &ifr);
} else {
- clone_cb(s, &ifr);
+ dcp->clone_cb(s, &ifr);
}
/*