[MPTCP][PATCH mptcp-next] Squash to "mptcp: use WRITE_ONCE/READ_ONCE for the pernet *_max"
by Geliang Tang
As Jakub suggested, drop all the READ_ONCEs in the original patch.
And the commit message needs to be updated too:
-
Subject: mptcp: use WRITE_ONCE for the pernet *_max
This patch uses WRITE_ONCE() for all the pernet add_addr_signal_max,
add_addr_accept_max, local_addr_max and subflows_max fields in struct
pm_nl_pernet to avoid concurrency issues.
-
Signed-off-by: Geliang Tang <geliangtang(a)gmail.com>
---
net/mptcp/pm_netlink.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 7d6081d9a1db..c429bd82313e 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -616,11 +616,11 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
pernet->next_id = entry->addr.id;
if (entry->addr.flags & MPTCP_PM_ADDR_FLAG_SIGNAL) {
- addr_max = READ_ONCE(pernet->add_addr_signal_max);
+ addr_max = pernet->add_addr_signal_max;
WRITE_ONCE(pernet->add_addr_signal_max, addr_max + 1);
}
if (entry->addr.flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) {
- addr_max = READ_ONCE(pernet->local_addr_max);
+ addr_max = pernet->local_addr_max;
WRITE_ONCE(pernet->local_addr_max, addr_max + 1);
}
@@ -932,11 +932,11 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info)
return -EINVAL;
}
if (entry->addr.flags & MPTCP_PM_ADDR_FLAG_SIGNAL) {
- addr_max = READ_ONCE(pernet->add_addr_signal_max);
+ addr_max = pernet->add_addr_signal_max;
WRITE_ONCE(pernet->add_addr_signal_max, addr_max - 1);
}
if (entry->addr.flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) {
- addr_max = READ_ONCE(pernet->local_addr_max);
+ addr_max = pernet->local_addr_max;
WRITE_ONCE(pernet->local_addr_max, addr_max - 1);
}
@@ -1140,12 +1140,12 @@ mptcp_nl_cmd_set_limits(struct sk_buff *skb, struct genl_info *info)
int ret;
spin_lock_bh(&pernet->lock);
- rcv_addrs = READ_ONCE(pernet->add_addr_accept_max);
+ rcv_addrs = pernet->add_addr_accept_max;
ret = parse_limit(info, MPTCP_PM_ATTR_RCV_ADD_ADDRS, &rcv_addrs);
if (ret)
goto unlock;
- subflows = READ_ONCE(pernet->subflows_max);
+ subflows = pernet->subflows_max;
ret = parse_limit(info, MPTCP_PM_ATTR_SUBFLOWS, &subflows);
if (ret)
goto unlock;
--
2.29.2
1 year, 3 months
[MPTCP][PATCH v2 mptcp-next 0/7] RM_ADDR: remove a list of addrs
by Geliang Tang
v2:
- use an array of ids instead of a u64 map
- drop "mptcp: update the netlink event for rm_addr" in v1
- tag: export/20210131T062218
This patchset added the removing a list of addresses support for
RM_ADDR. It addressed issue #140.
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/140
Geliang Tang (7):
mptcp: remove multi addrs on outgoing path
mptcp: remove multi addrs on incoming path
mptcp: remove multi addresses in PM
mptcp: remove multi subflows in PM
mptcp: implement mptcp_nl_remove_addrs_and_subflows
mptcp: remove a list of addrs when flushing
selftests: mptcp: add testcases for removing addrs
include/net/mptcp.h | 4 +-
net/mptcp/options.c | 55 +++--
net/mptcp/pm.c | 28 +--
net/mptcp/pm_netlink.c | 190 ++++++++++++++----
net/mptcp/protocol.h | 26 ++-
.../testing/selftests/net/mptcp/mptcp_join.sh | 23 +++
6 files changed, 252 insertions(+), 74 deletions(-)
--
2.29.2
1 year, 3 months
[PATCH net-next v3] mptcp: fix length of MP_PRIO suboption
by Davide Caratti
With version 0 of the protocol it was legal to encode the 'Subflow Id' in
the MP_PRIO suboption, to specify which subflow would change its 'Backup'
flag. This has been removed from v1 specification: thus, according to RFC
8684 §3.3.8, the resulting 'Length' for MP_PRIO changed from 4 to 3 byte.
Current Linux generates / parses MP_PRIO according to the old spec, using
'Length' equal to 4, and hardcoding 1 as 'Subflow Id'; RFC compliance can
improve if we change 'Length' in other to become 3, leaving a 'Nop' after
the MP_PRIO suboption. In this way the kernel will emit and accept *only*
MP_PRIO suboptions that are compliant to version 1 of the MPTCP protocol.
unpatched 5.11-rc kernel:
[root@bottarga ~]# tcpdump -tnnr unpatched.pcap | grep prio
reading from file unpatched.pcap, link-type LINUX_SLL (Linux cooked v1)
dropped privs to tcpdump
IP 10.0.3.2.48433 > 10.0.1.1.10006: Flags [.], ack 1, win 502, options [nop,nop,TS val 4032325513 ecr 1876514270,mptcp prio non-backup id 1,mptcp dss ack 14084896651682217737], length 0
patched 5.11-rc kernel:
[root@bottarga ~]# tcpdump -tnnr patched.pcap | grep prio
reading from file patched.pcap, link-type LINUX_SLL (Linux cooked v1)
dropped privs to tcpdump
IP 10.0.3.2.49735 > 10.0.1.1.10006: Flags [.], ack 1, win 502, options [nop,nop,TS val 1276737699 ecr 2686399734,mptcp prio non-backup,nop,mptcp dss ack 18433038869082491686], length 0
Changes since v2:
- when accounting for option space, don't increment 'TCPOLEN_MPTCP_PRIO'
and use 'TCPOLEN_MPTCP_PRIO_ALIGN' instead, thanks to Matthieu Baerts.
Changes since v1:
- refactor patch to avoid using 'TCPOLEN_MPTCP_PRIO' with its old value,
thanks to Geliang Tang.
Fixes: 067065422fcd ("mptcp: add the outgoing MP_PRIO support")
Signed-off-by: Davide Caratti <dcaratti(a)redhat.com>
---
net/mptcp/options.c | 5 +++--
net/mptcp/protocol.h | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 775f0576592e..bb874c5d663a 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -699,10 +699,11 @@ static bool mptcp_established_options_mp_prio(struct sock *sk,
if (!subflow->send_mp_prio)
return false;
- if (remaining < TCPOLEN_MPTCP_PRIO)
+ /* account for the trailing 'nop' option */
+ if (remaining < TCPOLEN_MPTCP_PRIO_ALIGN)
return false;
- *size = TCPOLEN_MPTCP_PRIO;
+ *size = TCPOLEN_MPTCP_PRIO_ALIGN;
opts->suboptions |= OPTION_MPTCP_PRIO;
opts->backup = subflow->request_bkup;
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 447ce4631b43..d31edbae8da8 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -61,7 +61,8 @@
#define TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT 24
#define TCPOLEN_MPTCP_PORT_LEN 4
#define TCPOLEN_MPTCP_RM_ADDR_BASE 4
-#define TCPOLEN_MPTCP_PRIO 4
+#define TCPOLEN_MPTCP_PRIO 3
+#define TCPOLEN_MPTCP_PRIO_ALIGN 4
#define TCPOLEN_MPTCP_FASTCLOSE 12
/* MPTCP MP_JOIN flags */
--
2.29.2
1 year, 3 months