Skip to contentSkip to conversation

tcp: Fix build break when CONFIG_IPV6=n

PATCH Superseded Saeed Mahameed 3 participants 5 messages Nov 22, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: Fix build break when CONFIG_IPV6=n

From: Saeed Mahameed <[email protected]>

The cited commit caused the following build break when CONFIG_IPV6 was disabled

net/ipv4/tcp_input.c: In function ‘tcp_syn_flood_action’:
include/net/sock.h:387:37: error: ‘const struct sock_common’ has no member named ‘skc_v6_rcv_saddr’; did you mean ‘skc_rcv_saddr’?

Fix by using inet6_rcv_saddr() macro which handles this situation nicely.

Fixes d9282e48c608 ("tcp: Add listening address to SYN flood message")
CC Matthieu Baerts <[email protected]>
CC Jamie Bainbridge <[email protected]>
---
 net/ipv4/tcp_input.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp_input.c +2 -2
index 0ae291e53eab..f8548a57a17a 100644
@@ -6843,9 +6843,9 @@ static bool tcp_syn_flood_action(const struct sock *sk, const char *proto)
 
 	if (!READ_ONCE(queue->synflood_warned) && syncookies != 2 &&
 	    xchg(&queue->synflood_warned, 1) == 0) {
-		if (IS_ENABLED(CONFIG_IPV6) && sk->sk_family == AF_INET6) {
+		if (sk->sk_family == AF_INET6) {
 			net_info_ratelimited("%s: Possible SYN flooding on port [%pI6c]:%u. %s.\n",
-					proto, &sk->sk_v6_rcv_saddr,
+					proto, inet6_rcv_saddr(sk),
 					sk->sk_num, msg);
 		} else {
 			net_info_ratelimited("%s: Possible SYN flooding on port %pI4:%u. %s.\n",
Signature · 1 line
2.38.1
#1 lore raw

Hi Saeed,

Quoted 5 lines · Saeed Mahameed

From: Saeed Mahameed <[email protected]>

The cited commit caused the following build break when CONFIG_IPV6 was disabled

Quoted 8 lines

net/ipv4/tcp_input.c: In function ‘tcp_syn_flood_action’:
include/net/sock.h:387:37: error: ‘const struct sock_common’ has no member named ‘skc_v6_rcv_saddr’; did you mean ‘skc_rcv_saddr’?

Fix by using inet6_rcv_saddr() macro which handles this situation nicely.

Fixes d9282e48c608 ("tcp: Add listening address to SYN flood message")

Thanks for your patch!

net/ipv4/tcp_input.c static bool tcp_syn_flood_action(const struct sock *sk, const char *proto) · line 6846

Quoted 8 lines
net/ipv4/tcp_input.c +1 -1
@@ -6843,9 +6843,9 @@ static bool tcp_syn_flood_action(const struct sock *sk, const char *proto)
 
        if (!READ_ONCE(queue->synflood_warned) && syncookies != 2 &&
            xchg(&queue->synflood_warned, 1) == 0) {
-               if (IS_ENABLED(CONFIG_IPV6) && sk->sk_family == AF_INET6) {
+               if (sk->sk_family == AF_INET6) {

I think the IS_ENABLED() should stay, to make sure the IPV6-only code is optimized away when IPv6-support is disabled.

net/ipv4/tcp_input.c static bool tcp_syn_flood_action(const struct sock *sk, const char *proto) · line 6851

Quoted 6 lines
net/ipv4/tcp_input.c +1 -1
                        net_info_ratelimited("%s: Possible SYN flooding on port [%pI6c]:%u. %s.\n",
-                                       proto, &sk->sk_v6_rcv_saddr,
+                                       proto, inet6_rcv_saddr(sk),
                                        sk->sk_num, msg);
                } else {
                        net_info_ratelimited("%s: Possible SYN flooding on port %pI4:%u. %s.\n",

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#2 lore raw
Quoted 24 lines · Geert Uytterhoeven

Hi Saeed,

Quoted 5 lines · Saeed Mahameed

From: Saeed Mahameed <[email protected]>

The cited commit caused the following build break when CONFIG_IPV6 was disabled

Quoted 8 lines

net/ipv4/tcp_input.c: In function ‘tcp_syn_flood_action’:
include/net/sock.h:387:37: error: ‘const struct sock_common’ has no member named ‘skc_v6_rcv_saddr’; did you mean ‘skc_rcv_saddr’?

Fix by using inet6_rcv_saddr() macro which handles this situation nicely.

Fixes d9282e48c608 ("tcp: Add listening address to SYN flood message")

Thanks for your patch!

Quoted 4 lines
net/ipv4/tcp_input.c +0 -0
@@ -6843,9 +6843,9 @@ static bool tcp_syn_flood_action(const struct sock *sk, const char *proto)
 
Quoted 7 lines

net/ipv4/tcp_input.c static bool tcp_syn_flood_action(const struct sock *sk, const char *proto) · line 6846

Quoted 4 lines
net/ipv4/tcp_input.c +1 -1
        if (!READ_ONCE(queue->synflood_warned) && syncookies != 2 &&
            xchg(&queue->synflood_warned, 1) == 0) {
-               if (IS_ENABLED(CONFIG_IPV6) && sk->sk_family == AF_INET6) {
+               if (sk->sk_family == AF_INET6) {

I think the IS_ENABLED() should stay, to make sure the IPV6-only code is optimized away when IPv6-support is disabled.

Agreed.

#3 lore raw
Quoted 33 lines · Eric Dumazet
Quoted 24 lines · Geert Uytterhoeven

Hi Saeed,

Quoted 5 lines · Saeed Mahameed

From: Saeed Mahameed <[email protected]>

The cited commit caused the following build break when CONFIG_IPV6 was disabled

Quoted 8 lines

net/ipv4/tcp_input.c: In function ‘tcp_syn_flood_action’:
include/net/sock.h:387:37: error: ‘const struct sock_common’ has no member named ‘skc_v6_rcv_saddr’; did you mean ‘skc_rcv_saddr’?

Fix by using inet6_rcv_saddr() macro which handles this situation nicely.

Fixes d9282e48c608 ("tcp: Add listening address to SYN flood message")

Thanks for your patch!

Quoted 4 lines
net/ipv4/tcp_input.c +0 -0
@@ -6843,9 +6843,9 @@ static bool tcp_syn_flood_action(const struct sock *sk, const char *proto)
 
Quoted 7 lines

net/ipv4/tcp_input.c static bool tcp_syn_flood_action(const struct sock *sk, const char *proto) · line 6846

Quoted 4 lines
net/ipv4/tcp_input.c +1 -1
        if (!READ_ONCE(queue->synflood_warned) && syncookies != 2 &&
            xchg(&queue->synflood_warned, 1) == 0) {
-               if (IS_ENABLED(CONFIG_IPV6) && sk->sk_family == AF_INET6) {
+               if (sk->sk_family == AF_INET6) {

I think the IS_ENABLED() should stay, to make sure the IPV6-only code is optimized away when IPv6-support is disabled.

Quoted 1 line

Agreed.

sending V2.

but for the record, I don't think such a user exist. Simply if you care about such micro optimization, then you are serious enough not to disable IPv6.

#4 lore raw

Hi Saeed,

Quoted 31 lines · Saeed Mahameed
Quoted 30 lines · Eric Dumazet
Quoted 28 lines · Geert Uytterhoeven
Quoted 5 lines · Saeed Mahameed

From: Saeed Mahameed <[email protected]>

The cited commit caused the following build break when CONFIG_IPV6 was disabled

Quoted 8 lines

net/ipv4/tcp_input.c: In function ‘tcp_syn_flood_action’:
include/net/sock.h:387:37: error: ‘const struct sock_common’ has no member named ‘skc_v6_rcv_saddr’; did you mean ‘skc_rcv_saddr’?

Fix by using inet6_rcv_saddr() macro which handles this situation nicely.

Fixes d9282e48c608 ("tcp: Add listening address to SYN flood message")

Thanks for your patch!

net/ipv4/tcp_input.c static bool tcp_syn_flood_action(const struct sock *sk, const char *proto) · line 6846

Quoted 8 lines
net/ipv4/tcp_input.c +1 -1
@@ -6843,9 +6843,9 @@ static bool tcp_syn_flood_action(const struct sock *sk, const char *proto)
 
        if (!READ_ONCE(queue->synflood_warned) && syncookies != 2 &&
            xchg(&queue->synflood_warned, 1) == 0) {
-               if (IS_ENABLED(CONFIG_IPV6) && sk->sk_family == AF_INET6) {
+               if (sk->sk_family == AF_INET6) {

I think the IS_ENABLED() should stay, to make sure the IPV6-only code is optimized away when IPv6-support is disabled.

Quoted 7 lines
Quoted 1 line

Agreed.

sending V2.

but for the record, I don't think such a user exist. Simply if you care about such micro optimization, then you are serious enough not to disable IPv6.

Sure we do. It's not a micro-optimization, as it gets rid of a printed string. Several defconfig disable CONFIG_IPV6. People who disable IPv6 because of limited memory welcome the removal of such unused code.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds