From patchwork Mon Jan 14 00:03:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 10761567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF0EF91E for ; Mon, 14 Jan 2019 00:55:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC07B2893A for ; Mon, 14 Jan 2019 00:55:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AED8C28989; Mon, 14 Jan 2019 00:55:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F9852893A for ; Mon, 14 Jan 2019 00:55:55 +0000 (UTC) Received: from localhost ([127.0.0.1]:50065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1giqXi-00082M-Ns for patchwork-qemu-devel@patchwork.kernel.org; Sun, 13 Jan 2019 19:55:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gipkc-0003Oj-8r for qemu-devel@nongnu.org; Sun, 13 Jan 2019 19:05:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gipka-0006l5-EV for qemu-devel@nongnu.org; Sun, 13 Jan 2019 19:05:10 -0500 Received: from hera.aquilenet.fr ([2a0c:e300::1]:57496) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gipka-0006ag-3n for qemu-devel@nongnu.org; Sun, 13 Jan 2019 19:05:08 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 853D81B90; Mon, 14 Jan 2019 01:04:39 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bKss2PHoDmUu; Mon, 14 Jan 2019 01:04:38 +0100 (CET) Received: from function.home (lfbn-1-11161-124.w86-213.abo.wanadoo.fr [86.213.235.124]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 3C81A1BC3; Mon, 14 Jan 2019 01:04:10 +0100 (CET) Received: from samy by function.home with local (Exim 4.92-RC4) (envelope-from ) id 1gipjb-0007pB-2Q; Mon, 14 Jan 2019 01:04:07 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org Date: Mon, 14 Jan 2019 01:03:09 +0100 Message-Id: <20190114000326.29847-49-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114000326.29847-1-samuel.thibault@ens-lyon.org> References: <20190114000326.29847-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a0c:e300::1 Subject: [Qemu-devel] [PULL 48/65] slirp: rename exec_list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau This list is not only used to handle command to execute on guest connection, it can also redirect to an arbitrary object, such as a chardev. Let's rename the struct and the field to "guestfwd". Signed-off-by: Marc-André Lureau Signed-off-by: Samuel Thibault --- slirp/misc.c | 6 +++--- slirp/misc.h | 6 +++--- slirp/slirp.c | 18 +++++++++--------- slirp/slirp.h | 2 +- slirp/tcp_input.c | 6 +++--- slirp/tcp_subr.c | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/slirp/misc.c b/slirp/misc.c index 2d092624d3..526cefa0f1 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -36,10 +36,10 @@ remque(void *a) element->qh_rlink = NULL; } -int add_exec(struct ex_list **ex_ptr, void *chardev, const char *cmdline, +int add_exec(struct gfwd_list **ex_ptr, void *chardev, const char *cmdline, struct in_addr addr, int port) { - struct ex_list *tmp_ptr; + struct gfwd_list *tmp_ptr; /* First, check if the port is "bound" */ for (tmp_ptr = *ex_ptr; tmp_ptr; tmp_ptr = tmp_ptr->ex_next) { @@ -49,7 +49,7 @@ int add_exec(struct ex_list **ex_ptr, void *chardev, const char *cmdline, } tmp_ptr = *ex_ptr; - *ex_ptr = g_new0(struct ex_list, 1); + *ex_ptr = g_new0(struct gfwd_list, 1); (*ex_ptr)->ex_fport = port; (*ex_ptr)->ex_addr = addr; if (chardev) { diff --git a/slirp/misc.h b/slirp/misc.h index 0bc5e74bc5..1df707c052 100644 --- a/slirp/misc.h +++ b/slirp/misc.h @@ -8,12 +8,12 @@ #ifndef MISC_H #define MISC_H -struct ex_list { +struct gfwd_list { void *ex_chardev; struct in_addr ex_addr; /* Server address */ int ex_fport; /* Port to telnet to */ char *ex_exec; /* Command line of what to exec */ - struct ex_list *ex_next; + struct gfwd_list *ex_next; }; #define EMU_NONE 0x0 @@ -51,7 +51,7 @@ struct slirp_quehead { void slirp_insque(void *, void *); void slirp_remque(void *); -int add_exec(struct ex_list **, void *, const char *, struct in_addr, int); +int add_exec(struct gfwd_list **, void *, const char *, struct in_addr, int); int fork_exec(struct socket *so, const char *ex); #endif diff --git a/slirp/slirp.c b/slirp/slirp.c index 591dd1fcb4..e860750f72 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -345,9 +345,9 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, void slirp_cleanup(Slirp *slirp) { - struct ex_list *e, *next; + struct gfwd_list *e, *next; - for (e = slirp->exec_list; e; e = next) { + for (e = slirp->guestfwd_list; e; e = next) { next = e->ex_next; g_free(e->ex_exec); g_free(e); @@ -760,7 +760,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) struct ethhdr *reh = (struct ethhdr *)arp_reply; struct slirp_arphdr *rah = (struct slirp_arphdr *)(arp_reply + ETH_HLEN); int ar_op; - struct ex_list *ex_ptr; + struct gfwd_list *ex_ptr; if (!slirp->in_enabled) { return; @@ -780,7 +780,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) if (ah->ar_tip == slirp->vnameserver_addr.s_addr || ah->ar_tip == slirp->vhost_addr.s_addr) goto arp_ok; - for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { + for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if (ex_ptr->ex_addr.s_addr == ah->ar_tip) goto arp_ok; } @@ -1052,7 +1052,7 @@ int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline, return -1; } - return add_exec(&slirp->exec_list, chardev, cmdline, *guest_addr, + return add_exec(&slirp->guestfwd_list, chardev, cmdline, *guest_addr, htons(guest_port)); } @@ -1423,9 +1423,9 @@ static const VMStateDescription vmstate_slirp = { static void slirp_state_save(QEMUFile *f, void *opaque) { Slirp *slirp = opaque; - struct ex_list *ex_ptr; + struct gfwd_list *ex_ptr; - for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) + for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) if (ex_ptr->ex_chardev) { struct socket *so; so = slirp_find_ctl_socket(slirp, ex_ptr->ex_addr, @@ -1445,7 +1445,7 @@ static void slirp_state_save(QEMUFile *f, void *opaque) static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) { Slirp *slirp = opaque; - struct ex_list *ex_ptr; + struct gfwd_list *ex_ptr; while (qemu_get_byte(f)) { int ret; @@ -1460,7 +1460,7 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) slirp->vnetwork_addr.s_addr) { return -EINVAL; } - for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { + for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if (ex_ptr->ex_chardev && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr && so->so_fport == ex_ptr->ex_fport) { diff --git a/slirp/slirp.h b/slirp/slirp.h index fdf397256b..9aa245715d 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -147,7 +147,7 @@ struct Slirp { char client_hostname[33]; int restricted; - struct ex_list *exec_list; + struct gfwd_list *guestfwd_list; /* mbuf states */ struct quehead m_freelist; diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c index c4d7abf1fa..f1cddce992 100644 --- a/slirp/tcp_input.c +++ b/slirp/tcp_input.c @@ -211,7 +211,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af) struct sockaddr_storage lhost, fhost; struct sockaddr_in *lhost4, *fhost4; struct sockaddr_in6 *lhost6, *fhost6; - struct ex_list *ex_ptr; + struct gfwd_list *ex_ptr; Slirp *slirp; DEBUG_CALL("tcp_input"); @@ -394,7 +394,7 @@ findso: * for non-hostfwd connections. These should be dropped, unless it * happens to be a guestfwd. */ - for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { + for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if (ex_ptr->ex_fport == ti->ti_dport && ti->ti_dst.s_addr == ex_ptr->ex_addr.s_addr) { break; @@ -616,7 +616,7 @@ findso: if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr && so->so_faddr.s_addr != slirp->vnameserver_addr.s_addr) { /* May be an add exec */ - for (ex_ptr = slirp->exec_list; ex_ptr; + for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if(ex_ptr->ex_fport == so->so_fport && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) { diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index 00cee73163..3b14684107 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -949,14 +949,14 @@ int tcp_ctl(struct socket *so) { Slirp *slirp = so->slirp; struct sbuf *sb = &so->so_snd; - struct ex_list *ex_ptr; + struct gfwd_list *ex_ptr; DEBUG_CALL("tcp_ctl"); DEBUG_ARG("so = %p", so); if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr) { /* Check if it's pty_exec */ - for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { + for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if (ex_ptr->ex_fport == so->so_fport && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) { if (ex_ptr->ex_chardev) {