All of lore.kernel.org
 help / color / mirror / Atom feed
* a patch for conntrack_tuple
       [not found] <20050111102202.99FD6A90F2@mail.goldenhope.com.cn>
@ 2005-01-14  3:52 ` zhongyu
  2005-01-14  4:03   ` Patrick McHardy
  0 siblings, 1 reply; 2+ messages in thread
From: zhongyu @ 2005-01-14  3:52 UTC (permalink / raw)
  To: netfilter-devel

##################begin##########################################
--- include/linux/netfilter_ipv4/ip_conntrack_tuple.h   27 Nov 2003 
12:42:40 -0000      1.2
+++ include/linux/netfilter_ipv4/ip_conntrack_tuple.h   10 Jan 2005 
04:28:28 -0000
@@ -50,13 +50,37 @@
                         u_int64_t all;

                         struct {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
                                 u_int16_t port;
+#elif defined (__BIG_ENDIAN_BITFIELD)
+                               u_int32_t pad1;
+                               u_int16_t pad2;
+                               u_int16_t port;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
                         } tcp;
                         struct {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+                               u_int16_t port;
+#elif defined (__BIG_ENDIAN_BITFIELD)
+                               u_int32_t pad1;
+                               u_int16_t pad2;
                                 u_int16_t port;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
                         } udp;
                         struct {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+                               u_int8_t type, code;
+#elif defined (__BIG_ENDIAN_BITFIELD)
+                               u_int32_t pad1;
+                               u_int16_t pad2;
                                 u_int8_t type, code;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
                         } icmp;
                         struct {
                                 u_int16_t protocol;
################end#######################
The function hash_conntrack use the low 16 bits of tuple->dst, but in 
big-endian system
the port infomation is in high 16 bits. So the destination port on 
big-endian system was
ignored. This caused hash collision. The patch above fixed this problem 
:-)

static u_int32_t
hash_conntrack(const struct ip_conntrack_tuple *tuple)
{
#if 0
         dump_tuple(tuple);
#endif
         return (jhash_3words(tuple->src.ip,
                              (tuple->dst.ip ^ tuple->dst.protonum),
                              (tuple->src.u.all | (tuple->dst.u.all << 
16)),
                              ip_conntrack_hash_rnd) % 
ip_conntrack_htable_size);
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: a patch for conntrack_tuple
  2005-01-14  3:52 ` a patch for conntrack_tuple zhongyu
@ 2005-01-14  4:03   ` Patrick McHardy
  0 siblings, 0 replies; 2+ messages in thread
From: Patrick McHardy @ 2005-01-14  4:03 UTC (permalink / raw)
  To: zhongyu; +Cc: netfilter-devel

zhongyu wrote:

> --- include/linux/netfilter_ipv4/ip_conntrack_tuple.h   27 Nov 2003 
> 12:42:40 -0000      1.2
> +++ include/linux/netfilter_ipv4/ip_conntrack_tuple.h   10 Jan 2005 
> 04:28:28 -0000
> @@ -50,13 +50,37 @@
>                         u_int64_t all;
>
> [...] 

> The function hash_conntrack use the low 16 bits of tuple->dst, but in 
> big-endian system
> the port infomation is in high 16 bits. So the destination port on 
> big-endian system was
> ignored. This caused hash collision. The patch above fixed this 
> problem :-)


In the mainline kernel "all" is u_int16_t. Have you applied any patches ?

Regards
Patrick

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-01-14  4:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20050111102202.99FD6A90F2@mail.goldenhope.com.cn>
2005-01-14  3:52 ` a patch for conntrack_tuple zhongyu
2005-01-14  4:03   ` Patrick McHardy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.