35 Commits
Author SHA1 Message Date
Nayana BidariandgVisor bot a3e5887415 Changes to support netstack save restore.
- Added a new Stats() method in inet.Stack to get the saved stats
during restore.
- Mark stack.nic, tcpip.Route and stack.addressState structs as "nosave".
These fields should not be saved because the IP addresses and routes can
change during restore and new configuration of routes and IP addresses will be
extracted from the restore spec and initialized in the saved stack.
- Changes in Restore() method in icmp, udp, tcp, packet and raw endpoint files
to support save restore of these endpoints. These changes are flag guarded by
the TESTONLY-save-restore-netstack flag.

PiperOrigin-RevId: 707639274
2024-12-18 12:52:22 -08:00
Nayana BidariandgVisor bot df9ba5fb67 Restore listening connections when netstack s/r is enabled.
This CL restores the listening connections when netstack s/r is enabled.
The changes include:
- New method as a workaround to replace the new routes and nics to the loaded
stack after restore.
- New Restore() for transport layer protocols to restore the protocol level
background workers.
- Adds afterLoad() method for fdbased processors.
- Adds a test to verify listening connection is restored after checkpointing
with netstack s/r enabled.
- Few other changes to save restore fields to enable netstack s/r.

PiperOrigin-RevId: 698453124
2024-11-20 11:13:57 -08:00
Jing ChenandgVisor bot f681bcc095 Implement RTM_DELROUTE in netstack.
PiperOrigin-RevId: 675711612
2024-09-17 14:33:41 -07:00
Nayana BidariandgVisor bot 740dc367db Mark netstack as save and use it only in tests
- Adds a new flag which will enable netstack s/r. When the flag is not enabled,
there is no change in the existing behavior. The flag will be enabled only in
tests to verify the s/r functionality of netstack.
- Some additional fields in netstack were causing panic when netstack is
save/restored. Such fields are marked as 'save'/'nosave' accordingly to resolve
the panic.

PiperOrigin-RevId: 668566657
2024-08-28 12:49:43 -07:00
Jing ChenandgVisor bot 35309c96c0 Implement RTM_NEWROUTE in netstack to create/replace a route.
PiperOrigin-RevId: 650814137
2024-07-09 18:04:19 -07:00
Andrei VaginandgVisor bot 04e7902bb5 Implement veth devices
The veth devices are virtual Ethernet devices. They can act as
tunnels between network namespaces to create a bridge to a
physical network device in another namespace, but can also be
used as standalone network devices.

More information can be found here:
https://man7.org/linux/man-pages/man4/veth.4.html

PiperOrigin-RevId: 638853289
2024-05-30 18:25:30 -07:00
Andrei VaginandgVisor bot 129734a352 Pass NEWLINK netlink commands to network stacks
The NEWLINK commands contains many properties and here is no reason to have
another abstract interface between the Sentry and network stacks.

PiperOrigin-RevId: 627916629
2024-04-24 18:42:44 -07:00
Kevin KrakauerandgVisor bot c9964aa985 netstack: remove GRO from ingress flow
GRO is getting moved and updated. This removes it in preparation for a
follow-up CL.

PiperOrigin-RevId: 621984030
2024-04-04 15:17:08 -07:00
Nayana BidariandgVisor bot d5f24ea92a Add Resume() method in netstack.
Resume method resumes the endpoints after save which is required for
save/resume. This method resumes the endpoint states which were frozen during
save.

PiperOrigin-RevId: 615467468
2024-03-13 10:36:29 -07:00
Nayana BidariandgVisor bot a76911efa9 Rename Resume() to Restore() in netstack.
The existing Resume method in netstack is doing the work of Restore. This
method does not resume endpoints as the resumable endpoints are only stored
during the Restore of the sandbox, rename the method appropriately.

PiperOrigin-RevId: 613320887
2024-03-06 13:25:31 -08:00
Kevin KrakauerandgVisor bot 901d9a75d3 netstack: add gro_flush_timeout
Makes a per-interface file available to configure the GRO timeout, e.g.
/sys/class/net/eth0/gro_flush_timeout

PiperOrigin-RevId: 487082821
2022-11-08 16:34:55 -08:00
Kevin KrakauerandgVisor bot d8aa09e04c convert uses of interface{} to any
Done via:
  find . -name "*.go" | xargs sed -i -E 's/interface\{\}/any/g'

PiperOrigin-RevId: 487033228
2022-11-08 13:14:06 -08:00
Andrei VaginandgVisor bot 5ffcc1f799 Don't leak network namespaces
PiperOrigin-RevId: 454707336
2022-06-13 15:05:21 -07:00
Bhasker HariharanandgVisor bot 74a1820ceb Remove TCP endpoint goroutines.
This change removes all endpoint goroutines and all TCP processing is now done
inline in the TCP processor loop. TCP timers directly invoke handlers as
required rather than assert a waker.

UnlockUser is also simplified to just queue the endpoint to the processor
instead of trying to process segments inline. This allows us to centralize logic
for TCP state handling in the processor. This potentially could involve an extra
wakeup but now that endpoint goroutines do not exist this is not such a big
concern as in case of busy servers the processor goroutines will already be
running anyway.

This change also allows us to clean up S/R as now restoring a TCP endpoint does
not require restarting a goroutine and moving it to the right logical point but
only requires that we restart any timers that may have been running when the
save was done and restore any port bindings as required.

Endpoint.Release is now removed in favor of Endpoint.Abort by using Abort in
places where we use Endpoint.Release.

Updates #231

PiperOrigin-RevId: 442673015
2022-04-18 17:35:36 -07:00
Bhasker HariharanandgVisor bot fe88fe6768 Support custom socket options in hostinet.
PiperOrigin-RevId: 416625574
2021-12-15 12:51:54 -08:00
Zeling FengandgVisor bot 979d6e7d77 Support RTM_DELLINK
This change will allow us to remove the default link in a packetimpact test so
we can reduce indeterministic behaviors as required in https://fxbug.dev/78430.
This will also help with testing #1388.

Updates #578, #1388.

