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