0

I have a kernel module that receives data from userland using netlink socket. The kernel module in question is a standard (proprietary) one which has offered some hooks, that can be used for extending the module's functionality. The hooks are just function calls, which I can define and use. After some processing in the module, when the control reaches the exposed hook that I defined, the data has to be fed to linux TC flower. Unfortunately, most of TC flower's symbols are private and it is exposed only via netlink. Netlink requires a userland component.

I have not seen information on using netlink for communication within kernel. Yes, I know that exported symbols are the ideal way but what's the point if the feature that I want to talk to doesn't have any symbols exported!

Can netlink be used for IPC between a linux kernel module and the kernel (which already is a netlink receiver) without a userland component?

dpaks
  • 375
  • 1
  • 13
  • Probably not (or not easily), since [netlink(7)](http://man7.org/linux/man-pages/man7/netlink.7.html) is used for [socket(2)](http://man7.org/linux/man-pages/man2/socket.2.html) in *user-space* – Basile Starynkevitch Aug 24 '18 at 09:16
  • 2
    BTW, you should give a lot more details about your use case. What is is the kernel feature involved, what is your kernel module doing, and why can't you use some user-land helper process. So **edit your question** to explain it a lot more (it smells very badly like some [XY problem](http://xyproblem.info)....) – Basile Starynkevitch Aug 24 '18 at 09:27
  • @BasileStarynkevitch I'll explain it more but for me, userland is a no go place. – dpaks Aug 24 '18 at 09:33
  • Then you might have no easy solution to your issue and could need to duplicate functionality in your own kernel module. Intuitively, you should want to make the most simplest kernel module possible, since kernel bugs are a nightmare. Don't forget the hint: "avoid bloating kernel code" so prefer user-space to kernel space. Have you read [*Operating Systems: Three Easy Pieces*](http://pages.cs.wisc.edu/~remzi/OSTEP/)? You really should! Without a lot more explanations, your question remains unclear (the nogo place should be kernel, not user-land) – Basile Starynkevitch Aug 24 '18 at 09:33
  • 1
    The explanation is not clear enough. Please explain even more (probably in *several* additional paragraphs; I would expect your question to triple in size). What and how is that kernel module receiving data? (this is very unusual, if you are not using system calls for that). What does TC means? Is there a kernel thread involved? What about *several* processes using simultaneously your kernel module? You look confused... – Basile Starynkevitch Aug 24 '18 at 09:45
  • @BasileStarynkevitch I've updated the question. Thanks for the reference to the book. Unfortunately, the nogo place is userland here due to organisational constraints. Sometimes, the use cases demand us to take the unfavourable but shorter route :) – dpaks Aug 24 '18 at 09:48
  • @BasileStarynkevitch I have made it clearer but I really wonder why you would require the internals of kernal module like the kthreads in it and the processes using it. A slower and unfavourable way would be to do a round trip of going from my kernel module back to user land and again from there to kernel land. – dpaks Aug 24 '18 at 10:01
  • @jww It's not really between modules. On one side, I have a module and on the other side, I have the standard tc flower netlink receiver. Is my question clear enough or do you want me to enhance it? – dpaks Aug 24 '18 at 10:17
  • You might be in much bigger trouble that you feel you are. Did you consider lobbying internally to publish your kernel module as free software, then you could be getting outside help and advices (which are really needed in your case). Even with your latest edit, I find your question still unclear. And please, don't comment your own question (everything you said in your comments should go inside your question) – Basile Starynkevitch Aug 24 '18 at 10:58

0 Answers0