]> git.baikalelectronics.ru Git - kernel.git/commit
udp: enable MSG_PEEK at non-zero offset
authorsamanthakumar <samanthakumar@google.com>
Tue, 5 Apr 2016 16:41:16 +0000 (12:41 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Apr 2016 20:29:37 +0000 (16:29 -0400)
commita915da8cf0cde8c2b201b5b0762df633aada3bf0
tree4a4d64af861781920b2b4ef6d0e7b4423b787292
parent44fa15a2618b71a382bd536b4b8d323bbaa6c261
udp: enable MSG_PEEK at non-zero offset

Enable peeking at UDP datagrams at the offset specified with socket
option SOL_SOCKET/SO_PEEK_OFF. Peek at any datagram in the queue, up
to the end of the given datagram.

Implement the SO_PEEK_OFF semantics introduced in commit bd88f1a4c767
("sock: Introduce the SO_PEEK_OFF sock option"). Increase the offset
on peek, decrease it on regular reads.

When peeking, always checksum the packet immediately, to avoid
recomputation on subsequent peeks and final read.

The socket lock is not held for the duration of udp_recvmsg, so
peek and read operations can run concurrently. Only the last store
to sk_peek_off is preserved.

Signed-off-by: Sam Kumar <samanthakumar@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
include/net/sock.h
net/core/datagram.c
net/core/sock.c
net/ipv4/af_inet.c
net/ipv4/udp.c
net/ipv6/af_inet6.c
net/ipv6/udp.c