* [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups
@ 2024-05-14 1:13 Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 1/8] mptcp: SO_KEEPALIVE: fix getsockopt support Mat Martineau
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Mat Martineau @ 2024-05-14 1:13 UTC (permalink / raw)
To: mptcp, geliang, davem, edumazet, kuba, pabeni, fw; +Cc: Mat Martineau, netdev
This series contain mostly unrelated patches:
- The two first patches can be seen as "fixes". They are part of this
series for -next because it looks like the last batch of fixes for
v6.9 has already been sent. These fixes are not urgent, so they can
wait if an unlikely v6.9-rc8 is published. About the two patches:
- Patch 1 fixes getsockopt(SO_KEEPALIVE) support on MPTCP sockets
- Patch 2 makes sure the full TCP keep-alive feature is supported,
not just SO_KEEPALIVE.
- Patch 3 is a small optimisation when getsockopt(MPTCP_INFO) is used
without buffer, just to check if MPTCP is still being used: no
fallback to TCP.
- Patch 4 adds net.mptcp.available_schedulers sysctl knob to list packet
schedulers, similar to net.ipv4.tcp_available_congestion_control.
- Patch 5 and 6 fix CheckPatch warnings: "prefer strscpy over strcpy"
and "else is not generally useful after a break or return".
- Patch 7 and 8 remove and add header includes to avoid unused ones, and
add missing ones to be self-contained.
v2: Rebased
Gregory Detal (1):
mptcp: add net.mptcp.available_schedulers
Matthieu Baerts (NGI0) (7):
mptcp: SO_KEEPALIVE: fix getsockopt support
mptcp: fix full TCP keep-alive support
mptcp: sockopt: info: stop early if no buffer
mptcp: prefer strscpy over strcpy
mptcp: remove unnecessary else statements
mptcp: move mptcp_pm_gen.h's include
mptcp: include inet_common in mib.h
include/net/mptcp.h | 3 ++
net/mptcp/ctrl.c | 29 ++++++++++++++++--
net/mptcp/mib.h | 2 ++
net/mptcp/pm_netlink.c | 1 +
net/mptcp/pm_userspace.c | 1 +
net/mptcp/protocol.c | 5 +--
net/mptcp/protocol.h | 6 ++--
net/mptcp/sched.c | 22 ++++++++++++++
net/mptcp/sockopt.c | 66 ++++++++++++++++++++++++++++++++++++++--
net/mptcp/subflow.c | 32 ++++++++++---------
10 files changed, 143 insertions(+), 24 deletions(-)
--
2.45.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v2 1/8] mptcp: SO_KEEPALIVE: fix getsockopt support
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
@ 2024-05-14 1:13 ` Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 2/8] mptcp: fix full TCP keep-alive support Mat Martineau
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Mat Martineau @ 2024-05-14 1:13 UTC (permalink / raw)
To: mptcp, geliang, davem, edumazet, kuba, pabeni, fw
Cc: Matthieu Baerts (NGI0), netdev, Mat Martineau
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
SO_KEEPALIVE support has to be set on each subflow: on each TCP socket,
where sk_prot->keepalive is defined. Technically, nothing has to be done
on the MPTCP socket. That's why mptcp_sol_socket_sync_intval() was
called instead of mptcp_sol_socket_intval().
Except that when nothing is done on the MPTCP socket, the
getsockopt(SO_KEEPALIVE), handled in net/core/sock.c:sk_getsockopt(),
will not know if SO_KEEPALIVE has been set on the different subflows or
not.
The fix is simple: simply call mptcp_sol_socket_intval() which will end
up calling net/core/sock.c:sk_setsockopt() where the SOCK_KEEPOPEN flag
will be set, the one used in sk_getsockopt().
So now, getsockopt(SO_KEEPALIVE) on an MPTCP socket will return the same
value as the one previously set with setsockopt(SO_KEEPALIVE).
Fixes: 1b3e7ede1365 ("mptcp: setsockopt: handle SO_KEEPALIVE and SO_PRIORITY")
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Mat Martineau <martineau@kernel.org>
---
net/mptcp/sockopt.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index eaa3b79651a4..5ab506c96609 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -181,8 +181,6 @@ static int mptcp_setsockopt_sol_socket_int(struct mptcp_sock *msk, int optname,
switch (optname) {
case SO_KEEPALIVE:
- mptcp_sol_socket_sync_intval(msk, optname, val);
- return 0;
case SO_DEBUG:
case SO_MARK:
case SO_PRIORITY:
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 2/8] mptcp: fix full TCP keep-alive support
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 1/8] mptcp: SO_KEEPALIVE: fix getsockopt support Mat Martineau
@ 2024-05-14 1:13 ` Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 3/8] mptcp: sockopt: info: stop early if no buffer Mat Martineau
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Mat Martineau @ 2024-05-14 1:13 UTC (permalink / raw)
To: mptcp, geliang, davem, edumazet, kuba, pabeni, fw
Cc: Matthieu Baerts (NGI0), netdev, Mat Martineau
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
SO_KEEPALIVE support has been added a while ago, as part of a series
"adding SOL_SOCKET" support. To have a full control of this keep-alive
feature, it is important to also support TCP_KEEP* socket options at the
SOL_TCP level.
Supporting them on the setsockopt() part is easy, it is just a matter of
remembering each value in the MPTCP sock structure, and calling
tcp_sock_set_keep*() helpers on each subflow. If the value is not
modified (0), calling these helpers will not do anything. For the
getsockopt() part, the corresponding value from the MPTCP sock structure
or the default one is simply returned. All of this is very similar to
other TCP_* socket options supported by MPTCP.
It looks important for kernels supporting SO_KEEPALIVE, to also support
TCP_KEEP* options as well: some apps seem to (wrongly) consider that if
the former is supported, the latter ones will be supported as well. But
also, not having this simple and isolated change is preventing MPTCP
support in some apps, and libraries like GoLang [1]. This is why this
patch is seen as a fix.
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/383
Fixes: 1b3e7ede1365 ("mptcp: setsockopt: handle SO_KEEPALIVE and SO_PRIORITY")
Link: https://github.com/golang/go/issues/56539 [1]
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Mat Martineau <martineau@kernel.org>
---
net/mptcp/protocol.h | 3 +++
net/mptcp/sockopt.c | 58 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index cfc5f9c3f113..4dcce3641d1d 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -312,6 +312,9 @@ struct mptcp_sock {
free_first:1,
rcvspace_init:1;
u32 notsent_lowat;
+ int keepalive_cnt;
+ int keepalive_idle;
+ int keepalive_intvl;
struct work_struct work;
struct sk_buff *ooo_last_skb;
struct rb_root out_of_order_queue;
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index 5ab506c96609..fcca9433c858 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -622,6 +622,31 @@ static int mptcp_setsockopt_sol_tcp_congestion(struct mptcp_sock *msk, sockptr_t
return ret;
}
+static int __mptcp_setsockopt_set_val(struct mptcp_sock *msk, int max,
+ int (*set_val)(struct sock *, int),
+ int *msk_val, int val)
+{
+ struct mptcp_subflow_context *subflow;
+ int err = 0;
+
+ mptcp_for_each_subflow(msk, subflow) {
+ struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+ int ret;
+
+ lock_sock(ssk);
+ ret = set_val(ssk, val);
+ err = err ? : ret;
+ release_sock(ssk);
+ }
+
+ if (!err) {
+ *msk_val = val;
+ sockopt_seq_inc(msk);
+ }
+
+ return err;
+}
+
static int __mptcp_setsockopt_sol_tcp_cork(struct mptcp_sock *msk, int val)
{
struct mptcp_subflow_context *subflow;
@@ -818,6 +843,22 @@ static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
case TCP_NODELAY:
ret = __mptcp_setsockopt_sol_tcp_nodelay(msk, val);
break;
+ case TCP_KEEPIDLE:
+ ret = __mptcp_setsockopt_set_val(msk, MAX_TCP_KEEPIDLE,
+ &tcp_sock_set_keepidle_locked,
+ &msk->keepalive_idle, val);
+ break;
+ case TCP_KEEPINTVL:
+ ret = __mptcp_setsockopt_set_val(msk, MAX_TCP_KEEPINTVL,
+ &tcp_sock_set_keepintvl,
+ &msk->keepalive_intvl, val);
+ break;
+ case TCP_KEEPCNT:
+ ret = __mptcp_setsockopt_set_val(msk, MAX_TCP_KEEPCNT,
+ &tcp_sock_set_keepcnt,
+ &msk->keepalive_cnt,
+ val);
+ break;
default:
ret = -ENOPROTOOPT;
}
@@ -1326,6 +1367,8 @@ static int mptcp_put_int_option(struct mptcp_sock *msk, char __user *optval,
static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
char __user *optval, int __user *optlen)
{
+ struct sock *sk = (void *)msk;
+
switch (optname) {
case TCP_ULP:
case TCP_CONGESTION:
@@ -1344,6 +1387,18 @@ static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
return mptcp_put_int_option(msk, optval, optlen, msk->cork);
case TCP_NODELAY:
return mptcp_put_int_option(msk, optval, optlen, msk->nodelay);
+ case TCP_KEEPIDLE:
+ return mptcp_put_int_option(msk, optval, optlen,
+ msk->keepalive_idle ? :
+ READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_keepalive_time) / HZ);
+ case TCP_KEEPINTVL:
+ return mptcp_put_int_option(msk, optval, optlen,
+ msk->keepalive_intvl ? :
+ READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_keepalive_intvl) / HZ);
+ case TCP_KEEPCNT:
+ return mptcp_put_int_option(msk, optval, optlen,
+ msk->keepalive_cnt ? :
+ READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_keepalive_probes));
case TCP_NOTSENT_LOWAT:
return mptcp_put_int_option(msk, optval, optlen, msk->notsent_lowat);
case TCP_IS_MPTCP:
@@ -1463,6 +1518,9 @@ static void sync_socket_options(struct mptcp_sock *msk, struct sock *ssk)
tcp_set_congestion_control(ssk, msk->ca_name, false, true);
__tcp_sock_set_cork(ssk, !!msk->cork);
__tcp_sock_set_nodelay(ssk, !!msk->nodelay);
+ tcp_sock_set_keepidle_locked(ssk, msk->keepalive_idle);
+ tcp_sock_set_keepintvl(ssk, msk->keepalive_intvl);
+ tcp_sock_set_keepcnt(ssk, msk->keepalive_cnt);
inet_assign_bit(TRANSPARENT, ssk, inet_test_bit(TRANSPARENT, sk));
inet_assign_bit(FREEBIND, ssk, inet_test_bit(FREEBIND, sk));
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 3/8] mptcp: sockopt: info: stop early if no buffer
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 1/8] mptcp: SO_KEEPALIVE: fix getsockopt support Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 2/8] mptcp: fix full TCP keep-alive support Mat Martineau
@ 2024-05-14 1:13 ` Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 4/8] mptcp: add net.mptcp.available_schedulers Mat Martineau
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Mat Martineau @ 2024-05-14 1:13 UTC (permalink / raw)
To: mptcp, geliang, davem, edumazet, kuba, pabeni, fw
Cc: Matthieu Baerts (NGI0), netdev, Mat Martineau
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Up to recently, it has been recommended to use getsockopt(MPTCP_INFO) to
check if a fallback to TCP happened, or if the client requested to use
MPTCP.
In this case, the userspace app is only interested by the returned value
of the getsocktop() call, and can then give 0 for the option length, and
NULL for the buffer address. An easy optimisation is then to stop early,
and avoid filling a local buffer -- which now requires two different
locks -- if it is not needed.
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Mat Martineau <martineau@kernel.org>
---
net/mptcp/sockopt.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index fcca9433c858..a77b33488176 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -999,6 +999,10 @@ static int mptcp_getsockopt_info(struct mptcp_sock *msk, char __user *optval, in
if (get_user(len, optlen))
return -EFAULT;
+ /* When used only to check if a fallback to TCP happened. */
+ if (len == 0)
+ return 0;
+
len = min_t(unsigned int, len, sizeof(struct mptcp_info));
mptcp_diag_fill_info(msk, &m_info);
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 4/8] mptcp: add net.mptcp.available_schedulers
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
` (2 preceding siblings ...)
2024-05-14 1:13 ` [PATCH net-next v2 3/8] mptcp: sockopt: info: stop early if no buffer Mat Martineau
@ 2024-05-14 1:13 ` Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 5/8] mptcp: prefer strscpy over strcpy Mat Martineau
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Mat Martineau @ 2024-05-14 1:13 UTC (permalink / raw)
To: mptcp, geliang, davem, edumazet, kuba, pabeni, fw
Cc: Gregory Detal, netdev, Mat Martineau, Matthieu Baerts
From: Gregory Detal <gregory.detal@gmail.com>
The sysctl lists the available schedulers that can be set using
net.mptcp.scheduler similarly to net.ipv4.tcp_available_congestion_control.
Signed-off-by: Gregory Detal <gregory.detal@gmail.com>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Tested-by: Geliang Tang <geliang@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Mat Martineau <martineau@kernel.org>
---
include/net/mptcp.h | 3 +++
net/mptcp/ctrl.c | 27 ++++++++++++++++++++++++++-
net/mptcp/protocol.h | 1 +
net/mptcp/sched.c | 22 ++++++++++++++++++++++
4 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index fb996124b3d5..0bc4ab03f487 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -97,6 +97,9 @@ struct mptcp_out_options {
};
#define MPTCP_SCHED_NAME_MAX 16
+#define MPTCP_SCHED_MAX 128
+#define MPTCP_SCHED_BUF_MAX (MPTCP_SCHED_NAME_MAX * MPTCP_SCHED_MAX)
+
#define MPTCP_SUBFLOWS_MAX 8
struct mptcp_sched_data {
diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
index 49abf80b3fad..542555ba474c 100644
--- a/net/mptcp/ctrl.c
+++ b/net/mptcp/ctrl.c
@@ -133,6 +133,24 @@ static int proc_scheduler(struct ctl_table *ctl, int write,
return ret;
}
+static int proc_available_schedulers(struct ctl_table *ctl,
+ int write, void *buffer,
+ size_t *lenp, loff_t *ppos)
+{
+ struct ctl_table tbl = { .maxlen = MPTCP_SCHED_BUF_MAX, };
+ int ret;
+
+ tbl.data = kmalloc(tbl.maxlen, GFP_USER);
+ if (!tbl.data)
+ return -ENOMEM;
+
+ mptcp_get_available_schedulers(tbl.data, MPTCP_SCHED_BUF_MAX);
+ ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
+ kfree(tbl.data);
+
+ return ret;
+}
+
static struct ctl_table mptcp_sysctl_table[] = {
{
.procname = "enabled",
@@ -187,6 +205,12 @@ static struct ctl_table mptcp_sysctl_table[] = {
.mode = 0644,
.proc_handler = proc_scheduler,
},
+ {
+ .procname = "available_schedulers",
+ .maxlen = MPTCP_SCHED_BUF_MAX,
+ .mode = 0644,
+ .proc_handler = proc_available_schedulers,
+ },
{
.procname = "close_timeout",
.maxlen = sizeof(unsigned int),
@@ -214,7 +238,8 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
table[4].data = &pernet->stale_loss_cnt;
table[5].data = &pernet->pm_type;
table[6].data = &pernet->scheduler;
- table[7].data = &pernet->close_timeout;
+ /* table[7] is for available_schedulers which is read-only info */
+ table[8].data = &pernet->close_timeout;
hdr = register_net_sysctl_sz(net, MPTCP_SYSCTL_PATH, table,
ARRAY_SIZE(mptcp_sysctl_table));
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 4dcce3641d1d..39fc47e6b88a 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -686,6 +686,7 @@ unsigned int mptcp_stale_loss_cnt(const struct net *net);
unsigned int mptcp_close_timeout(const struct sock *sk);
int mptcp_get_pm_type(const struct net *net);
const char *mptcp_get_scheduler(const struct net *net);
+void mptcp_get_available_schedulers(char *buf, size_t maxlen);
void __mptcp_subflow_fully_established(struct mptcp_sock *msk,
struct mptcp_subflow_context *subflow,
const struct mptcp_options_received *mp_opt);
diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index 4ab0693c069c..4a7fd0508ad2 100644
--- a/net/mptcp/sched.c
+++ b/net/mptcp/sched.c
@@ -51,6 +51,28 @@ struct mptcp_sched_ops *mptcp_sched_find(const char *name)
return ret;
}
+/* Build string with list of available scheduler values.
+ * Similar to tcp_get_available_congestion_control()
+ */
+void mptcp_get_available_schedulers(char *buf, size_t maxlen)
+{
+ struct mptcp_sched_ops *sched;
+ size_t offs = 0;
+
+ rcu_read_lock();
+ spin_lock(&mptcp_sched_list_lock);
+ list_for_each_entry_rcu(sched, &mptcp_sched_list, list) {
+ offs += snprintf(buf + offs, maxlen - offs,
+ "%s%s",
+ offs == 0 ? "" : " ", sched->name);
+
+ if (WARN_ON_ONCE(offs >= maxlen))
+ break;
+ }
+ spin_unlock(&mptcp_sched_list_lock);
+ rcu_read_unlock();
+}
+
int mptcp_register_scheduler(struct mptcp_sched_ops *sched)
{
if (!sched->get_subflow)
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 5/8] mptcp: prefer strscpy over strcpy
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
` (3 preceding siblings ...)
2024-05-14 1:13 ` [PATCH net-next v2 4/8] mptcp: add net.mptcp.available_schedulers Mat Martineau
@ 2024-05-14 1:13 ` Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 6/8] mptcp: remove unnecessary else statements Mat Martineau
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Mat Martineau @ 2024-05-14 1:13 UTC (permalink / raw)
To: mptcp, geliang, davem, edumazet, kuba, pabeni, fw
Cc: Matthieu Baerts (NGI0), netdev, Mat Martineau
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
strcpy() performs no bounds checking on the destination buffer. This
could result in linear overflows beyond the end of the buffer, leading
to all kinds of misbehaviors. The safe replacement is strscpy() [1].
This is in preparation of a possible future step where all strcpy() uses
will be removed in favour of strscpy() [2].
This fixes CheckPatch warnings:
WARNING: Prefer strscpy over strcpy
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Link: https://github.com/KSPP/linux/issues/88 [2]
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Mat Martineau <martineau@kernel.org>
---
net/mptcp/ctrl.c | 2 +-
net/mptcp/protocol.c | 5 +++--
net/mptcp/sockopt.c | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
index 542555ba474c..98b1dd498ff6 100644
--- a/net/mptcp/ctrl.c
+++ b/net/mptcp/ctrl.c
@@ -92,7 +92,7 @@ static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet)
pernet->allow_join_initial_addr_port = 1;
pernet->stale_loss_cnt = 4;
pernet->pm_type = MPTCP_PM_TYPE_KERNEL;
- strcpy(pernet->scheduler, "default");
+ strscpy(pernet->scheduler, "default", sizeof(pernet->scheduler));
}
#ifdef CONFIG_SYSCTL
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index bb8f96f2b86f..a42494d3a71b 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2814,7 +2814,8 @@ static void mptcp_ca_reset(struct sock *sk)
struct inet_connection_sock *icsk = inet_csk(sk);
tcp_assign_congestion_control(sk);
- strcpy(mptcp_sk(sk)->ca_name, icsk->icsk_ca_ops->name);
+ strscpy(mptcp_sk(sk)->ca_name, icsk->icsk_ca_ops->name,
+ sizeof(mptcp_sk(sk)->ca_name));
/* no need to keep a reference to the ops, the name will suffice */
tcp_cleanup_congestion_control(sk);
@@ -4169,7 +4170,7 @@ int __init mptcp_proto_v6_init(void)
int err;
mptcp_v6_prot = mptcp_prot;
- strcpy(mptcp_v6_prot.name, "MPTCPv6");
+ strscpy(mptcp_v6_prot.name, "MPTCPv6", sizeof(mptcp_v6_prot.name));
mptcp_v6_prot.slab = NULL;
mptcp_v6_prot.obj_size = sizeof(struct mptcp6_sock);
mptcp_v6_prot.ipv6_pinfo_offset = offsetof(struct mptcp6_sock, np);
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index a77b33488176..f9a4fb17b5b7 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -616,7 +616,7 @@ static int mptcp_setsockopt_sol_tcp_congestion(struct mptcp_sock *msk, sockptr_t
}
if (ret == 0)
- strcpy(msk->ca_name, name);
+ strscpy(msk->ca_name, name, sizeof(msk->ca_name));
release_sock(sk);
return ret;
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 6/8] mptcp: remove unnecessary else statements
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
` (4 preceding siblings ...)
2024-05-14 1:13 ` [PATCH net-next v2 5/8] mptcp: prefer strscpy over strcpy Mat Martineau
@ 2024-05-14 1:13 ` Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 7/8] mptcp: move mptcp_pm_gen.h's include Mat Martineau
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Mat Martineau @ 2024-05-14 1:13 UTC (permalink / raw)
To: mptcp, geliang, davem, edumazet, kuba, pabeni, fw
Cc: Matthieu Baerts (NGI0), netdev, Mat Martineau
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
The 'else' statements are not needed here, because their previous 'if'
block ends with a 'return'.
This fixes CheckPatch warnings:
WARNING: else is not generally useful after a break or return
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Mat Martineau <martineau@kernel.org>
---
net/mptcp/subflow.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index c1d13e555d10..612c38570a64 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1119,6 +1119,8 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
}
if (mpext->data_fin == 1) {
+ u64 data_fin_seq;
+
if (data_len == 1) {
bool updated = mptcp_update_rcv_data_fin(msk, mpext->data_seq,
mpext->dsn64);
@@ -1131,26 +1133,26 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
*/
skb_ext_del(skb, SKB_EXT_MPTCP);
return MAPPING_OK;
- } else {
- if (updated)
- mptcp_schedule_work((struct sock *)msk);
-
- return MAPPING_DATA_FIN;
}
- } else {
- u64 data_fin_seq = mpext->data_seq + data_len - 1;
- /* If mpext->data_seq is a 32-bit value, data_fin_seq
- * must also be limited to 32 bits.
- */
- if (!mpext->dsn64)
- data_fin_seq &= GENMASK_ULL(31, 0);
+ if (updated)
+ mptcp_schedule_work((struct sock *)msk);
- mptcp_update_rcv_data_fin(msk, data_fin_seq, mpext->dsn64);
- pr_debug("DATA_FIN with mapping seq=%llu dsn64=%d",
- data_fin_seq, mpext->dsn64);
+ return MAPPING_DATA_FIN;
}
+ data_fin_seq = mpext->data_seq + data_len - 1;
+
+ /* If mpext->data_seq is a 32-bit value, data_fin_seq must also
+ * be limited to 32 bits.
+ */
+ if (!mpext->dsn64)
+ data_fin_seq &= GENMASK_ULL(31, 0);
+
+ mptcp_update_rcv_data_fin(msk, data_fin_seq, mpext->dsn64);
+ pr_debug("DATA_FIN with mapping seq=%llu dsn64=%d",
+ data_fin_seq, mpext->dsn64);
+
/* Adjust for DATA_FIN using 1 byte of sequence space */
data_len--;
}
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 7/8] mptcp: move mptcp_pm_gen.h's include
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
` (5 preceding siblings ...)
2024-05-14 1:13 ` [PATCH net-next v2 6/8] mptcp: remove unnecessary else statements Mat Martineau
@ 2024-05-14 1:13 ` Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 8/8] mptcp: include inet_common in mib.h Mat Martineau
2024-05-14 1:40 ` [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups patchwork-bot+netdevbpf
8 siblings, 0 replies; 10+ messages in thread
From: Mat Martineau @ 2024-05-14 1:13 UTC (permalink / raw)
To: mptcp, geliang, davem, edumazet, kuba, pabeni, fw
Cc: Matthieu Baerts (NGI0), netdev, Mat Martineau
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Nothing from protocol.h depends on mptcp_pm_gen.h, only code from
pm_netlink.c and pm_userspace.c depends on it.
So this include can be moved where it is needed to avoid a "unused
includes" warning.
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Mat Martineau <martineau@kernel.org>
---
net/mptcp/pm_netlink.c | 1 +
net/mptcp/pm_userspace.c | 1 +
net/mptcp/protocol.h | 2 --
3 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 5c17d39146ea..7f53e022e27e 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -14,6 +14,7 @@
#include "protocol.h"
#include "mib.h"
+#include "mptcp_pm_gen.h"
static int pm_nl_pernet_id;
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 9f5d422d5ef6..f0a4590506c6 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -6,6 +6,7 @@
#include "protocol.h"
#include "mib.h"
+#include "mptcp_pm_gen.h"
void mptcp_free_local_addr_list(struct mptcp_sock *msk)
{
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 39fc47e6b88a..7aa47e2dd52b 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -14,8 +14,6 @@
#include <net/genetlink.h>
#include <net/rstreason.h>
-#include "mptcp_pm_gen.h"
-
#define MPTCP_SUPPORTED_VERSION 1
/* MPTCP option bits */
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 8/8] mptcp: include inet_common in mib.h
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
` (6 preceding siblings ...)
2024-05-14 1:13 ` [PATCH net-next v2 7/8] mptcp: move mptcp_pm_gen.h's include Mat Martineau
@ 2024-05-14 1:13 ` Mat Martineau
2024-05-14 1:40 ` [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups patchwork-bot+netdevbpf
8 siblings, 0 replies; 10+ messages in thread
From: Mat Martineau @ 2024-05-14 1:13 UTC (permalink / raw)
To: mptcp, geliang, davem, edumazet, kuba, pabeni, fw
Cc: Matthieu Baerts (NGI0), netdev, Mat Martineau
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
So this file is now self-contained: it can be compiled alone with
analytic tools.
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Mat Martineau <martineau@kernel.org>
---
net/mptcp/mib.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h
index dd7fd1f246b5..2704afd0dfe4 100644
--- a/net/mptcp/mib.h
+++ b/net/mptcp/mib.h
@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include <net/inet_common.h>
+
enum linux_mptcp_mib_field {
MPTCP_MIB_NUM = 0,
MPTCP_MIB_MPCAPABLEPASSIVE, /* Received SYN with MP_CAPABLE */
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
` (7 preceding siblings ...)
2024-05-14 1:13 ` [PATCH net-next v2 8/8] mptcp: include inet_common in mib.h Mat Martineau
@ 2024-05-14 1:40 ` patchwork-bot+netdevbpf
8 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-14 1:40 UTC (permalink / raw)
To: Mat Martineau; +Cc: mptcp, geliang, davem, edumazet, kuba, pabeni, fw, netdev
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 13 May 2024 18:13:24 -0700 you wrote:
> This series contain mostly unrelated patches:
>
> - The two first patches can be seen as "fixes". They are part of this
> series for -next because it looks like the last batch of fixes for
> v6.9 has already been sent. These fixes are not urgent, so they can
> wait if an unlikely v6.9-rc8 is published. About the two patches:
> - Patch 1 fixes getsockopt(SO_KEEPALIVE) support on MPTCP sockets
> - Patch 2 makes sure the full TCP keep-alive feature is supported,
> not just SO_KEEPALIVE.
>
> [...]
Here is the summary with links:
- [net-next,v2,1/8] mptcp: SO_KEEPALIVE: fix getsockopt support
https://git.kernel.org/netdev/net-next/c/a65198136eaa
- [net-next,v2,2/8] mptcp: fix full TCP keep-alive support
https://git.kernel.org/netdev/net-next/c/bd11dc4fb969
- [net-next,v2,3/8] mptcp: sockopt: info: stop early if no buffer
https://git.kernel.org/netdev/net-next/c/ce5f6f71b029
- [net-next,v2,4/8] mptcp: add net.mptcp.available_schedulers
https://git.kernel.org/netdev/net-next/c/73c900aa3660
- [net-next,v2,5/8] mptcp: prefer strscpy over strcpy
https://git.kernel.org/netdev/net-next/c/5eae7a8202f3
- [net-next,v2,6/8] mptcp: remove unnecessary else statements
https://git.kernel.org/netdev/net-next/c/00797af95f5e
- [net-next,v2,7/8] mptcp: move mptcp_pm_gen.h's include
https://git.kernel.org/netdev/net-next/c/76a86686e3f0
- [net-next,v2,8/8] mptcp: include inet_common in mib.h
https://git.kernel.org/netdev/net-next/c/7fad5b375611
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-05-14 1:40 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-14 1:13 [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 1/8] mptcp: SO_KEEPALIVE: fix getsockopt support Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 2/8] mptcp: fix full TCP keep-alive support Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 3/8] mptcp: sockopt: info: stop early if no buffer Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 4/8] mptcp: add net.mptcp.available_schedulers Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 5/8] mptcp: prefer strscpy over strcpy Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 6/8] mptcp: remove unnecessary else statements Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 7/8] mptcp: move mptcp_pm_gen.h's include Mat Martineau
2024-05-14 1:13 ` [PATCH net-next v2 8/8] mptcp: include inet_common in mib.h Mat Martineau
2024-05-14 1:40 ` [PATCH net-next v2 0/8] mptcp: small improvements, fix and clean-ups patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox