From owner-dev-commits-src-all@freebsd.org Tue Jan 19 05:08:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 58DDA4E5518; Tue, 19 Jan 2021 05:08:34 +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 4DKcB931w3z4XJS; Tue, 19 Jan 2021 05:08:33 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 F196A208E6; Tue, 19 Jan 2021 05:08:28 +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 10J58Sbg086078; Tue, 19 Jan 2021 05:08:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10J58SOK086077; Tue, 19 Jan 2021 05:08:28 GMT (envelope-from git) Date: Tue, 19 Jan 2021 05:08:28 GMT Message-Id: <202101190508.10J58SOK086077@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bryan Venteicher Subject: git: c3187190c71f - main - if_vtnet: Disable F_MTU feature if MTU is invalid MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bryanv X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c3187190c71f6850a8d8a058d78a671a45e2871c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2021 05:08:35 -0000 The branch main has been updated by bryanv: URL: https://cgit.FreeBSD.org/src/commit/?id=c3187190c71f6850a8d8a058d78a671a45e2871c commit c3187190c71f6850a8d8a058d78a671a45e2871c Author: Bryan Venteicher AuthorDate: 2021-01-19 04:55:25 +0000 Commit: Bryan Venteicher CommitDate: 2021-01-19 04:55:25 +0000 if_vtnet: Disable F_MTU feature if MTU is invalid Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27931 --- sys/dev/virtio/network/if_vtnet.c | 14 ++++++++++++++ sys/dev/virtio/network/if_vtnetvar.h | 1 + 2 files changed, 15 insertions(+) diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index a9dc3fad96a5..e3a42413d5cd 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -657,6 +657,20 @@ vtnet_negotiate_features(struct vtnet_softc *sc) negotiated_features = virtio_negotiate_features(dev, features); + if (virtio_with_feature(dev, VIRTIO_NET_F_MTU)) { + uint16_t mtu; + + mtu = virtio_read_dev_config_2(dev, + offsetof(struct virtio_net_config, mtu)); + if (mtu < VTNET_MIN_MTU /* || mtu > VTNET_MAX_MTU */) { + device_printf(dev, "Invalid MTU value: %d. " + "MTU feature disabled.\n", mtu); + features &= ~VIRTIO_NET_F_MTU; + negotiated_features = + virtio_negotiate_features(dev, features); + } + } + if (virtio_with_feature(dev, VIRTIO_NET_F_MQ)) { uint16_t npairs; diff --git a/sys/dev/virtio/network/if_vtnetvar.h b/sys/dev/virtio/network/if_vtnetvar.h index 96cd68abba82..7781e1c9b398 100644 --- a/sys/dev/virtio/network/if_vtnetvar.h +++ b/sys/dev/virtio/network/if_vtnetvar.h @@ -340,6 +340,7 @@ CTASSERT(sizeof(struct vtnet_mac_filter) <= PAGE_SIZE); #define VTNET_LRO_FEATURES (VIRTIO_NET_F_GUEST_TSO4 | \ VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_ECN) +#define VTNET_MIN_MTU 68 #define VTNET_MAX_MTU 65536 #define VTNET_MAX_RX_SIZE 65550