Commit 00175aec authored by Amir Vadai's avatar Amir Vadai Committed by David S. Miller

net/sched: Macro instead of CONFIG_NET_CLS_ACT ifdef

Introduce the macros tc_no_actions and tc_for_each_action to make code
clearer.
Extracted struct tc_action out of the ifdef to make calls to
is_tcf_gact_shot() and similar functions valid, even when it is a nop.
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Acked-by: default avatarJohn Fastabend <john.r.fastabend@intel.com>
Suggested-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarAmir Vadai <amir@vadai.me>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8de2d793
...@@ -78,11 +78,6 @@ static inline void tcf_lastuse_update(struct tcf_t *tm) ...@@ -78,11 +78,6 @@ static inline void tcf_lastuse_update(struct tcf_t *tm)
tm->lastuse = now; tm->lastuse = now;
} }
#ifdef CONFIG_NET_CLS_ACT
#define ACT_P_CREATED 1
#define ACT_P_DELETED 1
struct tc_action { struct tc_action {
void *priv; void *priv;
const struct tc_action_ops *ops; const struct tc_action_ops *ops;
...@@ -92,6 +87,11 @@ struct tc_action { ...@@ -92,6 +87,11 @@ struct tc_action {
struct tcf_hashinfo *hinfo; struct tcf_hashinfo *hinfo;
}; };
#ifdef CONFIG_NET_CLS_ACT
#define ACT_P_CREATED 1
#define ACT_P_DELETED 1
struct tc_action_ops { struct tc_action_ops {
struct list_head head; struct list_head head;
char kind[IFNAMSIZ]; char kind[IFNAMSIZ];
...@@ -171,5 +171,16 @@ int tcf_action_dump(struct sk_buff *skb, struct list_head *, int, int); ...@@ -171,5 +171,16 @@ int tcf_action_dump(struct sk_buff *skb, struct list_head *, int, int);
int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);
#define tc_no_actions(_exts) \
(list_empty(&(_exts)->actions))
#define tc_for_each_action(_a, _exts) \
list_for_each_entry(a, &(_exts)->actions, list)
#else /* CONFIG_NET_CLS_ACT */
#define tc_no_actions(_exts) true
#define tc_for_each_action(_a, _exts) while (0)
#endif /* CONFIG_NET_CLS_ACT */ #endif /* CONFIG_NET_CLS_ACT */
#endif #endif
...@@ -16,9 +16,9 @@ struct tcf_gact { ...@@ -16,9 +16,9 @@ struct tcf_gact {
#define to_gact(a) \ #define to_gact(a) \
container_of(a->priv, struct tcf_gact, common) container_of(a->priv, struct tcf_gact, common)
#ifdef CONFIG_NET_CLS_ACT
static inline bool is_tcf_gact_shot(const struct tc_action *a) static inline bool is_tcf_gact_shot(const struct tc_action *a)
{ {
#ifdef CONFIG_NET_CLS_ACT
struct tcf_gact *gact; struct tcf_gact *gact;
if (a->ops && a->ops->type != TCA_ACT_GACT) if (a->ops && a->ops->type != TCA_ACT_GACT)
...@@ -28,7 +28,7 @@ static inline bool is_tcf_gact_shot(const struct tc_action *a) ...@@ -28,7 +28,7 @@ static inline bool is_tcf_gact_shot(const struct tc_action *a)
if (gact->tcf_action == TC_ACT_SHOT) if (gact->tcf_action == TC_ACT_SHOT)
return true; return true;
#endif
return false; return false;
} }
#endif
#endif /* __NET_TC_GACT_H */ #endif /* __NET_TC_GACT_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment