flow.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. /*
  2. * Copyright (c) 2007-2013 Nicira, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of version 2 of the GNU General Public
  6. * License as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. * 02110-1301, USA
  17. */
  18. #include "flow.h"
  19. #include "datapath.h"
  20. #include <linux/uaccess.h>
  21. #include <linux/netdevice.h>
  22. #include <linux/etherdevice.h>
  23. #include <linux/if_ether.h>
  24. #include <linux/if_vlan.h>
  25. #include <net/llc_pdu.h>
  26. #include <linux/kernel.h>
  27. #include <linux/jhash.h>
  28. #include <linux/jiffies.h>
  29. #include <linux/llc.h>
  30. #include <linux/module.h>
  31. #include <linux/in.h>
  32. #include <linux/rcupdate.h>
  33. #include <linux/if_arp.h>
  34. #include <linux/ip.h>
  35. #include <linux/ipv6.h>
  36. #include <linux/sctp.h>
  37. #include <linux/smp.h>
  38. #include <linux/tcp.h>
  39. #include <linux/udp.h>
  40. #include <linux/icmp.h>
  41. #include <linux/icmpv6.h>
  42. #include <linux/rculist.h>
  43. #include <net/ip.h>
  44. #include <net/ip_tunnels.h>
  45. #include <net/ipv6.h>
  46. #include <net/ndisc.h>
  47. u64 ovs_flow_used_time(unsigned long flow_jiffies)
  48. {
  49. struct timespec cur_ts;
  50. u64 cur_ms, idle_ms;
  51. ktime_get_ts(&cur_ts);
  52. idle_ms = jiffies_to_msecs(jiffies - flow_jiffies);
  53. cur_ms = (u64)cur_ts.tv_sec * MSEC_PER_SEC +
  54. cur_ts.tv_nsec / NSEC_PER_MSEC;
  55. return cur_ms - idle_ms;
  56. }
  57. #define TCP_FLAGS_BE16(tp) (*(__be16 *)&tcp_flag_word(tp) & htons(0x0FFF))
  58. void ovs_flow_stats_update(struct sw_flow *flow, struct sk_buff *skb)
  59. {
  60. struct flow_stats *stats;
  61. __be16 tcp_flags = 0;
  62. if (!flow->stats.is_percpu)
  63. stats = flow->stats.stat;
  64. else
  65. stats = this_cpu_ptr(flow->stats.cpu_stats);
  66. if ((flow->key.eth.type == htons(ETH_P_IP) ||
  67. flow->key.eth.type == htons(ETH_P_IPV6)) &&
  68. flow->key.ip.proto == IPPROTO_TCP &&
  69. likely(skb->len >= skb_transport_offset(skb) + sizeof(struct tcphdr))) {
  70. tcp_flags = TCP_FLAGS_BE16(tcp_hdr(skb));
  71. }
  72. spin_lock(&stats->lock);
  73. stats->used = jiffies;
  74. stats->packet_count++;
  75. stats->byte_count += skb->len;
  76. stats->tcp_flags |= tcp_flags;
  77. spin_unlock(&stats->lock);
  78. }
  79. static void stats_read(struct flow_stats *stats,
  80. struct ovs_flow_stats *ovs_stats,
  81. unsigned long *used, __be16 *tcp_flags)
  82. {
  83. spin_lock(&stats->lock);
  84. if (time_after(stats->used, *used))
  85. *used = stats->used;
  86. *tcp_flags |= stats->tcp_flags;
  87. ovs_stats->n_packets += stats->packet_count;
  88. ovs_stats->n_bytes += stats->byte_count;
  89. spin_unlock(&stats->lock);
  90. }
  91. void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
  92. unsigned long *used, __be16 *tcp_flags)
  93. {
  94. int cpu, cur_cpu;
  95. *used = 0;
  96. *tcp_flags = 0;
  97. memset(ovs_stats, 0, sizeof(*ovs_stats));
  98. if (!flow->stats.is_percpu) {
  99. stats_read(flow->stats.stat, ovs_stats, used, tcp_flags);
  100. } else {
  101. cur_cpu = get_cpu();
  102. for_each_possible_cpu(cpu) {
  103. struct flow_stats *stats;
  104. if (cpu == cur_cpu)
  105. local_bh_disable();
  106. stats = per_cpu_ptr(flow->stats.cpu_stats, cpu);
  107. stats_read(stats, ovs_stats, used, tcp_flags);
  108. if (cpu == cur_cpu)
  109. local_bh_enable();
  110. }
  111. put_cpu();
  112. }
  113. }
  114. static void stats_reset(struct flow_stats *stats)
  115. {
  116. spin_lock(&stats->lock);
  117. stats->used = 0;
  118. stats->packet_count = 0;
  119. stats->byte_count = 0;
  120. stats->tcp_flags = 0;
  121. spin_unlock(&stats->lock);
  122. }
  123. void ovs_flow_stats_clear(struct sw_flow *flow)
  124. {
  125. int cpu, cur_cpu;
  126. if (!flow->stats.is_percpu) {
  127. stats_reset(flow->stats.stat);
  128. } else {
  129. cur_cpu = get_cpu();
  130. for_each_possible_cpu(cpu) {
  131. if (cpu == cur_cpu)
  132. local_bh_disable();
  133. stats_reset(per_cpu_ptr(flow->stats.cpu_stats, cpu));
  134. if (cpu == cur_cpu)
  135. local_bh_enable();
  136. }
  137. put_cpu();
  138. }
  139. }
  140. static int check_header(struct sk_buff *skb, int len)
  141. {
  142. if (unlikely(skb->len < len))
  143. return -EINVAL;
  144. if (unlikely(!pskb_may_pull(skb, len)))
  145. return -ENOMEM;
  146. return 0;
  147. }
  148. static bool arphdr_ok(struct sk_buff *skb)
  149. {
  150. return pskb_may_pull(skb, skb_network_offset(skb) +
  151. sizeof(struct arp_eth_header));
  152. }
  153. static int check_iphdr(struct sk_buff *skb)
  154. {
  155. unsigned int nh_ofs = skb_network_offset(skb);
  156. unsigned int ip_len;
  157. int err;
  158. err = check_header(skb, nh_ofs + sizeof(struct iphdr));
  159. if (unlikely(err))
  160. return err;
  161. ip_len = ip_hdrlen(skb);
  162. if (unlikely(ip_len < sizeof(struct iphdr) ||
  163. skb->len < nh_ofs + ip_len))
  164. return -EINVAL;
  165. skb_set_transport_header(skb, nh_ofs + ip_len);
  166. return 0;
  167. }
  168. static bool tcphdr_ok(struct sk_buff *skb)
  169. {
  170. int th_ofs = skb_transport_offset(skb);
  171. int tcp_len;
  172. if (unlikely(!pskb_may_pull(skb, th_ofs + sizeof(struct tcphdr))))
  173. return false;
  174. tcp_len = tcp_hdrlen(skb);
  175. if (unlikely(tcp_len < sizeof(struct tcphdr) ||
  176. skb->len < th_ofs + tcp_len))
  177. return false;
  178. return true;
  179. }
  180. static bool udphdr_ok(struct sk_buff *skb)
  181. {
  182. return pskb_may_pull(skb, skb_transport_offset(skb) +
  183. sizeof(struct udphdr));
  184. }
  185. static bool sctphdr_ok(struct sk_buff *skb)
  186. {
  187. return pskb_may_pull(skb, skb_transport_offset(skb) +
  188. sizeof(struct sctphdr));
  189. }
  190. static bool icmphdr_ok(struct sk_buff *skb)
  191. {
  192. return pskb_may_pull(skb, skb_transport_offset(skb) +
  193. sizeof(struct icmphdr));
  194. }
  195. static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key)
  196. {
  197. unsigned int nh_ofs = skb_network_offset(skb);
  198. unsigned int nh_len;
  199. int payload_ofs;
  200. struct ipv6hdr *nh;
  201. uint8_t nexthdr;
  202. __be16 frag_off;
  203. int err;
  204. err = check_header(skb, nh_ofs + sizeof(*nh));
  205. if (unlikely(err))
  206. return err;
  207. nh = ipv6_hdr(skb);
  208. nexthdr = nh->nexthdr;
  209. payload_ofs = (u8 *)(nh + 1) - skb->data;
  210. key->ip.proto = NEXTHDR_NONE;
  211. key->ip.tos = ipv6_get_dsfield(nh);
  212. key->ip.ttl = nh->hop_limit;
  213. key->ipv6.label = *(__be32 *)nh & htonl(IPV6_FLOWINFO_FLOWLABEL);
  214. key->ipv6.addr.src = nh->saddr;
  215. key->ipv6.addr.dst = nh->daddr;
  216. payload_ofs = ipv6_skip_exthdr(skb, payload_ofs, &nexthdr, &frag_off);
  217. if (unlikely(payload_ofs < 0))
  218. return -EINVAL;
  219. if (frag_off) {
  220. if (frag_off & htons(~0x7))
  221. key->ip.frag = OVS_FRAG_TYPE_LATER;
  222. else
  223. key->ip.frag = OVS_FRAG_TYPE_FIRST;
  224. }
  225. nh_len = payload_ofs - nh_ofs;
  226. skb_set_transport_header(skb, nh_ofs + nh_len);
  227. key->ip.proto = nexthdr;
  228. return nh_len;
  229. }
  230. static bool icmp6hdr_ok(struct sk_buff *skb)
  231. {
  232. return pskb_may_pull(skb, skb_transport_offset(skb) +
  233. sizeof(struct icmp6hdr));
  234. }
  235. static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
  236. {
  237. struct qtag_prefix {
  238. __be16 eth_type; /* ETH_P_8021Q */
  239. __be16 tci;
  240. };
  241. struct qtag_prefix *qp;
  242. if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
  243. return 0;
  244. if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
  245. sizeof(__be16))))
  246. return -ENOMEM;
  247. qp = (struct qtag_prefix *) skb->data;
  248. key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
  249. __skb_pull(skb, sizeof(struct qtag_prefix));
  250. return 0;
  251. }
  252. static __be16 parse_ethertype(struct sk_buff *skb)
  253. {
  254. struct llc_snap_hdr {
  255. u8 dsap; /* Always 0xAA */
  256. u8 ssap; /* Always 0xAA */
  257. u8 ctrl;
  258. u8 oui[3];
  259. __be16 ethertype;
  260. };
  261. struct llc_snap_hdr *llc;
  262. __be16 proto;
  263. proto = *(__be16 *) skb->data;
  264. __skb_pull(skb, sizeof(__be16));
  265. if (ntohs(proto) >= ETH_P_802_3_MIN)
  266. return proto;
  267. if (skb->len < sizeof(struct llc_snap_hdr))
  268. return htons(ETH_P_802_2);
  269. if (unlikely(!pskb_may_pull(skb, sizeof(struct llc_snap_hdr))))
  270. return htons(0);
  271. llc = (struct llc_snap_hdr *) skb->data;
  272. if (llc->dsap != LLC_SAP_SNAP ||
  273. llc->ssap != LLC_SAP_SNAP ||
  274. (llc->oui[0] | llc->oui[1] | llc->oui[2]) != 0)
  275. return htons(ETH_P_802_2);
  276. __skb_pull(skb, sizeof(struct llc_snap_hdr));
  277. if (ntohs(llc->ethertype) >= ETH_P_802_3_MIN)
  278. return llc->ethertype;
  279. return htons(ETH_P_802_2);
  280. }
  281. static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
  282. int nh_len)
  283. {
  284. struct icmp6hdr *icmp = icmp6_hdr(skb);
  285. /* The ICMPv6 type and code fields use the 16-bit transport port
  286. * fields, so we need to store them in 16-bit network byte order.
  287. */
  288. key->ipv6.tp.src = htons(icmp->icmp6_type);
  289. key->ipv6.tp.dst = htons(icmp->icmp6_code);
  290. if (icmp->icmp6_code == 0 &&
  291. (icmp->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION ||
  292. icmp->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT)) {
  293. int icmp_len = skb->len - skb_transport_offset(skb);
  294. struct nd_msg *nd;
  295. int offset;
  296. /* In order to process neighbor discovery options, we need the
  297. * entire packet.
  298. */
  299. if (unlikely(icmp_len < sizeof(*nd)))
  300. return 0;
  301. if (unlikely(skb_linearize(skb)))
  302. return -ENOMEM;
  303. nd = (struct nd_msg *)skb_transport_header(skb);
  304. key->ipv6.nd.target = nd->target;
  305. icmp_len -= sizeof(*nd);
  306. offset = 0;
  307. while (icmp_len >= 8) {
  308. struct nd_opt_hdr *nd_opt =
  309. (struct nd_opt_hdr *)(nd->opt + offset);
  310. int opt_len = nd_opt->nd_opt_len * 8;
  311. if (unlikely(!opt_len || opt_len > icmp_len))
  312. return 0;
  313. /* Store the link layer address if the appropriate
  314. * option is provided. It is considered an error if
  315. * the same link layer option is specified twice.
  316. */
  317. if (nd_opt->nd_opt_type == ND_OPT_SOURCE_LL_ADDR
  318. && opt_len == 8) {
  319. if (unlikely(!is_zero_ether_addr(key->ipv6.nd.sll)))
  320. goto invalid;
  321. memcpy(key->ipv6.nd.sll,
  322. &nd->opt[offset+sizeof(*nd_opt)], ETH_ALEN);
  323. } else if (nd_opt->nd_opt_type == ND_OPT_TARGET_LL_ADDR
  324. && opt_len == 8) {
  325. if (unlikely(!is_zero_ether_addr(key->ipv6.nd.tll)))
  326. goto invalid;
  327. memcpy(key->ipv6.nd.tll,
  328. &nd->opt[offset+sizeof(*nd_opt)], ETH_ALEN);
  329. }
  330. icmp_len -= opt_len;
  331. offset += opt_len;
  332. }
  333. }
  334. return 0;
  335. invalid:
  336. memset(&key->ipv6.nd.target, 0, sizeof(key->ipv6.nd.target));
  337. memset(key->ipv6.nd.sll, 0, sizeof(key->ipv6.nd.sll));
  338. memset(key->ipv6.nd.tll, 0, sizeof(key->ipv6.nd.tll));
  339. return 0;
  340. }
  341. /**
  342. * ovs_flow_extract - extracts a flow key from an Ethernet frame.
  343. * @skb: sk_buff that contains the frame, with skb->data pointing to the
  344. * Ethernet header
  345. * @in_port: port number on which @skb was received.
  346. * @key: output flow key
  347. *
  348. * The caller must ensure that skb->len >= ETH_HLEN.
  349. *
  350. * Returns 0 if successful, otherwise a negative errno value.
  351. *
  352. * Initializes @skb header pointers as follows:
  353. *
  354. * - skb->mac_header: the Ethernet header.
  355. *
  356. * - skb->network_header: just past the Ethernet header, or just past the
  357. * VLAN header, to the first byte of the Ethernet payload.
  358. *
  359. * - skb->transport_header: If key->eth.type is ETH_P_IP or ETH_P_IPV6
  360. * on output, then just past the IP header, if one is present and
  361. * of a correct length, otherwise the same as skb->network_header.
  362. * For other key->eth.type values it is left untouched.
  363. */
  364. int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key)
  365. {
  366. int error;
  367. struct ethhdr *eth;
  368. memset(key, 0, sizeof(*key));
  369. key->phy.priority = skb->priority;
  370. if (OVS_CB(skb)->tun_key)
  371. memcpy(&key->tun_key, OVS_CB(skb)->tun_key, sizeof(key->tun_key));
  372. key->phy.in_port = in_port;
  373. key->phy.skb_mark = skb->mark;
  374. skb_reset_mac_header(skb);
  375. /* Link layer. We are guaranteed to have at least the 14 byte Ethernet
  376. * header in the linear data area.
  377. */
  378. eth = eth_hdr(skb);
  379. memcpy(key->eth.src, eth->h_source, ETH_ALEN);
  380. memcpy(key->eth.dst, eth->h_dest, ETH_ALEN);
  381. __skb_pull(skb, 2 * ETH_ALEN);
  382. /* We are going to push all headers that we pull, so no need to
  383. * update skb->csum here.
  384. */
  385. if (vlan_tx_tag_present(skb))
  386. key->eth.tci = htons(skb->vlan_tci);
  387. else if (eth->h_proto == htons(ETH_P_8021Q))
  388. if (unlikely(parse_vlan(skb, key)))
  389. return -ENOMEM;
  390. key->eth.type = parse_ethertype(skb);
  391. if (unlikely(key->eth.type == htons(0)))
  392. return -ENOMEM;
  393. skb_reset_network_header(skb);
  394. __skb_push(skb, skb->data - skb_mac_header(skb));
  395. /* Network layer. */
  396. if (key->eth.type == htons(ETH_P_IP)) {
  397. struct iphdr *nh;
  398. __be16 offset;
  399. error = check_iphdr(skb);
  400. if (unlikely(error)) {
  401. if (error == -EINVAL) {
  402. skb->transport_header = skb->network_header;
  403. error = 0;
  404. }
  405. return error;
  406. }
  407. nh = ip_hdr(skb);
  408. key->ipv4.addr.src = nh->saddr;
  409. key->ipv4.addr.dst = nh->daddr;
  410. key->ip.proto = nh->protocol;
  411. key->ip.tos = nh->tos;
  412. key->ip.ttl = nh->ttl;
  413. offset = nh->frag_off & htons(IP_OFFSET);
  414. if (offset) {
  415. key->ip.frag = OVS_FRAG_TYPE_LATER;
  416. return 0;
  417. }
  418. if (nh->frag_off & htons(IP_MF) ||
  419. skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
  420. key->ip.frag = OVS_FRAG_TYPE_FIRST;
  421. /* Transport layer. */
  422. if (key->ip.proto == IPPROTO_TCP) {
  423. if (tcphdr_ok(skb)) {
  424. struct tcphdr *tcp = tcp_hdr(skb);
  425. key->ipv4.tp.src = tcp->source;
  426. key->ipv4.tp.dst = tcp->dest;
  427. key->ipv4.tp.flags = TCP_FLAGS_BE16(tcp);
  428. }
  429. } else if (key->ip.proto == IPPROTO_UDP) {
  430. if (udphdr_ok(skb)) {
  431. struct udphdr *udp = udp_hdr(skb);
  432. key->ipv4.tp.src = udp->source;
  433. key->ipv4.tp.dst = udp->dest;
  434. }
  435. } else if (key->ip.proto == IPPROTO_SCTP) {
  436. if (sctphdr_ok(skb)) {
  437. struct sctphdr *sctp = sctp_hdr(skb);
  438. key->ipv4.tp.src = sctp->source;
  439. key->ipv4.tp.dst = sctp->dest;
  440. }
  441. } else if (key->ip.proto == IPPROTO_ICMP) {
  442. if (icmphdr_ok(skb)) {
  443. struct icmphdr *icmp = icmp_hdr(skb);
  444. /* The ICMP type and code fields use the 16-bit
  445. * transport port fields, so we need to store
  446. * them in 16-bit network byte order. */
  447. key->ipv4.tp.src = htons(icmp->type);
  448. key->ipv4.tp.dst = htons(icmp->code);
  449. }
  450. }
  451. } else if ((key->eth.type == htons(ETH_P_ARP) ||
  452. key->eth.type == htons(ETH_P_RARP)) && arphdr_ok(skb)) {
  453. struct arp_eth_header *arp;
  454. arp = (struct arp_eth_header *)skb_network_header(skb);
  455. if (arp->ar_hrd == htons(ARPHRD_ETHER)
  456. && arp->ar_pro == htons(ETH_P_IP)
  457. && arp->ar_hln == ETH_ALEN
  458. && arp->ar_pln == 4) {
  459. /* We only match on the lower 8 bits of the opcode. */
  460. if (ntohs(arp->ar_op) <= 0xff)
  461. key->ip.proto = ntohs(arp->ar_op);
  462. memcpy(&key->ipv4.addr.src, arp->ar_sip, sizeof(key->ipv4.addr.src));
  463. memcpy(&key->ipv4.addr.dst, arp->ar_tip, sizeof(key->ipv4.addr.dst));
  464. memcpy(key->ipv4.arp.sha, arp->ar_sha, ETH_ALEN);
  465. memcpy(key->ipv4.arp.tha, arp->ar_tha, ETH_ALEN);
  466. }
  467. } else if (key->eth.type == htons(ETH_P_IPV6)) {
  468. int nh_len; /* IPv6 Header + Extensions */
  469. nh_len = parse_ipv6hdr(skb, key);
  470. if (unlikely(nh_len < 0)) {
  471. if (nh_len == -EINVAL) {
  472. skb->transport_header = skb->network_header;
  473. error = 0;
  474. } else {
  475. error = nh_len;
  476. }
  477. return error;
  478. }
  479. if (key->ip.frag == OVS_FRAG_TYPE_LATER)
  480. return 0;
  481. if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
  482. key->ip.frag = OVS_FRAG_TYPE_FIRST;
  483. /* Transport layer. */
  484. if (key->ip.proto == NEXTHDR_TCP) {
  485. if (tcphdr_ok(skb)) {
  486. struct tcphdr *tcp = tcp_hdr(skb);
  487. key->ipv6.tp.src = tcp->source;
  488. key->ipv6.tp.dst = tcp->dest;
  489. key->ipv6.tp.flags = TCP_FLAGS_BE16(tcp);
  490. }
  491. } else if (key->ip.proto == NEXTHDR_UDP) {
  492. if (udphdr_ok(skb)) {
  493. struct udphdr *udp = udp_hdr(skb);
  494. key->ipv6.tp.src = udp->source;
  495. key->ipv6.tp.dst = udp->dest;
  496. }
  497. } else if (key->ip.proto == NEXTHDR_SCTP) {
  498. if (sctphdr_ok(skb)) {
  499. struct sctphdr *sctp = sctp_hdr(skb);
  500. key->ipv6.tp.src = sctp->source;
  501. key->ipv6.tp.dst = sctp->dest;
  502. }
  503. } else if (key->ip.proto == NEXTHDR_ICMP) {
  504. if (icmp6hdr_ok(skb)) {
  505. error = parse_icmpv6(skb, key, nh_len);
  506. if (error)
  507. return error;
  508. }
  509. }
  510. }
  511. return 0;
  512. }