Commit Graph

2404 Commits

Author SHA1 Message Date
Bhasker Hariharan 356d81146b Deflake a couple of TCP syscall tests when run under gotsan.
PiperOrigin-RevId: 289010316
2020-01-09 17:58:48 -08:00
Zach Koopmans f1b69b159f Implement gcloud_producer for bm-tools
bm-tools works via "Machine" objects, which are front
objects for actual virtual or physical machines. glcoud_producer
produces machines on GCP using the `gcloud` tool.

Included are:
- GCloudProducer - the class producing machines
- MockGCloudProducer - class for mocking GCloudProducer.
- tests using the mock
- test data as .json files. Code to generate this test data may be
included in a follow up.

PiperOrigin-RevId: 289005958
2020-01-09 17:24:35 -08:00
Ghanan Gowripalan 26c5653bb5 Inform NDPDispatcher when Stack learns about available configurations via DHCPv6
Inform the Stack's NDPDispatcher when it receives an NDP Router Advertisement
that updates the available configurations via DHCPv6. The Stack makes sure that
its NDPDispatcher isn't informed unless the avaiable configurations via DHCPv6
for a NIC is updated.

Tests: Test that a Stack's NDPDispatcher is informed when it receives an NDP
Router Advertisement that informs it of new configurations available via DHCPv6.
PiperOrigin-RevId: 289001283
2020-01-09 16:56:28 -08:00
Ghanan Gowripalan 8fafd3142e Separate NDP tests into its own package
Internal tools timeout after 60s during tests that are required to pass before
changes can be submitted. Separate out NDP tests into its own package to help
prevent timeouts when testing.

