aboutsummaryrefslogtreecommitdiffstats
path: root/net/phonet
diff options
context:
space:
mode:
Diffstat (limited to 'net/phonet')
-rw-r--r--net/phonet/datagram.c5
-rw-r--r--net/phonet/pep-gprs.c4
-rw-r--r--net/phonet/pep.c7
-rw-r--r--net/phonet/pn_dev.c10
-rw-r--r--net/phonet/socket.c96
5 files changed, 117 insertions, 5 deletions
diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c
index e087862ed7e4..ef5c75c372e4 100644
--- a/net/phonet/datagram.c
+++ b/net/phonet/datagram.c
@@ -159,8 +159,11 @@ 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 if (err < 0) {
163 kfree_skb(skb); 163 kfree_skb(skb);
164 if (err == -ENOMEM)
165 atomic_inc(&sk->sk_drops);
166 }
164 return err ? NET_RX_DROP : NET_RX_SUCCESS; 167 return err ? NET_RX_DROP : NET_RX_SUCCESS;
165} 168}
166 169
diff --git a/net/phonet/pep-gprs.c b/net/phonet/pep-gprs.c
index 480839dfc560..4667af51ed71 100644
--- a/net/phonet/pep-gprs.c
+++ b/net/phonet/pep-gprs.c
@@ -195,7 +195,7 @@ static int gprs_xmit(struct sk_buff *skb, struct net_device *dev)
195 break; 195 break;
196 default: 196 default:
197 dev_kfree_skb(skb); 197 dev_kfree_skb(skb);
198 return 0; 198 return NETDEV_TX_OK;
199 } 199 }
200 200
201 skb_orphan(skb); 201 skb_orphan(skb);
@@ -215,7 +215,7 @@ static int gprs_xmit(struct sk_buff *skb, struct net_device *dev)
215 netif_stop_queue(dev); 215 netif_stop_queue(dev);
216 if (pep_writeable(sk)) 216 if (pep_writeable(sk))
217 netif_wake_queue(dev); 217 netif_wake_queue(dev);
218 return 0; 218 return NETDEV_TX_OK;
219} 219}
220 220
221static int gprs_set_mtu(struct net_device *dev, int new_mtu) 221static int gprs_set_mtu(struct net_device *dev, int new_mtu)
diff --git a/net/phonet/pep.c b/net/phonet/pep.c
index eef833ea6d7b..b8252d289cd7 100644
--- a/net/phonet/pep.c
+++ b/net/phonet/pep.c
@@ -346,8 +346,10 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
346 break; 346 break;
347 347
348 case PNS_PEP_CTRL_REQ: 348 case PNS_PEP_CTRL_REQ:
349 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) 349 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
350 atomic_inc(&sk->sk_drops);
350 break; 351 break;
352 }
351 __skb_pull(skb, 4); 353 __skb_pull(skb, 4);
352 queue = &pn->ctrlreq_queue; 354 queue = &pn->ctrlreq_queue;
353 goto queue; 355 goto queue;
@@ -358,10 +360,13 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
358 err = sock_queue_rcv_skb(sk, skb); 360 err = sock_queue_rcv_skb(sk, skb);
359 if (!err) 361 if (!err)
360 return 0; 362 return 0;
363 if (err == -ENOMEM)
364 atomic_inc(&sk->sk_drops);
361 break; 365 break;
362 } 366 }
363 367
364 if (pn->rx_credits == 0) { 368 if (pn->rx_credits == 0) {
369 atomic_inc(&sk->sk_drops);
365 err = -ENOBUFS; 370 err = -ENOBUFS;
366 break; 371 break;
367 } 372 }
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index b0d6ddd82a9d..5ae4c01e8388 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -27,6 +27,7 @@
27#include <linux/net.h> 27#include <linux/net.h>
28#include <linux/netdevice.h> 28#include <linux/netdevice.h>
29#include <linux/phonet.h> 29#include <linux/phonet.h>
30#include <linux/proc_fs.h>
30#include <net/sock.h> 31#include <net/sock.h>
31#include <net/netns/generic.h> 32#include <net/netns/generic.h>
32#include <net/phonet/pn_dev.h> 33#include <net/phonet/pn_dev.h>
@@ -96,7 +97,7 @@ struct net_device *phonet_device_get(struct net *net)
96{ 97{
97 struct phonet_device_list *pndevs = phonet_device_list(net); 98 struct phonet_device_list *pndevs = phonet_device_list(net);
98 struct phonet_device *pnd; 99 struct phonet_device *pnd;
99 struct net_device *dev; 100 struct net_device *dev = NULL;
100 101
101 spin_lock_bh(&pndevs->lock); 102 spin_lock_bh(&pndevs->lock);
102 list_for_each_entry(pnd, &pndevs->list, list) { 103 list_for_each_entry(pnd, &pndevs->list, list) {
@@ -218,6 +219,11 @@ static int phonet_init_net(struct net *net)
218 if (!pnn) 219 if (!pnn)
219 return -ENOMEM; 220 return -ENOMEM;
220 221
222 if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) {
223 kfree(pnn);
224 return -ENOMEM;
225 }
226
221 INIT_LIST_HEAD(&pnn->pndevs.list); 227 INIT_LIST_HEAD(&pnn->pndevs.list);
222 spin_lock_init(&pnn->pndevs.lock); 228 spin_lock_init(&pnn->pndevs.lock);
223 net_assign_generic(net, phonet_net_id, pnn); 229 net_assign_generic(net, phonet_net_id, pnn);
@@ -233,6 +239,8 @@ static void phonet_exit_net(struct net *net)
233 for_each_netdev(net, dev) 239 for_each_netdev(net, dev)
234 phonet_device_destroy(dev); 240 phonet_device_destroy(dev);
235 rtnl_unlock(); 241 rtnl_unlock();
242
243 proc_net_remove(net, "phonet");
236 kfree(pnn); 244 kfree(pnn);
237} 245}
238 246
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index ada2a35bf7a2..aa1617a7f265 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -412,3 +412,99 @@ found:
412 return 0; 412 return 0;
413} 413}
414EXPORT_SYMBOL(pn_sock_get_port); 414EXPORT_SYMBOL(pn_sock_get_port);
415
416static struct sock *pn_sock_get_idx(struct seq_file *seq, loff_t pos)
417{
418 struct net *net = seq_file_net(seq);
419 struct hlist_node *node;
420 struct sock *sknode;
421
422 sk_for_each(sknode, node, &pnsocks.hlist) {
423 if (!net_eq(net, sock_net(sknode)))
424 continue;
425 if (!pos)
426 return sknode;
427 pos--;
428 }
429 return NULL;
430}
431
432static struct sock *pn_sock_get_next(struct seq_file *seq, struct sock *sk)
433{
434 struct net *net = seq_file_net(seq);
435
436 do
437 sk = sk_next(sk);
438 while (sk && !net_eq(net, sock_net(sk)));
439
440 return sk;
441}
442
443static void *pn_sock_seq_start(struct seq_file *seq, loff_t *pos)
444 __acquires(pnsocks.lock)
445{
446 spin_lock_bh(&pnsocks.lock);
447 return *pos ? pn_sock_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
448}
449
450static void *pn_sock_seq_next(struct seq_file *seq, void *v, loff_t *pos)
451{
452 struct sock *sk;
453
454 if (v == SEQ_START_TOKEN)
455 sk = pn_sock_get_idx(seq, 0);
456 else
457 sk = pn_sock_get_next(seq, v);
458 (*pos)++;
459 return sk;
460}
461
462static void pn_sock_seq_stop(struct seq_file *seq, void *v)
463 __releases(pnsocks.lock)
464{
465 spin_unlock_bh(&pnsocks.lock);
466}
467
468static int pn_sock_seq_show(struct seq_file *seq, void *v)
469{
470 int len;
471
472 if (v == SEQ_START_TOKEN)
473 seq_printf(seq, "%s%n", "pt loc rem rs st tx_queue rx_queue "
474 " uid inode ref pointer drops", &len);
475 else {
476 struct sock *sk = v;
477 struct pn_sock *pn = pn_sk(sk);
478
479 seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu "
480 "%d %p %d%n",
481 sk->sk_protocol, pn->sobject, 0, pn->resource,
482 sk->sk_state,
483 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
484 sock_i_uid(sk), sock_i_ino(sk),
485 atomic_read(&sk->sk_refcnt), sk,
486 atomic_read(&sk->sk_drops), &len);
487 }
488 seq_printf(seq, "%*s\n", 127 - len, "");
489 return 0;
490}
491
492static const struct seq_operations pn_sock_seq_ops = {
493 .start = pn_sock_seq_start,
494 .next = pn_sock_seq_next,
495 .stop = pn_sock_seq_stop,
496 .show = pn_sock_seq_show,
497};
498
499static int pn_sock_open(struct inode *inode, struct file *file)
500{
501 return seq_open(file, &pn_sock_seq_ops);
502}
503
504const struct file_operations pn_sock_seq_fops = {
505 .owner = THIS_MODULE,
506 .open = pn_sock_open,
507 .read = seq_read,
508 .llseek = seq_lseek,
509 .release = seq_release,
510};