diff -Nurp linux-2.6.22-592/drivers/net/gre.c linux-2.6.22-593/drivers/net/gre.c
--- linux-2.6.22-592/drivers/net/gre.c 1969-12-31 19:00:00.000000000 -0500
+++ linux-2.6.22-593/drivers/net/gre.c 2008-02-28 13:51:50.000000000 -0500
-@@ -0,0 +1,1634 @@
+@@ -0,0 +1,1632 @@
+/*
+ * Linux NET3: GRE over IP protocol decoder.
+ *
+#endif
+
+
-+/* XXX skb->h.raw = skb->nh.raw; XXX */
-+// skb->h.raw = skb->mac.raw;
+ skb->transport_header = skb->mac_header; // Added by valas
-+
+ skb_push(skb, gre_hlen);
++ skb_reset_network_header(skb);
+ memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
+ dst_release(skb->dst);
+ skb->dst = &rt->u.dst;
};
diff -Nurp linux-2.6.22-592/net/ipv4/ip_gre.c linux-2.6.22-593/net/ipv4/ip_gre.c
---- linux-2.6.22-592/net/ipv4/ip_gre.c 2008-02-28 13:51:40.000000000 -0500
-+++ linux-2.6.22-593/net/ipv4/ip_gre.c 2008-02-28 14:05:12.000000000 -0500
+--- linux-2.6.22-592/net/ipv4/ip_gre.c 2008-02-29 16:37:50.000000000 -0500
++++ linux-2.6.22-593/net/ipv4/ip_gre.c 2008-02-29 17:22:06.000000000 -0500
@@ -25,6 +25,7 @@
#include <linux/init.h>
#include <linux/in6.h>
flags = *(__be16*)h;
+#ifdef GRE_DEBUG
-+ printk(KERN_DEBUG "gre.c [601] src:%x dst:%x proto:%d %x", iph->saddr, iph->daddr, iph->protocol, skb->data);
++ printk(KERN_DEBUG "gre.c [601] src:%x dst:%x proto:%d %p", iph->saddr, iph->daddr, iph->protocol, skb->data);
+#endif
+ proto = ntohs(*(__be16*)(h+2)); /* XXX added XXX */
+
+ {
+#ifdef GRE_DEBUG
+ unsigned char* tmp_hdr = skb->data;
-+ printk(KERN_DEBUG "gre.c [658] %x %x %x %x %x %x\tskb %x\n", tmp_hdr[0], tmp_hdr[1], tmp_hdr[2], tmp_hdr[3], tmp_hdr[4], tmp_hdr[5], skb->data);
++ printk(KERN_DEBUG "gre.c [658] %x %x %x %x %x %x\tskb %p\n", tmp_hdr[0], tmp_hdr[1], tmp_hdr[2], tmp_hdr[3], tmp_hdr[4], tmp_hdr[5], skb->data);
+#endif
+ skb->protocol = eth_type_trans(skb, tunnel->dev);
+
+
+#ifdef GRE_DEBUG
+ tmp_hdr = skb->data;
-+ printk(KERN_DEBUG "gre.c [669] %x %x %x %x %x %x\tskb %x\n", tmp_hdr[0], tmp_hdr[1], tmp_hdr[2], tmp_hdr[3], tmp_hdr[4], tmp_hdr[5], skb->data);
-+ printk(KERN_ALERT "gre.c [671] received ethernet on gre %x %x\n",skb->protocol, ((skb->nh).iph)->protocol);
++ printk(KERN_DEBUG "gre.c [669] %x %x %x %x %x %x\tskb %p\n", tmp_hdr[0], tmp_hdr[1], tmp_hdr[2], tmp_hdr[3], tmp_hdr[4], tmp_hdr[5], skb->data);
++ printk(KERN_ALERT "gre.c [671] received ethernet on gre %x\n",skb->protocol);
+#endif
+ memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
+ }
{
struct ip_tunnel *tunnel = netdev_priv(dev);
struct net_device_stats *stats = &tunnel->stat;
-@@ -904,6 +951,231 @@ tx_error:
+@@ -904,6 +951,228 @@ tx_error:
return 0;
}
+ printk(KERN_ALERT "gre.c:1094 Passed the headroom calculation\n");
+#endif
+
-+
-+/* XXX skb->h.raw = skb->nh.raw; XXX */
-+// skb->h.raw = skb->mac.raw;
-+ skb->transport_header = skb->mac_header; // Added by valas
-+
++ skb->transport_header = skb->data;
+ skb_push(skb, gre_hlen);
++ skb_reset_network_header(skb);
+ memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
+ dst_release(skb->dst);
+ skb->dst = &rt->u.dst;
if ((dev->flags^nflags)&(IFF_POINTOPOINT|IFF_BROADCAST)) {
err = -EINVAL;
-@@ -978,6 +1258,8 @@ ipgre_tunnel_ioctl (struct net_device *d
+@@ -978,8 +1258,12 @@ ipgre_tunnel_ioctl (struct net_device *d
t->parms.iph.daddr = p.iph.daddr;
t->parms.i_key = p.i_key;
t->parms.o_key = p.o_key;
+- memcpy(dev->dev_addr, &p.iph.saddr, 4);
+- memcpy(dev->broadcast, &p.iph.daddr, 4);
+ /* XXX:Copy in the protocol field */
+ t->parms.proto_type = p.proto_type;
- memcpy(dev->dev_addr, &p.iph.saddr, 4);
- memcpy(dev->broadcast, &p.iph.daddr, 4);
++ if (t->parms.proto_type != ETH_P_ETH) {
++ memcpy(dev->dev_addr, &p.iph.saddr, 4);
++ memcpy(dev->broadcast, &p.iph.daddr, 4);
++ }
ipgre_tunnel_link(t);
-@@ -1139,12 +1421,12 @@ static int ipgre_close(struct net_device
+ netdev_state_change(dev);
+ }
+@@ -1139,12 +1423,12 @@ static int ipgre_close(struct net_device
#endif
dev->get_stats = ipgre_tunnel_get_stats;
dev->do_ioctl = ipgre_tunnel_ioctl;
dev->change_mtu = ipgre_tunnel_change_mtu;
-@@ -1157,6 +1439,36 @@ static void ipgre_tunnel_setup(struct ne
+@@ -1157,6 +1441,35 @@ static void ipgre_tunnel_setup(struct ne
dev->addr_len = 4;
}
+static void ipgre_eth_tunnel_setup(struct net_device *dev)
+{
+ SET_MODULE_OWNER(dev);
++
++ // Set default values for Ethernet device
+ ether_setup(dev);
+
+ dev->uninit = ipgre_tunnel_uninit;
+ dev->do_ioctl = ipgre_tunnel_ioctl;
+ dev->change_mtu = ipgre_tunnel_change_mtu;
+
-+ dev->type = ARPHRD_IPGRE;
-+ dev->hard_header_len = ETH_HLEN + sizeof(struct iphdr) + 4;
-+ dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 4;
-+ dev->flags = 0;
++ dev->hard_header_len = LL_MAX_HEADER + ETH_HLEN + sizeof(struct iphdr) + 4;
++ dev->mtu = ETH_DATA_LEN - ETH_HLEN - sizeof(struct iphdr) - 4;
+ dev->tx_queue_len = 0;
++ dev->iflink = 0;
++
+ random_ether_addr(dev->dev_addr);
+
+#ifdef GRE_DEBUG
-+ unsigned char* d = dev->dev_addr;
-+ printk(KERN_ALERT "Here is the address we got:%x%x%x%x%x%x\n",d[0],d[1],d[2],d[3],d[4],d[5]);
++ { unsigned char* d = dev->dev_addr;
++ printk(KERN_ALERT "Here is the address we got:%x%x%x%x%x%x\n",d[0],d[1],d[2],d[3],d[4],d[5]); }
+#endif
-+
-+ dev->iflink = 0;
-+ dev->addr_len = 4;
+}
+
+
static int ipgre_tunnel_init(struct net_device *dev)
{
struct net_device *tdev = NULL;
-@@ -1191,7 +1503,14 @@ static int ipgre_tunnel_init(struct net_
+@@ -1172,8 +1486,12 @@ static int ipgre_tunnel_init(struct net_
+ tunnel->dev = dev;
+ strcpy(tunnel->parms.name, dev->name);
+
+- memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
+- memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
++ if (tunnel->parms.proto_type != ETH_P_ETH) {
++ memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
++ memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
++ } else {
++ addend += ETH_HLEN;
++ }
+
+ /* Guess output device to choose reasonable mtu and hard_header_len */
+
+@@ -1191,7 +1507,14 @@ static int ipgre_tunnel_init(struct net_
ip_rt_put(rt);
}
#ifdef CONFIG_NET_IPGRE_BROADCAST
if (MULTICAST(iph->daddr)) {
-@@ -1270,7 +1589,7 @@ static int __init ipgre_init(void)
+@@ -1270,7 +1593,7 @@ static int __init ipgre_init(void)
}
ipgre_fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "gre0",