Skip to contentSkip to conversation

2.6.3 very small patch: libc compatibility for skbuff.h (userspace access to sk_buffs)

PATCH In review [email protected] 1 participant 2 messages Mar 4, 2004 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6.3 very small patch: libc compatibility for skbuff.h (userspace access to sk_buffs)

hi,

for a network monitoring application I needed access to sk_buff's from
userspace. The current linux/skbuff.h headerfile cannot be included from userspace applications due to various kernel .h vs. libc .h clashes.

I basically pruned the #include statements by inserting #ifdef _KERNEL__ statements until gcc started complaining. Therefore nothing has changed in the kernelspace implementation. But this minor change makes it possible to include linux/skbuff.h from userspace.

Ideally, all the #ifdef __KERNEL__ secured headerfile references should be removed, since it is clear that skbuff.h doesn't really rely on them. Perhaps some .c file does, but I didn't feel like finding out which one.

cheers,

Willem

#1 lore raw

new version. Now uses sys/time.h in userspace to resolve timevals. Also, the patch mimetype is no longer (erroneously) reported as application/-octet-stream (since I just pasted it in below).

----begin---

include/linux/skbuff.h +8 -1
@@ -14,19 +14,26 @@
 #ifndef _LINUX_SKBUFF_H
 #define _LINUX_SKBUFF_H
 
+#ifdef __KERNEL__
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/compiler.h>
 #include <linux/time.h>
 #include <linux/cache.h>
-
 #include <asm/atomic.h>
+#else
+#include <sys/time.h>
+#endif
+
 #include <asm/types.h>
 #include <linux/spinlock.h>
+
+#ifdef __KERNEL__
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/poll.h>
 #include <linux/net.h>
+#endif
 
 #define HAVE_ALLOC_SKB		/* For the drivers to know */
 #define HAVE_ALIGNABLE_SKB	/* Ditto 8)		   */