Change in osmo-mgw[master]: TOS bits != DSCP

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Wed Apr 28 18:36:34 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/23924 )

Change subject: TOS bits != DSCP
......................................................................

TOS bits != DSCP

We have VTY options that allow to set the DSCP value.  However, we
then call a function to set the TOS bits in the kernel.  This is
very wrong.  The DSCP is only the upper 6 bits of the 8-bit TOS
value, and hence we are mussing that translation.

As libosmocore now has a helper function osmo_sock_set_dscp(),
let's make use of it and don't care about the low-level details.

However, this means we need to finally remove the deprecated
alias for "rtp ip-tos <0-255>".

Closes: OS#5137
Change-Id: I9c18c90273be97aedd2ad212b82f650e35c32851
Depends: libosmocore.git Ia4ba389a5b7e3e9d5f17a742a900d6fd68c08e40
---
M TODO-RELEASE
M doc/examples/osmo-mgw/osmo-mgw-abis_e1.cfg
M doc/examples/osmo-mgw/osmo-mgw.cfg
M doc/manuals/chapters/configuration.adoc
M include/osmocom/mgcp/mgcp_network.h
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_osmux.c
M src/libosmo-mgcp/mgcp_vty.c
8 files changed, 9 insertions(+), 28 deletions(-)

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



diff --git a/TODO-RELEASE b/TODO-RELEASE
index c5a3b36..add44f1 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -24,3 +24,4 @@
 # If any interfaces have been removed or changed since the last public release, a=0.
 #
 #library		what		description / commit summary line
+update dependency to libosmocore > 1.5.1 for our use of osmo_sock_set_dscp()
diff --git a/doc/examples/osmo-mgw/osmo-mgw-abis_e1.cfg b/doc/examples/osmo-mgw/osmo-mgw-abis_e1.cfg
index 6d369ef..bd948b8 100644
--- a/doc/examples/osmo-mgw/osmo-mgw-abis_e1.cfg
+++ b/doc/examples/osmo-mgw/osmo-mgw-abis_e1.cfg
@@ -9,7 +9,7 @@
   rtp port-range 4002 16000
   rtp bind-ip 127.0.0.1
   rtp ip-probing
-  rtp ip-tos 184
+  rtp ip-dscp 46
   bind port 2427
   sdp audio payload number 98
   sdp audio payload name GSM
diff --git a/doc/examples/osmo-mgw/osmo-mgw.cfg b/doc/examples/osmo-mgw/osmo-mgw.cfg
index ea00f6c..320feae 100644
--- a/doc/examples/osmo-mgw/osmo-mgw.cfg
+++ b/doc/examples/osmo-mgw/osmo-mgw.cfg
@@ -6,7 +6,7 @@
   rtp port-range 4002 16000
   rtp bind-ip 127.0.0.1
   rtp ip-probing
-  rtp ip-tos 184
+  rtp ip-dscp 46
   bind port 2427
   sdp audio payload number 98
   sdp audio payload name GSM
diff --git a/doc/manuals/chapters/configuration.adoc b/doc/manuals/chapters/configuration.adoc
index 2e2772e..177c096 100644
--- a/doc/manuals/chapters/configuration.adoc
+++ b/doc/manuals/chapters/configuration.adoc
@@ -101,7 +101,7 @@
  rtp net-range 6000 6011
  rtp net-bind-ip 192.168.100.130
  rtp ip-probing
- rtp ip-tos 184
+ rtp ip-dscp 46
  no rtp keep-alive
  bind port 2428
  number endpoints 30
diff --git a/include/osmocom/mgcp/mgcp_network.h b/include/osmocom/mgcp/mgcp_network.h
index 7dbf330..6e1e52c 100644
--- a/include/osmocom/mgcp/mgcp_network.h
+++ b/include/osmocom/mgcp/mgcp_network.h
@@ -148,7 +148,6 @@
 			  struct mgcp_rtp_end *rtp_end,
 			  struct osmo_sockaddr *addr, struct msgb *msg);
 void mgcp_get_local_addr(char *addr, struct mgcp_conn_rtp *conn);
