[2142] in linux-net channel archive

home help back first fref pref prev next nref lref last post

IPX modularization patch

daemon@ATHENA.MIT.EDU (Jim Freeman)
Tue Mar 19 02:10:55 1996

Date: 	Tue, 19 Mar 1996 00:04:59 -0700
From: Jim Freeman <jfree@caldera.com>
To: iialan@iifeak.swan.ac.uk, linux-net@vger.rutgers.edu

The following patch against 1.3.75 modularizes IPX.  It has had some
nominal testing, and seems to load, operate, and then unload OK.

If you use IPX and are so inclined, please test this out and report
any problems to jfree@caldera.com

unregister_snap_client() was borrowed from Tom Dyas's (tdyas@eden.rutgers.edu)
appletalk 1.3.74 patch from last week, and unregister_8022_client() was
modelled after it.

...jfree

======================
diff -u -r -P linux-1.3.75/Documentation/Configure.help linux/Documentation/Configure.help
--- linux-1.3.75/Documentation/Configure.help	Sat Mar 16 04:52:13 1996
+++ linux/Documentation/Configure.help	Mon Mar 18 12:59:21 1996
@@ -899,21 +899,26 @@
 
 The IPX protocol
 CONFIG_IPX
-  This is support for the Novell networking protocol, IPX, commonly
-  used for local networks of Windows machines. You need it if you want
-  to access Novell Netware file or print servers using the Linux
-  Novell client ncpfs (available via ftp (user: anonymous) from
-  sunsite.unc.edu:/pub/Linux/system/Filesystems/) or from within the
-  Linux DOS emulator dosemu (read the DOSEMU-HOWTO, available in
-  sunsite.unc.edu:/pub/Linux/docs/HOWTO). In order to do the former,
-  you'll also have to say Y to "NCP filesystem support", below. To
-  turn your Linux box into a fully featured Netware file server and
-  IPX router, say Y here and fetch either lwared from
-  sunsite.unc.edu:/pub/Linux/system/Network/daemons/ or mars_nwe from
-  linux01.gwdg.de:/pub/ncpfs. For more information, read the IPX-HOWTO
-  in sunsite.unc.edu:/pub/Linux/docs/howto. The IPX driver would
-  enlarge your kernel by about 5 kB. Unless you want to integrate your
-  Linux box with a local Novell network, say N.
+  IPX (Internetwork Packet eXchange) is a connectionless/datagram
+  network-layer protocol used predominantly in Novell networks.
+  Higher-level NetWare file and print services (NCPs) typically
+  depend on IPX being present.  If you expect to use any of the
+  NetWare clients available for Linux or under DOSEMU (see:
+    http://sunsite.unc.edu/pub/Linux/system/Filesystems/ncpfs-0.xx.tgz
+      (see also "NCP filesystem support", below)
+    http://sunsite.unc.edu/pub/Linux/docs/HOWTO/DOSEMU-HOWTO
+    http://www.caldera.com/  ) you should configure IPX in the kernel
+  ("y") or as a module ("m").  IPX routing is discussed in these docs:
+    http://sunsite.unc.edu/pub/Linux/docs/HOWTO/IPX-HOWTO
+    http://sunsite.unc.edu/pub/Linux/docs/HOWTO/PPP-HOWTO  (PPP-WAN)
+    http://www.sangoma.com/fguide.htm  (Linux/IPX/Frame-Relay/X.25...)
+    http://occam.sjf.novell.com:8080/nw410.english/ipxrtenu/1.toc
+    http://netwire.novell.com/home/novlabs/langrp/ipxrtr.htm
+    http://netwire.novell.com/home/novlabs/langrp/ipxrtr.exe  (SPEC)
+  Daemons that provide some file services can be found at:
+    sunsite.unc.edu:/pub/Linux/system/Network/daemons/lwared-0.xx.tar.gz
+    ftp://linux01.gwdg.de/pub/ncpfs/mars_nwe-0.xx.tgz
+  If your Linux system will not reside on a Novell network, answer "n".
 
 Full internal IPX network
 CONFIG_IPX_INTERN
diff -u -r -P linux-1.3.75/arch/i386/defconfig linux/arch/i386/defconfig
--- linux-1.3.75/arch/i386/defconfig	Sat Mar 16 04:52:13 1996
+++ linux/arch/i386/defconfig	Mon Mar 18 12:59:22 1996
@@ -70,7 +70,7 @@
 #
 #  
 #
-# CONFIG_IPX is not set
+CONFIG_IPX=m
 # CONFIG_ATALK is not set
 # CONFIG_AX25 is not set
 # CONFIG_NETLINK is not set
diff -u -r -P linux-1.3.75/include/net/ipx.h linux/include/net/ipx.h
--- linux-1.3.75/include/net/ipx.h	Sat Mar 16 06:00:09 1996
+++ linux/include/net/ipx.h	Mon Mar 18 14:16:53 1996
@@ -11,6 +11,7 @@
 #ifndef _NET_INET_IPX_H_
 #define _NET_INET_IPX_H_
 
+#include <linux/netdevice.h>
 #include <linux/skbuff.h>
 #include <net/datalink.h>
 #include <linux/ipx.h>
diff -u -r -P linux-1.3.75/include/net/p8022.h linux/include/net/p8022.h
--- linux-1.3.75/include/net/p8022.h	Tue Jun  6 02:22:17 1995
+++ linux/include/net/p8022.h	Mon Mar 18 12:59:22 1996
@@ -1,2 +1,13 @@
-struct datalink_proto *register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *));
+/*
+ * linux/include/net/p8022.h
+ * $Id$
+ */
+#ifndef _P8022_H_
+#define _P8022_H_
 
+extern struct datalink_proto *
+register_8022_client(unsigned char type,
+      int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *));
+extern void unregister_8022_client(unsigned char type);
+
+#endif	/* ndef _P8022_H_ */
diff -u -r -P linux-1.3.75/include/net/p8022call.h linux/include/net/p8022call.h
--- linux-1.3.75/include/net/p8022call.h	Tue Jun  6 02:22:17 1995
+++ linux/include/net/p8022call.h	Mon Mar 18 12:59:22 1996
@@ -1,2 +1,11 @@
+/*
+ * linux/include/net/p8022call.h
+ * $Id$
+ */
 /* Separate to keep compilation of Space.c simpler */
+#ifndef _P8022_CALL_H_
+#define _P8022_CALL_H_
+
 extern void p8022_proto_init(struct net_proto *);
+
+#endif	/* ndef _P8022_CALL_H_ */
diff -u -r -P linux-1.3.75/include/net/psnap.h linux/include/net/psnap.h
--- linux-1.3.75/include/net/psnap.h	Tue Jun  6 02:22:18 1995
+++ linux/include/net/psnap.h	Mon Mar 18 12:59:22 1996
@@ -1,2 +1,13 @@
-struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *));
+/*
+ * linux/include/net/psnap.h
+ * $Id$
+ */
+#ifndef _PSNAP_H_
+#define _PSNAP_H_
 
+extern struct datalink_proto *
+register_snap_client(unsigned char *desc,
+      int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *));
+extern void unregister_snap_client(unsigned char *desc);
+
+#endif	/* ndef _PSNAP_H_ */
diff -u -r -P linux-1.3.75/include/net/psnapcall.h linux/include/net/psnapcall.h
--- linux-1.3.75/include/net/psnapcall.h	Tue Jun  6 02:22:18 1995
+++ linux/include/net/psnapcall.h	Mon Mar 18 12:59:22 1996
@@ -1,2 +1,11 @@
+/*
+ * linux/include/net/psnapcall.h
+ * $Id$
+ */
 /* Separate to keep compilation of Space.c simpler */
+#ifndef _PSNAP_CALL_H_
+#define _PSNAP_CALL_H_
+
 extern void snap_proto_init(struct net_proto *);
+
+#endif	/* ndef _PSNAP_CALL_H_ */
diff -u -r -P linux-1.3.75/include/net/sock.h linux/include/net/sock.h
--- linux-1.3.75/include/net/sock.h	Sat Mar 16 06:00:09 1996
+++ linux/include/net/sock.h	Mon Mar 18 14:16:53 1996
@@ -35,6 +35,7 @@
 #include <linux/ip.h>		/* struct options */
 #include <linux/in.h>		/* struct sockaddr_in */
 #include <linux/tcp.h>		/* struct tcphdr */
