From nobody Mon Jan 17 09:35:24 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4693D195C8A5; Mon, 17 Jan 2022 09:35:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JcmwX4Cnkz3Kfw; Mon, 17 Jan 2022 09:35:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642412124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X679QvO2zD9rrLfVpTnyki8e+K1MjsKPwwqwgooOVMk=; b=wCJvltKUBcgbd1+16dJgap3iSLnpn5YPir2cRNhtrWrUEkt824VwKUOIxJ45ymjpoPRJ3N CnzbaD4y58rQaRsGzn/5gW+9kpwTjXwFG234cPfjLMTF4Rkn9SwG1T+Fa6LcX2DgGhzusp 0EdbGHW6LqGyda2mEjQdCgoDsOUtd8S5JTzt+CJo+ZJACzMj8dmaVVKLjVKt8Be5frUsHc DnCAixXPohFvb9Avk4rwjFXZOdb6UldOsLwb1Pk6/YwwMWfUASj7vAYVVOUTMIQicVliX7 Pv0/7mC24GtsD2WXpDV6Xaq1hM3hwzzeuD6SbUPNU0hX70uy9poh3/HMcf606Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2D1AD37A0; Mon, 17 Jan 2022 09:35:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20H9ZOaG069572; Mon, 17 Jan 2022 09:35:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20H9ZOpr069571; Mon, 17 Jan 2022 09:35:24 GMT (envelope-from git) Date: Mon, 17 Jan 2022 09:35:24 GMT Message-Id: <202201170935.20H9ZOpr069571@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 779fd0534466 - main - ifconfig: improve vlan options parsing List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 779fd05344662aeec79c29470258bf657318eab3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642412124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X679QvO2zD9rrLfVpTnyki8e+K1MjsKPwwqwgooOVMk=; b=cPekb71rMotCAFl8BVnd8SKNjnkIfFeMfqPRqpvhcFk7qvrmyMHRZw+UNKGdn9rAcDVc+g aTaSgeCsAujBezfGvMWFCWcM8vwaB66CQllcNEZqEDsySvl+rxItC3UDkmEkxEPUXOAUqg wbAddx4K/+Gwhx4J2Tk19TQFB8kg4Bh8/7xYu8rsB4wJQLvQWBbMKNfVh9hlt9IEWTtIZK z/VLH4i53AJ6Tw+Wfl9TDUavm63I6KnI0c3wWKg6+YxMHr5yQhsGEAAPwSpQ+FMJSUzCvZ meHgSboH8EDGUBaF73s2DDzl5OlHuHIjBRt5NJh6qwC39ArtLuRjJ8Z2/tOQRg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642412124; a=rsa-sha256; cv=none; b=Nv2jY/BXg9USHnVSTgF0zgJIFlVkl9eHRFAlKXcH9XUT7vLm4z/aA5EbTK5gKiv9KHtc8k LCAhuO4iZwJe/JoqYPCPq+k//5HNf9yNJT/fs/S7wv1s54qZoSQZAyXhZButQ/aml1qkmu w+vV7yoh4875XNekhzY+MenIkwbe4sdXtPJzGtsQNWMXV2x/bhhV32vHeqd7ObnQum0WU7 3V2YQojk2sO3+Sx4F1PgQ3AHJjgr9w4B3HZ4d4zkHxCAOjgkNswqDW72CjS0eu6W6V9Xoj g+S0CAL5NCrVqLOHxiRwrxOialLJQ6nivMocTs06Fe5IDoa84ZtzVJOKPsurAQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=779fd05344662aeec79c29470258bf657318eab3 commit 779fd05344662aeec79c29470258bf657318eab3 Author: Alexander V. Chernikov AuthorDate: 2022-01-17 09:30:26 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-01-17 09:35:15 +0000 ifconfig: improve vlan options parsing PR: 261136 Reported by: Daniel O'Connor MFC after: 2 weeks --- sbin/ifconfig/ifvlan.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c index 60f97338ee27..1e74b504fc26 100644 --- a/sbin/ifconfig/ifvlan.c +++ b/sbin/ifconfig/ifvlan.c @@ -126,11 +126,6 @@ vlan_parse_ethervid(const char *name) strlcpy(ifname, name, IFNAMSIZ); if ((cp = strrchr(ifname, '.')) == NULL) return; - /* - * Don't mix vlan/vlandev parameters with dot notation. - */ - if (params.vlr_tag != NOTAG || params.vlr_parent[0] != '\0') - errx(1, "ambiguous vlan specification"); /* * Derive params from interface name: "parent.vid". */ @@ -144,8 +139,20 @@ vlan_parse_ethervid(const char *name) if ((*cp != '\0') || (vid & ~0xFFF)) errx(1, "invalid vlan tag"); - strlcpy(params.vlr_parent, ifname, IFNAMSIZ); - params.vlr_tag = (vid & 0xFFF); + /* + * allow "devX.Y vlandev devX vlan Y" syntax + */ + if (params.vlr_tag == NOTAG || params.vlr_tag == vid) + params.vlr_tag = vid; + else + errx(1, "ambiguous vlan specification"); + + /* Restrict overriding interface name */ + if (params.vlr_parent[0] == '\0' || !strcmp(params.vlr_parent, ifname)) + strlcpy(params.vlr_parent, ifname, IFNAMSIZ); + else + errx(1, "ambiguous vlan specification"); + printf("CR: %s %d\n", params.vlr_parent, params.vlr_tag); } static void