Question about cache #118
Replies: 8 comments
-
nvm, I had the wrong understanding of what the code does. |
Beta Was this translation helpful? Give feedback.
-
@gustavo-iniguez-goya , still struggling to understand why here we call
(which zeroes out all caches)
? |
Beta Was this translation helpful? Give feedback.
-
The unique reason to call cleanUpCaches() is that it's unfinished. As you said, we should delete last entries, or better, last PIDs without network activity for the last n minutes, like we do here: https://github.com/evilsocket/opensnitch/blob/75a08245a966768b602ddf678a94afcd09cc5ad3/daemon/procmon/audit/client.go#L203 The reason to do it asynchronously is that I realized that we lost a lot of time checking for old events. |
Beta Was this translation helpful? Give feedback.
-
Ok, please confirm what I understood from your response. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I meant that I should have added a better mechanism to clean up the cache, rather than delete all the cache entries.
Yes, if we reach to the point to have to clean up the cache yes. Regarding the inodesCache, I think that it would be sufficient to use srcPort+srcIp+dstIp+dstPort, and maybe we'd get more hits at that point. |
Beta Was this translation helpful? Give feedback.
-
Thanks, it makes sense now. |
Beta Was this translation helpful? Give feedback.
-
do you mean on startup? I have no idea, I haven't explored that idea. But I guess that having so many threads would cause some penalty on the system. Bear in mind, that besides We'd need a way to hook a function just after a socket is created, well using eBPF, or by using kprobes. A few weeks ago I played with this idea, replacing the kprobe I have no idea how to configure this kprobe to dump the fields of skb_buff, which would dump the details of the connections (https://elixir.bootlin.com/linux/v4.0/source/security/security.c#L1186). But, by monitoring the subEvent
Unfortunately, the source port in the majority of ocassions is 0 ( |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing your observations. The idea with parallel threads which I had in mind was to have as many threads running as there are /proc/PID/fd entries for the most internet-active process. |
Beta Was this translation helpful? Give feedback.
-
@gustavo-iniguez-goya ,
https://github.com/evilsocket/opensnitch/blob/75a08245a966768b602ddf678a94afcd09cc5ad3/daemon/procmon/cache.go#L92
Is there a reason why we zero out the cache instead of just dropping the last entries?
Beta Was this translation helpful? Give feedback.
All reactions