flow.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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, __be16 tcp_flags,
  59. struct sk_buff *skb)
  60. {
  61. struct flow_stats *stats;
  62. int node = numa_node_id();
  63. stats = rcu_dereference(flow->stats[node]);
  64. /* Check if already have node-specific stats. */
  65. if (likely(stats)) {
  66. spin_lock(&stats->lock);
  67. /* Mark if we write on the pre-allocated stats. */
  68. if (node == 0 && unlikely(flow->stats_last_writer != node))
  69. flow->stats_last_writer = node;
  70. } else {
  71. stats = rcu_dereference(flow->stats[0]); /* Pre-allocated. */
  72. spin_lock(&stats->lock);
  73. /* If the current NUMA-node is the only writer on the
  74. * pre-allocated stats keep using them.
  75. */
  76. if (unlikely(flow->stats_last_writer != node)) {
  77. /* A previous locker may have already allocated the
  78. * stats, so we need to check again. If node-specific
  79. * stats were already allocated, we update the pre-
  80. * allocated stats as we have already locked them.
  81. */
  82. if (likely(flow->stats_last_writer != NUMA_NO_NODE)
  83. && likely(!rcu_dereference(flow->stats[node]))) {
  84. /* Try to allocate node-specific stats. */
  85. struct flow_stats *new_stats;
  86. new_stats =
  87. kmem_cache_alloc_node(flow_stats_cache,
  88. GFP_THISNODE |
  89. __GFP_NOMEMALLOC,
  90. node);
  91. if (likely(new_stats)) {
  92. new_stats->used = jiffies;
  93. new_stats->packet_count = 1;
  94. new_stats->byte_count = skb->len;
  95. new_stats->tcp_flags = tcp_flags;
  96. spin_lock_init(&new_stats->lock);
  97. rcu_assign_pointer(flow->stats[node],
  98. new_stats);
  99. goto unlock;
  100. }
  101. }
  102. flow->stats_last_writer = node;
  103. }
  104. }
  105. stats->used = jiffies;
  106. stats->packet_count++;
  107. stats->byte_count += skb->len;
  108. stats->tcp_flags |= tcp_flags;
  109. unlock:
  110. spin_unlock(&stats->lock);
  111. }
  112. /* Must be called with rcu_read_lock or ovs_mutex. */
  113. void ovs_flow_stats_get(const struct sw_flow *flow,
  114. struct ovs_flow_stats *ovs_stats,
  115. unsigned long *used, __be16 *tcp_flags)
  116. {
  117. int node;
  118. *used = 0;
  119. *tcp_flags = 0;
  120. memset(ovs_stats, 0, sizeof(*ovs_stats));
  121. for_each_node(node) {
  122. struct flow_stats *stats = rcu_dereference_ovsl(flow->stats[node]);
  123. if (stats) {
  124. /* Local CPU may write on non-local stats, so we must
  125. * block bottom-halves here.
  126. */
  127. spin_lock_bh(&stats->lock);
  128. if (!*used || time_after(stats->used, *used))
  129. *used = stats->used;
  130. *tcp_flags |= stats->tcp_flags;
  131. ovs_stats->n_packets += stats->packet_count;
  132. ovs_stats->n_bytes += stats->byte_count;
  133. spin_unlock_bh(&stats->lock);
  134. }
  135. }
  136. }
  137. /* Called with ovs_mutex. */
  138. void ovs_flow_stats_clear(struct sw_flow *flow)
  139. {
  140. int node;
  141. for_each_node(node) {
  142. struct flow_stats *stats = ovsl_dereference(flow->stats[node]);
  143. if (stats) {
  144. spin_lock_bh(&stats->lock);
  145. stats->used = 0;
  146. stats->packet_count = 0;
  147. stats->byte_count = 0;
  148. stats->tcp_flags = 0;
  149. spin_unlock_bh(&stats->lock);
  150. }
  151. }
  152. }
  153. static int check_header(struct sk_buff *skb, int len)
  154. {
  155. if (unlikely(skb->len < len))
  156. return -EINVAL;
  157. if (unlikely(!pskb_may_pull(skb, len)))
  158. return -ENOMEM;
  159. return 0;
  160. }
  161. static bool arphdr_ok(struct sk_buff *skb)
  162. {
  163. return pskb_may_pull(skb, skb_network_offset(skb) +
  164. sizeof(struct arp_eth_header));
  165. }
  166. static int check_iphdr(struct sk_buff *skb)
  167. {
  168. unsigned int nh_ofs = skb_network_offset(skb);
  169. unsigned int ip_len;
  170. int err;
  171. err = check_header(skb, nh_ofs + sizeof(struct iphdr));
  172. if (unlikely(err))
  173. return err;
  174. ip_len = ip_hdrlen(skb);
  175. if (unlikely(ip_len < sizeof(struct iphdr) ||
  176. skb->len < nh_ofs + ip_len))
  177. return -EINVAL;
  178. skb_set_transport_header(skb, nh_ofs + ip_len);
  179. return 0;
  180. }
  181. static bool tcphdr_ok(struct sk_buff *skb)
  182. {
  183. int th_ofs = skb_transport_offset(skb);
  184. int tcp_len;
  185. if (unlikely(!pskb_may_pull(skb, th_ofs + sizeof(struct tcphdr))))
  186. return false;
  187. tcp_len = tcp_hdrlen(skb);
  188. if (unlikely(tcp_len < sizeof(struct tcphdr) ||
  189. skb->len < th_ofs + tcp_len))
  190. return false;
  191. return true;
  192. }
  193. static bool udphdr_ok(struct sk_buff *skb)
  194. {
  195. return pskb_may_pull(skb, skb_transport_offset(skb) +
  196. sizeof(struct udphdr));
  197. }
  198. static bool sctphdr_ok(struct sk_buff *skb)
  199. {
  200. return pskb_may_pull(skb, skb_transport_offset(skb) +
  201. sizeof(struct sctphdr));
  202. }
  203. static bool icmphdr_ok(struct sk_buff *skb)
  204. {
  205. return pskb_may_pull(skb, skb_transport_offset(skb) +
  206. sizeof(struct icmphdr));
  207. }
  208. static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key)
  209. {
  210. unsigned int nh_ofs = skb_network_offset(skb);
  211. unsigned int nh_len;
  212. int payload_ofs;
  213. struct ipv6hdr *nh;
  214. uint8_t nexthdr;
  215. __be16 frag_off;
  216. int err;
  217. err = check_header(skb, nh_ofs + sizeof(*nh));
  218. if (unlikely(err))
  219. return err;
  220. nh = ipv6_hdr(skb);
  221. nexthdr = nh->nexthdr;
  222. payload_ofs = (u8 *)(nh + 1) - skb->data;
  223. key->ip.proto = NEXTHDR_NONE;
  224. key->ip.tos = ipv6_get_dsfield(nh);
  225. key->ip.ttl = nh->hop_limit;
  226. key->ipv6.label = *(__be32 *)nh & htonl(IPV6_FLOWINFO_FLOWLABEL);
  227. key->ipv6.addr.src = nh->saddr;
  228. key->ipv6.addr.dst = nh->daddr;
  229. payload_ofs = ipv6_skip_exthdr(skb, payload_ofs, &nexthdr, &frag_off);
  230. if (unlikely(payload_ofs < 0))
  231. return -EINVAL;
  232. if (frag_off) {
  233. if (frag_off & htons(~0x7))
  234. key->ip.frag = OVS_FRAG_TYPE_LATER;
  235. else
  236. key->ip.frag = OVS_FRAG_TYPE_FIRST;
  237. }
  238. nh_len = payload_ofs - nh_ofs;
  239. skb_set_transport_header(skb, nh_ofs + nh_len);
  240. key->ip.proto = nexthdr;
  241. return nh_len;
  242. }
  243. static bool icmp6hdr_ok(struct sk_buff *skb)
  244. {
  245. return pskb_may_pull(skb, skb_transport_offset(skb) +
  246. sizeof(struct icmp6hdr));
  247. }
  248. static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
  249. {
  250. struct qtag_prefix {
  251. __be16 eth_type; /* ETH_P_8021Q */
  252. __be16 tci;
  253. };
  254. struct qtag_prefix *qp;
  255. if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
  256. return 0;
  257. if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
  258. sizeof(__be16))))
  259. return -ENOMEM;
  260. qp = (struct qtag_prefix *) skb->data;
  261. key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
  262. __skb_pull(skb, sizeof(struct qtag_prefix));
  263. return 0;
  264. }
  265. static __be16 parse_ethertype(struct sk_buff *skb)
  266. {
  267. struct llc_snap_hdr {
  268. u8 dsap; /* Always 0xAA */
  269. u8 ssap; /* Always 0xAA */
  270. u8 ctrl;
  271. u8 oui[3];
  272. __be16 ethertype;
  273. };
  274. struct llc_snap_hdr *llc;
  275. __be16 proto;
  276. proto = *(__be16 *) skb->data;
  277. __skb_pull(skb, sizeof(__be16));
  278. if (ntohs(proto) >= ETH_P_802_3_MIN)
  279. return proto;
  280. if (skb->len < sizeof(struct llc_snap_hdr))
  281. return htons(ETH_P_802_2);
  282. if (unlikely(!pskb_may_pull(skb, sizeof(struct llc_snap_hdr))))
  283. return htons(0);
  284. llc = (struct llc_snap_hdr *) skb->data;
  285. if (llc->dsap != LLC_SAP_SNAP ||
  286. llc->ssap != LLC_SAP_SNAP ||
  287. (llc->oui[0] | llc->oui[1] | llc->oui[2]) != 0)
  288. return htons(ETH_P_802_2);
  289. __skb_pull(skb, sizeof(struct llc_snap_hdr));
  290. if (ntohs(llc->ethertype) >= ETH_P_802_3_MIN)
  291. return llc->ethertype;
  292. return htons(ETH_P_802_2);
  293. }
  294. static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
  295. int nh_len)
  296. {
  297. struct icmp6hdr *icmp = icmp6_hdr(skb);
  298. /* The ICMPv6 type and code fields use the 16-bit transport port
  299. * fields, so we need to store them in 16-bit network byte order.
  300. */
  301. key->tp.src = htons(icmp->icmp6_type);
  302. key->tp.dst = htons(icmp->icmp6_code);
  303. if (icmp->icmp6_code == 0 &&
  304. (icmp->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION ||
  305. icmp->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT)) {
  306. int icmp_len = skb->len - skb_transport_offset(skb);
  307. struct nd_msg *nd;
  308. int offset;
  309. /* In order to process neighbor discovery options, we need the
  310. * entire packet.
  311. */
  312. if (unlikely(icmp_len < sizeof(*nd)))
  313. return 0;
  314. if (unlikely(skb_linearize(skb)))
  315. return -ENOMEM;
  316. nd = (struct nd_msg *)skb_transport_header(skb);
  317. key->ipv6.nd.target = nd->target;
  318. icmp_len -= sizeof(*nd);
  319. offset = 0;
  320. while (icmp_len >= 8) {
  321. struct nd_opt_hdr *nd_opt =
  322. (struct nd_opt_hdr *)(nd->opt + offset);
  323. int opt_len = nd_opt->nd_opt_len * 8;
  324. if (unlikely(!opt_len || opt_len > icmp_len))
  325. return 0;
  326. /* Store the link layer address if the appropriate
  327. * option is provided. It is considered an error if
  328. * the same link layer option is specified twice.
  329. */
  330. if (nd_opt->nd_opt_type == ND_OPT_SOURCE_LL_ADDR
  331. && opt_len == 8) {
  332. if (unlikely(!is_zero_ether_addr(key->ipv6.nd.sll)))
  333. goto invalid;
  334. ether_addr_copy(key->ipv6.nd.sll,
  335. &nd->opt[offset+sizeof(*nd_opt)]);
  336. } else if (nd_opt->nd_opt_type == ND_OPT_TARGET_LL_ADDR
  337. && opt_len == 8) {
  338. if (unlikely(!is_zero_ether_addr(key->ipv6.nd.tll)))
  339. goto invalid;
  340. ether_addr_copy(key->ipv6.nd.tll,
  341. &nd->opt[offset+sizeof(*nd_opt)]);
  342. }
  343. icmp_len -= opt_len;
  344. offset += opt_len;
  345. }
  346. }
  347. return 0;
  348. invalid:
  349. memset(&key->ipv6.nd.target, 0, sizeof(key->ipv6.nd.target));
  350. memset(key->ipv6.nd.sll, 0, sizeof(key->ipv6.nd.sll));
  351. memset(key->ipv6.nd.tll, 0, sizeof(key->ipv6.nd.tll));
  352. return 0;
  353. }
  354. /**
  355. * ovs_flow_extract - extracts a flow key from an Ethernet frame.
  356. * @skb: sk_buff that contains the frame, with skb->data pointing to the
  357. * Ethernet header
  358. * @in_port: port number on which @skb was received.
  359. * @key: output flow key
  360. *
  361. * The caller must ensure that skb->len >= ETH_HLEN.
  362. *
  363. * Returns 0 if successful, otherwise a negative errno value.
  364. *
  365. * Initializes @skb header pointers as follows:
  366. *
  367. * - skb->mac_header: the Ethernet header.
  368. *
  369. * - skb->network_header: just past the Ethernet header, or just past the
  370. * VLAN header, to the first byte of the Ethernet payload.
  371. *
  372. * - skb->transport_header: If key->eth.type is ETH_P_IP or ETH_P_IPV6
  373. * on output, then just past the IP header, if one is present and
  374. * of a correct length, otherwise the same as skb->network_header.
  375. * For other key->eth.type values it is left untouched.
  376. */
  377. int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key)
  378. {
  379. int error;
  380. struct ethhdr *eth;
  381. memset(key, 0, sizeof(*key));
  382. key->phy.priority = skb->priority;
  383. if (OVS_CB(skb)->tun_key)
  384. memcpy(&key->tun_key, OVS_CB(skb)->tun_key, sizeof(key->tun_key));
  385. key->phy.in_port = in_port;
  386. key->phy.skb_mark = skb->mark;
  387. skb_reset_mac_header(skb);
  388. /* Link layer. We are guaranteed to have at least the 14 byte Ethernet
  389. * header in the linear data area.
  390. */
  391. eth = eth_hdr(skb);
  392. ether_addr_copy(key->eth.src, eth->h_source);
  393. ether_addr_copy(key->eth.dst, eth->h_dest);
  394. __skb_pull(skb, 2 * ETH_ALEN);
  395. /* We are going to push all headers that we pull, so no need to
  396. * update skb->csum here.
  397. */
  398. if (vlan_tx_tag_present(skb))
  399. key->eth.tci = htons(skb->vlan_tci);
  400. else if (eth->h_proto == htons(ETH_P_8021Q))
  401. if (unlikely(parse_vlan(skb, key)))
  402. return -ENOMEM;
  403. key->eth.type = parse_ethertype(skb);
  404. if (unlikely(key->eth.type == htons(0)))
  405. return -ENOMEM;
  406. skb_reset_network_header(skb);
  407. __skb_push(skb, skb->data - skb_mac_header(skb));
  408. /* Network layer. */
  409. if (key->eth.type == htons(ETH_P_IP)) {
  410. struct iphdr *nh;
  411. __be16 offset;
  412. error = check_iphdr(skb);
  413. if (unlikely(error)) {
  414. if (error == -EINVAL) {
  415. skb->transport_header = skb->network_header;
  416. error = 0;
  417. }
  418. return error;
  419. }
  420. nh = ip_hdr(skb);
  421. key->ipv4.addr.src = nh->saddr;
  422. key->ipv4.addr.dst = nh->daddr;
  423. key->ip.proto = nh->protocol;
  424. key->ip.tos = nh->tos;
  425. key->ip.ttl = nh->ttl;
  426. offset = nh->frag_off & htons(IP_OFFSET);
  427. if (offset) {
  428. key->ip.frag = OVS_FRAG_TYPE_LATER;
  429. return 0;
  430. }
  431. if (nh->frag_off & htons(IP_MF) ||
  432. skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
  433. key->ip.frag = OVS_FRAG_TYPE_FIRST;
  434. /* Transport layer. */
  435. if (key->ip.proto == IPPROTO_TCP) {
  436. if (tcphdr_ok(skb)) {
  437. struct tcphdr *tcp = tcp_hdr(skb);
  438. key->tp.src = tcp->source;
  439. key->tp.dst = tcp->dest;
  440. key->tp.flags = TCP_FLAGS_BE16(tcp);
  441. }
  442. } else if (key->ip.proto == IPPROTO_UDP) {
  443. if (udphdr_ok(skb)) {
  444. struct udphdr *udp = udp_hdr(skb);
  445. key->tp.src = udp->source;
  446. key->tp.dst = udp->dest;
  447. }
  448. } else if (key->ip.proto == IPPROTO_SCTP) {
  449. if (sctphdr_ok(skb)) {
  450. struct sctphdr *sctp = sctp_hdr(skb);
  451. key->tp.src = sctp->source;
  452. key->tp.dst = sctp->dest;
  453. }
  454. } else if (key->ip.proto == IPPROTO_ICMP) {
  455. if (icmphdr_ok(skb)) {
  456. struct icmphdr *icmp = icmp_hdr(skb);
  457. /* The ICMP type and code fields use the 16-bit
  458. * transport port fields, so we need to store
  459. * them in 16-bit network byte order. */
  460. key->tp.src = htons(icmp->type);
  461. key->tp.dst = htons(icmp->code);
  462. }
  463. }
  464. } else if ((key->eth.type == htons(ETH_P_ARP) ||
  465. key->eth.type == htons(ETH_P_RARP)) && arphdr_ok(skb)) {
  466. struct arp_eth_header *arp;
  467. arp = (struct arp_eth_header *)skb_network_header(skb);
  468. if (arp->ar_hrd == htons(ARPHRD_ETHER)
  469. && arp->ar_pro == htons(ETH_P_IP)
  470. && arp->ar_hln == ETH_ALEN
  471. && arp->ar_pln == 4) {
  472. /* We only match on the lower 8 bits of the opcode. */
  473. if (ntohs(arp->ar_op) <= 0xff)
  474. key->ip.proto = ntohs(arp->ar_op);
  475. memcpy(&key->ipv4.addr.src, arp->ar_sip, sizeof(key->ipv4.addr.src));
  476. memcpy(&key->ipv4.addr.dst, arp->ar_tip, sizeof(key->ipv4.addr.dst));
  477. ether_addr_copy(key->ipv4.arp.sha, arp->ar_sha);
  478. ether_addr_copy(key->ipv4.arp.tha, arp->ar_tha);
  479. }
  480. } else if (key->eth.type == htons(ETH_P_IPV6)) {
  481. int nh_len; /* IPv6 Header + Extensions */
  482. nh_len = parse_ipv6hdr(skb, key);
  483. if (unlikely(nh_len < 0)) {
  484. if (nh_len == -EINVAL) {
  485. skb->transport_header = skb->network_header;
  486. error = 0;
  487. } else {
  488. error = nh_len;
  489. }
  490. return error;
  491. }
  492. if (key->ip.frag == OVS_FRAG_TYPE_LATER)
  493. return 0;
  494. if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
  495. key->ip.frag = OVS_FRAG_TYPE_FIRST;
  496. /* Transport layer. */
  497. if (key->ip.proto == NEXTHDR_TCP) {
  498. if (tcphdr_ok(skb)) {
  499. struct tcphdr *tcp = tcp_hdr(skb);
  500. key->tp.src = tcp->source;
  501. key->tp.dst = tcp->dest;
  502. key->tp.flags = TCP_FLAGS_BE16(tcp);
  503. }
  504. } else if (key->ip.proto == NEXTHDR_UDP) {
  505. if (udphdr_ok(skb)) {
  506. struct udphdr *udp = udp_hdr(skb);
  507. key->tp.src = udp->source;
  508. key->tp.dst = udp->dest;
  509. }
  510. } else if (key->ip.proto == NEXTHDR_SCTP) {
  511. if (sctphdr_ok(skb)) {
  512. struct sctphdr *sctp = sctp_hdr(skb);
  513. key->tp.src = sctp->source;
  514. key->tp.dst = sctp->dest;
  515. }
  516. } else if (key->ip.proto == NEXTHDR_ICMP) {
  517. if (icmp6hdr_ok(skb)) {
  518. error = parse_icmpv6(skb, key, nh_len);
  519. if (error)
  520. return error;
  521. }
  522. }
  523. }
  524. return 0;
  525. }