Commit Graph

57 Commits

Author SHA1 Message Date
Fabricio Voznika 97f6b20e89 Move mount configutation to RunOpts
Separate mount configuration from links and move it to
RunOpts, like the other options.

PiperOrigin-RevId: 317010158
2020-06-17 18:43:26 -07:00
Kevin Krakauer 74a7d76c97 iptables: loopback traffic skips prerouting chain
Loopback traffic is not affected by rules in the PREROUTING chain.

This change is also necessary for istio's envoy to talk to other
components in the same pod.
2020-06-05 16:43:50 -07:00
Kevin Krakauer 790811f757 Fix copied comment mistakes.
PiperOrigin-RevId: 313862843
2020-05-29 15:39:17 -07:00
Kevin Krakauer c55b84e16a Enable iptables source filtering (-s/--source) 2020-05-28 17:45:47 -07:00
Nayana Bidari 27b1f19cab iptables: support gid match for owner matching.
- Added support for matching gid owner and invert flag for uid
and gid.
$ iptables -A OUTPUT -p tcp -m owner --gid-owner root -j ACCEPT
$ iptables -A OUTPUT -p tcp -m owner ! --uid-owner root -j ACCEPT
$ iptables -A OUTPUT -p tcp -m owner ! --gid-owner root -j DROP

- Added tests for uid, gid and invert flags.
2020-05-12 12:20:47 -07:00
gVisor bot cfd30665c1 iptables - filter packets using outgoing interface.
Enables commands with -o (--out-interface) for iptables rules.
$ iptables -A OUTPUT -o eth0 -j ACCEPT

PiperOrigin-RevId: 310642286
2020-05-08 15:44:54 -07:00
Nayana Bidari b660f16d18 Support for connection tracking of TCP packets.
Connection tracking is used to track packets in prerouting and
output hooks of iptables. The NAT rules modify the tuples in
connections. The connection tracking code modifies the packets by
looking at the modified tuples.
2020-05-01 16:59:40 -07:00
Adin Scannell c60613475c Standardize all Docker images.
This change moves all Docker images to a standard location, and abstracts the
build process so that they can be maintained in an automated fashion. This also
allows the images to be architecture-independent.

All images will now be referred to by the test framework via the canonical
`gvisor.dev/images/<name>`, where `<name>` is a function of the path within the
source tree.

In a subsequent change, continuous integration will be added so that the images
will always be correct and available locally.

In the end, using `bazel` for Docker containers is simply not possible. Given
that we already have the need to use `make` with the base container (for
Docker), we extend this approach to get more flexibility.

This change also adds a self-documenting and powerful Makefile that is intended
to replace the collection of scripts in scripts. Canonical (self-documenting)
targets can be added here for targets that understand which images need to be
loaded and/or built.

PiperOrigin-RevId: 308322438
2020-04-24 14:11:42 -07:00
Adin Scannell 1481499fe2 Simplify Docker test infrastructure.
This change adds a layer of abstraction around the internal Docker APIs,
and eliminates all direct dependencies on Dockerfiles in the infrastructure.

A subsequent change will automated the generation of local images (with
efficient caching). Note that this change drops the use of bazel container
rules, as that experiment does not seem to be viable.

PiperOrigin-RevId: 308095430
2020-04-23 11:33:30 -07:00
Nayana Bidari 92b9069b67 Support owner matching for iptables.
This feature will match UID and GID of the packet creator, for locally
generated packets. This match is only valid in the OUTPUT and POSTROUTING
chains. Forwarded packets do not have any socket associated with them.
Packets from kernel threads do have a socket, but usually no owner.
2020-03-26 12:21:24 -07:00
Kevin Krakauer bc3def43c3 Check error in DropTCP*Port tests and fix comment.
PiperOrigin-RevId: 303147253
2020-03-26 10:47:51 -07:00
gVisor bot 79389f8abb Merge pull request #2187 from kevinGC:deflake-connectTCP
PiperOrigin-RevId: 301716568
2020-03-18 18:58:30 -07:00
Kevin Krakauer a8f9cc8798 iptables: deflake DropTCP*Port tests
These tests could timeout because net.DialTCP didn't respect the
timeout.
2020-03-18 18:16:33 -07:00
Kevin Krakauer b5ea65c07c iptables: skip tests for not-yet-supported features
PiperOrigin-RevId: 301686266
2020-03-18 15:52:57 -07:00
Kevin Krakauer fc16e64396 Automated rollback of changelist 301476456
PiperOrigin-RevId: 301650898
2020-03-18 13:08:11 -07:00
Kevin Krakauer 1cc5a71a0e iptables: fix type in script name, mark some new tests as skipped
PiperOrigin-RevId: 301476456
2020-03-17 16:23:00 -07:00
gVisor bot 159a230b9b Merge pull request #1943 from kevinGC:ipt-filter-ip
PiperOrigin-RevId: 301197007
2020-03-16 11:13:14 -07:00
Kevin Krakauer 4054b021f0 iptables: ready tests to be enabled in kokoro
Fixed flakes (tested via --runs_per_test=100) and added skips for
not-yet-implemented features. Once submitted, the iptables tests will be
ready to enable in kokoro.
2020-03-11 15:13:58 -07:00
Kevin Krakauer 408979e619 iptables: filter by IP address (and range)
Enables commands such as:
$ iptables -A INPUT -d 127.0.0.1 -j ACCEPT
$ iptables -t nat -A PREROUTING ! -d 127.0.0.1 -j REDIRECT

