14 #include <linux/capability.h>
15 #include <linux/errno.h>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
19 #include <linux/socket.h>
21 #include <linux/in6.h>
22 #include <linux/ipv6.h>
24 #include <linux/slab.h>
25 #include <linux/export.h>
34 #include <linux/errqueue.h>
35 #include <asm/uaccess.h>
37 static bool ipv6_mapped_addr_any(
const struct in6_addr *
a)
39 return ipv6_addr_v4mapped(a) && (a->s6_addr32[3] == 0);
68 memset(&fl6, 0,
sizeof(fl6));
73 if (flowlabel ==
NULL)
79 addr_type = ipv6_addr_type(&usin->
sin6_addr);
98 sin.
sin_addr.s_addr = daddr->s6_addr32[3];
109 ipv6_addr_set_v4mapped(inet->inet_daddr, &np->
daddr);
111 if (ipv6_addr_any(&np->
saddr) ||
112 ipv6_mapped_addr_any(&np->
saddr))
117 ipv6_addr_set_v4mapped(inet->inet_rcv_saddr,
119 if (sk->sk_prot->rehash)
120 sk->sk_prot->rehash(sk);
129 if (sk->sk_bound_dev_if &&
141 if (!sk->sk_bound_dev_if) {
160 fl6.flowi6_oif = sk->sk_bound_dev_if;
168 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
170 opt = flowlabel ? flowlabel->
opt : np->
opt;
182 if (ipv6_addr_any(&np->
saddr))
188 if (sk->sk_prot->rehash)
189 sk->sk_prot->rehash(sk);
192 ip6_dst_store(sk, dst,
195 #ifdef CONFIG_IPV6_SUBTREES
203 fl6_sock_release(flowlabel);
212 struct icmp6hdr *icmph = icmp6_hdr(skb);
225 serr->
ee.ee_errno =
err;
231 serr->
ee.ee_data = 0;
233 skb_network_header(skb);
236 __skb_pull(skb, payload - skb->
data);
237 skb_reset_transport_header(skb);
260 skb_reset_network_header(skb);
265 serr->
ee.ee_errno =
err;
267 serr->
ee.ee_type = 0;
268 serr->
ee.ee_code = 0;
271 serr->
ee.ee_data = 0;
273 serr->
port = fl6->fl6_dport;
275 __skb_pull(skb, skb_tail_pointer(skb) - skb->
data);
276 skb_reset_transport_header(skb);
297 skb_reset_network_header(skb);
307 mtu_info->
ip6m_addr.sin6_scope_id = fl6->flowi6_oif;
308 mtu_info->
ip6m_addr.sin6_addr = ipv6_hdr(skb)->daddr;
310 __skb_pull(skb, skb_tail_pointer(skb) - skb->
data);
311 skb_reset_transport_header(skb);
347 sock_recv_timestamp(msg, sk, skb);
353 const unsigned char *nh = skb_network_header(skb);
374 sin = &errhdr.offender;
389 ipv6_addr_set_v4mapped(ip_hdr(skb)->
saddr,
447 sock_recv_timestamp(msg, sk, skb);
475 unsigned char *nh = skb_network_header(skb);
481 src_info.
ipi6_addr = ipv6_hdr(skb)->daddr;
486 int hlim = ipv6_hdr(skb)->hop_limit;
491 int tclass = ipv6_tclass(ipv6_hdr(skb));
517 unsigned int off =
sizeof(
struct ipv6hdr);
520 while (off <= opt->lastopt) {
527 len = (ptr[1] + 1) << 3;
533 len = (ptr[1] + 1) << 3;
539 len = (ptr[1] + 2) << 2;
543 len = (ptr[1] + 1) << 3;
556 src_info.
ipi6_addr = ipv6_hdr(skb)->daddr;
560 int hlim = ipv6_hdr(skb)->hop_limit;
583 if (skb_transport_offset(skb) + 4 <= skb->
len) {
604 int *hlimit,
int *tclass,
int *dontfrag)
638 if (fl6->flowi6_oif &&
647 if (fl6->flowi6_oif) {
660 if (!(inet_sk(sk)->freebind || inet_sk(sk)->transparent) &&
662 strict ? dev :
NULL, 0))
699 len = ((hdr->
hdrlen + 1) << 3);
719 len = ((hdr->
hdrlen + 1) << 3);
744 len = ((hdr->
hdrlen + 1) << 3);
771 switch (rthdr->
type) {
772 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
786 len = ((rthdr->
hdrlen + 1) << 3);
803 int dsthdrlen = ((opt->
dst1opt->hdrlen+1)<<3);
821 if (*hlimit < -1 || *hlimit > 0xff) {
855 if (df < 0 || df > 1)