]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/raw.c
Merge branches 'omap1-upstream' and 'omap2-upstream' into devel
[linux-2.6-omap-h63xx.git] / net / ipv4 / raw.c
index 87e9c1618100f4798c8f39cd56a0b32919cccbbf..3916faca3afef64fcbc8d583715b384f364c56d7 100644 (file)
@@ -59,6 +59,7 @@
 #include <linux/in_route.h>
 #include <linux/route.h>
 #include <linux/skbuff.h>
+#include <net/net_namespace.h>
 #include <net/dst.h>
 #include <net/sock.h>
 #include <linux/gfp.h>
@@ -132,7 +133,7 @@ static __inline__ int icmp_filter(struct sock *sk, struct sk_buff *skb)
        if (!pskb_may_pull(skb, sizeof(struct icmphdr)))
                return 1;
 
-       type = skb->h.icmph->type;
+       type = icmp_hdr(skb)->type;
        if (type < 32) {
                __u32 data = raw_sk(sk)->filter.data;
 
@@ -184,8 +185,8 @@ out:
 void raw_err (struct sock *sk, struct sk_buff *skb, u32 info)
 {
        struct inet_sock *inet = inet_sk(sk);
-       int type = skb->h.icmph->type;
-       int code = skb->h.icmph->code;
+       const int type = icmp_hdr(skb)->type;
+       const int code = icmp_hdr(skb)->code;
        int err = 0;
        int harderr = 0;
 
@@ -256,7 +257,7 @@ int raw_rcv(struct sock *sk, struct sk_buff *skb)
        }
        nf_reset(skb);
 
-       skb_push(skb, skb->data - skb->nh.raw);
+       skb_push(skb, skb->data - skb_network_header(skb));
 
        raw_rcv_skb(sk, skb);
        return 0;
@@ -291,11 +292,13 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
        skb->priority = sk->sk_priority;
        skb->dst = dst_clone(&rt->u.dst);
 
-       skb->nh.iph = iph = (struct iphdr *)skb_put(skb, length);
+       skb_reset_network_header(skb);
+       iph = ip_hdr(skb);
+       skb_put(skb, length);
 
        skb->ip_summed = CHECKSUM_NONE;
 
-       skb->h.raw = skb->nh.raw;
+       skb->transport_header = skb->network_header;
        err = memcpy_fromiovecend((void *)iph, from, 0, length);
        if (err)
                goto error_fault;
@@ -311,6 +314,9 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
 
                iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
        }
+       if (iph->protocol == IPPROTO_ICMP)
+               icmp_out_count(((struct icmphdr *)
+                       skb_transport_header(skb))->type);
 
        err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
                      dst_output);
@@ -613,7 +619,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        /* Copy the address. */
        if (sin) {
                sin->sin_family = AF_INET;
-               sin->sin_addr.s_addr = skb->nh.iph->saddr;
+               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
                sin->sin_port = 0;
                memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
        }
@@ -887,7 +893,7 @@ static int raw_seq_show(struct seq_file *seq, void *v)
        return 0;
 }
 
-static struct seq_operations raw_seq_ops = {
+static const struct seq_operations raw_seq_ops = {
        .start = raw_seq_start,
        .next  = raw_seq_next,
        .stop  = raw_seq_stop,
@@ -896,24 +902,8 @@ static struct seq_operations raw_seq_ops = {
 
 static int raw_seq_open(struct inode *inode, struct file *file)
 {
-       struct seq_file *seq;
-       int rc = -ENOMEM;
-       struct raw_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
-
-       if (!s)
-               goto out;
-       rc = seq_open(file, &raw_seq_ops);
-       if (rc)
-               goto out_kfree;
-
-       seq = file->private_data;
-       seq->private = s;
-       memset(s, 0, sizeof(*s));
-out:
-       return rc;
-out_kfree:
-       kfree(s);
-       goto out;
+       return seq_open_private(file, &raw_seq_ops,
+                       sizeof(struct raw_iter_state));
 }
 
 static const struct file_operations raw_seq_fops = {
@@ -926,13 +916,13 @@ static const struct file_operations raw_seq_fops = {
 
 int __init raw_proc_init(void)
 {
-       if (!proc_net_fops_create("raw", S_IRUGO, &raw_seq_fops))
+       if (!proc_net_fops_create(&init_net, "raw", S_IRUGO, &raw_seq_fops))
                return -ENOMEM;
        return 0;
 }
 
 void __init raw_proc_exit(void)
 {
-       proc_net_remove("raw");
+       proc_net_remove(&init_net, "raw");
 }
 #endif /* CONFIG_PROC_FS */