TPROXY, picking up the source address for UDP
Fri, 29 Mar 2002 14:35:20 +0100
Another problem I popped into while figuring out how to set the outgoing
source address for UDP frames.
In Linux 2.2 UDP sending with specified source address worked on a frame by
frame basis, and I would like to keep this behaviour.
An aux message would be used in sendmsg() to specify the outgoing source
address of a packet. My problem is that it is quite difficult to change the
source ip of the skb based on an aux message.
In the kernel it works as follows:
1) udp_sendmsg is called
2) which in turn calls ip_cmsg_send, which sets up an ipcm_cookie struct
3) this struct is then passed to ip_build_xmit(), which sets up the skb
based on ipcm
My problem is that to attach create a new cmsg, I'd need to modify the
cmsg_cookie struct as it is the only connection between the skb and
sendmsg(), and in addition ip_build_xmit() must also be changed as this is
the one which processes messages.
An alternative way would be add a translation entry about the required
change to the TPROXY translation table. The problem with this that adding
the entry, sending a single frame, and removing the entry doesn't seem to be
very atomic to me. (the only possibility here would be to create a flag
assigned to the translation entry, saying that this entry is applied only
once => but this might cause problems on SMP, as two processes might be
issuing sendmsg() calls at the same time)
PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1