Re: [PATCH v1 1/2] j1939: add MSG_ERRQUEUE support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 25.04.19 14:48, Kurt Van Dijck wrote:
On do, 25 apr 2019 13:46:19 +0200, Oleksij Rempel wrote:
Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
  include/uapi/linux/can/j1939.h |  6 +++++
  net/can/j1939/j1939-priv.h     |  2 ++
  net/can/j1939/socket.c         | 48 +++++++++++++++++++++++++++++++---
  net/can/j1939/transport.c      | 33 ++++++++++++++++++++---
  4 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/include/uapi/linux/can/j1939.h b/include/uapi/linux/can/j1939.h
index c7eb94d2ab10..77f8068bcc62 100644
--- a/include/uapi/linux/can/j1939.h
+++ b/include/uapi/linux/can/j1939.h
@@ -72,6 +72,8 @@ enum {
  	SCM_J1939_DEST_ADDR = 1,
  	SCM_J1939_DEST_NAME = 2,
  	SCM_J1939_PRIO = 3,
+	SCM_J1939_RECVERR = 4,
+	SCM_J1939_PKTINFO = 5,
  };
struct j1939_filter {
@@ -83,6 +85,10 @@ struct j1939_filter {
  	__u8 addr_mask;

....
+			continue;
+		switch (cmsg->cmsg_type) {
+		case SCM_J1939_PKTINFO:
+		{
+			struct j1939_pktinfo *tinfo;
+
+			if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct j1939_pktinfo)))
+				return -EINVAL;
+			tinfo = (struct j1939_pktinfo *)CMSG_DATA(cmsg);
+			memcpy(info, tinfo, sizeof(*info));
+			break;
+		}
+		default:
+			return -EINVAL;
+		}
+	}
+	return 0;
+}
+
  static int j1939_sk_sendmsg(struct socket *sock, struct msghdr *msg,
  			    size_t size)
  {
@@ -852,6 +887,7 @@ static int j1939_sk_sendmsg(struct socket *sock, struct msghdr *msg,
  	struct j1939_sock *jsk = j1939_sk(sk);
  	struct j1939_priv *priv;
  	struct net_device *ndev;
+	struct j1939_pktinfo info;

info is initialized only when msg_controllen is set.
This is not necessarily always the case?

Good point. Thx!

Kind regards,
Oleksij Rempel

--
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux