15 Commits
Author SHA1 Message Date
Jeff MartinandgVisor bot 966dfe5505 Avoid panic when forwarding races with endpoint shutdown
Catch tcpip.ErrClosedForSend errors while forwarding. This may occur if
an endpoint is being shutdown at the same time as it's being used to
forward a packet.

PiperOrigin-RevId: 695452542
2024-11-11 12:58:45 -08:00
Nayana BidariandgVisor bot 90266aa28a Netstack S/R: Mark all the structs in netstack as savable.
Marks the structs in netstack as savable. This does not change or break any
existing behavior as the netstack itself is not savable yet.

PiperOrigin-RevId: 635943481
2024-05-21 15:19:07 -07:00
Andrei Vagin 5f4abad306 Fix a few typos
It is an idea of running codespell as part of our presubmit checks.
Before enabling it for new changes, let's fix what it has found.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2023-10-25 12:13:42 -07:00
Ghanan GowripalanandgVisor bot 52985127a0 Don't route packets w/ unspecified source address
PiperOrigin-RevId: 509914627
2023-02-15 13:26:40 -08:00
Ghanan GowripalanandgVisor bot 8ebc4d767a Accept no buffer space errors when forwarding
The outgoing device queue may be full when forwarding packets and those
errors should not result in a panic.

PiperOrigin-RevId: 499946528
2023-01-05 11:16:56 -08:00
Nate HurleyandgVisor bot 006bbe78ca Implement IPv4 multicast forwarding.
This change implements AddMulticastRoute and the requisite routing logic.
Subsequent changes will still be needed to:

1. Emit events for missing route or unexpected input interface
2. Implement DelRoute
3. Implement GetRouteStats

Updates #7338.

PiperOrigin-RevId: 451026594
2022-05-25 15:18:13 -07:00
Nick BrownandgVisor bot b8b43f70c8 Send ICMP errors when link address resolution fails
Before this change, we would silently drop packets when link resolution
failed. This change brings us into line with RFC 792 (IPv4) and RFC 4443 (IPv6),
both of which specify that gateways should return an ICMP error to the sender
when link resolution fails.

PiperOrigin-RevId: 374699789
2021-05-19 12:13:09 -07:00
Ghanan GowripalanandgVisor bot 2b457d9ee9 Check filter table when forwarding IP packets
This change updates the forwarding path to perform the forwarding hook
with iptables so that the filter table is consulted before a packet is
forwarded

Updates #170.

Test: iptables_test.TestForwardingHook
PiperOrigin-RevId: 373702359
2021-05-13 18:54:09 -07:00
Nick BrownandgVisor bot 29f4b71eb3 Send ICMP errors when unable to forward fragmented packets
Before this change, we would silently drop packets when the packet was too
big to be sent out through the NIC (and, for IPv4 packets, if DF was set).
This change brings us into line with RFC 792 (IPv4) and RFC 4443 (IPv6),
both of which specify that gateways should return an ICMP error to the sender
when the packet can't be fragmented.

PiperOrigin-RevId: 373480078
2021-05-12 16:53:43 -07:00
Nick BrownandgVisor bot 1daabac237 Process Hop-by-Hop header when forwarding IPv6 packets
Currently, we process IPv6 extension headers when receiving packets
but not when forwarding them. This is fine for the most part, with
with one exception: RFC 8200 requires that we process the
Hop-by-Hop headers even while forwarding packets.

This CL adds that support by invoking the Hop-by-hop logic performed
when receiving packets during forwarding as well.

PiperOrigin-RevId: 373145478
2021-05-11 07:25:56 -07:00
Nick BrownandgVisor bot 3258adb9bb Send ICMP errors when the network is unreachable
Before this change, we would silently drop packets when unable to determine a
route to the destination host. This change brings us into line with RFC 792
(IPv4) and RFC 4443 (IPv6), both of which specify that gateways should return
an ICMP error to the sender when unable to reach the destination.

Startblock:
  has LGTM from asfez
  and then
  add reviewer ghanan
PiperOrigin-RevId: 372214051
2021-05-05 14:58:42 -07:00
Toshi KikuchiandgVisor bot d1edabdca0 iptables: support postrouting hook and SNAT target
The current SNAT implementation has several limitations:
- SNAT source port has to be specified. It is not optional.
- SNAT source port range is not supported.
- SNAT for UDP is a one-way translation. No response packets
  are handled (because conntrack doesn't support UDP currently).
- SNAT and REDIRECT can't work on the same connection.

Fixes #5489

PiperOrigin-RevId: 367750325
2021-04-09 21:11:26 -07:00
Arthur SfezandgVisor bot 80bc67c268 Export stats that were forgotten
While I'm here, simplify the comments and unify naming of certain stats
across protocols.

PiperOrigin-RevId: 360728849
2021-03-03 12:18:55 -08:00
Arthur SfezandgVisor bot 2a2cb29e1c Validate IGMP packets
This change also adds support for Router Alert option processing on
incoming packets, a new stat for Router Alert option, and exports
all the IP-option related stats.

Fixes #5491

PiperOrigin-RevId: 358238123
2021-02-18 12:29:54 -08:00
Ghanan GowripalanandgVisor bot 18e993eb4f Move network internal code to internal package
Utilities written to be common across IPv4/IPv6 are not planned to be
available for public use.

https://golang.org/doc/go1.4#internalpackages

PiperOrigin-RevId: 356554862
2021-02-09 11:52:31 -08:00