Hopefully somebody here can help me. I'm not that familiar with the detailed Linux Networking stack.
I have a box which acts as a gateway and need a way for (multiple) user (root) level applications to insert IP packets into the IP stack and somehow bypass normal routing which is based on the destination IP addr of the packet. I want the application(s) to specify the next hop the packet takes without modifying the IP packet itself, so that the packet can be directed/forwarded to a particular router based on the application parameters. The real reason is that IP addresses in the same subnet might reside behind different routers. (ie. 1.2.3.1 is behind RouterA, 1.2.3.2 is behind RouterB). The application knows which router to use. I've been able to do this under AIX V4.2.1(with some kernel extensions) using RAW IP sockets and then specifying a source route option on the socket with setsockopt(). The kernel mod checks the socket options and if it sees a source-route option, it computes a route to the first ip address in the source-route list instead of the ip destaddr. Now I need to do something similar with Linux. It seems I can register a NF_IP_LOCAL_OUT hook, but I don't know how to mangle skb->dst. I also assume that when the NF_IP_LOCAL_OUT hook is called, I can scan the socket options to do something similar. Additionally, I need a way intercept packets via the NF_IP_PREROUTING hook to intercept packets based on the source ipaddr, and then pass the packet up to multiple user application(s). Each application handles a single ipaddr. For instance, I want all packets with src_ipaddr=1.2.3.1 sent to Appl-A, src_ipaddr=1.2.3.3 sent to Appl-B, etc. I was able to do this under AIX with RAW IP sockets but I don't know which routine(s) to call under Linux. I might need to write a duplicate version of ip_local_deliver() or whatever the correct function is and modify it so that it doesn't use the values from the IP header and instead uses parameters I pass to it. Any help/hints would be greatly appreciated. Thanx