linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/1] s390: qeth network driver fix.
@ 2004-12-01 15:49 Heiko Carstens
  0 siblings, 0 replies; only message in thread
From: Heiko Carstens @ 2004-12-01 15:49 UTC (permalink / raw)
  To: akpm; +Cc: tspat, linux-kernel

Hi Andrew,

Thomas created the patch below which removes the hardcoded 3900 bytes
limit as suggested by Jeff Garzik. Please apply.

Thanks,
Heiko

-----

[patch 1/1] s390: qeth network driver fix.

From: Thomas Spatzier <tspat@de.ibm.com>

network driver changes:
 - qeth: Calculate end of sysfs data buffer correctly.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>

diffstat:
 drivers/s390/net/qeth_sys.c |   69 +++++++++++++++++++++-----------------------
 1 files changed, 34 insertions(+), 35 deletions(-)

diff -urN linux-2.6/drivers/s390/net/qeth_sys.c linux-2.6-patched/drivers/s390/net/qeth_sys.c
--- linux-2.6/drivers/s390/net/qeth_sys.c	2004-12-01 15:39:54.000000000 +0100
+++ linux-2.6-patched/drivers/s390/net/qeth_sys.c	2004-12-01 15:39:54.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  *
- * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.38 $)
+ * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.40 $)
  *
  * Linux on zSeries OSA Express and HiperSockets support
  * This file contains code related to sysfs.
@@ -20,7 +20,7 @@
 #include "qeth_mpc.h"
 #include "qeth_fs.h"
 
-const char *VERSION_QETH_SYS_C = "$Revision: 1.38 $";
+const char *VERSION_QETH_SYS_C = "$Revision: 1.40 $";
 
 /*****************************************************************************/
 /*                                                                           */
@@ -876,30 +876,31 @@
 {
 	struct qeth_ipato_entry *ipatoe;
 	unsigned long flags;
-	char addr_str[49];
+	char addr_str[40];
+	int entry_len; /* length of 1 entry string, differs between v4 and v6 */
 	int i = 0;
 
 	if (qeth_check_layer2(card))
 		return -EPERM;
 
+	entry_len = (proto == QETH_PROT_IPV4)? 12 : 40;
+	/* add strlen for "/<mask>\n" */
+	entry_len += (proto == QETH_PROT_IPV4)? 5 : 6;
 	spin_lock_irqsave(&card->ip_lock, flags);
 	list_for_each_entry(ipatoe, &card->ipato.entries, entry){
 		if (ipatoe->proto != proto)
 			continue;
-		/* String must not be longer than PAGE_SIZE. So we check for
-		 * length >= 3900 here. Then we can savely display the next
-		 * IPv6 address and our info message below */
-		if (i >= 3900) {
-			i += sprintf(buf + i,
-				     "... Too many entries to be displayed. "
-				     "Skipping remaining entries.\n");
+		/* String must not be longer than PAGE_SIZE. So we check if
+		 * string length gets near PAGE_SIZE. Then we can savely display
+		 * the next IPv6 address (worst case, compared to IPv4) */
+		if ((PAGE_SIZE - i) <= entry_len)
 			break;
-		}
 		qeth_ipaddr_to_string(proto, ipatoe->addr, addr_str);
-		i += sprintf(buf + i, "%s/%i\n", addr_str, ipatoe->mask_bits);
+		i += snprintf(buf + i, PAGE_SIZE - i,
+			      "%s/%i\n", addr_str, ipatoe->mask_bits);
 	}
 	spin_unlock_irqrestore(&card->ip_lock, flags);
-	i += sprintf(buf + i, "\n");
+	i += snprintf(buf + i, PAGE_SIZE - i, "\n");
 
 	return i;
 }
@@ -1131,33 +1132,32 @@
 			enum qeth_prot_versions proto)
 {
 	struct qeth_ipaddr *ipaddr;
-	char addr_str[49];
+	char addr_str[40];
+	int entry_len; /* length of 1 entry string, differs between v4 and v6 */
 	unsigned long flags;
 	int i = 0;
 
 	if (qeth_check_layer2(card))
 		return -EPERM;
 
+	entry_len = (proto == QETH_PROT_IPV4)? 12 : 40;
+	entry_len += 2; /* \n + terminator */
 	spin_lock_irqsave(&card->ip_lock, flags);
 	list_for_each_entry(ipaddr, &card->ip_list, entry){
 		if (ipaddr->proto != proto)
 			continue;
 		if (ipaddr->type != QETH_IP_TYPE_VIPA)
 			continue;
-		/* String must not be longer than PAGE_SIZE. So we check for
-		 * length >= 3900 here. Then we can savely display the next
-		 * IPv6 address and our info message below */
-		if (i >= 3900) {
-			i += sprintf(buf + i,
-				     "... Too many entries to be displayed. "
-				     "Skipping remaining entries.\n");
+		/* String must not be longer than PAGE_SIZE. So we check if
+		 * string length gets near PAGE_SIZE. Then we can savely display
+		 * the next IPv6 address (worst case, compared to IPv4) */
+		if ((PAGE_SIZE - i) <= entry_len)
 			break;
-		}
 		qeth_ipaddr_to_string(proto, (const u8 *)&ipaddr->u, addr_str);
-		i += sprintf(buf + i, "%s\n", addr_str);
+		i += snprintf(buf + i, PAGE_SIZE - i, "%s\n", addr_str);
 	}
 	spin_unlock_irqrestore(&card->ip_lock, flags);
-	i += sprintf(buf + i, "\n");
+	i += snprintf(buf + i, PAGE_SIZE - i, "\n");
 
 	return i;
 }
@@ -1313,33 +1313,32 @@
 		       enum qeth_prot_versions proto)
 {
 	struct qeth_ipaddr *ipaddr;
-	char addr_str[49];
+	char addr_str[40];
+	int entry_len; /* length of 1 entry string, differs between v4 and v6 */
 	unsigned long flags;
 	int i = 0;
 
 	if (qeth_check_layer2(card))
 		return -EPERM;
 
+	entry_len = (proto == QETH_PROT_IPV4)? 12 : 40;
+	entry_len += 2; /* \n + terminator */
 	spin_lock_irqsave(&card->ip_lock, flags);
 	list_for_each_entry(ipaddr, &card->ip_list, entry){
 		if (ipaddr->proto != proto)
 			continue;
 		if (ipaddr->type != QETH_IP_TYPE_RXIP)
 			continue;
-		/* String must not be longer than PAGE_SIZE. So we check for
-		 * length >= 3900 here. Then we can savely display the next
-		 * IPv6 address and our info message below */
-		if (i >= 3900) {
-			i += sprintf(buf + i,
-				     "... Too many entries to be displayed. "
-				     "Skipping remaining entries.\n");
+		/* String must not be longer than PAGE_SIZE. So we check if
+		 * string length gets near PAGE_SIZE. Then we can savely display
+		 * the next IPv6 address (worst case, compared to IPv4) */
+		if ((PAGE_SIZE - i) <= entry_len)
 			break;
-		}
 		qeth_ipaddr_to_string(proto, (const u8 *)&ipaddr->u, addr_str);
-		i += sprintf(buf + i, "%s\n", addr_str);
+		i += snprintf(buf + i, PAGE_SIZE - i, "%s\n", addr_str);
 	}
 	spin_unlock_irqrestore(&card->ip_lock, flags);
-	i += sprintf(buf + i, "\n");
+	i += snprintf(buf + i, PAGE_SIZE - i, "\n");
 
 	return i;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-12-01 15:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-01 15:49 [patch 1/1] s390: qeth network driver fix Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).