pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-netif/+/38894?usp=email )
Change subject: stream_cli: Add osmo_stream_srv_link_set_{ip_dscp,priority}() APIs
......................................................................
stream_cli: Add osmo_stream_srv_link_set_{ip_dscp,priority}() APIs
Change-Id: Iacb6b72a05055820253eaaa04850637dd2fc20e9
---
M TODO-RELEASE
M include/osmocom/netif/stream.h
M src/stream_srv.c
3 files changed, 48 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/94/38894/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 15f995e..4f59788 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,4 +7,4 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
-libosmo-netif add API osmo_stream_cli_set_{ip_dscp,priority}()
+libosmo-netif add API osmo_stream_cli_set_{ip_dscp,priority}(),
osmo_stream_srv_link_set_{ip_dscp,priority}()
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index 96d8bbf..6edf915 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -70,6 +70,8 @@
void osmo_stream_srv_link_set_name(struct osmo_stream_srv_link *link, const char *name);
const char *osmo_stream_srv_link_get_name(const struct osmo_stream_srv_link *link);
void osmo_stream_srv_link_set_nodelay(struct osmo_stream_srv_link *link, bool nodelay);
+int osmo_stream_srv_link_set_priority(struct osmo_stream_srv_link *link, int sk_prio);
+int osmo_stream_srv_link_set_ip_dscp(struct osmo_stream_srv_link *link, uint8_t
ip_dscp);
void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr);
int osmo_stream_srv_link_set_addrs(struct osmo_stream_srv_link *link, const char **addr,
size_t addrcnt);
void osmo_stream_srv_link_set_port(struct osmo_stream_srv_link *link, uint16_t port);
diff --git a/src/stream_srv.c b/src/stream_srv.c
index a600ad9..ced0e05 100644
--- a/src/stream_srv.c
+++ b/src/stream_srv.c
@@ -148,6 +148,24 @@
goto error_close_socket;
}
+ if (link->ip_dscp > 0) {
+ ret = osmo_sock_set_dscp(sock_fd, link->ip_dscp);
+ if (ret < 0) {
+ LOGSLNK(link, LOGL_ERROR, "set_ip_dscp(%u): failed setsockopt err=%d\n",
+ link->ip_dscp, errno);
+ goto error_close_socket;
+ }
+ }
+
+ if (link->sk_prio > 0) {
+ ret = osmo_sock_set_priority(sock_fd, link->sk_prio);
+ if (ret < 0) {
+ LOGSLNK(link, LOGL_ERROR, "set_priority(%u): failed setsockopt err=%d\n",
+ link->sk_prio, errno);
+ goto error_close_socket;
+ }
+ }
+
if (!link->accept_cb) {
ret = -ENOTSUP;
goto error_close_socket;
@@ -224,6 +242,33 @@
link->flags &= ~OSMO_STREAM_SRV_F_NODELAY;
}
+/*! Set the priority value of the stream socket.
+ * Setting this will automatically set the socket priority
+ * option on any socket established via this server link, before
+ * calling the accept_cb().
+ * \param[in] link server link whose sockets are to be configured
+ * \param[in] sk_prio priority value. Values outside 0..6 require CAP_NET_ADMIN.
+ * \return negative on error, 0 on success
+ */
+int osmo_stream_srv_link_set_priority(struct osmo_stream_srv_link *link, int sk_prio)
+{
+ link->sk_prio = sk_prio;
+ return 0;
+}
+
+/*! Set the DSCP (differentiated services code point) of the stream socket.
+ * Setting this will automatically set the IP DSCP option on any socket on any
+ * socket established via this server link, before calling the accept_cb().
+ * \param[in] link server link whose sockets are to be configured
+ * \param[in] ip_dscp DSCP value. Value range 0..63.
+ * \return negative on error, 0 on success
+ */
+int osmo_stream_srv_link_set_ip_dscp(struct osmo_stream_srv_link *link, uint8_t ip_dscp)
+{
+ link->ip_dscp = ip_dscp;
+ return 0;
+}
+
/*! Set the local address to which we bind.
* Any changes to this setting will only become active upon next (re)connect.
* \param[in] link Stream Server Link to modify
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-netif/+/38894?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Iacb6b72a05055820253eaaa04850637dd2fc20e9
Gerrit-Change-Number: 38894
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>