2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-18 18:23:53 +08:00

net: add option to enable error queue packets waking select

Currently, when a socket receives something on the error queue it only wakes up
the socket on select if it is in the "read" list, that is the socket has
something to read. It is useful also to wake the socket if it is in the error
list, which would enable software to wait on error queue packets without waking
up for regular data on the socket. The main use case is for receiving
timestamped transmit packets which return the timestamp to the socket via the
error queue. This enables an application to select on the socket for the error
queue only instead of for the regular traffic.

-v2-
* Added the SO_SELECT_ERR_QUEUE socket option to every architechture specific file
* Modified every socket poll function that checks error queue

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Cc: Jeffrey Kirsher <jeffrey.t.kirsher@intel.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Matthew Vick <matthew.vick@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Keller, Jacob E 2013-03-28 11:19:25 +00:00 committed by David S. Miller
parent 4eb0614825
commit 7d4c04fc17
23 changed files with 53 additions and 6 deletions

View File

@ -79,4 +79,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _UAPI_ASM_SOCKET_H */

View File

@ -72,4 +72,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* __ASM_AVR32_SOCKET_H */

View File

@ -74,6 +74,8 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _ASM_SOCKET_H */

View File

@ -72,5 +72,7 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _ASM_SOCKET_H */

View File

@ -72,4 +72,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _ASM_SOCKET_H */

View File

@ -81,4 +81,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _ASM_IA64_SOCKET_H */

View File

@ -72,4 +72,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _ASM_M32R_SOCKET_H */

View File

@ -90,4 +90,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _UAPI_ASM_SOCKET_H */

View File

@ -72,4 +72,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _ASM_SOCKET_H */

View File

@ -71,6 +71,8 @@
#define SO_LOCK_FILTER 0x4025
#define SO_SELECT_ERR_QUEUE 0x4026
/* O_NONBLOCK clashes with the bits used for socket types. Therefore we
* have to define SOCK_NONBLOCK to a different value here.
*/

View File

@ -79,4 +79,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _ASM_POWERPC_SOCKET_H */

View File

@ -78,4 +78,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _ASM_SOCKET_H */

View File

@ -68,6 +68,8 @@
#define SO_LOCK_FILTER 0x0028
#define SO_SELECT_ERR_QUEUE 0x0029
/* Security levels - as per NRL IPv6 - don't actually do anything */
#define SO_SECURITY_AUTHENTICATION 0x5001
#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002

View File

@ -83,4 +83,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* _XTENSA_SOCKET_H */

View File

@ -667,6 +667,7 @@ enum sock_flags {
* user-space instead.
*/
SOCK_FILTER_LOCKED, /* Filter cannot be changed anymore */
SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */
};
static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)

View File

@ -74,4 +74,6 @@
#define SO_LOCK_FILTER 44
#define SO_SELECT_ERR_QUEUE 45
#endif /* __ASM_GENERIC_SOCKET_H */

View File

@ -422,7 +422,8 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock,
return bt_accept_poll(sk);
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP | POLLIN | POLLRDNORM;

View File

@ -749,7 +749,9 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
/* exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP | POLLIN | POLLRDNORM;
if (sk->sk_shutdown == SHUTDOWN_MASK)

View File

@ -907,6 +907,10 @@ set_rcvbuf:
sock_valbool_flag(sk, SOCK_NOFCS, valbool);
break;
case SO_SELECT_ERR_QUEUE:
sock_valbool_flag(sk, SOCK_SELECT_ERR_QUEUE, valbool);
break;
default:
ret = -ENOPROTOOPT;
break;
@ -1160,6 +1164,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
v.val = sock_flag(sk, SOCK_FILTER_LOCKED);
break;
case SO_SELECT_ERR_QUEUE:
v.val = sock_flag(sk, SOCK_SELECT_ERR_QUEUE);
break;
default:
return -ENOPROTOOPT;
}

View File

@ -1461,7 +1461,8 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
return iucv_accept_poll(sk);
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP;

View File

@ -521,7 +521,8 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock,
return llcp_accept_poll(sk);
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
if (!skb_queue_empty(&sk->sk_receive_queue))
mask |= POLLIN | POLLRDNORM;

View File

@ -6185,7 +6185,8 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
/* Is there any exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP | POLLIN | POLLRDNORM;
if (sk->sk_shutdown == SHUTDOWN_MASK)

View File

@ -2196,7 +2196,9 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
/* exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP | POLLIN | POLLRDNORM;
if (sk->sk_shutdown == SHUTDOWN_MASK)