Skip to contentSkip to conversation

atm: expose ATM device index in sysfs

PATCH Superseded Dan Williams 5 participants 8 messages May 26, 2011 – May 27, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 atm: expose ATM device index in sysfs

It's current exposed only through /proc which besides requiring screen-scraping doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.

---

PS: -> stable too since it's a minimal change with no backwards incompatibility and I'd like to rely on this attribute in NetworkManager

net/atm/atm_sysfs.c +12 -0
index f7fa67c..e5edbde 100644
@@ -59,6 +59,16 @@ static ssize_t show_atmaddress(struct device *cdev,
 	return pos - buf;
 }
 
+static ssize_t show_atmindex(struct device *cdev,
+			     struct device_attribute *attr, char *buf)
+{
+	char *pos = buf;
+	struct atm_dev *adev = to_atm_dev(cdev);
+
+	pos += sprintf(pos, "%d\n", adev->number);
+	return pos - buf;
+}
+
 static ssize_t show_carrier(struct device *cdev,
 			    struct device_attribute *attr, char *buf)
 {
@@ -99,6 +109,7 @@ static ssize_t show_link_rate(struct device *cdev,
 
 static DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
 static DEVICE_ATTR(atmaddress, S_IRUGO, show_atmaddress, NULL);
+static DEVICE_ATTR(atmindex, S_IRUGO, show_atmindex, NULL);
 static DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL);
 static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
 static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);
@@ -106,6 +117,7 @@ static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);
 static struct device_attribute *atm_attrs[] = {
 	&dev_attr_atmaddress,
 	&dev_attr_address,
+	&dev_attr_atmindex,
 	&dev_attr_carrier,
 	&dev_attr_type,
 	&dev_attr_link_rate,
#1 lore raw
Quoted 19 lines · Dan Williams

It's current exposed only through /proc which besides requiring screen-scraping doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.

---

PS: -> stable too since it's a minimal change with no backwards incompatibility and I'd like to rely on this attribute in NetworkManager

net/atm/atm_sysfs.c +0 -0
index f7fa67c..e5edbde 100644
@@ -59,6 +59,16 @@ static ssize_t show_atmaddress(struct device *cdev,
 	return pos - buf;
 }
 

net/atm/atm_sysfs.c static ssize_t show_atmaddress(struct device *cdev, · line 71

Quoted 10 lines
net/atm/atm_sysfs.c +10 -0
+static ssize_t show_atmindex(struct device *cdev,
+			     struct device_attribute *attr, char *buf)
+{
+	char *pos = buf;
+	struct atm_dev *adev = to_atm_dev(cdev);
+
+	pos += sprintf(pos, "%d\n", adev->number);
+	return pos - buf;
+}
+

What about :

{
	struct atm_dev *adev = to_atm_dev(cdev);

	return sprintf(buf, "%d\n", adev->number);
}
#2 lore raw
Quoted 33 lines · Eric Dumazet
Quoted 19 lines · Dan Williams

It's current exposed only through /proc which besides requiring screen-scraping doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.

---

PS: -> stable too since it's a minimal change with no backwards incompatibility and I'd like to rely on this attribute in NetworkManager

net/atm/atm_sysfs.c +0 -0
index f7fa67c..e5edbde 100644
@@ -59,6 +59,16 @@ static ssize_t show_atmaddress(struct device *cdev,
 	return pos - buf;
 }
 

net/atm/atm_sysfs.c static ssize_t show_atmaddress(struct device *cdev, · line 71

Quoted 10 lines
net/atm/atm_sysfs.c +10 -0
+static ssize_t show_atmindex(struct device *cdev,
+			     struct device_attribute *attr, char *buf)
+{
+	char *pos = buf;
+	struct atm_dev *adev = to_atm_dev(cdev);
+
+	pos += sprintf(pos, "%d\n", adev->number);
+	return pos - buf;
+}
+

What about :

Quoted 5 lines
{
	struct atm_dev *adev = to_atm_dev(cdev);

	return sprintf(buf, "%d\n", adev->number);
}

Sure, will send v2.

Dan

#7 lore raw
In reply to Dan Williams
Quoted 10 lines · Dan Williams

It's current exposed only through /proc which besides requiring screen-scraping doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.

---

PS: -> stable too since it's a minimal change with no backwards incompatibility and I'd like to rely on this attribute in NetworkManager

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.

</formletter>

#3 lore raw

PATCH v2 1/1 atm: expose ATM device index in sysfs

In reply to Dan Williams

It's currently exposed only through /proc which, besides requiring screen-scraping, doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.

---

net/atm/atm_sysfs.c +10 -0
index f7fa67c..f49da58 100644
@@ -59,6 +59,14 @@ static ssize_t show_atmaddress(struct device *cdev,
 	return pos - buf;
 }
 
+static ssize_t show_atmindex(struct device *cdev,
+			     struct device_attribute *attr, char *buf)
+{
+	struct atm_dev *adev = to_atm_dev(cdev);
+
+	return sprintf(buf, "%d\n", adev->number);
+}
+
 static ssize_t show_carrier(struct device *cdev,
 			    struct device_attribute *attr, char *buf)
 {
@@ -99,6 +107,7 @@ static ssize_t show_link_rate(struct device *cdev,
 
 static DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
 static DEVICE_ATTR(atmaddress, S_IRUGO, show_atmaddress, NULL);
+static DEVICE_ATTR(atmindex, S_IRUGO, show_atmindex, NULL);
 static DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL);
 static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
 static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);
@@ -106,6 +115,7 @@ static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);
 static struct device_attribute *atm_attrs[] = {
 	&dev_attr_atmaddress,
 	&dev_attr_address,
+	&dev_attr_atmindex,
 	&dev_attr_carrier,
 	&dev_attr_type,
 	&dev_attr_link_rate,
Reviewed-by on v2 1/1
#4 lore raw
Quoted 8 lines · Dan Williams

It's currently exposed only through /proc which, besides requiring screen-scraping, doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.

---

Tested-by
#5 lore raw
Quoted 11 lines · Eric Dumazet
Quoted 8 lines · Dan Williams

It's currently exposed only through /proc which, besides requiring screen-scraping, doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.

---

[root@solos atm]# grep ^ /sys/class/atm/*/atmindex /sys/class/atm/solos-pci0/atmindex:0 /sys/class/atm/solos-pci1/atmindex:1

Signature · 1 line
dwmw2
maintainer Applied
#6 lore raw

From: David Woodhouse <[email protected]>
Date: Fri, 27 May 2011 16:05:41 +0100

Quoted 11 lines · Eric Dumazet
Quoted 10 lines · Dan Williams
Quoted 8 lines

It's currently exposed only through /proc which, besides requiring screen-scraping, doesn't allow userspace to distinguish between two identical ATM adapters with different ATM indexes. The ATM device index is required when using PPPoATM on a system with multiple ATM adapters.

---

Quoted 8 lines
Quoted 1 line

[root@solos atm]# grep ^ /sys/class/atm/*/atmindex /sys/class/atm/solos-pci0/atmindex:0 /sys/class/atm/solos-pci1/atmindex:1

Applied, thanks.