Skip to content

Commit 25ca8b4

Browse files
Dwyane-Yanekyooo
authored andcommitted
tools/mptcpify: mask socket type before matching SOCK_STREAM
The hook receives the raw type with SOCK_NONBLOCK/SOCK_CLOEXEC still ORed in, so callers like curl that pass SOCK_STREAM|SOCK_NONBLOCK never match "type == SOCK_STREAM" and aren't converted to MPTCP. Use (type & SOCK_TYPE_MASK) == SOCK_STREAM instead. Suggested-by: Guillaume @layus Maudoux <layus.on@gmail.com> Signed-off-by: Gang Yan <yangang@kylinos.cn>
1 parent 45348ee commit 25ca8b4

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tools/mptcpify.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class app_name(ct.Structure):
4848
#include <uapi/linux/in.h>
4949
#include <linux/string.h>
5050
51+
#ifndef SOCK_TYPE_MASK
52+
#define SOCK_TYPE_MASK 0xf
53+
#endif
54+
5155
struct app_name {
5256
char name[TASK_COMM_LEN];
5357
};
@@ -63,7 +67,7 @@ class app_name(ct.Structure):
6367
bpf_get_current_comm(&target.name, TASK_COMM_LEN);
6468
6569
if ((family == AF_INET || family == AF_INET6) &&
66-
type == SOCK_STREAM &&
70+
(type & SOCK_TYPE_MASK) == SOCK_STREAM &&
6771
(!protocol || protocol == IPPROTO_TCP) &&
6872
(mode && *mode == 0 || support_apps.lookup(&target)))
6973
return IPPROTO_MPTCP;

0 commit comments

Comments
 (0)