Skip to content

Commit

Permalink
netpoll: Add drop checks to all entry points
Browse files Browse the repository at this point in the history
The netpoll entry checks are required to ensure that we don't
receive normal packets when invoked via netpoll.  Unfortunately
it only ever worked for the netif_receive_skb/netif_rx entry
points.  The VLAN (and subsequently GRO) entry point didn't
have the check and therefore can trigger all sorts of weird
problems.

This patch adds the netpoll check to all entry points.

I'm still uneasy with receiving at all under netpoll (which
apparently is only used by the out-of-tree kdump code).  The
reason is it is perfectly legal to receive all data including
headers into highmem if netpoll is off, but if you try to do
that with netpoll on and someone gets a printk in an IRQ handler                                             
you're going to get a nice BUG_ON.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Mar 1, 2009
1 parent 18963ca commit 4ead443
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions net/8021q/vlan_core.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/if_vlan.h>
#include <linux/netpoll.h>
#include "vlan.h"

/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
u16 vlan_tci, int polling)
{
if (netpoll_rx(skb))
return NET_RX_DROP;

if (skb_bond_should_drop(skb))
goto drop;

Expand Down Expand Up @@ -100,6 +104,9 @@ int vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
{
int err = NET_RX_SUCCESS;

if (netpoll_receive_skb(skb))
return NET_RX_DROP;

switch (vlan_gro_common(napi, grp, vlan_tci, skb)) {
case -1:
return netif_receive_skb(skb);
Expand All @@ -126,6 +133,9 @@ int vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
if (!skb)
goto out;

if (netpoll_receive_skb(skb))
goto out;

err = NET_RX_SUCCESS;

switch (vlan_gro_common(napi, grp, vlan_tci, skb)) {
Expand Down
6 changes: 6 additions & 0 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2488,6 +2488,9 @@ static int __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)

int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
{
if (netpoll_receive_skb(skb))
return NET_RX_DROP;

switch (__napi_gro_receive(napi, skb)) {
case -1:
return netif_receive_skb(skb);
Expand Down Expand Up @@ -2558,6 +2561,9 @@ int napi_gro_frags(struct napi_struct *napi, struct napi_gro_fraginfo *info)
if (!skb)
goto out;

if (netpoll_receive_skb(skb))
goto out;

err = NET_RX_SUCCESS;

switch (__napi_gro_receive(napi, skb)) {
Expand Down

0 comments on commit 4ead443

Please sign in to comment.