I managed to write my small firewall that does delay packet by 1 second
before sending it out.
However add_timer() function seems to work bit differently than I assumed.
It seems (from sched.c) that it is not correct way to allocate memory for
each timeout?
It would have been very easy to do it in a way that I would just alloc
space for each timer and add every packet in the timer list but it seems
that no one would do memory freeing :(.
at the moment it goes like.
--
cloned_buffer=skb_clone(skb,GFP_ATOMIC);
packet_cb.ip = ip;
packet_cb.dev_name = dev_name;
packet_cb.redirport = redirport;
packet_cb.direction = direction;
packet_cb.skb = cloned_buffer;
del_timer(&my_timer); /* this is mucho importanto
if we don't want to crash */
init_timer(&my_timer);
our_timer.function = test_it;
our_timer.data = (unsigned long)&packet_cb;
our_timer.expires = jiffies + HZ;
add_timer(&my_timer);
--
meaning that if I send more than 1 package in second it goes nowhere :(
since I must delete timer so I can put timeout to next packet.
(and probably skb->data is left floating somewhere in kernel memory)
As I browsed trough sources I didn't see anything obious how to do
timeouts for each outgoing packet.
Would the correct way (tm) be putting them in task queue? but I don't see
how in that case I could set delay for each packet?
would there be any sense in putting
--
current->timeout=HZ;
current->state = TASK_INTERRUPTIBLE;
schedule();
current->timeout=0;
--
to test_it function to do the delay and just add coming packets to
tq_timer queue. Or is there some more efficient solution to do multiple
timeouts?
If you'd remember similiar cases I'd appreciate any pointers.
Thanks you very many
--
Janne P�nk�l�
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]