diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-01-22 10:27:54 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-03-17 19:32:49 +0100 |
commit | f10dc5ab203ecf9e56f6e69be284855ef0793fad (patch) | |
tree | bfa7e32934dfcd0f34657e81ec801b122a662698 /pkg/tcpip/stack | |
parent | cb87cbb7e46568c0bab786205369d11a7fc5b268 (diff) |
Update the TTL field in forwarded packets
Closes: #1085
Diffstat (limited to 'pkg/tcpip/stack')
-rw-r--r-- | pkg/tcpip/stack/nic.go | 5 | ||||
-rw-r--r-- | pkg/tcpip/stack/registration.go | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/pkg/tcpip/stack/nic.go b/pkg/tcpip/stack/nic.go index 9dcb1d52c..af211f953 100644 --- a/pkg/tcpip/stack/nic.go +++ b/pkg/tcpip/stack/nic.go @@ -1261,6 +1261,11 @@ func (n *NIC) DeliverNetworkPacket(linkEP LinkEndpoint, remote, local tcpip.Link return } + if err := r.ref.ep.UpdateTTL(pkt, 1); err != nil { + fmt.Println("Drop") + return + } + // n doesn't have a destination endpoint. // Send the packet out of n. // TODO(b/128629022): move this logic to route.WritePacket. diff --git a/pkg/tcpip/stack/registration.go b/pkg/tcpip/stack/registration.go index fa28b46b1..1231dee63 100644 --- a/pkg/tcpip/stack/registration.go +++ b/pkg/tcpip/stack/registration.go @@ -267,6 +267,8 @@ type NetworkEndpoint interface { // HandlePacket takes ownership of pkt. HandlePacket(r *Route, pkt tcpip.PacketBuffer) + UpdateTTL(pkt tcpip.PacketBuffer, n uint8) *tcpip.Error + // Close is called when the endpoint is reomved from a stack. Close() } |