Change the ethernet support routines to use constant address size.
This generates smaller faster code.

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>


--- sky2-2.6.17.orig/net/ethernet/eth.c 2006-03-07 13:28:54.000000000 -0800
+++ sky2-2.6.17/net/ethernet/eth.c      2006-04-12 13:10:56.000000000 -0700
@@ -77,6 +77,8 @@
 {
        struct ethhdr *eth = (struct ethhdr *)skb_push(skb,ETH_HLEN);
 
+       BUG_ON(dev->addr_len != ETH_ALEN);
+
        /* 
         *      Set the protocol type. For a packet of type ETH_P_802_3 we put 
the length
         *      in here instead. It is up to the 802.2 layer to carry protocol 
information.
@@ -93,11 +95,11 @@
         
        if(!saddr)
                saddr = dev->dev_addr;
-       memcpy(eth->h_source,saddr,dev->addr_len);
+       memcpy(eth->h_source,saddr, ETH_ALEN);
 
        if(daddr)
        {
-               memcpy(eth->h_dest,daddr,dev->addr_len);
+               memcpy(eth->h_dest,daddr, ETH_ALEN);
                return ETH_HLEN;
        }
        
@@ -107,7 +109,7 @@
 
        if (dev->flags & (IFF_LOOPBACK|IFF_NOARP)) 
        {
-               memset(eth->h_dest, 0, dev->addr_len);
+               memset(eth->h_dest, 0, ETH_ALEN);
                return ETH_HLEN;
        }
        
@@ -140,7 +142,7 @@
                       "%s: unable to resolve type %X addresses.\n", 
                       dev->name, (int)eth->h_proto);
                
-               memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
+               memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
                break;
        }
 
@@ -223,8 +225,8 @@
                return -1;
 
        eth->h_proto = type;
-       memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
-       memcpy(eth->h_dest, neigh->ha, dev->addr_len);
+       memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
+       memcpy(eth->h_dest, neigh->ha, ETH_ALEN);
        hh->hh_len = ETH_HLEN;
        return 0;
 }
@@ -236,7 +238,7 @@
 void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev, 
unsigned char * haddr)
 {
        memcpy(((u8*)hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
-              haddr, dev->addr_len);
+              haddr, ETH_ALEN);
 }
 
 EXPORT_SYMBOL(eth_type_trans);
@@ -246,7 +248,7 @@
        struct sockaddr *addr=p;
        if (netif_running(dev))
                return -EBUSY;
-       memcpy(dev->dev_addr, addr->sa_data,dev->addr_len);
+       memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
        return 0;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to