diff options
author | Wolfgang Grandegger <wg@grandegger.com> | 2009-10-20 03:08:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-20 03:08:01 -0400 |
commit | 7b6856a0296a8f187bb88ba31fa83a08abba7966 (patch) | |
tree | 0afbcc9291eeb368e4e4616b6eed9062df646de0 /include/linux/can | |
parent | 0eae750e6019a93643063924209c1daf9cb9b4a7 (diff) |
can: provide library functions for skb allocation
This patch makes the private functions alloc_can_skb() and
alloc_can_err_skb() of the at91_can driver public and adapts all
drivers to use these. While making the patch I realized, that
the skb's are *not* setup consistently. It's now done as shown
below:
skb->protocol = htons(ETH_P_CAN);
skb->pkt_type = PACKET_BROADCAST;
skb->ip_summed = CHECKSUM_UNNECESSARY;
*cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
memset(*cf, 0, sizeof(struct can_frame));
The frame is zeroed out to avoid uninitialized data to be passed to
user space. Some drivers or library code did not set "pkt_type" or
"ip_summed". Also, "__constant_htons()" should not be used for
runtime invocations, as pointed out by David Miller.
Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/can')
-rw-r--r-- | include/linux/can/dev.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 1d3f7f00e3af..1ed2a5cc03f5 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h | |||
@@ -68,4 +68,8 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, | |||
68 | void can_get_echo_skb(struct net_device *dev, unsigned int idx); | 68 | void can_get_echo_skb(struct net_device *dev, unsigned int idx); |
69 | void can_free_echo_skb(struct net_device *dev, unsigned int idx); | 69 | void can_free_echo_skb(struct net_device *dev, unsigned int idx); |
70 | 70 | ||
71 | struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf); | ||
72 | struct sk_buff *alloc_can_err_skb(struct net_device *dev, | ||
73 | struct can_frame **cf); | ||
74 | |||
71 | #endif /* CAN_DEV_H */ | 75 | #endif /* CAN_DEV_H */ |