PiperOrigin-RevId: 288990597
2020-01-09 15:56:44 -08:00
Nayana Bidari 04abc9cf55 Add test for redirect port
Fix the indentation and print statements.
Moved the NAT redirect tests to new file.
Added negative test to check redirect rule on ports other than
redirected port.
2020-01-09 15:38:28 -08:00
Kevin Krakauer ff719159be Confirmed that it works if I hardcode 17 in for pkt.Protocol. Need to address parsing the packet early :( 2020-01-09 15:38:21 -08:00
gVisor bot ee3158f713 Merge pull request #1423 from xiaobo55x:strace
PiperOrigin-RevId: 288965915
2020-01-09 13:58:24 -08:00
Kevin Krakauer 89d11b4d96 Added a test that we don't pass yet 2020-01-09 13:41:52 -08:00
Eyal Soha 8643933d6e Change BindToDeviceOption to store NICID
This makes it possible to call the sockopt from go even when the NIC has no
name.

PiperOrigin-RevId: 288955236
2020-01-09 13:07:53 -08:00
Bert Muthalaly e752ddbb72 Allow clients to store an opaque NICContext with NICs
...retrievable later via stack.NICInfo().

Clients of this library can use it to add metadata that should be tracked
alongside a NIC, to avoid having to keep a map[tcpip.NICID]metadata mirroring
stack.Stack's nic map.

PiperOrigin-RevId: 288924900
2020-01-09 10:46:01 -08:00
Nayana Bidari 6cc8e2d814 Add test to check iptables redirect port rule 2020-01-09 10:24:26 -08:00
Fabricio Voznika 290908fa8a Configure issue reviver to run with Kokoro
PiperOrigin-RevId: 288921032
2020-01-09 10:17:54 -08:00
Lai Jiangshan fdfa05ff2c Avoid panic when c.PCIDs is nil
When PCID is disabled, there would throw a panic
when dropPageTables() access to c.PCID without check.

Signed-off-by: Lai Jiangshan <eag0628@gmail.com>
2020-01-09 09:18:33 +00:00
Kevin Krakauer aeb3a4017b Working on filtering by protocol. 2020-01-08 22:10:35 -08:00
Kevin Krakauer 781a68eeb6 It works! It drops some packets. 2020-01-08 21:39:13 -08:00
Kevin Krakauer 06e2366e96 Merge branch 'iptables-write' into iptables-write-input-drop 2020-01-08 20:05:02 -08:00
Ghanan Gowripalan d057871f41 CancellableTimer to encapsulate the work of safely stopping timers
Add a new CancellableTimer type to encapsulate the work of safely stopping
timers when it fires at the same time some "related work" is being handled. The
term "related work" is some work that needs to be done while having obtained
some common lock (L).

Example: Say we have an invalidation timer that may be extended or cancelled by
some event. Creating a normal timer and simply cancelling may not be sufficient
as the timer may have already fired when the event handler attemps to cancel it.
Even if the timer and event handler obtains L before doing work, once the event
handler releases L, the timer will eventually obtain L and do some unwanted
work.

To prevent the timer from doing unwanted work, it checks if it should early
return instead of doing the normal work after obtaining L. When stopping the
timer callers must have L locked so the timer can be safely informed that it
should early return.

Test: Tests that CancellableTimer fires and resets properly. Test to make sure
the timer fn is not called after being stopped within the lock L.
PiperOrigin-RevId: 288806984
2020-01-08 17:50:54 -08:00
Kevin Krakauer ae060a63d9 More GH comments. 2020-01-08 17:30:08 -08:00
Ian Lewis fbb2c008e2 Return correct length with MSG_TRUNC for unix sockets.
This change calls a new Truncate method on the EndpointReader in RecvMsg for
both netlink and unix sockets.  This allows readers such as sockets to peek at
the length of data without actually reading it to a buffer.

Fixes #993 #1240

PiperOrigin-RevId: 288800167
2020-01-08 17:24:05 -08:00
Dean Deng 565b641483 Define sizes for extent headers and entries separately to improve clarity.
PiperOrigin-RevId: 288799694
2020-01-08 16:58:12 -08:00
Kevin Krakauer f26a576984 Addressed GH comments 2020-01-08 16:35:01 -08:00
Ting-Yu Wang b3ae8a62cf Fix slice bounds out of range panic in parsing socket control message.
Panic found by syzakller.

PiperOrigin-RevId: 288799046
2020-01-08 16:32:34 -08:00
Fabricio Voznika 1c24201467 Github bug reviver
For everyone's joy, this is a tool that reopens issues that
have been closed, but are still referenced by TODOs in the
code. The idea is to run it in Kokoro nightly. Kokoro changes
are coming up next.

PiperOrigin-RevId: 288789560
2020-01-08 16:06:40 -08:00
Kevin Krakauer 0999ae8b34 Getting a panic when running tests. For some reason the filter table is
ending up with the wrong chains and is indexing -1 into rules.
2020-01-08 15:57:25 -08:00
Tamir Duberstein d530df2f95 Introduce tcpip.SockOptBool
...and port V6OnlyOption to it.

PiperOrigin-RevId: 288789451
2020-01-08 15:40:48 -08:00
Bert Muthalaly e21c584056 Combine various Create*NIC methods into CreateNICWithOptions.
PiperOrigin-RevId: 288779416
2020-01-08 14:50:49 -08:00
Kevin Krakauer b2a881784c Built dead-simple traversal, but now getting depedency cycle error :'( 2020-01-08 14:48:47 -08:00
Tamir Duberstein a271bccfc6 Rename tcpip.SockOpt{,Int}
PiperOrigin-RevId: 288772878
2020-01-08 14:20:07 -08:00
Tamir Duberstein d01240d871 Take addresses as const
PiperOrigin-RevId: 288767927
2020-01-08 13:54:19 -08:00
Kevin Krakauer 447f64c561 Added test for unconditional DROP on the filter INPUT chain 2020-01-08 12:48:17 -08:00
Kevin Krakauer 7cebd77806 First commit -- re-adding DROP 2020-01-08 12:43:46 -08:00
gVisor bot bb96f52576 Merge pull request #1273 from lubinszARM:pr_ring_3
PiperOrigin-RevId: 288743614
2020-01-08 11:48:34 -08:00
Kevin Krakauer 366e050ad5 Revert go.mod and go.sum 2020-01-08 11:24:55 -08:00
Kevin Krakauer 446a250996 Comment cleanup. 2020-01-08 11:20:48 -08:00
Kevin Krakauer 2f02e15e54 Newline 2020-01-08 11:17:15 -08:00
Kevin Krakauer 899309c4eb Revert filter_input change 2020-01-08 11:16:41 -08:00
Kevin Krakauer 1e1921e2ac Minor fixes to comments and logging 2020-01-08 11:15:46 -08:00
Fabricio Voznika db376e1392 Make /proc/[pid] offset start at TGID_OFFSET
Updates #1195

PiperOrigin-RevId: 288725745
2020-01-08 10:45:12 -08:00
Tamir Duberstein 9df018767c Remove redundant function argument
PacketLooping is already a member on the passed Route.

PiperOrigin-RevId: 288721500
2020-01-08 10:22:51 -08:00
Kevin Krakauer 8cc1c35bbd Write simple ACCEPT rules to the filter table.
This gets us closer to passing the iptables tests and opens up iptables
so it can be worked on by multiple people.

A few restrictions are enforced for security (i.e. we don't want to let
users write a bunch of iptables rules and then just not enforce them):

- Only the filter table is writable.
- Only ACCEPT rules with no matching criteria can be added.
2020-01-08 10:08:14 -08:00
Bert Muthalaly 0cc1e74b57 Add NIC.isLoopback()
...enabling us to remove the "CreateNamedLoopbackNIC" variant of
CreateNIC and all the plumbing to connect it through to where the value
is read in FindRoute.

PiperOrigin-RevId: 288713093
2020-01-08 09:30:20 -08:00
Marek Majkowski c276e4740f Fix #1522 - implement silly window sydrome protection on rx side
Before, each of small read()'s that raises window either from zero
or above threshold of aMSS, would generate an ACK. In a classic
silly-window-syndrome scenario, we can imagine a pessimistic case
when small read()'s generate a stream of ACKs.

This PR fixes that, essentially treating window size < aMSS as zero.
We send ACK exactly in a moment when window increases to >= aMSS
or half of receive buffer size (whichever smaller).
2020-01-08 12:56:39 +00:00
Andrei Vagin a53ac7307a fs/splice: don't report a partialResult error if there is no data loss
PiperOrigin-RevId: 288642552
2020-01-07 23:54:14 -08:00
Adin Scannell e77ad57423 Fix partial_bad_buffer write tests.
The write tests are fitted to Linux-specific behavior, but it is not
well-specified. Tweak the tests to allow for both acceptable outcomes.

PiperOrigin-RevId: 288606386
2020-01-07 17:26:42 -08:00
Ghanan Gowripalan 4e19d165cc Support deprecating SLAAC addresses after the preferred lifetime
Support deprecating network endpoints on a NIC. If an endpoint is deprecated, it
should not be used for new connections unless a more preferred endpoint is not
available, or unless the deprecated endpoint was explicitly requested.

Test: Test that deprecated endpoints are only returned when more preferred
endpoints are not available and SLAAC addresses are deprecated after its
preferred lifetime
PiperOrigin-RevId: 288562705
2020-01-07 13:42:08 -08:00
Marek Majkowski 08a97a6d19 #1398 - send ACK when available buffer space gets larger than 1 MSS
When receiving data, netstack avoids sending spurious acks. When
user does recv() should netstack send ack telling the sender that
the window was increased? It depends. Before this patch, netstack
_will_ send the ack in the case when window was zero or window >>
scale was zero. Basically - when recv space increased from zero.

This is not working right with silly-window-avoidance on the sender
side. Some network stacks refuse to transmit segments, that will fill
the window but are below MSS. Before this patch, this confuses
netstack. On one hand if the window was like 3 bytes, netstack
will _not_ send ack if the window increases. On the other hand
sending party will refuse to transmit 3-byte packet.

This patch changes that, making netstack will send an ACK when
the available buffer size increases to or above 1*MSS. This will
inform other party buffer is large enough, and hopefully uncork it.


Signed-off-by: Marek Majkowski <marek@cloudflare.com>
2020-01-07 20:35:39 +00:00
Ghanan Gowripalan 2031cc4701 Disable auto-generation of IPv6 link-local addresses for loopback NICs
Test: Test that an IPv6 link-local address is not auto-generated for loopback
NICs, even when it is enabled for non-loopback NICS.
PiperOrigin-RevId: 288519591
2020-01-07 10:09:39 -08:00
Kevin Krakauer ed60bc326b Fix readme formatting.
PiperOrigin-RevId: 288402480
2020-01-06 16:49:34 -08:00
Ghanan Gowripalan 8dfd922840 Pass the NIC-internal name to the NIC name function when generating opaque IIDs
Pass the NIC-internal name to the NIC name function when generating opaque IIDs
so implementations can use the name that was provided when the NIC was created.
Previously, explicit NICID to NIC name resolution was required from the netstack
integrator.

Tests: Test that the name provided when creating a NIC is passed to the NIC name
function when generating opaque IIDs.
PiperOrigin-RevId: 288395359
2020-01-06 16:21:31 -08:00
Andrei Vagin 17c18241cd platform/syscall: use syscall + int3 to execute a system call in a stub process
Right now, we need to call ptrace(PTRACE_SYSCALL) and wait() twice to execute
one system call in a stub process. With these changes, we will need to call
ptrace + wait only once.

In addition, this allows to workaround the kernel bug when a stub process
doesn't stop on syscall-exit-stop and starts executing the next system call.

Reported-by: syzbot+37143cafa8dc3b5008ee@syzkaller.appspotmail.com
PiperOrigin-RevId: 288393029
2020-01-06 15:54:53 -08:00