PiperOrigin-RevId: 387896847
2021-07-30 15:41:36 -07:00
Ghanan GowripalanandgVisor bot 600d14f83e Don't read forwarding from netstack in sentry
https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt:
  /proc/sys/net/ipv4/* Variables:

  ip_forward - BOOLEAN
    0 - disabled (default)
    not 0 - enabled

    Forward Packets between interfaces.

    This variable is special, its change resets all configuration
    parameters to their default state (RFC1122 for hosts, RFC1812
    for routers)

/proc/sys/net/ipv4/ip_forward only does work when its value is changed
and always returns the last written value. The last written value may
not reflect the current state of the netstack (e.g. when `ip_forward`
was written a value of "1" then disable forwarding on an interface)
so there is no need for sentry to probe netstack to get the current
forwarding state of interfaces.

```
~$ cat /proc/sys/net/ipv4/ip_forward
0
~$ sudo bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
~$ cat /proc/sys/net/ipv4/ip_forward
1
~$ sudo sysctl -a | grep ipv4 | grep forward
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.eno1.forwarding = 1
net.ipv4.conf.lo.forwarding = 1
net.ipv4.conf.wlp1s0.forwarding = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward_update_priority = 1
net.ipv4.ip_forward_use_pmtu = 0
~$ sudo sysctl -w net.ipv4.conf.wlp1s0.forwarding=0
net.ipv4.conf.wlp1s0.forwarding = 0
~$ sudo sysctl -a | grep ipv4 | grep forward
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.eno1.forwarding = 1
net.ipv4.conf.lo.forwarding = 1
net.ipv4.conf.wlp1s0.forwarding = 0
net.ipv4.ip_forward = 1
net.ipv4.ip_forward_update_priority = 1
net.ipv4.ip_forward_use_pmtu = 0
~$ cat /proc/sys/net/ipv4/ip_forward
1
~$ sudo bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
~$ sudo sysctl -a | grep ipv4 | grep forward
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.eno1.forwarding = 1
net.ipv4.conf.lo.forwarding = 1
net.ipv4.conf.wlp1s0.forwarding = 0
net.ipv4.ip_forward = 1
net.ipv4.ip_forward_update_priority = 1
net.ipv4.ip_forward_use_pmtu = 0
~$ sudo bash -c "echo 0 > /proc/sys/net/ipv4/ip_forward"
~$ sudo sysctl -a | grep ipv4 | grep forward
sysctl: unable to open directory "/proc/sys/fs/binfmt_misc/"
net.ipv4.conf.all.forwarding = 0
net.ipv4.conf.default.forwarding = 0
net.ipv4.conf.eno1.forwarding = 0
net.ipv4.conf.lo.forwarding = 0
net.ipv4.conf.wlp1s0.forwarding = 0
net.ipv4.ip_forward = 0
net.ipv4.ip_forward_update_priority = 1
net.ipv4.ip_forward_use_pmtu = 0
~$ cat /proc/sys/net/ipv4/ip_forward
0
```

In the above example we can see that writing "1" to
/proc/sys/net/ipv4/ip_forward configures the stack to be a router (all
interfaces are configured to enable forwarding). However, if we manually
update an interace (`wlp1s0`) to not forward packets,
/proc/sys/net/ipv4/ip_forward continues to return the last written value
of "1", even though not all interfaces will forward packets.

Also note that writing the same value twice has no effect; work is
performed iff the value changes.

This change also removes the 'unset' state from sentry's ip forwarding
data structures as an 'unset' ip forwarding value is the same as leaving
forwarding disabled as the stack is always brought up with forwarding
initially disabled; disabling forwarding on a newly created stack is a
no-op.

PiperOrigin-RevId: 373853106
2021-05-14 13:22:58 -07:00
Kevin KrakauerandgVisor bot abbdcebc54 Implement /proc/sys/net/ipv4/ip_local_port_range
Speeds up the socket stress tests by a couple orders of magnitude.

PiperOrigin-RevId: 361721050
2021-03-08 20:40:34 -08:00
Ian LewisandgVisor bot 59e2c9f16a Add basic address deletion to netlink
Updates #3921

PiperOrigin-RevId: 339195417
2020-10-27 00:18:10 -07:00
Ian Lewis ac324f646e Merge branch 'master' into ip-forwarding
- Merges aleksej-paschenko's with HEAD
- Adds vfs2 support for ip_forward
2020-08-17 21:44:31 -04:00
Nayana BidariandgVisor bot 35312a95c4 Add loss recovery option for TCP.
/proc/sys/net/ipv4/tcp_recovery is used to enable RACK loss
recovery in TCP.

PiperOrigin-RevId: 325157807
2020-08-05 20:50:06 -07:00
Ting-Yu WangandgVisor bot 665b614e4a Support RTM_NEWADDR and RTM_GETLINK in (rt)netlink.
PiperOrigin-RevId: 293271055
2020-02-04 18:05:03 -08:00
Ian GudgerandgVisor bot a2c51efe36 Add endpoint tracking to the stack.
In the future this will replace DanglingEndpoints. DanglingEndpoints must be
kept for now due to issues with save/restore.

This is arguably a cleaner design and allows the stack to know which transport
endpoints might still be using its link endpoints.

Updates #837

PiperOrigin-RevId: 277386633
2019-10-29 16:14:51 -07:00
aleksej 352ae1022c Add /proc/sys/net/ipv4/ip_forward 2019-10-27 15:28:15 +03:00
Jianfeng Tan e3d4a67739 support /proc/net/snmp
This proc file contains statistics according to [1].

[1] https://tools.ietf.org/html/rfc2013

Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
Change-Id: I9662132085edd8a7783d356ce4237d7ac0800d94
2019-10-15 16:38:40 +00:00