0

I know that on Linux and many other operating systems, loopback TCP interfaces are a special case: checksums are disabled, data is atomically copied from one process to the next, entire sections of network stack ignored etc.

My question, that I've been able to understand beyond all the links telling me that this optimisation exists is: can Linux detect a loopback equivalence? Can it detect that connections to server1 are actually routing to an IP address registered to a local interface, and therefore the equivalent loopback could be used instead? Is this permitted by the TCP standard and if so what are the rules?

I don't think I've ever seen this detection happen in real life, and it seems so obvious I can't be the first to think of it. If this optimization can be permitted by the standard, are there reasons why it isn't performed? How is this governed?

4
  • 1
    As long as it's transparent to the application, any optimizations are permitted. Commented Mar 11 at 21:43
  • The purpose of the standard is to ensure interoperability between implementations. If you're not actually communicating between implementations, it's not really relevant. Commented Mar 11 at 21:45
  • I've updated my question in this case, thanks. Commented Mar 11 at 22:07
  • Do you have any source for the premise of the question, i.e. that "on Linux and many other operating systems, loopback TCP interfaces are a special case: checksums are disabled, data is atomically copied from one process to the next, entire sections of network stack ignored etc"? I mean, Linux already routes all of the system's local IP addresses through the 'lo' interface (as looking at the routing tables would reveal), so there's nothing to "detect" – but I'm not aware of it having any special treatment for 'lo' TCP traffic that you mention. Commented Mar 12 at 7:18

1 Answer 1

0

can Linux detect a loopback equivalence? Can it detect that connections to server1 are actually routing to an IP address registered to a local interface, and therefore the equivalent loopback could be used instead?

It doesn't have to detect this, as it knows that its own addresses are local and are indeed routed through the lo interface by default.

$ ip addr show to 10.35.14.3
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP>
    inet 10.35.14.3/16 brd 10.35.255.255 scope global dynamic noprefixroute wlan0

$ ip route get 10.35.14.3 fibmatch
local 10.35.14.3 dev wlan0 table local proto kernel scope host src 10.35.14.3 

$ ip route get 10.35.14.3
local 10.35.14.3 dev lo table local src 10.35.14.3 uid 1000 
                 ^^^^^^

Is this permitted by the TCP standard and if so what are the rules?

Merely routing IP packets through a loopback interface has no effect on TCP – doing so doesn't imply that any TCP-level optimizations would additionally be done – and therefore is not governed by the TCP standard.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.