if_vtnet: Disable F_MTU feature if MTU is invalid
Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27931
This commit is contained in:
parent
bd8809df20
commit
c3187190c7
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user