summaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2012-02-21 02:31:34 -0500
committerDavid S. Miller <davem@davemloft.net>2012-02-21 15:03:48 -0500
commitef64a54f6e558155b4f149bb10666b9e914b6c54 (patch)
treebd7adba8d802aff2aaec0f5f2a9e2ba5431cafcc /include/net/sock.h
parentda5ef6e51b327b41180b5d1000c06e8d3595a936 (diff)
sock: Introduce the SO_PEEK_OFF sock option
This one specifies where to start MSG_PEEK-ing queue data from. When set to negative value means that MSG_PEEK works as ususally -- peeks from the head of the queue always. When some bytes are peeked from queue and the peeking offset is non negative it is moved forward so that the next peek will return next portion of data. When non-peeking recvmsg occurs and the peeking offset is non negative is is moved backward so that the next peek will still peek the proper data (i.e. the one that would have been picked if there were no non peeking recv in between). The offset is set using per-proto opteration to let the protocol handle the locking issues and to check whether the peeking offset feature is supported by the protocol the socket belongs to. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 91c1c8baf020..9c0553b9e451 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -357,6 +357,7 @@ struct sock {
357 struct page *sk_sndmsg_page; 357 struct page *sk_sndmsg_page;
358 struct sk_buff *sk_send_head; 358 struct sk_buff *sk_send_head;
359 __u32 sk_sndmsg_off; 359 __u32 sk_sndmsg_off;
360 __s32 sk_peek_off;
360 int sk_write_pending; 361 int sk_write_pending;
361#ifdef CONFIG_SECURITY 362#ifdef CONFIG_SECURITY
362 void *sk_security; 363 void *sk_security;
@@ -373,6 +374,30 @@ struct sock {
373 void (*sk_destruct)(struct sock *sk); 374 void (*sk_destruct)(struct sock *sk);
374}; 375};
375 376
377static inline int sk_peek_offset(struct sock *sk, int flags)
378{
379 if ((flags & MSG_PEEK) && (sk->sk_peek_off >= 0))
380 return sk->sk_peek_off;
381 else
382 return 0;
383}
384
385static inline void sk_peek_offset_bwd(struct sock *sk, int val)
386{
387 if (sk->sk_peek_off >= 0) {
388 if (sk->sk_peek_off >= val)
389 sk->sk_peek_off -= val;
390 else
391 sk->sk_peek_off = 0;
392 }
393}
394
395static inline void sk_peek_offset_fwd(struct sock *sk, int val)
396{
397 if (sk->sk_peek_off >= 0)
398 sk->sk_peek_off += val;
399}
400
376/* 401/*
377 * Hashed lists helper routines 402 * Hashed lists helper routines
378 */ 403 */