Skip to contentSkip to conversation

selftests: allow compilation on older systems

PATCH In review Florian Westphal 3 participants 7 messages Oct 14, 2019 – Oct 15, 2019

Subsystems (3)
lore
Share & tools
lore

Florian Westphal

author
#0 lore raw

PATCH 1/1 selftests: allow compilation on older systems

squashto: mptcp: add basic kselftest for mptcp

An older VM image i was using lacks TCP_ULP define, add a workaround.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 3 +++
 1 file changed, 3 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_connect.c +3 -0
index a472e056fae6..987a8411756e 100644
@@ -26,6 +26,9 @@ extern int optind;
 #ifndef IPPROTO_MPTCP
 #define IPPROTO_MPTCP 262
 #endif
+#ifndef TCP_ULP
+#define TCP_ULP 31
+#endif
 
 static bool listen_mode;
 static int  poll_timeout;
Signature · 1 line
2.21.0
#1 lore raw

Review

Quoted 6 lines · Florian Westphal

#ifndef IPPROTO_MPTCP
#define IPPROTO_MPTCP 262
#endif

(quoted diff) +3 -0
+#ifndef TCP_ULP
+#define TCP_ULP 31
+#endif

good morning Florian!

AFAIU this is no more needed after

"selftests: test setsockopt(..., TCP_ULP, "mptcp", ...)"

that had this hunk:

tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
@@ -18,7 +18,8 @@
 
 #include <netdb.h>
 #include <netinet/in.h>
-#include <netinet/tcp.h>
+
+#include <linux/tcp.h>
 

^^ this ensures that TCP_ULP is defined, if the 'kernel-headers' package is newer than 4.13.

netinet/tcp.h is provided by glibc-headers (you find a quite old uapi here), while linux/tcp.h is provided by kernel-headers (you find a newer version of the uapi, but maybe not the one that defines TCP_ULP). And if I well remember, the rules in lib.mk should allow installing the current kernel headers in ${top_srcdir}/usr/include, as per:

commit b2d35fa5fc80c27e868e393dcab4c94a0d71737f

Author: Anders Roxell <anders.roxell(a)linaro.org>
Date:   Tue Sep 4 12:47:21 2018 +0200

selftests: add headers_install to lib.mk

maybe we can use this to avoid this "#include foo.h -> #ifndef foo -> #define foo -> #endif" pattern?

any feedback appreciated, thanks

Signature · 1 line
davide
author
#2 lore raw
Quoted 10 lines · Davide Caratti
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
@@ -18,7 +18,8 @@
 
 #include <netdb.h>
 #include <netinet/in.h>
-#include <netinet/tcp.h>
+
+#include <linux/tcp.h>
 
Quoted 2 lines

^^ this ensures that TCP_ULP is defined, if the 'kernel-headers' package is newer than 4.13.

ii linux-libc-dev:amd64 4.9.168-1+deb9u5 amd64
Linux support headers for userspace development

I don't care though, I can carry this patch in my private branch.

#3 lore raw

Hi Florian, Davide,

Quoted 11 lines · Florian Westphal
Quoted 10 lines · Davide Caratti
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
@@ -18,7 +18,8 @@
 
  #include <netdb.h>
  #include <netinet/in.h>
-#include <netinet/tcp.h>
+
+#include <linux/tcp.h>
 
Quoted 7 lines
Quoted 2 lines

^^ this ensures that TCP_ULP is defined, if the 'kernel-headers' package is newer than 4.13.

ii linux-libc-dev:amd64 4.9.168-1+deb9u5 amd64
Linux support headers for userspace development

I don't care though, I can carry this patch in my private branch.

Thank you for the patch and the review.
I would prefer to apply the patch, it doesn't cost anything to have this in the code.

If there is no objection from Davide, I am going to apply it. We can still revert later if needed.

Cheers,
Matt

Signature · 5 lines
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
#4 lore raw

Hi Florian, Davide,

Quoted 19 lines · Matthieu Baerts

Hi Florian, Davide,

Quoted 16 lines · Florian Westphal
Quoted 11 lines · Davide Caratti
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
@@ -18,7 +18,8 @@
   #include <netdb.h>
   #include <netinet/in.h>
-#include <netinet/tcp.h>
+
+#include <linux/tcp.h>
 

^^ this ensures that TCP_ULP is defined, if the 'kernel-headers' package is newer than 4.13.

ii  linux-libc-dev:amd64            4.9.168-1+deb9u5               amd64 Linux support headers for userspace development

Quoted 8 lines
Quoted 1 line

I don't care though, I can carry this patch in my private branch.

Thank you for the patch and the review.
I would prefer to apply the patch, it doesn't cost anything to have this in the code.

If there is no objection from Davide, I am going to apply it. We can still revert later if needed.

- 29950008bd42: "squashed" in "mptcp: add basic kselftest for mptcp"
- a6ac152c2671..d7c09401756b: results

Cheers,
Matt

Signature · 5 lines
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
#5 lore raw
In reply to Florian Westphal
Quoted 11 lines · Florian Westphal
Quoted 10 lines · Davide Caratti
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
@@ -18,7 +18,8 @@
 
 #include <netdb.h>
 #include <netinet/in.h>
-#include <netinet/tcp.h>
+
+#include <linux/tcp.h>
 
Quoted 7 lines
Quoted 2 lines

^^ this ensures that TCP_ULP is defined, if the 'kernel-headers' package is newer than 4.13.

ii linux-libc-dev:amd64 4.9.168-1+deb9u5 amd64
Linux support headers for userspace development

I don't care though, I can carry this patch in my private branch.

we can also keep this patch merged until the whole thing is addressed entirely (because the same argument also applies to the definition of IPPROTO_MPTCP)-

the patch LGTM and probably it also fixes a build failure on some system, like Florian's Debian, that has been introduced with "selftests: test setsockopt(..., TCP_ULP, "mptcp", ...)".

Ok?

Signature · 1 line
davide
#6 lore raw

Hi Davide,

Quoted 18 lines · Davide Caratti
Quoted 17 lines · Florian Westphal
Quoted 10 lines · Davide Caratti
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
@@ -18,7 +18,8 @@
 
  #include <netdb.h>
  #include <netinet/in.h>
-#include <netinet/tcp.h>
+
+#include <linux/tcp.h>
 
Quoted 2 lines

^^ this ensures that TCP_ULP is defined, if the 'kernel-headers' package is newer than 4.13.

ii linux-libc-dev:amd64 4.9.168-1+deb9u5 amd64
Linux support headers for userspace development

Quoted 5 lines
Quoted 1 line

I don't care though, I can carry this patch in my private branch.

we can also keep this patch merged until the whole thing is addressed entirely (because the same argument also applies to the definition of IPPROTO_MPTCP)-

There is already something for IPPROTO_MPTCP:

   #ifndef IPPROTO_MPTCP
   #define IPPROTO_MPTCP 262
   #endif
Quoted 3 lines

the patch LGTM and probably it also fixes a build failure on some system, like Florian's Debian, that has been introduced with "selftests: test setsockopt(..., TCP_ULP, "mptcp", ...)".

Did you introduce this on purpose to make sure Florian would be forced not to use Debian but RHEL/Fedora??? Sneaky!!

Cheers,
Matt

Signature · 5 lines
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium