LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-03-2016, 03:25 AM   #1
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 270

Rep: Reputation: 33
pushing the packets back to kernel queue


I am using raw Ethernet sockets to capture the packets from receive queue.
Socket call I am using is :

Code:
socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
After capturing, I will do some calculations and depending on the result either I wish to drop or push back to kernel stack.

Could someone help me telling how to send the packet back to kernel for normal processing ?
 
Old 02-03-2016, 04:56 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
You don't have to 'push back the packets to kernel queue' because you have never removed them from there. You only got a copy of the packages.
 
Old 02-05-2016, 07:02 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
. . . but you also must be prepared to take steps to ensure that you do not examine the same packet(s) more than once, thereby invalidating your statistics . . .
 
Old 02-07-2016, 11:50 PM   #4
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 270

Original Poster
Rep: Reputation: 33
my code is like this:

while(1)
{
read();
calculate statistics;
}

in this way, i hope i won't be doing the calculations for same packet twice.
 
Old 02-24-2016, 09:08 PM   #5
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 270

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by NevemTeve View Post
You don't have to 'push back the packets to kernel queue' because you have never removed them from there. You only got a copy of the packages.
If so why "System Monitor" is showing zero traffic even if I am sending/receiving packets ?

In case my statistics result gives me TRUE, is there a way to remove the packet from the kernel space or make kernel discard that packet so that further processing won't happen or other applications won't receive those packets ?

Is there a way I get the handler of the packet directly instead of copy of the packet ?

My objective is to reduce the load on the kernel/hardware.
 
Old 02-24-2016, 10:38 PM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Carefully read the documentation of ipfwadm/ipchains/iptables/nftables/whateveritisnow
 
  


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 get back existing msg queue id vdx Programming 3 04-05-2012 02:30 PM
How to untar my tarred mail queue folder back to the sendmail queue directory again? Md.Abul Quashem Linux - Server 6 02-16-2010 08:32 AM
netstat : packets pruned from receive queue because of socket buffer overrun pcarey Linux - Networking 0 10-06-2009 09:49 AM
problem with storing packets in a queue cynthia_thomas Programming 1 02-05-2006 06:26 PM
log dropped packets from queue exeon Linux - Networking 2 03-26-2005 09:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:40 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