linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
PATCH 1/1 linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
--- linux-user/syscall.c | 30 ++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 15 +++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-)
linux-user/syscall.c +30 -0
@@ -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; }
linux-user/syscall_defs.h +15 -0
@@ -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;
Signature · 5 lines
1.6.2.4 -- Lionel Landwerlin <[email protected]>
Quoted 1 line · Lionel Landwerlin
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
Quoted 11 lines · Nathan Froyd
Quoted 1 line · Lionel Landwerlin
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...
Signature · 1 line
Lionel Landwerlin <[email protected]>
Quoted 10 lines · Lionel Landwerlin
Quoted 7 lines · Nathan Froyd
Quoted 1 line · Lionel Landwerlin
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
Quoted 5 lines · Riku Voipio
Quoted 3 lines · Lionel Landwerlin
Quoted 2 lines · Nathan Froyd
Quoted 1 line · Lionel Landwerlin
linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
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.hso 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
Quoted 4 lines · Jamie Lokier
Quoted 1 line · Riku Voipio
These are defined in
include/linux/in.hso 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.
Quoted 8 lines · Riku Voipio
Quoted 4 lines · Jamie Lokier
Quoted 1 line · Riku Voipio
These are defined in
include/linux/in.hso 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
Quoted 5 lines · Jamie Lokier
Quoted 4 lines · Riku Voipio
Quoted 2 lines · Jamie Lokier
Quoted 1 line · Riku Voipio
These are defined in
include/linux/in.hso they should be same on all archs?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
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.
Quoted 11 lines · Riku Voipio
Quoted 9 lines · Jamie Lokier
Quoted 8 lines · Riku Voipio
Quoted 4 lines · Jamie Lokier
Quoted 1 line · Riku Voipio
These are defined in
include/linux/in.hso 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.
Quoted 6 lines
Quoted 2 lines
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
Quoted 11 lines · Jamie Lokier
Quoted 10 lines · Riku Voipio
Quoted 8 lines · Lionel Landwerlin
Quoted 7 lines · Nathan Froyd
Quoted 1 line · Lionel Landwerlin
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.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
I'm agree too, I just did the way it was before...
These are defined in
include/linux/in.hso 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
Signature · 1 line
Lionel Landwerlin <[email protected]>