2009-09-17 05:21:23

by Xiaotian Feng

[permalink] [raw]
Subject: [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.

Signed-off-by: Marc Milgram <[email protected]>
Signed-off-by: Xiaotian Feng <[email protected]>
Cc: Patrick McHardy <[email protected]>
Cc: David S. Miller <[email protected]>
---
net/ipv4/ip_sockglue.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 5a29dce..1e8d026 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -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;
--
1.6.2.5


2009-09-17 09:12:10

by Shan Wei

[permalink] [raw]
Subject: Re: [PATCH 2/2] ipv4: make do_ip_setsockopt for IP_MULTICAST_IF support ip_mreq struct

Xiaotian Feng wrote, at 09/17/2009 01:20 PM:
> 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.
>

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

2009-09-17 09:20:15

by Xiaotian Feng

[permalink] [raw]
Subject: Re: [PATCH 2/2] ipv4: make do_ip_setsockopt for IP_MULTICAST_IF support ip_mreq struct

On 09/17/2009 05:16 PM, Shan Wei wrote:
> Xiaotian Feng wrote, at 09/17/2009 01:20 PM:
>> 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.
>>
>
> 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));
>
In fact, current implemetation supports:

struct ip_mreqn mreqn;
setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, &mreqn, sizeof(mreqn));

Then why not support mreq?
>
> Best Regards
> -----
> Shan Wei
>

2009-09-17 10:29:34

by Alexey Kuznetsov

[permalink] [raw]
Subject: Re: [PATCH 2/2] ipv4: make do_ip_setsockopt for IP_MULTICAST_IF support ip_mreq struct

Hello!

On Thu, Sep 17, 2009 at 05:19:16PM +0800, Danny Feng wrote:
> In fact, current implemetation supports:
>
> struct ip_mreqn mreqn;
> 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