Skip to content

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

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Dwyane-Yan
Copy link

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

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/[email protected]/

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

Gang Yan added 3 commits April 21, 2025 10:54
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 <[email protected]>
Signed-off-by: Geliang Tang <[email protected]>
Signed-off-by: Gang Yan <[email protected]>
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 <[email protected]>
Signed-off-by: Geliang Tang <[email protected]>
Signed-off-by: Gang Yan <[email protected]>
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 <[email protected]>
Signed-off-by: Geliang Tang <[email protected]>
Signed-off-by: Gang Yan <[email protected]>
@Dwyane-Yan
Copy link
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!

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