+#include <net/ipx.h>
 #include <linux/config.h>
 
 #include <linux/netdevice.h>
@@ -46,9 +47,6 @@
 #include <net/netrom.h>
 #endif
 #endif
-#ifdef CONFIG_IPX
-#include <net/ipx.h>
-#endif
 #ifdef CONFIG_ATALK
 #include <linux/atalk.h>
 #endif
@@ -89,16 +87,12 @@
 /*
  *	Once the IPX ncpd patches are in these are going into protinfo
  */
-
-#ifdef CONFIG_IPX 
 struct ipx_opt
 {
 	ipx_address		dest_addr;
 	ipx_interface		*intrfc;
 	unsigned short		port;
-#ifdef CONFIG_IPX_INTERN
 	unsigned char           node[IPX_NODE_LEN];
-#endif
 	unsigned short		type;
 /* 
  * To handle asynchronous messages from the NetWare server, we have to
@@ -107,7 +101,6 @@
 	struct ncp_server       *ncp_server;
 	
 };
-#endif
 
 #ifdef CONFIG_NUTCP
 struct tcp_opt
@@ -262,9 +255,7 @@
 #ifdef CONFIG_ATALK
 		struct atalk_sock	af_at;
 #endif
-#ifdef CONFIG_IPX
 		struct ipx_opt		af_ipx;
-#endif		
 #ifdef CONFIG_INET
 		struct inet_packet_opt  af_packet;
 #ifdef CONFIG_NUTCP		
diff -u -r -P linux-1.3.75/kernel/ksyms.c linux/kernel/ksyms.c
--- linux-1.3.75/kernel/ksyms.c	Sat Mar 16 04:52:16 1996
+++ linux/kernel/ksyms.c	Mon Mar 18 12:59:22 1996
@@ -48,12 +48,19 @@
 
 extern unsigned char aux_device_present, kbd_read_mask;
 
+extern struct datalink_proto	*make_EII_client(void);
+extern struct datalink_proto	*make_8023_client(void);
+extern void	rm_EII_client(struct datalink_proto *);
+extern void	rm_8023_client(struct datalink_proto *);
+
 #ifdef CONFIG_NET
 #include <linux/in.h>
 #include <linux/net.h>
 #include <linux/netdevice.h>
 #include <linux/firewall.h>
 #include <linux/trdevice.h>
+#include <net/psnap.h>
+#include <net/p8022.h>
 
 #ifdef CONFIG_AX25
 #include <net/ax25.h>
@@ -345,11 +352,24 @@
 	X(sock_register),
 	X(sock_unregister),
 	/* Socket layer support routines */
+	X(memcpy_fromiovec),
+	X(sock_setsockopt),
+	X(sock_getsockopt),
+	X(sock_wake_async),
+	X(sock_alloc_send_skb),
 	X(skb_recv_datagram),
 	X(skb_free_datagram),
 	X(skb_copy_datagram),
 	X(skb_copy_datagram_iovec),
 	X(datagram_select),
+	X(register_snap_client),
+	X(unregister_snap_client),
+	X(register_8022_client),
+	X(unregister_8022_client),
+	X(make_8023_client),
+	X(rm_8023_client),
+	X(make_EII_client),
+	X(rm_EII_client),
 #ifdef CONFIG_FIREWALL
 	/* Firewall registration */
 	X(register_firewall),
diff -u -r -P linux-1.3.75/net/802/p8022.c linux/net/802/p8022.c
--- linux-1.3.75/net/802/p8022.c	Fri Nov 24 07:39:54 1995
+++ linux/net/802/p8022.c	Mon Mar 18 12:59:22 1996
@@ -96,3 +96,16 @@
 	return proto;
 }
 
+void
+unregister_8022_client(unsigned char type)
+{	struct datalink_proto *tmp, **clients = &p8022_list;
+
+	while ((tmp = *clients) != NULL) {
+		if (tmp->type[0] == type) {
+			*clients = tmp->next;
+			kfree_s(tmp, sizeof(struct datalink_proto));
+		} else
+			clients = &tmp->next;
+	}
+	return;
+}
diff -u -r -P linux-1.3.75/net/802/p8023.c linux/net/802/p8023.c
--- linux-1.3.75/net/802/p8023.c	Thu Jul 27 10:34:36 1995
+++ linux/net/802/p8023.c	Mon Mar 18 12:59:22 1996
@@ -29,3 +29,9 @@
 	return proto;
 }
 
+void
+rm_8023_client(struct datalink_proto *dl)
+{
+	if(dl) kfree_s(dl, sizeof(*dl));
+	return;
+}
diff -u -r -P linux-1.3.75/net/802/psnap.c linux/net/802/psnap.c
--- linux-1.3.75/net/802/psnap.c	Thu Jul 27 10:34:36 1995
+++ linux/net/802/psnap.c	Mon Mar 18 12:59:22 1996
@@ -88,9 +88,9 @@
 	if(snap_dl==NULL)
 		printk("SNAP - unable to register with 802.2\n");
 }
-	
+ 
 /*
- *	Register SNAP clients. We don't yet use this for IP or IPX.
+ *	Register SNAP clients. Used for IPX, but not IP yet.
  */
  
 struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *))
@@ -116,3 +116,16 @@
 	return proto;
 }
 
+void
+unregister_snap_client(unsigned char *desc)
+{	struct datalink_proto *tmp, **clients = &snap_list;
+
+	while ((tmp = *clients) != NULL) {
+		if (memcmp(tmp->type, desc, 5) == 0) {
+			*clients = tmp->next;
+			kfree_s(tmp, sizeof(struct datalink_proto));
+		} else
+			clients = &tmp->next;
+	}
+	return;
+}
diff -u -r -P linux-1.3.75/net/Config.in linux/net/Config.in
--- linux-1.3.75/net/Config.in	Tue Feb  6 23:55:43 1996
+++ linux/net/Config.in	Mon Mar 18 12:59:22 1996
@@ -10,8 +10,8 @@
   source net/ipv4/Config.in
 fi
 comment ' '
-bool 'The IPX protocol' CONFIG_IPX
-if [ "$CONFIG_IPX" = "y" ]; then
+tristate 'The IPX protocol' CONFIG_IPX
+if [ "$CONFIG_IPX" != "n" ]; then
   bool 'Full internal IPX network' CONFIG_IPX_INTERN
 fi
 bool 'Appletalk DDP' CONFIG_ATALK
diff -u -r -P linux-1.3.75/net/Makefile linux/net/Makefile
--- linux-1.3.75/net/Makefile	Wed Nov  8 03:40:50 1995
+++ linux/net/Makefile	Mon Mar 18 12:59:23 1996
@@ -15,8 +15,12 @@
 SUB_DIRS += ipv4
 endif
 
-ifeq ($(CONFIG_IPX),y)
-SUB_DIRS += ipx
+ifeq ($(CONFIG_IPX),m)
+MOD_SUB_DIRS += ipx
+else
+  ifeq ($(CONFIG_IPX),y)
+  SUB_DIRS += ipx
+  endif
 endif
 
 ifeq ($(CONFIG_ATALK),y)
diff -u -r -P linux-1.3.75/net/ethernet/pe2.c linux/net/ethernet/pe2.c
--- linux-1.3.75/net/ethernet/pe2.c	Fri Nov 24 07:39:54 1995
+++ linux/net/ethernet/pe2.c	Mon Mar 18 12:59:23 1996
@@ -30,3 +30,9 @@
 	return proto;
 }
 
+void
+rm_EII_client(struct datalink_proto *dl)
+{
+	if(dl) kfree_s(dl, sizeof(*dl));
+	return;
+}
diff -u -r -P linux-1.3.75/net/ipx/Makefile linux/net/ipx/Makefile
--- linux-1.3.75/net/ipx/Makefile	Tue Aug 15 06:07:03 1995
+++ linux/net/ipx/Makefile	Mon Mar 18 12:59:23 1996
@@ -1,5 +1,5 @@
 #
-# Makefile for the Linux TCP/IP (INET) layer.
+# Makefile for Linux IPX.
 #
 # Note! Dependencies are done automagically by 'make dep', which also
 # removes any old dependencies. DON'T put your own dependencies here
