Open matttbe opened 1 year ago
Suggestion: probably most cases can be handled with such generic function:
static int mptcp_setsockopt_all_sf(struct mptcp_sock *msk, int level,
int optname, sockptr_t optval,
unsigned int optlen,
int (*get_val)(struct sock *),
void (*set_val)(struct sock *, int))
{
struct mptcp_subflow_context *subflow;
struct sock *sk = (struct sock *)msk;
int err, val;
err = tcp_setsockopt(sk, level, optname, optval, optlen);
if (err != 0)
return err;
lock_sock(sk);
sockopt_seq_inc(msk);
val = get_val(sk);
mptcp_for_each_subflow(msk, subflow) {
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
bool slow = lock_sock_fast(ssk); /* Not needed? */
set_val(ssk, val);
unlock_sock_fast(ssk, slow);
}
release_sock(sk);
return 0;
}
Example:
static int get_ip_treansparent(struct sock *sk)
{
return inet_sk(sk)->transparent;
}
static int set_ip_treansparent(struct sock *sk, int val)
{
return inet_sk(sk)->transparent;
}
(...)
switch (optname) {
case IP_TRANSPARENT:
return mptcp_setsockopt_all_sf(msk, level, optname, optval, optlen,
&get_ip_treansparent, &set_ip_treansparent);
(and add set_ip_treansparent()
in sync_socket_options()
)
WDYT?
Hey,
I hit some issue with setsockopt() with IP_TRANSPARENT (IPv4) when using MPTCPv1 (kernel version 5.15.0-69). It seems that IP_TRANSPARENT is not supported in 5.15.0-69. Should I upgrade my kernel ? do you have any recommendation on which version I should use ? Thanks.
Hi @funglee2k22,
You need at least the v5.17: https://github.com/multipath-tcp/mptcp_net-next/wiki#changelog We recommend to use the last stable version (or at least the last LTS version).
when using MPTCPv1
MPTCPv1 is the protocol version, not the implementation.
https://github.com/multipath-tcp/mptcp_net-next/wiki#mptcpv0-vs-mptcpv1
@matttbe Thanks Matt, I upgrade to 6.1.23. and IP_TRANSPARENT starts working. Thanks.
Currently, I have some issues with a dual haproxy setup. Before I move to haproxy I had the shadowsock-libev solution working w/ mptcpv1. The similar setup (dual haproxy setup) was working fine with the mptcpv0.97 (4.* kernel). But now, not matter what I did, I could not get the dual-haproxy working (subflow is not added). (Note, both haproxy are running as a transparent proxy.).
Is there any recommendation how to debug this issue ?
@funglee2k22 I think it would be better if you open a new issue about that, that's not related to the factoring suggested here.
In the description of this new issue, please explain how you forced HAProxy to use MPTCP (with mptcpize?) + share output of ss -pinmHM
and nstat -as Tcp* MPTcp*
When looking at
net/mptcp/sockopt.c
code, I can see multiple ways to set and get values. For example, for thesetsockopt()
side, we have:IP_TRANSPARENT
:ip_setsockopt()
is called on the MPTCP socksync_socket_options()
will set the same value to all the new subflows created afterIPV6_TRANSPARENT
: the oppositetcp_setsockopt()
is called on the first subflowsync_socket_options()
IP_TOS
: similar toIP_TRANSPARENT
but on all subflowsip_setsockopt()
is called on the MPTCP socksync_socket_options()
TCP_FASTOPEN
:tcp_setsockopt()
is called on the first subflowTCP_INQ
:tcp_setsockopt()
is not used but we do the sameSO_TIMESTAMPNS
:sock_setsockopt()
is usedetc.