[PATCH mptcp-net v3 2/6] mptcp: introduce MAPPING_BAD_CSUM

Paolo Abeni posted 6 patches 3 years, 3 months ago
Maintainers: Geliang Tang <geliangtang@xiaomi.com>, Paolo Abeni <pabeni@redhat.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Geliang Tang <geliang.tang@suse.com>
There is a newer version of this series
[PATCH mptcp-net v3 2/6] mptcp: introduce MAPPING_BAD_CSUM
Posted by Paolo Abeni 3 years, 3 months ago
This allow moving a couple of conditional out of the fast path,
making the code more easy to follow and will simplify the next
patch.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/subflow.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 57d2d8d933d0..98b12a9c4eb5 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -843,7 +843,8 @@ enum mapping_status {
 	MAPPING_INVALID,
 	MAPPING_EMPTY,
 	MAPPING_DATA_FIN,
-	MAPPING_DUMMY
+	MAPPING_DUMMY,
+	MAPPING_BAD_CSUM
 };
 
 static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn)
@@ -958,9 +959,7 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff *
 				 subflow->map_data_csum);
 	if (unlikely(csum)) {
 		MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DATACSUMERR);
-		if (subflow->mp_join || subflow->valid_csum_seen)
-			subflow->send_mp_fail = 1;
-		return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY;
+		return MAPPING_BAD_CSUM;
 	}
 
 	subflow->valid_csum_seen = 1;
@@ -1178,10 +1177,8 @@ static bool subflow_check_data_avail(struct sock *ssk)
 
 		status = get_mapping_status(ssk, msk);
 		trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue));
-		if (unlikely(status == MAPPING_INVALID))
-			goto fallback;
-
-		if (unlikely(status == MAPPING_DUMMY))
+		if (unlikely(status == MAPPING_INVALID || status == MAPPING_DUMMY ||
+			     status == MAPPING_BAD_CSUM))
 			goto fallback;
 
 		if (status != MAPPING_OK)
@@ -1223,7 +1220,10 @@ static bool subflow_check_data_avail(struct sock *ssk)
 fallback:
 	if (!__mptcp_check_fallback(msk)) {
 		/* RFC 8684 section 3.7. */
-		if (subflow->send_mp_fail) {
+		if (status == MAPPING_BAD_CSUM &&
+		    ((subflow->mp_join || subflow->valid_csum_seen))) {
+			subflow->send_mp_fail = 1;
+
 			if (!READ_ONCE(msk->allow_infinite_fallback)) {
 				ssk->sk_err = EBADMSG;
 				tcp_set_state(ssk, TCP_CLOSE);
-- 
2.35.3


Re: [PATCH mptcp-net v3 2/6] mptcp: introduce MAPPING_BAD_CSUM
Posted by Mat Martineau 3 years, 3 months ago
On Fri, 17 Jun 2022, Paolo Abeni wrote:

> This allow moving a couple of conditional out of the fast path,
> making the code more easy to follow and will simplify the next
> patch.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

I've had a few rounds of feedback from Jakub about the Fixes: tag in the 
last few months - whether missing for -net or questionable inclusion in 
net-next... So I'd like to get this right :)

Given that this is tied to the following patch ("mptcp: invoke MP_FAIL 
response when needed"), and that patch "Fixes:" a patch that's only in the 
5.19rc series, I don't think a missing tag here is harmful. But I'm not 
sure what Jakub will want.

One option is to duplicate the "Fixes: d9fb797046c5" line from "mptcp: 
invoke MP_FAIL response when needed".

What do you think Paolo?


- Mat

> ---
> net/mptcp/subflow.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 57d2d8d933d0..98b12a9c4eb5 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -843,7 +843,8 @@ enum mapping_status {
> 	MAPPING_INVALID,
> 	MAPPING_EMPTY,
> 	MAPPING_DATA_FIN,
> -	MAPPING_DUMMY
> +	MAPPING_DUMMY,
> +	MAPPING_BAD_CSUM
> };
>
> static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn)
> @@ -958,9 +959,7 @@ static enum mapping_status validate_data_csum(struct sock *ssk, struct sk_buff *
> 				 subflow->map_data_csum);
> 	if (unlikely(csum)) {
> 		MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DATACSUMERR);
> -		if (subflow->mp_join || subflow->valid_csum_seen)
> -			subflow->send_mp_fail = 1;
> -		return subflow->mp_join ? MAPPING_INVALID : MAPPING_DUMMY;
> +		return MAPPING_BAD_CSUM;
> 	}
>
> 	subflow->valid_csum_seen = 1;
> @@ -1178,10 +1177,8 @@ static bool subflow_check_data_avail(struct sock *ssk)
>
> 		status = get_mapping_status(ssk, msk);
> 		trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue));
> -		if (unlikely(status == MAPPING_INVALID))
> -			goto fallback;
> -
> -		if (unlikely(status == MAPPING_DUMMY))
> +		if (unlikely(status == MAPPING_INVALID || status == MAPPING_DUMMY ||
> +			     status == MAPPING_BAD_CSUM))
> 			goto fallback;
>
> 		if (status != MAPPING_OK)
> @@ -1223,7 +1220,10 @@ static bool subflow_check_data_avail(struct sock *ssk)
> fallback:
> 	if (!__mptcp_check_fallback(msk)) {
> 		/* RFC 8684 section 3.7. */
> -		if (subflow->send_mp_fail) {
> +		if (status == MAPPING_BAD_CSUM &&
> +		    ((subflow->mp_join || subflow->valid_csum_seen))) {
> +			subflow->send_mp_fail = 1;
> +
> 			if (!READ_ONCE(msk->allow_infinite_fallback)) {
> 				ssk->sk_err = EBADMSG;
> 				tcp_set_state(ssk, TCP_CLOSE);
> -- 
> 2.35.3
>
>
>

--
Mat Martineau
Intel

Re: [PATCH mptcp-net v3 2/6] mptcp: introduce MAPPING_BAD_CSUM
Posted by Paolo Abeni 3 years, 2 months ago
On Fri, 2022-06-17 at 16:13 -0700, Mat Martineau wrote:
> On Fri, 17 Jun 2022, Paolo Abeni wrote:
> 
> > This allow moving a couple of conditional out of the fast path,
> > making the code more easy to follow and will simplify the next
> > patch.
> > 
> > Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> 
> I've had a few rounds of feedback from Jakub about the Fixes: tag in the 
> last few months - whether missing for -net or questionable inclusion in 
> net-next... So I'd like to get this right :)
> 
> Given that this is tied to the following patch ("mptcp: invoke MP_FAIL 
> response when needed"), and that patch "Fixes:" a patch that's only in the 
> 5.19rc series, I don't think a missing tag here is harmful. But I'm not 
> sure what Jakub will want.
> 
> One option is to duplicate the "Fixes: d9fb797046c5" line from "mptcp: 
> invoke MP_FAIL response when needed".
> 
> What do you think Paolo?

I thought about the tagging, and I think this should be fine as is.

Thanks,

Paolo