@@ -38,17 +38,27 @@ static void smc_diag_msg_common_fill(struct smc_diag_msg *r, struct sock *sk)
3838{
3939 struct smc_sock * smc = smc_sk (sk );
4040
41- r -> diag_family = sk -> sk_family ;
4241 if (!smc -> clcsock )
4342 return ;
4443 r -> id .idiag_sport = htons (smc -> clcsock -> sk -> sk_num );
4544 r -> id .idiag_dport = smc -> clcsock -> sk -> sk_dport ;
4645 r -> id .idiag_if = smc -> clcsock -> sk -> sk_bound_dev_if ;
4746 sock_diag_save_cookie (sk , r -> id .idiag_cookie );
48- memset (& r -> id .idiag_src , 0 , sizeof (r -> id .idiag_src ));
49- memset (& r -> id .idiag_dst , 0 , sizeof (r -> id .idiag_dst ));
50- r -> id .idiag_src [0 ] = smc -> clcsock -> sk -> sk_rcv_saddr ;
51- r -> id .idiag_dst [0 ] = smc -> clcsock -> sk -> sk_daddr ;
47+ if (sk -> sk_protocol == SMCPROTO_SMC ) {
48+ r -> diag_family = PF_INET ;
49+ memset (& r -> id .idiag_src , 0 , sizeof (r -> id .idiag_src ));
50+ memset (& r -> id .idiag_dst , 0 , sizeof (r -> id .idiag_dst ));
51+ r -> id .idiag_src [0 ] = smc -> clcsock -> sk -> sk_rcv_saddr ;
52+ r -> id .idiag_dst [0 ] = smc -> clcsock -> sk -> sk_daddr ;
53+ #if IS_ENABLED (CONFIG_IPV6 )
54+ } else if (sk -> sk_protocol == SMCPROTO_SMC6 ) {
55+ r -> diag_family = PF_INET6 ;
56+ memcpy (& r -> id .idiag_src , & smc -> clcsock -> sk -> sk_v6_rcv_saddr ,
57+ sizeof (smc -> clcsock -> sk -> sk_v6_rcv_saddr ));
58+ memcpy (& r -> id .idiag_dst , & smc -> clcsock -> sk -> sk_v6_daddr ,
59+ sizeof (smc -> clcsock -> sk -> sk_v6_daddr ));
60+ #endif
61+ }
5262}
5363
5464static int smc_diag_msg_attrs_fill (struct sock * sk , struct sk_buff * skb ,
@@ -153,16 +163,17 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,
153163 return - EMSGSIZE ;
154164}
155165
156- static int smc_diag_dump (struct sk_buff * skb , struct netlink_callback * cb )
166+ static int smc_diag_dump_proto (struct proto * prot , struct sk_buff * skb ,
167+ struct netlink_callback * cb )
157168{
158169 struct net * net = sock_net (skb -> sk );
159170 struct nlattr * bc = NULL ;
160171 struct hlist_head * head ;
161172 struct sock * sk ;
162173 int rc = 0 ;
163174
164- read_lock (& smc_proto . h .smc_hash -> lock );
165- head = & smc_proto . h .smc_hash -> ht ;
175+ read_lock (& prot -> h .smc_hash -> lock );
176+ head = & prot -> h .smc_hash -> ht ;
166177 if (hlist_empty (head ))
167178 goto out ;
168179
@@ -175,7 +186,17 @@ static int smc_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
175186 }
176187
177188out :
178- read_unlock (& smc_proto .h .smc_hash -> lock );
189+ read_unlock (& prot -> h .smc_hash -> lock );
190+ return rc ;
191+ }
192+
193+ static int smc_diag_dump (struct sk_buff * skb , struct netlink_callback * cb )
194+ {
195+ int rc = 0 ;
196+
197+ rc = smc_diag_dump_proto (& smc_proto , skb , cb );
198+ if (!rc )
199+ rc = smc_diag_dump_proto (& smc_proto6 , skb , cb );
179200 return rc ;
180201}
181202
0 commit comments