public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.6 patch] netfilter/ip_nat_snmp_basic.c: fix inlines (fwd)
@ 2004-07-29 21:20 Adrian Bunk
  2004-08-01 17:31 ` Harald Welte
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2004-07-29 21:20 UTC (permalink / raw)
  To: James Morris, Andrew Morton; +Cc: linux-kernel, netfilter-devel


FYI:
The patch forwarded below is still required in 2.6.8-rc2-mm1.


----- Forwarded message from Adrian Bunk <bunk@fs.tum.de> -----

Date:	Wed, 14 Jul 2004 23:19:09 +0200
From: Adrian Bunk <bunk@fs.tum.de>
To: James Morris <jmorris@intercode.com.au>
Cc: linux-kernel@vger.kernel.org, netfilter-devel@lists.netfilter.org
Subject: [2.6 patch] netfilter/ip_nat_snmp_basic.c: fix inlines

Trying to compile net/ipv4/netfilter/ip_nat_snmp_basic.c in 
2.6.8-rc1-mm1 using gcc 3.4 results in the following compile error:

<--  snip  -->

...
  CC      net/ipv4/netfilter/ip_nat_snmp_basic.o
net/ipv4/netfilter/ip_nat_snmp_basic.c: In function `snmp_trap_decode':
net/ipv4/netfilter/ip_nat_snmp_basic.c:612: sorry, unimplemented: 
inlining failed in call to 'mangle_address': function body not available
net/ipv4/netfilter/ip_nat_snmp_basic.c:896: sorry, unimplemented: called from here
make[3]: *** [net/ipv4/netfilter/ip_nat_snmp_basic.o] Error 1

<--  snip  -->

The patch below moves an inlined function above the place where it is 
called the first time.

An alternative approach would be to remove the inline.


diffstat output:
 net/ipv4/netfilter/ip_nat_snmp_basic.c |  142 ++++++++++++-------------
 1 files changed, 71 insertions(+), 71 deletions(-)



Signed-off-by: Adrian Bunk <bunk@fs.tum.de>

--- linux-2.6.7-mm6-full-gcc3.4/net/ipv4/netfilter/ip_nat_snmp_basic.c.old	2004-07-09 02:18:23.000000000 +0200
+++ linux-2.6.7-mm6-full-gcc3.4/net/ipv4/netfilter/ip_nat_snmp_basic.c	2004-07-09 02:21:00.000000000 +0200
@@ -862,6 +862,77 @@
 	return 1;
 }
 
+/* 
+ * Fast checksum update for possibly oddly-aligned UDP byte, from the
+ * code example in the draft.
+ */
+static void fast_csum(unsigned char *csum,
+                      const unsigned char *optr,
+                      const unsigned char *nptr,
+                      int odd)
+{
+	long x, old, new;
+	
+	x = csum[0] * 256 + csum[1];
+	
+	x =~ x & 0xFFFF;
+	
+	if (odd) old = optr[0] * 256;
+	else old = optr[0];
+	
+	x -= old & 0xFFFF;
+	if (x <= 0) {
+		x--;
+		x &= 0xFFFF;
+	}
+	
+	if (odd) new = nptr[0] * 256;
+	else new = nptr[0];
+	
+	x += new & 0xFFFF;
+	if (x & 0x10000) {
+		x++;
+		x &= 0xFFFF;
+	}
+	
+	x =~ x & 0xFFFF;
+	csum[0] = x / 256;
+	csum[1] = x & 0xFF;
+}
+
+/* 
+ * Mangle IP address.
+ * 	- begin points to the start of the snmp messgae
+ *      - addr points to the start of the address
+ */
+static inline void mangle_address(unsigned char *begin,
+                                  unsigned char *addr,
+                                  const struct oct1_map *map,
+                                  u_int16_t *check)
+{
+	if (map->from == NOCT1(*addr)) {
+		u_int32_t old;
+		
+		if (debug)
+			memcpy(&old, (unsigned char *)addr, sizeof(old));
+			
+		*addr = map->to;
+		
+		/* Update UDP checksum if being used */
+		if (*check) {
+			unsigned char odd = !((addr - begin) % 2);
+			
+			fast_csum((unsigned char *)check,
+			          &map->from, &map->to, odd);
+			          
+		}
+		
+		if (debug)
+			printk(KERN_DEBUG "bsalg: mapped %u.%u.%u.%u to "
+			       "%u.%u.%u.%u\n", NIPQUAD(old), NIPQUAD(*addr));
+	}
+}
+
 static unsigned char snmp_trap_decode(struct asn1_ctx *ctx,
                                       struct snmp_v1_trap *trap,
                                       const struct oct1_map *map,
@@ -952,77 +1023,6 @@
 	printk("\n");
 }
 
