Skip to content

Commit cd5892c

Browse files
committed
rxrpc: Create an address for sendmsg() to bind unbound socket with
Create an address for sendmsg() to bind unbound socket with rather than using a completely blank address otherwise the transport socket creation will fail because it will try to use address family 0. We use the address family specified in the protocol argument when the AF_RXRPC socket was created and SOCK_DGRAM as the default. For anything else, bind() must be used. Signed-off-by: David Howells <[email protected]>
1 parent 75e4212 commit cd5892c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

net/rxrpc/af_rxrpc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,18 @@ static int rxrpc_sendmsg(struct socket *sock, struct msghdr *m, size_t len)
401401

402402
switch (rx->sk.sk_state) {
403403
case RXRPC_UNBOUND:
404+
rx->srx.srx_family = AF_RXRPC;
405+
rx->srx.srx_service = 0;
406+
rx->srx.transport_type = SOCK_DGRAM;
407+
rx->srx.transport.family = rx->family;
408+
switch (rx->family) {
409+
case AF_INET:
410+
rx->srx.transport_len = sizeof(struct sockaddr_in);
411+
break;
412+
default:
413+
ret = -EAFNOSUPPORT;
414+
goto error_unlock;
415+
}
404416
local = rxrpc_lookup_local(&rx->srx);
405417
if (IS_ERR(local)) {
406418
ret = PTR_ERR(local);

0 commit comments

Comments
 (0)