Change in libosmocore[master]: gprs_ns: Fix another DSCP vs. TOS mistake in old NS code

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
Thu Apr 29 13:55:21 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/23975 )


Change subject: gprs_ns: Fix another DSCP vs. TOS mistake in old NS code
......................................................................

gprs_ns: Fix another DSCP vs. TOS mistake in old NS code

DSCP is a 6-bit value stored in the upper 8 bit of what was used to
be known as TOS.  Let's use the newly introduced OSMO_SOCK_F_DSCP()
to prevent having to worry about this in higher level code.

Change-Id: I6b9848fd0752d99d3df5346313618d5847d64fb8
Related: OS#5136
---
M src/gb/gprs_ns.c
1 file changed, 4 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/75/23975/1

diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index a6ef6d4..f486333 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -2068,7 +2068,8 @@
 		    osmo_sock_init2_ofd(&nsi->nsip.fd, AF_INET, SOCK_DGRAM,
 					IPPROTO_UDP, inet_ntoa(in),
 					nsi->nsip.local_port, remote_str,
-					nsi->nsip.remote_port, OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT);
+					nsi->nsip.remote_port, OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT |
+					OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(nsi->nsip.dscp));
 
 		LOGP(DNS, LOGL_NOTICE,
 		     "Listening for nsip packets from %s:%u on %s:%u\n",
@@ -2076,7 +2077,8 @@
 	} else {
 		/* Accept UDP packets from any source IP/Port */
 		ret = osmo_sock_init_ofd(&nsi->nsip.fd, AF_INET, SOCK_DGRAM,
-					 IPPROTO_UDP, inet_ntoa(in), nsi->nsip.local_port, OSMO_SOCK_F_BIND);
+					 IPPROTO_UDP, inet_ntoa(in), nsi->nsip.local_port,
+					 OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(nsi->nsip.dscp));
 
 		LOGP(DNS, LOGL_NOTICE, "Listening for nsip packets on %s:%u\n", inet_ntoa(in), nsi->nsip.local_port);
 	}
@@ -2087,13 +2089,6 @@
 		return ret;
 	}
 
-	ret = setsockopt(nsi->nsip.fd.fd, IPPROTO_IP, IP_TOS,
-				&nsi->nsip.dscp, sizeof(nsi->nsip.dscp));
-	if (ret < 0)
-		LOGP(DNS, LOGL_ERROR,
-			"Failed to set the DSCP to %d with ret(%d) errno(%d)\n",
-			nsi->nsip.dscp, ret, errno);
-
 	LOGP(DNS, LOGL_NOTICE, "NS UDP socket at %s:%d\n", inet_ntoa(in), nsi->nsip.local_port);
 
 	return ret;

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6b9848fd0752d99d3df5346313618d5847d64fb8
Gerrit-Change-Number: 23975
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/20210429/4b313c9b/attachment.htm>


More information about the gerrit-log mailing list