diff options
Diffstat (limited to 'include/net/act_api.h')
-rw-r--r-- | include/net/act_api.h | 63 |
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 | ||
11 | struct tcf_common { | 11 | struct 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 | ||
38 | struct tcf_hashinfo { | 38 | struct 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 | ||
44 | static inline unsigned int tcf_hash(u32 index, unsigned int hmask) | 45 | static 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 | ||
50 | static 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 | |||
66 | static 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 | ||
54 | struct tcf_act_hdr { | ||
55 | struct tcf_common common; | ||
56 | }; | ||
57 | |||
58 | struct tc_action { | 76 | struct 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 | ||
67 | struct tc_action_ops { | 84 | struct 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 | ||
85 | struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo); | 100 | int tcf_hash_search(struct tc_action *a, u32 index); |
86 | void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo); | 101 | void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo); |
87 | int tcf_hash_release(struct tcf_common *p, int bind, | 102 | int tcf_hash_release(struct tcf_common *p, int bind, |
88 | struct tcf_hashinfo *hinfo); | 103 | struct tcf_hashinfo *hinfo); |
89 | int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb, | 104 | u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo); |
90 | int type, struct tc_action *a); | ||
91 | u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo); | ||
92 | int tcf_hash_search(struct tc_action *a, u32 index); | ||
93 | struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, | 105 | struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, |
94 | int bind, struct tcf_hashinfo *hinfo); | 106 | int bind); |
95 | struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, | 107 | struct 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); | ||
99 | void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo); | 110 | void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo); |
100 | 111 | ||
101 | int tcf_register_action(struct tc_action_ops *a); | 112 | int tcf_register_action(struct tc_action_ops *a); |
102 | int tcf_unregister_action(struct tc_action_ops *a); | 113 | int tcf_unregister_action(struct tc_action_ops *a); |
103 | void tcf_action_destroy(struct tc_action *a, int bind); | 114 | void tcf_action_destroy(struct list_head *actions, int bind); |
104 | int tcf_action_exec(struct sk_buff *skb, const struct tc_action *a, | 115 | int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions, |
105 | struct tcf_result *res); | 116 | struct tcf_result *res); |
106 | struct tc_action *tcf_action_init(struct net *net, struct nlattr *nla, | 117 | int 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 *); |
109 | struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla, | 120 | struct 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); |
112 | int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int); | 123 | int tcf_action_dump(struct sk_buff *skb, struct list_head *, int, int); |
113 | int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); | 124 | int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); |
114 | int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); | 125 | int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); |
115 | int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); | 126 | int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); |