tc_mirred.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. netdevice_tracker tcfm_dev_tracker;
  12. struct list_head tcfm_list;
  13. };
  14. #define to_mirred(a) ((struct tcf_mirred *)a)
  15. static inline bool is_tcf_mirred_egress_redirect(const struct tc_action *a)
  16. {
  17. #ifdef CONFIG_NET_CLS_ACT
  18. if (a->ops && a->ops->id == TCA_ID_MIRRED)
  19. return to_mirred(a)->tcfm_eaction == TCA_EGRESS_REDIR;
  20. #endif
  21. return false;
  22. }
  23. static inline bool is_tcf_mirred_egress_mirror(const struct tc_action *a)
  24. {
  25. #ifdef CONFIG_NET_CLS_ACT
  26. if (a->ops && a->ops->id == TCA_ID_MIRRED)
  27. return to_mirred(a)->tcfm_eaction == TCA_EGRESS_MIRROR;
  28. #endif
  29. return false;
  30. }
  31. static inline bool is_tcf_mirred_ingress_redirect(const struct tc_action *a)
  32. {
  33. #ifdef CONFIG_NET_CLS_ACT
  34. if (a->ops && a->ops->id == TCA_ID_MIRRED)
  35. return to_mirred(a)->tcfm_eaction == TCA_INGRESS_REDIR;
  36. #endif
  37. return false;
  38. }
  39. static inline bool is_tcf_mirred_ingress_mirror(const struct tc_action *a)
  40. {
  41. #ifdef CONFIG_NET_CLS_ACT
  42. if (a->ops && a->ops->id == TCA_ID_MIRRED)
  43. return to_mirred(a)->tcfm_eaction == TCA_INGRESS_MIRROR;
  44. #endif
  45. return false;
  46. }
  47. static inline struct net_device *tcf_mirred_dev(const struct tc_action *a)
  48. {
  49. return rtnl_dereference(to_mirred(a)->tcfm_dev);
  50. }
  51. #endif /* __NET_TC_MIR_H */