Skip to content

Avoid link dependency of dlm on sctp module

Marcelo Ricardo Leitner linux-sctp netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 11 repliesIn review
  2. v1 RFC2 patches 7 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2sctp: add new getsockopt option SCTP_SOCKOPT_PEELOFF_KERNELinclude/uapi/linux/sctp.h net/sctp/socket.c+49 -08 replies
2/2dlm: avoid using sctp_do_peeloff directlyfs/dlm/lowcomms.c+8 -90 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNeil Horman
SeriesA-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] Avoid link dependency of dlm on sctp module

Hi,

I'm trying to remove a direct dependency of dlm module on sctp one. Currently dlm code is calling sctp_do_peeloff() directly and this call only is causing the load of sctp module together with dlm. For that, we have basically 3 options:
- Doing a module split on dlm
- which I'm avoiding because it was already split and was merged (more info on patch2 changelog)
- and the sctp code on it is rather small if compared with sctp module itself
- Using some other infra that gets indirectly activated, like getsockopt()
- It was like this before, but the exposed sockopt created a file descriptor for the new socket and that create some serious issues. More info on 2f2d76cc3e93 ("dlm: Do not allocate a fd for peeloff")
- Doing something like ipv6_stub (which is used by vxlan) or similar
- but I don't feel that's a good way out here, it doesn't feel right.

So I'm approaching this by going with 2nd option again but this time also creating a new sockopt that is only accessible for kernel users of this protocol, so that we are safe to directly return a struct socket * via getsockopt() results.

"Kernel users" are identified by sockets that don't have a file descriptor attached to it, as only kernel users are allowed to do that and, if original socket has a file descriptor, one should just use the original option.

I kept __user marker on sctp_getsockopt_peeloff_kernel() prototype and its helpers just to avoid issues with static checkers.

I tried minimizing the code duplication while adding the new option, but it's just better to add a whole new function to handle it. As the sockopt arguments are different, the only thing in common between both call handlers is the call to sctp_do_peeloff(). All rest would have to have checks around it.

RFC->v1, from Neil:
- For identifying kernel users, switched from segment_eq() to fd check
- Reused original option to avoid code duplication
v1->v2, from David:
- Back to new sockopt implementation, to avoid changing sockopt arg format.

Marcelo Ricardo Leitner (2):
sctp: add new getsockopt option SCTP_SOCKOPT_PEELOFF_KERNEL
dlm: avoid using sctp_do_peeloff directly

 fs/dlm/lowcomms.c         | 17 ++++++++---------
 include/uapi/linux/sctp.h | 12 ++++++++++++
 net/sctp/socket.c         | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 9 deletions(-)
Signature · 1 line
2.4.1