All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ulogd fix for kernel 64bits/userspace 32bits system
@ 2006-10-12 12:03 Eric Leblond
  2006-10-12 12:10 ` Patrick McHardy
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Leblond @ 2006-10-12 12:03 UTC (permalink / raw)
  To: netfilter-devel


[-- Attachment #1.1: Type: text/plain, Size: 192 bytes --]

Hello,

This patch fixes ulogd for system with kernel space 64 bits and
userspace 32 bits.

Auto detection of system type is taken from iptables.

BR,
-- 
Eric Leblond <eric@inl.fr>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: ulogd-kernel64-user32.patch --]
[-- Type: text/x-patch; name=ulogd-kernel64-user32.patch; charset=us-ascii, Size: 4720 bytes --]

Index: Makefile.in
===================================================================
--- Makefile.in	(révision 6687)
+++ Makefile.in	(copie de travail)
@@ -31,6 +31,39 @@
 
 #  Normally You should not need to change anything below
 
+# Sparc64 hack
+ifeq ($(shell uname -m),sparc64)
+	POINTERTEST:=1
+	32bituser := $(shell echo -e "\#include <stdio.h>\n\#if !defined(__sparcv9) && !defined(__arch64__) && !defined(_LP64)\nuserspace_is_32bit\n\#endif" | $(CC) $(CFLAGS) -E - | grep userspace_is_32bit)
+	ifdef 32bituser
+		# The kernel is 64-bit, even though userspace is 32.
+		CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
+	else
+		EXT_LDFLAGS=-m elf64_sparc
+	endif
+endif
+
+# Alpha only has 64bit userspace and fails the test below
+ifeq ($(shell uname -m), alpha)
+	POINTERTEST:=1
+endif
+
+# Generic test if arch wasn't found above
+ifneq ($(POINTERTEST),1)
+	# Try to determine if kernel is 64bit and we are compiling for 32bit
+	ifeq ($(shell [ -a $(KERNEL_DIR)/include/asm ] && echo YES), YES)
+		64bitkernel := $(shell echo -e "\#include <asm/types.h>\n\#if BITS_PER_LONG == 64\nkernel_is_64bits\n\#endif" | $(CC) $(CFLAGS) -D__KERNEL__ -E - | grep kernel_is_64bits)
+		ifdef 64bitkernel
+			32bituser := $(shell echo -e "\#include <stdio.h>\n\#if !defined(__arch64__) && !defined(_LP64)\nuserspace_is_32bit\n\#endif" | $(CC) $(CFLAGS) -E - | grep userspace_is_32bit)
+			ifdef 32bituser
+				CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
+			endif
+		endif
+	else
+		CFLAGS+=-D_UNKNOWN_KERNEL_POINTER_SIZE
+	endif
+endif
+
 all: recurse ulogd
 
 .PHONY: distclean
Index: libipulog/include/linux/netfilter_ipv4/ipt_ULOG.h
===================================================================
--- libipulog/include/linux/netfilter_ipv4/ipt_ULOG.h	(révision 0)
+++ libipulog/include/linux/netfilter_ipv4/ipt_ULOG.h	(révision 0)
@@ -0,0 +1,62 @@
+/* Header file for IP tables userspace logging, Version 1.8
+ *
+ * (C) 2000-2002 by Harald Welte <laforge@gnumonks.org>
+ * 
+ * Distributed under the terms of GNU GPL */
+#ifndef _IPT_ULOG_H
+#define _IPT_ULOG_H
+
+#ifndef NETLINK_NFLOG
+#define NETLINK_NFLOG 	5
+#endif
+
+#define ULOG_DEFAULT_NLGROUP	1
+#define ULOG_DEFAULT_QTHRESHOLD	1
+
+#define ULOG_MAC_LEN	80
+#define ULOG_PREFIX_LEN	32
+
+#define ULOG_MAX_QLEN	50
+/* Why 50? Well... there is a limit imposed by the slab cache 131000
+ * bytes. So the multipart netlink-message has to be < 131000 bytes.
+ * Assuming a standard ethernet-mtu of 1500, we could define this up
+ * to 80... but even 50 seems to be big enough. */
+
+/* private data structure for each rule with a ULOG target */
+struct ipt_ulog_info {
+	unsigned int nl_group;
+#ifdef KERNEL_64_USERSPACE_32
+	unsigned long long copy_range;
+	unsigned long long qthreshold;
+#else
+	size_t copy_range;
+	size_t qthreshold;
+#endif
+	char prefix[ULOG_PREFIX_LEN];
+};
+
+/* Format of the ULOG packets passed through netlink */
+typedef struct ulog_packet_msg {
+	unsigned long mark;
+#ifdef KERNEL_64_USERSPACE_32
+	long long timestamp_sec;
+	long long timestamp_usec;
+#else
+	long timestamp_sec;
+	long timestamp_usec;
+#endif
+	unsigned int hook;
+	char indev_name[IFNAMSIZ];
+	char outdev_name[IFNAMSIZ];
+#ifdef KERNEL_64_USERSPACE_32
+	unsigned long long data_len;
+#else
+	size_t data_len;
+#endif
+	char prefix[ULOG_PREFIX_LEN];
+	unsigned char mac_len;
+	unsigned char mac[ULOG_MAC_LEN];
+	unsigned char payload[0];
+} ulog_packet_msg_t;
+
+#endif /*_IPT_ULOG_H*/
Index: libipulog/include/libipulog/libipulog.h
===================================================================
--- libipulog/include/libipulog/libipulog.h	(révision 6687)
+++ libipulog/include/libipulog/libipulog.h	(copie de travail)
@@ -1,7 +1,7 @@
 #ifndef _LIBIPULOG_H
 #define _LIBIPULOG_H
 
-/* $Id: libipulog.h,v 1.6 2002/07/30 07:23:36 laforge Exp $ */
+/* $Id$ */
 
 #include <errno.h>
 #include <unistd.h>
@@ -12,7 +12,7 @@
 #include <asm/types.h>
 #include <linux/netlink.h>
 #include <net/if.h>
-#include <linux/netfilter_ipv4/ipt_ULOG.h>
+#include "linux/netfilter_ipv4/ipt_ULOG.h"
 
 /* FIXME: glibc sucks */
 #ifndef MSG_TRUNC 
Index: Rules.make.in
===================================================================
--- Rules.make.in	(révision 6687)
+++ Rules.make.in	(copie de travail)
@@ -21,7 +21,7 @@
 CFLAGS=@CFLAGS@ @CPPFLAGS@ -Wall
 CFLAGS+=-DULOGD_CONFIGFILE=\"$(ULOGD_CONFIGFILE)\"
 # doesn't work for subdirs
-#CFLAGS+=$(INCIPULOG) $(INCCONFFILE)
+CFLAGS+=$(INCIPULOG)
 CFLAGS+=-I/lib/modules/`uname -r`/build/include
 #CFLAGS+=@DEFS@
 #CFLAGS+=-g -DDEBUG -DDEBUG_MYSQL -DDEBUG_PGSQL

[-- Attachment #2: Ceci est une partie de message numériquement signée --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2006-10-13  6:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-12 12:03 [PATCH] ulogd fix for kernel 64bits/userspace 32bits system Eric Leblond
2006-10-12 12:10 ` Patrick McHardy
2006-10-12 14:14   ` Eric Leblond
2006-10-12 14:23     ` Patrick McHardy
2006-10-12 14:26       ` Patrick McHardy
2006-10-12 16:18       ` Resend: Patch : " Eric Leblond
2006-10-13  6:00         ` Patrick McHardy
2006-10-13  6: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.