Commit 1ac507d4ffbff578c388e85f9637dca19ff07b95

Authored by Sowmini Varadhan
Committed by David S. Miller
1 parent f5f99309fa

RDS: TCP: report addr/port info based on TCP socket in rds-info

The socket argument passed to rds_tcp_tc_info() is a PF_RDS socket,
so it is incorrect to report the address port info based on
rds_getname() as part of TCP state report.

Invoke inet_getname() for the t_sock associated with the
rds_tcp_connection instead.

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 13 additions and 7 deletions Side-by-side Diff

... ... @@ -220,7 +220,7 @@
220 220 write_unlock_bh(&sock->sk->sk_callback_lock);
221 221 }
222 222  
223   -static void rds_tcp_tc_info(struct socket *sock, unsigned int len,
  223 +static void rds_tcp_tc_info(struct socket *rds_sock, unsigned int len,
224 224 struct rds_info_iterator *iter,
225 225 struct rds_info_lengths *lens)
226 226 {
... ... @@ -229,6 +229,7 @@
229 229 unsigned long flags;
230 230 struct sockaddr_in sin;
231 231 int sinlen;
  232 + struct socket *sock;
232 233  
233 234 spin_lock_irqsave(&rds_tcp_tc_list_lock, flags);
234 235  
... ... @@ -237,12 +238,17 @@
237 238  
238 239 list_for_each_entry(tc, &rds_tcp_tc_list, t_list_item) {
239 240  
240   - sock->ops->getname(sock, (struct sockaddr *)&sin, &sinlen, 0);
241   - tsinfo.local_addr = sin.sin_addr.s_addr;
242   - tsinfo.local_port = sin.sin_port;
243   - sock->ops->getname(sock, (struct sockaddr *)&sin, &sinlen, 1);
244   - tsinfo.peer_addr = sin.sin_addr.s_addr;
245   - tsinfo.peer_port = sin.sin_port;
  241 + sock = tc->t_sock;
  242 + if (sock) {
  243 + sock->ops->getname(sock, (struct sockaddr *)&sin,
  244 + &sinlen, 0);
  245 + tsinfo.local_addr = sin.sin_addr.s_addr;
  246 + tsinfo.local_port = sin.sin_port;
  247 + sock->ops->getname(sock, (struct sockaddr *)&sin,
  248 + &sinlen, 1);
  249 + tsinfo.peer_addr = sin.sin_addr.s_addr;
  250 + tsinfo.peer_port = sin.sin_port;
  251 + }
246 252  
247 253 tsinfo.hdr_rem = tc->t_tinc_hdr_rem;
248 254 tsinfo.data_rem = tc->t_tinc_data_rem;