linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] can: skb: add and set local_origin flag
@ 2022-05-11 12:19 Oleksij Rempel
  2022-05-11 12:38 ` Oliver Hartkopp
  0 siblings, 1 reply; 14+ messages in thread
From: Oleksij Rempel @ 2022-05-11 12:19 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, Oliver Hartkopp
  Cc: Oleksij Rempel, Devid Antonio Filoni, kernel, linux-can, netdev,
	linux-kernel, David Jander

Add new can_skb_priv::local_origin flag to be able detect egress
packages even if they was sent directly from kernel and not assigned to
some socket.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Devid Antonio Filoni <devid.filoni@egluetechnologies.com>
---
 drivers/net/can/dev/skb.c | 3 +++
 include/linux/can/skb.h   | 1 +
 net/can/raw.c             | 2 +-
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/dev/skb.c b/drivers/net/can/dev/skb.c
index 61660248c69e..3e2357fb387e 100644
--- a/drivers/net/can/dev/skb.c
+++ b/drivers/net/can/dev/skb.c
@@ -63,6 +63,7 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
 
 		/* save frame_len to reuse it when transmission is completed */
 		can_skb_prv(skb)->frame_len = frame_len;
+		can_skb_prv(skb)->local_origin = true;
 
 		skb_tx_timestamp(skb);
 
@@ -200,6 +201,7 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
 	can_skb_reserve(skb);
 	can_skb_prv(skb)->ifindex = dev->ifindex;
 	can_skb_prv(skb)->skbcnt = 0;
+	can_skb_prv(skb)->local_origin = false;
 
 	*cf = skb_put_zero(skb, sizeof(struct can_frame));
 
@@ -231,6 +233,7 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
 	can_skb_reserve(skb);
 	can_skb_prv(skb)->ifindex = dev->ifindex;
 	can_skb_prv(skb)->skbcnt = 0;
+	can_skb_prv(skb)->local_origin = false;
 
 	*cfd = skb_put_zero(skb, sizeof(struct canfd_frame));
 
diff --git a/include/linux/can/skb.h b/include/linux/can/skb.h
index fdb22b00674a..1b8a8cf2b13b 100644
--- a/include/linux/can/skb.h
+++ b/include/linux/can/skb.h
@@ -52,6 +52,7 @@ struct can_skb_priv {
 	int ifindex;
 	int skbcnt;
 	unsigned int frame_len;
+	bool local_origin;
 	struct can_frame cf[];
 };
 
diff --git a/net/can/raw.c b/net/can/raw.c
index b7dbb57557f3..df2d9334b395 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -173,7 +173,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
 	/* add CAN specific message flags for raw_recvmsg() */
 	pflags = raw_flags(skb);
 	*pflags = 0;
-	if (oskb->sk)
+	if (can_skb_prv(skb)->local_origin)
 		*pflags |= MSG_DONTROUTE;
 	if (oskb->sk == sk)
 		*pflags |= MSG_CONFIRM;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-05-14  3:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 12:19 [PATCH 1/1] can: skb: add and set local_origin flag Oleksij Rempel
2022-05-11 12:38 ` Oliver Hartkopp
2022-05-11 12:53   ` Oleksij Rempel
2022-05-11 13:05   ` Marc Kleine-Budde
2022-05-11 13:24     ` Oliver Hartkopp
2022-05-11 13:55       ` Marc Kleine-Budde
2022-05-11 13:24   ` Marc Kleine-Budde
2022-05-11 14:36     ` Marc Kleine-Budde
2022-05-11 14:50       ` Oliver Hartkopp
2022-05-11 14:54         ` Marc Kleine-Budde
2022-05-11 14:57           ` Oliver Hartkopp
2022-05-12  6:23             ` Oliver Hartkopp
2022-05-12  7:58               ` Marc Kleine-Budde
2022-05-14  3:43       ` Vincent Mailhol

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).