* [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
@ 2009-04-25 21:30 Lionel Landwerlin
2009-04-27 17:21 ` Nathan Froyd
0 siblings, 1 reply; 10+ messages in thread
From: Lionel Landwerlin @ 2009-04-25 21:30 UTC (permalink / raw)
To: qemu-devel
linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
---
linux-user/syscall.c | 30 ++++++++++++++++++++++++++++++
linux-user/syscall_defs.h | 15 +++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0bc9902..42f1089 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -944,6 +944,24 @@ static abi_long do_select(int n,
return ret;
}
+static inline abi_long target_to_host_ip_mreq(struct ip_mreqn *mreqn,
+ abi_ulong target_addr,
+ socklen_t len)
+{
+ struct target_ip_mreqn *target_smreqn;
+
+ target_smreqn = lock_user(VERIFY_READ, target_addr, len, 1);
+ if (!target_smreqn)
+ return -TARGET_EFAULT;
+ mreqn->imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr;
+ mreqn->imr_address.s_addr = target_smreqn->imr_address.s_addr;
+ if (len == sizeof(struct target_ip_mreqn))
+ mreqn->imr_ifindex = tswapl(target_smreqn->imr_ifindex);
+ unlock_user(target_smreqn, target_addr, 0);
+
+ return 0;
+}
+
static inline abi_long target_to_host_sockaddr(struct sockaddr *addr,
abi_ulong target_addr,
socklen_t len)
@@ -1119,6 +1137,7 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
{
abi_long ret;
int val;
+ struct ip_mreqn *ip_mreq;
switch(level) {
case SOL_TCP:
@@ -1157,6 +1176,17 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
}
ret = get_errno(setsockopt(sockfd, level, optname, &val, sizeof(val)));
break;
+ case IP_ADD_MEMBERSHIP:
+ case IP_DROP_MEMBERSHIP:
+ if (optlen < sizeof (struct target_ip_mreq) ||
+ optlen > sizeof (struct target_ip_mreqn))
+ return -TARGET_EINVAL;
+
+ ip_mreq = (struct ip_mreqn *) alloca(optlen);
+ target_to_host_ip_mreq(ip_mreq, optval_addr, optlen);
+ ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq, optlen));
+ break;
+
default:
goto unimplemented;
}
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 7f0b0df..3284710 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -104,6 +104,21 @@ struct target_sockaddr {
uint8_t sa_data[14];
};
+struct target_in_addr {
+ uint32_t s_addr; /* big endian */
+};
+
+struct target_ip_mreq {
+ struct target_in_addr imr_multiaddr;
+ struct target_in_addr imr_address;
+};
+
+struct target_ip_mreqn {
+ struct target_in_addr imr_multiaddr;
+ struct target_in_addr imr_address;
+ abi_long imr_ifindex;
+};
+
struct target_timeval {
abi_long tv_sec;
abi_long tv_usec;
--
1.6.2.4
--
Lionel Landwerlin <lionel.landwerlin@openwide.fr>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
2009-04-25 21:30 [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt Lionel Landwerlin
@ 2009-04-27 17:21 ` Nathan Froyd
2009-04-27 18:05 ` Lionel Landwerlin
0 siblings, 1 reply; 10+ messages in thread
From: Nathan Froyd @ 2009-04-27 17:21 UTC (permalink / raw)
To: qemu-devel
On Sat, Apr 25, 2009 at 11:30:19PM +0200, Lionel Landwerlin wrote:
> linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
Should these be TARGET_IP_* instead, or are they like the FUTEX_*
constants and the same on every platform? If the latter, at the very
least there should be explanatory comments somewhere--just making them
TARGET_IP_* would be even better, IMHO.
-Nathan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
2009-04-27 17:21 ` Nathan Froyd
@ 2009-04-27 18:05 ` Lionel Landwerlin
2009-04-29 18:00 ` Riku Voipio
0 siblings, 1 reply; 10+ messages in thread
From: Lionel Landwerlin @ 2009-04-27 18:05 UTC (permalink / raw)
To: Nathan Froyd, qemu-devel
Le lundi 27 avril 2009 à 10:21 -0700, Nathan Froyd a écrit :
> On Sat, Apr 25, 2009 at 11:30:19PM +0200, Lionel Landwerlin wrote:
> > linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
>
> Should these be TARGET_IP_* instead, or are they like the FUTEX_*
> constants and the same on every platform? If the latter, at the very
> least there should be explanatory comments somewhere--just making them
> TARGET_IP_* would be even better, IMHO.
>
> -Nathan
>
>
I'm agree too, I just did the way it was before...
--
Lionel Landwerlin <lionel.landwerlin@openwide.fr>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
2009-04-27 18:05 ` Lionel Landwerlin
@ 2009-04-29 18:00 ` Riku Voipio
2009-04-29 20:35 ` Jamie Lokier
0 siblings, 1 reply; 10+ messages in thread
From: Riku Voipio @ 2009-04-29 18:00 UTC (permalink / raw)
To: Lionel Landwerlin; +Cc: qemu-devel, Nathan Froyd
On Mon, Apr 27, 2009 at 08:05:06PM +0200, Lionel Landwerlin wrote:
> Le lundi 27 avril 2009 à 10:21 -0700, Nathan Froyd a écrit :
> > On Sat, Apr 25, 2009 at 11:30:19PM +0200, Lionel Landwerlin wrote:
> > > linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
> > Should these be TARGET_IP_* instead, or are they like the FUTEX_*
> > constants and the same on every platform? If the latter, at the very
> > least there should be explanatory comments somewhere--just making them
> > TARGET_IP_* would be even better, IMHO.
> I'm agree too, I just did the way it was before...
These are defined in include/linux/in.h so they should be same on all archs?
Cheers,
Riku
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
2009-04-29 18:00 ` Riku Voipio
@ 2009-04-29 20:35 ` Jamie Lokier
2009-04-29 20:43 ` Riku Voipio
2009-04-29 23:08 ` Lionel Landwerlin
0 siblings, 2 replies; 10+ messages in thread
From: Jamie Lokier @ 2009-04-29 20:35 UTC (permalink / raw)
To: Riku Voipio; +Cc: Lionel Landwerlin, Nathan Froyd, qemu-devel
Riku Voipio wrote:
> On Mon, Apr 27, 2009 at 08:05:06PM +0200, Lionel Landwerlin wrote:
> > Le lundi 27 avril 2009 à 10:21 -0700, Nathan Froyd a écrit :
> > > On Sat, Apr 25, 2009 at 11:30:19PM +0200, Lionel Landwerlin wrote:
> > > > linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
>
> > > Should these be TARGET_IP_* instead, or are they like the FUTEX_*
> > > constants and the same on every platform? If the latter, at the very
> > > least there should be explanatory comments somewhere--just making them
> > > TARGET_IP_* would be even better, IMHO.
>
> > I'm agree too, I just did the way it was before...
>
> These are defined in include/linux/in.h so they should be same on all archs?
But what if you're compiling for a non-Linux host?
IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP are standard BSD sockets options,
found everywhere, even on Windows I think.
-- Jamie
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
2009-04-29 20:35 ` Jamie Lokier
@ 2009-04-29 20:43 ` Riku Voipio
2009-04-29 21:00 ` Jamie Lokier
2009-04-29 23:08 ` Lionel Landwerlin
1 sibling, 1 reply; 10+ messages in thread
From: Riku Voipio @ 2009-04-29 20:43 UTC (permalink / raw)
To: Jamie Lokier; +Cc: Riku Voipio, Lionel Landwerlin, Nathan Froyd, qemu-devel
On Wed, Apr 29, 2009 at 09:35:52PM +0100, Jamie Lokier wrote:
> Riku Voipio wrote:
> > These are defined in include/linux/in.h so they should be same on all archs?
> But what if you're compiling for a non-Linux host?
Generally speaking if you comple Qemu Linux-user on a non-Linux host you
just fail. With or without this patch.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
2009-04-29 20:43 ` Riku Voipio
@ 2009-04-29 21:00 ` Jamie Lokier
2009-04-29 21:41 ` Riku Voipio
0 siblings, 1 reply; 10+ messages in thread
From: Jamie Lokier @ 2009-04-29 21:00 UTC (permalink / raw)
To: Riku Voipio; +Cc: Lionel Landwerlin, Nathan Froyd, qemu-devel
Riku Voipio wrote:
> On Wed, Apr 29, 2009 at 09:35:52PM +0100, Jamie Lokier wrote:
> > Riku Voipio wrote:
> > > These are defined in include/linux/in.h so they should be same on all archs?
>
> > But what if you're compiling for a non-Linux host?
>
> Generally speaking if you comple Qemu Linux-user on a non-Linux host you
> just fail. With or without this patch.
Oh. Are non-Linux hosts officially not supported, or is this just a
matter of some things being broken?
-- Jamie
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
2009-04-29 21:00 ` Jamie Lokier
@ 2009-04-29 21:41 ` Riku Voipio
2009-04-30 2:41 ` Jamie Lokier
0 siblings, 1 reply; 10+ messages in thread
From: Riku Voipio @ 2009-04-29 21:41 UTC (permalink / raw)
To: Jamie Lokier, qemu-devel, Nathan Froyd
On Wed, Apr 29, 2009 at 10:00:18PM +0100, Jamie Lokier wrote:
> Riku Voipio wrote:
> > On Wed, Apr 29, 2009 at 09:35:52PM +0100, Jamie Lokier wrote:
> > > Riku Voipio wrote:
> > > > These are defined in include/linux/in.h so they should be same on all archs?
> >
> > > But what if you're compiling for a non-Linux host?
> >
> > Generally speaking if you comple Qemu Linux-user on a non-Linux host you
> > just fail. With or without this patch.
> Oh. Are non-Linux hosts officially not supported, or is this just a
> matter of some things being broken?
It is not officially supported. There are just too many places in the
current linux-user code that expect a linux host. Thou there has been
interest in working those bits to be more generic recently. recently.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
2009-04-29 21:41 ` Riku Voipio
@ 2009-04-30 2:41 ` Jamie Lokier
0 siblings, 0 replies; 10+ messages in thread
From: Jamie Lokier @ 2009-04-30 2:41 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel, Nathan Froyd
Riku Voipio wrote:
> On Wed, Apr 29, 2009 at 10:00:18PM +0100, Jamie Lokier wrote:
> > Riku Voipio wrote:
> > > On Wed, Apr 29, 2009 at 09:35:52PM +0100, Jamie Lokier wrote:
> > > > Riku Voipio wrote:
> > > > > These are defined in include/linux/in.h so they should be same on all archs?
> > >
> > > > But what if you're compiling for a non-Linux host?
> > >
> > > Generally speaking if you comple Qemu Linux-user on a non-Linux host you
> > > just fail. With or without this patch.
>
> > Oh. Are non-Linux hosts officially not supported, or is this just a
> > matter of some things being broken?
>
> It is not officially supported. There are just too many places in the
> current linux-user code that expect a linux host. Thou there has been
> interest in working those bits to be more generic recently. recently.
If there's real interest in working those bits for other hosts,
*new* bits should use TARGET_ constants to avoid making life even
harder when it comes to finding places where'll they need to be
changed to TARGET_ later.
-- Jamie
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
2009-04-29 20:35 ` Jamie Lokier
2009-04-29 20:43 ` Riku Voipio
@ 2009-04-29 23:08 ` Lionel Landwerlin
1 sibling, 0 replies; 10+ messages in thread
From: Lionel Landwerlin @ 2009-04-29 23:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Nathan Froyd
Le mercredi 29 avril 2009 à 21:35 +0100, Jamie Lokier a écrit :
> Riku Voipio wrote:
> > On Mon, Apr 27, 2009 at 08:05:06PM +0200, Lionel Landwerlin wrote:
> > > Le lundi 27 avril 2009 à 10:21 -0700, Nathan Froyd a écrit :
> > > > On Sat, Apr 25, 2009 at 11:30:19PM +0200, Lionel Landwerlin wrote:
> > > > > linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
> >
> > > > Should these be TARGET_IP_* instead, or are they like the FUTEX_*
> > > > constants and the same on every platform? If the latter, at the very
> > > > least there should be explanatory comments somewhere--just making them
> > > > TARGET_IP_* would be even better, IMHO.
> >
> > > I'm agree too, I just did the way it was before...
> >
> > These are defined in include/linux/in.h so they should be same on all archs?
>
> But what if you're compiling for a non-Linux host?
>
> IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP are standard BSD sockets options,
> found everywhere, even on Windows I think.
Ok, so I think I can keep the patch as it is now
--
Lionel Landwerlin <lionel.landwerlin@openwide.fr>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-04-30 2:41 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-25 21:30 [Qemu-devel] [PATCH] linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt Lionel Landwerlin
2009-04-27 17:21 ` Nathan Froyd
2009-04-27 18:05 ` Lionel Landwerlin
2009-04-29 18:00 ` Riku Voipio
2009-04-29 20:35 ` Jamie Lokier
2009-04-29 20:43 ` Riku Voipio
2009-04-29 21:00 ` Jamie Lokier
2009-04-29 21:41 ` Riku Voipio
2009-04-30 2:41 ` Jamie Lokier
2009-04-29 23:08 ` Lionel Landwerlin
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.