Skip to content

Commit

Permalink
Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into…
Browse files Browse the repository at this point in the history
… staging

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCAAdFiEEIV1G9IJGaJ7HfzVi7wSWWzmNYhEFAmYGZ7EACgkQ7wSWWzmN
# YhHvxgf/SDEYYMlxU7PA1SfwlIYtUG8K1zQnwLXNY6ySCJuCn1IdVoITaUt3BtE5
# OtrhKI8cW5WwL4qzkElWlL431vyqomGdmJQedF8agwoR2aIo24i/Ue09MHxJxXUB
# ONEOv3bizDCYWUjz+PMHRdIbo0AiSNaUDnB8iY59yD6HZqSLVMDx8Ia2KVrzUKwc
# nMuqkDsVIc3gwqFNPbTl3yqVt6k1x+vBCGQUg9BiKE3pkUcONhsJpBYYj4hlY9mn
# /BPlQBcRUoLHQD7KGSUKVFSODHPYzDg7BsSz2+EpuZucRRI3VEyHlcB5A6LIVhrK
# fpqd+80Fb7VE9CAxA2gFj7gh5uPJ1A==
# =shO6
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 29 Mar 2024 07:03:13 GMT
# gpg:                using RSA key 215D46F48246689EC77F3562EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* tag 'net-pull-request' of https://github.com/jasowang/qemu:
  Revert "tap: setting error appropriately when calling net_init_tap_one()"
  tap-win32: Remove unnecessary stubs
  hw/net/net_tx_pkt: Fix virtio header without checksum offloading
  ebpf: Fix indirections table setting
  virtio-net: Fix vhost virtqueue notifiers for RSS

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Mar 30, 2024
2 parents 5012e52 + d9b3301 commit 10e637f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 78 deletions.
9 changes: 7 additions & 2 deletions ebpf/ebpf_rss.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,18 @@ static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
uint16_t *indirections_table,
size_t len)
{
char *cursor = ctx->mmap_indirections_table;

if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL ||
len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {
return false;
}

memcpy(ctx->mmap_indirections_table, indirections_table,
sizeof(*indirections_table) * len);
for (size_t i = 0; i < len; i++) {
*(uint16_t *)cursor = indirections_table[i];
cursor += 8;
}

return true;
}

Expand Down
1 change: 1 addition & 0 deletions hw/net/net_tx_pkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, bool offload,

if (offload || gso_type == VIRTIO_NET_HDR_GSO_NONE) {
if (!offload && pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
pkt->virt_hdr.flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;
net_tx_pkt_do_sw_csum(pkt, &pkt->vec[NET_TX_PKT_L2HDR_FRAG],
pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1,
pkt->payload_len);
Expand Down
4 changes: 2 additions & 2 deletions hw/net/virtio-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -3426,7 +3426,7 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
VirtIONet *n = VIRTIO_NET(vdev);
NetClientState *nc;
assert(n->vhost_started);
if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
if (!n->multiqueue && idx == 2) {
/* Must guard against invalid features and bogus queue index
* from being set by malicious guest, or penetrated through
* buggy migration stream.
Expand Down Expand Up @@ -3458,7 +3458,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
VirtIONet *n = VIRTIO_NET(vdev);
NetClientState *nc;
assert(n->vhost_started);
if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
if (!n->multiqueue && idx == 2) {
/* Must guard against invalid features and bogus queue index
* from being set by malicious guest, or penetrated through
* buggy migration stream.
Expand Down
3 changes: 0 additions & 3 deletions include/net/vhost_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include "net/net.h"
#include "hw/virtio/vhost-backend.h"

#define VHOST_NET_INIT_FAILED \
"vhost-net requested but could not be initialized"

struct vhost_net;
typedef struct vhost_net VHostNetState;

Expand Down
54 changes: 0 additions & 54 deletions net/tap-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,70 +707,16 @@ static void tap_win32_send(void *opaque)
}
}

static bool tap_has_ufo(NetClientState *nc)
{
return false;
}

static bool tap_has_vnet_hdr(NetClientState *nc)
{
return false;
}

int tap_probe_vnet_hdr_len(int fd, int len)
{
return 0;
}

void tap_fd_set_vnet_hdr_len(int fd, int len)
{
}

int tap_fd_set_vnet_le(int fd, int is_le)
{
return -EINVAL;
}

int tap_fd_set_vnet_be(int fd, int is_be)
{
return -EINVAL;
}

static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr)
{
}

static void tap_set_offload(NetClientState *nc, int csum, int tso4,
int tso6, int ecn, int ufo, int uso4, int uso6)
{
}

struct vhost_net *tap_get_vhost_net(NetClientState *nc)
{
return NULL;
}

static bool tap_has_vnet_hdr_len(NetClientState *nc, int len)
{
return false;
}

static void tap_set_vnet_hdr_len(NetClientState *nc, int len)
{
abort();
}

static NetClientInfo net_tap_win32_info = {
.type = NET_CLIENT_DRIVER_TAP,
.size = sizeof(TAPState),
.receive = tap_receive,
.cleanup = tap_cleanup,
.has_ufo = tap_has_ufo,
.has_vnet_hdr = tap_has_vnet_hdr,
.has_vnet_hdr_len = tap_has_vnet_hdr_len,
.using_vnet_hdr = tap_using_vnet_hdr,
.set_offload = tap_set_offload,
.set_vnet_hdr_len = tap_set_vnet_hdr_len,
};

static int tap_win32_init(NetClientState *peer, const char *model,
Expand Down
22 changes: 5 additions & 17 deletions net/tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
if (vhostfdname) {
vhostfd = monitor_fd_param(monitor_cur(), vhostfdname, &err);
if (vhostfd == -1) {
if (tap->has_vhostforce && tap->vhostforce) {
error_propagate(errp, err);
} else {
warn_report_err(err);
}
error_propagate(errp, err);
goto failed;
}
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
Expand All @@ -758,13 +754,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
} else {
vhostfd = open("/dev/vhost-net", O_RDWR);
if (vhostfd < 0) {
if (tap->has_vhostforce && tap->vhostforce) {
error_setg_errno(errp, errno,
"tap: open vhost char device failed");
} else {
warn_report("tap: open vhost char device failed: %s",
strerror(errno));
}
error_setg_errno(errp, errno,
"tap: open vhost char device failed");
goto failed;
}
if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) {
Expand All @@ -777,11 +768,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,

s->vhost_net = vhost_net_init(&options);
if (!s->vhost_net) {
if (tap->has_vhostforce && tap->vhostforce) {
error_setg(errp, VHOST_NET_INIT_FAILED);
} else {
warn_report(VHOST_NET_INIT_FAILED);
}
error_setg(errp,
"vhost-net requested but could not be initialized");
goto failed;
}
} else if (vhostfdname) {
Expand Down

0 comments on commit 10e637f

Please sign in to comment.