aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2015-05-09 16:51:31 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-11 11:10:34 -0400
commitc9e99fd078ef7fdcd9ee4f5a4cfdbece319587af (patch)
treeb9103eeb2aa3151ce6af1097938a6f42cc9b17f7 /net
parent986ccfdbd90a292e8242c5d2647d8bb8565c38c3 (diff)
net: sched: consolidate handle_ing and ing_filter
Given quite some code has been removed from ing_filter(), we can just consolidate that function into handle_ing() and get rid of a few instructions at the same time. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 862875ec8f2f..8a757464bfa2 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3521,37 +3521,19 @@ EXPORT_SYMBOL_GPL(br_fdb_test_addr_hook);
3521#endif 3521#endif
3522 3522
3523#ifdef CONFIG_NET_CLS_ACT 3523#ifdef CONFIG_NET_CLS_ACT
3524/* TODO: Maybe we should just force sch_ingress to be compiled in
3525 * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions
3526 * a compare and 2 stores extra right now if we dont have it on
3527 * but have CONFIG_NET_CLS_ACT
3528 * NOTE: This doesn't stop any functionality; if you dont have
3529 * the ingress scheduler, you just can't add policies on ingress.
3530 *
3531 */
3532static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq)
3533{
3534 int result = TC_ACT_OK;
3535 struct Qdisc *q;
3536
3537 skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_INGRESS);
3538
3539 q = rcu_dereference(rxq->qdisc);
3540 if (q != &noop_qdisc) {
3541 if (likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state)))
3542 result = qdisc_enqueue_root(skb, q);
3543 }
3544
3545 return result;
3546}
3547
3548static inline struct sk_buff *handle_ing(struct sk_buff *skb, 3524static inline struct sk_buff *handle_ing(struct sk_buff *skb,
3549 struct packet_type **pt_prev, 3525 struct packet_type **pt_prev,
3550 int *ret, struct net_device *orig_dev) 3526 int *ret, struct net_device *orig_dev)
3551{ 3527{
3552 struct netdev_queue *rxq = rcu_dereference(skb->dev->ingress_queue); 3528 struct netdev_queue *rxq = rcu_dereference(skb->dev->ingress_queue);
3529 struct Qdisc *q;
3553 3530
3554 if (!rxq || rcu_access_pointer(rxq->qdisc) == &noop_qdisc) 3531 /* If there's at least one ingress present somewhere (so
3532 * we get here via enabled static key), remaining devices
3533 * that are not configured with an ingress qdisc will bail
3534 * out w/o the rcu_dereference().
3535 */
3536 if (!rxq || (q = rcu_dereference(rxq->qdisc)) == &noop_qdisc)
3555 return skb; 3537 return skb;
3556 3538
3557 if (*pt_prev) { 3539 if (*pt_prev) {
@@ -3559,11 +3541,15 @@ static inline struct sk_buff *handle_ing(struct sk_buff *skb,
3559 *pt_prev = NULL; 3541 *pt_prev = NULL;
3560 } 3542 }
3561 3543
3562 switch (ing_filter(skb, rxq)) { 3544 skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_INGRESS);
3563 case TC_ACT_SHOT: 3545
3564 case TC_ACT_STOLEN: 3546 if (likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) {
3565 kfree_skb(skb); 3547 switch (qdisc_enqueue_root(skb, q)) {
3566 return NULL; 3548 case TC_ACT_SHOT:
3549 case TC_ACT_STOLEN:
3550 kfree_skb(skb);
3551 return NULL;
3552 }
3567 } 3553 }
3568 3554
3569 return skb; 3555 return skb;