From nobody Thu Jul 21 16:36:48 2022 X-Original-To: dev-commits-src-main@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 4LpdWN4WzNz4X1f4; Thu, 21 Jul 2022 16:36:48 +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 4LpdWN3xqsz4NBW; Thu, 21 Jul 2022 16:36:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658421408; 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=E3ZNcToc/lA5jC1LD+m0xdFBw2oPaygrwrbfvpUdfgU=; b=vcfbkIaVVCNFjgdkEkmyqfY2jX3/iD0vrhEdsQXKDVwcjgZfn8fqkRf8W9c0xFp67Lt1Hj dHSYPgtmC7cOo4wFQbSO9IwkkLU1wJAqrFlH3z7tzYqdKfnk02RcOydjuVvi0715Mqg/lQ Fo7pEAtig4rFOwHYH29UrBWZE0YmiMqChBC8q8YU5IgX7VmBlDDpjW9CmWXpVKFrr7p26K PT+tXxXJljvOi54uaIIls2G9eGnJCusdjQAH9kJlVTcBulibluorNfaf+vBzI8DYRzFvmR nVwhldpQYFbsoDzW3zrSA74zPeW64eJKkRuVHp4DKeGhSmzHx5NQYaGYTcZZQg== 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 4LpdWN333GzTDD; Thu, 21 Jul 2022 16:36:48 +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 26LGam9o034424; Thu, 21 Jul 2022 16:36:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26LGamv3034423; Thu, 21 Jul 2022 16:36:48 GMT (envelope-from git) Date: Thu, 21 Jul 2022 16:36:48 GMT Message-Id: <202207211636.26LGamv3034423@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: b82b8055ad44 - main - ifconfig: fix vlan/vlanproto reconfiguration List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b82b8055ad44cac6ee1e1201cf1ea4dbdd20cacd Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658421408; 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=E3ZNcToc/lA5jC1LD+m0xdFBw2oPaygrwrbfvpUdfgU=; b=SVBcu4opMuga8FtqpagNG5Qe+ZMvtKDDzOjXPYndo0+2Uvk7M1Ok8GS7UoVaFnlhJV2zeo nj58b5b5BjPLpa0RXAvm+RrRM36MvhXP+uEm9gJGWRpuJ+tkzo0FYZiKoiMcvmbcSN/1Q+ pKg1ESyKodCVeTzk2/Xn3mAZbUPxNLSCVVNx36VeM4I92GeDaNjf/Fe0EBVdKj0RRK0dkF T5p/kG8ns48yMPYXM7WYw8FoAKBaebQ+5lkXHL5BO8rDSlyV8nPdPb9mDjTMMjc9blDUwJ LEll0hzBvUJZp0EcP2oNg1voMGgXmeTrdmJDUijkJCj1ZRQiEaEJoTNUdT+dTA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658421408; a=rsa-sha256; cv=none; b=RkPxriXDAphKImOcADK8c8R6ZerG/mHNS3Ou7LyT7tfEpY2GvhR7agP8LKVJ0x1zlSKb2s gnKV+W2vbN2eCnX7hqVgoFPiuJK9nQM47bSljItcS58PhFnJpaYppdLPlJHQ2UTubJc1CS LqeQul6J26Vm4/gfpuJAsgG4sbBnjW+HTKxEM0zkHp5oqKe9Qv0O4SafAB0DaDzMpPZqC/ WjU7sBXFlt+g4Zd+mAGEohr4QWE3qFyaNkHECWbwiAAlVVdwjwuyBxS9gvY4L7gcTaYTb5 aaQIDYBz9ouYjWFFTayZqTBoQReVh+KIflwGty15oUg7deXkV383BBZSqvHYVQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b82b8055ad44cac6ee1e1201cf1ea4dbdd20cacd commit b82b8055ad44cac6ee1e1201cf1ea4dbdd20cacd Author: Kristof Provost AuthorDate: 2022-07-18 22:25:56 +0000 Commit: Kristof Provost CommitDate: 2022-07-21 16:36:01 +0000 ifconfig: fix vlan/vlanproto reconfiguration The setvlantag() and setvlanproto() functions are used in two scenarios: when we create a new vlan interface and when we update an existing interface. These are distinguished by the getvlan() at the end of the functions. If this fails we assume that is because the interface doesn't exist (so we're creating a new one). We only update the 'params' struct, and expect the settings to be applied when we vlan_create(). However, if we're updating an existing interface we do not retrieve the current settings, and can end up invalidating settings. Fix this by using the settings we retrieved while checking which scenario we're in. Note that we do not address this for setvlandev(), because if_vlan does not allow the vlan parent device to be changed without disassociating it first (with ifconfig vlanX -vlandev). Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D35848 --- sbin/ifconfig/ifvlan.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c index 8b7b6e9daf9a..74d683ebb55a 100644 --- a/sbin/ifconfig/ifvlan.c +++ b/sbin/ifconfig/ifvlan.c @@ -204,8 +204,11 @@ DECL_CMD_FUNC(setvlantag, val, d) if (params.vlr_tag != ul) errx(1, "value for vlan out of range"); - if (getvlan(s, &ifr, &vreq) != -1) + if (getvlan(s, &ifr, &vreq) != -1) { + vreq.vlr_tag = params.vlr_tag; + memcpy(¶ms, &vreq, sizeof(params)); vlan_set(s, &ifr); + } } static @@ -233,8 +236,11 @@ DECL_CMD_FUNC(setvlanproto, val, d) } else errx(1, "invalid value for vlanproto"); - if (getvlan(s, &ifr, &vreq) != -1) + if (getvlan(s, &ifr, &vreq) != -1) { + vreq.vlr_proto = params.vlr_proto; + memcpy(¶ms, &vreq, sizeof(params)); vlan_set(s, &ifr); + } } static