Skip to contentSkip to conversation

Add ipv6 hostfwd support

PATCH In review dje--- via 3 participants 7 messages Jan 21, 2021 Networking

lore
Share & tools
lore

dje--- via

author
#0 lore raw

cover Add ipv6 hostfwd support

Hi. This patchset takes the original patch from Maxim,
https://www.mail-archive.com/[email protected]/msg569573.html
and updates it.

The first patch is the slirp additions, the second patch adds the u/i.

Doug Evans (2):
slirp: Add ipv6 hostfwd support
net: Add ipv6_hostfwd option

Slirp:

 src/libslirp.h |   6 +++
 src/slirp.c    |  51 +++++++++++++++++++++--
 src/socket.c   | 109 +++++++++++++++++++++++++++++++++++--------------
 src/socket.h   |   9 ++++
 src/udp.c      |  73 ++++++++++++++++++++++++++-------
 src/udp.h      |   2 +
 6 files changed, 202 insertions(+), 48 deletions(-)

QEMU:

 hmp-commands.hx     |  29 ++++-
 include/net/slirp.h |   2 +
 net/slirp.c         | 311 +++++++++++++++++++++++++++++++++++---------
 qapi/net.json       |   1 +
 slirp               |   2 +-
 5 files changed, 279 insertions(+), 66 deletions(-)
Signature · 1 line
2.30.0.296.g2bfb1c46d8-goog
author
#1 lore raw

PATCH 1/2 slirp: Add ipv6 hostfwd support

---
 src/libslirp.h |   6 +++
 src/slirp.c    |  51 +++++++++++++++++++++--
 src/socket.c   | 109 +++++++++++++++++++++++++++++++++++--------------
 src/socket.h   |   9 ++++
 src/udp.c      |  73 ++++++++++++++++++++++++++-------
 src/udp.h      |   2 +
 6 files changed, 202 insertions(+), 48 deletions(-)
src/libslirp.h +6 -0
index 27e1f61..280d3d0 100644
@@ -142,6 +142,12 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,
                       int host_port, struct in_addr guest_addr, int guest_port);
 int slirp_remove_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,
                          int host_port);