@@ -8,7 +8,22 @@
 # Note 2! The CFLAGS definition is now in the main makefile...
 
 O_TARGET := ipx.o
+IPX_OBJS :=
+M_OBJS :=
 O_OBJS   := af_ipx.o
+
+MOD_LIST_NAME := NET_MODULES
+
+ifeq ($(CONFIG_IPX),m)
+  IPX_OBJS += af_ipx.o
+  M_OBJS += ipx.o
+else
+  ifeq ($(CONFIG_IPX),y)
+     IPX_OBJS += af_ipx.o
+  endif
+endif
+
+O_OBJS := $(IPX_OBJS)
 
 include $(TOPDIR)/Rules.make
 
diff -u -r -P linux-1.3.75/net/ipx/af_ipx.c linux/net/ipx/af_ipx.c
--- linux-1.3.75/net/ipx/af_ipx.c	Mon Mar  4 00:16:41 1996
+++ linux/net/ipx/af_ipx.c	Mon Mar 18 18:08:25 1996
@@ -47,7 +47,9 @@
  *	warranty for any of this software. This material is provided 
  *	"AS-IS" and at no charge.		
  */
-  
+
+#include <linux/module.h>
+
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
@@ -59,11 +61,10 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
-#include <linux/ipx.h>
-#include <linux/inet.h>
 #include <linux/netdevice.h>
+#include <net/ipx.h>
+#include <linux/inet.h>
 #include <linux/route.h>
-#include <linux/skbuff.h>
 #include <net/sock.h>
 #include <asm/segment.h>
 #include <asm/system.h>
@@ -77,7 +78,10 @@
 #include <linux/stat.h>
 #include <linux/firewall.h>
 
-#ifdef CONFIG_IPX
+#ifdef MODULE
+static void ipx_proto_finito(void);
+#endif /* def MODULE */
+
 /* Configuration Variables */
 static unsigned char	ipxcfg_max_hops = 16;
 static char		ipxcfg_auto_select_primary = 0;
@@ -89,10 +93,10 @@
 static struct datalink_proto	*p8023_datalink = NULL;
 static struct datalink_proto	*pSNAP_datalink = NULL;
 
-static ipx_interface	*ipx_interfaces = NULL;
 static ipx_route 	*ipx_routes = NULL;
-static ipx_interface	*ipx_internal_net = NULL;
+static ipx_interface	*ipx_interfaces = NULL;
 static ipx_interface	*ipx_primary_net = NULL;
+static ipx_interface	*ipx_internal_net = NULL;
 
 static int
 ipxcfg_set_auto_create(char val)
@@ -187,6 +191,7 @@
 	}
 	
 	kfree_s(sk,sizeof(*sk));
+	MOD_DEC_USE_COUNT;
 }
 	
 /* The following code is used to support IPX Interfaces (IPXITF).  An
@@ -194,7 +199,7 @@
  */
 
 static ipx_route * ipxrtr_lookup(unsigned long);
- 
+
 static void
 ipxitf_clear_primary_net(void)
 {
@@ -324,6 +329,10 @@
 		ipx_internal_net = NULL;
 
 	kfree_s(intrfc, sizeof(*intrfc));
+	/* sockets still dangling
+	 * - must be closed from user space
+	 */
+	return;
 }
 
 static int 
@@ -790,6 +799,7 @@
 
 	if (ipxcfg_auto_select_primary && (ipx_primary_net == NULL))
 		ipx_primary_net = intrfc;
+	return;
 }
 
 static int 
@@ -1155,7 +1165,7 @@
 /*
  *	Route an outgoing frame from a socket.
  */
- 
+
 static int ipxrtr_route_packet(ipx_socket *sk, struct sockaddr_ipx *usipx, struct iovec *iov, int len)
 {
 	struct sk_buff *skb;
@@ -1259,7 +1269,7 @@
 /*
  *	We use a normal struct rtentry for route handling
  */
- 
+
 static int ipxrtr_ioctl(unsigned int cmd, void *arg)
 {
 	int err;
@@ -1483,7 +1493,7 @@
 *	      Handling for system calls applied via the various interfaces to an IPX socket object		    *
 *														    *
 \*******************************************************************************************************************/
- 
+
 static int ipx_fcntl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
 	switch(cmd)
@@ -1642,6 +1652,7 @@
 	sk->error_report=def_callback1;
 
 	sk->zapped=1;
+	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -1830,8 +1841,10 @@
 
 static int ipx_accept(struct socket *sock, struct socket *newsock, int flags)
 {
-	if(newsock->data)
+	if(newsock->data) {
 		kfree_s(newsock->data,sizeof(ipx_socket));
+		MOD_DEC_USE_COUNT;
+	}
 	return -EOPNOTSUPP;
 }
 
@@ -2187,7 +2200,7 @@
 	NULL,
 	NULL,
 };
- 
+
 static struct packet_type ipx_dix_packet_type = 
 {
 	0,	/* MUTTER ntohs(ETH_P_IPX),*/
@@ -2196,7 +2209,7 @@
 	NULL,
 	NULL,
 };
- 
+
 static struct notifier_block ipx_dev_notifier={
 	ipxitf_device_event,
 	NULL,
@@ -2206,12 +2219,30 @@
 
 extern struct datalink_proto	*make_EII_client(void);
 extern struct datalink_proto	*make_8023_client(void);
+extern void	rm_EII_client(struct datalink_proto *);
+extern void	rm_8023_client(struct datalink_proto *);
 
-void ipx_proto_init(struct net_proto *pro)
-{
-	unsigned char	val = 0xE0;
-	unsigned char	snapval[5] =  { 0x0, 0x0, 0x0, 0x81, 0x37 };
+struct proc_dir_entry ipx_procinfo = {
+	PROC_NET_IPX, 3, "ipx", S_IFREG | S_IRUGO,
+	1, 0, 0, 0, &proc_net_inode_operations, ipx_get_info
+};
+
+struct proc_dir_entry ipx_if_procinfo = {
+	PROC_NET_IPX_INTERFACE, 13, "ipx_interface", S_IFREG | S_IRUGO,
+	1, 0, 0, 0, &proc_net_inode_operations, ipx_interface_get_info
+};
 
+struct proc_dir_entry ipx_rt_procinfo = {
+	PROC_NET_IPX_ROUTE, 9, "ipx_route", S_IFREG | S_IRUGO,
+	1, 0, 0, 0, &proc_net_inode_operations, ipx_rt_get_info
+};
+
+static unsigned char	ipx_8022_type = 0xE0;
+static unsigned char	ipx_snap_id[5] =  { 0x0, 0x0, 0x0, 0x81, 0x37 };
+
+void
+ipx_proto_init(struct net_proto *pro)
+{
 	(void) sock_register(ipx_proto_ops.family, &ipx_proto_ops);
 
 	pEII_datalink = make_EII_client();
@@ -2222,34 +2253,81 @@
 	ipx_8023_packet_type.type=htons(ETH_P_802_3);
 	dev_add_pack(&ipx_8023_packet_type);
 	
-	if ((p8022_datalink = register_8022_client(val, ipx_rcv)) == NULL)
+	if ((p8022_datalink = register_8022_client(ipx_8022_type, ipx_rcv)) == NULL)
 		printk("IPX: Unable to register with 802.2\n");
 
-	if ((pSNAP_datalink = register_snap_client(snapval, ipx_rcv)) == NULL)
+	if ((pSNAP_datalink = register_snap_client(ipx_snap_id, ipx_rcv)) == NULL)
 		printk("IPX: Unable to register with SNAP\n");
 	
 	register_netdevice_notifier(&ipx_dev_notifier);
 
-	proc_net_register(&(struct proc_dir_entry) {
-		PROC_NET_IPX, 3, "ipx",
-		S_IFREG | S_IRUGO, 1, 0, 0,
-		0, &proc_net_inode_operations,
-		ipx_get_info
-	});
-	proc_net_register(&(struct proc_dir_entry) {
-		PROC_NET_IPX_INTERFACE, 13, "ipx_interface",
-		S_IFREG | S_IRUGO, 1, 0, 0,
-		0, &proc_net_inode_operations,
-		ipx_interface_get_info
-	});
-	proc_net_register(&(struct proc_dir_entry) {
-		PROC_NET_IPX_ROUTE, 9, "ipx_route",
-		S_IFREG | S_IRUGO, 1, 0, 0,
-		0, &proc_net_inode_operations,
-		ipx_rt_get_info
-	});
+	proc_net_register(&ipx_procinfo);
+	proc_net_register(&ipx_if_procinfo);
+	proc_net_register(&ipx_rt_procinfo);
 		
 	printk("Swansea University Computer Society IPX 0.33 for NET3.032\n");
 	printk("IPX Portions Copyright (c) 1995 Caldera, Inc.\n");
 }
-#endif
+
+#ifdef MODULE
+/* Note on MOD_{INC,DEC}_USE_COUNT:
+ *
+ * Use counts are incremented/decremented when
+ * sockets are created/deleted.
+ * 
+ * Routes are always associated with an interface, and
+ * allocs/frees will remain properly accounted for by
+ * their associated interfaces.
+ * 
+ * Ergo, before the ipx module can be removed, all IPX
+ * sockets be closed from user space. 
+ */
+
+static void
+ipx_proto_finito(void)
+{	ipx_interface	*ifc;
+
+	while (ipx_interfaces) {
+		ifc = ipx_interfaces;
+		ipx_interfaces = ifc->if_next;
+		ifc->if_next = NULL;
+		ipxitf_down(ifc);
+	}
+
+	proc_net_unregister(PROC_NET_IPX_ROUTE);
+	proc_net_unregister(PROC_NET_IPX_INTERFACE);
+	proc_net_unregister(PROC_NET_IPX);
+
+	unregister_netdevice_notifier(&ipx_dev_notifier);
+
+	unregister_snap_client(ipx_snap_id);
+	pSNAP_datalink = NULL;
+
+	unregister_8022_client(ipx_8022_type);
+	p8022_datalink = NULL;
+
+	dev_remove_pack(&ipx_8023_packet_type);
+	rm_8023_client(p8023_datalink);
+	p8023_datalink = NULL;
+
+	dev_remove_pack(&ipx_dix_packet_type);
+	rm_EII_client(pEII_datalink);
+	pEII_datalink = NULL;
+
+	(void) sock_unregister(ipx_proto_ops.family);
+
+	return;
+}
+
+int init_module(void)
+{
+	ipx_proto_init(NULL);
+	return 0;
+}
+
+void cleanup_module(void)
+{
+	ipx_proto_finito();
+	return;
+}
+#endif /* def MODULE */
diff -u -r -P linux-1.3.75/net/protocols.c linux/net/protocols.c
--- linux-1.3.75/net/protocols.c	Mon Mar  4 01:37:53 1996
+++ linux/net/protocols.c	Mon Mar 18 17:10:49 1996
@@ -18,9 +18,9 @@
 #ifdef	CONFIG_INET
 #include <linux/inet.h>
 #endif
+#include <net/p8022call.h>
 #ifdef CONFIG_IPX
 #include <net/ipxcall.h>
-#include <net/p8022call.h>
 #endif
 #ifdef CONFIG_AX25
 #include <net/ax25call.h>
@@ -29,9 +29,6 @@
 #endif
 #endif
 #ifdef CONFIG_ATALK
-#ifndef CONFIG_IPX
-#include <net/p8022call.h>
-#endif
 #include <net/atalkcall.h>
 #endif
 #include <net/psnapcall.h>
@@ -48,10 +45,8 @@
 #ifdef	CONFIG_UNIX
   { "UNIX",	unix_proto_init	},			/* Unix domain socket family 	*/
 #endif
-#if defined(CONFIG_IPX)||defined(CONFIG_ATALK)  
   { "802.2",	p8022_proto_init },			/* 802.2 demultiplexor		*/
   { "SNAP",	snap_proto_init },			/* SNAP demultiplexor		*/
-#endif
 #ifdef CONFIG_TR
   { "RIF",	rif_init },				/* RIF for Token ring		*/
 #endif  

-- 
Jim Freeman
jfree@caldera.com


home help back first fref pref prev next nref lref last post