Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / net / ipv4 / netfilter / ipt_CLUSTERIP.c
index d994c5f..aad9d28 100644 (file)
@@ -10,6 +10,7 @@
  *
  */
 #include <linux/module.h>
+#include <linux/config.h>
 #include <linux/proc_fs.h>
 #include <linux/jhash.h>
 #include <linux/bitops.h>
@@ -172,10 +173,11 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip,
        struct clusterip_config *c;
        char buffer[16];
 
-       c = kzalloc(sizeof(*c), GFP_ATOMIC);
+       c = kmalloc(sizeof(*c), GFP_ATOMIC);
        if (!c)
                return NULL;
 
+       memset(c, 0, sizeof(*c));
        c->dev = dev;
        c->clusterip = ip;
        memcpy(&c->clustermac, &i->clustermac, ETH_ALEN);
@@ -239,17 +241,25 @@ clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
        struct iphdr *iph = skb->nh.iph;
        unsigned long hashval;
        u_int16_t sport, dport;
-       u_int16_t *ports;
+       struct tcphdr *th;
+       struct udphdr *uh;
+       struct icmphdr *ih;
 
        switch (iph->protocol) {
        case IPPROTO_TCP:
+               th = (void *)iph+iph->ihl*4;
+               sport = ntohs(th->source);
+               dport = ntohs(th->dest);
+               break;
        case IPPROTO_UDP:
-       case IPPROTO_SCTP:
-       case IPPROTO_DCCP:
+               uh = (void *)iph+iph->ihl*4;
+               sport = ntohs(uh->source);
+               dport = ntohs(uh->dest);
+               break;
        case IPPROTO_ICMP:
-               ports = (void *)iph+iph->ihl*4;
-               sport = ports[0];
-               dport = ports[1];
+               ih = (void *)iph+iph->ihl*4;
+               sport = ntohs(ih->un.echo.id);
+               dport = (ih->type<<8)|ih->code;
                break;
        default:
                if (net_ratelimit()) {