Commit c3bb0a6a authored by Jukka Rissanen's avatar Jukka Rissanen
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: default avatarJukka Rissanen <jukka.rissanen@linux.intel.com>
parent 10401415
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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.
+16 −0
Original line number Diff line number Diff line
@@ -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: