diff options
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/ip/ip4.h | 43 | ||||
-rw-r--r-- | src/vnet/session/session_node.c | 11 | ||||
-rw-r--r-- | src/vnet/udp/udp.c | 13 | ||||
-rw-r--r-- | src/vnet/udp/udp.h | 7 |
4 files changed, 37 insertions, 37 deletions
diff --git a/src/vnet/ip/ip4.h b/src/vnet/ip/ip4.h index a7ed5c26690..6e13cc8ea3e 100644 --- a/src/vnet/ip/ip4.h +++ b/src/vnet/ip/ip4.h @@ -363,23 +363,10 @@ u32 ip4_tcp_udp_validate_checksum (vlib_main_t * vm, vlib_buffer_t * p0); #define IP_DF 0x4000 /* don't fragment */ -/** - * Push IPv4 header to buffer - * - * This does not support fragmentation. - * - * @param vm - vlib_main - * @param b - buffer to write the header to - * @param src - source IP - * @param dst - destination IP - * @param prot - payload proto - * - * @return - pointer to start of IP header - */ always_inline void * -vlib_buffer_push_ip4 (vlib_main_t * vm, vlib_buffer_t * b, - ip4_address_t * src, ip4_address_t * dst, int proto, - u8 csum_offload) +vlib_buffer_push_ip4_custom (vlib_main_t * vm, vlib_buffer_t * b, + ip4_address_t * src, ip4_address_t * dst, + int proto, u8 csum_offload, u8 is_df) { ip4_header_t *ih; @@ -391,7 +378,7 @@ vlib_buffer_push_ip4 (vlib_main_t * vm, vlib_buffer_t * b, ih->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b)); /* No fragments */ - ih->flags_and_fragment_offset = clib_host_to_net_u16 (IP_DF); + ih->flags_and_fragment_offset = is_df ? clib_host_to_net_u16 (IP_DF) : 0; ih->ttl = 255; ih->protocol = proto; ih->src_address.as_u32 = src->as_u32; @@ -412,6 +399,28 @@ vlib_buffer_push_ip4 (vlib_main_t * vm, vlib_buffer_t * b, return ih; } +/** + * Push IPv4 header to buffer + * + * This does not support fragmentation. + * + * @param vm - vlib_main + * @param b - buffer to write the header to + * @param src - source IP + * @param dst - destination IP + * @param prot - payload proto + * + * @return - pointer to start of IP header + */ +always_inline void * +vlib_buffer_push_ip4 (vlib_main_t * vm, vlib_buffer_t * b, + ip4_address_t * src, ip4_address_t * dst, int proto, + u8 csum_offload) +{ + return vlib_buffer_push_ip4_custom (vm, b, src, dst, proto, csum_offload, + 1 /* is_df */ ); +} + always_inline u32 vlib_buffer_get_ip4_fib_index (vlib_buffer_t * b) { diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 573fbe91b09..464e6a105f5 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -1030,18 +1030,13 @@ session_tx_fifo_read_and_snd_i (session_worker_t * wrk, else session_tx_maybe_reschedule (wrk, ctx, elt); - if (!peek_data - && ctx->transport_vft->transport_options.tx_type == TRANSPORT_TX_DGRAM) + if (!peek_data) { /* Fix dgram pre header */ - if (ctx->max_len_to_snd < ctx->max_dequeue) + if (ctx->transport_vft->transport_options.tx_type == TRANSPORT_TX_DGRAM + && ctx->max_len_to_snd < ctx->max_dequeue) svm_fifo_overwrite_head (ctx->s->tx_fifo, (u8 *) & ctx->hdr, sizeof (session_dgram_pre_hdr_t)); - /* More data needs to be read */ - else if (svm_fifo_max_dequeue_cons (ctx->s->tx_fifo) > 0) - if (svm_fifo_set_event (ctx->s->tx_fifo)) - session_evt_add_old (wrk, elt); - if (svm_fifo_needs_deq_ntf (ctx->s->tx_fifo, ctx->max_len_to_snd)) session_dequeue_notify (ctx->s); } diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c index daab453f43d..8f26b57bb3f 100644 --- a/src/vnet/udp/udp.c +++ b/src/vnet/udp/udp.c @@ -241,15 +241,12 @@ udp_push_header (transport_connection_t * tc, vlib_buffer_t * b) vlib_buffer_push_udp (b, uc->c_lcl_port, uc->c_rmt_port, 1); if (tc->is_ip4) - vlib_buffer_push_ip4 (vm, b, &uc->c_lcl_ip4, &uc->c_rmt_ip4, - IP_PROTOCOL_UDP, 1); + vlib_buffer_push_ip4_custom (vm, b, &uc->c_lcl_ip4, &uc->c_rmt_ip4, + IP_PROTOCOL_UDP, 1 /* csum offload */ , + 0 /* is_df */ ); else - { - ip6_header_t *ih; - ih = vlib_buffer_push_ip6 (vm, b, &uc->c_lcl_ip6, &uc->c_rmt_ip6, - IP_PROTOCOL_UDP); - vnet_buffer (b)->l3_hdr_offset = (u8 *) ih - b->data; - } + vlib_buffer_push_ip6 (vm, b, &uc->c_lcl_ip6, &uc->c_rmt_ip6, + IP_PROTOCOL_UDP); vnet_buffer (b)->sw_if_index[VLIB_RX] = 0; vnet_buffer (b)->sw_if_index[VLIB_TX] = uc->c_fib_index; b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED; diff --git a/src/vnet/udp/udp.h b/src/vnet/udp/udp.h index f7985c928c2..ddc9a0eb27d 100644 --- a/src/vnet/udp/udp.h +++ b/src/vnet/udp/udp.h @@ -308,10 +308,9 @@ vlib_buffer_push_udp (vlib_buffer_t * b, u16 sp, u16 dp, u8 offload_csum) uh->checksum = 0; uh->length = clib_host_to_net_u16 (udp_len); if (offload_csum) - { - b->flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM; - vnet_buffer (b)->l4_hdr_offset = (u8 *) uh - b->data; - } + b->flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM; + vnet_buffer (b)->l4_hdr_offset = (u8 *) uh - b->data; + b->flags |= VNET_BUFFER_F_L4_HDR_OFFSET_VALID; return uh; } |