diff options
Diffstat (limited to 'include/net/sock.h')
| -rw-r--r-- | include/net/sock.h | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 982b4ecd187b..6961700ff3a0 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
| @@ -493,6 +493,7 @@ extern void sk_stream_kill_queues(struct sock *sk); | |||
| 493 | extern int sk_wait_data(struct sock *sk, long *timeo); | 493 | extern int sk_wait_data(struct sock *sk, long *timeo); |
| 494 | 494 | ||
| 495 | struct request_sock_ops; | 495 | struct request_sock_ops; |
| 496 | struct timewait_sock_ops; | ||
| 496 | 497 | ||
| 497 | /* Networking protocol blocks we attach to sockets. | 498 | /* Networking protocol blocks we attach to sockets. |
| 498 | * socket layer -> transport layer interface | 499 | * socket layer -> transport layer interface |
| @@ -557,11 +558,10 @@ struct proto { | |||
| 557 | kmem_cache_t *slab; | 558 | kmem_cache_t *slab; |
| 558 | unsigned int obj_size; | 559 | unsigned int obj_size; |
| 559 | 560 | ||
| 560 | kmem_cache_t *twsk_slab; | ||
| 561 | unsigned int twsk_obj_size; | ||
| 562 | atomic_t *orphan_count; | 561 | atomic_t *orphan_count; |
| 563 | 562 | ||
| 564 | struct request_sock_ops *rsk_prot; | 563 | struct request_sock_ops *rsk_prot; |
| 564 | struct timewait_sock_ops *twsk_prot; | ||
| 565 | 565 | ||
| 566 | struct module *owner; | 566 | struct module *owner; |
| 567 | 567 | ||
| @@ -926,6 +926,29 @@ static inline void sock_put(struct sock *sk) | |||
| 926 | sk_free(sk); | 926 | sk_free(sk); |
| 927 | } | 927 | } |
| 928 | 928 | ||
| 929 | static inline int sk_receive_skb(struct sock *sk, struct sk_buff *skb) | ||
| 930 | { | ||
| 931 | int rc = NET_RX_SUCCESS; | ||
| 932 | |||
| 933 | if (sk_filter(sk, skb, 0)) | ||
| 934 | goto discard_and_relse; | ||
| 935 | |||
| 936 | skb->dev = NULL; | ||
| 937 | |||
| 938 | bh_lock_sock(sk); | ||
| 939 | if (!sock_owned_by_user(sk)) | ||
| 940 | rc = sk->sk_backlog_rcv(sk, skb); | ||
| 941 | else | ||
| 942 | sk_add_backlog(sk, skb); | ||
| 943 | bh_unlock_sock(sk); | ||
| 944 | out: | ||
| 945 | sock_put(sk); | ||
| 946 | return rc; | ||
| 947 | discard_and_relse: | ||
| 948 | kfree_skb(skb); | ||
| 949 | goto out; | ||
| 950 | } | ||
| 951 | |||
| 929 | /* Detach socket from process context. | 952 | /* Detach socket from process context. |
| 930 | * Announce socket dead, detach it from wait queue and inode. | 953 | * Announce socket dead, detach it from wait queue and inode. |
| 931 | * Note that parent inode held reference count on this struct sock, | 954 | * Note that parent inode held reference count on this struct sock, |
| @@ -1166,7 +1189,10 @@ static inline int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb) | |||
| 1166 | 1189 | ||
| 1167 | static inline int sock_error(struct sock *sk) | 1190 | static inline int sock_error(struct sock *sk) |
| 1168 | { | 1191 | { |
| 1169 | int err = xchg(&sk->sk_err, 0); | 1192 | int err; |
| 1193 | if (likely(!sk->sk_err)) | ||
| 1194 | return 0; | ||
| 1195 | err = xchg(&sk->sk_err, 0); | ||
| 1170 | return -err; | 1196 | return -err; |
| 1171 | } | 1197 | } |
| 1172 | 1198 | ||
