Skip to contentSkip to conversation

af_unix: Add OOB support

PATCH Applied Rao Shoaib 2 participants 3 messages Aug 1, 2021 – Aug 4, 2021

Subsystems (4)
lore
Share & tools
lore

Rao Shoaib

author
#0 lore raw

cover af_unix: Add OOB support

From: Rao Shoaib <[email protected]>

The original Berkeley paper on sockets by Bill Joy
http://maibriz.de/unix/ultrix/_root/net.pdf
defined OOB support for all streams sockets. However, this support was never added to AF_UNIX streams sockets, probably because it was not needed.

With several containers running on the same host, AF_UNIX sockets are being used instead of TCP sockets because they are efficient. Papers have been published that show the performance benefit of using AF_UNIX sockets and mention lack of OOB support.
https://www.usenix.org/system/files/conference/atc15/atc15-paper-dietz.pdf
Products are also being built that require OOB support for AF_UNIX sockets.

This patch adds OOB support to AF_UNIX stream sockets. The semantics are same as that of TCP.

Rao Shoaib (1):
af_unix: Add OOB support

 include/net/af_unix.h                         |   3 +
 net/unix/Kconfig                              |   5 +
 net/unix/af_unix.c                            | 153 +++++-
 tools/testing/selftests/Makefile              |   1 +
 tools/testing/selftests/net/af_unix/Makefile  |   5 +
 .../selftests/net/af_unix/test_unix_oob.c     | 437 ++++++++++++++++++
 6 files changed, 602 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/net/af_unix/Makefile
 create mode 100644 tools/testing/selftests/net/af_unix/test_unix_oob.c
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 1/1 af_unix: Add OOB support

From: Rao Shoaib <[email protected]>

This patch adds OOB support for AF_UNIX sockets.
The semantics is same as TCP.

The last byte of a message with the OOB flag is treated as the OOB byte. The byte is separated into a skb and a pointer to the skb is stored in unix_sock. The pointer is used to enforce OOB semantics.

---
 include/net/af_unix.h                         |   3 +
 net/unix/Kconfig                              |   5 +
 net/unix/af_unix.c                            | 153 +++++-
 tools/testing/selftests/Makefile              |   1 +
 tools/testing/selftests/net/af_unix/Makefile  |   5 +
 .../selftests/net/af_unix/test_unix_oob.c     | 437 ++++++++++++++++++
 6 files changed, 602 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/net/af_unix/Makefile
 create mode 100644 tools/testing/selftests/net/af_unix/test_unix_oob.c
include/net/af_unix.h +3 -0
index f42fdddecd41..17965c8d6189 100644
@@ -70,6 +70,9 @@ struct unix_sock {
 	struct socket_wq	peer_wq;
 	wait_queue_entry_t	peer_wake;
 	struct scm_stat		scm_stat;
+#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
+	struct sk_buff		*oob_skb;
+#endif
 };
 
 static inline struct unix_sock *unix_sk(const struct sock *sk)
net/unix/Kconfig +5 -0
index b6c4282899ec..b7f811216820 100644
@@ -25,6 +25,11 @@ config UNIX_SCM
 	depends on UNIX
 	default y
 
+config	AF_UNIX_OOB
+	bool
+	depends on UNIX
+	default y
+
 config UNIX_DIAG
 	tristate "UNIX: socket monitoring interface"
 	depends on UNIX
net/unix/af_unix.c +151 -2

201 lines not on this page · raw message

tools/testing/selftests/Makefile +1 -0
index fb010a35d61a..da9e8b699e42 100644
@@ -38,6 +38,7 @@ TARGETS += mount_setattr
 TARGETS += mqueue
 TARGETS += nci
 TARGETS += net
+TARGETS += net/af_unix
 TARGETS += net/forwarding
 TARGETS += net/mptcp
 TARGETS += netfilter
tools/testing/selftests/net/af_unix/Makefile new file +5 -0
new file mode 100644
index 000000000000..cfc7f4f97fd1
@@ -0,0 +1,5 @@
+##TEST_GEN_FILES := test_unix_oob
+TEST_PROGS := test_unix_oob
+include ../../lib.mk
+
+all: $(TEST_PROGS)
tools/testing/selftests/net/af_unix/test_unix_oob.c new file +437 -0

437 lines not on this page · raw message

Signature · 1 line
2.31.1
#2 lore raw
In reply to Rao Shoaib
This patch was applied to netdev/net-next.git (refs/heads/master):

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Quoted 9 lines · On Sun, 1 Aug 2021 00:57:06 -0700 you wrote:

From: Rao Shoaib <[email protected]>

The original Berkeley paper on sockets by Bill Joy
http://maibriz.de/unix/ultrix/_root/net.pdf
defined OOB support for all streams sockets. However, this support was never added to AF_UNIX streams sockets, probably because it was not needed.

[...]

Here is the summary with links:
- [net-next,af_unix,v1,1/1] af_unix: Add OOB support

    https://git.kernel.org/netdev/net-next/c/314001f0bf92

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html