浏览代码

net/rpmsg: return ESHUTDOWN upon Tx on errored sockets

The rpmsg proto driver uses a single rpmsg channel device
published from a remote processor to transmit all socket-based
messages intended for that remote processor. This channel will
be auto-removed and recreated if the remote processor goes
through an error recovery process. Any connected sockets are
marked with an error status, and further transmissions on these
connected sockets should gracefully return an error. This error
condition is specifically checked for and a new error ESHUTDOWN
is returned back to userspace to differentiate it from
transmissions on an unconnected socket.

Signed-off-by: Suman Anna <s-anna@ti.com>
Suman Anna 11 年之前
父节点
当前提交
add529492d
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      net/rpmsg/rpmsg_proto.c

+ 6 - 0
net/rpmsg/rpmsg_proto.c

@@ -177,6 +177,12 @@ static int rpmsg_sock_sendmsg(struct socket *sock, struct msghdr *msg,
 
 	lock_sock(sk);
 
+	/* we don't support Tx on errored-out sockets */
+	if (sk->sk_state == RPMSG_ERROR) {
+		release_sock(sk);
+		return -ESHUTDOWN;
+	}
+
 	/* we don't support loopback at this point */
 	if (sk->sk_state != RPMSG_CONNECTED) {
 		release_sock(sk);