mptcp: implement IPV6_TCLASS socket option support
Subsystems (2)
Geliang Tang
reviewerPATCH 1/1 mptcp: implement IPV6_TCLASS socket option support
From: Geliang Tang <[email protected]>
This patch adds full support for the IPV6_TCLASS socket option in MPTCP, ensuring consistent traffic class handling across all subflows.
Key changes:
1. setsockopt(IPV6_TCLASS):
- First sets the traffic class value on the main MPTCP socket
- Propagates the new value to all existing subflows
- Uses lock synchronization to ensure atomic updates
2. getsockopt(IPV6_TCLASS):
- Returns the current traffic class value stored in the main socket's inet6_sk structure
This implementation mirrors the existing IPv4 TOS handling (IP_TOS) and ensures QoS settings are consistently applied to all underlying TCP connections in the MPTCP session.
--- net/mptcp/sockopt.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
net/mptcp/sockopt.c +32 -0
@@ -384,6 +384,33 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname,return -EOPNOTSUPP ; } +static int mptcp_setsockopt_v6_set_tclass (struct mptcp_sock *msk,int optname, +sockptr_t optval,unsigned int optlen) +{ +struct mptcp_subflow_context *subflow; +struct sock *sk = (struct sock *)msk; +int err, val; + + err =ipv6_setsockopt (sk,SOL_IPV6 , optname, optval, optlen); +if (err) +return err; + +lock_sock (sk); +sockopt_seq_inc (msk); + val =READ_ONCE (inet6_sk (sk)->tclass); +mptcp_for_each_subflow (msk, subflow) { +struct sock *ssk =mptcp_subflow_tcp_sock (subflow); +bool slow; + + slow =lock_sock_fast (ssk); +inet6_sk (ssk)->tclass = val; +unlock_sock_fast (ssk, slow); + } +release_sock (sk); + +return 0 ; +} +static int mptcp_setsockopt_v6 (struct mptcp_sock *msk,int optname,sockptr_t optval,unsigned int optlen) {
@@ -426,6 +453,8 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname,release_sock (sk);break ; +case IPV6_TCLASS : +return mptcp_setsockopt_v6_set_tclass (msk, optname, optval, optlen); }return ret;
@@ -1475,6 +1504,9 @@ static int mptcp_getsockopt_v6(struct mptcp_sock *msk, int optname,case IPV6_FREEBIND :return mptcp_put_int_option (msk, optval, optlen,inet_test_bit (FREEBIND , sk)); +case IPV6_TCLASS : +return mptcp_put_int_option (msk, optval, optlen, +inet6_sk (sk)->tclass); }return -EOPNOTSUPP ;
Signature · 1 line
2.48.1
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Geliang,
kernel test robot noticed the following build errors:
[auto build test ERROR on mptcp/export]
[also build test ERROR on mptcp/export-net linus/master v6.16 next-20250801] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/mptcp-implement-IPV6_TCLASS-socket-option-support/20250801-175837 base: https://github.com/multipath-tcp/mptcp_net-next.git export patch link: https://lore.kernel.org/r/7979be7e1b82de6ba2eeb8dbda37e1e443636862.1754042175.git.tanggeliang%40kylinos.cn patch subject: [PATCH mptcp-next] mptcp: implement IPV6_TCLASS socket option support config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20250802/[email protected]/config) compiler: or1k-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250802/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
or1k-linux-ld: net/mptcp/sockopt.o: in function `mptcp_setsockopt_v6':
>> sockopt.c:(.text+0x854): undefined reference to `ipv6_setsockopt' >> sockopt.c:(.text+0x854): relocation truncated to fit: R_OR1K_INSN_REL_26 against undefined symbol `ipv6_setsockopt'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki