Change in libosmocore[master]: socket: Introduce osmo_sock_set_priority() helper function

laforge gerrit-no-reply at lists.osmocom.org
Wed Apr 28 12:38:16 UTC 2021


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

Change subject: socket: Introduce osmo_sock_set_priority() helper function
......................................................................

socket: Introduce osmo_sock_set_priority() helper function

In some situations we want to set the SO_PRIORITY socket option
to determine the in-kernel priority of packets generated by this
socket.

Change-Id: I89abffcd125e6d073338a5c6437b9433220e1823
Related: SYS#5427
---
M include/osmocom/core/socket.h
M src/socket.c
2 files changed, 9 insertions(+), 0 deletions(-)

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



diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h
index 92cd202..10e1766 100644
--- a/include/osmocom/core/socket.h
+++ b/include/osmocom/core/socket.h
@@ -123,6 +123,7 @@
 			       const struct osmo_sockaddr *sockaddr);
 
 int osmo_sock_set_dscp(int fd, uint8_t dscp);
+int osmo_sock_set_priority(int fd, int prio);
 
 #endif /* (!EMBEDDED) */
 /*! @} */
diff --git a/src/socket.c b/src/socket.c
index 095dee6..6b8c34a 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -1802,6 +1802,14 @@
 	return setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
 }
 
+/*! Set the priority value of a socket.
+ *  \param[in] prio priority value. Values outside 0..6 require CAP_NET_ADMIN.
+ *  \returns 0 on success; negative on error. */
+int osmo_sock_set_priority(int fd, int prio)
+{
+	/* and write it back to the kernel */
+	return setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio));
+}
 
 #endif /* HAVE_SYS_SOCKET_H */
 

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I89abffcd125e6d073338a5c6437b9433220e1823
Gerrit-Change-Number: 23922
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
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/3c867de0/attachment.htm>


More information about the gerrit-log mailing list