Patchwork net: Include the peer's information in VLANClientState->info_str when using the udp socket backend.

login
register
mail settings
Submitter Benjamin
Date May 6, 2012, 3:21 p.m.
Message ID <1336317667-3484-1-git-send-email-mlspirat42@gmail.com>
Download mbox | patch
Permalink /patch/157065/
State New
Headers show

Comments

Benjamin - May 6, 2012, 3:21 p.m.
Signed-off-by: Benjamin MARSILI <mlspirat42@gmail.com>
---

It makes it easier to debug and figure out what's going on behind the scene.

When using this syntax:
-device DEVICE,netdev=ID -netdev socket,id=ID,udp=LHOST:LPORT,localaddr=RHOST:RPORT

Before:

(qemu) info network
Devices not on any VLAN:
  rtl8139.0: type=nic,model=rtl8139,macaddr=00:ab:29:8c:3e:00
   \ gns3-0: type=socket,socket: udp=127.0.0.1:20003
  rtl8139.1: type=nic,model=rtl8139,macaddr=00:ab:29:8c:3e:01
   \ gns3-1: type=socket,socket: udp=127.0.0.1:20002

After:

(qemu) info network
Devices not on any VLAN:
  rtl8139.0: type=nic,model=rtl8139,macaddr=00:ab:29:8c:3e:00
   \ gns3-0: type=socket,socket: udp=127.0.0.1:20003, localaddr=127.0.0.1,20004
  rtl8139.1: type=nic,model=rtl8139,macaddr=00:ab:29:8c:3e:01
   \ gns3-1: type=socket,socket: udp=127.0.0.1:20002, localaddr=127.0.0.1,10000

 net/socket.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

--
1.7.6
Benjamin - May 31, 2012, 6:15 a.m.
It's a trivial patch, IIRC I should send it somewhere else, right?

On Mon, May 7, 2012 at 12:21 AM, Benjamin MARSILI <mlspirat42@gmail.com>wrote:

>
> Signed-off-by: Benjamin MARSILI <mlspirat42@gmail.com>
> ---
>
> It makes it easier to debug and figure out what's going on behind the
> scene.
>
> When using this syntax:
> -device DEVICE,netdev=ID -netdev
> socket,id=ID,udp=LHOST:LPORT,localaddr=RHOST:RPORT
>
> Before:
>
> (qemu) info network
> Devices not on any VLAN:
>  rtl8139.0: type=nic,model=rtl8139,macaddr=00:ab:29:8c:3e:00
>   \ gns3-0: type=socket,socket: udp=127.0.0.1:20003
>  rtl8139.1: type=nic,model=rtl8139,macaddr=00:ab:29:8c:3e:01
>   \ gns3-1: type=socket,socket: udp=127.0.0.1:20002
>
> After:
>
> (qemu) info network
> Devices not on any VLAN:
>  rtl8139.0: type=nic,model=rtl8139,macaddr=00:ab:29:8c:3e:00
>   \ gns3-0: type=socket,socket: udp=127.0.0.1:20003,
> localaddr=127.0.0.1,20004
>  rtl8139.1: type=nic,model=rtl8139,macaddr=00:ab:29:8c:3e:01
>   \ gns3-1: type=socket,socket: udp=127.0.0.1:20002,
> localaddr=127.0.0.1,10000
>
>  net/socket.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/net/socket.c b/net/socket.c
> index 0bcf229..7613990 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -580,8 +580,9 @@ static int net_socket_udp_init(VLANState *vlan,
>     s->dgram_dst = raddr;
>
>     snprintf(s->nc.info_str, sizeof(s->nc.info_str),
> -             "socket: udp=%s:%d",
> -             inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port));
> +             "socket: udp=%s:%d, localaddr=%s,%d",
> +             inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port),
> +             inet_ntoa(laddr.sin_addr), ntohs(laddr.sin_port));
>     return 0;
>  }
>
> --
> 1.7.6
>
>

Patch

diff --git a/net/socket.c b/net/socket.c
index 0bcf229..7613990 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -580,8 +580,9 @@  static int net_socket_udp_init(VLANState *vlan,
     s->dgram_dst = raddr;

     snprintf(s->nc.info_str, sizeof(s->nc.info_str),
-             "socket: udp=%s:%d",
-             inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port));
+             "socket: udp=%s:%d, localaddr=%s,%d",
+             inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port),
+             inet_ntoa(laddr.sin_addr), ntohs(laddr.sin_port));
     return 0;
 }