patch-2.1.15 linux/net/ethernet/eth.c

Next file: linux/net/ipv4/Config.in
Previous file: linux/net/core/sock.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.14/linux/net/ethernet/eth.c linux/net/ethernet/eth.c
@@ -46,11 +46,13 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/inet.h>
+#include <linux/ip.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/errno.h>
 #include <linux/config.h>
+#include <net/dst.h>
 #include <net/arp.h>
 #include <net/sock.h>
 #include <net/ipv6.h>
@@ -150,10 +152,10 @@
  *	sk_buff. We now let ARP fill in the other fields.
  */
  
-int eth_rebuild_header(void *buff, struct device *dev, unsigned long dst,
-			struct sk_buff *skb)
+int eth_rebuild_header(struct sk_buff *skb)
 {
-	struct ethhdr *eth = (struct ethhdr *)buff;
+	struct ethhdr *eth = (struct ethhdr *)skb->data;
+	struct device *dev = skb->dev;
 
 	/*
 	 *	Only ARP/IP and NDISC/IPv6 are currently supported
@@ -168,8 +170,7 @@
 		 *	Try to get ARP to resolve the header.
 		 */
 
-		return (arp_find(eth->h_dest, dst, dev, dev->pa_addr, skb) ? 
-			1 : 0);
+		return arp_find(eth->h_dest, skb) ? 1 : 0;
 		break;
 #endif
 
@@ -250,30 +251,38 @@
 	return htons(ETH_P_802_2);
 }
 
-/*
- * Upper level calls this function to bind hardware header cache entry.
- * If the call is successful, then corresponding Address Resolution Protocol
- * (maybe, not ARP) takes responsibility for updating cache content.
- */
-
-void eth_header_cache_bind(struct hh_cache ** hhp, struct device *dev,
-			   unsigned short htype, __u32 daddr)
+int eth_header_cache(struct dst_entry *dst, struct dst_entry *neigh, struct hh_cache *hh)
 {
-	struct hh_cache *hh;
+	unsigned short type = hh->hh_type;
+	struct ethhdr *eth = (struct ethhdr*)hh->hh_data;
+	struct device *dev = dst->dev;
 
-	if (htype != ETH_P_IP)
-	{
-		printk(KERN_DEBUG "eth_header_cache_bind: %04x cache is not implemented\n", htype);
-		return;
+	if (type == ETH_P_802_3)
+		return -1;
+	
+	eth->h_proto = htons(type);
+
+	memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
+
+	if (dev->flags & IFF_LOOPBACK) {
+		memset(eth->h_dest, 0, dev->addr_len);
+		hh->hh_uptodate = 1;
+		return 0;
 	}
-	if (arp_bind_cache(hhp, dev, htype, daddr))
-		return;
-	if ((hh=*hhp) != NULL)
+
+	if (type != ETH_P_IP) 
 	{
-		memcpy(hh->hh_data+6, dev->dev_addr, ETH_ALEN);
-		hh->hh_data[12] = htype>>8;
-		hh->hh_data[13] = htype&0xFF;
+		printk(KERN_DEBUG "%s: unable to resolve type %X addresses.\n",dev->name,(int)eth->h_proto);
+		hh->hh_uptodate = 0;
+		return 0;
 	}
+
+#ifdef CONFIG_INET
+	hh->hh_uptodate = arp_find_1(eth->h_dest, dst, neigh);
+#else
+	hh->hh_uptodate = 0;
+#endif
+	return 0;
 }
 
 /*

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov