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.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/23934 ) Change subject: socket: QoS support for all our socket init functions ...................................................................... socket: QoS support for all our socket init functions Every socket function that can be passed a 'flags' argument now supports the following two additional macros that can be or-ed in with the flags: * OSMO_SOCK_F_DSCP(x) -- specify the IP DSCP of the socket * OSMO_SOCK_F_PRIO(x) -- specify the priority of the socket The existing osmo_sock_set_{dscp,priority}() functions are useful, but you cannot call them in between the socket creation and the connect() operation when using our socket helpers. This means that the first packet sent will have the default DSCP/priority, and only later packets would have the desired values. When using the functionality introduced by this patch, we can ensure that even the very first packet of e.g. a TCP or SCTP connect() will have the correct DSCP/priority applied. Change-Id: If22988735fe05e51226c6b091a5348dcf1208cdf Related: SYS#5427 --- M include/osmocom/core/socket.h M src/socket.c 2 files changed, 30 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h index 10e1766..a053391 100644 --- a/include/osmocom/core/socket.h +++ b/include/osmocom/core/socket.h @@ -44,6 +44,15 @@ /*! use SO_REUSEADDR on UDP ports (required for multicast) */ #define OSMO_SOCK_F_UDP_REUSEADDR (1 << 5) +/*! use OSMO_SOCK_F_DSCP(x) to set IP DSCP 'x' for packets transmitted on the socket */ +#define OSMO_SOCK_F_DSCP(x) (((x)&0x3f) << 24) +#define GET_OSMO_SOCK_F_DSCP(f) (((f) >> 24) & 0x3f) + +/*! use OSMO_SOCK_F_PRIO(x) to set priority 'x' for packets transmitted on the socket */ +#define OSMO_SOCK_F_PRIO(x) (((x)&0xff) << 16) +#define GET_OSMO_SOCK_F_PRIO(f) (((f) >> 16) & 0xff) + + /*! maximum number of local or remote addresses supported by an osmo_sock instance */ #define OSMO_SOCK_MAX_ADDRS 32 diff --git a/src/socket.c b/src/socket.c index b44bbc6..6afe986 100644 --- a/src/socket.c +++ b/src/socket.c @@ -134,7 +134,9 @@ static int socket_helper_tail(int sfd, unsigned int flags) { - int on = 1; + int rc, on = 1; + uint8_t dscp = GET_OSMO_SOCK_F_DSCP(flags); + uint8_t prio = GET_OSMO_SOCK_F_PRIO(flags); if (flags & OSMO_SOCK_F_NONBLOCK) { if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { @@ -146,6 +148,24 @@ } } + if (dscp) { + rc = osmo_sock_set_dscp(sfd, dscp); + if (rc) { + LOGP(DLGLOBAL, LOGL_ERROR, "cannot set IP DSCP of socket to %u: %s\n", + dscp, strerror(errno)); + /* we consider this a non-fatal error */ + } + } + + if (prio) { + rc = osmo_sock_set_priority(sfd, prio); + if (rc) { + LOGP(DLGLOBAL, LOGL_ERROR, "cannot set priority of socket to %u: %s\n", + prio, strerror(errno)); + /* we consider this a non-fatal error */ + } + } + return 0; } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/23934 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: If22988735fe05e51226c6b091a5348dcf1208cdf Gerrit-Change-Number: 23934 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/79a2f3d5/attachment.htm>