ksmbd ABI for ksmbd-tools...

Namjae Jeon namjae.jeon at samsung.com
Mon Feb 15 00:59:29 UTC 2021

> Hi Namjae,
Hi Metze,
> I looked through the interfaces used between userspace (ksmbd.mountd and ksmbd.control) and the kernel
> module.
> After loading the ksmbd.ko module and calling 'ksmbd.mountd', I see the following related
> proceses/kernel-threads:
>   12200 ?        I      0:00 [kworker/0:0-ksmbd-io]
>   12247 ?        Ss     0:00 ksmbd.mountd
>   12248 ?        S      0:00 ksmbd.mountd
>   12249 ?        S      0:00 [ksmbd-lo]
>   12250 ?        S      0:00 [ksmbd-enp0s3]
>   12251 ?        S      0:00 [ksmbd-enp0s8]
>   12252 ?        S      0:00 [ksmbd-enp0s9]
>   12253 ?        S      0:00 [ksmbd-enp0s10]
>   12254 ?        I<     0:00 [ksmbd-smb_direc]
>   12255 ?        S      0:00 [ksmbd:38794]
>   12257 ?        S      0:00 [ksmbd:51579]
> I haven't found the exact place, but ksmbd.mountd starts the kernel-part.
> ksmbd.mountd also acts as some kind of upcall, for the server part, that takes care of authentication
> and some basic DCERPC calls.
> I'm wondering why there are two separate ways to kill the running server, 'killall ksmbd.mountd' for
> the userspace part and 'ksmbd.control -s' (which is just a wrapper for 'echo -n "hard" >
> /sys/class/ksmbd-control/kill_server') to shutdown the server part.
Hm.. We can add the code that kill ksmbd.mountd in ksmbd.control -s.
> As it's not useful to run any of these two components on its own, so I'm wondering why there's no
> stronger relationship.
Sergey answered.
> As naive admin I'd assume that the kernel part would detect the exit of ksmbd.mountd and shutdown
> itself.
Sergey answered.
> It would also be great to bind to specific ip addresses instead of devices and allow to run more than
> one instance of ksmbd.mountd (with different config files and or within containers). That's why I
> think single global hardcoded path like '/sys/class/ksmbd-control/kill_server' should be avoided,
> something like:
> '/sys/class/ksmbd-control/<pid-of-ksmbd.mountd>/kill_server' would be better (if it's needed at all).
Could you please elaborate more why we should do this ?

> I also have ideas how ksmbd{.ok,.mountd} could make use of Samba's winbindd (or authentication) and
> Samba's rpc services, but this would require a few changes in the netlink protocol between ksmbd.ko
> and ksmbd.mountd. It would be great if a Samba smb.conf option could cause smbd to start ksmbd.mountd
> in the background and delegate all raw SMB handling to the kernel.
It's what I plan to do in the long run. It would be great for ksmbd to fully support the function
using samba's library. But I don't think ksmbd should have dependency on such samba's libraries.
i.e. If we change the existing netlink protocol in ksmbd to use samba's winbindd and librpc,
The current users using ksmbd on closed systems may not be able to use ksmbd due to GPLv3. So, This
should be a new netlink protocol addition or extension, not change the existing ones.

> So my main big question is how stable would the userspace interface to ksmbd.ko be treated?
Sergey answered. If his answer is not enough, Let me know it.
> Would it be possible to change the netlink protocol or /sys/class/* behavior in future in order to
> improve things?
> Can we require that the userspace tool matches the kernel version for a while?
Sergey answered. If there is a better way than now, please give me your opinion.
> I think iproute2 creates a version for each stable kernel tree and tools like bpftool, perf even come
> with each single kernel release.
Ah. Even if there is no change in source, Does it release according to the kernel version?
It would be better that ksmbd-tools also is merged into kernel/tools like bfptool or perf,
but I am not sure if it is possible. nfs-utils seems to be managed well apart from the kernel version.

More information about the samba-technical mailing list