Jiri Pirko | fbff949 | 2015-05-12 14:56:15 +0200 | [diff] [blame] | 1 | #include <linux/kernel.h> |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 2 | #include <linux/skbuff.h> |
Jesper Dangaard Brouer | c452ed7 | 2012-01-24 16:03:33 -0500 | [diff] [blame] | 3 | #include <linux/export.h> |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 4 | #include <linux/ip.h> |
| 5 | #include <linux/ipv6.h> |
| 6 | #include <linux/if_vlan.h> |
| 7 | #include <net/ip.h> |
Eric Dumazet | ddbe503 | 2012-07-18 08:11:12 +0000 | [diff] [blame] | 8 | #include <net/ipv6.h> |
Daniel Borkmann | f77668d | 2013-03-19 06:39:30 +0000 | [diff] [blame] | 9 | #include <linux/igmp.h> |
| 10 | #include <linux/icmp.h> |
| 11 | #include <linux/sctp.h> |
| 12 | #include <linux/dccp.h> |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 13 | #include <linux/if_tunnel.h> |
| 14 | #include <linux/if_pppox.h> |
| 15 | #include <linux/ppp_defs.h> |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 16 | #include <linux/stddef.h> |
Jiri Pirko | 67a900c | 2015-05-12 14:56:19 +0200 | [diff] [blame] | 17 | #include <linux/if_ether.h> |
Tom Herbert | b3baa0f | 2015-06-04 09:16:46 -0700 | [diff] [blame] | 18 | #include <linux/mpls.h> |
Jiri Pirko | 1bd758e | 2015-05-12 14:56:07 +0200 | [diff] [blame] | 19 | #include <net/flow_dissector.h> |
Alexander Duyck | 56193d1 | 2014-09-05 19:20:26 -0400 | [diff] [blame] | 20 | #include <scsi/fc/fc_fcoe.h> |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 21 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 22 | static bool dissector_uses_key(const struct flow_dissector *flow_dissector, |
| 23 | enum flow_dissector_key_id key_id) |
Jiri Pirko | fbff949 | 2015-05-12 14:56:15 +0200 | [diff] [blame] | 24 | { |
| 25 | return flow_dissector->used_keys & (1 << key_id); |
| 26 | } |
| 27 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 28 | static void dissector_set_key(struct flow_dissector *flow_dissector, |
| 29 | enum flow_dissector_key_id key_id) |
Jiri Pirko | fbff949 | 2015-05-12 14:56:15 +0200 | [diff] [blame] | 30 | { |
| 31 | flow_dissector->used_keys |= (1 << key_id); |
| 32 | } |
| 33 | |
| 34 | static void *skb_flow_dissector_target(struct flow_dissector *flow_dissector, |
| 35 | enum flow_dissector_key_id key_id, |
| 36 | void *target_container) |
| 37 | { |
| 38 | return ((char *) target_container) + flow_dissector->offset[key_id]; |
| 39 | } |
| 40 | |
| 41 | void skb_flow_dissector_init(struct flow_dissector *flow_dissector, |
| 42 | const struct flow_dissector_key *key, |
| 43 | unsigned int key_count) |
| 44 | { |
| 45 | unsigned int i; |
| 46 | |
| 47 | memset(flow_dissector, 0, sizeof(*flow_dissector)); |
| 48 | |
| 49 | for (i = 0; i < key_count; i++, key++) { |
| 50 | /* User should make sure that every key target offset is withing |
| 51 | * boundaries of unsigned short. |
| 52 | */ |
| 53 | BUG_ON(key->offset > USHRT_MAX); |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 54 | BUG_ON(dissector_uses_key(flow_dissector, |
| 55 | key->key_id)); |
Jiri Pirko | fbff949 | 2015-05-12 14:56:15 +0200 | [diff] [blame] | 56 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 57 | dissector_set_key(flow_dissector, key->key_id); |
Jiri Pirko | fbff949 | 2015-05-12 14:56:15 +0200 | [diff] [blame] | 58 | flow_dissector->offset[key->key_id] = key->offset; |
| 59 | } |
| 60 | |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 61 | /* Ensure that the dissector always includes control and basic key. |
| 62 | * That way we are able to avoid handling lack of these in fast path. |
Jiri Pirko | fbff949 | 2015-05-12 14:56:15 +0200 | [diff] [blame] | 63 | */ |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 64 | BUG_ON(!dissector_uses_key(flow_dissector, |
| 65 | FLOW_DISSECTOR_KEY_CONTROL)); |
| 66 | BUG_ON(!dissector_uses_key(flow_dissector, |
| 67 | FLOW_DISSECTOR_KEY_BASIC)); |
Jiri Pirko | fbff949 | 2015-05-12 14:56:15 +0200 | [diff] [blame] | 68 | } |
| 69 | EXPORT_SYMBOL(skb_flow_dissector_init); |
| 70 | |
Nikolay Aleksandrov | 357afe9 | 2013-10-02 13:39:24 +0200 | [diff] [blame] | 71 | /** |
WANG Cong | 6451b3f | 2014-08-25 17:03:46 -0700 | [diff] [blame] | 72 | * __skb_flow_get_ports - extract the upper layer ports and return them |
| 73 | * @skb: sk_buff to extract the ports from |
Nikolay Aleksandrov | 357afe9 | 2013-10-02 13:39:24 +0200 | [diff] [blame] | 74 | * @thoff: transport header offset |
| 75 | * @ip_proto: protocol for which to get port offset |
WANG Cong | 6451b3f | 2014-08-25 17:03:46 -0700 | [diff] [blame] | 76 | * @data: raw buffer pointer to the packet, if NULL use skb->data |
| 77 | * @hlen: packet header length, if @data is NULL use skb_headlen(skb) |
Nikolay Aleksandrov | 357afe9 | 2013-10-02 13:39:24 +0200 | [diff] [blame] | 78 | * |
| 79 | * The function will try to retrieve the ports at offset thoff + poff where poff |
| 80 | * is the protocol port offset returned from proto_ports_offset |
| 81 | */ |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 82 | __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto, |
| 83 | void *data, int hlen) |
Nikolay Aleksandrov | 357afe9 | 2013-10-02 13:39:24 +0200 | [diff] [blame] | 84 | { |
| 85 | int poff = proto_ports_offset(ip_proto); |
| 86 | |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 87 | if (!data) { |
| 88 | data = skb->data; |
| 89 | hlen = skb_headlen(skb); |
| 90 | } |
| 91 | |
Nikolay Aleksandrov | 357afe9 | 2013-10-02 13:39:24 +0200 | [diff] [blame] | 92 | if (poff >= 0) { |
| 93 | __be32 *ports, _ports; |
| 94 | |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 95 | ports = __skb_header_pointer(skb, thoff + poff, |
| 96 | sizeof(_ports), data, hlen, &_ports); |
Nikolay Aleksandrov | 357afe9 | 2013-10-02 13:39:24 +0200 | [diff] [blame] | 97 | if (ports) |
| 98 | return *ports; |
| 99 | } |
| 100 | |
| 101 | return 0; |
| 102 | } |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 103 | EXPORT_SYMBOL(__skb_flow_get_ports); |
Nikolay Aleksandrov | 357afe9 | 2013-10-02 13:39:24 +0200 | [diff] [blame] | 104 | |
WANG Cong | 453a940 | 2014-08-25 17:03:47 -0700 | [diff] [blame] | 105 | /** |
| 106 | * __skb_flow_dissect - extract the flow_keys struct and return it |
| 107 | * @skb: sk_buff to extract the flow from, can be NULL if the rest are specified |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 108 | * @flow_dissector: list of keys to dissect |
| 109 | * @target_container: target structure to put dissected values into |
WANG Cong | 453a940 | 2014-08-25 17:03:47 -0700 | [diff] [blame] | 110 | * @data: raw buffer pointer to the packet, if NULL use skb->data |
| 111 | * @proto: protocol for which to get the flow, if @data is NULL use skb->protocol |
| 112 | * @nhoff: network header offset, if @data is NULL use skb_network_offset(skb) |
| 113 | * @hlen: packet header length, if @data is NULL use skb_headlen(skb) |
| 114 | * |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 115 | * The function will try to retrieve individual keys into target specified |
| 116 | * by flow_dissector from either the skbuff or a raw buffer specified by the |
| 117 | * rest parameters. |
| 118 | * |
| 119 | * Caller must take care of zeroing target container memory. |
WANG Cong | 453a940 | 2014-08-25 17:03:47 -0700 | [diff] [blame] | 120 | */ |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 121 | bool __skb_flow_dissect(const struct sk_buff *skb, |
| 122 | struct flow_dissector *flow_dissector, |
| 123 | void *target_container, |
Tom Herbert | cd79a23 | 2015-09-01 09:24:27 -0700 | [diff] [blame] | 124 | void *data, __be16 proto, int nhoff, int hlen, |
| 125 | unsigned int flags) |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 126 | { |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 127 | struct flow_dissector_key_control *key_control; |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 128 | struct flow_dissector_key_basic *key_basic; |
| 129 | struct flow_dissector_key_addrs *key_addrs; |
| 130 | struct flow_dissector_key_ports *key_ports; |
Tom Herbert | d34af82 | 2015-06-04 09:16:43 -0700 | [diff] [blame] | 131 | struct flow_dissector_key_tags *key_tags; |
Tom Herbert | 1fdd512 | 2015-06-04 09:16:45 -0700 | [diff] [blame] | 132 | struct flow_dissector_key_keyid *key_keyid; |
Geert Uytterhoeven | 8e690ff | 2015-06-25 15:10:32 +0200 | [diff] [blame] | 133 | u8 ip_proto = 0; |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 134 | bool ret = false; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 135 | |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 136 | if (!data) { |
| 137 | data = skb->data; |
WANG Cong | 453a940 | 2014-08-25 17:03:47 -0700 | [diff] [blame] | 138 | proto = skb->protocol; |
| 139 | nhoff = skb_network_offset(skb); |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 140 | hlen = skb_headlen(skb); |
| 141 | } |
| 142 | |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 143 | /* It is ensured by skb_flow_dissector_init() that control key will |
| 144 | * be always present. |
| 145 | */ |
| 146 | key_control = skb_flow_dissector_target(flow_dissector, |
| 147 | FLOW_DISSECTOR_KEY_CONTROL, |
| 148 | target_container); |
| 149 | |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 150 | /* It is ensured by skb_flow_dissector_init() that basic key will |
| 151 | * be always present. |
| 152 | */ |
| 153 | key_basic = skb_flow_dissector_target(flow_dissector, |
| 154 | FLOW_DISSECTOR_KEY_BASIC, |
| 155 | target_container); |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 156 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 157 | if (dissector_uses_key(flow_dissector, |
| 158 | FLOW_DISSECTOR_KEY_ETH_ADDRS)) { |
Jiri Pirko | 67a900c | 2015-05-12 14:56:19 +0200 | [diff] [blame] | 159 | struct ethhdr *eth = eth_hdr(skb); |
| 160 | struct flow_dissector_key_eth_addrs *key_eth_addrs; |
| 161 | |
| 162 | key_eth_addrs = skb_flow_dissector_target(flow_dissector, |
| 163 | FLOW_DISSECTOR_KEY_ETH_ADDRS, |
| 164 | target_container); |
| 165 | memcpy(key_eth_addrs, ð->h_dest, sizeof(*key_eth_addrs)); |
| 166 | } |
| 167 | |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 168 | again: |
| 169 | switch (proto) { |
Joe Perches | 2b8837a | 2014-03-12 10:04:17 -0700 | [diff] [blame] | 170 | case htons(ETH_P_IP): { |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 171 | const struct iphdr *iph; |
| 172 | struct iphdr _iph; |
| 173 | ip: |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 174 | iph = __skb_header_pointer(skb, nhoff, sizeof(_iph), data, hlen, &_iph); |
Jason Wang | 6f09234 | 2013-11-01 15:01:10 +0800 | [diff] [blame] | 175 | if (!iph || iph->ihl < 5) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 176 | goto out_bad; |
Eric Dumazet | 3797d3e | 2013-11-07 08:37:28 -0800 | [diff] [blame] | 177 | nhoff += iph->ihl * 4; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 178 | |
Eric Dumazet | 3797d3e | 2013-11-07 08:37:28 -0800 | [diff] [blame] | 179 | ip_proto = iph->protocol; |
Eric Dumazet | 3797d3e | 2013-11-07 08:37:28 -0800 | [diff] [blame] | 180 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 181 | if (!dissector_uses_key(flow_dissector, |
| 182 | FLOW_DISSECTOR_KEY_IPV4_ADDRS)) |
Alexander Duyck | 5af7fb6 | 2014-10-10 12:09:12 -0700 | [diff] [blame] | 183 | break; |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 184 | |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 185 | key_addrs = skb_flow_dissector_target(flow_dissector, |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 186 | FLOW_DISSECTOR_KEY_IPV4_ADDRS, target_container); |
| 187 | memcpy(&key_addrs->v4addrs, &iph->saddr, |
| 188 | sizeof(key_addrs->v4addrs)); |
| 189 | key_control->addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; |
Tom Herbert | 807e165 | 2015-09-01 09:24:28 -0700 | [diff] [blame] | 190 | |
| 191 | if (ip_is_fragment(iph)) { |
David S. Miller | 4b36993 | 2015-09-01 16:46:08 -0700 | [diff] [blame] | 192 | key_control->flags |= FLOW_DIS_IS_FRAGMENT; |
Tom Herbert | 807e165 | 2015-09-01 09:24:28 -0700 | [diff] [blame] | 193 | |
| 194 | if (iph->frag_off & htons(IP_OFFSET)) { |
| 195 | goto out_good; |
| 196 | } else { |
David S. Miller | 4b36993 | 2015-09-01 16:46:08 -0700 | [diff] [blame] | 197 | key_control->flags |= FLOW_DIS_FIRST_FRAG; |
Tom Herbert | 807e165 | 2015-09-01 09:24:28 -0700 | [diff] [blame] | 198 | if (!(flags & FLOW_DISSECTOR_F_PARSE_1ST_FRAG)) |
| 199 | goto out_good; |
| 200 | } |
| 201 | } |
| 202 | |
Tom Herbert | 8306b68 | 2015-09-01 09:24:30 -0700 | [diff] [blame] | 203 | if (flags & FLOW_DISSECTOR_F_STOP_AT_L3) |
| 204 | goto out_good; |
| 205 | |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 206 | break; |
| 207 | } |
Joe Perches | 2b8837a | 2014-03-12 10:04:17 -0700 | [diff] [blame] | 208 | case htons(ETH_P_IPV6): { |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 209 | const struct ipv6hdr *iph; |
| 210 | struct ipv6hdr _iph; |
Tom Herbert | 19469a8 | 2014-07-01 21:33:01 -0700 | [diff] [blame] | 211 | |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 212 | ipv6: |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 213 | iph = __skb_header_pointer(skb, nhoff, sizeof(_iph), data, hlen, &_iph); |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 214 | if (!iph) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 215 | goto out_bad; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 216 | |
| 217 | ip_proto = iph->nexthdr; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 218 | nhoff += sizeof(struct ipv6hdr); |
Tom Herbert | 19469a8 | 2014-07-01 21:33:01 -0700 | [diff] [blame] | 219 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 220 | if (dissector_uses_key(flow_dissector, |
| 221 | FLOW_DISSECTOR_KEY_IPV6_ADDRS)) { |
Jiri Pirko | b924933 | 2015-05-12 14:56:18 +0200 | [diff] [blame] | 222 | struct flow_dissector_key_ipv6_addrs *key_ipv6_addrs; |
Alexander Duyck | 5af7fb6 | 2014-10-10 12:09:12 -0700 | [diff] [blame] | 223 | |
Jiri Pirko | b924933 | 2015-05-12 14:56:18 +0200 | [diff] [blame] | 224 | key_ipv6_addrs = skb_flow_dissector_target(flow_dissector, |
| 225 | FLOW_DISSECTOR_KEY_IPV6_ADDRS, |
| 226 | target_container); |
| 227 | |
| 228 | memcpy(key_ipv6_addrs, &iph->saddr, sizeof(*key_ipv6_addrs)); |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 229 | key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; |
Jiri Pirko | b924933 | 2015-05-12 14:56:18 +0200 | [diff] [blame] | 230 | } |
Tom Herbert | 87ee9e5 | 2015-06-04 09:16:44 -0700 | [diff] [blame] | 231 | |
Alexander Duyck | 461547f | 2016-02-09 02:49:54 -0800 | [diff] [blame] | 232 | if ((dissector_uses_key(flow_dissector, |
| 233 | FLOW_DISSECTOR_KEY_FLOW_LABEL) || |
| 234 | (flags & FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL)) && |
| 235 | ip6_flowlabel(iph)) { |
| 236 | __be32 flow_label = ip6_flowlabel(iph); |
| 237 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 238 | if (dissector_uses_key(flow_dissector, |
| 239 | FLOW_DISSECTOR_KEY_FLOW_LABEL)) { |
Tom Herbert | 87ee9e5 | 2015-06-04 09:16:44 -0700 | [diff] [blame] | 240 | key_tags = skb_flow_dissector_target(flow_dissector, |
| 241 | FLOW_DISSECTOR_KEY_FLOW_LABEL, |
| 242 | target_container); |
| 243 | key_tags->flow_label = ntohl(flow_label); |
Jiri Pirko | 12c227e | 2015-05-22 11:05:58 +0200 | [diff] [blame] | 244 | } |
Tom Herbert | 872b1ab | 2015-09-01 09:24:31 -0700 | [diff] [blame] | 245 | if (flags & FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL) |
| 246 | goto out_good; |
Tom Herbert | 19469a8 | 2014-07-01 21:33:01 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Tom Herbert | 8306b68 | 2015-09-01 09:24:30 -0700 | [diff] [blame] | 249 | if (flags & FLOW_DISSECTOR_F_STOP_AT_L3) |
| 250 | goto out_good; |
| 251 | |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 252 | break; |
| 253 | } |
Joe Perches | 2b8837a | 2014-03-12 10:04:17 -0700 | [diff] [blame] | 254 | case htons(ETH_P_8021AD): |
| 255 | case htons(ETH_P_8021Q): { |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 256 | const struct vlan_hdr *vlan; |
| 257 | struct vlan_hdr _vlan; |
| 258 | |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 259 | vlan = __skb_header_pointer(skb, nhoff, sizeof(_vlan), data, hlen, &_vlan); |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 260 | if (!vlan) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 261 | goto out_bad; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 262 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 263 | if (dissector_uses_key(flow_dissector, |
| 264 | FLOW_DISSECTOR_KEY_VLANID)) { |
Tom Herbert | d34af82 | 2015-06-04 09:16:43 -0700 | [diff] [blame] | 265 | key_tags = skb_flow_dissector_target(flow_dissector, |
| 266 | FLOW_DISSECTOR_KEY_VLANID, |
| 267 | target_container); |
| 268 | |
| 269 | key_tags->vlan_id = skb_vlan_tag_get_id(skb); |
| 270 | } |
| 271 | |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 272 | proto = vlan->h_vlan_encapsulated_proto; |
| 273 | nhoff += sizeof(*vlan); |
| 274 | goto again; |
| 275 | } |
Joe Perches | 2b8837a | 2014-03-12 10:04:17 -0700 | [diff] [blame] | 276 | case htons(ETH_P_PPP_SES): { |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 277 | struct { |
| 278 | struct pppoe_hdr hdr; |
| 279 | __be16 proto; |
| 280 | } *hdr, _hdr; |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 281 | hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, hlen, &_hdr); |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 282 | if (!hdr) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 283 | goto out_bad; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 284 | proto = hdr->proto; |
| 285 | nhoff += PPPOE_SES_HLEN; |
| 286 | switch (proto) { |
Joe Perches | 2b8837a | 2014-03-12 10:04:17 -0700 | [diff] [blame] | 287 | case htons(PPP_IP): |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 288 | goto ip; |
Joe Perches | 2b8837a | 2014-03-12 10:04:17 -0700 | [diff] [blame] | 289 | case htons(PPP_IPV6): |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 290 | goto ipv6; |
| 291 | default: |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 292 | goto out_bad; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 293 | } |
| 294 | } |
Erik Hugne | 08bfc9c | 2015-01-22 17:10:32 +0100 | [diff] [blame] | 295 | case htons(ETH_P_TIPC): { |
| 296 | struct { |
| 297 | __be32 pre[3]; |
| 298 | __be32 srcnode; |
| 299 | } *hdr, _hdr; |
| 300 | hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, hlen, &_hdr); |
| 301 | if (!hdr) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 302 | goto out_bad; |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 303 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 304 | if (dissector_uses_key(flow_dissector, |
| 305 | FLOW_DISSECTOR_KEY_TIPC_ADDRS)) { |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 306 | key_addrs = skb_flow_dissector_target(flow_dissector, |
Tom Herbert | 9f24908 | 2015-06-04 09:16:41 -0700 | [diff] [blame] | 307 | FLOW_DISSECTOR_KEY_TIPC_ADDRS, |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 308 | target_container); |
Tom Herbert | 9f24908 | 2015-06-04 09:16:41 -0700 | [diff] [blame] | 309 | key_addrs->tipcaddrs.srcnode = hdr->srcnode; |
| 310 | key_control->addr_type = FLOW_DISSECTOR_KEY_TIPC_ADDRS; |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 311 | } |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 312 | goto out_good; |
Erik Hugne | 08bfc9c | 2015-01-22 17:10:32 +0100 | [diff] [blame] | 313 | } |
Tom Herbert | b3baa0f | 2015-06-04 09:16:46 -0700 | [diff] [blame] | 314 | |
| 315 | case htons(ETH_P_MPLS_UC): |
| 316 | case htons(ETH_P_MPLS_MC): { |
| 317 | struct mpls_label *hdr, _hdr[2]; |
| 318 | mpls: |
| 319 | hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, |
| 320 | hlen, &_hdr); |
| 321 | if (!hdr) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 322 | goto out_bad; |
Tom Herbert | b3baa0f | 2015-06-04 09:16:46 -0700 | [diff] [blame] | 323 | |
Tom Herbert | 611d23c | 2015-06-12 09:01:05 -0700 | [diff] [blame] | 324 | if ((ntohl(hdr[0].entry) & MPLS_LS_LABEL_MASK) >> |
| 325 | MPLS_LS_LABEL_SHIFT == MPLS_LABEL_ENTROPY) { |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 326 | if (dissector_uses_key(flow_dissector, |
| 327 | FLOW_DISSECTOR_KEY_MPLS_ENTROPY)) { |
Tom Herbert | b3baa0f | 2015-06-04 09:16:46 -0700 | [diff] [blame] | 328 | key_keyid = skb_flow_dissector_target(flow_dissector, |
| 329 | FLOW_DISSECTOR_KEY_MPLS_ENTROPY, |
| 330 | target_container); |
| 331 | key_keyid->keyid = hdr[1].entry & |
| 332 | htonl(MPLS_LS_LABEL_MASK); |
| 333 | } |
| 334 | |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 335 | goto out_good; |
Tom Herbert | b3baa0f | 2015-06-04 09:16:46 -0700 | [diff] [blame] | 336 | } |
| 337 | |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 338 | goto out_good; |
Tom Herbert | b3baa0f | 2015-06-04 09:16:46 -0700 | [diff] [blame] | 339 | } |
| 340 | |
Alexander Duyck | 56193d1 | 2014-09-05 19:20:26 -0400 | [diff] [blame] | 341 | case htons(ETH_P_FCOE): |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 342 | key_control->thoff = (u16)(nhoff + FCOE_HEADER_LEN); |
Alexander Duyck | 56193d1 | 2014-09-05 19:20:26 -0400 | [diff] [blame] | 343 | /* fall through */ |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 344 | default: |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 345 | goto out_bad; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 346 | } |
| 347 | |
Tom Herbert | 6a74fcf | 2015-06-12 09:01:06 -0700 | [diff] [blame] | 348 | ip_proto_again: |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 349 | switch (ip_proto) { |
| 350 | case IPPROTO_GRE: { |
| 351 | struct gre_hdr { |
| 352 | __be16 flags; |
| 353 | __be16 proto; |
| 354 | } *hdr, _hdr; |
| 355 | |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 356 | hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, hlen, &_hdr); |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 357 | if (!hdr) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 358 | goto out_bad; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 359 | /* |
| 360 | * Only look inside GRE if version zero and no |
| 361 | * routing |
| 362 | */ |
Tom Herbert | ce3b535 | 2015-06-04 09:16:36 -0700 | [diff] [blame] | 363 | if (hdr->flags & (GRE_VERSION | GRE_ROUTING)) |
| 364 | break; |
Michael Dalton | e1733de | 2013-03-11 06:52:28 +0000 | [diff] [blame] | 365 | |
Tom Herbert | ce3b535 | 2015-06-04 09:16:36 -0700 | [diff] [blame] | 366 | proto = hdr->proto; |
| 367 | nhoff += 4; |
| 368 | if (hdr->flags & GRE_CSUM) |
| 369 | nhoff += 4; |
Tom Herbert | 1fdd512 | 2015-06-04 09:16:45 -0700 | [diff] [blame] | 370 | if (hdr->flags & GRE_KEY) { |
| 371 | const __be32 *keyid; |
| 372 | __be32 _keyid; |
| 373 | |
| 374 | keyid = __skb_header_pointer(skb, nhoff, sizeof(_keyid), |
| 375 | data, hlen, &_keyid); |
| 376 | |
| 377 | if (!keyid) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 378 | goto out_bad; |
Tom Herbert | 1fdd512 | 2015-06-04 09:16:45 -0700 | [diff] [blame] | 379 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 380 | if (dissector_uses_key(flow_dissector, |
| 381 | FLOW_DISSECTOR_KEY_GRE_KEYID)) { |
Tom Herbert | 1fdd512 | 2015-06-04 09:16:45 -0700 | [diff] [blame] | 382 | key_keyid = skb_flow_dissector_target(flow_dissector, |
| 383 | FLOW_DISSECTOR_KEY_GRE_KEYID, |
| 384 | target_container); |
| 385 | key_keyid->keyid = *keyid; |
| 386 | } |
Tom Herbert | ce3b535 | 2015-06-04 09:16:36 -0700 | [diff] [blame] | 387 | nhoff += 4; |
Tom Herbert | 1fdd512 | 2015-06-04 09:16:45 -0700 | [diff] [blame] | 388 | } |
Tom Herbert | ce3b535 | 2015-06-04 09:16:36 -0700 | [diff] [blame] | 389 | if (hdr->flags & GRE_SEQ) |
| 390 | nhoff += 4; |
| 391 | if (proto == htons(ETH_P_TEB)) { |
| 392 | const struct ethhdr *eth; |
| 393 | struct ethhdr _eth; |
| 394 | |
| 395 | eth = __skb_header_pointer(skb, nhoff, |
| 396 | sizeof(_eth), |
| 397 | data, hlen, &_eth); |
| 398 | if (!eth) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 399 | goto out_bad; |
Tom Herbert | ce3b535 | 2015-06-04 09:16:36 -0700 | [diff] [blame] | 400 | proto = eth->h_proto; |
| 401 | nhoff += sizeof(*eth); |
Alexander Duyck | 7856520 | 2016-02-09 06:14:43 -0800 | [diff] [blame] | 402 | |
| 403 | /* Cap headers that we access via pointers at the |
| 404 | * end of the Ethernet header as our maximum alignment |
| 405 | * at that point is only 2 bytes. |
| 406 | */ |
| 407 | if (NET_IP_ALIGN) |
| 408 | hlen = nhoff; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 409 | } |
Tom Herbert | 823b969 | 2015-09-01 09:24:32 -0700 | [diff] [blame] | 410 | |
David S. Miller | 4b36993 | 2015-09-01 16:46:08 -0700 | [diff] [blame] | 411 | key_control->flags |= FLOW_DIS_ENCAPSULATION; |
Tom Herbert | 823b969 | 2015-09-01 09:24:32 -0700 | [diff] [blame] | 412 | if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP) |
| 413 | goto out_good; |
| 414 | |
Tom Herbert | ce3b535 | 2015-06-04 09:16:36 -0700 | [diff] [blame] | 415 | goto again; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 416 | } |
Tom Herbert | 6a74fcf | 2015-06-12 09:01:06 -0700 | [diff] [blame] | 417 | case NEXTHDR_HOP: |
| 418 | case NEXTHDR_ROUTING: |
| 419 | case NEXTHDR_DEST: { |
| 420 | u8 _opthdr[2], *opthdr; |
| 421 | |
| 422 | if (proto != htons(ETH_P_IPV6)) |
| 423 | break; |
| 424 | |
| 425 | opthdr = __skb_header_pointer(skb, nhoff, sizeof(_opthdr), |
| 426 | data, hlen, &_opthdr); |
Eric Dumazet | 1e98a0f | 2015-06-12 19:31:32 -0700 | [diff] [blame] | 427 | if (!opthdr) |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 428 | goto out_bad; |
Tom Herbert | 6a74fcf | 2015-06-12 09:01:06 -0700 | [diff] [blame] | 429 | |
Eric Dumazet | 1e98a0f | 2015-06-12 19:31:32 -0700 | [diff] [blame] | 430 | ip_proto = opthdr[0]; |
| 431 | nhoff += (opthdr[1] + 1) << 3; |
Tom Herbert | 6a74fcf | 2015-06-12 09:01:06 -0700 | [diff] [blame] | 432 | |
| 433 | goto ip_proto_again; |
| 434 | } |
Tom Herbert | b840f28 | 2015-09-01 09:24:29 -0700 | [diff] [blame] | 435 | case NEXTHDR_FRAGMENT: { |
| 436 | struct frag_hdr _fh, *fh; |
| 437 | |
| 438 | if (proto != htons(ETH_P_IPV6)) |
| 439 | break; |
| 440 | |
| 441 | fh = __skb_header_pointer(skb, nhoff, sizeof(_fh), |
| 442 | data, hlen, &_fh); |
| 443 | |
| 444 | if (!fh) |
| 445 | goto out_bad; |
| 446 | |
David S. Miller | 4b36993 | 2015-09-01 16:46:08 -0700 | [diff] [blame] | 447 | key_control->flags |= FLOW_DIS_IS_FRAGMENT; |
Tom Herbert | b840f28 | 2015-09-01 09:24:29 -0700 | [diff] [blame] | 448 | |
| 449 | nhoff += sizeof(_fh); |
| 450 | |
| 451 | if (!(fh->frag_off & htons(IP6_OFFSET))) { |
David S. Miller | 4b36993 | 2015-09-01 16:46:08 -0700 | [diff] [blame] | 452 | key_control->flags |= FLOW_DIS_FIRST_FRAG; |
Tom Herbert | b840f28 | 2015-09-01 09:24:29 -0700 | [diff] [blame] | 453 | if (flags & FLOW_DISSECTOR_F_PARSE_1ST_FRAG) { |
| 454 | ip_proto = fh->nexthdr; |
| 455 | goto ip_proto_again; |
| 456 | } |
| 457 | } |
| 458 | goto out_good; |
| 459 | } |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 460 | case IPPROTO_IPIP: |
Tom Herbert | fca4189 | 2013-07-29 11:07:36 -0700 | [diff] [blame] | 461 | proto = htons(ETH_P_IP); |
Tom Herbert | 823b969 | 2015-09-01 09:24:32 -0700 | [diff] [blame] | 462 | |
David S. Miller | 4b36993 | 2015-09-01 16:46:08 -0700 | [diff] [blame] | 463 | key_control->flags |= FLOW_DIS_ENCAPSULATION; |
Tom Herbert | 823b969 | 2015-09-01 09:24:32 -0700 | [diff] [blame] | 464 | if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP) |
| 465 | goto out_good; |
| 466 | |
Tom Herbert | fca4189 | 2013-07-29 11:07:36 -0700 | [diff] [blame] | 467 | goto ip; |
Tom Herbert | b438f94 | 2013-07-29 11:07:42 -0700 | [diff] [blame] | 468 | case IPPROTO_IPV6: |
| 469 | proto = htons(ETH_P_IPV6); |
Tom Herbert | 823b969 | 2015-09-01 09:24:32 -0700 | [diff] [blame] | 470 | |
David S. Miller | 4b36993 | 2015-09-01 16:46:08 -0700 | [diff] [blame] | 471 | key_control->flags |= FLOW_DIS_ENCAPSULATION; |
Tom Herbert | 823b969 | 2015-09-01 09:24:32 -0700 | [diff] [blame] | 472 | if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP) |
| 473 | goto out_good; |
| 474 | |
Tom Herbert | b438f94 | 2013-07-29 11:07:42 -0700 | [diff] [blame] | 475 | goto ipv6; |
Tom Herbert | b3baa0f | 2015-06-04 09:16:46 -0700 | [diff] [blame] | 476 | case IPPROTO_MPLS: |
| 477 | proto = htons(ETH_P_MPLS_UC); |
| 478 | goto mpls; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 479 | default: |
| 480 | break; |
| 481 | } |
| 482 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 483 | if (dissector_uses_key(flow_dissector, |
| 484 | FLOW_DISSECTOR_KEY_PORTS)) { |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 485 | key_ports = skb_flow_dissector_target(flow_dissector, |
| 486 | FLOW_DISSECTOR_KEY_PORTS, |
| 487 | target_container); |
| 488 | key_ports->ports = __skb_flow_get_ports(skb, nhoff, ip_proto, |
| 489 | data, hlen); |
| 490 | } |
Alexander Duyck | 5af7fb6 | 2014-10-10 12:09:12 -0700 | [diff] [blame] | 491 | |
Tom Herbert | a6e544b | 2015-09-01 09:24:26 -0700 | [diff] [blame] | 492 | out_good: |
| 493 | ret = true; |
| 494 | |
| 495 | out_bad: |
| 496 | key_basic->n_proto = proto; |
| 497 | key_basic->ip_proto = ip_proto; |
| 498 | key_control->thoff = (u16)nhoff; |
| 499 | |
| 500 | return ret; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 501 | } |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 502 | EXPORT_SYMBOL(__skb_flow_dissect); |
Cong Wang | 441d9d3 | 2013-01-21 00:39:24 +0000 | [diff] [blame] | 503 | |
| 504 | static u32 hashrnd __read_mostly; |
Hannes Frederic Sowa | 66415cf | 2013-10-23 20:06:00 +0200 | [diff] [blame] | 505 | static __always_inline void __flow_hash_secret_init(void) |
| 506 | { |
| 507 | net_get_random_once(&hashrnd, sizeof(hashrnd)); |
| 508 | } |
| 509 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 510 | static __always_inline u32 __flow_hash_words(const u32 *words, u32 length, |
| 511 | u32 keyval) |
Hannes Frederic Sowa | 66415cf | 2013-10-23 20:06:00 +0200 | [diff] [blame] | 512 | { |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 513 | return jhash2(words, length, keyval); |
| 514 | } |
| 515 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 516 | static inline const u32 *flow_keys_hash_start(const struct flow_keys *flow) |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 517 | { |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 518 | const void *p = flow; |
| 519 | |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 520 | BUILD_BUG_ON(FLOW_KEYS_HASH_OFFSET % sizeof(u32)); |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 521 | return (const u32 *)(p + FLOW_KEYS_HASH_OFFSET); |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 522 | } |
| 523 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 524 | static inline size_t flow_keys_hash_length(const struct flow_keys *flow) |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 525 | { |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 526 | size_t diff = FLOW_KEYS_HASH_OFFSET + sizeof(flow->addrs); |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 527 | BUILD_BUG_ON((sizeof(*flow) - FLOW_KEYS_HASH_OFFSET) % sizeof(u32)); |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 528 | BUILD_BUG_ON(offsetof(typeof(*flow), addrs) != |
| 529 | sizeof(*flow) - sizeof(flow->addrs)); |
| 530 | |
| 531 | switch (flow->control.addr_type) { |
| 532 | case FLOW_DISSECTOR_KEY_IPV4_ADDRS: |
| 533 | diff -= sizeof(flow->addrs.v4addrs); |
| 534 | break; |
| 535 | case FLOW_DISSECTOR_KEY_IPV6_ADDRS: |
| 536 | diff -= sizeof(flow->addrs.v6addrs); |
| 537 | break; |
Tom Herbert | 9f24908 | 2015-06-04 09:16:41 -0700 | [diff] [blame] | 538 | case FLOW_DISSECTOR_KEY_TIPC_ADDRS: |
| 539 | diff -= sizeof(flow->addrs.tipcaddrs); |
| 540 | break; |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 541 | } |
| 542 | return (sizeof(*flow) - diff) / sizeof(u32); |
| 543 | } |
| 544 | |
| 545 | __be32 flow_get_u32_src(const struct flow_keys *flow) |
| 546 | { |
| 547 | switch (flow->control.addr_type) { |
| 548 | case FLOW_DISSECTOR_KEY_IPV4_ADDRS: |
| 549 | return flow->addrs.v4addrs.src; |
| 550 | case FLOW_DISSECTOR_KEY_IPV6_ADDRS: |
| 551 | return (__force __be32)ipv6_addr_hash( |
| 552 | &flow->addrs.v6addrs.src); |
Tom Herbert | 9f24908 | 2015-06-04 09:16:41 -0700 | [diff] [blame] | 553 | case FLOW_DISSECTOR_KEY_TIPC_ADDRS: |
| 554 | return flow->addrs.tipcaddrs.srcnode; |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 555 | default: |
| 556 | return 0; |
| 557 | } |
| 558 | } |
| 559 | EXPORT_SYMBOL(flow_get_u32_src); |
| 560 | |
| 561 | __be32 flow_get_u32_dst(const struct flow_keys *flow) |
| 562 | { |
| 563 | switch (flow->control.addr_type) { |
| 564 | case FLOW_DISSECTOR_KEY_IPV4_ADDRS: |
| 565 | return flow->addrs.v4addrs.dst; |
| 566 | case FLOW_DISSECTOR_KEY_IPV6_ADDRS: |
| 567 | return (__force __be32)ipv6_addr_hash( |
| 568 | &flow->addrs.v6addrs.dst); |
| 569 | default: |
| 570 | return 0; |
| 571 | } |
| 572 | } |
| 573 | EXPORT_SYMBOL(flow_get_u32_dst); |
| 574 | |
| 575 | static inline void __flow_hash_consistentify(struct flow_keys *keys) |
| 576 | { |
| 577 | int addr_diff, i; |
| 578 | |
| 579 | switch (keys->control.addr_type) { |
| 580 | case FLOW_DISSECTOR_KEY_IPV4_ADDRS: |
| 581 | addr_diff = (__force u32)keys->addrs.v4addrs.dst - |
| 582 | (__force u32)keys->addrs.v4addrs.src; |
| 583 | if ((addr_diff < 0) || |
| 584 | (addr_diff == 0 && |
| 585 | ((__force u16)keys->ports.dst < |
| 586 | (__force u16)keys->ports.src))) { |
| 587 | swap(keys->addrs.v4addrs.src, keys->addrs.v4addrs.dst); |
| 588 | swap(keys->ports.src, keys->ports.dst); |
| 589 | } |
| 590 | break; |
| 591 | case FLOW_DISSECTOR_KEY_IPV6_ADDRS: |
| 592 | addr_diff = memcmp(&keys->addrs.v6addrs.dst, |
| 593 | &keys->addrs.v6addrs.src, |
| 594 | sizeof(keys->addrs.v6addrs.dst)); |
| 595 | if ((addr_diff < 0) || |
| 596 | (addr_diff == 0 && |
| 597 | ((__force u16)keys->ports.dst < |
| 598 | (__force u16)keys->ports.src))) { |
| 599 | for (i = 0; i < 4; i++) |
| 600 | swap(keys->addrs.v6addrs.src.s6_addr32[i], |
| 601 | keys->addrs.v6addrs.dst.s6_addr32[i]); |
| 602 | swap(keys->ports.src, keys->ports.dst); |
| 603 | } |
| 604 | break; |
| 605 | } |
Hannes Frederic Sowa | 66415cf | 2013-10-23 20:06:00 +0200 | [diff] [blame] | 606 | } |
| 607 | |
Tom Herbert | 50fb799 | 2015-05-01 11:30:12 -0700 | [diff] [blame] | 608 | static inline u32 __flow_hash_from_keys(struct flow_keys *keys, u32 keyval) |
Tom Herbert | 5ed20a6 | 2014-07-01 21:32:05 -0700 | [diff] [blame] | 609 | { |
| 610 | u32 hash; |
| 611 | |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 612 | __flow_hash_consistentify(keys); |
Tom Herbert | 5ed20a6 | 2014-07-01 21:32:05 -0700 | [diff] [blame] | 613 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 614 | hash = __flow_hash_words(flow_keys_hash_start(keys), |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 615 | flow_keys_hash_length(keys), keyval); |
Tom Herbert | 5ed20a6 | 2014-07-01 21:32:05 -0700 | [diff] [blame] | 616 | if (!hash) |
| 617 | hash = 1; |
| 618 | |
| 619 | return hash; |
| 620 | } |
| 621 | |
| 622 | u32 flow_hash_from_keys(struct flow_keys *keys) |
| 623 | { |
Tom Herbert | 50fb799 | 2015-05-01 11:30:12 -0700 | [diff] [blame] | 624 | __flow_hash_secret_init(); |
| 625 | return __flow_hash_from_keys(keys, hashrnd); |
Tom Herbert | 5ed20a6 | 2014-07-01 21:32:05 -0700 | [diff] [blame] | 626 | } |
| 627 | EXPORT_SYMBOL(flow_hash_from_keys); |
| 628 | |
Tom Herbert | 50fb799 | 2015-05-01 11:30:12 -0700 | [diff] [blame] | 629 | static inline u32 ___skb_get_hash(const struct sk_buff *skb, |
| 630 | struct flow_keys *keys, u32 keyval) |
| 631 | { |
Tom Herbert | 6db61d7 | 2015-09-01 09:24:33 -0700 | [diff] [blame] | 632 | skb_flow_dissect_flow_keys(skb, keys, |
| 633 | FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL); |
Tom Herbert | 50fb799 | 2015-05-01 11:30:12 -0700 | [diff] [blame] | 634 | |
| 635 | return __flow_hash_from_keys(keys, keyval); |
| 636 | } |
| 637 | |
Tom Herbert | 2f59e1e | 2015-05-01 11:30:17 -0700 | [diff] [blame] | 638 | struct _flow_keys_digest_data { |
| 639 | __be16 n_proto; |
| 640 | u8 ip_proto; |
| 641 | u8 padding; |
| 642 | __be32 ports; |
| 643 | __be32 src; |
| 644 | __be32 dst; |
| 645 | }; |
| 646 | |
| 647 | void make_flow_keys_digest(struct flow_keys_digest *digest, |
| 648 | const struct flow_keys *flow) |
| 649 | { |
| 650 | struct _flow_keys_digest_data *data = |
| 651 | (struct _flow_keys_digest_data *)digest; |
| 652 | |
| 653 | BUILD_BUG_ON(sizeof(*data) > sizeof(*digest)); |
| 654 | |
| 655 | memset(digest, 0, sizeof(*digest)); |
| 656 | |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 657 | data->n_proto = flow->basic.n_proto; |
| 658 | data->ip_proto = flow->basic.ip_proto; |
| 659 | data->ports = flow->ports.ports; |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 660 | data->src = flow->addrs.v4addrs.src; |
| 661 | data->dst = flow->addrs.v4addrs.dst; |
Tom Herbert | 2f59e1e | 2015-05-01 11:30:17 -0700 | [diff] [blame] | 662 | } |
| 663 | EXPORT_SYMBOL(make_flow_keys_digest); |
| 664 | |
Jiri Pirko | d4fd327 | 2015-05-12 14:56:10 +0200 | [diff] [blame] | 665 | /** |
| 666 | * __skb_get_hash: calculate a flow hash |
| 667 | * @skb: sk_buff to calculate flow hash from |
| 668 | * |
| 669 | * This function calculates a flow hash based on src/dst addresses |
Tom Herbert | 61b905d | 2014-03-24 15:34:47 -0700 | [diff] [blame] | 670 | * and src/dst port numbers. Sets hash in skb to non-zero hash value |
| 671 | * on success, zero indicates no valid hash. Also, sets l4_hash in skb |
Cong Wang | 441d9d3 | 2013-01-21 00:39:24 +0000 | [diff] [blame] | 672 | * if hash is a canonical 4-tuple hash over transport ports. |
| 673 | */ |
Tom Herbert | 3958afa1b | 2013-12-15 22:12:06 -0800 | [diff] [blame] | 674 | void __skb_get_hash(struct sk_buff *skb) |
Cong Wang | 441d9d3 | 2013-01-21 00:39:24 +0000 | [diff] [blame] | 675 | { |
| 676 | struct flow_keys keys; |
Cong Wang | 441d9d3 | 2013-01-21 00:39:24 +0000 | [diff] [blame] | 677 | |
Tom Herbert | 50fb799 | 2015-05-01 11:30:12 -0700 | [diff] [blame] | 678 | __flow_hash_secret_init(); |
| 679 | |
Tom Herbert | 6db61d7 | 2015-09-01 09:24:33 -0700 | [diff] [blame] | 680 | __skb_set_sw_hash(skb, ___skb_get_hash(skb, &keys, hashrnd), |
Tom Herbert | bcc8383 | 2015-09-01 09:24:24 -0700 | [diff] [blame] | 681 | flow_keys_have_l4(&keys)); |
Cong Wang | 441d9d3 | 2013-01-21 00:39:24 +0000 | [diff] [blame] | 682 | } |
Tom Herbert | 3958afa1b | 2013-12-15 22:12:06 -0800 | [diff] [blame] | 683 | EXPORT_SYMBOL(__skb_get_hash); |
Cong Wang | 441d9d3 | 2013-01-21 00:39:24 +0000 | [diff] [blame] | 684 | |
Tom Herbert | 50fb799 | 2015-05-01 11:30:12 -0700 | [diff] [blame] | 685 | __u32 skb_get_hash_perturb(const struct sk_buff *skb, u32 perturb) |
| 686 | { |
| 687 | struct flow_keys keys; |
| 688 | |
| 689 | return ___skb_get_hash(skb, &keys, perturb); |
| 690 | } |
| 691 | EXPORT_SYMBOL(skb_get_hash_perturb); |
| 692 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 693 | __u32 __skb_get_hash_flowi6(struct sk_buff *skb, const struct flowi6 *fl6) |
Tom Herbert | f70ea01 | 2015-07-31 16:52:10 -0700 | [diff] [blame] | 694 | { |
| 695 | struct flow_keys keys; |
| 696 | |
| 697 | memset(&keys, 0, sizeof(keys)); |
| 698 | |
| 699 | memcpy(&keys.addrs.v6addrs.src, &fl6->saddr, |
| 700 | sizeof(keys.addrs.v6addrs.src)); |
| 701 | memcpy(&keys.addrs.v6addrs.dst, &fl6->daddr, |
| 702 | sizeof(keys.addrs.v6addrs.dst)); |
| 703 | keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; |
| 704 | keys.ports.src = fl6->fl6_sport; |
| 705 | keys.ports.dst = fl6->fl6_dport; |
| 706 | keys.keyid.keyid = fl6->fl6_gre_key; |
| 707 | keys.tags.flow_label = (__force u32)fl6->flowlabel; |
| 708 | keys.basic.ip_proto = fl6->flowi6_proto; |
| 709 | |
Tom Herbert | bcc8383 | 2015-09-01 09:24:24 -0700 | [diff] [blame] | 710 | __skb_set_sw_hash(skb, flow_hash_from_keys(&keys), |
| 711 | flow_keys_have_l4(&keys)); |
Tom Herbert | f70ea01 | 2015-07-31 16:52:10 -0700 | [diff] [blame] | 712 | |
| 713 | return skb->hash; |
| 714 | } |
| 715 | EXPORT_SYMBOL(__skb_get_hash_flowi6); |
| 716 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 717 | __u32 __skb_get_hash_flowi4(struct sk_buff *skb, const struct flowi4 *fl4) |
Tom Herbert | f70ea01 | 2015-07-31 16:52:10 -0700 | [diff] [blame] | 718 | { |
| 719 | struct flow_keys keys; |
| 720 | |
| 721 | memset(&keys, 0, sizeof(keys)); |
| 722 | |
| 723 | keys.addrs.v4addrs.src = fl4->saddr; |
| 724 | keys.addrs.v4addrs.dst = fl4->daddr; |
| 725 | keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; |
| 726 | keys.ports.src = fl4->fl4_sport; |
| 727 | keys.ports.dst = fl4->fl4_dport; |
| 728 | keys.keyid.keyid = fl4->fl4_gre_key; |
| 729 | keys.basic.ip_proto = fl4->flowi4_proto; |
| 730 | |
Tom Herbert | bcc8383 | 2015-09-01 09:24:24 -0700 | [diff] [blame] | 731 | __skb_set_sw_hash(skb, flow_hash_from_keys(&keys), |
| 732 | flow_keys_have_l4(&keys)); |
Tom Herbert | f70ea01 | 2015-07-31 16:52:10 -0700 | [diff] [blame] | 733 | |
| 734 | return skb->hash; |
| 735 | } |
| 736 | EXPORT_SYMBOL(__skb_get_hash_flowi4); |
| 737 | |
Alexander Duyck | 56193d1 | 2014-09-05 19:20:26 -0400 | [diff] [blame] | 738 | u32 __skb_get_poff(const struct sk_buff *skb, void *data, |
| 739 | const struct flow_keys *keys, int hlen) |
Daniel Borkmann | f77668d | 2013-03-19 06:39:30 +0000 | [diff] [blame] | 740 | { |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 741 | u32 poff = keys->control.thoff; |
Daniel Borkmann | f77668d | 2013-03-19 06:39:30 +0000 | [diff] [blame] | 742 | |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 743 | switch (keys->basic.ip_proto) { |
Daniel Borkmann | f77668d | 2013-03-19 06:39:30 +0000 | [diff] [blame] | 744 | case IPPROTO_TCP: { |
Alexander Duyck | 5af7fb6 | 2014-10-10 12:09:12 -0700 | [diff] [blame] | 745 | /* access doff as u8 to avoid unaligned access */ |
| 746 | const u8 *doff; |
| 747 | u8 _doff; |
Daniel Borkmann | f77668d | 2013-03-19 06:39:30 +0000 | [diff] [blame] | 748 | |
Alexander Duyck | 5af7fb6 | 2014-10-10 12:09:12 -0700 | [diff] [blame] | 749 | doff = __skb_header_pointer(skb, poff + 12, sizeof(_doff), |
| 750 | data, hlen, &_doff); |
| 751 | if (!doff) |
Daniel Borkmann | f77668d | 2013-03-19 06:39:30 +0000 | [diff] [blame] | 752 | return poff; |
| 753 | |
Alexander Duyck | 5af7fb6 | 2014-10-10 12:09:12 -0700 | [diff] [blame] | 754 | poff += max_t(u32, sizeof(struct tcphdr), (*doff & 0xF0) >> 2); |
Daniel Borkmann | f77668d | 2013-03-19 06:39:30 +0000 | [diff] [blame] | 755 | break; |
| 756 | } |
| 757 | case IPPROTO_UDP: |
| 758 | case IPPROTO_UDPLITE: |
| 759 | poff += sizeof(struct udphdr); |
| 760 | break; |
| 761 | /* For the rest, we do not really care about header |
| 762 | * extensions at this point for now. |
| 763 | */ |
| 764 | case IPPROTO_ICMP: |
| 765 | poff += sizeof(struct icmphdr); |
| 766 | break; |
| 767 | case IPPROTO_ICMPV6: |
| 768 | poff += sizeof(struct icmp6hdr); |
| 769 | break; |
| 770 | case IPPROTO_IGMP: |
| 771 | poff += sizeof(struct igmphdr); |
| 772 | break; |
| 773 | case IPPROTO_DCCP: |
| 774 | poff += sizeof(struct dccp_hdr); |
| 775 | break; |
| 776 | case IPPROTO_SCTP: |
| 777 | poff += sizeof(struct sctphdr); |
| 778 | break; |
| 779 | } |
| 780 | |
| 781 | return poff; |
| 782 | } |
| 783 | |
Jiri Pirko | 0db89b8 | 2015-05-12 14:56:14 +0200 | [diff] [blame] | 784 | /** |
| 785 | * skb_get_poff - get the offset to the payload |
| 786 | * @skb: sk_buff to get the payload offset from |
| 787 | * |
| 788 | * The function will get the offset to the payload as far as it could |
| 789 | * be dissected. The main user is currently BPF, so that we can dynamically |
Alexander Duyck | 56193d1 | 2014-09-05 19:20:26 -0400 | [diff] [blame] | 790 | * truncate packets without needing to push actual payload to the user |
| 791 | * space and can analyze headers only, instead. |
| 792 | */ |
| 793 | u32 skb_get_poff(const struct sk_buff *skb) |
| 794 | { |
| 795 | struct flow_keys keys; |
| 796 | |
Tom Herbert | cd79a23 | 2015-09-01 09:24:27 -0700 | [diff] [blame] | 797 | if (!skb_flow_dissect_flow_keys(skb, &keys, 0)) |
Alexander Duyck | 56193d1 | 2014-09-05 19:20:26 -0400 | [diff] [blame] | 798 | return 0; |
| 799 | |
| 800 | return __skb_get_poff(skb, skb->data, &keys, skb_headlen(skb)); |
| 801 | } |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 802 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 803 | __u32 __get_hash_from_flowi6(const struct flowi6 *fl6, struct flow_keys *keys) |
David S. Miller | a17ace9 | 2015-09-01 17:00:24 -0700 | [diff] [blame] | 804 | { |
| 805 | memset(keys, 0, sizeof(*keys)); |
| 806 | |
| 807 | memcpy(&keys->addrs.v6addrs.src, &fl6->saddr, |
| 808 | sizeof(keys->addrs.v6addrs.src)); |
| 809 | memcpy(&keys->addrs.v6addrs.dst, &fl6->daddr, |
| 810 | sizeof(keys->addrs.v6addrs.dst)); |
| 811 | keys->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; |
| 812 | keys->ports.src = fl6->fl6_sport; |
| 813 | keys->ports.dst = fl6->fl6_dport; |
| 814 | keys->keyid.keyid = fl6->fl6_gre_key; |
| 815 | keys->tags.flow_label = (__force u32)fl6->flowlabel; |
| 816 | keys->basic.ip_proto = fl6->flowi6_proto; |
| 817 | |
| 818 | return flow_hash_from_keys(keys); |
| 819 | } |
| 820 | EXPORT_SYMBOL(__get_hash_from_flowi6); |
| 821 | |
David S. Miller | 20a17bf | 2015-09-01 21:19:17 -0700 | [diff] [blame] | 822 | __u32 __get_hash_from_flowi4(const struct flowi4 *fl4, struct flow_keys *keys) |
David S. Miller | a17ace9 | 2015-09-01 17:00:24 -0700 | [diff] [blame] | 823 | { |
| 824 | memset(keys, 0, sizeof(*keys)); |
| 825 | |
| 826 | keys->addrs.v4addrs.src = fl4->saddr; |
| 827 | keys->addrs.v4addrs.dst = fl4->daddr; |
| 828 | keys->control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; |
| 829 | keys->ports.src = fl4->fl4_sport; |
| 830 | keys->ports.dst = fl4->fl4_dport; |
| 831 | keys->keyid.keyid = fl4->fl4_gre_key; |
| 832 | keys->basic.ip_proto = fl4->flowi4_proto; |
| 833 | |
| 834 | return flow_hash_from_keys(keys); |
| 835 | } |
| 836 | EXPORT_SYMBOL(__get_hash_from_flowi4); |
| 837 | |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 838 | static const struct flow_dissector_key flow_keys_dissector_keys[] = { |
| 839 | { |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 840 | .key_id = FLOW_DISSECTOR_KEY_CONTROL, |
| 841 | .offset = offsetof(struct flow_keys, control), |
| 842 | }, |
| 843 | { |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 844 | .key_id = FLOW_DISSECTOR_KEY_BASIC, |
| 845 | .offset = offsetof(struct flow_keys, basic), |
| 846 | }, |
| 847 | { |
| 848 | .key_id = FLOW_DISSECTOR_KEY_IPV4_ADDRS, |
Tom Herbert | c3f8324 | 2015-06-04 09:16:40 -0700 | [diff] [blame] | 849 | .offset = offsetof(struct flow_keys, addrs.v4addrs), |
| 850 | }, |
| 851 | { |
| 852 | .key_id = FLOW_DISSECTOR_KEY_IPV6_ADDRS, |
| 853 | .offset = offsetof(struct flow_keys, addrs.v6addrs), |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 854 | }, |
| 855 | { |
Tom Herbert | 9f24908 | 2015-06-04 09:16:41 -0700 | [diff] [blame] | 856 | .key_id = FLOW_DISSECTOR_KEY_TIPC_ADDRS, |
| 857 | .offset = offsetof(struct flow_keys, addrs.tipcaddrs), |
| 858 | }, |
| 859 | { |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 860 | .key_id = FLOW_DISSECTOR_KEY_PORTS, |
| 861 | .offset = offsetof(struct flow_keys, ports), |
| 862 | }, |
Tom Herbert | d34af82 | 2015-06-04 09:16:43 -0700 | [diff] [blame] | 863 | { |
| 864 | .key_id = FLOW_DISSECTOR_KEY_VLANID, |
| 865 | .offset = offsetof(struct flow_keys, tags), |
| 866 | }, |
Tom Herbert | 87ee9e5 | 2015-06-04 09:16:44 -0700 | [diff] [blame] | 867 | { |
| 868 | .key_id = FLOW_DISSECTOR_KEY_FLOW_LABEL, |
| 869 | .offset = offsetof(struct flow_keys, tags), |
| 870 | }, |
Tom Herbert | 1fdd512 | 2015-06-04 09:16:45 -0700 | [diff] [blame] | 871 | { |
| 872 | .key_id = FLOW_DISSECTOR_KEY_GRE_KEYID, |
| 873 | .offset = offsetof(struct flow_keys, keyid), |
| 874 | }, |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 875 | }; |
| 876 | |
| 877 | static const struct flow_dissector_key flow_keys_buf_dissector_keys[] = { |
| 878 | { |
Tom Herbert | 42aecaa | 2015-06-04 09:16:39 -0700 | [diff] [blame] | 879 | .key_id = FLOW_DISSECTOR_KEY_CONTROL, |
| 880 | .offset = offsetof(struct flow_keys, control), |
| 881 | }, |
| 882 | { |
Jiri Pirko | 06635a3 | 2015-05-12 14:56:16 +0200 | [diff] [blame] | 883 | .key_id = FLOW_DISSECTOR_KEY_BASIC, |
| 884 | .offset = offsetof(struct flow_keys, basic), |
| 885 | }, |
| 886 | }; |
| 887 | |
| 888 | struct flow_dissector flow_keys_dissector __read_mostly; |
| 889 | EXPORT_SYMBOL(flow_keys_dissector); |
| 890 | |
| 891 | struct flow_dissector flow_keys_buf_dissector __read_mostly; |
| 892 | |
| 893 | static int __init init_default_flow_dissectors(void) |
| 894 | { |
| 895 | skb_flow_dissector_init(&flow_keys_dissector, |
| 896 | flow_keys_dissector_keys, |
| 897 | ARRAY_SIZE(flow_keys_dissector_keys)); |
| 898 | skb_flow_dissector_init(&flow_keys_buf_dissector, |
| 899 | flow_keys_buf_dissector_keys, |
| 900 | ARRAY_SIZE(flow_keys_buf_dissector_keys)); |
| 901 | return 0; |
| 902 | } |
| 903 | |
| 904 | late_initcall_sync(init_default_flow_dissectors); |