{"id":2220583,"url":"http://patchwork.ozlabs.org/api/1.1/covers/2220583/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/cover/cover.1775571957.git.metze@samba.org/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.1/projects/12/?format=json","name":"Linux CIFS Client","link_name":"linux-cifs-client","list_id":"linux-cifs.vger.kernel.org","list_email":"linux-cifs@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<cover.1775571957.git.metze@samba.org>","date":"2026-04-07T14:46:26","name":"[0/8] smb: add kernel internal IPPROTO_SMBDIRECT","submitter":{"id":8149,"url":"http://patchwork.ozlabs.org/api/1.1/people/8149/?format=json","name":"Stefan Metzmacher","email":"metze@samba.org"},"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/cover/cover.1775571957.git.metze@samba.org/mbox/","series":[{"id":498990,"url":"http://patchwork.ozlabs.org/api/1.1/series/498990/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=498990","date":"2026-04-07T14:46:28","name":"smb: add kernel internal IPPROTO_SMBDIRECT","version":1,"mbox":"http://patchwork.ozlabs.org/series/498990/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/covers/2220583/comments/","headers":{"Return-Path":"\n <linux-cifs+bounces-10698-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (3072-bit key;\n secure) header.d=samba.org header.i=@samba.org header.a=rsa-sha256\n header.s=42 header.b=mGSdguxW;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10698-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (3072-bit key) header.d=samba.org header.i=@samba.org\n header.b=\"mGSdguxW\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=144.76.82.148","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=samba.org","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=samba.org"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fqqBr3wbpz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 08 Apr 2026 01:00:52 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id DD2B630C368F\n\tfor <incoming@patchwork.ozlabs.org>; Tue,  7 Apr 2026 14:55:22 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id E8D9F33C186;\n\tTue,  7 Apr 2026 14:55:21 +0000 (UTC)","from hr2.samba.org (hr2.samba.org [144.76.82.148])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id B17D833ADAB;\n\tTue,  7 Apr 2026 14:55:19 +0000 (UTC)","from [127.0.0.2] (localhost [127.0.0.1])\n\tby hr2.samba.org with esmtpsa\n (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256)\n\t(Exim)\n\tid 1wA7hp-00000007WOO-39uS;\n\tTue, 07 Apr 2026 14:47:05 +0000"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775573721; cv=none;\n b=n6WDmWr77jAfyrQII0zh/MiKnwOuhQFM0Jr57ZdPAmpJiwSgm8EZQgzOXFt5XuCehHHxI/l36F9FED8ASg1Y6sEI5/RbwZob/T1HnkIAQe8SscQ4RFjuBGWrs3VciDBfnrxiNPyL3o/A5NaWQ1Zh6BmKZ3tO8WJyyfLR0OZ+VZo=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775573721; c=relaxed/simple;\n\tbh=Vr7+Y9O6Lq0UctbS41Ypfr586Zm9YHBHCjGTcLSBDdA=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=itGoXDC5r7klGlpDDiGnttCZ3q+jaWvMDvasOCkv4I7mhPFQdlgH39dUxOxJqkpxu3N8+u3pYpM4ofQvMtwdomQ+569jz6SkkkXVHABdoWJMQckSJG+aG9BI2N2AXbsMJSY/GHhF8mxdB/BQGqkC88Qnhqng6wm4kFh8W7bH8M0=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=samba.org;\n spf=pass smtp.mailfrom=samba.org;\n dkim=pass (3072-bit key) header.d=samba.org header.i=@samba.org\n header.b=mGSdguxW; arc=none smtp.client-ip=144.76.82.148","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org;\n\ts=42; h=Message-ID:Date:Cc:To:From;\n\tbh=KWVlvf/fLA4JQzZbInCx2uw0d9Dz/WHGRPxlljy4Ttw=; b=mGSdguxWBFjgZo63d/t65P6+z9\n\tpdRGYfVK8+7ziH7WzurTclyg6OtYVeUp87NfHUeBRHrLvNioM0CJKvzRLvm0BDnSFHvfKanCIjdg6\n\tb5bAPDNFWNI/x3yUJqNkhvKJGj4JBdK4k0z4YzJA/KR4YWOrkJJN8za09IQv1casJmfPVsVuEJAiE\n\tlndPPPtc+3kWt8Gp05pufZOZEELRbOBmALl3nTVnj+IYgZOCwhRoCBe7vhg0L9QJcf3pY4nfxpDo+\n\t4pVXvxpp+1LMRmb/LlPyGKbufSU/A1nPRI5HrrUKBvVRVcglCZrvyrULSL1+VAVblQLHqpeYHg4S/\n\t26dBM3RvFU/95VIQrRMMTQ8zK0THs1SqDXR9P2enZqZntZZ+nu8HbtJf4z/tuVDUAUYsmXZYBLlZf\n\t+crEDXMaKSvBX0JDiI/7H7LGLNldBP+8qrzwdjv9sIN6l05JNfXnptzR9PUE99RdCJgGLrExnfSyY\n\tb1qKNhG09rtB8L/5pbmSMZCW;","From":"Stefan Metzmacher <metze@samba.org>","To":"linux-cifs@vger.kernel.org,\n\tsamba-technical@lists.samba.org","Cc":"metze@samba.org,\n\tSteve French <smfrench@gmail.com>,\n\tTom Talpey <tom@talpey.com>,\n\tLong Li <longli@microsoft.com>,\n\tNamjae Jeon <linkinjeon@kernel.org>,\n\tDavid Howells <dhowells@redhat.com>,\n\tHenrique Carvalho <henrique.carvalho@suse.com>,\n\t\"David S . Miller\" <davem@davemloft.net>,\n\tEric Dumazet <edumazet@google.com>,\n\tJakub Kicinski <kuba@kernel.org>,\n\tPaolo Abeni <pabeni@redhat.com>,\n\tSimon Horman <horms@kernel.org>,\n\tKuniyuki Iwashima <kuniyu@google.com>,\n\tWillem de Bruijn <willemb@google.com>,\n\tnetdev@vger.kernel.org,\n\tXin Long <lucien.xin@gmail.com>,\n\tquic@lists.linux.dev,\n\tlinux-rdma@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tMark Brown <broonie@kernel.org>,\n\tlinux-next@vger.kernel.org","Subject":"[PATCH 0/8] smb: add kernel internal IPPROTO_SMBDIRECT","Date":"Tue,  7 Apr 2026 16:46:26 +0200","Message-ID":"<cover.1775571957.git.metze@samba.org>","X-Mailer":"git-send-email 2.43.0","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"Hi,\n\nas the work to unify the smbdirect code\nbetween cifs.ko and ksmbd.ko into an smbdirect.ko\nis in linux-next for a while this is the next\nstep to also share the code with userspace\ne.g. Samba as client and server.\n\nThe SMBDIRECT protocol, defined in [MS-SMBD] by Microsoft.\nIt is used as wrapper around RDMA in order to provide a transport for SMB3,\nbut Microsoft also uses it as transport for other protocols.\n\nSMBDIRECT works over Infiniband, RoCE and iWarp.  RoCEv2 is based on IP/UDP\nand iWarp is based on IP/TCP, so these use IP addresses natively.\nInfiniband and RoCEv1 require IPOIB in order to be used for SMBDIRECT.\n\nSo instead of adding a PF_SMBDIRECT, which would only use AF_INET[6],\nwe use IPPROTO_SMBDIRECT instead, this uses a number not\nallocated from IANA, as it would not appear in an IP header.\n\nThis is similar to IPPROTO_SMC, IPPROTO_MPTCP and IPPROTO_QUIC,\nwhich are linux specific values for the socket() syscall.\n\n  socket(AF_INET, SOCK_STREAM, IPPROTO_SMBDIRECT);\n  socket(AF_INET6, SOCK_STREAM, IPPROTO_SMBDIRECT);\n\nThis will allow the existing smbdirect code used by\ncifs.ko and ksmbd.ko to be moved behind the socket layer [1],\nso that there's less special handling. Only sock_sendmsg()\nsock_recvmsg() are used, so that the main stream handling\nis done all the same for tcp, smbdirect and later also quic.\n\nThe special RDMA read/write handling will be via direct\nfunction calls as they are currently done for the in kernel\nconsumers.\n\nAs a start __sock_create(kern=0)/sk->sk_kern_sock == 0 will\nstill cause a -EPROTONOSUPPORT. So only in kernel consumers\nwill be supported for now.\n\nFor now the core smbdirect code still supports both\nmodes, direct calls in indirect via the socket layer.\nThe core code uses if (sc->sk.sk_family) as indication\nfor the new socket mode. Once cifs.ko and ksmbd.ko\nare converted we can remove the old mode slowly,\nbut I'll deferr that to a future patchset.\n\nThere's still a way to go in order to make this\nas generic as tcp and quic e.g. adding MSG_SPLICE_PAGES support or\nsplice_read/read_sock/read_skb.\n\nBut it's a good start, which will make changes much easier.\n\nThis patchset is based on top of the smbdirect.ko patches\nin ksmbd-for-next and it's also based on netdev-next\nbecause it needs this commit from there:\n8341c989ac77d712c7d6e2bce29e8a4bcb2eeae4\n\"net: remove addr_len argument of recvmsg() handlers\"\n\nPatches 1-4 are some preparation fixes for the\nexisting smbdirect.ko patchset. We may\nsquash them into the existing patches before\nsending them to Linus. But for now I kept\nthem separately. I also don't cc the network and rdma\npeople on these...\n\nPatch 5 defines IPPROTO_SMBDIRECT and SOL_SMBDIRECT\nconstants (and also reserve the number 288 for SOL_QUIC\nas applications are already using that and we don't\nwant to conflict)\n\nPatch 6 adds basic IPPROTO_SMBDIRECT layering\non top of the existing smbdirect code.\nThis is just enough in order to let cifs.ko\nand ksmbd.ko use it in the following commits,\nso userspace still sees -EPROTONOSUPPORT.\n\nPatch 7 converts cifs.ko to use IPPROTO_SMBDIRECT\nas much as currently possible.\nUsing sock_sendmsg is not yet possible, because of the\ntcp_sock_set_cork usage, but that will change in future.\n\nPatch 8 converts ksmbd.ko to use IPPROTO_SMBDIRECT.\n\nBecause of the need for netdev-next commit\n8341c989ac77d712c7d6e2bce29e8a4bcb2eeae4\n\"net: remove addr_len argument of recvmsg() handlers\"\nit's a bit tricky to prepare something that would not\ncause problems in linux-next.\n\nWe could merge in netdev-next completely,\nbut I saw commit 00f03539e3d97af925abf42992d8c46167d54243\nin next-20260406, indicates some resolved conflicts\nwith (at least) the rdma tree, which comes\njust before netdev-next, while ksmbd-for-next is merged\nbefore all of them. So merging netdev-next into\nksmbd-for-next changes the order of netdev-next vs. rdma.\n\nOr we add a new branch smbdirect-for-next that's\nmerged into linux-next after netdev-next.\n\nOr a bit hacky but likely easier, ksmbd-for-next\njust cherry-picks 8341c989ac77d712c7d6e2bce29e8a4bcb2eeae4\n\"net: remove addr_len argument of recvmsg() handlers\"\nand that cherry picked commit is reverted as\nlast commit in ksmbd-for-next, or only in linux-next\nright before netdev-next is merged.\n\nFor now I have the patches in a branch with a\ncherry picked version of the needed commit only, see\nfor-7.1/ipproto-smbdirect-20260407-v1 at commit:\ne1972e6f1fda9842c5724b7daf4a2aa7779901a5\ngit fetch https://git.samba.org/metze/linux/wip.git for-7.1/ipproto-smbdirect-20260407-v1\nhttps://git.samba.org/?p=metze/linux/wip.git;a=shortlog;h=refs/heads/for-7.1/ipproto-smbdirect-20260407-v1\n\nIt would be great to get this somehow into linux-next soon :-)\n\nStefan Metzmacher (8):\n  smb: smbdirect: change\n    smbdirect_socket_parameters.{initiator_depth,responder_resources} to\n    __u16\n  smb: smbdirect: fix copyright header of smbdirect.h\n  smb: smbdirect: fix the logic in smbdirect_socket_destroy_sync()\n    without an error\n  smb: smbdirect: let smbdirect_connection_deregister_mr_io unlock while\n    waiting\n  net: define IPPROTO_SMBDIRECT and SOL_SMBDIRECT constants\n  smb: smbdirect: add in kernel only support for IPPROTO_SMBDIRECT\n  smb: client: make use of IPPROTO_SMBDIRECT sockets\n  smb: server: make use of IPPROTO_SMBDIRECT sockets\n\n fs/smb/client/cifs_debug.c                    |    2 +-\n fs/smb/client/cifsfs.c                        |    2 +-\n fs/smb/client/cifsglob.h                      |    7 +-\n fs/smb/client/connect.c                       |  123 +-\n fs/smb/client/file.c                          |    8 +-\n fs/smb/client/sess.c                          |    4 +-\n fs/smb/client/smb2ops.c                       |    8 +-\n fs/smb/client/smb2pdu.c                       |   10 +-\n fs/smb/client/smbdirect.c                     |  275 +--\n fs/smb/client/smbdirect.h                     |   27 +-\n fs/smb/client/transport.c                     |    2 +-\n fs/smb/common/smbdirect/Makefile              |    1 +\n fs/smb/common/smbdirect/smbdirect.h           |   69 +-\n fs/smb/common/smbdirect/smbdirect_accept.c    |   14 +-\n .../common/smbdirect/smbdirect_connection.c   |   58 +\n fs/smb/common/smbdirect/smbdirect_devices.c   |    2 +-\n fs/smb/common/smbdirect/smbdirect_internal.h  |   59 +-\n fs/smb/common/smbdirect/smbdirect_listen.c    |   49 +-\n fs/smb/common/smbdirect/smbdirect_main.c      |   45 +\n fs/smb/common/smbdirect/smbdirect_mr.c        |   18 +\n fs/smb/common/smbdirect/smbdirect_proto.c     | 1549 +++++++++++++++++\n fs/smb/common/smbdirect/smbdirect_public.h    |    3 +\n fs/smb/common/smbdirect/smbdirect_rw.c        |   29 +-\n fs/smb/common/smbdirect/smbdirect_socket.c    |  180 +-\n fs/smb/common/smbdirect/smbdirect_socket.h    |   26 +-\n fs/smb/server/transport_rdma.c                |  119 +-\n include/linux/socket.h                        |    2 +\n include/uapi/linux/in.h                       |    2 +\n 28 files changed, 2320 insertions(+), 373 deletions(-)\n create mode 100644 fs/smb/common/smbdirect/smbdirect_proto.c"}