41 Commits
Author SHA1 Message Date
Jeff MartinandgVisor bot 966dfe5505 Avoid panic when forwarding races with endpoint shutdown
Catch tcpip.ErrClosedForSend errors while forwarding. This may occur if
an endpoint is being shutdown at the same time as it's being used to
forward a packet.

PiperOrigin-RevId: 695452542
2024-11-11 12:58:45 -08:00
Jing Chen a093ad0450 Simplify and format gVisor codebase.
The changes are just output of `gofmt -s -w .`.
2024-10-13 00:50:32 -07:00
Nayana BidariandgVisor bot 90266aa28a Netstack S/R: Mark all the structs in netstack as savable.
Marks the structs in netstack as savable. This does not change or break any
existing behavior as the netstack itself is not savable yet.

PiperOrigin-RevId: 635943481
2024-05-21 15:19:07 -07:00
dongjinlong ba02461e12 chore: remove repetitive words in comments
Signed-off-by: dongjinlong <dongjinlong@outlook.com>
2024-03-26 19:57:40 +08:00
Tony GongandgVisor bot 3517ac4c0b Cancel multicast delayed report job on Disable
Cancel the delayed report job when operating in V2 mode (this already
happens in V1 mode) in MakeAllNonMemberLocked, which is called on
endpoint Disable. This prevents a panic inside the delayed report
job where it asserts that the protocol is enabled.

PiperOrigin-RevId: 588113303
2023-12-05 10:21:31 -08:00
Andrei Vagin 5f4abad306 Fix a few typos
It is an idea of running codespell as part of our presubmit checks.
Before enabling it for new changes, let's fix what it has found.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2023-10-25 12:13:42 -07: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
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Ghanan GowripalanandgVisor bot 52985127a0 Don't route packets w/ unspecified source address
PiperOrigin-RevId: 509914627
2023-02-15 13:26:40 -08:00
Ghanan GowripalanandgVisor bot 89cc675c29 Don't transition from V1 -> V2 unless requested
Leave the generic multicast protocol in V1 mode even when transitioning
all groups to non-member state (when interface is disabled).

Updates #8346

PiperOrigin-RevId: 508448263
2023-02-09 12:43:14 -08:00
Ghanan GowripalanandgVisor bot a5ac059e27 Return current IGMP/MLD version
Updates #8346

PiperOrigin-RevId: 508218820
2023-02-08 16:48:42 -08:00
Ghanan GowripalanandgVisor bot c3ff31ef8c Allow setting MLD version
Updates #8346

PiperOrigin-RevId: 507851551
2023-02-07 12:19:01 -08:00
Ghanan GowripalanandgVisor bot be5314c5a6 Allow forcing multicast group protocol mode
Updates #8346

PiperOrigin-RevId: 507832493
2023-02-07 11:08:42 -08:00
Ghanan GowripalanandgVisor bot a8900d549b Coalesce records for reports on MGP enable
This change sends multiple records into a single IGMPv3/MLDv2 report
instead of a single record per report when enabling IGMPv3/MLDv2.

Updates #8346

PiperOrigin-RevId: 501941751
2023-01-13 14:39:06 -08:00
Ghanan GowripalanandgVisor bot c76b03723e Coalesce records sent by the state changed timer
When the state changed timer fires, instead of sending a single record
per report, send as many records as possible per report message.

Updates #8346

PiperOrigin-RevId: 501932735
2023-01-13 14:00:29 -08:00
Ghanan GowripalanandgVisor bot 4560252d16 Coalesce records for reports on MGP disable
This change sends multiple records into a single IGMPv3/MLDv2 report
instead of a single record per report when disabling IGMPv3/MLDv2.

Updates #8346

PiperOrigin-RevId: 501419672
2023-01-11 17:25:18 -08:00
Ghanan GowripalanandgVisor bot 4632d45dd8 Perform MLDv2/IGMPv3 without SSM
This change introduces support for MLDv2/IGMPv3. Note that this change
does not yet introduce APIs to perform source filtering so SSM is not
yet supported. Also note that this change does not yet coalesce records
in a report as that will come in a follow-up.

Updates #8346

PiperOrigin-RevId: 501336347
2023-01-11 11:39:25 -08:00
Ghanan GowripalanandgVisor bot 8ebc4d767a Accept no buffer space errors when forwarding
The outgoing device queue may be full when forwarding packets and those
errors should not result in a panic.

PiperOrigin-RevId: 499946528
2023-01-05 11:16:56 -08:00
Ghanan GowripalanandgVisor bot a2ff07e535 Use struct to check mockMulticastGroupProtocol fields
Instead of passing each of the values as arguments to a function.
This prepares for a followup change which introduces a new field
to mockMulticastGroupProtocol that is unused in some places
(improving readability by not having to explicitly pass in a
function argument).

PiperOrigin-RevId: 495918528
2022-12-16 11:18:36 -08:00
Ghanan GowripalanandgVisor bot f68e7dbd32 Drop state labels in IGMP/MLD
This change removes the explicit `state`/`hostState` fields from the
generic multicast host state and instead uses other readily available
or other newly introduced fields that more explicitly describe what
actions are pending for a host's group membership.

1) `delayedReportJobFiresAt` already lets us know if we are in the
   "delaying" member state/have a timer scheduled.
2) `transmissionLeft` lets us know if we have pending reports to send.

This prepares us to use the same state machine to support both
MLDv1/IGMPv2 and MLDv2/IGMPv3. Note that MLDv2/IGMPv3 do not use the
same "state machine" as MLDv1/IGMPv2. Specifically, states like
"Non-Listener/Member", "Delaying Listener/Member" and
"Idle Listener/Member" do not exist in MLDv2/IGMPv3.

PiperOrigin-RevId: 495386469
2022-12-14 12:33:22 -08:00
Bruno Dal BoandgVisor bot c40f8e3651 Rename ErrNoRoute to ErrHostUnreachable
ErrNoRoute gets translated to EHOSTUNREACH which causes some code paths to
produce different errors unexpectedly. Rename the error so we can clean up some
sites to return ENETUNREACH more clearly where needed.

Updates #8105

PiperOrigin-RevId: 482355099
2022-10-19 18:29:13 -07:00
Nate HurleyandgVisor bot 006bbe78ca Implement IPv4 multicast forwarding.
This change implements AddMulticastRoute and the requisite routing logic.
Subsequent changes will still be needed to:

1. Emit events for missing route or unexpected input interface
2. Implement DelRoute
3. Implement GetRouteStats

Updates #7338.

PiperOrigin-RevId: 451026594
2022-05-25 15:18:13 -07:00
Ayush RanjanandgVisor bot f6ed4523dc Reformat codebase.
PiperOrigin-RevId: 449358041
2022-05-17 17:48:35 -07:00
Adin ScannellandgVisor bot 16b751b6c6 Mix checklocks and atomic analyzers.
This change makes the checklocks analyzer considerable more powerful, adding:
* The ability to traverse complex structures, e.g. to have multiple nested
  fields as part of the annotation.
* The ability to resolve simple anonymous functions and closures, and perform
  lock analysis across these invocations. This does not apply to closures that
  are passed elsewhere, since it is not possible to know the context in which
  they might be invoked.
* The ability to annotate return values in addition to receivers and other
  parameters, with the same complex structures noted above.
* Ignoring locking semantics for "fresh" objects, i.e. objects that are
  allocated in the local frame (typically a new-style function).
* Sanity checking of locking state across block transitions and returns, to
  ensure that no unexpected locks are held.

Note that initially, most of these findings are excluded by a comprehensive
nogo.yaml. The findings that are included are fundamental lock violations.
The changes here should be relatively low risk, minor refactorings to either
include necessary annotations to simplify the code structure (in general
removing closures in favor of methods) so that the analyzer can be easily
track the lock state.

This change additional includes two changes to nogo itself:
* Sanity checking of all types to ensure that the binary and ast-derived
  types have a consistent objectpath, to prevent the bug above from occurring
  silently (and causing much confusion). This also requires a trick in
  order to ensure that serialized facts are consumable downstream. This can
  be removed with https://go-review.googlesource.com/c/tools/+/331789 merged.
* A minor refactoring to isolation the objdump settings in its own package.
  This was originally used to implement the sanity check above, but this
  information is now being passed another way. The minor refactor is preserved
  however, since it cleans up the code slightly and is minimal risk.

PiperOrigin-RevId: 382613300
2021-07-01 15:07:56 -07:00
Tamir DubersteinandgVisor bot 4f2439fb0e Use opaque types to represent time
Introduce tcpip.MonotonicTime; replace int64 in tcpip.Clock method
returns with time.Time and MonotonicTime to improve type safety and
ensure that monotonic clock readings are never compared to wall clock
readings.

PiperOrigin-RevId: 375775907
2021-05-25 13:00:29 -07:00