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.
selftests/bpf: Test bpf_mptcpify helper
This patch tests the new helper bpf_mptcpify(). Store the new protocol value after invoking the helper to a local BSS variable. This is defined in a 'sock_create' SEC, so it will be invoked in BPF_CGROUP_RUN_PROG_INET_SOCK() in inet_create(). Signed-off-by: Geliang Tang <[email protected]>
- Loading branch information
1 parent
96703c9
commit c67ffc5
Showing
2 changed files
with
27 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,26 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (c) 2023, SUSE. */ | ||
|
||
#include <sys/socket.h> | ||
#include <linux/bpf.h> | ||
#include <bpf/bpf_helpers.h> | ||
#include "bpf_tcp_helpers.h" | ||
|
||
char _license[] SEC("license") = "GPL"; | ||
__u16 protocol = 0; | ||
|
||
SEC("cgroup/sock_create") | ||
int sock(struct bpf_sock *ctx) | ||
{ | ||
struct sock *sk; | ||
|
||
if (ctx->type != SOCK_STREAM) | ||
return 1; | ||
|
||
sk = bpf_mptcpify(ctx); | ||
if (!sk) | ||
return 1; | ||
|
||
protocol = sk->sk_protocol; | ||
return 1; | ||
} |