Skip to content

Commit fdc5432

Browse files
borkmanndavem330
authored andcommitted
net, sched: add skb_at_tc_ingress helper
Add a skb_at_tc_ingress() as this will be needed elsewhere as well and can hide the ugly ifdef. Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4156afa commit fdc5432

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

include/net/sch_generic.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,15 @@ bool tcf_destroy(struct tcf_proto *tp, bool force);
407407
void tcf_destroy_chain(struct tcf_proto __rcu **fl);
408408
int skb_do_redirect(struct sk_buff *);
409409

410+
static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
411+
{
412+
#ifdef CONFIG_NET_CLS_ACT
413+
return G_TC_AT(skb->tc_verd) & AT_INGRESS;
414+
#else
415+
return false;
416+
#endif
417+
}
418+
410419
/* Reset all TX qdiscs greater then index of a device. */
411420
static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
412421
{

net/sched/cls_bpf.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,8 @@ static int cls_bpf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
7979
struct tcf_result *res)
8080
{
8181
struct cls_bpf_head *head = rcu_dereference_bh(tp->root);
82+
bool at_ingress = skb_at_tc_ingress(skb);
8283
struct cls_bpf_prog *prog;
83-
#ifdef CONFIG_NET_CLS_ACT
84-
bool at_ingress = G_TC_AT(skb->tc_verd) & AT_INGRESS;
85-
#else
86-
bool at_ingress = false;
87-
#endif
8884
int ret = -1;
8985

9086
if (unlikely(!skb_mac_header_was_set(skb)))

0 commit comments

Comments
 (0)