aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki@daynix.com>2024-04-28 16:00:45 +0900
committerJason Wang <jasowang@redhat.com>2024-06-04 15:14:25 +0800
commit4b52d63249a508dd927222ffac1a868d38681fc5 (patch)
tree5f19fc43f34d0b1029d1cee2aaa4a1b3bc28a051 /net
parent52a7ff526964e7810ec1ccc71efbdd60952dd20b (diff)
tap: Remove qemu_using_vnet_hdr()
Since qemu_set_vnet_hdr_len() is always called when qemu_using_vnet_hdr() is called, we can merge them and save some code. For consistency, express that the virtio-net header is not in use by returning 0 with qemu_get_vnet_hdr_len() instead of having a dedicated function, qemu_get_using_vnet_hdr(). Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/dump.c4
-rw-r--r--net/net.c24
-rw-r--r--net/netmap.c5
-rw-r--r--net/tap.c28
4 files changed, 3 insertions, 58 deletions
diff --git a/net/dump.c b/net/dump.c
index 16073f2458..956e34a123 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -154,10 +154,8 @@ static ssize_t filter_dump_receive_iov(NetFilterState *nf, NetClientState *sndr,
int iovcnt, NetPacketSent *sent_cb)
{
NetFilterDumpState *nfds = FILTER_DUMP(nf);
- int offset = qemu_get_using_vnet_hdr(nf->netdev) ?
- qemu_get_vnet_hdr_len(nf->netdev) : 0;
- dump_receive_iov(&nfds->ds, iov, iovcnt, offset);
+ dump_receive_iov(&nfds->ds, iov, iovcnt, qemu_get_vnet_hdr_len(nf->netdev));
return 0;
}
diff --git a/net/net.c b/net/net.c
index a2f0c828bb..bd51037ebf 100644
--- a/net/net.c
+++ b/net/net.c
@@ -529,24 +529,6 @@ bool qemu_has_vnet_hdr_len(NetClientState *nc, int len)
return nc->info->has_vnet_hdr_len(nc, len);
}
-bool qemu_get_using_vnet_hdr(NetClientState *nc)
-{
- if (!nc || !nc->info->get_using_vnet_hdr) {
- return false;
- }
-
- return nc->info->get_using_vnet_hdr(nc);
-}
-
-void qemu_using_vnet_hdr(NetClientState *nc, bool enable)
-{
- if (!nc || !nc->info->using_vnet_hdr) {
- return;
- }
-
- nc->info->using_vnet_hdr(nc, enable);
-}
-
void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
int ecn, int ufo, int uso4, int uso6)
{
@@ -559,11 +541,7 @@ void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
int qemu_get_vnet_hdr_len(NetClientState *nc)
{
- if (!nc || !nc->info->get_vnet_hdr_len) {
- return 0;
- }
-
- return nc->info->get_vnet_hdr_len(nc);
+ return nc->vnet_hdr_len;
}
void qemu_set_vnet_hdr_len(NetClientState *nc, int len)
diff --git a/net/netmap.c b/net/netmap.c
index 241b27c8e9..297510e190 100644
--- a/net/netmap.c
+++ b/net/netmap.c
@@ -351,10 +351,6 @@ static bool netmap_has_vnet_hdr(NetClientState *nc)
return netmap_has_vnet_hdr_len(nc, sizeof(struct virtio_net_hdr));
}
-static void netmap_using_vnet_hdr(NetClientState *nc, bool enable)
-{
-}
-
static void netmap_set_vnet_hdr_len(NetClientState *nc, int len)
{
NetmapState *s = DO_UPCAST(NetmapState, nc, nc);
@@ -393,7 +389,6 @@ static NetClientInfo net_netmap_info = {
.has_ufo = netmap_has_vnet_hdr,
.has_vnet_hdr = netmap_has_vnet_hdr,
.has_vnet_hdr_len = netmap_has_vnet_hdr_len,
- .using_vnet_hdr = netmap_using_vnet_hdr,
.set_offload = netmap_set_offload,
.set_vnet_hdr_len = netmap_set_vnet_hdr_len,
};
diff --git a/net/tap.c b/net/tap.c
index 72ae95894f..c848844955 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -262,13 +262,6 @@ static bool tap_has_vnet_hdr_len(NetClientState *nc, int len)
return tap_has_vnet_hdr(nc);
}
-static int tap_get_vnet_hdr_len(NetClientState *nc)
-{
- TAPState *s = DO_UPCAST(TAPState, nc, nc);
-
- return s->host_vnet_hdr_len;
-}
-
static void tap_set_vnet_hdr_len(NetClientState *nc, int len)
{
TAPState *s = DO_UPCAST(TAPState, nc, nc);
@@ -280,23 +273,7 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, int len)
tap_fd_set_vnet_hdr_len(s->fd, len);
s->host_vnet_hdr_len = len;
-}
-
-static bool tap_get_using_vnet_hdr(NetClientState *nc)
-{
- TAPState *s = DO_UPCAST(TAPState, nc, nc);
-
- return s->using_vnet_hdr;
-}
-
-static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr)
-{
- TAPState *s = DO_UPCAST(TAPState, nc, nc);
-
- assert(nc->info->type == NET_CLIENT_DRIVER_TAP);
- assert(!!s->host_vnet_hdr_len == using_vnet_hdr);
-
- s->using_vnet_hdr = using_vnet_hdr;
+ s->using_vnet_hdr = true;
}
static int tap_set_vnet_le(NetClientState *nc, bool is_le)
@@ -394,10 +371,7 @@ static NetClientInfo net_tap_info = {
.has_uso = tap_has_uso,
.has_vnet_hdr = tap_has_vnet_hdr,
.has_vnet_hdr_len = tap_has_vnet_hdr_len,
- .get_using_vnet_hdr = tap_get_using_vnet_hdr,
- .using_vnet_hdr = tap_using_vnet_hdr,
.set_offload = tap_set_offload,
- .get_vnet_hdr_len = tap_get_vnet_hdr_len,
.set_vnet_hdr_len = tap_set_vnet_hdr_len,
.set_vnet_le = tap_set_vnet_le,
.set_vnet_be = tap_set_vnet_be,