From nobody Mon Mar 28 09:16:07 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 952291A412F0; Mon, 28 Mar 2022 09:16:08 +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 4KRnB00mcxz4sbf; Mon, 28 Mar 2022 09:16:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648458968; 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=Llc2werBgxDFBiZUJYff2pFGXf+lawmj5x3C/B+m+so=; b=SO6bDnF9bqLWS30CawhCCtGZKUuHhMC7Rfm7xK/HSnT3VRxt70I+I7tt/JEvURVtJ/R3nW BJilyimwzVgKsRlGVqxv21ZqDP62Qig9vyg6wSR9uSwA6ie7ZQbQFQOVBwJOIM6YHEebnt nDWd1AmA/F8uKPxV5WrfgPNLEfeFIXZZbmgBMkXR3LuIaLNfaQQGHNaacx9Kb5/kuuifhc GjZf5WLuaYX3XMdp186EFr2Q2RlwxYDYbtmo3T2IzpZSz7cMvdHI4SqcWneEXfDTo1sVUA HXZ0xtCHt94I2vwihaMXhpoTb9SbM0Z6exSRqxRzxyccJjIz9YkhwdwYyAj/Cg== 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 578FC27018; Mon, 28 Mar 2022 09:16:07 +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 22S9G7GX087814; Mon, 28 Mar 2022 09:16:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22S9G7B8087813; Mon, 28 Mar 2022 09:16:07 GMT (envelope-from git) Date: Mon, 28 Mar 2022 09:16:07 GMT Message-Id: <202203280916.22S9G7B8087813@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 157bf2c9964a - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 157bf2c9964a54124e05bb7c354d8e5ad784802a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648458968; 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=Llc2werBgxDFBiZUJYff2pFGXf+lawmj5x3C/B+m+so=; b=BTQEXs8UkcMdUTmDMhkDBVb4iUQQrkGVGfEib5mc6f441qqv2yc5umIngwRviZhBT1oM9n /Pu95aB2zWwlwrXajy0n8vaO+U9yLmY/N44OQ9Y+2Uq1waYPtlAQ3NAin7OQXnlVFnrg6Y TKKtwgSogxHNR6L5XAY7b4KkyQZz6cHqkT635cMWaNADeh1AY1bb0/X74qdTttSGD1Ti6k Y+OVHpXkuPrU/7INwnBv1dM3pc9dlzW08sTStiwuNhCMTqx03O1ORwSdpuOtOmcv+I6ovV d19rPfYsQNztuK3OOpDAbbUJBqEUPe3msHgLyeNQrlbcf8nU5rN5GtAxbNbDKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648458968; a=rsa-sha256; cv=none; b=j1Jd2/3QyE0CahA5K790mX+CrTS9kgS7/9fLAfsTkeEArF9PF5LLEvSkk91JUSPcsbaGIn BTwhhVC4uOHGJFAtY0Oo16tBrSLa0guGsj+TMbKsvIVCW4HvY8nwq3yaR4S5f7/jsdztgU +uxZGSk3BFtm5mRkyr51Qbe/Z/jD57pYFCxN8anTBgK76f18/SrivSbSl45O0Pxp+g9ksl QIRZt0fodWipIhbk1fzdxo6oZ1nAXYGLAvmpACSh537f/NfKj6qA23oWGRr8OehCmqeYfS DYVdqKUcRn2I6em9Wnob273tO0F+w3lrv7VBigGymFXSrRx2AdEChKEYcjFX0w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=157bf2c9964a54124e05bb7c354d8e5ad784802a commit 157bf2c9964a54124e05bb7c354d8e5ad784802a Author: Alexander V. Chernikov AuthorDate: 2022-01-17 09:30:26 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-03-28 08:50:12 +0000 ifconfig: improve vlan options parsing PR: 261136 Reported by: Daniel O'Connor MFC after: 2 weeks (cherry picked from commit 779fd05344662aeec79c29470258bf657318eab3) --- 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