+int slirp_add_ipv6_hostfwd(Slirp *slirp, int is_udp,
+                           struct in6_addr host_addr, int host_port,
+                           struct in6_addr guest_addr, int guest_port);
+int slirp_remove_ipv6_hostfwd(Slirp *slirp, int is_udp,
+                              struct in6_addr host_addr, int host_port);
+
 int slirp_add_exec(Slirp *slirp, const char *cmdline,
                    struct in_addr *guest_addr, int guest_port);
 int slirp_add_unix(Slirp *slirp, const char *unixsock,
src/slirp.c +48 -3

75 lines not on this page · raw message

src/socket.c +79 -30

143 lines not on this page · raw message

src/socket.h +9 -0
index a6a1e5e..425c607 100644
@@ -11,6 +11,13 @@
 #define SO_EXPIRE 240000
 #define SO_EXPIREFAST 10000
 
+/* Helps unify some in/in6 routines. */
+union in4or6_addr {
+    uint32_t addr4;
+    struct in6_addr addr6;
+};
+typedef union in4or6_addr in4or6_addr;
+
 /*
  * Our socket structure
  */
@@ -148,6 +155,8 @@ int sowrite(struct socket *);
 void sorecvfrom(struct socket *);
 int sosendto(struct socket *, struct mbuf *);
 struct socket *tcp_listen(Slirp *, uint32_t, unsigned, uint32_t, unsigned, int);
+struct socket *tcp6_listen(Slirp *, struct in6_addr, u_int,
+                           struct in6_addr, u_int, int);
 void soisfconnecting(register struct socket *);
 void soisfconnected(register struct socket *);
 void sofwdrain(struct socket *);
src/udp.c +58 -15

100 lines not on this page · raw message

src/udp.h +2 -0
index c3b83fd..b3fbeac 100644
@@ -80,6 +80,8 @@ void udp_input(register struct mbuf *, int);
 int udp_attach(struct socket *, unsigned short af);
 void udp_detach(struct socket *);
 struct socket *udp_listen(Slirp *, uint32_t, unsigned, uint32_t, unsigned, int);
+struct socket *udp6_listen(Slirp *slirp, struct in6_addr, u_int,
+                            struct in6_addr, u_int, int);
 int udp_output(struct socket *so, struct mbuf *m, struct sockaddr_in *saddr,
                struct sockaddr_in *daddr, int iptos);
 
Signature · 1 line
2.30.0.296.g2bfb1c46d8-goog
author
#2 lore raw

PATCH 2/2 net: Add ipv6_hostfwd option

In reply to dje--- via
---
 hmp-commands.hx     |  29 ++++-
 include/net/slirp.h |   2 +
 net/slirp.c         | 311 +++++++++++++++++++++++++++++++++++---------
 qapi/net.json       |   1 +
 slirp               |   2 +-
 5 files changed, 279 insertions(+), 66 deletions(-)
hmp-commands.hx +28 -1
index 73e0832ea1..fa404123b7 100644
@@ -1398,6 +1398,34 @@ SRST
   Remove host-to-guest TCP or UDP redirection.
 ERST
 
+#ifdef CONFIG_SLIRP
+    {
+        .name       = "ipv6_hostfwd_add",
+        .args_type  = "arg1:s,arg2:s?",
+        .params     = "[netdev_id] [tcp|udp]:[hostaddr6]:hostport-[guestaddr6]:guestport",
+        .help       = "redirect TCP6 or UDP6 connections from host to guest (requires -net user)",
+        .cmd        = hmp_ipv6_hostfwd_add,
+    },
+#endif
+SRST
+``ipv6_hostfwd_add``
+  Redirect TCP6 or UDP6 connections from host to guest (requires -net user).
+ERST
+
+#ifdef CONFIG_SLIRP
+    {
+        .name       = "ipv6_hostfwd_remove",
+        .args_type  = "arg1:s,arg2:s?",
+        .params     = "[netdev_id] [tcp|udp]:[hostaddr6]:hostport",
+        .help       = "remove host-to-guest TCP6 or UDP6 redirection",
+        .cmd        = hmp_ipv6_hostfwd_remove,
+    },
+#endif
+SRST
+``ipv6_hostfwd_remove``
+  Remove host-to-guest TCP6 or UDP6 redirection.
+ERST
+
     {
         .name       = "balloon",
         .args_type  = "value:M",
@@ -1866,4 +1894,3 @@ ERST
         .sub_table  = hmp_info_cmds,
         .flags      = "p",
     },
-
include/net/slirp.h +2 -0
index bad3e1e241..4796a5cd39 100644
@@ -29,6 +29,8 @@
 
 void hmp_hostfwd_add(Monitor *mon, const QDict *qdict);
 void hmp_hostfwd_remove(Monitor *mon, const QDict *qdict);
+void hmp_ipv6_hostfwd_add(Monitor *mon, const QDict *qdict);
+void hmp_ipv6_hostfwd_remove(Monitor *mon, const QDict *qdict);
 
 void hmp_info_usernet(Monitor *mon, const QDict *qdict);
 
net/slirp.c +247 -64

409 lines not on this page · raw message

qapi/net.json +1 -0
index c31748c87f..34ea92277c 100644
@@ -189,6 +189,7 @@
     '*smb':       'str',
     '*smbserver': 'str',
     '*hostfwd':   ['String'],
+    '*ipv6-hostfwd': ['String'],
     '*guestfwd':  ['String'],
     '*tftp-server-name': 'str' } }
 
slirp +1 -1
index 8f43a99191..6c0db866ef 160000
@@ -1 +1 @@
-Subproject commit 8f43a99191afb47ca3f3c6972f6306209f367ece
+Subproject commit 6c0db866ef5e11a3b87640e57769fbf9b0a1e3b8
Signature · 1 line
2.30.0.296.g2bfb1c46d8-goog
#3 lore raw

Re: [PATCH 2/2] net: Add ipv6_hostfwd option

Quoted 2 lines · dje--- via

---

Rather light on the commit message description. The one-line summary does a good job of saying "what" the commit does, but the rest of the commit body should say "why" the commit is worthwhile, rather than being silent.

Quoted 10 lines
 hmp-commands.hx     |  29 ++++-
 include/net/slirp.h |   2 +
 net/slirp.c         | 311 +++++++++++++++++++++++++++++++++++---------
 qapi/net.json       |   1 +
 slirp               |   2 +-
 5 files changed, 279 insertions(+), 66 deletions(-)

+++ b/qapi/net.json

qapi/net.json line 192

Quoted 4 lines
qapi/net.json +1 -0
@@ -189,6 +189,7 @@
     '*smb':       'str',
     '*smbserver': 'str',
     '*hostfwd':   ['String'],
+    '*ipv6-hostfwd': ['String'],

Missing documentation, including a 'since 6.0' tag on the new member.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#4 lore raw
In reply to dje--- via

