session: restore cl session dscp support 10/43510/11
authorSemir Sionek <[email protected]>
Fri, 1 Aug 2025 12:16:52 +0000 (12:16 +0000)
committerFlorin Coras <[email protected]>
Sat, 9 Aug 2025 03:38:07 +0000 (03:38 +0000)
Included dscp in session_listen messages and propagated it up to the
listener struct, which is used for connection info in cl sessions.
Additionally, included a switch in vcl_test_cl_udp allowing to select
dscp values for the session.

Type: fix
Change-Id: I6dffe12b66b25617dc9e3b6d4008f1097ff150cf
Signed-off-by: Semir Sionek <[email protected]>
extras/hs-test/docker/Dockerfile.vpp
extras/hs-test/infra/vppinstance.go
extras/hs-test/vcl_test.go
src/plugins/hs_apps/vcl/vcl_test_cl_udp.c
src/vcl/vppcom.c
src/vnet/session/application_interface.h
src/vnet/session/session_node.c
src/vnet/udp/udp.c

index cf620ee..20d2c65 100644 (file)
@@ -24,6 +24,7 @@ COPY \
    $DIR/prom_plugin.so \
    $DIR/tlsopenssl_plugin.so \
    $DIR/mactime_plugin.so \
+   $DIR/arping_plugin.so \
    /usr/lib/$OS_ARCH-linux-gnu/vpp_plugins/
 
 COPY vpp-data/bin/vpp /usr/bin/
index 2e9c756..cfb3959 100644 (file)
@@ -72,6 +72,7 @@ plugins {
   plugin ping_plugin.so { enable }
   plugin nsim_plugin.so { enable }
   plugin mactime_plugin.so { enable }
+  plugin arping_plugin.so { enable }
 }
 
 logging {
index e00937b..f184d78 100644 (file)
@@ -9,7 +9,7 @@ import (
 
 func init() {
        RegisterVethTests(XEchoVclClientUdpTest, XEchoVclClientTcpTest, XEchoVclServerUdpTest,
-               XEchoVclServerTcpTest, VclEchoTcpTest, VclEchoUdpTest, VclHttpPostTest)
+               XEchoVclServerTcpTest, VclEchoTcpTest, VclEchoUdpTest, VclHttpPostTest, VclClUdpDscpTest)
        RegisterSoloVethTests(VclRetryAttachTest)
 }
 
@@ -156,3 +156,34 @@ func testRetryAttach(s *VethsSuite, proto string) {
        s.AssertNil(err, o)
        s.Log("Done.")
 }
+
+func VclClUdpDscpTest(s *VethsSuite) {
+       srvVppCont := s.Containers.ServerVpp
+       srvAppCont := s.Containers.ServerApp
+       srvAppCont.CreateFile("/vcl.conf", getVclConfig(srvVppCont))
+       srvAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf")
+       serverVethAddress := s.Interfaces.Server.Ip4AddressString()
+
+       // DSCP 40 - Class selector 5 - Signalling
+       vclSrvCmd := fmt.Sprintf("vcl_test_cl_udp -s %s -d 40", serverVethAddress)
+       srvAppCont.ExecServer(true, vclSrvCmd)
+
+       cliVppCont := s.Containers.ClientVpp
+       cliAppCont := s.Containers.ClientApp
+       cliAppCont.CreateFile("/vcl.conf", getVclConfig(cliVppCont))
+       cliAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf")
+       cliVppCont.VppInstance.Vppctl("arping %s host-%s", serverVethAddress, s.Interfaces.Client.Name())
+
+       cliVppCont.VppInstance.Vppctl("trace add af-packet-input 10")
+       srvVppCont.VppInstance.Vppctl("trace add af-packet-input 10")
+
+       // DSCP 16 - Class selector 2 - Network operations
+       cliSrvCmd := fmt.Sprintf("vcl_test_cl_udp -c %s -d 16", serverVethAddress)
+       o, err := cliAppCont.Exec(true, cliSrvCmd)
+       s.AssertNil(err, o)
+
+       o = srvVppCont.VppInstance.Vppctl("show trace")
+       s.AssertContains(o, "dscp CS2")
+       o = cliVppCont.VppInstance.Vppctl("show trace")
+       s.AssertContains(o, "dscp CS5")
+}
index 1325941..7d27db0 100644 (file)
@@ -44,6 +44,7 @@ typedef struct vtclu_main_
     struct sockaddr_storage clnt_addr;
   };
   uint16_t port;
+  uint8_t dscp;
   int num_workers;
   pthread_t *worker_threads;
   int thread_id_counter;
@@ -51,6 +52,7 @@ typedef struct vtclu_main_
 } vt_clu_main_t;
 
 static vt_clu_main_t vt_clu_main;
+static const uint32_t dscplen = 1;
 
 typedef struct vtclu_worker_args_
 {
@@ -62,13 +64,15 @@ static void
 vt_clu_parse_args (vt_clu_main_t *vclum, int argc, char **argv)
 {
   int c;
+  int temp;
 
   memset (vclum, 0, sizeof (*vclum));
   vclum->port = VCL_TEST_SERVER_PORT;
   vclum->num_workers = 1;
+  vclum->dscp = 0;
 
   opterr = 0;
-  while ((c = getopt (argc, argv, "s:c:w:")) != -1)
+  while ((c = getopt (argc, argv, "s:c:w:d:")) != -1)
     switch (c)
       {
       case 's':
@@ -93,6 +97,15 @@ vt_clu_parse_args (vt_clu_main_t *vclum, int argc, char **argv)
            vclum->num_workers = 1;
          }
        break;
+      case 'd':
+       temp = atoi (optarg);
+       if (temp <= 0 || temp > 63)
+         {
+           vtwrn ("invalid dscp value %s", optarg);
+           vclum->dscp = 0;
+         }
+       vclum->dscp = temp;
+       break;
       }
 
   if (vclum->app_type == VT_CLU_TYPE_NONE)
@@ -169,6 +182,10 @@ vt_clu_server_worker (void *arg)
       return NULL;
     }
 
+  if (vclum->dscp)
+    vppcom_session_attr (vcl_sh, VPPCOM_ATTR_SET_DSCP, &vclum->dscp,
+                        (uint32_t *) &dscplen);
+
   /* Bind to the same endpoint as main thread */
   rv = vppcom_session_bind (vcl_sh, &vclum->endpt);
   if (rv < 0)
@@ -241,6 +258,9 @@ vt_clu_client_worker (void *arg)
       vterr ("vppcom_session_create()", vcl_sh);
       return NULL;
     }
+  if (vclum->dscp)
+    vppcom_session_attr (vcl_sh, VPPCOM_ATTR_SET_DSCP, &vclum->dscp,
+                        (uint32_t *) &dscplen);
 
   char message[buflen];
   int msg_len =
index 9da68c1..0887970 100644 (file)
@@ -69,6 +69,7 @@ vcl_send_session_listen (vcl_worker_t *wrk, vcl_session_t *s)
   mp->port = s->transport.lcl_port;
   mp->proto = s->session_type;
   mp->vrf = s->vrf;
+  mp->dscp = s->dscp;
   if (s->flags & VCL_SESSION_F_CONNECTED)
     mp->flags = TRANSPORT_CFG_F_CONNECTED;
   if (s->ext_config)
index f58b0fa..284c154 100644 (file)
@@ -312,6 +312,7 @@ typedef struct session_listen_msg_
   ip46_address_t ip;
   u8 flags;
   uword ext_config;
+  u8 dscp;
 } __clib_packed session_listen_msg_t;
 
 STATIC_ASSERT (sizeof (session_listen_msg_t) <= SESSION_CTRL_MSG_MAX_SIZE,
index fb4c625..379ae53 100644 (file)
@@ -132,6 +132,7 @@ session_mq_listen_handler (session_worker_t *wrk, session_evt_elt_t *elt)
   a->sep.fib_index = mp->vrf;
   a->sep.sw_if_index = ENDPOINT_INVALID_INDEX;
   a->sep.transport_proto = mp->proto;
+  a->sep.dscp = mp->dscp;
   a->app_index = app->app_index;
   a->wrk_map_index = mp->wrk_index;
   a->sep_ext.transport_flags = mp->flags;
index 0848936..e1cd98a 100644 (file)
@@ -193,6 +193,7 @@ udp_session_bind (u32 session_index, transport_endpoint_cfg_t *lcl)
   listener->c_proto = TRANSPORT_PROTO_UDP;
   listener->c_s_index = session_index;
   listener->c_fib_index = lcl->fib_index;
+  listener->c_dscp = lcl->dscp;
   listener->mss =
     lcl->mss ? lcl->mss : udp_default_mtu (um, listener->c_is_ip4);
   listener->flags |= UDP_CONN_F_OWNS_PORT | UDP_CONN_F_LISTEN;