aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Vadai <amir@vadai.me>2016-03-08 05:42:31 -0500
committerDavid S. Miller <davem@davemloft.net>2016-03-10 16:24:02 -0500
commit00175aec941e9c306d8a5ce930b2d91f7c04468c (patch)
treed269c99cb155b40765f5687154098063e72f56ae
parent8de2d793daf784f8f109565bcc023a6d198bad85 (diff)
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: Jiri Pirko <jiri@mellanox.com> Acked-by: John Fastabend <john.r.fastabend@intel.com> Suggested-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Amir Vadai <amir@vadai.me> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/act_api.h21
-rw-r--r--include/net/tc_act/tc_gact.h4
2 files changed, 18 insertions, 7 deletions
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 342be6c5ab5c..2a19fe111c78 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -78,11 +78,6 @@ static inline void tcf_lastuse_update(struct tcf_t *tm)
78 tm->lastuse = now; 78 tm->lastuse = now;
79} 79}
80 80
81#ifdef CONFIG_NET_CLS_ACT
82
83#define ACT_P_CREATED 1
84#define ACT_P_DELETED 1
85
86struct tc_action { 81struct tc_action {
87 void *priv; 82 void *priv;
88 const struct tc_action_ops *ops; 83 const struct tc_action_ops *ops;
@@ -92,6 +87,11 @@ struct tc_action {
92 struct tcf_hashinfo *hinfo; 87 struct tcf_hashinfo *hinfo;
93}; 88};
94 89
90#ifdef CONFIG_NET_CLS_ACT
91
92#define ACT_P_CREATED 1
93#define ACT_P_DELETED 1
94
95struct tc_action_ops { 95struct tc_action_ops {
96 struct list_head head; 96 struct list_head head;
97 char kind[IFNAMSIZ]; 97 char kind[IFNAMSIZ];
@@ -171,5 +171,16 @@ int tcf_action_dump(struct sk_buff *skb, struct list_head *, int, int);
171int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); 171int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
172int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); 172int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
173int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); 173int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);
174
175#define tc_no_actions(_exts) \
176 (list_empty(&(_exts)->actions))
177
178#define tc_for_each_action(_a, _exts) \
179 list_for_each_entry(a, &(_exts)->actions, list)
180#else /* CONFIG_NET_CLS_ACT */
181
182#define tc_no_actions(_exts) true
183#define tc_for_each_action(_a, _exts) while (0)
184
174#endif /* CONFIG_NET_CLS_ACT */ 185#endif /* CONFIG_NET_CLS_ACT */
175#endif 186#endif
diff --git a/include/net/tc_act/tc_gact.h b/include/net/tc_act/tc_gact.h
index 04a31830711b..93c520b83d10 100644
--- a/include/net/tc_act/tc_gact.h
+++ b/include/net/tc_act/tc_gact.h
@@ -16,9 +16,9 @@ struct tcf_gact {
16#define to_gact(a) \ 16#define to_gact(a) \
17 container_of(a->priv, struct tcf_gact, common) 17 container_of(a->priv, struct tcf_gact, common)
18 18
19#ifdef CONFIG_NET_CLS_ACT
20static inline bool is_tcf_gact_shot(const struct tc_action *a) 19static inline bool is_tcf_gact_shot(const struct tc_action *a)
21{ 20{
21#ifdef CONFIG_NET_CLS_ACT
22 struct tcf_gact *gact; 22 struct tcf_gact *gact;
23 23
24 if (a->ops && a->ops->type != TCA_ACT_GACT) 24 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 if (gact->tcf_action == TC_ACT_SHOT) 28 if (gact->tcf_action == TC_ACT_SHOT)
29 return true; 29 return true;
30 30
31#endif
31 return false; 32 return false;
32} 33}
33#endif
34#endif /* __NET_TC_GACT_H */ 34#endif /* __NET_TC_GACT_H */