aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-10-14 23:40:11 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-14 23:40:11 -0400
commit766e9037cc139ee25ed93ee5ad11e1450c4b99f6 (patch)
tree062702b8edf203a6e91d1e6853ab24989617d758 /net
parent48bccd25df71f4f8177cb800f4b288222eb57761 (diff)
net: sk_drops consolidation
sock_queue_rcv_skb() can update sk_drops itself, removing need for callers to take care of it. This is more consistent since sock_queue_rcv_skb() also reads sk_drops when queueing a skb. This adds sk_drops managment to many protocols that not cared yet. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/sock.c15
-rw-r--r--net/ieee802154/dgram.c1
-rw-r--r--net/ieee802154/raw.c1
-rw-r--r--net/ipv4/raw.c1
-rw-r--r--net/ipv4/udp.c19
-rw-r--r--net/ipv6/raw.c3
-rw-r--r--net/ipv6/udp.c6
-rw-r--r--net/phonet/datagram.c6
-rw-r--r--net/phonet/pep.c2
9 files changed, 20 insertions, 34 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 43ca2c995393..38713aa3faf2 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -274,7 +274,7 @@ static void sock_disable_timestamp(struct sock *sk, int flag)
274 274
275int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 275int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
276{ 276{
277 int err = 0; 277 int err;
278 int skb_len; 278 int skb_len;
279 unsigned long flags; 279 unsigned long flags;
280 struct sk_buff_head *list = &sk->sk_receive_queue; 280 struct sk_buff_head *list = &sk->sk_receive_queue;
@@ -284,17 +284,17 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
284 */ 284 */
285 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= 285 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
286 (unsigned)sk->sk_rcvbuf) { 286 (unsigned)sk->sk_rcvbuf) {
287 err = -ENOMEM; 287 atomic_inc(&sk->sk_drops);
288 goto out; 288 return -ENOMEM;
289 } 289 }
290 290
291 err = sk_filter(sk, skb); 291 err = sk_filter(sk, skb);
292 if (err) 292 if (err)
293 goto out; 293 return err;
294 294
295 if (!sk_rmem_schedule(sk, skb->truesize)) { 295 if (!sk_rmem_schedule(sk, skb->truesize)) {
296 err = -ENOBUFS; 296 atomic_inc(&sk->sk_drops);
297 goto out; 297 return -ENOBUFS;
298 } 298 }
299 299
300 skb->dev = NULL; 300 skb->dev = NULL;
@@ -314,8 +314,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
314 314
315 if (!sock_flag(sk, SOCK_DEAD)) 315 if (!sock_flag(sk, SOCK_DEAD))
316 sk->sk_data_ready(sk, skb_len); 316 sk->sk_data_ready(sk, skb_len);
317out: 317 return 0;
318 return err;
319} 318}
320EXPORT_SYMBOL(sock_queue_rcv_skb); 319EXPORT_SYMBOL(sock_queue_rcv_skb);
321 320
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
index 25ad956a39d8..9aac5aee1575 100644
--- a/net/ieee802154/dgram.c
+++ b/net/ieee802154/dgram.c
@@ -318,7 +318,6 @@ out:
318static int dgram_rcv_skb(struct sock *sk, struct sk_buff *skb) 318static int dgram_rcv_skb(struct sock *sk, struct sk_buff *skb)
319{ 319{
320 if (sock_queue_rcv_skb(sk, skb) < 0) { 320 if (sock_queue_rcv_skb(sk, skb) < 0) {
321 atomic_inc(&sk->sk_drops);
322 kfree_skb(skb); 321 kfree_skb(skb);
323 return NET_RX_DROP; 322 return NET_RX_DROP;
324 } 323 }
diff --git a/net/ieee802154/raw.c b/net/ieee802154/raw.c
index 769c8d138fc3..9c9b85c00033 100644
--- a/net/ieee802154/raw.c
+++ b/net/ieee802154/raw.c
@@ -206,7 +206,6 @@ out:
206static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb) 206static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
207{ 207{
208 if (sock_queue_rcv_skb(sk, skb) < 0) { 208 if (sock_queue_rcv_skb(sk, skb) < 0) {
209 atomic_inc(&sk->sk_drops);
210 kfree_skb(skb); 209 kfree_skb(skb);
211 return NET_RX_DROP; 210 return NET_RX_DROP;
212 } 211 }
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index f18172b07611..39e2a6b8752c 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -292,7 +292,6 @@ static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb)
292 /* Charge it to the socket. */ 292 /* Charge it to the socket. */
293 293
294 if (sock_queue_rcv_skb(sk, skb) < 0) { 294 if (sock_queue_rcv_skb(sk, skb) < 0) {
295 atomic_inc(&sk->sk_drops);
296 kfree_skb(skb); 295 kfree_skb(skb);
297 return NET_RX_DROP; 296 return NET_RX_DROP;
298 } 297 }
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index ee61b3fc4cae..45a8a7e374d8 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1063,25 +1063,22 @@ EXPORT_SYMBOL(udp_lib_unhash);
1063 1063
1064static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 1064static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1065{ 1065{
1066 int is_udplite = IS_UDPLITE(sk); 1066 int rc = sock_queue_rcv_skb(sk, skb);
1067 int rc; 1067
1068 if (rc < 0) {
1069 int is_udplite = IS_UDPLITE(sk);
1068 1070
1069 if ((rc = sock_queue_rcv_skb(sk, skb)) < 0) {
1070 /* Note that an ENOMEM error is charged twice */ 1071 /* Note that an ENOMEM error is charged twice */
1071 if (rc == -ENOMEM) { 1072 if (rc == -ENOMEM)
1072 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS, 1073 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
1073 is_udplite); 1074 is_udplite);
1074 atomic_inc(&sk->sk_drops); 1075 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
1075 } 1076 kfree_skb(skb);
1076 goto drop; 1077 return -1;
1077 } 1078 }
1078 1079
1079 return 0; 1080 return 0;
1080 1081
1081drop:
1082 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
1083 kfree_skb(skb);
1084 return -1;
1085} 1082}
1086 1083
1087/* returns: 1084/* returns:
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index d8375bc7f2d5..fd737efed96c 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -381,8 +381,7 @@ static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
381 } 381 }
382 382
383 /* Charge it to the socket. */ 383 /* Charge it to the socket. */
384 if (sock_queue_rcv_skb(sk,skb)<0) { 384 if (sock_queue_rcv_skb(sk, skb) < 0) {
385 atomic_inc(&sk->sk_drops);
386 kfree_skb(skb); 385 kfree_skb(skb);
387 return NET_RX_DROP; 386 return NET_RX_DROP;
388 } 387 }
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 1f8e2afa4490..b86425b7ea22 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -385,13 +385,11 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
385 goto drop; 385 goto drop;
386 } 386 }
387 387
388 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { 388 if ((rc = sock_queue_rcv_skb(sk, skb)) < 0) {
389 /* Note that an ENOMEM error is charged twice */ 389 /* Note that an ENOMEM error is charged twice */
390 if (rc == -ENOMEM) { 390 if (rc == -ENOMEM)
391 UDP6_INC_STATS_BH(sock_net(sk), 391 UDP6_INC_STATS_BH(sock_net(sk),
392 UDP_MIB_RCVBUFERRORS, is_udplite); 392 UDP_MIB_RCVBUFERRORS, is_udplite);
393 atomic_inc(&sk->sk_drops);
394 }
395 goto drop; 393 goto drop;
396 } 394 }
397 395
diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c
index ef5c75c372e4..67f072e94d00 100644
--- a/net/phonet/datagram.c
+++ b/net/phonet/datagram.c
@@ -159,11 +159,9 @@ out_nofree:
159static int pn_backlog_rcv(struct sock *sk, struct sk_buff *skb) 159static int pn_backlog_rcv(struct sock *sk, struct sk_buff *skb)
160{ 160{
161 int err = sock_queue_rcv_skb(sk, skb); 161 int err = sock_queue_rcv_skb(sk, skb);
162 if (err < 0) { 162
163 if (err < 0)
163 kfree_skb(skb); 164 kfree_skb(skb);
164 if (err == -ENOMEM)
165 atomic_inc(&sk->sk_drops);
166 }
167 return err ? NET_RX_DROP : NET_RX_SUCCESS; 165 return err ? NET_RX_DROP : NET_RX_SUCCESS;
168} 166}
169 167
diff --git a/net/phonet/pep.c b/net/phonet/pep.c
index 5f32d217535b..cbaa1d67d77b 100644
--- a/net/phonet/pep.c
+++ b/net/phonet/pep.c
@@ -360,8 +360,6 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
360 err = sock_queue_rcv_skb(sk, skb); 360 err = sock_queue_rcv_skb(sk, skb);
361 if (!err) 361 if (!err)
362 return 0; 362 return 0;
363 if (err == -ENOMEM)
364 atomic_inc(&sk->sk_drops);
365 break; 363 break;
366 } 364 }
367 365