tc_mirred.h 983 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NET_TC_MIR_H
  3. #define __NET_TC_MIR_H
  4. #include <net/act_api.h>
  5. #include <linux/tc_act/tc_mirred.h>
  6. struct tcf_mirred {
  7. struct tc_action common;
  8. int tcfm_eaction;
  9. bool tcfm_mac_header_xmit;
  10. struct net_device __rcu *tcfm_dev;
  11. struct list_head tcfm_list;
  12. };
  13. #define to_mirred(a) ((struct tcf_mirred *)a)
  14. static inline bool is_tcf_mirred_egress_redirect(const struct tc_action *a)
  15. {
  16. #ifdef CONFIG_NET_CLS_ACT
  17. if (a->ops && a->ops->type == TCA_ACT_MIRRED)
  18. return to_mirred(a)->tcfm_eaction == TCA_EGRESS_REDIR;
  19. #endif
  20. return false;
  21. }
  22. static inline bool is_tcf_mirred_egress_mirror(const struct tc_action *a)
  23. {
  24. #ifdef CONFIG_NET_CLS_ACT
  25. if (a->ops && a->ops->type == TCA_ACT_MIRRED)
  26. return to_mirred(a)->tcfm_eaction == TCA_EGRESS_MIRROR;
  27. #endif
  28. return false;
  29. }
  30. static inline struct net_device *tcf_mirred_dev(const struct tc_action *a)
  31. {
  32. return rtnl_dereference(to_mirred(a)->tcfm_dev);
  33. }
  34. #endif /* __NET_TC_MIR_H */