Page MenuHomeFreeBSD

D23971.id69222.diff
No OneTemporary

D23971.id69222.diff

Index: usr.sbin/bhyve/net_backends.h
===================================================================
--- usr.sbin/bhyve/net_backends.h
+++ usr.sbin/bhyve/net_backends.h
@@ -59,6 +59,7 @@
*/
#define VIRTIO_NET_F_CSUM (1 << 0) /* host handles partial cksum */
#define VIRTIO_NET_F_GUEST_CSUM (1 << 1) /* guest handles partial cksum */
+#define VIRTIO_NET_F_MTU (1 << 3) /* initial MTU advice */
#define VIRTIO_NET_F_MAC (1 << 5) /* host supplies MAC */
#define VIRTIO_NET_F_GSO_DEPREC (1 << 6) /* deprecated: host handles GSO */
#define VIRTIO_NET_F_GUEST_TSO4 (1 << 7) /* guest can rcv TSOv4 */
Index: usr.sbin/bhyve/net_utils.h
===================================================================
--- usr.sbin/bhyve/net_utils.h
+++ usr.sbin/bhyve/net_utils.h
@@ -35,5 +35,6 @@
void net_genmac(struct pci_devinst *pi, uint8_t *macaddr);
int net_parsemac(char *mac_str, uint8_t *mac_addr);
+int net_parsemtu(const char *mtu_str, uint16_t *mtu);
#endif /* _NET_UTILS_H_ */
Index: usr.sbin/bhyve/net_utils.c
===================================================================
--- usr.sbin/bhyve/net_utils.c
+++ usr.sbin/bhyve/net_utils.c
@@ -32,8 +32,10 @@
#include <net/ethernet.h>
#include <errno.h>
+#include <limits.h>
#include <md5.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "bhyverun.h"
@@ -59,6 +61,24 @@
memcpy(mac_addr, ea->octet, ETHER_ADDR_LEN);
return (0);
+}
+
+int
+net_parsemtu(const char *mtu_str, uint16_t *mtu)
+{
+ unsigned int val;
+
+ val = strtoul (mtu_str, NULL, 0);
+
+ if (val == ULONG_MAX)
+ return (ERANGE);
+
+ if (val < ETHERMIN || val > ETHERMTU_JUMBO)
+ return (EINVAL);
+
+ *mtu = (uint16_t)val;
+
+ return (0);
}
void
Index: usr.sbin/bhyve/pci_virtio_net.c
===================================================================
--- usr.sbin/bhyve/pci_virtio_net.c
+++ usr.sbin/bhyve/pci_virtio_net.c
@@ -68,7 +68,7 @@
#define VTNET_MAX_PKT_LEN (65536 + 64)
#define VTNET_S_HOSTCAPS \
- ( VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | \
+ ( VIRTIO_NET_F_MAC | VIRTIO_NET_F_MTU | VIRTIO_NET_F_STATUS | \
VIRTIO_F_NOTIFY_ON_EMPTY | VIRTIO_RING_F_INDIRECT_DESC)
/*
@@ -77,6 +77,8 @@
struct virtio_net_config {
uint8_t mac[6];
uint16_t status;
+ uint16_t max_virtqueue_pairs;
+ uint16_t mtu;
} __packed;
/*
@@ -532,6 +534,7 @@
struct pci_vtnet_softc *sc;
char tname[MAXCOMLEN + 1];
int mac_provided;
+ uint16_t mtu = ETHERMIN;
/*
* Allocate data structures for further virtio initializations.
@@ -585,6 +588,10 @@
if (err)
break;
mac_provided = 1;
+ } else if (strcmp(key, "mtu") == 0) {
+ err = net_parsemtu(value, &mtu);
+ if (err)
+ break;
}
}
@@ -608,6 +615,8 @@
if (!mac_provided) {
net_genmac(pi, sc->vsc_config.mac);
}
+
+ sc->vsc_config.mtu = mtu;
/* initialize config space */
pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_NET);

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 1, 11:40 AM (3 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40012873
Default Alt Text
D23971.id69222.diff (2 KB)

Event Timeline