2 * IPv6 BSD socket options interface
3 * Linux INET6 implementation
6 * Pedro Roque <roque@di.fc.ul.pt>
8 * Based on linux/net/ipv4/ip_sockglue.c
10 * $Id: ipv6_sockglue.c,v 1.41 2002/02/01 22:01:04 davem Exp $
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
17 * FIXME: Make the setsockopt code POSIX compliant: That is
19 * o Return -EINVAL for setsockopt of short lengths
20 * o Truncate getsockopt returns
21 * o Return an optlen of the truncated length if need be
24 * David L Stevens <dlstevens@us.ibm.com>:
25 * - added multicast source filtering API for MLDv2
28 #include <linux/module.h>
29 #include <linux/capability.h>
30 #include <linux/errno.h>
31 #include <linux/types.h>
32 #include <linux/socket.h>
33 #include <linux/sockios.h>
34 #include <linux/net.h>
35 #include <linux/in6.h>
36 #include <linux/netdevice.h>
37 #include <linux/if_arp.h>
38 #include <linux/init.h>
39 #include <linux/sysctl.h>
40 #include <linux/netfilter.h>
45 #include <net/ndisc.h>
46 #include <net/protocol.h>
47 #include <net/transp_v6.h>
48 #include <net/ip6_route.h>
49 #include <net/addrconf.h>
50 #include <net/inet_common.h>
53 #include <net/udplite.h>
56 #include <asm/uaccess.h>
58 DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics) __read_mostly;
60 static struct inet6_protocol *ipv6_gso_pull_exthdrs(struct sk_buff *skb,
63 struct inet6_protocol *ops = NULL;
66 struct ipv6_opt_hdr *opth;
69 if (proto != NEXTHDR_HOP) {
70 ops = rcu_dereference(inet6_protos[proto]);
75 if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
79 if (unlikely(!pskb_may_pull(skb, 8)))
82 opth = (void *)skb->data;
83 len = opth->hdrlen * 8 + 8;
85 if (unlikely(!pskb_may_pull(skb, len)))
88 proto = opth->nexthdr;
95 static int ipv6_gso_send_check(struct sk_buff *skb)
97 struct ipv6hdr *ipv6h;
98 struct inet6_protocol *ops;
101 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
104 ipv6h = ipv6_hdr(skb);
105 __skb_pull(skb, sizeof(*ipv6h));
106 err = -EPROTONOSUPPORT;
109 ops = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr);
110 if (likely(ops && ops->gso_send_check)) {
111 skb_reset_transport_header(skb);
112 err = ops->gso_send_check(skb);
120 static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features)
122 struct sk_buff *segs = ERR_PTR(-EINVAL);
123 struct ipv6hdr *ipv6h;
124 struct inet6_protocol *ops;
126 if (!(features & NETIF_F_V6_CSUM))
127 features &= ~NETIF_F_SG;
129 if (unlikely(skb_shinfo(skb)->gso_type &
137 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
140 ipv6h = ipv6_hdr(skb);
141 __skb_pull(skb, sizeof(*ipv6h));
142 segs = ERR_PTR(-EPROTONOSUPPORT);
145 ops = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr);
146 if (likely(ops && ops->gso_segment)) {
147 skb_reset_transport_header(skb);
148 segs = ops->gso_segment(skb, features);
152 if (unlikely(IS_ERR(segs)))
155 for (skb = segs; skb; skb = skb->next) {
156 ipv6h = ipv6_hdr(skb);
157 ipv6h->payload_len = htons(skb->len - skb->mac_len -
165 static struct packet_type ipv6_packet_type = {
166 .type = __constant_htons(ETH_P_IPV6),
168 .gso_send_check = ipv6_gso_send_check,
169 .gso_segment = ipv6_gso_segment,
172 struct ip6_ra_chain *ip6_ra_chain;
173 DEFINE_RWLOCK(ip6_ra_lock);
175 int ip6_ra_control(struct sock *sk, int sel, void (*destructor)(struct sock *))
177 struct ip6_ra_chain *ra, *new_ra, **rap;
179 /* RA packet may be delivered ONLY to IPPROTO_RAW socket */
180 if (sk->sk_type != SOCK_RAW || inet_sk(sk)->num != IPPROTO_RAW)
183 new_ra = (sel>=0) ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL;
185 write_lock_bh(&ip6_ra_lock);
186 for (rap = &ip6_ra_chain; (ra=*rap) != NULL; rap = &ra->next) {
189 write_unlock_bh(&ip6_ra_lock);
195 write_unlock_bh(&ip6_ra_lock);
204 if (new_ra == NULL) {
205 write_unlock_bh(&ip6_ra_lock);
210 new_ra->destructor = destructor;
214 write_unlock_bh(&ip6_ra_lock);
218 static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
219 char __user *optval, int optlen)
221 struct ipv6_pinfo *np = inet6_sk(sk);
223 int retv = -ENOPROTOOPT;
227 else if (get_user(val, (int __user *) optval))
237 if (val == PF_INET) {
238 struct ipv6_txoptions *opt;
239 struct sk_buff *pktopt;
241 if (sk->sk_protocol != IPPROTO_UDP &&
242 sk->sk_protocol != IPPROTO_UDPLITE &&
243 sk->sk_protocol != IPPROTO_TCP)
246 if (sk->sk_state != TCP_ESTABLISHED) {
251 if (ipv6_only_sock(sk) ||
252 !ipv6_addr_v4mapped(&np->daddr)) {
253 retv = -EADDRNOTAVAIL;
257 fl6_free_socklist(sk);
258 ipv6_sock_mc_close(sk);
261 * Sock is moving from IPv6 to IPv4 (sk_prot), so
262 * remove it from the refcnt debug socks count in the
265 sk_refcnt_debug_dec(sk);
267 if (sk->sk_protocol == IPPROTO_TCP) {
268 struct inet_connection_sock *icsk = inet_csk(sk);
271 sock_prot_dec_use(sk->sk_prot);
272 sock_prot_inc_use(&tcp_prot);
274 sk->sk_prot = &tcp_prot;
275 icsk->icsk_af_ops = &ipv4_specific;
276 sk->sk_socket->ops = &inet_stream_ops;
277 sk->sk_family = PF_INET;
278 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
280 struct proto *prot = &udp_prot;
282 if (sk->sk_protocol == IPPROTO_UDPLITE)
283 prot = &udplite_prot;
285 sock_prot_dec_use(sk->sk_prot);
286 sock_prot_inc_use(prot);
289 sk->sk_socket->ops = &inet_dgram_ops;
290 sk->sk_family = PF_INET;
292 opt = xchg(&np->opt, NULL);
294 sock_kfree_s(sk, opt, opt->tot_len);
295 pktopt = xchg(&np->pktoptions, NULL);
299 sk->sk_destruct = inet_sock_destruct;
301 * ... and add it to the refcnt debug socks count
302 * in the new family. -acme
304 sk_refcnt_debug_inc(sk);
305 module_put(THIS_MODULE);
312 if (inet_sk(sk)->num)
314 np->ipv6only = valbool;
318 case IPV6_RECVPKTINFO:
319 np->rxopt.bits.rxinfo = valbool;
323 case IPV6_2292PKTINFO:
324 np->rxopt.bits.rxoinfo = valbool;
328 case IPV6_RECVHOPLIMIT:
329 np->rxopt.bits.rxhlim = valbool;
333 case IPV6_2292HOPLIMIT:
334 np->rxopt.bits.rxohlim = valbool;
339 np->rxopt.bits.srcrt = valbool;
344 np->rxopt.bits.osrcrt = valbool;
348 case IPV6_RECVHOPOPTS:
349 np->rxopt.bits.hopopts = valbool;
353 case IPV6_2292HOPOPTS:
354 np->rxopt.bits.ohopopts = valbool;
358 case IPV6_RECVDSTOPTS:
359 np->rxopt.bits.dstopts = valbool;
363 case IPV6_2292DSTOPTS:
364 np->rxopt.bits.odstopts = valbool;
369 if (val < -1 || val > 0xff)
375 case IPV6_RECVTCLASS:
376 np->rxopt.bits.rxtclass = valbool;
381 np->rxopt.bits.rxflow = valbool;
386 case IPV6_RTHDRDSTOPTS:
390 struct ipv6_txoptions *opt;
394 /* hop-by-hop / destination options are privileged option */
396 if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW))
400 if (optlen & 0x7 || optlen > 8 * 255)
403 opt = ipv6_renew_options(sk, np->opt, optname,
404 (struct ipv6_opt_hdr __user *)optval,
411 /* routing header option needs extra check */
412 if (optname == IPV6_RTHDR && opt && opt->srcrt) {
413 struct ipv6_rt_hdr *rthdr = opt->srcrt;
414 switch (rthdr->type) {
415 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
416 case IPV6_SRCRT_TYPE_2:
423 if ((rthdr->hdrlen & 1) ||
424 (rthdr->hdrlen >> 1) != rthdr->segments_left)
429 if (inet_sk(sk)->is_icsk) {
431 struct inet_connection_sock *icsk = inet_csk(sk);
432 if (!((1 << sk->sk_state) &
433 (TCPF_LISTEN | TCPF_CLOSE))
434 && inet_sk(sk)->daddr != LOOPBACK4_IPV6) {
435 icsk->icsk_ext_hdr_len =
436 opt->opt_flen + opt->opt_nflen;
437 icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie);
440 opt = xchg(&np->opt, opt);
443 write_lock(&sk->sk_dst_lock);
444 opt = xchg(&np->opt, opt);
445 write_unlock(&sk->sk_dst_lock);
450 sock_kfree_s(sk, opt, opt->tot_len);
454 case IPV6_2292PKTOPTIONS:
456 struct ipv6_txoptions *opt = NULL;
461 fl.fl6_flowlabel = 0;
462 fl.oif = sk->sk_bound_dev_if;
467 /* 1K is probably excessive
468 * 1K is surely not enough, 2K per standard header is 16K.
471 if (optlen > 64*1024)
474 opt = sock_kmalloc(sk, sizeof(*opt) + optlen, GFP_KERNEL);
479 memset(opt, 0, sizeof(*opt));
480 opt->tot_len = sizeof(*opt) + optlen;
482 if (copy_from_user(opt+1, optval, optlen))
485 msg.msg_controllen = optlen;
486 msg.msg_control = (void*)(opt+1);
488 retv = datagram_send_ctl(&msg, &fl, opt, &junk, &junk);
493 if (inet_sk(sk)->is_icsk) {
495 struct inet_connection_sock *icsk = inet_csk(sk);
496 if (!((1 << sk->sk_state) &
497 (TCPF_LISTEN | TCPF_CLOSE))
498 && inet_sk(sk)->daddr != LOOPBACK4_IPV6) {
499 icsk->icsk_ext_hdr_len =
500 opt->opt_flen + opt->opt_nflen;
501 icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie);
504 opt = xchg(&np->opt, opt);
507 write_lock(&sk->sk_dst_lock);
508 opt = xchg(&np->opt, opt);
509 write_unlock(&sk->sk_dst_lock);
515 sock_kfree_s(sk, opt, opt->tot_len);
518 case IPV6_UNICAST_HOPS:
519 if (val > 255 || val < -1)
525 case IPV6_MULTICAST_HOPS:
526 if (sk->sk_type == SOCK_STREAM)
528 if (val > 255 || val < -1)
530 np->mcast_hops = val;
534 case IPV6_MULTICAST_LOOP:
535 np->mc_loop = valbool;
539 case IPV6_MULTICAST_IF:
540 if (sk->sk_type == SOCK_STREAM)
544 if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
547 if (__dev_get_by_index(&init_net, val) == NULL) {
555 case IPV6_ADD_MEMBERSHIP:
556 case IPV6_DROP_MEMBERSHIP:
558 struct ipv6_mreq mreq;
561 if (inet_sk(sk)->is_icsk)
565 if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq)))
568 if (optname == IPV6_ADD_MEMBERSHIP)
569 retv = ipv6_sock_mc_join(sk, mreq.ipv6mr_ifindex, &mreq.ipv6mr_multiaddr);
571 retv = ipv6_sock_mc_drop(sk, mreq.ipv6mr_ifindex, &mreq.ipv6mr_multiaddr);
574 case IPV6_JOIN_ANYCAST:
575 case IPV6_LEAVE_ANYCAST:
577 struct ipv6_mreq mreq;
579 if (optlen != sizeof(struct ipv6_mreq))
583 if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq)))
586 if (optname == IPV6_JOIN_ANYCAST)
587 retv = ipv6_sock_ac_join(sk, mreq.ipv6mr_ifindex, &mreq.ipv6mr_acaddr);
589 retv = ipv6_sock_ac_drop(sk, mreq.ipv6mr_ifindex, &mreq.ipv6mr_acaddr);
592 case MCAST_JOIN_GROUP:
593 case MCAST_LEAVE_GROUP:
595 struct group_req greq;
596 struct sockaddr_in6 *psin6;
599 if (copy_from_user(&greq, optval, sizeof(struct group_req)))
601 if (greq.gr_group.ss_family != AF_INET6) {
602 retv = -EADDRNOTAVAIL;
605 psin6 = (struct sockaddr_in6 *)&greq.gr_group;
606 if (optname == MCAST_JOIN_GROUP)
607 retv = ipv6_sock_mc_join(sk, greq.gr_interface,
610 retv = ipv6_sock_mc_drop(sk, greq.gr_interface,
614 case MCAST_JOIN_SOURCE_GROUP:
615 case MCAST_LEAVE_SOURCE_GROUP:
616 case MCAST_BLOCK_SOURCE:
617 case MCAST_UNBLOCK_SOURCE:
619 struct group_source_req greqs;
622 if (optlen != sizeof(struct group_source_req))
624 if (copy_from_user(&greqs, optval, sizeof(greqs))) {
628 if (greqs.gsr_group.ss_family != AF_INET6 ||
629 greqs.gsr_source.ss_family != AF_INET6) {
630 retv = -EADDRNOTAVAIL;
633 if (optname == MCAST_BLOCK_SOURCE) {
634 omode = MCAST_EXCLUDE;
636 } else if (optname == MCAST_UNBLOCK_SOURCE) {
637 omode = MCAST_EXCLUDE;
639 } else if (optname == MCAST_JOIN_SOURCE_GROUP) {
640 struct sockaddr_in6 *psin6;
642 psin6 = (struct sockaddr_in6 *)&greqs.gsr_group;
643 retv = ipv6_sock_mc_join(sk, greqs.gsr_interface,
645 /* prior join w/ different source is ok */
646 if (retv && retv != -EADDRINUSE)
648 omode = MCAST_INCLUDE;
650 } else /* MCAST_LEAVE_SOURCE_GROUP */ {
651 omode = MCAST_INCLUDE;
654 retv = ip6_mc_source(add, omode, sk, &greqs);
659 extern int sysctl_mld_max_msf;
660 struct group_filter *gsf;
662 if (optlen < GROUP_FILTER_SIZE(0))
664 if (optlen > sysctl_optmem_max) {
668 gsf = kmalloc(optlen,GFP_KERNEL);
674 if (copy_from_user(gsf, optval, optlen)) {
678 /* numsrc >= (4G-140)/128 overflow in 32 bits */
679 if (gsf->gf_numsrc >= 0x1ffffffU ||
680 gsf->gf_numsrc > sysctl_mld_max_msf) {
685 if (GROUP_FILTER_SIZE(gsf->gf_numsrc) > optlen) {
690 retv = ip6_mc_msfilter(sk, gsf);
695 case IPV6_ROUTER_ALERT:
696 retv = ip6_ra_control(sk, val, NULL);
698 case IPV6_MTU_DISCOVER:
705 if (val && val < IPV6_MIN_MTU)
711 np->recverr = valbool;
713 skb_queue_purge(&sk->sk_error_queue);
716 case IPV6_FLOWINFO_SEND:
717 np->sndflow = valbool;
720 case IPV6_FLOWLABEL_MGR:
721 retv = ipv6_flowlabel_opt(sk, optval, optlen);
723 case IPV6_IPSEC_POLICY:
724 case IPV6_XFRM_POLICY:
726 if (!capable(CAP_NET_ADMIN))
728 retv = xfrm_user_policy(sk, optname, optval, optlen);
741 int ipv6_setsockopt(struct sock *sk, int level, int optname,
742 char __user *optval, int optlen)
746 if (level == SOL_IP && sk->sk_type != SOCK_RAW)
747 return udp_prot.setsockopt(sk, level, optname, optval, optlen);
749 if (level != SOL_IPV6)
752 err = do_ipv6_setsockopt(sk, level, optname, optval, optlen);
753 #ifdef CONFIG_NETFILTER
754 /* we need to exclude all possible ENOPROTOOPTs except default case */
755 if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY &&
756 optname != IPV6_XFRM_POLICY) {
758 err = nf_setsockopt(sk, PF_INET6, optname, optval,
766 EXPORT_SYMBOL(ipv6_setsockopt);
769 int compat_ipv6_setsockopt(struct sock *sk, int level, int optname,
770 char __user *optval, int optlen)
774 if (level == SOL_IP && sk->sk_type != SOCK_RAW) {
775 if (udp_prot.compat_setsockopt != NULL)
776 return udp_prot.compat_setsockopt(sk, level, optname,
778 return udp_prot.setsockopt(sk, level, optname, optval, optlen);
781 if (level != SOL_IPV6)
784 err = do_ipv6_setsockopt(sk, level, optname, optval, optlen);
785 #ifdef CONFIG_NETFILTER
786 /* we need to exclude all possible ENOPROTOOPTs except default case */
787 if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY &&
788 optname != IPV6_XFRM_POLICY) {
790 err = compat_nf_setsockopt(sk, PF_INET6, optname,
798 EXPORT_SYMBOL(compat_ipv6_setsockopt);
801 static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt,
802 int optname, char __user *optval, int len)
804 struct ipv6_opt_hdr *hdr;
813 case IPV6_RTHDRDSTOPTS:
817 hdr = (struct ipv6_opt_hdr *)opt->srcrt;
823 return -EINVAL; /* should not happen */
829 len = min_t(unsigned int, len, ipv6_optlen(hdr));
830 if (copy_to_user(optval, hdr, len))
832 return ipv6_optlen(hdr);
835 static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
836 char __user *optval, int __user *optlen)
838 struct ipv6_pinfo *np = inet6_sk(sk);
842 if (get_user(len, optlen))
846 if (sk->sk_protocol != IPPROTO_UDP &&
847 sk->sk_protocol != IPPROTO_UDPLITE &&
848 sk->sk_protocol != IPPROTO_TCP)
850 if (sk->sk_state != TCP_ESTABLISHED)
856 struct group_filter gsf;
859 if (len < GROUP_FILTER_SIZE(0))
861 if (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0)))
864 err = ip6_mc_msfget(sk, &gsf,
865 (struct group_filter __user *)optval, optlen);
870 case IPV6_2292PKTOPTIONS:
875 if (sk->sk_type != SOCK_STREAM)
878 msg.msg_control = optval;
879 msg.msg_controllen = len;
883 skb = np->pktoptions;
885 atomic_inc(&skb->users);
889 int err = datagram_recv_ctl(sk, &msg, skb);
894 if (np->rxopt.bits.rxinfo) {
895 struct in6_pktinfo src_info;
896 src_info.ipi6_ifindex = np->mcast_oif;
897 ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr);
898 put_cmsg(&msg, SOL_IPV6, IPV6_PKTINFO, sizeof(src_info), &src_info);
900 if (np->rxopt.bits.rxhlim) {
901 int hlim = np->mcast_hops;
902 put_cmsg(&msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim);
904 if (np->rxopt.bits.rxoinfo) {
905 struct in6_pktinfo src_info;
906 src_info.ipi6_ifindex = np->mcast_oif;
907 ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr);
908 put_cmsg(&msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info);
910 if (np->rxopt.bits.rxohlim) {
911 int hlim = np->mcast_hops;
912 put_cmsg(&msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim);
915 len -= msg.msg_controllen;
916 return put_user(len, optlen);
920 struct dst_entry *dst;
923 dst = sk_dst_get(sk);
938 case IPV6_RECVPKTINFO:
939 val = np->rxopt.bits.rxinfo;
942 case IPV6_2292PKTINFO:
943 val = np->rxopt.bits.rxoinfo;
946 case IPV6_RECVHOPLIMIT:
947 val = np->rxopt.bits.rxhlim;
950 case IPV6_2292HOPLIMIT:
951 val = np->rxopt.bits.rxohlim;
955 val = np->rxopt.bits.srcrt;
959 val = np->rxopt.bits.osrcrt;
963 case IPV6_RTHDRDSTOPTS:
969 len = ipv6_getsockopt_sticky(sk, np->opt,
970 optname, optval, len);
972 return put_user(len, optlen);
975 case IPV6_RECVHOPOPTS:
976 val = np->rxopt.bits.hopopts;
979 case IPV6_2292HOPOPTS:
980 val = np->rxopt.bits.ohopopts;
983 case IPV6_RECVDSTOPTS:
984 val = np->rxopt.bits.dstopts;
987 case IPV6_2292DSTOPTS:
988 val = np->rxopt.bits.odstopts;
997 case IPV6_RECVTCLASS:
998 val = np->rxopt.bits.rxtclass;
1002 val = np->rxopt.bits.rxflow;
1005 case IPV6_UNICAST_HOPS:
1006 case IPV6_MULTICAST_HOPS:
1008 struct dst_entry *dst;
1010 if (optname == IPV6_UNICAST_HOPS)
1011 val = np->hop_limit;
1013 val = np->mcast_hops;
1015 dst = sk_dst_get(sk);
1018 val = dst_metric(dst, RTAX_HOPLIMIT);
1020 val = ipv6_get_hoplimit(dst->dev);
1024 val = ipv6_devconf.hop_limit;
1028 case IPV6_MULTICAST_LOOP:
1032 case IPV6_MULTICAST_IF:
1033 val = np->mcast_oif;
1036 case IPV6_MTU_DISCOVER:
1044 case IPV6_FLOWINFO_SEND:
1049 return -ENOPROTOOPT;
1051 len = min_t(unsigned int, sizeof(int), len);
1052 if(put_user(len, optlen))
1054 if(copy_to_user(optval,&val,len))
1059 int ipv6_getsockopt(struct sock *sk, int level, int optname,
1060 char __user *optval, int __user *optlen)
1064 if (level == SOL_IP && sk->sk_type != SOCK_RAW)
1065 return udp_prot.getsockopt(sk, level, optname, optval, optlen);
1067 if(level != SOL_IPV6)
1068 return -ENOPROTOOPT;
1070 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
1071 #ifdef CONFIG_NETFILTER
1072 /* we need to exclude all possible ENOPROTOOPTs except default case */
1073 if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
1076 if (get_user(len, optlen))
1080 err = nf_getsockopt(sk, PF_INET6, optname, optval,
1084 err = put_user(len, optlen);
1090 EXPORT_SYMBOL(ipv6_getsockopt);
1092 #ifdef CONFIG_COMPAT
1093 int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
1094 char __user *optval, int __user *optlen)
1098 if (level == SOL_IP && sk->sk_type != SOCK_RAW) {
1099 if (udp_prot.compat_getsockopt != NULL)
1100 return udp_prot.compat_getsockopt(sk, level, optname,
1102 return udp_prot.getsockopt(sk, level, optname, optval, optlen);
1105 if (level != SOL_IPV6)
1106 return -ENOPROTOOPT;
1108 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
1109 #ifdef CONFIG_NETFILTER
1110 /* we need to exclude all possible ENOPROTOOPTs except default case */
1111 if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
1114 if (get_user(len, optlen))
1118 err = compat_nf_getsockopt(sk, PF_INET6,
1119 optname, optval, &len);
1122 err = put_user(len, optlen);
1128 EXPORT_SYMBOL(compat_ipv6_getsockopt);
1131 void __init ipv6_packet_init(void)
1133 dev_add_pack(&ipv6_packet_type);
1136 void ipv6_packet_cleanup(void)
1138 dev_remove_pack(&ipv6_packet_type);