Commit 1c287512 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[NET]: Return EDESTADDRREQ as appropriate in sendmsg implementations.

Another 1003.1 fix:

[EDESTADDRREQ]
    The socket is not connection-mode and does not have its peer
    address set, and no destination address was specified.

fixes sendmsg in ipv{4,6}/{raw,udp}
parent 055de689
...@@ -383,7 +383,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -383,7 +383,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
* IP_HDRINCL is much more convenient. * IP_HDRINCL is much more convenient.
*/ */
} else { } else {
err = -EINVAL; err = -EDESTADDRREQ;
if (sk->sk_state != TCP_ESTABLISHED) if (sk->sk_state != TCP_ESTABLISHED)
goto out; goto out;
daddr = inet->daddr; daddr = inet->daddr;
......
...@@ -540,7 +540,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -540,7 +540,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
return -EINVAL; return -EINVAL;
} else { } else {
if (sk->sk_state != TCP_ESTABLISHED) if (sk->sk_state != TCP_ESTABLISHED)
return -ENOTCONN; return -EDESTADDRREQ;
daddr = inet->daddr; daddr = inet->daddr;
dport = inet->dport; dport = inet->dport;
/* Open fast path for connected socket. /* Open fast path for connected socket.
......
...@@ -602,7 +602,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg ...@@ -602,7 +602,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
fl.oif = sin6->sin6_scope_id; fl.oif = sin6->sin6_scope_id;
} else { } else {
if (sk->sk_state != TCP_ESTABLISHED) if (sk->sk_state != TCP_ESTABLISHED)
return(-EINVAL); return -EDESTADDRREQ;
proto = inet->num; proto = inet->num;
daddr = &np->daddr; daddr = &np->daddr;
......
...@@ -862,7 +862,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg ...@@ -862,7 +862,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
fl.oif = sin6->sin6_scope_id; fl.oif = sin6->sin6_scope_id;
} else { } else {
if (sk->sk_state != TCP_ESTABLISHED) if (sk->sk_state != TCP_ESTABLISHED)
return -ENOTCONN; return -EDESTADDRREQ;
up->dport = inet->dport; up->dport = inet->dport;
daddr = &np->daddr; daddr = &np->daddr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment