Bug 40

Summary: Outbound UDP packets sometimes incorrectly sent on loopback interface
Product: passt Reporter: David Gibson <dgibson>
Component: UDPAssignee: nobody
Status: RESOLVED INVALID    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   

Description David Gibson 2022-12-01 02:09:00 UTC
# Steps to reproduce

Assume $HOST is the host IP address and $GW is the gateway address:

1. On host, run:
      $ socat -u UDP4-LISTEN:2000,bind=$HOST STDOUT
2. On host, run:
      $ tcpdump -i lo
3. On host, run:
      $ pasta --config-net
4. Within pasta shell run:
      # echo hello | socat -u STDIN UDP4:$GW:2000

# Expected results

"hello" appears on socat from step (1).  tcpdump at (2) shows no packets related to this operation.

# Actual results

No output on the host listening socat, UDP packet with "hello" appears on the host loopback interface.
Comment 1 David Gibson 2022-12-01 02:10:29 UTC
It looks like this is because the sockets created for forwarding the output packets are bound to UNSPEC, meaning that when delivering to the host via gateway translation they use loopback.
Comment 2 David Gibson 2023-01-24 03:43:55 UTC
I based this on a misunderstanding of how the $GW translation is supposed to work.

After discussing with Stefano the meaning of GW translation, the consensus was that $GW in the guest/ns represents the host's loopback address as seen from the host.

There are still some weird edge cases with $GW translation, but this specific example is working as intended.