#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;
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;
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)
{
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);
}
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;
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;
}