patch-2.4.22 linux-2.4.22/net/atm/proc.c
Next file: linux-2.4.22/net/atm/pvc.c
Previous file: linux-2.4.22/net/atm/pppoatm.c
Back to the patch index
Back to the overall index
- Lines: 299
- Date:
2003-08-25 04:44:44.000000000 -0700
- Orig file:
linux-2.4.21/net/atm/proc.c
- Orig date:
2003-06-13 07:51:39.000000000 -0700
diff -urN linux-2.4.21/net/atm/proc.c linux-2.4.22/net/atm/proc.c
@@ -39,10 +39,9 @@
#include "common.h" /* atm_proc_init prototype */
#include "signaling.h" /* to get sigd - ugly too */
-#ifdef CONFIG_ATM_CLIP
+#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
#include <net/atmclip.h>
#include "ipcommon.h"
-extern void clip_push(struct atm_vcc *vcc,struct sk_buff *skb);
#endif
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
@@ -85,11 +84,12 @@
add_stats(buf,"0",&dev->stats.aal0);
strcat(buf," ");
add_stats(buf,"5",&dev->stats.aal5);
+ sprintf(strchr(buf,0), "\t[%d]", atomic_read(&dev->refcnt));
strcat(buf,"\n");
}
-#ifdef CONFIG_ATM_CLIP
+#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
static int svc_addr(char *buf,struct sockaddr_atmsvc *addr)
@@ -162,7 +162,7 @@
#endif
-static void pvc_info(struct atm_vcc *vcc,char *buf)
+static void pvc_info(struct atm_vcc *vcc, char *buf, int clip_info)
{
static const char *class_name[] = { "off","UBR","CBR","VBR","ABR" };
static const char *aal_name[] = {
@@ -178,16 +178,18 @@
aal_name[vcc->qos.aal],vcc->qos.rxtp.min_pcr,
class_name[vcc->qos.rxtp.traffic_class],vcc->qos.txtp.min_pcr,
class_name[vcc->qos.txtp.traffic_class]);
-#ifdef CONFIG_ATM_CLIP
- if (vcc->push == clip_push) {
+#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
+ if (clip_info && (vcc->push == atm_clip_ops->clip_push)) {
struct clip_vcc *clip_vcc = CLIP_VCC(vcc);
struct net_device *dev;
dev = clip_vcc->entry ? clip_vcc->entry->neigh->dev : NULL;
off += sprintf(buf+off,"CLIP, Itf:%s, Encap:",
dev ? dev->name : "none?");
- if (clip_vcc->encap) off += sprintf(buf+off,"LLC/SNAP");
- else off += sprintf(buf+off,"None");
+ if (clip_vcc->encap)
+ off += sprintf(buf+off,"LLC/SNAP");
+ else
+ off += sprintf(buf+off,"None");
}
#endif
strcpy(buf+off,"\n");
@@ -308,16 +310,19 @@
if (!pos) {
return sprintf(buf,"Itf Type ESI/\"MAC\"addr "
- "AAL(TX,err,RX,err,drop) ...\n");
+ "AAL(TX,err,RX,err,drop) ... [refcnt]\n");
}
left = pos-1;
+ spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
if (left-- == 0) {
dev_info(dev,buf);
+ spin_unlock(&atm_dev_lock);
return strlen(buf);
}
}
+ spin_unlock(&atm_dev_lock);
return 0;
}
@@ -328,31 +333,50 @@
static int atm_pvc_info(loff_t pos,char *buf)
{
+ unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct atm_vcc *vcc;
- int left;
+ int left, clip_info = 0;
if (!pos) {
return sprintf(buf,"Itf VPI VCI AAL RX(PCR,Class) "
"TX(PCR,Class)\n");
}
left = pos-1;
+#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
+ if (try_atm_clip_ops())
+ clip_info = 1;
+#endif
+ spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
+ spin_lock_irqsave(&dev->lock, flags);
for (vcc = dev->vccs; vcc; vcc = vcc->next)
- if (vcc->sk->family == PF_ATMPVC &&
- vcc->dev && !left--) {
- pvc_info(vcc,buf);
+ if (vcc->sk->family == PF_ATMPVC && vcc->dev && !left--) {
+ pvc_info(vcc,buf,clip_info);
+ spin_unlock_irqrestore(&dev->lock, flags);
+ spin_unlock(&atm_dev_lock);
+#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
+ if (clip_info)
+ __MOD_DEC_USE_COUNT(atm_clip_ops->owner);
+#endif
return strlen(buf);
}
+ spin_unlock_irqrestore(&dev->lock, flags);
}
+ spin_unlock(&atm_dev_lock);
+#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
+ if (clip_info)
+ __MOD_DEC_USE_COUNT(atm_clip_ops->owner);
+#endif
return 0;
}
static int atm_vc_info(loff_t pos,char *buf)
{
+ unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct atm_vcc *vcc;
@@ -363,19 +387,20 @@
"Address"," Itf VPI VCI Fam Flags Reply Send buffer"
" Recv buffer\n");
left = pos-1;
+ spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
+ spin_lock_irqsave(&dev->lock, flags);
for (vcc = dev->vccs; vcc; vcc = vcc->next)
if (!left--) {
vc_info(vcc,buf);
+ spin_unlock_irqrestore(&dev->lock, flags);
+ spin_unlock(&atm_dev_lock);
return strlen(buf);
}
+ spin_unlock_irqrestore(&dev->lock, flags);
}
- for (vcc = nodev_vccs; vcc; vcc = vcc->next)
- if (!left--) {
- vc_info(vcc,buf);
- return strlen(buf);
- }
+ spin_unlock(&atm_dev_lock);
return 0;
}
@@ -383,6 +408,7 @@
static int atm_svc_info(loff_t pos,char *buf)
{
+ unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct atm_vcc *vcc;
@@ -391,23 +417,25 @@
if (!pos)
return sprintf(buf,"Itf VPI VCI State Remote\n");
left = pos-1;
+ spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
+ spin_lock_irqsave(&dev->lock, flags);
for (vcc = dev->vccs; vcc; vcc = vcc->next)
if (vcc->sk->family == PF_ATMSVC && !left--) {
svc_info(vcc,buf);
+ spin_unlock_irqrestore(&dev->lock, flags);
+ spin_unlock(&atm_dev_lock);
return strlen(buf);
}
+ spin_unlock_irqrestore(&dev->lock, flags);
}
- for (vcc = nodev_vccs; vcc; vcc = vcc->next)
- if (vcc->sk->family == PF_ATMSVC && !left--) {
- svc_info(vcc,buf);
- return strlen(buf);
- }
+ spin_unlock(&atm_dev_lock);
+
return 0;
}
-#ifdef CONFIG_ATM_CLIP
+#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
static int atm_arp_info(loff_t pos,char *buf)
{
struct neighbour *n;
@@ -417,28 +445,33 @@
return sprintf(buf,"IPitf TypeEncp Idle IP address "
"ATM address\n");
}
+ if (!try_atm_clip_ops())
+ return 0;
count = pos;
- read_lock_bh(&clip_tbl.lock);
+ read_lock_bh(&clip_tbl_hook->lock);
for (i = 0; i <= NEIGH_HASHMASK; i++)
- for (n = clip_tbl.hash_buckets[i]; n; n = n->next) {
+ for (n = clip_tbl_hook->hash_buckets[i]; n; n = n->next) {
struct atmarp_entry *entry = NEIGH2ENTRY(n);
struct clip_vcc *vcc;
if (!entry->vccs) {
if (--count) continue;
atmarp_info(n->dev,entry,NULL,buf);
- read_unlock_bh(&clip_tbl.lock);
+ read_unlock_bh(&clip_tbl_hook->lock);
+ __MOD_DEC_USE_COUNT(atm_clip_ops->owner);
return strlen(buf);
}
for (vcc = entry->vccs; vcc;
vcc = vcc->next) {
if (--count) continue;
atmarp_info(n->dev,entry,vcc,buf);
- read_unlock_bh(&clip_tbl.lock);
+ read_unlock_bh(&clip_tbl_hook->lock);
+ __MOD_DEC_USE_COUNT(atm_clip_ops->owner);
return strlen(buf);
}
}
- read_unlock_bh(&clip_tbl.lock);
+ read_unlock_bh(&clip_tbl_hook->lock);
+ __MOD_DEC_USE_COUNT(atm_clip_ops->owner);
return 0;
}
#endif
@@ -599,12 +632,28 @@
name->proc_fops = &proc_spec_atm_operations; \
name->owner = THIS_MODULE
+static struct proc_dir_entry *devices = NULL, *pvc = NULL,
+ *svc = NULL, *arp = NULL, *lec = NULL, *vc = NULL;
-int __init atm_proc_init(void)
+static void atm_proc_cleanup(void)
{
- struct proc_dir_entry *devices = NULL,*pvc = NULL,*svc = NULL;
- struct proc_dir_entry *arp = NULL,*lec = NULL,*vc = NULL;
+ if (devices)
+ remove_proc_entry("devices",atm_proc_root);
+ if (pvc)
+ remove_proc_entry("pvc",atm_proc_root);
+ if (svc)
+ remove_proc_entry("svc",atm_proc_root);
+ if (arp)
+ remove_proc_entry("arp",atm_proc_root);
+ if (lec)
+ remove_proc_entry("lec",atm_proc_root);
+ if (vc)
+ remove_proc_entry("vc",atm_proc_root);
+ remove_proc_entry("net/atm",NULL);
+}
+int atm_proc_init(void)
+{
atm_proc_root = proc_mkdir("net/atm",NULL);
if (!atm_proc_root)
return -ENOMEM;
@@ -612,7 +661,7 @@
CREATE_ENTRY(pvc);
CREATE_ENTRY(svc);
CREATE_ENTRY(vc);
-#ifdef CONFIG_ATM_CLIP
+#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
CREATE_ENTRY(arp);
#endif
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
@@ -621,12 +670,11 @@
return 0;
cleanup:
- if (devices) remove_proc_entry("devices",atm_proc_root);
- if (pvc) remove_proc_entry("pvc",atm_proc_root);
- if (svc) remove_proc_entry("svc",atm_proc_root);
- if (arp) remove_proc_entry("arp",atm_proc_root);
- if (lec) remove_proc_entry("lec",atm_proc_root);
- if (vc) remove_proc_entry("vc",atm_proc_root);
- remove_proc_entry("net/atm",NULL);
+ atm_proc_cleanup();
return -ENOMEM;
}
+
+void atm_proc_exit(void)
+{
+ atm_proc_cleanup();
+}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)