]> err.no Git - linux-2.6/blobdiff - net/ipv4/ipvs/ip_vs_app.c
[NET]: Make core networking code use seq_open_private
[linux-2.6] / net / ipv4 / ipvs / ip_vs_app.c
index 22e104c6a49387fafdd139f9ca1b07bd849fbc38..341474eefa557846a9332348bea21cd247106e62 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/skbuff.h>
 #include <linux/in.h>
 #include <linux/ip.h>
+#include <net/net_namespace.h>
 #include <net/protocol.h>
 #include <net/tcp.h>
 #include <asm/system.h>
@@ -331,14 +332,14 @@ static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff **pskb,
                                  struct ip_vs_app *app)
 {
        int diff;
-       unsigned int tcp_offset = (*pskb)->nh.iph->ihl*4;
+       const unsigned int tcp_offset = ip_hdrlen(*pskb);
        struct tcphdr *th;
        __u32 seq;
 
        if (!ip_vs_make_skb_writable(pskb, tcp_offset + sizeof(*th)))
                return 0;
 
-       th = (struct tcphdr *)((*pskb)->nh.raw + tcp_offset);
+       th = (struct tcphdr *)(skb_network_header(*pskb) + tcp_offset);
 
        /*
         *      Remember seq number in case this pkt gets resized
@@ -406,14 +407,14 @@ static inline int app_tcp_pkt_in(struct ip_vs_conn *cp, struct sk_buff **pskb,
                                 struct ip_vs_app *app)
 {
        int diff;
-       unsigned int tcp_offset = (*pskb)->nh.iph->ihl*4;
+       const unsigned int tcp_offset = ip_hdrlen(*pskb);
        struct tcphdr *th;
        __u32 seq;
 
        if (!ip_vs_make_skb_writable(pskb, tcp_offset + sizeof(*th)))
                return 0;
 
-       th = (struct tcphdr *)((*pskb)->nh.raw + tcp_offset);
+       th = (struct tcphdr *)(skb_network_header(*pskb) + tcp_offset);
 
        /*
         *      Remember seq number in case this pkt gets resized
@@ -549,7 +550,7 @@ static int ip_vs_app_seq_show(struct seq_file *seq, void *v)
        return 0;
 }
 
-static struct seq_operations ip_vs_app_seq_ops = {
+static const struct seq_operations ip_vs_app_seq_ops = {
        .start = ip_vs_app_seq_start,
        .next  = ip_vs_app_seq_next,
        .stop  = ip_vs_app_seq_stop,
@@ -577,7 +578,6 @@ static const struct file_operations ip_vs_app_fops = {
 int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri,
                      char *o_buf, int o_len, char *n_buf, int n_len)
 {
-       struct iphdr *iph;
        int diff;
        int o_offset;
        int o_left;
@@ -603,12 +603,11 @@ int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri,
                skb_put(skb, diff);
                memmove(skb->data + o_offset + n_len,
                        skb->data + o_offset + o_len, o_left);
-               memcpy(skb->data + o_offset, n_buf, n_len);
+               skb_copy_to_linear_data_offset(skb, o_offset, n_buf, n_len);
        }
 
        /* must update the iph total length here */
-       iph = skb->nh.iph;
-       iph->tot_len = htons(skb->len);
+       ip_hdr(skb)->tot_len = htons(skb->len);
 
        LeaveFunction(9);
        return 0;
@@ -618,12 +617,12 @@ int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri,
 int ip_vs_app_init(void)
 {
        /* we will replace it with proc_net_ipvs_create() soon */
-       proc_net_fops_create("ip_vs_app", 0, &ip_vs_app_fops);
+       proc_net_fops_create(&init_net, "ip_vs_app", 0, &ip_vs_app_fops);
        return 0;
 }
 
 
 void ip_vs_app_cleanup(void)
 {
-       proc_net_remove("ip_vs_app");
+       proc_net_remove(&init_net, "ip_vs_app");
 }