ipv4: make do_ip_setsockopt for IP_MULTICAST_IF support ip_mreq struct
Subsystems (3)
PATCH 2/2 ipv4: make do_ip_setsockopt for IP_MULTICAST_IF support ip_mreq struct
ip_mreq and ip_mreqn is almost the same, and do_ip_setsockopt for IP_MULTICAST_IF part supported ip_mreqn struct. This patch adds support for ip_mreq struct.
--- net/ipv4/ip_sockglue.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
net/ipv4/ip_sockglue.c +6 -1
@@ -612,11 +612,16 @@ static int do_ip_setsockopt(struct sock *sk, int level,*/ err = -EFAULT ; +memset (&mreq,0 ,sizeof (mreq)); +if (optlen >=sizeof (struct ip_mreqn )) {if (copy_from_user (&mreq, optval,sizeof (mreq)))break ; + }else if (optlen >=sizeof (struct ip_mreq )) { +if (copy_from_user (&mreq, optval, +sizeof (struct ip_mreq ))) +break ; }else if (optlen >=sizeof (struct in_addr )) { -memset (&mreq,0 ,sizeof (mreq));if (copy_from_user (&mreq.imr_address, optval,sizeof (struct in_addr )))break ;
Signature · 1 line
1.6.2.5
Xiaotian Feng wrote, at 09/17/2009 01:20 PM:
Quoted 3 lines
ip_mreqandip_mreqnis almost the same, anddo_ip_setsockoptforIP_MULTICAST_IFpart supportedip_mreqnstruct. This patch adds support forip_mreqstruct.
It's not meaning to support the ip_mreq struct, the imr_multiaddr member never be used by the IP_MULTICAST_IF.
In addition, using the option normally like this:
struct in_addr interface_addr;
setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, &interface_addr, sizeof(interface_addr));
Do your patch suggest using the option like this?
struct ip_mreq mreq;
setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, &mreq, sizeof(mreq));
Best Regards
-----
Shan Wei
Quoted 8 lines · Shan Wei
Xiaotian Feng wrote, at 09/17/2009 01:20 PM:
Quoted 3 lines
ip_mreqandip_mreqnis almost the same, anddo_ip_setsockoptforIP_MULTICAST_IFpart supportedip_mreqnstruct. This patch adds support forip_mreqstruct.It's not meaning to support the
ip_mreqstruct, theimr_multiaddrmember never be used by theIP_MULTICAST_IF.
Quoted 8 lines
In addition, using the option normally like this:
struct in_addr interface_addr; setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF,&interface_addr, sizeof(interface_addr));Do your patch suggest using the option like this?
struct ip_mreq mreq; setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF,&mreq, sizeof(mreq));
In fact, current implemetation supports:
struct ip_mreqn mreqn;setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, &mreqn, sizeof(mreqn));
Then why not support mreq?
Quoted 5 lines
Best Regards
-----
Shan Wei
Hello!
Quoted 6 lines · Danny Feng
In fact, current implemetation supports:
struct
ip_mreqnmreqn;setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, &mreqn, sizeof(mreqn));Then why not support mreq?
Because support of ip_mreqn makes sense (it user interface index) and support of ip_mreq, which does not contain interface index, does not. "Polymorphic" IP_MULTICAST_IF was a stupid mistake (mine), which should not grow like a tumor.
Ack to patch #1, nack to #2.
Alexey