Skip to contentSkip to conversation

IPv6:Remove options header when setsockopt's optlen is 0

RFC PATCH Applied Shan Wei 3 participants 3 messages Jun 18, 2008 – Jun 19, 2008

Subsystems (3)
lore
Share & tools
lore

Shan Wei

author
#0 lore raw

RFC PATCH 1/1 IPv6:Remove options header when setsockopt's optlen is 0

Remove the sticky Hop-by-Hop options header by calling setsockopt() for IPV6_HOPOPTS with a zero option length, per RFC3542.

Routing header and Destination options header does the same as Hop-by-Hop options header.

---
 net/ipv6/ipv6_sockglue.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
net/ipv6/ipv6_sockglue.c +7 -4
index c042ce1..86e28a7 100644
@@ -345,18 +345,21 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 	case IPV6_DSTOPTS:
 	{
 		struct ipv6_txoptions *opt;
+
+		/* remove any sticky options header with a zero option
+		 * length, per RFC3542.
+		 */
 		if (optlen == 0)
 			optval = NULL;
+		else if (optlen < sizeof(struct ipv6_opt_hdr) ||
+			 optlen & 0x7 || optlen > 8 * 255)
+			goto e_inval;
 
 		/* hop-by-hop / destination options are privileged option */
 		retv = -EPERM;
 		if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW))
 			break;
 
-		if (optlen < sizeof(struct ipv6_opt_hdr) ||
-		    optlen & 0x7 || optlen > 8 * 255)
-			goto e_inval;
-
 		opt = ipv6_renew_options(sk, np->opt, optname,
 					 (struct ipv6_opt_hdr __user *)optval,
 					 optlen);
#1 lore raw

In article <[email protected]> (at Wed, 18 Jun 2008 14:42:05 +0800), Shan Wei <[email protected]> says:

Quoted 7 lines

Remove the sticky Hop-by-Hop options header by calling setsockopt() for IPV6_HOPOPTS with a zero option length, per RFC3542.

Routing header and Destination options header does the same as Hop-by-Hop options header.

--yoshfuji

maintainer Applied
#2 lore raw

From: YOSHIFUJI Hideaki / 吉藤英明 <[email protected]>
Date: Thu, 19 Jun 2008 16:52:18 +0900 (JST)

Quoted 10 lines

In article <[email protected]> (at Wed, 18 Jun 2008 14:42:05 +0800), Shan Wei <[email protected]> says:

Quoted 7 lines

Remove the sticky Hop-by-Hop options header by calling setsockopt() for IPV6_HOPOPTS with a zero option length, per RFC3542.

Routing header and Destination options header does the same as Hop-by-Hop options header.

Applied to net-2.6, thanks!