diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2016-03-15 20:42:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-03-18 19:38:46 -0400 |
commit | 808c1b697c3c4dd2a7132882424c390b0d0acfb9 (patch) | |
tree | c43c9d8bd383b1c6063110c26c1ff495a37b5827 | |
parent | 09c37a2c5bbc28b5fbc07a01db4bccdbd0a5d8a2 (diff) |
bpf, dst: add and use dst_tclassid helper
We can just add a small helper dst_tclassid() for retrieving the
dst->tclassid value. It makes the code a bit better in that we can
get rid of the ifdef from filter.c by moving this into the header.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/dst.h | 12 | ||||
-rw-r--r-- | net/core/filter.c | 9 |
2 files changed, 13 insertions, 8 deletions
diff --git a/include/net/dst.h b/include/net/dst.h index c7329dcd90cc..5c98443c1c9e 100644 --- a/include/net/dst.h +++ b/include/net/dst.h | |||
@@ -398,6 +398,18 @@ static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev, | |||
398 | __skb_tunnel_rx(skb, dev, net); | 398 | __skb_tunnel_rx(skb, dev, net); |
399 | } | 399 | } |
400 | 400 | ||
401 | static inline u32 dst_tclassid(const struct sk_buff *skb) | ||
402 | { | ||
403 | #ifdef CONFIG_IP_ROUTE_CLASSID | ||
404 | const struct dst_entry *dst; | ||
405 | |||
406 | dst = skb_dst(skb); | ||
407 | if (dst) | ||
408 | return dst->tclassid; | ||
409 | #endif | ||
410 | return 0; | ||
411 | } | ||
412 | |||
401 | int dst_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb); | 413 | int dst_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb); |
402 | static inline int dst_discard(struct sk_buff *skb) | 414 | static inline int dst_discard(struct sk_buff *skb) |
403 | { | 415 | { |
diff --git a/net/core/filter.c b/net/core/filter.c index 69c7b2fecf44..4c35d8325c34 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -1682,14 +1682,7 @@ static const struct bpf_func_proto bpf_get_cgroup_classid_proto = { | |||
1682 | 1682 | ||
1683 | static u64 bpf_get_route_realm(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) | 1683 | static u64 bpf_get_route_realm(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) |
1684 | { | 1684 | { |
1685 | #ifdef CONFIG_IP_ROUTE_CLASSID | 1685 | return dst_tclassid((struct sk_buff *) (unsigned long) r1); |
1686 | const struct dst_entry *dst; | ||
1687 | |||
1688 | dst = skb_dst((struct sk_buff *) (unsigned long) r1); | ||
1689 | if (dst) | ||
1690 | return dst->tclassid; | ||
1691 | #endif | ||
1692 | return 0; | ||
1693 | } | 1686 | } |
1694 | 1687 | ||
1695 | static const struct bpf_func_proto bpf_get_route_realm_proto = { | 1688 | static const struct bpf_func_proto bpf_get_route_realm_proto = { |