linux kernel - read() from tun device without removing data read from the OS buffer -


short version. there linux api allows read file descriptor (similar read()) without removing data os buffer? way split read() equivalent of front() (read without removing) , pop() (remove).

scenario. have tun device use deliver ip datagrams via own network stack. problem is, when application above uses udp, tun device may flooded data os, stack can't manage fast enough.

goal. i'd to: read datagram arrives on tun device, without removing kernel buffer, inspect datagram, decide if rest of proprietary protocol stack below can handle it, , if so, pop() data kernel buffer, otherwise keep data there.

why. reason makes difference not pop() kernel buffer application above can realize lower layers of network protocols congested (since own write() or send() on network interface fail), , act accordingly. if data removed, regular read(), application doesn't have clue congestion, , keeps flooding.

the source available write such option.

you use iptables -j tee option to duplicate packets second interface , read there. originals remaining unread.

not best answer, agree...


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -