net: Allow fib_rule_unregister to batch
[safe/jmp/linux-2.6] / net / decnet / dn_neigh.c
index bf701cf..794b5bf 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/rcupdate.h>
 #include <linux/jhash.h>
 #include <asm/atomic.h>
+#include <net/net_namespace.h>
 #include <net/neighbour.h>
 #include <net/dst.h>
 #include <net/flow.h>
@@ -58,7 +59,7 @@ static int dn_phase3_output(struct sk_buff *);
 /*
  * For talking to broadcast devices: Ethernet & PPP
  */
-static struct neigh_ops dn_long_ops = {
+static const struct neigh_ops dn_long_ops = {
        .family =               AF_DECnet,
        .error_report =         dn_long_error_report,
        .output =               dn_long_output,
@@ -70,7 +71,7 @@ static struct neigh_ops dn_long_ops = {
 /*
  * For talking to pointopoint and multidrop devices: DDCMP and X.25
  */
-static struct neigh_ops dn_short_ops = {
+static const struct neigh_ops dn_short_ops = {
        .family =               AF_DECnet,
        .error_report =         dn_short_error_report,
        .output =               dn_short_output,
@@ -82,7 +83,7 @@ static struct neigh_ops dn_short_ops = {
 /*
  * For talking to DECnet phase III nodes
  */
-static struct neigh_ops dn_phase3_ops = {
+static const struct neigh_ops dn_phase3_ops = {
        .family =               AF_DECnet,
        .error_report =         dn_short_error_report, /* Can use short version here */
        .output =               dn_phase3_output,
@@ -203,14 +204,15 @@ static void dn_short_error_report(struct neighbour *neigh, struct sk_buff *skb)
 
 static int dn_neigh_output_packet(struct sk_buff *skb)
 {
-       struct dst_entry *dst = skb->dst;
+       struct dst_entry *dst = skb_dst(skb);
        struct dn_route *rt = (struct dn_route *)dst;
        struct neighbour *neigh = dst->neighbour;
        struct net_device *dev = neigh->dev;
        char mac_addr[ETH_ALEN];
 
        dn_dn2eth(mac_addr, rt->rt_local_src);
-       if (!dev->hard_header || dev->hard_header(skb, dev, ntohs(skb->protocol), neigh->ha, mac_addr, skb->len) >= 0)
+       if (dev_hard_header(skb, dev, ntohs(skb->protocol), neigh->ha,
+                           mac_addr, skb->len) >= 0)
                return neigh->ops->queue_xmit(skb);
 
        if (net_ratelimit())
@@ -222,7 +224,7 @@ static int dn_neigh_output_packet(struct sk_buff *skb)
 
 static int dn_long_output(struct sk_buff *skb)
 {
-       struct dst_entry *dst = skb->dst;
+       struct dst_entry *dst = skb_dst(skb);
        struct neighbour *neigh = dst->neighbour;
        struct net_device *dev = neigh->dev;
        int headroom = dev->hard_header_len + sizeof(struct dn_long_packet) + 3;
@@ -248,7 +250,7 @@ static int dn_long_output(struct sk_buff *skb)
        data = skb_push(skb, sizeof(struct dn_long_packet) + 3);
        lp = (struct dn_long_packet *)(data+3);
 
-       *((__le16 *)data) = dn_htons(skb->len - 2);
+       *((__le16 *)data) = cpu_to_le16(skb->len - 2);
        *(data + 2) = 1 | DN_RT_F_PF; /* Padding */
 
        lp->msgflg   = DN_RT_PKT_LONG|(cb->rt_flags&(DN_RT_F_IE|DN_RT_F_RQR|DN_RT_F_RTS));
@@ -261,14 +263,14 @@ static int dn_long_output(struct sk_buff *skb)
        lp->s_class  = 0;
        lp->pt       = 0;
 
-       skb->nh.raw = skb->data;
+       skb_reset_network_header(skb);
 
        return NF_HOOK(PF_DECnet, NF_DN_POST_ROUTING, skb, NULL, neigh->dev, dn_neigh_output_packet);
 }
 
 static int dn_short_output(struct sk_buff *skb)
 {
-       struct dst_entry *dst = skb->dst;
+       struct dst_entry *dst = skb_dst(skb);
        struct neighbour *neigh = dst->neighbour;
        struct net_device *dev = neigh->dev;
        int headroom = dev->hard_header_len + sizeof(struct dn_short_packet) + 2;
@@ -292,7 +294,7 @@ static int dn_short_output(struct sk_buff *skb)
        }
 
        data = skb_push(skb, sizeof(struct dn_short_packet) + 2);
-       *((__le16 *)data) = dn_htons(skb->len - 2);
+       *((__le16 *)data) = cpu_to_le16(skb->len - 2);
        sp = (struct dn_short_packet *)(data+2);
 
        sp->msgflg     = DN_RT_PKT_SHORT|(cb->rt_flags&(DN_RT_F_RQR|DN_RT_F_RTS));
@@ -300,7 +302,7 @@ static int dn_short_output(struct sk_buff *skb)
        sp->srcnode    = cb->src;
        sp->forward    = cb->hops & 0x3f;
 
-       skb->nh.raw = skb->data;
+       skb_reset_network_header(skb);
 
        return NF_HOOK(PF_DECnet, NF_DN_POST_ROUTING, skb, NULL, neigh->dev, dn_neigh_output_packet);
 }
@@ -311,7 +313,7 @@ static int dn_short_output(struct sk_buff *skb)
  */
 static int dn_phase3_output(struct sk_buff *skb)
 {
-       struct dst_entry *dst = skb->dst;
+       struct dst_entry *dst = skb_dst(skb);
        struct neighbour *neigh = dst->neighbour;
        struct net_device *dev = neigh->dev;
        int headroom = dev->hard_header_len + sizeof(struct dn_short_packet) + 2;
@@ -334,15 +336,15 @@ static int dn_phase3_output(struct sk_buff *skb)
        }
 
        data = skb_push(skb, sizeof(struct dn_short_packet) + 2);
-       *((__le16 *)data) = dn_htons(skb->len - 2);
+       *((__le16 *)data) = cpu_to_le16(skb->len - 2);
        sp = (struct dn_short_packet *)(data + 2);
 
        sp->msgflg   = DN_RT_PKT_SHORT|(cb->rt_flags&(DN_RT_F_RQR|DN_RT_F_RTS));
-       sp->dstnode  = cb->dst & dn_htons(0x03ff);
-       sp->srcnode  = cb->src & dn_htons(0x03ff);
+       sp->dstnode  = cb->dst & cpu_to_le16(0x03ff);
+       sp->srcnode  = cb->src & cpu_to_le16(0x03ff);
        sp->forward  = cb->hops & 0x3f;
 
-       skb->nh.raw = skb->data;
+       skb_reset_network_header(skb);
 
        return NF_HOOK(PF_DECnet, NF_DN_POST_ROUTING, skb, NULL, neigh->dev, dn_neigh_output_packet);
 }
@@ -392,7 +394,7 @@ int dn_neigh_router_hello(struct sk_buff *skb)
                        if (neigh->dev->type == ARPHRD_ETHER)
                                memcpy(neigh->ha, &eth_hdr(skb)->h_source, ETH_ALEN);
 
-                       dn->blksize  = dn_ntohs(msg->blksize);
+                       dn->blksize  = le16_to_cpu(msg->blksize);
                        dn->priority = msg->priority;
 
                        dn->flags &= ~DN_NDFLAG_P3;
@@ -408,7 +410,7 @@ int dn_neigh_router_hello(struct sk_buff *skb)
                }
 
                /* Only use routers in our area */
-               if ((dn_ntohs(src)>>10) == (dn_ntohs((decnet_address))>>10)) {
+               if ((le16_to_cpu(src)>>10) == (le16_to_cpu((decnet_address))>>10)) {
                        if (!dn_db->router) {
                                dn_db->router = neigh_clone(neigh);
                        } else {
@@ -451,7 +453,7 @@ int dn_neigh_endnode_hello(struct sk_buff *skb)
                        if (neigh->dev->type == ARPHRD_ETHER)
                                memcpy(neigh->ha, &eth_hdr(skb)->h_source, ETH_ALEN);
                        dn->flags   &= ~(DN_NDFLAG_R1 | DN_NDFLAG_R2);
-                       dn->blksize  = dn_ntohs(msg->blksize);
+                       dn->blksize  = le16_to_cpu(msg->blksize);
                        dn->priority = 0;
                }
 
@@ -541,7 +543,7 @@ static inline void dn_neigh_format_entry(struct seq_file *seq,
 
        read_lock(&n->lock);
        seq_printf(seq, "%-7s %s%s%s   %02x    %02d  %07ld %-8s\n",
-                  dn_addr2asc(dn_ntohs(dn->addr), buf),
+                  dn_addr2asc(le16_to_cpu(dn->addr), buf),
                   (dn->flags&DN_NDFLAG_R1) ? "1" : "-",
                   (dn->flags&DN_NDFLAG_R2) ? "2" : "-",
                   (dn->flags&DN_NDFLAG_P3) ? "3" : "-",
@@ -569,7 +571,7 @@ static void *dn_neigh_seq_start(struct seq_file *seq, loff_t *pos)
                               NEIGH_SEQ_NEIGH_ONLY);
 }
 
-static struct seq_operations dn_neigh_seq_ops = {
+static const struct seq_operations dn_neigh_seq_ops = {
        .start = dn_neigh_seq_start,
        .next  = neigh_seq_next,
        .stop  = neigh_seq_stop,
@@ -578,24 +580,8 @@ static struct seq_operations dn_neigh_seq_ops = {
 
 static int dn_neigh_seq_open(struct inode *inode, struct file *file)
 {
-       struct seq_file *seq;
-       int rc = -ENOMEM;
-       struct neigh_seq_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-
-       if (!s)
-               goto out;
-
-       rc = seq_open(file, &dn_neigh_seq_ops);
-       if (rc)
-               goto out_kfree;
-
-       seq          = file->private_data;
-       seq->private = s;
-out:
-       return rc;
-out_kfree:
-       kfree(s);
-       goto out;
+       return seq_open_net(inode, file, &dn_neigh_seq_ops,
+                           sizeof(struct neigh_seq_state));
 }
 
 static const struct file_operations dn_neigh_seq_fops = {
@@ -603,7 +589,7 @@ static const struct file_operations dn_neigh_seq_fops = {
        .open           = dn_neigh_seq_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
-       .release        = seq_release_private,
+       .release        = seq_release_net,
 };
 
 #endif
@@ -611,11 +597,11 @@ static const struct file_operations dn_neigh_seq_fops = {
 void __init dn_neigh_init(void)
 {
        neigh_table_init(&dn_neigh_table);
-       proc_net_fops_create("decnet_neigh", S_IRUGO, &dn_neigh_seq_fops);
+       proc_net_fops_create(&init_net, "decnet_neigh", S_IRUGO, &dn_neigh_seq_fops);
 }
 
 void __exit dn_neigh_cleanup(void)
 {
-       proc_net_remove("decnet_neigh");
+       proc_net_remove(&init_net, "decnet_neigh");
        neigh_table_clear(&dn_neigh_table);
 }