I need to delete a conntrack entry in the kernel. There are numerous functions like nf_ct_delete and nf_ct_put. At the moment I use both on a skb->nfct (block on every tracked skb). It seems to work fine at first, but after some seconds the kernel just crashes.
My current code is as follows:
struct nf_conntrack *con = skb->nfct;
nf_conntrack_get(sub_conntrack);
//... do some stuff
nf_ct_delete((struct nf_conn *) con, 0, 0);
nf_ct_put((struct nf_conn *) con);
Directly after execution of the delete and put statement, I check the entries with conntrack -L conntrack and they are gone (as expected). But after one minute or so, the system freezes. I guess conntrack starts some timers that crash when fired.
So my question is: How can I immediately delete everything for a specific connection? Including stopping any timers and cleaning up all state.
This is adapted from the netfilter code