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
This commit is contained in:
Harald Welte 2021-04-27 22:30:52 +02:00
parent 9ffaba7c1b
commit 5936a9c23e
8 changed files with 9 additions and 28 deletions

View File

@ -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()

View File

@ -9,7 +9,7 @@ mgcp
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

View File

@ -6,7 +6,7 @@ mgcp
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

View File

@ -101,7 +101,7 @@ mgcp
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

View File

@ -148,7 +148,6 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp,
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,

View File

@ -1514,20 +1514,6 @@ static int rx_rtp(struct msgb *msg)
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 @@ static int bind_rtp(struct mgcp_config *cfg, const char *source_addr,
}
/* 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,

View File

@ -424,7 +424,7 @@ int osmux_init(int role, struct mgcp_config *cfg)
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) {

View File

@ -579,19 +579,15 @@ DEFUN_USRATTR(cfg_mgcp_rtp_no_net_bind_ip_probing,
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 @@ int mgcp_vty_init(void)
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);