All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: den@openvz.org, jasowang@redhat.com, vsementsov@virtuozzo.com
Subject: [PATCH 2/5] net/tap: drop duplicated tap stubs
Date: Mon, 21 Dec 2020 22:06:06 +0300	[thread overview]
Message-ID: <20201221190609.93768-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20201221190609.93768-1-vsementsov@virtuozzo.com>

tap-solaris and tap-bsd realize only tap_open() interface and all other
functions are duplicated with tap-stub. Let's split tap-stub so that we
can reuse all stubs except for tap_open() for solaris and bsd.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 net/tap-bsd.c       | 53 ---------------------------------------------
 net/tap-open-stub.c | 34 +++++++++++++++++++++++++++++
 net/tap-solaris.c   | 53 ---------------------------------------------
 net/tap-stub.c      |  7 ------
 net/meson.build     |  3 +++
 5 files changed, 37 insertions(+), 113 deletions(-)
 create mode 100644 net/tap-open-stub.c

diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index 77aaf674b1..5667e87c9a 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -206,56 +206,3 @@ error:
     return -1;
 }
 #endif /* __FreeBSD__ */
-
-void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
-{
-}
-
-int tap_probe_vnet_hdr(int fd, Error **errp)
-{
-    return 0;
-}
-
-int tap_probe_has_ufo(int fd)
-{
-    return 0;
-}
-
-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;
-}
-
-void tap_fd_set_offload(int fd, int csum, int tso4,
-                        int tso6, int ecn, int ufo)
-{
-}
-
-int tap_fd_enable(int fd)
-{
-    return -1;
-}
-
-int tap_fd_disable(int fd)
-{
-    return -1;
-}
-
-int tap_fd_get_ifname(int fd, char *ifname)
-{
-    return -1;
-}
diff --git a/net/tap-open-stub.c b/net/tap-open-stub.c
new file mode 100644
index 0000000000..01cc03f630
--- /dev/null
+++ b/net/tap-open-stub.c
@@ -0,0 +1,34 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "tap_int.h"
+
+int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
+             int vnet_hdr_required, int mq_required, Error **errp)
+{
+    error_setg(errp, "tap is not supported in this build");
+    return -1;
+}
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index 0475a58207..920b4df2fe 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -202,56 +202,3 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
     fcntl(fd, F_SETFL, O_NONBLOCK);
     return fd;
 }
-
-void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
-{
-}
-
-int tap_probe_vnet_hdr(int fd, Error **errp)
-{
-    return 0;
-}
-
-int tap_probe_has_ufo(int fd)
-{
-    return 0;
-}
-
-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;
-}
-
-void tap_fd_set_offload(int fd, int csum, int tso4,
-                        int tso6, int ecn, int ufo)
-{
-}
-
-int tap_fd_enable(int fd)
-{
-    return -1;
-}
-
-int tap_fd_disable(int fd)
-{
-    return -1;
-}
-
-int tap_fd_get_ifname(int fd, char *ifname)
-{
-    return -1;
-}
diff --git a/net/tap-stub.c b/net/tap-stub.c
index de525a2e69..6fa130758b 100644
--- a/net/tap-stub.c
+++ b/net/tap-stub.c
@@ -26,13 +26,6 @@
 #include "qapi/error.h"
 #include "tap_int.h"
 
-int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
-             int vnet_hdr_required, int mq_required, Error **errp)
-{
-    error_setg(errp, "tap is not supported in this build");
-    return -1;
-}
-
 void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
 {
 }
diff --git a/net/meson.build b/net/meson.build
index 1076b0a7ab..73b2ab78c2 100644
--- a/net/meson.build
+++ b/net/meson.build
@@ -32,6 +32,9 @@ softmmu_ss.add(when: 'CONFIG_BSD', if_true: files('tap-bsd.c'))
 softmmu_ss.add(when: 'CONFIG_SOLARIS', if_true: files('tap-solaris.c'))
 tap_posix = ['tap.c']
 if not config_host.has_key('CONFIG_LINUX') and not config_host.has_key('CONFIG_BSD') and not config_host.has_key('CONFIG_SOLARIS')
+  tap_posix += 'tap-open-stub.c'
+endif
+if not config_host.has_key('CONFIG_LINUX')
   tap_posix += 'tap-stub.c'
 endif
 softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_posix))
-- 
2.28.0



  parent reply	other threads:[~2020-12-21 19:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21 19:06 [PATCH 0/5] net/tap: some fixes and refactorings Vladimir Sementsov-Ogievskiy
2020-12-21 19:06 ` [PATCH 1/5] net/tap: fix net_init_tap(): set ret on failure path Vladimir Sementsov-Ogievskiy
2020-12-21 19:06 ` Vladimir Sementsov-Ogievskiy [this message]
2020-12-21 19:06 ` [PATCH 3/5] net/tap: tap_set_sndbuf(): return status Vladimir Sementsov-Ogievskiy
2020-12-21 20:12   ` Philippe Mathieu-Daudé
2020-12-22  9:50     ` Vladimir Sementsov-Ogievskiy
2020-12-21 19:06 ` [PATCH 4/5] net/tap: refactor and improve net_init_tap_one() Vladimir Sementsov-Ogievskiy
2020-12-21 19:06 ` [PATCH 5/5] net/tap: net_init_tap_one(): fix net-client leak on failure path Vladimir Sementsov-Ogievskiy
2021-01-12  4:53   ` Jason Wang
2021-12-23 16:45     ` Vladimir Sementsov-Ogievskiy
2021-01-09  9:58 ` [PATCH 0/5] net/tap: some fixes and refactorings Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201221190609.93768-3-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.