Commit Graph
198 Commits
Author SHA1 Message Date
clickyotomy 4a8209f26f netfilter: Support multiport matching (-m multiport)
This set of changes adds:

  - support for `xt_multiport_{,v1}` matchers for matching for
    a range of ports and their inverse, i.e.,:

      ```
      -m multiport [!] --[s|d]ports (PORT,...|PORT:PORT,...)
      ```

  - support for `IP{,6}T_SO_GET_REVISION_MATCH` socket options,
    which allows `iptables` to query for the highest supported
    revision for a given matcher
2025-01-18 09:46:30 -05:00
Lucas ManningandgVisor bot 2267c24a41 Add support for custom socket options and setting the experiment IP option.
PiperOrigin-RevId: 700011458
2024-11-25 09:43:21 -08:00
Jamie LiuandgVisor bot e23347e5b5 Move //pkg/sentry/kernel/time to //pkg/sentry/ktime.
This avoids needing to rename it everywhere it's imported.

PiperOrigin-RevId: 693930089
2024-11-06 18:13:51 -08:00
Koichi Shiraishi 0cf77c02f8 all: remove use io/ioutil deprecated package & fix some deprecated thing
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2024-10-10 20:36:24 +09:00
Kevin KrakauerandgVisor bot 626010438a noop upon IP_PMTUDISC_INTERFACE and IP_PMTUDISC_OMIT
This is what we did previously, and doing so avoids breaking some users.

Fixes #10760.

PiperOrigin-RevId: 663358270
2024-08-15 10:35:00 -07:00
Ayush RanjanandgVisor bot c6d16988a9 Log endpoint type when SOL_IP options are not supported.
PiperOrigin-RevId: 647392128
2024-06-27 11:43:48 -07:00
Etienne PerotandgVisor bot abde965590 Metrics: Refactor uint64 metric constructor, allow non-cumulative gauges.
This turns the uint64 metric constructor arguments into a struct, making it
more explicit as to what each part means. It also allows the creation of
non-cumulative uint64 (gauge) metrics, and adds methods to decrement or set
them.

PiperOrigin-RevId: 647134245
2024-06-26 17:41:24 -07:00
Kevin KrakauerandgVisor bot e367e0b134 make PMTUD on by default and settable via sockopt
We've supported PMTUD for a long time and just never turned it on.

Addresses #10344.

PiperOrigin-RevId: 634003508
2024-05-15 10:44:02 -07:00
Kevin KrakauerandgVisor bot 89f5550a36 netstack: remove stale TODOs
PiperOrigin-RevId: 633751715
2024-05-14 17:11:30 -07:00
Nayana BidariandgVisor bot eb0505cdf1 Remove TODOs for supporting TCP_INFO option.
TCP_INFO option is supported in gVisor, but does not return all the fields
in struct TCP_INFO. The fields which were required for debugging are added.
The support for other fields in the struct can be added when required.

PiperOrigin-RevId: 632621246
2024-05-10 15:40:45 -07:00
Kevin KrakauerandgVisor bot 3f8ecf023c netstack: don't allocate interfaces when copying data in and out
In a redis-benchmark PING_INLINE test, this reduces allocations by 32%.

PiperOrigin-RevId: 618248114
2024-03-22 12:01:02 -07:00
Kevin KrakauerandgVisor bot 7f08016fb8 iptables: check revision numbers and support owner matcher v1
This change also replaces use of kernel.Task with a narrower type (IDMapper) in
preparation for a follow-up CL.

PiperOrigin-RevId: 578387814
2023-10-31 21:17:26 -07:00
Nayana BidariandgVisor bot aa02c6fa15 Fix SO_ACCEPTCONN option for unix sockets.
SO_ACCEPTCONN returns true for TCP sockets which are in a listening state.
Added this socket option support for unix sockets.

PiperOrigin-RevId: 577008617
2023-10-26 15:48:38 -07:00
Nicolas LacasseandgVisor bot c227d185a4 Emit SentryTcpListenEvent when the application listens on a tcp port.
PiperOrigin-RevId: 562957239
2023-09-05 19:15:45 -07:00
Andrei VaginandgVisor bot 46115504ec Implement the setns syscall
This change introduces the nsfs file system. Each new namespace allocates
a new nsfs inode.

