blob: a5d465105b69375cab96217d0afd2485da303261 [file] [log] [blame]
Vlad Yasevich3c73a032012-11-15 08:49:20 +00001/*
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.
4 */
5#include <linux/export.h>
6#include <net/ipv6.h>
7#include <net/ip6_fib.h>
8
Vlad Yasevich3c73a032012-11-15 08:49:20 +00009
10int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
11{
12 u16 offset = sizeof(struct ipv6hdr);
13 struct ipv6_opt_hdr *exthdr =
14 (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1);
15 unsigned int packet_len = skb->tail - skb->network_header;
16 int found_rhdr = 0;
17 *nexthdr = &ipv6_hdr(skb)->nexthdr;
18
19 while (offset + 1 <= packet_len) {
20
21 switch (**nexthdr) {
22
23 case NEXTHDR_HOP:
24 break;
25 case NEXTHDR_ROUTING:
26 found_rhdr = 1;
27 break;
28 case NEXTHDR_DEST:
29#if IS_ENABLED(CONFIG_IPV6_MIP6)
30 if (ipv6_find_tlv(skb, offset, IPV6_TLV_HAO) >= 0)
31 break;
32#endif
33 if (found_rhdr)
34 return offset;
35 break;
36 default :
37 return offset;
38 }
39
40 offset += ipv6_optlen(exthdr);
41 *nexthdr = &exthdr->nexthdr;
42 exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) +
43 offset);
44 }
45
46 return offset;
47}
48EXPORT_SYMBOL(ip6_find_1stfragopt);