LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 07-27-2009, 01:36 AM   #1
MehdiKarimi
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
Question Is it possible to hook a packet after NF_IP_POST_ROUTING step of Netfilter?


I think that detection of source/destination mac addresses of a packet is done after NF_IP_POST_ROUTING step of Netfilter. Is it possible to hook the packet after this step with correct mac addresses? I want to decide about outgoing packets from my NIC to drop/accept them. I think it is like a firewall on outgoing packets. I studied many firewall codes but they usually work on NF_IP_PRE_ROUTING.
 
Old 07-27-2009, 01:09 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
I must say I do not understand the situation you describe. You want to drop packets you're about to send? If so, postrouting seems to be the place to deal with it. You already know the interface.

Firewalls usually work on prerouting, because they filter the packets that are coming in, not those going out (which were handled earlier).
 
Old 07-27-2009, 11:44 PM   #3
MehdiKarimi
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for your attention to my question. When I get a packet in post-routing step, the packet has no src/dst mac addresses and after this step, src/dst mac addresses will set according to the route tables. I want to hook a packet with its correct src/dst mac addresses.
In my project, I want to get all receiving/sending packets from/to the NIC and send them to the userspace app (with NETLINK) and drop thems. So all receiving packets from NIC should be received by my kernel module and after calling my kernel module the receive packet should be droped. Also when a packet is ready for sending to NIC, my kernel module should hook and drop them. In my kernel module a copy of packet (sk_buff) is sent to an userspace app with NETLINK.
In userspace app I should do some special works on the received sk_buff from kernel module with its direction.
I think there is no way to hook a packet after port-routing step of netfilter with its src/dst mac addresses. I think I should rewrite and customize the dev_queue_xmit function.
 
Old 07-30-2009, 12:29 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
If you really want the packet with MAC, you'll have to add your own hook. I'm just wondering if you really need it - you know it will have the right one.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to send copied skb in netfilter hook? simon_qwl Programming 5 04-18-2012 05:24 AM
Priorities on Netfilter hook and kernel socket Kunsheng Programming 0 05-01-2009 09:24 AM
netfilter hook problem mihirsevak Linux - Networking 2 10-21-2007 01:17 AM
netfilter hook forward packets tim24 Linux - Networking 3 03-27-2006 03:14 PM
netfilter hook function error jinxcat Programming 1 09-23-2005 04:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration