lkml.org 
[lkml]   [1997]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectmodular AF_UNIX (patch)

Here is a patch against 2.1.65 that makes the AF_UNIX protocol a
compile time option, including full module support. I sent this out about
a week ago but it wasn't quite as complete (didn't support /proc/sys as a
module) but now it should work fine. My next goal is to make ipv4 a
module (any info regarding this is very appreciated).
A few quick notes: if you are using kerneld, you must add 'alias
net-pf-1 unix' to /etc/conf.modules or the bad stuff happens (kerneld
tells modprobe to load net-pf-1, which it can't find, and stalls). I've
asked the modutils maintainer to add that alias and 'alias net-pf-2 ipv4'
as defaults, which he did.
A final note, could someone tell me if there is a reason that this
won't be added to the 2.1.x kernels? I realize it isn't the most useful
patch, but it doesn't really change much and might be useful to someone
(besides the fact that it was a good learning experience for someone that
might go on to further kernel hacking).
Thanks.

Bye,
Kirk
kirk@muppetlabs.com
http://www.muppetlabs.com/~kirk/

--- cut here ---
diff -u --recursive --new-file v2.1.65/linux/CREDITS linux/CREDITS
--- v2.1.65/linux/CREDITS Sat Nov 15 11:43:08 1997
+++ linux/CREDITS Tue Nov 18 20:29:32 1997
@@ -1209,6 +1209,11 @@
S: Tula 300000
S: Russia

+N: Kirk Petersen
+E: kirk@speakeasy.org
+W: http://www.speakeasy.org/~kirk/
+D: modularized BSD Unix domain sockets
+
N: Kai Petzke
E: wpp@marie.physik.tu-berlin.de
W: http://physik.tu-berlin.de/~wpp
diff -u --recursive --new-file v2.1.65/linux/Documentation/Configure.help linux/Documentation/Configure.help
--- v2.1.65/linux/Documentation/Configure.help Thu Nov 13 12:56:48 1997
+++ linux/Documentation/Configure.help Tue Nov 18 20:29:32 1997
@@ -1320,6 +1320,13 @@
a second or satellite links this option will make no difference to
performance.

+BSD Unix domain sockets
+CONFIG_UNIX
+ Y if you want BSD Unix domain sockets. Unless you are working on an
+ embedded system or somthing, you probably want to say Y. If you try
+ building this as a module and you are running kerneld, you need to make
+ sure and add 'alias net-pf-1 unix' to your /etc/conf.module file.
+
The IPv6 protocol
CONFIG_IPV6
This is experimental support for the next version of the Internet
diff -u --recursive --new-file v2.1.65/linux/arch/i386/kernel/i386_ksyms.c linux/arch/i386/kernel/i386_ksyms.c
--- v2.1.65/linux/arch/i386/kernel/i386_ksyms.c Fri Oct 17 13:59:30 1997
+++ linux/arch/i386/kernel/i386_ksyms.c Tue Nov 18 20:29:32 1997
@@ -42,6 +42,7 @@
EXPORT_SYMBOL(__intel_bh_counter);
/* Networking helper routines. */
EXPORT_SYMBOL(csum_partial_copy);
+EXPORT_SYMBOL(csum_partial);

#ifdef __SMP__
EXPORT_SYMBOL(apic_reg); /* Needed internally for the I386 inlines */
diff -u --recursive --new-file v2.1.65/linux/net/Config.in linux/net/Config.in
--- v2.1.65/linux/net/Config.in Thu Nov 13 12:58:50 1997
+++ linux/net/Config.in Tue Nov 18 20:29:32 1997
@@ -14,6 +14,7 @@
fi
fi
bool 'Network aliasing' CONFIG_NET_ALIAS
+tristate 'BSD Unix domain sockets' CONFIG_UNIX
bool 'TCP/IP networking' CONFIG_INET
if [ "$CONFIG_INET" = "y" ]; then
source net/ipv4/Config.in
diff -u --recursive --new-file v2.1.65/linux/net/Makefile linux/net/Makefile
--- v2.1.65/linux/net/Makefile Wed Jul 16 19:22:51 1997
+++ linux/net/Makefile Tue Nov 18 20:29:32 1997
@@ -7,10 +7,10 @@
#
# Note 2! The CFLAGS definition is now in the main makefile...

-MOD_SUB_DIRS := ipv4
+MOD_SUB_DIRS :=
ALL_SUB_DIRS := 802 ax25 bridge core ethernet ipv4 ipv6 ipx unix appletalk \
netrom rose lapb x25 wanrouter sunrpc #decnet
-SUB_DIRS := core ethernet unix
+SUB_DIRS := core ethernet
MOD_LIST_NAME := NET_MISC_MODULES

ifeq ($(CONFIG_NET),y)
@@ -19,6 +19,14 @@

ifeq ($(CONFIG_INET),y)
SUB_DIRS += ipv4
+endif
+
+ifeq ($(CONFIG_UNIX),y)
+SUB_DIRS += unix
+else
+ ifeq ($(CONFIG_UNIX),m)
+ MOD_SUB_DIRS += unix
+ endif
endif

ifeq ($(CONFIG_IPV6),y)
diff -u --recursive --new-file v2.1.65/linux/net/netsyms.c linux/net/netsyms.c
--- v2.1.65/linux/net/netsyms.c Thu Oct 23 14:30:45 1997
+++ linux/net/netsyms.c Tue Nov 18 20:29:32 1997
@@ -144,6 +144,12 @@
EXPORT_SYMBOL(__scm_destroy);
EXPORT_SYMBOL(__scm_send);

+/* Needed by unix.o */
+EXPORT_SYMBOL(scm_fp_dup);
+EXPORT_SYMBOL(max_files);
+EXPORT_SYMBOL(do_mknod);
+EXPORT_SYMBOL(memcpy_toiovec);
+
#ifdef CONFIG_IPX_MODULE
EXPORT_SYMBOL(make_8023_client);
EXPORT_SYMBOL(destroy_8023_client);
diff -u --recursive --new-file v2.1.65/linux/net/protocols.c linux/net/protocols.c
--- v2.1.65/linux/net/protocols.c Mon Jun 16 16:36:02 1997
+++ linux/net/protocols.c Tue Nov 18 20:29:32 1997
@@ -10,8 +10,6 @@
#include <linux/net.h>
#include <linux/fs.h>

-#define CONFIG_UNIX /* always present... */
-
#ifdef CONFIG_UNIX
#include <linux/un.h>
#include <net/af_unix.h>
diff -u --recursive --new-file v2.1.65/linux/net/sysctl_net.c linux/net/sysctl_net.c
--- v2.1.65/linux/net/sysctl_net.c Mon Jun 16 16:36:02 1997
+++ linux/net/sysctl_net.c Tue Nov 18 20:29:32 1997
@@ -24,7 +24,11 @@
extern ctl_table ipx_table[];
#endif

-extern ctl_table core_table[], unix_table[];
+extern ctl_table core_table[];
+
+#ifdef CONFIG_UNIX
+extern ctl_table unix_table[];
+#endif

#ifdef CONFIG_NET
extern ctl_table ether_table[], e802_table[];
@@ -44,7 +48,9 @@

ctl_table net_table[] = {
{NET_CORE, "core", NULL, 0, 0555, core_table},
+#ifdef CONFIG_UNIX
{NET_UNIX, "unix", NULL, 0, 0555, unix_table},
+#endif
#ifdef CONFIG_NET
{NET_802, "802", NULL, 0, 0555, e802_table},
{NET_ETHER, "ethernet", NULL, 0, 0555, ether_table},
diff -u --recursive --new-file v2.1.65/linux/net/unix/Makefile linux/net/unix/Makefile
--- v2.1.65/linux/net/unix/Makefile Mon Apr 7 11:35:33 1997
+++ linux/net/unix/Makefile Tue Nov 18 20:29:33 1997
@@ -9,6 +9,7 @@

O_TARGET := unix.o
O_OBJS := af_unix.o garbage.o
+M_OBJS := $(O_TARGET)

ifeq ($(CONFIG_SYSCTL),y)
O_OBJS += sysctl_net_unix.o
diff -u --recursive --new-file v2.1.65/linux/net/unix/af_unix.c linux/net/unix/af_unix.c
--- v2.1.65/linux/net/unix/af_unix.c Sat Sep 20 14:51:55 1997
+++ linux/net/unix/af_unix.c Tue Nov 18 20:51:40 1997
@@ -26,6 +26,7 @@
* Alan Cox : Started POSIXisms
* Andreas Schwab : Replace inode by dentry for proper
* reference counting
+ * Kirk Petersen : Made this a module
*
* Known differences from reference BSD that was tested:
*
@@ -57,6 +58,7 @@
* with BSD names.
*/

+#include <linux/module.h>
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/major.h>
@@ -310,6 +312,9 @@
sk->dead=1;
unix_delayed_delete(sk); /* Try every so often until buffers are all freed */
}
+
+ /* socket destroyed, decrement count */
+ MOD_DEC_USE_COUNT;
}

static int unix_listen(struct socket *sock, int backlog)
@@ -373,6 +378,10 @@
sk->mtu=4096;
sk->protinfo.af_unix.list=&unix_sockets_unbound;
unix_insert_socket(sk);
+
+ /* socket created, increment count */
+ MOD_INC_USE_COUNT;
+
return 0;
}

@@ -1465,7 +1474,14 @@
unix_create
};

+#ifdef MODULE
+extern void unix_sysctl_register(void);
+extern void unix_sysctl_unregister(void);
+
+int init_module(void)
+#else
__initfunc(void unix_proto_init(struct net_proto *pro))
+#endif
{
struct sk_buff *dummy_skb;
struct proc_dir_entry *ent;
@@ -1474,14 +1490,33 @@
if (sizeof(struct unix_skb_parms) > sizeof(dummy_skb->cb))
{
printk(KERN_CRIT "unix_proto_init: panic\n");
+#ifdef MODULE
+ return -1;
+#else
return;
+#endif
}
sock_register(&unix_family_ops);
#ifdef CONFIG_PROC_FS
ent = create_proc_entry("net/unix", 0, 0);
ent->read_proc = unix_read_proc;
#endif
+
+#ifdef MODULE
+ unix_sysctl_register();
+
+ return 0;
+#endif
}
+
+#ifdef MODULE
+void cleanup_module(void)
+{
+ sock_unregister(AF_UNIX);
+ unix_sysctl_unregister();
+}
+#endif
+
/*
* Local variables:
* compile-command: "gcc -g -D__KERNEL__ -Wall -O6 -I/usr/src/linux/include -c af_unix.c"
diff -u --recursive --new-file v2.1.65/linux/net/unix/sysctl_net_unix.c linux/net/unix/sysctl_net_unix.c
--- v2.1.65/linux/net/unix/sysctl_net_unix.c Mon Jul 7 08:20:00 1997
+++ linux/net/unix/sysctl_net_unix.c Tue Nov 18 20:53:46 1997
@@ -29,4 +29,31 @@
&proc_dointvec_jiffies},
{0}
};
-#endif
+
+#ifdef MODULE
+static struct ctl_table_header * unix_sysctl_header;
+static struct ctl_table unix_root_table[];
+static struct ctl_table unix_net_table[];
+
+ctl_table unix_root_table[] = {
+ {CTL_NET, "net", NULL, 0, 0555, unix_net_table},
+ {0}
+};
+
+ctl_table unix_net_table[] = {
+ {NET_UNIX, "unix", NULL, 0, 0555, unix_table},
+ {0}
+};
+
+void unix_sysctl_register(void)
+{
+ unix_sysctl_header = register_sysctl_table(unix_root_table, 0);
+}
+
+void unix_sysctl_unregister(void)
+{
+ unregister_sysctl_table(unix_sysctl_header);
+}
+#endif /* MODULE */
+
+#endif /* CONFIG_SYSCTL */


\
 
 \ /
  Last update: 2005-03-22 13:40    [from the cache]
©2003-2011 Jasper Spaans