2

I have searched on the web for the past few days. Every article or reference on the web is suggesting to go for IPTables and netfilter. I am aware of such tools and in fact used them to achieve the goal.

But I am searching for a simple or minimalistic steps to follow the goal which is shown in the attached figure from inside the Linux kernel as a separate module. enter image description here

Please note that I'm new to kernel module development and still in the learning phase. So, I'm sorry if the question is to naïve or obvious.

Edited

Ok, so we can get the Ethernet frame using Netfilter hooks (Though we cannot explicitly mention which eth interface from). Since this question was put on hold and requested to narrow it down, I would like to know how can we do the following in a kernel module:

  • Get a list of available Ethernet interfaces
  • Select an Interface
  • Send/inject an IP Packet to it

I have done this from the userspace so I am looking for answers that are related to kernel space and not any userspace alternatives.

halfer
  • 19,824
  • 17
  • 99
  • 186
user3243499
  • 2,953
  • 6
  • 33
  • 75
  • Could you be trying to [write a new netfilter module?](http://www.netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-4.html#ss4.6) – pedwards Nov 25 '15 at 16:40
  • Thanks for the link. But again we netfilter does not have any procedures to select particular interface to send the modified frame. I think we need to add routing entries and then use netfilter. – user3243499 Nov 25 '15 at 17:21
  • Please see [this question on 'user mode networking'](http://stackoverflow.com/questions/18343365/zero-copy-networking-vs-kernel-bypass) for some hints. There is the term [bridging](https://en.wikipedia.org/wiki/Bridging_%28networking%29) and [google 'linux network bridge'](https://www.google.ca/search?q=linux+network+bridge) might be helpful (as you didn't know the term 'bridge' before?) – artless noise Nov 25 '15 at 18:21
  • @artlessnoise I knew this term 'bridge'. I just wanted to achieve this thing through my own kernel module so that I can achieve greater flexibility based on requirement and increase performance. All the google results shows that we need to use some commands to configure the bridge. But none is suggesting any tips or steps to follow to build a kernel module for it. – user3243499 Nov 26 '15 at 05:58
  • @pedwards Is it possible to get the broadcast ARPs using netfilter hooks or just the IP packets? – user3243499 Nov 26 '15 at 08:37
  • There are already some Linux components in the kernel that do bridging. Why don't you like those (`brctl`, etc, not netfilter)? Have you tried to use those? Most everything you want exists. Some things don't make sense to do in the kernel. – artless noise Nov 26 '15 at 13:12

0 Answers0