]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/ipvs/ip_vs_proto_tcp.c
Merge master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6-omap-h63xx.git] / net / ipv4 / ipvs / ip_vs_proto_tcp.c
index 6ff05c3a32e67913191c114dc2644dbfafbfe1fd..e65577a77006f3ed199f8e8c640a11123c97326e 100644 (file)
@@ -76,16 +76,15 @@ tcp_conn_schedule(struct sk_buff *skb,
        struct ip_vs_service *svc;
        struct tcphdr _tcph, *th;
 
-       th = skb_header_pointer(skb, skb->nh.iph->ihl*4,
-                               sizeof(_tcph), &_tcph);
+       th = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph);
        if (th == NULL) {
                *verdict = NF_DROP;
                return 0;
        }
 
        if (th->syn &&
-           (svc = ip_vs_service_get(skb->nfmark, skb->nh.iph->protocol,
-                                    skb->nh.iph->daddr, th->dest))) {
+           (svc = ip_vs_service_get(skb->mark, ip_hdr(skb)->protocol,
+                                    ip_hdr(skb)->daddr, th->dest))) {
                if (ip_vs_todrop()) {
                        /*
                         * It seems that we are very loaded.
@@ -116,9 +115,9 @@ tcp_fast_csum_update(struct tcphdr *tcph, __be32 oldip, __be32 newip,
                     __be16 oldport, __be16 newport)
 {
        tcph->check =
-               ip_vs_check_diff(~oldip, newip,
-                                ip_vs_check_diff(oldport ^ htons(0xFFFF),
-                                                 newport, tcph->check));
+               csum_fold(ip_vs_check_diff4(oldip, newip,
+                                ip_vs_check_diff2(oldport, newport,
+                                               ~csum_unfold(tcph->check))));
 }
 
 
@@ -127,7 +126,7 @@ tcp_snat_handler(struct sk_buff **pskb,
                 struct ip_vs_protocol *pp, struct ip_vs_conn *cp)
 {
        struct tcphdr *tcph;
-       unsigned int tcphoff = (*pskb)->nh.iph->ihl * 4;
+       const unsigned int tcphoff = ip_hdrlen(*pskb);
 
        /* csum_check requires unshared skb */
        if (!ip_vs_make_skb_writable(pskb, tcphoff+sizeof(*tcph)))
@@ -143,7 +142,7 @@ tcp_snat_handler(struct sk_buff **pskb,
                        return 0;
        }
 
-       tcph = (void *)(*pskb)->nh.iph + tcphoff;
+       tcph = (void *)ip_hdr(*pskb) + tcphoff;
        tcph->source = cp->vport;
 
        /* Adjust TCP checksums */
@@ -175,7 +174,7 @@ tcp_dnat_handler(struct sk_buff **pskb,
                 struct ip_vs_protocol *pp, struct ip_vs_conn *cp)
 {
        struct tcphdr *tcph;
-       unsigned int tcphoff = (*pskb)->nh.iph->ihl * 4;
+       const unsigned int tcphoff = ip_hdrlen(*pskb);
 
        /* csum_check requires unshared skb */
        if (!ip_vs_make_skb_writable(pskb, tcphoff+sizeof(*tcph)))
@@ -194,7 +193,7 @@ tcp_dnat_handler(struct sk_buff **pskb,
                        return 0;
        }
 
-       tcph = (void *)(*pskb)->nh.iph + tcphoff;
+       tcph = (void *)ip_hdr(*pskb) + tcphoff;
        tcph->dest = cp->dport;
 
        /*
@@ -224,15 +223,15 @@ tcp_dnat_handler(struct sk_buff **pskb,
 static int
 tcp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
 {
-       unsigned int tcphoff = skb->nh.iph->ihl*4;
+       const unsigned int tcphoff = ip_hdrlen(skb);
 
        switch (skb->ip_summed) {
        case CHECKSUM_NONE:
                skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
        case CHECKSUM_COMPLETE:
-               if (csum_tcpudp_magic(skb->nh.iph->saddr, skb->nh.iph->daddr,
+               if (csum_tcpudp_magic(ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
                                      skb->len - tcphoff,
-                                     skb->nh.iph->protocol, skb->csum)) {
+                                     ip_hdr(skb)->protocol, skb->csum)) {
                        IP_VS_DBG_RL_PKT(0, pp, skb, 0,
                                         "Failed checksum for");
                        return 0;
@@ -467,8 +466,7 @@ tcp_state_transition(struct ip_vs_conn *cp, int direction,
 {
        struct tcphdr _tcph, *th;
 
-       th = skb_header_pointer(skb, skb->nh.iph->ihl*4,
-                               sizeof(_tcph), &_tcph);
+       th = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph);
        if (th == NULL)
                return 0;
 
@@ -490,16 +488,18 @@ tcp_state_transition(struct ip_vs_conn *cp, int direction,
 static struct list_head tcp_apps[TCP_APP_TAB_SIZE];
 static DEFINE_SPINLOCK(tcp_app_lock);
 
-static inline __u16 tcp_app_hashkey(__u16 port)
+static inline __u16 tcp_app_hashkey(__be16 port)
 {
-       return ((port >> TCP_APP_TAB_BITS) ^ port) & TCP_APP_TAB_MASK;
+       return (((__force u16)port >> TCP_APP_TAB_BITS) ^ (__force u16)port)
+               & TCP_APP_TAB_MASK;
 }
 
 
 static int tcp_register_app(struct ip_vs_app *inc)
 {
        struct ip_vs_app *i;
-       __u16 hash, port = inc->port;
+       __u16 hash;
+       __be16 port = inc->port;
        int ret = 0;
 
        hash = tcp_app_hashkey(port);