tc_mirred.h 1.5 KB

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