-int mgcp_set_ip_tos(int fd, int tos);
 
 /* payload processing default functions */
 int mgcp_rtp_processing_default(struct mgcp_endpoint *endp, struct mgcp_rtp_end *dst_end,
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 6b31f2b..675a0fc 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1514,20 +1514,6 @@
 	return conn->endp->type->dispatch_rtp_cb(msg);
 }
 
-/*! set IP Type of Service parameter.
- *  \param[in] fd associated file descriptor.
- *  \param[in] tos dscp value.
- *  \returns 0 on success, -1 on ERROR. */
-int mgcp_set_ip_tos(int fd, int tos)
-{
-	int ret;
-	ret = setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
-
-	if (ret < 0)
-		return -1;
-	return 0;
-}
-
 /*! bind RTP port to osmo_fd.
  *  \param[in] source_addr source (local) address to bind on.
  *  \param[in] fd associated file descriptor.
@@ -1574,8 +1560,8 @@
 	}
 
 	/* Set Type of Service (DSCP-Value) as configured via VTY */
-	mgcp_set_ip_tos(rtp_end->rtp.fd, cfg->endp_dscp);
-	mgcp_set_ip_tos(rtp_end->rtcp.fd, cfg->endp_dscp);
+	osmo_sock_set_dscp(rtp_end->rtp.fd, cfg->endp_dscp);
+	osmo_sock_set_dscp(rtp_end->rtcp.fd, cfg->endp_dscp);
 
 	if (osmo_fd_register(&rtp_end->rtp) != 0) {
 		LOGPENDP(endp, DRTP, LOGL_ERROR,
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index a7c0eef..6c40307 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -424,7 +424,7 @@
 		     cfg->osmux_addr, cfg->osmux_port);
 		return ret;
 	}
-	mgcp_set_ip_tos(osmux_fd.fd, cfg->endp_dscp);
+	osmo_sock_set_dscp(osmux_fd.fd, cfg->endp_dscp);
 
 	ret = osmo_fd_register(&osmux_fd);
 	if (ret < 0) {
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 9ad8c24..6b180ef 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -579,19 +579,15 @@
 DEFUN_USRATTR(cfg_mgcp_rtp_ip_dscp,
 	      cfg_mgcp_rtp_ip_dscp_cmd,
 	      X(MGW_CMD_ATTR_NEWCONN),
-	      "rtp ip-dscp <0-255>",
+	      "rtp ip-dscp <0-63>",
 	      RTP_STR
-	      "Apply IP_TOS to the audio stream (including Osmux)\n" "The DSCP value\n")
+	      "Use specified DSCP for the audio stream (including Osmux)\n" "The DSCP value\n")
 {
 	int dscp = atoi(argv[0]);
 	g_cfg->endp_dscp = dscp;
 	return CMD_SUCCESS;
 }
 
-ALIAS_DEPRECATED(cfg_mgcp_rtp_ip_dscp, cfg_mgcp_rtp_ip_tos_cmd,
-		 "rtp ip-tos <0-255>",
-		 RTP_STR
-		 "Apply IP_TOS to the audio stream\n" "The DSCP value\n")
 #define FORCE_PTIME_STR "Force a fixed ptime for packets sent"
 DEFUN_USRATTR(cfg_mgcp_rtp_force_ptime,
 	      cfg_mgcp_rtp_force_ptime_cmd,
@@ -1622,7 +1618,6 @@
 	install_element(MGCP_NODE, &cfg_mgcp_rtp_net_bind_ip_probing_cmd);
 	install_element(MGCP_NODE, &cfg_mgcp_rtp_no_net_bind_ip_probing_cmd);
 	install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_dscp_cmd);
-	install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_tos_cmd);
 	install_element(MGCP_NODE, &cfg_mgcp_rtp_force_ptime_cmd);
 	install_element(MGCP_NODE, &cfg_mgcp_no_rtp_force_ptime_cmd);
 	install_element(MGCP_NODE, &cfg_mgcp_rtp_keepalive_cmd);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/23924
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I9c18c90273be97aedd2ad212b82f650e35c32851
Gerrit-Change-Number: 23924
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210428/4c3bc1a5/attachment.htm>


More information about the gerrit-log mailing list