blob: a2e9cbca5c9edbb770af873f6d885602e1ccf86a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __NET_TC_MIR_H
3#define __NET_TC_MIR_H
4
5#include <net/act_api.h>
Sridhar Samudrala229d2852016-05-02 03:33:42 -07006#include <linux/tc_act/tc_mirred.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
David S. Millere9ce1cd2006-08-21 23:54:55 -07008struct tcf_mirred {
WANG Congec0595c2016-07-25 16:09:42 -07009 struct tc_action common;
David S. Millere9ce1cd2006-08-21 23:54:55 -070010 int tcfm_eaction;
Shmulik Ladkani16577922016-10-13 09:06:41 +030011 bool tcfm_mac_header_xmit;
Eric Dumazet2ee22a92015-07-06 05:18:09 -070012 struct net_device __rcu *tcfm_dev;
stephen hemminger3b879562010-07-22 18:45:04 +000013 struct list_head tcfm_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014};
WANG Conga85a9702016-07-25 16:09:41 -070015#define to_mirred(a) ((struct tcf_mirred *)a)
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Shmulik Ladkani5724b8b2016-10-13 09:06:43 +030017static inline bool is_tcf_mirred_egress_redirect(const struct tc_action *a)
Sridhar Samudrala229d2852016-05-02 03:33:42 -070018{
19#ifdef CONFIG_NET_CLS_ACT
20 if (a->ops && a->ops->type == TCA_ACT_MIRRED)
21 return to_mirred(a)->tcfm_eaction == TCA_EGRESS_REDIR;
22#endif
23 return false;
24}
25
Shmulik Ladkani5724b8b2016-10-13 09:06:43 +030026static inline bool is_tcf_mirred_egress_mirror(const struct tc_action *a)
Yotam Gigi56a20682016-07-21 12:03:16 +020027{
28#ifdef CONFIG_NET_CLS_ACT
29 if (a->ops && a->ops->type == TCA_ACT_MIRRED)
30 return to_mirred(a)->tcfm_eaction == TCA_EGRESS_MIRROR;
31#endif
32 return false;
33}
34
Cong Wang9f8a7392017-12-05 16:17:26 -080035static inline struct net_device *tcf_mirred_dev(const struct tc_action *a)
Sridhar Samudrala229d2852016-05-02 03:33:42 -070036{
Cong Wang9f8a7392017-12-05 16:17:26 -080037 return rtnl_dereference(to_mirred(a)->tcfm_dev);
Sridhar Samudrala229d2852016-05-02 03:33:42 -070038}
39
David S. Millere9ce1cd2006-08-21 23:54:55 -070040#endif /* __NET_TC_MIR_H */