From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Lauriault" Subject: Re: extra/string inital port to 2.6 Date: Mon, 29 Mar 2004 11:09:07 -0500 Sender: netfilter-devel-admin@lists.netfilter.org Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: To: Content-Disposition: inline Errors-To: netfilter-devel-admin@lists.netfilter.org List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: List-Id: netfilter-devel.vger.kernel.org Hi. Here's the patch. Seems to work for me. --- ipt_string-2.4.c Mon Mar 29 06:00:23 2004 +++ ipt_string-2.6.c Mon Mar 29 06:01:04 2004 @@ -3,6 +3,8 @@ * Copyright (C) 2000 Emmanuel Roger * * ChangeLog + * 24.03.2004: Eric Lauriault + * Initial 2.6 port * 19.02.2002: Gianni Tedesco * Fixed SMP re-entrancy problem using per-cpu data areas * for the skip/shift tables. @@ -18,6 +20,7 @@ */ #include +#include #include #include #include @@ -29,12 +32,13 @@ MODULE_LICENSE("GPL"); struct string_per_cpu { - int *skip; - int *shift; - int *len; + int skip[BM_MAX_HLEN]; + int shift[BM_MAX_HLEN]; + int len[BM_MAX_HLEN]; }; -struct string_per_cpu *bm_string_data=NULL; +static DEFINE_PER_CPU(struct string_per_cpu, bm_string_data); + /* Boyer Moore Sublinear string search - VERY FAST */ char *search_sublinear (char *needle, char *haystack, int needle_len, int haystack_len) @@ -45,14 +49,14 @@ int *skip, *shift, *len; /* use data suitable for this CPU */ - shift=bm_string_data[smp_processor_id()].shift; - skip=bm_string_data[smp_processor_id()].skip; - len=bm_string_data[smp_processor_id()].len; + shift=__get_cpu_var(bm_string_data).shift; + skip=__get_cpu_var(bm_string_data).skip; + len=__get_cpu_var(bm_string_data).len; /* Setup skip/shift tables */ M1 = right_end = needle_len-1; for (i = 0; i < BM_MAX_HLEN; i++) skip[i] = needle_len; - for (i = 0; needle[i]; i++) skip[needle[i]] = M1 - i; + for (i = 0; needle[i]; i++) skip[(int)needle[i]] = M1 - i; for (i = 1; i < needle_len; i++) { for (j = 0; j < needle_len && needle[M1 - j] == needle[M1 - i - j]; j++); @@ -77,7 +81,7 @@ return haystack+(right_end - M1); } - sk = skip[haystack[right_end - i]]; + sk = skip[(int)haystack[right_end - i]]; sh = shift[i]; right_end = max(right_end - i + sk, right_end + sh); } @@ -100,15 +104,12 @@ return NULL; } - static int match(const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const void *matchinfo, int offset, - const void *hdr, - u_int16_t datalen, int *hotdrop) { const struct ipt_string_info *info = matchinfo; @@ -158,61 +159,25 @@ return 1; } -void string_freeup_data(void) -{ - int c; - - if ( bm_string_data ) { - for(c=0; c>> Harald Welte 03/28/04 1:37 PM >>> On Wed, Mar 24, 2004 at 01:49:34PM -0500, Eric Lauriault wrote: > Hi, > > Just did a quick and dirty port of ipt_string to 2.6 using rusty's > comments from feb. Who should I submit it to? This mailinglist ;) > Thanks, -- - Harald Welte http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie