Commit Graph

802 Commits

Author SHA1 Message Date
gVisor bot 9662600f3f Merge release-20210315.0-21-gec0aa657e (automated) 2021-03-24 16:44:16 +00:00
Nick Brown ec0aa657ed Unexpose immutable fields in stack.Route
This change sets the inner `routeInfo` struct to be a named private member
and replaces direct access with access through getters. Note that direct
access to the fields of `routeInfo` is still possible through the `RouteInfo`
struct.

Fixes #4902

PiperOrigin-RevId: 364822872
2021-03-24 09:38:27 -07:00
gVisor bot e48ad2ada0 Merge release-20210315.0-15-gacb4c6288 (automated) 2021-03-23 19:03:20 +00:00
gVisor bot 16def91ab4 Merge release-20210315.0-7-ga073d7697 (automated) 2021-03-22 19:36:16 +00:00
Ghanan Gowripalan a073d76979 Return tcpip.Error from (*Stack).GetMainNICAddress
PiperOrigin-RevId: 364381970
2021-03-22 12:31:46 -07:00
Ghanan Gowripalan d3a433caae Do not use martian loopback packets in tests
Transport demuxer and UDP tests should not use a loopback address as the
source address for packets injected into the stack as martian loopback
packets will be dropped in a later change.

PiperOrigin-RevId: 363479681
2021-03-17 12:29:08 -07:00
gVisor bot fc371b3b4d Merge release-20210309.0-32-g68065d1ce (automated) 2021-03-16 18:14:32 +00:00
Ghanan Gowripalan 68065d1ceb Detect looped-back NDP DAD messages
...as per RFC 7527.

If a looped-back DAD message is received, do not fail DAD since our own
DAD message does not indicate that a neighbor has the address assigned.

Test: ndp_test.TestDADResolveLoopback
PiperOrigin-RevId: 363224288
2021-03-16 11:09:26 -07:00
gVisor bot 8663fa59e7 Merge release-20210309.0-31-gebd7c1b88 (automated) 2021-03-16 17:34:27 +00:00
Ghanan Gowripalan ebd7c1b889 Do not call into Stack from LinkAddressRequest
Calling into the stack from LinkAddressRequest is not needed as we
already have a reference to the network endpoint (IPv6) or network
interface (IPv4/ARP).

PiperOrigin-RevId: 363213973
2021-03-16 10:29:49 -07:00
gVisor bot 32e04bc1d7 Merge release-20210301.0-44-g82d7fb2cb (automated) 2021-03-12 05:10:20 +00:00
Kevin Krakauer 82d7fb2cb0 improve readability of ports package
Lots of small changes:
- simplify package API via Reservation type
- rename some single-letter variable names that were hard to follow
- rename some types

PiperOrigin-RevId: 362442366
2021-03-11 21:05:32 -08:00
gVisor bot 8aebd0c66a Merge release-20210301.0-29-gabbdcebc5 (automated) 2021-03-09 04:45:46 +00:00
Kevin Krakauer abbdcebc54 Implement /proc/sys/net/ipv4/ip_local_port_range
Speeds up the socket stress tests by a couple orders of magnitude.

PiperOrigin-RevId: 361721050
2021-03-08 20:40:34 -08:00
gVisor bot c72f163bca Merge release-20210301.0-18-g498709250 (automated) 2021-03-05 21:36:50 +00:00
Ghanan Gowripalan 498709250a Include duplicate address holder info in DADResult
The integrator may be interested in who owns a duplicate address so
pass this information (if available) along.

Fixes #5605.

PiperOrigin-RevId: 361213556
2021-03-05 13:32:05 -08:00
gVisor bot 3d2ce29b9e Merge release-20210301.0-15-g3e8e2cad8 (automated) 2021-03-05 20:00:16 +00:00
Ghanan Gowripalan 3e8e2cad88 Make stack.DADResult an interface
While I'm here, update NDPDispatcher.OnDuplicateAddressDetectionStatus to
take a DADResult and rename it to OnDuplicateAddressDetectionResult.

Fixes #5606.

PiperOrigin-RevId: 360965416
2021-03-05 11:54:58 -08:00
gVisor bot 441d4acfe5 Merge release-20210301.0-12-g1cd76d958 (automated) 2021-03-04 00:10:22 +00:00
Ting-Yu Wang 1cd76d958a Make dedicated methods for data operations in PacketBuffer
One of the preparation to decouple underlying buffer implementation.
There are still some methods that tie to VectorisedView, and they will be
changed gradually in later CLs.

This CL also introduce a new ICMPv6ChecksumParams to replace long list of
parameters when calling ICMPv6Checksum, aiming to be more descriptive.

PiperOrigin-RevId: 360778149
2021-03-03 16:05:16 -08:00
Sam Balana 011ba4d4fe Assert UpdatedAtNanos in neighbor cache tests
Changes the neighbor_cache_test.go tests to always assert UpdatedAtNanos.

Completes the assertion of UpdatedAtNanos in every NUD test, a field that was
historically not checked due to the lack of a deterministic, controllable
clock. This is no longer true with the tcpip.Clock interface. While the tests
have been adjusted to use Clock, asserting by the UpdatedAtNanos was neglected.

Fixes #4663

PiperOrigin-RevId: 360730077
2021-03-03 12:26:30 -08:00
gVisor bot 2083ef0f25 Merge release-20210208.0-107-g6bc27946a (automated) 2021-03-02 20:03:00 +00:00
Tamir Duberstein 6bc27946a6 Plumb link address request errors up to requester
Prevent the situation where callers to (*stack).GetLinkAddress provide
incorrect arguments and are unable to observe this condition.

Updates #5583.

PiperOrigin-RevId: 360481557
2021-03-02 11:58:12 -08:00
Sam Balana af6e6d5e7f Assert UpdatedAtNanos in neighbor entry tests
Changes the neighbor_entry_test.go tests to always assert UpdatedAtNanos.

This field was historically not checked due to the lack of a deterministic,
controllable clock. This is no longer true with the tcpip.Clock interface.
While the tests have been adjusted to use Clock, asserting by the
UpdatedAtNanos was neglected.

Subsequent work is needed to assert UpdatedAtNanos in the neighbor cache tests.

Updates #4663

PiperOrigin-RevId: 359868254
2021-02-26 17:09:55 -08:00
Sam Balana 85d5958669 Embed sync.Mutex for entryTestLinkResolver and testNUDDispatcher
Converts entryTestLinkResolver and testNUDDispatcher to use the embedded
sync.Mutex pattern for fields that may be accessed concurrently from different
gorountines.

Fixes #5541

PiperOrigin-RevId: 359826169
2021-02-26 13:27:49 -08:00
Sam Balana 35a71a24f2 Use helper functions in neighbor entry tests
Adds helper functions for transitioning into common states. This reduces the
boilerplate by a fair amount, decreasing the barriers to entry for new features
added to neighborEntry.

PiperOrigin-RevId: 359810465
2021-02-26 12:11:44 -08:00
gVisor bot 796fd943e2 Merge release-20210208.0-101-gda2505df9 (automated) 2021-02-26 19:23:18 +00:00
Tamir Duberstein da2505df94 Use closure to avoid manual unlocking
Also increase refcount of raw.endpoint.route while in use.

Avoid allocating an array of size zero.

PiperOrigin-RevId: 359797788
2021-02-26 11:18:30 -08:00
gVisor bot c35f73b493 Merge release-20210208.0-97-g38c42bbf4 (automated) 2021-02-25 21:40:11 +00:00
Kevin Krakauer 38c42bbf4a Remove deadlock in raw.endpoint caused by recursive read locking
Prevents the following deadlock:
- Raw packet is sent via e.Write(), which read locks e.mu
- Connect() is called, blocking on write locking e.mu
- The packet is routed to loopback and back to e.HandlePacket(), which read
  locks e.mu

Per the atomic.RWMutex documentation, this deadlocks:

"If a goroutine holds a RWMutex for reading and another goroutine might call
Lock, no goroutine should expect to be able to acquire a read lock until the
initial read lock is released. In particular, this prohibits recursive read
locking. This is to ensure that the lock eventually becomes available; a blocked
Lock call excludes new readers from acquiring the lock."

Also, release eps.mu earlier in deliverRawPacket.

PiperOrigin-RevId: 359600926
2021-02-25 13:35:44 -08:00
Ghanan Gowripalan fcd4ff4fca Cleanup temp SLAAC address jobs on DAD conflicts
Previously, when DAD would detect a conflict for a temporary address,
the address would be removed but its timers would not be stopped,
resulting in a panic when the removed address's invalidation timer
fired.

While I'm here, remove the check for unicast-ness on removed address
endpoints since multicast addresses are no longer stored in the same
structure as unicast addresses as of 27ee4fe76a.

Test: stack_test.TestMixedSLAACAddrConflictRegen
PiperOrigin-RevId: 359344849
2021-02-24 12:32:20 -08:00
gVisor bot 328bba2faa Merge release-20210208.0-69-gbb5db8044 (automated) 2021-02-18 19:45:53 +00:00
Sam Balana bb5db80448 Remove deprecated NUD types Failed and FailedEntryLookups
Completes the soft migration to Unreachable state by removing the Failed state
and the the FailedEntryLookups StatCounter.

Fixes #4667

PiperOrigin-RevId: 358226380
2021-02-18 11:40:52 -08:00
gVisor bot 7b56be1ab4 Merge release-20210208.0-65-g1fc2c5f75 (automated) 2021-02-18 02:29:27 +00:00
Kevin Krakauer 1fc2c5f750 Move Name() out of netstack Matcher. It can live in the sentry.
PiperOrigin-RevId: 358078157
2021-02-17 18:24:34 -08:00
gVisor bot 7976b340af Merge release-20210201.0-66-gd0c0549e6 (automated) 2021-02-09 19:52:01 +00:00
Sam Balana d0c0549e60 Deprecate Failed state in favor of Unreachable state
... as per RFC 7048. The Failed state is an internal state that is not
specified by any RFC; replacing it with the Unreachable state enables us to
expose this state while keeping our terminology consistent with RFC 4861 and
RFC 7048.

Unreachable state replaces all internal references for Failed state. However
unlike the Failed state, change events are dispatched when moving into
Unreachable state. This gives developers insight into whether a neighbor entry
failed address resolution or whether it was explicitly removed.

The Failed state will be removed entirely once all references to it are
removed. This is done to avoid a Fuchsia roll failure.

Updates #4667

PiperOrigin-RevId: 356554104
2021-02-09 11:47:06 -08:00
gVisor bot b98fa348b6 Merge release-20210201.0-61-g6671a42d6 (automated) 2021-02-09 05:46:00 +00:00
Ghanan Gowripalan 6671a42d60 Remove unnecessary locking
The thing the lock protects will never be accessed concurrently.

PiperOrigin-RevId: 356423331
2021-02-08 21:41:17 -08:00
gVisor bot 5741b2ffd9 Merge release-20210201.0-58-g39251f31c (automated) 2021-02-09 03:10:57 +00:00
Ghanan Gowripalan 39251f31cb Support performing DAD for any address
...as long as the network protocol supports duplicate address detection.

This CL provides the facilities for a netstack integrator to perform
DAD.

DHCP recommends that clients effectively perform DAD before accepting an
offer. As per RFC 2131 section 4.4.1 pg 38,

  The client SHOULD perform a check on the suggested address to ensure
  that the address is not already in use.  For example, if the client
  is on a network that supports ARP, the client may issue an ARP request
  for the suggested request.

The implementation of ARP-based IPv4 DAD effectively operates the same
as IPv6's NDP DAD - using ARP requests and responses in place of
NDP neighbour solicitations and advertisements, respectively.

DAD performed by calls to (*Stack).CheckDuplicateAddress don't interfere
with DAD performed when a new IPv6 address is added. This is so that
integrator requests to check for duplicate addresses aren't unexpectedly
aborted when addresses are removed.

A network package internal package provides protocol agnostic DAD state
management that specific protocols that provide DAD can use.

Fixes #4550.

Tests:
  - internal/ip_test.*
  - integration_test.TestDAD
  - arp_test.TestDADARPRequestPacket
  - ipv6.TestCheckDuplicateAddress
PiperOrigin-RevId: 356405593
2021-02-08 19:05:45 -08:00
gVisor bot 21036aed5e Merge release-20210125.0-98-g3853a94f1 (automated) 2021-02-07 05:42:08 +00:00
Ghanan Gowripalan 3853a94f10 Remove linkAddrCache
It was replaced by NUD/neighborCache.

Fixes #4658.

PiperOrigin-RevId: 356085221
2021-02-06 21:37:15 -08:00
gVisor bot 4f3d6f2aa9 Merge release-20210125.0-95-gc5afaf285 (automated) 2021-02-06 21:30:25 +00:00
Ghanan Gowripalan c5afaf2854 Remove (*stack.Stack).FindNetworkEndpoint
The network endpoints only look for other network endpoints of the
same kind. Since the network protocols keeps track of all endpoints,
go through the protocol to find an endpoint with an address instead
of the stack.

PiperOrigin-RevId: 356051498
2021-02-06 13:25:28 -08:00
gVisor bot e4266e460e Merge release-20210125.0-94-g494334713 (automated) 2021-02-06 20:48:58 +00:00
Ghanan Gowripalan 4943347137 Use fine grained locks while sending NUD probes
Previously when sending probe messages, we would hold a shared lock
which lead to deadlocks (due to synchronous packet loooping (e.g. pipe
and loopback link endpoints)) and lock contention.

Writing packets may be an expensive operation which could prevent other
goroutines from doing meaningful work if a shared lock is held while
writing packets.

This change upates the NUD timers to not hold shared locks while
sending packets.

PiperOrigin-RevId: 356048697
2021-02-06 12:44:15 -08:00
gVisor bot 3bb7df3f6b Merge release-20210125.0-93-ga83c8585a (automated) 2021-02-06 18:52:41 +00:00
Ghanan Gowripalan a83c8585af Use embedded mutex pattern in neighbor cache/entry
Also while I'm here, update neighbor cahce/entry tests to use the
stack's RNG instead of creating a neigbor cache/entry specific one.

PiperOrigin-RevId: 356040581
2021-02-06 10:47:28 -08:00
gVisor bot 89218937bf Merge release-20210125.0-92-g9530f624e (automated) 2021-02-06 17:54:29 +00:00