[PATCH mptcp-next v8 6/8] mptcp: allow sending both ADD_ADDR and RM_ADDR

Matthieu Baerts posted 8 patches 4 years, 1 month ago
Maintainers: "David S. Miller" <davem@davemloft.net>, Geliang Tang <geliangtang@xiaomi.com>, Andrii Nakryiko <andrii@kernel.org>, Yonghong Song <yhs@fb.com>, John Fastabend <john.fastabend@gmail.com>, Paolo Abeni <pabeni@redhat.com>, KP Singh <kpsingh@kernel.org>, Shuah Khan <shuah@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Song Liu <songliubraving@fb.com>, Daniel Borkmann <daniel@iogearbox.net>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, Martin KaFai Lau <kafai@fb.com>
There is a newer version of this series
[PATCH mptcp-next v8 6/8] mptcp: allow sending both ADD_ADDR and RM_ADDR
Posted by Matthieu Baerts 4 years, 1 month ago
This is mainly to be sync with what is done in mptcp_write_options()
where after having written the ADD_ADDR option, we check if the RM_ADDR
option also needs to be added.

But if we have room, it makes sense to write the two options in the same
packet. So best to remove the 'else'.

While at it, also mention that mptcp_established_options_add_addr() can
remove options.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 net/mptcp/options.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 8553b928c5bf..06f64101d27b 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -864,11 +864,14 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 
 	*size += opt_size;
 	remaining -= opt_size;
+	/* Note: this can remove previously set options in some conditions */
 	if (mptcp_established_options_add_addr(sk, skb, &opt_size, remaining, opts)) {
 		*size += opt_size;
 		remaining -= opt_size;
 		ret = true;
-	} else if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, opts)) {
+	}
+
+	if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, opts)) {
 		*size += opt_size;
 		remaining -= opt_size;
 		ret = true;
-- 
2.33.1