summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-10-07 22:36:48 +0000
committergVisor bot <gvisor-bot@google.com>2021-10-07 22:36:48 +0000
commite17919f623c6b58ae0f01033e5939df042012d46 (patch)
tree8f964bcc07a9a646e6e2713b7c8b71dfc75ef00c /pkg/tcpip
parentf00d0c19e5ee676f732a89020209cadfd3448768 (diff)
parent3517d070cc3128ad3439e10b8abb42b7df60c2b2 (diff)
Merge release-20210927.0-46-g3517d070c (automated)
Diffstat (limited to 'pkg/tcpip')
-rw-r--r--pkg/tcpip/stack/iptables_targets.go32
1 files changed, 4 insertions, 28 deletions
diff --git a/pkg/tcpip/stack/iptables_targets.go b/pkg/tcpip/stack/iptables_targets.go
index 8b74677d0..7e5a1672a 100644
--- a/pkg/tcpip/stack/iptables_targets.go
+++ b/pkg/tcpip/stack/iptables_targets.go
@@ -132,36 +132,12 @@ func (rt *RedirectTarget) Action(pkt *PacketBuffer, hook Hook, r *Route, address
panic("redirect target is supported only on output and prerouting hooks")
}
- switch protocol := pkt.TransportProtocolNumber; protocol {
- case header.UDPProtocolNumber:
- udpHeader := header.UDP(pkt.TransportHeader().View())
-
- if hook == Output {
- // Only calculate the checksum if offloading isn't supported.
- requiresChecksum := r.RequiresTXTransportChecksum()
- rewritePacket(
- pkt.Network(),
- udpHeader,
- false, /* updateSRCFields */
- requiresChecksum,
- requiresChecksum,
- rt.Port,
- address,
- )
- } else {
- udpHeader.SetDestinationPort(rt.Port)
- }
-
- pkt.NatDone = true
- case header.TCPProtocolNumber:
- if t := pkt.tuple; t != nil {
- t.conn.performNAT(pkt, hook, r, rt.Port, address, true /* dnat */)
- }
- default:
- return RuleDrop, 0
+ if t := pkt.tuple; t != nil {
+ t.conn.performNAT(pkt, hook, r, rt.Port, address, true /* dnat */)
+ return RuleAccept, 0
}
- return RuleAccept, 0
+ return RuleDrop, 0
}
// SNATTarget modifies the source port/IP in the outgoing packets.