Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 199469
b: refs/heads/master
c: b1faf56
h: refs/heads/master
i:
  199467: 0944e75
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jun 1, 2010
1 parent 6bed2df commit 0292946
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 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: bc284f94f84c3d76e49c6f3df9028c503f9589d9
refs/heads/master: b1faf5666438090a4dc4fceac8502edc7788b7e3
15 changes: 1 addition & 14 deletions trunk/include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -1524,20 +1524,7 @@ extern void sk_stop_timer(struct sock *sk, struct timer_list* timer);

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)
{
/* 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)
return -ENOMEM;
skb_set_owner_r(skb, sk);
skb_queue_tail(&sk->sk_error_queue, skb);
if (!sock_flag(sk, SOCK_DEAD))
sk->sk_data_ready(sk, skb->len);
return 0;
}
extern int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb);

/*
* Recover an error report and clear atomically
Expand Down
30 changes: 28 additions & 2 deletions trunk/net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -2965,6 +2965,34 @@ int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer)
}
EXPORT_SYMBOL_GPL(skb_cow_data);

static void sock_rmem_free(struct sk_buff *skb)
{
struct sock *sk = skb->sk;

atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
}

/*
* Note: We dont mem charge error packets (no sk_forward_alloc changes)
*/
int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
{
if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
(unsigned)sk->sk_rcvbuf)
return -ENOMEM;

skb_orphan(skb);
skb->sk = sk;
skb->destructor = sock_rmem_free;
atomic_add(skb->truesize, &sk->sk_rmem_alloc);

skb_queue_tail(&sk->sk_error_queue, skb);
if (!sock_flag(sk, SOCK_DEAD))
sk->sk_data_ready(sk, skb->len);
return 0;
}
EXPORT_SYMBOL(sock_queue_err_skb);

void skb_tstamp_tx(struct sk_buff *orig_skb,
struct skb_shared_hwtstamps *hwtstamps)
{
Expand Down Expand Up @@ -2997,9 +3025,7 @@ void skb_tstamp_tx(struct sk_buff *orig_skb,
serr->ee.ee_errno = ENOMSG;
serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;

bh_lock_sock(sk);
err = sock_queue_err_skb(sk, skb);
bh_unlock_sock(sk);

if (err)
kfree_skb(skb);
Expand Down
6 changes: 2 additions & 4 deletions trunk/net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,11 +633,9 @@ void __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable)
if (!inet->recverr) {
if (!harderr || sk->sk_state != TCP_ESTABLISHED)
goto out;
} else {
bh_lock_sock(sk);
} else
ip_icmp_error(sk, skb, err, uh->dest, info, (u8 *)(uh+1));
bh_unlock_sock(sk);
}

sk->sk_err = err;
sk->sk_error_report(sk);
out:
Expand Down
6 changes: 2 additions & 4 deletions trunk/net/ipv6/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,9 @@ void __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
if (sk->sk_state != TCP_ESTABLISHED && !np->recverr)
goto out;

if (np->recverr) {
bh_lock_sock(sk);
if (np->recverr)
ipv6_icmp_error(sk, skb, err, uh->dest, ntohl(info), (u8 *)(uh+1));
bh_unlock_sock(sk);
}

sk->sk_err = err;
sk->sk_error_report(sk);
out:
Expand Down

0 comments on commit 0292946

Please sign in to comment.