Hi Doug,

Quoted 6 lines · dje--- via

Hi. This patchset takes the original patch from Maxim,
https://www.mail-archive.com/[email protected]/msg569573.html
and updates it.

The first patch is the slirp additions, the second patch adds the u/i.

libslirp is maintained on gitlab. Can you open a merge request?
https://gitlab.freedesktop.org/slirp/libslirp/-/merge_requests

thanks

Quoted 26 lines

Doug Evans (2):
slirp: Add ipv6 hostfwd support
net: Add ipv6_hostfwd option

Slirp:

 src/libslirp.h |   6 +++
 src/slirp.c    |  51 +++++++++++++++++++++--
 src/socket.c   | 109 +++++++++++++++++++++++++++++++++++--------------
 src/socket.h   |   9 ++++
 src/udp.c      |  73 ++++++++++++++++++++++++++-------
 src/udp.h      |   2 +
 6 files changed, 202 insertions(+), 48 deletions(-)

QEMU:

 hmp-commands.hx     |  29 ++++-
 include/net/slirp.h |   2 +
 net/slirp.c         | 311 +++++++++++++++++++++++++++++++++++---------
 qapi/net.json       |   1 +
 slirp               |   2 +-
 5 files changed, 279 insertions(+), 66 deletions(-)

--
2.30.0.296.g2bfb1c46d8-goog

Signature · 1 line
Marc-André Lureau
author
#5 lore raw
Quoted 8 lines · Marc-André Lureau

Hi Doug,

Quoted 5 lines · dje--- via

Hi. This patchset takes the original patch from Maxim,
https://www.mail-archive.com/[email protected]/msg569573.html
and updates it.

Quoted 7 lines
Quoted 1 line

The first patch is the slirp additions, the second patch adds the u/i.

libslirp is maintained on gitlab. Can you open a merge request?
https://gitlab.freedesktop.org/slirp/libslirp/-/merge_requests

thanks

Hi. Sure, no problem.
I wasn't sure what the procedure is but figured it would come out during the review.
How does review of libslirp patches work?
I gather Samuel is a libslirp maintainer so I'm guessing it just needs to be approved here (after appropriate review) and then afterwards I should file the merge request?

Quoted 32 lines
Quoted 23 lines

Doug Evans (2):
slirp: Add ipv6 hostfwd support
net: Add ipv6_hostfwd option

Slirp:

 src/libslirp.h |   6 +++
 src/slirp.c    |  51 +++++++++++++++++++++--
 src/socket.c   | 109 +++++++++++++++++++++++++++++++++++--------------
 src/socket.h   |   9 ++++
 src/udp.c      |  73 ++++++++++++++++++++++++++-------
 src/udp.h      |   2 +
 6 files changed, 202 insertions(+), 48 deletions(-)

QEMU:

 hmp-commands.hx     |  29 ++++-
 include/net/slirp.h |   2 +
 net/slirp.c         | 311 +++++++++++++++++++++++++++++++++++---------
 qapi/net.json       |   1 +
 slirp               |   2 +-
 5 files changed, 279 insertions(+), 66 deletions(-)
Quoted 4 lines

--
2.30.0.296.g2bfb1c46d8-goog

--
Marc-André Lureau

#6 lore raw

Hi Doug

Quoted 16 lines · Doug Evans
Quoted 14 lines · Marc-André Lureau

Hi Doug,

Quoted 6 lines · dje--- via

Hi. This patchset takes the original patch from Maxim,
https://www.mail-archive.com/[email protected]/msg569573.html
and updates it.

The first patch is the slirp additions, the second patch adds the u/i.

libslirp is maintained on gitlab. Can you open a merge request?
https://gitlab.freedesktop.org/slirp/libslirp/-/merge_requests

Quoted 7 lines
Quoted 1 line

thanks

Hi. Sure, no problem.
I wasn't sure what the procedure is but figured it would come out during the review. How does review of libslirp patches work?

We do the reviews on the gitlab MR (of the individual patches).

Quoted 1 line

I gather Samuel is a libslirp maintainer so I'm guessing it just needs to be approved here (after appropriate review) and then afterwards I should file the merge request?

Any of the libslirp maintainer can merge after reviews (including me).

Then anybody can propose a patch to update libslirp in qemu, get reviews/comments, and Samuel can send the pull request. Sometimes someone else sends it.

Note that libslirp is packaged in a number of distributions these days
(https://repology.org/project/libslirp/versions), and that qemu may link to it depending on how it is built.