Jiri Pirko | 1bd758e | 2015-05-12 14:56:07 +0200 | [diff] [blame^] | 1 | #ifndef _NET_FLOW_DISSECTOR_H |
| 2 | #define _NET_FLOW_DISSECTOR_H |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 3 | |
Govindarajulu Varadarajan | e0f31d8 | 2014-06-23 16:07:58 +0530 | [diff] [blame] | 4 | /* struct flow_keys: |
| 5 | * @src: source ip address in case of IPv4 |
| 6 | * For IPv6 it contains 32bit hash of src address |
| 7 | * @dst: destination ip address in case of IPv4 |
| 8 | * For IPv6 it contains 32bit hash of dst address |
| 9 | * @ports: port numbers of Transport header |
| 10 | * port16[0]: src port number |
| 11 | * port16[1]: dst port number |
| 12 | * @thoff: Transport header offset |
| 13 | * @n_proto: Network header protocol (eg. IPv4/IPv6) |
| 14 | * @ip_proto: Transport header protocol (eg. TCP/UDP) |
| 15 | * All the members, except thoff, are in network byte order. |
| 16 | */ |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 17 | struct flow_keys { |
Eric Dumazet | 4d77d2b | 2011-11-28 20:30:35 +0000 | [diff] [blame] | 18 | /* (src,dst) must be grouped, in the same way than in IP header */ |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 19 | __be32 src; |
| 20 | __be32 dst; |
| 21 | union { |
| 22 | __be32 ports; |
| 23 | __be16 port16[2]; |
| 24 | }; |
Eric Dumazet | f4575d3 | 2015-02-04 13:31:54 -0800 | [diff] [blame] | 25 | u16 thoff; |
| 26 | __be16 n_proto; |
| 27 | u8 ip_proto; |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 30 | bool __skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow, |
WANG Cong | 453a940 | 2014-08-25 17:03:47 -0700 | [diff] [blame] | 31 | void *data, __be16 proto, int nhoff, int hlen); |
Jiri Pirko | 1bd758e | 2015-05-12 14:56:07 +0200 | [diff] [blame^] | 32 | |
| 33 | static inline bool skb_flow_dissect(const struct sk_buff *skb, |
| 34 | struct flow_keys *flow) |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 35 | { |
WANG Cong | 453a940 | 2014-08-25 17:03:47 -0700 | [diff] [blame] | 36 | return __skb_flow_dissect(skb, flow, NULL, 0, 0, 0); |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 37 | } |
Jiri Pirko | 1bd758e | 2015-05-12 14:56:07 +0200 | [diff] [blame^] | 38 | |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 39 | __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto, |
| 40 | void *data, int hlen_proto); |
Jiri Pirko | 1bd758e | 2015-05-12 14:56:07 +0200 | [diff] [blame^] | 41 | |
| 42 | static inline __be32 skb_flow_get_ports(const struct sk_buff *skb, |
| 43 | int thoff, u8 ip_proto) |
David S. Miller | 690e36e | 2014-08-23 12:13:41 -0700 | [diff] [blame] | 44 | { |
| 45 | return __skb_flow_get_ports(skb, thoff, ip_proto, NULL, 0); |
| 46 | } |
Jiri Pirko | 1bd758e | 2015-05-12 14:56:07 +0200 | [diff] [blame^] | 47 | |
Tom Herbert | 5ed20a6 | 2014-07-01 21:32:05 -0700 | [diff] [blame] | 48 | u32 flow_hash_from_keys(struct flow_keys *keys); |
Jiri Pirko | 1bd758e | 2015-05-12 14:56:07 +0200 | [diff] [blame^] | 49 | |
Alexander Duyck | 56193d1 | 2014-09-05 19:20:26 -0400 | [diff] [blame] | 50 | unsigned int flow_get_hlen(const unsigned char *data, unsigned int max_len, |
| 51 | __be16 protocol); |
Tom Herbert | 2f59e1e | 2015-05-01 11:30:17 -0700 | [diff] [blame] | 52 | |
| 53 | /* struct flow_keys_digest: |
| 54 | * |
| 55 | * This structure is used to hold a digest of the full flow keys. This is a |
| 56 | * larger "hash" of a flow to allow definitively matching specific flows where |
| 57 | * the 32 bit skb->hash is not large enough. The size is limited to 16 bytes so |
| 58 | * that it can by used in CB of skb (see sch_choke for an example). |
| 59 | */ |
| 60 | #define FLOW_KEYS_DIGEST_LEN 16 |
| 61 | struct flow_keys_digest { |
| 62 | u8 data[FLOW_KEYS_DIGEST_LEN]; |
| 63 | }; |
| 64 | |
| 65 | void make_flow_keys_digest(struct flow_keys_digest *digest, |
| 66 | const struct flow_keys *flow); |
| 67 | |
Eric Dumazet | 0744dd0 | 2011-11-28 05:22:18 +0000 | [diff] [blame] | 68 | #endif |