Change in osmo-mgw[master]: mgw: Add support for setting socket priority from VTY

laforge gerrit-no-reply at lists.osmocom.org
Wed Apr 28 17:35:02 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/23965 )


Change subject: mgw: Add support for setting socket priority from VTY
......................................................................

mgw: Add support for setting socket priority from VTY

This is useful for affecting the 802.1Q PCP value without any separate
external packet filter rules for classification.

Change-Id: I69136c6dd114c24b1dace034e75dba5157bac37e
Depends: libosmocore.git I89abffcd125e6d073338a5c6437b9433220e1823
---
M include/osmocom/mgcp/mgcp.h
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_osmux.c
M src/libosmo-mgcp/mgcp_vty.c
4 files changed, 30 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/65/23965/1

diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index e0aeb83..1de579a 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -143,6 +143,7 @@
 
 	struct mgcp_port_range net_ports;
 	int endp_dscp;
+	int endp_priority;
 
 	int force_ptime;
 
@@ -208,5 +209,6 @@
 int mgcp_send_reset_all(struct mgcp_config *cfg);
 
 
-int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port, uint8_t dscp);
+int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port, uint8_t dscp,
+		     uint8_t prio);
 int mgcp_udp_send(int fd, struct osmo_sockaddr *addr, int port, char *buf, int len);
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 76fe730..6a30165 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1518,13 +1518,17 @@
  *  \param[in] source_addr source (local) address to bind on.
  *  \param[in] fd associated file descriptor.
  *  \param[in] port to bind on.
+ *  \param[in] dscp IP DSCP value to use.
+ *  \param[in] prio socket priority to use.
  *  \returns 0 on success, -1 on ERROR. */
-int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port, uint8_t dscp)
+int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port, uint8_t dscp,
+		     uint8_t prio)
 {
 	int rc;
 
 	rc = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, source_addr, port,
-			     NULL, 0, OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(dscp));
+			     NULL, 0, OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(dscp) |
+			     OSMO_SOCK_F_PRIO(prio));
 	if (rc < 0) {
 		LOGP(DRTP, LOGL_ERROR, "failed to bind UDP port (%s:%i).\n",
 		     source_addr, port);
@@ -1543,14 +1547,16 @@
 	/* NOTE: The port that is used for RTCP is the RTP port incremented by one
 	 * (e.g. RTP-Port = 16000 ==> RTCP-Port = 16001) */
 
-	if (mgcp_create_bind(source_addr, &rtp_end->rtp, rtp_end->local_port, cfg->endp_dscp) != 0) {
+	if (mgcp_create_bind(source_addr, &rtp_end->rtp, rtp_end->local_port,
+			     cfg->endp_dscp, cfg->endp_priority) != 0) {
 		LOGPENDP(endp, DRTP, LOGL_ERROR,
 			 "failed to create RTP port: %s:%d\n",
 			 source_addr, rtp_end->local_port);
 		goto cleanup0;
 	}
 
-	if (mgcp_create_bind(source_addr, &rtp_end->rtcp, rtp_end->local_port + 1, cfg->endp_dscp) != 0) {
+	if (mgcp_create_bind(source_addr, &rtp_end->rtcp, rtp_end->local_port + 1,
+			     cfg->endp_dscp, cfg->endp_priority) != 0) {
 		LOGPENDP(endp, DRTP, LOGL_ERROR,
 			 "failed to create RTCP port: %s:%d\n",
 			 source_addr, rtp_end->local_port + 1);
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 62a6720..bb85735 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -418,7 +418,8 @@
 
 	osmo_fd_setup(&osmux_fd, -1, OSMO_FD_READ, osmux_read_fd_cb, cfg, 0);
 
-	ret = mgcp_create_bind(cfg->osmux_addr, &osmux_fd, cfg->osmux_port, cfg->endp_dscp);
+	ret = mgcp_create_bind(cfg->osmux_addr, &osmux_fd, cfg->osmux_port,
+				cfg->endp_dscp, cfg->endp_priority);
 	if (ret < 0) {
 		LOGP(DLMGCP, LOGL_ERROR, "cannot bind OSMUX socket to %s:%u\n",
 		     cfg->osmux_addr, cfg->osmux_port);
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index e8aeab1..6aa0387 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -83,6 +83,8 @@
 	else
 		vty_out(vty, " no rtp ip-probing%s", VTY_NEWLINE);
 	vty_out(vty, " rtp ip-dscp %d%s", g_cfg->endp_dscp, VTY_NEWLINE);
+	if (g_cfg->endp_priority)
+		vty_out(vty, " rtp priority %d%s", g_cfg->endp_priority, VTY_NEWLINE);
 	if (trunk->keepalive_interval == MGCP_KEEPALIVE_ONCE)
 		vty_out(vty, " rtp keep-alive once%s", VTY_NEWLINE);
 	else if (trunk->keepalive_interval)
@@ -588,6 +590,18 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN_USRATTR(cfg_mgcp_rtp_priority,
+	      cfg_mgcp_rtp_priority_cmd,
+	      X(MGW_CMD_ATTR_NEWCONN),
+	      "rtp priority <0-255>",
+	      RTP_STR
+	      "socket priority (values > 6 require CAP_NET_ADMIN)\n" "socket priority value\n")
+{
+	int prio = atoi(argv[0]);
+	g_cfg->endp_priority = prio;
+	return CMD_SUCCESS;
+}
+
 #define FORCE_PTIME_STR "Force a fixed ptime for packets sent"
 DEFUN_USRATTR(cfg_mgcp_rtp_force_ptime,
 	      cfg_mgcp_rtp_force_ptime_cmd,
@@ -1618,6 +1632,7 @@
 	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_priority_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/+/23965
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I69136c6dd114c24b1dace034e75dba5157bac37e
Gerrit-Change-Number: 23965
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210428/77c6091b/attachment.htm>


More information about the gerrit-log mailing list