modular net-pf-1 (patch)

Kirk Petersen (kirk@eidolon.speakeasy.org)
Wed, 12 Nov 1997 21:49:58 -0800 (PST)


Hi,
This patch makes the BSD Unix domain socket interface a compile
time option (including loading and unloading as a module). Why, you ask?
Mostly because it could easily be done. But I'm sure there are a few
people that will find it useful (embedded systems people or module
fanatics).
I'm going to attempt to make more parts of the kernel modules (or
run time options via sysctl). Any suggestions?

Bye,
Kirk Petersen
kirk@speakeasy.org
http://www.speakeasy.org/~kirk/

--- cut here ---

diff -u --recursive --new-file v2.1.63/linux/CREDITS linux/CREDITS
--- v2.1.63/linux/CREDITS Wed Nov 12 19:00:08 1997
+++ linux/CREDITS Wed Nov 12 21:21:52 1997
@@ -1197,6 +1197,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.63/linux/Documentation/Configure.help linux/Documentation/Configure.help
--- v2.1.63/linux/Documentation/Configure.help Wed Nov 12 19:00:09 1997
+++ linux/Documentation/Configure.help Wed Nov 12 20:12:49 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.63/linux/arch/i386/kernel/i386_ksyms.c linux/arch/i386/kernel/i386_ksyms.c
--- v2.1.63/linux/arch/i386/kernel/i386_ksyms.c Fri Oct 17 13:59:30 1997
+++ linux/arch/i386/kernel/i386_ksyms.c Wed Nov 12 20:13:35 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.63/linux/net/Config.in linux/net/Config.in
--- v2.1.63/linux/net/Config.in Sat Sep 13 11:07:29 1997
+++ linux/net/Config.in Wed Nov 12 20:14:08 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.63/linux/net/Makefile linux/net/Makefile
--- v2.1.63/linux/net/Makefile Wed Jul 16 19:22:51 1997
+++ linux/net/Makefile Wed Nov 12 20:15:09 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.63/linux/net/netsyms.c linux/net/netsyms.c
--- v2.1.63/linux/net/netsyms.c Wed Nov 12 18:59:36 1997
+++ linux/net/netsyms.c Wed Nov 12 20:16:03 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.63/linux/net/protocols.c linux/net/protocols.c
--- v2.1.63/linux/net/protocols.c Mon Jun 16 16:36:02 1997
+++ linux/net/protocols.c Wed Nov 12 20:16:15 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.63/linux/net/sysctl_net.c linux/net/sysctl_net.c
--- v2.1.63/linux/net/sysctl_net.c Mon Jun 16 16:36:02 1997
+++ linux/net/sysctl_net.c Wed Nov 12 20:17:06 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.63/linux/net/unix/Makefile linux/net/unix/Makefile
--- v2.1.63/linux/net/unix/Makefile Mon Apr 7 11:35:33 1997
+++ linux/net/unix/Makefile Wed Nov 12 20:17:26 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.63/linux/net/unix/af_unix.c linux/net/unix/af_unix.c
--- v2.1.63/linux/net/unix/af_unix.c Sat Sep 20 14:51:55 1997
+++ linux/net/unix/af_unix.c Wed Nov 12 21:21:41 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,11 @@
unix_create
};

+#ifdef MODULE
+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 +1487,30 @@
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
+ return 0;
+#endif
+}
+
+#ifdef MODULE
+void cleanup_module(void)
+{
+ sock_unregister(AF_UNIX);
}
+#endif
+
/*
* Local variables:
* compile-command: "gcc -g -D__KERNEL__ -Wall -O6 -I/usr/src/linux/include -c af_unix.c"