Skip to contentSkip to conversation

net/ipv4: SMC and SYN Cookies

PATCH Superseded Ursula Braun 2 participants 6 messages Mar 20, 2018 – Mar 22, 2018

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover net/ipv4: SMC and SYN Cookies

Dave,

net/smc code is based on the SMC TCP experimental option. Please apply Hans' patch to fix an inconsistency when SYN cookies are active.

Thanks, Ursula

Hans Wippel (1):
net/ipv4: disable SMC TCP option with SYN Cookies

 net/ipv4/tcp_output.c | 2 ++
 1 file changed, 2 insertions(+)
Signature · 1 line
2.13.5
#1 lore raw

PATCH 1/1 net/ipv4: disable SMC TCP option with SYN Cookies

From: Hans Wippel <[email protected]>

Currently, the SMC experimental TCP option in a SYN packet is lost on the server side when SYN Cookies are active. However, the corresponding SYNACK sent back to the client contains the SMC option. This causes an inconsistent view of the SMC capabilities on the client and server.

This patch disables the SMC option in the SYNACK when SYN Cookies are active to avoid this issue.

---
 net/ipv4/tcp_output.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv4/tcp_output.c +2 -0
index 383cac0ff0ec..22894514feae 100644
@@ -3199,6 +3199,8 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
 		/* Under synflood, we do not attach skb to a socket,
 		 * to avoid false sharing.
 		 */
+		if (IS_ENABLED(CONFIG_SMC))
+			ireq->smc_ok = 0;
 		break;
 	case TCP_SYNACK_FASTOPEN:
 		/* sk is a const pointer, because we want to express multiple
Signature · 1 line
2.13.5
#2 lore raw

Re: [PATCH net-next 1/1] net/ipv4: disable SMC TCP option with SYN Cookies

Quoted 22 lines · Ursula Braun

From: Hans Wippel <[email protected]>

Currently, the SMC experimental TCP option in a SYN packet is lost on the server side when SYN Cookies are active. However, the corresponding SYNACK sent back to the client contains the SMC option. This causes an inconsistent view of the SMC capabilities on the client and server.

This patch disables the SMC option in the SYNACK when SYN Cookies are active to avoid this issue.

---
 net/ipv4/tcp_output.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv4/tcp_output.c +0 -0
index 383cac0ff0ec..22894514feae 100644

net/ipv4/tcp_output.c struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst, · line 3206

Quoted 8 lines
net/ipv4/tcp_output.c +2 -0
@@ -3199,6 +3199,8 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
 		/* Under synflood, we do not attach skb to a socket,
 		 * to avoid false sharing.
 		 */
+		if (IS_ENABLED(CONFIG_SMC))
+			ireq->smc_ok = 0;
 		break;
 	case TCP_SYNACK_FASTOPEN:
 		/* sk is a const pointer, because we want to express multiple

I disagree with net-next qualification.

This fixes a bug, so please send it for net tree, and including an appropriate Fixes: tag.

Thanks !

#3 lore raw

Re: [PATCH net-next 1/1] net/ipv4: disable SMC TCP option with SYN Cookies

Quoted 36 lines · Eric Dumazet
Quoted 22 lines · Ursula Braun

From: Hans Wippel <[email protected]>

Currently, the SMC experimental TCP option in a SYN packet is lost on the server side when SYN Cookies are active. However, the corresponding SYNACK sent back to the client contains the SMC option. This causes an inconsistent view of the SMC capabilities on the client and server.

This patch disables the SMC option in the SYNACK when SYN Cookies are active to avoid this issue.

---
 net/ipv4/tcp_output.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv4/tcp_output.c +0 -0
index 383cac0ff0ec..22894514feae 100644

net/ipv4/tcp_output.c struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst, · line 3206

Quoted 8 lines
net/ipv4/tcp_output.c +2 -0
@@ -3199,6 +3199,8 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
 		/* Under synflood, we do not attach skb to a socket,
 		 * to avoid false sharing.
 		 */
+		if (IS_ENABLED(CONFIG_SMC))
+			ireq->smc_ok = 0;
 		break;
 	case TCP_SYNACK_FASTOPEN:
 		/* sk is a const pointer, because we want to express multiple

I disagree with net-next qualification.

Quoted 2 lines

This fixes a bug, so please send it for net tree, and including an appropriate Fixes: tag.

Also, please do not add the fix in tcp_make_synack()

tcp_make_synack() builds an skb, and really should not modify ireq, ideally. The only reason ireq is not const is because of the skb_set_owner_w().

I would clear it in cookie_v4_check()/cookie_v6_check()

(We could have a common helper to allocate a TCP ireq btw, but this will wait a future patch for net-next)

#4 lore raw

Re: [PATCH net-next 1/1] net/ipv4: disable SMC TCP option with SYN Cookies

Quoted 39 lines · Eric Dumazet
Quoted 36 lines · Eric Dumazet
Quoted 22 lines · Ursula Braun

From: Hans Wippel <[email protected]>

Currently, the SMC experimental TCP option in a SYN packet is lost on the server side when SYN Cookies are active. However, the corresponding SYNACK sent back to the client contains the SMC option. This causes an inconsistent view of the SMC capabilities on the client and server.

This patch disables the SMC option in the SYNACK when SYN Cookies are active to avoid this issue.

---
 net/ipv4/tcp_output.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv4/tcp_output.c +0 -0
index 383cac0ff0ec..22894514feae 100644

net/ipv4/tcp_output.c struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst, · line 3206

Quoted 8 lines
net/ipv4/tcp_output.c +2 -0
@@ -3199,6 +3199,8 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
 		/* Under synflood, we do not attach skb to a socket,
 		 * to avoid false sharing.
 		 */
+		if (IS_ENABLED(CONFIG_SMC))
+			ireq->smc_ok = 0;
 		break;
 	case TCP_SYNACK_FASTOPEN:
 		/* sk is a const pointer, because we want to express multiple

I disagree with net-next qualification.

Quoted 2 lines
Quoted 2 lines

This fixes a bug, so please send it for net tree, and including an appropriate Fixes: tag.

Okay, I will send it for the net tree.

Quoted 10 lines

Also, please do not add the fix in tcp_make_synack()

tcp_make_synack() builds an skb, and really should not modify ireq, ideally. The only reason ireq is not const is because of the skb_set_owner_w().

I would clear it in cookie_v4_check()/cookie_v6_check()

(We could have a common helper to allocate a TCP ireq btw, but this will wait a future patch for net-next)

We moved the clear to cookie_v4_check()/cookie_v6_check. However, this does not seem to be sufficient to prevent the SYNACK from containing the SMC experimental option. We found that an additional check in tcp_conn_request() helps:

net/ipv4/tcp_input.c +3 -0
@@ -6248,6 +6248,9 @@ int tcp_conn_request(struct request_sock
 	if (want_cookie && !tmp_opt.saw_tstamp)
 		tcp_clear_options(&tmp_opt);
 
+	if (IS_ENABLED(CONFIG_SMC) && want_cookie && tmp_opt.smc_ok)
+		tmp_opt.smc_ok = 0;
+
 	tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
 	tcp_openreq_init(req, &tmp_opt, skb, sk);
 	inet_rsk(req)->no_srccheck = inet_sk(sk)->transparent;

Do you think this could be the right place for clearing the smc_ok bit?

#5 lore raw

Re: [PATCH net-next 1/1] net/ipv4: disable SMC TCP option with SYN Cookies

Quoted 17 lines · Ursula Braun

We moved the clear to cookie_v4_check()/cookie_v6_check. However, this does not seem to be sufficient to prevent the SYNACK from containing the SMC experimental option. We found that an additional check in tcp_conn_request() helps:

net/ipv4/tcp_input.c +3 -0
@@ -6248,6 +6248,9 @@ int tcp_conn_request(struct request_sock
 	if (want_cookie && !tmp_opt.saw_tstamp)
 		tcp_clear_options(&tmp_opt);
 
+	if (IS_ENABLED(CONFIG_SMC) && want_cookie && tmp_opt.smc_ok)
+		tmp_opt.smc_ok = 0;
+
 	tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
 	tcp_openreq_init(req, &tmp_opt, skb, sk);
 	inet_rsk(req)->no_srccheck = inet_sk(sk)->transparent;
Quoted 1 line

Do you think this could be the right place for clearing the smc_ok bit?

Yes, but since tmp_opt is private to this thread/cpu, no false sharing to be afraid of

if (IS_ENABLED(CONFIG_SMC) && want_cookie)

    tmp_opt.smc_ok = 0;