qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE)
@ 2014-07-12 13:47 Joakim Tjernlund
  2014-07-12 13:47 ` [Qemu-devel] [PATCH 2/2 v3] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr Joakim Tjernlund
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Joakim Tjernlund @ 2014-07-12 13:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Joakim Tjernlund

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---
 linux-user/syscall.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 57c1664..3ef046a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1497,6 +1497,25 @@ set_timeout:
                 unlock_user_struct(tfprog, optval_addr, 1);
                 return ret;
         }
+	case TARGET_SO_BINDTODEVICE:
+	{
+		char *dev_ifname, *addr_ifname;
+
+		if (optlen > IFNAMSIZ - 1) {
+		    optlen = IFNAMSIZ - 1;
+		}
+		dev_ifname = lock_user(VERIFY_READ, optval_addr, optlen, 1);
+		if (!dev_ifname) {
+		    return -TARGET_EFAULT;
+		}
+		optname = SO_BINDTODEVICE;
+		addr_ifname = alloca(IFNAMSIZ);
+		memcpy(addr_ifname, dev_ifname, optlen);
+		addr_ifname[optlen] = 0;
+		ret = get_errno(setsockopt(sockfd, level, optname, addr_ifname, optlen));
+		unlock_user (dev_ifname, optval_addr, 0);
+		return ret;
+	}
             /* Options with 'int' argument.  */
         case TARGET_SO_DEBUG:
 		optname = SO_DEBUG;
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 2/2 v3] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr
  2014-07-12 13:47 [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) Joakim Tjernlund
@ 2014-07-12 13:47 ` Joakim Tjernlund
  2014-07-12 16:32   ` Peter Maydell
  2014-07-15 13:33   ` Riku Voipio
  2014-07-12 16:31 ` [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) Peter Maydell
  2014-07-15 13:33 ` Riku Voipio
  2 siblings, 2 replies; 6+ messages in thread
From: Joakim Tjernlund @ 2014-07-12 13:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Joakim Tjernlund

Implement conversion of the AF_PACKET sockaddr subtype
in target_to_host_sockaddr.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---
 linux-user/syscall.c      |  7 +++++++
 linux-user/syscall_defs.h | 10 ++++++++++
 2 files changed, 17 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3ef046a..a50229d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1140,6 +1140,13 @@ static inline abi_long target_to_host_sockaddr(struct sockaddr *addr,
 
     memcpy(addr, target_saddr, len);
     addr->sa_family = sa_family;
+    if (sa_family == AF_PACKET) {
+	struct target_sockaddr_ll *lladdr;
+
+	lladdr = (struct target_sockaddr_ll *)addr;
+	lladdr->sll_ifindex = tswap32(lladdr->sll_ifindex);
+	lladdr->sll_hatype = tswap16(lladdr->sll_hatype);
+    }
     unlock_user(target_saddr, target_addr, 0);
 
     return 0;
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 8563027..c9e6323 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -121,6 +121,16 @@ struct target_sockaddr {
     uint8_t sa_data[14];
 };
 
+struct target_sockaddr_ll {
+    uint16_t sll_family;   /* Always AF_PACKET */
+    uint16_t sll_protocol; /* Physical layer protocol */
+    int      sll_ifindex;  /* Interface number */
+    uint16_t sll_hatype;   /* ARP hardware type */
+    uint8_t  sll_pkttype;  /* Packet type */
+    uint8_t  sll_halen;    /* Length of address */
+    uint8_t  sll_addr[8];  /* Physical layer address */
+};
+
 struct target_sock_filter {
     abi_ushort code;
     uint8_t jt;
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE)
  2014-07-12 13:47 [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) Joakim Tjernlund
  2014-07-12 13:47 ` [Qemu-devel] [PATCH 2/2 v3] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr Joakim Tjernlund
@ 2014-07-12 16:31 ` Peter Maydell
  2014-07-15 13:33 ` Riku Voipio
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2014-07-12 16:31 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: Riku Voipio, QEMU Developers

On 12 July 2014 14:47, Joakim Tjernlund <Joakim.Tjernlund@transmode.se> wrote:

[cc'ing Riku who's the linux-user maintainer.]

> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> ---
>  linux-user/syscall.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 57c1664..3ef046a 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1497,6 +1497,25 @@ set_timeout:
>                  unlock_user_struct(tfprog, optval_addr, 1);
>                  return ret;
>          }
> +       case TARGET_SO_BINDTODEVICE:
> +       {
> +               char *dev_ifname, *addr_ifname;
> +
> +               if (optlen > IFNAMSIZ - 1) {
> +                   optlen = IFNAMSIZ - 1;
> +               }
> +               dev_ifname = lock_user(VERIFY_READ, optval_addr, optlen, 1);
> +               if (!dev_ifname) {
> +                   return -TARGET_EFAULT;
> +               }
> +               optname = SO_BINDTODEVICE;
> +               addr_ifname = alloca(IFNAMSIZ);
> +               memcpy(addr_ifname, dev_ifname, optlen);
> +               addr_ifname[optlen] = 0;
> +               ret = get_errno(setsockopt(sockfd, level, optname, addr_ifname, optlen));
> +               unlock_user (dev_ifname, optval_addr, 0);
> +               return ret;
> +       }
>              /* Options with 'int' argument.  */
>          case TARGET_SO_DEBUG:
>                 optname = SO_DEBUG;
> --
> 1.8.5.5

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2 v3] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr
  2014-07-12 13:47 ` [Qemu-devel] [PATCH 2/2 v3] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr Joakim Tjernlund
@ 2014-07-12 16:32   ` Peter Maydell
  2014-07-15 13:33   ` Riku Voipio
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2014-07-12 16:32 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: Riku Voipio, QEMU Developers

On 12 July 2014 14:47, Joakim Tjernlund <Joakim.Tjernlund@transmode.se> wrote:
> Implement conversion of the AF_PACKET sockaddr subtype
> in target_to_host_sockaddr.
>
> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> ---
>  linux-user/syscall.c      |  7 +++++++
>  linux-user/syscall_defs.h | 10 ++++++++++
>  2 files changed, 17 insertions(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 3ef046a..a50229d 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1140,6 +1140,13 @@ static inline abi_long target_to_host_sockaddr(struct sockaddr *addr,
>
>      memcpy(addr, target_saddr, len);
>      addr->sa_family = sa_family;
> +    if (sa_family == AF_PACKET) {
> +       struct target_sockaddr_ll *lladdr;
> +
> +       lladdr = (struct target_sockaddr_ll *)addr;
> +       lladdr->sll_ifindex = tswap32(lladdr->sll_ifindex);
> +       lladdr->sll_hatype = tswap16(lladdr->sll_hatype);
> +    }
>      unlock_user(target_saddr, target_addr, 0);
>
>      return 0;
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index 8563027..c9e6323 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -121,6 +121,16 @@ struct target_sockaddr {
>      uint8_t sa_data[14];
>  };
>
> +struct target_sockaddr_ll {
> +    uint16_t sll_family;   /* Always AF_PACKET */
> +    uint16_t sll_protocol; /* Physical layer protocol */
> +    int      sll_ifindex;  /* Interface number */
> +    uint16_t sll_hatype;   /* ARP hardware type */
> +    uint8_t  sll_pkttype;  /* Packet type */
> +    uint8_t  sll_halen;    /* Length of address */
> +    uint8_t  sll_addr[8];  /* Physical layer address */
> +};
> +
>  struct target_sock_filter {
>      abi_ushort code;
>      uint8_t jt;
> --

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE)
  2014-07-12 13:47 [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) Joakim Tjernlund
  2014-07-12 13:47 ` [Qemu-devel] [PATCH 2/2 v3] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr Joakim Tjernlund
  2014-07-12 16:31 ` [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) Peter Maydell
@ 2014-07-15 13:33 ` Riku Voipio
  2 siblings, 0 replies; 6+ messages in thread
From: Riku Voipio @ 2014-07-15 13:33 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: qemu-devel

On Sat, Jul 12, 2014 at 03:47:06PM +0200, Joakim Tjernlund wrote:
> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>

Thanks, applied to linux-user tree,
Riku

> ---
>  linux-user/syscall.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 57c1664..3ef046a 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1497,6 +1497,25 @@ set_timeout:
>                  unlock_user_struct(tfprog, optval_addr, 1);
>                  return ret;
>          }
> +	case TARGET_SO_BINDTODEVICE:
> +	{
> +		char *dev_ifname, *addr_ifname;
> +
> +		if (optlen > IFNAMSIZ - 1) {
> +		    optlen = IFNAMSIZ - 1;
> +		}
> +		dev_ifname = lock_user(VERIFY_READ, optval_addr, optlen, 1);
> +		if (!dev_ifname) {
> +		    return -TARGET_EFAULT;
> +		}
> +		optname = SO_BINDTODEVICE;
> +		addr_ifname = alloca(IFNAMSIZ);
> +		memcpy(addr_ifname, dev_ifname, optlen);
> +		addr_ifname[optlen] = 0;
> +		ret = get_errno(setsockopt(sockfd, level, optname, addr_ifname, optlen));
> +		unlock_user (dev_ifname, optval_addr, 0);
> +		return ret;
> +	}
>              /* Options with 'int' argument.  */
>          case TARGET_SO_DEBUG:
>  		optname = SO_DEBUG;
> -- 
> 1.8.5.5
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2 v3] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr
  2014-07-12 13:47 ` [Qemu-devel] [PATCH 2/2 v3] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr Joakim Tjernlund
  2014-07-12 16:32   ` Peter Maydell
@ 2014-07-15 13:33   ` Riku Voipio
  1 sibling, 0 replies; 6+ messages in thread
From: Riku Voipio @ 2014-07-15 13:33 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: qemu-devel

On Sat, Jul 12, 2014 at 03:47:07PM +0200, Joakim Tjernlund wrote:
> Implement conversion of the AF_PACKET sockaddr subtype
> in target_to_host_sockaddr.

Thanks, Applied to linux-user tree,

Riku

> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> ---
>  linux-user/syscall.c      |  7 +++++++
>  linux-user/syscall_defs.h | 10 ++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 3ef046a..a50229d 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1140,6 +1140,13 @@ static inline abi_long target_to_host_sockaddr(struct sockaddr *addr,
>  
>      memcpy(addr, target_saddr, len);
>      addr->sa_family = sa_family;
> +    if (sa_family == AF_PACKET) {
> +	struct target_sockaddr_ll *lladdr;
> +
> +	lladdr = (struct target_sockaddr_ll *)addr;
> +	lladdr->sll_ifindex = tswap32(lladdr->sll_ifindex);
> +	lladdr->sll_hatype = tswap16(lladdr->sll_hatype);
> +    }
>      unlock_user(target_saddr, target_addr, 0);
>  
>      return 0;
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index 8563027..c9e6323 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -121,6 +121,16 @@ struct target_sockaddr {
>      uint8_t sa_data[14];
>  };
>  
> +struct target_sockaddr_ll {
> +    uint16_t sll_family;   /* Always AF_PACKET */
> +    uint16_t sll_protocol; /* Physical layer protocol */
> +    int      sll_ifindex;  /* Interface number */
> +    uint16_t sll_hatype;   /* ARP hardware type */
> +    uint8_t  sll_pkttype;  /* Packet type */
> +    uint8_t  sll_halen;    /* Length of address */
> +    uint8_t  sll_addr[8];  /* Physical layer address */
> +};
> +
>  struct target_sock_filter {
>      abi_ushort code;
>      uint8_t jt;
> -- 
> 1.8.5.5
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-07-15 13:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-12 13:47 [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) Joakim Tjernlund
2014-07-12 13:47 ` [Qemu-devel] [PATCH 2/2 v3] linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr Joakim Tjernlund
2014-07-12 16:32   ` Peter Maydell
2014-07-15 13:33   ` Riku Voipio
2014-07-12 16:31 ` [Qemu-devel] [PATCH 1/2 v3] qemu-user: Impl. setsockopt(SO_BINDTODEVICE) Peter Maydell
2014-07-15 13:33 ` Riku Voipio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).