The NF_INET_LOCAL_OUT hook has skb->sk pointing to a struct sock for the socket that sent the packet. If there a hook that has it set for the socket that receives the packet? In the NF_INET_LOCAL_IN hook, skb->sk is null. Will I have to use __inet_lookup_skb()? If so, what is the complexity of that function? EDIT: looks like __inet_lookup_skb() is for
Tag: sockets
get process inode using netlink
I want to try and correlate an IP packet (using libpcap) to a process. I have had some limited success using the relevant /proc/net/ files but found that on some of the machines i’m using, this file can be many thousands of lines and parsing it is not efficient (caching has alleviated some performance problems). I read that using sock_diag
IPv6 example program fails on connect()
IPv6 example program fails on connect() I arranged the server argument to be evaluated by inet_pton() if numeric, otherwise, it goes through getaddrinfo(). inet_pton() sets up the address and it works. getaddrinfo() does not, apparently, it dies in connect (hangs up). The example program is a simple web page fetch and print (not https). I used the www.example.com server to
How to resolve “setsockopt(3, SOL_SOCKET, SO_MARK, [10], 4) = -1 EPERM” Operation denied for none root users
I got two network interfaces (ethernet and wlan). Now I found a little script on github (https://github.com/Intika-Linux-Firewall/App-Route-Jail) which seems to allow me to route specific applications through the none default gateway to loadbalance the traffic a little bit. The script is using the following call: setsockopt(sd, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)); As I found out via an strace I got: ‘-1
C socket programming errors
It’s been an hour since I started looking for THE error. I just started C sockets. The program exits with code -1 after printing “Error 1 connection error”. The server in online, it’s a netcat server. Where did I messed up ? Answer Due to operator precedence, the expression is actually equal to That is, you assign the result of
Linux asynchronous epoll() server having problems when EPOLLRDHUP occurrs
I’m trying to make an asynchronous web server using epoll() in Linux, but problems occur whenever the event EPOLLRDHUP occurs. When the flag EPOLLONESHOT is not set, the server tries to process a useless event (not EPOLLIN or EPOLLOUT) multiple times during the loop without stopping, which causes the server to be come completely unresponsive (and require a restart). When
Is there a way to convert stdin/stdout fds into one fd?
I want to process SSL from stdin, and send SSL out stdout, but OpenSSL accepts only one file descriptor in the set fd call: Is there a way to combine the stdin and stdout file descriptors into one? I realize I can make a process that just reads from stdin/out and writes to the file descriptor, but I was trying
Simultaneous TCP termination and subsequent connect(): EADDRNOTAVAIL
My company releases a special TCP stack for special purposes and I’m tasked with implementing RFC793 compliant closing sequence. One of the unit tests has a server working on top of the special TCP stack talking to a normal Linux TCP client, and I’m running into some strange behaviour that I’m not sure whether is caused by programming error on
Attempt to re-bind an already closed listening socket is failing (EADDRINUSE)?
The following is the essence of my test fixture – In the normal use of the application the listening socket is bound only once during the lifetime of the application, however the test setup repeatedly opens and closes the listening socket. The first iteration of the testcase works fine but subsequent iterations fail at the bind() call with errno ==
accept(…) seems to be modifying the file descriptor parameter I give it
Here’s a section of my code, for a simple echo server I’m attempting to write using the linux sockets syscalls: Just before this piece of code, I set up a socket descriptor fd, and then, immediately before the while loop begins: I compile this and then run it, and then run a client program which I’ve written to send a