]> Pileus Git - ~andy/linux/blobdiff - include/net/sock.h
Merge HEAD from master.kernel.org:/home/rmk/linux-2.6-ucb.git
[~andy/linux] / include / net / sock.h
index be81cabd0da3f8afb5c645fffeea2b71be3aae97..e9b1dbab90d007fec58e666d98205c1b8ca6a114 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Version:    @(#)sock.h      1.0.4   05/13/93
  *
- * Authors:    Ross Biro, <bir7@leland.Stanford.Edu>
+ * Authors:    Ross Biro
  *             Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  *             Corey Minyard <wf-rch!minyard@relay.EU.net>
  *             Florian La Roche <flla@stud.uni-sb.de>
@@ -90,17 +90,17 @@ do {        spin_lock_init(&((__sk)->sk_lock.slock)); \
 struct sock;
 
 /**
 *    struct sock_common - minimal network layer representation of sockets
 *    @skc_family - network address family
 *    @skc_state - Connection state
 *    @skc_reuse - %SO_REUSEADDR setting
 *    @skc_bound_dev_if - bound device index if != 0
 *    @skc_node - main hash linkage for various protocol lookup tables
 *    @skc_bind_node - bind hash linkage for various protocol lookup tables
 *    @skc_refcnt - reference count
 *
 *    This is the minimal network layer representation of sockets, the header
 *    for struct sock and struct tcp_tw_bucket.
    struct sock_common - minimal network layer representation of sockets
*     @skc_family: network address family
*     @skc_state: Connection state
*     @skc_reuse: %SO_REUSEADDR setting
*     @skc_bound_dev_if: bound device index if != 0
*     @skc_node: main hash linkage for various protocol lookup tables
*     @skc_bind_node: bind hash linkage for various protocol lookup tables
*     @skc_refcnt: reference count
+ *
    This is the minimal network layer representation of sockets, the header
    for struct sock and struct tcp_tw_bucket.
   */
 struct sock_common {
        unsigned short          skc_family;
@@ -114,60 +114,62 @@ struct sock_common {
 
 /**
   *    struct sock - network layer representation of sockets
-  *    @__sk_common - shared layout with tcp_tw_bucket
-  *    @sk_shutdown - mask of %SEND_SHUTDOWN and/or %RCV_SHUTDOWN
-  *    @sk_userlocks - %SO_SNDBUF and %SO_RCVBUF settings
-  *    @sk_lock -      synchronizer
-  *    @sk_rcvbuf - size of receive buffer in bytes
-  *    @sk_sleep - sock wait queue
-  *    @sk_dst_cache - destination cache
-  *    @sk_dst_lock - destination cache lock
-  *    @sk_policy - flow policy
-  *    @sk_rmem_alloc - receive queue bytes committed
-  *    @sk_receive_queue - incoming packets
-  *    @sk_wmem_alloc - transmit queue bytes committed
-  *    @sk_write_queue - Packet sending queue
-  *    @sk_omem_alloc - "o" is "option" or "other"
-  *    @sk_wmem_queued - persistent queue size
-  *    @sk_forward_alloc - space allocated forward
-  *    @sk_allocation - allocation mode
-  *    @sk_sndbuf - size of send buffer in bytes
-  *    @sk_flags - %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings
-  *    @sk_no_check - %SO_NO_CHECK setting, wether or not checkup packets
-  *    @sk_route_caps - route capabilities (e.g. %NETIF_F_TSO)
-  *    @sk_lingertime - %SO_LINGER l_linger setting
-  *    @sk_hashent - hash entry in several tables (e.g. tcp_ehash)
-  *    @sk_backlog - always used with the per-socket spinlock held
-  *    @sk_callback_lock - used with the callbacks in the end of this struct
-  *    @sk_error_queue - rarely used
-  *    @sk_prot - protocol handlers inside a network family
-  *    @sk_err - last error
-  *    @sk_err_soft - errors that don't cause failure but are the cause of a persistent failure not just 'timed out'
-  *    @sk_ack_backlog - current listen backlog
-  *    @sk_max_ack_backlog - listen backlog set in listen()
-  *    @sk_priority - %SO_PRIORITY setting
-  *    @sk_type - socket type (%SOCK_STREAM, etc)
-  *    @sk_protocol - which protocol this socket belongs in this network family
-  *    @sk_peercred - %SO_PEERCRED setting
-  *    @sk_rcvlowat - %SO_RCVLOWAT setting
-  *    @sk_rcvtimeo - %SO_RCVTIMEO setting
-  *    @sk_sndtimeo - %SO_SNDTIMEO setting
-  *    @sk_filter - socket filtering instructions
-  *    @sk_protinfo - private area, net family specific, when not using slab
-  *    @sk_timer - sock cleanup timer
-  *    @sk_stamp - time stamp of last packet received
-  *    @sk_socket - Identd and reporting IO signals
-  *    @sk_user_data - RPC layer private data
-  *    @sk_sndmsg_page - cached page for sendmsg
-  *    @sk_sndmsg_off - cached offset for sendmsg
-  *    @sk_send_head - front of stuff to transmit
-  *    @sk_write_pending - a write to stream socket waits to start
-  *    @sk_state_change - callback to indicate change in the state of the sock
-  *    @sk_data_ready - callback to indicate there is data to be processed
-  *    @sk_write_space - callback to indicate there is bf sending space available
-  *    @sk_error_report - callback to indicate errors (e.g. %MSG_ERRQUEUE)
-  *    @sk_backlog_rcv - callback to process the backlog
-  *    @sk_destruct - called at sock freeing time, i.e. when all refcnt == 0
+  *    @__sk_common: shared layout with tcp_tw_bucket
+  *    @sk_shutdown: mask of %SEND_SHUTDOWN and/or %RCV_SHUTDOWN
+  *    @sk_userlocks: %SO_SNDBUF and %SO_RCVBUF settings
+  *    @sk_lock:       synchronizer
+  *    @sk_rcvbuf: size of receive buffer in bytes
+  *    @sk_sleep: sock wait queue
+  *    @sk_dst_cache: destination cache
+  *    @sk_dst_lock: destination cache lock
+  *    @sk_policy: flow policy
+  *    @sk_rmem_alloc: receive queue bytes committed
+  *    @sk_receive_queue: incoming packets
+  *    @sk_wmem_alloc: transmit queue bytes committed
+  *    @sk_write_queue: Packet sending queue
+  *    @sk_omem_alloc: "o" is "option" or "other"
+  *    @sk_wmem_queued: persistent queue size
+  *    @sk_forward_alloc: space allocated forward
+  *    @sk_allocation: allocation mode
+  *    @sk_sndbuf: size of send buffer in bytes
+  *    @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings
+  *    @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
+  *    @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
+  *    @sk_lingertime: %SO_LINGER l_linger setting
+  *    @sk_hashent: hash entry in several tables (e.g. tcp_ehash)
+  *    @sk_backlog: always used with the per-socket spinlock held
+  *    @sk_callback_lock: used with the callbacks in the end of this struct
+  *    @sk_error_queue: rarely used
+  *    @sk_prot: protocol handlers inside a network family
+  *    @sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance)
+  *    @sk_err: last error
+  *    @sk_err_soft: errors that don't cause failure but are the cause of a persistent failure not just 'timed out'
+  *    @sk_ack_backlog: current listen backlog
+  *    @sk_max_ack_backlog: listen backlog set in listen()
+  *    @sk_priority: %SO_PRIORITY setting
+  *    @sk_type: socket type (%SOCK_STREAM, etc)
+  *    @sk_protocol: which protocol this socket belongs in this network family
+  *    @sk_peercred: %SO_PEERCRED setting
+  *    @sk_rcvlowat: %SO_RCVLOWAT setting
+  *    @sk_rcvtimeo: %SO_RCVTIMEO setting
+  *    @sk_sndtimeo: %SO_SNDTIMEO setting
+  *    @sk_filter: socket filtering instructions
+  *    @sk_protinfo: private area, net family specific, when not using slab
+  *    @sk_timer: sock cleanup timer
+  *    @sk_stamp: time stamp of last packet received
+  *    @sk_socket: Identd and reporting IO signals
+  *    @sk_user_data: RPC layer private data
+  *    @sk_sndmsg_page: cached page for sendmsg
+  *    @sk_sndmsg_off: cached offset for sendmsg
+  *    @sk_send_head: front of stuff to transmit
+  *    @sk_security: used by security modules
+  *    @sk_write_pending: a write to stream socket waits to start
+  *    @sk_state_change: callback to indicate change in the state of the sock
+  *    @sk_data_ready: callback to indicate there is data to be processed
+  *    @sk_write_space: callback to indicate there is bf sending space available
+  *    @sk_error_report: callback to indicate errors (e.g. %MSG_ERRQUEUE)
+  *    @sk_backlog_rcv: callback to process the backlog
+  *    @sk_destruct: called at sock freeing time, i.e. when all refcnt == 0
  */
 struct sock {
        /*
@@ -217,6 +219,7 @@ struct sock {
        } sk_backlog;
        struct sk_buff_head     sk_error_queue;
        struct proto            *sk_prot;
+       struct proto            *sk_prot_creator;
        rwlock_t                sk_callback_lock;
        int                     sk_err,
                                sk_err_soft;
@@ -381,6 +384,11 @@ enum sock_flags {
        SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */
 };
 
+static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
+{
+       nsk->sk_flags = osk->sk_flags;
+}
+
 static inline void sock_set_flag(struct sock *sk, enum sock_flags flag)
 {
        __set_bit(flag, &sk->sk_flags);
@@ -481,6 +489,8 @@ extern void sk_stream_kill_queues(struct sock *sk);
 
 extern int sk_wait_data(struct sock *sk, long *timeo);
 
+struct request_sock_ops;
+
 /* Networking protocol blocks we attach to sockets.
  * socket layer -> transport layer interface
  * transport -> network interface is defined by struct inet_proto
@@ -544,6 +554,8 @@ struct proto {
        kmem_cache_t            *slab;
        unsigned int            obj_size;
 
+       struct request_sock_ops *rsk_prot;
+
        struct module           *owner;
 
        char                    name[32];
@@ -677,16 +689,17 @@ extern void FASTCALL(release_sock(struct sock *sk));
 #define bh_lock_sock(__sk)     spin_lock(&((__sk)->sk_lock.slock))
 #define bh_unlock_sock(__sk)   spin_unlock(&((__sk)->sk_lock.slock))
 
-extern struct sock             *sk_alloc(int family, int priority,
+extern struct sock             *sk_alloc(int family,
+                                         unsigned int __nocast priority,
                                          struct proto *prot, int zero_it);
 extern void                    sk_free(struct sock *sk);
 
 extern struct sk_buff          *sock_wmalloc(struct sock *sk,
                                              unsigned long size, int force,
-                                             int priority);
+                                             unsigned int __nocast priority);
 extern struct sk_buff          *sock_rmalloc(struct sock *sk,
                                              unsigned long size, int force,
-                                             int priority);
+                                             unsigned int __nocast priority);
 extern void                    sock_wfree(struct sk_buff *skb);
 extern void                    sock_rfree(struct sk_buff *skb);
 
@@ -701,7 +714,8 @@ extern struct sk_buff               *sock_alloc_send_skb(struct sock *sk,
                                                     unsigned long size,
                                                     int noblock,
                                                     int *errcode);
-extern void *sock_kmalloc(struct sock *sk, int size, int priority);
+extern void *sock_kmalloc(struct sock *sk, int size,
+                         unsigned int __nocast priority);
 extern void sock_kfree_s(struct sock *sk, void *mem, int size);
 extern void sk_send_sigurg(struct sock *sk);
 
@@ -1125,15 +1139,19 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
 }
 
 static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
-                                                  int size, int mem, int gfp)
+                                                  int size, int mem,
+                                                  unsigned int __nocast gfp)
 {
-       struct sk_buff *skb = alloc_skb(size + sk->sk_prot->max_header, gfp);
+       struct sk_buff *skb;
+       int hdr_len;
 
+       hdr_len = SKB_DATA_ALIGN(sk->sk_prot->max_header);
+       skb = alloc_skb(size + hdr_len, gfp);
        if (skb) {
                skb->truesize += mem;
                if (sk->sk_forward_alloc >= (int)skb->truesize ||
                    sk_stream_mem_schedule(sk, skb->truesize, 0)) {
-                       skb_reserve(skb, sk->sk_prot->max_header);
+                       skb_reserve(skb, hdr_len);
                        return skb;
                }
                __kfree_skb(skb);
@@ -1145,7 +1163,8 @@ static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
 }
 
 static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk,
-                                                 int size, int gfp)
+                                                 int size,
+                                                 unsigned int __nocast gfp)
 {
        return sk_stream_alloc_pskb(sk, size, 0, gfp);
 }
@@ -1178,7 +1197,7 @@ static inline int sock_writeable(const struct sock *sk)
        return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf / 2);
 }
 
-static inline int gfp_any(void)
+static inline unsigned int __nocast gfp_any(void)
 {
        return in_softirq() ? GFP_ATOMIC : GFP_KERNEL;
 }
@@ -1223,8 +1242,8 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
 
 /**
  * sk_eat_skb - Release a skb if it is no longer needed
- * @sk - socket to eat this skb from
- * @skb - socket buffer to eat
+ * @sk: socket to eat this skb from
+ * @skb: socket buffer to eat
  *
  * This routine must be called with interrupts disabled or with the socket
  * locked so that the sk_buff queue operation is ok.