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
This commit is contained in:
Tamir Duberstein
2018-10-31 08:04:57 -07:00
committed by Shentubot
parent 0091db9cbd
commit 0692ad72ef
+5 -13
View File
@@ -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