session: add support for DSCP 77/34477/3
authorFilip Tehlar <ftehlar@cisco.com>
Thu, 21 Oct 2021 14:07:31 +0000 (14:07 +0000)
committerFlorin Coras <florin.coras@gmail.com>
Fri, 12 Nov 2021 20:41:09 +0000 (20:41 +0000)
Type: feature

Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Change-Id: I817b1503ada1ae53c1134a85263f9b801d74e88a

src/vnet/ip/ip4_inlines.h
src/vnet/session/transport_types.h
src/vnet/udp/udp.c

index 00a4712..9a6c8c7 100644 (file)
@@ -98,9 +98,9 @@ ip4_compute_flow_hash (const ip4_header_t * ip,
 }
 
 always_inline void *
-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)
+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, u8 dscp)
 {
   ip4_header_t *ih;
 
@@ -108,7 +108,8 @@ vlib_buffer_push_ip4_custom (vlib_main_t * vm, vlib_buffer_t * b,
   ih = vlib_buffer_push_uninit (b, sizeof (ip4_header_t));
 
   ih->ip_version_and_header_length = 0x45;
-  ih->tos = 0;
+  ip4_header_set_dscp (ih, dscp);
+  ip4_header_set_ecn (ih, 0);
   ih->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b));
 
   /* No fragments */
@@ -152,7 +153,7 @@ vlib_buffer_push_ip4 (vlib_main_t * vm, vlib_buffer_t * b,
                      u8 csum_offload)
 {
   return vlib_buffer_push_ip4_custom (vm, b, src, dst, proto, csum_offload,
-                                     1 /* is_df */ );
+                                     1 /* is_df */, 0);
 }
 
 #endif /* included_ip_ip4_inlines_h */
index 9ea1f21..188c21a 100644 (file)
@@ -106,6 +106,7 @@ typedef struct _transport_connection
   u32 c_index;                 /**< Connection index in transport pool */
   u32 thread_index;            /**< Worker-thread index */
   u8 flags;                    /**< Transport specific flags */
+  u8 dscp;                     /**< Differentiated Services Code Point */
 
   /*fib_node_index_t rmt_fei;
      dpo_id_t rmt_dpo; */
@@ -146,6 +147,7 @@ typedef struct _transport_connection
 #define c_stats connection.stats
 #define c_pacer connection.pacer
 #define c_flags connection.flags
+#define c_dscp          connection.dscp
 #define s_ho_handle pacer.bytes_per_sec
 } transport_connection_t;
 
@@ -209,6 +211,7 @@ typedef enum transport_endpt_cfg_flags_
   _ (u32, next_node_index)                                             \
   _ (u32, next_node_opaque)                                            \
   _ (u16, mss)                                                         \
+  _ (u8, dscp) \
   _ (u8, transport_flags)                                              \
 /* clang-format on */
 
index 40e0053..b27f0d7 100644 (file)
@@ -247,8 +247,8 @@ 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_custom (vm, b, &uc->c_lcl_ip4, &uc->c_rmt_ip4,
-                                IP_PROTOCOL_UDP, 1 /* csum offload */ ,
-                                0 /* is_df */ );
+                                IP_PROTOCOL_UDP, 1 /* csum offload */,
+                                0 /* is_df */, uc->c_dscp);
   else
     vlib_buffer_push_ip6 (vm, b, &uc->c_lcl_ip6, &uc->c_rmt_ip6,
                          IP_PROTOCOL_UDP);
@@ -385,6 +385,7 @@ conn_alloc:
   uc->c_is_ip4 = rmt->is_ip4;
   uc->c_proto = TRANSPORT_PROTO_UDP;
   uc->c_fib_index = rmt->fib_index;
+  uc->c_dscp = rmt->dscp;
   uc->mss = rmt->mss ? rmt->mss : udp_default_mtu (um, uc->c_is_ip4);
   uc->flags |= UDP_CONN_F_OWNS_PORT;
   if (rmt->transport_flags & TRANSPORT_CFG_F_CONNECTED)