Change in libosmocore[master]: ns2: migrate from osmo_sock_set_dscp() to OSMO_SOCK_F_DSCP()

laforge gerrit-no-reply at lists.osmocom.org
Thu Apr 29 17:51:24 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/23974 )

Change subject: ns2: migrate from osmo_sock_set_dscp() to OSMO_SOCK_F_DSCP()
......................................................................

ns2: migrate from osmo_sock_set_dscp() to OSMO_SOCK_F_DSCP()

The latter is much more compact than the former.

Change-Id: I2a24c0cbb17fad8ed84297267dcd63730efbc014
---
M src/gb/gprs_ns2_frgre.c
M src/gb/gprs_ns2_udp.c
2 files changed, 4 insertions(+), 21 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/gb/gprs_ns2_frgre.c b/src/gb/gprs_ns2_frgre.c
index f888af2..9391343 100644
--- a/src/gb/gprs_ns2_frgre.c
+++ b/src/gb/gprs_ns2_frgre.c
@@ -589,25 +589,16 @@
 	priv->fd.data = bind;
 	priv->addr = *local;
 	INIT_LLIST_HEAD(&bind->nsvc);
+	priv->dscp = dscp;
 
 	rc = osmo_sock_init_osa_ofd(&priv->fd, SOCK_RAW, IPPROTO_GRE,
 				 local, NULL,
-				 OSMO_SOCK_F_BIND);
+				 OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(priv->dscp));
 	if (rc < 0) {
 		gprs_ns2_free_bind(bind);
 		return rc;
 	}
 
-	if (dscp > 0) {
-		priv->dscp = dscp;
-
-		rc = setsockopt(priv->fd.fd, IPPROTO_IP, IP_TOS,
-				&dscp, sizeof(dscp));
-		if (rc < 0)
-			LOGBIND(bind, LOGL_ERROR, "Failed to set the DSCP to %d with ret(%d) errno(%d)\n",
-				dscp, rc, errno);
-	}
-
 	if (result)
 		*result = bind;
 
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 22d371f..0de207c 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -352,24 +352,16 @@
 	priv->fd.cb = nsip_fd_cb;
 	priv->fd.data = bind;
 	priv->addr = *local;
+	priv->dscp = dscp;
 
 	rc = osmo_sock_init_osa_ofd(&priv->fd, SOCK_DGRAM, IPPROTO_UDP,
 				 local, NULL,
-				 OSMO_SOCK_F_BIND);
+				 OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(priv->dscp));
 	if (rc < 0) {
 		gprs_ns2_free_bind(bind);
 		return rc;
 	}
 
-	if (dscp > 0) {
-		priv->dscp = dscp;
-
-		rc = osmo_sock_set_dscp(priv->fd.fd, dscp);
-		if (rc < 0)
-			LOGBIND(bind, LOGL_ERROR, "Failed to set the DSCP to %d with ret(%d) errno(%d)\n",
-				dscp, rc, errno);
-	}
-
 	/* IPv4: max fragmented payload can be (13 bit) * 8 byte => 65535.
 	 * IPv6: max payload can be 65535 (RFC 2460).
 	 * UDP header = 8 byte */

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2a24c0cbb17fad8ed84297267dcd63730efbc014
Gerrit-Change-Number: 23974
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
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/20210429/5f99c5c2/attachment.htm>


More information about the gerrit-log mailing list