lkml.org 
[lkml]   [2003]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
Date
From
Subject[PATCH][RFC] 3 net drivers [etherleak]
Hi,

about a discussion about padding of ethernet frames, here are 3 patches
to 3 old popular net drivers that should do the padding:
- eexpress.c
- 3c507.c
- eepro.c

I do not have these old cards handy, it would be nice if someone who has
them, could test the drivers (which should be very easy with them compiled
as modules)

Is this a good solution?

Regards,
Maciej Soltysiak


Here are the 3 little patches:

--- linux/drivers/net/eexpress.c 2002-11-29 00:53:13.000000000 +0100
+++ linux.new/drivers/net/eexpress.c 2003-01-10 13:23:01.000000000 +0100
@@ -660,10 +654,16 @@
#endif

{
- unsigned short length = (ETH_ZLEN < buf->len) ? buf->len :
- ETH_ZLEN;
+ unsigned short length;
unsigned short *data = (unsigned short *)buf->data;

+ if (ETH_ZLEN < buf->len) {
+ length = buf->len;
+ } else {
+ length = ETH_ZLEN;
+ memset(data + buf->len, 0, length - buf->len);
+ }
+
lp->stats.tx_bytes += length;

eexp_hw_tx_pio(dev,data,length);
--- linux/drivers/net/3c507.c 2002-02-25 20:37:58.000000000 +0100
+++ linux.new/drivers/net/3c507.c 2003-01-10 13:02:02.000000000 +0100
@@ -19,6 +19,10 @@
Mark Salazar <leslie@access.digex.net> made the changes for cards with
only 16K packet buffers.

+
+ Maciej Soltysiak: Padding of ethernet frames of length less
+ than ETH_ZLEN (RFC 894, RFC 1042)
+
Things remaining to do:
Verify that the tx and rx buffers don't have fencepost errors.
Move the theory of operation and memory map documentation.
@@ -26,8 +30,8 @@
*/

#define DRV_NAME "3c507"
-#define DRV_VERSION "1.10a"
-#define DRV_RELDATE "11/17/2001"
+#define DRV_VERSION "1.11"
+#define DRV_RELDATE "01/10/2003"

static const char version[] =
DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Donald Becker (becker@scyld.com)\n";
@@ -494,9 +498,16 @@
struct net_local *lp = (struct net_local *) dev->priv;
int ioaddr = dev->base_addr;
unsigned long flags;
- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
+ short length;
unsigned char *buf = skb->data;

+ if (ETH_ZLEN < skb->len) {
+ length = skb->len;
+ } else {
+ length = ETH_ZLEN;
+ memset(buf + skb->len, 0, length - skb->len);
+ }
+
netif_stop_queue (dev);

spin_lock_irqsave (&lp->lock, flags);
--- linux/drivers/net/eepro.c 2002-11-29 00:53:13.000000000 +0100
+++ linux.new/drivers/net/eepro.c 2003-01-10 13:01:55.000000000 +0100
@@ -23,6 +23,8 @@
This is a compatibility hardware problem.

Versions:
+ 0.14 padding of ethernet frames of length less than
+ ETH_ZLEN (01/10/2003)
0.13a in memory shortage, drop packets also in board
(Michael Westermann <mw@microdata-pos.de>, 07/30/2002)
0.13 irq sharing, rewrote probe function, fixed a nasty bug in
@@ -104,7 +106,7 @@
*/

static const char version[] =
- "eepro.c: v0.13 11/08/2001 aris@cathedrallabs.org\n";
+ "eepro.c: v0.14 01/10/2003 aris@cathedrallabs.org\n";

#include <linux/module.h>

@@ -1138,9 +1140,16 @@
spin_lock_irqsave(&lp->lock, flags);

{
- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
+ short length;
unsigned char *buf = skb->data;

+ if (ETH_ZLEN <= skb->len) {
+ length = skb->len
+ } else {
+ length = ETH_ZLEN;
+ memset(buf + skb->len, 0, length - skb->len);
+ }
+
if (hardware_send_packet(dev, buf, length))
/* we won't wake queue here because we're out of space */
lp->stats.tx_dropped++;--- linux/drivers/net/eexpress.c 2002-11-29 00:53:13.000000000 +0100
+++ linux.new/drivers/net/eexpress.c 2003-01-10 13:23:01.000000000 +0100
@@ -660,10 +654,16 @@
#endif

{
- unsigned short length = (ETH_ZLEN < buf->len) ? buf->len :
- ETH_ZLEN;
+ unsigned short length;
unsigned short *data = (unsigned short *)buf->data;

+ if (ETH_ZLEN < buf->len) {
+ length = buf->len;
+ } else {
+ length = ETH_ZLEN;
+ memset(data + buf->len, 0, length - buf->len);
+ }
+
lp->stats.tx_bytes += length;

eexp_hw_tx_pio(dev,data,length);--- linux/drivers/net/3c507.c 2002-02-25 20:37:58.000000000 +0100
+++ linux.new/drivers/net/3c507.c 2003-01-10 13:02:02.000000000 +0100
@@ -19,6 +19,10 @@
Mark Salazar <leslie@access.digex.net> made the changes for cards with
only 16K packet buffers.

+
+ Maciej Soltysiak: Padding of ethernet frames of length less
+ than ETH_ZLEN (RFC 894, RFC 1042)
+
Things remaining to do:
Verify that the tx and rx buffers don't have fencepost errors.
Move the theory of operation and memory map documentation.
@@ -26,8 +30,8 @@
*/

#define DRV_NAME "3c507"
-#define DRV_VERSION "1.10a"
-#define DRV_RELDATE "11/17/2001"
+#define DRV_VERSION "1.11"
+#define DRV_RELDATE "01/10/2003"

static const char version[] =
DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Donald Becker (becker@scyld.com)\n";
@@ -494,9 +498,16 @@
struct net_local *lp = (struct net_local *) dev->priv;
int ioaddr = dev->base_addr;
unsigned long flags;
- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
+ short length;
unsigned char *buf = skb->data;

+ if (ETH_ZLEN < skb->len) {
+ length = skb->len;
+ } else {
+ length = ETH_ZLEN;
+ memset(buf + skb->len, 0, length - skb->len);
+ }
+
netif_stop_queue (dev);

spin_lock_irqsave (&lp->lock, flags);--- linux/drivers/net/eepro.c 2002-11-29 00:53:13.000000000 +0100
+++ linux.new/drivers/net/eepro.c 2003-01-10 13:01:55.000000000 +0100
@@ -23,6 +23,8 @@
This is a compatibility hardware problem.

Versions:
+ 0.14 padding of ethernet frames of length less than
+ ETH_ZLEN (01/10/2003)
0.13a in memory shortage, drop packets also in board
(Michael Westermann <mw@microdata-pos.de>, 07/30/2002)
0.13 irq sharing, rewrote probe function, fixed a nasty bug in
@@ -104,7 +106,7 @@
*/

static const char version[] =
- "eepro.c: v0.13 11/08/2001 aris@cathedrallabs.org\n";
+ "eepro.c: v0.14 01/10/2003 aris@cathedrallabs.org\n";

#include <linux/module.h>

@@ -1138,9 +1140,16 @@
spin_lock_irqsave(&lp->lock, flags);

{
- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
+ short length;
unsigned char *buf = skb->data;

+ if (ETH_ZLEN <= skb->len) {
+ length = skb->len
+ } else {
+ length = ETH_ZLEN;
+ memset(buf + skb->len, 0, length - skb->len);
+ }
+
if (hardware_send_packet(dev, buf, length))
/* we won't wake queue here because we're out of space */
lp->stats.tx_dropped++;
\
 
 \ /
  Last update: 2005-03-22 13:32    [W:0.099 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site