google / gvisor

Application Kernel for Containers
https://gvisor.dev
Apache License 2.0
15.53k stars 1.28k forks source link

IPPacketInfo is not properly populated #3556

Open ghananigans opened 4 years ago

ghananigans commented 4 years ago

As per linux:

IP_PKTINFO (since Linux 2.2)
Pass an IP_PKTINFO ancillary message that contains a pktinfo structure that supplies some information about the incoming packet. This only works for datagram oriented sockets. The argument is a flag that tells the socket whether the IP_PKTINFO message should be passed or not. The message itself can only be sent/retrieved as control message with a packet using recvmsg(2) or sendmsg(2).
struct in_pktinfo {
    unsigned int   ipi_ifindex;  /* Interface index */
    struct in_addr ipi_spec_dst; /* Local address */
    struct in_addr ipi_addr;     /* Header Destination
                                    address */
};
ipi_ifindex is the unique index of the interface the packet was received on. ipi_spec_dst is the local address of the packet and ipi_addr is the destination address in the packet header. If IP_PKTINFO is passed to sendmsg(2) and ipi_spec_dst is not zero, then it is used as the local source address for the routing table lookup and for setting up IP source route options. When ipi_ifindex is not zero, the primary local address of the interface specified by the index overwrites ipi_spec_dst for the routing table lookup.

tcpip.IPPacketInfo.LocalAddress (which maps too ipi_spec_dst should be a unicast address that may be used to respond to an incoming packet. Currently, the gvisor netstack's udp implementation blindly uses the destination address of incoming packets, but this would be incorrect if the packet was destined to a multicast or broadcast address.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 3 years ago

There are TODOs still referencing this issue:

  1. pkg/tcpip/transport/udp/endpoint.go:1324: r.LocalAddress may be a multicast or broadcast
  2. pkg/tcpip/transport/udp/udp_test.go:1378: This check is validating incorrect
  3. pkg/tcpip/transport/udp/udp_test.go:1391: This check is validating incorrect
  4. pkg/tcpip/transport/udp/udp_test.go:1411: This check is validating incorrect
  5. pkg/tcpip/transport/udp/udp_test.go:1473: This check is validating incorrect
  6. pkg/tcpip/transport/udp/udp_test.go:1485: This check is validating incorrect
  7. pkg/tcpip/transport/udp/udp_test.go:1503: This check is validating incorrect
  8. test/syscalls/linux/socket_ipv4_udp_unbound.cc:2500: This check is validating incorrect

Search TODO

github-actions[bot] commented 11 months ago

A friendly reminder that this issue had no activity for 120 days.

github-actions[bot] commented 8 months ago

This issue has been closed due to lack of activity.

github-actions[bot] commented 8 months ago

There are TODOs still referencing this issue:

  1. pkg/tcpip/transport/udp/endpoint.go:986: r.LocalAddress may be a multicast or broadcast
  2. pkg/tcpip/transport/raw/endpoint.go:657: dstAddr may be a multicast or broadcast
  3. pkg/tcpip/transport/udp/udp_test.go:1047: This check is validating incorrect
  4. pkg/tcpip/transport/udp/udp_test.go:1059: This check is validating incorrect
  5. pkg/tcpip/transport/udp/udp_test.go:1077: This check is validating incorrect
  6. test/syscalls/linux/socket_ipv4_udp_unbound.cc:2318: This check is validating incorrect

Search TODO

github-actions[bot] commented 4 months ago

A friendly reminder that this issue had no activity for 120 days.