Re: Accessing sk_buffs from userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Felix Radensky wrote:
> Is there a way of accessing sk_buffs from userspace, e.g.
> mapping sk_buff memory from process ?

It is possible, but you need to modify the kernel (or you can patch
just the network device driver).  There is no standard way to do it.
I've discussed this with people before, but we decided on a different
solution (see below).

> We have an application that has to inspect first packet of
> each connection and kernel module that intercepts sk_buffs.
> Having direct access to sk_buffs from userspace should be
> a great speed improvement.

If your application just needs to look at the header of lots of
packets, I would suggest using AF_PACKET's mmap feature with a limited
capture length.  That will copy just a few bytes into user space for
each packet, and user space can process batches of packets at a time
when your device is loaded.  This is very efficient.

If you really need to map sk_buffs efficiently, without a per-packet
mapping overhead (which would be significant), modify the kernel or
the network driver to allocate its sk_buffs from a special pool of
memory which can also be mmaped (as a single large block of memory)
into user space.  Then write something like AF_PACKET which passes
handles to & from userspace.  (You need to pass handles back to the
kernel to tell it when to free the sk_buffs when userspace is finished
with them).

> Thanks for your help.

Pleasure :)

-- Jamie
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux