mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 23:21:46 +00:00
can: replace timestamp as unique skb attribute
Commit514ac99c64
"can: fix multiple delivery of a single CAN frame for overlapping CAN filters" requires the skb->tstamp to be set to check for identical CAN skbs. Without timestamping to be required by user space applications this timestamp was not generated which lead to commit36c01245eb
"can: fix loss of CAN frames in raw_rcv" - which forces the timestamp to be set in all CAN related skbuffs by introducing several __net_timestamp() calls. This forces e.g. out of tree drivers which are not using alloc_can{,fd}_skb() to add __net_timestamp() after skbuff creation to prevent the frame loss fixed in mainline Linux. This patch removes the timestamp dependency and uses an atomic counter to create an unique identifier together with the skbuff pointer. Btw: the new skbcnt element introduced in struct can_skb_priv has to be initialized with zero in out-of-tree drivers which are not using alloc_can{,fd}_skb() too. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
2acb5c301e
commit
d3b58c47d3
7 changed files with 18 additions and 17 deletions
|
@ -75,7 +75,7 @@ MODULE_ALIAS("can-proto-1");
|
|||
*/
|
||||
|
||||
struct uniqframe {
|
||||
ktime_t tstamp;
|
||||
int skbcnt;
|
||||
const struct sk_buff *skb;
|
||||
unsigned int join_rx_count;
|
||||
};
|
||||
|
@ -133,7 +133,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
|
|||
|
||||
/* eliminate multiple filter matches for the same skb */
|
||||
if (this_cpu_ptr(ro->uniq)->skb == oskb &&
|
||||
ktime_equal(this_cpu_ptr(ro->uniq)->tstamp, oskb->tstamp)) {
|
||||
this_cpu_ptr(ro->uniq)->skbcnt == can_skb_prv(oskb)->skbcnt) {
|
||||
if (ro->join_filters) {
|
||||
this_cpu_inc(ro->uniq->join_rx_count);
|
||||
/* drop frame until all enabled filters matched */
|
||||
|
@ -144,7 +144,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
|
|||
}
|
||||
} else {
|
||||
this_cpu_ptr(ro->uniq)->skb = oskb;
|
||||
this_cpu_ptr(ro->uniq)->tstamp = oskb->tstamp;
|
||||
this_cpu_ptr(ro->uniq)->skbcnt = can_skb_prv(oskb)->skbcnt;
|
||||
this_cpu_ptr(ro->uniq)->join_rx_count = 1;
|
||||
/* drop first frame to check all enabled filters? */
|
||||
if (ro->join_filters && ro->count > 1)
|
||||
|
@ -749,6 +749,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
|
|||
|
||||
can_skb_reserve(skb);
|
||||
can_skb_prv(skb)->ifindex = dev->ifindex;
|
||||
can_skb_prv(skb)->skbcnt = 0;
|
||||
|
||||
err = memcpy_from_msg(skb_put(skb, size), msg, size);
|
||||
if (err < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue