Commit Graph

16 Commits

Author SHA1 Message Date
Tamir Duberstein 8d1afb4185 Change tcpip.Error to an interface
This makes it possible to add data to types that implement tcpip.Error.
ErrBadLinkEndpoint is removed as it is unused.

PiperOrigin-RevId: 354437314
2021-01-28 17:59:58 -08:00
Ghanan Gowripalan 0ca4cf7698 Populate EgressRoute, GSO, Netproto in NIC
fdbased and qdisc layers expect these fields to already be
populated before being reached.

PiperOrigin-RevId: 353099492
2021-01-21 14:10:37 -08:00
Ghanan Gowripalan fd5b52c87f Only pass stack.Route's fields to LinkEndpoints
stack.Route is used to send network packets and resolve link addresses.
A LinkEndpoint does not need to do either of these and only needs the
route's fields at the time of the packet write request.

Since LinkEndpoints only need the route's fields when writing packets,
pass a stack.RouteInfo instead.

PiperOrigin-RevId: 352108405
2021-01-15 16:49:15 -08:00
Ghanan Gowripalan 55c7fe48d2 Populate EgressRoute, GSO, Netproto for batch writes
We loop over the list of packets anyways so setting these aren't
expensive.

Now that they are populated only by the link endpoint that uses them,
TCP does not need to.

PiperOrigin-RevId: 352090853
2021-01-15 15:03:47 -08:00
Peter Johnston fee2cd640f Invoke address resolution upon subsequent traffic to Failed neighbor
Removes the period of time in which subseqeuent traffic to a Failed neighbor
immediately fails with ErrNoLinkAddress. A Failed neighbor is one in which
address resolution fails; or in other words, the neighbor's IP address cannot
be translated to a MAC address.

This means removing the Failed state for linkAddrCache and allowing transitiong
out of Failed into Incomplete for neighborCache. Previously, both caches would
transition entries to Failed after address resolution fails. In this state, any
subsequent traffic requested within an unreachable time would immediately fail
with ErrNoLinkAddress. This does not follow RFC 4861 section 7.3.3:

  If address resolution fails, the entry SHOULD be deleted, so that subsequent
  traffic to that neighbor invokes the next-hop determination procedure again.
  Invoking next-hop determination at this point ensures that alternate default
  routers are tried.

The API for getting a link address for a given address, whether through the link
address cache or the neighbor table, is updated to optionally take a callback
which will be called when address resolution completes. This allows `Route` to
handle completing link resolution internally, so callers of (*Route).Resolve
(e.g. endpoints) don’t have to keep track of when it completes and update the
Route accordingly.

This change also removes the wakers from LinkAddressCache, NeighborCache, and
Route in favor of the callbacks, and callers that previously used a waker can
now just pass a callback to (*Route).Resolve that will notify the waker on
resolution completion.

Fixes #4796

Startblock:
  has LGTM from sbalana
  and then
  add reviewer ghanan
PiperOrigin-RevId: 348597478
2020-12-22 01:37:05 -08:00
Ghanan Gowripalan 2485a4e2cb Make stack.Route safe to access concurrently
Multiple goroutines may use the same stack.Route concurrently so
the stack.Route should make sure that any functions called on it
are thread-safe.

Fixes #4073

PiperOrigin-RevId: 344320491
2020-11-25 14:52:59 -08:00
Bruno Dal Bo 9d148627f8 Introduce stack.WritePacketToRemote, remove LinkEndpoint.WriteRawPacket
Redefine stack.WritePacket into stack.WritePacketToRemote which lets the NIC
decide whether to append link headers.

PiperOrigin-RevId: 343071742
2020-11-18 07:05:59 -08:00
Adin Scannell c92242c89a Fix-up issue comment.
PiperOrigin-RevId: 326129258
2020-08-11 16:49:53 -07:00
Bhasker Hariharan 71bf90c55b Support for receiving outbound packets in AF_PACKET.
Updates #173

PiperOrigin-RevId: 322665518
2020-07-22 15:33:33 -07:00
Bhasker Hariharan fef90c61c6 Fix minor bugs in a couple of interface IOCTLs.
gVisor incorrectly returns the wrong ARP type for SIOGIFHWADDR. This breaks
tcpdump as it tries to interpret the packets incorrectly.

Similarly, SIOCETHTOOL is used by tcpdump to query interface properties which
fails with an EINVAL since we don't implement it. For now change it to return
EOPNOTSUPP to indicate that we don't support the query rather than return
EINVAL.

NOTE: ARPHRD types for link endpoints are distinct from NIC capabilities
and NIC flags. In Linux all 3 exist eg. ARPHRD types are stored in dev->type
field while NIC capabilities are more like the device features which can be
queried using SIOCETHTOOL but not modified and NIC Flags are fields that can
be modified from user space. eg. NIC status (UP/DOWN/MULTICAST/BROADCAST) etc.

Updates #2746

PiperOrigin-RevId: 321436525
2020-07-15 14:15:44 -07:00
Ting-Yu Wang d3a8bffe04 Pass PacketBuffer as pointer.
Historically we've been passing PacketBuffer by shallow copying through out
the stack. Right now, this is only correct as the caller would not use
PacketBuffer after passing into the next layer in netstack.

With new buffer management effort in gVisor/netstack, PacketBuffer will
own a Buffer (to be added). Internally, both PacketBuffer and Buffer may
have pointers and shallow copying shouldn't be used.

Updates #2404.

PiperOrigin-RevId: 314610879
2020-06-03 15:00:42 -07:00
Sam Balana 835e8c89a5 Remove linkEP from DeliverNetworkPacket
The specified LinkEndpoint is not being used in a significant way.
No behavior change, existing tests pass.

This change is a breaking change.

PiperOrigin-RevId: 313496602
2020-05-27 17:35:46 -07:00
Bhasker Hariharan e838e7ab34 Automated rollback of changelist 310417191
PiperOrigin-RevId: 310963404
2020-05-11 12:09:06 -07:00
Bhasker Hariharan 28b5565fdd Automated rollback of changelist 309339316
PiperOrigin-RevId: 310417191
2020-05-07 12:48:23 -07:00
Bhasker Hariharan 8962b7840f Enable FIFO QDisc by default in runsc.
Updates #231

PiperOrigin-RevId: 309339316
2020-04-30 18:29:57 -07:00
Bhasker Hariharan ae15d90436 FIFO QDisc implementation
Updates #231

PiperOrigin-RevId: 309323808
2020-04-30 16:41:00 -07:00