Skip to contentSkip to conversation

IPv4:Check IP_MULTICAST_LOOP option value

RFC PATCH In review Shan Wei 2 participants 6 messages Jun 10, 2008

Subsystems (3)
lore
Share & tools
lore

Shan Wei

author
#0 lore raw

RFC PATCH 3/3 IPv4:Check IP_MULTICAST_LOOP option value

The IP_MULTICAST_LOOP option can only be set with o or 1. When other valuse are set, the kernel should return an error of EINVAL.

In addition, the option should not be uesd by SOCK_STREAM type, same as IP_MULTICAST_IF, IP_MULTICAST_TTL.

But the kernel doesn't check them.

---
 net/ipv4/ip_sockglue.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/ipv4/ip_sockglue.c +4 -0
index e0514e8..82196a5 100644
@@ -558,8 +558,12 @@ static int do_ip_setsockopt(struct sock *sk, int level,
 		inet->mc_ttl = val;
 		break;
 	case IP_MULTICAST_LOOP:
+		if (sk->sk_type == SOCK_STREAM)
+			goto e_inval;
 		if (optlen<1)
 			goto e_inval;
+		if (val < 0 || val > 1)
+			goto e_inval;
 		inet->mc_loop = !!val;
 		break;
 	case IP_MULTICAST_IF:
Signature · 1 line
1.5.4.4
#1 lore raw

In article <[email protected]> (at Tue, 10 Jun 2008 15:51:47 +0800), Shan Wei <[email protected]> says:

Quoted 7 lines

The IP_MULTICAST_LOOP option can only be set with o or 1. When other valuse are set, the kernel should return an error of EINVAL.

In addition, the option should not be uesd by SOCK_STREAM type, same as IP_MULTICAST_IF, IP_MULTICAST_TTL.

But the kernel doesn't check them.

Is there any standard reference about this?

--yoshfuji

#2 lore raw

In article <[email protected]> (at Tue, 10 Jun 2008 17:15:27 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <[email protected]> says:

Quoted 11 lines

In article <[email protected]> (at Tue, 10 Jun 2008 15:51:47 +0800), Shan Wei <[email protected]> says:

Quoted 7 lines

The IP_MULTICAST_LOOP option can only be set with o or 1. When other valuse are set, the kernel should return an error of EINVAL.

In addition, the option should not be uesd by SOCK_STREAM type, same as IP_MULTICAST_IF, IP_MULTICAST_TTL.

But the kernel doesn't check them.

Is there any standard reference about this?

And actually I diagree to check "val."
(For example, FreeBSD does not check this.)

--yoshfuji

author
#3 lore raw
In reply to YOSHIFUJI Hideaki / 吉藤英明
Quoted 5 lines · YOSHIFUJI Hideaki / 吉藤英明

In article <[email protected]> (at Tue, 10 Jun 2008 15:51:47 +0800), Shan Wei <[email protected]> says:

Quoted 3 lines

The IP_MULTICAST_LOOP option can only be set with o or 1. When other valuse are set, the kernel should return an error of EINVAL.

Quoted 7 lines
Quoted 4 lines

In addition, the option should not be uesd by SOCK_STREAM type, same as IP_MULTICAST_IF, IP_MULTICAST_TTL.

But the kernel doesn't check them.

Is there any standard reference about this?

I have not found it.
But, the IP_MULTICAST_LOOP option is same as IPV6_MULTICAST_LOOP.

Quoted 4 lines

--yoshfuji

#4 lore raw

In article <[email protected]> (at Tue, 10 Jun 2008 16:32:10 +0800), Shan Wei <[email protected]> says:

Quoted 9 lines
Quoted 8 lines · YOSHIFUJI Hideaki / 吉藤英明

In article <[email protected]> (at Tue, 10 Jun 2008 15:51:47 +0800), Shan Wei <[email protected]> says:

Quoted 6 lines

The IP_MULTICAST_LOOP option can only be set with o or 1. When other valuse are set, the kernel should return an error of EINVAL.

In addition, the option should not be uesd by SOCK_STREAM type, same as IP_MULTICAST_IF, IP_MULTICAST_TTL.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

But the kernel doesn't check them.

Is there any standard reference about this?

I have not found it.
But, the IP_MULTICAST_LOOP option is same as IPV6_MULTICAST_LOOP.

I disagree.
We follow what traditional BSDs do, and they do not check if the value is 0 or 1 for IP_MULTICAST_LOOP.
On the other hand, they do for IPV6_MULTICAST_LOOP.

--yoshfuji

author
#5 lore raw
Quoted 14 lines · YOSHIFUJI Hideaki / 吉藤英明

In article <[email protected]> (at Tue, 10 Jun 2008 16:32:10 +0800), Shan Wei <[email protected]> says:

Quoted 12 lines
Quoted 11 lines · YOSHIFUJI Hideaki / 吉藤英明

In article <[email protected]> (at Tue, 10 Jun 2008 15:51:47 +0800), Shan Wei <[email protected]> says:

Quoted 7 lines

The IP_MULTICAST_LOOP option can only be set with o or 1. When other valuse are set, the kernel should return an error of EINVAL.

In addition, the option should not be uesd by SOCK_STREAM type, same as IP_MULTICAST_IF, IP_MULTICAST_TTL.

But the kernel doesn't check them.

Is there any standard reference about this?

Quoted 8 lines
Quoted 2 lines

I have not found it.
But, the IP_MULTICAST_LOOP option is same as IPV6_MULTICAST_LOOP.

I disagree.
We follow what traditional BSDs do, and they do not check if the value is 0 or 1 for IP_MULTICAST_LOOP.
On the other hand, they do for IPV6_MULTICAST_LOOP.

Ok.
no need to check "val".

The option should not be uesd by SOCK_STREAM type. how do you think of ?

Quoted 4 lines

--yoshfuji

Signature · 15 lines
Regards
単 衛
--------------------------------------------------
Shan Wei
Development Dept.I

Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
8/F., Civil Defense Building, No.189 Guangzhou Road,
Nanjing, 210029, China
TEL:+86+25-86630566-836
FUJITSU INTERNAL:79955-836
FAX:+86+25-83317685
Mail:[email protected]
--------------------------------------------------
This communication is for use by the intended recipient(s) only and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not an intended recipient of this communication, you are hereby notified that any dissemination, distribution or copying hereof is strictly prohibited.  If you have received this communication in error, please notify me by reply e-mail, permanently delete this communication from your system, and destroy any hard copies you may have printed.