About time delay in kernel threads at LOCAL_OUT netfilter hook
Rifat Rahman
rifatrahmanovi at gmail.com
Wed Mar 20 10:03:24 EDT 2013
Hello there,
I am in a situation where I am mangling RTP data in kernel space. I
have written a netfilter module which is responsible for encryption,
padding and ptime modification. The thing is that, encryption, padding
works just fine. Ptime modification involves two steps. When large
packets are incoming to the server (say 60 ptime, 60 bytes of RTP
payload with g729 codec), they are splitted with ptime 20. The SIP
server is Asterisk. When asterisk (the server) is sending packets of
20 ptime, they are merged to the desired big ptime(say 60). All the
things went well. I looked up packets whether checksumming, RTP
timestamping and sequencing is done perfectly. And it is done quite
well. The whole process without large ptime is satisfactory.
The thing is that, after contacting with asterisk mailing list, I came
to know that I have to make some delay before sending each large
packet. But, I am sending packets outside of the box in LOCAL_OUT
hook. I wrote a thread to make queue the packets until some delay
conditions is satisfied. And then trying to send packets from that
thread.
But, eventually what I found is that, if I set delay to zero, then
everything is fine, the packets are queued and sent as expected. But,
if I set delay>0, the thread does not send packets. I used
dst_output() in include/linux/dst.h for sending packets. But, this
function works only in LOCAL_OUT hook. When I am adding some delay in
a thread, the thread just misses the hook and the packet is never
sent. I tested that, if I add the delay condition in the target
function, the whole kernel faces the delay, so it is of no help. I
have to do this thing inside a thread. But how to not miss that hook?
Can anyone suggest any work around regarding this?
--
Rifat Rahman
More information about the Kernelnewbies
mailing list