blog:linux:routing_decisions_in_the_linux_kernel_2_caching
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| blog:linux:routing_decisions_in_the_linux_kernel_2_caching [2022-07-31] – old revision restored (2022-07-31) Andrej Stender | blog:linux:routing_decisions_in_the_linux_kernel_2_caching [2025-01-19] (current) – connected sockets in tx socket caching Andrej Stender | ||
|---|---|---|---|
| Line 35: | Line 35: | ||
| You've probably heard the term //routing cache// here and there, right? | You've probably heard the term //routing cache// here and there, right? | ||
| An actual full-blown //routing cache// was present in older kernels and | An actual full-blown //routing cache// was present in older kernels and | ||
| - | has been removed with v3.6. However, that does not mean that caching thereby | + | had been removed with v3.6. However, that does not mean that caching thereby |
| - | vanished completely. Other caching | + | vanished completely. Other caching |
| routing decisions have been added to the kernel since that removal. | routing decisions have been added to the kernel since that removal. | ||
| Further, some already existing ones have been kept. The Internet | Further, some already existing ones have been kept. The Internet | ||
| Line 77: | Line 77: | ||
| </ | </ | ||
| - | Now let's take a look at the local output path in kernel v3.5, illustrated in Figure {{ref> | + | Now let's take a look at the local output path in kernel v3.5, illustrated in Figure {{ref> |
| Like in the previous article, I again take function '' | Like in the previous article, I again take function '' | ||
| However, no matter whether the routing decision object had just been allocated or came from the routing cache, its attachment to the network packet is actually not handled as part of this whole routing lookup. That happens a few function call layers up in function '' | However, no matter whether the routing decision object had just been allocated or came from the routing cache, its attachment to the network packet is actually not handled as part of this whole routing lookup. That happens a few function call layers up in function '' | ||
| Line 276: | Line 276: | ||
| ===== Socked Caching (TX) ===== | ===== Socked Caching (TX) ===== | ||
| This caching feature is being used on the local output path; thus, only for sending locally | This caching feature is being used on the local output path; thus, only for sending locally | ||
| - | generated packets, not for received or forwarded packets. When a socket on the system | + | generated packets, not for received or forwarded packets. When a connected/ |
| - | (e.g. TCP or UDP socket, client or server) | + | socket on the system (e.g. TCP or UDP socket, client or server) |
| is sending data on the the network, then it is sufficient to only do a routing lookup | is sending data on the the network, then it is sufficient to only do a routing lookup | ||
| - | for the very first packet it sends. After all, the destination IP address | + | for the very first packet it sends. After all, the destination IP address |
| for all following packets it sends and so is the routing decision. Thus, the //routing | for all following packets it sends and so is the routing decision. Thus, the //routing | ||
| decision// object, once obtained from the initial lookup, is being cached within the | decision// object, once obtained from the initial lookup, is being cached within the | ||
| Line 327: | Line 327: | ||
| <figure early_demux1> | <figure early_demux1> | ||
| - | {{ : | + | {{ : |
| - | < | + | < |
| </ | </ | ||
| Line 367: | Line 367: | ||
| an existing socket on the system reaches // | an existing socket on the system reaches // | ||
| and this is done within OSI layer 4 handling, e.g. for TCP | and this is done within OSI layer 4 handling, e.g. for TCP | ||
| - | in function | + | in '' |
| - | on network namespace level to switch this feature on/off either globally | + | I described this feature here for IPv4. An equivalent implementation |
| - | for IPv4 within the network namespace or just for TCP and/or UDP (default: on). | + | exists on the IPv6 receive path. Sysctls are implemented on network |
| + | namespace level to switch this feature on/off either globally | ||
| + | and IPv6((Yes, despite their naming, the //sysctls// listed below represent the on/off switches | ||
| + | for //early demux// for both IPv4 and IPv6!)) | ||
| <code bash> | <code bash> | ||
| Line 391: | Line 394: | ||
| <figure ip_list_rcv_finish1> | <figure ip_list_rcv_finish1> | ||
| - | {{ : | + | {{ : |
| - | < | + | < |
| </ | </ | ||
| Line 413: | Line 416: | ||
| <figure hint_caching1> | <figure hint_caching1> | ||
| - | {{ : | + | {{ : |
| - | < | + | < |
| </ | </ | ||
| Line 440: | Line 443: | ||
| ===== Flowtables ===== | ===== Flowtables ===== | ||
| - | [[https://www.kernel.org/doc/html/ | + | //Flowtables// is a //software// (and under certain circumstances also //hardware//) //fastpath// mechanism implemented by the // |
| ===== Cache Invalidation ===== | ===== Cache Invalidation ===== | ||
| What actually happens in case something changes, like a new entry being added to a routing table | What actually happens in case something changes, like a new entry being added to a routing table | ||
| Line 490: | Line 494: | ||
| // | // | ||
| // | // | ||
| - | that the // | + | that the // |
| Thus, when a //routing decision// is about to be used once more (e.g. when it is about to be | Thus, when a //routing decision// is about to be used once more (e.g. when it is about to be | ||
| attached to yet another skb), its // | attached to yet another skb), its // | ||
| to the global one, which is done by function '' | to the global one, which is done by function '' | ||
| - | In case of e.g. the //nexthop// caching mechanism described above, that function is wrapped inside function '' | + | In case of e.g. the //nexthop// caching mechanism described above, that function is wrapped inside function '' |
| <code c> | <code c> | ||
| Line 553: | Line 557: | ||
| to my attention and of course I'll then fix my content asap accordingly. | to my attention and of course I'll then fix my content asap accordingly. | ||
| - | //published 2022-07-31//, | + | //published 2022-07-31//, |
blog/linux/routing_decisions_in_the_linux_kernel_2_caching.1659291563.txt.gz · Last modified: 2022-07-31 by Andrej Stender
