From 081d4c620cf0be4ae008242bd81792170cc25dbb Mon Sep 17 00:00:00 2001 From: hselasky Date: Thu, 10 Dec 2020 09:39:27 +0000 Subject: [PATCH] Fix bug in ifconfig regarding VLAN creation. Detection of VLAN interface type 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 works, because the data pointed to by the ifr_data pointer is not parsed by the VLAN create ioctl(2). How to reproduce: # ifconfig lagg0 create # ifconfig lagg0.256 create This is a direct commit. Differential Revision: https://reviews.freebsd.org/D27521 Tested by: raul.munoz@custos.es Sponsored by: Mellanox Technologies // NVIDIA Networking git-svn-id: svn://svn.freebsd.org/base/stable/10@368505 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sbin/ifconfig/ifclone.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbin/ifconfig/ifclone.c b/sbin/ifconfig/ifclone.c index 21dcdc3de..8acb9029c 100644 --- a/sbin/ifconfig/ifclone.c +++ b/sbin/ifconfig/ifclone.c @@ -122,6 +122,7 @@ ifclonecreate(int s, void *arg) struct ifreq ifr; struct clone_defcb *dcp; clone_callback_func *clone_cb = NULL; + const char *ifr_name = strchr(name, '.') ? "vlan" : name; memset(&ifr, 0, sizeof(ifr)); (void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); @@ -129,7 +130,7 @@ ifclonecreate(int s, void *arg) if (clone_cb == NULL) { /* Try to find a default callback */ SLIST_FOREACH(dcp, &clone_defcbh, next) { - if (strncmp(dcp->ifprefix, ifr.ifr_name, + if (strncmp(dcp->ifprefix, ifr_name, strlen(dcp->ifprefix)) == 0) { clone_cb = dcp->clone_cb; break; -- 2.42.0