Thread (8 messages) 8 messages, 3 authors, 2012-10-23

Re: [PATCH 3/3] sock-diag: Report shutdown for inet and unix sockets

flat view

From: David Miller <davem@davemloft.net>
Date: 2012-10-23 17:42:37

From: Pavel Emelyanov <redacted>
Date: Tue, 23 Oct 2012 20:28:22 +0400
quoted hunk ↗ jump to hunk
+static inline int shutdown_mask2u(int mask)
+{
+	/*
+	 * map
+	 * 	RCV_SHUTDOWN -> SHUT_RD
+	 * 	SEND_SHUTDOWN -> SHUT_WR
+	 * 	SHUTDOWN_MASK -> SHUT_RDWR
+	 */
+
+	return mask - 1;
+}
This is horrible.

You're returning "-1" when the socket hasn't been shutdown in any way.

Do this:

1) Use a '1' based encoding like the kernel codes so that '0' means
   no shutdown, as any sane interface would.  That's why we use that
   representation internally.

2) Get rid of all of this extension crap, and just report this value
   in the pad byte.  In older kernels it will just be zero, which is
   fine.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help