-/* 
- * Fast checksum update for possibly oddly-aligned UDP byte, from the
- * code example in the draft.
- */
-static void fast_csum(unsigned char *csum,
-                      const unsigned char *optr,
-                      const unsigned char *nptr,
-                      int odd)
-{
-	long x, old, new;
-	
-	x = csum[0] * 256 + csum[1];
-	
-	x =~ x & 0xFFFF;
-	
-	if (odd) old = optr[0] * 256;
-	else old = optr[0];
-	
-	x -= old & 0xFFFF;
-	if (x <= 0) {
-		x--;
-		x &= 0xFFFF;
-	}
-	
-	if (odd) new = nptr[0] * 256;
-	else new = nptr[0];
-	
-	x += new & 0xFFFF;
-	if (x & 0x10000) {
-		x++;
-		x &= 0xFFFF;
-	}
-	
-	x =~ x & 0xFFFF;
-	csum[0] = x / 256;
-	csum[1] = x & 0xFF;
-}
-
-/* 
- * Mangle IP address.
- * 	- begin points to the start of the snmp messgae
- *      - addr points to the start of the address
- */
-static inline void mangle_address(unsigned char *begin,
-                                  unsigned char *addr,
-                                  const struct oct1_map *map,
-                                  u_int16_t *check)
-{
-	if (map->from == NOCT1(*addr)) {
-		u_int32_t old;
-		
-		if (debug)
-			memcpy(&old, (unsigned char *)addr, sizeof(old));
-			
-		*addr = map->to;
-		
-		/* Update UDP checksum if being used */
-		if (*check) {
-			unsigned char odd = !((addr - begin) % 2);
-			
-			fast_csum((unsigned char *)check,
-			          &map->from, &map->to, odd);
-			          
-		}
-		
-		if (debug)
-			printk(KERN_DEBUG "bsalg: mapped %u.%u.%u.%u to "
-			       "%u.%u.%u.%u\n", NIPQUAD(old), NIPQUAD(*addr));
-	}
-}
-
 /*
  * Parse and mangle SNMP message according to mapping.
  * (And this is the fucking 'basic' method).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

----- End forwarded message -----


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

* Re: [2.6 patch] netfilter/ip_nat_snmp_basic.c: fix inlines (fwd)
  2004-07-29 21:20 [2.6 patch] netfilter/ip_nat_snmp_basic.c: fix inlines (fwd) Adrian Bunk
@ 2004-08-01 17:31 ` Harald Welte
  0 siblings, 0 replies; 2+ messages in thread
From: Harald Welte @ 2004-08-01 17:31 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: James Morris, Andrew Morton, linux-kernel, netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 596 bytes --]

On Thu, Jul 29, 2004 at 11:20:49PM +0200, Adrian Bunk wrote:
> 
> FYI:
> The patch forwarded below is still required in 2.6.8-rc2-mm1.

I've pushed your patch to DaveM now.  Apparently some gcc-3.4 specific
issue...

-- 
- Harald Welte <laforge@netfilter.org>             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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2004-08-01 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-29 21:20 [2.6 patch] netfilter/ip_nat_snmp_basic.c: fix inlines (fwd) Adrian Bunk
2004-08-01 17:31 ` Harald Welte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox