X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fipsec%2Fipsec_output.c;h=a62c0a5345838d06622997784e0d36a615e1549c;hb=31da2e30317bc1fcb4586e1dc0d560600d9b29d3;hp=d56b665157dd670e5d08d4f4f8be3749d81d2d84;hpb=191a59401c0552e5ea79041f34456eb9fcc1f311;p=vpp.git diff --git a/src/vnet/ipsec/ipsec_output.c b/src/vnet/ipsec/ipsec_output.c index d56b665157d..a62c0a53458 100644 --- a/src/vnet/ipsec/ipsec_output.c +++ b/src/vnet/ipsec/ipsec_output.c @@ -88,16 +88,16 @@ ipsec_output_policy_match (ipsec_spd_t * spd, u8 pr, u32 la, u32 ra, u16 lp, if (PREDICT_FALSE (p->protocol && (p->protocol != pr))) continue; - if (la < clib_net_to_host_u32 (p->laddr.start.ip4.as_u32)) + if (ra < clib_net_to_host_u32 (p->raddr.start.ip4.as_u32)) continue; - if (la > clib_net_to_host_u32 (p->laddr.stop.ip4.as_u32)) + if (ra > clib_net_to_host_u32 (p->raddr.stop.ip4.as_u32)) continue; - if (ra < clib_net_to_host_u32 (p->raddr.start.ip4.as_u32)) + if (la < clib_net_to_host_u32 (p->laddr.start.ip4.as_u32)) continue; - if (ra > clib_net_to_host_u32 (p->raddr.stop.ip4.as_u32)) + if (la > clib_net_to_host_u32 (p->laddr.stop.ip4.as_u32)) continue; if (PREDICT_FALSE @@ -190,6 +190,7 @@ ipsec_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t *f = 0; u32 spd_index0 = ~0; ipsec_spd_t *spd0 = 0; + int bogus; u64 nc_protect = 0, nc_bypass = 0, nc_discard = 0, nc_nomatch = 0; from = vlib_frame_vector_args (from_frame); @@ -204,6 +205,7 @@ ipsec_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node, ip6_header_t *ip6_0 = 0; udp_header_t *udp0; u32 iph_offset = 0; + tcp_header_t *tcp0; bi0 = from[0]; b0 = vlib_get_buffer (vm, bi0); @@ -269,33 +271,67 @@ ipsec_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node, clib_net_to_host_u16 (udp0->dst_port)); } + tcp0 = (void *) udp0; if (PREDICT_TRUE (p0 != NULL)) { if (p0->policy == IPSEC_POLICY_ACTION_PROTECT) { - u32 sa_index = 0; ipsec_sa_t *sa = 0; nc_protect++; - sa_index = ipsec_get_sa_index_by_sa_id (p0->sa_id); - sa = pool_elt_at_index (im->sad, sa_index); + sa = pool_elt_at_index (im->sad, p0->sa_index); if (sa->protocol == IPSEC_PROTOCOL_ESP) next_node_index = im->esp_encrypt_node_index; else next_node_index = im->ah_encrypt_node_index; vnet_buffer (b0)->ipsec.sad_index = p0->sa_index; - vlib_buffer_advance (b0, iph_offset); p0->counter.packets++; if (is_ipv6) { p0->counter.bytes += clib_net_to_host_u16 (ip6_0->payload_length); p0->counter.bytes += sizeof (ip6_header_t); + if (PREDICT_FALSE + (b0->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)) + { + tcp0->checksum = + ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip6_0, + &bogus); + b0->flags &= ~VNET_BUFFER_F_OFFLOAD_TCP_CKSUM; + } + if (PREDICT_FALSE + (b0->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM)) + { + udp0->checksum = + ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip6_0, + &bogus); + b0->flags &= ~VNET_BUFFER_F_OFFLOAD_UDP_CKSUM; + } } else { p0->counter.bytes += clib_net_to_host_u16 (ip0->length); + if (b0->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM) + { + ip0->checksum = ip4_header_checksum (ip0); + b0->flags &= ~VNET_BUFFER_F_OFFLOAD_IP_CKSUM; + } + if (PREDICT_FALSE + (b0->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)) + { + tcp0->checksum = + ip4_tcp_udp_compute_checksum (vm, b0, ip0); + b0->flags &= ~VNET_BUFFER_F_OFFLOAD_TCP_CKSUM; + } + if (PREDICT_FALSE + (b0->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM)) + { + udp0->checksum = + ip4_tcp_udp_compute_checksum (vm, b0, ip0); + b0->flags &= ~VNET_BUFFER_F_OFFLOAD_UDP_CKSUM; + } } + vlib_buffer_advance (b0, iph_offset); } else if (p0->policy == IPSEC_POLICY_ACTION_BYPASS) {