Skip to content

Python-BCC: support fmod_ret attaching method, and add a useful tool for mptcp#5274

Merged
chenhengqi merged 3 commits into
iovisor:masterfrom
Dwyane-Yan:fmod_ret
May 9, 2025
Merged

Python-BCC: support fmod_ret attaching method, and add a useful tool for mptcp#5274
chenhengqi merged 3 commits into
iovisor:masterfrom
Dwyane-Yan:fmod_ret

Conversation

@Dwyane-Yan

@Dwyane-Yan Dwyane-Yan commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Multipath TCP (MPTCP) serves as an enhancement to the conventional TCP
protocol, enabling a single transport-layer connection to leverage
multiple network interfaces. This capability makes MPTCP advantageous
for applications requiring bandwidth consolidation, seamless failover
mechanisms, and more robust connectivity solutions.

Linux kernel starts to support MPTCP since v5.6, and it provides a
fmod_ret interface 'update_socket_protocol' to force applications using
MPTCP instead of TCP without modifyiing its code.

So these patches provide a tool named 'mptcpify' which can achieve this.
Using python-BCC is a more easy way for future development, so it is so
important to support 'fmod_ret' in python-BCC.

The first patch is suggested by Yonghong:
‘’‘
On Sun, 2024-08-25 at 21:05 -0700, Yonghong Song wrote:
...
> Gang Yan, could you explore to add fmod_ret support in bcc? It should
> be similar to kfunc/kretfunc support. I am happy to review your patches.
’‘’
when I try to make a commit to kernel. (Link attached below)
https://patchwork.kernel.org/project/netdevbpf/patch/tencent_1E619C9E44C8C4B2B713A0D6DD45B92BF70A@qq.com/

@matttbe from the MPTCP kernel team had a look at the new tool.

Comment thread src/python/bcc/__init__.py Outdated
Comment thread tools/mptcpify.py
Comment thread tools/mptcpify.txt Outdated
Comment thread tools/mptcpify.txt Outdated
Comment thread src/cc/libbpf.c
Comment thread src/python/bcc/__init__.py
Comment thread src/python/bcc/__init__.py
Comment thread tools/mptcpify.py Outdated
@Dwyane-Yan Dwyane-Yan requested a review from chenhengqi April 15, 2025 03:20
Comment thread src/python/bcc/__init__.py Outdated
@Dwyane-Yan

Copy link
Copy Markdown
Contributor Author

Hi @chenhengqi and @yonghong-song,

It was truly delightful to receive your valuable suggestions regarding this pull request. I'm pleased to inform you that all the issues have now been addressed. Would you mind taking another look at it when you have a moment?

Thank you so much!

Comment thread src/cc/libbpf.c Outdated
Comment thread src/python/bcc/__init__.py
Followed by the suggestions of Hengqi, which judging the kernel whether
supported 'fmod_ret' by using 'kernel_struct_has_field' to check the
existence of enum 'BPF_MODIFY_RETURN'.

But, the 'kernel_struct_has_filed' is not supported the 'enum' type, so
this patch provides an interface 'kernel_enum_has_val' to achieve this.

Co-developed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
In kernel, there exists a lot of 'fmod_ret' functions, such as
'update_socket_protocol'. But it cannot attached in BCC-python directly,
so this patch provides an interface for python to use 'fmod_ret'
attaching method.

This patch is suggested by Yonghong:

'''
On Sun, 2024-08-25 at 21:05 -0700, Yonghong Song wrote:
...
> Gang Yan, could you explore to add fmod_ret support in bcc? It should
> be similar to kfunc/kretfunc support. I am happy to review your patches.
'''

And the method to check 'fmod_ret' support in kernel is from Hengqi.

Co-developed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Multipath TCP (MPTCP) is an extension of the standard TCP protocol
that allows a single transport connection to use multiple network
interfaces or paths. MPTCP is useful for applications like bandwidth
aggregation, failover, and more resilient connections.

Linux kernel starts to support MPTCP since v5.6, this patch provides
a method which can easily force applications use MPTCP socket without
modifing its code.

Co-developed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
@Dwyane-Yan Dwyane-Yan requested a review from chenhengqi April 30, 2025 02:43

@chenhengqi chenhengqi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@Dwyane-Yan

Copy link
Copy Markdown
Contributor Author

Hi, @chenhengqi ,
Many tests has been skipped in CI, should it be triggered again?
Thanks!

@Dwyane-Yan Dwyane-Yan requested a review from chenhengqi May 8, 2025 06:50
@chenhengqi chenhengqi merged commit 27dee08 into iovisor:master May 9, 2025
1 of 23 checks passed
@chenhengqi

Copy link
Copy Markdown
Collaborator

Just merged. The CI need to be fixed. Will investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants