Oliver Hartkopp wrote:
> Marc Kleine-Budde wrote:
>> Wolfgang Grandegger wrote:
>>> 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. The skb's are now setup
>>> as shown:
>>>     skb->dev = dev;
>> nitpick: we use "netdev_alloc_skb()", so "skb->dev = dev" isn't needed
>> any more. The code is allright, just the commit message is misleading.
>>
>>>     skb->protocol = __constant_htons(ETH_P_CAN);
>>>     skb->ip_summed = CHECKSUM_UNNECESSARY;
>>> Some drivers or library code used:
>>>         skb->protocol = htons(ETH_P_CAN); or
>>>     skb->pkt_type = PACKET_BROADCAST;
>>> or did not set CHECKSUM_UNNECESSARY.
>>> Please check and comment.
>>> Marc, feel free to add your signed-off-by here.
>> nitpick: as you did the patch, I can rather add my Acked-by: under your
>> S-o-b.
>>
>>> Signed-off-by: Wolfgang Grandegger <[email protected]>
>>> ---
>>>  kernel/2.6/drivers/net/can/at91_can.c             |   32 ------------------
>>>  kernel/2.6/drivers/net/can/cc770/cc770.c          |   13 +------
>>>  kernel/2.6/drivers/net/can/dev.c                  |   38 
>>> ++++++++++++++++++++--
>>>  kernel/2.6/drivers/net/can/esd_pci331.c           |   14 +-------
>>>  kernel/2.6/drivers/net/can/mcp251x.c              |   20 +----------
>>>  kernel/2.6/drivers/net/can/mscan/mscan.c          |    6 ---
>>>  kernel/2.6/drivers/net/can/sja1000/sja1000.c      |   12 +-----
>>>  kernel/2.6/drivers/net/can/softing/softing_main.c |    8 +---
>>>  kernel/2.6/drivers/net/can/usb/ems_usb.c          |   16 +--------
>>>  kernel/2.6/include/socketcan/can/dev.h            |    4 ++
>>>  10 files changed, 54 insertions(+), 109 deletions(-)
>>> Index: trunk/kernel/2.6/drivers/net/can/dev.c
>>> ===================================================================
>>> --- trunk.orig/kernel/2.6/drivers/net/can/dev.c
>>> +++ trunk/kernel/2.6/drivers/net/can/dev.c
>>> @@ -318,8 +318,7 @@ void can_put_echo_skb(struct sk_buff *sk
>>>             skb->sk = srcsk;
>>>             /* make settings for echo to reduce code in irq context */
>>> -           skb->protocol = htons(ETH_P_CAN);
>>> -           skb->pkt_type = PACKET_BROADCAST;
>> is it save to remove this flag?
> 
> This was also my concern.
> 
> This pkt_type is also set in af_can.c and we should set it for now.
> You might also use CAN netdevices with PACKET socket and wireshark, where the
> PACKET_BROADCAST pkt_type is remarked.

OK, note that currently only the slcan, vcan and the mcp251x set it...
but I might have accidentally dropped it when porting from the old drivers.

> If it is unnecessary i would send a separate patch to remove both of them.
> 
>>> +           skb->protocol = __constant_htons(ETH_P_CAN);
>>>             skb->ip_summed = CHECKSUM_UNNECESSARY;
>>>             skb->dev = dev;
>>> @@ -403,7 +402,8 @@ void can_restart(unsigned long data)
>>>             goto restart;
>>>     }
>>>     skb->dev = dev;
>>> -   skb->protocol = htons(ETH_P_CAN);
>>> +   skb->protocol = __constant_htons(ETH_P_CAN);
>>> +   skb->ip_summed = CHECKSUM_UNNECESSARY;
>>>     cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
>>>     memset(cf, 0, sizeof(struct can_frame));
>>>     cf->can_id = CAN_ERR_FLAG | CAN_ERR_RESTARTED;
>>> @@ -496,6 +496,38 @@ static void can_setup(struct net_device 
>>>  #endif
>>>  }
>>> +struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame 
>>> **cf)
>>> +{
>>> +   struct sk_buff *skb;
>>> +
>>> +   skb = netdev_alloc_skb(dev, sizeof(struct can_frame));
>>> +   if (unlikely(!skb))
>>> +           return NULL;
>>> +
>>> +   skb->protocol = __constant_htons(ETH_P_CAN);
>>> +   skb->ip_summed = CHECKSUM_UNNECESSARY;
> 
> Please add 'skb->pkt_type = PACKET_BROADCAST' here.

And add it at other similar locations in dev.c as well. I assume that it
should be set for all kind of messages, real, echo'ed and error messages.

> 
>>> +   *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
> 
> This could be also the place, where we could memset the struct can_frame to
> zero, right?
> 
> Maybe we should do it here and leave it in alloc_can_err_skb() ...

Yep, and remove the zero'ing from the driver code.

Wolfgang.
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to