Skip to contentSkip to conversation

libipq: How to get PIDs for packets

DISCUSSION [email protected] 2 participants 2 messages Nov 2, 2005 – Nov 3, 2005

lore
Share & tools
lore
#0 lore raw

Hello!

I'm using libipq to filter packets in userspace. Is there a way provided by the API of libipq to get the PID of the process the packet is going to or coming from?

If this is not possible I'm thinking of determinig the PIDs with the port values in the packets via lsof. The disadvantge is that this is not possible for every protocol (eg ICMP). Thus, this is not an ideal solution.

Any other ideas are welcome.

-Peter

Signature · 2 lines
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++
#1 lore raw
Quoted 3 lines · On Wed, 2 Nov 2005 [email protected] wrote:

I'm using libipq to filter packets in userspace. Is there a way provided by the API of libipq to get the PID of the process the packet is going to or coming from?

No.

Isn't even an API within the kernel to tell this.. There is no mapping between packet and process within the kernel, the two concepts are too far apart. On locally generated packets you can get down to which socket the packet was sent on, but that is about it.

Once upon a time there was the "owners" match in iptables capable of matching on pid or even application name, but this capability has been removed from there as it was not really working. Only worked on Uni-processor boxes (no SMP) and only in very restricted conditions even then..

Regards
Henrik