multipath-tcp / mptcp

⚠️⚠️⚠️ Deprecated 🚫 Out-of-tree Linux Kernel implementation of MultiPath TCP. 👉 Use https://github.com/multipath-tcp/mptcp_net-next repo instead ⚠️⚠️⚠️
https://github.com/multipath-tcp/mptcp_net-next
Other
889 stars 335 forks source link

How to include MPTCP_ENABLED and SOL_TCP definitions #439

Closed VenkateswaranJ closed 3 years ago

VenkateswaranJ commented 3 years ago

Macro MPTCP_ENABLED is defined in #include <linux/tcp.h> and SOL_TCP defined in #include <netinet/in.h> I want these two definitions to set the mptcp socket option but if I include those two files I get lots of type conflict errors. Is there any better way to do it or do I need to define one of the macros in my CPP file? ( example : #define SOL_TCP 6)

matttbe commented 3 years ago

Hi,

User programs should include files from netninet. Of course here, MPTCP_* macros are not going to be defined there as this is a out-of-tree kernel!

There are workarounds I think, please see: https://github.com/multipath-tcp/mptcp/issues/393#issuecomment-631324403

But it is maybe easier not to include linux/tcp.h and define MPTCP_ENABLED (and others). The associated numbers should not change.

(Feel free to close this ticket if you got the answer you wanted ;) )

VenkateswaranJ commented 3 years ago

I want to include some code only if it's mptcp kernel something like

#ifdef MPTCP_ENABLED
//code
#endif

for this, I need to check linux/tcp.h file. Is there any other way to do this?

matttbe commented 3 years ago

This implies you compile the userspace code on the machine it is supposed to run. That's not always the case.

If the workaround from https://github.com/multipath-tcp/mptcp/issues/393#issuecomment-631324403 is not working for you, the best is probably to grep MPTCP_ENABLED (...)/linux/tcp.h and add a -D MPTCP_ENABLED=42 at the compilation time.

I don't think there are "cleaner" solutions for out-of-tree kernels. But if you find any, feel free to share it with us.