patch-2.0.30 linux/include/net/sock.h
Next file: linux/include/net/tcp.h
Previous file: linux/include/net/raw.h
Back to the patch index
Back to the overall index
- Lines: 143
- Date:
Tue Apr 8 08:47:47 1997
- Orig file:
v2.0.29/linux/include/net/sock.h
- Orig date:
Sun Dec 1 10:01:21 1996
diff -u --recursive --new-file v2.0.29/linux/include/net/sock.h linux/include/net/sock.h
@@ -22,6 +22,7 @@
* Alan Cox : New fields for options
* Pauline Middelink : identd support
* Alan Cox : Eliminate low level recv/recvfrom
+ * David S. Miller : New socket lookup architecture for ISS.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -59,10 +60,6 @@
#include <asm/atomic.h>
-/* Think big (also on some systems a byte is faster) */
-#define SOCK_ARRAY_SIZE 256
-
-
/*
* The AF_UNIX specific socket options
*/
@@ -155,6 +152,10 @@
*/
struct sock
{
+ /* This must be first. */
+ struct sock *sklist_next;
+ struct sock *sklist_prev;
+
struct options *opt;
atomic_t wmem_alloc;
atomic_t rmem_alloc;
@@ -193,9 +194,14 @@
bsdism;
unsigned long lingertime;
int proc;
+
struct sock *next;
- struct sock *prev; /* Doubly linked chain.. */
+ struct sock **pprev;
+ struct sock *bind_next;
+ struct sock **bind_pprev;
struct sock *pair;
+ int hashent;
+ struct sock *prev;
struct sk_buff * volatile send_head;
struct sk_buff * volatile send_next;
struct sk_buff * volatile send_tail;
@@ -337,6 +343,10 @@
struct proto
{
+ /* These must be first. */
+ struct sock *sklist_next;
+ struct sock *sklist_prev;
+
void (*close)(struct sock *sk, unsigned long timeout);
int (*build_header)(struct sk_buff *skb,
__u32 saddr,
@@ -372,11 +382,18 @@
int (*recvmsg)(struct sock *sk, struct msghdr *msg, int len,
int noblock, int flags, int *addr_len);
int (*bind)(struct sock *sk, struct sockaddr *uaddr, int addr_len);
+
+ /* Keeping track of sk's, looking them up, and port selection methods. */
+ void (*hash)(struct sock *sk);
+ void (*unhash)(struct sock *sk);
+ void (*rehash)(struct sock *sk);
+ unsigned short (*good_socknum)(void);
+ int (*verify_bind)(struct sock *sk, unsigned short snum);
+
unsigned short max_header;
unsigned long retransmits;
char name[32];
int inuse, highestinuse;
- struct sock * sock_array[SOCK_ARRAY_SIZE];
};
#define TIME_WRITE 1
@@ -402,6 +419,46 @@
#define RCV_SHUTDOWN 1
#define SEND_SHUTDOWN 2
+/* Per-protocol hash table implementations use this to make sure
+ * nothing changes.
+ */
+#define SOCKHASH_LOCK() start_bh_atomic()
+#define SOCKHASH_UNLOCK() end_bh_atomic()
+
+/* Some things in the kernel just want to get at a protocols
+ * entire socket list commensurate, thus...
+ */
+static __inline__ void add_to_prot_sklist(struct sock *sk)
+{
+ SOCKHASH_LOCK();
+ if(!sk->sklist_next) {
+ struct proto *p = sk->prot;
+
+ sk->sklist_prev = (struct sock *) p;
+ sk->sklist_next = p->sklist_next;
+ p->sklist_next->sklist_prev = sk;
+ p->sklist_next = sk;
+
+ /* Charge the protocol. */
+ sk->prot->inuse += 1;
+ if(sk->prot->highestinuse < sk->prot->inuse)
+ sk->prot->highestinuse = sk->prot->inuse;
+ }
+ SOCKHASH_UNLOCK();
+}
+
+static __inline__ void del_from_prot_sklist(struct sock *sk)
+{
+ SOCKHASH_LOCK();
+ if(sk->sklist_next) {
+ sk->sklist_next->sklist_prev = sk->sklist_prev;
+ sk->sklist_prev->sklist_next = sk->sklist_next;
+ sk->sklist_next = NULL;
+ sk->prot->inuse--;
+ }
+ SOCKHASH_UNLOCK();
+}
+
/*
* Used by processes to "lock" a socket state, so that
* interrupts and bottom half handlers won't change it
@@ -449,18 +506,6 @@
extern struct sock * sk_alloc(int priority);
extern void sk_free(struct sock *sk);
extern void destroy_sock(struct sock *sk);
-extern unsigned short get_new_socknum(struct proto *,
- unsigned short);
-extern void put_sock(unsigned short, struct sock *);
-extern struct sock *get_sock(struct proto *, unsigned short,
- unsigned long, unsigned short,
- unsigned long,
- unsigned long, unsigned short);
-extern struct sock *get_sock_mcast(struct sock *, unsigned short,
- unsigned long, unsigned short,
- unsigned long);
-extern struct sock *get_sock_raw(struct sock *, unsigned short,
- unsigned long, unsigned long);
extern struct sk_buff *sock_wmalloc(struct sock *sk,
unsigned long size, int force,
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov