From: Antonio Quartulli <antonio@meshcoding.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Antonio Quartulli <antonio@meshcoding.com>
Subject: [PATCH net] netpoll: fix rx_hook() interface by passing the skb
Date: Tue, 22 Oct 2013 10:48:35 +0200 [thread overview]
Message-ID: <1382431715-3128-1-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <20131022.025038.1046903740187748879.davem@davemloft.net>
Right now skb->data is passed to rx_hook() even if the skb
has not been linearised and without giving rx_hook() a way
to linearise it.
Change the rx_hook() interface and make it accept the skb
as argument. In this way users implementing rx_hook() can
perform all the needed operations to properly (and safely)
access the skb data.
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
---
include/linux/netpoll.h | 2 +-
net/core/netpoll.c | 10 ++++------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index f3c7c24..5352160 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -24,7 +24,7 @@ struct netpoll {
struct net_device *dev;
char dev_name[IFNAMSIZ];
const char *name;
- void (*rx_hook)(struct netpoll *, int, char *, int);
+ void (*rx_hook)(struct netpoll *np, struct sk_buff *skb, int offset);
union inet_addr local_ip, remote_ip;
bool ipv6;
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index fc75c9e..b415437 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -834,9 +834,8 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
if (np->local_port && np->local_port != ntohs(uh->dest))
continue;
- np->rx_hook(np, ntohs(uh->source),
- (char *)(uh+1),
- ulen - sizeof(struct udphdr));
+ np->rx_hook(np, skb,
+ (unsigned char *)(uh + 1) - skb->data);
hits++;
}
} else {
@@ -872,9 +871,8 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
if (np->local_port && np->local_port != ntohs(uh->dest))
continue;
- np->rx_hook(np, ntohs(uh->source),
- (char *)(uh+1),
- ulen - sizeof(struct udphdr));
+ np->rx_hook(np, skb,
+ (unsigned char *)(uh + 1) - skb->data);
hits++;
}
#endif
--
1.8.4
next prev parent reply other threads:[~2013-10-22 8:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-21 21:31 [PATCH net] netpoll: linearize skb before accessing its data Antonio Quartulli
2013-10-21 22:23 ` David Miller
2013-10-22 6:06 ` Antonio Quartulli
2013-10-22 6:25 ` David Miller
2013-10-22 6:37 ` Antonio Quartulli
2013-10-22 6:50 ` David Miller
2013-10-22 8:48 ` Antonio Quartulli [this message]
2013-10-22 9:09 ` [PATCH net] netpoll: fix rx_hook() interface by passing the skb David Laight
2013-10-22 10:11 ` Antonio Quartulli
2013-10-22 12:46 ` David Laight
2013-10-22 17:13 ` Antonio Quartulli
2013-10-22 19:40 ` David Miller
2013-10-23 8:33 ` David Laight
2013-10-23 10:28 ` Antonio Quartulli
2013-10-23 11:18 ` David Laight
2013-10-23 12:44 ` Antonio Quartulli
2013-10-23 20:16 ` David Miller
2013-10-23 21:36 ` [PATCHv2 " Antonio Quartulli
2013-10-24 8:43 ` David Laight
2013-10-24 12:01 ` Antonio Quartulli
2013-10-24 17:53 ` David Miller
2013-10-25 23:27 ` David Miller
2013-10-21 22:25 ` [PATCH net] netpoll: linearize skb before accessing its data Eric Dumazet
2013-10-21 22:33 ` David Miller
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=1382431715-3128-1-git-send-email-antonio@meshcoding.com \
--to=antonio@meshcoding.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).