diff options
author | Andrew Yourtchenko <ayourtch@gmail.com> | 2019-11-05 17:34:08 +0000 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2019-11-07 20:08:36 +0000 |
commit | f073acdcaeeb7ad4b7916e839db8a7fbfefa87b2 (patch) | |
tree | 4bc32ac3cc3812b4afc6bdfa917178d3a2bb9120 /src/plugins/nat/in2out_ed.c | |
parent | 1c3c9f0393e4bd3a5902efbc79cb9a4e6737bda2 (diff) |
nat: Revert "nat: respect udp checksum"
This reverts commit 80276a7101f23ddd7207983f48f85422daf2cb7f.
The commit in master was found to be wrong, was reverted, and replaced by 16572355c9069e2e8e4836dc6bd6a65feed2d390
This reverts the corresponding commit in stable/1908, to replace with the correct fix.
Type: fix
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Change-Id: Idc27c0d81edf2263e523088f7ee7b66655db20f1
Diffstat (limited to 'src/plugins/nat/in2out_ed.c')
-rw-r--r-- | src/plugins/nat/in2out_ed.c | 120 |
1 files changed, 22 insertions, 98 deletions
diff --git a/src/plugins/nat/in2out_ed.c b/src/plugins/nat/in2out_ed.c index c878dddd13e..de00c6e7b13 100644 --- a/src/plugins/nat/in2out_ed.c +++ b/src/plugins/nat/in2out_ed.c @@ -1045,11 +1045,11 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm, dst_address); ip0->checksum = ip_csum_fold (sum0); - old_port0 = udp0->src_port; - new_port0 = udp0->src_port = s0->out2in.port; - if (PREDICT_TRUE (proto0 == SNAT_PROTOCOL_TCP)) { + old_port0 = tcp0->src_port; + new_port0 = tcp0->src_port = s0->out2in.port; + sum0 = tcp0->checksum; sum0 = ip_csum_update (sum0, old_addr0, new_addr0, ip4_header_t, dst_address); @@ -1073,29 +1073,10 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm, (sm, s0, tcp0, thread_index)) goto trace00; } - else if (udp0->checksum) - { - sum0 = udp0->checksum; - sum0 = ip_csum_update (sum0, old_addr0, new_addr0, ip4_header_t, - dst_address); - sum0 = ip_csum_update (sum0, old_port0, new_port0, ip4_header_t, - length); - if (PREDICT_FALSE (is_twice_nat_session (s0))) - { - sum0 = ip_csum_update (sum0, ip0->dst_address.as_u32, - s0->ext_host_addr.as_u32, - ip4_header_t, dst_address); - sum0 = ip_csum_update (sum0, tcp0->dst_port, - s0->ext_host_port, ip4_header_t, - length); - udp0->dst_port = s0->ext_host_port; - ip0->dst_address.as_u32 = s0->ext_host_addr.as_u32; - } - udp0->checksum = ip_csum_fold (sum0); - udp_packets++; - } else { + udp0->src_port = s0->out2in.port; + udp0->checksum = 0; if (PREDICT_FALSE (is_twice_nat_session (s0))) { udp0->dst_port = s0->ext_host_port; @@ -1274,11 +1255,11 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm, dst_address); ip1->checksum = ip_csum_fold (sum1); - old_port1 = udp1->src_port; - new_port1 = udp1->src_port = s1->out2in.port; - if (PREDICT_TRUE (proto1 == SNAT_PROTOCOL_TCP)) { + old_port1 = tcp1->src_port; + new_port1 = tcp1->src_port = s1->out2in.port; + sum1 = tcp1->checksum; sum1 = ip_csum_update (sum1, old_addr1, new_addr1, ip4_header_t, dst_address); @@ -1302,30 +1283,10 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm, (sm, s1, tcp1, thread_index)) goto trace01; } - else if (udp1->checksum) - { - sum1 = udp1->checksum; - sum1 = ip_csum_update (sum1, old_addr1, new_addr1, ip4_header_t, - dst_address); - sum1 = ip_csum_update (sum1, old_port1, new_port1, ip4_header_t, - length); - - if (PREDICT_FALSE (is_twice_nat_session (s1))) - { - sum1 = ip_csum_update (sum1, ip1->dst_address.as_u32, - s1->ext_host_addr.as_u32, - ip4_header_t, dst_address); - sum1 = ip_csum_update (sum1, tcp1->dst_port, - s1->ext_host_port, ip4_header_t, - length); - udp1->dst_port = s1->ext_host_port; - ip1->dst_address.as_u32 = s1->ext_host_addr.as_u32; - } - udp1->checksum = ip_csum_fold (sum1); - udp_packets++; - } else { + udp1->src_port = s1->out2in.port; + udp1->checksum = 0; if (PREDICT_FALSE (is_twice_nat_session (s1))) { udp1->dst_port = s1->ext_host_port; @@ -1532,11 +1493,11 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm, dst_address); ip0->checksum = ip_csum_fold (sum0); - old_port0 = udp0->src_port; - new_port0 = udp0->src_port = s0->out2in.port; - if (PREDICT_TRUE (proto0 == SNAT_PROTOCOL_TCP)) { + old_port0 = tcp0->src_port; + new_port0 = tcp0->src_port = s0->out2in.port; + sum0 = tcp0->checksum; sum0 = ip_csum_update (sum0, old_addr0, new_addr0, ip4_header_t, dst_address); @@ -1560,29 +1521,10 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm, (sm, s0, tcp0, thread_index)) goto trace0; } - else if (udp0->checksum) - { - sum0 = udp0->checksum; - sum0 = ip_csum_update (sum0, old_addr0, new_addr0, ip4_header_t, - dst_address); - sum0 = ip_csum_update (sum0, old_port0, new_port0, ip4_header_t, - length); - if (PREDICT_FALSE (is_twice_nat_session (s0))) - { - sum0 = ip_csum_update (sum0, ip0->dst_address.as_u32, - s0->ext_host_addr.as_u32, - ip4_header_t, dst_address); - sum0 = ip_csum_update (sum0, tcp0->dst_port, - s0->ext_host_port, ip4_header_t, - length); - udp0->dst_port = s0->ext_host_port; - ip0->dst_address.as_u32 = s0->ext_host_addr.as_u32; - } - udp0->checksum = ip_csum_fold (sum0); - udp_packets++; - } else { + udp0->src_port = s0->out2in.port; + udp0->checksum = 0; if (PREDICT_FALSE (is_twice_nat_session (s0))) { udp0->dst_port = s0->ext_host_port; @@ -1973,11 +1915,12 @@ nat44_ed_in2out_reass_node_fn_inline (vlib_main_t * vm, if (PREDICT_FALSE (ip4_is_first_fragment (ip0))) { - old_port0 = udp0->src_port; - new_port0 = udp0->src_port = s0->out2in.port; - if (PREDICT_TRUE (proto0 == SNAT_PROTOCOL_TCP)) { + old_port0 = tcp0->src_port; + tcp0->src_port = s0->out2in.port; + new_port0 = tcp0->src_port; + sum0 = tcp0->checksum; sum0 = ip_csum_update (sum0, old_addr0, new_addr0, ip4_header_t, @@ -1998,30 +1941,11 @@ nat44_ed_in2out_reass_node_fn_inline (vlib_main_t * vm, } tcp0->checksum = ip_csum_fold (sum0); } - else if (udp0->checksum) - { - sum0 = udp0->checksum; - sum0 = - ip_csum_update (sum0, old_addr0, new_addr0, ip4_header_t, - dst_address); - sum0 = - ip_csum_update (sum0, old_port0, new_port0, ip4_header_t, - length); - if (PREDICT_FALSE (is_twice_nat_session (s0))) - { - sum0 = ip_csum_update (sum0, ip0->dst_address.as_u32, - s0->ext_host_addr.as_u32, - ip4_header_t, dst_address); - sum0 = ip_csum_update (sum0, tcp0->dst_port, - s0->ext_host_port, ip4_header_t, - length); - udp0->dst_port = s0->ext_host_port; - ip0->dst_address.as_u32 = s0->ext_host_addr.as_u32; - } - udp0->checksum = ip_csum_fold (sum0); - } else { + old_port0 = udp0->src_port; + udp0->src_port = s0->out2in.port; + udp0->checksum = 0; if (PREDICT_FALSE (is_twice_nat_session (s0))) { udp0->dst_port = s0->ext_host_port; |