act_api.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef __NET_ACT_API_H
  2. #define __NET_ACT_API_H
  3. /*
  4. * Public police action API for classifiers/qdiscs
  5. */
  6. #include <net/sch_generic.h>
  7. #include <net/pkt_sched.h>
  8. struct tcf_common {
  9. struct tcf_common *tcfc_next;
  10. u32 tcfc_index;
  11. int tcfc_refcnt;
  12. int tcfc_bindcnt;
  13. u32 tcfc_capab;
  14. int tcfc_action;
  15. struct tcf_t tcfc_tm;
  16. struct gnet_stats_basic_packed tcfc_bstats;
  17. struct gnet_stats_queue tcfc_qstats;
  18. struct gnet_stats_rate_est tcfc_rate_est;
  19. spinlock_t tcfc_lock;
  20. struct rcu_head tcfc_rcu;
  21. };
  22. #define tcf_next common.tcfc_next
  23. #define tcf_index common.tcfc_index
  24. #define tcf_refcnt common.tcfc_refcnt
  25. #define tcf_bindcnt common.tcfc_bindcnt
  26. #define tcf_capab common.tcfc_capab
  27. #define tcf_action common.tcfc_action
  28. #define tcf_tm common.tcfc_tm
  29. #define tcf_bstats common.tcfc_bstats
  30. #define tcf_qstats common.tcfc_qstats
  31. #define tcf_rate_est common.tcfc_rate_est
  32. #define tcf_lock common.tcfc_lock
  33. #define tcf_rcu common.tcfc_rcu
  34. struct tcf_hashinfo {
  35. struct tcf_common **htab;
  36. unsigned int hmask;
  37. rwlock_t *lock;
  38. };
  39. static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
  40. {
  41. return index & hmask;
  42. }
  43. #ifdef CONFIG_NET_CLS_ACT
  44. #define ACT_P_CREATED 1
  45. #define ACT_P_DELETED 1
  46. struct tcf_act_hdr {
  47. struct tcf_common common;
  48. };
  49. struct tc_action {
  50. void *priv;
  51. const struct tc_action_ops *ops;
  52. __u32 type; /* for backward compat(TCA_OLD_COMPAT) */
  53. __u32 order;
  54. struct tc_action *next;
  55. };
  56. #define TCA_CAP_NONE 0
  57. struct tc_action_ops {
  58. struct tc_action_ops *next;
  59. struct tcf_hashinfo *hinfo;
  60. char kind[IFNAMSIZ];
  61. __u32 type; /* TBD to match kind */
  62. __u32 capab; /* capabilities includes 4 bit version */
  63. struct module *owner;
  64. int (*act)(struct sk_buff *, const struct tc_action *, struct tcf_result *);
  65. int (*get_stats)(struct sk_buff *, struct tc_action *);
  66. int (*dump)(struct sk_buff *, struct tc_action *, int, int);
  67. int (*cleanup)(struct tc_action *, int bind);
  68. int (*lookup)(struct tc_action *, u32);
  69. int (*init)(struct net *net, struct nlattr *nla,
  70. struct nlattr *est, struct tc_action *act, int ovr,
  71. int bind);
  72. int (*walk)(struct sk_buff *, struct netlink_callback *, int, struct tc_action *);
  73. };
  74. extern struct tcf_common *tcf_hash_lookup(u32 index,
  75. struct tcf_hashinfo *hinfo);
  76. extern void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo);
  77. extern int tcf_hash_release(struct tcf_common *p, int bind,
  78. struct tcf_hashinfo *hinfo);
  79. extern int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
  80. int type, struct tc_action *a);
  81. extern u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo);
  82. extern int tcf_hash_search(struct tc_action *a, u32 index);
  83. extern struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a,
  84. int bind, struct tcf_hashinfo *hinfo);
  85. extern struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
  86. struct tc_action *a, int size,
  87. int bind, u32 *idx_gen,
  88. struct tcf_hashinfo *hinfo);
  89. extern void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);
  90. extern int tcf_register_action(struct tc_action_ops *a);
  91. extern int tcf_unregister_action(struct tc_action_ops *a);
  92. extern void tcf_action_destroy(struct tc_action *a, int bind);
  93. extern int tcf_action_exec(struct sk_buff *skb, const struct tc_action *a, struct tcf_result *res);
  94. extern struct tc_action *tcf_action_init(struct net *net, struct nlattr *nla,
  95. struct nlattr *est, char *n, int ovr,
  96. int bind);
  97. extern struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla,
  98. struct nlattr *est, char *n, int ovr,
  99. int bind);
  100. extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
  101. extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
  102. extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
  103. extern int tcf_action_copy_stats (struct sk_buff *,struct tc_action *, int);
  104. #endif /* CONFIG_NET_CLS_ACT */
  105. #endif