net/smc: original socket family in inet_sock_diag
authorKarsten Graul <kgraul@linux.ibm.com>
Thu, 7 Feb 2019 14:56:20 +0000 (15:56 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Feb 2019 02:06:19 +0000 (18:06 -0800)
Commit ed75986f4aae ("net/smc: ipv6 support for smc_diag.c") changed the
value of the diag_family field. The idea was to indicate the family of
the IP address in the inet_diag_sockid field. But the change makes it
impossible to distinguish an inet_sock_diag response message from SMC
sock_diag response. This patch restores the original behaviour and sends
AF_SMC as value of the diag_family field.

Fixes: ed75986f4aae ("net/smc: ipv6 support for smc_diag.c")
Reported-by: Eugene Syromiatnikov <esyr@redhat.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/smc_diag.c

index dbf64a93d68add6f834cb20533ffc31b82fa4f9e..371b4cf31fcd215eff23a3910768f86dc468cb17 100644 (file)
@@ -38,6 +38,7 @@ static void smc_diag_msg_common_fill(struct smc_diag_msg *r, struct sock *sk)
 {
        struct smc_sock *smc = smc_sk(sk);
 
+       r->diag_family = sk->sk_family;
        if (!smc->clcsock)
                return;
        r->id.idiag_sport = htons(smc->clcsock->sk->sk_num);
@@ -45,14 +46,12 @@ static void smc_diag_msg_common_fill(struct smc_diag_msg *r, struct sock *sk)
        r->id.idiag_if = smc->clcsock->sk->sk_bound_dev_if;
        sock_diag_save_cookie(sk, r->id.idiag_cookie);
        if (sk->sk_protocol == SMCPROTO_SMC) {
-               r->diag_family = PF_INET;
                memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
                memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
                r->id.idiag_src[0] = smc->clcsock->sk->sk_rcv_saddr;
                r->id.idiag_dst[0] = smc->clcsock->sk->sk_daddr;
 #if IS_ENABLED(CONFIG_IPV6)
        } else if (sk->sk_protocol == SMCPROTO_SMC6) {
-               r->diag_family = PF_INET6;
                memcpy(&r->id.idiag_src, &smc->clcsock->sk->sk_v6_rcv_saddr,
                       sizeof(smc->clcsock->sk->sk_v6_rcv_saddr));
                memcpy(&r->id.idiag_dst, &smc->clcsock->sk->sk_v6_daddr,