xref: /linux/include/net/tc_act/tc_mirred.h (revision a85a970af265f156740977168b542234511b28a8)
11da177e4SLinus Torvalds #ifndef __NET_TC_MIR_H
21da177e4SLinus Torvalds #define __NET_TC_MIR_H
31da177e4SLinus Torvalds 
41da177e4SLinus Torvalds #include <net/act_api.h>
5229d2850SSridhar Samudrala #include <linux/tc_act/tc_mirred.h>
61da177e4SLinus Torvalds 
7e9ce1cd3SDavid S. Miller struct tcf_mirred {
8e9ce1cd3SDavid S. Miller 	struct tcf_common	common;
9e9ce1cd3SDavid S. Miller 	int			tcfm_eaction;
10e9ce1cd3SDavid S. Miller 	int			tcfm_ifindex;
11e9ce1cd3SDavid S. Miller 	int			tcfm_ok_push;
122ee22a90SEric Dumazet 	struct net_device __rcu	*tcfm_dev;
133b87956eSstephen hemminger 	struct list_head	tcfm_list;
141da177e4SLinus Torvalds };
15*a85a970aSWANG Cong #define to_mirred(a) ((struct tcf_mirred *)a)
161da177e4SLinus Torvalds 
17229d2850SSridhar Samudrala static inline bool is_tcf_mirred_redirect(const struct tc_action *a)
18229d2850SSridhar Samudrala {
19229d2850SSridhar Samudrala #ifdef CONFIG_NET_CLS_ACT
20229d2850SSridhar Samudrala 	if (a->ops && a->ops->type == TCA_ACT_MIRRED)
21229d2850SSridhar Samudrala 		return to_mirred(a)->tcfm_eaction == TCA_EGRESS_REDIR;
22229d2850SSridhar Samudrala #endif
23229d2850SSridhar Samudrala 	return false;
24229d2850SSridhar Samudrala }
25229d2850SSridhar Samudrala 
2656a20680SYotam Gigi static inline bool is_tcf_mirred_mirror(const struct tc_action *a)
2756a20680SYotam Gigi {
2856a20680SYotam Gigi #ifdef CONFIG_NET_CLS_ACT
2956a20680SYotam Gigi 	if (a->ops && a->ops->type == TCA_ACT_MIRRED)
3056a20680SYotam Gigi 		return to_mirred(a)->tcfm_eaction == TCA_EGRESS_MIRROR;
3156a20680SYotam Gigi #endif
3256a20680SYotam Gigi 	return false;
3356a20680SYotam Gigi }
3456a20680SYotam Gigi 
35229d2850SSridhar Samudrala static inline int tcf_mirred_ifindex(const struct tc_action *a)
36229d2850SSridhar Samudrala {
37229d2850SSridhar Samudrala 	return to_mirred(a)->tcfm_ifindex;
38229d2850SSridhar Samudrala }
39229d2850SSridhar Samudrala 
40e9ce1cd3SDavid S. Miller #endif /* __NET_TC_MIR_H */
41