diff options
author | Tamir Duberstein <tamird@google.com> | 2018-10-31 08:04:05 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-10-31 08:04:57 -0700 |
commit | 0692ad72ef826c4b8cf0f74c5dbf8d1c3083d299 (patch) | |
tree | 20da5ed9e97bc58e67e8a6b69ebff3a660887e22 /pkg/tcpip/network | |
parent | 0091db9cbddb6c9fb4c96fbde980780c98006eda (diff) |
Remove ipv4.endpoint.address
This field was added in the intial implementation, before Route existed
to pass the local and remote addresses to the packet-writing path.
Today, the Route's members should be respected. A similar bug was
previously fixed in 214650822.
PiperOrigin-RevId: 219474095
Change-Id: Id2a8ee4421d2841c8d88ccb3c193c455086350ee
Diffstat (limited to 'pkg/tcpip/network')
-rw-r--r-- | pkg/tcpip/network/ipv4/ipv4.go | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/pkg/tcpip/network/ipv4/ipv4.go b/pkg/tcpip/network/ipv4/ipv4.go index d7801ec19..c0d334b56 100644 --- a/pkg/tcpip/network/ipv4/ipv4.go +++ b/pkg/tcpip/network/ipv4/ipv4.go @@ -46,32 +46,29 @@ const ( buckets = 2048 ) -type address [header.IPv4AddressSize]byte - type endpoint struct { nicid tcpip.NICID id stack.NetworkEndpointID - address address linkEP stack.LinkEndpoint dispatcher stack.TransportDispatcher echoRequests chan echoRequest fragmentation *fragmentation.Fragmentation } -func newEndpoint(nicid tcpip.NICID, addr tcpip.Address, dispatcher stack.TransportDispatcher, linkEP stack.LinkEndpoint) *endpoint { +// NewEndpoint creates a new ipv4 endpoint. +func (p *protocol) NewEndpoint(nicid tcpip.NICID, addr tcpip.Address, linkAddrCache stack.LinkAddressCache, dispatcher stack.TransportDispatcher, linkEP stack.LinkEndpoint) (stack.NetworkEndpoint, *tcpip.Error) { e := &endpoint{ nicid: nicid, + id: stack.NetworkEndpointID{LocalAddress: addr}, linkEP: linkEP, dispatcher: dispatcher, echoRequests: make(chan echoRequest, 10), fragmentation: fragmentation.NewFragmentation(fragmentation.HighFragThreshold, fragmentation.LowFragThreshold, fragmentation.DefaultReassembleTimeout), } - copy(e.address[:], addr) - e.id = stack.NetworkEndpointID{LocalAddress: tcpip.Address(e.address[:])} go e.echoReplier() - return e + return e, nil } // DefaultTTL is the default time-to-live value for this endpoint. @@ -122,7 +119,7 @@ func (e *endpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload b ID: uint16(id), TTL: ttl, Protocol: uint8(protocol), - SrcAddr: tcpip.Address(e.address[:]), + SrcAddr: r.LocalAddress, DstAddr: r.RemoteAddress, }) ip.SetChecksum(^ip.CalculateChecksum()) @@ -194,11 +191,6 @@ func (*protocol) ParseAddresses(v buffer.View) (src, dst tcpip.Address) { return h.SourceAddress(), h.DestinationAddress() } -// NewEndpoint creates a new ipv4 endpoint. -func (p *protocol) NewEndpoint(nicid tcpip.NICID, addr tcpip.Address, linkAddrCache stack.LinkAddressCache, dispatcher stack.TransportDispatcher, linkEP stack.LinkEndpoint) (stack.NetworkEndpoint, *tcpip.Error) { - return newEndpoint(nicid, addr, dispatcher, linkEP), nil -} - // SetOption implements NetworkProtocol.SetOption. func (p *protocol) SetOption(option interface{}) *tcpip.Error { return tcpip.ErrUnknownProtocolOption |