Also adds a bunch of REDIRECT+destination tests.
2020-02-26 11:04:00 -08:00
nybidari 818abc2bd5
Merge branch 'master' into iptables 2020-02-25 15:33:59 -08:00
Nayana Bidari acc405ba60 Add nat table support for iptables.
- commit the changes for the comments.
2020-02-25 15:03:51 -08:00
gVisor bot 247843bbc5 iptables: use "-t nat" for NAT tests
PiperOrigin-RevId: 295835807
2020-02-18 15:25:51 -08:00
gVisor bot 7fdb609b3e Merge pull request #1850 from kevinGC:jump2
PiperOrigin-RevId: 295785052
2020-02-18 11:41:54 -08:00
Nayana Bidari b30b7f3422 Add nat table support for iptables.
Add nat table support for Prerouting hook with Redirect option.
Add tests to check redirect of ports.
2020-02-18 11:30:42 -08:00
Kevin Krakauer 6ef63cd7da We can now create and jump in iptables. For example:
$ iptables -N foochain
$ iptables -A INPUT -j foochain
2020-02-13 17:02:50 -08:00
Kevin Krakauer 6fdf2c53a1 iptables: User chains
- Adds creation of user chains via `-N <chainname>`
- Adds `-j RETURN` support for built-in chains, which triggers the
  chain's underflow rule (usually the default policy).
- Adds tests for chain creation, default policies, and `-j RETURN' from
  built-in chains.
2020-02-12 15:02:47 -08:00
Kevin Krakauer 31f2182cd3 iptables: add instructions for runsc building.
The readme didn't mention that users need to:
- `bazel build` when working on iptables tests
- enable raw sockets in /etc/docker/daemon.json.

PiperOrigin-RevId: 294260169
2020-02-10 11:09:19 -08:00
Kevin Krakauer bfa4a235f4 Fix `bazel run` target in docs.
PiperOrigin-RevId: 293676954
2020-02-06 14:27:31 -08:00
gVisor bot b29aeebaf6 Merge pull request #1683 from kevinGC:ipt-udp-matchers
PiperOrigin-RevId: 293243342
2020-02-04 16:20:16 -08:00
Kevin Krakauer 0ade523f06 Fix iptables tests that were broken by rename.
The name of the runner binary target changed from "runner" to "runner-image",
causing iptables tests to fail.

PiperOrigin-RevId: 292242263
2020-01-29 16:27:12 -08:00
Kevin Krakauer 29316e66ad Cleanup for GH review. 2020-01-27 12:27:04 -08:00
Adin Scannell d29e59af9f Standardize on tools directory.
PiperOrigin-RevId: 291745021
2020-01-27 12:21:00 -08:00
Kevin Krakauer 7636478a31 Merge branch 'master' into ipt-udp-matchers 2020-01-24 10:42:43 -08:00
gVisor bot 3d10edc942 Merge pull request #1617 from kevinGC:iptables-write-filter-proto
PiperOrigin-RevId: 291249314
2020-01-23 14:48:39 -08:00
Kevin Krakauer 9143fcd7fd Add UDP matchers. 2020-01-21 14:47:17 -08:00
Kevin Krakauer 9f736ac6a7 More little fixes. 2020-01-21 13:42:43 -08:00
Kevin Krakauer 47bc7550c0 Fixing stuff 2020-01-21 13:37:25 -08:00
Kevin Krakauer 62357a0afb Merge branch 'master' into iptables-write-filter-proto 2020-01-21 13:16:25 -08:00
gVisor bot 5f82f092e7 Merge pull request #1558 from kevinGC:iptables-write-input-drop
PiperOrigin-RevId: 290793754
2020-01-21 12:08:52 -08:00
gVisor bot 989b611f5a Merge pull request #1541 from nybidari:iptables
PiperOrigin-RevId: 290273561
2020-01-17 08:38:25 -08:00
Kevin Krakauer d51eaa59c0 Merge branch 'iptables-write-input-drop' into iptables-write-filter-proto 2020-01-13 16:06:29 -08:00
Kevin Krakauer 31e49f4b19 Merge branch 'master' into iptables-write-input-drop 2020-01-13 12:22:15 -08:00
Nayana Bidari 98327a94cc Add test for iptables TCP rule
Added tests for tcp protocol with input and output rules including options sport and dport
Increased timeout in iptables_test as TCP tests were timing out with existing value.
2020-01-13 09:11:40 -08:00
Nayana Bidari 9aeb053bba Add tests for redirect port
Fix indentation and change function names.
2020-01-10 09:05:25 -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 89d11b4d96 Added a test that we don't pass yet 2020-01-09 13:41:52 -08:00
Nayana Bidari 6cc8e2d814 Add test to check iptables redirect port rule 2020-01-09 10:24:26 -08:00
Kevin Krakauer aeb3a4017b Working on filtering by protocol. 2020-01-08 22:10:35 -08:00
Kevin Krakauer b2a881784c Built dead-simple traversal, but now getting depedency cycle error :'( 2020-01-08 14:48:47 -08:00
Kevin Krakauer 447f64c561 Added test for unconditional DROP on the filter INPUT chain 2020-01-08 12:48:17 -08:00