diff options
| -rw-r--r-- | include/linux/if_packet.h | 1 | ||||
| -rw-r--r-- | net/packet/af_packet.c | 15 |
2 files changed, 13 insertions, 3 deletions
diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h index 72bfa5a034dd..6d66ce1791a9 100644 --- a/include/linux/if_packet.h +++ b/include/linux/if_packet.h | |||
| @@ -70,6 +70,7 @@ struct tpacket_auxdata { | |||
| 70 | #define TP_STATUS_COPY 0x2 | 70 | #define TP_STATUS_COPY 0x2 |
| 71 | #define TP_STATUS_LOSING 0x4 | 71 | #define TP_STATUS_LOSING 0x4 |
| 72 | #define TP_STATUS_CSUMNOTREADY 0x8 | 72 | #define TP_STATUS_CSUMNOTREADY 0x8 |
| 73 | #define TP_STATUS_VLAN_VALID 0x10 /* auxdata has valid tp_vlan_tci */ | ||
| 73 | 74 | ||
| 74 | /* Tx ring - header status */ | 75 | /* Tx ring - header status */ |
| 75 | #define TP_STATUS_AVAILABLE 0x0 | 76 | #define TP_STATUS_AVAILABLE 0x0 |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 925f715686a5..ba248d93399a 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
| @@ -798,7 +798,12 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 798 | getnstimeofday(&ts); | 798 | getnstimeofday(&ts); |
| 799 | h.h2->tp_sec = ts.tv_sec; | 799 | h.h2->tp_sec = ts.tv_sec; |
| 800 | h.h2->tp_nsec = ts.tv_nsec; | 800 | h.h2->tp_nsec = ts.tv_nsec; |
| 801 | h.h2->tp_vlan_tci = vlan_tx_tag_get(skb); | 801 | if (vlan_tx_tag_present(skb)) { |
| 802 | h.h2->tp_vlan_tci = vlan_tx_tag_get(skb); | ||
| 803 | status |= TP_STATUS_VLAN_VALID; | ||
| 804 | } else { | ||
| 805 | h.h2->tp_vlan_tci = 0; | ||
| 806 | } | ||
| 802 | hdrlen = sizeof(*h.h2); | 807 | hdrlen = sizeof(*h.h2); |
| 803 | break; | 808 | break; |
| 804 | default: | 809 | default: |
| @@ -1725,8 +1730,12 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 1725 | aux.tp_snaplen = skb->len; | 1730 | aux.tp_snaplen = skb->len; |
| 1726 | aux.tp_mac = 0; | 1731 | aux.tp_mac = 0; |
| 1727 | aux.tp_net = skb_network_offset(skb); | 1732 | aux.tp_net = skb_network_offset(skb); |
| 1728 | aux.tp_vlan_tci = vlan_tx_tag_get(skb); | 1733 | if (vlan_tx_tag_present(skb)) { |
| 1729 | 1734 | aux.tp_vlan_tci = vlan_tx_tag_get(skb); | |
| 1735 | aux.tp_status |= TP_STATUS_VLAN_VALID; | ||
| 1736 | } else { | ||
| 1737 | aux.tp_vlan_tci = 0; | ||
| 1738 | } | ||
| 1730 | put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux); | 1739 | put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux); |
| 1731 | } | 1740 | } |
| 1732 | 1741 | ||
