netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] IPv6:Remove options header when setsockopt's optlen is 0
@ 2008-06-18  6:42 Shan Wei
  2008-06-19  7:52 ` YOSHIFUJI Hideaki / 吉藤英明
  0 siblings, 1 reply; 3+ messages in thread
From: Shan Wei @ 2008-06-18  6:42 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / 吉藤英明; +Cc: davem, netdev

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. 


Signed-off-by: Shan Wei<shanwei@cn.fujitsu.com>
---
 net/ipv6/ipv6_sockglue.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index c042ce1..86e28a7 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -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);




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-06-19 23:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-18  6:42 [RFC][PATCH] IPv6:Remove options header when setsockopt's optlen is 0 Shan Wei
2008-06-19  7:52 ` YOSHIFUJI Hideaki / 吉藤英明
2008-06-19 23:30   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).