aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/vcan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/can/vcan.c')
-rw-r--r--drivers/net/can/vcan.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
index 80ac56313981..a30b8f480f61 100644
--- a/drivers/net/can/vcan.c
+++ b/drivers/net/can/vcan.c
@@ -47,6 +47,8 @@
47#include <linux/if_arp.h> 47#include <linux/if_arp.h>
48#include <linux/if_ether.h> 48#include <linux/if_ether.h>
49#include <linux/can.h> 49#include <linux/can.h>
50#include <linux/can/dev.h>
51#include <linux/slab.h>
50#include <net/rtnetlink.h> 52#include <net/rtnetlink.h>
51 53
52static __initdata const char banner[] = 54static __initdata const char banner[] =
@@ -70,10 +72,11 @@ MODULE_PARM_DESC(echo, "Echo sent frames (for testing). Default: 0 (Off)");
70 72
71static void vcan_rx(struct sk_buff *skb, struct net_device *dev) 73static void vcan_rx(struct sk_buff *skb, struct net_device *dev)
72{ 74{
75 struct can_frame *cf = (struct can_frame *)skb->data;
73 struct net_device_stats *stats = &dev->stats; 76 struct net_device_stats *stats = &dev->stats;
74 77
75 stats->rx_packets++; 78 stats->rx_packets++;
76 stats->rx_bytes += skb->len; 79 stats->rx_bytes += cf->can_dlc;
77 80
78 skb->protocol = htons(ETH_P_CAN); 81 skb->protocol = htons(ETH_P_CAN);
79 skb->pkt_type = PACKET_BROADCAST; 82 skb->pkt_type = PACKET_BROADCAST;
@@ -85,11 +88,15 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev)
85 88
86static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev) 89static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev)
87{ 90{
91 struct can_frame *cf = (struct can_frame *)skb->data;
88 struct net_device_stats *stats = &dev->stats; 92 struct net_device_stats *stats = &dev->stats;
89 int loop; 93 int loop;
90 94
95 if (can_dropped_invalid_skb(dev, skb))
96 return NETDEV_TX_OK;
97
91 stats->tx_packets++; 98 stats->tx_packets++;
92 stats->tx_bytes += skb->len; 99 stats->tx_bytes += cf->can_dlc;
93 100
94 /* set flag whether this packet has to be looped back */ 101 /* set flag whether this packet has to be looped back */
95 loop = skb->pkt_type == PACKET_LOOPBACK; 102 loop = skb->pkt_type == PACKET_LOOPBACK;
@@ -103,7 +110,7 @@ static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev)
103 * CAN core already did the echo for us 110 * CAN core already did the echo for us
104 */ 111 */
105 stats->rx_packets++; 112 stats->rx_packets++;
106 stats->rx_bytes += skb->len; 113 stats->rx_bytes += cf->can_dlc;
107 } 114 }
108 kfree_skb(skb); 115 kfree_skb(skb);
109 return NETDEV_TX_OK; 116 return NETDEV_TX_OK;