aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/act_api.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/act_api.h')
-rw-r--r--include/net/act_api.h63
1 files changed, 37 insertions, 26 deletions
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 9e90fdff470d..788d8378e587 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -9,7 +9,7 @@
9#include <net/pkt_sched.h> 9#include <net/pkt_sched.h>
10 10
11struct tcf_common { 11struct tcf_common {
12 struct tcf_common *tcfc_next; 12 struct hlist_node tcfc_head;
13 u32 tcfc_index; 13 u32 tcfc_index;
14 int tcfc_refcnt; 14 int tcfc_refcnt;
15 int tcfc_bindcnt; 15 int tcfc_bindcnt;
@@ -22,7 +22,7 @@ struct tcf_common {
22 spinlock_t tcfc_lock; 22 spinlock_t tcfc_lock;
23 struct rcu_head tcfc_rcu; 23 struct rcu_head tcfc_rcu;
24}; 24};
25#define tcf_next common.tcfc_next 25#define tcf_head common.tcfc_head
26#define tcf_index common.tcfc_index 26#define tcf_index common.tcfc_index
27#define tcf_refcnt common.tcfc_refcnt 27#define tcf_refcnt common.tcfc_refcnt
28#define tcf_bindcnt common.tcfc_bindcnt 28#define tcf_bindcnt common.tcfc_bindcnt
@@ -36,9 +36,10 @@ struct tcf_common {
36#define tcf_rcu common.tcfc_rcu 36#define tcf_rcu common.tcfc_rcu
37 37
38struct tcf_hashinfo { 38struct tcf_hashinfo {
39 struct tcf_common **htab; 39 struct hlist_head *htab;
40 unsigned int hmask; 40 unsigned int hmask;
41 rwlock_t *lock; 41 spinlock_t lock;
42 u32 index;
42}; 43};
43 44
44static inline unsigned int tcf_hash(u32 index, unsigned int hmask) 45static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
@@ -46,33 +47,47 @@ static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
46 return index & hmask; 47 return index & hmask;
47} 48}
48 49
50static inline int tcf_hashinfo_init(struct tcf_hashinfo *hf, unsigned int mask)
51{
52 int i;
53
54 spin_lock_init(&hf->lock);
55 hf->index = 0;
56 hf->hmask = mask;
57 hf->htab = kzalloc((mask + 1) * sizeof(struct hlist_head),
58 GFP_KERNEL);
59 if (!hf->htab)
60 return -ENOMEM;
61 for (i = 0; i < mask + 1; i++)
62 INIT_HLIST_HEAD(&hf->htab[i]);
63 return 0;
64}
65
66static inline void tcf_hashinfo_destroy(struct tcf_hashinfo *hf)
67{
68 kfree(hf->htab);
69}
70
49#ifdef CONFIG_NET_CLS_ACT 71#ifdef CONFIG_NET_CLS_ACT
50 72
51#define ACT_P_CREATED 1 73#define ACT_P_CREATED 1
52#define ACT_P_DELETED 1 74#define ACT_P_DELETED 1
53 75
54struct tcf_act_hdr {
55 struct tcf_common common;
56};
57
58struct tc_action { 76struct tc_action {
59 void *priv; 77 void *priv;
60 const struct tc_action_ops *ops; 78 const struct tc_action_ops *ops;
61 __u32 type; /* for backward compat(TCA_OLD_COMPAT) */ 79 __u32 type; /* for backward compat(TCA_OLD_COMPAT) */
62 __u32 order; 80 __u32 order;
63 struct tc_action *next; 81 struct list_head list;
64}; 82};
65 83
66#define TCA_CAP_NONE 0
67struct tc_action_ops { 84struct tc_action_ops {
68 struct tc_action_ops *next; 85 struct list_head head;
69 struct tcf_hashinfo *hinfo; 86 struct tcf_hashinfo *hinfo;
70 char kind[IFNAMSIZ]; 87 char kind[IFNAMSIZ];
71 __u32 type; /* TBD to match kind */ 88 __u32 type; /* TBD to match kind */
72 __u32 capab; /* capabilities includes 4 bit version */
73 struct module *owner; 89 struct module *owner;
74 int (*act)(struct sk_buff *, const struct tc_action *, struct tcf_result *); 90 int (*act)(struct sk_buff *, const struct tc_action *, struct tcf_result *);
75 int (*get_stats)(struct sk_buff *, struct tc_action *);
76 int (*dump)(struct sk_buff *, struct tc_action *, int, int); 91 int (*dump)(struct sk_buff *, struct tc_action *, int, int);
77 int (*cleanup)(struct tc_action *, int bind); 92 int (*cleanup)(struct tc_action *, int bind);
78 int (*lookup)(struct tc_action *, u32); 93 int (*lookup)(struct tc_action *, u32);
@@ -82,34 +97,30 @@ struct tc_action_ops {
82 int (*walk)(struct sk_buff *, struct netlink_callback *, int, struct tc_action *); 97 int (*walk)(struct sk_buff *, struct netlink_callback *, int, struct tc_action *);
83}; 98};
84 99
85struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo); 100int tcf_hash_search(struct tc_action *a, u32 index);
86void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo); 101void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo);
87int tcf_hash_release(struct tcf_common *p, int bind, 102int tcf_hash_release(struct tcf_common *p, int bind,
88 struct tcf_hashinfo *hinfo); 103 struct tcf_hashinfo *hinfo);
89int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb, 104u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo);
90 int type, struct tc_action *a);
91u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo);
92int tcf_hash_search(struct tc_action *a, u32 index);
93struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, 105struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a,
94 int bind, struct tcf_hashinfo *hinfo); 106 int bind);
95struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, 107struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
96 struct tc_action *a, int size, 108 struct tc_action *a, int size,
97 int bind, u32 *idx_gen, 109 int bind);
98 struct tcf_hashinfo *hinfo);
99void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo); 110void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);
100 111
101int tcf_register_action(struct tc_action_ops *a); 112int tcf_register_action(struct tc_action_ops *a);
102int tcf_unregister_action(struct tc_action_ops *a); 113int tcf_unregister_action(struct tc_action_ops *a);
103void tcf_action_destroy(struct tc_action *a, int bind); 114void tcf_action_destroy(struct list_head *actions, int bind);
104int tcf_action_exec(struct sk_buff *skb, const struct tc_action *a, 115int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions,
105 struct tcf_result *res); 116 struct tcf_result *res);
106struct tc_action *tcf_action_init(struct net *net, struct nlattr *nla, 117int tcf_action_init(struct net *net, struct nlattr *nla,
107 struct nlattr *est, char *n, int ovr, 118 struct nlattr *est, char *n, int ovr,
108 int bind); 119 int bind, struct list_head *);
109struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla, 120struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla,
110 struct nlattr *est, char *n, int ovr, 121 struct nlattr *est, char *n, int ovr,
111 int bind); 122 int bind);
112int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int); 123int tcf_action_dump(struct sk_buff *skb, struct list_head *, int, int);
113int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); 124int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
114int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); 125int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
115int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); 126int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);