flow_keys.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef _NET_FLOW_KEYS_H
  2. #define _NET_FLOW_KEYS_H
  3. /* struct flow_keys:
  4. * @src: source ip address in case of IPv4
  5. * For IPv6 it contains 32bit hash of src address
  6. * @dst: destination ip address in case of IPv4
  7. * For IPv6 it contains 32bit hash of dst address
  8. * @ports: port numbers of Transport header
  9. * port16[0]: src port number
  10. * port16[1]: dst port number
  11. * @thoff: Transport header offset
  12. * @n_proto: Network header protocol (eg. IPv4/IPv6)
  13. * @ip_proto: Transport header protocol (eg. TCP/UDP)
  14. * All the members, except thoff, are in network byte order.
  15. */
  16. struct flow_keys {
  17. /* (src,dst) must be grouped, in the same way than in IP header */
  18. __be32 src;
  19. __be32 dst;
  20. union {
  21. __be32 ports;
  22. __be16 port16[2];
  23. };
  24. u16 thoff;
  25. __be16 n_proto;
  26. u8 ip_proto;
  27. };
  28. bool __skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow,
  29. void *data, __be16 proto, int nhoff, int hlen);
  30. static inline bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow)
  31. {
  32. return __skb_flow_dissect(skb, flow, NULL, 0, 0, 0);
  33. }
  34. __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
  35. void *data, int hlen_proto);
  36. static inline __be32 skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto)
  37. {
  38. return __skb_flow_get_ports(skb, thoff, ip_proto, NULL, 0);
  39. }
  40. u32 flow_hash_from_keys(struct flow_keys *keys);
  41. unsigned int flow_get_hlen(const unsigned char *data, unsigned int max_len,
  42. __be16 protocol);
  43. /* struct flow_keys_digest:
  44. *
  45. * This structure is used to hold a digest of the full flow keys. This is a
  46. * larger "hash" of a flow to allow definitively matching specific flows where
  47. * the 32 bit skb->hash is not large enough. The size is limited to 16 bytes so
  48. * that it can by used in CB of skb (see sch_choke for an example).
  49. */
  50. #define FLOW_KEYS_DIGEST_LEN 16
  51. struct flow_keys_digest {
  52. u8 data[FLOW_KEYS_DIGEST_LEN];
  53. };
  54. void make_flow_keys_digest(struct flow_keys_digest *digest,
  55. const struct flow_keys *flow);
  56. #endif