laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-sigtran/+/42808?usp=email )

Change subject: Add DSCP configuration support for each individual ASP
......................................................................

Add DSCP configuration support for each individual ASP

Introduce VTY command to configure the Differentiated Services Code
Point (DSCP) values for each Application Server Process.

If the ASP connection has the role "server", it will inherit the DSCP
settings of the listener, unless it is configured at the ASP connection.

Related: SYS#8071
Change-Id: Ia125a392eec5605553809774162675b5249b8494
---
M src/ss7_asp.c
M src/ss7_asp.h
M src/ss7_asp_vty.c
M src/ss7_xua_srv.c
M tests/vty/osmo_stp_test.vty
M tests/vty/ss7_asp_test.vty
6 files changed, 59 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/src/ss7_asp.c b/src/ss7_asp.c
index c1739f3..c47ee7c 100644
--- a/src/ss7_asp.c
+++ b/src/ss7_asp.c
@@ -374,6 +374,23 @@
        return osmo_sock_multiaddr_del_local_addr(fd, &new_loc_addr, 1);
 }

+int ss7_asp_apply_ip_dscp(const struct osmo_ss7_asp *asp)
+{
+       int fd = -1;
+
+       LOGPASP(asp, DLSS7, LOGL_INFO, "Set IP DSCP %d\n", asp->cfg.ip_dscp);
+
+       if (asp->cfg.is_server && asp->server)
+               fd = osmo_stream_srv_get_fd(asp->server);
+       else if (asp->client)
+               fd = osmo_stream_cli_get_fd(asp->client);
+
+       if (fd < 0)
+               return fd;
+
+       return osmo_sock_set_dscp(fd, asp->cfg.ip_dscp);
+}
+
 int ss7_asp_apply_peer_primary_address(const struct osmo_ss7_asp *asp)
 {
        struct osmo_sockaddr_str addr_str;
@@ -816,6 +833,8 @@
        osmo_stream_cli_set_local_addrs(asp->client, (const char 
**)asp->cfg.local.host, asp->cfg.local.host_cnt);
        osmo_stream_cli_set_local_port(asp->client, asp->cfg.local.port);
        osmo_stream_cli_set_proto(asp->client, asp->cfg.trans_proto);
+       if (asp->cfg.ip_dscp != 0)
+               osmo_stream_cli_set_ip_dscp(asp->client, asp->cfg.ip_dscp);
        osmo_stream_cli_set_reconnect_timeout(asp->client, 5);
        osmo_stream_cli_set_connect_cb(asp->client, xua_cli_connect_cb);
        osmo_stream_cli_set_disconnect_cb(asp->client, xua_cli_disconnect_cb);
diff --git a/src/ss7_asp.h b/src/ss7_asp.h
index a4e0e2f..a7e8978 100644
--- a/src/ss7_asp.h
+++ b/src/ss7_asp.h
@@ -138,6 +138,7 @@

                struct osmo_ss7_asp_peer local;
                struct osmo_ss7_asp_peer remote;
+               uint8_t ip_dscp;
                uint8_t qos_class;
                uint32_t quirks;

@@ -191,6 +192,7 @@
 int ss7_asp_apply_primary_address(const struct osmo_ss7_asp *asp);
 int ss7_asp_apply_new_local_address(const struct osmo_ss7_asp *asp, unsigned 
int loc_idx);
 int ss7_asp_apply_drop_local_address(const struct osmo_ss7_asp *asp, unsigned 
int loc_idx);
+int ss7_asp_apply_ip_dscp(const struct osmo_ss7_asp *asp);

 void ss7_asp_set_blocked(struct osmo_ss7_asp *asp, bool blocked);
 void ss7_asp_restart_after_reconfigure(struct osmo_ss7_asp *asp);
diff --git a/src/ss7_asp_vty.c b/src/ss7_asp_vty.c
index 89fb949..c38b5b8 100644
--- a/src/ss7_asp_vty.c
+++ b/src/ss7_asp_vty.c
@@ -410,6 +410,29 @@
        return CMD_SUCCESS;
 }

