Skip to content
Permalink
Browse files

net: socket: Add SO_PRIORITY support to setsockopt

Allow user to set the socket priority using setsockopt() call.
The priority value is used to order the networking queues so
that packets with a higher priority may be processed first.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information...
jukkar committed May 30, 2019
1 parent 1040141 commit c3bb0a6af9e6ab3ddc7cb8503979e75f08f9c4e5
Showing with 19 additions and 0 deletions.
  1. +3 −0 include/net/socket.h
  2. +16 −0 subsys/net/lib/sockets/sockets.c
@@ -740,6 +740,9 @@ static inline char *inet_ntop(sa_family_t family, const void *src, char *dst,
/** sockopt: Don't support IPv4 access (ignored, for compatibility) */
#define IPV6_V6ONLY 26

/** sockopt: Socket priority */
#define SO_PRIORITY 12

/** @cond INTERNAL_HIDDEN */
/**
* @brief Registration information for a given BSD socket family.
@@ -1116,6 +1116,8 @@ int zsock_getsockopt(int sock, int level, int optname,
int zsock_setsockopt_ctx(struct net_context *ctx, int level, int optname,
const void *optval, socklen_t optlen)
{
int ret;

switch (level) {
case SOL_SOCKET:
switch (optname) {
@@ -1124,7 +1126,21 @@ int zsock_setsockopt_ctx(struct net_context *ctx, int level, int optname,
* existing apps.
*/
return 0;

case SO_PRIORITY:
if (IS_ENABLED(CONFIG_NET_CONTEXT_PRIORITY)) {
ret = net_context_set_option(ctx,
NET_OPT_PRIORITY,
optval, optlen);
if (ret < 0) {
errno = -ret;
return -1;
}

return 0;
}
}

break;

case IPPROTO_TCP:

0 comments on commit c3bb0a6

Please sign in to comment.
You can’t perform that action at this time.