patch-2.4.4 linux/net/ipv4/ipip.c
Next file: linux/net/ipv4/ipmr.c
Previous file: linux/net/ipv4/ip_sockglue.c
Back to the patch index
Back to the overall index
- Lines: 157
- Date:
Wed Apr 25 14:57:39 2001
- Orig file:
v2.4.3/linux/net/ipv4/ipip.c
- Orig date:
Tue Nov 28 21:53:45 2000
diff -u --recursive --new-file v2.4.3/linux/net/ipv4/ipip.c linux/net/ipv4/ipip.c
@@ -1,7 +1,7 @@
/*
* Linux NET3: IP/IP protocol decoder.
*
- * Version: $Id: ipip.c,v 1.41 2000/11/28 13:13:27 davem Exp $
+ * Version: $Id: ipip.c,v 1.45 2001/04/19 22:32:55 davem Exp $
*
* Authors:
* Sam Lantinga (slouken@cs.ucdavis.edu) 02/01/95
@@ -123,11 +123,13 @@
static int ipip_tunnel_init(struct net_device *dev);
static struct net_device ipip_fb_tunnel_dev = {
- "tunl0", 0x0, 0x0, 0x0, 0x0, 0, 0, 0, 0, 0, NULL, ipip_fb_tunnel_init,
+ name: "tunl0",
+ init: ipip_fb_tunnel_init,
};
static struct ip_tunnel ipip_fb_tunnel = {
- NULL, &ipip_fb_tunnel_dev, {0, }, 0, 0, 0, 0, 0, 0, 0, {"tunl0", }
+ dev: &ipip_fb_tunnel_dev,
+ parms: { name: "tunl0", }
};
static struct ip_tunnel *tunnels_r_l[HASH_SIZE];
@@ -281,14 +283,12 @@
write_lock_bh(&ipip_lock);
tunnels_wc[0] = NULL;
write_unlock_bh(&ipip_lock);
- dev_put(dev);
- } else {
+ } else
ipip_tunnel_unlink((struct ip_tunnel*)dev->priv);
- dev_put(dev);
- }
+ dev_put(dev);
}
-void ipip_err(struct sk_buff *skb, unsigned char *dp, int len)
+void ipip_err(struct sk_buff *skb, u32 info)
{
#ifndef I_WISH_WORLD_WERE_PERFECT
@@ -296,14 +296,11 @@
8 bytes of packet payload. It means, that precise relaying of
ICMP in the real Internet is absolutely infeasible.
*/
- struct iphdr *iph = (struct iphdr*)dp;
+ struct iphdr *iph = (struct iphdr*)skb->data;
int type = skb->h.icmph->type;
int code = skb->h.icmph->code;
struct ip_tunnel *t;
- if (len < sizeof(struct iphdr))
- return;
-
switch (type) {
default:
case ICMP_PARAMETERPROB:
@@ -473,17 +470,19 @@
IP_ECN_set_ce(iph);
}
-int ipip_rcv(struct sk_buff *skb, unsigned short len)
+int ipip_rcv(struct sk_buff *skb)
{
struct iphdr *iph;
struct ip_tunnel *tunnel;
+ if (!pskb_may_pull(skb, sizeof(struct iphdr)))
+ goto out;
+
iph = skb->nh.iph;
skb->mac.raw = skb->nh.raw;
- skb->nh.raw = skb_pull(skb, skb->h.raw - skb->data);
+ skb->nh.raw = skb->data;
memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
skb->protocol = __constant_htons(ETH_P_IP);
- skb->ip_summed = 0;
skb->pkt_type = PACKET_HOST;
read_lock(&ipip_lock);
@@ -508,6 +507,7 @@
read_unlock(&ipip_lock);
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PROT_UNREACH, 0);
+out:
kfree_skb(skb);
return 0;
}
@@ -794,8 +794,6 @@
dev->do_ioctl = ipip_tunnel_ioctl;
dev->change_mtu = ipip_tunnel_change_mtu;
- dev_init_buffers(dev);
-
dev->type = ARPHRD_TUNNEL;
dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr);
dev->mtu = 1500 - sizeof(struct iphdr);
@@ -873,44 +871,34 @@
}
static struct inet_protocol ipip_protocol = {
- ipip_rcv, /* IPIP handler */
- ipip_err, /* TUNNEL error control */
- 0, /* next */
- IPPROTO_IPIP, /* protocol ID */
- 0, /* copy */
- NULL, /* data */
- "IPIP" /* name */
+ handler: ipip_rcv,
+ err_handler: ipip_err,
+ protocol: IPPROTO_IPIP,
+ name: "IPIP"
};
-#ifdef MODULE
-int init_module(void)
-#else
+static const char banner[] __initdata =
+ KERN_INFO "IPv4 over IPv4 tunneling driver\n";
+
int __init ipip_init(void)
-#endif
{
- printk(KERN_INFO "IPv4 over IPv4 tunneling driver\n");
+ printk(banner);
ipip_fb_tunnel_dev.priv = (void*)&ipip_fb_tunnel;
-#ifdef MODULE
register_netdev(&ipip_fb_tunnel_dev);
-#else
- rtnl_lock();
- register_netdevice(&ipip_fb_tunnel_dev);
- rtnl_unlock();
-#endif
-
inet_add_protocol(&ipip_protocol);
return 0;
}
-#ifdef MODULE
-
-void cleanup_module(void)
+static void __exit ipip_fini(void)
{
if ( inet_del_protocol(&ipip_protocol) < 0 )
printk(KERN_INFO "ipip close: can't remove protocol\n");
- unregister_netdevice(&ipip_fb_tunnel_dev);
+ unregister_netdev(&ipip_fb_tunnel_dev);
}
+#ifdef MODULE
+module_init(ipip_init);
#endif
+module_exit(ipip_fini);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)