+DEFUN_ATTR(asp_ip_dscps, asp_ip_dscp_cmd,
+          "ip-dscp " IP_DSCP_RANGE_STR,
+          "Specify IP DSCP of ASP\n"
+          IP_DSCP_RANGE_HELP_STR,
+          CMD_ATTR_NODE_EXIT)
+{
+       struct osmo_ss7_asp *asp = vty->index;
+       asp->cfg.ip_dscp = atoi(argv[0]);
+       ss7_asp_apply_ip_dscp(asp);
+       return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(asp_no_ip_dscps, asp_no_ip_dscp_cmd,
+          "no ip-dscp",
+          NO_STR "Reset IP DSCP of ASP to default\n",
+          CMD_ATTR_NODE_EXIT)
+{
+       struct osmo_ss7_asp *asp = vty->index;
+       asp->cfg.ip_dscp = 0;
+       ss7_asp_apply_ip_dscp(asp);
+       return CMD_SUCCESS;
+}
+
 DEFUN_ATTR(asp_qos_clas, asp_qos_class_cmd,
           "qos-class " QOS_CLASS_RANGE_STR,
           "Specify QoS Class of ASP\n"
@@ -1381,6 +1404,8 @@
                        vty_out(vty, "  remote-ip %s%s%s", 
asp->cfg.remote.host[i],
                                asp->cfg.remote.idx_primary == i ? " primary" : 
"", VTY_NEWLINE);
        }
+       if (asp->cfg.ip_dscp != 0)
+               vty_out(vty, "  ip-dscp %u%s", asp->cfg.ip_dscp, VTY_NEWLINE);
        if (asp->cfg.qos_class)
                vty_out(vty, "  qos-class %u%s", asp->cfg.qos_class, 
VTY_NEWLINE);
        vty_out(vty, "  role %s%s", 
osmo_str_tolower(get_value_string(osmo_ss7_asp_role_names, asp->cfg.role)),
@@ -1490,6 +1515,8 @@
        install_lib_element(L_CS7_ASP_NODE, &asp_no_remote_ip_cmd);
        install_lib_element(L_CS7_ASP_NODE, &asp_local_ip_cmd);
        install_lib_element(L_CS7_ASP_NODE, &asp_no_local_ip_cmd);
+       install_lib_element(L_CS7_ASP_NODE, &asp_ip_dscp_cmd);
+       install_lib_element(L_CS7_ASP_NODE, &asp_no_ip_dscp_cmd);
        install_lib_element(L_CS7_ASP_NODE, &asp_qos_class_cmd);
        install_lib_element(L_CS7_ASP_NODE, &asp_role_cmd);
        install_lib_element(L_CS7_ASP_NODE, &asp_transport_role_cmd);
diff --git a/src/ss7_xua_srv.c b/src/ss7_xua_srv.c
index 96a20bc..3d9332d 100644
--- a/src/ss7_xua_srv.c
+++ b/src/ss7_xua_srv.c
@@ -105,6 +105,9 @@
                        /* Dynamic ASPs (transport-role=server) may be 
destroyed as a consequence, re-fetch the ASP: */
                        asp = ss7_asp_find_by_socket_addr(fd, 
oxs->cfg.trans_proto);
                }
+               /* If ASP uses individual DSCP setting, override the setting 
from the listener socket. */
+               if (asp->cfg.ip_dscp > 0)
+                       osmo_sock_set_dscp(fd, asp->cfg.ip_dscp);
        }

        if (!asp && !oxs->cfg.accept_dyn_reg) {
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty
index 359d65e..1b452c8 100644
--- a/tests/vty/osmo_stp_test.vty
+++ b/tests/vty/osmo_stp_test.vty
@@ -285,6 +285,8 @@
   no remote-ip (A.B.C.D|X:X::X:X)
   local-ip (A.B.C.D|X:X::X:X) [primary]
   no local-ip (A.B.C.D|X:X::X:X)
+  ip-dscp <0-63>
+  no ip-dscp
   qos-class <0-7>
   role (sg|asp|ipsp)
   transport-role (client|server)
@@ -315,6 +317,7 @@
   no                 Negate a command or set its defaults
   remote-ip          Specify Remote IP Address of ASP
   local-ip           Specify Local IP Address from which to contact ASP
+  ip-dscp            Specify IP DSCP of ASP
   qos-class          Specify QoS Class of ASP
   role               Specify the xUA role for this ASP
   transport-role     Specify the transport layer role for this ASP
@@ -329,6 +332,7 @@

 OsmoSTP(config-cs7-asp)# no ?
 ...
+  ip-dscp            Reset IP DSCP of ASP to default
   sctp-param         Configure SCTP parameters
   tcp-param          Configure TCP parameters
   destination-audit  Configure ASP Auditing (xUA DAUD)
diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty
index 0b8f4fd..e93e037 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -281,6 +281,8 @@
   no remote-ip (A.B.C.D|X:X::X:X)
   local-ip (A.B.C.D|X:X::X:X) [primary]
   no local-ip (A.B.C.D|X:X::X:X)
+  ip-dscp <0-63>
+  no ip-dscp
   qos-class <0-7>
   role (sg|asp|ipsp)
   transport-role (client|server)
@@ -311,6 +313,7 @@
   no                 Negate a command or set its defaults
   remote-ip          Specify Remote IP Address of ASP
   local-ip           Specify Local IP Address from which to contact ASP
+  ip-dscp            Specify IP DSCP of ASP
   qos-class          Specify QoS Class of ASP
   role               Specify the xUA role for this ASP
   transport-role     Specify the transport layer role for this ASP
@@ -327,6 +330,7 @@
 ...
   remote-ip          Specify Remote IP Address of ASP
   local-ip           Specify Local IP Address from which to contact ASP
+  ip-dscp            Reset IP DSCP of ASP to default
   sctp-param         Configure SCTP parameters
   tcp-param          Configure TCP parameters
   destination-audit  Configure ASP Auditing (xUA DAUD)

--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42808?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Ia125a392eec5605553809774162675b5249b8494
Gerrit-Change-Number: 42808
Gerrit-PatchSet: 9
Gerrit-Owner: jolly <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to