287 Commits
Author SHA1 Message Date
Jing ChenandgVisor bot 6dd4ef415b Implement IFLA_MTU which changes a link's MTU.
PiperOrigin-RevId: 648618069
2024-07-02 00:36:40 -07:00
Jing ChenandgVisor bot 59adcc9b1e Implement IFLA_IFNAME which specifies an interface's name.
IFLA_IFNAME is used to set an interface's name when being used
with RTM_NEWLINK and RTM_SETLINK. RTM_NEWLINK is the preferred way, it
is backwards compatible with RTM_SETLINK. For gVisor, when RTM_SETLINK is
introduced, it shall just share the implementation.

PiperOrigin-RevId: 647833657
2024-06-28 17:02:31 -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
Andrei VaginandgVisor bot 89ae593e2a netstack/veth: use a correct stack to call setLink for a peer device
PiperOrigin-RevId: 647074848
2024-06-26 14:17:49 -07:00
Ayush RanjanandgVisor bot 344f19745f Delete pkg/tcpip/stack.UniqueID.
There are 2 interfaces in gVisor which are exactly the same:
- pkg/tcpip/stack.UniqueID
- pkg/sentry/uniqueid.Provider

Before this change, both were using the Kernel as the unique number generator.
However, we want to decouple the netstack from the kernel. This coupling is
causing bugs in restore because netstack needs to be created before the Kernel
is restored. So right now, netstack ends up using a "temporary" Kernel which is
later destroyed in the restore sequence, but netstack keeps referencing it.

Before this change, the unique ID generator in pkg/tcpip/stack.Stack was used
for 2 things:
1. Provide NIC IDs which are unique across all network namespaces.
2. Implement stack.TransportEndpoint.UniqueID.

(2) is not used anywhere, so deleted it. (1) is overly unique. NIC IDs do not
need to be unique across network namespace. So instead of holding a pointer to
the kernel, added a NIC ID generator in stack.Stack itself and added
NextNICID() function with proper typing.

PiperOrigin-RevId: 646997006
2024-06-26 10:34:48 -07:00
Jing ChenandgVisor bot cd3efc6519 Support IFLA_ADDRESS which changes a device's hardware address.
PiperOrigin-RevId: 645611089
2024-06-21 23:56:13 -07:00
Andrei VaginandgVisor bot 646a033213 tcpip: destroy both ends of one veth pair together
PiperOrigin-RevId: 645562424
2024-06-21 18:50:54 -07:00
Andrei VaginandgVisor bot 0d20b827d2 netstack: implement bridge devices
Implement the core part. All packets are broadcast-ed to all ports. The next
step will be to implement forwarding and multicast group databases.

PiperOrigin-RevId: 644471256
2024-06-18 12:15: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
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
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
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
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
Ayush RanjanandgVisor bot 7e395bbbd4 Plumb restore context to load*() methods.
This allows for external information to be passed to restore code.
Similar to c087777e37 ("Plumb restore context to afterLoad()").

Updates #1956.

PiperOrigin-RevId: 614125262
2024-03-08 20:28:02 -08: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
Fabricio VoznikaandgVisor bot 1676e8a877 Add restore context to netstack
PiperOrigin-RevId: 613295366
2024-03-06 12:04:24 -08:00
Fabricio VoznikaandgVisor bot c087777e37 Plumb restore context to afterLoad()
This allows for external information to be passed to restore code, like
host FDs to be remapped.

Updates #1956

PiperOrigin-RevId: 612540749
2024-03-04 12:21:50 -08:00
Kevin Krakauer c351246ce8 netstack: log upon attempted raw socket creation when --net-raw is missing
Helpful when debugging issues like #9917.
2024-01-30 10:34:58 -08: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