linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][ATM] get minimum frame size right in lec.c
@ 2003-02-24 13:46 chas williams
  2003-03-03  8:56 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: chas williams @ 2003-02-24 13:46 UTC (permalink / raw)
  To: davem; +Cc: linux-kernel

the minimum frame size for token ring (802.5) pdus is 16 octets.  also,
count the pdus that failed to copy as dropped.  also, skb_copy_expand()
now seems to be the right way to do this.

Index: linux/net/atm/lec.c
===================================================================
RCS file: /home/chas/CVSROOT/linux/net/atm/lec.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -b -w -r1.5 -r1.6
--- linux/net/atm/lec.c	22 Feb 2003 19:23:22 -0000	1.5
+++ linux/net/atm/lec.c	24 Feb 2003 13:24:45 -0000	1.6
@@ -223,7 +223,8 @@
         struct lecdatahdr_8023 *lec_h;
         struct atm_vcc *send_vcc;
 	struct lec_arp_table *entry;
-        unsigned char *nb, *dst;
+        unsigned char *dst;
+	int min_frame_size;
 #ifdef CONFIG_TR
         unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */
 #endif
@@ -294,26 +295,24 @@
 #endif /* DUMP_PACKETS > 0 */
 
         /* Minimum ethernet-frame size */
-        if (skb->len <62) {
-                if (skb->truesize < 62) {
-                        printk("%s:data packet %d / %d\n",
-                               dev->name,
-                               skb->len,skb->truesize);
-                        nb=(unsigned char*)kmalloc(64, GFP_ATOMIC);
-                        if (nb == NULL) {
+#ifdef CONFIG_TR
+        if (priv->is_trdev)
+                min_frame_size = LEC_MINIMUM_8025_SIZE;
+	else
+#endif
+        min_frame_size = LEC_MINIMUM_8023_SIZE;
+        if (skb->len < min_frame_size) {
+                if (skb->truesize < min_frame_size) {
+                        skb2 = skb_copy_expand(skb, 0,
+                            min_frame_size - skb->truesize, GFP_ATOMIC);
                                 dev_kfree_skb(skb);
+                        if (skb2 == NULL) {
+                                priv->stats.tx_dropped++;
                                 return 0;
                         }
-                        memcpy(nb,skb->data,skb->len);
-                        kfree(skb->head);
-                        skb->head = skb->data = nb;
-                        skb->tail = nb+62;
-                        skb->end = nb+64;
-                        skb->len=62;
-                        skb->truesize = 64;
-                } else {
-                        skb->len = 62;
+                        skb = skb2;
                 }
+		skb_put(skb, min_frame_size - skb->len);
         }
         
         /* Send to right vcc */
Index: linux/net/atm/lec.h
===================================================================
RCS file: /home/chas/CVSROOT/linux/net/atm/lec.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -b -w -r1.2 -r1.3
--- linux/net/atm/lec.h	22 Feb 2003 19:29:27 -0000	1.2
+++ linux/net/atm/lec.h	24 Feb 2003 13:24:46 -0000	1.3
@@ -38,6 +38,9 @@
   unsigned char h_source[ETH_ALEN];
 };
 
+#define LEC_MINIMUM_8023_SIZE   62
+#define LEC_MINIMUM_8025_SIZE   16
+
 /*
  * Operations that LANE2 capable device can do. Two first functions
  * are used to make the device do things. See spec 3.1.3 and 3.1.4.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][ATM] get minimum frame size right in lec.c
  2003-02-24 13:46 [PATCH][ATM] get minimum frame size right in lec.c chas williams
@ 2003-03-03  8:56 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2003-03-03  8:56 UTC (permalink / raw)
  To: chas; +Cc: linux-kernel

   From: chas williams <chas@locutus.cmf.nrl.navy.mil>
   Date: Mon, 24 Feb 2003 08:46:56 -0500

   the minimum frame size for token ring (802.5) pdus is 16 octets.  also,
   count the pdus that failed to copy as dropped.  also, skb_copy_expand()
   now seems to be the right way to do this.
   
Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-03-03  9:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-24 13:46 [PATCH][ATM] get minimum frame size right in lec.c chas williams
2003-03-03  8:56 ` David S. Miller

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).