mptcp: fix compilation without IPV6
Subsystems (2)
Matthieu Baerts
cover mptcp: fix compilation without IPV6
I just checked the compilation without CONFIG_IPV6 and fixed what GCC was complaining about. Nothing fancy.
Matthieu Baerts (3):
mptcp: fix compilation warning without IPV6
mptcp: fix compilation error without IPV6
mptcp:basic: check for v6 family
net/mptcp/basic.c | 2 +- net/mptcp/options.c | 2 ++ net/mptcp/pm.c | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
Matthieu Baerts
PATCH 1/3 mptcp: fix compilation warning without IPV6
net/mptcp/pm.c:228:23: warning: unused variable ‘addr6’ [-Wunused-variable]
228 | struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)saddr;
| ^~~~~---
Notes:
To squash in "mptcp: Add path manager interface"
net/mptcp/pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/mptcp/pm.c +3 -1
@@ -224,8 +224,10 @@ void mptcp_pm_add_addr6(struct mptcp_sock *msk, const struct in6_addr *addr,int mptcp_pm_addr_signal (struct mptcp_sock *msk,u8 *id,struct sockaddr_storage *saddr) { -struct sockaddr_in *addr = (struct sockaddr_in *)saddr; +#if IS_ENABLED (CONFIG_IPV6 )struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)saddr; +#endif +struct sockaddr_in *addr = (struct sockaddr_in *)saddr;if (!msk->pm.local_valid)return -1 ;
Signature · 1 line
2.20.1
Matthieu Baerts
[MPTCP] Re: [PATCH 1/3] mptcp: fix compilation warning without IPV6
Hi,
Quoted 18 lines · Matthieu Baerts
net/mptcp/pm.c:228:23: warning: unused variable ‘addr6’ [-Wunused-variable] 228 | struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)saddr; | ^~~~~Signed-off-by Matthieu Baerts <matthieu.baerts(a)tessares.net>---
Notes:
To squash in "mptcp: Add path manager interface"net/mptcp/pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)net/mptcp/pm.c +0
-0
net/mptcp/pm.c void mptcp_pm_add_addr6(struct mptcp_sock *msk, const struct in6_addr *addr, · line 230
Quoted 8 lines
net/mptcp/pm.c +3
-1@@ -224,8 +224,10 @@ void mptcp_pm_add_addr6(struct mptcp_sock *msk, const struct in6_addr *addr,int mptcp_pm_addr_signal (struct mptcp_sock *msk,u8 *id,struct sockaddr_storage *saddr) { -struct sockaddr_in *addr = (struct sockaddr_in *)saddr; +#if IS_ENABLED (CONFIG_IPV6 )struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)saddr; +#endif +struct sockaddr_in *addr = (struct sockaddr_in *)saddr;
I forgot to say that I also fixed the "reversed Christmas tree" order.
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
Matthieu Baerts
PATCH 2/3 mptcp: fix compilation error without IPV6
In reply to Matthieu Baerts net/mptcp/options.c: In function ‘mptcp_established_options_addr’:
net/mptcp/options.c:478:9: error: ‘struct mptcp_out_options’ has no member named ‘addr6’; did you mean ‘addr’?
478 | opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr;
| ^~~~~
| addr---
Notes:
To squash in "mptcp: Add ADD_ADDR handling"
net/mptcp/options.c | 2 ++ 1 file changed, 2 insertions(+)
net/mptcp/options.c +2 -0
@@ -470,6 +470,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr = ((struct sockaddr_in *)&saddr)->sin_addr; *size =TCPOLEN_MPTCP_ADD_ADDR ; +#if IS_ENABLED (CONFIG_IPV6 ) } else if (saddr.ss_family == AF_INET6) {if (remaining <TCPOLEN_MPTCP_ADD_ADDR6 )return false;
@@ -477,6 +478,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr; *size =TCPOLEN_MPTCP_ADD_ADDR6 ; +#endif } msk->addr_signal =0 ;
Signature · 1 line
2.20.1
Paolo Abeni
[MPTCP] Re: [PATCH 2/3] mptcp: fix compilation error without IPV6
Quoted 28 lines · Matthieu Baerts
net/mptcp/options.c: In function ‘mptcp_established_options_addr’:
net/mptcp/options.c:478:9: error: ‘struct mptcp_out_options’ has no member named ‘addr6’; did you mean ‘addr’?478 | opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr; | ^~~~~ | addrSigned-off-by Matthieu Baerts <matthieu.baerts(a)tessares.net>---
Notes:
To squash in "mptcp: AddADD_ADDRhandling"net/mptcp/options.c | 2 ++ 1 file changed, 2 insertions(+)net/mptcp/options.c +1
-0@@ -470,6 +470,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr = ((struct sockaddr_in *)&saddr)->sin_addr; *size =TCPOLEN_MPTCP_ADD_ADDR ; +#if IS_ENABLED (CONFIG_IPV6 ) } else if (saddr.ss_family == AF_INET6) {if (remaining <TCPOLEN_MPTCP_ADD_ADDR6 )return false;
net/mptcp/options.c static bool mptcp_established_options_addr(struct sock *sk, · line 481
Quoted 4 lines
net/mptcp/options.c +1
-0@@ -477,6 +478,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr; *size =TCPOLEN_MPTCP_ADD_ADDR6 ; +#endif
I think that the preferred codying style here is something alike:
// ipv4 branch
}
#if IS_ENABLED(CONFIG_IPV6)
else if (/* ... */) {
// ...
}#endif
yep, without the preprocess conditional that would be against the codying rules, but looks like checkpatch would be happy here.
The rationale is that is more clear in both the patch and the resulting code what is protected by the conditional.
/P
Matthieu Baerts
[MPTCP] Re: [PATCH 2/3] mptcp: fix compilation error without IPV6
Hi Paolo,
Thank you for the review!
Quoted 42 lines · Paolo Abeni
Quoted 28 lines · Matthieu Baerts
net/mptcp/options.c: In function ‘mptcp_established_options_addr’:net/mptcp/options.c:478:9: error: ‘struct mptcp_out_options’ has no member named ‘addr6’; did you mean ‘addr’? 478 | opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr; | ^~~~~ | addrSigned-off-by Matthieu Baerts <matthieu.baerts(a)tessares.net>---
Notes:
To squash in "mptcp: AddADD_ADDRhandling"net/mptcp/options.c | 2 ++ 1 file changed, 2 insertions(+)net/mptcp/options.c +1
-0@@ -470,6 +470,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr = ((struct sockaddr_in *)&saddr)->sin_addr; *size =TCPOLEN_MPTCP_ADD_ADDR ; +#if IS_ENABLED (CONFIG_IPV6 ) } else if (saddr.ss_family == AF_INET6) {if (remaining <TCPOLEN_MPTCP_ADD_ADDR6 )return false;net/mptcp/options.c static bool mptcp_established_options_addr(struct sock *sk, · line 481
Quoted 4 lines
net/mptcp/options.c +1
-0@@ -477,6 +478,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr; *size =TCPOLEN_MPTCP_ADD_ADDR6 ; +#endif I think that the preferred codying style here is something alike:
// ipv4 branch } #if IS_ENABLED(CONFIG_IPV6) else if (/* ... */) { // ... }
Quoted 7 lines
#endif
yep, without the preprocess conditional that would be against the codying rules, but looks like checkpatch would be happy here.
The rationale is that is more clear in both the patch and the resulting code what is protected by the conditional.
Fine for me! I copied what was done in net/mptcp/basic.c:75 Do you want me to apply the same change there as well?
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
Paolo Abeni
[MPTCP] Re: [PATCH 2/3] mptcp: fix compilation error without IPV6
Quoted 49 lines · Matthieu Baerts
Hi Paolo,
Thank you for the review!
Quoted 44 lines · Paolo Abeni
Quoted 28 lines · Matthieu Baerts
net/mptcp/options.c: In function ‘mptcp_established_options_addr’:net/mptcp/options.c:478:9: error: ‘struct mptcp_out_options’ has no member named ‘addr6’; did you mean ‘addr’? 478 | opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr; | ^~~~~ | addrSigned-off-by Matthieu Baerts <matthieu.baerts(a)tessares.net>---
Notes:
To squash in "mptcp: AddADD_ADDRhandling"net/mptcp/options.c | 2 ++ 1 file changed, 2 insertions(+)net/mptcp/options.c +1
-0@@ -470,6 +470,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr = ((struct sockaddr_in *)&saddr)->sin_addr; *size =TCPOLEN_MPTCP_ADD_ADDR ; +#if IS_ENABLED (CONFIG_IPV6 ) } else if (saddr.ss_family == AF_INET6) {if (remaining <TCPOLEN_MPTCP_ADD_ADDR6 )return false;net/mptcp/options.c static bool mptcp_established_options_addr(struct sock *sk, · line 481
Quoted 4 lines
net/mptcp/options.c +1
-0@@ -477,6 +478,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr; *size =TCPOLEN_MPTCP_ADD_ADDR6 ; +#endif I think that the preferred codying style here is something alike:
// ipv4 branch } #if IS_ENABLED(CONFIG_IPV6) else if (/* ... */) { // ... }#endif
Quoted 8 lines
Quoted 5 lines
yep, without the preprocess conditional that would be against the codying rules, but looks like checkpatch would be happy here.
The rationale is that is more clear in both the patch and the resulting code what is protected by the conditional.
Fine for me! I copied what was done in
net/mptcp/basic.c:75Do you want me to apply the same change there as well?
Oops... I missed that - and net/mptcp/options.c:587, too.
I personally would go with what I mentioned above. Since there is a build to fix, I think we can merge as is for speed's sake, and update all the places later.
Cheers,
Paolo
Matthieu Baerts
[MPTCP] Re: [PATCH 2/3] mptcp: fix compilation error without IPV6
Hi Paolo,
Quoted 53 lines · Paolo Abeni
Quoted 52 lines · Matthieu Baerts
Hi Paolo,
Thank you for the review!
Quoted 47 lines · Paolo Abeni
Quoted 28 lines · Matthieu Baerts
net/mptcp/options.c: In function ‘mptcp_established_options_addr’:
net/mptcp/options.c:478:9: error: ‘struct mptcp_out_options’ has no member named ‘addr6’; did you mean ‘addr’?
478 |opts->addr6= ((structsockaddr_in6*)&saddr)->sin6_addr;
| ^~~~~
| addrSigned-off-by Matthieu Baerts <matthieu.baerts(a)tessares.net>---
Notes:
To squash in "mptcp: AddADD_ADDRhandling"net/mptcp/options.c | 2 ++ 1 file changed, 2 insertions(+)net/mptcp/options.c +1
-0@@ -470,6 +470,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr = ((struct sockaddr_in *)&saddr)->sin_addr; *size =TCPOLEN_MPTCP_ADD_ADDR ; +#if IS_ENABLED (CONFIG_IPV6 ) } else if (saddr.ss_family == AF_INET6) {if (remaining <TCPOLEN_MPTCP_ADD_ADDR6 )return false;net/mptcp/options.c static bool mptcp_established_options_addr(struct sock *sk, · line 481
Quoted 4 lines
net/mptcp/options.c +1
-0@@ -477,6 +478,7 @@ static bool mptcp_established_options_addr(struct sock *sk, opts->addr_id = id; opts->addr6 = ((struct sockaddr_in6 *)&saddr)->sin6_addr; *size =TCPOLEN_MPTCP_ADD_ADDR6 ; +#endif I think that the preferred codying style here is something alike:
// ipv4 branch } #if IS_ENABLED(CONFIG_IPV6) else if (/* ... */) { // ... }#endif
yep, without the preprocess conditional that would be against the codying rules, but looks like checkpatch would be happy here.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The rationale is that is more clear in both the patch and the resulting code what is protected by the conditional.
Fine for me! I copied what was done in
net/mptcp/basic.c:75Do you want me to apply the same change there as well?Oops... I missed that - and
net/mptcp/options.c:587, too.
Which code are you referring to?
https://github.com/multipath-tcp/mptcp_net-next/blob/export/net/mptcp/options.c#L587
Quoted 3 lines
I personally would go with what I mentioned above. Since there is a build to fix, I think we can merge as is for speed's sake, and update all the places later.
I was already updating the patches. If you don't mind, I am going to send them and apply the ones that fix the build.
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
Matthieu Baerts
PATCH 3/3 mptcp:basic: check for v6 family
In reply to Matthieu BaertsInstead of by default taking IPv6 if it is not v4.
I don't know exactly what are the recommendations about that but it seems we can often see code checking 'if v4' then 'else if v6', not checking 'if v4' then 'else it is v6'.
Anyway, that's a detail, more to know what we should do next time in this situation :)
---
Notes:
To squash in "mptcp: Implement basic path manager"
net/mptcp/basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/basic.c +1 -1
@@ -218,7 +218,7 @@ static void create_subflow_worker(struct work_struct *work)else if (pm->local_family ==AF_INET )mptcp_pm_create_subflow (pm->token, pm->remote_id,NULL );#if IS_ENABLED (CONFIG_IPV6 ) - else + else if (pm->local_family == AF_INET6) mptcp_pm_create_subflow6(pm->token, pm->remote_id, NULL);#endif
Signature · 1 line
2.20.1
Peter Krystad
[MPTCP] Re: [PATCH 3/3] mptcp:basic: check for v6 family
Quoted 5 lines · Matthieu Baerts
Instead of by default taking IPv6 if it is not v4.
I don't know exactly what are the recommendations about that but it seems we can often see code checking 'if v4' then 'else if v6', not checking 'if v4' then 'else it is v6'.
In this situation I think it is OK to use 'else it is v6' because this code is within the module and we know the field is set correctly (i.e. if local_valid is set then local_family is set to one or the other). That has been my
approach: use "else if v6" when the value comes from elsewhere. But YMMV.
Peter.
Quoted 25 lines
Anyway, that's a detail, more to know what we should do next time in this situation :)
Signed-off-by Matthieu Baerts <matthieu.baerts(a)tessares.net>---
Notes:
To squash in "mptcp: Implement basic path manager"net/mptcp/basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/mptcp/basic.c +1
-1@@ -218,7 +218,7 @@ static void create_subflow_worker(struct work_struct *work)else if (pm->local_family ==AF_INET )mptcp_pm_create_subflow (pm->token, pm->remote_id,NULL );#if IS_ENABLED (CONFIG_IPV6 ) - else + else if (pm->local_family == AF_INET6) mptcp_pm_create_subflow6(pm->token, pm->remote_id, NULL);#endif
Matthieu Baerts
[MPTCP] Re: [PATCH 3/3] mptcp:basic: check for v6 family
Hi Peter,
Quoted 11 lines · Peter Krystad
Quoted 5 lines · Matthieu Baerts
Instead of by default taking IPv6 if it is not v4.
I don't know exactly what are the recommendations about that but it seems we can often see code checking 'if v4' then 'else if v6', not checking 'if v4' then 'else it is v6'.
In this situation I think it is OK to use 'else it is v6' because this code is within the module and we know the field is set correctly (i.e. if
local_validis set thenlocal_familyis set to one or the other). That has been my
approach: use "else if v6" when the value comes from elsewhere. But YMMV.
Thank you for this comment.
Sounds good to me not to have the "else if v6" as long as we are careful with who can set this family :-)
We can drop the patch then.
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium