Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24676
b: refs/heads/master
c: f0088a5
h: refs/heads/master
v: v3
  • Loading branch information
Denis Vlasenko authored and David S. Miller committed Mar 29, 2006
1 parent 3f4e46d commit 54b5c3a
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 88 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1d1818316f0b61e0997a159680e1e631a23a407e
refs/heads/master: f0088a50e7c49d1ba285c88fe06345f223652fd3
91 changes: 4 additions & 87 deletions trunk/include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -938,28 +938,7 @@ static inline void sock_put(struct sock *sk)
sk_free(sk);
}

static inline int sk_receive_skb(struct sock *sk, struct sk_buff *skb)
{
int rc = NET_RX_SUCCESS;

if (sk_filter(sk, skb, 0))
goto discard_and_relse;

skb->dev = NULL;

bh_lock_sock(sk);
if (!sock_owned_by_user(sk))
rc = sk->sk_backlog_rcv(sk, skb);
else
sk_add_backlog(sk, skb);
bh_unlock_sock(sk);
out:
sock_put(sk);
return rc;
discard_and_relse:
kfree_skb(skb);
goto out;
}
extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb);

/* Detach socket from process context.
* Announce socket dead, detach it from wait queue and inode.
Expand Down Expand Up @@ -1044,33 +1023,9 @@ sk_dst_reset(struct sock *sk)
write_unlock(&sk->sk_dst_lock);
}

static inline struct dst_entry *
__sk_dst_check(struct sock *sk, u32 cookie)
{
struct dst_entry *dst = sk->sk_dst_cache;

if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
sk->sk_dst_cache = NULL;
dst_release(dst);
return NULL;
}

return dst;
}

static inline struct dst_entry *
sk_dst_check(struct sock *sk, u32 cookie)
{
struct dst_entry *dst = sk_dst_get(sk);
extern struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie);

if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
sk_dst_reset(sk);
dst_release(dst);
return NULL;
}

return dst;
}
extern struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie);

static inline void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
{
Expand Down Expand Up @@ -1140,45 +1095,7 @@ extern void sk_reset_timer(struct sock *sk, struct timer_list* timer,

extern void sk_stop_timer(struct sock *sk, struct timer_list* timer);

static inline int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
{
int err = 0;
int skb_len;

/* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
number of warnings when compiling with -W --ANK
*/
if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
(unsigned)sk->sk_rcvbuf) {
err = -ENOMEM;
goto out;
}

/* It would be deadlock, if sock_queue_rcv_skb is used
with socket lock! We assume that users of this
function are lock free.
*/
err = sk_filter(sk, skb, 1);
if (err)
goto out;

skb->dev = NULL;
skb_set_owner_r(skb, sk);

/* Cache the SKB length before we tack it onto the receive
* queue. Once it is added it no longer belongs to us and
* may be freed by other threads of control pulling packets
* from the queue.
*/
skb_len = skb->len;

skb_queue_tail(&sk->sk_receive_queue, skb);

if (!sock_flag(sk, SOCK_DEAD))
sk->sk_data_ready(sk, skb_len);
out:
return err;
}
extern int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);

static inline int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
{
Expand Down
93 changes: 93 additions & 0 deletions trunk/net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,99 @@ static void sock_disable_timestamp(struct sock *sk)
}


int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
{
int err = 0;
int skb_len;

/* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
number of warnings when compiling with -W --ANK
*/
if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
(unsigned)sk->sk_rcvbuf) {
err = -ENOMEM;
goto out;
}

/* It would be deadlock, if sock_queue_rcv_skb is used
with socket lock! We assume that users of this
function are lock free.
*/
err = sk_filter(sk, skb, 1);
if (err)
goto out;

skb->dev = NULL;
skb_set_owner_r(skb, sk);

/* Cache the SKB length before we tack it onto the receive
* queue. Once it is added it no longer belongs to us and
* may be freed by other threads of control pulling packets
* from the queue.
*/
skb_len = skb->len;

skb_queue_tail(&sk->sk_receive_queue, skb);

if (!sock_flag(sk, SOCK_DEAD))
sk->sk_data_ready(sk, skb_len);
out:
return err;
}
EXPORT_SYMBOL(sock_queue_rcv_skb);

int sk_receive_skb(struct sock *sk, struct sk_buff *skb)
{
int rc = NET_RX_SUCCESS;

if (sk_filter(sk, skb, 0))
goto discard_and_relse;

skb->dev = NULL;

bh_lock_sock(sk);
if (!sock_owned_by_user(sk))
rc = sk->sk_backlog_rcv(sk, skb);
else
sk_add_backlog(sk, skb);
bh_unlock_sock(sk);
out:
sock_put(sk);
return rc;
discard_and_relse:
kfree_skb(skb);
goto out;
}
EXPORT_SYMBOL(sk_receive_skb);

struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie)
{
struct dst_entry *dst = sk->sk_dst_cache;

if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
sk->sk_dst_cache = NULL;
dst_release(dst);
return NULL;
}

return dst;
}
EXPORT_SYMBOL(__sk_dst_check);

struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie)
{
struct dst_entry *dst = sk_dst_get(sk);

if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
sk_dst_reset(sk);
dst_release(dst);
return NULL;
}

return dst;
}
EXPORT_SYMBOL(sk_dst_check);

/*
* This is meant for all protocols to use and covers goings on
* at the socket level. Everything here is generic.
Expand Down

0 comments on commit 54b5c3a

Please sign in to comment.