If you’ve been reading articles/books about Linux namespaces you might have come across with variances of this statement “each network namespace has it’s own network stack” .
If you seen this before you might have wondered what does it really mean? it seems something very abstract , like one would guess that then a namespace would have it’s own and isolated “methods/functions” to manage network connections coming in and out ?
What I’m getting at is that a “network stack” didn’t make sense to me , it is too abstract and i really want to know what a “network stack” looks like in the kernel.
So this is what i found , most books refer as “network stack” to one of the most fundamental data structures in the Linux kernel , struct net.
Struct net is located in net_namespace.h and it should look like this:
So the idea is then that each namespace holds at least one struct net(the could be many as namespaces can be recursive).
This struct is very important as this is going to be passed around on methods use for forward/transmit (xmit) skb (socket buffers) around , this struct is almost always one of the parameters than the xmit functions require:
Struct net is massive , but exploring it slightly you will find a lot of interesting things , for example the pointer from struct net_device to the loopback , hence we always will get a loopback when we create a new namespace:
Anyway that’s for now , i want to keep these to a minimum .
Thank you all for the view and reads .