2 * IPv6 library code, needed by static components when full IPv6 support is
3 * not configured or static. These functions are needed by GSO/GRO implementation.
5 #include <linux/export.h>
7 #include <net/ip6_fib.h>
8 #include <net/addrconf.h>
9 #include <net/secure_seq.h>
11 void ipv6_select_ident(struct frag_hdr
*fhdr
, struct rt6_info
*rt
)
13 static atomic_t ipv6_fragmentation_id
;
17 #if IS_ENABLED(CONFIG_IPV6)
18 struct inet_peer
*peer
;
21 net
= dev_net(rt
->dst
.dev
);
22 peer
= inet_getpeer_v6(net
->ipv6
.peers
, &rt
->rt6i_dst
.addr
, 1);
24 fhdr
->identification
= htonl(inet_getid(peer
, 0));
30 old
= atomic_read(&ipv6_fragmentation_id
);
34 } while (atomic_cmpxchg(&ipv6_fragmentation_id
, old
, new) != old
);
36 addr
= rt
->rt6i_dst
.addr
;
37 addr
.s6_addr32
[0] ^= (__force __be32
)new;
38 fhdr
->identification
= htonl(secure_ipv6_id(addr
.s6_addr32
));
40 EXPORT_SYMBOL(ipv6_select_ident
);
42 int ip6_find_1stfragopt(struct sk_buff
*skb
, u8
**nexthdr
)
44 u16 offset
= sizeof(struct ipv6hdr
);
45 struct ipv6_opt_hdr
*exthdr
=
46 (struct ipv6_opt_hdr
*)(ipv6_hdr(skb
) + 1);
47 unsigned int packet_len
= skb_tail_pointer(skb
) -
48 skb_network_header(skb
);
50 *nexthdr
= &ipv6_hdr(skb
)->nexthdr
;
52 while (offset
+ 1 <= packet_len
) {
62 #if IS_ENABLED(CONFIG_IPV6_MIP6)
63 if (ipv6_find_tlv(skb
, offset
, IPV6_TLV_HAO
) >= 0)
73 offset
+= ipv6_optlen(exthdr
);
74 *nexthdr
= &exthdr
->nexthdr
;
75 exthdr
= (struct ipv6_opt_hdr
*)(skb_network_header(skb
) +
81 EXPORT_SYMBOL(ip6_find_1stfragopt
);
83 #if IS_ENABLED(CONFIG_IPV6)
84 int ip6_dst_hoplimit(struct dst_entry
*dst
)
86 int hoplimit
= dst_metric_raw(dst
, RTAX_HOPLIMIT
);
88 struct net_device
*dev
= dst
->dev
;
89 struct inet6_dev
*idev
;
92 idev
= __in6_dev_get(dev
);
94 hoplimit
= idev
->cnf
.hop_limit
;
96 hoplimit
= dev_net(dev
)->ipv6
.devconf_all
->hop_limit
;
101 EXPORT_SYMBOL(ip6_dst_hoplimit
);
104 int __ip6_local_out(struct sk_buff
*skb
)
108 len
= skb
->len
- sizeof(struct ipv6hdr
);
109 if (len
> IPV6_MAXPLEN
)
111 ipv6_hdr(skb
)->payload_len
= htons(len
);
113 return nf_hook(NFPROTO_IPV6
, NF_INET_LOCAL_OUT
, skb
, NULL
,
114 skb_dst(skb
)->dev
, dst_output
);
116 EXPORT_SYMBOL_GPL(__ip6_local_out
);
118 int ip6_local_out(struct sk_buff
*skb
)
122 err
= __ip6_local_out(skb
);
123 if (likely(err
== 1))
124 err
= dst_output(skb
);
128 EXPORT_SYMBOL_GPL(ip6_local_out
);