Page MenuHomeFreeBSD

iWARP rping server fails to bind socket when no IP address is specified
ClosedPublic

Authored by krishna2_chelsio.com on Oct 25 2018, 7:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 17 2024, 9:30 AM
Unknown Object (File)
Mar 10 2024, 1:54 PM
Unknown Object (File)
Mar 10 2024, 1:53 PM
Unknown Object (File)
Mar 10 2024, 1:53 PM
Unknown Object (File)
Mar 10 2024, 1:53 PM
Unknown Object (File)
Mar 7 2024, 7:55 PM
Unknown Object (File)
Feb 2 2024, 4:56 PM
Unknown Object (File)
Jan 8 2024, 9:24 PM
Subscribers

Details

Summary

The rping server command('rping -s') fails at line:308 in tcp_usr_bind(), this is because of the uninitialize "cb->sin.ss_len" variable in rping.c.

300 tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
301 {
302 int error = 0;
303 struct inpcb *inp;
304 struct tcpcb *tp = NULL;
305 struct sockaddr_in *sinp;
306
307 sinp = (struct sockaddr_in *)nam;
308 if (nam->sa_len != sizeof (*sinp))
309 return (EINVAL);

Note that this issue is only seen with the command "rping -s", but not with "rping -s -a <ip>".
Also, this issue is observed with Chelsio iWARP driver and may not occur on other RDMA drivers. I believe any RDMA driver that uses TCP kernel stack(offload mode) should hit this issue.

Attached patch fixes this issue. Please review.

Test Plan

Run rping server on an iwarp device using below command:

"rping -s"

dmesg:
RDMA CMA: cma_listen_on_dev, error 22, listening on device t6nex0

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Where is the real upstream for rping? Maybe this fix should go there first?

In D17707#378374, @np wrote:

Where is the real upstream for rping? Maybe this fix should go there first?

Not sure, but if the real upstream is Linux based then "ss_len" variable would not compile on Linux.

https://github.com/spotify/linux/blob/6eb782fc88d11b9f40f3d1d714531f22c57b39f9/include/linux/socket.h#L11

struct kernel_sockaddr_storage {
unsigned short ss_family; /* address family */
/* Following field(s) are implementation specific */
char
data[_K_SS_MAXSIZE - sizeof(unsigned short)];

				/* space to achieve desired size, */
				/* _SS_MAXSIZE value minus size of ss_family */

} attribute ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */

Updated patch works on both FreeBSD & Linux. Please review.

I'll check this into FreeBSD later today. Please send the patch upstream too.

This revision is now accepted and ready to land.Oct 29 2018, 7:00 PM
This revision was automatically updated to reflect the committed changes.