0220-net-sched-add-skb_at_tc_ingress-helper.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From 20f13356555bf192a95e2ea77a01746d754e37be Mon Sep 17 00:00:00 2001
  2. From: Daniel Borkmann <daniel@iogearbox.net>
  3. Date: Thu, 7 Jan 2016 15:50:22 +0100
  4. Subject: [PATCH 220/381] net, sched: add skb_at_tc_ingress helper
  5. Add a skb_at_tc_ingress() as this will be needed elsewhere as well and
  6. can hide the ugly ifdef.
  7. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  8. Acked-by: Alexei Starovoitov <ast@kernel.org>
  9. Signed-off-by: David S. Miller <davem@davemloft.net>
  10. ---
  11. include/net/sch_generic.h | 9 +++++++++
  12. net/sched/cls_bpf.c | 6 +-----
  13. 2 files changed, 10 insertions(+), 5 deletions(-)
  14. --- a/include/net/sch_generic.h
  15. +++ b/include/net/sch_generic.h
  16. @@ -409,6 +409,15 @@ bool tcf_destroy(struct tcf_proto *tp, b
  17. void tcf_destroy_chain(struct tcf_proto __rcu **fl);
  18. int skb_do_redirect(struct sk_buff *);
  19. +static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
  20. +{
  21. +#ifdef CONFIG_NET_CLS_ACT
  22. + return G_TC_AT(skb->tc_verd) & AT_INGRESS;
  23. +#else
  24. + return false;
  25. +#endif
  26. +}
  27. +
  28. /* Reset all TX qdiscs greater then index of a device. */
  29. static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
  30. {
  31. --- a/net/sched/cls_bpf.c
  32. +++ b/net/sched/cls_bpf.c
  33. @@ -79,12 +79,8 @@ static int cls_bpf_classify(struct sk_bu
  34. struct tcf_result *res)
  35. {
  36. struct cls_bpf_head *head = rcu_dereference_bh(tp->root);
  37. + bool at_ingress = skb_at_tc_ingress(skb);
  38. struct cls_bpf_prog *prog;
  39. -#ifdef CONFIG_NET_CLS_ACT
  40. - bool at_ingress = G_TC_AT(skb->tc_verd) & AT_INGRESS;
  41. -#else
  42. - bool at_ingress = false;
  43. -#endif
  44. int ret = -1;
  45. if (unlikely(!skb_mac_header_was_set(skb)))