Here are reasons why we need these inodes:
* each namespace has to have an unique id.
* proc/pid/ns/ contains one entry for each namespace. Bind mounting one of
  the files in this directory to somewhere else in the filesystem keeps the
  corresponding namespace alive even if all processes currently in
  the namespace terminate.
* setns() allows the calling process to join an existing namespace specified
  by a file descriptor.

PiperOrigin-RevId: 550694515
2023-07-24 15:45:08 -07:00
Andrew Dunham 057e0b7eae pkg/tcpip/transport/tcp: add statistics for dropped connections
When the TCP forwarder ignores a connection due to having too many
in-flight connections, it's not easy to log a message or update a metric
for later debugging. Add a metric that will be incremented in this case
so that the user of the Forwarder can observe this.

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
2023-07-17 15:07:55 -04:00
Kevin KrakauerandgVisor bot 64268c8483 netstack: make tcpip.Address an opaque type
The important change here is in tcpip/tcpip.go, where tcpip.Address is defined.
The rest is updating uses of tcpip.Address.

This is preparation for netip.Addr or []byte based addresses, which should save
us a bunch of allocations. Currently, we allocate every time we want to, say,
get a tcpip.Address from a header. This is because the header is a byte slice,
but Address is a string. Strings are immutable, so Go allocates and copies.

PiperOrigin-RevId: 532284732
2023-05-15 18:07:03 -07:00
Etienne PerotandgVisor bot a938259779 gVisor metric library: Change interface for passing in field values.
This introduces a `metric.FieldValue` struct type that wraps a string.
All metric interfaces that deal with field values have been updated to use
pointers to this type instead of strings.

The intent of this change is to make it more obvious that field values must
be passed using references. Prior to this change, this was done using string
pointer comparisons. Now this must be done by using a pointer to the same
`metric.FieldValue` struct.

The struct type still externally exposes its string so that it can be referred
to in value function callbacks by "custom" metrics. (Though there are no
current uses of callback metrics with fields.)

PiperOrigin-RevId: 527030738
2023-04-25 11:49:02 -07:00
Kevin KrakauerandgVisor bot 8478fe0a27 stop using tcpip.FullAddress with unix sockets
It's unnecessarily overloading the type, which makes it hard to change the type
in netstack.

PiperOrigin-RevId: 526168235
2023-04-21 16:48:37 -07:00
Etienne PerotandgVisor bot f8b9824813 Update unimpl.EmitUnimplementedEvent interface to add the syscall number.
This catches up the interface to the `EmitUnimplementedEvent` method signature
on `kernel.Kernel`.

Also add build-time test to verify that `kernel.Kernel` implements this
interface, in order to catch such breakages at build time in the future.

PiperOrigin-RevId: 519000411
2023-03-23 17:01:37 -07:00
Nicolas LacasseandgVisor bot c020e2de83 Move netstack's isTCP/UDP/ICMPSocket methods into socket package.
They are useful across other socket implementations.

PiperOrigin-RevId: 510699847
2023-02-18 13:27:45 -08:00
Andrei VaginandgVisor bot e08f204299 inet: each socket has to hold a reference to its network namespace
Otherwise a network namespace can be destroyed before sockets.

Reported-by: syzbot+78dcf6a117cd41dcb84e@syzkaller.appspotmail.com
PiperOrigin-RevId: 503552997
2023-01-20 17:10:58 -08:00
Ayush RanjanandgVisor bot 1fa3c06f1e Delete VFS1 completely.
- Delete pkg/sentry/fs/*.
- Move pkg/sentry/fs/fsutil out of VFS1 directory and remove VFS1 components.
- Remove remaining unused references to VFS1 from remaining codebase.
- Rename/refactor code to avoid even referencing VFS2, unless necessary.
- Rewrite VFS1-only tests to VFS2.

Updates #1624

PiperOrigin-RevId: 490064269
2022-11-21 13:57:52 -08:00
Alex KonradiandgVisor bot 5c9476aa87 Add counters for dropped neighbor advertisements
Add counters for when neighbor advertisements are ignored, either because they
don't correspond to a known neighbor cache entry or because they contain an
unexpected source address.

Fixes #8053

PiperOrigin-RevId: 479428582
2022-10-06 15:36:32 -07:00
Nicolas LacasseandgVisor bot 4761bf4537 Stop emitting unimplemented events from get/setsockopt.
These are of dubious value, and can often flood user's console with errors.

Fixes #8011

PiperOrigin-RevId: 478537513
2022-10-03 10:18:41 -07:00