diff options
Diffstat (limited to 'include/net/act_api.h')
| -rw-r--r-- | include/net/act_api.h | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/include/net/act_api.h b/include/net/act_api.h index 9e59ebfded62..1ad5b19e83a9 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | * Public action API for classifiers/qdiscs | 6 | * Public action API for classifiers/qdiscs |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <linux/refcount.h> | ||
| 9 | #include <net/sch_generic.h> | 10 | #include <net/sch_generic.h> |
| 10 | #include <net/pkt_sched.h> | 11 | #include <net/pkt_sched.h> |
| 11 | #include <net/net_namespace.h> | 12 | #include <net/net_namespace.h> |
| @@ -26,8 +27,8 @@ struct tc_action { | |||
| 26 | struct tcf_idrinfo *idrinfo; | 27 | struct tcf_idrinfo *idrinfo; |
| 27 | 28 | ||
| 28 | u32 tcfa_index; | 29 | u32 tcfa_index; |
| 29 | int tcfa_refcnt; | 30 | refcount_t tcfa_refcnt; |
| 30 | int tcfa_bindcnt; | 31 | atomic_t tcfa_bindcnt; |
| 31 | u32 tcfa_capab; | 32 | u32 tcfa_capab; |
| 32 | int tcfa_action; | 33 | int tcfa_action; |
| 33 | struct tcf_t tcfa_tm; | 34 | struct tcf_t tcfa_tm; |
| @@ -37,7 +38,7 @@ struct tc_action { | |||
| 37 | spinlock_t tcfa_lock; | 38 | spinlock_t tcfa_lock; |
| 38 | struct gnet_stats_basic_cpu __percpu *cpu_bstats; | 39 | struct gnet_stats_basic_cpu __percpu *cpu_bstats; |
| 39 | struct gnet_stats_queue __percpu *cpu_qstats; | 40 | struct gnet_stats_queue __percpu *cpu_qstats; |
| 40 | struct tc_cookie *act_cookie; | 41 | struct tc_cookie __rcu *act_cookie; |
| 41 | struct tcf_chain *goto_chain; | 42 | struct tcf_chain *goto_chain; |
| 42 | }; | 43 | }; |
| 43 | #define tcf_index common.tcfa_index | 44 | #define tcf_index common.tcfa_index |
| @@ -84,14 +85,15 @@ struct tc_action_ops { | |||
| 84 | size_t size; | 85 | size_t size; |
| 85 | struct module *owner; | 86 | struct module *owner; |
| 86 | int (*act)(struct sk_buff *, const struct tc_action *, | 87 | int (*act)(struct sk_buff *, const struct tc_action *, |
| 87 | struct tcf_result *); | 88 | struct tcf_result *); /* called under RCU BH lock*/ |
| 88 | int (*dump)(struct sk_buff *, struct tc_action *, int, int); | 89 | int (*dump)(struct sk_buff *, struct tc_action *, int, int); |
| 89 | void (*cleanup)(struct tc_action *); | 90 | void (*cleanup)(struct tc_action *); |
| 90 | int (*lookup)(struct net *net, struct tc_action **a, u32 index, | 91 | int (*lookup)(struct net *net, struct tc_action **a, u32 index, |
| 91 | struct netlink_ext_ack *extack); | 92 | struct netlink_ext_ack *extack); |
| 92 | int (*init)(struct net *net, struct nlattr *nla, | 93 | int (*init)(struct net *net, struct nlattr *nla, |
| 93 | struct nlattr *est, struct tc_action **act, int ovr, | 94 | struct nlattr *est, struct tc_action **act, int ovr, |
| 94 | int bind, struct netlink_ext_ack *extack); | 95 | int bind, bool rtnl_held, |
| 96 | struct netlink_ext_ack *extack); | ||
| 95 | int (*walk)(struct net *, struct sk_buff *, | 97 | int (*walk)(struct net *, struct sk_buff *, |
| 96 | struct netlink_callback *, int, | 98 | struct netlink_callback *, int, |
| 97 | const struct tc_action_ops *, | 99 | const struct tc_action_ops *, |
| @@ -99,6 +101,8 @@ struct tc_action_ops { | |||
| 99 | void (*stats_update)(struct tc_action *, u64, u32, u64); | 101 | void (*stats_update)(struct tc_action *, u64, u32, u64); |
| 100 | size_t (*get_fill_size)(const struct tc_action *act); | 102 | size_t (*get_fill_size)(const struct tc_action *act); |
| 101 | struct net_device *(*get_dev)(const struct tc_action *a); | 103 | struct net_device *(*get_dev)(const struct tc_action *a); |
| 104 | void (*put_dev)(struct net_device *dev); | ||
| 105 | int (*delete)(struct net *net, u32 index); | ||
| 102 | }; | 106 | }; |
| 103 | 107 | ||
| 104 | struct tc_action_net { | 108 | struct tc_action_net { |
| @@ -151,6 +155,10 @@ int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est, | |||
| 151 | int bind, bool cpustats); | 155 | int bind, bool cpustats); |
| 152 | void tcf_idr_insert(struct tc_action_net *tn, struct tc_action *a); | 156 | void tcf_idr_insert(struct tc_action_net *tn, struct tc_action *a); |
| 153 | 157 | ||
| 158 | void tcf_idr_cleanup(struct tc_action_net *tn, u32 index); | ||
| 159 | int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index, | ||
| 160 | struct tc_action **a, int bind); | ||
| 161 | int tcf_idr_delete_index(struct tc_action_net *tn, u32 index); | ||
| 154 | int __tcf_idr_release(struct tc_action *a, bool bind, bool strict); | 162 | int __tcf_idr_release(struct tc_action *a, bool bind, bool strict); |
| 155 | 163 | ||
| 156 | static inline int tcf_idr_release(struct tc_action *a, bool bind) | 164 | static inline int tcf_idr_release(struct tc_action *a, bool bind) |
| @@ -161,18 +169,20 @@ static inline int tcf_idr_release(struct tc_action *a, bool bind) | |||
| 161 | int tcf_register_action(struct tc_action_ops *a, struct pernet_operations *ops); | 169 | int tcf_register_action(struct tc_action_ops *a, struct pernet_operations *ops); |
| 162 | int tcf_unregister_action(struct tc_action_ops *a, | 170 | int tcf_unregister_action(struct tc_action_ops *a, |
| 163 | struct pernet_operations *ops); | 171 | struct pernet_operations *ops); |
| 164 | int tcf_action_destroy(struct list_head *actions, int bind); | 172 | int tcf_action_destroy(struct tc_action *actions[], int bind); |
| 165 | int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, | 173 | int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, |
| 166 | int nr_actions, struct tcf_result *res); | 174 | int nr_actions, struct tcf_result *res); |
| 167 | int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, | 175 | int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, |
| 168 | struct nlattr *est, char *name, int ovr, int bind, | 176 | struct nlattr *est, char *name, int ovr, int bind, |
| 169 | struct list_head *actions, size_t *attr_size, | 177 | struct tc_action *actions[], size_t *attr_size, |
| 170 | struct netlink_ext_ack *extack); | 178 | bool rtnl_held, struct netlink_ext_ack *extack); |
| 171 | struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, | 179 | struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, |
| 172 | struct nlattr *nla, struct nlattr *est, | 180 | struct nlattr *nla, struct nlattr *est, |
| 173 | char *name, int ovr, int bind, | 181 | char *name, int ovr, int bind, |
| 182 | bool rtnl_held, | ||
| 174 | struct netlink_ext_ack *extack); | 183 | struct netlink_ext_ack *extack); |
| 175 | int tcf_action_dump(struct sk_buff *skb, struct list_head *, int, int); | 184 | int tcf_action_dump(struct sk_buff *skb, struct tc_action *actions[], int bind, |
| 185 | int ref); | ||
| 176 | int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); | 186 | int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); |
| 177 | int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); | 187 | int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); |
| 178 | int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); | 188 | int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); |
| @@ -190,9 +200,6 @@ static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes, | |||
| 190 | #endif | 200 | #endif |
| 191 | } | 201 | } |
| 192 | 202 | ||
| 193 | typedef int tc_setup_cb_t(enum tc_setup_type type, | ||
| 194 | void *type_data, void *cb_priv); | ||
| 195 | |||
| 196 | #ifdef CONFIG_NET_CLS_ACT | 203 | #ifdef CONFIG_NET_CLS_ACT |
| 197 | int tc_setup_cb_egdev_register(const struct net_device *dev, | 204 | int tc_setup_cb_egdev_register(const struct net_device *dev, |
| 198 | tc_setup_cb_t *cb, void *cb_priv); | 205 | tc_setup_cb_t *cb, void *cb_priv); |
