netpoll: handle vlan tags in netpoll tx and rx path

Without this patch, I can't get netconsole logs remotely over
vlan. The reason is probably we don't handle vlan tags in either
netpoll tx or rx path.

I am not sure if I use these vlan functions correctly, at
least this patch works.

Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Amerigo Wang 2012-08-10 01:24:49 +00:00 committed by David S. Miller
parent 6eacf8ad8d
commit 689971b446
1 changed files with 15 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/if_vlan.h>
#include <net/tcp.h> #include <net/tcp.h>
#include <net/udp.h> #include <net/udp.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
@ -334,6 +335,14 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
tries > 0; --tries) { tries > 0; --tries) {
if (__netif_tx_trylock(txq)) { if (__netif_tx_trylock(txq)) {
if (!netif_xmit_stopped(txq)) { if (!netif_xmit_stopped(txq)) {
if (vlan_tx_tag_present(skb) &&
!(netif_skb_features(skb) & NETIF_F_HW_VLAN_TX)) {
skb = __vlan_put_tag(skb, vlan_tx_tag_get(skb));
if (unlikely(!skb))
break;
skb->vlan_tci = 0;
}
status = ops->ndo_start_xmit(skb, dev); status = ops->ndo_start_xmit(skb, dev);
if (status == NETDEV_TX_OK) if (status == NETDEV_TX_OK)
txq_trans_update(txq); txq_trans_update(txq);
@ -567,6 +576,12 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
return 1; return 1;
} }
if (skb->protocol == cpu_to_be16(ETH_P_8021Q)) {
skb = vlan_untag(skb);
if (unlikely(!skb))
goto out;
}
proto = ntohs(eth_hdr(skb)->h_proto); proto = ntohs(eth_hdr(skb)->h_proto);
if (proto != ETH_P_IP) if (proto != ETH_P_IP)
goto out; goto out;