Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/smc: Introduce smc_ops #8367

Open
wants to merge 5 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: net/smc: Introduce smc_ops
version: 6
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 87c5441
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 87c5441
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 87c5441
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: a8d1c48
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 556a399
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 556a399
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: b53b63d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: f8a0569
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: e055a46
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

D. Wythe added 4 commits January 17, 2025 10:43
Exports three necessary symbols for implementing struct_ops with
tristate subsystem.

To hold or release refcnt of struct_ops refcnt by inline funcs
bpf_try_module_get and bpf_module_put which use bpf_struct_ops_get(put)
conditionally.

And to copy obj name from one to the other with effective checks by
bpf_obj_name_cpy.

Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
The introduction of IPPROTO_SMC enables eBPF programs to determine
whether to use SMC based on the context of socket creation, such as
network namespaces, PID and comm name, etc.

As a subsequent enhancement, to introduce a new generic hook that
allows decisions on whether to use SMC or not at runtime, including
but not limited to local/remote IP address or ports.

Moreover, in the future, we can achieve more complex extensions to the
protocol stack by extending this ops.

Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
To implement injection capability for smc via struct_ops, so that
user can make their own smc_ops to modify the behavior of smc stack.

Currently, user can write their own implememtion to choose whether to
use SMC or not before TCP 3rd handshake to be comleted. In the future,
users can implement more complex functions on smc by expanding it.

Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
When a struct_ops named xxx_ops was registered by a module, and
it will be used in both built-in modules and the module itself,
so that the btf_type of xxx_ops will be present in btf_vmlinux
instead of in btf_mod, which means that the btf_type of
bpf_struct_ops_xxx_ops and xxx_ops will not be in the same btf.

Here are four possible case:

+--------+---------------+-------------+---------------------------------+
|        | st_ops_xxx_ops| xxx_ops     |                                 |
+--------+---------------+-------------+---------------------------------+
| case 0 | btf_vmlinux   | bft_vmlinux | be used and reg only in vmlinux |
+--------+---------------+-------------+---------------------------------+
| case 1 | btf_vmlinux   | bpf_mod     | INVALID                         |
+--------+---------------+-------------+---------------------------------+
| case 2 | btf_mod       | btf_vmlinux | reg in mod but be used both in  |
|        |               |             | vmlinux and mod.                |
+--------+---------------+-------------+---------------------------------+
| case 3 | btf_mod       | btf_mod     | be used and reg only in mod     |
+--------+---------------+-------------+---------------------------------+

At present, cases 0, 1, and 3 can be correctly identified, because
st_ops_xxx_ops is searched from the same btf with xxx_ops. In order to
handle case 2 correctly without affecting other cases, we cannot simply
change the search method for st_ops_xxx_ops from find_btf_by_prefix_kind()
to find_ksym_btf_id(), because in this way, case 1 will not be
recognized anymore.

To address the issue, we always look for st_ops_xxx_ops first,
figure out the btf, and then look for xxx_ops with the very btf to avoid
such issue.

Fixes: 590a008 ("bpf: libbpf: Add STRUCT_OPS support")
Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 01f3ce5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=925965
version: 6

This tests introduces a tiny smc_ops for filtering SMC connections based on
IP pairs, and also adds a realistic topology model to verify this ops.

Also, we can only use SMC loopback under CI test, so an
additional configuration needs to be enabled.

Follow the steps below to run this test.

make -C tools/testing/selftests/bpf
cd tools/testing/selftests/bpf
sudo ./test_progs -t smc

Results shows:
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants