From: Ben Greear <greearb@candelatech.com>
To: Evgeniy Polyakov <zbr@ioremap.net>
Cc: Luca Deri <deri@ntop.org>,
Stephen Hemminger <shemminger@vyatta.com>,
Brad Doctor <brad.doctor@gmail.com>,
netdev@vger.kernel.org
Subject: Re: PF_RING: Include in main line kernel?
Date: Wed, 14 Oct 2009 14:27:45 -0700 [thread overview]
Message-ID: <4AD64251.50903@candelatech.com> (raw)
In-Reply-To: <20091014203640.GB32317@ioremap.net>
[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]
On 10/14/2009 01:36 PM, Evgeniy Polyakov wrote:
> On Wed, Oct 14, 2009 at 10:17:30PM +0200, Luca Deri (deri@ntop.org) wrote:
>> The reason why I decided to patch dev.c is because I wanted PF_RING to
>> decide whether the packet journey shall continue or not. In other
>> words with my solution PF_RING applications can decide whether the
>> received packets will also be delivered to upper layers (and to other
>> kernel network components). This configurable 'early packet drop'
>> allows the overall performance to be significantly increased as
>> received packets are not supposed to be delivered to upper layers;
>> this is a typical situations for many monitoring devices.
>
> This is a feature many projects implement themself indeed. What about
> creating special return value from the packet handler which will
> indicate that packet was already consumed and no further work should be
> done on it?
Maybe something similar to the attached patch?
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
[-- Attachment #2: patch0.patch --]
[-- Type: text/plain, Size: 2636 bytes --]
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 907d118..da78f0a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -78,6 +78,7 @@ struct wireless_dev;
#define NET_RX_CN_MOD 3 /* Storm on its way! */
#define NET_RX_CN_HIGH 4 /* The storm is here */
#define NET_RX_BAD 5 /* packet dropped due to kernel error */
+#define NET_RX_CONSUMED 6 /* pkt is consumed, stop rx logic here. */
/* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It
* indicates that the device will soon be dropping packets, or already drops
diff --git a/net/core/dev.c b/net/core/dev.c
index 0101178..d5024b9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2105,6 +2105,10 @@ static inline struct sk_buff *handle_bridge(struct sk_buff *skb,
if (*pt_prev) {
*ret = deliver_skb(skb, *pt_prev, orig_dev);
*pt_prev = NULL;
+ if (*ret == NET_RX_CONSUMED) {
+ kfree_skb(skb); /* we made a copy in deliver_skb */
+ return NULL;
+ }
}
return br_handle_frame_hook(port, skb);
@@ -2128,6 +2132,10 @@ static inline struct sk_buff *handle_macvlan(struct sk_buff *skb,
if (*pt_prev) {
*ret = deliver_skb(skb, *pt_prev, orig_dev);
*pt_prev = NULL;
+ if (*ret == NET_RX_CONSUMED) {
+ kfree_skb(skb); /* we made a copy in deliver_skb */
+ return NULL;
+ }
}
return macvlan_handle_frame_hook(skb);
}
@@ -2185,6 +2193,10 @@ static inline struct sk_buff *handle_ing(struct sk_buff *skb,
if (*pt_prev) {
*ret = deliver_skb(skb, *pt_prev, orig_dev);
*pt_prev = NULL;
+ if (*ret == NET_RX_CONSUMED) {
+ kfree_skb(skb); /* we made a copy in deliver_skb */
+ return NULL;
+ }
} else {
/* Huh? Why does turning on AF_PACKET affect this? */
skb->tc_verd = SET_TC_OK2MUNGE(skb->tc_verd);
@@ -2300,8 +2312,13 @@ int netif_receive_skb(struct sk_buff *skb)
list_for_each_entry_rcu(ptype, &ptype_all, list) {
if (ptype->dev == null_or_orig || ptype->dev == skb->dev ||
ptype->dev == orig_dev) {
- if (pt_prev)
+ if (pt_prev) {
ret = deliver_skb(skb, pt_prev, orig_dev);
+ if (ret == NET_RX_CONSUMED) {
+ kfree_skb(skb); /* we made a copy in deliver_skb */
+ goto out;
+ }
+ }
pt_prev = ptype;
}
}
@@ -2336,8 +2353,13 @@ ncls:
if (ptype->type == type &&
(ptype->dev == null_or_orig || ptype->dev == skb->dev ||
ptype->dev == orig_dev)) {
- if (pt_prev)
+ if (pt_prev) {
ret = deliver_skb(skb, pt_prev, orig_dev);
+ if (ret == NET_RX_CONSUMED) {
+ kfree_skb(skb); /* we made a copy in deliver_skb */
+ goto out;
+ }
+ }
pt_prev = ptype;
}
}
next prev parent reply other threads:[~2009-10-14 21:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-14 14:33 PF_RING: Include in main line kernel? Brad Doctor
2009-10-14 16:01 ` Stephen Hemminger
2009-10-14 17:02 ` Brad Doctor
2009-10-14 19:33 ` Stephen Hemminger
2009-10-14 20:17 ` Luca Deri
2009-10-14 20:27 ` David Miller
2009-10-15 0:25 ` Eric Dumazet
2009-10-14 20:36 ` Evgeniy Polyakov
2009-10-14 21:27 ` Ben Greear [this message]
2009-10-14 21:34 ` Luca Deri
2009-10-14 21:49 ` David Miller
2009-10-14 23:29 ` Ben Greear
2009-10-15 7:02 ` Evgeniy Polyakov
2009-10-15 7:22 ` David Miller
2009-10-15 16:33 ` Ben Greear
2009-10-18 12:45 ` Harald Welte
2009-10-18 12:43 ` Harald Welte
2009-10-18 14:18 ` Evgeniy Polyakov
2009-10-14 16:46 ` Jarek Poplawski
2009-10-14 17:02 ` Brad Doctor
2009-10-14 17:18 ` Jarek Poplawski
2009-10-18 12:47 ` [OT] ntop / GPL (was Re: PF_RING: Include in main line kernel?) Harald Welte
2009-10-19 5:55 ` Jarek Poplawski
2009-10-19 7:12 ` Jarek Poplawski
2009-10-14 18:19 ` PF_RING: Include in main line kernel? Brent Cook
2009-10-14 19:54 ` Luca Deri
2009-10-14 20:15 ` David Miller
2009-10-14 20:26 ` Luca Deri
2009-10-14 20:29 ` David Miller
2009-10-14 20:34 ` Luca Deri
2009-10-14 20:50 ` Mark Smith
2009-10-18 12:56 ` Harald Welte
2009-10-18 12:50 ` Harald Welte
2009-10-18 14:50 ` Evgeniy Polyakov
2009-10-15 7:35 ` Rémi Denis-Courmont
2009-10-18 12:38 ` Harald Welte
2009-10-18 17:37 ` Luca Deri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AD64251.50903@candelatech.com \
--to=greearb@candelatech.com \
--cc=brad.doctor@gmail.com \
--cc=deri@ntop.org \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
--cc=zbr@ioremap.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.