Hi All,
As part of project fault-tolerant TCP , I am implementing a kernel
module which will intercept all inbound /outbound packets for the
connection to be monitored . I use netfilter module to insert my hooks
and get those packets.(I use PRE_ROUTING and POST_ROUTING hooks).
Now correct me if i go wrong in any of my next statements.
My hook will be called in interrupt context, so i can not block
from that , so i put those packets in a work-queue which i create at
module initialization. Before putting that hook there, i copy data from
sk_buff structure and the payload also. I am using kmalloc with
GFP_ATOMIC flag. Is this right way to allocate memory to replicate this
data ??
My concerns :
1: There must be limitation to how much kmalloc can give with
GFP_ATOMIC . I wont require more than skb buffer ever but this
allocated memory will be freed only when my worker thread send that
data to another server over a TCP socket.
Will there be case when i will have allocated lots of memory in this
way ?? I guess no ,as my worker thread should execute quite often than
not if there are pending data to be sent.
2: Also there seems to be skb_clone , which can also be used. This may
be faster method as it uses some cache i guess. But i have not
investigated into this much.
3: Or computing some max limit for pending packets at any time and
allocating memory for them in the module initialization and instead of
freeing it using same again and again. This way if i get it in the
start , i will be always safe. but this method doesn't look very
attractive as computing max limit may be very difficult and if i try to
be conservative , the value can be very high in other word useless.
So what are your suggestion about this allocation and how exactly it
should be done for performance issues.
Thanks ,
Rohit
What i was bit confused about is :
|