Skip to content

Commit 00175ae

Browse files
amirvdavem330
authored andcommitted
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 <[email protected]> Acked-by: John Fastabend <[email protected]> Suggested-by: Jiri Pirko <[email protected]> Signed-off-by: Amir Vadai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8de2d79 commit 00175ae

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

include/net/act_api.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ static inline void tcf_lastuse_update(struct tcf_t *tm)
7878
tm->lastuse = now;
7979
}
8080

81-
#ifdef CONFIG_NET_CLS_ACT
82-
83-
#define ACT_P_CREATED 1
84-
#define ACT_P_DELETED 1
85-
8681
struct tc_action {
8782
void *priv;
8883
const struct tc_action_ops *ops;
@@ -92,6 +87,11 @@ struct tc_action {
9287
struct tcf_hashinfo *hinfo;
9388
};
9489

90+
#ifdef CONFIG_NET_CLS_ACT
91+
92+
#define ACT_P_CREATED 1
93+
#define ACT_P_DELETED 1
94+
9595
struct tc_action_ops {
9696
struct list_head head;
9797
char kind[IFNAMSIZ];
@@ -171,5 +171,16 @@ int tcf_action_dump(struct sk_buff *skb, struct list_head *, int, int);
171171
int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
172172
int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
173173
int 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+
174185
#endif /* CONFIG_NET_CLS_ACT */
175186
#endif

include/net/tc_act/tc_gact.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ struct tcf_gact {
1616
#define to_gact(a) \
1717
container_of(a->priv, struct tcf_gact, common)
1818

19-
#ifdef CONFIG_NET_CLS_ACT
2019
static inline bool is_tcf_gact_shot(const struct tc_action *a)
2120
{
21+
#ifdef CONFIG_NET_CLS_ACT
2222
struct tcf_gact *gact;
2323

2424
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)
2828
if (gact->tcf_action == TC_ACT_SHOT)
2929
return true;
3030

31+
#endif
3132
return false;
3233
}
33-
#endif
3434
#endif /* __NET_TC_GACT_H */

0 commit comments

Comments
 (0)