]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[IPV6]: Return correct result for sticky options.
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Mon, 19 Mar 2007 00:35:57 +0000 (17:35 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 05:24:16 +0000 (22:24 -0700)
We returned incorrect result with IPV6_RTHDRDSTOPTS, IPV6_RTHDR and
IPV6_DSTOPTS.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/ipv6_sockglue.c

index 1cb7a084f0c05c6478f6272da9c66d867031461e..eceed09e434d9d183c648a06df8b128181f490fe 100644 (file)
@@ -797,13 +797,32 @@ EXPORT_SYMBOL(compat_ipv6_setsockopt);
 #endif
 
 static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt,
-                                 char __user *optval, int len)
+                                 int optname, char __user *optval, int len)
 {
        struct ipv6_opt_hdr *hdr;
 
-       if (!opt || !opt->hopopt)
+       if (!opt)
+               return 0;
+
+       switch(optname) {
+       case IPV6_HOPOPTS:
+               hdr = opt->hopopt;
+               break;
+       case IPV6_RTHDRDSTOPTS:
+               hdr = opt->dst0opt;
+               break;
+       case IPV6_RTHDR:
+               hdr = (struct ipv6_opt_hdr *)opt->srcrt;
+               break;
+       case IPV6_DSTOPTS:
+               hdr = opt->dst1opt;
+               break;
+       default:
+               return -EINVAL; /* should not happen */
+       }
+
+       if (!hdr)
                return 0;
-       hdr = opt->hopopt;
 
        len = min_t(unsigned int, len, ipv6_optlen(hdr));
        if (copy_to_user(optval, hdr, ipv6_optlen(hdr)))
@@ -946,7 +965,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
 
                lock_sock(sk);
                len = ipv6_getsockopt_sticky(sk, np->opt,
-                                            optval, len);
+                                            optname, optval, len);
                release_sock(sk);
                return put_user(len, optlen);
        }