]> git.pld-linux.org Git - packages/kernel.git/blame - linux-2.4.20-net-padding.patch
- ported from linux-2.4.25-atmdd.patch
[packages/kernel.git] / linux-2.4.20-net-padding.patch
CommitLineData
10679586 1 # CAN-2003-0001 fix
2 (extracted from Debian's patch, with missing sun3_82586 chunk (1.884.35.15),
3 fixed smc9194 change (1.930.9.68) and later davem's skb_padto fix (1.930.17.10);
4 1.1063.1.51 not included here)
5--- kernel-source-2.4.18-2.4.18.orig/drivers/net/3c501.c
6+++ kernel-source-2.4.18-2.4.18/drivers/net/3c501.c
7@@ -35,6 +35,9 @@
8 Cleaned up for 2.3.x because we broke SMP now.
9 20000208 Alan Cox <alan@redhat.com>
10
11+ Fixed zero fill corner case
12+ 20030104 Alan Cox <alan@redhat.com>
13+
14 */
15
16
17@@ -503,8 +506,15 @@
18
19 do
20 {
21- int gp_start = 0x800 - (ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN);
22+ int len = skb->len;
23+ int pad = 0;
24+ int gp_start;
25 unsigned char *buf = skb->data;
26+
27+ if(len < ETH_ZLEN)
28+ pad = ETH_ZLEN - len;
29+
30+ gp_start = 0x800 - ( len + pad );
31
32 lp->tx_pkt_start = gp_start;
33 lp->collisions = 0;
34@@ -532,7 +542,12 @@
35
36 outw(0x00, RX_BUF_CLR); /* Set rx packet area to 0. */
37 outw(gp_start, GP_LOW); /* aim - packet will be loaded into buffer start */
38- outsb(DATAPORT,buf,skb->len); /* load buffer (usual thing each byte increments the pointer) */
39+ outsb(DATAPORT,buf,len); /* load buffer (usual thing each byte increments the pointer) */
40+ if(pad)
41+ {
42+ while(pad--) /* Zero fill buffer tail */
43+ outb(0, DATAPORT);
44+ }
45 outw(gp_start, GP_LOW); /* the board reuses the same register */
46
47 if(lp->loading != 2)
48--- kernel-source-2.4.18-2.4.18.orig/drivers/net/3c505.c
49+++ kernel-source-2.4.18-2.4.18/drivers/net/3c505.c
50@@ -1036,8 +1036,9 @@
51 adapter->current_dma.direction = 1;
52 adapter->current_dma.start_time = jiffies;
53
54- if ((unsigned long)(skb->data + nlen) >= MAX_DMA_ADDRESS) {
55- memcpy(adapter->dma_buffer, skb->data, nlen);
56+ if ((unsigned long)(skb->data + nlen) >= MAX_DMA_ADDRESS || nlen != skb->len) {
57+ memcpy(adapter->dma_buffer, skb->data, skb->len);
58+ memset(adapter->dma_buffer+skb->len, 0, nlen-skb->len);
59 target = virt_to_bus(adapter->dma_buffer);
60 }
61 else {
62--- kernel-source-2.4.18-2.4.18.orig/drivers/net/3c507.c
63+++ kernel-source-2.4.18-2.4.18/drivers/net/3c507.c
64@@ -303,7 +303,7 @@
65 static struct net_device_stats *el16_get_stats(struct net_device *dev);
66 static void el16_tx_timeout (struct net_device *dev);
67
68-static void hardware_send_packet(struct net_device *dev, void *buf, short length);
69+static void hardware_send_packet(struct net_device *dev, void *buf, short length, short pad);
70 static void init_82586_mem(struct net_device *dev);
71 static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
72
73@@ -505,7 +505,7 @@
74 /* Disable the 82586's input to the interrupt line. */
75 outb (0x80, ioaddr + MISC_CTRL);
76
77- hardware_send_packet (dev, buf, length);
78+ hardware_send_packet (dev, buf, skb->len, length - skb->len);
79
80 dev->trans_start = jiffies;
81 /* Enable the 82586 interrupt input. */
82@@ -758,12 +758,13 @@
83 return;
84 }
85
86-static void hardware_send_packet(struct net_device *dev, void *buf, short length)
87+static void hardware_send_packet(struct net_device *dev, void *buf, short length, short pad)
88 {
89 struct net_local *lp = (struct net_local *)dev->priv;
90 short ioaddr = dev->base_addr;
91 ushort tx_block = lp->tx_head;
92 unsigned long write_ptr = dev->mem_start + tx_block;
93+ static char padding[ETH_ZLEN];
94
95 /* Set the write pointer to the Tx block, and put out the header. */
96 isa_writew(0x0000,write_ptr); /* Tx status */
97@@ -772,7 +773,7 @@
98 isa_writew(tx_block+8,write_ptr+=2); /* Data Buffer offset. */
99
100 /* Output the data buffer descriptor. */
101- isa_writew(length | 0x8000,write_ptr+=2); /* Byte count parameter. */
102+ isa_writew((pad + length) | 0x8000,write_ptr+=2); /* Byte count parameter. */
103 isa_writew(-1,write_ptr+=2); /* No next data buffer. */
104 isa_writew(tx_block+22+SCB_BASE,write_ptr+=2); /* Buffer follows the NoOp command. */
105 isa_writew(0x0000,write_ptr+=2); /* Buffer address high bits (always zero). */
106@@ -784,6 +785,8 @@
107
108 /* Output the packet at the write pointer. */
109 isa_memcpy_toio(write_ptr+2, buf, length);
110+ if(pad)
111+ isa_memcpy_toio(write_ptr+length+2, padding, pad);
112
113 /* Set the old command link pointing to this send packet. */
114 isa_writew(tx_block,dev->mem_start + lp->tx_cmd_link);
115--- kernel-source-2.4.18-2.4.18.orig/drivers/net/3c523.c
116+++ kernel-source-2.4.18-2.4.18/drivers/net/3c523.c
117@@ -1121,8 +1121,11 @@
118
119 netif_stop_queue(dev);
120
121- memcpy((char *) p->xmit_cbuffs[p->xmit_count], (char *) (skb->data), skb->len);
122 len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
123+
124+ if(len != skb->len)
125+ memset((char *) p->xmit_cbuffs[p->xmit_count], 0, ETH_ZLEN);
126+ memcpy((char *) p->xmit_cbuffs[p->xmit_count], (char *) (skb->data), skb->len);
127
128 #if (NUM_XMIT_BUFFS == 1)
129 #ifdef NO_NOPCOMMANDS
130--- kernel-source-2.4.18-2.4.18.orig/drivers/net/3c527.c
131+++ kernel-source-2.4.18-2.4.18/drivers/net/3c527.c
132@@ -1086,6 +1086,12 @@
133 /* We will need this to flush the buffer out */
134 lp->tx_ring[lp->tx_ring_head].skb=skb;
135
136+ if(skb->len < ETH_ZLEN)
137+ {
138+ skb = skb_padto(skb, ETH_ZLEN);
139+ if(skb == NULL)
140+ goto out;
141+ }
142 np->length = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len;
143
144 np->data = virt_to_bus(skb->data);
145@@ -1094,7 +1100,7 @@
146 wmb();
147
148 p->control &= ~CONTROL_EOL; /* Clear EOL on p */
149-
150+out:
151 restore_flags(flags);
152
153 netif_wake_queue(dev);
154--- kernel-source-2.4.18-2.4.18.orig/drivers/net/7990.c
155+++ kernel-source-2.4.18-2.4.18/drivers/net/7990.c
156@@ -531,6 +531,8 @@
157 ib->btx_ring [entry].length = (-len) | 0xf000;
158 ib->btx_ring [entry].misc = 0;
159
160+ if(skb->len < ETH_ZLEN)
161+ memset((char *)&ib->tx_buf[entry][0], 0, ETH_ZLEN);
162 memcpy ((char *)&ib->tx_buf [entry][0], skb->data, skblen);
163
164 /* Now, give the packet to the lance */
165--- kernel-source-2.4.18-2.4.18.orig/drivers/net/8139too.c
166+++ kernel-source-2.4.18-2.4.18/drivers/net/8139too.c
167@@ -1655,6 +1659,8 @@
168 entry = tp->cur_tx % NUM_TX_DESC;
169
170 if (likely(len < TX_BUF_SIZE)) {
171+ if(len < ETH_ZLEN)
172+ memset(tp->tx_buf[entry], 0, ETH_ZLEN);
173 skb_copy_and_csum_dev(skb, tp->tx_buf[entry]);
174 dev_kfree_skb(skb);
175 } else {
176--- kernel-source-2.4.18-2.4.18.orig/drivers/net/82596.c
177+++ kernel-source-2.4.18-2.4.18/drivers/net/82596.c
178@@ -1032,12 +1032,19 @@
179 struct i596_private *lp = (struct i596_private *) dev->priv;
180 struct tx_cmd *tx_cmd;
181 struct i596_tbd *tbd;
182- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
183+ short length = skb->len;
184 dev->trans_start = jiffies;
185
186 DEB(DEB_STARTTX,printk(KERN_DEBUG "%s: i596_start_xmit(%x,%x) called\n", dev->name,
187 skb->len, (unsigned int)skb->data));
188
189+ if(skb->len < ETH_ZLEN)
190+ {
191+ skb = skb_padto(skb, ETH_ZLEN);
192+ if(skb == NULL)
193+ return 0;
194+ length = ETH_ZLEN;
195+ }
196 netif_stop_queue(dev);
197
198 tx_cmd = lp->tx_cmds + lp->next_tx_cmd;
199--- kernel-source-2.4.18-2.4.18.orig/drivers/net/8390.c
200+++ kernel-source-2.4.18-2.4.18/drivers/net/8390.c
201@@ -270,6 +270,7 @@
202 struct ei_device *ei_local = (struct ei_device *) dev->priv;
203 int length, send_length, output_page;
204 unsigned long flags;
205+ char scratch[ETH_ZLEN];
206
207 length = skb->len;
208
209@@ -340,8 +341,16 @@
210 * isn't already sending. If it is busy, the interrupt handler will
211 * trigger the send later, upon receiving a Tx done interrupt.
212 */
213-
214- ei_block_output(dev, length, skb->data, output_page);
215+
216+ if(length == send_length)
217+ ei_block_output(dev, length, skb->data, output_page);
218+ else
219+ {
220+ memset(scratch, 0, ETH_ZLEN);
221+ memcpy(scratch, skb->data, skb->len);
222+ ei_block_output(dev, ETH_ZLEN, scratch, output_page);
223+ }
224+
225 if (! ei_local->txing)
226 {
227 ei_local->txing = 1;
228@@ -373,7 +382,14 @@
229 * reasonable hardware if you only use one Tx buffer.
230 */
231
232- ei_block_output(dev, length, skb->data, ei_local->tx_start_page);
233+ if(length == send_length)
234+ ei_block_output(dev, length, skb->data, ei_local->tx_start_page);
235+ else
236+ {
237+ memset(scratch, 0, ETH_ZLEN);
238+ memcpy(scratch, skb->data, skb->len);
239+ ei_block_output(dev, ETH_ZLEN, scratch, ei_local->tx_start_page);
240+ }
241 ei_local->txing = 1;
242 NS8390_trigger_send(dev, send_length, ei_local->tx_start_page);
243 dev->trans_start = jiffies;
244--- kernel-source-2.4.18-2.4.18.orig/drivers/net/a2065.c
245+++ kernel-source-2.4.18-2.4.18/drivers/net/a2065.c
246@@ -572,6 +572,15 @@
247 unsigned long flags;
248
249 skblen = skb->len;
250+ len = skblen;
251+
252+ if(len < ETH_ZLEN)
253+ {
254+ len = ETH_ZLEN:
255+ skb = skb_padto(skb, ETH_ZLEN);
256+ if(skb == NULL)
257+ return 0;
258+ }
259
260 save_flags(flags);
261 cli();
262@@ -593,7 +602,6 @@
263 }
264 }
265 #endif
266- len = (skblen <= ETH_ZLEN) ? ETH_ZLEN : skblen;
267 entry = lp->tx_new & lp->tx_ring_mod_mask;
268 ib->btx_ring [entry].length = (-len) | 0xf000;
269 ib->btx_ring [entry].misc = 0;
270--- kernel-source-2.4.18-2.4.18.orig/drivers/net/am79c961a.c
271+++ kernel-source-2.4.18-2.4.18/drivers/net/am79c961a.c
272@@ -428,10 +428,19 @@
273 am79c961_sendpacket(struct sk_buff *skb, struct net_device *dev)
274 {
275 struct dev_priv *priv = (struct dev_priv *)dev->priv;
276- unsigned int length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
277+ unsigned int length = skb->len;
278 unsigned int hdraddr, bufaddr;
279 unsigned int head;
280 unsigned long flags;
281+
282+ /* FIXME: I thought the 79c961 could do padding - RMK ??? */
283+ if(length < ETH_ZLEN)
284+ {
285+ skb = skb_padto(skb, ETH_ZLEN);
286+ if(skb == NULL)
287+ return 0;
288+ length = ETH_ZLEN;
289+ }
290
291 head = priv->txhead;
292 hdraddr = priv->txhdr + (head << 3);
293--- kernel-source-2.4.18-2.4.18.orig/drivers/net/ariadne.c
294+++ kernel-source-2.4.18-2.4.18/drivers/net/ariadne.c
295@@ -577,6 +577,7 @@
296 volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr;
297 int entry;
298 unsigned long flags;
299+ int len = skb->len;
300
301 #if 0
302 if (ariadne_debug > 3) {
303@@ -587,6 +588,15 @@
304 }
305 #endif
306
307+ /* FIXME: is the 79C960 new enough to do its own padding right ? */
308+ if(skb->len < ETH_ZLEN)
309+ {
310+ skb = skb_padto(skb, ETH_ZLEN);
311+ if(skb == NULL)
312+ return 0;
313+ len = ETH_ZLEN;
314+ }
315+
316 /* Fill in a Tx ring entry */
317
318 #if 0
319@@ -617,8 +627,7 @@
320
321 priv->tx_ring[entry]->TMD2 = swapw((u_short)-skb->len);
322 priv->tx_ring[entry]->TMD3 = 0x0000;
323- memcpyw(priv->tx_buff[entry], (u_short *)skb->data,
324- skb->len <= ETH_ZLEN ? ETH_ZLEN : skb->len);
325+ memcpyw(priv->tx_buff[entry], (u_short *)skb->data, len);
326
327 #if 0
328 {
329--- kernel-source-2.4.18-2.4.18.orig/drivers/net/at1700.c
330+++ kernel-source-2.4.18-2.4.18/drivers/net/at1700.c
331@@ -577,7 +577,9 @@
332 struct net_local *lp = (struct net_local *) dev->priv;
333 int ioaddr = dev->base_addr;
334 short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
335+ short len = skb->len;
336 unsigned char *buf = skb->data;
337+ static u8 pad[ETH_ZLEN];
338
339 netif_stop_queue (dev);
340
341@@ -589,7 +591,17 @@
342 lp->tx_queue_ready = 0;
343 {
344 outw (length, ioaddr + DATAPORT);
345- outsw (ioaddr + DATAPORT, buf, (length + 1) >> 1);
346+ /* Packet data */
347+ outsw (ioaddr + DATAPORT, buf, len >> 1);
348+ /* Check for dribble byte */
349+ if(len & 1)
350+ {
351+ outw(skb->data[skb->len-1], ioaddr + DATAPORT);
352+ len++;
353+ }
354+ /* Check for packet padding */
355+ if(length != skb->len)
356+ outsw(ioaddr + DATAPORT, pad, (length - len + 1) >> 1);
357
358 lp->tx_queue++;
359 lp->tx_queue_len += length + 2;
360--- kernel-source-2.4.18-2.4.18.orig/drivers/net/atarilance.c
361+++ kernel-source-2.4.18-2.4.18/drivers/net/atarilance.c
362@@ -786,6 +786,22 @@
363 DPRINTK( 2, ( "%s: lance_start_xmit() called, csr0 %4.4x.\n",
364 dev->name, DREG ));
365
366+
367+ /* The old LANCE chips doesn't automatically pad buffers to min. size. */
368+ len = skb->len;
369+ if(len < ETH_ZLEN)
370+ len = ETH_ZLEN;
371+ /* PAM-Card has a bug: Can only send packets with even number of bytes! */
372+ else if (lp->cardtype == PAM_CARD && (len & 1))
373+ ++len;
374+
375+ if(len > skb->len)
376+ {
377+ skb = skb_padto(skb, len);
378+ if(skb == NULL)
379+ return 0;
380+ }
381+
382 netif_stop_queue (dev);
383
384 /* Fill in a Tx ring entry */
385@@ -815,11 +831,6 @@
386 * last.
387 */
388
389- /* The old LANCE chips doesn't automatically pad buffers to min. size. */
390- len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
391- /* PAM-Card has a bug: Can only send packets with even number of bytes! */
392- if (lp->cardtype == PAM_CARD && (len & 1))
393- ++len;
394
395 head->length = -len;
396 head->misc = 0;
397--- kernel-source-2.4.18-2.4.18.orig/drivers/net/atp.c
398+++ kernel-source-2.4.18-2.4.18/drivers/net/atp.c
399@@ -202,7 +202,7 @@
400 static unsigned short eeprom_op(long ioaddr, unsigned int cmd);
401 static int net_open(struct net_device *dev);
402 static void hardware_init(struct net_device *dev);
403-static void write_packet(long ioaddr, int length, unsigned char *packet, int mode);
404+static void write_packet(long ioaddr, int length, unsigned char *packet, int pad, int mode);
405 static void trigger_send(long ioaddr, int length);
406 static int atp_send_packet(struct sk_buff *skb, struct net_device *dev);
407 static void atp_interrupt(int irq, void *dev_id, struct pt_regs *regs);
408@@ -499,15 +499,23 @@
409 write_reg(ioaddr, CMR1, CMR1_Xmit);
410 }
411
412-static void write_packet(long ioaddr, int length, unsigned char *packet, int data_mode)
413+static void write_packet(long ioaddr, int length, unsigned char *packet, int pad_len, int data_mode)
414 {
415- length = (length + 1) & ~1; /* Round up to word length. */
416+ if(length & 1)
417+ {
418+ length++;
419+ pad_len++;
420+ }
421+
422 outb(EOC+MAR, ioaddr + PAR_DATA);
423 if ((data_mode & 1) == 0) {
424 /* Write the packet out, starting with the write addr. */
425 outb(WrAddr+MAR, ioaddr + PAR_DATA);
426 do {
427 write_byte_mode0(ioaddr, *packet++);
428+ } while (--length > pad_len) ;
429+ do {
430+ write_byte_mode0(ioaddr, 0);
431 } while (--length > 0) ;
432 } else {
433 /* Write the packet out in slow mode. */
434@@ -521,8 +529,10 @@
435 outbyte >>= 4;
436 outb(outbyte & 0x0f, ioaddr + PAR_DATA);
437 outb(Ctrl_HNibWrite + Ctrl_IRQEN, ioaddr + PAR_CONTROL);
438- while (--length > 0)
439+ while (--length > pad_len)
440 write_byte_mode1(ioaddr, *packet++);
441+ while (--length > 0)
442+ write_byte_mode1(ioaddr, 0);
443 }
444 /* Terminate the Tx frame. End of write: ECB. */
445 outb(0xff, ioaddr + PAR_DATA);
446@@ -564,7 +574,7 @@
447 write_reg_high(ioaddr, IMR, 0);
448 spin_unlock_irqrestore(&lp->lock, flags);
449
450- write_packet(ioaddr, length, skb->data, dev->if_port);
451+ write_packet(ioaddr, length, skb->data, length-skb->len, dev->if_port);
452
453 lp->pac_cnt_in_tx_buf++;
454 if (lp->tx_unit_busy == 0) {
455--- kernel-source-2.4.18-2.4.18.orig/drivers/net/bagetlance.c
456+++ kernel-source-2.4.18-2.4.18/drivers/net/bagetlance.c
457@@ -835,6 +835,19 @@
458 struct lance_tx_head *head;
459 unsigned long flags;
460
461+ /* The old LANCE chips doesn't automatically pad buffers to min. size. */
462+ len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
463+ /* PAM-Card has a bug: Can only send packets with even number of bytes! */
464+ if (lp->cardtype == PAM_CARD && (len & 1))
465+ ++len;
466+
467+ if (len > skb->len)
468+ {
469+ skb = skb_padto(skb, len);
470+ if(skb == NULL)
471+ return 0;
472+ }
473+
474 /* Transmitter timeout, serious problems. */
475 if (dev->tbusy) {
476 int tickssofar = jiffies - dev->trans_start;
477@@ -920,12 +933,6 @@
478 /* Caution: the write order is important here, set the "ownership" bits
479 * last.
480 */
481-
482- /* The old LANCE chips doesn't automatically pad buffers to min. size. */
483- len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
484- /* PAM-Card has a bug: Can only send packets with even number of bytes! */
485- if (lp->cardtype == PAM_CARD && (len & 1))
486- ++len;
487
488 head->length = -len;
489 head->misc = 0;
490--- kernel-source-2.4.18-2.4.18.orig/drivers/net/de600.c
491+++ kernel-source-2.4.18-2.4.18/drivers/net/de600.c
492@@ -403,6 +403,7 @@
493 int len;
494 int tickssofar;
495 byte *buffer = skb->data;
496+ int i;
497
498 if (free_tx_pages <= 0) { /* Do timeouts, to avoid hangs. */
499 tickssofar = jiffies - dev->trans_start;
500@@ -447,8 +448,10 @@
501 #endif
502
503 de600_setup_address(transmit_from, RW_ADDR);
504- for ( ; len > 0; --len, ++buffer)
505+ for (i = 0; i < skb->len ; ++i, ++buffer)
506 de600_put_byte(*buffer);
507+ for (; i < len; ++i)
508+ de600_put_byte(0);
509
510 if (free_tx_pages-- == TX_PAGES) { /* No transmission going on */
511 dev->trans_start = jiffies;
512--- kernel-source-2.4.18-2.4.18.orig/drivers/net/de620.c
513+++ kernel-source-2.4.18-2.4.18/drivers/net/de620.c
514@@ -316,7 +316,7 @@
515 }
516
517 static inline void
518-de620_write_block(struct net_device *dev, byte *buffer, int count)
519+de620_write_block(struct net_device *dev, byte *buffer, int count, int pad)
520 {
521 #ifndef LOWSPEED
522 byte uflip = NIC_Cmd ^ (DS0 | DS1);
523@@ -335,6 +335,9 @@
524 for ( ; count > 0; --count, ++buffer) {
525 de620_put_byte(dev,*buffer);
526 }
527+ for ( count = pad ; count > 0; --count, ++buffer) {
528+ de620_put_byte(dev, 0);
529+ }
530 de620_send_command(dev,W_DUMMY);
531 #ifdef COUNT_LOOPS
532 /* trial debug output: loops per byte in de620_ready() */
533@@ -570,7 +573,7 @@
534 restore_flags(flags);
535 return 1;
536 }
537- de620_write_block(dev, buffer, len);
538+ de620_write_block(dev, buffer, skb->len, len-skb->len);
539
540 dev->trans_start = jiffies;
541 if(!(using_txbuf == (TXBF0 | TXBF1)))
542--- kernel-source-2.4.18-2.4.18.orig/drivers/net/declance.c
543+++ kernel-source-2.4.18-2.4.18/drivers/net/declance.c
544@@ -871,7 +871,15 @@
545
546 skblen = skb->len;
547
548- len = (skblen <= ETH_ZLEN) ? ETH_ZLEN : skblen;
549+ len = skblen;
550+
551+ if(len < ETH_ZLEN)
552+ {
553+ skb = skb_padto(skb, ETH_ZLEN);
554+ if(skb == NULL)
555+ return 0;
556+ len = ETH_ZLEN;
557+ }
558
559 lp->stats.tx_bytes += len;
560
561--- kernel-source-2.4.18-2.4.18.orig/drivers/net/depca.c
562+++ kernel-source-2.4.18-2.4.18/drivers/net/depca.c
563@@ -875,6 +875,13 @@
564 if (skb->len < 1)
565 goto out;
566
567+ if(skb->len < ETH_ZLEN)
568+ {
569+ skb = skb_padto(skb, ETH_ZLEN);
570+ if(skb == NULL)
571+ goto out;
572+ }
573+
574 netif_stop_queue(dev);
575
576 if (TX_BUFFS_AVAIL) { /* Fill in a Tx ring entry */
577--- kernel-source-2.4.18-2.4.18.orig/drivers/net/eepro.c
578+++ kernel-source-2.4.18-2.4.18/drivers/net/eepro.c
579@@ -1125,17 +1125,24 @@
580 struct eepro_local *lp = (struct eepro_local *)dev->priv;
581 unsigned long flags;
582 int ioaddr = dev->base_addr;
583+ short length = skb->len;
584
585 if (net_debug > 5)
586 printk(KERN_DEBUG "%s: entering eepro_send_packet routine.\n", dev->name);
587
588+ if(length < ETH_ZLEN)
589+ {
590+ skb = skb_padto(skb, ETH_ZLEN);
591+ if(skb == NULL)
592+ return 0;
593+ length = ETH_ZLEN;
594+ }
595 netif_stop_queue (dev);
596
597 eepro_dis_int(ioaddr);
598 spin_lock_irqsave(&lp->lock, flags);
599
600 {
601- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
602 unsigned char *buf = skb->data;
603
604 if (hardware_send_packet(dev, buf, length))
605--- kernel-source-2.4.18-2.4.18.orig/drivers/net/eexpress.c
606+++ kernel-source-2.4.18-2.4.18/drivers/net/eexpress.c
607@@ -614,6 +614,7 @@
608 static int eexp_xmit(struct sk_buff *buf, struct net_device *dev)
609 {
610 struct net_local *lp = (struct net_local *)dev->priv;
611+ short length = buf->len;
612 #ifdef CONFIG_SMP
613 unsigned long flags;
614 #endif
615@@ -622,6 +623,14 @@
616 printk(KERN_DEBUG "%s: eexp_xmit()\n", dev->name);
617 #endif
618
619+ if(buf->len < ETH_ZLEN)
620+ {
621+ buf = skb_padto(buf, ETH_ZLEN);
622+ if(buf == NULL)
623+ return 0;
624+ length = buf->len;
625+ }
626+
627 disable_irq(dev->irq);
628
629 /*
630@@ -634,8 +643,6 @@
631 #endif
632
633 {
634- unsigned short length = (ETH_ZLEN < buf->len) ? buf->len :
635- ETH_ZLEN;
636 unsigned short *data = (unsigned short *)buf->data;
637
638 lp->stats.tx_bytes += length;
639--- kernel-source-2.4.18-2.4.18.orig/drivers/net/epic100.c
640+++ kernel-source-2.4.18-2.4.18/drivers/net/epic100.c
641@@ -959,6 +959,13 @@
642 int entry, free_count;
643 u32 ctrl_word;
644 long flags;
645+
646+ if(skb->len < ETH_ZLEN)
647+ {
648+ skb = skb_padto(skb, ETH_ZLEN);
649+ if(skb == NULL)
650+ return 0;
651+ }
652
653 /* Caution: the write order is important here, set the field with the
654 "ownership" bit last. */
655--- kernel-source-2.4.18-2.4.18.orig/drivers/net/eth16i.c
656+++ kernel-source-2.4.18-2.4.18/drivers/net/eth16i.c
657@@ -1056,10 +1056,17 @@
658 struct eth16i_local *lp = (struct eth16i_local *)dev->priv;
659 int ioaddr = dev->base_addr;
660 int status = 0;
661- ushort length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
662+ ushort length = skb->len;
663 unsigned char *buf = skb->data;
664 unsigned long flags;
665
666+ if(length < ETH_ZLEN)
667+ {
668+ skb = skb_padto(skb, ETH_ZLEN);
669+ if(skb == NULL)
670+ return 0;
671+ length = ETH_ZLEN;
672+ }
673
674 netif_stop_queue(dev);
675
676--- kernel-source-2.4.18-2.4.18.orig/drivers/net/fmv18x.c
677+++ kernel-source-2.4.18-2.4.18/drivers/net/fmv18x.c
678@@ -369,7 +369,7 @@
679 {
680 struct net_local *lp = dev->priv;
681 int ioaddr = dev->base_addr;
682- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
683+ short length = skb->len;
684 unsigned char *buf = skb->data;
685 unsigned long flags;
686
687@@ -381,6 +381,15 @@
688 dev->name, length);
689 return 1;
690 }
691+
692+ if (length < ETH_ZLEN)
693+ {
694+ skb = skb_padto(skb, ETH_ZLEN);
695+ if(skb == NULL)
696+ return 0;
697+ length = ETH_ZLEN;
698+ }
699+
700 if (net_debug > 4)
701 printk("%s: Transmitting a packet of length %lu.\n", dev->name,
702 (unsigned long)skb->len);
703--- kernel-source-2.4.18-2.4.18.orig/drivers/net/hp100.c
704+++ kernel-source-2.4.18-2.4.18/drivers/net/hp100.c
705@@ -1511,6 +1511,13 @@
706
707 if (skb->len <= 0)
708 return 0;
709+
710+ if (skb->len < ETH_ZLEN && lp->chip == HP100_CHIPID_SHASTA)
711+ {
712+ skb = skb_padto(skb, ETH_ZLEN);
713+ if(skb == NULL)
714+ return 0;
715+ }
716
717 /* Get Tx ring tail pointer */
718 if (lp->txrtail->next == lp->txrhead) {
719--- kernel-source-2.4.18-2.4.18.orig/drivers/net/lance.c
720+++ kernel-source-2.4.18-2.4.18/drivers/net/lance.c
721@@ -893,8 +893,15 @@
722
723 /* The old LANCE chips doesn't automatically pad buffers to min. size. */
724 if (chip_table[lp->chip_version].flags & LANCE_MUST_PAD) {
725- lp->tx_ring[entry].length =
726- -(ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN);
727+ if(skb->len < ETH_ZLEN)
728+ {
729+ skb = skb_padto(skb, ETH_ZLEN);
730+ if(skb == NULL)
731+ goto out;
732+ lp->tx_ring[entry].length = -ETH_ZLEN;
733+ }
734+ else
735+ lp->tx_ring[entry].length = -skb->len;
736 } else
737 lp->tx_ring[entry].length = -skb->len;
738
739@@ -927,6 +934,7 @@
740 if ((lp->cur_tx - lp->dirty_tx) >= TX_RING_SIZE)
741 netif_stop_queue(dev);
742
743+out:
744 spin_unlock_irqrestore(&lp->devlock, flags);
745 return 0;
746 }
747--- kernel-source-2.4.18-2.4.18.orig/drivers/net/lasi_82596.c
748+++ kernel-source-2.4.18-2.4.18/drivers/net/lasi_82596.c
749@@ -1061,11 +1061,19 @@
750 struct i596_private *lp = (struct i596_private *) dev->priv;
751 struct tx_cmd *tx_cmd;
752 struct i596_tbd *tbd;
753- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
754+ short length = skb->len;
755 dev->trans_start = jiffies;
756
757 DEB(DEB_STARTTX,printk("%s: i596_start_xmit(%x,%p) called\n", dev->name,
758 skb->len, skb->data));
759+
760+ if(length < ETH_ZLEN)
761+ {
762+ skb = skb_padto(skb, ETH_ZLEN);
763+ if(skb == NULL)
764+ return 0;
765+ length = ETH_ZLEN;
766+ }
767
768 netif_stop_queue(dev);
769
770--- kernel-source-2.4.18-2.4.18.orig/drivers/net/lp486e.c
771+++ kernel-source-2.4.18-2.4.18/drivers/net/lp486e.c
772@@ -886,7 +886,16 @@
773 if (skb->len <= 0)
774 return 0;
775
776- length = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
777+ length = skb->len;
778+
779+ if(length < ETH_ZLEN)
780+ {
781+ skb = skb_padto(skb, ETH_ZLEN);
782+ if(skb == NULL)
783+ return 0;
784+ length = ETH_ZLEN;
785+ }
786+
787 dev->trans_start = jiffies;
788
789 tx_cmd = (struct tx_cmd *)
790--- kernel-source-2.4.18-2.4.18.orig/drivers/net/ni5010.c
791+++ kernel-source-2.4.18-2.4.18/drivers/net/ni5010.c
792@@ -114,7 +114,7 @@
793
794 static int process_xmt_interrupt(struct net_device *dev);
795 #define tx_done(dev) 1
796-static void hardware_send_packet(struct net_device *dev, char *buf, int length);
797+static void hardware_send_packet(struct net_device *dev, char *buf, int length, int pad);
798 static void chipset_init(struct net_device *dev, int startp);
799 static void dump_packet(void *buf, int len);
800 static void ni5010_show_registers(struct net_device *dev);
801@@ -437,7 +437,7 @@
802 */
803
804 netif_stop_queue(dev);
805- hardware_send_packet(dev, (unsigned char *)skb->data, length);
806+ hardware_send_packet(dev, (unsigned char *)skb->data, skb->len, length-skb->len);
807 dev->trans_start = jiffies;
808 dev_kfree_skb (skb);
809 return 0;
810@@ -661,7 +661,7 @@
811 }
812 }
813
814-static void hardware_send_packet(struct net_device *dev, char *buf, int length)
815+static void hardware_send_packet(struct net_device *dev, char *buf, int length, int pad)
816 {
817 struct ni5010_local *lp = (struct ni5010_local *)dev->priv;
818 int ioaddr = dev->base_addr;
819@@ -686,8 +686,8 @@
820
821 if (NI5010_DEBUG > 3) dump_packet(buf, length);
822
823- buf_offs = NI5010_BUFSIZE - length;
824- lp->o_pkt_size = length;
825+ buf_offs = NI5010_BUFSIZE - length - pad;
826+ lp->o_pkt_size = length + pad;
827
828 save_flags(flags);
829 cli();
830@@ -698,6 +698,9 @@
831
832 outw(buf_offs, IE_GP); /* Point GP at start of packet */
833 outsb(IE_XBUF, buf, length); /* Put data in buffer */
834+ while(pad--)
835+ outb(0, IE_XBUF);
836+
837 outw(buf_offs, IE_GP); /* Rewrite where packet starts */
838
839 /* should work without that outb() (Crynwr used it) */
840--- kernel-source-2.4.18-2.4.18.orig/drivers/net/ni52.c
841+++ kernel-source-2.4.18-2.4.18/drivers/net/ni52.c
842@@ -1162,7 +1162,12 @@
843 #endif
844 {
845 memcpy((char *)p->xmit_cbuffs[p->xmit_count],(char *)(skb->data),skb->len);
846- len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
847+ len = skb->len;
848+ if(len < ETH_ZLEN)
849+ {
850+ len = ETH_ZLEN;
851+ memset((char *)p->xmit_cbuffs[p->xmit_count]+skb->len, 0, len - skb->len);
852+ }
853
854 #if (NUM_XMIT_BUFFS == 1)
855 # ifdef NO_NOPCOMMANDS
856--- kernel-source-2.4.18-2.4.18.orig/drivers/net/ni65.c
857+++ kernel-source-2.4.18-2.4.18/drivers/net/ni65.c
858@@ -1109,6 +1109,8 @@
859
860 memcpy((char *) p->tmdbounce[p->tmdbouncenum] ,(char *)skb->data,
861 (skb->len > T_BUF_SIZE) ? T_BUF_SIZE : skb->len);
862+ if(len > skb->len)
863+ memset((char *)p->tmdbounce[p->tmdbouncenum]+skb->len, 0, len-skb->len);
864 dev_kfree_skb (skb);
865
866 save_flags(flags);
867--- kernel-source-2.4.18-2.4.18.orig/drivers/net/seeq8005.c
868+++ kernel-source-2.4.18-2.4.18/drivers/net/seeq8005.c
869@@ -378,9 +378,16 @@
870 static int seeq8005_send_packet(struct sk_buff *skb, struct net_device *dev)
871 {
872 struct net_local *lp = (struct net_local *)dev->priv;
873- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
874+ short length = skb->len;
875 unsigned char *buf = skb->data;
876
877+ if(length < ETH_ZLEN)
878+ {
879+ skb = skb_padto(skb, ETH_ZLEN);
880+ if(skb == NULL)
881+ return 0;
882+ length = ETH_ZLEN;
883+ }
884 /* Block a timer-based transmit from overlapping */
885 netif_stop_queue(dev);
886
887--- kernel-source-2.4.18-2.4.18.orig/drivers/net/sgiseeq.c
888+++ kernel-source-2.4.18-2.4.18/drivers/net/sgiseeq.c
889@@ -535,6 +535,8 @@
890 * added this new entry and restarted it.
891 */
892 memcpy((char *)(long)td->buf_vaddr, skb->data, skblen);
893+ if(len != skblen)
894+ memset((char *)(long)td->buf_vaddr + skb->len, 0, len-skblen);
895 td->tdma.cntinfo = (len & HPCDMA_BCNT) |
896 (HPCDMA_XIU | HPCDMA_EOXP | HPCDMA_XIE | HPCDMA_EOX);
897 if (sp->tx_old != sp->tx_new) {
898--- kernel-source-2.4.18-2.4.18.orig/drivers/net/sk_g16.c
899+++ kernel-source-2.4.18-2.4.18/drivers/net/sk_g16.c
900@@ -1256,6 +1256,7 @@
901 {
902 struct priv *p = (struct priv *) dev->priv;
903 struct tmd *tmdp;
904+ static char pad[64];
905
906 PRINTK2(("## %s: SK_send_packet() called, CSR0 %#04x.\n",
907 SK_NAME, SK_read_reg(CSR0)));
908@@ -1280,6 +1281,8 @@
909 /* Copy data into dual ported ram */
910
911 memcpy_toio((tmdp->u.buffer & 0x00ffffff), skb->data, skb->len);
912+ if(len != skb->len)
913+ memcpy_toio((tmdp->u.buffer & 0x00ffffff) + sb->len, pad, len-skb->len);
914
915 writew(-len, &tmdp->blen); /* set length to transmit */
916
917--- kernel-source-2.4.18-2.4.18.orig/drivers/net/smc9194.c
918+++ kernel-source-2.4.18-2.4.18/drivers/net/smc9194.c
919@@ -514,8 +514,18 @@
920 }
921- lp->saved_skb = skb;
922
923- length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
924+ length = skb->len;
925
926+ if(length < ETH_ZLEN)
927+ {
928+ skb = skb_padto(skb, ETH_ZLEN);
929+ if(skb == NULL)
930+ {
931+ netif_wake_queue(dev);
932+ return 0;
933+ }
934+ length = ETH_ZLEN;
935+ }
936+ lp->saved_skb = skb;
937
938 /*
939 ** The MMU wants the number of pages to be the number of 256 bytes
940--- linux-2.4.20.orig/drivers/net/sun3_82586.c
941+++ linux-2.4.20/drivers/net/sun3_82586.c
942@@ -1024,8 +1024,13 @@
943 else
944 #endif
945 {
946+ len = skb->len;
947+ if(len < ETH_ZLEN)
948+ {
949+ memset((char *)p->xmit_cbuffs[p->xmit_count], 0, ETH_ZLEN);
950+ len = ETH_ZLEN;
951+ }
952 memcpy((char *)p->xmit_cbuffs[p->xmit_count],(char *)(skb->data),skb->len);
953- len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
954
955 #if (NUM_XMIT_BUFFS == 1)
956 # ifdef NO_NOPCOMMANDS
957--- kernel-source-2.4.18-2.4.18.orig/drivers/net/sun3lance.c
958+++ kernel-source-2.4.18-2.4.18/drivers/net/sun3lance.c
959@@ -561,6 +561,9 @@
960 head->misc = 0;
961
962 memcpy( PKTBUF_ADDR(head), (void *)skb->data, skb->len );
963+ if(len != skb->len)
964+ memset(PKTBUF_ADDR(head) + skb->len, 0, len-skb->len);
965+
966 head->flag = TMD1_OWN_CHIP | TMD1_ENP | TMD1_STP;
967 lp->new_tx = (lp->new_tx + 1) & TX_RING_MOD_MASK;
968 lp->stats.tx_bytes += skb->len;
969--- kernel-source-2.4.18-2.4.18.orig/drivers/net/via-rhine.c
970+++ kernel-source-2.4.18-2.4.18/drivers/net/via-rhine.c
971@@ -1198,6 +1198,12 @@
972 /* Calculate the next Tx descriptor entry. */
973 entry = np->cur_tx % TX_RING_SIZE;
974
975+ if (skb->len < ETH_ZLEN) {
976+ skb = skb_padto(skb, ETH_ZLEN);
977+ if(skb == NULL)
978+ return 0;
979+ }
980+
981 np->tx_skbuff[entry] = skb;
982
983 if ((np->drv_flags & ReqTxAlign) &&
984--- kernel-source-2.4.18-2.4.18.orig/drivers/net/wavelan.c
985+++ kernel-source-2.4.18-2.4.18/drivers/net/wavelan.c
986@@ -2822,6 +2822,13 @@
987 (unsigned) skb);
988 #endif
989
990+ if(skb->len < ETH_ZLEN)
991+ {
992+ skb = skb_padto(skb, ETH_ZLEN);
993+ if(skb == NULL)
994+ return 0;
995+ }
996+
997 /*
998 * Block a timer-based transmit from overlapping.
999 * In other words, prevent reentering this routine.
1000--- kernel-source-2.4.18-2.4.18.orig/drivers/net/yellowfin.c
1001+++ kernel-source-2.4.18-2.4.18/drivers/net/yellowfin.c
1002@@ -856,6 +856,7 @@
1003 {
1004 struct yellowfin_private *yp = dev->priv;
1005 unsigned entry;
1006+ int len = skb->len;
1007
1008 netif_stop_queue (dev);
1009
1010@@ -871,27 +872,37 @@
1011 int cacheline_end = ((unsigned long)skb->data + skb->len) % 32;
1012 /* Fix GX chipset errata. */
1013 if (cacheline_end > 24 || cacheline_end == 0)
1014- skb->len += 32 - cacheline_end + 1;
1015+ {
1016+ len = skb->len + 32 - cacheline_end + 1;
1017+ if(len != skb->len)
1018+ skb = skb_padto(skb, len);
1019+ }
1020+ if(skb == NULL)
1021+ {
1022+ yp->tx_skbuff[entry] = NULL;
1023+ netif_wake_queue(dev);
1024+ return 0;
1025+ }
1026 }
1027 #ifdef NO_TXSTATS
1028 yp->tx_ring[entry].addr = cpu_to_le32(pci_map_single(yp->pci_dev,
1029- skb->data, skb->len, PCI_DMA_TODEVICE));
1030+ skb->data, len, PCI_DMA_TODEVICE));
1031 yp->tx_ring[entry].result_status = 0;
1032 if (entry >= TX_RING_SIZE-1) {
1033 /* New stop command. */
1034 yp->tx_ring[0].dbdma_cmd = cpu_to_le32(CMD_STOP);
1035 yp->tx_ring[TX_RING_SIZE-1].dbdma_cmd =
1036- cpu_to_le32(CMD_TX_PKT|BRANCH_ALWAYS | skb->len);
1037+ cpu_to_le32(CMD_TX_PKT|BRANCH_ALWAYS | len);
1038 } else {
1039 yp->tx_ring[entry+1].dbdma_cmd = cpu_to_le32(CMD_STOP);
1040 yp->tx_ring[entry].dbdma_cmd =
1041- cpu_to_le32(CMD_TX_PKT | BRANCH_IFTRUE | skb->len);
1042+ cpu_to_le32(CMD_TX_PKT | BRANCH_IFTRUE | len);
1043 }
1044 yp->cur_tx++;
1045 #else
1046- yp->tx_ring[entry<<1].request_cnt = skb->len;
1047+ yp->tx_ring[entry<<1].request_cnt = len;
1048 yp->tx_ring[entry<<1].addr = cpu_to_le32(pci_map_single(yp->pci_dev,
1049- skb->data, skb->len, PCI_DMA_TODEVICE));
1050+ skb->data, len, PCI_DMA_TODEVICE));
1051 /* The input_last (status-write) command is constant, but we must
1052 rewrite the subsequent 'stop' command. */
1053
1054@@ -904,7 +915,7 @@
1055
1056 yp->tx_ring[entry<<1].dbdma_cmd =
1057 cpu_to_le32( ((entry % 6) == 0 ? CMD_TX_PKT|INTR_ALWAYS|BRANCH_IFTRUE :
1058- CMD_TX_PKT | BRANCH_IFTRUE) | skb->len);
1059+ CMD_TX_PKT | BRANCH_IFTRUE) | len);
1060 #endif
1061
1062 /* Non-x86 Todo: explicitly flush cache lines here. */
1063--- kernel-source-2.4.18-2.4.18.orig/drivers/net/znet.c
1064+++ kernel-source-2.4.18-2.4.18/drivers/net/znet.c
1065@@ -348,10 +348,19 @@
1066 int ioaddr = dev->base_addr;
1067 struct net_local *lp = (struct net_local *)dev->priv;
1068 unsigned long flags;
1069+ short length = skb->len;
1070
1071 if (znet_debug > 4)
1072 printk(KERN_DEBUG "%s: ZNet_send_packet.\n", dev->name);
1073
1074+ if(length < ETH_ZLEN)
1075+ {
1076+ skb = skb_padto(skb, ETH_ZLEN);
1077+ if(skb == NULL)
1078+ return 0;
1079+ length = ETH_ZLEN;
1080+ }
1081+
1082 netif_stop_queue (dev);
1083
1084 /* Check that the part hasn't reset itself, probably from suspend. */
1085@@ -362,7 +371,6 @@
1086 hardware_init(dev);
1087
1088 if (1) {
1089- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
1090 unsigned char *buf = (void *)skb->data;
1091 ushort *tx_link = zn.tx_cur - 1;
1092 ushort rnd_len = (length + 1)>>1;
1093--- kernel-source-2.4.18-2.4.18.orig/drivers/net/pcmcia/axnet_cs.c
1094+++ kernel-source-2.4.18-2.4.18/drivers/net/pcmcia/axnet_cs.c
1095@@ -1139,7 +1139,8 @@
1096 struct ei_device *ei_local = (struct ei_device *) dev->priv;
1097 int length, send_length, output_page;
1098 unsigned long flags;
1099-
1100+ u8 packet[ETH_ZLEN];
1101+
1102 netif_stop_queue(dev);
1103
1104 length = skb->len;
1105@@ -1164,7 +1165,7 @@
1106 ei_local->irqlock = 1;
1107
1108 send_length = ETH_ZLEN < length ? length : ETH_ZLEN;
1109-
1110+
1111 /*
1112 * We have two Tx slots available for use. Find the first free
1113 * slot, and then perform some sanity checks. With two Tx bufs,
1114@@ -1209,7 +1210,15 @@
1115 * trigger the send later, upon receiving a Tx done interrupt.
1116 */
1117
1118- ei_block_output(dev, length, skb->data, output_page);
1119+ if(length == skb->len)
1120+ ei_block_output(dev, length, skb->data, output_page);
1121+ else
1122+ {
1123+ memset(packet, 0, ETH_ZLEN);
1124+ memcpy(packet, skb->data, skb->len);
1125+ ei_block_output(dev, length, packet, output_page);
1126+ }
1127+
1128 if (! ei_local->txing)
1129 {
1130 ei_local->txing = 1;
1131--- kernel-source-2.4.18-2.4.18.orig/drivers/net/pcmcia/fmvj18x_cs.c
1132+++ kernel-source-2.4.18-2.4.18/drivers/net/pcmcia/fmvj18x_cs.c
1133@@ -865,11 +865,19 @@
1134 {
1135 struct local_info_t *lp = (struct local_info_t *)dev->priv;
1136 ioaddr_t ioaddr = dev->base_addr;
1137+ short length = skb->len;
1138+
1139+ if(length < ETH_ZLEN)
1140+ {
1141+ skb = skb_padto(skb, ETH_ZLEN);
1142+ if(skb == NULL)
1143+ return 0;
1144+ length = ETH_ZLEN;
1145+ }
1146
1147 netif_stop_queue(dev);
1148
1149 {
1150- short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
1151 unsigned char *buf = skb->data;
1152
1153 if (length > ETH_FRAME_LEN) {
1154--- kernel-source-2.4.18-2.4.18.orig/drivers/net/pcmcia/ray_cs.c
1155+++ kernel-source-2.4.18-2.4.18/drivers/net/pcmcia/ray_cs.c
1156@@ -1042,7 +1042,7 @@
1157 {
1158 ray_dev_t *local = dev->priv;
1159 dev_link_t *link = local->finder;
1160- short length;
1161+ short length = skb->len;
1162
1163 if (!(link->state & DEV_PRESENT)) {
1164 DEBUG(2,"ray_dev_start_xmit - device not present\n");
1165@@ -1058,7 +1058,13 @@
1166 }
1167 }
1168
1169- length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
1170+ if(length < ETH_ZLEN)
1171+ {
1172+ skb = skb_padto(skb, ETH_ZLEN);
1173+ if(skb == NULL)
1174+ return 0;
1175+ length = ETH_ZLEN;
1176+ }
1177 switch (ray_hw_xmit( skb->data, length, dev, DATA_TYPE)) {
1178 case XMIT_NO_CCS:
1179 case XMIT_NEED_AUTH:
1180--- kernel-source-2.4.18-2.4.18.orig/drivers/net/pcmcia/xirc2ps_cs.c
1181+++ kernel-source-2.4.18-2.4.18/drivers/net/pcmcia/xirc2ps_cs.c
1182@@ -1546,7 +1546,6 @@
1183 DEBUG(1, "do_start_xmit(skb=%p, dev=%p) len=%u\n",
1184 skb, dev, pktlen);
1185
1186- netif_stop_queue(dev);
1187
1188 /* adjust the packet length to min. required
1189 * and hope that the buffer is large enough
1190@@ -1556,8 +1555,14 @@
1191 * pad this in his buffer with random bytes
1192 */
1193 if (pktlen < ETH_ZLEN)
1194+ {
1195+ skb = skb_padto(skb, ETH_ZLEN);
1196+ if(skb == NULL)
1197+ return 0;
1198 pktlen = ETH_ZLEN;
1199+ }
1200
1201+ netif_stop_queue(dev);
1202 SelectPage(0);
1203 PutWord(XIRCREG0_TRS, (u_short)pktlen+2);
1204 freespace = GetWord(XIRCREG0_TSO);
1205--- kernel-source-2.4.18-2.4.18.orig/drivers/net/pcmcia/xircom_tulip_cb.c
1206+++ kernel-source-2.4.18-2.4.18/drivers/net/pcmcia/xircom_tulip_cb.c
1207@@ -922,6 +922,14 @@
1208 /* Calculate the next Tx descriptor entry. */
1209 entry = tp->cur_tx % TX_RING_SIZE;
1210
1211+ /* Seems to be needed even though the docs disagree */
1212+ if(skb->len < ETH_ZLEN)
1213+ {
1214+ skb = skb_padto(skb, ETH_ZLEN);
1215+ if(skb == NULL)
1216+ return 0;
1217+ }
1218+
1219 tp->tx_skbuff[entry] = skb;
1220 #ifdef CARDBUS
1221 if (tp->chip_id == X3201_3) {
1222--- kernel-source-2.4.18-2.4.18.orig/include/linux/skbuff.h
1223+++ kernel-source-2.4.18-2.4.18/include/linux/skbuff.h
1224@@ -240,6 +240,7 @@
1225 int newheadroom,
1226 int newtailroom,
1227 int priority);
1228+extern struct sk_buff * skb_pad(struct sk_buff *skb, int pad);
1229 #define dev_kfree_skb(a) kfree_skb(a)
1230 extern void skb_over_panic(struct sk_buff *skb, int len, void *here);
1231 extern void skb_under_panic(struct sk_buff *skb, int len, void *here);
1232@@ -1079,6 +1080,26 @@
1233 if (delta || skb_cloned(skb))
1234 return pskb_expand_head(skb, (delta+15)&~15, 0, GFP_ATOMIC);
1235 return 0;
1236+}
1237+
1238+/**
1239+ * skb_padto - pad an skbuff up to a minimal size
1240+ * @skb: buffer to pad
1241+ * @len: minimal length
1242+ *
1243+ * Pads up a buffer to ensure the trailing bytes exist and are
1244+ * blanked. If the buffer already contains sufficient data it
1245+ * is untouched. Returns the buffer, which may be a replacement
1246+ * for the original, or NULL for out of memory - in which case
1247+ * the original buffer is still freed.
1248+ */
1249+
1250+static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len)
1251+{
1252+ unsigned int size = skb->len;
1253+ if(likely(size >= len))
1254+ return skb;
1255+ return skb_pad(skb, len-size);
1256 }
1257
1258 /**
1259--- kernel-source-2.4.18-2.4.18.orig/net/netsyms.c
1260+++ kernel-source-2.4.18-2.4.18/net/netsyms.c
1261@@ -489,6 +489,7 @@
1262 EXPORT_SYMBOL(__kfree_skb);
1263 EXPORT_SYMBOL(skb_clone);
1264 EXPORT_SYMBOL(skb_copy);
1265+EXPORT_SYMBOL(skb_pad);
1266 EXPORT_SYMBOL(netif_rx);
1267 EXPORT_SYMBOL(dev_add_pack);
1268 EXPORT_SYMBOL(dev_remove_pack);
1269--- kernel-source-2.4.18-2.4.18.orig/net/core/skbuff.c
1270+++ kernel-source-2.4.18-2.4.18/net/core/skbuff.c
1271@@ -731,6 +731,36 @@
1272 return n;
1273 }
1274
1275+/**
1276+ * skb_pad - zero pad the tail of an skb
1277+ * @skb: buffer to pad
1278+ * @pad: space to pad
1279+ *
1280+ * Ensure that a buffer is followed by a padding area that is zero
1281+ * filled. Used by network drivers which may DMA or transfer data
1282+ * beyond the buffer end onto the wire.
1283+ *
1284+ * May return NULL in out of memory cases.
1285+ */
1286+
1287+struct sk_buff *skb_pad(struct sk_buff *skb, int pad)
1288+{
1289+ struct sk_buff *nskb;
1290+
1291+ /* If the skbuff is non linear tailroom is always zero.. */
1292+ if(skb_tailroom(skb) >= pad)
1293+ {
1294+ memset(skb->data+skb->len, 0, pad);
1295+ return skb;
1296+ }
1297+
1298+ nskb = skb_copy_expand(skb, skb_headroom(skb), skb_tailroom(skb) + pad, GFP_ATOMIC);
1299+ kfree_skb(skb);
1300+ if(nskb)
1301+ memset(nskb->data+nskb->len, 0, pad);
1302+ return nskb;
1303+}
1304+
1305 /* Trims skb to length len. It can change skb pointers, if "realloc" is 1.
1306 * If realloc==0 and trimming is impossible without change of data,
1307 * it is BUG().
This page took 0.267225 seconds and 4 git commands to generate.