From 02313a8a30c82475a1fbf1155fab3bbb331e413a Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Thu, 12 May 2011 18:14:51 +0200 Subject: [PATCH] move kfree_skb into fb_dummy --- src/fb_dummy.c | 7 +++++++ src/xt_engine.c | 11 +++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/fb_dummy.c b/src/fb_dummy.c index 0d92551..8575262 100644 --- a/src/fb_dummy.c +++ b/src/fb_dummy.c @@ -33,6 +33,7 @@ static struct fblock_ops fb_dummy_ops; static int fb_dummy_netrx(struct fblock *fb, struct sk_buff *skb, enum path_type *dir) { + int drop = 0; unsigned int seq; struct fb_dummy_priv __percpu *fb_priv_cpu; @@ -44,7 +45,13 @@ static int fb_dummy_netrx(struct fblock *fb, struct sk_buff *skb, do { seq = read_seqbegin(&fb_priv_cpu->lock); write_next_idp_to_skb(skb, fb->idp, fb_priv_cpu->port[*dir]); + if (fb_priv_cpu->port[*dir] == IDP_UNKNOWN) + drop = 1; } while (read_seqretry(&fb_priv_cpu->lock, seq)); + if (drop) { + kfree_skb(skb); + return PPE_DROPPED; + } return PPE_SUCCESS; } diff --git a/src/xt_engine.c b/src/xt_engine.c index f89f5e2..4447bbc 100644 --- a/src/xt_engine.c +++ b/src/xt_engine.c @@ -66,6 +66,7 @@ static inline int process_packet(struct sk_buff *skb, enum path_type dir) int ret = PPE_DROPPED; idp_t cont; struct fblock *fb; + prefetch(skb->cb); while ((cont = read_next_idp_from_skb(skb))) { fb = __search_fblock(cont); if (unlikely(!fb)) @@ -75,6 +76,7 @@ static inline int process_packet(struct sk_buff *skb, enum path_type dir) put_fblock(fb); if (ret == PPE_DROPPED) return PPE_DROPPED; + prefetch(skb->cb); } return ret; } @@ -104,16 +106,15 @@ static int engine_thread(void *arg) } ppeq = next_filled_ppe_queue(ppeq); - if (unlikely((skb = skb_dequeue(&ppeq->queue)) == NULL)) - continue; - if (skb_is_time_marked_first(skb)) + skb = skb_dequeue(&ppeq->queue); + if (unlikely(skb_is_time_marked_first(skb))) ppe->timef = ktime_get(); if (need_lock) rcu_read_lock(); ret = process_packet(skb, ppeq->type); if (need_lock) rcu_read_unlock(); - if (skb_is_time_marked_last(skb)) + if (unlikely(skb_is_time_marked_last(skb))) ppe->timel = ktime_get(); u64_stats_update_begin(&ppeq->stats.syncp); @@ -124,8 +125,6 @@ static int engine_thread(void *arg) else if (unlikely(ret == PPE_ERROR)) ppeq->stats.errors++; u64_stats_update_end(&ppeq->stats.syncp); - - kfree_skb(skb); } printk(KERN_INFO "[lana] Packet Processing Engine stopped " -- 2.11.4.GIT