forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a new test program mptcpify: if the family is AF_INET or AF_INET6, the type is SOCK_STREAM, and the protocol ID is 0 or IPPROTO_TCP, set it to IPPROTO_MPTCP. It will be hooked in update_socket_protocol(). Extend the MPTCP test base, add a selftest test_mptcpify() for the mptcpify case. Open and load the mptcpify test prog to mptcpify the TCP sockets dynamically, then use start_server() and connect_to_fd() to create a TCP socket, but actually what's created is an MPTCP socket, which can be verified through 'getsockopt(SOL_PROTOCOL)' and 'nstat' commands. Acked-by: Yonghong Song <[email protected]> Reviewed-by: Matthieu Baerts <[email protected]> Signed-off-by: Geliang Tang <[email protected]>
- Loading branch information
1 parent
d490b53
commit 04b42ba
Showing
2 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (c) 2023, SUSE. */ | ||
|
||
#include "vmlinux.h" | ||
#include <bpf/bpf_tracing.h> | ||
#include "bpf_tracing_net.h" | ||
|
||
char _license[] SEC("license") = "GPL"; | ||
|
||
SEC("fmod_ret/update_socket_protocol") | ||
int BPF_PROG(mptcpify, int family, int type, int protocol) | ||
{ | ||
if ((family == AF_INET || family == AF_INET6) && | ||
type == SOCK_STREAM && | ||
(!protocol || protocol == IPPROTO_TCP)) { | ||
return IPPROTO_MPTCP; | ||
} | ||
|
||
return protocol; | ||
} |