aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/Makefile4
-rw-r--r--net/ipv6/af_inet6.c21
-rw-r--r--net/ipv6/ipv6_sockglue.c11
-rw-r--r--net/ipv6/netfilter/ip6t_LOG.c10
-rw-r--r--net/ipv6/proc.c11
-rw-r--r--net/ipv6/udp.c361
-rw-r--r--net/ipv6/udp_impl.h34
-rw-r--r--net/ipv6/udplite.c105
-rw-r--r--net/ipv6/xfrm6_policy.c1
9 files changed, 388 insertions, 170 deletions
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile
index addcc011bc01..8bacda109b7f 100644
--- a/net/ipv6/Makefile
+++ b/net/ipv6/Makefile
@@ -5,8 +5,8 @@
5obj-$(CONFIG_IPV6) += ipv6.o 5obj-$(CONFIG_IPV6) += ipv6.o
6 6
7ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \ 7ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \
8 route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o raw.o \ 8 route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o udplite.o \
9 protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \ 9 raw.o protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \
10 exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \ 10 exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \
11 ip6_flowlabel.o ipv6_syms.o inet6_connection_sock.o 11 ip6_flowlabel.o ipv6_syms.o inet6_connection_sock.o
12 12
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 92bfccf62cb7..1eb1c7f261d4 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -49,6 +49,7 @@
49#include <net/ip.h> 49#include <net/ip.h>
50#include <net/ipv6.h> 50#include <net/ipv6.h>
51#include <net/udp.h> 51#include <net/udp.h>
52#include <net/udplite.h>
52#include <net/tcp.h> 53#include <net/tcp.h>
53#include <net/ipip.h> 54#include <net/ipip.h>
54#include <net/protocol.h> 55#include <net/protocol.h>
@@ -737,8 +738,13 @@ static int __init init_ipv6_mibs(void)
737 if (snmp6_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib), 738 if (snmp6_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib),
738 __alignof__(struct udp_mib)) < 0) 739 __alignof__(struct udp_mib)) < 0)
739 goto err_udp_mib; 740 goto err_udp_mib;
741 if (snmp6_mib_init((void **)udplite_stats_in6, sizeof (struct udp_mib),
742 __alignof__(struct udp_mib)) < 0)
743 goto err_udplite_mib;
740 return 0; 744 return 0;
741 745
746err_udplite_mib:
747 snmp6_mib_free((void **)udp_stats_in6);
742err_udp_mib: 748err_udp_mib:
743 snmp6_mib_free((void **)icmpv6_statistics); 749 snmp6_mib_free((void **)icmpv6_statistics);
744err_icmp_mib: 750err_icmp_mib:
@@ -753,6 +759,7 @@ static void cleanup_ipv6_mibs(void)
753 snmp6_mib_free((void **)ipv6_statistics); 759 snmp6_mib_free((void **)ipv6_statistics);
754 snmp6_mib_free((void **)icmpv6_statistics); 760 snmp6_mib_free((void **)icmpv6_statistics);
755 snmp6_mib_free((void **)udp_stats_in6); 761 snmp6_mib_free((void **)udp_stats_in6);
762 snmp6_mib_free((void **)udplite_stats_in6);
756} 763}
757 764
758static int __init inet6_init(void) 765static int __init inet6_init(void)
@@ -780,10 +787,14 @@ static int __init inet6_init(void)
780 if (err) 787 if (err)
781 goto out_unregister_tcp_proto; 788 goto out_unregister_tcp_proto;
782 789
783 err = proto_register(&rawv6_prot, 1); 790 err = proto_register(&udplitev6_prot, 1);
784 if (err) 791 if (err)
785 goto out_unregister_udp_proto; 792 goto out_unregister_udp_proto;
786 793
794 err = proto_register(&rawv6_prot, 1);
795 if (err)
796 goto out_unregister_udplite_proto;
797
787 798
788 /* Register the socket-side information for inet6_create. */ 799 /* Register the socket-side information for inet6_create. */
789 for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r) 800 for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
@@ -837,6 +848,8 @@ static int __init inet6_init(void)
837 goto proc_tcp6_fail; 848 goto proc_tcp6_fail;
838 if (udp6_proc_init()) 849 if (udp6_proc_init())
839 goto proc_udp6_fail; 850 goto proc_udp6_fail;
851 if (udplite6_proc_init())
852 goto proc_udplite6_fail;
840 if (ipv6_misc_proc_init()) 853 if (ipv6_misc_proc_init())
841 goto proc_misc6_fail; 854 goto proc_misc6_fail;
842 855
@@ -862,6 +875,7 @@ static int __init inet6_init(void)
862 875
863 /* Init v6 transport protocols. */ 876 /* Init v6 transport protocols. */
864 udpv6_init(); 877 udpv6_init();
878 udplitev6_init();
865 tcpv6_init(); 879 tcpv6_init();
866 880
867 ipv6_packet_init(); 881 ipv6_packet_init();
@@ -879,6 +893,8 @@ proc_if6_fail:
879proc_anycast6_fail: 893proc_anycast6_fail:
880 ipv6_misc_proc_exit(); 894 ipv6_misc_proc_exit();
881proc_misc6_fail: 895proc_misc6_fail:
896 udplite6_proc_exit();
897proc_udplite6_fail:
882 udp6_proc_exit(); 898 udp6_proc_exit();
883proc_udp6_fail: 899proc_udp6_fail:
884 tcp6_proc_exit(); 900 tcp6_proc_exit();
@@ -902,6 +918,8 @@ out_unregister_sock:
902 sock_unregister(PF_INET6); 918 sock_unregister(PF_INET6);
903out_unregister_raw_proto: 919out_unregister_raw_proto:
904 proto_unregister(&rawv6_prot); 920 proto_unregister(&rawv6_prot);
921out_unregister_udplite_proto:
922 proto_unregister(&udplitev6_prot);
905out_unregister_udp_proto: 923out_unregister_udp_proto:
906 proto_unregister(&udpv6_prot); 924 proto_unregister(&udpv6_prot);
907out_unregister_tcp_proto: 925out_unregister_tcp_proto:
@@ -919,6 +937,7 @@ static void __exit inet6_exit(void)
919 ac6_proc_exit(); 937 ac6_proc_exit();
920 ipv6_misc_proc_exit(); 938 ipv6_misc_proc_exit();
921 udp6_proc_exit(); 939 udp6_proc_exit();
940 udplite6_proc_exit();
922 tcp6_proc_exit(); 941 tcp6_proc_exit();
923 raw6_proc_exit(); 942 raw6_proc_exit();
924#endif 943#endif
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index de6b91981b30..1eafcfc95e81 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -51,6 +51,7 @@
51#include <net/inet_common.h> 51#include <net/inet_common.h>
52#include <net/tcp.h> 52#include <net/tcp.h>
53#include <net/udp.h> 53#include <net/udp.h>
54#include <net/udplite.h>
54#include <net/xfrm.h> 55#include <net/xfrm.h>
55 56
56#include <asm/uaccess.h> 57#include <asm/uaccess.h>
@@ -239,6 +240,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
239 struct sk_buff *pktopt; 240 struct sk_buff *pktopt;
240 241
241 if (sk->sk_protocol != IPPROTO_UDP && 242 if (sk->sk_protocol != IPPROTO_UDP &&
243 sk->sk_protocol != IPPROTO_UDPLITE &&
242 sk->sk_protocol != IPPROTO_TCP) 244 sk->sk_protocol != IPPROTO_TCP)
243 break; 245 break;
244 246
@@ -276,11 +278,15 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
276 sk->sk_family = PF_INET; 278 sk->sk_family = PF_INET;
277 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); 279 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
278 } else { 280 } else {
281 struct proto *prot = &udp_prot;
282
283 if (sk->sk_protocol == IPPROTO_UDPLITE)
284 prot = &udplite_prot;
279 local_bh_disable(); 285 local_bh_disable();
280 sock_prot_dec_use(sk->sk_prot); 286 sock_prot_dec_use(sk->sk_prot);
281 sock_prot_inc_use(&udp_prot); 287 sock_prot_inc_use(prot);
282 local_bh_enable(); 288 local_bh_enable();
283 sk->sk_prot = &udp_prot; 289 sk->sk_prot = prot;
284 sk->sk_socket->ops = &inet_dgram_ops; 290 sk->sk_socket->ops = &inet_dgram_ops;
285 sk->sk_family = PF_INET; 291 sk->sk_family = PF_INET;
286 } 292 }
@@ -813,6 +819,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
813 switch (optname) { 819 switch (optname) {
814 case IPV6_ADDRFORM: 820 case IPV6_ADDRFORM:
815 if (sk->sk_protocol != IPPROTO_UDP && 821 if (sk->sk_protocol != IPPROTO_UDP &&
822 sk->sk_protocol != IPPROTO_UDPLITE &&
816 sk->sk_protocol != IPPROTO_TCP) 823 sk->sk_protocol != IPPROTO_TCP)
817 return -EINVAL; 824 return -EINVAL;
818 if (sk->sk_state != TCP_ESTABLISHED) 825 if (sk->sk_state != TCP_ESTABLISHED)
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
index 0cf537d30185..3cb6bb79cc05 100644
--- a/net/ipv6/netfilter/ip6t_LOG.c
+++ b/net/ipv6/netfilter/ip6t_LOG.c
@@ -270,11 +270,15 @@ static void dump_packet(const struct nf_loginfo *info,
270 } 270 }
271 break; 271 break;
272 } 272 }
273 case IPPROTO_UDP: { 273 case IPPROTO_UDP:
274 case IPPROTO_UDPLITE: {
274 struct udphdr _udph, *uh; 275 struct udphdr _udph, *uh;
275 276
276 /* Max length: 10 "PROTO=UDP " */ 277 if (currenthdr == IPPROTO_UDP)
277 printk("PROTO=UDP "); 278 /* Max length: 10 "PROTO=UDP " */
279 printk("PROTO=UDP " );
280 else /* Max length: 14 "PROTO=UDPLITE " */
281 printk("PROTO=UDPLITE ");
278 282
279 if (fragment) 283 if (fragment)
280 break; 284 break;
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 4158d386b0aa..35249d8487bb 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -49,6 +49,8 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v)
49 fold_prot_inuse(&tcpv6_prot)); 49 fold_prot_inuse(&tcpv6_prot));
50 seq_printf(seq, "UDP6: inuse %d\n", 50 seq_printf(seq, "UDP6: inuse %d\n",
51 fold_prot_inuse(&udpv6_prot)); 51 fold_prot_inuse(&udpv6_prot));
52 seq_printf(seq, "UDPLITE6: inuse %d\n",
53 fold_prot_inuse(&udplitev6_prot));
52 seq_printf(seq, "RAW6: inuse %d\n", 54 seq_printf(seq, "RAW6: inuse %d\n",
53 fold_prot_inuse(&rawv6_prot)); 55 fold_prot_inuse(&rawv6_prot));
54 seq_printf(seq, "FRAG6: inuse %d memory %d\n", 56 seq_printf(seq, "FRAG6: inuse %d memory %d\n",
@@ -133,6 +135,14 @@ static struct snmp_mib snmp6_udp6_list[] = {
133 SNMP_MIB_SENTINEL 135 SNMP_MIB_SENTINEL
134}; 136};
135 137
138static struct snmp_mib snmp6_udplite6_list[] = {
139 SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS),
140 SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS),
141 SNMP_MIB_ITEM("UdpLite6InErrors", UDP_MIB_INERRORS),
142 SNMP_MIB_ITEM("UdpLite6OutDatagrams", UDP_MIB_OUTDATAGRAMS),
143 SNMP_MIB_SENTINEL
144};
145
136static unsigned long 146static unsigned long
137fold_field(void *mib[], int offt) 147fold_field(void *mib[], int offt)
138{ 148{
@@ -167,6 +177,7 @@ static int snmp6_seq_show(struct seq_file *seq, void *v)
167 snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list); 177 snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list);
168 snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); 178 snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list);
169 snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list); 179 snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list);
180 snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list);
170 } 181 }
171 return 0; 182 return 0;
172} 183}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 886300d13a59..5a64027bf2fc 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -38,26 +38,18 @@
38#include <linux/skbuff.h> 38#include <linux/skbuff.h>
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40 40
41#include <net/sock.h>
42#include <net/snmp.h>
43
44#include <net/ipv6.h>
45#include <net/ndisc.h> 41#include <net/ndisc.h>
46#include <net/protocol.h> 42#include <net/protocol.h>
47#include <net/transp_v6.h> 43#include <net/transp_v6.h>
48#include <net/ip6_route.h> 44#include <net/ip6_route.h>
49#include <net/addrconf.h>
50#include <net/ip.h>
51#include <net/udp.h>
52#include <net/raw.h> 45#include <net/raw.h>
53#include <net/inet_common.h>
54#include <net/tcp_states.h> 46#include <net/tcp_states.h>
55
56#include <net/ip6_checksum.h> 47#include <net/ip6_checksum.h>
57#include <net/xfrm.h> 48#include <net/xfrm.h>
58 49
59#include <linux/proc_fs.h> 50#include <linux/proc_fs.h>
60#include <linux/seq_file.h> 51#include <linux/seq_file.h>
52#include "udp_impl.h"
61 53
62DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; 54DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
63 55
@@ -66,23 +58,9 @@ static inline int udp_v6_get_port(struct sock *sk, unsigned short snum)
66 return udp_get_port(sk, snum, ipv6_rcv_saddr_equal); 58 return udp_get_port(sk, snum, ipv6_rcv_saddr_equal);
67} 59}
68 60
69static void udp_v6_hash(struct sock *sk) 61static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport,
70{ 62 struct in6_addr *daddr, __be16 dport,
71 BUG(); 63 int dif, struct hlist_head udptable[])
72}
73
74static void udp_v6_unhash(struct sock *sk)
75{
76 write_lock_bh(&udp_hash_lock);
77 if (sk_del_node_init(sk)) {
78 inet_sk(sk)->num = 0;
79 sock_prot_dec_use(sk->sk_prot);
80 }
81 write_unlock_bh(&udp_hash_lock);
82}
83
84static struct sock *udp_v6_lookup(struct in6_addr *saddr, u16 sport,
85 struct in6_addr *daddr, u16 dport, int dif)
86{ 64{
87 struct sock *sk, *result = NULL; 65 struct sock *sk, *result = NULL;
88 struct hlist_node *node; 66 struct hlist_node *node;
@@ -90,7 +68,7 @@ static struct sock *udp_v6_lookup(struct in6_addr *saddr, u16 sport,
90 int badness = -1; 68 int badness = -1;
91 69
92 read_lock(&udp_hash_lock); 70 read_lock(&udp_hash_lock);
93 sk_for_each(sk, node, &udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]) { 71 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
94 struct inet_sock *inet = inet_sk(sk); 72 struct inet_sock *inet = inet_sk(sk);
95 73
96 if (inet->num == hnum && sk->sk_family == PF_INET6) { 74 if (inet->num == hnum && sk->sk_family == PF_INET6) {
@@ -132,20 +110,11 @@ static struct sock *udp_v6_lookup(struct in6_addr *saddr, u16 sport,
132} 110}
133 111
134/* 112/*
135 *
136 */
137
138static void udpv6_close(struct sock *sk, long timeout)
139{
140 sk_common_release(sk);
141}
142
143/*
144 * This should be easy, if there is something there we 113 * This should be easy, if there is something there we
145 * return it, otherwise we block. 114 * return it, otherwise we block.
146 */ 115 */
147 116
148static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, 117int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
149 struct msghdr *msg, size_t len, 118 struct msghdr *msg, size_t len,
150 int noblock, int flags, int *addr_len) 119 int noblock, int flags, int *addr_len)
151{ 120{
@@ -153,7 +122,7 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
153 struct inet_sock *inet = inet_sk(sk); 122 struct inet_sock *inet = inet_sk(sk);
154 struct sk_buff *skb; 123 struct sk_buff *skb;
155 size_t copied; 124 size_t copied;
156 int err; 125 int err, copy_only, is_udplite = IS_UDPLITE(sk);
157 126
158 if (addr_len) 127 if (addr_len)
159 *addr_len=sizeof(struct sockaddr_in6); 128 *addr_len=sizeof(struct sockaddr_in6);
@@ -172,15 +141,21 @@ try_again:
172 msg->msg_flags |= MSG_TRUNC; 141 msg->msg_flags |= MSG_TRUNC;
173 } 142 }
174 143
175 if (skb->ip_summed==CHECKSUM_UNNECESSARY) { 144 /*
176 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov, 145 * Decide whether to checksum and/or copy data.
177 copied); 146 */
178 } else if (msg->msg_flags&MSG_TRUNC) { 147 copy_only = (skb->ip_summed==CHECKSUM_UNNECESSARY);
179 if (__skb_checksum_complete(skb)) 148
149 if (is_udplite || (!copy_only && msg->msg_flags&MSG_TRUNC)) {
150 if (__udp_lib_checksum_complete(skb))
180 goto csum_copy_err; 151 goto csum_copy_err;
181 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov, 152 copy_only = 1;
182 copied); 153 }
183 } else { 154
155 if (copy_only)
156 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
157 msg->msg_iov, copied );
158 else {
184 err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov); 159 err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov);
185 if (err == -EINVAL) 160 if (err == -EINVAL)
186 goto csum_copy_err; 161 goto csum_copy_err;
@@ -231,14 +206,15 @@ csum_copy_err:
231 skb_kill_datagram(sk, skb, flags); 206 skb_kill_datagram(sk, skb, flags);
232 207
233 if (flags & MSG_DONTWAIT) { 208 if (flags & MSG_DONTWAIT) {
234 UDP6_INC_STATS_USER(UDP_MIB_INERRORS); 209 UDP6_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite);
235 return -EAGAIN; 210 return -EAGAIN;
236 } 211 }
237 goto try_again; 212 goto try_again;
238} 213}
239 214
240static void udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 215void __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
241 int type, int code, int offset, __be32 info) 216 int type, int code, int offset, __be32 info,
217 struct hlist_head udptable[] )
242{ 218{
243 struct ipv6_pinfo *np; 219 struct ipv6_pinfo *np;
244 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data; 220 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data;
@@ -248,8 +224,8 @@ static void udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
248 struct sock *sk; 224 struct sock *sk;
249 int err; 225 int err;
250 226
251 sk = udp_v6_lookup(daddr, uh->dest, saddr, uh->source, inet6_iif(skb)); 227 sk = __udp6_lib_lookup(daddr, uh->dest,
252 228 saddr, uh->source, inet6_iif(skb), udptable);
253 if (sk == NULL) 229 if (sk == NULL)
254 return; 230 return;
255 231
@@ -270,31 +246,55 @@ out:
270 sock_put(sk); 246 sock_put(sk);
271} 247}
272 248
273static inline int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) 249static __inline__ void udpv6_err(struct sk_buff *skb,
250 struct inet6_skb_parm *opt, int type,
251 int code, int offset, __u32 info )
252{
253 return __udp6_lib_err(skb, opt, type, code, offset, info, udp_hash);
254}
255
256int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
274{ 257{
258 struct udp_sock *up = udp_sk(sk);
275 int rc; 259 int rc;
276 260
277 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) { 261 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
278 kfree_skb(skb); 262 goto drop;
279 return -1;
280 }
281 263
282 if (skb_checksum_complete(skb)) { 264 /*
283 UDP6_INC_STATS_BH(UDP_MIB_INERRORS); 265 * UDP-Lite specific tests, ignored on UDP sockets (see net/ipv4/udp.c).
284 kfree_skb(skb); 266 */
285 return 0; 267 if ((up->pcflag & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) {
268
269 if (up->pcrlen == 0) { /* full coverage was set */
270 LIMIT_NETDEBUG(KERN_WARNING "UDPLITE6: partial coverage"
271 " %d while full coverage %d requested\n",
272 UDP_SKB_CB(skb)->cscov, skb->len);
273 goto drop;
274 }
275 if (UDP_SKB_CB(skb)->cscov < up->pcrlen) {
276 LIMIT_NETDEBUG(KERN_WARNING "UDPLITE6: coverage %d "
277 "too small, need min %d\n",
278 UDP_SKB_CB(skb)->cscov, up->pcrlen);
279 goto drop;
280 }
286 } 281 }
287 282
283 if (udp_lib_checksum_complete(skb))
284 goto drop;
285
288 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { 286 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) {
289 /* Note that an ENOMEM error is charged twice */ 287 /* Note that an ENOMEM error is charged twice */
290 if (rc == -ENOMEM) 288 if (rc == -ENOMEM)
291 UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS); 289 UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, up->pcflag);
292 UDP6_INC_STATS_BH(UDP_MIB_INERRORS); 290 goto drop;
293 kfree_skb(skb);
294 return 0;
295 } 291 }
296 UDP6_INC_STATS_BH(UDP_MIB_INDATAGRAMS); 292 UDP6_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
297 return 0; 293 return 0;
294drop:
295 UDP6_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag);
296 kfree_skb(skb);
297 return -1;
298} 298}
299 299
300static struct sock *udp_v6_mcast_next(struct sock *sk, 300static struct sock *udp_v6_mcast_next(struct sock *sk,
@@ -338,15 +338,15 @@ static struct sock *udp_v6_mcast_next(struct sock *sk,
338 * Note: called only from the BH handler context, 338 * Note: called only from the BH handler context,
339 * so we don't need to lock the hashes. 339 * so we don't need to lock the hashes.
340 */ 340 */
341static void udpv6_mcast_deliver(struct udphdr *uh, 341static int __udp6_lib_mcast_deliver(struct sk_buff *skb, struct in6_addr *saddr,
342 struct in6_addr *saddr, struct in6_addr *daddr, 342 struct in6_addr *daddr, struct hlist_head udptable[])
343 struct sk_buff *skb)
344{ 343{
345 struct sock *sk, *sk2; 344 struct sock *sk, *sk2;
345 const struct udphdr *uh = skb->h.uh;
346 int dif; 346 int dif;
347 347
348 read_lock(&udp_hash_lock); 348 read_lock(&udp_hash_lock);
349 sk = sk_head(&udp_hash[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]); 349 sk = sk_head(&udptable[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]);
350 dif = inet6_iif(skb); 350 dif = inet6_iif(skb);
351 sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif); 351 sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif);
352 if (!sk) { 352 if (!sk) {
@@ -364,9 +364,34 @@ static void udpv6_mcast_deliver(struct udphdr *uh,
364 udpv6_queue_rcv_skb(sk, skb); 364 udpv6_queue_rcv_skb(sk, skb);
365out: 365out:
366 read_unlock(&udp_hash_lock); 366 read_unlock(&udp_hash_lock);
367 return 0;
367} 368}
368 369
369static int udpv6_rcv(struct sk_buff **pskb) 370static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh)
371
372{
373 if (uh->check == 0) {
374 /* RFC 2460 section 8.1 says that we SHOULD log
375 this error. Well, it is reasonable.
376 */
377 LIMIT_NETDEBUG(KERN_INFO "IPv6: udp checksum is 0\n");
378 return 1;
379 }
380 if (skb->ip_summed == CHECKSUM_COMPLETE &&
381 !csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr,
382 skb->len, IPPROTO_UDP, skb->csum ))
383 skb->ip_summed = CHECKSUM_UNNECESSARY;
384
385 if (skb->ip_summed != CHECKSUM_UNNECESSARY)
386 skb->csum = ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
387 &skb->nh.ipv6h->daddr,
388 skb->len, IPPROTO_UDP, 0);
389
390 return (UDP_SKB_CB(skb)->partial_cov = 0);
391}
392
393int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[],
394 int is_udplite)
370{ 395{
371 struct sk_buff *skb = *pskb; 396 struct sk_buff *skb = *pskb;
372 struct sock *sk; 397 struct sock *sk;
@@ -383,44 +408,39 @@ static int udpv6_rcv(struct sk_buff **pskb)
383 uh = skb->h.uh; 408 uh = skb->h.uh;
384 409
385 ulen = ntohs(uh->len); 410 ulen = ntohs(uh->len);
411 if (ulen > skb->len)
412 goto short_packet;
386 413
387 /* Check for jumbo payload */ 414 if(! is_udplite ) { /* UDP validates ulen. */
388 if (ulen == 0)
389 ulen = skb->len;
390 415
391 if (ulen > skb->len || ulen < sizeof(*uh)) 416 /* Check for jumbo payload */
392 goto short_packet; 417 if (ulen == 0)
418 ulen = skb->len;
393 419
394 if (uh->check == 0) { 420 if (ulen < sizeof(*uh))
395 /* RFC 2460 section 8.1 says that we SHOULD log 421 goto short_packet;
396 this error. Well, it is reasonable.
397 */
398 LIMIT_NETDEBUG(KERN_INFO "IPv6: udp checksum is 0\n");
399 goto discard;
400 }
401 422
402 if (ulen < skb->len) { 423 if (ulen < skb->len) {
403 if (pskb_trim_rcsum(skb, ulen)) 424 if (pskb_trim_rcsum(skb, ulen))
404 goto discard; 425 goto short_packet;
405 saddr = &skb->nh.ipv6h->saddr; 426 saddr = &skb->nh.ipv6h->saddr;
406 daddr = &skb->nh.ipv6h->daddr; 427 daddr = &skb->nh.ipv6h->daddr;
407 uh = skb->h.uh; 428 uh = skb->h.uh;
408 } 429 }
409 430
410 if (skb->ip_summed == CHECKSUM_COMPLETE && 431 if (udp6_csum_init(skb, uh))
411 !csum_ipv6_magic(saddr, daddr, ulen, IPPROTO_UDP, skb->csum)) 432 goto discard;
412 skb->ip_summed = CHECKSUM_UNNECESSARY;
413 433
414 if (skb->ip_summed != CHECKSUM_UNNECESSARY) 434 } else { /* UDP-Lite validates cscov. */
415 skb->csum = ~csum_ipv6_magic(saddr, daddr, ulen, IPPROTO_UDP, 0); 435 if (udplite6_csum_init(skb, uh))
436 goto discard;
437 }
416 438
417 /* 439 /*
418 * Multicast receive code 440 * Multicast receive code
419 */ 441 */
420 if (ipv6_addr_is_multicast(daddr)) { 442 if (ipv6_addr_is_multicast(daddr))
421 udpv6_mcast_deliver(uh, saddr, daddr, skb); 443 return __udp6_lib_mcast_deliver(skb, saddr, daddr, udptable);
422 return 0;
423 }
424 444
425 /* Unicast */ 445 /* Unicast */
426 446
@@ -428,15 +448,16 @@ static int udpv6_rcv(struct sk_buff **pskb)
428 * check socket cache ... must talk to Alan about his plans 448 * check socket cache ... must talk to Alan about his plans
429 * for sock caches... i'll skip this for now. 449 * for sock caches... i'll skip this for now.
430 */ 450 */
431 sk = udp_v6_lookup(saddr, uh->source, daddr, uh->dest, inet6_iif(skb)); 451 sk = __udp6_lib_lookup(saddr, uh->source,
452 daddr, uh->dest, inet6_iif(skb), udptable);
432 453
433 if (sk == NULL) { 454 if (sk == NULL) {
434 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) 455 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
435 goto discard; 456 goto discard;
436 457
437 if (skb_checksum_complete(skb)) 458 if (udp_lib_checksum_complete(skb))
438 goto discard; 459 goto discard;
439 UDP6_INC_STATS_BH(UDP_MIB_NOPORTS); 460 UDP6_INC_STATS_BH(UDP_MIB_NOPORTS, is_udplite);
440 461
441 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, dev); 462 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, dev);
442 463
@@ -451,14 +472,20 @@ static int udpv6_rcv(struct sk_buff **pskb)
451 return(0); 472 return(0);
452 473
453short_packet: 474short_packet:
454 if (net_ratelimit()) 475 LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n",
455 printk(KERN_DEBUG "UDP: short packet: %d/%u\n", ulen, skb->len); 476 is_udplite? "-Lite" : "", ulen, skb->len);
456 477
457discard: 478discard:
458 UDP6_INC_STATS_BH(UDP_MIB_INERRORS); 479 UDP6_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
459 kfree_skb(skb); 480 kfree_skb(skb);
460 return(0); 481 return(0);
461} 482}
483
484static __inline__ int udpv6_rcv(struct sk_buff **pskb)
485{
486 return __udp6_lib_rcv(pskb, udp_hash, 0);
487}
488
462/* 489/*
463 * Throw away all pending data and cancel the corking. Socket is locked. 490 * Throw away all pending data and cancel the corking. Socket is locked.
464 */ 491 */
@@ -484,6 +511,7 @@ static int udp_v6_push_pending_frames(struct sock *sk, struct udp_sock *up)
484 struct inet_sock *inet = inet_sk(sk); 511 struct inet_sock *inet = inet_sk(sk);
485 struct flowi *fl = &inet->cork.fl; 512 struct flowi *fl = &inet->cork.fl;
486 int err = 0; 513 int err = 0;
514 u32 csum = 0;
487 515
488 /* Grab the skbuff where UDP header space exists. */ 516 /* Grab the skbuff where UDP header space exists. */
489 if ((skb = skb_peek(&sk->sk_write_queue)) == NULL) 517 if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
@@ -498,35 +526,17 @@ static int udp_v6_push_pending_frames(struct sock *sk, struct udp_sock *up)
498 uh->len = htons(up->len); 526 uh->len = htons(up->len);
499 uh->check = 0; 527 uh->check = 0;
500 528
501 if (sk->sk_no_check == UDP_CSUM_NOXMIT) { 529 if (up->pcflag)
502 skb->ip_summed = CHECKSUM_NONE; 530 csum = udplite_csum_outgoing(sk, skb);
503 goto send; 531 else
504 } 532 csum = udp_csum_outgoing(sk, skb);
505
506 if (skb_queue_len(&sk->sk_write_queue) == 1) {
507 skb->csum = csum_partial((char *)uh,
508 sizeof(struct udphdr), skb->csum);
509 uh->check = csum_ipv6_magic(&fl->fl6_src,
510 &fl->fl6_dst,
511 up->len, fl->proto, skb->csum);
512 } else {
513 u32 tmp_csum = 0;
514
515 skb_queue_walk(&sk->sk_write_queue, skb) {
516 tmp_csum = csum_add(tmp_csum, skb->csum);
517 }
518 tmp_csum = csum_partial((char *)uh,
519 sizeof(struct udphdr), tmp_csum);
520 tmp_csum = csum_ipv6_magic(&fl->fl6_src,
521 &fl->fl6_dst,
522 up->len, fl->proto, tmp_csum);
523 uh->check = tmp_csum;
524 533
525 } 534 /* add protocol-dependent pseudo-header */
535 uh->check = csum_ipv6_magic(&fl->fl6_src, &fl->fl6_dst,
536 up->len, fl->proto, csum );
526 if (uh->check == 0) 537 if (uh->check == 0)
527 uh->check = -1; 538 uh->check = -1;
528 539
529send:
530 err = ip6_push_pending_frames(sk); 540 err = ip6_push_pending_frames(sk);
531out: 541out:
532 up->len = 0; 542 up->len = 0;
@@ -534,7 +544,7 @@ out:
534 return err; 544 return err;
535} 545}
536 546
537static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, 547int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
538 struct msghdr *msg, size_t len) 548 struct msghdr *msg, size_t len)
539{ 549{
540 struct ipv6_txoptions opt_space; 550 struct ipv6_txoptions opt_space;
@@ -554,6 +564,8 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
554 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; 564 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
555 int err; 565 int err;
556 int connected = 0; 566 int connected = 0;
567 int is_udplite = up->pcflag;
568 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
557 569
558 /* destination address check */ 570 /* destination address check */
559 if (sin6) { 571 if (sin6) {
@@ -694,7 +706,7 @@ do_udp_sendmsg:
694 opt = fl6_merge_options(&opt_space, flowlabel, opt); 706 opt = fl6_merge_options(&opt_space, flowlabel, opt);
695 opt = ipv6_fixup_options(&opt_space, opt); 707 opt = ipv6_fixup_options(&opt_space, opt);
696 708
697 fl.proto = IPPROTO_UDP; 709 fl.proto = sk->sk_protocol;
698 ipv6_addr_copy(&fl.fl6_dst, daddr); 710 ipv6_addr_copy(&fl.fl6_dst, daddr);
699 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) 711 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
700 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 712 ipv6_addr_copy(&fl.fl6_src, &np->saddr);
@@ -761,7 +773,8 @@ back_from_confirm:
761 773
762do_append_data: 774do_append_data:
763 up->len += ulen; 775 up->len += ulen;
764 err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, 776 getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
777 err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen,
765 sizeof(struct udphdr), hlimit, tclass, opt, &fl, 778 sizeof(struct udphdr), hlimit, tclass, opt, &fl,
766 (struct rt6_info*)dst, 779 (struct rt6_info*)dst,
767 corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); 780 corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags);
@@ -793,7 +806,7 @@ do_append_data:
793out: 806out:
794 fl6_sock_release(flowlabel); 807 fl6_sock_release(flowlabel);
795 if (!err) { 808 if (!err) {
796 UDP6_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS); 809 UDP6_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS, is_udplite);
797 return len; 810 return len;
798 } 811 }
799 /* 812 /*
@@ -804,7 +817,7 @@ out:
804 * seems like overkill. 817 * seems like overkill.
805 */ 818 */
806 if (err == -ENOBUFS || test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) { 819 if (err == -ENOBUFS || test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
807 UDP6_INC_STATS_USER(UDP_MIB_SNDBUFERRORS); 820 UDP6_INC_STATS_USER(UDP_MIB_SNDBUFERRORS, is_udplite);
808 } 821 }
809 return err; 822 return err;
810 823
@@ -816,7 +829,7 @@ do_confirm:
816 goto out; 829 goto out;
817} 830}
818 831
819static int udpv6_destroy_sock(struct sock *sk) 832int udpv6_destroy_sock(struct sock *sk)
820{ 833{
821 lock_sock(sk); 834 lock_sock(sk);
822 udp_v6_flush_pending_frames(sk); 835 udp_v6_flush_pending_frames(sk);
@@ -854,7 +867,6 @@ static int do_udpv6_setsockopt(struct sock *sk, int level, int optname,
854 release_sock(sk); 867 release_sock(sk);
855 } 868 }
856 break; 869 break;
857
858 case UDP_ENCAP: 870 case UDP_ENCAP:
859 switch (val) { 871 switch (val) {
860 case 0: 872 case 0:
@@ -866,6 +878,24 @@ static int do_udpv6_setsockopt(struct sock *sk, int level, int optname,
866 } 878 }
867 break; 879 break;
868 880
881 case UDPLITE_SEND_CSCOV:
882 if (!up->pcflag) /* Disable the option on UDP sockets */
883 return -ENOPROTOOPT;
884 if (val != 0 && val < 8) /* Illegal coverage: use default (8) */
885 val = 8;
886 up->pcslen = val;
887 up->pcflag |= UDPLITE_SEND_CC;
888 break;
889
890 case UDPLITE_RECV_CSCOV:
891 if (!up->pcflag) /* Disable the option on UDP sockets */
892 return -ENOPROTOOPT;
893 if (val != 0 && val < 8) /* Avoid silly minimal values. */
894 val = 8;
895 up->pcrlen = val;
896 up->pcflag |= UDPLITE_RECV_CC;
897 break;
898
869 default: 899 default:
870 err = -ENOPROTOOPT; 900 err = -ENOPROTOOPT;
871 break; 901 break;
@@ -874,22 +904,21 @@ static int do_udpv6_setsockopt(struct sock *sk, int level, int optname,
874 return err; 904 return err;
875} 905}
876 906
877static int udpv6_setsockopt(struct sock *sk, int level, int optname, 907int udpv6_setsockopt(struct sock *sk, int level, int optname,
878 char __user *optval, int optlen) 908 char __user *optval, int optlen)
879{ 909{
880 if (level != SOL_UDP) 910 if (level == SOL_UDP || level == SOL_UDPLITE)
881 return ipv6_setsockopt(sk, level, optname, optval, optlen); 911 return do_udpv6_setsockopt(sk, level, optname, optval, optlen);
882 return do_udpv6_setsockopt(sk, level, optname, optval, optlen); 912 return ipv6_setsockopt(sk, level, optname, optval, optlen);
883} 913}
884 914
885#ifdef CONFIG_COMPAT 915#ifdef CONFIG_COMPAT
886static int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, 916int compat_udpv6_setsockopt(struct sock *sk, int level, int optname,
887 char __user *optval, int optlen) 917 char __user *optval, int optlen)
888{ 918{
889 if (level != SOL_UDP) 919 if (level == SOL_UDP || level == SOL_UDPLITE)
890 return compat_ipv6_setsockopt(sk, level, optname, 920 return do_udpv6_setsockopt(sk, level, optname, optval, optlen);
891 optval, optlen); 921 return compat_ipv6_setsockopt(sk, level, optname, optval, optlen);
892 return do_udpv6_setsockopt(sk, level, optname, optval, optlen);
893} 922}
894#endif 923#endif
895 924
@@ -916,6 +945,14 @@ static int do_udpv6_getsockopt(struct sock *sk, int level, int optname,
916 val = up->encap_type; 945 val = up->encap_type;
917 break; 946 break;
918 947
948 case UDPLITE_SEND_CSCOV:
949 val = up->pcslen;
950 break;
951
952 case UDPLITE_RECV_CSCOV:
953 val = up->pcrlen;
954 break;
955
919 default: 956 default:
920 return -ENOPROTOOPT; 957 return -ENOPROTOOPT;
921 }; 958 };
@@ -927,22 +964,21 @@ static int do_udpv6_getsockopt(struct sock *sk, int level, int optname,
927 return 0; 964 return 0;
928} 965}
929 966
930static int udpv6_getsockopt(struct sock *sk, int level, int optname, 967int udpv6_getsockopt(struct sock *sk, int level, int optname,
931 char __user *optval, int __user *optlen) 968 char __user *optval, int __user *optlen)
932{ 969{
933 if (level != SOL_UDP) 970 if (level == SOL_UDP || level == SOL_UDPLITE)
934 return ipv6_getsockopt(sk, level, optname, optval, optlen); 971 return do_udpv6_getsockopt(sk, level, optname, optval, optlen);
935 return do_udpv6_getsockopt(sk, level, optname, optval, optlen); 972 return ipv6_getsockopt(sk, level, optname, optval, optlen);
936} 973}
937 974
938#ifdef CONFIG_COMPAT 975#ifdef CONFIG_COMPAT
939static int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, 976int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
940 char __user *optval, int __user *optlen) 977 char __user *optval, int __user *optlen)
941{ 978{
942 if (level != SOL_UDP) 979 if (level == SOL_UDP || level == SOL_UDPLITE)
943 return compat_ipv6_getsockopt(sk, level, optname, 980 return do_udpv6_getsockopt(sk, level, optname, optval, optlen);
944 optval, optlen); 981 return compat_ipv6_getsockopt(sk, level, optname, optval, optlen);
945 return do_udpv6_getsockopt(sk, level, optname, optval, optlen);
946} 982}
947#endif 983#endif
948 984
@@ -983,7 +1019,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
983 atomic_read(&sp->sk_refcnt), sp); 1019 atomic_read(&sp->sk_refcnt), sp);
984} 1020}
985 1021
986static int udp6_seq_show(struct seq_file *seq, void *v) 1022int udp6_seq_show(struct seq_file *seq, void *v)
987{ 1023{
988 if (v == SEQ_START_TOKEN) 1024 if (v == SEQ_START_TOKEN)
989 seq_printf(seq, 1025 seq_printf(seq,
@@ -1002,6 +1038,7 @@ static struct udp_seq_afinfo udp6_seq_afinfo = {
1002 .owner = THIS_MODULE, 1038 .owner = THIS_MODULE,
1003 .name = "udp6", 1039 .name = "udp6",
1004 .family = AF_INET6, 1040 .family = AF_INET6,
1041 .hashtable = udp_hash,
1005 .seq_show = udp6_seq_show, 1042 .seq_show = udp6_seq_show,
1006 .seq_fops = &udp6_seq_fops, 1043 .seq_fops = &udp6_seq_fops,
1007}; 1044};
@@ -1021,7 +1058,7 @@ void udp6_proc_exit(void) {
1021struct proto udpv6_prot = { 1058struct proto udpv6_prot = {
1022 .name = "UDPv6", 1059 .name = "UDPv6",
1023 .owner = THIS_MODULE, 1060 .owner = THIS_MODULE,
1024 .close = udpv6_close, 1061 .close = udp_lib_close,
1025 .connect = ip6_datagram_connect, 1062 .connect = ip6_datagram_connect,
1026 .disconnect = udp_disconnect, 1063 .disconnect = udp_disconnect,
1027 .ioctl = udp_ioctl, 1064 .ioctl = udp_ioctl,
@@ -1031,8 +1068,8 @@ struct proto udpv6_prot = {
1031 .sendmsg = udpv6_sendmsg, 1068 .sendmsg = udpv6_sendmsg,
1032 .recvmsg = udpv6_recvmsg, 1069 .recvmsg = udpv6_recvmsg,
1033 .backlog_rcv = udpv6_queue_rcv_skb, 1070 .backlog_rcv = udpv6_queue_rcv_skb,
1034 .hash = udp_v6_hash, 1071 .hash = udp_lib_hash,
1035 .unhash = udp_v6_unhash, 1072 .unhash = udp_lib_unhash,
1036 .get_port = udp_v6_get_port, 1073 .get_port = udp_v6_get_port,
1037 .obj_size = sizeof(struct udp6_sock), 1074 .obj_size = sizeof(struct udp6_sock),
1038#ifdef CONFIG_COMPAT 1075#ifdef CONFIG_COMPAT
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
new file mode 100644
index 000000000000..ec9878899128
--- /dev/null
+++ b/net/ipv6/udp_impl.h
@@ -0,0 +1,34 @@
1#ifndef _UDP6_IMPL_H
2#define _UDP6_IMPL_H
3#include <net/udp.h>
4#include <net/udplite.h>
5#include <net/protocol.h>
6#include <net/addrconf.h>
7#include <net/inet_common.h>
8
9extern int __udp6_lib_rcv(struct sk_buff **, struct hlist_head [], int );
10extern void __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *,
11 int , int , int , __be32 , struct hlist_head []);
12
13extern int udpv6_getsockopt(struct sock *sk, int level, int optname,
14 char __user *optval, int __user *optlen);
15extern int udpv6_setsockopt(struct sock *sk, int level, int optname,
16 char __user *optval, int optlen);
17#ifdef CONFIG_COMPAT
18extern int compat_udpv6_setsockopt(struct sock *sk, int level, int optname,
19 char __user *optval, int optlen);
20extern int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
21 char __user *optval, int __user *optlen);
22#endif
23extern int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
24 struct msghdr *msg, size_t len);
25extern int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
26 struct msghdr *msg, size_t len,
27 int noblock, int flags, int *addr_len);
28extern int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb);
29extern int udpv6_destroy_sock(struct sock *sk);
30
31#ifdef CONFIG_PROC_FS
32extern int udp6_seq_show(struct seq_file *seq, void *v);
33#endif
34#endif /* _UDP6_IMPL_H */
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
new file mode 100644
index 000000000000..e0ec5e63004a
--- /dev/null
+++ b/net/ipv6/udplite.c
@@ -0,0 +1,105 @@
1/*
2 * UDPLITEv6 An implementation of the UDP-Lite protocol over IPv6.
3 * See also net/ipv4/udplite.c
4 *
5 * Version: $Id: udplite.c,v 1.9 2006/10/19 08:28:10 gerrit Exp $
6 *
7 * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk>
8 *
9 * Changes:
10 * Fixes:
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16#include "udp_impl.h"
17
18DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6) __read_mostly;
19
20static __inline__ int udplitev6_rcv(struct sk_buff **pskb)
21{
22 return __udp6_lib_rcv(pskb, udplite_hash, 1);
23}
24
25static __inline__ void udplitev6_err(struct sk_buff *skb,
26 struct inet6_skb_parm *opt,
27 int type, int code, int offset, __u32 info)
28{
29 return __udp6_lib_err(skb, opt, type, code, offset, info, udplite_hash);
30}
31
32static struct inet6_protocol udplitev6_protocol = {
33 .handler = udplitev6_rcv,
34 .err_handler = udplitev6_err,
35 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
36};
37
38static __inline__ int udplite_v6_get_port(struct sock *sk, unsigned short snum)
39{
40 return udplite_get_port(sk, snum, ipv6_rcv_saddr_equal);
41}
42
43struct proto udplitev6_prot = {
44 .name = "UDPLITEv6",
45 .owner = THIS_MODULE,
46 .close = udp_lib_close,
47 .connect = ip6_datagram_connect,
48 .disconnect = udp_disconnect,
49 .ioctl = udp_ioctl,
50 .init = udplite_sk_init,
51 .destroy = udpv6_destroy_sock,
52 .setsockopt = udpv6_setsockopt,
53 .getsockopt = udpv6_getsockopt,
54 .sendmsg = udpv6_sendmsg,
55 .recvmsg = udpv6_recvmsg,
56 .backlog_rcv = udpv6_queue_rcv_skb,
57 .hash = udp_lib_hash,
58 .unhash = udp_lib_unhash,
59 .get_port = udplite_v6_get_port,
60 .obj_size = sizeof(struct udp6_sock),
61#ifdef CONFIG_COMPAT
62 .compat_setsockopt = compat_udpv6_setsockopt,
63 .compat_getsockopt = compat_udpv6_getsockopt,
64#endif
65};
66
67static struct inet_protosw udplite6_protosw = {
68 .type = SOCK_DGRAM,
69 .protocol = IPPROTO_UDPLITE,
70 .prot = &udplitev6_prot,
71 .ops = &inet6_dgram_ops,
72 .capability = -1,
73 .no_check = 0,
74 .flags = INET_PROTOSW_PERMANENT,
75};
76
77void __init udplitev6_init(void)
78{
79 if (inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE) < 0)
80 printk(KERN_ERR "%s: Could not register.\n", __FUNCTION__);
81
82 inet6_register_protosw(&udplite6_protosw);
83}
84
85#ifdef CONFIG_PROC_FS
86static struct file_operations udplite6_seq_fops;
87static struct udp_seq_afinfo udplite6_seq_afinfo = {
88 .owner = THIS_MODULE,
89 .name = "udplite6",
90 .family = AF_INET6,
91 .hashtable = udplite_hash,
92 .seq_show = udp6_seq_show,
93 .seq_fops = &udplite6_seq_fops,
94};
95
96int __init udplite6_proc_init(void)
97{
98 return udp_proc_register(&udplite6_seq_afinfo);
99}
100
101void udplite6_proc_exit(void)
102{
103 udp_proc_unregister(&udplite6_seq_afinfo);
104}
105#endif
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 2fba1f0739aa..8dffd4daae9c 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -274,6 +274,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
274 break; 274 break;
275 275
276 case IPPROTO_UDP: 276 case IPPROTO_UDP:
277 case IPPROTO_UDPLITE:
277 case IPPROTO_TCP: 278 case IPPROTO_TCP:
278 case IPPROTO_SCTP: 279 case IPPROTO_SCTP:
279 case IPPROTO_DCCP: 280 case IPPROTO_DCCP: