diff mbox series

mptcp: fix compilation warning

Message ID 20200117165631.1329562-1-matthieu.baerts@tessares.net
State Superseded, archived
Delegated to: Paolo Abeni
Headers show
Series mptcp: fix compilation warning | expand

Commit Message

Matthieu Baerts Jan. 17, 2020, 4:56 p.m. UTC
After having applied 77c6b6aec34b (mptcp: handle ipv4-mapped ipv6 address.),
we have this warning:

  net/ipv6/tcp_ipv6.c: In function ‘tcp_v6_syn_recv_sock’:
  net/ipv6/tcp_ipv6.c:1211:29: warning: passing argument 1 of ‘mptcp_handle_ipv6_mapped’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   1211 |    mptcp_handle_ipv6_mapped(sk, true);
        |                             ^~
  In file included from ./include/net/tcp.h:42,
                   from net/ipv6/tcp_ipv6.c:44:
  ./include/net/mptcp.h:201:44: note: expected ‘struct sock *’ but argument is of type ‘const struct sock *’
    201 | void mptcp_handle_ipv6_mapped(struct sock *sk, bool mapped);
        |                               ~~~~~~~~~~~~~^~

Simply fixed by passing some arguments to 'const'.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---

Notes:
    to be squashed in "mptcp: Handle MP_CAPABLE options for outgoing connections"

 include/net/mptcp.h | 2 +-
 net/mptcp/subflow.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Paolo Abeni Jan. 17, 2020, 5:16 p.m. UTC | #1
On Fri, 2020-01-17 at 17:56 +0100, Matthieu Baerts wrote:
> After having applied 77c6b6aec34b (mptcp: handle ipv4-mapped ipv6 address.),
> we have this warning:
> 
>   net/ipv6/tcp_ipv6.c: In function ‘tcp_v6_syn_recv_sock’:
>   net/ipv6/tcp_ipv6.c:1211:29: warning: passing argument 1 of ‘mptcp_handle_ipv6_mapped’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
>    1211 |    mptcp_handle_ipv6_mapped(sk, true);
>         |                             ^~
>   In file included from ./include/net/tcp.h:42,
>                    from net/ipv6/tcp_ipv6.c:44:
>   ./include/net/mptcp.h:201:44: note: expected ‘struct sock *’ but argument is of type ‘const struct sock *’
>     201 | void mptcp_handle_ipv6_mapped(struct sock *sk, bool mapped);
>         |                               ~~~~~~~~~~~~~^~
> 
> Simply fixed by passing some arguments to 'const'.
> 
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> ---
> 
> Notes:
>     to be squashed in "mptcp: Handle MP_CAPABLE options for outgoing connections"
> 
>  include/net/mptcp.h | 2 +-
>  net/mptcp/subflow.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/net/mptcp.h b/include/net/mptcp.h
> index eabc57c3fde4..d9214f4387c3 100644
> --- a/include/net/mptcp.h
> +++ b/include/net/mptcp.h
> @@ -162,7 +162,7 @@ static inline bool mptcp_skb_can_collapse(const struct sk_buff *to,
>  
>  #endif /* CONFIG_MPTCP */
>  
> -void mptcp_handle_ipv6_mapped(struct sock *sk, bool mapped);
> +void mptcp_handle_ipv6_mapped(const struct sock *sk, bool mapped);
>  
>  #if IS_ENABLED(CONFIG_MPTCP_IPV6)
>  int mptcpv6_init(void);
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 1eff992a43dc..2525da9d28c9 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -165,7 +165,7 @@ static int subflow_v6_conn_request(struct sock *sk, struct sk_buff *skb)
>  #endif
>  
>  static struct inet_connection_sock_af_ops *
> -subflow_default_af_ops(struct sock *sk)
> +subflow_default_af_ops(const struct sock *sk)
>  {
>  #if IS_ENABLED(CONFIG_MPTCP_IPV6)
>  	if (sk->sk_family == AF_INET6)
> @@ -174,7 +174,7 @@ subflow_default_af_ops(struct sock *sk)
>  	return &subflow_specific;
>  }
>  
> -void mptcp_handle_ipv6_mapped(struct sock *sk, bool mapped)
> +void mptcp_handle_ipv6_mapped(const struct sock *sk, bool mapped)
>  {
>  #if IS_ENABLED(CONFIG_MPTCP_IPV6)
>  	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);


Uhmm..

I think the correct fix is replacing in the call-side:

	mptcp_handle_ipv6_mapped(sk, true);

with:

	mptcp_handle_ipv6_mapped(newsk, true);

(the current code passes the wrong argument to the mptcp helper)

Cheers,

Paolo
diff mbox series

Patch

diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index eabc57c3fde4..d9214f4387c3 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -162,7 +162,7 @@  static inline bool mptcp_skb_can_collapse(const struct sk_buff *to,
 
 #endif /* CONFIG_MPTCP */
 
-void mptcp_handle_ipv6_mapped(struct sock *sk, bool mapped);
+void mptcp_handle_ipv6_mapped(const struct sock *sk, bool mapped);
 
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 int mptcpv6_init(void);
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 1eff992a43dc..2525da9d28c9 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -165,7 +165,7 @@  static int subflow_v6_conn_request(struct sock *sk, struct sk_buff *skb)
 #endif
 
 static struct inet_connection_sock_af_ops *
-subflow_default_af_ops(struct sock *sk)
+subflow_default_af_ops(const struct sock *sk)
 {
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 	if (sk->sk_family == AF_INET6)
@@ -174,7 +174,7 @@  subflow_default_af_ops(struct sock *sk)
 	return &subflow_specific;
 }
 
-void mptcp_handle_ipv6_mapped(struct sock *sk, bool mapped)
+void mptcp_handle_ipv6_mapped(const struct sock *sk, bool mapped)
 {
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);