Skip to contentSkip to conversation

can: isotp: upgrade 5.15 LTS to latest 6.6 mainline code base

PATCH In review Oliver Hartkopp 3 participants 6 messages Oct 30, 2023

Subsystems (3)
lore
Share & tools
lore

Oliver Hartkopp

author maintainer
#0 lore raw

PATCH 1/1 can: isotp: upgrade 5.15 LTS to latest 6.6 mainline code base

The backport of commit 9c5df2f14ee3 ("can: isotp: isotp_ops: fix poll() to not report false EPOLLOUT events") introduced a new regression where the fix could potentially introduce new side effects.

To reduce the risk of other unmet dependencies and missing fixes and checks the latest mainline code base is ported back to the 5.15 LTS tree.

To meet the former Linux 5.15 API these commits have been reverted:
f4b41f062c42 ("net: remove noblock parameter from skb_recv_datagram()") 96a7457a14d9 ("can: skb: unify skb CAN frame identification helpers") dc97391e6610 ("sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)") 0145462fc802 ("can: isotp: isotp_recvmsg(): use sock_recv_cmsgs() to get SOCK_RXQ_OVFL infos")

New features and communication stability measures:
9f39d36530e5 ("can: isotp: add support for transmission without flow control") 96d1c81e6a04 ("can: isotp: add module parameter for maximum pdu size") 4b7fe92c0690 ("can: isotp: add local echo tx processing for consecutive frames") 530e0d46c613 ("can: isotp: set default value for N_As to 50 micro seconds")

And various sanity checks, fixes and improved return values.

---
 include/uapi/linux/can/isotp.h |  25 +-
 net/can/isotp.c                | 487 ++++++++++++++++++++++-----------
 2 files changed, 342 insertions(+), 170 deletions(-)
include/uapi/linux/can/isotp.h +13 -12
index 590f8aea2b6d..439c982f7e81 100644
@@ -122,22 +122,23 @@ struct can_isotp_ll_options {
 				/* by the CAN netdriver configuration	*/
 };
 
 /* flags for isotp behaviour */
 
-#define CAN_ISOTP_LISTEN_MODE	0x001	/* listen only (do not send FC) */
-#define CAN_ISOTP_EXTEND_ADDR	0x002	/* enable extended addressing */
-#define CAN_ISOTP_TX_PADDING	0x004	/* enable CAN frame padding tx path */
-#define CAN_ISOTP_RX_PADDING	0x008	/* enable CAN frame padding rx path */
-#define CAN_ISOTP_CHK_PAD_LEN	0x010	/* check received CAN frame padding */
-#define CAN_ISOTP_CHK_PAD_DATA	0x020	/* check received CAN frame padding */
-#define CAN_ISOTP_HALF_DUPLEX	0x040	/* half duplex error state handling */
-#define CAN_ISOTP_FORCE_TXSTMIN	0x080	/* ignore stmin from received FC */
-#define CAN_ISOTP_FORCE_RXSTMIN	0x100	/* ignore CFs depending on rx stmin */
-#define CAN_ISOTP_RX_EXT_ADDR	0x200	/* different rx extended addressing */
-#define CAN_ISOTP_WAIT_TX_DONE	0x400	/* wait for tx completion */
-#define CAN_ISOTP_SF_BROADCAST	0x800	/* 1-to-N functional addressing */
+#define CAN_ISOTP_LISTEN_MODE	0x0001	/* listen only (do not send FC) */
+#define CAN_ISOTP_EXTEND_ADDR	0x0002	/* enable extended addressing */
+#define CAN_ISOTP_TX_PADDING	0x0004	/* enable CAN frame padding tx path */
+#define CAN_ISOTP_RX_PADDING	0x0008	/* enable CAN frame padding rx path */
+#define CAN_ISOTP_CHK_PAD_LEN	0x0010	/* check received CAN frame padding */
+#define CAN_ISOTP_CHK_PAD_DATA	0x0020	/* check received CAN frame padding */
+#define CAN_ISOTP_HALF_DUPLEX	0x0040	/* half duplex error state handling */
+#define CAN_ISOTP_FORCE_TXSTMIN	0x0080	/* ignore stmin from received FC */
+#define CAN_ISOTP_FORCE_RXSTMIN	0x0100	/* ignore CFs depending on rx stmin */
+#define CAN_ISOTP_RX_EXT_ADDR	0x0200	/* different rx extended addressing */
+#define CAN_ISOTP_WAIT_TX_DONE	0x0400	/* wait for tx completion */
+#define CAN_ISOTP_SF_BROADCAST	0x0800	/* 1-to-N functional addressing */
+#define CAN_ISOTP_CF_BROADCAST	0x1000	/* 1-to-N transmission w/o FC */
 
 /* protocol machine default values */
 
 #define CAN_ISOTP_DEFAULT_FLAGS		0
 #define CAN_ISOTP_DEFAULT_EXT_ADDRESS	0x00
net/can/isotp.c +329 -158

877 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw
FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] can: isotp: upgrade 5.15 LTS to latest 6.6 mainline code base

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#2 lore raw
In reply to Oliver Hartkopp
Quoted 13 lines · Oliver Hartkopp

The backport of commit 9c5df2f14ee3 ("can: isotp: isotp_ops: fix poll() to not report false EPOLLOUT events") introduced a new regression where the fix could potentially introduce new side effects.

To reduce the risk of other unmet dependencies and missing fixes and checks the latest mainline code base is ported back to the 5.15 LTS tree.

To meet the former Linux 5.15 API these commits have been reverted:
f4b41f062c42 ("net: remove noblock parameter from skb_recv_datagram()") 96a7457a14d9 ("can: skb: unify skb CAN frame identification helpers") dc97391e6610 ("sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)") 0145462fc802 ("can: isotp: isotp_recvmsg(): use sock_recv_cmsgs() to get SOCK_RXQ_OVFL infos")

Quoted 5 lines

New features and communication stability measures:
9f39d36530e5 ("can: isotp: add support for transmission without flow control") 96d1c81e6a04 ("can: isotp: add module parameter for maximum pdu size") 4b7fe92c0690 ("can: isotp: add local echo tx processing for consecutive frames") 530e0d46c613 ("can: isotp: set default value for N_As to 50 micro seconds")

Please send these as individual patches, reverts and then the new ones added, not as one huge commit that we can't review properly at all.

But why just 5.15? What about 6.1.y and 6.5.y?

thanks,

greg k-h

author maintainer
#3 lore raw

Hello Greg,

Quoted 14 lines · Greg KH
Quoted 13 lines · Oliver Hartkopp

The backport of commit 9c5df2f14ee3 ("can: isotp: isotp_ops: fix poll() to not report false EPOLLOUT events") introduced a new regression where the fix could potentially introduce new side effects.

To reduce the risk of other unmet dependencies and missing fixes and checks the latest mainline code base is ported back to the 5.15 LTS tree.

To meet the former Linux 5.15 API these commits have been reverted:
f4b41f062c42 ("net: remove noblock parameter from skb_recv_datagram()") 96a7457a14d9 ("can: skb: unify skb CAN frame identification helpers") dc97391e6610 ("sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)") 0145462fc802 ("can: isotp: isotp_recvmsg(): use sock_recv_cmsgs() to get SOCK_RXQ_OVFL infos")

Quoted 8 lines
Quoted 5 lines

New features and communication stability measures:
9f39d36530e5 ("can: isotp: add support for transmission without flow control") 96d1c81e6a04 ("can: isotp: add module parameter for maximum pdu size") 4b7fe92c0690 ("can: isotp: add local echo tx processing for consecutive frames") 530e0d46c613 ("can: isotp: set default value for N_As to 50 micro seconds")

Please send these as individual patches, reverts and then the new ones added, not as one huge commit that we can't review properly at all.

That would be around 20 patches including fixes and fixes of fixes of fixes. For that reason I simply copied the 6.6 code and made the code work in 5.x by adapting it to the old 5.x kernel APIs.

E.g. the diff from the new 5.15 and the 6.6 code is just this:

$ diff -U 2 isotp.c-5.15-new isotp.c-6.6
--- isotp.c-5.15-new	2023-10-29 15:41:39.770567182 +0100
+++ isotp.c-6.6	2023-10-28 22:07:21.293444651 +0200
@@ -695,5 +695,5 @@
 			isotp_rcv_sf(sk, cf, SF_PCI_SZ4 + ae, skb, sf_dl);
 		} else {
-			if (skb->len == CANFD_MTU) {
+			if (can_is_canfd_skb(skb)) {
 				/* We have a CAN FD frame and CAN_DL is greater than 8:
 				 * Only frames with the SF_DL == 0 ESC value are valid.
@@ -1130,5 +1130,4 @@
 	struct sk_buff *skb;
 	struct isotp_sock *so = isotp_sk(sk);
-	int noblock = flags & MSG_DONTWAIT;
 	int ret = 0;

@@ -1139,6 +1138,5 @@
return -EADDRNOTAVAIL;

- flags &= ~MSG_DONTWAIT;
- skb = skb_recv_datagram(sk, flags, noblock, &ret);
+ skb = skb_recv_datagram(sk, flags, &ret);
if (!skb)
return ret;
@@ -1153,5 +1151,5 @@
goto out_err;

- sock_recv_timestamp(msg, sk, skb);
+ sock_recv_cmsgs(msg, sk, skb);

if (msg->msg_name) {
@@ -1692,5 +1690,4 @@
.recvmsg = isotp_recvmsg,
.mmap = sock_no_mmap,
- .sendpage = sock_no_sendpage,
};

Of course I could split all the fixes and improvements into new patches that omit the API changes. But is it worth the effort when we end up with the 6.6 code using the old API?

Quoted 1 line

But why just 5.15? What about 6.1.y and 6.5.y?

I have posted 5.10 and 5.15 for now.
6.1 would be only this patch
96d1c81e6a04 ("can: isotp: add module parameter for maximum pdu size") I can also provide.

6.5 is up to date with the latest 6.6

Best regards,
Oliver

maintainer
#4 lore raw
Quoted 23 lines · Oliver Hartkopp

Hello Greg,

Quoted 20 lines · Greg KH
Quoted 18 lines · Oliver Hartkopp

The backport of commit 9c5df2f14ee3 ("can: isotp: isotp_ops: fix poll() to not report false EPOLLOUT events") introduced a new regression where the fix could potentially introduce new side effects.

To reduce the risk of other unmet dependencies and missing fixes and checks the latest mainline code base is ported back to the 5.15 LTS tree.

To meet the former Linux 5.15 API these commits have been reverted:
f4b41f062c42 ("net: remove noblock parameter from skb_recv_datagram()") 96a7457a14d9 ("can: skb: unify skb CAN frame identification helpers") dc97391e6610 ("sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)") 0145462fc802 ("can: isotp: isotp_recvmsg(): use sock_recv_cmsgs() to get SOCK_RXQ_OVFL infos")

New features and communication stability measures:
9f39d36530e5 ("can: isotp: add support for transmission without flow control") 96d1c81e6a04 ("can: isotp: add module parameter for maximum pdu size") 4b7fe92c0690 ("can: isotp: add local echo tx processing for consecutive frames") 530e0d46c613 ("can: isotp: set default value for N_As to 50 micro seconds")

Quoted 6 lines
Quoted 2 lines

Please send these as individual patches, reverts and then the new ones added, not as one huge commit that we can't review properly at all.

That would be around 20 patches including fixes and fixes of fixes of fixes. For that reason I simply copied the 6.6 code and made the code work in 5.x by adapting it to the old 5.x kernel APIs.

20 patches is trivial for us to handle, please do it that way as it ensures we keep the proper history, AND we know what to backport when in the future.

When you try to crunch patches together, or do non-upstream changes, 90%+ of the time they end up being wrong or impossible to maintain over time.

Quoted 6 lines
Quoted 1 line

But why just 5.15? What about 6.1.y and 6.5.y?

I have posted 5.10 and 5.15 for now.
6.1 would be only this patch
96d1c81e6a04 ("can: isotp: add module parameter for maximum pdu size") I can also provide.

Why add new features to older kernels? That's not going to be ok, sorry.

And why is can adding module parameters? This isn't the 1990's, we have proper ways of doing this correctly (hint, module parameters are not the way to do that...)

thanks,

greg k-h

author maintainer
#5 lore raw
Quoted 3 lines · Greg KH

20 patches is trivial for us to handle, please do it that way as it ensures we keep the proper history, AND we know what to backport when in the future.

Ok, will do.

Quoted 3 lines

When you try to crunch patches together, or do non-upstream changes, 90%+ of the time they end up being wrong or impossible to maintain over time.

Ok, then I will maintain the entire history of fixes of fixes without crunching them together.

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

But why just 5.15? What about 6.1.y and 6.5.y?

I have posted 5.10 and 5.15 for now.
6.1 would be only this patch
96d1c81e6a04 ("can: isotp: add module parameter for maximum pdu size") I can also provide.

Why add new features to older kernels? That's not going to be ok, sorry.

I will drop the module parameter stuff then, as it has no impact on the communication state machine that is in the focus to be consistently fixed and updated to the 6.6 code base. Then everything in 5.15 and 5.10 will be on the same level as 6.1. This will ease further fixes and maintenance.

Best regards,
Oliver