diff -uNr linux-2.5.1/drivers/net/pppoe.c linux-2.5.1.acme/drivers/net/pppoe.c --- linux-2.5.1/drivers/net/pppoe.c Fri Nov 9 20:02:24 2001 +++ linux-2.5.1.acme/drivers/net/pppoe.c Wed Dec 19 23:44:47 2001 @@ -127,7 +127,8 @@ return hash & ( PPPOE_HASH_SIZE - 1 ); } -static struct pppox_opt *item_hash_table[PPPOE_HASH_SIZE] = { 0, }; +/* zeroed because its in .bss */ +static struct pppox_opt *item_hash_table[PPPOE_HASH_SIZE]; /********************************************************************** * @@ -340,7 +341,7 @@ ***********************************************************************/ int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb) { - struct pppox_opt *po = sk->protinfo.pppox; + struct pppox_opt *po = PPPOX_SK(sk); struct pppox_opt *relay_po = NULL; if (sk->state & PPPOX_BOUND) { @@ -468,8 +469,8 @@ **********************************************************************/ void pppoe_sock_destruct(struct sock *sk) { - if (sk->protinfo.destruct_hook) - kfree(sk->protinfo.destruct_hook); + if (PPPOX_SK(sk)) + kfree(PPPOX_SK(sk)); MOD_DEC_USE_COUNT; } @@ -505,17 +506,15 @@ sk->type = SOCK_STREAM; sk->destruct = pppoe_sock_destruct; - sk->protinfo.pppox = kmalloc(sizeof(struct pppox_opt), GFP_KERNEL); - if (!sk->protinfo.pppox) { + PPPOX_SK(sk) = kmalloc(sizeof(struct pppox_opt), GFP_KERNEL); + if (!PPPOX_SK(sk)) { error = -ENOMEM; goto free_sk; } - memset((void *) sk->protinfo.pppox, 0, sizeof(struct pppox_opt)); - sk->protinfo.pppox->sk = sk; + memset(PPPOX_SK(sk), 0, sizeof(struct pppox_opt)); + PPPOX_SK(sk)->sk = sk; - /* Delete the protinfo when it is time to do so. */ - sk->protinfo.destruct_hook = sk->protinfo.pppox; sock->sk = sk; return 0; @@ -542,7 +541,7 @@ /* Signal the death of the socket. */ sk->state = PPPOX_DEAD; - po = sk->protinfo.pppox; + po = PPPOX_SK(sk); if (po->pppoe_pa.sid) { delete_item(po->pppoe_pa.sid, po->pppoe_pa.remote); } @@ -568,7 +567,7 @@ struct sock *sk = sock->sk; struct net_device *dev = NULL; struct sockaddr_pppox *sp = (struct sockaddr_pppox *) uservaddr; - struct pppox_opt *po = sk->protinfo.pppox; + struct pppox_opt *po = PPPOX_SK(sk); int error; lock_sock(sk); @@ -657,7 +656,7 @@ sp.sa_family = AF_PPPOX; sp.sa_protocol = PX_PROTO_OE; - memcpy(&sp.sa_addr.pppoe, &sock->sk->protinfo.pppox->pppoe_pa, + memcpy(&sp.sa_addr.pppoe, &PPPOX_SK(sock->sk)->pppoe_pa, sizeof(struct pppoe_addr)); memcpy(uaddr, &sp, len); @@ -672,11 +671,10 @@ unsigned long arg) { struct sock *sk = sock->sk; - struct pppox_opt *po; + struct pppox_opt *po = PPPOX_SK(sk); int val = 0; int err = 0; - po = sk->protinfo.pppox; switch (cmd) { case PPPIOCGMRU: err = -ENXIO; @@ -794,7 +792,7 @@ lock_sock(sk); - dev = sk->protinfo.pppox->pppoe_dev; + dev = PPPOX_SK(sk)->pppoe_dev; error = -EMSGSIZE; if (total_len > (dev->mtu + dev->hard_header_len)) @@ -829,8 +827,7 @@ error = total_len; dev->hard_header(skb, dev, ETH_P_PPP_SES, - sk->protinfo.pppox->pppoe_pa.remote, - NULL, total_len); + PPPOX_SK(sk)->pppoe_pa.remote, NULL, total_len); memcpy(ph, &hdr, sizeof(struct pppoe_hdr)); @@ -851,7 +848,7 @@ ***********************************************************************/ int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) { - struct net_device *dev = sk->protinfo.pppox->pppoe_dev; + struct net_device *dev = PPPOX_SK(sk)->pppoe_dev; struct pppoe_hdr hdr; struct pppoe_hdr *ph; int headroom = skb_headroom(skb); @@ -897,8 +894,7 @@ skb2->dev = dev; dev->hard_header(skb2, dev, ETH_P_PPP_SES, - sk->protinfo.pppox->pppoe_pa.remote, - NULL, data_len); + PPPOX_SK(sk)->pppoe_pa.remote, NULL, data_len); /* We're transmitting skb2, and assuming that dev_queue_xmit * will free it. The generic ppp layer however, is expecting diff -uNr linux-2.5.1/drivers/net/pppox.c linux-2.5.1.acme/drivers/net/pppox.c --- linux-2.5.1/drivers/net/pppox.c Fri Nov 9 20:02:24 2001 +++ linux-2.5.1.acme/drivers/net/pppox.c Wed Dec 19 23:44:47 2001 @@ -68,7 +68,7 @@ /* Clear connection to ppp device, if attached. */ if (sk->state & PPPOX_BOUND) { - ppp_unregister_channel(&sk->protinfo.pppox->chan); + ppp_unregister_channel(&PPPOX_SK(sk)->chan); sk->state &= ~PPPOX_BOUND; } } @@ -81,10 +81,8 @@ unsigned long arg) { struct sock *sk = sock->sk; - struct pppox_opt *po; + struct pppox_opt *po = PPPOX_SK(sk); int err = 0; - - po = sk->protinfo.pppox; lock_sock(sk); diff -uNr linux-2.5.1/include/linux/atalk.h linux-2.5.1.acme/include/linux/atalk.h --- linux-2.5.1/include/linux/atalk.h Thu Nov 22 17:47:11 2001 +++ linux-2.5.1.acme/include/linux/atalk.h Wed Dec 19 23:44:47 2001 @@ -176,5 +176,7 @@ extern void aarp_cleanup_module(void); #endif /* MODULE */ +#define AT_SK(__sk) ((struct atalk_sock *)(__sk)->protinfo) + #endif /* __KERNEL__ */ #endif /* __LINUX_ATALK_H__ */ diff -uNr linux-2.5.1/include/linux/atmdev.h linux-2.5.1.acme/include/linux/atmdev.h --- linux-2.5.1/include/linux/atmdev.h Thu Nov 22 17:49:02 2001 +++ linux-2.5.1.acme/include/linux/atmdev.h Wed Dec 19 23:44:47 2001 @@ -33,7 +33,8 @@ #define ATM_PDU_OVHD 0 /* number of bytes to charge against buffer quota per PDU */ -#define ATM_SD(s) ((s)->sk->protinfo.af_atm) +#define ATM_SK(__sk) ((struct atm_vcc *)(__sk)->protinfo) +#define ATM_SD(s) (ATM_SK((s)->sk)) #define __AAL_STAT_ITEMS \ diff -uNr linux-2.5.1/include/linux/if_ec.h linux-2.5.1.acme/include/linux/if_ec.h --- linux-2.5.1/include/linux/if_ec.h Thu Apr 19 12:38:50 2001 +++ linux-2.5.1.acme/include/linux/if_ec.h Wed Dec 19 23:44:47 2001 @@ -55,6 +55,8 @@ unsigned char net; }; +#define EC_SK(__sk) ((struct econet_opt *)(__sk)->protinfo) + struct ec_device { unsigned char station, net; /* Econet protocol address */ diff -uNr linux-2.5.1/include/linux/if_pppox.h linux-2.5.1.acme/include/linux/if_pppox.h --- linux-2.5.1/include/linux/if_pppox.h Thu Nov 22 17:47:14 2001 +++ linux-2.5.1.acme/include/linux/if_pppox.h Wed Dec 19 23:44:47 2001 @@ -113,6 +113,26 @@ } __attribute__ ((packed)); #ifdef __KERNEL__ +struct pppoe_opt { + struct net_device *dev; /* device associated with socket*/ + struct pppoe_addr pa; /* what this socket is bound to*/ + struct sockaddr_pppox relay; /* what socket data will be + relayed to (PPPoE relaying) */ +}; + +struct pppox_opt { + struct ppp_channel chan; + struct sock *sk; + struct pppox_opt *next; /* for hash table */ + union { + struct pppoe_opt pppoe; + } proto; +}; +#define pppoe_dev proto.pppoe.dev +#define pppoe_pa proto.pppoe.pa +#define pppoe_relay proto.pppoe.relay + +#define PPPOX_SK(__sk) ((struct pppox_opt *)(__sk)->protinfo) struct pppox_proto { int (*create)(struct socket *sock); diff -uNr linux-2.5.1/include/linux/if_wanpipe.h linux-2.5.1.acme/include/linux/if_wanpipe.h --- linux-2.5.1/include/linux/if_wanpipe.h Thu Nov 22 17:47:11 2001 +++ linux-2.5.1.acme/include/linux/if_wanpipe.h Wed Dec 19 23:44:47 2001 @@ -123,6 +123,9 @@ unsigned char force; /* Used to force sock release */ atomic_t packet_sent; }; + +#define WP_SK(__sk) ((struct wanpipe_opt *)(__sk)->protinfo) + #endif #endif diff -uNr linux-2.5.1/include/linux/ip.h linux-2.5.1.acme/include/linux/ip.h --- linux-2.5.1/include/linux/ip.h Thu Nov 22 17:47:11 2001 +++ linux-2.5.1.acme/include/linux/ip.h Wed Dec 19 23:44:47 2001 @@ -111,6 +111,29 @@ }; #define optlength(opt) (sizeof(struct ip_options) + opt->optlen) + +struct inet_opt { + int ttl; /* TTL setting */ + int tos; /* TOS */ + unsigned cmsg_flags; + struct ip_options *opt; + unsigned char hdrincl; /* Include headers ? */ + __u8 mc_ttl; /* Multicasting TTL */ + __u8 mc_loop; /* Loopback */ + unsigned recverr : 1, + freebind : 1; + __u16 id; /* ID counter for DF pkts */ + __u8 pmtudisc; + int mc_index; /* Multicast device index */ + __u32 mc_addr; + struct ip_mc_socklist *mc_list; /* Group array */ +}; + +#include + +#define IP_SK(__sk) ((struct inet_opt *) \ + (((char *)((((struct sock *)(__sk)) + 1))) + \ + sizeof(struct tcp_opt))) #endif struct iphdr { diff -uNr linux-2.5.1/include/linux/ipv6.h linux-2.5.1.acme/include/linux/ipv6.h --- linux-2.5.1/include/linux/ipv6.h Thu Nov 22 17:47:11 2001 +++ linux-2.5.1.acme/include/linux/ipv6.h Wed Dec 19 23:44:47 2001 @@ -101,6 +101,9 @@ }; #ifdef __KERNEL__ +#include /* struct sockaddr_in6 */ +#include +#include /* struct ipv6_mc_socklist */ /* This structure contains results of exthdrs parsing @@ -118,6 +121,58 @@ __u16 dst1; }; +struct ipv6_pinfo { + struct in6_addr saddr; + struct in6_addr rcv_saddr; + struct in6_addr daddr; + struct in6_addr *daddr_cache; + + __u32 flow_label; + __u32 frag_size; + int hop_limit; + int mcast_hops; + int mcast_oif; + + /* pktoption flags */ + union { + struct { + __u8 srcrt:2, + rxinfo:1, + rxhlim:1, + hopopts:1, + dstopts:1, + authhdr:1, + rxflow:1; + } bits; + __u8 all; + } rxopt; + + /* sockopt flags */ + __u8 mc_loop:1, + recverr:1, + sndflow:1, + pmtudisc:2; + + struct ipv6_mc_socklist *ipv6_mc_list; + struct ipv6_fl_socklist *ipv6_fl_list; + __u32 dst_cookie; + + struct ipv6_txoptions *opt; + struct sk_buff *pktoptions; +}; + +struct raw6_opt { + __u32 checksum; /* perform checksum */ + __u32 offset; /* checksum offset */ + + struct icmp6_filter filter; +}; + +/* same place as tcp_opt, in the old days both were in sk->tp_pinfo */ +#define RAW6_PINFO(__sk) ((struct raw6_opt *)(((struct sock *)(__sk)) + 1)) +#define IP6_PINFO(__sk) ((struct ipv6_pinfo *) \ + ((char *)(((struct sock *)(__sk) + 1)) + \ + sizeof(struct tcp_opt) + sizeof(struct inet_opt))) #endif #endif diff -uNr linux-2.5.1/include/linux/kmem_cache_t.h linux-2.5.1.acme/include/linux/kmem_cache_t.h --- linux-2.5.1/include/linux/kmem_cache_t.h Wed Dec 31 21:00:00 1969 +++ linux-2.5.1.acme/include/linux/kmem_cache_t.h Wed Dec 19 23:44:47 2001 @@ -0,0 +1,4 @@ +#ifndef _LINUX_KMEM_CACHE_T_H +#define _LINUX_KMEM_CACHE_T_H +typedef struct kmem_cache_s kmem_cache_t; +#endif diff -uNr linux-2.5.1/include/linux/net.h linux-2.5.1.acme/include/linux/net.h --- linux-2.5.1/include/linux/net.h Thu Nov 22 17:46:19 2001 +++ linux-2.5.1.acme/include/linux/net.h Wed Dec 19 23:44:47 2001 @@ -21,6 +21,7 @@ #include #include #include +#include struct poll_table_struct; @@ -121,6 +122,8 @@ short authentication; short encryption; short encrypt_net; + kmem_cache_t *sk_cachep; + short sk_size; }; struct net_proto @@ -143,6 +146,7 @@ extern int net_ratelimit(void); extern unsigned long net_random(void); extern void net_srandom(unsigned long); +extern int net_proto_sk_size(int family); #ifndef CONFIG_SMP #define SOCKOPS_WRAPPED(name) name diff -uNr linux-2.5.1/include/linux/slab.h linux-2.5.1.acme/include/linux/slab.h --- linux-2.5.1/include/linux/slab.h Wed Dec 19 23:27:57 2001 +++ linux-2.5.1.acme/include/linux/slab.h Wed Dec 19 23:44:47 2001 @@ -9,7 +9,7 @@ #if defined(__KERNEL__) -typedef struct kmem_cache_s kmem_cache_t; +#include #include #include diff -uNr linux-2.5.1/include/linux/tcp.h linux-2.5.1.acme/include/linux/tcp.h --- linux-2.5.1/include/linux/tcp.h Thu Nov 22 17:47:11 2001 +++ linux-2.5.1.acme/include/linux/tcp.h Wed Dec 19 23:44:47 2001 @@ -17,7 +17,7 @@ #ifndef _LINUX_TCP_H #define _LINUX_TCP_H -#include +#include #include struct tcphdr { @@ -184,5 +184,188 @@ __u32 tcpi_advmss; __u32 tcpi_reordering; }; + +/* This defines a selective acknowledgement block. */ +struct tcp_sack_block { + __u32 start_seq; + __u32 end_seq; +}; + +struct tcp_opt { + int tcp_header_len; /* Bytes of tcp header to send */ + +/* + * Header prediction flags + * 0x5?10 << 16 + snd_wnd in net byte order + */ + __u32 pred_flags; + +/* + * RFC793 variables by their proper names. This means you can + * read the code and the spec side by side (and laugh ...) + * See RFC793 and RFC1122. The RFC writes these in capitals. + */ + __u32 rcv_nxt; /* What we want to receive next */ + __u32 snd_nxt; /* Next sequence we send */ + + __u32 snd_una; /* First byte we want an ack for */ + __u32 snd_sml; /* Last byte of the most recently transmitted small packet */ + __u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ + __u32 lsndtime; /* timestamp of last sent data packet (for restart window) */ + + /* Delayed ACK control data */ + struct { + __u8 pending; /* ACK is pending */ + __u8 quick; /* Scheduled number of quick acks */ + __u8 pingpong; /* The session is interactive */ + __u8 blocked; /* Delayed ACK was blocked by socket lock*/ + __u32 ato; /* Predicted tick of soft clock */ + unsigned long timeout; /* Currently scheduled timeout */ + __u32 lrcvtime; /* timestamp of last received data packet*/ + __u16 last_seg_size; /* Size of last incoming segment */ + __u16 rcv_mss; /* MSS used for delayed ACK decisions */ + } ack; + + /* Data for direct copy to user */ + struct { + struct sk_buff_head prequeue; + int memory; + struct task_struct *task; + struct iovec *iov; + int len; + } ucopy; + + __u32 snd_wl1; /* Sequence for window update */ + __u32 snd_wnd; /* The window we expect to receive */ + __u32 max_window; /* Maximal window ever seen from peer */ + __u32 pmtu_cookie; /* Last pmtu seen by socket */ + __u16 mss_cache; /* Cached effective mss, not including SACKS */ + __u16 mss_clamp; /* Maximal mss, negotiated at connection setup */ + __u16 ext_header_len; /* Network protocol overhead (IP/IPv6 options) */ + __u8 ca_state; /* State of fast-retransmit machine */ + __u8 retransmits; /* Number of unrecovered RTO timeouts. */ + + __u8 reordering; /* Packet reordering metric. */ + __u8 queue_shrunk; /* Write queue has been shrunk recently.*/ + __u8 defer_accept; /* User waits for some data after accept() */ + +/* RTT measurement */ + __u8 backoff; /* backoff */ + __u32 srtt; /* smothed round trip time << 3 */ + __u32 mdev; /* medium deviation */ + __u32 mdev_max; /* maximal mdev for the last rtt period */ + __u32 rttvar; /* smoothed mdev_max */ + __u32 rtt_seq; /* sequence number to update rttvar */ + __u32 rto; /* retransmit timeout */ + + __u32 packets_out; /* Packets which are "in flight" */ + __u32 left_out; /* Packets which leaved network */ + __u32 retrans_out; /* Retransmitted packets out */ + + +/* + * Slow start and congestion control (see also Nagle, and Karn & Partridge) + */ + __u32 snd_ssthresh; /* Slow start size threshold */ + __u32 snd_cwnd; /* Sending congestion window */ + __u16 snd_cwnd_cnt; /* Linear increase counter */ + __u16 snd_cwnd_clamp; /* Do not allow snd_cwnd to grow above this */ + __u32 snd_cwnd_used; + __u32 snd_cwnd_stamp; + + /* Two commonly used timers in both sender and receiver paths. */ + unsigned long timeout; + struct timer_list retransmit_timer; /* Resend (no ack) */ + struct timer_list delack_timer; /* Ack delay */ + + struct sk_buff_head out_of_order_queue; /* Out of order segments go here */ + + struct tcp_func *af_specific; /* Operations which are AF_INET{4,6} specific */ + struct sk_buff *send_head; /* Front of stuff to transmit */ + struct page *sndmsg_page; /* Cached page for sendmsg */ + u32 sndmsg_off; /* Cached offset for sendmsg */ + + __u32 rcv_wnd; /* Current receiver window */ + __u32 rcv_wup; /* rcv_nxt on last window update sent */ + __u32 write_seq; /* Tail(+1) of data held in tcp send buffer */ + __u32 pushed_seq; /* Last pushed seq, required to talk to windows */ + __u32 copied_seq; /* Head of yet unread data */ +/* + * Options received (usually on last packet, some only on SYN packets). + */ + char tstamp_ok, /* TIMESTAMP seen on SYN packet */ + wscale_ok, /* Wscale seen on SYN packet */ + sack_ok; /* SACK seen on SYN packet */ + char saw_tstamp; /* Saw TIMESTAMP on last packet */ + __u8 snd_wscale; /* Window scaling received from sender */ + __u8 rcv_wscale; /* Window scaling to send to receiver */ + __u8 nonagle; /* Disable Nagle algorithm? */ + __u8 keepalive_probes; /* num of allowed keep alive probes */ + +/* PAWS/RTTM data */ + __u32 rcv_tsval; /* Time stamp value */ + __u32 rcv_tsecr; /* Time stamp echo reply */ + __u32 ts_recent; /* Time stamp to echo next */ + long ts_recent_stamp;/* Time we stored ts_recent (for aging) */ + +/* SACKs data */ + __u16 user_mss; /* mss requested by user in ioctl */ + __u8 dsack; /* D-SACK is scheduled */ + __u8 eff_sacks; /* Size of SACK array to send with next packet */ + struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */ + struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/ + + __u32 window_clamp; /* Maximal window to advertise */ + __u32 rcv_ssthresh; /* Current window clamp */ + __u8 probes_out; /* unanswered 0 window probes */ + __u8 num_sacks; /* Number of SACK blocks */ + __u16 advmss; /* Advertised MSS */ + + __u8 syn_retries; /* num of allowed syn retries */ + __u8 ecn_flags; /* ECN status bits. */ + __u16 prior_ssthresh; /* ssthresh saved at recovery start */ + __u32 lost_out; /* Lost packets */ + __u32 sacked_out; /* SACK'd packets */ + __u32 fackets_out; /* FACK'd packets */ + __u32 high_seq; /* snd_nxt at onset of congestion */ + + __u32 retrans_stamp; /* Timestamp of the last retransmit, + * also used in SYN-SENT to remember stamp of + * the first SYN. */ + __u32 undo_marker; /* tracking retrans started here. */ + int undo_retrans; /* number of undoable retransmissions. */ + __u32 urg_seq; /* Seq of received urgent pointer */ + __u16 urg_data; /* Saved octet of OOB data and control flags */ + __u8 pending; /* Scheduled timer event */ + __u8 urg_mode; /* In urgent mode */ + __u32 snd_up; /* Urgent pointer */ + + /* The syn_wait_lock is necessary only to avoid tcp_get_info having + * to grab the main lock sock while browsing the listening hash + * (otherwise it's deadlock prone). + * This lock is acquired in read mode only from tcp_get_info() and + * it's acquired in write mode _only_ from code that is actively + * changing the syn_wait_queue. All readers that are holding + * the master sock lock don't need to grab this lock in read mode + * too as the syn_wait_queue writes are always protected from + * the main sock lock. + */ + rwlock_t syn_wait_lock; + struct tcp_listen_opt *listen_opt; + + /* FIFO of established children */ + struct open_request *accept_queue; + struct open_request *accept_queue_tail; + + int write_pending; /* A write to socket waits to start. */ + + unsigned int keepalive_time; /* time before keep alive takes place */ + unsigned int keepalive_intvl; /* time interval between keep alive probes */ + int linger2; + + unsigned long last_synq_overflow; +}; + +#define TCP_PINFO(__sk) ((struct tcp_opt *)(((struct sock *)(__sk)) + 1)) #endif /* _LINUX_TCP_H */ diff -uNr linux-2.5.1/include/net/af_unix.h linux-2.5.1.acme/include/net/af_unix.h --- linux-2.5.1/include/net/af_unix.h Mon Apr 24 17:43:04 2000 +++ linux-2.5.1.acme/include/net/af_unix.h Wed Dec 19 23:44:47 2001 @@ -34,9 +34,26 @@ #define UNIXCB(skb) (*(struct unix_skb_parms*)&((skb)->cb)) #define UNIXCREDS(skb) (&UNIXCB((skb)).creds) -#define unix_state_rlock(s) read_lock(&(s)->protinfo.af_unix.lock) -#define unix_state_runlock(s) read_unlock(&(s)->protinfo.af_unix.lock) -#define unix_state_wlock(s) write_lock(&(s)->protinfo.af_unix.lock) -#define unix_state_wunlock(s) write_unlock(&(s)->protinfo.af_unix.lock) +#define unix_state_rlock(s) read_lock(&UNIX_SK(s)->lock) +#define unix_state_runlock(s) read_unlock(&UNIX_SK(s)->lock) +#define unix_state_wlock(s) write_lock(&UNIX_SK(s)->lock) +#define unix_state_wunlock(s) write_unlock(&UNIX_SK(s)->lock) +#ifdef __KERNEL__ +/* The AF_UNIX specific socket options */ +struct unix_opt { + struct unix_address *addr; + struct dentry *dentry; + struct vfsmount *mnt; + struct semaphore readsem; + struct sock *other; + struct sock **list; + struct sock *gc_tree; + atomic_t inflight; + rwlock_t lock; + wait_queue_head_t peer_wait; +}; + +#define UNIX_SK(__sk) ((struct unix_opt *)(((struct sock *)(__sk)) + 1)) +#endif #endif diff -uNr linux-2.5.1/include/net/ax25.h linux-2.5.1.acme/include/net/ax25.h --- linux-2.5.1/include/net/ax25.h Thu Nov 22 17:47:11 2001 +++ linux-2.5.1.acme/include/net/ax25.h Wed Dec 19 23:44:47 2001 @@ -194,6 +194,8 @@ struct sock *sk; /* Backlink to socket */ } ax25_cb; +#define AX25_SK(__sk) ((ax25_cb *)(__sk)->protinfo) + /* af_ax25.c */ extern ax25_cb *volatile ax25_list; extern void ax25_free_cb(ax25_cb *); diff -uNr linux-2.5.1/include/net/checksum.h linux-2.5.1.acme/include/net/checksum.h --- linux-2.5.1/include/net/checksum.h Thu Nov 22 17:47:22 2001 +++ linux-2.5.1.acme/include/net/checksum.h Wed Dec 19 23:44:47 2001 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff -uNr linux-2.5.1/include/net/dn.h linux-2.5.1.acme/include/net/dn.h --- linux-2.5.1/include/net/dn.h Thu Nov 22 17:47:11 2001 +++ linux-2.5.1.acme/include/net/dn.h Wed Dec 19 23:44:47 2001 @@ -9,8 +9,6 @@ #define dn_ntohs(x) le16_to_cpu((unsigned short)(x)) #define dn_htons(x) cpu_to_le16((unsigned short)(x)) -#define DN_SK(sk) (&sk->protinfo.dn) - struct dn_scp /* Session Control Port */ { unsigned char state; @@ -134,6 +132,8 @@ void (*delack_fxn)(struct sock *sk); }; + +#define DN_SK(__sk) ((struct dn_scp *)(__sk)->protinfo) /* * src,dst : Source and Destination DECnet addresses diff -uNr linux-2.5.1/include/net/dn_nsp.h linux-2.5.1.acme/include/net/dn_nsp.h --- linux-2.5.1/include/net/dn_nsp.h Mon Jan 22 19:32:10 2001 +++ linux-2.5.1.acme/include/net/dn_nsp.h Wed Dec 19 23:44:47 2001 @@ -150,7 +150,7 @@ * numbers used in NSP. Similar in operation to the functions * of the same name in TCP. */ -static __inline__ int before(unsigned short seq1, unsigned short seq2) +static __inline__ int dn_before(unsigned short seq1, unsigned short seq2) { seq1 &= 0x0fff; seq2 &= 0x0fff; @@ -159,7 +159,7 @@ } -static __inline__ int after(unsigned short seq1, unsigned short seq2) +static __inline__ int dn_after(unsigned short seq1, unsigned short seq2) { seq1 &= 0x0fff; seq2 &= 0x0fff; @@ -167,14 +167,14 @@ return (int)((seq2 - seq1) & 0x0fff) > 2048; } -static __inline__ int equal(unsigned short seq1, unsigned short seq2) +static __inline__ int dn_equal(unsigned short seq1, unsigned short seq2) { return ((seq1 ^ seq2) & 0x0fff) == 0; } -static __inline__ int before_or_equal(unsigned short seq1, unsigned short seq2) +static __inline__ int dn_before_or_equal(unsigned short seq1, unsigned short seq2) { - return (before(seq1, seq2) || equal(seq1, seq2)); + return (dn_before(seq1, seq2) || dn_equal(seq1, seq2)); } static __inline__ void seq_add(unsigned short *seq, unsigned short off) @@ -185,7 +185,7 @@ static __inline__ int seq_next(unsigned short seq1, unsigned short seq2) { - return equal(seq1 + 1, seq2); + return dn_equal(seq1 + 1, seq2); } /* diff -uNr linux-2.5.1/include/net/dn_route.h linux-2.5.1.acme/include/net/dn_route.h --- linux-2.5.1/include/net/dn_route.h Mon Dec 11 19:33:56 2000 +++ linux-2.5.1.acme/include/net/dn_route.h Wed Dec 19 23:44:47 2001 @@ -113,7 +113,7 @@ static inline void dn_nsp_send(struct sk_buff *skb) { struct sock *sk = skb->sk; - struct dn_scp *scp = &sk->protinfo.dn; + struct dn_scp *scp = DN_SK(sk); struct dst_entry *dst; skb->h.raw = skb->data; diff -uNr linux-2.5.1/include/net/icmp.h linux-2.5.1.acme/include/net/icmp.h --- linux-2.5.1/include/net/icmp.h Thu Nov 22 17:47:15 2001 +++ linux-2.5.1.acme/include/net/icmp.h Wed Dec 19 23:44:47 2001 @@ -43,4 +43,10 @@ /* Move into dst.h ? */ extern int xrlim_allow(struct dst_entry *dst, int timeout); +struct raw_opt { + struct icmp_filter filter; +}; + +#define RAW4_PINFO(__sk) ((struct raw_opt *)(((struct sock *)(__sk)) + 1)) + #endif /* _ICMP_H */ diff -uNr linux-2.5.1/include/net/inet_ecn.h linux-2.5.1.acme/include/net/inet_ecn.h --- linux-2.5.1/include/net/inet_ecn.h Tue Oct 30 21:08:12 2001 +++ linux-2.5.1.acme/include/net/inet_ecn.h Wed Dec 19 23:44:47 2001 @@ -24,15 +24,15 @@ return outer; } -#define INET_ECN_xmit(sk) do { (sk)->protinfo.af_inet.tos |= 2; } while (0) -#define INET_ECN_dontxmit(sk) do { (sk)->protinfo.af_inet.tos &= ~3; } while (0) +#define INET_ECN_xmit(sk) do { IP_SK(sk)->tos |= 2; } while (0) +#define INET_ECN_dontxmit(sk) do { IP_SK(sk)->tos &= ~3; } while (0) #define IP6_ECN_flow_init(label) do { \ (label) &= ~htonl(3<<20); \ } while (0) #define IP6_ECN_flow_xmit(sk, label) do { \ - if (INET_ECN_is_capable((sk)->protinfo.af_inet.tos)) \ + if (INET_ECN_is_capable(IP_SK(sk)->tos)) \ (label) |= __constant_htons(2 << 4); \ } while (0) diff -uNr linux-2.5.1/include/net/ip.h linux-2.5.1.acme/include/net/ip.h --- linux-2.5.1/include/net/ip.h Thu Nov 22 17:47:15 2001 +++ linux-2.5.1.acme/include/net/ip.h Wed Dec 19 23:44:47 2001 @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -181,8 +182,8 @@ static inline int ip_dont_fragment(struct sock *sk, struct dst_entry *dst) { - return (sk->protinfo.af_inet.pmtudisc == IP_PMTUDISC_DO || - (sk->protinfo.af_inet.pmtudisc == IP_PMTUDISC_WANT && + return (IP_SK(sk)->pmtudisc == IP_PMTUDISC_DO || + (IP_SK(sk)->pmtudisc == IP_PMTUDISC_WANT && !(dst->mxlock&(1<id = ((sk && sk->daddr) ? htons(sk->protinfo.af_inet.id++) : 0); + iph->id = ((sk && sk->daddr) ? htons(IP_SK(sk)->id++) : 0); } else __ip_select_ident(iph, dst); } diff -uNr linux-2.5.1/include/net/ip6_route.h linux-2.5.1.acme/include/net/ip6_route.h --- linux-2.5.1/include/net/ip6_route.h Mon Dec 11 19:30:48 2000 +++ linux-2.5.1.acme/include/net/ip6_route.h Wed Dec 19 23:44:47 2001 @@ -11,6 +11,8 @@ #include #include +#include +#include struct pol_chain { int type; @@ -97,7 +99,7 @@ static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst, struct in6_addr *daddr) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct rt6_info *rt = (struct rt6_info *) dst; write_lock(&sk->dst_lock); diff -uNr linux-2.5.1/include/net/ipx.h linux-2.5.1.acme/include/net/ipx.h --- linux-2.5.1/include/net/ipx.h Thu Nov 22 17:47:14 2001 +++ linux-2.5.1.acme/include/net/ipx.h Wed Dec 19 23:44:47 2001 @@ -86,6 +86,22 @@ int index; } last_hop; }; + +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 special ncp connection-handling sockets for mars_nwe, + * the connection number must be stored in the socket. */ + unsigned short ipx_ncp_conn; +}; + +#define IPX_SK(__sk) ((struct ipx_opt *)(__sk)->protinfo) +#define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0])) #endif #define IPX_MIN_EPHEMERAL_SOCKET 0x4000 #define IPX_MAX_EPHEMERAL_SOCKET 0x7fff diff -uNr linux-2.5.1/include/net/irda/irda.h linux-2.5.1.acme/include/net/irda/irda.h --- linux-2.5.1/include/net/irda/irda.h Thu Nov 22 17:47:14 2001 +++ linux-2.5.1.acme/include/net/irda/irda.h Wed Dec 19 23:44:47 2001 @@ -168,6 +168,8 @@ LOCAL_FLOW rx_flow; }; +#define IRDA_SK(__sk) ((struct irda_sock *)(__sk)->protinfo) + /* * This type is used by the protocols that transmit 16 bits words in * little endian format. A little endian machine stores MSB of word in diff -uNr linux-2.5.1/include/net/netrom.h linux-2.5.1.acme/include/net/netrom.h --- linux-2.5.1/include/net/netrom.h Mon Oct 16 17:42:53 2000 +++ linux-2.5.1.acme/include/net/netrom.h Wed Dec 19 23:44:47 2001 @@ -74,6 +74,8 @@ struct sock *sk; /* Backlink to socket */ } nr_cb; +#define NR_SK(__sk) ((nr_cb *)(__sk)->protinfo) + struct nr_neigh { struct nr_neigh *next; ax25_address callsign; diff -uNr linux-2.5.1/include/net/rose.h linux-2.5.1.acme/include/net/rose.h --- linux-2.5.1/include/net/rose.h Mon Oct 16 17:42:53 2000 +++ linux-2.5.1.acme/include/net/rose.h Wed Dec 19 23:44:47 2001 @@ -138,6 +138,8 @@ struct sock *sk; /* Backlink to socket */ } rose_cb; +#define ROSE_SK(__sk) ((rose_cb *)(__sk)->protinfo) + /* af_rose.c */ extern ax25_address rose_callsign; extern int sysctl_rose_restart_request_timeout; diff -uNr linux-2.5.1/include/net/route.h linux-2.5.1.acme/include/net/route.h --- linux-2.5.1/include/net/route.h Thu Nov 22 17:47:15 2001 +++ linux-2.5.1.acme/include/net/route.h Wed Dec 19 23:44:47 2001 @@ -42,7 +42,7 @@ /* RTO_CONN is not used (being alias for 0), but preserved not to break * some modules referring to it. */ -#define RT_CONN_FLAGS(sk) (RT_TOS(sk->protinfo.af_inet.tos) | sk->localroute) +#define RT_CONN_FLAGS(sk) (RT_TOS(IP_SK(sk)->tos) | sk->localroute) struct rt_key { diff -uNr linux-2.5.1/include/net/sock.h linux-2.5.1.acme/include/net/sock.h --- linux-2.5.1/include/net/sock.h Thu Nov 22 17:47:15 2001 +++ linux-2.5.1.acme/include/net/sock.h Wed Dec 19 23:44:47 2001 @@ -24,6 +24,11 @@ * Alan Cox : Eliminate low level recv/recvfrom * David S. Miller : New socket lookup architecture. * Steve Whitehouse: Default routines for sock_ops + * Arnaldo C. Melo : removed net_pinfo, tp_pinfo and made + * protinfo be just a void pointer, as the + * protocol specific parts were moved to + * respective headers and ipv4/v6, etc now + * use private slabcaches for its socks * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -36,68 +41,9 @@ #include #include #include -#include /* struct sockaddr_in */ - -#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -#include /* struct sockaddr_in6 */ -#include /* dest_cache, inet6_options */ -#include -#include /* struct ipv6_mc_socklist */ -#endif - -#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE) -#include -#endif -#include /* struct tcphdr */ #include #include /* struct sk_buff */ -#include /* struct inet_protocol */ -#if defined(CONFIG_X25) || defined(CONFIG_X25_MODULE) -#include -#endif -#if defined(CONFIG_WAN_ROUTER) || defined(CONFIG_WAN_ROUTER_MODULE) -#include -#endif - -#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) -#include -#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE) -#include -#endif -#if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE) -#include -#endif -#endif - -#if defined(CONFIG_PPPOE) || defined(CONFIG_PPPOE_MODULE) -#include -#include /* struct ppp_channel */ -#endif - -#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE) -#if defined(CONFIG_SPX) || defined(CONFIG_SPX_MODULE) -#include -#else -#include -#endif /* CONFIG_SPX */ -#endif /* CONFIG_IPX */ - -#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE) -#include -#endif - -#if defined(CONFIG_DECNET) || defined(CONFIG_DECNET_MODULE) -#include -#endif - -#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE) -#include -#endif - -#if defined(CONFIG_ATM) || defined(CONFIG_ATM_MODULE) -struct atm_vcc; -#endif #ifdef CONFIG_FILTER #include @@ -106,362 +52,12 @@ #include #include - -/* The AF_UNIX specific socket options */ -struct unix_opt { - struct unix_address *addr; - struct dentry * dentry; - struct vfsmount * mnt; - struct semaphore readsem; - struct sock * other; - struct sock ** list; - struct sock * gc_tree; - atomic_t inflight; - rwlock_t lock; - wait_queue_head_t peer_wait; -}; - - -/* Once the IPX ncpd patches are in these are going into protinfo. */ -#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE) -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 special ncp connection-handling sockets for mars_nwe, - * the connection number must be stored in the socket. - */ - unsigned short ipx_ncp_conn; -}; -#endif - -#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -struct ipv6_pinfo { - struct in6_addr saddr; - struct in6_addr rcv_saddr; - struct in6_addr daddr; - struct in6_addr *daddr_cache; - - __u32 flow_label; - __u32 frag_size; - int hop_limit; - int mcast_hops; - int mcast_oif; - - /* pktoption flags */ - union { - struct { - __u8 srcrt:2, - rxinfo:1, - rxhlim:1, - hopopts:1, - dstopts:1, - authhdr:1, - rxflow:1; - } bits; - __u8 all; - } rxopt; - - /* sockopt flags */ - __u8 mc_loop:1, - recverr:1, - sndflow:1, - pmtudisc:2; - - struct ipv6_mc_socklist *ipv6_mc_list; - struct ipv6_fl_socklist *ipv6_fl_list; - __u32 dst_cookie; - - struct ipv6_txoptions *opt; - struct sk_buff *pktoptions; -}; - -struct raw6_opt { - __u32 checksum; /* perform checksum */ - __u32 offset; /* checksum offset */ - - struct icmp6_filter filter; -}; - -#endif /* IPV6 */ - -#if defined(CONFIG_INET) || defined(CONFIG_INET_MODULE) -struct raw_opt { - struct icmp_filter filter; -}; -#endif - -#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE) -struct inet_opt -{ - int ttl; /* TTL setting */ - int tos; /* TOS */ - unsigned cmsg_flags; - struct ip_options *opt; - unsigned char hdrincl; /* Include headers ? */ - __u8 mc_ttl; /* Multicasting TTL */ - __u8 mc_loop; /* Loopback */ - unsigned recverr : 1, - freebind : 1; - __u16 id; /* ID counter for DF pkts */ - __u8 pmtudisc; - int mc_index; /* Multicast device index */ - __u32 mc_addr; - struct ip_mc_socklist *mc_list; /* Group array */ -}; -#endif - -#if defined(CONFIG_PPPOE) || defined (CONFIG_PPPOE_MODULE) -struct pppoe_opt -{ - struct net_device *dev; /* device associated with socket*/ - struct pppoe_addr pa; /* what this socket is bound to*/ - struct sockaddr_pppox relay; /* what socket data will be - relayed to (PPPoE relaying) */ -}; - -struct pppox_opt -{ - struct ppp_channel chan; - struct sock *sk; - struct pppox_opt *next; /* for hash table */ - union { - struct pppoe_opt pppoe; - } proto; -}; -#define pppoe_dev proto.pppoe.dev -#define pppoe_pa proto.pppoe.pa -#define pppoe_relay proto.pppoe.relay -#endif - -/* This defines a selective acknowledgement block. */ -struct tcp_sack_block { - __u32 start_seq; - __u32 end_seq; -}; - -struct tcp_opt { - int tcp_header_len; /* Bytes of tcp header to send */ - -/* - * Header prediction flags - * 0x5?10 << 16 + snd_wnd in net byte order - */ - __u32 pred_flags; - -/* - * RFC793 variables by their proper names. This means you can - * read the code and the spec side by side (and laugh ...) - * See RFC793 and RFC1122. The RFC writes these in capitals. - */ - __u32 rcv_nxt; /* What we want to receive next */ - __u32 snd_nxt; /* Next sequence we send */ - - __u32 snd_una; /* First byte we want an ack for */ - __u32 snd_sml; /* Last byte of the most recently transmitted small packet */ - __u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ - __u32 lsndtime; /* timestamp of last sent data packet (for restart window) */ - - /* Delayed ACK control data */ - struct { - __u8 pending; /* ACK is pending */ - __u8 quick; /* Scheduled number of quick acks */ - __u8 pingpong; /* The session is interactive */ - __u8 blocked; /* Delayed ACK was blocked by socket lock*/ - __u32 ato; /* Predicted tick of soft clock */ - unsigned long timeout; /* Currently scheduled timeout */ - __u32 lrcvtime; /* timestamp of last received data packet*/ - __u16 last_seg_size; /* Size of last incoming segment */ - __u16 rcv_mss; /* MSS used for delayed ACK decisions */ - } ack; - - /* Data for direct copy to user */ - struct { - struct sk_buff_head prequeue; - int memory; - struct task_struct *task; - struct iovec *iov; - int len; - } ucopy; - - __u32 snd_wl1; /* Sequence for window update */ - __u32 snd_wnd; /* The window we expect to receive */ - __u32 max_window; /* Maximal window ever seen from peer */ - __u32 pmtu_cookie; /* Last pmtu seen by socket */ - __u16 mss_cache; /* Cached effective mss, not including SACKS */ - __u16 mss_clamp; /* Maximal mss, negotiated at connection setup */ - __u16 ext_header_len; /* Network protocol overhead (IP/IPv6 options) */ - __u8 ca_state; /* State of fast-retransmit machine */ - __u8 retransmits; /* Number of unrecovered RTO timeouts. */ - - __u8 reordering; /* Packet reordering metric. */ - __u8 queue_shrunk; /* Write queue has been shrunk recently.*/ - __u8 defer_accept; /* User waits for some data after accept() */ - -/* RTT measurement */ - __u8 backoff; /* backoff */ - __u32 srtt; /* smothed round trip time << 3 */ - __u32 mdev; /* medium deviation */ - __u32 mdev_max; /* maximal mdev for the last rtt period */ - __u32 rttvar; /* smoothed mdev_max */ - __u32 rtt_seq; /* sequence number to update rttvar */ - __u32 rto; /* retransmit timeout */ - - __u32 packets_out; /* Packets which are "in flight" */ - __u32 left_out; /* Packets which leaved network */ - __u32 retrans_out; /* Retransmitted packets out */ - - -/* - * Slow start and congestion control (see also Nagle, and Karn & Partridge) - */ - __u32 snd_ssthresh; /* Slow start size threshold */ - __u32 snd_cwnd; /* Sending congestion window */ - __u16 snd_cwnd_cnt; /* Linear increase counter */ - __u16 snd_cwnd_clamp; /* Do not allow snd_cwnd to grow above this */ - __u32 snd_cwnd_used; - __u32 snd_cwnd_stamp; - - /* Two commonly used timers in both sender and receiver paths. */ - unsigned long timeout; - struct timer_list retransmit_timer; /* Resend (no ack) */ - struct timer_list delack_timer; /* Ack delay */ - - struct sk_buff_head out_of_order_queue; /* Out of order segments go here */ - - struct tcp_func *af_specific; /* Operations which are AF_INET{4,6} specific */ - struct sk_buff *send_head; /* Front of stuff to transmit */ - struct page *sndmsg_page; /* Cached page for sendmsg */ - u32 sndmsg_off; /* Cached offset for sendmsg */ - - __u32 rcv_wnd; /* Current receiver window */ - __u32 rcv_wup; /* rcv_nxt on last window update sent */ - __u32 write_seq; /* Tail(+1) of data held in tcp send buffer */ - __u32 pushed_seq; /* Last pushed seq, required to talk to windows */ - __u32 copied_seq; /* Head of yet unread data */ -/* - * Options received (usually on last packet, some only on SYN packets). - */ - char tstamp_ok, /* TIMESTAMP seen on SYN packet */ - wscale_ok, /* Wscale seen on SYN packet */ - sack_ok; /* SACK seen on SYN packet */ - char saw_tstamp; /* Saw TIMESTAMP on last packet */ - __u8 snd_wscale; /* Window scaling received from sender */ - __u8 rcv_wscale; /* Window scaling to send to receiver */ - __u8 nonagle; /* Disable Nagle algorithm? */ - __u8 keepalive_probes; /* num of allowed keep alive probes */ - -/* PAWS/RTTM data */ - __u32 rcv_tsval; /* Time stamp value */ - __u32 rcv_tsecr; /* Time stamp echo reply */ - __u32 ts_recent; /* Time stamp to echo next */ - long ts_recent_stamp;/* Time we stored ts_recent (for aging) */ - -/* SACKs data */ - __u16 user_mss; /* mss requested by user in ioctl */ - __u8 dsack; /* D-SACK is scheduled */ - __u8 eff_sacks; /* Size of SACK array to send with next packet */ - struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */ - struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/ - - __u32 window_clamp; /* Maximal window to advertise */ - __u32 rcv_ssthresh; /* Current window clamp */ - __u8 probes_out; /* unanswered 0 window probes */ - __u8 num_sacks; /* Number of SACK blocks */ - __u16 advmss; /* Advertised MSS */ - - __u8 syn_retries; /* num of allowed syn retries */ - __u8 ecn_flags; /* ECN status bits. */ - __u16 prior_ssthresh; /* ssthresh saved at recovery start */ - __u32 lost_out; /* Lost packets */ - __u32 sacked_out; /* SACK'd packets */ - __u32 fackets_out; /* FACK'd packets */ - __u32 high_seq; /* snd_nxt at onset of congestion */ - - __u32 retrans_stamp; /* Timestamp of the last retransmit, - * also used in SYN-SENT to remember stamp of - * the first SYN. */ - __u32 undo_marker; /* tracking retrans started here. */ - int undo_retrans; /* number of undoable retransmissions. */ - __u32 urg_seq; /* Seq of received urgent pointer */ - __u16 urg_data; /* Saved octet of OOB data and control flags */ - __u8 pending; /* Scheduled timer event */ - __u8 urg_mode; /* In urgent mode */ - __u32 snd_up; /* Urgent pointer */ - - /* The syn_wait_lock is necessary only to avoid tcp_get_info having - * to grab the main lock sock while browsing the listening hash - * (otherwise it's deadlock prone). - * This lock is acquired in read mode only from tcp_get_info() and - * it's acquired in write mode _only_ from code that is actively - * changing the syn_wait_queue. All readers that are holding - * the master sock lock don't need to grab this lock in read mode - * too as the syn_wait_queue writes are always protected from - * the main sock lock. - */ - rwlock_t syn_wait_lock; - struct tcp_listen_opt *listen_opt; - - /* FIFO of established children */ - struct open_request *accept_queue; - struct open_request *accept_queue_tail; - - int write_pending; /* A write to socket waits to start. */ - - unsigned int keepalive_time; /* time before keep alive takes place */ - unsigned int keepalive_intvl; /* time interval between keep alive probes */ - int linger2; - - unsigned long last_synq_overflow; -}; - - /* * This structure really needs to be cleaned up. * Most of it is for TCP, and not used by any of * the other protocols. */ -/* - * The idea is to start moving to a newer struct gradualy - * - * IMHO the newer struct should have the following format: - * - * struct sock { - * sockmem [mem, proto, callbacks] - * - * union or struct { - * ax25; - * } ll_pinfo; - * - * union { - * ipv4; - * ipv6; - * ipx; - * netrom; - * rose; - * x25; - * } net_pinfo; - * - * union { - * tcp; - * udp; - * spx; - * netrom; - * } tp_pinfo; - * - * } - * - * The idea failed because IPv6 transition asssumes dual IP/IPv6 sockets. - * So, net_pinfo is IPv6 are really, and protinfo unifies all another - * private areas. - */ - /* Define this to get the sk->debug debugging facility. */ #define SOCK_DEBUGGING #ifdef SOCK_DEBUGGING @@ -567,26 +163,6 @@ struct proto *prot; -#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) - union { - struct ipv6_pinfo af_inet6; - } net_pinfo; -#endif - - union { - struct tcp_opt af_tcp; -#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE) - struct raw_opt tp_raw4; -#endif -#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) - struct raw6_opt tp_raw; -#endif /* CONFIG_IPV6 */ -#if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE) - struct spx_opt af_spx; -#endif /* CONFIG_SPX */ - - } tp_pinfo; - int err, err_soft; /* Soft holds errors that don't cause failure but are the cause of a persistent failure not just @@ -610,55 +186,7 @@ /* This is where all the private (optional) areas that don't * overlap will eventually live. */ - union { - void *destruct_hook; - struct unix_opt af_unix; -#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE) - struct inet_opt af_inet; -#endif -#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE) - struct atalk_sock af_at; -#endif -#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE) - struct ipx_opt af_ipx; -#endif -#if defined (CONFIG_DECNET) || defined(CONFIG_DECNET_MODULE) - struct dn_scp dn; -#endif -#if defined (CONFIG_PACKET) || defined(CONFIG_PACKET_MODULE) - struct packet_opt *af_packet; -#endif -#if defined(CONFIG_X25) || defined(CONFIG_X25_MODULE) - x25_cb *x25; -#endif -#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) - ax25_cb *ax25; -#endif -#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE) - nr_cb *nr; -#endif -#if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE) - rose_cb *rose; -#endif -#if defined(CONFIG_PPPOE) || defined(CONFIG_PPPOE_MODULE) - struct pppox_opt *pppox; -#endif -#ifdef CONFIG_NETLINK - struct netlink_opt *af_netlink; -#endif -#if defined(CONFIG_ECONET) || defined(CONFIG_ECONET_MODULE) - struct econet_opt *af_econet; -#endif -#if defined(CONFIG_ATM) || defined(CONFIG_ATM_MODULE) - struct atm_vcc *af_atm; -#endif -#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE) - struct irda_sock *irda; -#endif -#if defined(CONFIG_WAN_ROUTER) || defined(CONFIG_WAN_ROUTER_MODULE) - struct wanpipe_opt *af_wanpipe; -#endif - } protinfo; + void *protinfo; /* This part is used for the timeout functions. */ diff -uNr linux-2.5.1/include/net/spx.h linux-2.5.1.acme/include/net/spx.h --- linux-2.5.1/include/net/spx.h Thu Nov 22 17:47:15 2001 +++ linux-2.5.1.acme/include/net/spx.h Wed Dec 19 23:44:47 2001 @@ -48,6 +48,8 @@ struct sk_buff_head retransmit_queue; }; +#define SPX_PINFO(__sk) ((struct spx_opt *)(((struct sock *)(__sk)) + 1)) + /* Packet connectino control defines */ #define CCTL_SPXII_XHD 0x01 /* SPX2 extended header */ #define CCTL_SPX_UNKNOWN 0x02 /* Unknown (unused ??) */ diff -uNr linux-2.5.1/include/net/tcp.h linux-2.5.1.acme/include/net/tcp.h --- linux-2.5.1/include/net/tcp.h Thu Nov 22 17:47:22 2001 +++ linux-2.5.1.acme/include/net/tcp.h Wed Dec 19 23:44:47 2001 @@ -29,6 +29,9 @@ #include #include #include +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +#include +#endif /* This is for all connections with a full identity, no wildcards. * New scheme, half the table is for TIME_WAIT, the other half is @@ -245,8 +248,8 @@ #define TCP_IPV6_MATCH(__sk, __saddr, __daddr, __ports, __dif) \ (((*((__u32 *)&((__sk)->dport)))== (__ports)) && \ ((__sk)->family == AF_INET6) && \ - !ipv6_addr_cmp(&(__sk)->net_pinfo.af_inet6.daddr, (__saddr)) && \ - !ipv6_addr_cmp(&(__sk)->net_pinfo.af_inet6.rcv_saddr, (__daddr)) && \ + !ipv6_addr_cmp(&IP6_PINFO(__sk)->daddr, (__saddr)) && \ + !ipv6_addr_cmp(&IP6_PINFO(__sk)->rcv_saddr, (__daddr)) && \ (!((__sk)->bound_dev_if) || ((__sk)->bound_dev_if == (__dif)))) /* These can have wildcards, don't try too hard. */ @@ -824,7 +827,7 @@ static inline void tcp_clear_xmit_timer(struct sock *sk, int what) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); switch (what) { case TCP_TIME_RETRANS: @@ -859,7 +862,7 @@ */ static inline void tcp_reset_xmit_timer(struct sock *sk, int what, unsigned long when) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); if (when > TCP_RTO_MAX) { #ifdef TCP_DEBUG @@ -895,7 +898,7 @@ static __inline__ unsigned int tcp_current_mss(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); struct dst_entry *dst = __sk_dst_get(sk); int mss_now = tp->mss_cache; @@ -918,7 +921,7 @@ static inline void tcp_initialize_rcv_mss(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); unsigned int hint = min(tp->advmss, tp->mss_cache); hint = min(hint, tp->rcv_wnd/2); @@ -1321,7 +1324,7 @@ */ static __inline__ int tcp_prequeue(struct sock *sk, struct sk_buff *skb) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); if (tp->ucopy.task) { __skb_queue_tail(&tp->ucopy.prequeue, skb); @@ -1572,7 +1575,7 @@ static inline void tcp_acceptq_queue(struct sock *sk, struct open_request *req, struct sock *child) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); req->sk = child; tcp_acceptq_added(sk); @@ -1598,7 +1601,7 @@ static inline void tcp_synq_removed(struct sock *sk, struct open_request *req) { - struct tcp_listen_opt *lopt = sk->tp_pinfo.af_tcp.listen_opt; + struct tcp_listen_opt *lopt = TCP_PINFO(sk)->listen_opt; if (--lopt->qlen == 0) tcp_delete_keepalive_timer(sk); @@ -1608,7 +1611,7 @@ static inline void tcp_synq_added(struct sock *sk) { - struct tcp_listen_opt *lopt = sk->tp_pinfo.af_tcp.listen_opt; + struct tcp_listen_opt *lopt = TCP_PINFO(sk)->listen_opt; if (lopt->qlen++ == 0) tcp_reset_keepalive_timer(sk, TCP_TIMEOUT_INIT); @@ -1617,17 +1620,17 @@ static inline int tcp_synq_len(struct sock *sk) { - return sk->tp_pinfo.af_tcp.listen_opt->qlen; + return TCP_PINFO(sk)->listen_opt->qlen; } static inline int tcp_synq_young(struct sock *sk) { - return sk->tp_pinfo.af_tcp.listen_opt->qlen_young; + return TCP_PINFO(sk)->listen_opt->qlen_young; } static inline int tcp_synq_is_full(struct sock *sk) { - return tcp_synq_len(sk)>>sk->tp_pinfo.af_tcp.listen_opt->max_qlen_log; + return tcp_synq_len(sk) >> TCP_PINFO(sk)->listen_opt->max_qlen_log; } static inline void tcp_synq_unlink(struct tcp_opt *tp, struct open_request *req, @@ -1641,7 +1644,7 @@ static inline void tcp_synq_drop(struct sock *sk, struct open_request *req, struct open_request **prev) { - tcp_synq_unlink(&sk->tp_pinfo.af_tcp, req, prev); + tcp_synq_unlink(TCP_PINFO(sk), req, prev); tcp_synq_removed(sk, req); tcp_openreq_free(req); } @@ -1667,7 +1670,7 @@ static inline void tcp_free_skb(struct sock *sk, struct sk_buff *skb) { - sk->tp_pinfo.af_tcp.queue_shrunk = 1; + TCP_PINFO(sk)->queue_shrunk = 1; sk->wmem_queued -= skb->truesize; sk->forward_alloc += skb->truesize; __kfree_skb(skb); diff -uNr linux-2.5.1/include/net/x25.h linux-2.5.1.acme/include/net/x25.h --- linux-2.5.1/include/net/x25.h Mon Jan 22 19:32:10 2001 +++ linux-2.5.1.acme/include/net/x25.h Wed Dec 19 23:44:47 2001 @@ -139,6 +139,8 @@ unsigned long vc_facil_mask; /* inc_call facilities mask */ } x25_cb; +#define X25_SK(__sk) ((x25_cb *)(__sk)->protinfo) + /* af_x25.c */ extern int sysctl_x25_restart_request_timeout; extern int sysctl_x25_call_request_timeout; diff -uNr linux-2.5.1/net/appletalk/ddp.c linux-2.5.1.acme/net/appletalk/ddp.c --- linux-2.5.1/net/appletalk/ddp.c Mon Sep 10 11:57:00 2001 +++ linux-2.5.1.acme/net/appletalk/ddp.c Wed Dec 19 23:44:47 2001 @@ -152,16 +152,18 @@ spin_lock_bh(&atalk_sockets_lock); for (s = atalk_sockets; s; s = s->next) { - if (to->sat_port != s->protinfo.af_at.src_port) + struct atalk_sock *at = AT_SK(s); + + if (to->sat_port != at->src_port) continue; if (to->sat_addr.s_net == ATADDR_ANYNET && to->sat_addr.s_node == ATADDR_BCAST && - s->protinfo.af_at.src_net == atif->address.s_net) + at->src_net == atif->address.s_net) break; - if (to->sat_addr.s_net == s->protinfo.af_at.src_net && - (to->sat_addr.s_node == s->protinfo.af_at.src_node || + if (to->sat_addr.s_net == at->src_net && + (to->sat_addr.s_node == at->src_node || to->sat_addr.s_node == ATADDR_BCAST || to->sat_addr.s_node == ATADDR_ANYNODE)) break; @@ -170,7 +172,7 @@ * that the node is appropriately set. */ if (to->sat_addr.s_node == ATADDR_ANYNODE && to->sat_addr.s_net != ATADDR_ANYNET && - atif->address.s_node == s->protinfo.af_at.src_node) { + atif->address.s_node == at->src_node) { to->sat_addr.s_node = atif->address.s_node; break; } @@ -192,11 +194,14 @@ struct sock *s; spin_lock_bh(&atalk_sockets_lock); - for (s = atalk_sockets; s; s = s->next) - if (s->protinfo.af_at.src_net == sat->sat_addr.s_net && - s->protinfo.af_at.src_node == sat->sat_addr.s_node && - s->protinfo.af_at.src_port == sat->sat_port) + for (s = atalk_sockets; s; s = s->next) { + struct atalk_sock *at = AT_SK(s); + + if (at->src_net == sat->sat_addr.s_net && + at->src_node == sat->sat_addr.s_node && + at->src_port == sat->sat_port) break; + } if (!s) { /* Wheee, it's free, assign and insert. */ @@ -255,15 +260,14 @@ spin_lock_bh(&atalk_sockets_lock); for (s = atalk_sockets; s; s = s->next) { + struct atalk_sock *at = AT_SK(s); + len += sprintf(buffer + len,"%02X ", s->type); len += sprintf(buffer + len,"%04X:%02X:%02X ", - ntohs(s->protinfo.af_at.src_net), - s->protinfo.af_at.src_node, - s->protinfo.af_at.src_port); + ntohs(at->src_net), at->src_node, at->src_port); len += sprintf(buffer + len,"%04X:%02X:%02X ", - ntohs(s->protinfo.af_at.dest_net), - s->protinfo.af_at.dest_node, - s->protinfo.af_at.dest_port); + ntohs(at->dest_net), at->dest_node, + at->dest_port); len += sprintf(buffer + len,"%08X:%08X ", atomic_read(&s->wmem_alloc), atomic_read(&s->rmem_alloc)); @@ -1112,42 +1116,34 @@ */ static int atalk_create(struct socket *sock, int protocol) { - struct sock *sk = sk_alloc(PF_APPLETALK, GFP_KERNEL, 1); - - if (!sk) - return -ENOMEM; - - switch (sock->type) { - /* - * We permit SOCK_DGRAM and RAW is an extension. It is - * trivial to do and gives you the full ELAP frame. - * Should be handy for CAP 8) - */ - case SOCK_RAW: - case SOCK_DGRAM: - sock->ops = &atalk_dgram_ops; - break; - - case SOCK_STREAM: - /* - * TODO: if you want to implement ADSP, here's the - * place to start - */ - /* - sock->ops = &atalk_stream_ops; - break; - */ - default: - sk_free(sk); - return -ESOCKTNOSUPPORT; - } + struct sock *sk; + struct atalk_sock *at; + int rc = -ESOCKTNOSUPPORT; MOD_INC_USE_COUNT; + /* + * We permit SOCK_DGRAM and RAW is an extension. It is trivial to do + * and gives you the full ELAP frame. Should be handy for CAP 8) + */ + if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM) + goto decmod; + rc = -ENOMEM; + sk = sk_alloc(PF_APPLETALK, GFP_KERNEL, 1); + if (!sk) + goto decmod; + at = kmalloc(sizeof(*at), GFP_KERNEL); + if (!at) + goto outsk; + rc = 0; + sock->ops = &atalk_dgram_ops; sock_init_data(sock, sk); - sk->destruct = NULL; + AT_SK(sk) = at; /* Checksums on by default */ sk->zapped = 1; - return 0; +out: return rc; +outsk: sk_free(sk); +decmod: MOD_DEC_USE_COUNT; + goto out; } /* Free a socket. No work needed */ @@ -1156,15 +1152,13 @@ struct sock *sk = sock->sk; if (!sk) - return 0; - + goto out; if (!sk->dead) sk->state_change(sk); - sk->dead = 1; sock->sk = NULL; atalk_destroy_socket(sk); - return 0; +out: return 0; } /* @@ -1185,10 +1179,11 @@ sat->sat_port < ATPORT_LAST; sat->sat_port++) { for (s = atalk_sockets; s; s = s->next) { - if (s->protinfo.af_at.src_net == sat->sat_addr.s_net && - s->protinfo.af_at.src_node == - sat->sat_addr.s_node && - s->protinfo.af_at.src_port == sat->sat_port) + struct atalk_sock *at = AT_SK(s); + + if (at->src_net == sat->sat_addr.s_net && + at->src_node == sat->sat_addr.s_node && + at->src_port == sat->sat_port) goto try_next_port; } @@ -1198,7 +1193,7 @@ atalk_sockets->pprev = &sk->next; atalk_sockets = sk; sk->pprev = &atalk_sockets; - sk->protinfo.af_at.src_port = sat->sat_port; + AT_SK(sk)->src_port = sat->sat_port; retval = 0; goto out; @@ -1213,6 +1208,7 @@ static int atalk_autobind(struct sock *sk) { + struct atalk_sock *at = AT_SK(sk); struct sockaddr_at sat; int n; struct at_addr *ap = atalk_find_primary(); @@ -1220,8 +1216,8 @@ if (!ap || ap->s_net == htons(ATADDR_ANYNET)) return -EADDRNOTAVAIL; - sk->protinfo.af_at.src_net = sat.sat_addr.s_net = ap->s_net; - sk->protinfo.af_at.src_node = sat.sat_addr.s_node = ap->s_node; + at->src_net = sat.sat_addr.s_net = ap->s_net; + at->src_node = sat.sat_addr.s_node = ap->s_node; n = atalk_pick_and_bind_port(sk, &sat); if (n < 0) @@ -1236,6 +1232,7 @@ { struct sockaddr_at *addr = (struct sockaddr_at *)uaddr; struct sock *sk = sock->sk; + struct atalk_sock *at = AT_SK(sk); if (!sk->zapped || addr_len != sizeof(struct sockaddr_at)) return -EINVAL; @@ -1249,15 +1246,15 @@ if (!ap) return -EADDRNOTAVAIL; - sk->protinfo.af_at.src_net = addr->sat_addr.s_net = ap->s_net; - sk->protinfo.af_at.src_node = addr->sat_addr.s_node= ap->s_node; + at->src_net = addr->sat_addr.s_net = ap->s_net; + at->src_node = addr->sat_addr.s_node= ap->s_node; } else { if (!atalk_find_interface(addr->sat_addr.s_net, addr->sat_addr.s_node)) return -EADDRNOTAVAIL; - sk->protinfo.af_at.src_net = addr->sat_addr.s_net; - sk->protinfo.af_at.src_node = addr->sat_addr.s_node; + at->src_net = addr->sat_addr.s_net; + at->src_node = addr->sat_addr.s_node; } if (addr->sat_port == ATADDR_ANYPORT) { @@ -1266,7 +1263,7 @@ if (n < 0) return n; } else { - sk->protinfo.af_at.src_port = addr->sat_port; + at->src_port = addr->sat_port; if (atalk_find_or_insert_socket(sk, addr)) return -EADDRINUSE; @@ -1281,6 +1278,7 @@ int addr_len, int flags) { struct sock *sk = sock->sk; + struct atalk_sock *at = AT_SK(sk); struct sockaddr_at *addr; sk->state = TCP_CLOSE; @@ -1312,9 +1310,9 @@ if (!atrtr_get_dev(&addr->sat_addr)) return -ENETUNREACH; - sk->protinfo.af_at.dest_port = addr->sat_port; - sk->protinfo.af_at.dest_net = addr->sat_addr.s_net; - sk->protinfo.af_at.dest_node = addr->sat_addr.s_node; + at->dest_port = addr->sat_port; + at->dest_net = addr->sat_addr.s_net; + at->dest_node = addr->sat_addr.s_node; sock->state = SS_CONNECTED; sk->state = TCP_ESTABLISHED; @@ -1331,6 +1329,7 @@ { struct sockaddr_at sat; struct sock *sk = sock->sk; + struct atalk_sock *at = AT_SK(sk); if (sk->zapped) if (atalk_autobind(sk) < 0) @@ -1342,13 +1341,13 @@ if (sk->state != TCP_ESTABLISHED) return -ENOTCONN; - sat.sat_addr.s_net = sk->protinfo.af_at.dest_net; - sat.sat_addr.s_node = sk->protinfo.af_at.dest_node; - sat.sat_port = sk->protinfo.af_at.dest_port; + sat.sat_addr.s_net = at->dest_net; + sat.sat_addr.s_node = at->dest_node; + sat.sat_port = at->dest_port; } else { - sat.sat_addr.s_net = sk->protinfo.af_at.src_net; - sat.sat_addr.s_node = sk->protinfo.af_at.src_node; - sat.sat_port = sk->protinfo.af_at.src_port; + sat.sat_addr.s_net = at->src_net; + sat.sat_addr.s_node = at->src_node; + sat.sat_port = at->src_port; } sat.sat_family = AF_APPLETALK; @@ -1597,6 +1596,7 @@ struct scm_cookie *scm) { struct sock *sk = sock->sk; + struct atalk_sock *at = AT_SK(sk); struct sockaddr_at *usat = (struct sockaddr_at *)msg->msg_name; int flags = msg->msg_flags; int loopback = 0; @@ -1635,10 +1635,10 @@ if (sk->state != TCP_ESTABLISHED) return -ENOTCONN; usat = &local_satalk; - usat->sat_family = AF_APPLETALK; - usat->sat_port = sk->protinfo.af_at.dest_port; - usat->sat_addr.s_node = sk->protinfo.af_at.dest_node; - usat->sat_addr.s_net = sk->protinfo.af_at.dest_net; + usat->sat_family = AF_APPLETALK; + usat->sat_port = at->dest_port; + usat->sat_addr.s_node = at->dest_node; + usat->sat_addr.s_net = at->dest_net; } /* Build a packet */ @@ -1657,7 +1657,7 @@ struct at_addr at_hint; at_hint.s_node = 0; - at_hint.s_net = sk->protinfo.af_at.src_net; + at_hint.s_net = at->src_net; rt = atrtr_find(&at_hint); if (!rt) @@ -1693,11 +1693,11 @@ *((__u16 *)ddp) = ntohs(*((__u16 *)ddp)); ddp->deh_dnet = usat->sat_addr.s_net; - ddp->deh_snet = sk->protinfo.af_at.src_net; + ddp->deh_snet = at->src_net; ddp->deh_dnode = usat->sat_addr.s_node; - ddp->deh_snode = sk->protinfo.af_at.src_node; + ddp->deh_snode = at->src_node; ddp->deh_dport = usat->sat_port; - ddp->deh_sport = sk->protinfo.af_at.src_port; + ddp->deh_sport = at->src_port; SOCK_DEBUG(sk, "SK %p: Copy user data (%d bytes).\n", sk, len); @@ -1894,10 +1894,9 @@ return put_user(amount, (int *)arg); } -static struct net_proto_family atalk_family_ops = -{ - PF_APPLETALK, - atalk_create +static struct net_proto_family atalk_family_ops = { + family: PF_APPLETALK, + create: atalk_create, }; static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops)= diff -uNr linux-2.5.1/net/atm/common.c linux-2.5.1.acme/net/atm/common.c --- linux-2.5.1/net/atm/common.c Fri Nov 9 20:11:15 2001 +++ linux-2.5.1.acme/net/atm/common.c Wed Dec 19 23:44:47 2001 @@ -105,7 +105,7 @@ sock->sk = NULL; if (sock->type == SOCK_STREAM) return -EINVAL; if (!(sk = alloc_atm_vcc_sk(family))) return -ENOMEM; - vcc = sk->protinfo.af_atm; + vcc = ATM_SK(sk); memset(&vcc->flags,0,sizeof(vcc->flags)); vcc->dev = NULL; vcc->family = sock->ops->family; @@ -136,7 +136,7 @@ struct atm_vcc *vcc; struct sk_buff *skb; - vcc = sk->protinfo.af_atm; + vcc = ATM_SK(sk); clear_bit(ATM_VF_READY,&vcc->flags); if (vcc->dev) { if (vcc->dev->ops->close) vcc->dev->ops->close(vcc); diff -uNr linux-2.5.1/net/atm/pvc.c linux-2.5.1.acme/net/atm/pvc.c --- linux-2.5.1/net/atm/pvc.c Thu Apr 12 16:11:39 2001 +++ linux-2.5.1.acme/net/atm/pvc.c Wed Dec 19 23:44:47 2001 @@ -111,11 +111,8 @@ static struct net_proto_family pvc_family_ops = { - PF_ATMPVC, - pvc_create, - 0, /* no authentication */ - 0, /* no encryption */ - 0 /* no encrypt_net */ + family: PF_ATMPVC, + create: pvc_create, }; diff -uNr linux-2.5.1/net/atm/resources.c linux-2.5.1.acme/net/atm/resources.c --- linux-2.5.1/net/atm/resources.c Fri Nov 9 20:11:15 2001 +++ linux-2.5.1.acme/net/atm/resources.c Wed Dec 19 23:44:47 2001 @@ -143,7 +143,7 @@ /* Handler for sk->destruct, invoked by sk_free() */ static void atm_free_sock(struct sock *sk) { - kfree(sk->protinfo.af_atm); + kfree(ATM_SK(sk)); } @@ -154,7 +154,7 @@ sk = sk_alloc(family, GFP_KERNEL, 1); if (!sk) return NULL; - vcc = sk->protinfo.af_atm = kmalloc(sizeof(*vcc),GFP_KERNEL); + vcc = ATM_SK(sk) = kmalloc(sizeof(*vcc),GFP_KERNEL); if (!vcc) { sk_free(sk); return NULL; @@ -186,7 +186,7 @@ void free_atm_vcc_sk(struct sock *sk) { - unlink_vcc(sk->protinfo.af_atm,NULL); + unlink_vcc(ATM_SK(sk),NULL); sk_free(sk); } diff -uNr linux-2.5.1/net/atm/svc.c linux-2.5.1.acme/net/atm/svc.c --- linux-2.5.1/net/atm/svc.c Thu Apr 12 16:11:39 2001 +++ linux-2.5.1.acme/net/atm/svc.c Wed Dec 19 23:44:47 2001 @@ -430,11 +430,8 @@ static struct net_proto_family svc_family_ops = { - PF_ATMSVC, - svc_create, - 0, /* no authentication */ - 0, /* no encryption */ - 0 /* no encrypt_net */ + family: PF_ATMSVC, + create: svc_create, }; diff -uNr linux-2.5.1/net/ax25/af_ax25.c linux-2.5.1.acme/net/ax25/af_ax25.c --- linux-2.5.1/net/ax25/af_ax25.c Thu Sep 13 21:16:23 2001 +++ linux-2.5.1.acme/net/ax25/af_ax25.c Wed Dec 19 23:44:47 2001 @@ -161,7 +161,7 @@ static void ax25_free_sock(struct sock *sk) { - ax25_free_cb(sk->protinfo.ax25); + ax25_free_cb(AX25_SK(sk)); } /* @@ -424,8 +424,8 @@ while ((skb = skb_dequeue(&ax25->sk->receive_queue)) != NULL) { if (skb->sk != ax25->sk) { /* A pending connection */ skb->sk->dead = 1; /* Queue the unaccepted socket for death */ - ax25_start_heartbeat(skb->sk->protinfo.ax25); - skb->sk->protinfo.ax25->state = AX25_STATE_0; + ax25_start_heartbeat(AX25_SK(skb->sk)); + AX25_SK(skb->sk)->state = AX25_STATE_0; } kfree_skb(skb); @@ -631,6 +631,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, char *optval, int optlen) { struct sock *sk = sock->sk; + ax25_cb *ax25 = AX25_SK(sk); struct net_device *dev; char devname[IFNAMSIZ]; int opt; @@ -646,69 +647,69 @@ switch (optname) { case AX25_WINDOW: - if (sk->protinfo.ax25->modulus == AX25_MODULUS) { + if (ax25->modulus == AX25_MODULUS) { if (opt < 1 || opt > 7) return -EINVAL; } else { if (opt < 1 || opt > 63) return -EINVAL; } - sk->protinfo.ax25->window = opt; + ax25->window = opt; return 0; case AX25_T1: if (opt < 1) return -EINVAL; - sk->protinfo.ax25->rtt = (opt * HZ) / 2; - sk->protinfo.ax25->t1 = opt * HZ; + ax25->rtt = (opt * HZ) / 2; + ax25->t1 = opt * HZ; return 0; case AX25_T2: if (opt < 1) return -EINVAL; - sk->protinfo.ax25->t2 = opt * HZ; + ax25->t2 = opt * HZ; return 0; case AX25_N2: if (opt < 1 || opt > 31) return -EINVAL; - sk->protinfo.ax25->n2 = opt; + ax25->n2 = opt; return 0; case AX25_T3: if (opt < 1) return -EINVAL; - sk->protinfo.ax25->t3 = opt * HZ; + ax25->t3 = opt * HZ; return 0; case AX25_IDLE: if (opt < 0) return -EINVAL; - sk->protinfo.ax25->idle = opt * 60 * HZ; + ax25->idle = opt * 60 * HZ; return 0; case AX25_BACKOFF: if (opt < 0 || opt > 2) return -EINVAL; - sk->protinfo.ax25->backoff = opt; + ax25->backoff = opt; return 0; case AX25_EXTSEQ: - sk->protinfo.ax25->modulus = opt ? AX25_EMODULUS : AX25_MODULUS; + ax25->modulus = opt ? AX25_EMODULUS : AX25_MODULUS; return 0; case AX25_PIDINCL: - sk->protinfo.ax25->pidincl = opt ? 1 : 0; + ax25->pidincl = opt ? 1 : 0; return 0; case AX25_IAMDIGI: - sk->protinfo.ax25->iamdigi = opt ? 1 : 0; + ax25->iamdigi = opt ? 1 : 0; return 0; case AX25_PACLEN: if (opt < 16 || opt > 65535) return -EINVAL; - sk->protinfo.ax25->paclen = opt; + ax25->paclen = opt; return 0; case SO_BINDTODEVICE: @@ -723,8 +724,8 @@ (sock->state != SS_UNCONNECTED || sk->state == TCP_LISTEN)) return -EADDRNOTAVAIL; - sk->protinfo.ax25->ax25_dev = ax25_dev_ax25dev(dev); - ax25_fillin_cb(sk->protinfo.ax25, sk->protinfo.ax25->ax25_dev); + ax25->ax25_dev = ax25_dev_ax25dev(dev); + ax25_fillin_cb(ax25, ax25->ax25_dev); return 0; default: @@ -735,6 +736,7 @@ static int ax25_getsockopt(struct socket *sock, int level, int optname, char *optval, int *optlen) { struct sock *sk = sock->sk; + ax25_cb *ax25 = AX25_SK(sk); struct ax25_dev *ax25_dev; char devname[IFNAMSIZ]; void *valptr; @@ -755,51 +757,51 @@ switch (optname) { case AX25_WINDOW: - val = sk->protinfo.ax25->window; + val = ax25->window; break; case AX25_T1: - val = sk->protinfo.ax25->t1 / HZ; + val = ax25->t1 / HZ; break; case AX25_T2: - val = sk->protinfo.ax25->t2 / HZ; + val = ax25->t2 / HZ; break; case AX25_N2: - val = sk->protinfo.ax25->n2; + val = ax25->n2; break; case AX25_T3: - val = sk->protinfo.ax25->t3 / HZ; + val = ax25->t3 / HZ; break; case AX25_IDLE: - val = sk->protinfo.ax25->idle / (60 * HZ); + val = ax25->idle / (60 * HZ); break; case AX25_BACKOFF: - val = sk->protinfo.ax25->backoff; + val = ax25->backoff; break; case AX25_EXTSEQ: - val = (sk->protinfo.ax25->modulus == AX25_EMODULUS); + val = (ax25->modulus == AX25_EMODULUS); break; case AX25_PIDINCL: - val = sk->protinfo.ax25->pidincl; + val = ax25->pidincl; break; case AX25_IAMDIGI: - val = sk->protinfo.ax25->iamdigi; + val = ax25->iamdigi; break; case AX25_PACLEN: - val = sk->protinfo.ax25->paclen; + val = ax25->paclen; break; case SO_BINDTODEVICE: - ax25_dev = sk->protinfo.ax25->ax25_dev; + ax25_dev = ax25->ax25_dev; if (ax25_dev != NULL && ax25_dev->dev != NULL) { strncpy(devname, ax25_dev->dev->name, IFNAMSIZ); @@ -898,8 +900,8 @@ sock->ops = &ax25_proto_ops; sk->protocol = protocol; - ax25->sk = sk; - sk->protinfo.ax25 = ax25; + ax25->sk = sk; + AX25_SK(sk) = ax25; return 0; } @@ -907,7 +909,7 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev) { struct sock *sk; - ax25_cb *ax25; + ax25_cb *ax25, *oax25; if ((sk = sk_alloc(PF_AX25, GFP_ATOMIC, 1)) == NULL) return NULL; @@ -942,33 +944,35 @@ sk->sleep = osk->sleep; sk->zapped = osk->zapped; - ax25->modulus = osk->protinfo.ax25->modulus; - ax25->backoff = osk->protinfo.ax25->backoff; - ax25->pidincl = osk->protinfo.ax25->pidincl; - ax25->iamdigi = osk->protinfo.ax25->iamdigi; - ax25->rtt = osk->protinfo.ax25->rtt; - ax25->t1 = osk->protinfo.ax25->t1; - ax25->t2 = osk->protinfo.ax25->t2; - ax25->t3 = osk->protinfo.ax25->t3; - ax25->n2 = osk->protinfo.ax25->n2; - ax25->idle = osk->protinfo.ax25->idle; - ax25->paclen = osk->protinfo.ax25->paclen; - ax25->window = osk->protinfo.ax25->window; + oax25 = AX25_SK(osk); + + ax25->modulus = oax25->modulus; + ax25->backoff = oax25->backoff; + ax25->pidincl = oax25->pidincl; + ax25->iamdigi = oax25->iamdigi; + ax25->rtt = oax25->rtt; + ax25->t1 = oax25->t1; + ax25->t2 = oax25->t2; + ax25->t3 = oax25->t3; + ax25->n2 = oax25->n2; + ax25->idle = oax25->idle; + ax25->paclen = oax25->paclen; + ax25->window = oax25->window; ax25->ax25_dev = ax25_dev; - ax25->source_addr = osk->protinfo.ax25->source_addr; + ax25->source_addr = oax25->source_addr; - if (osk->protinfo.ax25->digipeat != NULL) { + if (oax25->digipeat != NULL) { if ((ax25->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { sk_free(sk); return NULL; } - memcpy(ax25->digipeat, osk->protinfo.ax25->digipeat, sizeof(ax25_digi)); + memcpy(ax25->digipeat, oax25->digipeat, sizeof(ax25_digi)); } - sk->protinfo.ax25 = ax25; - ax25->sk = sk; + AX25_SK(sk) = ax25; + ax25->sk = sk; return sk; } @@ -976,45 +980,51 @@ static int ax25_release(struct socket *sock) { struct sock *sk = sock->sk; + ax25_cb *ax25; if (sk == NULL) return 0; + ax25 = AX25_SK(sk); + if (sk->type == SOCK_SEQPACKET) { - switch (sk->protinfo.ax25->state) { + switch (ax25->state) { case AX25_STATE_0: - ax25_disconnect(sk->protinfo.ax25, 0); - ax25_destroy_socket(sk->protinfo.ax25); + ax25_disconnect(ax25, 0); + ax25_destroy_socket(ax25); break; case AX25_STATE_1: case AX25_STATE_2: - ax25_send_control(sk->protinfo.ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND); - ax25_disconnect(sk->protinfo.ax25, 0); - ax25_destroy_socket(sk->protinfo.ax25); + ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND); + ax25_disconnect(ax25, 0); + ax25_destroy_socket(ax25); break; case AX25_STATE_3: case AX25_STATE_4: - ax25_clear_queues(sk->protinfo.ax25); - sk->protinfo.ax25->n2count = 0; - switch (sk->protinfo.ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { + ax25_clear_queues(ax25); + ax25->n2count = 0; + switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { case AX25_PROTO_STD_SIMPLEX: case AX25_PROTO_STD_DUPLEX: - ax25_send_control(sk->protinfo.ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND); - ax25_stop_t2timer(sk->protinfo.ax25); - ax25_stop_t3timer(sk->protinfo.ax25); - ax25_stop_idletimer(sk->protinfo.ax25); + ax25_send_control(ax25, + AX25_DISC, + AX25_POLLON, + AX25_COMMAND); + ax25_stop_t2timer(ax25); + ax25_stop_t3timer(ax25); + ax25_stop_idletimer(ax25); break; #ifdef CONFIG_AX25_DAMA_SLAVE case AX25_PROTO_DAMA_SLAVE: - ax25_stop_t3timer(sk->protinfo.ax25); - ax25_stop_idletimer(sk->protinfo.ax25); + ax25_stop_t3timer(ax25); + ax25_stop_idletimer(ax25); break; #endif } - ax25_calculate_t1(sk->protinfo.ax25); - ax25_start_t1timer(sk->protinfo.ax25); - sk->protinfo.ax25->state = AX25_STATE_2; + ax25_calculate_t1(ax25); + ax25_start_t1timer(ax25); + ax25->state = AX25_STATE_2; sk->state = TCP_CLOSE; sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); @@ -1030,7 +1040,7 @@ sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); sk->dead = 1; - ax25_destroy_socket(sk->protinfo.ax25); + ax25_destroy_socket(ax25); } sock->sk = NULL; @@ -1048,6 +1058,7 @@ static int ax25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct sock *sk = sock->sk; + ax25_cb *ax25 = AX25_SK(sk); struct full_sockaddr_ax25 *addr = (struct full_sockaddr_ax25 *)uaddr; ax25_address *call; ax25_dev *ax25_dev = NULL; @@ -1074,15 +1085,15 @@ return -EACCES; if (call == NULL) - sk->protinfo.ax25->source_addr = addr->fsa_ax25.sax25_call; + ax25->source_addr = addr->fsa_ax25.sax25_call; else - sk->protinfo.ax25->source_addr = *call; + ax25->source_addr = *call; /* * User already set interface with SO_BINDTODEVICE */ - if (sk->protinfo.ax25->ax25_dev != NULL) + if (ax25->ax25_dev != NULL) goto done; if (addr_len > sizeof(struct sockaddr_ax25) && addr->fsa_ax25.sax25_ndigis == 1) { @@ -1095,10 +1106,10 @@ } if (ax25_dev != NULL) - ax25_fillin_cb(sk->protinfo.ax25, ax25_dev); + ax25_fillin_cb(ax25, ax25_dev); done: - ax25_insert_socket(sk->protinfo.ax25); + ax25_insert_socket(ax25); sk->zapped = 0; return 0; } @@ -1109,6 +1120,7 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags) { struct sock *sk = sock->sk; + ax25_cb *ax25 = AX25_SK(sk); struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)uaddr; ax25_digi *digi = NULL; int ct = 0, err; @@ -1157,9 +1169,9 @@ if (fsa->fsa_ax25.sax25_family != AF_AX25) return -EINVAL; - if (sk->protinfo.ax25->digipeat != NULL) { - kfree(sk->protinfo.ax25->digipeat); - sk->protinfo.ax25->digipeat = NULL; + if (ax25->digipeat != NULL) { + kfree(ax25->digipeat); + ax25->digipeat = NULL; } /* @@ -1177,7 +1189,8 @@ digi->lastrepeat = -1; while (ct < fsa->fsa_ax25.sax25_ndigis) { - if ((fsa->fsa_digipeater[ct].ax25_call[6] & AX25_HBIT) && sk->protinfo.ax25->iamdigi) { + if ((fsa->fsa_digipeater[ct].ax25_call[6] & + AX25_HBIT) && ax25->iamdigi) { digi->repeated[ct] = 1; digi->lastrepeat = ct; } else { @@ -1197,22 +1210,24 @@ /* check if we can remove this feature. It is broken. */ printk(KERN_WARNING "ax25_connect(): %s uses autobind, please contact jreuter@yaina.de\n", current->comm); - if ((err = ax25_rt_autobind(sk->protinfo.ax25, &fsa->fsa_ax25.sax25_call)) < 0) + if ((err = ax25_rt_autobind(ax25, &fsa->fsa_ax25.sax25_call)) < 0) return err; - ax25_fillin_cb(sk->protinfo.ax25, sk->protinfo.ax25->ax25_dev); - ax25_insert_socket(sk->protinfo.ax25); + ax25_fillin_cb(ax25, ax25->ax25_dev); + ax25_insert_socket(ax25); } else { - if (sk->protinfo.ax25->ax25_dev == NULL) + if (ax25->ax25_dev == NULL) return -EHOSTUNREACH; } - if (sk->type == SOCK_SEQPACKET && ax25_find_cb(&sk->protinfo.ax25->source_addr, &fsa->fsa_ax25.sax25_call, digi, sk->protinfo.ax25->ax25_dev->dev) != NULL) { + if (sk->type == SOCK_SEQPACKET && + ax25_find_cb(&ax25->source_addr, &fsa->fsa_ax25.sax25_call, digi, + ax25->ax25_dev->dev)) { if (digi != NULL) kfree(digi); return -EADDRINUSE; /* Already such a connection */ } - sk->protinfo.ax25->dest_addr = fsa->fsa_ax25.sax25_call; - sk->protinfo.ax25->digipeat = digi; + ax25->dest_addr = fsa->fsa_ax25.sax25_call; + ax25->digipeat = digi; /* First the easy one */ if (sk->type != SOCK_SEQPACKET) { @@ -1225,27 +1240,28 @@ sock->state = SS_CONNECTING; sk->state = TCP_SYN_SENT; - switch (sk->protinfo.ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { + switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { case AX25_PROTO_STD_SIMPLEX: case AX25_PROTO_STD_DUPLEX: - ax25_std_establish_data_link(sk->protinfo.ax25); + ax25_std_establish_data_link(ax25); break; #ifdef CONFIG_AX25_DAMA_SLAVE case AX25_PROTO_DAMA_SLAVE: - sk->protinfo.ax25->modulus = AX25_MODULUS; - sk->protinfo.ax25->window = sk->protinfo.ax25->ax25_dev->values[AX25_VALUES_WINDOW]; - if (sk->protinfo.ax25->ax25_dev->dama.slave) - ax25_ds_establish_data_link(sk->protinfo.ax25); + ax25->modulus = AX25_MODULUS; + ax25->window = + ax25->ax25_dev->values[AX25_VALUES_WINDOW]; + if (ax25->ax25_dev->dama.slave) + ax25_ds_establish_data_link(ax25); else - ax25_std_establish_data_link(sk->protinfo.ax25); + ax25_std_establish_data_link(ax25); break; #endif } - sk->protinfo.ax25->state = AX25_STATE_1; + ax25->state = AX25_STATE_1; - ax25_start_heartbeat(sk->protinfo.ax25); + ax25_start_heartbeat(ax25); /* Now the loop */ if (sk->state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) @@ -1327,6 +1343,7 @@ static int ax25_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer) { struct sock *sk = sock->sk; + ax25_cb *ax25 = AX25_SK(sk); struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)uaddr; unsigned char ndigi, i; @@ -1335,21 +1352,23 @@ return -ENOTCONN; fsa->fsa_ax25.sax25_family = AF_AX25; - fsa->fsa_ax25.sax25_call = sk->protinfo.ax25->dest_addr; + fsa->fsa_ax25.sax25_call = ax25->dest_addr; fsa->fsa_ax25.sax25_ndigis = 0; - if (sk->protinfo.ax25->digipeat != NULL) { - ndigi = sk->protinfo.ax25->digipeat->ndigi; + if (ax25->digipeat != NULL) { + ndigi = ax25->digipeat->ndigi; fsa->fsa_ax25.sax25_ndigis = ndigi; for (i = 0; i < ndigi; i++) - fsa->fsa_digipeater[i] = sk->protinfo.ax25->digipeat->calls[i]; + fsa->fsa_digipeater[i] = + ax25->digipeat->calls[i]; } } else { fsa->fsa_ax25.sax25_family = AF_AX25; - fsa->fsa_ax25.sax25_call = sk->protinfo.ax25->source_addr; + fsa->fsa_ax25.sax25_call = ax25->source_addr; fsa->fsa_ax25.sax25_ndigis = 1; - if (sk->protinfo.ax25->ax25_dev != NULL) { - memcpy(&fsa->fsa_digipeater[0], sk->protinfo.ax25->ax25_dev->dev->dev_addr, AX25_ADDR_LEN); + if (ax25->ax25_dev != NULL) { + memcpy(&fsa->fsa_digipeater[0], + ax25->ax25_dev->dev->dev_addr, AX25_ADDR_LEN); } else { fsa->fsa_digipeater[0] = null_ax25_address; } @@ -1361,6 +1380,7 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct scm_cookie *scm) { struct sock *sk = sock->sk; + ax25_cb *ax25 = AX25_SK(sk); struct sockaddr_ax25 *usax = (struct sockaddr_ax25 *)msg->msg_name; int err; struct sockaddr_ax25 sax; @@ -1383,7 +1403,7 @@ return -EPIPE; } - if (sk->protinfo.ax25->ax25_dev == NULL) + if (ax25->ax25_dev == NULL) return -ENETUNREACH; if (usax != NULL) { @@ -1424,7 +1444,7 @@ } sax = *usax; - if (sk->type == SOCK_SEQPACKET && ax25cmp(&sk->protinfo.ax25->dest_addr, &sax.sax25_call) != 0) + if (sk->type == SOCK_SEQPACKET && ax25cmp(&ax25->dest_addr, &sax.sax25_call) != 0) return -EISCONN; if (usax->sax25_ndigis == 0) dp = NULL; @@ -1439,8 +1459,8 @@ if (sk->state != TCP_ESTABLISHED) return -ENOTCONN; sax.sax25_family = AF_AX25; - sax.sax25_call = sk->protinfo.ax25->dest_addr; - dp = sk->protinfo.ax25->digipeat; + sax.sax25_call = ax25->dest_addr; + dp = ax25->digipeat; } SOCK_DEBUG(sk, "AX.25: sendto: Addresses built.\n"); @@ -1463,7 +1483,7 @@ skb->nh.raw = skb->data; /* Add the PID if one is not supplied by the user in the skb */ - if (!sk->protinfo.ax25->pidincl) { + if (!ax25->pidincl) { asmptr = skb_push(skb, 1); *asmptr = sk->protocol; } @@ -1477,7 +1497,8 @@ return -ENOTCONN; } - ax25_output(sk->protinfo.ax25, sk->protinfo.ax25->paclen, skb); /* Shove it onto the queue and kick */ + /* Shove it onto the queue and kick */ + ax25_output(ax25, ax25->paclen, skb); return len; } else { @@ -1489,7 +1510,9 @@ SOCK_DEBUG(sk, "Num digipeaters=%d\n", dp->ndigi); /* Build an AX.25 header */ - asmptr += (lv = ax25_addr_build(asmptr, &sk->protinfo.ax25->source_addr, &sax.sax25_call, dp, AX25_COMMAND, AX25_MODULUS)); + asmptr += (lv = ax25_addr_build(asmptr, &ax25->source_addr, + &sax.sax25_call, dp, + AX25_COMMAND, AX25_MODULUS)); SOCK_DEBUG(sk, "Built header (%d bytes)\n",lv); @@ -1500,7 +1523,7 @@ *asmptr = AX25_UI; /* Datagram frames go straight out of the door as UI */ - skb->dev = sk->protinfo.ax25->ax25_dev->dev; + skb->dev = ax25->ax25_dev->dev; ax25_queue_xmit(skb); @@ -1526,7 +1549,7 @@ if ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL) return er; - if (!sk->protinfo.ax25->pidincl) + if (!AX25_SK(sk)->pidincl) skb_pull(skb, 1); /* Remove PID */ skb->h.raw = skb->data; @@ -1639,27 +1662,28 @@ case SIOCAX25GETINFO: case SIOCAX25GETINFOOLD: { + ax25_cb *ax25 = AX25_SK(sk); struct ax25_info_struct ax25_info; - ax25_info.t1 = sk->protinfo.ax25->t1 / HZ; - ax25_info.t2 = sk->protinfo.ax25->t2 / HZ; - ax25_info.t3 = sk->protinfo.ax25->t3 / HZ; - ax25_info.idle = sk->protinfo.ax25->idle / (60 * HZ); - ax25_info.n2 = sk->protinfo.ax25->n2; - ax25_info.t1timer = ax25_display_timer(&sk->protinfo.ax25->t1timer) / HZ; - ax25_info.t2timer = ax25_display_timer(&sk->protinfo.ax25->t2timer) / HZ; - ax25_info.t3timer = ax25_display_timer(&sk->protinfo.ax25->t3timer) / HZ; - ax25_info.idletimer = ax25_display_timer(&sk->protinfo.ax25->idletimer) / (60 * HZ); - ax25_info.n2count = sk->protinfo.ax25->n2count; - ax25_info.state = sk->protinfo.ax25->state; + ax25_info.t1 = ax25->t1 / HZ; + ax25_info.t2 = ax25->t2 / HZ; + ax25_info.t3 = ax25->t3 / HZ; + ax25_info.idle = ax25->idle / (60 * HZ); + ax25_info.n2 = ax25->n2; + ax25_info.t1timer = ax25_display_timer(&ax25->t1timer) / HZ; + ax25_info.t2timer = ax25_display_timer(&ax25->t2timer) / HZ; + ax25_info.t3timer = ax25_display_timer(&ax25->t3timer) / HZ; + ax25_info.idletimer = ax25_display_timer(&ax25->idletimer) / (60 * HZ); + ax25_info.n2count = ax25->n2count; + ax25_info.state = ax25->state; ax25_info.rcv_q = atomic_read(&sk->rmem_alloc); ax25_info.snd_q = atomic_read(&sk->wmem_alloc); - ax25_info.vs = sk->protinfo.ax25->vs; - ax25_info.vr = sk->protinfo.ax25->vr; - ax25_info.va = sk->protinfo.ax25->va; - ax25_info.vs_max = sk->protinfo.ax25->vs; /* reserved */ - ax25_info.paclen = sk->protinfo.ax25->paclen; - ax25_info.window = sk->protinfo.ax25->window; + ax25_info.vs = ax25->vs; + ax25_info.vr = ax25->vr; + ax25_info.va = ax25->va; + ax25_info.vs_max = ax25->vs; /* reserved */ + ax25_info.paclen = ax25->paclen; + ax25_info.window = ax25->window; /* old structure? */ if (cmd == SIOCAX25GETINFOOLD) { diff -uNr linux-2.5.1/net/ax25/ax25_ds_timer.c linux-2.5.1.acme/net/ax25/ax25_ds_timer.c --- linux-2.5.1/net/ax25/ax25_ds_timer.c Fri Dec 29 20:35:47 2000 +++ linux-2.5.1.acme/net/ax25/ax25_ds_timer.c Wed Dec 19 23:44:47 2001 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff -uNr linux-2.5.1/net/ax25/ax25_in.c linux-2.5.1.acme/net/ax25/ax25_in.c --- linux-2.5.1/net/ax25/ax25_in.c Sun Sep 9 14:52:35 2001 +++ linux-2.5.1.acme/net/ax25/ax25_in.c Wed Dec 19 23:44:47 2001 @@ -388,7 +388,7 @@ return 0; } - ax25 = make->protinfo.ax25; + ax25 = AX25_SK(make); skb_set_owner_r(skb, make); skb_queue_head(&sk->receive_queue, skb); diff -uNr linux-2.5.1/net/ax25/ax25_std_timer.c linux-2.5.1.acme/net/ax25/ax25_std_timer.c --- linux-2.5.1/net/ax25/ax25_std_timer.c Fri Dec 29 20:35:47 2000 +++ linux-2.5.1.acme/net/ax25/ax25_std_timer.c Wed Dec 19 23:44:47 2001 @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff -uNr linux-2.5.1/net/ax25/ax25_subr.c linux-2.5.1.acme/net/ax25/ax25_subr.c --- linux-2.5.1/net/ax25/ax25_subr.c Fri Jun 29 23:38:26 2001 +++ linux-2.5.1.acme/net/ax25/ax25_subr.c Wed Dec 19 23:44:47 2001 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include diff -uNr linux-2.5.1/net/bluetooth/af_bluetooth.c linux-2.5.1.acme/net/bluetooth/af_bluetooth.c --- linux-2.5.1/net/bluetooth/af_bluetooth.c Fri Sep 7 13:28:38 2001 +++ linux-2.5.1.acme/net/bluetooth/af_bluetooth.c Wed Dec 19 23:44:47 2001 @@ -122,9 +122,9 @@ write_unlock(&l->lock); } -struct net_proto_family bluez_sock_family_ops = -{ - PF_BLUETOOTH, bluez_sock_create +struct net_proto_family bluez_sock_family_ops = { + family: PF_BLUETOOTH, + create: bluez_sock_create, }; int bluez_init(void) diff -uNr linux-2.5.1/net/bluetooth/hci_sock.c linux-2.5.1.acme/net/bluetooth/hci_sock.c --- linux-2.5.1/net/bluetooth/hci_sock.c Fri Sep 7 13:28:38 2001 +++ linux-2.5.1.acme/net/bluetooth/hci_sock.c Wed Dec 19 23:44:47 2001 @@ -519,7 +519,7 @@ struct net_proto_family hci_sock_family_ops = { family: PF_BLUETOOTH, - create: hci_sock_create + create: hci_sock_create, }; struct notifier_block hci_sock_nblock = { diff -uNr linux-2.5.1/net/bluetooth/l2cap_core.c linux-2.5.1.acme/net/bluetooth/l2cap_core.c --- linux-2.5.1/net/bluetooth/l2cap_core.c Sun Sep 30 16:26:08 2001 +++ linux-2.5.1.acme/net/bluetooth/l2cap_core.c Wed Dec 19 23:44:47 2001 @@ -2238,7 +2238,7 @@ struct net_proto_family l2cap_sock_family_ops = { family: PF_BLUETOOTH, - create: l2cap_sock_create + create: l2cap_sock_create, }; struct hci_proto l2cap_hci_proto = { diff -uNr linux-2.5.1/net/core/sock.c linux-2.5.1.acme/net/core/sock.c --- linux-2.5.1/net/core/sock.c Sat Jul 28 16:12:38 2001 +++ linux-2.5.1.acme/net/core/sock.c Wed Dec 19 23:44:47 2001 @@ -576,7 +576,14 @@ return 0; } -static kmem_cache_t *sk_cachep; +kmem_cache_t *sk_cachep; +extern struct net_proto_family *net_families[NPROTO]; + +int net_proto_sk_size(int family) +{ + return net_families[family] ? + net_families[family]->sk_size : sizeof(struct sock); +} /* * All socket objects are allocated here. This is for future @@ -585,10 +592,14 @@ struct sock *sk_alloc(int family, int priority, int zero_it) { - struct sock *sk = kmem_cache_alloc(sk_cachep, priority); + /* this is needed because the rt_netlink sock is created early, + * before it has called sock_register */ + kmem_cache_t *slab = net_families[family] ? + net_families[family]->sk_cachep : sk_cachep; + struct sock *sk = kmem_cache_alloc(slab, priority); if(sk && zero_it) { - memset(sk, 0, sizeof(struct sock)); + memset(sk, 0, net_proto_sk_size(family)); sk->family = family; sock_lock_init(sk); } @@ -616,7 +627,7 @@ if (atomic_read(&sk->omem_alloc)) printk(KERN_DEBUG "sk_free: optmem leakage (%d bytes) detected.\n", atomic_read(&sk->omem_alloc)); - kmem_cache_free(sk_cachep, sk); + kmem_cache_free(net_families[sk->family]->sk_cachep, sk); } void __init sk_init(void) @@ -1144,8 +1155,8 @@ void sock_def_destruct(struct sock *sk) { - if (sk->protinfo.destruct_hook) - kfree(sk->protinfo.destruct_hook); + if (sk->protinfo) + kfree(sk->protinfo); } void sock_init_data(struct socket *sock, struct sock *sk) diff -uNr linux-2.5.1/net/decnet/af_decnet.c linux-2.5.1.acme/net/decnet/af_decnet.c --- linux-2.5.1/net/decnet/af_decnet.c Fri Nov 9 20:12:54 2001 +++ linux-2.5.1.acme/net/decnet/af_decnet.c Wed Dec 19 23:44:47 2001 @@ -112,6 +112,7 @@ #include #include #include +#include #include #include #include @@ -406,12 +407,15 @@ if ((sk = sk_alloc(PF_DECnet, gfp, 1)) == NULL) goto no_sock; + scp = kmalloc(sizeof(*scp), gfp); + if (!scp) + goto free_sock; if (sock) { sock->ops = &dn_proto_ops; } sock_init_data(sock,sk); - scp = DN_SK(sk); + DN_SK(sk) = scp; sk->backlog_rcv = dn_nsp_backlog_rcv; sk->destruct = dn_destruct; @@ -472,6 +476,8 @@ MOD_INC_USE_COUNT; return sk; +free_sock: + sk_free(sk); no_sock: return NULL; } diff -uNr linux-2.5.1/net/decnet/dn_nsp_in.c linux-2.5.1.acme/net/decnet/dn_nsp_in.c --- linux-2.5.1/net/decnet/dn_nsp_in.c Fri Nov 9 20:12:54 2001 +++ linux-2.5.1.acme/net/decnet/dn_nsp_in.c Wed Dec 19 23:44:47 2001 @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,7 @@ #include #include #include +#include #include #include #include @@ -100,7 +102,7 @@ switch(type) { case 0: /* ACK - Data */ - if (after(ack, scp->ackrcv_dat)) { + if (dn_after(ack, scp->ackrcv_dat)) { scp->ackrcv_dat = ack & 0x0fff; wakeup |= dn_nsp_check_xmit_queue(sk, skb, &scp->data_xmit_queue, ack); } @@ -108,7 +110,7 @@ case 1: /* NAK - Data */ break; case 2: /* ACK - OtherData */ - if (after(ack, scp->ackrcv_oth)) { + if (dn_after(ack, scp->ackrcv_oth)) { scp->ackrcv_oth = ack & 0x0fff; wakeup |= dn_nsp_check_xmit_queue(sk, skb, &scp->other_xmit_queue, ack); } diff -uNr linux-2.5.1/net/decnet/dn_nsp_out.c linux-2.5.1.acme/net/decnet/dn_nsp_out.c --- linux-2.5.1/net/decnet/dn_nsp_out.c Mon Jan 22 19:32:10 2001 +++ linux-2.5.1.acme/net/decnet/dn_nsp_out.c Wed Dec 19 23:44:47 2001 @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include @@ -402,7 +403,7 @@ while(list != skb2) { struct dn_skb_cb *cb2 = DN_SKB_CB(skb2); - if (before_or_equal(cb2->segnum, acknum)) + if (dn_before_or_equal(cb2->segnum, acknum)) ack = skb2; /* printk(KERN_DEBUG "ack: %s %04x %04x\n", ack ? "ACK" : "SKIP", (int)cb2->segnum, (int)acknum); */ @@ -439,7 +440,7 @@ * further. */ if (xmit_count == 1) { - if (equal(segnum, acknum)) + if (dn_equal(segnum, acknum)) dn_nsp_rtt(sk, (long)(pkttime - reftime)); if (scp->snd_window < scp->max_window) diff -uNr linux-2.5.1/net/econet/af_econet.c linux-2.5.1.acme/net/econet/af_econet.c --- linux-2.5.1/net/econet/af_econet.c Fri Jun 29 23:38:26 2001 +++ linux-2.5.1.acme/net/econet/af_econet.c Wed Dec 19 23:44:47 2001 @@ -176,10 +176,10 @@ sec->sec_family != AF_ECONET) return -EINVAL; - sk->protinfo.af_econet->cb = sec->cb; - sk->protinfo.af_econet->port = sec->port; - sk->protinfo.af_econet->station = sec->addr.station; - sk->protinfo.af_econet->net = sec->addr.net; + EC_SK(sk)->cb = sec->cb; + EC_SK(sk)->port = sec->port; + EC_SK(sk)->station = sec->addr.station; + EC_SK(sk)->net = sec->addr.net; return 0; } @@ -265,10 +265,10 @@ */ if (saddr == NULL) { - addr.station = sk->protinfo.af_econet->station; - addr.net = sk->protinfo.af_econet->net; - port = sk->protinfo.af_econet->port; - cb = sk->protinfo.af_econet->cb; + addr.station = EC_SK(sk)->station; + addr.net = EC_SK(sk)->net; + port = EC_SK(sk)->port; + cb = EC_SK(sk)->cb; } else { if (msg->msg_namelen < sizeof(struct sockaddr_ec)) return -EINVAL; @@ -455,9 +455,9 @@ return -EOPNOTSUPP; sec->sec_family = AF_ECONET; - sec->port = sk->protinfo.af_econet->port; - sec->addr.station = sk->protinfo.af_econet->station; - sec->addr.net = sk->protinfo.af_econet->net; + sec->port = EC_SK(sk)->port; + sec->addr.station = EC_SK(sk)->station; + sec->addr.net = EC_SK(sk)->net; *uaddr_len = sizeof(*sec); return 0; @@ -543,10 +543,10 @@ sock->ops = &econet_ops; sock_init_data(sock,sk); - sk->protinfo.af_econet = kmalloc(sizeof(struct econet_opt), GFP_KERNEL); - if (sk->protinfo.af_econet == NULL) + EC_SK(sk) = kmalloc(sizeof(struct econet_opt), GFP_KERNEL); + if (EC_SK(sk) == NULL) goto out_free; - memset(sk->protinfo.af_econet, 0, sizeof(struct econet_opt)); + memset(EC_SK(sk), 0, sizeof(struct econet_opt)); sk->zapped=0; sk->family = PF_ECONET; sk->num = protocol; @@ -731,7 +731,7 @@ while (sk) { - struct econet_opt *opt = sk->protinfo.af_econet; + struct econet_opt *opt = EC_SK(sk); if ((opt->port == port || opt->port == 0) && (opt->station == station || opt->station == 0) && (opt->net == net || opt->net == 0)) diff -uNr linux-2.5.1/net/ipv4/af_inet.c linux-2.5.1.acme/net/ipv4/af_inet.c --- linux-2.5.1/net/ipv4/af_inet.c Mon Nov 5 15:46:12 2001 +++ linux-2.5.1.acme/net/ipv4/af_inet.c Wed Dec 19 23:44:47 2001 @@ -175,8 +175,8 @@ BUG_TRAP(sk->wmem_queued == 0); BUG_TRAP(sk->forward_alloc == 0); - if (sk->protinfo.af_inet.opt) - kfree(sk->protinfo.af_inet.opt); + if (IP_SK(sk)->opt) + kfree(IP_SK(sk)->opt); dst_release(sk->dst_cache); #ifdef INET_REFCNT_DEBUG atomic_dec(&inet_sock_nr); @@ -366,15 +366,15 @@ if (SOCK_RAW == sock->type) { sk->num = protocol; if (IPPROTO_RAW == protocol) - sk->protinfo.af_inet.hdrincl = 1; + IP_SK(sk)->hdrincl = 1; } if (ipv4_config.no_pmtu_disc) - sk->protinfo.af_inet.pmtudisc = IP_PMTUDISC_DONT; + IP_SK(sk)->pmtudisc = IP_PMTUDISC_DONT; else - sk->protinfo.af_inet.pmtudisc = IP_PMTUDISC_WANT; + IP_SK(sk)->pmtudisc = IP_PMTUDISC_WANT; - sk->protinfo.af_inet.id = 0; + IP_SK(sk)->id = 0; sock_init_data(sock,sk); @@ -386,12 +386,12 @@ sk->backlog_rcv = sk->prot->backlog_rcv; - sk->protinfo.af_inet.ttl = sysctl_ip_default_ttl; + IP_SK(sk)->ttl = sysctl_ip_default_ttl; - sk->protinfo.af_inet.mc_loop = 1; - sk->protinfo.af_inet.mc_ttl = 1; - sk->protinfo.af_inet.mc_index = 0; - sk->protinfo.af_inet.mc_list = NULL; + IP_SK(sk)->mc_loop = 1; + IP_SK(sk)->mc_ttl = 1; + IP_SK(sk)->mc_index = 0; + IP_SK(sk)->mc_list = NULL; #ifdef INET_REFCNT_DEBUG atomic_inc(&inet_sock_nr); @@ -495,7 +495,7 @@ * is temporarily down) */ if (sysctl_ip_nonlocal_bind == 0 && - sk->protinfo.af_inet.freebind == 0 && + IP_SK(sk)->freebind == 0 && addr->sin_addr.s_addr != INADDR_ANY && chk_addr_ret != RTN_LOCAL && chk_addr_ret != RTN_MULTICAST && @@ -992,8 +992,10 @@ }; struct net_proto_family inet_family_ops = { - family: PF_INET, - create: inet_create + family: PF_INET, + create: inet_create, + sk_size: sizeof(struct sock) + sizeof(struct tcp_opt) + + sizeof(struct inet_opt), }; @@ -1120,6 +1122,15 @@ return -EINVAL; } + /* allocate our sock slab cache */ + + inet_family_ops.sk_cachep = kmem_cache_create("inet_sock", + inet_family_ops.sk_size, + 0, SLAB_HWCACHE_ALIGN, + 0, 0); + if (!inet_family_ops.sk_cachep) + printk(KERN_CRIT __FUNCTION__ + ": Cannot create inet_sock SLAB cache!\n"); /* * Tell SOCKET that we are alive... */ diff -uNr linux-2.5.1/net/ipv4/icmp.c linux-2.5.1.acme/net/ipv4/icmp.c --- linux-2.5.1/net/ipv4/icmp.c Wed Nov 7 20:39:36 2001 +++ linux-2.5.1.acme/net/ipv4/icmp.c Wed Dec 19 23:44:47 2001 @@ -353,7 +353,7 @@ icmp_param->csum=0; icmp_out_count(icmp_param->data.icmph.type); - sk->protinfo.af_inet.tos = skb->nh.iph->tos; + IP_SK(sk)->tos = skb->nh.iph->tos; daddr = ipc.addr = rt->rt_src; ipc.opt = NULL; if (icmp_param->replyopts.optlen) { @@ -497,7 +497,7 @@ icmp_param.skb=skb_in; icmp_param.offset=skb_in->nh.raw - skb_in->data; icmp_out_count(icmp_param.data.icmph.type); - icmp_socket->sk->protinfo.af_inet.tos = tos; + IP_SK(icmp_socket->sk)->tos = tos; ipc.addr = iph->saddr; ipc.opt = &icmp_param.replyopts; if (icmp_param.replyopts.srr) { @@ -996,8 +996,8 @@ panic("Failed to create the ICMP control socket.\n"); icmp_socket->sk->allocation=GFP_ATOMIC; icmp_socket->sk->sndbuf = SK_WMEM_MAX*2; - icmp_socket->sk->protinfo.af_inet.ttl = MAXTTL; - icmp_socket->sk->protinfo.af_inet.pmtudisc = IP_PMTUDISC_DONT; + IP_SK(icmp_socket->sk)->ttl = MAXTTL; + IP_SK(icmp_socket->sk)->pmtudisc = IP_PMTUDISC_DONT; /* Unhash it so that IP input processing does not even * see it, we do not wish this socket to see incoming diff -uNr linux-2.5.1/net/ipv4/igmp.c linux-2.5.1.acme/net/ipv4/igmp.c --- linux-2.5.1/net/ipv4/igmp.c Sat Jul 28 16:12:38 2001 +++ linux-2.5.1.acme/net/ipv4/igmp.c Wed Dec 19 23:44:47 2001 @@ -668,7 +668,7 @@ iml = (struct ip_mc_socklist *)sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL); err = -EADDRINUSE; - for (i=sk->protinfo.af_inet.mc_list; i; i=i->next) { + for (i=IP_SK(sk)->mc_list; i; i=i->next) { if (memcmp(&i->multi, imr, sizeof(*imr)) == 0) { /* New style additions are reference counted */ if (imr->imr_address.s_addr == 0) { @@ -683,9 +683,9 @@ if (iml == NULL || count >= sysctl_igmp_max_memberships) goto done; memcpy(&iml->multi, imr, sizeof(*imr)); - iml->next = sk->protinfo.af_inet.mc_list; + iml->next = IP_SK(sk)->mc_list; iml->count = 1; - sk->protinfo.af_inet.mc_list = iml; + IP_SK(sk)->mc_list = iml; ip_mc_inc_group(in_dev, addr); iml = NULL; err = 0; @@ -706,7 +706,7 @@ struct ip_mc_socklist *iml, **imlp; rtnl_lock(); - for (imlp=&sk->protinfo.af_inet.mc_list; (iml=*imlp)!=NULL; imlp=&iml->next) { + for (imlp=&IP_SK(sk)->mc_list; (iml=*imlp)!=NULL; imlp=&iml->next) { if (iml->multi.imr_multiaddr.s_addr==imr->imr_multiaddr.s_addr && iml->multi.imr_address.s_addr==imr->imr_address.s_addr && (!imr->imr_ifindex || iml->multi.imr_ifindex==imr->imr_ifindex)) { @@ -740,13 +740,13 @@ { struct ip_mc_socklist *iml; - if (sk->protinfo.af_inet.mc_list == NULL) + if (IP_SK(sk)->mc_list == NULL) return; rtnl_lock(); - while ((iml=sk->protinfo.af_inet.mc_list) != NULL) { + while ((iml=IP_SK(sk)->mc_list) != NULL) { struct in_device *in_dev; - sk->protinfo.af_inet.mc_list = iml->next; + IP_SK(sk)->mc_list = iml->next; if ((in_dev = inetdev_by_index(iml->multi.imr_ifindex)) != NULL) { ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr); diff -uNr linux-2.5.1/net/ipv4/ip_output.c linux-2.5.1.acme/net/ipv4/ip_output.c --- linux-2.5.1/net/ipv4/ip_output.c Wed Oct 17 19:16:39 2001 +++ linux-2.5.1.acme/net/ipv4/ip_output.c Wed Dec 19 23:44:47 2001 @@ -133,11 +133,11 @@ iph->version = 4; iph->ihl = 5; - iph->tos = sk->protinfo.af_inet.tos; + iph->tos = IP_SK(sk)->tos; iph->frag_off = 0; if (ip_dont_fragment(sk, &rt->u.dst)) iph->frag_off |= htons(IP_DF); - iph->ttl = sk->protinfo.af_inet.ttl; + iph->ttl = IP_SK(sk)->ttl; iph->daddr = rt->rt_dst; iph->saddr = rt->rt_src; iph->protocol = sk->protocol; @@ -214,7 +214,7 @@ */ if (rt->rt_flags&RTCF_MULTICAST) { - if ((!sk || sk->protinfo.af_inet.mc_loop) + if ((!sk || IP_SK(sk)->mc_loop) #ifdef CONFIG_IP_MROUTE /* Small optimization: do not loopback not local frames, which returned after forwarding; they will be dropped @@ -341,7 +341,7 @@ int ip_queue_xmit(struct sk_buff *skb) { struct sock *sk = skb->sk; - struct ip_options *opt = sk->protinfo.af_inet.opt; + struct ip_options *opt = IP_SK(sk)->opt; struct rtable *rt; struct iphdr *iph; @@ -381,10 +381,10 @@ /* OK, we know where to send it, allocate and build IP header. */ iph = (struct iphdr *) skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0)); - *((__u16 *)iph) = htons((4 << 12) | (5 << 8) | (sk->protinfo.af_inet.tos & 0xff)); + *((__u16 *)iph) = htons((4 << 12) | (5 << 8) | (IP_SK(sk)->tos & 0xff)); iph->tot_len = htons(skb->len); iph->frag_off = 0; - iph->ttl = sk->protinfo.af_inet.ttl; + iph->ttl = IP_SK(sk)->ttl; iph->protocol = sk->protocol; iph->saddr = rt->rt_src; iph->daddr = rt->rt_dst; @@ -499,7 +499,7 @@ * Don't fragment packets for path mtu discovery. */ - if (offset > 0 && sk->protinfo.af_inet.pmtudisc==IP_PMTUDISC_DO) { + if (offset > 0 && IP_SK(sk)->pmtudisc==IP_PMTUDISC_DO) { ip_local_error(sk, EMSGSIZE, rt->rt_dst, sk->dport, mtu); return -EMSGSIZE; } @@ -510,7 +510,7 @@ * Begin outputting the bytes. */ - id = sk->protinfo.af_inet.id++; + id = IP_SK(sk)->id++; do { char *data; @@ -553,7 +553,7 @@ ip_options_build(skb, opt, ipc->addr, rt, offset); } - iph->tos = sk->protinfo.af_inet.tos; + iph->tos = IP_SK(sk)->tos; iph->tot_len = htons(fraglen - fragheaderlen + iph->ihl*4); iph->frag_off = htons(offset>>3)|mf|df; iph->id = id; @@ -573,9 +573,9 @@ mf = htons(IP_MF); } if (rt->rt_type == RTN_MULTICAST) - iph->ttl = sk->protinfo.af_inet.mc_ttl; + iph->ttl = IP_SK(sk)->mc_ttl; else - iph->ttl = sk->protinfo.af_inet.ttl; + iph->ttl = IP_SK(sk)->ttl; iph->protocol = sk->protocol; iph->check = 0; iph->saddr = rt->rt_src; @@ -603,7 +603,7 @@ skb->dst->dev, output_maybe_reroute); if (err) { if (err > 0) - err = sk->protinfo.af_inet.recverr ? net_xmit_errno(err) : 0; + err = IP_SK(sk)->recverr ? net_xmit_errno(err) : 0; if (err) goto error; } @@ -645,7 +645,7 @@ * choice RAW frames within 20 bytes of maximum size(rare) to the long path */ - if (!sk->protinfo.af_inet.hdrincl) { + if (!IP_SK(sk)->hdrincl) { length += sizeof(struct iphdr); /* @@ -687,16 +687,16 @@ skb->nh.iph = iph = (struct iphdr *)skb_put(skb, length); - if(!sk->protinfo.af_inet.hdrincl) { + if(!IP_SK(sk)->hdrincl) { iph->version=4; iph->ihl=5; - iph->tos=sk->protinfo.af_inet.tos; + iph->tos=IP_SK(sk)->tos; iph->tot_len = htons(length); iph->frag_off = df; - iph->ttl=sk->protinfo.af_inet.mc_ttl; + iph->ttl=IP_SK(sk)->mc_ttl; ip_select_ident(iph, &rt->u.dst, sk); if (rt->rt_type != RTN_MULTICAST) - iph->ttl=sk->protinfo.af_inet.ttl; + iph->ttl=IP_SK(sk)->ttl; iph->protocol=sk->protocol; iph->saddr=rt->rt_src; iph->daddr=rt->rt_dst; @@ -713,7 +713,7 @@ err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev, output_maybe_reroute); if (err > 0) - err = sk->protinfo.af_inet.recverr ? net_xmit_errno(err) : 0; + err = IP_SK(sk)->recverr ? net_xmit_errno(err) : 0; if (err) goto error; out: @@ -974,7 +974,7 @@ with locally disabled BH and that sk cannot be already spinlocked. */ bh_lock_sock(sk); - sk->protinfo.af_inet.tos = skb->nh.iph->tos; + IP_SK(sk)->tos = skb->nh.iph->tos; sk->priority = skb->priority; sk->protocol = skb->nh.iph->protocol; ip_build_xmit(sk, ip_reply_glue_bits, arg, len, &ipc, rt, MSG_DONTWAIT); diff -uNr linux-2.5.1/net/ipv4/ip_sockglue.c linux-2.5.1.acme/net/ipv4/ip_sockglue.c --- linux-2.5.1/net/ipv4/ip_sockglue.c Tue Oct 30 21:08:12 2001 +++ linux-2.5.1.acme/net/ipv4/ip_sockglue.c Wed Dec 19 23:44:47 2001 @@ -110,7 +110,7 @@ void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb) { - unsigned flags = skb->sk->protinfo.af_inet.cmsg_flags; + unsigned flags = IP_SK(skb->sk)->cmsg_flags; /* Ordered by supposed usage frequency */ if (flags & 1) @@ -236,7 +236,7 @@ { struct sock_exterr_skb *serr; - if (!sk->protinfo.af_inet.recverr) + if (!IP_SK(sk)->recverr) return; skb = skb_clone(skb, GFP_ATOMIC); @@ -266,7 +266,7 @@ struct iphdr *iph; struct sk_buff *skb; - if (!sk->protinfo.af_inet.recverr) + if (!IP_SK(sk)->recverr) return; skb = alloc_skb(sizeof(struct iphdr), GFP_ATOMIC); @@ -344,7 +344,7 @@ sin->sin_addr.s_addr = skb->nh.iph->saddr; sin->sin_port = 0; memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); - if (sk->protinfo.af_inet.cmsg_flags) + if (IP_SK(sk)->cmsg_flags) ip_cmsg_recv(msg, skb); } @@ -425,7 +425,7 @@ if (err) break; if (sk->type == SOCK_STREAM) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) if (sk->family == PF_INET || (!((1<state)&(TCPF_LISTEN|TCPF_CLOSE)) @@ -438,53 +438,53 @@ } #endif } - opt = xchg(&sk->protinfo.af_inet.opt, opt); + opt = xchg(&IP_SK(sk)->opt, opt); if (opt) kfree(opt); break; } case IP_PKTINFO: if (val) - sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_PKTINFO; + IP_SK(sk)->cmsg_flags |= IP_CMSG_PKTINFO; else - sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_PKTINFO; + IP_SK(sk)->cmsg_flags &= ~IP_CMSG_PKTINFO; break; case IP_RECVTTL: if (val) - sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_TTL; + IP_SK(sk)->cmsg_flags |= IP_CMSG_TTL; else - sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_TTL; + IP_SK(sk)->cmsg_flags &= ~IP_CMSG_TTL; break; case IP_RECVTOS: if (val) - sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_TOS; + IP_SK(sk)->cmsg_flags |= IP_CMSG_TOS; else - sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_TOS; + IP_SK(sk)->cmsg_flags &= ~IP_CMSG_TOS; break; case IP_RECVOPTS: if (val) - sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_RECVOPTS; + IP_SK(sk)->cmsg_flags |= IP_CMSG_RECVOPTS; else - sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_RECVOPTS; + IP_SK(sk)->cmsg_flags &= ~IP_CMSG_RECVOPTS; break; case IP_RETOPTS: if (val) - sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_RETOPTS; + IP_SK(sk)->cmsg_flags |= IP_CMSG_RETOPTS; else - sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_RETOPTS; + IP_SK(sk)->cmsg_flags &= ~IP_CMSG_RETOPTS; break; case IP_TOS: /* This sets both TOS and Precedence */ if (sk->type == SOCK_STREAM) { val &= ~3; - val |= sk->protinfo.af_inet.tos & 3; + val |= IP_SK(sk)->tos & 3; } if (IPTOS_PREC(val) >= IPTOS_PREC_CRITIC_ECP && !capable(CAP_NET_ADMIN)) { err = -EPERM; break; } - if (sk->protinfo.af_inet.tos != val) { - sk->protinfo.af_inet.tos=val; + if (IP_SK(sk)->tos != val) { + IP_SK(sk)->tos=val; sk->priority = rt_tos2priority(val); sk_dst_reset(sk); } @@ -496,22 +496,22 @@ val = sysctl_ip_default_ttl; if(val<1||val>255) goto e_inval; - sk->protinfo.af_inet.ttl=val; + IP_SK(sk)->ttl=val; break; case IP_HDRINCL: if(sk->type!=SOCK_RAW) { err = -ENOPROTOOPT; break; } - sk->protinfo.af_inet.hdrincl=val?1:0; + IP_SK(sk)->hdrincl=val?1:0; break; case IP_MTU_DISCOVER: if (val<0 || val>2) goto e_inval; - sk->protinfo.af_inet.pmtudisc = val; + IP_SK(sk)->pmtudisc = val; break; case IP_RECVERR: - sk->protinfo.af_inet.recverr = !!val; + IP_SK(sk)->recverr = !!val; if (!val) skb_queue_purge(&sk->error_queue); break; @@ -524,12 +524,12 @@ val = 1; if (val < 0 || val > 255) goto e_inval; - sk->protinfo.af_inet.mc_ttl=val; + IP_SK(sk)->mc_ttl=val; break; case IP_MULTICAST_LOOP: if (optlen<1) goto e_inval; - sk->protinfo.af_inet.mc_loop = val ? 1 : 0; + IP_SK(sk)->mc_loop = val ? 1 : 0; break; case IP_MULTICAST_IF: { @@ -555,8 +555,8 @@ if (!mreq.imr_ifindex) { if (mreq.imr_address.s_addr == INADDR_ANY) { - sk->protinfo.af_inet.mc_index = 0; - sk->protinfo.af_inet.mc_addr = 0; + IP_SK(sk)->mc_index = 0; + IP_SK(sk)->mc_addr = 0; err = 0; break; } @@ -577,8 +577,8 @@ if (sk->bound_dev_if && mreq.imr_ifindex != sk->bound_dev_if) break; - sk->protinfo.af_inet.mc_index = mreq.imr_ifindex; - sk->protinfo.af_inet.mc_addr = mreq.imr_address.s_addr; + IP_SK(sk)->mc_index = mreq.imr_ifindex; + IP_SK(sk)->mc_addr = mreq.imr_address.s_addr; err = 0; break; } @@ -613,7 +613,7 @@ case IP_FREEBIND: if (optlen<1) goto e_inval; - sk->protinfo.af_inet.freebind = !!val; + IP_SK(sk)->freebind = !!val; break; default: @@ -666,10 +666,10 @@ unsigned char optbuf[sizeof(struct ip_options)+40]; struct ip_options * opt = (struct ip_options*)optbuf; opt->optlen = 0; - if (sk->protinfo.af_inet.opt) - memcpy(optbuf, sk->protinfo.af_inet.opt, + if (IP_SK(sk)->opt) + memcpy(optbuf, IP_SK(sk)->opt, sizeof(struct ip_options)+ - sk->protinfo.af_inet.opt->optlen); + IP_SK(sk)->opt->optlen); release_sock(sk); if (opt->optlen == 0) @@ -685,31 +685,31 @@ return 0; } case IP_PKTINFO: - val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_PKTINFO) != 0; + val = (IP_SK(sk)->cmsg_flags & IP_CMSG_PKTINFO) != 0; break; case IP_RECVTTL: - val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_TTL) != 0; + val = (IP_SK(sk)->cmsg_flags & IP_CMSG_TTL) != 0; break; case IP_RECVTOS: - val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_TOS) != 0; + val = (IP_SK(sk)->cmsg_flags & IP_CMSG_TOS) != 0; break; case IP_RECVOPTS: - val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_RECVOPTS) != 0; + val = (IP_SK(sk)->cmsg_flags & IP_CMSG_RECVOPTS) != 0; break; case IP_RETOPTS: - val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_RETOPTS) != 0; + val = (IP_SK(sk)->cmsg_flags & IP_CMSG_RETOPTS) != 0; break; case IP_TOS: - val=sk->protinfo.af_inet.tos; + val=IP_SK(sk)->tos; break; case IP_TTL: - val=sk->protinfo.af_inet.ttl; + val=IP_SK(sk)->ttl; break; case IP_HDRINCL: - val=sk->protinfo.af_inet.hdrincl; + val=IP_SK(sk)->hdrincl; break; case IP_MTU_DISCOVER: - val=sk->protinfo.af_inet.pmtudisc; + val=IP_SK(sk)->pmtudisc; break; case IP_MTU: { @@ -727,19 +727,19 @@ break; } case IP_RECVERR: - val=sk->protinfo.af_inet.recverr; + val=IP_SK(sk)->recverr; break; case IP_MULTICAST_TTL: - val=sk->protinfo.af_inet.mc_ttl; + val=IP_SK(sk)->mc_ttl; break; case IP_MULTICAST_LOOP: - val=sk->protinfo.af_inet.mc_loop; + val=IP_SK(sk)->mc_loop; break; case IP_MULTICAST_IF: { struct in_addr addr; len = min_t(unsigned int, len, sizeof(struct in_addr)); - addr.s_addr = sk->protinfo.af_inet.mc_addr; + addr.s_addr = IP_SK(sk)->mc_addr; release_sock(sk); if(put_user(len, optlen)) @@ -761,23 +761,23 @@ msg.msg_controllen = len; msg.msg_flags = 0; - if (sk->protinfo.af_inet.cmsg_flags&IP_CMSG_PKTINFO) { + if (IP_SK(sk)->cmsg_flags&IP_CMSG_PKTINFO) { struct in_pktinfo info; info.ipi_addr.s_addr = sk->rcv_saddr; info.ipi_spec_dst.s_addr = sk->rcv_saddr; - info.ipi_ifindex = sk->protinfo.af_inet.mc_index; + info.ipi_ifindex = IP_SK(sk)->mc_index; put_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info); } - if (sk->protinfo.af_inet.cmsg_flags&IP_CMSG_TTL) { - int hlim = sk->protinfo.af_inet.mc_ttl; + if (IP_SK(sk)->cmsg_flags&IP_CMSG_TTL) { + int hlim = IP_SK(sk)->mc_ttl; put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim); } len -= msg.msg_controllen; return put_user(len, optlen); } case IP_FREEBIND: - val = sk->protinfo.af_inet.freebind; + val = IP_SK(sk)->freebind; break; default: #ifdef CONFIG_NETFILTER diff -uNr linux-2.5.1/net/ipv4/ipconfig.c linux-2.5.1.acme/net/ipv4/ipconfig.c --- linux-2.5.1/net/ipv4/ipconfig.c Wed Dec 19 23:27:58 2001 +++ linux-2.5.1.acme/net/ipv4/ipconfig.c Wed Dec 19 23:44:47 2001 @@ -53,7 +53,7 @@ #include #include -#include +#include #include /* Define this to allow debugging output */ diff -uNr linux-2.5.1/net/ipv4/netfilter/ip_conntrack_core.c linux-2.5.1.acme/net/ipv4/netfilter/ip_conntrack_core.c --- linux-2.5.1/net/ipv4/netfilter/ip_conntrack_core.c Tue Aug 7 12:30:50 2001 +++ linux-2.5.1.acme/net/ipv4/netfilter/ip_conntrack_core.c Wed Dec 19 23:44:48 2001 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff -uNr linux-2.5.1/net/ipv4/netfilter/ip_nat_snmp_basic.c linux-2.5.1.acme/net/ipv4/netfilter/ip_nat_snmp_basic.c --- linux-2.5.1/net/ipv4/netfilter/ip_nat_snmp_basic.c Tue Oct 30 21:08:12 2001 +++ linux-2.5.1.acme/net/ipv4/netfilter/ip_nat_snmp_basic.c Wed Dec 19 23:44:48 2001 @@ -52,10 +52,11 @@ #include #include #include +#include #include #include #include -#include +#include diff -uNr linux-2.5.1/net/ipv4/netfilter/ip_nat_standalone.c linux-2.5.1.acme/net/ipv4/netfilter/ip_nat_standalone.c --- linux-2.5.1/net/ipv4/netfilter/ip_nat_standalone.c Sun Sep 30 16:26:08 2001 +++ linux-2.5.1.acme/net/ipv4/netfilter/ip_nat_standalone.c Wed Dec 19 23:44:48 2001 @@ -9,6 +9,7 @@ #include #include +#include #include #include #include diff -uNr linux-2.5.1/net/ipv4/raw.c linux-2.5.1.acme/net/ipv4/raw.c --- linux-2.5.1/net/ipv4/raw.c Tue Jul 10 20:11:43 2001 +++ linux-2.5.1.acme/net/ipv4/raw.c Wed Dec 19 23:44:47 2001 @@ -122,7 +122,7 @@ type = skb->h.icmph->type; if (type < 32) { - __u32 data = sk->tp_pinfo.tp_raw4.filter.data; + __u32 data = RAW4_PINFO(sk)->filter.data; return ((1 << type) & data) != 0; } @@ -186,7 +186,7 @@ 2. Socket is connected (otherwise the error indication is useless without ip_recverr and error is hard. */ - if (!sk->protinfo.af_inet.recverr && sk->state != TCP_ESTABLISHED) + if (!IP_SK(sk)->recverr && sk->state != TCP_ESTABLISHED) return; switch (type) { @@ -207,22 +207,22 @@ err = icmp_err_convert[code].errno; harderr = icmp_err_convert[code].fatal; if (code == ICMP_FRAG_NEEDED) { - harderr = sk->protinfo.af_inet.pmtudisc != + harderr = IP_SK(sk)->pmtudisc != IP_PMTUDISC_DONT; err = EMSGSIZE; } } - if (sk->protinfo.af_inet.recverr) { + if (IP_SK(sk)->recverr) { struct iphdr *iph = (struct iphdr*)skb->data; u8 *payload = skb->data + (iph->ihl << 2); - if (sk->protinfo.af_inet.hdrincl) + if (IP_SK(sk)->hdrincl) payload = skb->data; ip_icmp_error(sk, skb, err, 0, info, payload); } - if (sk->protinfo.af_inet.recverr || harderr) { + if (IP_SK(sk)->recverr || harderr) { sk->err = err; sk->error_report(sk); } @@ -382,14 +382,14 @@ ipc.addr = daddr; if (!ipc.opt) - ipc.opt = sk->protinfo.af_inet.opt; + ipc.opt = IP_SK(sk)->opt; if (ipc.opt) { err = -EINVAL; /* Linux does not mangle headers on raw sockets, * so that IP options + IP_HDRINCL is non-sense. */ - if (sk->protinfo.af_inet.hdrincl) + if (IP_SK(sk)->hdrincl) goto done; if (ipc.opt->srr) { if (!daddr) @@ -397,15 +397,15 @@ daddr = ipc.opt->faddr; } } - tos = RT_TOS(sk->protinfo.af_inet.tos) | sk->localroute; + tos = RT_TOS(IP_SK(sk)->tos) | sk->localroute; if (msg->msg_flags & MSG_DONTROUTE) tos |= RTO_ONLINK; if (MULTICAST(daddr)) { if (!ipc.oif) - ipc.oif = sk->protinfo.af_inet.mc_index; + ipc.oif = IP_SK(sk)->mc_index; if (!rfh.saddr) - rfh.saddr = sk->protinfo.af_inet.mc_addr; + rfh.saddr = IP_SK(sk)->mc_addr; } err = ip_route_output(&rt, daddr, rfh.saddr, tos, ipc.oif); @@ -426,7 +426,7 @@ rfh.dst = &rt->u.dst; if (!ipc.addr) ipc.addr = rt->rt_dst; - err = ip_build_xmit(sk, sk->protinfo.af_inet.hdrincl ? raw_getrawfrag : + err = ip_build_xmit(sk, IP_SK(sk)->hdrincl ? raw_getrawfrag : raw_getfrag, &rfh, len, &ipc, rt, msg->msg_flags); done: @@ -522,7 +522,7 @@ sin->sin_addr.s_addr = skb->nh.iph->saddr; memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); } - if (sk->protinfo.af_inet.cmsg_flags) + if (IP_SK(sk)->cmsg_flags) ip_cmsg_recv(msg, skb); done: skb_free_datagram(sk, skb); @@ -531,7 +531,7 @@ static int raw_init(struct sock *sk) { - struct raw_opt *tp = &(sk->tp_pinfo.tp_raw4); + struct raw_opt *tp = RAW4_PINFO(sk); if (sk->num == IPPROTO_ICMP) memset(&tp->filter, 0, sizeof(tp->filter)); return 0; @@ -541,7 +541,7 @@ { if (optlen > sizeof(struct icmp_filter)) optlen = sizeof(struct icmp_filter); - if (copy_from_user(&sk->tp_pinfo.tp_raw4.filter, optval, optlen)) + if (copy_from_user(&RAW4_PINFO(sk)->filter, optval, optlen)) return -EFAULT; return 0; } @@ -559,7 +559,7 @@ len = sizeof(struct icmp_filter); ret = -EFAULT; if (put_user(len, optlen) || - copy_to_user(optval, &sk->tp_pinfo.tp_raw4.filter, len)) + copy_to_user(optval, &RAW4_PINFO(sk)->filter, len)) goto out; ret = 0; out: return ret; diff -uNr linux-2.5.1/net/ipv4/syncookies.c linux-2.5.1.acme/net/ipv4/syncookies.c --- linux-2.5.1/net/ipv4/syncookies.c Tue Oct 30 21:08:12 2001 +++ linux-2.5.1.acme/net/ipv4/syncookies.c Wed Dec 19 23:44:47 2001 @@ -52,7 +52,7 @@ const __u16 mss = *mssp; - sk->tp_pinfo.af_tcp.last_synq_overflow = jiffies; + TCP_PINFO(sk)->last_synq_overflow = jiffies; /* XXX sort msstab[] by probability? Binary search? */ for (mssind = 0; mss > msstab[mssind + 1]; mssind++) @@ -98,7 +98,7 @@ struct open_request *req, struct dst_entry *dst) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sock *child; child = tp->af_specific->syn_recv_sock(sk, skb, req, dst); @@ -123,7 +123,7 @@ if (!sysctl_tcp_syncookies || !skb->h.th->ack) goto out; - if (time_after(jiffies, sk->tp_pinfo.af_tcp.last_synq_overflow + TCP_TIMEOUT_INIT) || + if (time_after(jiffies, TCP_PINFO(sk)->last_synq_overflow + TCP_TIMEOUT_INIT) || (mss = cookie_check(skb, cookie)) == 0) { NET_INC_STATS_BH(SyncookiesFailed); goto out; diff -uNr linux-2.5.1/net/ipv4/tcp.c linux-2.5.1.acme/net/ipv4/tcp.c --- linux-2.5.1/net/ipv4/tcp.c Tue Oct 30 21:08:12 2001 +++ linux-2.5.1.acme/net/ipv4/tcp.c Wed Dec 19 23:44:48 2001 @@ -363,7 +363,7 @@ */ static __inline__ unsigned int tcp_listen_poll(struct sock *sk, poll_table *wait) { - return sk->tp_pinfo.af_tcp.accept_queue ? (POLLIN | POLLRDNORM) : 0; + return TCP_PINFO(sk)->accept_queue ? (POLLIN | POLLRDNORM) : 0; } /* @@ -377,7 +377,7 @@ { unsigned int mask; struct sock *sk = sock->sk; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); poll_wait(file, sk->sleep, wait); if (sk->state == TCP_LISTEN) @@ -477,7 +477,7 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int answ; switch(cmd) { @@ -524,7 +524,7 @@ int tcp_listen_start(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct tcp_listen_opt *lopt; sk->max_ack_backlog = 0; @@ -576,7 +576,7 @@ static void tcp_listen_stop (struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct tcp_listen_opt *lopt = tp->listen_opt; struct open_request *acc_req = tp->accept_queue; struct open_request *req; @@ -663,7 +663,7 @@ __set_task_state(tsk, TASK_INTERRUPTIBLE); add_wait_queue(sk->sleep, &wait); - sk->tp_pinfo.af_tcp.write_pending++; + TCP_PINFO(sk)->write_pending++; release_sock(sk); *timeo_p = schedule_timeout(*timeo_p); @@ -671,7 +671,7 @@ __set_task_state(tsk, TASK_RUNNING); remove_wait_queue(sk->sleep, &wait); - sk->tp_pinfo.af_tcp.write_pending--; + TCP_PINFO(sk)->write_pending--; } return 0; } @@ -711,12 +711,12 @@ break; set_bit(SOCK_NOSPACE, &sk->socket->flags); - sk->tp_pinfo.af_tcp.write_pending++; + TCP_PINFO(sk)->write_pending++; release_sock(sk); if (!tcp_memory_free(sk) || vm_wait) current_timeo = schedule_timeout(current_timeo); lock_sock(sk); - sk->tp_pinfo.af_tcp.write_pending--; + TCP_PINFO(sk)->write_pending--; if (vm_wait) { vm_wait -= current_timeo; @@ -825,7 +825,7 @@ ssize_t do_tcp_sendpages(struct sock *sk, struct page **pages, int poffset, size_t psize, int flags) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int mss_now; int err; ssize_t copied; @@ -950,8 +950,8 @@ return res; } -#define TCP_PAGE(sk) (sk->tp_pinfo.af_tcp.sndmsg_page) -#define TCP_OFF(sk) (sk->tp_pinfo.af_tcp.sndmsg_off) +#define TCP_PAGE(sk) (TCP_PINFO(sk)->sndmsg_page) +#define TCP_OFF(sk) (TCP_PINFO(sk)->sndmsg_off) static inline int tcp_copy_to_page(struct sock *sk, char *from, struct sk_buff *skb, @@ -1015,7 +1015,7 @@ int err, copied; long timeo; - tp = &(sk->tp_pinfo.af_tcp); + tp = TCP_PINFO(sk); lock_sock(sk); TCP_CHECK_TIMER(sk); @@ -1216,7 +1216,7 @@ struct msghdr *msg, int len, int flags, int *addr_len) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); /* No URG data to read. */ if (sk->urginline || !tp->urg_data || tp->urg_data == TCP_URG_READ) @@ -1277,7 +1277,7 @@ */ static void cleanup_rbuf(struct sock *sk, int copied) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int time_to_ack = 0; #if TCP_DEBUG @@ -1362,7 +1362,7 @@ static void tcp_prequeue_process(struct sock *sk) { struct sk_buff *skb; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); net_statistics[smp_processor_id()*2+1].TCPPrequeued += skb_queue_len(&tp->ucopy.prequeue); @@ -1387,7 +1387,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, int len, int nonblock, int flags, int *addr_len) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int copied = 0; u32 peek_seq; u32 *seq; @@ -1936,7 +1936,7 @@ */ if (sk->state == TCP_FIN_WAIT2) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (tp->linger2 < 0) { tcp_set_state(sk, TCP_CLOSE); tcp_send_active_reset(sk, GFP_ATOMIC); @@ -1988,7 +1988,7 @@ int tcp_disconnect(struct sock *sk, int flags) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); int old_state; int err = 0; @@ -2021,8 +2021,10 @@ sk->rcv_saddr = 0; sk->saddr = 0; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) - memset(&sk->net_pinfo.af_inet6.saddr, 0, 16); - memset(&sk->net_pinfo.af_inet6.rcv_saddr, 0, 16); + if (sk->family == PF_INET6) { + memset(&IP6_PINFO(sk)->saddr, 0, 16); + memset(&IP6_PINFO(sk)->rcv_saddr, 0, 16); + } #endif } @@ -2078,11 +2080,11 @@ for (;;) { current->state = TASK_INTERRUPTIBLE; release_sock(sk); - if (sk->tp_pinfo.af_tcp.accept_queue == NULL) + if (TCP_PINFO(sk)->accept_queue == NULL) timeo = schedule_timeout(timeo); lock_sock(sk); err = 0; - if (sk->tp_pinfo.af_tcp.accept_queue) + if (TCP_PINFO(sk)->accept_queue) break; err = -EINVAL; if (sk->state != TCP_LISTEN) @@ -2105,7 +2107,7 @@ struct sock *tcp_accept(struct sock *sk, int flags, int *err) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); struct open_request *req; struct sock *newsk; int error; @@ -2157,7 +2159,7 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int val; int err = 0; @@ -2316,7 +2318,7 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int val, len; if(level != SOL_TCP) diff -uNr linux-2.5.1/net/ipv4/tcp_input.c linux-2.5.1.acme/net/ipv4/tcp_input.c --- linux-2.5.1/net/ipv4/tcp_input.c Wed Dec 19 23:27:58 2001 +++ linux-2.5.1.acme/net/ipv4/tcp_input.c Wed Dec 19 23:44:48 2001 @@ -190,7 +190,7 @@ static void tcp_fixup_sndbuf(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int sndmem = tp->mss_clamp+MAX_TCP_HEADER+16+sizeof(struct sk_buff); if (sk->sndbuf < 3*sndmem) @@ -268,7 +268,7 @@ static void tcp_fixup_rcvbuf(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int rcvmem = tp->advmss+MAX_TCP_HEADER+16+sizeof(struct sk_buff); /* Try to select rcvbuf so that 4 mss-sized segments @@ -286,7 +286,7 @@ */ static void tcp_init_buffer_space(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int maxwin; if (!(sk->userlocks&SOCK_RCVBUF_LOCK)) @@ -512,7 +512,7 @@ */ void tcp_update_metrics(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct dst_entry *dst = __sk_dst_get(sk); dst_confirm(dst); @@ -620,7 +620,7 @@ static void tcp_init_metrics(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct dst_entry *dst = __sk_dst_get(sk); if (dst == NULL) @@ -762,7 +762,7 @@ static int tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_una) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); unsigned char *ptr = ack_skb->h.raw + TCP_SKB_CB(ack_skb)->sacked; struct tcp_sack_block *sp = (struct tcp_sack_block *)(ptr+2); int num_sacks = (ptr[1] - TCPOLEN_SACK_BASE)>>3; @@ -977,7 +977,7 @@ */ void tcp_enter_loss(struct sock *sk, int how) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb; int cnt = 0; @@ -1493,7 +1493,7 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, int prior_packets, int flag) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int is_dupack = (tp->snd_una == prior_snd_una && !(flag&FLAG_NOT_DUP)); /* Some technical things: @@ -1735,7 +1735,7 @@ /* Remove acknowledged frames from the retransmission queue. */ static int tcp_clean_rtx_queue(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb; __u32 now = tcp_time_stamp; int acked = 0; @@ -1820,7 +1820,7 @@ static void tcp_ack_probe(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); /* Was it a usable window open? */ @@ -1897,7 +1897,7 @@ /* This routine deals with incoming acks, but not outgoing ones. */ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); u32 prior_snd_una = tp->snd_una; u32 ack_seq = TCP_SKB_CB(skb)->seq; u32 ack = TCP_SKB_CB(skb)->ack_seq; @@ -2230,7 +2230,7 @@ */ static void tcp_fin(struct sk_buff *skb, struct sock *sk, struct tcphdr *th) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); tcp_schedule_ack(tp); @@ -2333,7 +2333,7 @@ static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { @@ -2396,7 +2396,7 @@ static void tcp_sack_new_ofo_skb(struct sock *sk, u32 seq, u32 end_seq) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct tcp_sack_block *sp = &tp->selective_acks[0]; int cur_sacks = tp->num_sacks; int this_sack; @@ -2480,7 +2480,7 @@ */ static void tcp_ofo_queue(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); __u32 dsack_high = tp->rcv_nxt; struct sk_buff *skb; @@ -2524,7 +2524,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) { struct tcphdr *th = skb->h.th; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int eaten = -1; if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq) @@ -2828,7 +2828,7 @@ */ static void tcp_collapse_ofo_queue(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb = skb_peek(&tp->out_of_order_queue); struct sk_buff *head; u32 start, end; @@ -2873,7 +2873,7 @@ */ static int tcp_prune_queue(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); SOCK_DEBUG(sk, "prune_queue: c=%x\n", tp->copied_seq); @@ -2932,7 +2932,7 @@ */ void tcp_cwnd_application_limited(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (tp->ca_state == TCP_CA_Open && sk->socket && !test_bit(SOCK_NOSPACE, &sk->socket->flags)) { @@ -2954,7 +2954,7 @@ */ static void tcp_new_space(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (tp->packets_out < tp->snd_cwnd && !(sk->userlocks&SOCK_SNDBUF_LOCK) && @@ -2975,7 +2975,7 @@ static inline void tcp_check_space(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (tp->queue_shrunk) { tp->queue_shrunk = 0; @@ -2986,7 +2986,7 @@ static void __tcp_data_snd_check(struct sock *sk, struct sk_buff *skb) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (after(TCP_SKB_CB(skb)->end_seq, tp->snd_una + tp->snd_wnd) || tcp_packets_in_flight(tp) >= tp->snd_cwnd || @@ -2996,7 +2996,7 @@ static __inline__ void tcp_data_snd_check(struct sock *sk) { - struct sk_buff *skb = sk->tp_pinfo.af_tcp.send_head; + struct sk_buff *skb = TCP_PINFO(sk)->send_head; if (skb != NULL) __tcp_data_snd_check(sk, skb); @@ -3008,7 +3008,7 @@ */ static __inline__ void __tcp_ack_snd_check(struct sock *sk, int ofo_possible) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); /* More than one full frame received... */ if (((tp->rcv_nxt - tp->rcv_wup) > tp->ack.rcv_mss @@ -3031,7 +3031,7 @@ static __inline__ void tcp_ack_snd_check(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (!tcp_ack_scheduled(tp)) { /* We sent a data segment already. */ return; @@ -3051,7 +3051,7 @@ static void tcp_check_urg(struct sock * sk, struct tcphdr * th) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); u32 ptr = ntohs(th->urg_ptr); if (ptr && !sysctl_tcp_stdurg) @@ -3124,7 +3124,7 @@ /* This is the 'fast' part of urgent handling. */ static inline void tcp_urg(struct sock *sk, struct sk_buff *skb, struct tcphdr *th) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); /* Check if we get a new urgent pointer - normally not. */ if (th->urg) @@ -3148,7 +3148,7 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int chunk = skb->len - hlen; int err; @@ -3223,7 +3223,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, struct tcphdr *th, unsigned len) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); /* * Header prediction. @@ -3441,7 +3441,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, struct tcphdr *th, unsigned len) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int saved_clamp = tp->mss_clamp; tcp_parse_options(skb, tp, 0); @@ -3670,7 +3670,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, struct tcphdr *th, unsigned len) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int queued = 0; tp->saw_tstamp = 0; diff -uNr linux-2.5.1/net/ipv4/tcp_ipv4.c linux-2.5.1.acme/net/ipv4/tcp_ipv4.c --- linux-2.5.1/net/ipv4/tcp_ipv4.c Mon Nov 5 15:46:12 2001 +++ linux-2.5.1.acme/net/ipv4/tcp_ipv4.c Wed Dec 19 23:44:48 2001 @@ -550,7 +550,7 @@ tw = (struct tcp_tw_bucket*)sk2; if(TCP_IPV4_MATCH(sk2, acookie, saddr, daddr, ports, dif)) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); /* With PAWS, it is safe from the viewpoint of data integrity. Even without PAWS it @@ -645,7 +645,7 @@ /* This will initiate an outgoing connection. */ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sockaddr_in *usin = (struct sockaddr_in *) uaddr; struct sk_buff *buff; struct rtable *rt; @@ -660,10 +660,10 @@ return(-EAFNOSUPPORT); nexthop = daddr = usin->sin_addr.s_addr; - if (sk->protinfo.af_inet.opt && sk->protinfo.af_inet.opt->srr) { + if (IP_SK(sk)->opt && IP_SK(sk)->opt->srr) { if (daddr == 0) return -EINVAL; - nexthop = sk->protinfo.af_inet.opt->faddr; + nexthop = IP_SK(sk)->opt->faddr; } tmp = ip_route_connect(&rt, nexthop, sk->saddr, @@ -679,7 +679,7 @@ __sk_dst_set(sk, &rt->u.dst); sk->route_caps = rt->u.dst.dev->features; - if (!sk->protinfo.af_inet.opt || !sk->protinfo.af_inet.opt->srr) + if (!IP_SK(sk)->opt || !IP_SK(sk)->opt->srr) daddr = rt->rt_dst; err = -ENOBUFS; @@ -723,9 +723,9 @@ sk->sport, usin->sin_port); tp->ext_header_len = 0; - if (sk->protinfo.af_inet.opt) - tp->ext_header_len = sk->protinfo.af_inet.opt->optlen; - sk->protinfo.af_inet.id = tp->write_seq^jiffies; + if (IP_SK(sk)->opt) + tp->ext_header_len = IP_SK(sk)->opt->optlen; + IP_SK(sk)->id = tp->write_seq^jiffies; tp->mss_clamp = 536; @@ -781,7 +781,7 @@ static void tcp_v4_synq_add(struct sock *sk, struct open_request *req) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); struct tcp_listen_opt *lopt = tp->listen_opt; unsigned h = tcp_v4_synq_hash(req->af.v4_req.rmt_addr, req->rmt_port); @@ -805,7 +805,7 @@ static inline void do_pmtu_discovery(struct sock *sk, struct iphdr *ip, unsigned mtu) { struct dst_entry *dst; - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); /* We are not interested in TCP_LISTEN and open_requests (SYN-ACKs * send out by Linux are always <576bytes so they should go through @@ -831,7 +831,7 @@ if (mtu < dst->pmtu && ip_dont_fragment(sk, dst)) sk->err_soft = EMSGSIZE; - if (sk->protinfo.af_inet.pmtudisc != IP_PMTUDISC_DONT && + if (IP_SK(sk)->pmtudisc != IP_PMTUDISC_DONT && tp->pmtu_cookie > dst->pmtu) { tcp_sync_mss(sk, dst->pmtu); @@ -896,7 +896,7 @@ if (sk->state == TCP_CLOSE) goto out; - tp = &sk->tp_pinfo.af_tcp; + tp = TCP_PINFO(sk); seq = ntohl(th->seq); if (sk->state != TCP_LISTEN && !between(seq, tp->snd_una, tp->snd_nxt)) { NET_INC_STATS(OutOfWindowIcmps); @@ -995,7 +995,7 @@ * --ANK (980905) */ - if (sk->lock.users == 0 && sk->protinfo.af_inet.recverr) { + if (sk->lock.users == 0 && IP_SK(sk)->recverr) { sk->err = err; sk->error_report(sk); } else { /* Only an error on timeout */ @@ -1314,7 +1314,7 @@ tcp_clear_options(&tp); tp.mss_clamp = 536; - tp.user_mss = sk->tp_pinfo.af_tcp.user_mss; + tp.user_mss = TCP_PINFO(sk)->user_mss; tcp_parse_options(skb, &tp, 0); @@ -1439,18 +1439,18 @@ newsk->dst_cache = dst; newsk->route_caps = dst->dev->features; - newtp = &(newsk->tp_pinfo.af_tcp); + newtp = TCP_PINFO(newsk); newsk->daddr = req->af.v4_req.rmt_addr; newsk->saddr = req->af.v4_req.loc_addr; newsk->rcv_saddr = req->af.v4_req.loc_addr; - newsk->protinfo.af_inet.opt = req->af.v4_req.opt; + IP_SK(newsk)->opt = req->af.v4_req.opt; req->af.v4_req.opt = NULL; - newsk->protinfo.af_inet.mc_index = tcp_v4_iif(skb); - newsk->protinfo.af_inet.mc_ttl = skb->nh.iph->ttl; + IP_SK(newsk)->mc_index = tcp_v4_iif(skb); + IP_SK(newsk)->mc_ttl = skb->nh.iph->ttl; newtp->ext_header_len = 0; - if (newsk->protinfo.af_inet.opt) - newtp->ext_header_len = newsk->protinfo.af_inet.opt->optlen; - newsk->protinfo.af_inet.id = newtp->write_seq^jiffies; + if (IP_SK(newsk)->opt) + newtp->ext_header_len = IP_SK(newsk)->opt->optlen; + IP_SK(newsk)->id = newtp->write_seq^jiffies; tcp_sync_mss(newsk, dst->pmtu); newtp->advmss = dst->advmss; @@ -1473,7 +1473,7 @@ { struct open_request *req, **prev; struct tcphdr *th = skb->h.th; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sock *nsk; /* Find possible connection requests. */ @@ -1727,12 +1727,12 @@ __u32 new_saddr; __u32 daddr = sk->daddr; - if(sk->protinfo.af_inet.opt && sk->protinfo.af_inet.opt->srr) - daddr = sk->protinfo.af_inet.opt->faddr; + if(IP_SK(sk)->opt && IP_SK(sk)->opt->srr) + daddr = IP_SK(sk)->opt->faddr; /* Query new route. */ err = ip_route_connect(&rt, daddr, 0, - RT_TOS(sk->protinfo.af_inet.tos)|sk->localroute, + RT_TOS(IP_SK(sk)->tos)|sk->localroute, sk->bound_dev_if); if (err) return err; @@ -1778,8 +1778,8 @@ /* Reroute. */ daddr = sk->daddr; - if(sk->protinfo.af_inet.opt && sk->protinfo.af_inet.opt->srr) - daddr = sk->protinfo.af_inet.opt->faddr; + if(IP_SK(sk)->opt && IP_SK(sk)->opt->srr) + daddr = IP_SK(sk)->opt->faddr; err = ip_route_output(&rt, daddr, sk->saddr, RT_CONN_FLAGS(sk), sk->bound_dev_if); @@ -1818,7 +1818,7 @@ int tcp_v4_remember_stamp(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); struct rtable *rt = (struct rtable*)__sk_dst_get(sk); struct inet_peer *peer = NULL; int release_it = 0; @@ -1888,7 +1888,7 @@ */ static int tcp_v4_init_sock(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); skb_queue_head_init(&tp->out_of_order_queue); tcp_init_xmit_timers(sk); @@ -1918,7 +1918,7 @@ sk->write_space = tcp_write_space; sk->use_write_queue = 1; - sk->tp_pinfo.af_tcp.af_specific = &ipv4_specific; + TCP_PINFO(sk)->af_specific = &ipv4_specific; sk->sndbuf = sysctl_tcp_wmem[1]; sk->rcvbuf = sysctl_tcp_rmem[1]; @@ -1930,7 +1930,7 @@ static int tcp_v4_destroy_sock(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); tcp_clear_xmit_timers(sk); @@ -1987,7 +1987,7 @@ __u16 destp, srcp; int timer_active; unsigned long timer_expires; - struct tcp_opt *tp = &sp->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sp); dest = sp->daddr; src = sp->rcv_saddr; @@ -2068,7 +2068,7 @@ for (sk = tcp_listening_hash[i]; sk; sk = sk->next, num++) { struct open_request *req; int uid; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (!TCP_INET_FAMILY(sk->family)) goto skip_listen; @@ -2207,7 +2207,7 @@ if ((err=ops->create(tcp_socket, IPPROTO_TCP))<0) panic("Failed to create the TCP control socket.\n"); tcp_socket->sk->allocation=GFP_ATOMIC; - tcp_socket->sk->protinfo.af_inet.ttl = MAXTTL; + IP_SK(tcp_socket->sk)->ttl = MAXTTL; /* Unhash it so that IP input processing does not even * see it, we do not wish this socket to see incoming diff -uNr linux-2.5.1/net/ipv4/tcp_minisocks.c linux-2.5.1.acme/net/ipv4/tcp_minisocks.c --- linux-2.5.1/net/ipv4/tcp_minisocks.c Mon Oct 1 13:19:57 2001 +++ linux-2.5.1.acme/net/ipv4/tcp_minisocks.c Wed Dec 19 23:44:48 2001 @@ -347,7 +347,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) { struct tcp_tw_bucket *tw = NULL; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int recycle_ok = 0; if (sysctl_tcp_tw_recycle && tp->ts_recent_stamp) @@ -384,10 +384,10 @@ #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) if(tw->family == PF_INET6) { memcpy(&tw->v6_daddr, - &sk->net_pinfo.af_inet6.daddr, + &IP6_PINFO(sk)->daddr, sizeof(struct in6_addr)); memcpy(&tw->v6_rcv_saddr, - &sk->net_pinfo.af_inet6.rcv_saddr, + &IP6_PINFO(sk)->rcv_saddr, sizeof(struct in6_addr)); } #endif @@ -649,7 +649,7 @@ struct sk_filter *filter; #endif - memcpy(newsk, sk, sizeof(*newsk)); + memcpy(newsk, sk, net_proto_sk_size(sk->family)); newsk->state = TCP_SYN_RECV; /* SANITY */ @@ -684,7 +684,7 @@ #endif /* Now setup tcp_opt */ - newtp = &(newsk->tp_pinfo.af_tcp); + newtp = TCP_PINFO(newsk); newtp->pred_flags = 0; newtp->rcv_nxt = req->rcv_isn + 1; newtp->snd_nxt = req->snt_isn + 1; @@ -797,7 +797,7 @@ struct open_request **prev) { struct tcphdr *th = skb->h.th; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); u32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); int paws_reject = 0; struct tcp_opt ttp; diff -uNr linux-2.5.1/net/ipv4/tcp_output.c linux-2.5.1.acme/net/ipv4/tcp_output.c --- linux-2.5.1/net/ipv4/tcp_output.c Mon Nov 5 15:46:12 2001 +++ linux-2.5.1.acme/net/ipv4/tcp_output.c Wed Dec 19 23:44:48 2001 @@ -84,7 +84,7 @@ */ static __u16 tcp_advertise_mss(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct dst_entry *dst = __sk_dst_get(sk); int mss = tp->advmss; @@ -132,7 +132,7 @@ static __inline__ void tcp_event_ack_sent(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); tcp_dec_quickack_mode(tp); tcp_clear_xmit_timer(sk, TCP_TIME_DACK); @@ -145,7 +145,7 @@ */ static __inline__ u16 tcp_select_window(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); u32 cur_win = tcp_receive_window(tp); u32 new_win = __tcp_select_window(sk); @@ -188,7 +188,7 @@ int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb) { if(skb != NULL) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct tcp_skb_cb *tcb = TCP_SKB_CB(skb); int tcp_header_size = tp->tcp_header_len; struct tcphdr *th; @@ -303,7 +303,7 @@ */ void tcp_send_skb(struct sock *sk, struct sk_buff *skb, int force_queue, unsigned cur_mss) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); /* Advance write_seq and place onto the write_queue. */ tp->write_seq = TCP_SKB_CB(skb)->end_seq; @@ -331,7 +331,7 @@ */ void tcp_push_one(struct sock *sk, unsigned cur_mss) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb = tp->send_head; if (tcp_snd_test(tp, skb, cur_mss, 1)) { @@ -418,7 +418,7 @@ */ static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *buff; int nsize = skb->len - len; u16 flags; @@ -501,7 +501,7 @@ int tcp_sync_mss(struct sock *sk, u32 pmtu) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); int mss_now; /* Calculate base mss without TCP options: @@ -509,7 +509,6 @@ */ mss_now = pmtu - tp->af_specific->net_header_len - sizeof(struct tcphdr); - /* Clamp it (mss_clamp does not include tcp options) */ if (mss_now > tp->mss_clamp) mss_now = tp->mss_clamp; @@ -544,7 +543,7 @@ */ int tcp_write_xmit(struct sock *sk, int nonagle) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); unsigned int mss_now; /* If we are closed, the bytes will have to remain here. @@ -642,7 +641,7 @@ */ u32 __tcp_select_window(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); /* MSS for the peer's data. Previous verions used mss_clamp * here. I don't know if the value based on our guesses * of peer's MSS is better for the performance. It's more correct @@ -688,7 +687,7 @@ /* Attempt to collapse two adjacent SKB's during retransmission. */ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int mss_now) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *next_skb = skb->next; /* The first test we must make is that neither of these two @@ -764,7 +763,7 @@ */ void tcp_simple_retransmit(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb; unsigned int mss = tcp_current_mss(sk); int lost = 0; @@ -810,7 +809,7 @@ */ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); unsigned int cur_mss = tcp_current_mss(sk); int err; @@ -909,7 +908,7 @@ */ void tcp_xmit_retransmit_queue(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb; int packet_cnt = tp->lost_out; @@ -989,7 +988,7 @@ */ void tcp_send_fin(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb = skb_peek_tail(&sk->write_queue); unsigned int mss_now; @@ -1034,7 +1033,7 @@ */ void tcp_send_active_reset(struct sock *sk, int priority) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb; /* NOTE: No TCP options attached and we never retransmit this. */ @@ -1085,7 +1084,7 @@ } TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ACK; - TCP_ECN_send_synack(&sk->tp_pinfo.af_tcp, skb); + TCP_ECN_send_synack(TCP_PINFO(sk), skb); } TCP_SKB_CB(skb)->when = tcp_time_stamp; return tcp_transmit_skb(sk, skb_clone(skb, GFP_ATOMIC)); @@ -1097,7 +1096,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, struct open_request *req) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct tcphdr *th; int tcp_header_size; struct sk_buff *skb; @@ -1160,7 +1159,7 @@ int tcp_connect(struct sock *sk, struct sk_buff *buff) { struct dst_entry *dst = __sk_dst_get(sk); - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); /* Reserve space for headers. */ skb_reserve(buff, MAX_TCP_HEADER); @@ -1247,7 +1246,7 @@ */ void tcp_send_delayed_ack(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); int ato = tp->ack.ato; unsigned long timeout; @@ -1300,7 +1299,7 @@ { /* If we have been reset, we may not send again. */ if(sk->state != TCP_CLOSE) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *buff; /* We are not putting this on the write queue, so @@ -1341,7 +1340,7 @@ */ static int tcp_xmit_probe_skb(struct sock *sk, int urgent) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb; /* We don't queue it, tcp_transmit_skb() sets ownership. */ @@ -1368,7 +1367,7 @@ int tcp_write_wakeup(struct sock *sk) { if (sk->state != TCP_CLOSE) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sk_buff *skb; if ((skb = tp->send_head) != NULL && @@ -1413,7 +1412,7 @@ */ void tcp_send_probe0(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int err; err = tcp_write_wakeup(sk); diff -uNr linux-2.5.1/net/ipv4/tcp_timer.c linux-2.5.1.acme/net/ipv4/tcp_timer.c --- linux-2.5.1/net/ipv4/tcp_timer.c Mon Oct 1 13:19:57 2001 +++ linux-2.5.1.acme/net/ipv4/tcp_timer.c Wed Dec 19 23:44:48 2001 @@ -45,7 +45,7 @@ void tcp_init_xmit_timers(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); init_timer(&tp->retransmit_timer); tp->retransmit_timer.function=&tcp_write_timer; @@ -64,7 +64,7 @@ void tcp_clear_xmit_timers(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); tp->pending = 0; if (timer_pending(&tp->retransmit_timer) && @@ -103,7 +103,7 @@ */ static int tcp_out_of_resources(struct sock *sk, int do_reset) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int orphans = atomic_read(&tcp_orphan_count); /* If peer does not open window for long time, or did not transmit @@ -156,7 +156,7 @@ /* A write timeout has occurred. Process the after effects. */ static int tcp_write_timeout(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); int retry_until; if ((1<state)&(TCPF_SYN_SENT|TCPF_SYN_RECV)) { @@ -210,7 +210,7 @@ static void tcp_delack_timer(unsigned long data) { struct sock *sk = (struct sock*)data; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); bh_lock_sock(sk); if (sk->lock.users) { @@ -271,7 +271,7 @@ static void tcp_probe_timer(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); int max_probes; if (tp->packets_out || !tp->send_head) { @@ -319,7 +319,7 @@ static void tcp_retransmit_timer(struct sock *sk) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); if (tp->packets_out == 0) goto out; @@ -415,7 +415,7 @@ static void tcp_write_timer(unsigned long data) { struct sock *sk = (struct sock*)data; - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); int event; bh_lock_sock(sk); @@ -461,7 +461,7 @@ static void tcp_synack_timer(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct tcp_listen_opt *lopt = tp->listen_opt; int max_retries = tp->syn_retries ? : sysctl_tcp_synack_retries; int thresh = max_retries; @@ -565,7 +565,7 @@ return; if (val && !sk->keepopen) - tcp_reset_keepalive_timer(sk, keepalive_time_when(&sk->tp_pinfo.af_tcp)); + tcp_reset_keepalive_timer(sk, keepalive_time_when(TCP_PINFO(sk))); else if (!val) tcp_delete_keepalive_timer(sk); } @@ -574,7 +574,7 @@ static void tcp_keepalive_timer (unsigned long data) { struct sock *sk = (struct sock *) data; - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); __u32 elapsed; /* Only process if socket is not in use. */ diff -uNr linux-2.5.1/net/ipv4/udp.c linux-2.5.1.acme/net/ipv4/udp.c --- linux-2.5.1/net/ipv4/udp.c Wed Oct 17 19:16:39 2001 +++ linux-2.5.1.acme/net/ipv4/udp.c Wed Dec 19 23:44:48 2001 @@ -323,7 +323,7 @@ break; case ICMP_DEST_UNREACH: if (code == ICMP_FRAG_NEEDED) { /* Path MTU discovery */ - if (sk->protinfo.af_inet.pmtudisc != IP_PMTUDISC_DONT) { + if (IP_SK(sk)->pmtudisc != IP_PMTUDISC_DONT) { err = EMSGSIZE; harderr = 1; break; @@ -342,7 +342,7 @@ * RFC1122: OK. Passes ICMP errors back to application, as per * 4.1.3.3. */ - if (!sk->protinfo.af_inet.recverr) { + if (!IP_SK(sk)->recverr) { if (!harderr || sk->state != TCP_ESTABLISHED) goto out; } else { @@ -487,7 +487,7 @@ connected = 0; } if (!ipc.opt) - ipc.opt = sk->protinfo.af_inet.opt; + ipc.opt = IP_SK(sk)->opt; ufh.saddr = ipc.addr; ipc.addr = daddr = ufh.daddr; @@ -498,7 +498,7 @@ daddr = ipc.opt->faddr; connected = 0; } - tos = RT_TOS(sk->protinfo.af_inet.tos); + tos = RT_TOS(IP_SK(sk)->tos); if (sk->localroute || (msg->msg_flags&MSG_DONTROUTE) || (ipc.opt && ipc.opt->is_strictroute)) { tos |= RTO_ONLINK; @@ -507,9 +507,9 @@ if (MULTICAST(daddr)) { if (!ipc.oif) - ipc.oif = sk->protinfo.af_inet.mc_index; + ipc.oif = IP_SK(sk)->mc_index; if (!ufh.saddr) - ufh.saddr = sk->protinfo.af_inet.mc_addr; + ufh.saddr = IP_SK(sk)->mc_addr; connected = 0; } @@ -678,7 +678,7 @@ sin->sin_addr.s_addr = skb->nh.iph->saddr; memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); } - if (sk->protinfo.af_inet.cmsg_flags) + if (IP_SK(sk)->cmsg_flags) ip_cmsg_recv(msg, skb); err = copied; @@ -738,7 +738,7 @@ sk->daddr = rt->rt_dst; sk->dport = usin->sin_port; sk->state = TCP_ESTABLISHED; - sk->protinfo.af_inet.id = jiffies; + IP_SK(sk)->id = jiffies; sk_dst_set(sk, &rt->u.dst); return(0); @@ -758,8 +758,10 @@ sk->rcv_saddr = 0; sk->saddr = 0; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) - memset(&sk->net_pinfo.af_inet6.saddr, 0, 16); - memset(&sk->net_pinfo.af_inet6.rcv_saddr, 0, 16); + if (sk->family == PF_INET6) { + memset(&IP6_PINFO(sk)->saddr, 0, 16); + memset(&IP6_PINFO(sk)->rcv_saddr, 0, 16); + } #endif } if (!(sk->userlocks&SOCK_BINDPORT_LOCK)) { diff -uNr linux-2.5.1/net/ipv6/af_inet6.c linux-2.5.1.acme/net/ipv6/af_inet6.c --- linux-2.5.1/net/ipv6/af_inet6.c Wed Oct 17 19:16:39 2001 +++ linux-2.5.1.acme/net/ipv6/af_inet6.c Wed Dec 19 23:44:48 2001 @@ -158,7 +158,7 @@ if (SOCK_RAW == sock->type) { sk->num = protocol; if (IPPROTO_RAW == protocol) - sk->protinfo.af_inet.hdrincl = 1; + IP_SK(sk)->hdrincl = 1; } sk->destruct = inet6_sock_destruct; @@ -168,25 +168,25 @@ sk->backlog_rcv = answer->prot->backlog_rcv; - sk->net_pinfo.af_inet6.hop_limit = -1; - sk->net_pinfo.af_inet6.mcast_hops = -1; - sk->net_pinfo.af_inet6.mc_loop = 1; - sk->net_pinfo.af_inet6.pmtudisc = IPV6_PMTUDISC_WANT; + IP6_PINFO(sk)->hop_limit = -1; + IP6_PINFO(sk)->mcast_hops = -1; + IP6_PINFO(sk)->mc_loop = 1; + IP6_PINFO(sk)->pmtudisc = IPV6_PMTUDISC_WANT; /* Init the ipv4 part of the socket since we can have sockets * using v6 API for ipv4. */ - sk->protinfo.af_inet.ttl = 64; + IP_SK(sk)->ttl = 64; - sk->protinfo.af_inet.mc_loop = 1; - sk->protinfo.af_inet.mc_ttl = 1; - sk->protinfo.af_inet.mc_index = 0; - sk->protinfo.af_inet.mc_list = NULL; + IP_SK(sk)->mc_loop = 1; + IP_SK(sk)->mc_ttl = 1; + IP_SK(sk)->mc_index = 0; + IP_SK(sk)->mc_list = NULL; if (ipv4_config.no_pmtu_disc) - sk->protinfo.af_inet.pmtudisc = IP_PMTUDISC_DONT; + IP_SK(sk)->pmtudisc = IP_PMTUDISC_DONT; else - sk->protinfo.af_inet.pmtudisc = IP_PMTUDISC_WANT; + IP_SK(sk)->pmtudisc = IP_PMTUDISC_WANT; #ifdef INET_REFCNT_DEBUG @@ -296,17 +296,17 @@ sk->rcv_saddr = v4addr; sk->saddr = v4addr; - ipv6_addr_copy(&sk->net_pinfo.af_inet6.rcv_saddr, &addr->sin6_addr); + ipv6_addr_copy(&IP6_PINFO(sk)->rcv_saddr, &addr->sin6_addr); if (!(addr_type & IPV6_ADDR_MULTICAST)) - ipv6_addr_copy(&sk->net_pinfo.af_inet6.saddr, &addr->sin6_addr); + ipv6_addr_copy(&IP6_PINFO(sk)->saddr, &addr->sin6_addr); /* Make sure we are allowed to bind here. */ if (sk->prot->get_port(sk, snum) != 0) { sk->rcv_saddr = 0; sk->saddr = 0; - memset(&sk->net_pinfo.af_inet6.rcv_saddr, 0, sizeof(struct in6_addr)); - memset(&sk->net_pinfo.af_inet6.saddr, 0, sizeof(struct in6_addr)); + memset(&IP6_PINFO(sk)->rcv_saddr, 0, sizeof(struct in6_addr)); + memset(&IP6_PINFO(sk)->saddr, 0, sizeof(struct in6_addr)); release_sock(sk); return -EADDRINUSE; @@ -350,7 +350,7 @@ /* Release rx options */ - if ((skb = xchg(&sk->net_pinfo.af_inet6.pktoptions, NULL)) != NULL) + if ((skb = xchg(&IP6_PINFO(sk)->pktoptions, NULL)) != NULL) kfree_skb(skb); /* Free flowlabels */ @@ -358,7 +358,7 @@ /* Free tx options */ - if ((opt = xchg(&sk->net_pinfo.af_inet6.opt, NULL)) != NULL) + if ((opt = xchg(&IP6_PINFO(sk)->opt, NULL)) != NULL) sock_kfree_s(sk, opt, opt->tot_len); return 0; @@ -383,18 +383,18 @@ if (((1<state)&(TCPF_CLOSE|TCPF_SYN_SENT)) && peer == 1) return -ENOTCONN; sin->sin6_port = sk->dport; - memcpy(&sin->sin6_addr, &sk->net_pinfo.af_inet6.daddr, + memcpy(&sin->sin6_addr, &IP6_PINFO(sk)->daddr, sizeof(struct in6_addr)); - if (sk->net_pinfo.af_inet6.sndflow) - sin->sin6_flowinfo = sk->net_pinfo.af_inet6.flow_label; + if (IP6_PINFO(sk)->sndflow) + sin->sin6_flowinfo = IP6_PINFO(sk)->flow_label; } else { - if (ipv6_addr_type(&sk->net_pinfo.af_inet6.rcv_saddr) == IPV6_ADDR_ANY) + if (ipv6_addr_type(&IP6_PINFO(sk)->rcv_saddr) == IPV6_ADDR_ANY) memcpy(&sin->sin6_addr, - &sk->net_pinfo.af_inet6.saddr, + &IP6_PINFO(sk)->saddr, sizeof(struct in6_addr)); else memcpy(&sin->sin6_addr, - &sk->net_pinfo.af_inet6.rcv_saddr, + &IP6_PINFO(sk)->rcv_saddr, sizeof(struct in6_addr)); sin->sin6_port = sk->sport; @@ -502,8 +502,10 @@ }; struct net_proto_family inet6_family_ops = { - PF_INET6, - inet6_create + family: PF_INET6, + create: inet6_create, + sk_size: sizeof(struct sock) + sizeof(struct tcp_opt) + + sizeof(struct inet_opt) + sizeof(struct ipv6_pinfo), }; #ifdef MODULE @@ -606,6 +608,17 @@ printk(KERN_CRIT "inet6_proto_init: size fault\n"); return -EINVAL; } + + /* allocate our sock slab cache */ + + inet6_family_ops.sk_cachep = kmem_cache_create("inet6_sock", + inet6_family_ops.sk_size, + 0, SLAB_HWCACHE_ALIGN, + 0, 0); + if (!inet6_family_ops.sk_cachep) + printk(KERN_CRIT __FUNCTION__ + ": Cannot create inet6_sock SLAB cache!\n"); + /* Register the socket-side information for inet6_create. */ for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r) diff -uNr linux-2.5.1/net/ipv6/datagram.c linux-2.5.1.acme/net/ipv6/datagram.c --- linux-2.5.1/net/ipv6/datagram.c Fri Sep 7 15:01:21 2001 +++ linux-2.5.1.acme/net/ipv6/datagram.c Wed Dec 19 23:44:48 2001 @@ -38,7 +38,7 @@ struct icmp6hdr *icmph = (struct icmp6hdr *)skb->h.raw; struct sock_exterr_skb *serr; - if (!sk->net_pinfo.af_inet6.recverr) + if (!IP6_PINFO(sk)->recverr) return; skb = skb_clone(skb, GFP_ATOMIC); @@ -69,7 +69,7 @@ struct ipv6hdr *iph; struct sk_buff *skb; - if (!sk->net_pinfo.af_inet6.recverr) + if (!IP6_PINFO(sk)->recverr) return; skb = alloc_skb(sizeof(struct ipv6hdr), GFP_ATOMIC); @@ -139,7 +139,7 @@ sin->sin6_scope_id = 0; if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) { memcpy(&sin->sin6_addr, skb->nh.raw + serr->addr_offset, 16); - if (sk->net_pinfo.af_inet6.sndflow) + if (IP6_PINFO(sk)->sndflow) sin->sin6_flowinfo = *(u32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK; if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) { struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb; @@ -160,7 +160,7 @@ sin->sin6_flowinfo = 0; if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) { memcpy(&sin->sin6_addr, &skb->nh.ipv6h->saddr, 16); - if (sk->net_pinfo.af_inet6.rxopt.all) + if (IP6_PINFO(sk)->rxopt.all) datagram_recv_ctl(sk, msg, skb); if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) { struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb; @@ -170,7 +170,7 @@ ipv6_addr_set(&sin->sin6_addr, 0, 0, __constant_htonl(0xffff), skb->nh.iph->saddr); - if (sk->protinfo.af_inet.cmsg_flags) + if (IP_SK(sk)->cmsg_flags) ip_cmsg_recv(msg, skb); } } @@ -203,7 +203,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb; if (np->rxopt.bits.rxinfo) { diff -uNr linux-2.5.1/net/ipv6/ip6_flowlabel.c linux-2.5.1.acme/net/ipv6/ip6_flowlabel.c --- linux-2.5.1/net/ipv6/ip6_flowlabel.c Mon Aug 7 02:20:09 2000 +++ linux-2.5.1.acme/net/ipv6/ip6_flowlabel.c Wed Dec 19 23:44:48 2001 @@ -180,7 +180,7 @@ struct ip6_flowlabel * fl6_sock_lookup(struct sock *sk, u32 label) { struct ipv6_fl_socklist *sfl; - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); label &= IPV6_FLOWLABEL_MASK; @@ -197,7 +197,7 @@ void fl6_free_socklist(struct sock *sk) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct ipv6_fl_socklist *sfl; while ((sfl = np->ipv6_fl_list) != NULL) { @@ -361,7 +361,7 @@ if (room > FL_MAX_SIZE - FL_MAX_PER_SOCK) return 0; - for (sfl = sk->net_pinfo.af_inet6.ipv6_fl_list; sfl; sfl = sfl->next) + for (sfl = IP6_PINFO(sk)->ipv6_fl_list; sfl; sfl = sfl->next) count++; if (room <= 0 || @@ -404,7 +404,7 @@ int ipv6_flowlabel_opt(struct sock *sk, char *optval, int optlen) { int err; - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct in6_flowlabel_req freq; struct ipv6_fl_socklist *sfl1=NULL; struct ipv6_fl_socklist *sfl, **sflp; diff -uNr linux-2.5.1/net/ipv6/ip6_output.c linux-2.5.1.acme/net/ipv6/ip6_output.c --- linux-2.5.1/net/ipv6/ip6_output.c Thu Sep 20 18:12:56 2001 +++ linux-2.5.1.acme/net/ipv6/ip6_output.c Wed Dec 19 23:44:48 2001 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -106,7 +107,7 @@ if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr)) { if (!(dev->flags&IFF_LOOPBACK) && - (skb->sk == NULL || skb->sk->net_pinfo.af_inet6.mc_loop) && + (skb->sk == NULL || IP6_PINFO(skb->sk)->mc_loop) && ipv6_chk_mcast_addr(dev, &skb->nh.ipv6h->daddr)) { struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); @@ -182,7 +183,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, struct ipv6_txoptions *opt) { - struct ipv6_pinfo * np = sk ? &sk->net_pinfo.af_inet6 : NULL; + struct ipv6_pinfo * np = sk ? IP6_PINFO(sk) : NULL; struct in6_addr *first_hop = fl->nl_u.ip6_u.daddr; struct dst_entry *dst = skb->dst; struct ipv6hdr *hdr; @@ -258,7 +259,7 @@ struct in6_addr *saddr, struct in6_addr *daddr, int proto, int len) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct ipv6hdr *hdr; int totlen; @@ -500,7 +501,7 @@ struct flowi *fl, unsigned length, struct ipv6_txoptions *opt, int hlimit, int flags) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct in6_addr *final_dst = NULL; struct dst_entry *dst; int err = 0; @@ -582,7 +583,7 @@ jumbolen = 0; - if (!sk->protinfo.af_inet.hdrincl) { + if (!IP_SK(sk)->hdrincl) { pktlength += sizeof(struct ipv6hdr); if (opt) pktlength += opt->opt_flen + opt->opt_nflen; @@ -642,7 +643,7 @@ hdr = (struct ipv6hdr *) skb->tail; skb->nh.ipv6h = hdr; - if (!sk->protinfo.af_inet.hdrincl) { + if (!IP_SK(sk)->hdrincl) { ip6_bld_1(sk, skb, fl, hlimit, jumbolen ? sizeof(struct ipv6hdr) : pktlength); @@ -667,7 +668,7 @@ kfree_skb(skb); } } else { - if (sk->protinfo.af_inet.hdrincl || jumbolen || + if (IP_SK(sk)->hdrincl || jumbolen || np->pmtudisc == IPV6_PMTUDISC_DO) { ipv6_local_error(sk, EMSGSIZE, fl, mtu); err = -EMSGSIZE; diff -uNr linux-2.5.1/net/ipv6/ipv6_sockglue.c linux-2.5.1.acme/net/ipv6/ipv6_sockglue.c --- linux-2.5.1/net/ipv6/ipv6_sockglue.c Thu Sep 20 18:12:56 2001 +++ linux-2.5.1.acme/net/ipv6/ipv6_sockglue.c Wed Dec 19 23:44:48 2001 @@ -122,7 +122,7 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); int val, valbool; int retv = -ENOPROTOOPT; @@ -166,7 +166,7 @@ ipv6_sock_mc_close(sk); if (sk->protocol == IPPROTO_TCP) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); local_bh_disable(); sock_prot_dec_use(sk->prot); @@ -281,7 +281,7 @@ retv = 0; if (sk->type == SOCK_STREAM) { if (opt) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); if (!((1<state)&(TCPF_LISTEN|TCPF_CLOSE)) && sk->daddr != LOOPBACK4_IPV6) { tp->ext_header_len = opt->opt_flen + opt->opt_nflen; @@ -401,7 +401,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); int len; int val; diff -uNr linux-2.5.1/net/ipv6/mcast.c linux-2.5.1.acme/net/ipv6/mcast.c --- linux-2.5.1/net/ipv6/mcast.c Wed Aug 15 05:54:24 2001 +++ linux-2.5.1.acme/net/ipv6/mcast.c Wed Dec 19 23:44:48 2001 @@ -77,7 +77,7 @@ { struct net_device *dev = NULL; struct ipv6_mc_socklist *mc_lst; - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); int err; if (!(ipv6_addr_type(addr) & IPV6_ADDR_MULTICAST)) @@ -136,7 +136,7 @@ */ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, struct in6_addr *addr) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct ipv6_mc_socklist *mc_lst, **lnk; write_lock_bh(&ipv6_sk_mc_lock); @@ -163,7 +163,7 @@ void ipv6_sock_mc_close(struct sock *sk) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct ipv6_mc_socklist *mc_lst; write_lock_bh(&ipv6_sk_mc_lock); @@ -191,7 +191,7 @@ struct ipv6_mc_socklist *mc; read_lock(&ipv6_sk_mc_lock); - for (mc = sk->net_pinfo.af_inet6.ipv6_mc_list; mc; mc=mc->next) { + for (mc = IP6_PINFO(sk)->ipv6_mc_list; mc; mc=mc->next) { if (ipv6_addr_cmp(&mc->addr, addr) == 0) { read_unlock(&ipv6_sk_mc_lock); return 1; @@ -774,7 +774,7 @@ sk->allocation = GFP_ATOMIC; sk->prot->unhash(sk); - sk->net_pinfo.af_inet6.hop_limit = 1; + IP6_PINFO(sk)->hop_limit = 1; #ifdef CONFIG_PROC_FS create_proc_read_entry("net/igmp6", 0, 0, igmp6_read_proc, NULL); #endif diff -uNr linux-2.5.1/net/ipv6/ndisc.c linux-2.5.1.acme/net/ipv6/ndisc.c --- linux-2.5.1/net/ipv6/ndisc.c Mon Sep 10 11:57:00 2001 +++ linux-2.5.1.acme/net/ipv6/ndisc.c Wed Dec 19 23:44:48 2001 @@ -1308,9 +1308,9 @@ sk = ndisc_socket->sk; sk->allocation = GFP_ATOMIC; - sk->net_pinfo.af_inet6.hop_limit = 255; + IP6_PINFO(sk)->hop_limit = 255; /* Do not loopback ndisc messages */ - sk->net_pinfo.af_inet6.mc_loop = 0; + IP6_PINFO(sk)->mc_loop = 0; sk->prot->unhash(sk); /* diff -uNr linux-2.5.1/net/ipv6/proc.c linux-2.5.1.acme/net/ipv6/proc.c --- linux-2.5.1/net/ipv6/proc.c Mon Jul 10 02:30:41 2000 +++ linux-2.5.1.acme/net/ipv6/proc.c Wed Dec 19 23:44:48 2001 @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff -uNr linux-2.5.1/net/ipv6/raw.c linux-2.5.1.acme/net/ipv6/raw.c --- linux-2.5.1/net/ipv6/raw.c Thu Sep 20 18:12:56 2001 +++ linux-2.5.1.acme/net/ipv6/raw.c Wed Dec 19 23:44:48 2001 @@ -86,7 +86,7 @@ for(s = sk; s; s = s->next) { if(s->num == num) { - struct ipv6_pinfo *np = &s->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(s); if (!ipv6_addr_any(&np->daddr) && ipv6_addr_cmp(&np->daddr, rmt_addr)) @@ -115,7 +115,7 @@ struct icmp6hdr *icmph; struct raw6_opt *opt; - opt = &sk->tp_pinfo.tp_raw; + opt = RAW6_PINFO(sk); if (pskb_may_pull(skb, sizeof(struct icmp6hdr))) { __u32 *data = &opt->filter.data[0]; int bit_nr; @@ -235,9 +235,9 @@ sk->rcv_saddr = v4addr; sk->saddr = v4addr; - ipv6_addr_copy(&sk->net_pinfo.af_inet6.rcv_saddr, &addr->sin6_addr); + ipv6_addr_copy(&IP6_PINFO(sk)->rcv_saddr, &addr->sin6_addr); if (!(addr_type & IPV6_ADDR_MULTICAST)) - ipv6_addr_copy(&sk->net_pinfo.af_inet6.saddr, &addr->sin6_addr); + ipv6_addr_copy(&IP6_PINFO(sk)->saddr, &addr->sin6_addr); err = 0; out: release_sock(sk); @@ -256,21 +256,21 @@ 2. Socket is connected (otherwise the error indication is useless without recverr and error is hard. */ - if (!sk->net_pinfo.af_inet6.recverr && sk->state != TCP_ESTABLISHED) + if (!IP6_PINFO(sk)->recverr && sk->state != TCP_ESTABLISHED) return; harderr = icmpv6_err_convert(type, code, &err); if (type == ICMPV6_PKT_TOOBIG) - harderr = (sk->net_pinfo.af_inet6.pmtudisc == IPV6_PMTUDISC_DO); + harderr = (IP6_PINFO(sk)->pmtudisc == IPV6_PMTUDISC_DO); - if (sk->net_pinfo.af_inet6.recverr) { + if (IP6_PINFO(sk)->recverr) { u8 *payload = skb->data; - if (!sk->protinfo.af_inet.hdrincl) + if (!IP_SK(sk)->hdrincl) payload += offset; ipv6_icmp_error(sk, skb, err, 0, ntohl(info), payload); } - if (sk->net_pinfo.af_inet6.recverr || harderr) { + if (IP6_PINFO(sk)->recverr || harderr) { sk->err = err; sk->error_report(sk); } @@ -298,7 +298,7 @@ */ int rawv6_rcv(struct sock *sk, struct sk_buff *skb) { - if (sk->protinfo.af_inet.hdrincl) { + if (IP_SK(sk)->hdrincl) { __skb_push(skb, skb->nh.raw - skb->data); skb->h.raw = skb->nh.raw; } @@ -358,7 +358,7 @@ sock_recv_timestamp(msg, sk, skb); - if (sk->net_pinfo.af_inet6.rxopt.all) + if (IP6_PINFO(sk)->rxopt.all) datagram_recv_ctl(sk, msg, skb); err = copied; @@ -405,7 +405,7 @@ struct in6_addr *daddr; sk = hdr->sk; - opt = &sk->tp_pinfo.tp_raw; + opt = RAW6_PINFO(sk); if (hdr->daddr) daddr = hdr->daddr; @@ -434,7 +434,7 @@ { struct ipv6_txoptions opt_space; struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name; - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct ipv6_txoptions *opt = NULL; struct ip6_flowlabel *flowlabel = NULL; struct flowi fl; @@ -491,8 +491,8 @@ /* Otherwise it will be difficult to maintain sk->dst_cache. */ if (sk->state == TCP_ESTABLISHED && - !ipv6_addr_cmp(daddr, &sk->net_pinfo.af_inet6.daddr)) - daddr = &sk->net_pinfo.af_inet6.daddr; + !ipv6_addr_cmp(daddr, &IP6_PINFO(sk)->daddr)) + daddr = &IP6_PINFO(sk)->daddr; if (addr_len >= sizeof(struct sockaddr_in6) && sin6->sin6_scope_id && @@ -503,7 +503,7 @@ return(-EINVAL); proto = sk->num; - daddr = &(sk->net_pinfo.af_inet6.daddr); + daddr = &(IP6_PINFO(sk)->daddr); fl.fl6_flowlabel = np->flow_label; } @@ -541,7 +541,7 @@ if (flowlabel) opt = fl6_merge_options(&opt_space, flowlabel, opt); - raw_opt = &sk->tp_pinfo.tp_raw; + raw_opt = RAW6_PINFO(sk); fl.proto = proto; fl.fl6_dst = daddr; @@ -583,7 +583,7 @@ case ICMPV6_FILTER: if (optlen > sizeof(struct icmp6_filter)) optlen = sizeof(struct icmp6_filter); - if (copy_from_user(&sk->tp_pinfo.tp_raw.filter, optval, optlen)) + if (copy_from_user(&RAW6_PINFO(sk)->filter, optval, optlen)) return -EFAULT; return 0; default: @@ -608,7 +608,7 @@ len = sizeof(struct icmp6_filter); if (put_user(len, optlen)) return -EFAULT; - if (copy_to_user(optval, &sk->tp_pinfo.tp_raw.filter, len)) + if (copy_to_user(optval, &RAW6_PINFO(sk)->filter, len)) return -EFAULT; return 0; default: @@ -622,7 +622,7 @@ static int rawv6_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen) { - struct raw6_opt *opt = &sk->tp_pinfo.tp_raw; + struct raw6_opt *opt = RAW6_PINFO(sk); int val; switch(level) { @@ -665,7 +665,7 @@ static int rawv6_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen) { - struct raw6_opt *opt = &sk->tp_pinfo.tp_raw; + struct raw6_opt *opt = RAW6_PINFO(sk); int val, len; switch(level) { @@ -755,8 +755,8 @@ struct in6_addr *dest, *src; __u16 destp, srcp; - dest = &sp->net_pinfo.af_inet6.daddr; - src = &sp->net_pinfo.af_inet6.rcv_saddr; + dest = &IP6_PINFO(sp)->daddr; + src = &IP6_PINFO(sp)->rcv_saddr; destp = 0; srcp = sp->num; sprintf(tmpbuf, diff -uNr linux-2.5.1/net/ipv6/tcp_ipv6.c linux-2.5.1.acme/net/ipv6/tcp_ipv6.c --- linux-2.5.1/net/ipv6/tcp_ipv6.c Mon Nov 5 15:46:12 2001 +++ linux-2.5.1.acme/net/ipv6/tcp_ipv6.c Wed Dec 19 23:44:48 2001 @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -75,8 +76,8 @@ static __inline__ int tcp_v6_sk_hashfn(struct sock *sk) { - struct in6_addr *laddr = &sk->net_pinfo.af_inet6.rcv_saddr; - struct in6_addr *faddr = &sk->net_pinfo.af_inet6.daddr; + struct in6_addr *laddr = &IP6_PINFO(sk)->rcv_saddr; + struct in6_addr *faddr = &IP6_PINFO(sk)->daddr; __u16 lport = sk->num; __u16 fport = sk->dport; return tcp_v6_hashfn(laddr, lport, faddr, fport); @@ -138,7 +139,7 @@ } else { struct sock *sk2 = tb->owners; int sk_reuse = sk->reuse; - int addr_type = ipv6_addr_type(&sk->net_pinfo.af_inet6.rcv_saddr); + int addr_type = ipv6_addr_type(&IP6_PINFO(sk)->rcv_saddr); /* We must walk the whole port owner list in this case. -DaveM */ for( ; sk2 != NULL; sk2 = sk2->bind_next) { @@ -150,9 +151,9 @@ /* NOTE: IPv6 tw bucket have different format */ if (!sk2->rcv_saddr || addr_type == IPV6_ADDR_ANY || - !ipv6_addr_cmp(&sk->net_pinfo.af_inet6.rcv_saddr, + !ipv6_addr_cmp(&IP6_PINFO(sk)->rcv_saddr, sk2->state != TCP_TIME_WAIT ? - &sk2->net_pinfo.af_inet6.rcv_saddr : + &IP6_PINFO(sk2)->rcv_saddr : &((struct tcp_tw_bucket*)sk)->v6_rcv_saddr) || (addr_type==IPV6_ADDR_MAPPED && sk2->family==AF_INET && sk->rcv_saddr==sk2->rcv_saddr)) @@ -228,7 +229,7 @@ static void tcp_v6_hash(struct sock *sk) { if(sk->state != TCP_CLOSE) { - if (sk->tp_pinfo.af_tcp.af_specific == &ipv6_mapped) { + if (TCP_PINFO(sk)->af_specific == &ipv6_mapped) { tcp_prot.hash(sk); return; } @@ -249,7 +250,7 @@ sk = tcp_listening_hash[tcp_lhashfn(hnum)]; for(; sk; sk = sk->next) { if((sk->num == hnum) && (sk->family == PF_INET6)) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); score = 1; if(!ipv6_addr_any(&np->rcv_saddr)) { @@ -417,8 +418,8 @@ static int tcp_v6_check_established(struct sock *sk) { - struct in6_addr *daddr = &sk->net_pinfo.af_inet6.rcv_saddr; - struct in6_addr *saddr = &sk->net_pinfo.af_inet6.daddr; + struct in6_addr *daddr = &IP6_PINFO(sk)->rcv_saddr; + struct in6_addr *saddr = &IP6_PINFO(sk)->daddr; int dif = sk->bound_dev_if; u32 ports = TCP_COMBINED_PORTS(sk->dport, sk->num); int hash = tcp_v6_hashfn(daddr, sk->num, saddr, sk->dport); @@ -436,7 +437,7 @@ !ipv6_addr_cmp(&tw->v6_daddr, saddr) && !ipv6_addr_cmp(&tw->v6_rcv_saddr, daddr) && sk2->bound_dev_if == sk->bound_dev_if) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (tw->ts_recent_stamp) { /* See comment in tcp_ipv4.c */ @@ -514,8 +515,8 @@ int addr_len) { struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct ipv6_pinfo *np = IP6_PINFO(sk); + struct tcp_opt *tp = TCP_PINFO(sk); struct in6_addr *saddr = NULL; struct in6_addr saddr_buf; struct flowi fl; @@ -597,14 +598,14 @@ sin.sin_port = usin->sin6_port; sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3]; - sk->tp_pinfo.af_tcp.af_specific = &ipv6_mapped; + TCP_PINFO(sk)->af_specific = &ipv6_mapped; sk->backlog_rcv = tcp_v4_do_rcv; err = tcp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); if (err) { tp->ext_header_len = exthdrlen; - sk->tp_pinfo.af_tcp.af_specific = &ipv6_specific; + TCP_PINFO(sk)->af_specific = &ipv6_specific; sk->backlog_rcv = tcp_v6_do_rcv; goto failure; } else { @@ -720,14 +721,14 @@ if (sk->state == TCP_CLOSE) goto out; - tp = &sk->tp_pinfo.af_tcp; + tp = TCP_PINFO(sk); seq = ntohl(th->seq); if (sk->state != TCP_LISTEN && !between(seq, tp->snd_una, tp->snd_nxt)) { NET_INC_STATS_BH(OutOfWindowIcmps); goto out; } - np = &sk->net_pinfo.af_inet6; + np = IP6_PINFO(sk); if (type == ICMPV6_PKT_TOOBIG) { struct dst_entry *dst = NULL; @@ -843,9 +844,9 @@ fl.uli_u.ports.sport = sk->sport; if (dst == NULL) { - opt = sk->net_pinfo.af_inet6.opt; + opt = IP6_PINFO(sk)->opt; if (opt == NULL && - sk->net_pinfo.af_inet6.rxopt.bits.srcrt == 2 && + IP6_PINFO(sk)->rxopt.bits.srcrt == 2 && req->af.v6_req.pktopts) { struct sk_buff *pktopts = req->af.v6_req.pktopts; struct inet6_skb_parm *rxopt = (struct inet6_skb_parm *)pktopts->cb; @@ -879,7 +880,7 @@ done: dst_release(dst); - if (opt && opt != sk->net_pinfo.af_inet6.opt) + if (opt && opt != IP6_PINFO(sk)->opt) sock_kfree_s(sk, opt, opt->tot_len); return err; } @@ -902,12 +903,12 @@ { struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb; - if (sk->net_pinfo.af_inet6.rxopt.all) { - if ((opt->hop && sk->net_pinfo.af_inet6.rxopt.bits.hopopts) || + if (IP6_PINFO(sk)->rxopt.all) { + if ((opt->hop && IP6_PINFO(sk)->rxopt.bits.hopopts) || ((IPV6_FLOWINFO_MASK&*(u32*)skb->nh.raw) && - sk->net_pinfo.af_inet6.rxopt.bits.rxflow) || - (opt->srcrt && sk->net_pinfo.af_inet6.rxopt.bits.srcrt) || - ((opt->dst1 || opt->dst0) && sk->net_pinfo.af_inet6.rxopt.bits.dstopts)) + IP6_PINFO(sk)->rxopt.bits.rxflow) || + (opt->srcrt && IP6_PINFO(sk)->rxopt.bits.srcrt) || + ((opt->dst1 || opt->dst0) && IP6_PINFO(sk)->rxopt.bits.dstopts)) return 1; } return 0; @@ -917,7 +918,7 @@ static void tcp_v6_send_check(struct sock *sk, struct tcphdr *th, int len, struct sk_buff *skb) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); if (skb->ip_summed == CHECKSUM_HW) { th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 0); @@ -1084,7 +1085,7 @@ { struct open_request *req, **prev; struct tcphdr *th = skb->h.th; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); struct sock *nsk; /* Find possible connection requests. */ @@ -1116,7 +1117,7 @@ static void tcp_v6_synq_add(struct sock *sk, struct open_request *req) { - struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sk); struct tcp_listen_opt *lopt = tp->listen_opt; unsigned h = tcp_v6_synq_hash(&req->af.v6_req.rmt_addr, req->rmt_port); @@ -1168,7 +1169,7 @@ tcp_clear_options(&tp); tp.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr); - tp.user_mss = sk->tp_pinfo.af_tcp.user_mss; + tp.user_mss = TCP_PINFO(sk)->user_mss; tcp_parse_options(skb, &tp, 0); @@ -1180,8 +1181,8 @@ TCP_ECN_create_request(req, skb->h.th); req->af.v6_req.pktopts = NULL; if (ipv6_opt_accepted(sk, skb) || - sk->net_pinfo.af_inet6.rxopt.bits.rxinfo || - sk->net_pinfo.af_inet6.rxopt.bits.rxhlim) { + IP6_PINFO(sk)->rxopt.bits.rxinfo || + IP6_PINFO(sk)->rxopt.bits.rxhlim) { atomic_inc(&skb->users); req->af.v6_req.pktopts = skb; } @@ -1231,7 +1232,7 @@ if (newsk == NULL) return NULL; - np = &newsk->net_pinfo.af_inet6; + np = IP6_PINFO(newsk); ipv6_addr_set(&np->daddr, 0, 0, __constant_htonl(0x0000FFFF), newsk->daddr); @@ -1241,12 +1242,12 @@ ipv6_addr_copy(&np->rcv_saddr, &np->saddr); - newsk->tp_pinfo.af_tcp.af_specific = &ipv6_mapped; + TCP_PINFO(sk)->af_specific = &ipv6_mapped; newsk->backlog_rcv = tcp_v4_do_rcv; - newsk->net_pinfo.af_inet6.pktoptions = NULL; - newsk->net_pinfo.af_inet6.opt = NULL; - newsk->net_pinfo.af_inet6.mcast_oif = tcp_v6_iif(skb); - newsk->net_pinfo.af_inet6.mcast_hops = skb->nh.ipv6h->hop_limit; + IP6_PINFO(newsk)->pktoptions = NULL; + IP6_PINFO(newsk)->opt = NULL; + IP6_PINFO(newsk)->mcast_oif = tcp_v6_iif(skb); + IP6_PINFO(newsk)->mcast_hops = skb->nh.ipv6h->hop_limit; /* Charge newly allocated IPv6 socket. Though it is mapped, * it is IPv6 yet. @@ -1260,17 +1261,17 @@ worked with IPv6 af_tcp.af_specific. Sync it now. */ - tcp_sync_mss(newsk, newsk->tp_pinfo.af_tcp.pmtu_cookie); + tcp_sync_mss(newsk, TCP_PINFO(sk)->pmtu_cookie); return newsk; } - opt = sk->net_pinfo.af_inet6.opt; + opt = IP6_PINFO(sk)->opt; if (tcp_acceptq_is_full(sk)) goto out_overflow; - if (sk->net_pinfo.af_inet6.rxopt.bits.srcrt == 2 && + if (IP6_PINFO(sk)->rxopt.bits.srcrt == 2 && opt == NULL && req->af.v6_req.pktopts) { struct inet6_skb_parm *rxopt = (struct inet6_skb_parm *)req->af.v6_req.pktopts->cb; if (rxopt->srcrt) @@ -1309,9 +1310,9 @@ ip6_dst_store(newsk, dst, NULL); sk->route_caps = dst->dev->features&~NETIF_F_IP_CSUM; - newtp = &(newsk->tp_pinfo.af_tcp); + newtp = TCP_PINFO(newsk); - np = &newsk->net_pinfo.af_inet6; + np = IP6_PINFO(newsk); ipv6_addr_copy(&np->daddr, &req->af.v6_req.rmt_addr); ipv6_addr_copy(&np->saddr, &req->af.v6_req.loc_addr); ipv6_addr_copy(&np->rcv_saddr, &req->af.v6_req.loc_addr); @@ -1321,10 +1322,10 @@ First: no IPv4 options. */ - newsk->protinfo.af_inet.opt = NULL; + IP_SK(newsk)->opt = NULL; /* Clone RX bits */ - np->rxopt.all = sk->net_pinfo.af_inet6.rxopt.all; + np->rxopt.all = IP6_PINFO(sk)->rxopt.all; /* Clone pktoptions received with SYN */ np->pktoptions = NULL; @@ -1347,7 +1348,7 @@ */ if (opt) { np->opt = ipv6_dup_options(newsk, opt); - if (opt != sk->net_pinfo.af_inet6.opt) + if (opt != IP6_PINFO(sk)->opt) sock_kfree_s(sk, opt, opt->tot_len); } @@ -1372,7 +1373,7 @@ NET_INC_STATS_BH(ListenOverflows); out: NET_INC_STATS_BH(ListenDrops); - if (opt && opt != sk->net_pinfo.af_inet6.opt) + if (opt && opt != IP6_PINFO(sk)->opt) sock_kfree_s(sk, opt, opt->tot_len); dst_release(dst); return NULL; @@ -1451,7 +1452,7 @@ by tcp. Feel free to propose better solution. --ANK (980728) */ - if (sk->net_pinfo.af_inet6.rxopt.all) + if (IP6_PINFO(sk)->rxopt.all) opt_skb = skb_clone(skb, GFP_ATOMIC); if (sk->state == TCP_ESTABLISHED) { /* Fast path */ @@ -1514,18 +1515,18 @@ 3. socket is not in passive state. 4. Finally, it really contains options, which user wants to receive. */ - if (TCP_SKB_CB(opt_skb)->end_seq == sk->tp_pinfo.af_tcp.rcv_nxt && + if (TCP_SKB_CB(opt_skb)->end_seq == TCP_PINFO(sk)->rcv_nxt && !((1<state)&(TCPF_CLOSE|TCPF_LISTEN))) { - if (sk->net_pinfo.af_inet6.rxopt.bits.rxinfo) - sk->net_pinfo.af_inet6.mcast_oif = tcp_v6_iif(opt_skb); - if (sk->net_pinfo.af_inet6.rxopt.bits.rxhlim) - sk->net_pinfo.af_inet6.mcast_hops = opt_skb->nh.ipv6h->hop_limit; + if (IP6_PINFO(sk)->rxopt.bits.rxinfo) + IP6_PINFO(sk)->mcast_oif = tcp_v6_iif(opt_skb); + if (IP6_PINFO(sk)->rxopt.bits.rxhlim) + IP6_PINFO(sk)->mcast_hops = opt_skb->nh.ipv6h->hop_limit; if (ipv6_opt_accepted(sk, opt_skb)) { skb_set_owner_r(opt_skb, sk); - opt_skb = xchg(&sk->net_pinfo.af_inet6.pktoptions, opt_skb); + opt_skb = xchg(&IP6_PINFO(sk)->pktoptions, opt_skb); } else { __kfree_skb(opt_skb); - opt_skb = xchg(&sk->net_pinfo.af_inet6.pktoptions, NULL); + opt_skb = xchg(&IP6_PINFO(sk)->pktoptions, NULL); } } @@ -1655,7 +1656,7 @@ { int err; struct dst_entry *dst; - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); dst = __sk_dst_check(sk, np->dst_cookie); @@ -1694,7 +1695,7 @@ static int tcp_v6_xmit(struct sk_buff *skb) { struct sock *sk = skb->sk; - struct ipv6_pinfo * np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo * np = IP6_PINFO(sk); struct flowi fl; struct dst_entry *dst; @@ -1736,7 +1737,7 @@ static void v6_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr) { - struct ipv6_pinfo * np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo * np = IP6_PINFO(sk); struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) uaddr; sin6->sin6_family = AF_INET6; @@ -1798,7 +1799,7 @@ */ static int tcp_v6_init_sock(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); skb_queue_head_init(&tp->out_of_order_queue); tcp_init_xmit_timers(sk); @@ -1825,7 +1826,7 @@ sk->state = TCP_CLOSE; - sk->tp_pinfo.af_tcp.af_specific = &ipv6_specific; + TCP_PINFO(sk)->af_specific = &ipv6_specific; sk->write_space = tcp_write_space; sk->use_write_queue = 1; @@ -1840,7 +1841,7 @@ static int tcp_v6_destroy_sock(struct sock *sk) { - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); tcp_clear_xmit_timers(sk); @@ -1904,10 +1905,10 @@ __u16 destp, srcp; int timer_active; unsigned long timer_expires; - struct tcp_opt *tp = &sp->tp_pinfo.af_tcp; + struct tcp_opt *tp = TCP_PINFO(sp); - dest = &sp->net_pinfo.af_inet6.daddr; - src = &sp->net_pinfo.af_inet6.rcv_saddr; + dest = &IP6_PINFO(sp)->daddr; + src = &IP6_PINFO(sp)->rcv_saddr; destp = ntohs(sp->dport); srcp = ntohs(sp->sport); if (tp->pending == TCP_TIME_RETRANS) { @@ -2003,7 +2004,7 @@ for (sk = tcp_listening_hash[i]; sk; sk = sk->next, num++) { struct open_request *req; int uid; - struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + struct tcp_opt *tp = TCP_PINFO(sk); if (sk->family != PF_INET6) continue; @@ -2121,13 +2122,10 @@ static struct inet6_protocol tcpv6_protocol = { - tcp_v6_rcv, /* TCP handler */ - tcp_v6_err, /* TCP error control */ - NULL, /* next */ - IPPROTO_TCP, /* protocol ID */ - 0, /* copy */ - NULL, /* data */ - "TCPv6" /* name */ + handler: tcp_v6_rcv, + err_handler: tcp_v6_err, + protocol: IPPROTO_TCP, + name: "TCPv6", }; extern struct proto_ops inet6_stream_ops; diff -uNr linux-2.5.1/net/ipv6/udp.c linux-2.5.1.acme/net/ipv6/udp.c --- linux-2.5.1/net/ipv6/udp.c Fri Sep 7 15:01:21 2001 +++ linux-2.5.1.acme/net/ipv6/udp.c Wed Dec 19 23:44:48 2001 @@ -98,7 +98,7 @@ udp_port_rover = snum = result; } else { struct sock *sk2; - int addr_type = ipv6_addr_type(&sk->net_pinfo.af_inet6.rcv_saddr); + int addr_type = ipv6_addr_type(&IP6_PINFO(sk)->rcv_saddr); for (sk2 = udp_hash[snum & (UDP_HTABLE_SIZE - 1)]; sk2 != NULL; @@ -108,8 +108,8 @@ sk2->bound_dev_if == sk->bound_dev_if && (!sk2->rcv_saddr || addr_type == IPV6_ADDR_ANY || - !ipv6_addr_cmp(&sk->net_pinfo.af_inet6.rcv_saddr, - &sk2->net_pinfo.af_inet6.rcv_saddr) || + !ipv6_addr_cmp(&IP6_PINFO(sk)->rcv_saddr, + &IP6_PINFO(sk2)->rcv_saddr) || (addr_type == IPV6_ADDR_MAPPED && sk2->family == AF_INET && sk->rcv_saddr == sk2->rcv_saddr)) && @@ -167,7 +167,7 @@ for(sk = udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]; sk != NULL; sk = sk->next) { if((sk->num == hnum) && (sk->family == PF_INET6)) { - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); int score = 0; if(sk->dport) { if(sk->dport != sport) @@ -211,7 +211,7 @@ int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct in6_addr *daddr; struct in6_addr saddr; struct dst_entry *dst; @@ -418,13 +418,13 @@ if (skb->protocol == __constant_htons(ETH_P_IP)) { ipv6_addr_set(&sin6->sin6_addr, 0, 0, __constant_htonl(0xffff), skb->nh.iph->saddr); - if (sk->protinfo.af_inet.cmsg_flags) + if (IP_SK(sk)->cmsg_flags) ip_cmsg_recv(msg, skb); } else { memcpy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr, sizeof(struct in6_addr)); - if (sk->net_pinfo.af_inet6.rxopt.all) + if (IP6_PINFO(sk)->rxopt.all) datagram_recv_ctl(sk, msg, skb); if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) { struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb; @@ -478,14 +478,14 @@ return; if (!icmpv6_err_convert(type, code, &err) && - !sk->net_pinfo.af_inet6.recverr) + !IP6_PINFO(sk)->recverr) goto out; if (sk->state!=TCP_ESTABLISHED && - !sk->net_pinfo.af_inet6.recverr) + !IP6_PINFO(sk)->recverr) goto out; - if (sk->net_pinfo.af_inet6.recverr) + if (IP6_PINFO(sk)->recverr) ipv6_icmp_error(sk, skb, err, uh->dest, ntohl(info), (u8 *)(uh+1)); sk->err = err; @@ -527,7 +527,7 @@ unsigned short num = ntohs(loc_port); for(; s; s = s->next) { if(s->num == num) { - struct ipv6_pinfo *np = &s->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(s); if(s->dport) { if(s->dport != rmt_port) continue; @@ -755,7 +755,7 @@ { struct ipv6_txoptions opt_space; struct udpv6fakehdr udh; - struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6; + struct ipv6_pinfo *np = IP6_PINFO(sk); struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) msg->msg_name; struct ipv6_txoptions *opt = NULL; struct ip6_flowlabel *flowlabel = NULL; @@ -805,8 +805,8 @@ /* Otherwise it will be difficult to maintain sk->dst_cache. */ if (sk->state == TCP_ESTABLISHED && - !ipv6_addr_cmp(daddr, &sk->net_pinfo.af_inet6.daddr)) - daddr = &sk->net_pinfo.af_inet6.daddr; + !ipv6_addr_cmp(daddr, &IP6_PINFO(sk)->daddr)) + daddr = &IP6_PINFO(sk)->daddr; if (addr_len >= sizeof(struct sockaddr_in6) && sin6->sin6_scope_id && @@ -817,7 +817,7 @@ return -ENOTCONN; udh.uh.dest = sk->dport; - daddr = &sk->net_pinfo.af_inet6.daddr; + daddr = &IP6_PINFO(sk)->daddr; fl.fl6_flowlabel = np->flow_label; } @@ -910,8 +910,8 @@ struct in6_addr *dest, *src; __u16 destp, srcp; - dest = &sp->net_pinfo.af_inet6.daddr; - src = &sp->net_pinfo.af_inet6.rcv_saddr; + dest = &IP6_PINFO(sp)->daddr; + src = &IP6_PINFO(sp)->rcv_saddr; destp = ntohs(sp->dport); srcp = ntohs(sp->sport); sprintf(tmpbuf, diff -uNr linux-2.5.1/net/ipx/af_ipx.c linux-2.5.1.acme/net/ipx/af_ipx.c --- linux-2.5.1/net/ipx/af_ipx.c Sun Sep 30 16:26:13 2001 +++ linux-2.5.1.acme/net/ipx/af_ipx.c Wed Dec 19 23:44:48 2001 @@ -73,6 +73,9 @@ * Petr Vandrovec for review and good suggestions. (acme) * Revision 047: Cleanups, CodingStyle changes, move the ncp connection * hack out of line (acme) + * Revision 048: Use sk->protinfo to store the pointer to IPX private + * area, remove af_ipx from sk->protinfo and move ipx_opt + * to include/net/ipx.h, use IPX_SK like DecNET, etc * * Protect the module by a MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT * pair. Also, now usage count is managed this way @@ -103,6 +106,7 @@ #include #include #include +#include #include #include #include @@ -221,7 +225,7 @@ ipx_interface *intrfc; /* Determine interface with which socket is associated */ - intrfc = sk->protinfo.af_ipx.intrfc; + intrfc = IPX_SK(sk)->intrfc; if (!intrfc) goto out; @@ -323,7 +327,7 @@ ipxitf_hold(intrfc); sock_hold(sk); spin_lock_bh(&intrfc->if_sklist_lock); - sk->protinfo.af_ipx.intrfc = intrfc; + IPX_SK(sk)->intrfc = intrfc; sk->next = NULL; if (!intrfc->if_sklist) intrfc->if_sklist = sk; @@ -343,7 +347,7 @@ { struct sock *s = intrfc->if_sklist; - while (s && s->protinfo.af_ipx.port != port) + while (s && IPX_SK(s)->port != port) s = s->next; return s; @@ -375,8 +379,8 @@ s = intrfc->if_sklist; while (s) { - if (s->protinfo.af_ipx.port == port && - !memcmp(node, s->protinfo.af_ipx.node, IPX_NODE_LEN)) + if (IPX_SK(s)->port == port && + !memcmp(node, IPX_SK(s)->node, IPX_NODE_LEN)) break; s = s->next; } @@ -401,8 +405,8 @@ for (s = intrfc->if_sklist; s;) { s->err = ENOLINK; s->error_report(s); - s->protinfo.af_ipx.intrfc = NULL; - s->protinfo.af_ipx.port = 0; + IPX_SK(s)->intrfc = NULL; + IPX_SK(s)->port = 0; s->zapped = 1; /* Indicates it is no longer bound */ t = s; s = s->next; @@ -491,10 +495,9 @@ s = intrfc->if_sklist; while (s) { - if (s->protinfo.af_ipx.port == ipx->ipx_dest.sock && + if (IPX_SK(s)->port == ipx->ipx_dest.sock && (is_broadcast || !memcmp(ipx->ipx_dest.node, - s->protinfo.af_ipx.node, - IPX_NODE_LEN))) { + IPX_SK(s)->node, IPX_NODE_LEN))) { /* We found a socket to which to send */ struct sk_buff *skb1; @@ -550,7 +553,7 @@ * SIOCIPXNCPCONN. */ spin_lock_bh(&intrfc->if_sklist_lock); for (sk = intrfc->if_sklist; - sk && sk->protinfo.af_ipx.ipx_ncp_conn != connection; + sk && IPX_SK(sk)->ipx_ncp_conn != connection; sk = sk->next); if (sk) sock_hold(sk); @@ -1548,21 +1551,21 @@ IPX_SKB_CB(skb)->last_hop.index = -1; #ifdef CONFIG_IPX_INTERN - IPX_SKB_CB(skb)->ipx_source_net = sk->protinfo.af_ipx.intrfc->if_netnum; - memcpy(ipx->ipx_source.node, sk->protinfo.af_ipx.node, IPX_NODE_LEN); + IPX_SKB_CB(skb)->ipx_source_net = IPX_SK(sk)->intrfc->if_netnum; + memcpy(ipx->ipx_source.node, IPX_SK(sk)->node, IPX_NODE_LEN); #else - err = ntohs(sk->protinfo.af_ipx.port); + err = ntohs(IPX_SK(sk)->port); if (err == 0x453 || err == 0x452) { /* RIP/SAP special handling for mars_nwe */ IPX_SKB_CB(skb)->ipx_source_net = intrfc->if_netnum; memcpy(ipx->ipx_source.node, intrfc->if_node, IPX_NODE_LEN); } else { - IPX_SKB_CB(skb)->ipx_source_net = - sk->protinfo.af_ipx.intrfc->if_netnum; - memcpy(ipx->ipx_source.node, sk->protinfo.af_ipx.intrfc->if_node, IPX_NODE_LEN); + IPX_SKB_CB(skb)->ipx_source_net = IPX_SK(sk)->intrfc->if_netnum; + memcpy(ipx->ipx_source.node, IPX_SK(sk)->intrfc->if_node, + IPX_NODE_LEN); } #endif /* CONFIG_IPX_INTERN */ - ipx->ipx_source.sock = sk->protinfo.af_ipx.port; + ipx->ipx_source.sock = IPX_SK(sk)->port; IPX_SKB_CB(skb)->ipx_dest_net = usipx->sipx_network; memcpy(ipx->ipx_dest.node, usipx->sipx_node, IPX_NODE_LEN); ipx->ipx_dest.sock = usipx->sipx_port; @@ -1746,18 +1749,15 @@ #ifdef CONFIG_IPX_INTERN len += sprintf(buffer + len, "%08lX:%02X%02X%02X%02X%02X%02X:%04X ", - (unsigned long) htonl(s->protinfo.af_ipx.intrfc->if_netnum), - s->protinfo.af_ipx.node[0], - s->protinfo.af_ipx.node[1], - s->protinfo.af_ipx.node[2], - s->protinfo.af_ipx.node[3], - s->protinfo.af_ipx.node[4], - s->protinfo.af_ipx.node[5], - htons(s->protinfo.af_ipx.port)); + (unsigned long)htonl(IPX_SK(s)->intrfc->if_netnum), + IPX_SK(s)->node[0], IPX_SK(s)->node[1], + IPX_SK(s)->node[2], IPX_SK(s)->node[3], + IPX_SK(s)->node[4], IPX_SK(s)->node[5], + htons(IPX_SK(s)->port)); #else len += sprintf(buffer + len, "%08lX:%04X ", (unsigned long) htonl(i->if_netnum), - htons(s->protinfo.af_ipx.port)); + htons(IPX_SK(s)->port)); #endif /* CONFIG_IPX_INTERN */ if (s->state != TCP_ESTABLISHED) len += sprintf(buffer + len, "%-28s", @@ -1765,14 +1765,14 @@ else { len += sprintf(buffer + len, "%08lX:%02X%02X%02X%02X%02X%02X:%04X ", - (unsigned long) htonl(s->protinfo.af_ipx.dest_addr.net), - s->protinfo.af_ipx.dest_addr.node[0], - s->protinfo.af_ipx.dest_addr.node[1], - s->protinfo.af_ipx.dest_addr.node[2], - s->protinfo.af_ipx.dest_addr.node[3], - s->protinfo.af_ipx.dest_addr.node[4], - s->protinfo.af_ipx.dest_addr.node[5], - htons(s->protinfo.af_ipx.dest_addr.sock)); + (unsigned long)htonl(IPX_SK(s)->dest_addr.net), + IPX_SK(s)->dest_addr.node[0], + IPX_SK(s)->dest_addr.node[1], + IPX_SK(s)->dest_addr.node[2], + IPX_SK(s)->dest_addr.node[3], + IPX_SK(s)->dest_addr.node[4], + IPX_SK(s)->dest_addr.node[5], + htons(IPX_SK(s)->dest_addr.sock)); } len += sprintf(buffer + len, "%08X %08X ", @@ -1868,7 +1868,7 @@ if (!(level == SOL_IPX && optname == IPX_TYPE)) goto out; - sk->protinfo.af_ipx.type = opt; + IPX_SK(sk)->type = opt; ret = 0; out: return ret; } @@ -1884,7 +1884,7 @@ if (!(level == SOL_IPX && optname == IPX_TYPE)) goto out; - val = sk->protinfo.af_ipx.type; + val = IPX_SK(sk)->type; ret = -EFAULT; if (get_user(len, optlen)) @@ -1906,14 +1906,19 @@ static int ipx_create(struct socket *sock, int protocol) { int ret = -ESOCKTNOSUPPORT; + struct ipx_opt *ipx = NULL; struct sock *sk; + MOD_INC_USE_COUNT; switch (sock->type) { case SOCK_DGRAM: sk = sk_alloc(PF_IPX, GFP_KERNEL, 1); ret = -ENOMEM; if (!sk) - goto out; + goto decmod; + ipx = kmalloc(sizeof(*ipx), GFP_KERNEL); + if (!ipx) + goto outsk; sock->ops = &ipx_dgram_ops; break; @@ -1924,12 +1929,12 @@ */ if (spx_family_ops) { ret = spx_family_ops->create(sock, protocol); - goto out; + goto decmod; } /* Fall through if SPX is not loaded */ case SOCK_STREAM: /* Allow higher levels to piggyback */ default: - goto out; + goto decmod; } #ifdef IPX_REFCNT_DEBUG atomic_inc(&ipx_sock_nr); @@ -1937,12 +1942,13 @@ atomic_read(&ipx_sock_nr)); #endif sock_init_data(sock, sk); - sk->destruct = NULL; - sk->no_check = 1; /* Checksum off by default */ - - MOD_INC_USE_COUNT; + sk->no_check = 1; /* Checksum off by default */ + IPX_SK(sk) = ipx; ret = 0; out: return ret; +outsk: sk_free(sk); +decmod: MOD_DEC_USE_COUNT; + goto out; } static int ipx_release(struct socket *sock) @@ -2016,7 +2022,7 @@ !capable(CAP_NET_ADMIN)) goto out_put; - sk->protinfo.af_ipx.port = addr->sipx_port; + IPX_SK(sk)->port = addr->sipx_port; #ifdef CONFIG_IPX_INTERN if (intrfc == ipx_internal_net) { @@ -2029,16 +2035,13 @@ if (!memcmp(addr->sipx_node, ipx_broadcast_node, IPX_NODE_LEN)) goto out_put; if (!memcmp(addr->sipx_node, ipx_this_node, IPX_NODE_LEN)) - memcpy(sk->protinfo.af_ipx.node, intrfc->if_node, - IPX_NODE_LEN); + memcpy(IPX_SK(sk)->node, intrfc->if_node, IPX_NODE_LEN); else - memcpy(sk->protinfo.af_ipx.node, addr->sipx_node, - IPX_NODE_LEN); + memcpy(IPX_SK(sk)->node, addr->sipx_node, IPX_NODE_LEN); ret = -EADDRINUSE; - if (ipxitf_find_internal_socket(intrfc, - sk->protinfo.af_ipx.node, - sk->protinfo.af_ipx.port)) { + if (ipxitf_find_internal_socket(intrfc, IPX_SK(sk)->node, + IPX_SK(sk)->port)) { SOCK_DEBUG(sk, "IPX: bind failed because port %X in use.\n", ntohs((int)addr->sipx_port)); @@ -2050,8 +2053,7 @@ * with the ipx routing ioctl() */ - memcpy(sk->protinfo.af_ipx.node, intrfc->if_node, - IPX_NODE_LEN); + memcpy(IPX_SK(sk)->node, intrfc->if_node, IPX_NODE_LEN); ret = -EADDRINUSE; if (ipxitf_find_socket(intrfc, addr->sipx_port)) { @@ -2102,7 +2104,7 @@ addr = (struct sockaddr_ipx *)uaddr; /* put the autobinding in */ - if (!sk->protinfo.af_ipx.port) { + if (!IPX_SK(sk)->port) { struct sockaddr_ipx uaddr; uaddr.sipx_port = 0; @@ -2110,9 +2112,9 @@ #ifdef CONFIG_IPX_INTERN ret = -ENETDOWN; - if (!sk->protinfo.af_ipx.intrfc) + if (!IPX_SK(sk)->intrfc) goto out; /* Someone zonked the iface */ - memcpy(uaddr.sipx_node, sk->protinfo.af_ipx.intrfc->if_node, + memcpy(uaddr.sipx_node, IPX_SK(sk)->intrfc->if_node, IPX_NODE_LEN); #endif /* CONFIG_IPX_INTERN */ @@ -2129,11 +2131,10 @@ if (!rt && !(!addr->sipx_network && ipx_primary_net)) goto out; - sk->protinfo.af_ipx.dest_addr.net = addr->sipx_network; - sk->protinfo.af_ipx.dest_addr.sock = addr->sipx_port; - memcpy(sk->protinfo.af_ipx.dest_addr.node, - addr->sipx_node, IPX_NODE_LEN); - sk->protinfo.af_ipx.type = addr->sipx_type; + IPX_SK(sk)->dest_addr.net = addr->sipx_network; + IPX_SK(sk)->dest_addr.sock = addr->sipx_port; + memcpy(IPX_SK(sk)->dest_addr.node, addr->sipx_node, IPX_NODE_LEN); + IPX_SK(sk)->type = addr->sipx_type; if (sock->type == SOCK_DGRAM) { sock->state = SS_CONNECTED; @@ -2162,20 +2163,17 @@ if (sk->state != TCP_ESTABLISHED) goto out; - addr = &sk->protinfo.af_ipx.dest_addr; + addr = &IPX_SK(sk)->dest_addr; sipx.sipx_network = addr->net; sipx.sipx_port = addr->sock; memcpy(sipx.sipx_node, addr->node, IPX_NODE_LEN); } else { - if (sk->protinfo.af_ipx.intrfc) { - sipx.sipx_network = - sk->protinfo.af_ipx.intrfc->if_netnum; + if (IPX_SK(sk)->intrfc) { + sipx.sipx_network = IPX_SK(sk)->intrfc->if_netnum; #ifdef CONFIG_IPX_INTERN - memcpy(sipx.sipx_node, sk->protinfo.af_ipx.node, - IPX_NODE_LEN); + memcpy(sipx.sipx_node, IPX_SK(sk)->node, IPX_NODE_LEN); #else - memcpy(sipx.sipx_node, - sk->protinfo.af_ipx.intrfc->if_node, + memcpy(sipx.sipx_node, IPX_SK(sk)->intrfc->if_node, IPX_NODE_LEN); #endif /* CONFIG_IPX_INTERN */ @@ -2184,11 +2182,11 @@ memset(sipx.sipx_node, '\0', IPX_NODE_LEN); } - sipx.sipx_port = sk->protinfo.af_ipx.port; + sipx.sipx_port = IPX_SK(sk)->port; } sipx.sipx_family = AF_IPX; - sipx.sipx_type = sk->protinfo.af_ipx.type; + sipx.sipx_type = IPX_SK(sk)->type; memcpy(uaddr, &sipx, sizeof(sipx)); ret = 0; @@ -2263,17 +2261,16 @@ goto out; if (usipx) { - if (!sk->protinfo.af_ipx.port) { + if (!IPX_SK(sk)->port) { struct sockaddr_ipx uaddr; uaddr.sipx_port = 0; uaddr.sipx_network = 0; #ifdef CONFIG_IPX_INTERN ret = -ENETDOWN; - if (!sk->protinfo.af_ipx.intrfc) + if (!IPX_SK(sk)->intrfc) goto out; /* Someone zonked the iface */ - memcpy(uaddr.sipx_node, - sk->protinfo.af_ipx.intrfc->if_node, + memcpy(uaddr.sipx_node, IPX_SK(sk)->intrfc->if_node, IPX_NODE_LEN); #endif ret = ipx_bind(sock, (struct sockaddr *)&uaddr, @@ -2293,11 +2290,11 @@ usipx = &local_sipx; usipx->sipx_family = AF_IPX; - usipx->sipx_type = sk->protinfo.af_ipx.type; - usipx->sipx_port = sk->protinfo.af_ipx.dest_addr.sock; - usipx->sipx_network = sk->protinfo.af_ipx.dest_addr.net; - memcpy(usipx->sipx_node, sk->protinfo.af_ipx.dest_addr.node, - IPX_NODE_LEN); + usipx->sipx_type = IPX_SK(sk)->type; + usipx->sipx_port = IPX_SK(sk)->dest_addr.sock; + usipx->sipx_network = IPX_SK(sk)->dest_addr.net; + memcpy(usipx->sipx_node, IPX_SK(sk)->dest_addr.node, + IPX_NODE_LEN); } ret = ipxrtr_route_packet(sk, usipx, msg->msg_iov, len, @@ -2318,7 +2315,7 @@ int copied, err; /* put the autobinding in */ - if (!sk->protinfo.af_ipx.port) { + if (!IPX_SK(sk)->port) { struct sockaddr_ipx uaddr; uaddr.sipx_port = 0; @@ -2326,10 +2323,10 @@ #ifdef CONFIG_IPX_INTERN err = -ENETDOWN; - if (!sk->protinfo.af_ipx.intrfc) + if (!IPX_SK(sk)->intrfc) goto out; /* Someone zonked the iface */ - memcpy(uaddr.sipx_node, - sk->protinfo.af_ipx.intrfc->if_node, IPX_NODE_LEN); + memcpy(uaddr.sipx_node, IPX_SK(sk)->intrfc->if_node, + IPX_NODE_LEN); #endif /* CONFIG_IPX_INTERN */ err = ipx_bind(sock, (struct sockaddr *)&uaddr, @@ -2423,7 +2420,7 @@ */ if (!capable(CAP_NET_ADMIN)) return -EPERM; - return get_user(sk->protinfo.af_ipx.ipx_ncp_conn, + return get_user(IPX_SK(sk)->ipx_ncp_conn, (const unsigned short *)(arg)); case SIOCGSTAMP: { @@ -2536,10 +2533,14 @@ static unsigned char ipx_8022_type = 0xE0; static unsigned char ipx_snap_id[5] = { 0x0, 0x0, 0x0, 0x81, 0x37 }; -static char banner[] __initdata = - KERN_INFO "NET4: Linux IPX 0.47 for NET4.0\n" +static char ipx_banner[] __initdata = + KERN_INFO "NET4: Linux IPX 0.48 for NET4.0\n" KERN_INFO "IPX Portions Copyright (c) 1995 Caldera, Inc.\n" \ KERN_INFO "IPX Portions Copyright (c) 2000, 2001 Conectiva, Inc.\n"; +static char ipx_llc_err_msg[] __initdata = + KERN_CRIT "IPX: Unable to register with 802.2\n"; +static char ipx_snap_err_msg[] __initdata = + KERN_CRIT "IPX: Unable to register with SNAP\n"; static int __init ipx_init(void) { @@ -2553,11 +2554,11 @@ p8022_datalink = register_8022_client(ipx_8022_type, ipx_rcv); if (!p8022_datalink) - printk(KERN_CRIT "IPX: Unable to register with 802.2\n"); + printk(ipx_llc_err_msg); pSNAP_datalink = register_snap_client(ipx_snap_id, ipx_rcv); if (!pSNAP_datalink) - printk(KERN_CRIT "IPX: Unable to register with SNAP\n"); + printk(ipx_snap_err_msg); register_netdevice_notifier(&ipx_dev_notifier); ipx_register_sysctl(); @@ -2566,7 +2567,7 @@ proc_net_create("ipx_interface", 0, ipx_interface_get_info); proc_net_create("ipx_route", 0, ipx_rt_get_info); #endif - printk(banner); + printk(ipx_banner); return 0; } diff -uNr linux-2.5.1/net/ipx/af_spx.c linux-2.5.1.acme/net/ipx/af_spx.c --- linux-2.5.1/net/ipx/af_spx.c Thu Sep 13 21:16:23 2001 +++ linux-2.5.1.acme/net/ipx/af_spx.c Wed Dec 19 23:44:48 2001 @@ -20,6 +20,8 @@ * Added spx_datagram_poll() so that select() * works now on SPX sockets. Added updating * of the alloc count to follow rmt_seq. + * Arnaldo C. Melo : Use a private slabcache for the old tp_pinfo + * struct sock member, use SPX_PINFO and IPX_SK * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -34,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -60,7 +63,7 @@ static unsigned int spx_datagram_poll(struct file * file, struct socket *sock, poll_table *wait) { struct sock *sk = sock->sk; - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); unsigned int mask; poll_wait(file, sk->sleep, wait); @@ -95,7 +98,7 @@ /* Create the SPX specific data */ static int spx_sock_init(struct sock *sk) { - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); pdata->state = SPX_CLOSED; pdata->sequence = 0; @@ -159,7 +162,7 @@ void spx_close_socket(struct sock *sk) { - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); pdata->state = SPX_CLOSED; sk->state = TCP_CLOSE; @@ -169,7 +172,7 @@ void spx_destroy_socket(struct sock *sk) { - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); struct sk_buff *skb; ipx_remove_socket(sk); @@ -190,7 +193,7 @@ static int spx_release(struct socket *sock) { struct sock *sk = sock->sk; - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); if(sk == NULL) return (0); @@ -285,7 +288,7 @@ sk->ack_backlog--; newsock->sk = newsk; newsk->state = TCP_ESTABLISHED; - newsk->protinfo.af_ipx.dest_addr = newsk->tp_pinfo.af_spx.dest_addr; + IPX_SK(newsk)->dest_addr = SPX_PINFO(newsk)->dest_addr; return (0); } @@ -295,7 +298,7 @@ int addr_len, int flags) { struct sock *sk = sock->sk; - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); struct sockaddr_ipx src; struct sk_buff *skb; int size, err; @@ -313,7 +316,7 @@ if(err) return (err); - pdata->dest_addr = sk->protinfo.af_ipx.dest_addr; + pdata->dest_addr = IPX_SK(sk)->dest_addr; pdata->state = SPX_CONNECTING; sock->state = SS_CONNECTING; sk->state = TCP_SYN_SENT; @@ -423,7 +426,7 @@ /* SPX packet transmit engine */ static int spx_transmit(struct sock *sk, struct sk_buff *skb, int type, int len) { - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); struct ipxspxhdr *ipxh; unsigned long flags; int err; @@ -520,7 +523,7 @@ static void spx_watchdog(unsigned long data) { struct sock *sk = (struct sock*)data; - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); del_timer(&pdata->watchdog); if(pdata->state == SPX_CLOSED) @@ -541,7 +544,7 @@ static void spx_retransmit(unsigned long data) { struct sock *sk = (struct sock*)data; - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); struct sk_buff *skb; unsigned long flags; int err; @@ -614,7 +617,7 @@ { struct sk_buff *skb; struct ipxspxhdr *ipxh; - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); skb = skb_dequeue(&sk->receive_queue); if(skb == NULL) @@ -736,7 +739,7 @@ if(flags&~MSG_DONTWAIT) return (-EINVAL); - offset = ipx_if_offset(sk->tp_pinfo.af_spx.dest_addr.net); + offset = ipx_if_offset(SPX_PINFO(sk)->dest_addr.net); size = offset + sizeof(struct ipxspxhdr) + len; cli(); @@ -770,7 +773,7 @@ struct sk_buff *skb; struct ipxspxhdr *ispxh; struct sock *sk = sock->sk; - struct spx_opt *pdata = &sk->tp_pinfo.af_spx; + struct spx_opt *pdata = SPX_PINFO(sk); struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)msg->msg_name; int copied, err; @@ -906,8 +909,10 @@ SOCKOPS_WRAP(spx, PF_IPX); static struct net_proto_family spx_family_ops = { - family: PF_IPX, - create: spx_create, + family: PF_IPX, + create: spx_create, + sk_size: sizeof(struct sock) + sizeof(struct ipx_opt) + + sizeof(struct spx_opt), }; static char banner[] __initdata = KERN_INFO "NET4: Sequenced Packet eXchange (SPX) 0.02 for Linux NET4.0\n"; @@ -917,6 +922,16 @@ int error; connids = (__u16)jiffies; /* initalize random */ + + /* allocate our sock slab cache */ + + spx_family_ops.sk_cachep = kmem_cache_create("spx_sock", + spx_family_ops.sk_size, + 0, SLAB_HWCACHE_ALIGN, + 0, 0); + if (!spx_family_ops.sk_cachep) + printk(KERN_CRIT __FUNCTION__ + ": Cannot create spx_sock SLAB cache!\n"); error = ipx_register_spx(&ipx_operations, &spx_family_ops); if (error) diff -uNr linux-2.5.1/net/irda/af_irda.c linux-2.5.1.acme/net/irda/af_irda.c --- linux-2.5.1/net/irda/af_irda.c Wed Dec 19 23:27:58 2001 +++ linux-2.5.1.acme/net/irda/af_irda.c Wed Dec 19 23:44:48 2001 @@ -56,6 +56,7 @@ #include #include +#include #include #include @@ -728,7 +729,7 @@ { struct sockaddr_irda saddr; struct sock *sk = sock->sk; - struct irda_sock *self = sk->protinfo.irda; + struct irda_sock *self = IRDA_SK(sk); if (peer) { if (sk->state != TCP_ESTABLISHED) @@ -792,7 +793,7 @@ struct irda_sock *self; int err; - self = sk->protinfo.irda; + self = IRDA_SK(sk); ASSERT(self != NULL, return -1;); IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self); @@ -853,7 +854,7 @@ IRDA_DEBUG(2, __FUNCTION__ "()\n"); - self = sk->protinfo.irda; + self = IRDA_SK(sk); ASSERT(self != NULL, return -1;); err = irda_create(newsock, sk->protocol); @@ -891,7 +892,7 @@ newsk = newsock->sk; newsk->state = TCP_ESTABLISHED; - new = newsk->protinfo.irda; + new = IRDA_SK(newsk); ASSERT(new != NULL, return -1;); /* Now attach up the new socket */ @@ -956,7 +957,7 @@ struct irda_sock *self; int err; - self = sk->protinfo.irda; + self = IRDA_SK(sk); IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self); @@ -1098,7 +1099,7 @@ sk->family = PF_IRDA; sk->protocol = protocol; /* Link networking socket and IrDA socket structs together */ - sk->protinfo.irda = self; + IRDA_SK(sk) = self; self->sk = sk; switch (sock->type) { @@ -1208,9 +1209,9 @@ sk->state_change(sk); /* Destroy IrDA socket */ - irda_destroy_socket(sk->protinfo.irda); + irda_destroy_socket(IRDA_SK(sk)); /* Prevent sock_def_destruct() to create havoc */ - sk->protinfo.irda = NULL; + IRDA_SK(sk) = NULL; sock_orphan(sk); sock->sk = NULL; @@ -1281,7 +1282,7 @@ if (sk->state != TCP_ESTABLISHED) return -ENOTCONN; - self = sk->protinfo.irda; + self = IRDA_SK(sk); ASSERT(self != NULL, return -1;); /* Check if IrTTP is wants us to slow down */ @@ -1341,7 +1342,7 @@ IRDA_DEBUG(4, __FUNCTION__ "()\n"); - self = sk->protinfo.irda; + self = IRDA_SK(sk); ASSERT(self != NULL, return -1;); skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, @@ -1412,7 +1413,7 @@ IRDA_DEBUG(3, __FUNCTION__ "()\n"); - self = sk->protinfo.irda; + self = IRDA_SK(sk); ASSERT(self != NULL, return -1;); if (sock->flags & __SO_ACCEPTCON) @@ -1531,7 +1532,7 @@ if (sk->state != TCP_ESTABLISHED) return -ENOTCONN; - self = sk->protinfo.irda; + self = IRDA_SK(sk); ASSERT(self != NULL, return -1;); /* @@ -1594,7 +1595,7 @@ return -EPIPE; } - self = sk->protinfo.irda; + self = IRDA_SK(sk); ASSERT(self != NULL, return -1;); /* @@ -1639,7 +1640,7 @@ struct irda_sock *self; struct sock *sk = sock->sk; - self = sk->protinfo.irda; + self = IRDA_SK(sk); ASSERT(self != NULL, return -1;); IRDA_DEBUG(1, __FUNCTION__ "(%p)\n", self); @@ -1682,7 +1683,7 @@ IRDA_DEBUG(4, __FUNCTION__ "()\n"); - self = sk->protinfo.irda; + self = IRDA_SK(sk); poll_wait(file, sk->sleep, wait); mask = 0; @@ -1814,7 +1815,7 @@ struct ias_attrib * ias_attr; /* Attribute in IAS object */ int opt; - self = sk->protinfo.irda; + self = IRDA_SK(sk); ASSERT(self != NULL, return -1;); IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self); @@ -2119,7 +2120,7 @@ int err; int offset, total; - self = sk->protinfo.irda; + self = IRDA_SK(sk); IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self); @@ -2408,10 +2409,9 @@ return 0; } -static struct net_proto_family irda_family_ops = -{ - PF_IRDA, - irda_create +static struct net_proto_family irda_family_ops = { + family: PF_IRDA, + create: irda_create, }; static struct proto_ops SOCKOPS_WRAPPED(irda_stream_ops) = { diff -uNr linux-2.5.1/net/khttpd/accept.c linux-2.5.1.acme/net/khttpd/accept.c --- linux-2.5.1/net/khttpd/accept.c Sat Jan 22 17:54:58 2000 +++ linux-2.5.1.acme/net/khttpd/accept.c Wed Dec 19 23:44:48 2001 @@ -63,7 +63,7 @@ the allocation of a new socket. (Which doesn't seem to be used anyway) */ - if (Socket->sk->tp_pinfo.af_tcp.accept_queue==NULL) + if (TCP_PINFO(Socket->sk)->accept_queue==NULL) { return 0; } diff -uNr linux-2.5.1/net/khttpd/datasending.c linux-2.5.1.acme/net/khttpd/datasending.c --- linux-2.5.1/net/khttpd/datasending.c Mon Sep 10 11:58:35 2001 +++ linux-2.5.1.acme/net/khttpd/datasending.c Wed Dec 19 23:44:48 2001 @@ -171,8 +171,8 @@ if (CurrentRequest->sock->sk->state == TCP_ESTABLISHED || CurrentRequest->sock->sk->state == TCP_CLOSE_WAIT) { - CurrentRequest->sock->sk->tp_pinfo.af_tcp.nonagle = 0; - tcp_push_pending_frames(CurrentRequest->sock->sk,&(CurrentRequest->sock->sk->tp_pinfo.af_tcp)); + TCP_PINFO(CurrentRequest->sock->sk)->nonagle = 0; + tcp_push_pending_frames(CurrentRequest->sock->sk,TCP_PINFO(CurrentRequest->sock->sk)); } release_sock(CurrentRequest->sock->sk); diff -uNr linux-2.5.1/net/khttpd/prototypes.h linux-2.5.1.acme/net/khttpd/prototypes.h --- linux-2.5.1/net/khttpd/prototypes.h Wed Aug 15 05:22:18 2001 +++ linux-2.5.1.acme/net/khttpd/prototypes.h Wed Dec 19 23:44:48 2001 @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "structure.h" diff -uNr linux-2.5.1/net/khttpd/waitheaders.c linux-2.5.1.acme/net/khttpd/waitheaders.c --- linux-2.5.1/net/khttpd/waitheaders.c Mon Sep 10 11:57:00 2001 +++ linux-2.5.1.acme/net/khttpd/waitheaders.c Wed Dec 19 23:44:48 2001 @@ -255,7 +255,7 @@ } else /* Normal Case */ { - Request->sock->sk->tp_pinfo.af_tcp.nonagle = 2; /* this is TCP_CORK */ + TCP_PINFO(Request->sock->sk)->nonagle = 2; /* this is TCP_CORK */ if (Request->HTTPVER!=9) /* HTTP/0.9 doesn't allow a header */ SendHTTPHeader(Request); } diff -uNr linux-2.5.1/net/netlink/af_netlink.c linux-2.5.1.acme/net/netlink/af_netlink.c --- linux-2.5.1/net/netlink/af_netlink.c Fri Jun 29 23:38:26 2001 +++ linux-2.5.1.acme/net/netlink/af_netlink.c Wed Dec 19 23:44:48 2001 @@ -64,6 +64,8 @@ void (*data_ready)(struct sock *sk, int bytes); }; +#define NLK_SK(__sk) ((struct netlink_opt *)(__sk)->protinfo) + static struct sock *nl_table[MAX_LINKS]; static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait); @@ -89,9 +91,9 @@ } BUG_TRAP(atomic_read(&sk->rmem_alloc)==0); BUG_TRAP(atomic_read(&sk->wmem_alloc)==0); - BUG_TRAP(sk->protinfo.af_netlink->cb==NULL); + BUG_TRAP(NLK_SK(sk)->cb==NULL); - kfree(sk->protinfo.af_netlink); + kfree(NLK_SK(sk)); atomic_dec(&netlink_sock_nr); #ifdef NETLINK_REFCNT_DEBUG @@ -156,7 +158,7 @@ read_lock(&nl_table_lock); for (sk=nl_table[protocol]; sk; sk=sk->next) { - if (sk->protinfo.af_netlink->pid == pid) { + if (NLK_SK(sk)->pid == pid) { sock_hold(sk); read_unlock(&nl_table_lock); return sk; @@ -176,13 +178,13 @@ netlink_table_grab(); for (osk=nl_table[sk->protocol]; osk; osk=osk->next) { - if (osk->protinfo.af_netlink->pid == pid) + if (NLK_SK(osk)->pid == pid) break; } if (osk == NULL) { err = -EBUSY; - if (sk->protinfo.af_netlink->pid == 0) { - sk->protinfo.af_netlink->pid = pid; + if (NLK_SK(sk)->pid == 0) { + NLK_SK(sk)->pid = pid; sk->next = nl_table[sk->protocol]; nl_table[sk->protocol] = sk; sock_hold(sk); @@ -228,15 +230,15 @@ sock_init_data(sock,sk); - sk->protinfo.af_netlink = kmalloc(sizeof(struct netlink_opt), GFP_KERNEL); - if (sk->protinfo.af_netlink == NULL) { + NLK_SK(sk) = kmalloc(sizeof(struct netlink_opt), GFP_KERNEL); + if (NLK_SK(sk) == NULL) { sk_free(sk); return -ENOMEM; } - memset(sk->protinfo.af_netlink, 0, sizeof(struct netlink_opt)); + memset(NLK_SK(sk), 0, sizeof(struct netlink_opt)); - spin_lock_init(&sk->protinfo.af_netlink->cb_lock); - init_waitqueue_head(&sk->protinfo.af_netlink->wait); + spin_lock_init(&NLK_SK(sk)->cb_lock); + init_waitqueue_head(&NLK_SK(sk)->wait); sk->destruct = netlink_sock_destruct; atomic_inc(&netlink_sock_nr); @@ -253,21 +255,21 @@ netlink_remove(sk); - spin_lock(&sk->protinfo.af_netlink->cb_lock); - if (sk->protinfo.af_netlink->cb) { - sk->protinfo.af_netlink->cb->done(sk->protinfo.af_netlink->cb); - netlink_destroy_callback(sk->protinfo.af_netlink->cb); - sk->protinfo.af_netlink->cb = NULL; + spin_lock(&NLK_SK(sk)->cb_lock); + if (NLK_SK(sk)->cb) { + NLK_SK(sk)->cb->done(NLK_SK(sk)->cb); + netlink_destroy_callback(NLK_SK(sk)->cb); + NLK_SK(sk)->cb = NULL; __sock_put(sk); } - spin_unlock(&sk->protinfo.af_netlink->cb_lock); + spin_unlock(&NLK_SK(sk)->cb_lock); /* OK. Socket is unlinked, and, therefore, no new packets will arrive */ sock_orphan(sk); sock->sk = NULL; - wake_up_interruptible_all(&sk->protinfo.af_netlink->wait); + wake_up_interruptible_all(&NLK_SK(sk)->wait); skb_queue_purge(&sk->write_queue); @@ -285,7 +287,7 @@ retry: netlink_table_grab(); for (osk=nl_table[sk->protocol]; osk; osk=osk->next) { - if (osk->protinfo.af_netlink->pid == pid) { + if (NLK_SK(osk)->pid == pid) { /* Bind collision, search negative pid values. */ if (pid > 0) pid = -4096; @@ -299,7 +301,7 @@ err = netlink_insert(sk, pid); if (err == -EADDRINUSE) goto retry; - sk->protinfo.af_netlink->groups = 0; + NLK_SK(sk)->groups = 0; return 0; } @@ -316,23 +318,23 @@ if (nladdr->nl_groups && !capable(CAP_NET_ADMIN)) return -EPERM; - if (sk->protinfo.af_netlink->pid) { - if (nladdr->nl_pid != sk->protinfo.af_netlink->pid) + if (NLK_SK(sk)->pid) { + if (nladdr->nl_pid != NLK_SK(sk)->pid) return -EINVAL; - sk->protinfo.af_netlink->groups = nladdr->nl_groups; + NLK_SK(sk)->groups = nladdr->nl_groups; return 0; } if (nladdr->nl_pid == 0) { err = netlink_autobind(sock); if (err == 0) - sk->protinfo.af_netlink->groups = nladdr->nl_groups; + NLK_SK(sk)->groups = nladdr->nl_groups; return err; } err = netlink_insert(sk, nladdr->nl_pid); if (err == 0) - sk->protinfo.af_netlink->groups = nladdr->nl_groups; + NLK_SK(sk)->groups = nladdr->nl_groups; return err; } @@ -344,8 +346,8 @@ struct sockaddr_nl *nladdr=(struct sockaddr_nl*)addr; if (addr->sa_family == AF_UNSPEC) { - sk->protinfo.af_netlink->dst_pid = 0; - sk->protinfo.af_netlink->dst_groups = 0; + NLK_SK(sk)->dst_pid = 0; + NLK_SK(sk)->dst_groups = 0; return 0; } if (addr->sa_family != AF_NETLINK) @@ -355,12 +357,12 @@ if (nladdr->nl_groups && !capable(CAP_NET_ADMIN)) return -EPERM; - if (!sk->protinfo.af_netlink->pid) + if (!NLK_SK(sk)->pid) err = netlink_autobind(sock); if (err == 0) { - sk->protinfo.af_netlink->dst_pid = nladdr->nl_pid; - sk->protinfo.af_netlink->dst_groups = nladdr->nl_groups; + NLK_SK(sk)->dst_pid = nladdr->nl_pid; + NLK_SK(sk)->dst_groups = nladdr->nl_groups; } return 0; @@ -375,18 +377,18 @@ *addr_len = sizeof(*nladdr); if (peer) { - nladdr->nl_pid = sk->protinfo.af_netlink->dst_pid; - nladdr->nl_groups = sk->protinfo.af_netlink->dst_groups; + nladdr->nl_pid = NLK_SK(sk)->dst_pid; + nladdr->nl_groups = NLK_SK(sk)->dst_groups; } else { - nladdr->nl_pid = sk->protinfo.af_netlink->pid; - nladdr->nl_groups = sk->protinfo.af_netlink->groups; + nladdr->nl_pid = NLK_SK(sk)->pid; + nladdr->nl_groups = NLK_SK(sk)->groups; } return 0; } static void netlink_overrun(struct sock *sk) { - if (!test_and_set_bit(0, &sk->protinfo.af_netlink->state)) { + if (!test_and_set_bit(0, &NLK_SK(sk)->state)) { sk->err = ENOBUFS; sk->error_report(sk); } @@ -408,18 +410,18 @@ goto no_dst; #ifdef NL_EMULATE_DEV - if (sk->protinfo.af_netlink->handler) { + if (NLK_SK(sk)->handler) { skb_orphan(skb); - len = sk->protinfo.af_netlink->handler(protocol, skb); + len = NLK_SK(sk)->handler(protocol, skb); sock_put(sk); return len; } #endif if (atomic_read(&sk->rmem_alloc) > sk->rcvbuf || - test_bit(0, &sk->protinfo.af_netlink->state)) { + test_bit(0, &NLK_SK(sk)->state)) { if (!timeo) { - if (ssk->protinfo.af_netlink->pid == 0) + if (NLK_SK(ssk)->pid == 0) netlink_overrun(sk); sock_put(sk); kfree_skb(skb); @@ -427,15 +429,15 @@ } __set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&sk->protinfo.af_netlink->wait, &wait); + add_wait_queue(&NLK_SK(sk)->wait, &wait); if ((atomic_read(&sk->rmem_alloc) > sk->rcvbuf || - test_bit(0, &sk->protinfo.af_netlink->state)) && + test_bit(0, &NLK_SK(sk)->state)) && !sk->dead) timeo = schedule_timeout(timeo); __set_current_state(TASK_RUNNING); - remove_wait_queue(&sk->protinfo.af_netlink->wait, &wait); + remove_wait_queue(&NLK_SK(sk)->wait, &wait); sock_put(sk); if (signal_pending(current)) { @@ -460,14 +462,14 @@ static __inline__ int netlink_broadcast_deliver(struct sock *sk, struct sk_buff *skb) { #ifdef NL_EMULATE_DEV - if (sk->protinfo.af_netlink->handler) { + if (NLK_SK(sk)->handler) { skb_orphan(skb); - sk->protinfo.af_netlink->handler(sk->protocol, skb); + NLK_SK(sk)->handler(sk->protocol, skb); return 0; } else #endif if (atomic_read(&sk->rmem_alloc) <= sk->rcvbuf && - !test_bit(0, &sk->protinfo.af_netlink->state)) { + !test_bit(0, &NLK_SK(sk)->state)) { skb_orphan(skb); skb_set_owner_r(skb, sk); skb_queue_tail(&sk->receive_queue, skb); @@ -493,8 +495,8 @@ if (ssk == sk) continue; - if (sk->protinfo.af_netlink->pid == pid || - !(sk->protinfo.af_netlink->groups&group)) + if (NLK_SK(sk)->pid == pid || + !(NLK_SK(sk)->groups&group)) continue; if (failure) { @@ -539,8 +541,8 @@ if (ssk == sk) continue; - if (sk->protinfo.af_netlink->pid == pid || - !(sk->protinfo.af_netlink->groups&group)) + if (NLK_SK(sk)->pid == pid || + !(NLK_SK(sk)->groups&group)) continue; sk->err = code; @@ -570,11 +572,11 @@ if (dst_groups && !capable(CAP_NET_ADMIN)) return -EPERM; } else { - dst_pid = sk->protinfo.af_netlink->dst_pid; - dst_groups = sk->protinfo.af_netlink->dst_groups; + dst_pid = NLK_SK(sk)->dst_pid; + dst_groups = NLK_SK(sk)->dst_groups; } - if (!sk->protinfo.af_netlink->pid) { + if (!NLK_SK(sk)->pid) { err = netlink_autobind(sock); if (err) goto out; @@ -588,8 +590,8 @@ if (skb==NULL) goto out; - NETLINK_CB(skb).pid = sk->protinfo.af_netlink->pid; - NETLINK_CB(skb).groups = sk->protinfo.af_netlink->groups; + NETLINK_CB(skb).pid = NLK_SK(sk)->pid; + NETLINK_CB(skb).groups = NLK_SK(sk)->groups; NETLINK_CB(skb).dst_pid = dst_pid; NETLINK_CB(skb).dst_groups = dst_groups; memcpy(NETLINK_CREDS(skb), &scm->creds, sizeof(struct ucred)); @@ -657,30 +659,30 @@ scm->creds = *NETLINK_CREDS(skb); skb_free_datagram(sk, skb); - if (sk->protinfo.af_netlink->cb + if (NLK_SK(sk)->cb && atomic_read(&sk->rmem_alloc) <= sk->rcvbuf/2) netlink_dump(sk); out: if (skb_queue_len(&sk->receive_queue) <= sk->rcvbuf/2) { if (skb_queue_len(&sk->receive_queue) == 0) - clear_bit(0, &sk->protinfo.af_netlink->state); - if (!test_bit(0, &sk->protinfo.af_netlink->state)) - wake_up_interruptible(&sk->protinfo.af_netlink->wait); + clear_bit(0, &NLK_SK(sk)->state); + if (!test_bit(0, &NLK_SK(sk)->state)) + wake_up_interruptible(&NLK_SK(sk)->wait); } return err ? : copied; } void netlink_data_ready(struct sock *sk, int len) { - if (sk->protinfo.af_netlink->data_ready) - sk->protinfo.af_netlink->data_ready(sk, len); + if (NLK_SK(sk)->data_ready) + NLK_SK(sk)->data_ready(sk, len); if (skb_queue_len(&sk->receive_queue) <= sk->rcvbuf/2) { if (skb_queue_len(&sk->receive_queue) == 0) - clear_bit(0, &sk->protinfo.af_netlink->state); - if (!test_bit(0, &sk->protinfo.af_netlink->state)) - wake_up_interruptible(&sk->protinfo.af_netlink->wait); + clear_bit(0, &NLK_SK(sk)->state); + if (!test_bit(0, &NLK_SK(sk)->state)) + wake_up_interruptible(&NLK_SK(sk)->wait); } } @@ -711,7 +713,7 @@ sk = sock->sk; sk->data_ready = netlink_data_ready; if (input) - sk->protinfo.af_netlink->data_ready = input; + NLK_SK(sk)->data_ready = input; netlink_insert(sk, 0); return sk; @@ -740,11 +742,11 @@ if (!skb) return -ENOBUFS; - spin_lock(&sk->protinfo.af_netlink->cb_lock); + spin_lock(&NLK_SK(sk)->cb_lock); - cb = sk->protinfo.af_netlink->cb; + cb = NLK_SK(sk)->cb; if (cb == NULL) { - spin_unlock(&sk->protinfo.af_netlink->cb_lock); + spin_unlock(&NLK_SK(sk)->cb_lock); kfree_skb(skb); return -EINVAL; } @@ -752,7 +754,7 @@ len = cb->dump(skb, cb); if (len > 0) { - spin_unlock(&sk->protinfo.af_netlink->cb_lock); + spin_unlock(&NLK_SK(sk)->cb_lock); skb_queue_tail(&sk->receive_queue, skb); sk->data_ready(sk, len); return 0; @@ -765,8 +767,8 @@ sk->data_ready(sk, skb->len); cb->done(cb); - sk->protinfo.af_netlink->cb = NULL; - spin_unlock(&sk->protinfo.af_netlink->cb_lock); + NLK_SK(sk)->cb = NULL; + spin_unlock(&NLK_SK(sk)->cb_lock); netlink_destroy_callback(cb); sock_put(sk); @@ -798,15 +800,15 @@ return -ECONNREFUSED; } /* A dump is in progress... */ - spin_lock(&sk->protinfo.af_netlink->cb_lock); - if (sk->protinfo.af_netlink->cb) { - spin_unlock(&sk->protinfo.af_netlink->cb_lock); + spin_lock(&NLK_SK(sk)->cb_lock); + if (NLK_SK(sk)->cb) { + spin_unlock(&NLK_SK(sk)->cb_lock); netlink_destroy_callback(cb); sock_put(sk); return -EBUSY; } - sk->protinfo.af_netlink->cb = cb; - spin_unlock(&sk->protinfo.af_netlink->cb_lock); + NLK_SK(sk)->cb = cb; + spin_unlock(&NLK_SK(sk)->cb_lock); netlink_dump(sk); return 0; @@ -850,7 +852,7 @@ struct sock *sk = netlink_kernel_create(unit, NULL); if (sk == NULL) return -ENOBUFS; - sk->protinfo.af_netlink->handler = function; + NLK_SK(sk)->handler = function; write_lock_bh(&nl_emu_lock); netlink_kernel[unit] = sk->socket; write_unlock_bh(&nl_emu_lock); @@ -912,11 +914,11 @@ len+=sprintf(buffer+len,"%p %-3d %-6d %08x %-8d %-8d %p %d", s, s->protocol, - s->protinfo.af_netlink->pid, - s->protinfo.af_netlink->groups, + NLK_SK(s)->pid, + NLK_SK(s)->groups, atomic_read(&s->rmem_alloc), atomic_read(&s->wmem_alloc), - s->protinfo.af_netlink->cb, + NLK_SK(s)->cb, atomic_read(&s->refcnt) ); @@ -969,8 +971,8 @@ }; struct net_proto_family netlink_family_ops = { - PF_NETLINK, - netlink_create + family: PF_NETLINK, + create: netlink_create, }; static int __init netlink_proto_init(void) diff -uNr linux-2.5.1/net/netrom/af_netrom.c linux-2.5.1.acme/net/netrom/af_netrom.c --- linux-2.5.1/net/netrom/af_netrom.c Mon Sep 10 11:58:35 2001 +++ linux-2.5.1.acme/net/netrom/af_netrom.c Wed Dec 19 23:44:48 2001 @@ -109,7 +109,7 @@ memset(nr, 0x00, sizeof(*nr)); - sk->protinfo.nr = nr; + NR_SK(sk) = nr; nr->sk = sk; return sk; @@ -152,7 +152,7 @@ struct sock *s; for (s = nr_list; s != NULL; s = s->next) { - if (s->protinfo.nr->device == dev) + if (NR_SK(s)->device == dev) nr_disconnect(s, ENETUNREACH); } } @@ -201,7 +201,8 @@ cli(); for (s = nr_list; s != NULL; s = s->next) { - if (ax25cmp(&s->protinfo.nr->source_addr, addr) == 0 && s->state == TCP_LISTEN) { + if (!ax25cmp(&NR_SK(s)->source_addr, addr) && + s->state == TCP_LISTEN) { restore_flags(flags); return s; } @@ -223,7 +224,9 @@ cli(); for (s = nr_list; s != NULL; s = s->next) { - if (s->protinfo.nr->my_index == index && s->protinfo.nr->my_id == id) { + nr_cb *nr = NR_SK(s); + + if (nr->my_index == index && nr->my_id == id) { restore_flags(flags); return s; } @@ -246,7 +249,10 @@ cli(); for (s = nr_list; s != NULL; s = s->next) { - if (s->protinfo.nr->your_index == index && s->protinfo.nr->your_id == id && ax25cmp(&s->protinfo.nr->dest_addr, dest) == 0) { + nr_cb *nr = NR_SK(s); + + if (nr->your_index == index && nr->your_id == id && + !ax25cmp(&nr->dest_addr, dest)) { restore_flags(flags); return s; } @@ -318,7 +324,7 @@ if (skb->sk != sk) { /* A pending connection */ skb->sk->dead = 1; /* Queue the unaccepted socket for death */ nr_start_heartbeat(skb->sk); - skb->sk->protinfo.nr->state = NR_STATE_0; + NR_SK(skb->sk)->state = NR_STATE_0; } kfree_skb(skb); @@ -347,6 +353,7 @@ char *optval, int optlen) { struct sock *sk = sock->sk; + nr_cb *nr = NR_SK(sk); int opt; if (level != SOL_NETROM) @@ -362,31 +369,31 @@ case NETROM_T1: if (opt < 1) return -EINVAL; - sk->protinfo.nr->t1 = opt * HZ; + nr->t1 = opt * HZ; return 0; case NETROM_T2: if (opt < 1) return -EINVAL; - sk->protinfo.nr->t2 = opt * HZ; + nr->t2 = opt * HZ; return 0; case NETROM_N2: if (opt < 1 || opt > 31) return -EINVAL; - sk->protinfo.nr->n2 = opt; + nr->n2 = opt; return 0; case NETROM_T4: if (opt < 1) return -EINVAL; - sk->protinfo.nr->t4 = opt * HZ; + nr->t4 = opt * HZ; return 0; case NETROM_IDLE: if (opt < 0) return -EINVAL; - sk->protinfo.nr->idle = opt * 60 * HZ; + nr->idle = opt * 60 * HZ; return 0; default: @@ -398,6 +405,7 @@ char *optval, int *optlen) { struct sock *sk = sock->sk; + nr_cb *nr = NR_SK(sk); int val = 0; int len; @@ -412,23 +420,23 @@ switch (optname) { case NETROM_T1: - val = sk->protinfo.nr->t1 / HZ; + val = nr->t1 / HZ; break; case NETROM_T2: - val = sk->protinfo.nr->t2 / HZ; + val = nr->t2 / HZ; break; case NETROM_N2: - val = sk->protinfo.nr->n2; + val = nr->n2; break; case NETROM_T4: - val = sk->protinfo.nr->t4 / HZ; + val = nr->t4 / HZ; break; case NETROM_IDLE: - val = sk->protinfo.nr->idle / (60 * HZ); + val = nr->idle / (60 * HZ); break; default: @@ -448,7 +456,7 @@ struct sock *sk = sock->sk; if (sk->state != TCP_LISTEN) { - memset(&sk->protinfo.nr->user_addr, '\0', AX25_ADDR_LEN); + memset(&NR_SK(sk)->user_addr, '\0', AX25_ADDR_LEN); sk->max_ack_backlog = backlog; sk->state = TCP_LISTEN; return 0; @@ -468,7 +476,7 @@ if ((sk = nr_alloc_sock()) == NULL) return -ENOMEM; - nr = sk->protinfo.nr; + nr = NR_SK(sk); sock_init_data(sock, sk); @@ -500,7 +508,7 @@ static struct sock *nr_make_new(struct sock *osk) { struct sock *sk; - nr_cb *nr; + nr_cb *nr, *onr; if (osk->type != SOCK_SEQPACKET) return NULL; @@ -508,7 +516,7 @@ if ((sk = nr_alloc_sock()) == NULL) return NULL; - nr = sk->protinfo.nr; + nr = NR_SK(sk); sock_init_data(NULL, sk); @@ -532,15 +540,17 @@ init_timer(&nr->t4timer); init_timer(&nr->idletimer); - nr->t1 = osk->protinfo.nr->t1; - nr->t2 = osk->protinfo.nr->t2; - nr->n2 = osk->protinfo.nr->n2; - nr->t4 = osk->protinfo.nr->t4; - nr->idle = osk->protinfo.nr->idle; - nr->window = osk->protinfo.nr->window; + onr = NR_SK(osk); + + nr->t1 = onr->t1; + nr->t2 = onr->t2; + nr->n2 = onr->n2; + nr->t4 = onr->t4; + nr->idle = onr->idle; + nr->window = onr->window; - nr->device = osk->protinfo.nr->device; - nr->bpqext = osk->protinfo.nr->bpqext; + nr->device = onr->device; + nr->bpqext = onr->bpqext; return sk; } @@ -548,10 +558,13 @@ static int nr_release(struct socket *sock) { struct sock *sk = sock->sk; + nr_cb *nr; if (sk == NULL) return 0; - switch (sk->protinfo.nr->state) { + nr = NR_SK(sk); + + switch (nr->state) { case NR_STATE_0: case NR_STATE_1: @@ -562,19 +575,19 @@ case NR_STATE_3: nr_clear_queues(sk); - sk->protinfo.nr->n2count = 0; + nr->n2count = 0; nr_write_internal(sk, NR_DISCREQ); nr_start_t1timer(sk); nr_stop_t2timer(sk); nr_stop_t4timer(sk); nr_stop_idletimer(sk); - sk->protinfo.nr->state = NR_STATE_2; - sk->state = TCP_CLOSE; - sk->shutdown |= SEND_SHUTDOWN; + nr->state = NR_STATE_2; + sk->state = TCP_CLOSE; + sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); - sk->dead = 1; - sk->destroy = 1; - sk->socket = NULL; + sk->dead = 1; + sk->destroy = 1; + sk->socket = NULL; break; default: @@ -590,6 +603,7 @@ static int nr_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct sock *sk = sock->sk; + nr_cb *nr = NR_SK(sk); struct full_sockaddr_ax25 *addr = (struct full_sockaddr_ax25 *)uaddr; struct net_device *dev; ax25_address *user, *source; @@ -618,8 +632,8 @@ if (addr->fsa_ax25.sax25_ndigis == 1) { if (!capable(CAP_NET_BIND_SERVICE)) return -EACCES; - sk->protinfo.nr->user_addr = addr->fsa_digipeater[0]; - sk->protinfo.nr->source_addr = addr->fsa_ax25.sax25_call; + nr->user_addr = addr->fsa_digipeater[0]; + nr->source_addr = addr->fsa_ax25.sax25_call; } else { source = &addr->fsa_ax25.sax25_call; @@ -629,11 +643,11 @@ user = source; } - sk->protinfo.nr->user_addr = *user; - sk->protinfo.nr->source_addr = *source; + nr->user_addr = *user; + nr->source_addr = *source; } - sk->protinfo.nr->device = dev; + nr->device = dev; nr_insert_socket(sk); sk->zapped = 0; @@ -645,6 +659,7 @@ int addr_len, int flags) { struct sock *sk = sock->sk; + nr_cb *nr = NR_SK(sk); struct sockaddr_ax25 *addr = (struct sockaddr_ax25 *)uaddr; ax25_address *user, *source = NULL; struct net_device *dev; @@ -685,19 +700,19 @@ user = source; } - sk->protinfo.nr->user_addr = *user; - sk->protinfo.nr->source_addr = *source; - sk->protinfo.nr->device = dev; + nr->user_addr = *user; + nr->source_addr = *source; + nr->device = dev; nr_insert_socket(sk); /* Finish the bind */ } - sk->protinfo.nr->dest_addr = addr->sax25_call; + nr->dest_addr = addr->sax25_call; circuit = nr_find_next_circuit(); - sk->protinfo.nr->my_index = circuit / 256; - sk->protinfo.nr->my_id = circuit % 256; + nr->my_index = circuit / 256; + nr->my_id = circuit % 256; circuit++; @@ -707,7 +722,7 @@ nr_establish_data_link(sk); - sk->protinfo.nr->state = NR_STATE_1; + nr->state = NR_STATE_1; nr_start_heartbeat(sk); @@ -794,19 +809,20 @@ { struct full_sockaddr_ax25 *sax = (struct full_sockaddr_ax25 *)uaddr; struct sock *sk = sock->sk; + nr_cb *nr = NR_SK(sk); if (peer != 0) { if (sk->state != TCP_ESTABLISHED) return -ENOTCONN; sax->fsa_ax25.sax25_family = AF_NETROM; sax->fsa_ax25.sax25_ndigis = 1; - sax->fsa_ax25.sax25_call = sk->protinfo.nr->user_addr; - sax->fsa_digipeater[0] = sk->protinfo.nr->dest_addr; + sax->fsa_ax25.sax25_call = nr->user_addr; + sax->fsa_digipeater[0] = nr->dest_addr; *uaddr_len = sizeof(struct full_sockaddr_ax25); } else { sax->fsa_ax25.sax25_family = AF_NETROM; sax->fsa_ax25.sax25_ndigis = 0; - sax->fsa_ax25.sax25_call = sk->protinfo.nr->source_addr; + sax->fsa_ax25.sax25_call = nr->source_addr; *uaddr_len = sizeof(struct sockaddr_ax25); } @@ -817,6 +833,7 @@ { struct sock *sk; struct sock *make; + nr_cb *nr_make; ax25_address *src, *dest, *user; unsigned short circuit_index, circuit_id; unsigned short peer_circuit_index, peer_circuit_id; @@ -874,9 +891,9 @@ skb->h.raw = skb->data; if (frametype == NR_CONNACK && skb->len == 22) - sk->protinfo.nr->bpqext = 1; + NR_SK(sk)->bpqext = 1; else - sk->protinfo.nr->bpqext = 0; + NR_SK(sk)->bpqext = 0; return nr_process_rx_frame(sk, skb); } @@ -916,42 +933,43 @@ make->state = TCP_ESTABLISHED; /* Fill in his circuit details */ - make->protinfo.nr->source_addr = *dest; - make->protinfo.nr->dest_addr = *src; - make->protinfo.nr->user_addr = *user; + nr_make = NR_SK(make); + nr_make->source_addr = *dest; + nr_make->dest_addr = *src; + nr_make->user_addr = *user; - make->protinfo.nr->your_index = circuit_index; - make->protinfo.nr->your_id = circuit_id; + nr_make->your_index = circuit_index; + nr_make->your_id = circuit_id; circuit = nr_find_next_circuit(); - make->protinfo.nr->my_index = circuit / 256; - make->protinfo.nr->my_id = circuit % 256; + nr_make->my_index = circuit / 256; + nr_make->my_id = circuit % 256; circuit++; /* Window negotiation */ - if (window < make->protinfo.nr->window) - make->protinfo.nr->window = window; + if (window < nr_make->window) + nr_make->window = window; /* L4 timeout negotiation */ if (skb->len == 37) { timeout = skb->data[36] * 256 + skb->data[35]; - if (timeout * HZ < make->protinfo.nr->t1) - make->protinfo.nr->t1 = timeout * HZ; - make->protinfo.nr->bpqext = 1; + if (timeout * HZ < nr_make->t1) + nr_make->t1 = timeout * HZ; + nr_make->bpqext = 1; } else { - make->protinfo.nr->bpqext = 0; + nr_make->bpqext = 0; } nr_write_internal(make, NR_CONNACK); - make->protinfo.nr->condition = 0x00; - make->protinfo.nr->vs = 0; - make->protinfo.nr->va = 0; - make->protinfo.nr->vr = 0; - make->protinfo.nr->vl = 0; - make->protinfo.nr->state = NR_STATE_3; + nr_make->condition = 0x00; + nr_make->vs = 0; + nr_make->va = 0; + nr_make->vr = 0; + nr_make->vl = 0; + nr_make->state = NR_STATE_3; sk->ack_backlog++; make->pair = sk; @@ -971,6 +989,7 @@ static int nr_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct scm_cookie *scm) { struct sock *sk = sock->sk; + nr_cb *nr = NR_SK(sk); struct sockaddr_ax25 *usax = (struct sockaddr_ax25 *)msg->msg_name; int err; struct sockaddr_ax25 sax; @@ -989,14 +1008,14 @@ return -EPIPE; } - if (sk->protinfo.nr->device == NULL) + if (nr->device == NULL) return -ENETUNREACH; if (usax) { if (msg->msg_namelen < sizeof(sax)) return -EINVAL; sax = *usax; - if (ax25cmp(&sk->protinfo.nr->dest_addr, &sax.sax25_call) != 0) + if (ax25cmp(&nr->dest_addr, &sax.sax25_call) != 0) return -EISCONN; if (sax.sax25_family != AF_NETROM) return -EINVAL; @@ -1004,7 +1023,7 @@ if (sk->state != TCP_ESTABLISHED) return -ENOTCONN; sax.sax25_family = AF_NETROM; - sax.sax25_call = sk->protinfo.nr->dest_addr; + sax.sax25_call = nr->dest_addr; } SOCK_DEBUG(sk, "NET/ROM: sendto: Addresses built.\n"); @@ -1027,8 +1046,8 @@ /* Build a NET/ROM Transport header */ - *asmptr++ = sk->protinfo.nr->your_index; - *asmptr++ = sk->protinfo.nr->your_id; + *asmptr++ = nr->your_index; + *asmptr++ = nr->your_id; *asmptr++ = 0; /* To be filled in later */ *asmptr++ = 0; /* Ditto */ *asmptr++ = NR_INFO; @@ -1171,37 +1190,39 @@ len += sprintf(buffer, "user_addr dest_node src_node dev my your st vs vr va t1 t2 t4 idle n2 wnd Snd-Q Rcv-Q inode\n"); for (s = nr_list; s != NULL; s = s->next) { - if ((dev = s->protinfo.nr->device) == NULL) + nr_cb *nr = NR_SK(s); + + if ((dev = nr->device) == NULL) devname = "???"; else devname = dev->name; len += sprintf(buffer + len, "%-9s ", - ax2asc(&s->protinfo.nr->user_addr)); + ax2asc(&nr->user_addr)); len += sprintf(buffer + len, "%-9s ", - ax2asc(&s->protinfo.nr->dest_addr)); + ax2asc(&nr->dest_addr)); len += sprintf(buffer + len, "%-9s %-3s %02X/%02X %02X/%02X %2d %3d %3d %3d %3lu/%03lu %2lu/%02lu %3lu/%03lu %3lu/%03lu %2d/%02d %3d %5d %5d %ld\n", - ax2asc(&s->protinfo.nr->source_addr), + ax2asc(&nr->source_addr), devname, - s->protinfo.nr->my_index, - s->protinfo.nr->my_id, - s->protinfo.nr->your_index, - s->protinfo.nr->your_id, - s->protinfo.nr->state, - s->protinfo.nr->vs, - s->protinfo.nr->vr, - s->protinfo.nr->va, - ax25_display_timer(&s->protinfo.nr->t1timer) / HZ, - s->protinfo.nr->t1 / HZ, - ax25_display_timer(&s->protinfo.nr->t2timer) / HZ, - s->protinfo.nr->t2 / HZ, - ax25_display_timer(&s->protinfo.nr->t4timer) / HZ, - s->protinfo.nr->t4 / HZ, - ax25_display_timer(&s->protinfo.nr->idletimer) / (60 * HZ), - s->protinfo.nr->idle / (60 * HZ), - s->protinfo.nr->n2count, - s->protinfo.nr->n2, - s->protinfo.nr->window, + nr->my_index, + nr->my_id, + nr->your_index, + nr->your_id, + nr->state, + nr->vs, + nr->vr, + nr->va, + ax25_display_timer(&nr->t1timer) / HZ, + nr->t1 / HZ, + ax25_display_timer(&nr->t2timer) / HZ, + nr->t2 / HZ, + ax25_display_timer(&nr->t4timer) / HZ, + nr->t4 / HZ, + ax25_display_timer(&nr->idletimer) / (60 * HZ), + nr->idle / (60 * HZ), + nr->n2count, + nr->n2, + nr->window, atomic_read(&s->wmem_alloc), atomic_read(&s->rmem_alloc), s->socket != NULL ? s->socket->inode->i_ino : 0L); diff -uNr linux-2.5.1/net/netrom/nr_in.c linux-2.5.1.acme/net/netrom/nr_in.c --- linux-2.5.1/net/netrom/nr_in.c Fri Dec 29 20:44:46 2000 +++ linux-2.5.1.acme/net/netrom/nr_in.c Wed Dec 19 23:44:48 2001 @@ -50,32 +50,33 @@ static int nr_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more) { struct sk_buff *skbo, *skbn = skb; + nr_cb *nr = NR_SK(sk); skb_pull(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN); nr_start_idletimer(sk); if (more) { - sk->protinfo.nr->fraglen += skb->len; - skb_queue_tail(&sk->protinfo.nr->frag_queue, skb); + nr->fraglen += skb->len; + skb_queue_tail(&nr->frag_queue, skb); return 0; } - if (!more && sk->protinfo.nr->fraglen > 0) { /* End of fragment */ - sk->protinfo.nr->fraglen += skb->len; - skb_queue_tail(&sk->protinfo.nr->frag_queue, skb); + if (!more && nr->fraglen > 0) { /* End of fragment */ + nr->fraglen += skb->len; + skb_queue_tail(&nr->frag_queue, skb); - if ((skbn = alloc_skb(sk->protinfo.nr->fraglen, GFP_ATOMIC)) == NULL) + if ((skbn = alloc_skb(nr->fraglen, GFP_ATOMIC)) == NULL) return 1; skbn->h.raw = skbn->data; - while ((skbo = skb_dequeue(&sk->protinfo.nr->frag_queue)) != NULL) { + while ((skbo = skb_dequeue(&nr->frag_queue)) != NULL) { memcpy(skb_put(skbn, skbo->len), skbo->data, skbo->len); kfree_skb(skbo); } - sk->protinfo.nr->fraglen = 0; + nr->fraglen = 0; } return sock_queue_rcv_skb(sk, skbn); @@ -90,22 +91,25 @@ { switch (frametype) { - case NR_CONNACK: + case NR_CONNACK: { + nr_cb *nr = NR_SK(sk); + nr_stop_t1timer(sk); nr_start_idletimer(sk); - sk->protinfo.nr->your_index = skb->data[17]; - sk->protinfo.nr->your_id = skb->data[18]; - sk->protinfo.nr->vs = 0; - sk->protinfo.nr->va = 0; - sk->protinfo.nr->vr = 0; - sk->protinfo.nr->vl = 0; - sk->protinfo.nr->state = NR_STATE_3; - sk->protinfo.nr->n2count = 0; - sk->protinfo.nr->window = skb->data[20]; - sk->state = TCP_ESTABLISHED; + nr->your_index = skb->data[17]; + nr->your_id = skb->data[18]; + nr->vs = 0; + nr->va = 0; + nr->vr = 0; + nr->vl = 0; + nr->state = NR_STATE_3; + nr->n2count = 0; + nr->window = skb->data[20]; + sk->state = TCP_ESTABLISHED; if (!sk->dead) sk->state_change(sk); break; + } case NR_CONNACK | NR_CHOKE_FLAG: nr_disconnect(sk, ECONNREFUSED); @@ -152,6 +156,7 @@ */ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype) { + nr_cb *nrom = NR_SK(sk); struct sk_buff_head temp_queue; struct sk_buff *skbn; unsigned short save_vr; @@ -182,10 +187,10 @@ case NR_INFOACK | NR_NAK_FLAG: case NR_INFOACK | NR_NAK_FLAG | NR_CHOKE_FLAG: if (frametype & NR_CHOKE_FLAG) { - sk->protinfo.nr->condition |= NR_COND_PEER_RX_BUSY; + nrom->condition |= NR_COND_PEER_RX_BUSY; nr_start_t4timer(sk); } else { - sk->protinfo.nr->condition &= ~NR_COND_PEER_RX_BUSY; + nrom->condition &= ~NR_COND_PEER_RX_BUSY; nr_stop_t4timer(sk); } if (!nr_validate_nr(sk, nr)) { @@ -195,7 +200,7 @@ nr_frames_acked(sk, nr); nr_send_nak_frame(sk); } else { - if (sk->protinfo.nr->condition & NR_COND_PEER_RX_BUSY) { + if (nrom->condition & NR_COND_PEER_RX_BUSY) { nr_frames_acked(sk, nr); } else { nr_check_iframes_acked(sk, nr); @@ -212,10 +217,10 @@ case NR_INFO | NR_NAK_FLAG | NR_MORE_FLAG: case NR_INFO | NR_NAK_FLAG | NR_CHOKE_FLAG | NR_MORE_FLAG: if (frametype & NR_CHOKE_FLAG) { - sk->protinfo.nr->condition |= NR_COND_PEER_RX_BUSY; + nrom->condition |= NR_COND_PEER_RX_BUSY; nr_start_t4timer(sk); } else { - sk->protinfo.nr->condition &= ~NR_COND_PEER_RX_BUSY; + nrom->condition &= ~NR_COND_PEER_RX_BUSY; nr_stop_t4timer(sk); } if (nr_validate_nr(sk, nr)) { @@ -223,7 +228,7 @@ nr_frames_acked(sk, nr); nr_send_nak_frame(sk); } else { - if (sk->protinfo.nr->condition & NR_COND_PEER_RX_BUSY) { + if (nrom->condition & NR_COND_PEER_RX_BUSY) { nr_frames_acked(sk, nr); } else { nr_check_iframes_acked(sk, nr); @@ -231,19 +236,19 @@ } } queued = 1; - skb_queue_head(&sk->protinfo.nr->reseq_queue, skb); - if (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY) + skb_queue_head(&nrom->reseq_queue, skb); + if (nrom->condition & NR_COND_OWN_RX_BUSY) break; skb_queue_head_init(&temp_queue); do { - save_vr = sk->protinfo.nr->vr; - while ((skbn = skb_dequeue(&sk->protinfo.nr->reseq_queue)) != NULL) { + save_vr = nrom->vr; + while ((skbn = skb_dequeue(&nrom->reseq_queue)) != NULL) { ns = skbn->data[17]; - if (ns == sk->protinfo.nr->vr) { + if (ns == nrom->vr) { if (nr_queue_rx_frame(sk, skbn, frametype & NR_MORE_FLAG) == 0) { - sk->protinfo.nr->vr = (sk->protinfo.nr->vr + 1) % NR_MODULUS; + nrom->vr = (nrom->vr + 1) % NR_MODULUS; } else { - sk->protinfo.nr->condition |= NR_COND_OWN_RX_BUSY; + nrom->condition |= NR_COND_OWN_RX_BUSY; skb_queue_tail(&temp_queue, skbn); } } else if (nr_in_rx_window(sk, ns)) { @@ -253,17 +258,17 @@ } } while ((skbn = skb_dequeue(&temp_queue)) != NULL) { - skb_queue_tail(&sk->protinfo.nr->reseq_queue, skbn); + skb_queue_tail(&nrom->reseq_queue, skbn); } - } while (save_vr != sk->protinfo.nr->vr); + } while (save_vr != nrom->vr); /* * Window is full, ack it immediately. */ - if (((sk->protinfo.nr->vl + sk->protinfo.nr->window) % NR_MODULUS) == sk->protinfo.nr->vr) { + if (((nrom->vl + nrom->window) % NR_MODULUS) == nrom->vr) { nr_enquiry_response(sk); } else { - if (!(sk->protinfo.nr->condition & NR_COND_ACK_PENDING)) { - sk->protinfo.nr->condition |= NR_COND_ACK_PENDING; + if (!(nrom->condition & NR_COND_ACK_PENDING)) { + nrom->condition |= NR_COND_ACK_PENDING; nr_start_t2timer(sk); } } @@ -279,14 +284,15 @@ /* Higher level upcall for a LAPB frame */ int nr_process_rx_frame(struct sock *sk, struct sk_buff *skb) { + nr_cb *nr = NR_SK(sk); int queued = 0, frametype; - if (sk->protinfo.nr->state == NR_STATE_0) + if (nr->state == NR_STATE_0) return 0; frametype = skb->data[19]; - switch (sk->protinfo.nr->state) { + switch (nr->state) { case NR_STATE_1: queued = nr_state1_machine(sk, skb, frametype); break; diff -uNr linux-2.5.1/net/netrom/nr_out.c linux-2.5.1.acme/net/netrom/nr_out.c --- linux-2.5.1/net/netrom/nr_out.c Thu Apr 12 16:11:39 2001 +++ linux-2.5.1.acme/net/netrom/nr_out.c Wed Dec 19 23:44:48 2001 @@ -91,13 +91,15 @@ */ static void nr_send_iframe(struct sock *sk, struct sk_buff *skb) { + nr_cb *nr = NR_SK(sk); + if (skb == NULL) return; - skb->data[2] = sk->protinfo.nr->vs; - skb->data[3] = sk->protinfo.nr->vr; + skb->data[2] = nr->vs; + skb->data[3] = nr->vr; - if (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY) + if (nr->condition & NR_COND_OWN_RX_BUSY) skb->data[4] |= NR_CHOKE_FLAG; nr_start_idletimer(sk); @@ -108,48 +110,50 @@ void nr_send_nak_frame(struct sock *sk) { struct sk_buff *skb, *skbn; + nr_cb *nr = NR_SK(sk); - if ((skb = skb_peek(&sk->protinfo.nr->ack_queue)) == NULL) + if ((skb = skb_peek(&nr->ack_queue)) == NULL) return; if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) return; - skbn->data[2] = sk->protinfo.nr->va; - skbn->data[3] = sk->protinfo.nr->vr; + skbn->data[2] = nr->va; + skbn->data[3] = nr->vr; - if (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY) + if (nr->condition & NR_COND_OWN_RX_BUSY) skbn->data[4] |= NR_CHOKE_FLAG; nr_transmit_buffer(sk, skbn); - sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING; - sk->protinfo.nr->vl = sk->protinfo.nr->vr; + nr->condition &= ~NR_COND_ACK_PENDING; + nr->vl = nr->vr; nr_stop_t1timer(sk); } void nr_kick(struct sock *sk) { + nr_cb *nr = NR_SK(sk); struct sk_buff *skb, *skbn; unsigned short start, end; - if (sk->protinfo.nr->state != NR_STATE_3) + if (nr->state != NR_STATE_3) return; - if (sk->protinfo.nr->condition & NR_COND_PEER_RX_BUSY) + if (nr->condition & NR_COND_PEER_RX_BUSY) return; if (skb_peek(&sk->write_queue) == NULL) return; - start = (skb_peek(&sk->protinfo.nr->ack_queue) == NULL) ? sk->protinfo.nr->va : sk->protinfo.nr->vs; - end = (sk->protinfo.nr->va + sk->protinfo.nr->window) % NR_MODULUS; + start = (skb_peek(&nr->ack_queue) == NULL) ? nr->va : nr->vs; + end = (nr->va + nr->window) % NR_MODULUS; if (start == end) return; - sk->protinfo.nr->vs = start; + nr->vs = start; /* * Transmit data until either we're out of data to send or @@ -174,17 +178,17 @@ */ nr_send_iframe(sk, skbn); - sk->protinfo.nr->vs = (sk->protinfo.nr->vs + 1) % NR_MODULUS; + nr->vs = (nr->vs + 1) % NR_MODULUS; /* * Requeue the original data frame. */ - skb_queue_tail(&sk->protinfo.nr->ack_queue, skb); + skb_queue_tail(&nr->ack_queue, skb); - } while (sk->protinfo.nr->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL); + } while (nr->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL); - sk->protinfo.nr->vl = sk->protinfo.nr->vr; - sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING; + nr->vl = nr->vr; + nr->condition &= ~NR_COND_ACK_PENDING; if (!nr_t1timer_running(sk)) nr_start_t1timer(sk); @@ -192,6 +196,7 @@ void nr_transmit_buffer(struct sock *sk, struct sk_buff *skb) { + nr_cb *nr = nr; unsigned char *dptr; /* @@ -199,13 +204,13 @@ */ dptr = skb_push(skb, NR_NETWORK_LEN); - memcpy(dptr, &sk->protinfo.nr->source_addr, AX25_ADDR_LEN); + memcpy(dptr, &nr->source_addr, AX25_ADDR_LEN); dptr[6] &= ~AX25_CBIT; dptr[6] &= ~AX25_EBIT; dptr[6] |= AX25_SSSID_SPARE; dptr += AX25_ADDR_LEN; - memcpy(dptr, &sk->protinfo.nr->dest_addr, AX25_ADDR_LEN); + memcpy(dptr, &nr->dest_addr, AX25_ADDR_LEN); dptr[6] &= ~AX25_CBIT; dptr[6] |= AX25_EBIT; dptr[6] |= AX25_SSSID_SPARE; @@ -226,8 +231,10 @@ void nr_establish_data_link(struct sock *sk) { - sk->protinfo.nr->condition = 0x00; - sk->protinfo.nr->n2count = 0; + nr_cb *nr = NR_SK(sk); + + nr->condition = 0x00; + nr->n2count = 0; nr_write_internal(sk, NR_CONNREQ); @@ -242,29 +249,32 @@ */ void nr_enquiry_response(struct sock *sk) { + nr_cb *nr = NR_SK(sk); int frametype = NR_INFOACK; - if (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY) { + if (nr->condition & NR_COND_OWN_RX_BUSY) { frametype |= NR_CHOKE_FLAG; } else { - if (skb_peek(&sk->protinfo.nr->reseq_queue) != NULL) + if (skb_peek(&nr->reseq_queue) != NULL) frametype |= NR_NAK_FLAG; } nr_write_internal(sk, frametype); - sk->protinfo.nr->vl = sk->protinfo.nr->vr; - sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING; + nr->vl = nr->vr; + nr->condition &= ~NR_COND_ACK_PENDING; } void nr_check_iframes_acked(struct sock *sk, unsigned short nr) { - if (sk->protinfo.nr->vs == nr) { + nr_cb *nrom = NR_SK(sk); + + if (nrom->vs == nr) { nr_frames_acked(sk, nr); nr_stop_t1timer(sk); - sk->protinfo.nr->n2count = 0; + nrom->n2count = 0; } else { - if (sk->protinfo.nr->va != nr) { + if (nrom->va != nr) { nr_frames_acked(sk, nr); nr_start_t1timer(sk); } diff -uNr linux-2.5.1/net/netrom/nr_subr.c linux-2.5.1.acme/net/netrom/nr_subr.c --- linux-2.5.1/net/netrom/nr_subr.c Wed Jun 27 21:10:55 2001 +++ linux-2.5.1.acme/net/netrom/nr_subr.c Wed Dec 19 23:44:48 2001 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -42,10 +43,12 @@ */ void nr_clear_queues(struct sock *sk) { + nr_cb *nr = NR_SK(sk); + skb_queue_purge(&sk->write_queue); - skb_queue_purge(&sk->protinfo.nr->ack_queue); - skb_queue_purge(&sk->protinfo.nr->reseq_queue); - skb_queue_purge(&sk->protinfo.nr->frag_queue); + skb_queue_purge(&nr->ack_queue); + skb_queue_purge(&nr->reseq_queue); + skb_queue_purge(&nr->frag_queue); } /* @@ -55,16 +58,17 @@ */ void nr_frames_acked(struct sock *sk, unsigned short nr) { + nr_cb *nrom = NR_SK(sk); struct sk_buff *skb; /* * Remove all the ack-ed frames from the ack queue. */ - if (sk->protinfo.nr->va != nr) { - while (skb_peek(&sk->protinfo.nr->ack_queue) != NULL && sk->protinfo.nr->va != nr) { - skb = skb_dequeue(&sk->protinfo.nr->ack_queue); + if (nrom->va != nr) { + while (skb_peek(&nrom->ack_queue) != NULL && nrom->va != nr) { + skb = skb_dequeue(&nrom->ack_queue); kfree_skb(skb); - sk->protinfo.nr->va = (sk->protinfo.nr->va + 1) % NR_MODULUS; + nrom->va = (nrom->va + 1) % NR_MODULUS; } } } @@ -78,7 +82,7 @@ { struct sk_buff *skb, *skb_prev = NULL; - while ((skb = skb_dequeue(&sk->protinfo.nr->ack_queue)) != NULL) { + while ((skb = skb_dequeue(&NR_SK(sk)->ack_queue)) != NULL) { if (skb_prev == NULL) skb_queue_head(&sk->write_queue, skb); else @@ -93,16 +97,15 @@ */ int nr_validate_nr(struct sock *sk, unsigned short nr) { - unsigned short vc = sk->protinfo.nr->va; + nr_cb *nrom = NR_SK(sk); + unsigned short vc = nrom->va; - while (vc != sk->protinfo.nr->vs) { + while (vc != nrom->vs) { if (nr == vc) return 1; vc = (vc + 1) % NR_MODULUS; } - if (nr == sk->protinfo.nr->vs) return 1; - - return 0; + return nr == nrom->vs; } /* @@ -110,8 +113,9 @@ */ int nr_in_rx_window(struct sock *sk, unsigned short ns) { - unsigned short vc = sk->protinfo.nr->vr; - unsigned short vt = (sk->protinfo.nr->vl + sk->protinfo.nr->window) % NR_MODULUS; + nr_cb *nr = NR_SK(sk); + unsigned short vc = nr->vr; + unsigned short vt = (nr->vl + nr->window) % NR_MODULUS; while (vc != vt) { if (ns == vc) return 1; @@ -127,6 +131,7 @@ */ void nr_write_internal(struct sock *sk, int frametype) { + nr_cb *nr = NR_SK(sk); struct sk_buff *skb; unsigned char *dptr; int len, timeout; @@ -138,7 +143,7 @@ len += 17; break; case NR_CONNACK: - len += (sk->protinfo.nr->bpqext) ? 2 : 1; + len += (nr->bpqext) ? 2 : 1; break; case NR_DISCREQ: case NR_DISCACK: @@ -162,19 +167,19 @@ switch (frametype & 0x0F) { case NR_CONNREQ: - timeout = sk->protinfo.nr->t1 / HZ; - *dptr++ = sk->protinfo.nr->my_index; - *dptr++ = sk->protinfo.nr->my_id; + timeout = nr->t1 / HZ; + *dptr++ = nr->my_index; + *dptr++ = nr->my_id; *dptr++ = 0; *dptr++ = 0; *dptr++ = frametype; - *dptr++ = sk->protinfo.nr->window; - memcpy(dptr, &sk->protinfo.nr->user_addr, AX25_ADDR_LEN); + *dptr++ = nr->window; + memcpy(dptr, &nr->user_addr, AX25_ADDR_LEN); dptr[6] &= ~AX25_CBIT; dptr[6] &= ~AX25_EBIT; dptr[6] |= AX25_SSSID_SPARE; dptr += AX25_ADDR_LEN; - memcpy(dptr, &sk->protinfo.nr->source_addr, AX25_ADDR_LEN); + memcpy(dptr, &nr->source_addr, AX25_ADDR_LEN); dptr[6] &= ~AX25_CBIT; dptr[6] &= ~AX25_EBIT; dptr[6] |= AX25_SSSID_SPARE; @@ -184,29 +189,29 @@ break; case NR_CONNACK: - *dptr++ = sk->protinfo.nr->your_index; - *dptr++ = sk->protinfo.nr->your_id; - *dptr++ = sk->protinfo.nr->my_index; - *dptr++ = sk->protinfo.nr->my_id; + *dptr++ = nr->your_index; + *dptr++ = nr->your_id; + *dptr++ = nr->my_index; + *dptr++ = nr->my_id; *dptr++ = frametype; - *dptr++ = sk->protinfo.nr->window; - if (sk->protinfo.nr->bpqext) *dptr++ = sysctl_netrom_network_ttl_initialiser; + *dptr++ = nr->window; + if (nr->bpqext) *dptr++ = sysctl_netrom_network_ttl_initialiser; break; case NR_DISCREQ: case NR_DISCACK: - *dptr++ = sk->protinfo.nr->your_index; - *dptr++ = sk->protinfo.nr->your_id; + *dptr++ = nr->your_index; + *dptr++ = nr->your_id; *dptr++ = 0; *dptr++ = 0; *dptr++ = frametype; break; case NR_INFOACK: - *dptr++ = sk->protinfo.nr->your_index; - *dptr++ = sk->protinfo.nr->your_id; + *dptr++ = nr->your_index; + *dptr++ = nr->your_id; *dptr++ = 0; - *dptr++ = sk->protinfo.nr->vr; + *dptr++ = nr->vr; *dptr++ = frametype; break; } @@ -275,7 +280,7 @@ nr_clear_queues(sk); - sk->protinfo.nr->state = NR_STATE_0; + NR_SK(sk)->state = NR_STATE_0; sk->state = TCP_CLOSE; sk->err = reason; diff -uNr linux-2.5.1/net/netrom/nr_timer.c linux-2.5.1.acme/net/netrom/nr_timer.c --- linux-2.5.1/net/netrom/nr_timer.c Fri Dec 29 20:44:46 2000 +++ linux-2.5.1.acme/net/netrom/nr_timer.c Wed Dec 19 23:44:48 2001 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -45,47 +46,55 @@ void nr_start_t1timer(struct sock *sk) { - del_timer(&sk->protinfo.nr->t1timer); + nr_cb *nr = NR_SK(sk); - sk->protinfo.nr->t1timer.data = (unsigned long)sk; - sk->protinfo.nr->t1timer.function = &nr_t1timer_expiry; - sk->protinfo.nr->t1timer.expires = jiffies + sk->protinfo.nr->t1; + del_timer(&nr->t1timer); - add_timer(&sk->protinfo.nr->t1timer); + nr->t1timer.data = (unsigned long)sk; + nr->t1timer.function = &nr_t1timer_expiry; + nr->t1timer.expires = jiffies + nr->t1; + + add_timer(&nr->t1timer); } void nr_start_t2timer(struct sock *sk) { - del_timer(&sk->protinfo.nr->t2timer); + nr_cb *nr = NR_SK(sk); + + del_timer(&nr->t2timer); - sk->protinfo.nr->t2timer.data = (unsigned long)sk; - sk->protinfo.nr->t2timer.function = &nr_t2timer_expiry; - sk->protinfo.nr->t2timer.expires = jiffies + sk->protinfo.nr->t2; + nr->t2timer.data = (unsigned long)sk; + nr->t2timer.function = &nr_t2timer_expiry; + nr->t2timer.expires = jiffies + nr->t2; - add_timer(&sk->protinfo.nr->t2timer); + add_timer(&nr->t2timer); } void nr_start_t4timer(struct sock *sk) { - del_timer(&sk->protinfo.nr->t4timer); + nr_cb *nr = NR_SK(sk); + + del_timer(&nr->t4timer); - sk->protinfo.nr->t4timer.data = (unsigned long)sk; - sk->protinfo.nr->t4timer.function = &nr_t4timer_expiry; - sk->protinfo.nr->t4timer.expires = jiffies + sk->protinfo.nr->t4; + nr->t4timer.data = (unsigned long)sk; + nr->t4timer.function = &nr_t4timer_expiry; + nr->t4timer.expires = jiffies + nr->t4; - add_timer(&sk->protinfo.nr->t4timer); + add_timer(&nr->t4timer); } void nr_start_idletimer(struct sock *sk) { - del_timer(&sk->protinfo.nr->idletimer); + nr_cb *nr = NR_SK(sk); - if (sk->protinfo.nr->idle > 0) { - sk->protinfo.nr->idletimer.data = (unsigned long)sk; - sk->protinfo.nr->idletimer.function = &nr_idletimer_expiry; - sk->protinfo.nr->idletimer.expires = jiffies + sk->protinfo.nr->idle; + del_timer(&nr->idletimer); - add_timer(&sk->protinfo.nr->idletimer); + if (nr->idle > 0) { + nr->idletimer.data = (unsigned long)sk; + nr->idletimer.function = &nr_idletimer_expiry; + nr->idletimer.expires = jiffies + nr->idle; + + add_timer(&nr->idletimer); } } @@ -102,22 +111,22 @@ void nr_stop_t1timer(struct sock *sk) { - del_timer(&sk->protinfo.nr->t1timer); + del_timer(&NR_SK(sk)->t1timer); } void nr_stop_t2timer(struct sock *sk) { - del_timer(&sk->protinfo.nr->t2timer); + del_timer(&NR_SK(sk)->t2timer); } void nr_stop_t4timer(struct sock *sk) { - del_timer(&sk->protinfo.nr->t4timer); + del_timer(&NR_SK(sk)->t4timer); } void nr_stop_idletimer(struct sock *sk) { - del_timer(&sk->protinfo.nr->idletimer); + del_timer(&NR_SK(sk)->idletimer); } void nr_stop_heartbeat(struct sock *sk) @@ -127,14 +136,14 @@ int nr_t1timer_running(struct sock *sk) { - return timer_pending(&sk->protinfo.nr->t1timer); + return timer_pending(&NR_SK(sk)->t1timer); } static void nr_heartbeat_expiry(unsigned long param) { struct sock *sk = (struct sock *)param; - switch (sk->protinfo.nr->state) { + switch (NR_SK(sk)->state) { case NR_STATE_0: /* Magic here: If we listen() and a new link dies before it @@ -145,19 +154,21 @@ } break; - case NR_STATE_3: + case NR_STATE_3: { + nr_cb *nr = NR_SK(sk); /* * Check for the state of the receive buffer. */ if (atomic_read(&sk->rmem_alloc) < (sk->rcvbuf / 2) && - (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY)) { - sk->protinfo.nr->condition &= ~NR_COND_OWN_RX_BUSY; - sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING; - sk->protinfo.nr->vl = sk->protinfo.nr->vr; + (nr->condition & NR_COND_OWN_RX_BUSY)) { + nr->condition &= ~NR_COND_OWN_RX_BUSY; + nr->condition &= ~NR_COND_ACK_PENDING; + nr->vl = nr->vr; nr_write_internal(sk, NR_INFOACK); break; } break; + } } nr_start_heartbeat(sk); @@ -166,9 +177,10 @@ static void nr_t2timer_expiry(unsigned long param) { struct sock *sk = (struct sock *)param; + nr_cb *nr = NR_SK(sk); - if (sk->protinfo.nr->condition & NR_COND_ACK_PENDING) { - sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING; + if (nr->condition & NR_COND_ACK_PENDING) { + nr->condition &= ~NR_COND_ACK_PENDING; nr_enquiry_response(sk); } } @@ -177,18 +189,19 @@ { struct sock *sk = (struct sock *)param; - sk->protinfo.nr->condition &= ~NR_COND_PEER_RX_BUSY; + NR_SK(sk)->condition &= ~NR_COND_PEER_RX_BUSY; } static void nr_idletimer_expiry(unsigned long param) { struct sock *sk = (struct sock *)param; + nr_cb *nr = NR_SK(sk); nr_clear_queues(sk); - sk->protinfo.nr->n2count = 0; + nr->n2count = 0; nr_write_internal(sk, NR_DISCREQ); - sk->protinfo.nr->state = NR_STATE_2; + nr->state = NR_STATE_2; nr_start_t1timer(sk); nr_stop_t2timer(sk); @@ -207,35 +220,36 @@ static void nr_t1timer_expiry(unsigned long param) { struct sock *sk = (struct sock *)param; + nr_cb *nr = NR_SK(sk); - switch (sk->protinfo.nr->state) { + switch (nr->state) { case NR_STATE_1: - if (sk->protinfo.nr->n2count == sk->protinfo.nr->n2) { + if (nr->n2count == nr->n2) { nr_disconnect(sk, ETIMEDOUT); return; } else { - sk->protinfo.nr->n2count++; + nr->n2count++; nr_write_internal(sk, NR_CONNREQ); } break; case NR_STATE_2: - if (sk->protinfo.nr->n2count == sk->protinfo.nr->n2) { + if (nr->n2count == nr->n2) { nr_disconnect(sk, ETIMEDOUT); return; } else { - sk->protinfo.nr->n2count++; + nr->n2count++; nr_write_internal(sk, NR_DISCREQ); } break; case NR_STATE_3: - if (sk->protinfo.nr->n2count == sk->protinfo.nr->n2) { + if (nr->n2count == nr->n2) { nr_disconnect(sk, ETIMEDOUT); return; } else { - sk->protinfo.nr->n2count++; + nr->n2count++; nr_requeue_frames(sk); } break; diff -uNr linux-2.5.1/net/packet/af_packet.c linux-2.5.1.acme/net/packet/af_packet.c --- linux-2.5.1/net/packet/af_packet.c Tue Oct 30 21:08:12 2001 +++ linux-2.5.1.acme/net/packet/af_packet.c Wed Dec 19 23:44:48 2001 @@ -199,6 +199,8 @@ #endif }; +#define PKT_SK(__sk) ((struct packet_opt *)(__sk)->protinfo) + void packet_sock_destruct(struct sock *sk) { BUG_TRAP(atomic_read(&sk->rmem_alloc)==0); @@ -209,8 +211,8 @@ return; } - if (sk->protinfo.destruct_hook) - kfree(sk->protinfo.destruct_hook); + if (PKT_SK(sk)) + kfree(PKT_SK(sk)); atomic_dec(&packet_socks_nr); #ifdef PACKET_REFCNT_DEBUG printk(KERN_DEBUG "PACKET socket %p is free, %d are alive\n", sk, atomic_read(&packet_socks_nr)); @@ -413,7 +415,7 @@ goto drop; sk = (struct sock *) pt->data; - po = sk->protinfo.af_packet; + po = PKT_SK(sk); skb->dev = dev; @@ -528,7 +530,7 @@ goto drop; sk = (struct sock *) pt->data; - po = sk->protinfo.af_packet; + po = PKT_SK(sk); if (dev->hard_header) { if (sk->type != SOCK_DGRAM) @@ -676,7 +678,7 @@ */ if (saddr == NULL) { - ifindex = sk->protinfo.af_packet->ifindex; + ifindex = PKT_SK(sk)->ifindex; proto = sk->num; addr = NULL; } else { @@ -780,12 +782,12 @@ * Unhook packet receive handler. */ - if (sk->protinfo.af_packet->running) { + if (PKT_SK(sk)->running) { /* * Remove the protocol hook */ - dev_remove_pack(&sk->protinfo.af_packet->prot_hook); - sk->protinfo.af_packet->running = 0; + dev_remove_pack(&PKT_SK(sk)->prot_hook); + PKT_SK(sk)->running = 0; __sock_put(sk); } @@ -794,7 +796,7 @@ #endif #ifdef CONFIG_PACKET_MMAP - if (sk->protinfo.af_packet->pg_vec) { + if (PKT_SK(sk)->pg_vec) { struct tpacket_req req; memset(&req, 0, sizeof(req)); packet_set_ring(sk, &req, 1); @@ -828,40 +830,40 @@ lock_sock(sk); - spin_lock(&sk->protinfo.af_packet->bind_lock); - if (sk->protinfo.af_packet->running) { - dev_remove_pack(&sk->protinfo.af_packet->prot_hook); + spin_lock(&PKT_SK(sk)->bind_lock); + if (PKT_SK(sk)->running) { + dev_remove_pack(&PKT_SK(sk)->prot_hook); __sock_put(sk); - sk->protinfo.af_packet->running = 0; + PKT_SK(sk)->running = 0; } sk->num = protocol; - sk->protinfo.af_packet->prot_hook.type = protocol; - sk->protinfo.af_packet->prot_hook.dev = dev; + PKT_SK(sk)->prot_hook.type = protocol; + PKT_SK(sk)->prot_hook.dev = dev; - sk->protinfo.af_packet->ifindex = dev ? dev->ifindex : 0; + PKT_SK(sk)->ifindex = dev ? dev->ifindex : 0; if (protocol == 0) goto out_unlock; if (dev) { if (dev->flags&IFF_UP) { - dev_add_pack(&sk->protinfo.af_packet->prot_hook); + dev_add_pack(&PKT_SK(sk)->prot_hook); sock_hold(sk); - sk->protinfo.af_packet->running = 1; + PKT_SK(sk)->running = 1; } else { sk->err = ENETDOWN; if (!sk->dead) sk->error_report(sk); } } else { - dev_add_pack(&sk->protinfo.af_packet->prot_hook); + dev_add_pack(&PKT_SK(sk)->prot_hook); sock_hold(sk); - sk->protinfo.af_packet->running = 1; + PKT_SK(sk)->running = 1; } out_unlock: - spin_unlock(&sk->protinfo.af_packet->bind_lock); + spin_unlock(&PKT_SK(sk)->bind_lock); release_sock(sk); return 0; } @@ -962,10 +964,10 @@ #endif sock_init_data(sock,sk); - sk->protinfo.af_packet = kmalloc(sizeof(struct packet_opt), GFP_KERNEL); - if (sk->protinfo.af_packet == NULL) + PKT_SK(sk) = kmalloc(sizeof(struct packet_opt), GFP_KERNEL); + if (!PKT_SK(sk)) goto out_free; - memset(sk->protinfo.af_packet, 0, sizeof(struct packet_opt)); + memset(PKT_SK(sk), 0, sizeof(struct packet_opt)); sk->family = PF_PACKET; sk->num = protocol; @@ -976,19 +978,19 @@ * Attach a protocol block */ - spin_lock_init(&sk->protinfo.af_packet->bind_lock); - sk->protinfo.af_packet->prot_hook.func = packet_rcv; + spin_lock_init(&PKT_SK(sk)->bind_lock); + PKT_SK(sk)->prot_hook.func = packet_rcv; #ifdef CONFIG_SOCK_PACKET if (sock->type == SOCK_PACKET) - sk->protinfo.af_packet->prot_hook.func = packet_rcv_spkt; + PKT_SK(sk)->prot_hook.func = packet_rcv_spkt; #endif - sk->protinfo.af_packet->prot_hook.data = (void *)sk; + PKT_SK(sk)->prot_hook.data = (void *)sk; if (protocol) { - sk->protinfo.af_packet->prot_hook.type = protocol; - dev_add_pack(&sk->protinfo.af_packet->prot_hook); + PKT_SK(sk)->prot_hook.type = protocol; + dev_add_pack(&PKT_SK(sk)->prot_hook); sock_hold(sk); - sk->protinfo.af_packet->running = 1; + PKT_SK(sk)->running = 1; } write_lock_bh(&packet_sklist_lock); @@ -1023,7 +1025,7 @@ #if 0 /* What error should we return now? EUNATTACH? */ - if (sk->protinfo.af_packet->ifindex < 0) + if (PKT_SK(sk)->ifindex < 0) return -ENODEV; #endif @@ -1101,7 +1103,7 @@ return -EOPNOTSUPP; uaddr->sa_family = AF_PACKET; - dev = dev_get_by_index(sk->protinfo.af_packet->ifindex); + dev = dev_get_by_index(PKT_SK(sk)->ifindex); if (dev) { strncpy(uaddr->sa_data, dev->name, 15); dev_put(dev); @@ -1124,9 +1126,9 @@ return -EOPNOTSUPP; sll->sll_family = AF_PACKET; - sll->sll_ifindex = sk->protinfo.af_packet->ifindex; + sll->sll_ifindex = PKT_SK(sk)->ifindex; sll->sll_protocol = sk->num; - dev = dev_get_by_index(sk->protinfo.af_packet->ifindex); + dev = dev_get_by_index(PKT_SK(sk)->ifindex); if (dev) { sll->sll_hatype = dev->type; sll->sll_halen = dev->addr_len; @@ -1192,7 +1194,7 @@ goto done; err = 0; - for (ml=sk->protinfo.af_packet->mclist; ml; ml=ml->next) { + for (ml=PKT_SK(sk)->mclist; ml; ml=ml->next) { if (ml->ifindex == mreq->mr_ifindex && ml->type == mreq->mr_type && ml->alen == mreq->mr_alen && @@ -1209,8 +1211,8 @@ i->alen = mreq->mr_alen; memcpy(i->addr, mreq->mr_address, i->alen); i->count = 1; - i->next = sk->protinfo.af_packet->mclist; - sk->protinfo.af_packet->mclist = i; + i->next = PKT_SK(sk)->mclist; + PKT_SK(sk)->mclist = i; packet_dev_mc(dev, i, +1); done: @@ -1224,7 +1226,7 @@ rtnl_lock(); - for (mlp=&sk->protinfo.af_packet->mclist; (ml=*mlp)!=NULL; mlp=&ml->next) { + for (mlp=&PKT_SK(sk)->mclist; (ml=*mlp)!=NULL; mlp=&ml->next) { if (ml->ifindex == mreq->mr_ifindex && ml->type == mreq->mr_type && ml->alen == mreq->mr_alen && @@ -1251,13 +1253,13 @@ { struct packet_mclist *ml; - if (sk->protinfo.af_packet->mclist == NULL) + if (PKT_SK(sk)->mclist == NULL) return; rtnl_lock(); - while ((ml=sk->protinfo.af_packet->mclist) != NULL) { + while ((ml=PKT_SK(sk)->mclist) != NULL) { struct net_device *dev; - sk->protinfo.af_packet->mclist = ml->next; + PKT_SK(sk)->mclist = ml->next; if ((dev = dev_get_by_index(ml->ifindex)) != NULL) { packet_dev_mc(dev, ml, -1); dev_put(dev); @@ -1314,7 +1316,7 @@ if (copy_from_user(&val,optval,sizeof(val))) return -EFAULT; - sk->protinfo.af_packet->copy_thresh = val; + PKT_SK(sk)->copy_thresh = val; return 0; } #endif @@ -1346,8 +1348,8 @@ if (len > sizeof(struct tpacket_stats)) len = sizeof(struct tpacket_stats); spin_lock_bh(&sk->receive_queue.lock); - st = sk->protinfo.af_packet->stats; - memset(&sk->protinfo.af_packet->stats, 0, sizeof(st)); + st = PKT_SK(sk)->stats; + memset(&PKT_SK(sk)->stats, 0, sizeof(st)); spin_unlock_bh(&sk->receive_queue.lock); st.tp_packets += st.tp_drops; @@ -1373,7 +1375,7 @@ read_lock(&packet_sklist_lock); for (sk = packet_sklist; sk; sk = sk->next) { - po = sk->protinfo.af_packet; + po = PKT_SK(sk); switch (msg) { case NETDEV_DOWN: @@ -1552,7 +1554,7 @@ unsigned int packet_poll(struct file * file, struct socket *sock, poll_table *wait) { struct sock *sk = sock->sk; - struct packet_opt *po = sk->protinfo.af_packet; + struct packet_opt *po = PKT_SK(sk); unsigned int mask = datagram_poll(file, sock, wait); spin_lock_bh(&sk->receive_queue.lock); @@ -1579,7 +1581,7 @@ struct sock *sk = sock->sk; if (sk) - atomic_inc(&sk->protinfo.af_packet->mapped); + atomic_inc(&PKT_SK(sk)->mapped); } static void packet_mm_close(struct vm_area_struct *vma) @@ -1590,7 +1592,7 @@ struct sock *sk = sock->sk; if (sk) - atomic_dec(&sk->protinfo.af_packet->mapped); + atomic_dec(&PKT_SK(sk)->mapped); } static struct vm_operations_struct packet_mmap_ops = { @@ -1620,7 +1622,7 @@ { unsigned long *pg_vec = NULL; struct tpacket_hdr **io_vec = NULL; - struct packet_opt *po = sk->protinfo.af_packet; + struct packet_opt *po = PKT_SK(sk); int order = 0; int err = 0; @@ -1742,7 +1744,7 @@ static int packet_mmap(struct file *file, struct socket *sock, struct vm_area_struct *vma) { struct sock *sk = sock->sk; - struct packet_opt *po = sk->protinfo.af_packet; + struct packet_opt *po = PKT_SK(sk); unsigned long size; unsigned long start; int err = -EINVAL; @@ -1851,8 +1853,8 @@ atomic_read(&s->refcnt), s->type, ntohs(s->num), - s->protinfo.af_packet->ifindex, - s->protinfo.af_packet->running, + PKT_SK(s)->ifindex, + PKT_SK(s)->running, atomic_read(&s->rmem_alloc), sock_i_uid(s), sock_i_ino(s) diff -uNr linux-2.5.1/net/rose/af_rose.c linux-2.5.1.acme/net/rose/af_rose.c --- linux-2.5.1/net/rose/af_rose.c Mon Sep 10 11:58:35 2001 +++ linux-2.5.1.acme/net/rose/af_rose.c Wed Dec 19 23:44:48 2001 @@ -161,8 +161,8 @@ memset(rose, 0x00, sizeof(*rose)); - sk->protinfo.rose = rose; - rose->sk = sk; + ROSE_SK(sk) = rose; + rose->sk = sk; return sk; } @@ -205,10 +205,12 @@ struct sock *s; for (s = rose_list; s != NULL; s = s->next) { - if (s->protinfo.rose->neighbour == neigh) { + rose_cb *rose = ROSE_SK(s); + + if (rose->neighbour == neigh) { rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0); - s->protinfo.rose->neighbour->use--; - s->protinfo.rose->neighbour = NULL; + rose->neighbour->use--; + rose->neighbour = NULL; } } } @@ -221,10 +223,12 @@ struct sock *s; for (s = rose_list; s != NULL; s = s->next) { - if (s->protinfo.rose->device == dev) { + rose_cb *rose = ROSE_SK(s); + + if (rose->device == dev) { rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0); - s->protinfo.rose->neighbour->use--; - s->protinfo.rose->device = NULL; + rose->neighbour->use--; + rose->device = NULL; } } } @@ -279,14 +283,22 @@ save_flags(flags); cli(); for (s = rose_list; s != NULL; s = s->next) { - if (rosecmp(&s->protinfo.rose->source_addr, addr) == 0 && ax25cmp(&s->protinfo.rose->source_call, call) == 0 && s->protinfo.rose->source_ndigis == 0 && s->state == TCP_LISTEN) { + rose_cb *rose = ROSE_SK(s); + + if (!rosecmp(&rose->source_addr, addr) && + !ax25cmp(&rose->source_call, call) && + !rose->source_ndigis && s->state == TCP_LISTEN) { restore_flags(flags); return s; } } for (s = rose_list; s != NULL; s = s->next) { - if (rosecmp(&s->protinfo.rose->source_addr, addr) == 0 && ax25cmp(&s->protinfo.rose->source_call, &null_ax25_address) == 0 && s->state == TCP_LISTEN) { + rose_cb *rose = ROSE_SK(s); + + if (!rosecmp(&rose->source_addr, addr) && + !ax25cmp(&rose->source_call, &null_ax25_address) && + s->state == TCP_LISTEN) { restore_flags(flags); return s; } @@ -307,7 +319,9 @@ save_flags(flags); cli(); for (s = rose_list; s != NULL; s = s->next) { - if (s->protinfo.rose->lci == lci && s->protinfo.rose->neighbour == neigh) { + rose_cb *rose = ROSE_SK(s); + + if (rose->lci == lci && rose->neighbour == neigh) { restore_flags(flags); return s; } @@ -375,7 +389,7 @@ if (skb->sk != sk) { /* A pending connection */ skb->sk->dead = 1; /* Queue the unaccepted socket for death */ rose_start_heartbeat(skb->sk); - skb->sk->protinfo.rose->state = ROSE_STATE_0; + ROSE_SK(skb->sk)->state = ROSE_STATE_0; } kfree_skb(skb); @@ -404,6 +418,7 @@ char *optval, int optlen) { struct sock *sk = sock->sk; + rose_cb *rose = ROSE_SK(sk); int opt; if (level != SOL_ROSE) @@ -417,41 +432,41 @@ switch (optname) { case ROSE_DEFER: - sk->protinfo.rose->defer = opt ? 1 : 0; + rose->defer = opt ? 1 : 0; return 0; case ROSE_T1: if (opt < 1) return -EINVAL; - sk->protinfo.rose->t1 = opt * HZ; + rose->t1 = opt * HZ; return 0; case ROSE_T2: if (opt < 1) return -EINVAL; - sk->protinfo.rose->t2 = opt * HZ; + rose->t2 = opt * HZ; return 0; case ROSE_T3: if (opt < 1) return -EINVAL; - sk->protinfo.rose->t3 = opt * HZ; + rose->t3 = opt * HZ; return 0; case ROSE_HOLDBACK: if (opt < 1) return -EINVAL; - sk->protinfo.rose->hb = opt * HZ; + rose->hb = opt * HZ; return 0; case ROSE_IDLE: if (opt < 0) return -EINVAL; - sk->protinfo.rose->idle = opt * 60 * HZ; + rose->idle = opt * 60 * HZ; return 0; case ROSE_QBITINCL: - sk->protinfo.rose->qbitincl = opt ? 1 : 0; + rose->qbitincl = opt ? 1 : 0; return 0; default: @@ -463,6 +478,7 @@ char *optval, int *optlen) { struct sock *sk = sock->sk; + rose_cb *rose = ROSE_SK(sk); int val = 0; int len; @@ -477,31 +493,31 @@ switch (optname) { case ROSE_DEFER: - val = sk->protinfo.rose->defer; + val = rose->defer; break; case ROSE_T1: - val = sk->protinfo.rose->t1 / HZ; + val = rose->t1 / HZ; break; case ROSE_T2: - val = sk->protinfo.rose->t2 / HZ; + val = rose->t2 / HZ; break; case ROSE_T3: - val = sk->protinfo.rose->t3 / HZ; + val = rose->t3 / HZ; break; case ROSE_HOLDBACK: - val = sk->protinfo.rose->hb / HZ; + val = rose->hb / HZ; break; case ROSE_IDLE: - val = sk->protinfo.rose->idle / (60 * HZ); + val = rose->idle / (60 * HZ); break; case ROSE_QBITINCL: - val = sk->protinfo.rose->qbitincl; + val = rose->qbitincl; break; default: @@ -521,10 +537,12 @@ struct sock *sk = sock->sk; if (sk->state != TCP_LISTEN) { - sk->protinfo.rose->dest_ndigis = 0; - memset(&sk->protinfo.rose->dest_addr, '\0', ROSE_ADDR_LEN); - memset(&sk->protinfo.rose->dest_call, '\0', AX25_ADDR_LEN); - memset(sk->protinfo.rose->dest_digis, '\0', AX25_ADDR_LEN*ROSE_MAX_DIGIS); + rose_cb *rose = ROSE_SK(sk); + + rose->dest_ndigis = 0; + memset(&rose->dest_addr, 0, ROSE_ADDR_LEN); + memset(&rose->dest_call, 0, AX25_ADDR_LEN); + memset(rose->dest_digis, 0, AX25_ADDR_LEN * ROSE_MAX_DIGIS); sk->max_ack_backlog = backlog; sk->state = TCP_LISTEN; return 0; @@ -544,7 +562,7 @@ if ((sk = rose_alloc_sock()) == NULL) return -ENOMEM; - rose = sk->protinfo.rose; + rose = ROSE_SK(sk); sock_init_data(sock, sk); @@ -574,7 +592,7 @@ static struct sock *rose_make_new(struct sock *osk) { struct sock *sk; - rose_cb *rose; + rose_cb *rose, *orose; if (osk->type != SOCK_SEQPACKET) return NULL; @@ -582,7 +600,7 @@ if ((sk = rose_alloc_sock()) == NULL) return NULL; - rose = sk->protinfo.rose; + rose = ROSE_SK(sk); sock_init_data(NULL, sk); @@ -606,15 +624,15 @@ init_timer(&rose->timer); init_timer(&rose->idletimer); - rose->t1 = osk->protinfo.rose->t1; - rose->t2 = osk->protinfo.rose->t2; - rose->t3 = osk->protinfo.rose->t3; - rose->hb = osk->protinfo.rose->hb; - rose->idle = osk->protinfo.rose->idle; - - rose->defer = osk->protinfo.rose->defer; - rose->device = osk->protinfo.rose->device; - rose->qbitincl = osk->protinfo.rose->qbitincl; + orose = ROSE_SK(osk); + rose->t1 = orose->t1; + rose->t2 = orose->t2; + rose->t3 = orose->t3; + rose->hb = orose->hb; + rose->idle = orose->idle; + rose->defer = orose->defer; + rose->device = orose->device; + rose->qbitincl = orose->qbitincl; return sk; } @@ -622,10 +640,13 @@ static int rose_release(struct socket *sock) { struct sock *sk = sock->sk; + rose_cb *rose; if (sk == NULL) return 0; - switch (sk->protinfo.rose->state) { + rose = ROSE_SK(sk); + + switch (rose->state) { case ROSE_STATE_0: rose_disconnect(sk, 0, -1, -1); @@ -633,7 +654,7 @@ break; case ROSE_STATE_2: - sk->protinfo.rose->neighbour->use--; + rose->neighbour->use--; rose_disconnect(sk, 0, -1, -1); rose_destroy_socket(sk); break; @@ -646,12 +667,12 @@ rose_stop_idletimer(sk); rose_write_internal(sk, ROSE_CLEAR_REQUEST); rose_start_t3timer(sk); - sk->protinfo.rose->state = ROSE_STATE_2; - sk->state = TCP_CLOSE; - sk->shutdown |= SEND_SHUTDOWN; + rose->state = ROSE_STATE_2; + sk->state = TCP_CLOSE; + sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); - sk->dead = 1; - sk->destroy = 1; + sk->dead = 1; + sk->destroy = 1; break; default: @@ -667,6 +688,7 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct sock *sk = sock->sk; + rose_cb *rose = ROSE_SK(sk); struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr; struct net_device *dev; ax25_address *user, *source; @@ -700,18 +722,18 @@ user = source; } - sk->protinfo.rose->source_addr = addr->srose_addr; - sk->protinfo.rose->source_call = *user; - sk->protinfo.rose->device = dev; - sk->protinfo.rose->source_ndigis = addr->srose_ndigis; + rose->source_addr = addr->srose_addr; + rose->source_call = *user; + rose->device = dev; + rose->source_ndigis = addr->srose_ndigis; if (addr_len == sizeof(struct full_sockaddr_rose)) { struct full_sockaddr_rose *full_addr = (struct full_sockaddr_rose *)uaddr; for (n = 0 ; n < addr->srose_ndigis ; n++) - sk->protinfo.rose->source_digis[n] = full_addr->srose_digis[n]; + rose->source_digis[n] = full_addr->srose_digis[n]; } else { - if (sk->protinfo.rose->source_ndigis == 1) { - sk->protinfo.rose->source_digis[0] = addr->srose_digi; + if (rose->source_ndigis == 1) { + rose->source_digis[0] = addr->srose_digi; } } @@ -725,6 +747,7 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags) { struct sock *sk = sock->sk; + rose_cb *rose = ROSE_SK(sk); struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr; unsigned char cause, diagnostic; ax25_address *user; @@ -760,13 +783,16 @@ return -EINVAL; /* Source + Destination digis should not exceed ROSE_MAX_DIGIS */ - if ((sk->protinfo.rose->source_ndigis + addr->srose_ndigis) > ROSE_MAX_DIGIS) + if ((rose->source_ndigis + addr->srose_ndigis) > ROSE_MAX_DIGIS) return -EINVAL; - if ((sk->protinfo.rose->neighbour = rose_get_neigh(&addr->srose_addr, &cause, &diagnostic)) == NULL) + rose->neighbour = rose_get_neigh(&addr->srose_addr, &cause, + &diagnostic); + if (!rose->neighbour) return -ENETUNREACH; - if ((sk->protinfo.rose->lci = rose_new_lci(sk->protinfo.rose->neighbour)) == 0) + rose->lci = rose_new_lci(rose->neighbour); + if (!rose->lci) return -ENETUNREACH; if (sk->zapped) { /* Must bind first - autobinding in this may or may not work */ @@ -778,25 +804,25 @@ if ((user = ax25_findbyuid(current->euid)) == NULL) return -EINVAL; - memcpy(&sk->protinfo.rose->source_addr, dev->dev_addr, ROSE_ADDR_LEN); - sk->protinfo.rose->source_call = *user; - sk->protinfo.rose->device = dev; + memcpy(&rose->source_addr, dev->dev_addr, ROSE_ADDR_LEN); + rose->source_call = *user; + rose->device = dev; rose_insert_socket(sk); /* Finish the bind */ } - sk->protinfo.rose->dest_addr = addr->srose_addr; - sk->protinfo.rose->dest_call = addr->srose_call; - sk->protinfo.rose->rand = ((int)sk->protinfo.rose & 0xFFFF) + sk->protinfo.rose->lci; - sk->protinfo.rose->dest_ndigis = addr->srose_ndigis; + rose->dest_addr = addr->srose_addr; + rose->dest_call = addr->srose_call; + rose->rand = ((int)rose & 0xFFFF) + rose->lci; + rose->dest_ndigis = addr->srose_ndigis; if (addr_len == sizeof(struct full_sockaddr_rose)) { struct full_sockaddr_rose *full_addr = (struct full_sockaddr_rose *)uaddr; for (n = 0 ; n < addr->srose_ndigis ; n++) - sk->protinfo.rose->dest_digis[n] = full_addr->srose_digis[n]; + rose->dest_digis[n] = full_addr->srose_digis[n]; } else { - if (sk->protinfo.rose->dest_ndigis == 1) { - sk->protinfo.rose->dest_digis[0] = addr->srose_digi; + if (rose->dest_ndigis == 1) { + rose->dest_digis[0] = addr->srose_digi; } } @@ -804,9 +830,9 @@ sock->state = SS_CONNECTING; sk->state = TCP_SYN_SENT; - sk->protinfo.rose->state = ROSE_STATE_1; + rose->state = ROSE_STATE_1; - sk->protinfo.rose->neighbour->use++; + rose->neighbour->use++; rose_write_internal(sk, ROSE_CALL_REQUEST); rose_start_heartbeat(sk); @@ -896,24 +922,25 @@ { struct full_sockaddr_rose *srose = (struct full_sockaddr_rose *)uaddr; struct sock *sk = sock->sk; + rose_cb *rose = ROSE_SK(sk); int n; if (peer != 0) { if (sk->state != TCP_ESTABLISHED) return -ENOTCONN; srose->srose_family = AF_ROSE; - srose->srose_addr = sk->protinfo.rose->dest_addr; - srose->srose_call = sk->protinfo.rose->dest_call; - srose->srose_ndigis = sk->protinfo.rose->dest_ndigis; - for (n = 0 ; n < sk->protinfo.rose->dest_ndigis ; n++) - srose->srose_digis[n] = sk->protinfo.rose->dest_digis[n]; + srose->srose_addr = rose->dest_addr; + srose->srose_call = rose->dest_call; + srose->srose_ndigis = rose->dest_ndigis; + for (n = 0; n < rose->dest_ndigis; n++) + srose->srose_digis[n] = rose->dest_digis[n]; } else { srose->srose_family = AF_ROSE; - srose->srose_addr = sk->protinfo.rose->source_addr; - srose->srose_call = sk->protinfo.rose->source_call; - srose->srose_ndigis = sk->protinfo.rose->source_ndigis; - for (n = 0 ; n < sk->protinfo.rose->source_ndigis ; n++) - srose->srose_digis[n] = sk->protinfo.rose->source_digis[n]; + srose->srose_addr = rose->source_addr; + srose->srose_call = rose->source_call; + srose->srose_ndigis = rose->source_ndigis; + for (n = 0; n < rose->source_ndigis; n++) + srose->srose_digis[n] = rose->source_digis[n]; } *uaddr_len = sizeof(struct full_sockaddr_rose); @@ -924,6 +951,7 @@ { struct sock *sk; struct sock *make; + rose_cb *make_rose; struct rose_facilities_struct facilities; int n, len; @@ -953,37 +981,38 @@ skb->sk = make; make->state = TCP_ESTABLISHED; + make_rose = ROSE_SK(make); - make->protinfo.rose->lci = lci; - make->protinfo.rose->dest_addr = facilities.dest_addr; - make->protinfo.rose->dest_call = facilities.dest_call; - make->protinfo.rose->dest_ndigis = facilities.dest_ndigis; + make_rose->lci = lci; + make_rose->dest_addr = facilities.dest_addr; + make_rose->dest_call = facilities.dest_call; + make_rose->dest_ndigis = facilities.dest_ndigis; for (n = 0 ; n < facilities.dest_ndigis ; n++) - make->protinfo.rose->dest_digis[n] = facilities.dest_digis[n]; - make->protinfo.rose->source_addr = facilities.source_addr; - make->protinfo.rose->source_call = facilities.source_call; - make->protinfo.rose->source_ndigis = facilities.source_ndigis; + make_rose->dest_digis[n] = facilities.dest_digis[n]; + make_rose->source_addr = facilities.source_addr; + make_rose->source_call = facilities.source_call; + make_rose->source_ndigis = facilities.source_ndigis; for (n = 0 ; n < facilities.source_ndigis ; n++) - make->protinfo.rose->source_digis[n]= facilities.source_digis[n]; - make->protinfo.rose->neighbour = neigh; - make->protinfo.rose->device = dev; - make->protinfo.rose->facilities = facilities; + make_rose->source_digis[n]= facilities.source_digis[n]; + make_rose->neighbour = neigh; + make_rose->device = dev; + make_rose->facilities = facilities; - make->protinfo.rose->neighbour->use++; + make_rose->neighbour->use++; - if (sk->protinfo.rose->defer) { - make->protinfo.rose->state = ROSE_STATE_5; + if (ROSE_SK(sk)->defer) { + make_rose->state = ROSE_STATE_5; } else { rose_write_internal(make, ROSE_CALL_ACCEPTED); - make->protinfo.rose->state = ROSE_STATE_3; + make_rose->state = ROSE_STATE_3; rose_start_idletimer(make); } - make->protinfo.rose->condition = 0x00; - make->protinfo.rose->vs = 0; - make->protinfo.rose->va = 0; - make->protinfo.rose->vr = 0; - make->protinfo.rose->vl = 0; + make_rose->condition = 0x00; + make_rose->vs = 0; + make_rose->va = 0; + make_rose->vr = 0; + make_rose->vl = 0; sk->ack_backlog++; make->pair = sk; @@ -1003,6 +1032,7 @@ struct scm_cookie *scm) { struct sock *sk = sock->sk; + rose_cb *rose = ROSE_SK(sk); struct sockaddr_rose *usrose = (struct sockaddr_rose *)msg->msg_name; int err; struct full_sockaddr_rose srose; @@ -1021,7 +1051,7 @@ return -EPIPE; } - if (sk->protinfo.rose->neighbour == NULL || sk->protinfo.rose->device == NULL) + if (rose->neighbour == NULL || rose->device == NULL) return -ENETUNREACH; if (usrose != NULL) { @@ -1029,14 +1059,15 @@ return -EINVAL; memset(&srose, 0, sizeof(struct full_sockaddr_rose)); memcpy(&srose, usrose, msg->msg_namelen); - if (rosecmp(&sk->protinfo.rose->dest_addr, &srose.srose_addr) != 0 || - ax25cmp(&sk->protinfo.rose->dest_call, &srose.srose_call) != 0) + if (rosecmp(&rose->dest_addr, &srose.srose_addr) != 0 || + ax25cmp(&rose->dest_call, &srose.srose_call) != 0) return -EISCONN; - if (srose.srose_ndigis != sk->protinfo.rose->dest_ndigis) + if (srose.srose_ndigis != rose->dest_ndigis) return -EISCONN; - if (srose.srose_ndigis == sk->protinfo.rose->dest_ndigis) { + if (srose.srose_ndigis == rose->dest_ndigis) { for (n = 0 ; n < srose.srose_ndigis ; n++) - if (ax25cmp(&sk->protinfo.rose->dest_digis[n], &srose.srose_digis[n]) != 0) + if (ax25cmp(&rose->dest_digis[n], + &srose.srose_digis[n])) return -EISCONN; } if (srose.srose_family != AF_ROSE) @@ -1046,11 +1077,11 @@ return -ENOTCONN; srose.srose_family = AF_ROSE; - srose.srose_addr = sk->protinfo.rose->dest_addr; - srose.srose_call = sk->protinfo.rose->dest_call; - srose.srose_ndigis = sk->protinfo.rose->dest_ndigis; - for (n = 0 ; n < sk->protinfo.rose->dest_ndigis ; n++) - srose.srose_digis[n] = sk->protinfo.rose->dest_digis[n]; + srose.srose_addr = rose->dest_addr; + srose.srose_call = rose->dest_call; + srose.srose_ndigis = rose->dest_ndigis; + for (n = 0 ; n < rose->dest_ndigis ; n++) + srose.srose_digis[n] = rose->dest_digis[n]; } SOCK_DEBUG(sk, "ROSE: sendto: Addresses built.\n"); @@ -1077,7 +1108,7 @@ * If the Q BIT Include socket option is in force, the first * byte of the user data is the logical value of the Q Bit. */ - if (sk->protinfo.rose->qbitincl) { + if (rose->qbitincl) { qbit = skb->data[0]; skb_pull(skb, 1); } @@ -1090,8 +1121,8 @@ SOCK_DEBUG(sk, "ROSE: Building Network Header.\n"); /* Build a ROSE Network header */ - asmptr[0] = ((sk->protinfo.rose->lci >> 8) & 0x0F) | ROSE_GFI; - asmptr[1] = (sk->protinfo.rose->lci >> 0) & 0xFF; + asmptr[0] = ((rose->lci >> 8) & 0x0F) | ROSE_GFI; + asmptr[1] = (rose->lci >> 0) & 0xFF; asmptr[2] = ROSE_DATA; if (qbit) @@ -1165,6 +1196,7 @@ int flags, struct scm_cookie *scm) { struct sock *sk = sock->sk; + rose_cb *rose = ROSE_SK(sk); struct sockaddr_rose *srose = (struct sockaddr_rose *)msg->msg_name; int copied, qbit; unsigned char *asmptr; @@ -1186,7 +1218,7 @@ skb_pull(skb, ROSE_MIN_LEN); - if (sk->protinfo.rose->qbitincl) { + if (rose->qbitincl) { asmptr = skb_push(skb, 1); *asmptr = qbit; } @@ -1203,18 +1235,18 @@ if (srose != NULL) { srose->srose_family = AF_ROSE; - srose->srose_addr = sk->protinfo.rose->dest_addr; - srose->srose_call = sk->protinfo.rose->dest_call; - srose->srose_ndigis = sk->protinfo.rose->dest_ndigis; + srose->srose_addr = rose->dest_addr; + srose->srose_call = rose->dest_call; + srose->srose_ndigis = rose->dest_ndigis; if (msg->msg_namelen >= sizeof(struct full_sockaddr_rose)) { struct full_sockaddr_rose *full_srose = (struct full_sockaddr_rose *)msg->msg_name; - for (n = 0 ; n < sk->protinfo.rose->dest_ndigis ; n++) - full_srose->srose_digis[n] = sk->protinfo.rose->dest_digis[n]; + for (n = 0 ; n < rose->dest_ndigis ; n++) + full_srose->srose_digis[n] = rose->dest_digis[n]; msg->msg_namelen = sizeof(struct full_sockaddr_rose); } else { - if (sk->protinfo.rose->dest_ndigis >= 1) { + if (rose->dest_ndigis >= 1) { srose->srose_ndigis = 1; - srose->srose_digi = sk->protinfo.rose->dest_digis[0]; + srose->srose_digi = rose->dest_digis[0]; } msg->msg_namelen = sizeof(struct sockaddr_rose); } @@ -1229,6 +1261,7 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; + rose_cb *rose = ROSE_SK(sk); switch (cmd) { case TIOCOUTQ: { @@ -1276,8 +1309,8 @@ case SIOCRSGCAUSE: { struct rose_cause_struct rose_cause; - rose_cause.cause = sk->protinfo.rose->cause; - rose_cause.diagnostic = sk->protinfo.rose->diagnostic; + rose_cause.cause = rose->cause; + rose_cause.diagnostic = rose->diagnostic; return copy_to_user((void *)arg, &rose_cause, sizeof(struct rose_cause_struct)) ? -EFAULT : 0; } @@ -1285,8 +1318,8 @@ struct rose_cause_struct rose_cause; if (copy_from_user(&rose_cause, (void *)arg, sizeof(struct rose_cause_struct))) return -EFAULT; - sk->protinfo.rose->cause = rose_cause.cause; - sk->protinfo.rose->diagnostic = rose_cause.diagnostic; + rose->cause = rose_cause.cause; + rose->diagnostic = rose_cause.diagnostic; return 0; } @@ -1304,15 +1337,15 @@ return copy_to_user((void *)arg, &rose_callsign, sizeof(ax25_address)) ? -EFAULT : 0; case SIOCRSACCEPT: - if (sk->protinfo.rose->state == ROSE_STATE_5) { + if (rose->state == ROSE_STATE_5) { rose_write_internal(sk, ROSE_CALL_ACCEPTED); rose_start_idletimer(sk); - sk->protinfo.rose->condition = 0x00; - sk->protinfo.rose->vs = 0; - sk->protinfo.rose->va = 0; - sk->protinfo.rose->vr = 0; - sk->protinfo.rose->vl = 0; - sk->protinfo.rose->state = ROSE_STATE_3; + rose->condition = 0x00; + rose->vs = 0; + rose->va = 0; + rose->vr = 0; + rose->vl = 0; + rose->state = ROSE_STATE_3; } return 0; @@ -1338,37 +1371,39 @@ len += sprintf(buffer, "dest_addr dest_call src_addr src_call dev lci neigh st vs vr va t t1 t2 t3 hb idle Snd-Q Rcv-Q inode\n"); for (s = rose_list; s != NULL; s = s->next) { - if ((dev = s->protinfo.rose->device) == NULL) + rose_cb *rose = ROSE_SK(s); + + if ((dev = rose->device) == NULL) devname = "???"; else devname = dev->name; len += sprintf(buffer + len, "%-10s %-9s ", - rose2asc(&s->protinfo.rose->dest_addr), - ax2asc(&s->protinfo.rose->dest_call)); + rose2asc(&rose->dest_addr), + ax2asc(&rose->dest_call)); - if (ax25cmp(&s->protinfo.rose->source_call, &null_ax25_address) == 0) + if (ax25cmp(&rose->source_call, &null_ax25_address) == 0) callsign = "??????-?"; else - callsign = ax2asc(&s->protinfo.rose->source_call); + callsign = ax2asc(&rose->source_call); len += sprintf(buffer + len, "%-10s %-9s %-5s %3.3X %05d %d %d %d %d %3lu %3lu %3lu %3lu %3lu %3lu/%03lu %5d %5d %ld\n", - rose2asc(&s->protinfo.rose->source_addr), + rose2asc(&rose->source_addr), callsign, devname, - s->protinfo.rose->lci & 0x0FFF, - (s->protinfo.rose->neighbour) ? s->protinfo.rose->neighbour->number : 0, - s->protinfo.rose->state, - s->protinfo.rose->vs, - s->protinfo.rose->vr, - s->protinfo.rose->va, - ax25_display_timer(&s->protinfo.rose->timer) / HZ, - s->protinfo.rose->t1 / HZ, - s->protinfo.rose->t2 / HZ, - s->protinfo.rose->t3 / HZ, - s->protinfo.rose->hb / HZ, - ax25_display_timer(&s->protinfo.rose->idletimer) / (60 * HZ), - s->protinfo.rose->idle / (60 * HZ), + rose->lci & 0x0FFF, + (rose->neighbour) ? rose->neighbour->number : 0, + rose->state, + rose->vs, + rose->vr, + rose->va, + ax25_display_timer(&rose->timer) / HZ, + rose->t1 / HZ, + rose->t2 / HZ, + rose->t3 / HZ, + rose->hb / HZ, + ax25_display_timer(&rose->idletimer) / (60 * HZ), + rose->idle / (60 * HZ), atomic_read(&s->wmem_alloc), atomic_read(&s->rmem_alloc), s->socket != NULL ? s->socket->inode->i_ino : 0L); diff -uNr linux-2.5.1/net/rose/rose_in.c linux-2.5.1.acme/net/rose/rose_in.c --- linux-2.5.1/net/rose/rose_in.c Fri Dec 29 20:44:46 2000 +++ linux-2.5.1.acme/net/rose/rose_in.c Wed Dec 19 23:44:48 2001 @@ -52,17 +52,19 @@ */ static int rose_state1_machine(struct sock *sk, struct sk_buff *skb, int frametype) { + rose_cb *rose = ROSE_SK(sk); + switch (frametype) { case ROSE_CALL_ACCEPTED: rose_stop_timer(sk); rose_start_idletimer(sk); - sk->protinfo.rose->condition = 0x00; - sk->protinfo.rose->vs = 0; - sk->protinfo.rose->va = 0; - sk->protinfo.rose->vr = 0; - sk->protinfo.rose->vl = 0; - sk->protinfo.rose->state = ROSE_STATE_3; + rose->condition = 0x00; + rose->vs = 0; + rose->va = 0; + rose->vr = 0; + rose->vl = 0; + rose->state = ROSE_STATE_3; sk->state = TCP_ESTABLISHED; if (!sk->dead) sk->state_change(sk); @@ -71,7 +73,7 @@ case ROSE_CLEAR_REQUEST: rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION); rose_disconnect(sk, ECONNREFUSED, skb->data[3], skb->data[4]); - sk->protinfo.rose->neighbour->use--; + rose->neighbour->use--; break; default: @@ -88,17 +90,19 @@ */ static int rose_state2_machine(struct sock *sk, struct sk_buff *skb, int frametype) { + rose_cb *rose = ROSE_SK(sk); + switch (frametype) { case ROSE_CLEAR_REQUEST: rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION); rose_disconnect(sk, 0, skb->data[3], skb->data[4]); - sk->protinfo.rose->neighbour->use--; + rose->neighbour->use--; break; case ROSE_CLEAR_CONFIRMATION: rose_disconnect(sk, 0, -1, -1); - sk->protinfo.rose->neighbour->use--; + rose->neighbour->use--; break; default: @@ -115,6 +119,7 @@ */ static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype, int ns, int nr, int q, int d, int m) { + rose_cb *rose = ROSE_SK(sk); int queued = 0; switch (frametype) { @@ -123,88 +128,88 @@ rose_stop_timer(sk); rose_start_idletimer(sk); rose_write_internal(sk, ROSE_RESET_CONFIRMATION); - sk->protinfo.rose->condition = 0x00; - sk->protinfo.rose->vs = 0; - sk->protinfo.rose->vr = 0; - sk->protinfo.rose->va = 0; - sk->protinfo.rose->vl = 0; + rose->condition = 0x00; + rose->vs = 0; + rose->vr = 0; + rose->va = 0; + rose->vl = 0; rose_requeue_frames(sk); break; case ROSE_CLEAR_REQUEST: rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION); rose_disconnect(sk, 0, skb->data[3], skb->data[4]); - sk->protinfo.rose->neighbour->use--; + rose->neighbour->use--; break; case ROSE_RR: case ROSE_RNR: if (!rose_validate_nr(sk, nr)) { rose_write_internal(sk, ROSE_RESET_REQUEST); - sk->protinfo.rose->condition = 0x00; - sk->protinfo.rose->vs = 0; - sk->protinfo.rose->vr = 0; - sk->protinfo.rose->va = 0; - sk->protinfo.rose->vl = 0; - sk->protinfo.rose->state = ROSE_STATE_4; + rose->condition = 0x00; + rose->vs = 0; + rose->vr = 0; + rose->va = 0; + rose->vl = 0; + rose->state = ROSE_STATE_4; rose_start_t2timer(sk); rose_stop_idletimer(sk); } else { rose_frames_acked(sk, nr); if (frametype == ROSE_RNR) { - sk->protinfo.rose->condition |= ROSE_COND_PEER_RX_BUSY; + rose->condition |= ROSE_COND_PEER_RX_BUSY; } else { - sk->protinfo.rose->condition &= ~ROSE_COND_PEER_RX_BUSY; + rose->condition &= ~ROSE_COND_PEER_RX_BUSY; } } break; case ROSE_DATA: /* XXX */ - sk->protinfo.rose->condition &= ~ROSE_COND_PEER_RX_BUSY; + rose->condition &= ~ROSE_COND_PEER_RX_BUSY; if (!rose_validate_nr(sk, nr)) { rose_write_internal(sk, ROSE_RESET_REQUEST); - sk->protinfo.rose->condition = 0x00; - sk->protinfo.rose->vs = 0; - sk->protinfo.rose->vr = 0; - sk->protinfo.rose->va = 0; - sk->protinfo.rose->vl = 0; - sk->protinfo.rose->state = ROSE_STATE_4; + rose->condition = 0x00; + rose->vs = 0; + rose->vr = 0; + rose->va = 0; + rose->vl = 0; + rose->state = ROSE_STATE_4; rose_start_t2timer(sk); rose_stop_idletimer(sk); break; } rose_frames_acked(sk, nr); - if (ns == sk->protinfo.rose->vr) { + if (ns == rose->vr) { rose_start_idletimer(sk); if (sock_queue_rcv_skb(sk, skb) == 0) { - sk->protinfo.rose->vr = (sk->protinfo.rose->vr + 1) % ROSE_MODULUS; + rose->vr = (rose->vr + 1) % ROSE_MODULUS; queued = 1; } else { /* Should never happen ! */ rose_write_internal(sk, ROSE_RESET_REQUEST); - sk->protinfo.rose->condition = 0x00; - sk->protinfo.rose->vs = 0; - sk->protinfo.rose->vr = 0; - sk->protinfo.rose->va = 0; - sk->protinfo.rose->vl = 0; - sk->protinfo.rose->state = ROSE_STATE_4; + rose->condition = 0x00; + rose->vs = 0; + rose->vr = 0; + rose->va = 0; + rose->vl = 0; + rose->state = ROSE_STATE_4; rose_start_t2timer(sk); rose_stop_idletimer(sk); break; } if (atomic_read(&sk->rmem_alloc) > (sk->rcvbuf / 2)) - sk->protinfo.rose->condition |= ROSE_COND_OWN_RX_BUSY; + rose->condition |= ROSE_COND_OWN_RX_BUSY; } /* * If the window is full, ack the frame, else start the * acknowledge hold back timer. */ - if (((sk->protinfo.rose->vl + sysctl_rose_window_size) % ROSE_MODULUS) == sk->protinfo.rose->vr) { - sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING; + if (((rose->vl + sysctl_rose_window_size) % ROSE_MODULUS) == rose->vr) { + rose->condition &= ~ROSE_COND_ACK_PENDING; rose_stop_timer(sk); rose_enquiry_response(sk); } else { - sk->protinfo.rose->condition |= ROSE_COND_ACK_PENDING; + rose->condition |= ROSE_COND_ACK_PENDING; rose_start_hbtimer(sk); } break; @@ -224,6 +229,8 @@ */ static int rose_state4_machine(struct sock *sk, struct sk_buff *skb, int frametype) { + rose_cb *rose = ROSE_SK(sk); + switch (frametype) { case ROSE_RESET_REQUEST: @@ -231,19 +238,19 @@ case ROSE_RESET_CONFIRMATION: rose_stop_timer(sk); rose_start_idletimer(sk); - sk->protinfo.rose->condition = 0x00; - sk->protinfo.rose->va = 0; - sk->protinfo.rose->vr = 0; - sk->protinfo.rose->vs = 0; - sk->protinfo.rose->vl = 0; - sk->protinfo.rose->state = ROSE_STATE_3; + rose->condition = 0x00; + rose->va = 0; + rose->vr = 0; + rose->vs = 0; + rose->vl = 0; + rose->state = ROSE_STATE_3; rose_requeue_frames(sk); break; case ROSE_CLEAR_REQUEST: rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION); rose_disconnect(sk, 0, skb->data[3], skb->data[4]); - sk->protinfo.rose->neighbour->use--; + rose->neighbour->use--; break; default: @@ -263,7 +270,7 @@ if (frametype == ROSE_CLEAR_REQUEST) { rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION); rose_disconnect(sk, 0, skb->data[3], skb->data[4]); - sk->protinfo.rose->neighbour->use--; + ROSE_SK(sk)->neighbour->use--; } return 0; @@ -274,12 +281,12 @@ { int queued = 0, frametype, ns, nr, q, d, m; - if (sk->protinfo.rose->state == ROSE_STATE_0) + if (ROSE_SK(sk)->state == ROSE_STATE_0) return 0; frametype = rose_decode(skb, &ns, &nr, &q, &d, &m); - switch (sk->protinfo.rose->state) { + switch (ROSE_SK(sk)->state) { case ROSE_STATE_1: queued = rose_state1_machine(sk, skb, frametype); break; diff -uNr linux-2.5.1/net/rose/rose_out.c linux-2.5.1.acme/net/rose/rose_out.c --- linux-2.5.1/net/rose/rose_out.c Fri Dec 29 20:44:46 2000 +++ linux-2.5.1.acme/net/rose/rose_out.c Wed Dec 19 23:44:48 2001 @@ -43,38 +43,41 @@ */ static void rose_send_iframe(struct sock *sk, struct sk_buff *skb) { + rose_cb *rose = ROSE_SK(sk); + if (skb == NULL) return; - skb->data[2] |= (sk->protinfo.rose->vr << 5) & 0xE0; - skb->data[2] |= (sk->protinfo.rose->vs << 1) & 0x0E; + skb->data[2] |= (rose->vr << 5) & 0xE0; + skb->data[2] |= (rose->vs << 1) & 0x0E; rose_start_idletimer(sk); - rose_transmit_link(skb, sk->protinfo.rose->neighbour); + rose_transmit_link(skb, rose->neighbour); } void rose_kick(struct sock *sk) { + rose_cb *rose = ROSE_SK(sk); struct sk_buff *skb, *skbn; unsigned short start, end; - if (sk->protinfo.rose->state != ROSE_STATE_3) + if (rose->state != ROSE_STATE_3) return; - if (sk->protinfo.rose->condition & ROSE_COND_PEER_RX_BUSY) + if (rose->condition & ROSE_COND_PEER_RX_BUSY) return; if (skb_peek(&sk->write_queue) == NULL) return; - start = (skb_peek(&sk->protinfo.rose->ack_queue) == NULL) ? sk->protinfo.rose->va : sk->protinfo.rose->vs; - end = (sk->protinfo.rose->va + sysctl_rose_window_size) % ROSE_MODULUS; + start = (skb_peek(&rose->ack_queue) == NULL) ? rose->va : rose->vs; + end = (rose->va + sysctl_rose_window_size) % ROSE_MODULUS; if (start == end) return; - sk->protinfo.rose->vs = start; + rose->vs = start; /* * Transmit data until either we're out of data to send or @@ -96,17 +99,17 @@ */ rose_send_iframe(sk, skbn); - sk->protinfo.rose->vs = (sk->protinfo.rose->vs + 1) % ROSE_MODULUS; + rose->vs = (rose->vs + 1) % ROSE_MODULUS; /* * Requeue the original data frame. */ - skb_queue_tail(&sk->protinfo.rose->ack_queue, skb); + skb_queue_tail(&rose->ack_queue, skb); - } while (sk->protinfo.rose->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL); + } while (rose->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL); - sk->protinfo.rose->vl = sk->protinfo.rose->vr; - sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING; + rose->vl = rose->vr; + rose->condition &= ~ROSE_COND_ACK_PENDING; rose_stop_timer(sk); } @@ -118,13 +121,15 @@ void rose_enquiry_response(struct sock *sk) { - if (sk->protinfo.rose->condition & ROSE_COND_OWN_RX_BUSY) + rose_cb *rose = ROSE_SK(sk); + + if (rose->condition & ROSE_COND_OWN_RX_BUSY) rose_write_internal(sk, ROSE_RNR); else rose_write_internal(sk, ROSE_RR); - sk->protinfo.rose->vl = sk->protinfo.rose->vr; - sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING; + rose->vl = rose->vr; + rose->condition &= ~ROSE_COND_ACK_PENDING; rose_stop_timer(sk); } diff -uNr linux-2.5.1/net/rose/rose_route.c linux-2.5.1.acme/net/rose/rose_route.c --- linux-2.5.1/net/rose/rose_route.c Fri Jun 29 23:38:26 2001 +++ linux-2.5.1.acme/net/rose/rose_route.c Wed Dec 19 23:44:48 2001 @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -810,14 +811,15 @@ */ if ((sk = rose_find_socket(lci, rose_neigh)) != NULL) { if (frametype == ROSE_CALL_REQUEST) { + rose_cb *rose = ROSE_SK(sk); /* Remove an existing unused socket */ rose_clear_queues(sk); - sk->protinfo.rose->cause = ROSE_NETWORK_CONGESTION; - sk->protinfo.rose->diagnostic = 0; - sk->protinfo.rose->neighbour->use--; - sk->protinfo.rose->neighbour = NULL; - sk->protinfo.rose->lci = 0; - sk->protinfo.rose->state = ROSE_STATE_0; + rose->cause = ROSE_NETWORK_CONGESTION; + rose->diagnostic = 0; + rose->neighbour->use--; + rose->neighbour = NULL; + rose->lci = 0; + rose->state = ROSE_STATE_0; sk->state = TCP_CLOSE; sk->err = 0; sk->shutdown |= SEND_SHUTDOWN; diff -uNr linux-2.5.1/net/rose/rose_subr.c linux-2.5.1.acme/net/rose/rose_subr.c --- linux-2.5.1/net/rose/rose_subr.c Fri Jun 29 23:38:26 2001 +++ linux-2.5.1.acme/net/rose/rose_subr.c Wed Dec 19 23:44:48 2001 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,7 @@ void rose_clear_queues(struct sock *sk) { skb_queue_purge(&sk->write_queue); - skb_queue_purge(&sk->protinfo.rose->ack_queue); + skb_queue_purge(&ROSE_SK(sk)->ack_queue); } /* @@ -54,15 +55,16 @@ void rose_frames_acked(struct sock *sk, unsigned short nr) { struct sk_buff *skb; + rose_cb *rose = ROSE_SK(sk); /* * Remove all the ack-ed frames from the ack queue. */ - if (sk->protinfo.rose->va != nr) { - while (skb_peek(&sk->protinfo.rose->ack_queue) != NULL && sk->protinfo.rose->va != nr) { - skb = skb_dequeue(&sk->protinfo.rose->ack_queue); + if (rose->va != nr) { + while (skb_peek(&rose->ack_queue) != NULL && rose->va != nr) { + skb = skb_dequeue(&rose->ack_queue); kfree_skb(skb); - sk->protinfo.rose->va = (sk->protinfo.rose->va + 1) % ROSE_MODULUS; + rose->va = (rose->va + 1) % ROSE_MODULUS; } } } @@ -76,7 +78,7 @@ * up by rose_kick. This arrangement handles the possibility of an * empty output queue. */ - while ((skb = skb_dequeue(&sk->protinfo.rose->ack_queue)) != NULL) { + while ((skb = skb_dequeue(&ROSE_SK(sk)->ack_queue)) != NULL) { if (skb_prev == NULL) skb_queue_head(&sk->write_queue, skb); else @@ -91,16 +93,15 @@ */ int rose_validate_nr(struct sock *sk, unsigned short nr) { - unsigned short vc = sk->protinfo.rose->va; + rose_cb *rose = ROSE_SK(sk); + unsigned short vc = rose->va; - while (vc != sk->protinfo.rose->vs) { + while (vc != rose->vs) { if (nr == vc) return 1; vc = (vc + 1) % ROSE_MODULUS; } - if (nr == sk->protinfo.rose->vs) return 1; - - return 0; + return nr == rose->vs; } /* @@ -109,6 +110,7 @@ */ void rose_write_internal(struct sock *sk, int frametype) { + rose_cb *rose = ROSE_SK(sk); struct sk_buff *skb; unsigned char *dptr; unsigned char lci1, lci2; @@ -120,7 +122,7 @@ switch (frametype) { case ROSE_CALL_REQUEST: len += 1 + ROSE_ADDR_LEN + ROSE_ADDR_LEN; - faclen = rose_create_facilities(buffer, sk->protinfo.rose); + faclen = rose_create_facilities(buffer, rose); len += faclen; break; case ROSE_CALL_ACCEPTED: @@ -140,8 +142,8 @@ dptr = skb_put(skb, skb_tailroom(skb)); - lci1 = (sk->protinfo.rose->lci >> 8) & 0x0F; - lci2 = (sk->protinfo.rose->lci >> 0) & 0xFF; + lci1 = (rose->lci >> 8) & 0x0F; + lci2 = (rose->lci >> 0) & 0xFF; switch (frametype) { @@ -150,9 +152,9 @@ *dptr++ = lci2; *dptr++ = frametype; *dptr++ = 0xAA; - memcpy(dptr, &sk->protinfo.rose->dest_addr, ROSE_ADDR_LEN); + memcpy(dptr, &rose->dest_addr, ROSE_ADDR_LEN); dptr += ROSE_ADDR_LEN; - memcpy(dptr, &sk->protinfo.rose->source_addr, ROSE_ADDR_LEN); + memcpy(dptr, &rose->source_addr, ROSE_ADDR_LEN); dptr += ROSE_ADDR_LEN; memcpy(dptr, buffer, faclen); dptr += faclen; @@ -170,8 +172,8 @@ *dptr++ = ROSE_GFI | lci1; *dptr++ = lci2; *dptr++ = frametype; - *dptr++ = sk->protinfo.rose->cause; - *dptr++ = sk->protinfo.rose->diagnostic; + *dptr++ = rose->cause; + *dptr++ = rose->diagnostic; break; case ROSE_RESET_REQUEST: @@ -187,7 +189,7 @@ *dptr++ = ROSE_GFI | lci1; *dptr++ = lci2; *dptr = frametype; - *dptr++ |= (sk->protinfo.rose->vr << 5) & 0xE0; + *dptr++ |= (rose->vr << 5) & 0xE0; break; case ROSE_CLEAR_CONFIRMATION: @@ -203,7 +205,7 @@ return; } - rose_transmit_link(skb, sk->protinfo.rose->neighbour); + rose_transmit_link(skb, rose->neighbour); } int rose_decode(struct sk_buff *skb, int *ns, int *nr, int *q, int *d, int *m) @@ -498,19 +500,21 @@ void rose_disconnect(struct sock *sk, int reason, int cause, int diagnostic) { + rose_cb *rose = ROSE_SK(sk); + rose_stop_timer(sk); rose_stop_idletimer(sk); rose_clear_queues(sk); - sk->protinfo.rose->lci = 0; - sk->protinfo.rose->state = ROSE_STATE_0; + rose->lci = 0; + rose->state = ROSE_STATE_0; if (cause != -1) - sk->protinfo.rose->cause = cause; + rose->cause = cause; if (diagnostic != -1) - sk->protinfo.rose->diagnostic = diagnostic; + rose->diagnostic = diagnostic; sk->state = TCP_CLOSE; sk->err = reason; diff -uNr linux-2.5.1/net/rose/rose_timer.c linux-2.5.1.acme/net/rose/rose_timer.c --- linux-2.5.1/net/rose/rose_timer.c Fri Dec 29 20:44:46 2000 +++ linux-2.5.1.acme/net/rose/rose_timer.c Wed Dec 19 23:44:48 2001 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -54,58 +55,68 @@ void rose_start_t1timer(struct sock *sk) { - del_timer(&sk->protinfo.rose->timer); + rose_cb *rose = ROSE_SK(sk); - sk->protinfo.rose->timer.data = (unsigned long)sk; - sk->protinfo.rose->timer.function = &rose_timer_expiry; - sk->protinfo.rose->timer.expires = jiffies + sk->protinfo.rose->t1; + del_timer(&rose->timer); - add_timer(&sk->protinfo.rose->timer); + rose->timer.data = (unsigned long)sk; + rose->timer.function = &rose_timer_expiry; + rose->timer.expires = jiffies + rose->t1; + + add_timer(&rose->timer); } void rose_start_t2timer(struct sock *sk) { - del_timer(&sk->protinfo.rose->timer); + rose_cb *rose = ROSE_SK(sk); + + del_timer(&rose->timer); - sk->protinfo.rose->timer.data = (unsigned long)sk; - sk->protinfo.rose->timer.function = &rose_timer_expiry; - sk->protinfo.rose->timer.expires = jiffies + sk->protinfo.rose->t2; + rose->timer.data = (unsigned long)sk; + rose->timer.function = &rose_timer_expiry; + rose->timer.expires = jiffies + rose->t2; - add_timer(&sk->protinfo.rose->timer); + add_timer(&rose->timer); } void rose_start_t3timer(struct sock *sk) { - del_timer(&sk->protinfo.rose->timer); + rose_cb *rose = ROSE_SK(sk); + + del_timer(&rose->timer); - sk->protinfo.rose->timer.data = (unsigned long)sk; - sk->protinfo.rose->timer.function = &rose_timer_expiry; - sk->protinfo.rose->timer.expires = jiffies + sk->protinfo.rose->t3; + rose->timer.data = (unsigned long)sk; + rose->timer.function = &rose_timer_expiry; + rose->timer.expires = jiffies + rose->t3; - add_timer(&sk->protinfo.rose->timer); + add_timer(&rose->timer); } void rose_start_hbtimer(struct sock *sk) { - del_timer(&sk->protinfo.rose->timer); + rose_cb *rose = ROSE_SK(sk); - sk->protinfo.rose->timer.data = (unsigned long)sk; - sk->protinfo.rose->timer.function = &rose_timer_expiry; - sk->protinfo.rose->timer.expires = jiffies + sk->protinfo.rose->hb; + del_timer(&rose->timer); - add_timer(&sk->protinfo.rose->timer); + rose->timer.data = (unsigned long)sk; + rose->timer.function = &rose_timer_expiry; + rose->timer.expires = jiffies + rose->hb; + + add_timer(&rose->timer); } void rose_start_idletimer(struct sock *sk) { - del_timer(&sk->protinfo.rose->idletimer); + rose_cb *rose = ROSE_SK(sk); + + del_timer(&rose->idletimer); - if (sk->protinfo.rose->idle > 0) { - sk->protinfo.rose->idletimer.data = (unsigned long)sk; - sk->protinfo.rose->idletimer.function = &rose_idletimer_expiry; - sk->protinfo.rose->idletimer.expires = jiffies + sk->protinfo.rose->idle; + if (rose->idle > 0) { + rose->idletimer.data = (unsigned long)sk; + rose->idletimer.function = &rose_idletimer_expiry; + rose->idletimer.expires = jiffies + rose->idle; - add_timer(&sk->protinfo.rose->idletimer); + add_timer(&rose->idletimer); } } @@ -116,19 +127,20 @@ void rose_stop_timer(struct sock *sk) { - del_timer(&sk->protinfo.rose->timer); + del_timer(&ROSE_SK(sk)->timer); } void rose_stop_idletimer(struct sock *sk) { - del_timer(&sk->protinfo.rose->idletimer); + del_timer(&ROSE_SK(sk)->idletimer); } static void rose_heartbeat_expiry(unsigned long param) { struct sock *sk = (struct sock *)param; + rose_cb *rose = ROSE_SK(sk); - switch (sk->protinfo.rose->state) { + switch (rose->state) { case ROSE_STATE_0: /* Magic here: If we listen() and a new link dies before it @@ -144,10 +156,10 @@ * Check for the state of the receive buffer. */ if (atomic_read(&sk->rmem_alloc) < (sk->rcvbuf / 2) && - (sk->protinfo.rose->condition & ROSE_COND_OWN_RX_BUSY)) { - sk->protinfo.rose->condition &= ~ROSE_COND_OWN_RX_BUSY; - sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING; - sk->protinfo.rose->vl = sk->protinfo.rose->vr; + (rose->condition & ROSE_COND_OWN_RX_BUSY)) { + rose->condition &= ~ROSE_COND_OWN_RX_BUSY; + rose->condition &= ~ROSE_COND_ACK_PENDING; + rose->vl = rose->vr; rose_write_internal(sk, ROSE_RR); rose_stop_timer(sk); /* HB */ break; @@ -161,24 +173,25 @@ static void rose_timer_expiry(unsigned long param) { struct sock *sk = (struct sock *)param; + rose_cb *rose = ROSE_SK(sk); - switch (sk->protinfo.rose->state) { + switch (rose->state) { case ROSE_STATE_1: /* T1 */ case ROSE_STATE_4: /* T2 */ rose_write_internal(sk, ROSE_CLEAR_REQUEST); - sk->protinfo.rose->state = ROSE_STATE_2; + rose->state = ROSE_STATE_2; rose_start_t3timer(sk); break; case ROSE_STATE_2: /* T3 */ - sk->protinfo.rose->neighbour->use--; + rose->neighbour->use--; rose_disconnect(sk, ETIMEDOUT, -1, -1); break; case ROSE_STATE_3: /* HB */ - if (sk->protinfo.rose->condition & ROSE_COND_ACK_PENDING) { - sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING; + if (rose->condition & ROSE_COND_ACK_PENDING) { + rose->condition &= ~ROSE_COND_ACK_PENDING; rose_enquiry_response(sk); } break; @@ -192,7 +205,7 @@ rose_clear_queues(sk); rose_write_internal(sk, ROSE_CLEAR_REQUEST); - sk->protinfo.rose->state = ROSE_STATE_2; + ROSE_SK(sk)->state = ROSE_STATE_2; rose_start_t3timer(sk); diff -uNr linux-2.5.1/net/socket.c linux-2.5.1.acme/net/socket.c --- linux-2.5.1/net/socket.c Wed Oct 17 19:38:28 2001 +++ linux-2.5.1.acme/net/socket.c Wed Dec 19 23:44:47 2001 @@ -133,7 +133,7 @@ * The protocol list. Each protocol is registered in here. */ -static struct net_proto_family *net_families[NPROTO]; +struct net_proto_family *net_families[NPROTO]; #ifdef CONFIG_SMP static atomic_t net_family_lockct = ATOMIC_INIT(0); @@ -1631,6 +1631,7 @@ int sock_register(struct net_proto_family *ops) { int err; + extern kmem_cache_t *sk_cachep; if (ops->family >= NPROTO) { printk(KERN_CRIT "protocol %d >= NPROTO(%d)\n", ops->family, NPROTO); @@ -1639,6 +1640,10 @@ net_family_write_lock(); err = -EEXIST; if (net_families[ops->family] == NULL) { + if (!ops->sk_cachep) { + ops->sk_cachep = sk_cachep; + ops->sk_size = sizeof(struct sock); + } net_families[ops->family]=ops; err = 0; } diff -uNr linux-2.5.1/net/unix/af_unix.c linux-2.5.1.acme/net/unix/af_unix.c --- linux-2.5.1/net/unix/af_unix.c Mon Nov 5 14:32:32 2001 +++ linux-2.5.1.acme/net/unix/af_unix.c Wed Dec 19 23:44:48 2001 @@ -119,7 +119,7 @@ #define unix_sockets_unbound (unix_socket_table[UNIX_HASH_SIZE]) -#define UNIX_ABSTRACT(sk) ((sk)->protinfo.af_unix.addr->hash!=UNIX_HASH_SIZE) +#define UNIX_ABSTRACT(sk) (UNIX_SK(sk)->addr->hash!=UNIX_HASH_SIZE) /* * SMP locking strategy: @@ -200,7 +200,7 @@ static void __unix_remove_socket(unix_socket *sk) { - unix_socket **list = sk->protinfo.af_unix.list; + unix_socket **list = UNIX_SK(sk)->list; if (list) { if (sk->next) sk->next->prev = sk->prev; @@ -208,7 +208,7 @@ sk->prev->next = sk->next; if (*list == sk) *list = sk->next; - sk->protinfo.af_unix.list = NULL; + UNIX_SK(sk)->list = NULL; sk->prev = NULL; sk->next = NULL; __sock_put(sk); @@ -217,9 +217,9 @@ static void __unix_insert_socket(unix_socket **list, unix_socket *sk) { - BUG_TRAP(sk->protinfo.af_unix.list==NULL); + BUG_TRAP(UNIX_SK(sk)->list==NULL); - sk->protinfo.af_unix.list = list; + UNIX_SK(sk)->list = list; sk->prev = NULL; sk->next = *list; if (*list) @@ -248,8 +248,8 @@ unix_socket *s; for (s=unix_socket_table[hash^type]; s; s=s->next) { - if(s->protinfo.af_unix.addr->len==len && - memcmp(s->protinfo.af_unix.addr->name, sunname, len) == 0) + if(UNIX_SK(s)->addr->len==len && + memcmp(UNIX_SK(s)->addr->name, sunname, len) == 0) return s; } return NULL; @@ -276,7 +276,7 @@ read_lock(&unix_table_lock); for (s=unix_socket_table[i->i_ino & (UNIX_HASH_SIZE-1)]; s; s=s->next) { - struct dentry *dentry = s->protinfo.af_unix.dentry; + struct dentry *dentry = UNIX_SK(s)->dentry; if(dentry && dentry->d_inode == i) { @@ -312,7 +312,7 @@ { if (skb_queue_len(&sk->receive_queue)) { skb_queue_purge(&sk->receive_queue); - wake_up_interruptible_all(&sk->protinfo.af_unix.peer_wait); + wake_up_interruptible_all(&UNIX_SK(sk)->peer_wait); /* If one link of bidirectional dgram pipe is disconnected, * we signal error. Messages are lost. Do not make this, @@ -330,15 +330,15 @@ skb_queue_purge(&sk->receive_queue); BUG_TRAP(atomic_read(&sk->wmem_alloc) == 0); - BUG_TRAP(sk->protinfo.af_unix.list==NULL); + BUG_TRAP(UNIX_SK(sk)->list==NULL); BUG_TRAP(sk->socket==NULL); if (sk->dead==0) { printk("Attempt to release alive unix socket: %p\n", sk); return; } - if (sk->protinfo.af_unix.addr) - unix_release_addr(sk->protinfo.af_unix.addr); + if (UNIX_SK(sk)->addr) + unix_release_addr(UNIX_SK(sk)->addr); atomic_dec(&unix_nr_socks); #ifdef UNIX_REFCNT_DEBUG @@ -361,15 +361,15 @@ unix_state_wlock(sk); sock_orphan(sk); sk->shutdown = SHUTDOWN_MASK; - dentry = sk->protinfo.af_unix.dentry; - sk->protinfo.af_unix.dentry=NULL; - mnt = sk->protinfo.af_unix.mnt; - sk->protinfo.af_unix.mnt=NULL; + dentry = UNIX_SK(sk)->dentry; + UNIX_SK(sk)->dentry=NULL; + mnt = UNIX_SK(sk)->mnt; + UNIX_SK(sk)->mnt=NULL; state = sk->state; sk->state = TCP_CLOSE; unix_state_wunlock(sk); - wake_up_interruptible_all(&sk->protinfo.af_unix.peer_wait); + wake_up_interruptible_all(&UNIX_SK(sk)->peer_wait); skpair=unix_peer(sk); @@ -434,13 +434,13 @@ if (sock->type!=SOCK_STREAM) goto out; /* Only stream sockets accept */ err = -EINVAL; - if (!sk->protinfo.af_unix.addr) + if (!UNIX_SK(sk)->addr) goto out; /* No listens on an unbound socket */ unix_state_wlock(sk); if (sk->state != TCP_CLOSE && sk->state != TCP_LISTEN) goto out_unlock; if (backlog > sk->max_ack_backlog) - wake_up_interruptible_all(&sk->protinfo.af_unix.peer_wait); + wake_up_interruptible_all(&UNIX_SK(sk)->peer_wait); sk->max_ack_backlog=backlog; sk->state=TCP_LISTEN; /* set credentials so connect can copy them */ @@ -480,13 +480,13 @@ sk->max_ack_backlog = sysctl_unix_max_dgram_qlen; sk->destruct = unix_sock_destructor; - sk->protinfo.af_unix.dentry=NULL; - sk->protinfo.af_unix.mnt=NULL; - sk->protinfo.af_unix.lock = RW_LOCK_UNLOCKED; - atomic_set(&sk->protinfo.af_unix.inflight, 0); - init_MUTEX(&sk->protinfo.af_unix.readsem);/* single task reading lock */ - init_waitqueue_head(&sk->protinfo.af_unix.peer_wait); - sk->protinfo.af_unix.list=NULL; + UNIX_SK(sk)->dentry=NULL; + UNIX_SK(sk)->mnt=NULL; + UNIX_SK(sk)->lock = RW_LOCK_UNLOCKED; + atomic_set(&UNIX_SK(sk)->inflight, 0); + init_MUTEX(&UNIX_SK(sk)->readsem);/* single task reading lock */ + init_waitqueue_head(&UNIX_SK(sk)->peer_wait); + UNIX_SK(sk)->list=NULL; unix_insert_socket(&unix_sockets_unbound, sk); return sk; @@ -538,10 +538,10 @@ struct unix_address * addr; int err; - down(&sk->protinfo.af_unix.readsem); + down(&UNIX_SK(sk)->readsem); err = 0; - if (sk->protinfo.af_unix.addr) + if (UNIX_SK(sk)->addr) goto out; err = -ENOMEM; @@ -573,13 +573,13 @@ addr->hash ^= sk->type; __unix_remove_socket(sk); - sk->protinfo.af_unix.addr = addr; + UNIX_SK(sk)->addr = addr; __unix_insert_socket(&unix_socket_table[addr->hash], sk); write_unlock(&unix_table_lock); err = 0; out: - up(&sk->protinfo.af_unix.readsem); + up(&UNIX_SK(sk)->readsem); return err; } @@ -655,10 +655,10 @@ goto out; addr_len = err; - down(&sk->protinfo.af_unix.readsem); + down(&UNIX_SK(sk)->readsem); err = -EINVAL; - if (sk->protinfo.af_unix.addr) + if (UNIX_SK(sk)->addr) goto out_up; err = -ENOMEM; @@ -736,19 +736,19 @@ list = &unix_socket_table[addr->hash]; } else { list = &unix_socket_table[dentry->d_inode->i_ino & (UNIX_HASH_SIZE-1)]; - sk->protinfo.af_unix.dentry = nd.dentry; - sk->protinfo.af_unix.mnt = nd.mnt; + UNIX_SK(sk)->dentry = nd.dentry; + UNIX_SK(sk)->mnt = nd.mnt; } err = 0; __unix_remove_socket(sk); - sk->protinfo.af_unix.addr = addr; + UNIX_SK(sk)->addr = addr; __unix_insert_socket(list, sk); out_unlock: write_unlock(&unix_table_lock); out_up: - up(&sk->protinfo.af_unix.readsem); + up(&UNIX_SK(sk)->readsem); out: return err; @@ -780,7 +780,7 @@ goto out; alen = err; - if (sock->passcred && !sk->protinfo.af_unix.addr && + if (sock->passcred && !UNIX_SK(sk)->addr && (err = unix_autobind(sock)) != 0) goto out; @@ -831,7 +831,7 @@ DECLARE_WAITQUEUE(wait, current); __set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue_exclusive(&other->protinfo.af_unix.peer_wait, &wait); + add_wait_queue_exclusive(&UNIX_SK(other)->peer_wait, &wait); sched = (!other->dead && !(other->shutdown&RCV_SHUTDOWN) && @@ -843,7 +843,7 @@ timeo = schedule_timeout(timeo); __set_current_state(TASK_RUNNING); - remove_wait_queue(&other->protinfo.af_unix.peer_wait, &wait); + remove_wait_queue(&UNIX_SK(other)->peer_wait, &wait); return timeo; } @@ -865,7 +865,7 @@ goto out; addr_len = err; - if (sock->passcred && !sk->protinfo.af_unix.addr && + if (sock->passcred && !UNIX_SK(sk)->addr && (err = unix_autobind(sock)) != 0) goto out; @@ -966,17 +966,17 @@ newsk->peercred.pid = current->pid; newsk->peercred.uid = current->euid; newsk->peercred.gid = current->egid; - newsk->sleep = &newsk->protinfo.af_unix.peer_wait; + newsk->sleep = &UNIX_SK(newsk)->peer_wait; /* copy address information from listening to new sock*/ - if (other->protinfo.af_unix.addr) + if (UNIX_SK(other)->addr) { - atomic_inc(&other->protinfo.af_unix.addr->refcnt); - newsk->protinfo.af_unix.addr=other->protinfo.af_unix.addr; + atomic_inc(&UNIX_SK(other)->addr->refcnt); + UNIX_SK(newsk)->addr=UNIX_SK(other)->addr; } - if (other->protinfo.af_unix.dentry) { - newsk->protinfo.af_unix.dentry=dget(other->protinfo.af_unix.dentry); - newsk->protinfo.af_unix.mnt=mntget(other->protinfo.af_unix.mnt); + if (UNIX_SK(other)->dentry) { + UNIX_SK(newsk)->dentry=dget(UNIX_SK(other)->dentry); + UNIX_SK(newsk)->mnt=mntget(UNIX_SK(other)->mnt); } /* Set credentials */ @@ -1058,7 +1058,7 @@ tsk = skb->sk; skb_free_datagram(sk, skb); - wake_up_interruptible(&sk->protinfo.af_unix.peer_wait); + wake_up_interruptible(&UNIX_SK(sk)->peer_wait); /* attach accepted sock to socket */ unix_state_wlock(tsk); @@ -1090,12 +1090,12 @@ } unix_state_rlock(sk); - if (!sk->protinfo.af_unix.addr) { + if (!UNIX_SK(sk)->addr) { sunaddr->sun_family = AF_UNIX; sunaddr->sun_path[0] = 0; *uaddr_len = sizeof(short); } else { - struct unix_address *addr = sk->protinfo.af_unix.addr; + struct unix_address *addr = UNIX_SK(sk)->addr; *uaddr_len = addr->len; memcpy(sunaddr, addr->name, *uaddr_len); @@ -1173,7 +1173,7 @@ goto out; } - if (sock->passcred && !sk->protinfo.af_unix.addr && + if (sock->passcred && !UNIX_SK(sk)->addr && (err = unix_autobind(sock)) != 0) goto out; @@ -1376,11 +1376,11 @@ static void unix_copy_addr(struct msghdr *msg, struct sock *sk) { msg->msg_namelen = sizeof(short); - if (sk->protinfo.af_unix.addr) { - msg->msg_namelen=sk->protinfo.af_unix.addr->len; + if (UNIX_SK(sk)->addr) { + msg->msg_namelen=UNIX_SK(sk)->addr->len; memcpy(msg->msg_name, - sk->protinfo.af_unix.addr->name, - sk->protinfo.af_unix.addr->len); + UNIX_SK(sk)->addr->name, + UNIX_SK(sk)->addr->len); } } @@ -1402,7 +1402,7 @@ if (!skb) goto out; - wake_up_interruptible(&sk->protinfo.af_unix.peer_wait); + wake_up_interruptible(&UNIX_SK(sk)->peer_wait); if (msg->msg_name) unix_copy_addr(msg, skb->sk); @@ -1513,7 +1513,7 @@ * while sleeps in memcpy_tomsg */ - down(&sk->protinfo.af_unix.readsem); + down(&UNIX_SK(sk)->readsem); do { @@ -1537,7 +1537,7 @@ err = -EAGAIN; if (!timeo) break; - up(&sk->protinfo.af_unix.readsem); + up(&UNIX_SK(sk)->readsem); timeo = unix_stream_data_wait(sk, timeo); @@ -1545,7 +1545,7 @@ err = sock_intr_errno(timeo); goto out; } - down(&sk->protinfo.af_unix.readsem); + down(&UNIX_SK(sk)->readsem); continue; } @@ -1611,7 +1611,7 @@ } } while (size); - up(&sk->protinfo.af_unix.readsem); + up(&UNIX_SK(sk)->readsem); out: return copied ? : err; } @@ -1753,16 +1753,16 @@ (s->state == TCP_ESTABLISHED ? SS_CONNECTING : SS_DISCONNECTING), sock_i_ino(s)); - if (s->protinfo.af_unix.addr) + if (UNIX_SK(s)->addr) { buffer[len++] = ' '; - memcpy(buffer+len, s->protinfo.af_unix.addr->name->sun_path, - s->protinfo.af_unix.addr->len-sizeof(short)); + memcpy(buffer+len, UNIX_SK(s)->addr->name->sun_path, + UNIX_SK(s)->addr->len-sizeof(short)); if (!UNIX_ABSTRACT(s)) len--; else buffer[len] = '@'; - len += s->protinfo.af_unix.addr->len - sizeof(short); + len += UNIX_SK(s)->addr->len - sizeof(short); } unix_state_runlock(s); @@ -1833,8 +1833,9 @@ }; struct net_proto_family unix_family_ops = { - family: PF_UNIX, - create: unix_create + family: PF_UNIX, + create: unix_create, + sk_size: sizeof(struct sock) + sizeof(struct unix_opt), }; #ifdef CONFIG_SYSCTL @@ -1857,6 +1858,15 @@ printk(KERN_CRIT "unix_proto_init: panic\n"); return -1; } + /* allocate our sock slab cache */ + unix_family_ops.sk_cachep = kmem_cache_create("unix_sock", + unix_family_ops.sk_size, + 0, SLAB_HWCACHE_ALIGN, + 0, 0); + if (!unix_family_ops.sk_cachep) + printk(KERN_CRIT __FUNCTION__ + ": Cannot create unix_sock SLAB cache!\n"); + sock_register(&unix_family_ops); #ifdef CONFIG_PROC_FS create_proc_read_entry("net/unix", 0, 0, unix_read_proc, NULL); diff -uNr linux-2.5.1/net/unix/garbage.c linux-2.5.1.acme/net/unix/garbage.c --- linux-2.5.1/net/unix/garbage.c Fri Jun 29 23:38:26 2001 +++ linux-2.5.1.acme/net/unix/garbage.c Wed Dec 19 23:44:48 2001 @@ -122,7 +122,7 @@ { unix_socket *s=unix_get_socket(fp); if(s) { - atomic_inc(&s->protinfo.af_unix.inflight); + atomic_inc(&UNIX_SK(s)->inflight); atomic_inc(&unix_tot_inflight); } } @@ -131,7 +131,7 @@ { unix_socket *s=unix_get_socket(fp); if(s) { - atomic_dec(&s->protinfo.af_unix.inflight); + atomic_dec(&UNIX_SK(s)->inflight); atomic_dec(&unix_tot_inflight); } } @@ -144,7 +144,7 @@ extern inline unix_socket *pop_stack(void) { unix_socket *p=gc_current; - gc_current = p->protinfo.af_unix.gc_tree; + gc_current = UNIX_SK(p)->gc_tree; return p; } @@ -155,10 +155,10 @@ extern inline void maybe_unmark_and_push(unix_socket *x) { - if (x->protinfo.af_unix.gc_tree != GC_ORPHAN) + if (UNIX_SK(x)->gc_tree != GC_ORPHAN) return; sock_hold(x); - x->protinfo.af_unix.gc_tree = gc_current; + UNIX_SK(x)->gc_tree = gc_current; gc_current = x; } @@ -184,7 +184,7 @@ forall_unix_sockets(i, s) { - s->protinfo.af_unix.gc_tree=GC_ORPHAN; + UNIX_SK(s)->gc_tree=GC_ORPHAN; } /* * Everything is now marked @@ -210,7 +210,7 @@ * in flight we are in use. */ if(s->socket && s->socket->file && - file_count(s->socket->file) > atomic_read(&s->protinfo.af_unix.inflight)) + file_count(s->socket->file) > atomic_read(&UNIX_SK(s)->inflight)) maybe_unmark_and_push(s); } @@ -268,7 +268,7 @@ forall_unix_sockets(i, s) { - if (s->protinfo.af_unix.gc_tree == GC_ORPHAN) + if (UNIX_SK(s)->gc_tree == GC_ORPHAN) { struct sk_buff *nextsk; spin_lock(&s->receive_queue.lock); @@ -288,7 +288,7 @@ } spin_unlock(&s->receive_queue.lock); } - s->protinfo.af_unix.gc_tree = GC_ORPHAN; + UNIX_SK(s)->gc_tree = GC_ORPHAN; } read_unlock(&unix_table_lock); diff -uNr linux-2.5.1/net/wanrouter/af_wanpipe.c linux-2.5.1.acme/net/wanrouter/af_wanpipe.c --- linux-2.5.1/net/wanrouter/af_wanpipe.c Sun Sep 30 16:26:42 2001 +++ linux-2.5.1.acme/net/wanrouter/af_wanpipe.c Wed Dec 19 23:44:48 2001 @@ -326,7 +326,7 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk) { - + wanpipe_opt *wp = WP_SK(sk), *newwp; struct wan_sockaddr_ll *sll = (struct wan_sockaddr_ll*)skb->cb; struct sock *newsk; netdevice_t *dev; @@ -337,7 +337,7 @@ /* Find a free device, if none found, all svc's are busy */ - card = (sdla_t*)sk->protinfo.af_wanpipe->card; + card = (sdla_t*)wp->card; if (!card){ printk(KERN_INFO "wansock: LISTEN ERROR, No Card\n"); return -ENODEV; @@ -364,7 +364,8 @@ /* Initialize the new sock structure */ newsk->bound_dev_if = dev->ifindex; - newsk->protinfo.af_wanpipe->card = sk->protinfo.af_wanpipe->card; + newwp = WP_SK(newsk); + newwp->card = wp->card; /* Insert the sock into the main wanpipe * sock list. @@ -389,8 +390,8 @@ * whic lcn to clear */ - newsk->protinfo.af_wanpipe->lcn = mbox_ptr->cmd.lcn; - newsk->protinfo.af_wanpipe->mbox = (void *)mbox_ptr; + newwp->lcn = mbox_ptr->cmd.lcn; + newwp->mbox = (void *)mbox_ptr; DBG_PRINTK(KERN_INFO "NEWSOCK : Device %s, bind to lcn %i\n", dev->name,mbox_ptr->cmd.lcn); @@ -506,13 +507,12 @@ } memset(wan_opt, 0x00, sizeof(struct wanpipe_opt)); - sk->protinfo.af_wanpipe = wan_opt; - sk->protinfo.destruct_hook = wan_opt; + WP_SK(sk) = wan_opt; /* Use timer to send data to the driver. This will act * as a BH handler for sendmsg functions */ - sk->protinfo.af_wanpipe->tx_timer.data=(unsigned long)sk; - sk->protinfo.af_wanpipe->tx_timer.function=wanpipe_delayed_transmit; + wan_opt->tx_timer.data = (unsigned long)sk; + wan_opt->tx_timer.function = wanpipe_delayed_transmit; MOD_INC_USE_COUNT; @@ -542,6 +542,7 @@ static int wanpipe_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct scm_cookie *scm) { + wanpipe_opt *wp; struct sock *sk = sock->sk; struct wan_sockaddr_ll *saddr=(struct wan_sockaddr_ll *)msg->msg_name; struct sk_buff *skb; @@ -647,12 +648,13 @@ } skb_queue_tail(&sk->write_queue,skb); - atomic_inc(&sk->protinfo.af_wanpipe->packet_sent); + wp = WP_SK(sk); + atomic_inc(&wp->packet_sent); - if (!(test_and_set_bit(0,&sk->protinfo.af_wanpipe->timer))){ - del_timer(&sk->protinfo.af_wanpipe->tx_timer); - sk->protinfo.af_wanpipe->tx_timer.expires=jiffies+1; - add_timer(&sk->protinfo.af_wanpipe->tx_timer); + if (!(test_and_set_bit(0, &wp->timer))){ + del_timer(&wp->tx_timer); + wp->tx_timer.expires = jiffies + 1; + add_timer(&wp->tx_timer); } return(len); @@ -683,17 +685,18 @@ { struct sock *sk=(struct sock *)data; struct sk_buff *skb; - netdevice_t *dev = sk->protinfo.af_wanpipe->dev; - sdla_t *card = (sdla_t*)sk->protinfo.af_wanpipe->card; + wanpipe_opt *wp = WP_SK(sk); + netdevice_t *dev = wp->dev; + sdla_t *card = (sdla_t*)wp->card; if (!card || !dev){ - clear_bit (0,&sk->protinfo.af_wanpipe->timer); + clear_bit(0, &wp->timer); DBG_PRINTK(KERN_INFO "wansock: Transmit delay, no dev or card\n"); return; } if (sk->state != WANSOCK_CONNECTED || !sk->zapped){ - clear_bit (0,&sk->protinfo.af_wanpipe->timer); + clear_bit(0, &wp->timer); DBG_PRINTK(KERN_INFO "wansock: Tx Timer, State not CONNECTED\n"); return; } @@ -703,8 +706,8 @@ * pending command will never get a free buffer * to execute */ if (atomic_read(&card->u.x.command_busy)){ - sk->protinfo.af_wanpipe->tx_timer.expires=jiffies+SLOW_BACKOFF; - add_timer(&sk->protinfo.af_wanpipe->tx_timer); + wp->tx_timer.expires = jiffies + SLOW_BACKOFF; + add_timer(&wp->tx_timer); DBG_PRINTK(KERN_INFO "wansock: Tx Timer, command bys BACKOFF\n"); return; } @@ -712,8 +715,8 @@ if (test_and_set_bit(0,&wanpipe_tx_critical)){ printk(KERN_INFO "WanSock: Tx timer critical %s\n",dev->name); - sk->protinfo.af_wanpipe->tx_timer.expires=jiffies+SLOW_BACKOFF; - add_timer(&sk->protinfo.af_wanpipe->tx_timer); + wp->tx_timer.expires = jiffies + SLOW_BACKOFF; + add_timer(&wp->tx_timer); return; } @@ -733,18 +736,18 @@ * if more packets, re-trigger the transmit routine * other wise exit */ - atomic_dec(&sk->protinfo.af_wanpipe->packet_sent); + atomic_dec(&wp->packet_sent); if (skb_peek(&sk->write_queue) == NULL){ /* If there is nothing to send, kick * the poll routine, which will trigger * the application to send more data */ sk->data_ready(sk,0); - clear_bit (0,&sk->protinfo.af_wanpipe->timer); + clear_bit(0, &wp->timer); }else{ /* Reschedule as fast as possible */ - sk->protinfo.af_wanpipe->tx_timer.expires=jiffies+1; - add_timer(&sk->protinfo.af_wanpipe->tx_timer); + wp->tx_timer.expires = jiffies + 1; + add_timer(&wp->tx_timer); } } } @@ -758,7 +761,7 @@ * chan->command is used to indicate to the driver that * command is pending for exection. The acutal command * structure is placed into a sock mbox structure - * (sk->protinfo.af_wanpipe->mbox). + * (WP_SK(sk)->mbox). * * The sock private structure, mbox is * used as shared memory between sock and the driver. @@ -774,6 +777,7 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int flags) { + wanpipe_opt *wp = WP_SK(sk); netdevice_t *dev; wanpipe_common_t *chan=NULL; int err=0; @@ -798,15 +802,14 @@ return -EINVAL; } - if (!sk->protinfo.af_wanpipe->mbox){ + if (!wp->mbox) { printk(KERN_INFO "wansock: In execute without MBOX\n"); return -EINVAL; } - ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.command=cmd; - ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.lcn = - sk->protinfo.af_wanpipe->lcn; - ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.result=0x7F; + ((mbox_cmd_t*)wp->mbox)->cmd.command = cmd; + ((mbox_cmd_t*)wp->mbox)->cmd.lcn = wp->lcn; + ((mbox_cmd_t*)wp->mbox)->cmd.result = 0x7F; if (flags & O_NONBLOCK){ @@ -819,7 +822,7 @@ add_wait_queue(sk->sleep,&wait); current->state = TASK_INTERRUPTIBLE; for (;;){ - if (((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.result != 0x7F) { + if (((mbox_cmd_t*)wp->mbox)->cmd.result != 0x7F) { err = 0; break; } @@ -845,17 +848,16 @@ static void wanpipe_destroy_timer(unsigned long data) { struct sock *sk=(struct sock *)data; + wanpipe_opt *wp = WP_SK(sk); if ((!atomic_read(&sk->wmem_alloc) && !atomic_read(&sk->rmem_alloc)) || - (++sk->protinfo.af_wanpipe->force == 5)) { + (++wp->force == 5)) { if (atomic_read(&sk->wmem_alloc) || atomic_read(&sk->rmem_alloc)) printk(KERN_INFO "wansock: Warning, Packet Discarded due to sock shutdown!\n"); - if (sk->protinfo.af_wanpipe){ - kfree(sk->protinfo.af_wanpipe); - sk->protinfo.af_wanpipe=NULL; - } + kfree(wp); + WP_SK(sk) = NULL; #ifdef LINUX_2_4 if (atomic_read(&sk->refcnt) != 1){ @@ -891,7 +893,7 @@ sk->zapped=0; sk->state = WANSOCK_DISCONNECTED; - sk->protinfo.af_wanpipe->dev = NULL; + WP_SK(sk)->dev = NULL; dev = dev_get_by_index(sk->bound_dev_if); if (!dev){ @@ -928,15 +930,16 @@ static void wanpipe_link_driver (netdevice_t *dev, struct sock *sk) { + wanpipe_opt *wp = WP_SK(sk); wanpipe_common_t *chan = dev->priv; if (!chan) return; set_bit(0,&chan->common_critical); chan->sk=sk; chan->func=wanpipe_rcv; - chan->mbox=sk->protinfo.af_wanpipe->mbox; - chan->tx_timer = &sk->protinfo.af_wanpipe->tx_timer; - sk->protinfo.af_wanpipe->dev=dev; + chan->mbox = wp->mbox; + chan->tx_timer = &wp->tx_timer; + wp->dev = dev; sk->zapped = 1; clear_bit(0,&chan->common_critical); } @@ -974,12 +977,14 @@ #ifndef LINUX_2_4 struct sk_buff *skb; #endif + wanpipe_opt *wp; struct sock *sk = sock->sk; struct sock **skp; if (!sk) return 0; + wp = WP_SK(sk); check_write_queue(sk); /* Kill the tx timer, if we don't kill it now, the timer @@ -987,7 +992,7 @@ * try to access the sock which has been killed and cause * kernel panic */ - del_timer(&sk->protinfo.af_wanpipe->tx_timer); + del_timer(&wp->tx_timer); /* * Unhook packet receive handler. @@ -1060,10 +1065,8 @@ return 0; } - if (sk->protinfo.af_wanpipe){ - kfree(sk->protinfo.af_wanpipe); - sk->protinfo.af_wanpipe=NULL; - } + kfree(wp); + WP_SK(sk) = NULL; #ifdef LINUX_2_4 if (atomic_read(&sk->refcnt) != 1){ @@ -1113,6 +1116,7 @@ static void release_driver(struct sock *sk) { + wanpipe_opt *wp; struct sk_buff *skb=NULL; struct sock *deadsk=NULL; @@ -1134,12 +1138,11 @@ sk->state = WANSOCK_DISCONNECTED; sk->bound_dev_if = 0; sk->zapped=0; + wp = WP_SK(sk); - if (sk->protinfo.af_wanpipe){ - if (sk->protinfo.af_wanpipe->mbox){ - kfree(sk->protinfo.af_wanpipe->mbox); - sk->protinfo.af_wanpipe->mbox=NULL; - } + if (wp && wp->mbox) { + kfree(wp->mbox); + wp->mbox = NULL; } } @@ -1244,9 +1247,9 @@ return; } - if (sk->protinfo.af_wanpipe){ - kfree(sk->protinfo.af_wanpipe); - sk->protinfo.af_wanpipe=NULL; + if (WP_SK(sk)){ + kfree(WP_SK(sk)); + WP_SK(sk)=NULL; } #ifdef LINUX_2_4 @@ -1288,9 +1291,9 @@ sk->socket = NULL; - if (sk->protinfo.af_wanpipe){ - kfree(sk->protinfo.af_wanpipe); - sk->protinfo.af_wanpipe=NULL; + if (WP_SK(sk)){ + kfree(WP_SK(sk)); + WP_SK(sk)=NULL; } #ifdef LINUX_2_4 @@ -1317,9 +1320,9 @@ sk->socket = NULL; - if (sk->protinfo.af_wanpipe){ - kfree(sk->protinfo.af_wanpipe); - sk->protinfo.af_wanpipe=NULL; + if (WP_SK(sk)){ + kfree(WP_SK(sk)); + WP_SK(sk)=NULL; } #ifdef LINUX_2_4 @@ -1386,7 +1389,7 @@ /* X25 Specific option */ if (sk->num == htons(X25_PROT)) - sk->protinfo.af_wanpipe->svc = chan->svc; + WP_SK(sk)->svc = chan->svc; } else { sk->err = ENETDOWN; @@ -1440,7 +1443,7 @@ printk(KERN_INFO "wansock: Wanpipe card not found: %s\n",sll->sll_card); return -ENODEV; }else{ - sk->protinfo.af_wanpipe->card = (void *)card; + WP_SK(sk)->card = (void *)card; } if (!strcmp(sll->sll_device,"svc_listen")){ @@ -1808,7 +1811,7 @@ for (sk = wanpipe_sklist; sk; sk = sk->next) { - if ((po = sk->protinfo.af_wanpipe)==NULL) + if ((po = WP_SK(sk))==NULL) continue; if (dev == NULL) continue; @@ -2005,6 +2008,7 @@ wan_debug_t *dbg_data = (wan_debug_t *)arg; for (sk = wanpipe_sklist; sk; sk = sk->next){ + wanpipe_opt *wp = WP_SK(sk); if (sk == origsk){ continue; @@ -2024,8 +2028,7 @@ return err; if ((err=put_user(sk_count, &dbg_data->debug[cnt].sk_count))) return err; - if ((err=put_user(sk->protinfo.af_wanpipe->poll_cnt, - &dbg_data->debug[cnt].poll_cnt))) + if ((err=put_user(wp->poll_cnt, &dbg_data->debug[cnt].poll_cnt))) return err; if ((err=put_user(sk->bound_dev_if, &dbg_data->debug[cnt].bound))) return err; @@ -2048,8 +2051,8 @@ return err; - if (sk->protinfo.af_wanpipe){ - sdla_t *card = (sdla_t*)sk->protinfo.af_wanpipe->card; + if (wp){ + sdla_t *card = (sdla_t*)wp->card; if (card){ if ((err=put_user(atomic_read(&card->u.x.command_busy), @@ -2057,11 +2060,11 @@ return err; } - if ((err=put_user(sk->protinfo.af_wanpipe->lcn, - &dbg_data->debug[cnt].lcn))) + if ((err=put_user(wp->lcn, + &dbg_data->debug[cnt].lcn))) return err; - if (sk->protinfo.af_wanpipe->mbox){ + if (wp->mbox) { if ((err=put_user(1, &dbg_data->debug[cnt].mbox))) return err; } @@ -2096,11 +2099,11 @@ if (usr_data == NULL) return -EINVAL; - if (!sk->protinfo.af_wanpipe->mbox){ + if (!WP_SK(sk)->mbox){ return -EINVAL; } - mbox_ptr = (mbox_cmd_t *)sk->protinfo.af_wanpipe->mbox; + mbox_ptr = (mbox_cmd_t *)WP_SK(sk)->mbox; if ((err=put_user(mbox_ptr->cmd.qdm, &usr_data->hdr.qdm))) return err; @@ -2140,7 +2143,7 @@ mbox_cmd_t *mbox_ptr; int err; - if (!sk->protinfo.af_wanpipe->mbox){ + if (!WP_SK(sk)->mbox){ void *mbox_ptr; netdevice_t *dev = dev_get_by_index(sk->bound_dev_if); if (!dev) @@ -2152,12 +2155,12 @@ return -ENOMEM; memset(mbox_ptr, 0, sizeof(mbox_cmd_t)); - sk->protinfo.af_wanpipe->mbox = mbox_ptr; + WP_SK(sk)->mbox = mbox_ptr; wanpipe_link_driver(dev,sk); } - mbox_ptr = (mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox; + mbox_ptr = (mbox_cmd_t*)WP_SK(sk)->mbox; memset(mbox_ptr, 0, sizeof(mbox_cmd_t)); if (usr_data == NULL){ @@ -2204,7 +2207,7 @@ struct sock *sk = sock->sk; unsigned int mask; - ++sk->protinfo.af_wanpipe->poll_cnt; + ++WP_SK(sk)->poll_cnt; poll_wait(file, sk->sleep, wait); mask = 0; @@ -2240,7 +2243,7 @@ * transmit queue */ if (sk->num == htons(X25_PROT)){ - if (atomic_read(&sk->protinfo.af_wanpipe->packet_sent)) + if (atomic_read(&WP_SK(sk)->packet_sent)) return mask; } @@ -2296,7 +2299,7 @@ { sdla_t *card; - card = (sdla_t*)sk->protinfo.af_wanpipe->card; + card = (sdla_t*)WP_SK(sk)->card; if (!card) return -ENOMEM; @@ -2321,9 +2324,7 @@ static void wanpipe_unlink_card (struct sock *sk) { - sdla_t *card; - - card = (sdla_t*)sk->protinfo.af_wanpipe->card; + sdla_t *card = (sdla_t*)WP_SK(sk)->card; if (card){ card->sk=NULL; @@ -2342,7 +2343,8 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags) { int err = -EINVAL; - mbox_cmd_t *mbox_ptr = (mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox; + wanpipe_opt *wp = WP_SK(sk); + mbox_cmd_t *mbox_ptr = (mbox_cmd_t*)wp->mbox; if (!mbox_ptr){ printk(KERN_INFO "NO MBOX PTR !!!!!\n"); @@ -2373,16 +2375,15 @@ * it is done in wanpipe_listen_rcv(). */ if (sk->state == WANSOCK_CONNECTED){ - sk->protinfo.af_wanpipe->lcn = - ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.lcn; + wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn; DBG_PRINTK(KERN_INFO "\nwansock: Accept OK %i\n", - sk->protinfo.af_wanpipe->lcn ); + wp->lcn); err = 0; }else{ DBG_PRINTK (KERN_INFO "\nwansock: Accept Failed %i\n", - sk->protinfo.af_wanpipe->lcn); - sk->protinfo.af_wanpipe->lcn = 0; + wp->lcn); + wp->lcn = 0; err = -ECONNREFUSED; } break; @@ -2400,7 +2401,7 @@ * is transmitted, or clear a call and drop packets */ if (atomic_read(&sk->wmem_alloc) || check_driver_busy(sk)){ - mbox_cmd_t *mbox = sk->protinfo.af_wanpipe->mbox; + mbox_cmd_t *mbox = wp->mbox; if (mbox->cmd.qdm & 0x80){ mbox->cmd.result = 0x35; err = -EAGAIN; @@ -2417,8 +2418,8 @@ err = -ECONNREFUSED; if (sk->state == WANSOCK_DISCONNECTED){ DBG_PRINTK(KERN_INFO "\nwansock: CLEAR OK %i\n", - sk->protinfo.af_wanpipe->lcn); - sk->protinfo.af_wanpipe->lcn=0; + wp->lcn); + wp->lcn = 0; err = 0; } break; @@ -2436,7 +2437,7 @@ * is transmitted, or reset a call and drop packets */ if (atomic_read(&sk->wmem_alloc) || check_driver_busy(sk)){ - mbox_cmd_t *mbox = sk->protinfo.af_wanpipe->mbox; + mbox_cmd_t *mbox = wp->mbox; if (mbox->cmd.qdm & 0x80){ mbox->cmd.result = 0x35; err = -EAGAIN; @@ -2461,18 +2462,16 @@ if (sk->state == WANSOCK_CONNECTED){ - sk->protinfo.af_wanpipe->lcn = - ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.lcn; + wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn; DBG_PRINTK(KERN_INFO "\nwansock: PLACE CALL OK %i\n", - sk->protinfo.af_wanpipe->lcn); + wp->lcn); err = 0; }else if (sk->state == WANSOCK_CONNECTING && (flags & O_NONBLOCK)){ - sk->protinfo.af_wanpipe->lcn = - ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.lcn; + wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn; DBG_PRINTK(KERN_INFO "\nwansock: Place Call OK: Waiting %i\n", - sk->protinfo.af_wanpipe->lcn); + wp->lcn); err = 0; @@ -2583,7 +2582,7 @@ kfree_skb(skb); - DBG_PRINTK(KERN_INFO "\nwansock: ACCEPT Got LCN %i\n",newsk->protinfo.af_wanpipe->lcn); + DBG_PRINTK(KERN_INFO "\nwansock: ACCEPT Got LCN %i\n",WP_SK(newsk)->lcn); return 0; } @@ -2660,8 +2659,8 @@ sock->state = SS_CONNECTING; sk->state = WANSOCK_CONNECTING; - if (!sk->protinfo.af_wanpipe->mbox){ - if (sk->protinfo.af_wanpipe->svc){ + if (!WP_SK(sk)->mbox){ + if (WP_SK(sk)->svc){ return -EINVAL; }else{ int err; @@ -2733,14 +2732,12 @@ static struct net_proto_family wanpipe_family_ops = { - PF_WANPIPE, - wanpipe_create + family: PF_WANPIPE, + create: wanpipe_create, }; -struct notifier_block wanpipe_netdev_notifier={ - wanpipe_notifier, - NULL, - 0 +struct notifier_block wanpipe_netdev_notifier = { + notifier_call: wanpipe_notifier, }; diff -uNr linux-2.5.1/net/x25/af_x25.c linux-2.5.1.acme/net/x25/af_x25.c --- linux-2.5.1/net/x25/af_x25.c Mon Sep 10 11:58:35 2001 +++ linux-2.5.1.acme/net/x25/af_x25.c Wed Dec 19 23:44:48 2001 @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -182,8 +183,7 @@ struct sock *s; for (s = x25_list; s != NULL; s = s->next) - if (s->protinfo.x25->neighbour && - s->protinfo.x25->neighbour->dev == dev) + if (X25_SK(s)->neighbour && X25_SK(s)->neighbour->dev == dev) x25_disconnect(s, ENETUNREACH, 0, 0); } @@ -248,7 +248,7 @@ cli(); for (s = x25_list; s != NULL; s = s->next) { - if ((strcmp(addr->x25_addr, s->protinfo.x25->source_addr.x25_addr) == 0 || + if ((!strcmp(addr->x25_addr, X25_SK(s)->source_addr.x25_addr) || strcmp(addr->x25_addr, null_x25_address.x25_addr) == 0) && s->state == TCP_LISTEN) { restore_flags(flags); @@ -272,7 +272,7 @@ cli(); for (s = x25_list; s != NULL; s = s->next) { - if (s->protinfo.x25->lci == lci && s->protinfo.x25->neighbour == neigh) { + if (X25_SK(s)->lci == lci && X25_SK(s)->neighbour == neigh) { restore_flags(flags); return s; } @@ -334,7 +334,7 @@ if (skb->sk != sk) { /* A pending connection */ skb->sk->dead = 1; /* Queue the unaccepted socket for death */ x25_start_heartbeat(skb->sk); - skb->sk->protinfo.x25->state = X25_STATE_0; + X25_SK(skb->sk)->state = X25_STATE_0; } kfree_skb(skb); @@ -377,7 +377,7 @@ switch (optname) { case X25_QBITINCL: - sk->protinfo.x25->qbitincl = opt ? 1 : 0; + X25_SK(sk)->qbitincl = opt ? 1 : 0; return 0; default: @@ -400,7 +400,7 @@ switch (optname) { case X25_QBITINCL: - val = sk->protinfo.x25->qbitincl; + val = X25_SK(sk)->qbitincl; break; default: @@ -423,7 +423,7 @@ struct sock *sk = sock->sk; if (sk->state != TCP_LISTEN) { - memset(&sk->protinfo.x25->dest_addr, '\0', X25_ADDR_LEN); + memset(&X25_SK(sk)->dest_addr, '\0', X25_ADDR_LEN); sk->max_ack_backlog = backlog; sk->state = TCP_LISTEN; return 0; @@ -447,8 +447,8 @@ memset(x25, 0x00, sizeof(*x25)); - x25->sk = sk; - sk->protinfo.x25 = x25; + x25->sk = sk; + X25_SK(sk) = x25; MOD_INC_USE_COUNT; @@ -473,7 +473,7 @@ if ((sk = x25_alloc_socket()) == NULL) return -ENOMEM; - x25 = sk->protinfo.x25; + x25 = X25_SK(sk); sock_init_data(sock, sk); @@ -510,7 +510,7 @@ if ((sk = x25_alloc_socket()) == NULL) return NULL; - x25 = sk->protinfo.x25; + x25 = X25_SK(sk); sk->type = osk->type; sk->socket = osk->socket; @@ -524,14 +524,12 @@ sk->zapped = osk->zapped; sk->backlog_rcv = osk->backlog_rcv; - x25->t21 = osk->protinfo.x25->t21; - x25->t22 = osk->protinfo.x25->t22; - x25->t23 = osk->protinfo.x25->t23; - x25->t2 = osk->protinfo.x25->t2; - - x25->facilities = osk->protinfo.x25->facilities; - - x25->qbitincl = osk->protinfo.x25->qbitincl; + x25->t21 = X25_SK(osk)->t21; + x25->t22 = X25_SK(osk)->t22; + x25->t23 = X25_SK(osk)->t23; + x25->t2 = X25_SK(osk)->t2; + x25->facilities = X25_SK(osk)->facilities; + x25->qbitincl = X25_SK(osk)->qbitincl; init_timer(&x25->timer); @@ -544,7 +542,7 @@ if (sk == NULL) return 0; - switch (sk->protinfo.x25->state) { + switch (X25_SK(sk)->state) { case X25_STATE_0: case X25_STATE_2: @@ -558,7 +556,7 @@ x25_clear_queues(sk); x25_write_internal(sk, X25_CLEAR_REQUEST); x25_start_t23timer(sk); - sk->protinfo.x25->state = X25_STATE_2; + X25_SK(sk)->state = X25_STATE_2; sk->state = TCP_CLOSE; sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); @@ -590,7 +588,7 @@ if (addr->sx25_family != AF_X25) return -EINVAL; - sk->protinfo.x25->source_addr = addr->sx25_addr; + X25_SK(sk)->source_addr = addr->sx25_addr; x25_insert_socket(sk); @@ -632,28 +630,28 @@ if ((dev = x25_get_route(&addr->sx25_addr)) == NULL) return -ENETUNREACH; - if ((sk->protinfo.x25->neighbour = x25_get_neigh(dev)) == NULL) + if ((X25_SK(sk)->neighbour = x25_get_neigh(dev)) == NULL) return -ENETUNREACH; - x25_limit_facilities(&sk->protinfo.x25->facilities, - sk->protinfo.x25->neighbour); + x25_limit_facilities(&X25_SK(sk)->facilities, X25_SK(sk)->neighbour); - if ((sk->protinfo.x25->lci = x25_new_lci(sk->protinfo.x25->neighbour)) == 0) + if ((X25_SK(sk)->lci = x25_new_lci(X25_SK(sk)->neighbour)) == 0) return -ENETUNREACH; if (sk->zapped) /* Must bind first - autobinding does not work */ return -EINVAL; - if (strcmp(sk->protinfo.x25->source_addr.x25_addr, null_x25_address.x25_addr) == 0) - memset(&sk->protinfo.x25->source_addr, '\0', X25_ADDR_LEN); + if (!strcmp(X25_SK(sk)->source_addr.x25_addr, + null_x25_address.x25_addr)) + memset(&X25_SK(sk)->source_addr, '\0', X25_ADDR_LEN); - sk->protinfo.x25->dest_addr = addr->sx25_addr; + X25_SK(sk)->dest_addr = addr->sx25_addr; /* Move to connecting socket, start sending Connect Requests */ sock->state = SS_CONNECTING; sk->state = TCP_SYN_SENT; - sk->protinfo.x25->state = X25_STATE_1; + X25_SK(sk)->state = X25_STATE_1; x25_write_internal(sk, X25_CALL_REQUEST); @@ -748,9 +746,9 @@ if (peer != 0) { if (sk->state != TCP_ESTABLISHED) return -ENOTCONN; - sx25->sx25_addr = sk->protinfo.x25->dest_addr; + sx25->sx25_addr = X25_SK(sk)->dest_addr; } else { - sx25->sx25_addr = sk->protinfo.x25->source_addr; + sx25->sx25_addr = X25_SK(sk)->source_addr; } sx25->sx25_family = AF_X25; @@ -822,12 +820,12 @@ skb->sk = make; make->state = TCP_ESTABLISHED; - make->protinfo.x25->lci = lci; - make->protinfo.x25->dest_addr = dest_addr; - make->protinfo.x25->source_addr = source_addr; - make->protinfo.x25->neighbour = neigh; - make->protinfo.x25->facilities = facilities; - make->protinfo.x25->vc_facil_mask = sk->protinfo.x25->vc_facil_mask; + X25_SK(make)->lci = lci; + X25_SK(make)->dest_addr = dest_addr; + X25_SK(make)->source_addr = source_addr; + X25_SK(make)->neighbour = neigh; + X25_SK(make)->facilities = facilities; + X25_SK(make)->vc_facil_mask = X25_SK(sk)->vc_facil_mask; x25_write_internal(make, X25_CALL_ACCEPTED); @@ -835,11 +833,11 @@ * Incoming Call User Data. */ if (skb->len >= 0) { - memcpy(make->protinfo.x25->calluserdata.cuddata, skb->data, skb->len); - make->protinfo.x25->calluserdata.cudlength = skb->len; + memcpy(X25_SK(make)->calluserdata.cuddata, skb->data, skb->len); + X25_SK(make)->calluserdata.cudlength = skb->len; } - make->protinfo.x25->state = X25_STATE_3; + X25_SK(make)->state = X25_STATE_3; sk->ack_backlog++; make->pair = sk; @@ -881,14 +879,15 @@ return -EPIPE; } - if (sk->protinfo.x25->neighbour == NULL) + if (X25_SK(sk)->neighbour == NULL) return -ENETUNREACH; if (usx25 != NULL) { if (msg->msg_namelen < sizeof(sx25)) return -EINVAL; sx25 = *usx25; - if (strcmp(sk->protinfo.x25->dest_addr.x25_addr, sx25.sx25_addr.x25_addr) != 0) + if (strcmp(X25_SK(sk)->dest_addr.x25_addr, + sx25.sx25_addr.x25_addr)) return -EISCONN; if (sx25.sx25_family != AF_X25) return -EINVAL; @@ -902,7 +901,7 @@ return -ENOTCONN; sx25.sx25_family = AF_X25; - sx25.sx25_addr = sk->protinfo.x25->dest_addr; + sx25.sx25_addr = X25_SK(sk)->dest_addr; } SOCK_DEBUG(sk, "x25_sendmsg: sendto: Addresses built.\n"); @@ -934,7 +933,7 @@ * If the Q BIT Include socket option is in force, the first * byte of the user data is the logical value of the Q Bit. */ - if (sk->protinfo.x25->qbitincl) { + if (X25_SK(sk)->qbitincl) { qbit = skb->data[0]; skb_pull(skb, 1); } @@ -945,30 +944,34 @@ SOCK_DEBUG(sk, "x25_sendmsg: Building X.25 Header.\n"); if (msg->msg_flags & MSG_OOB) { - if (sk->protinfo.x25->neighbour->extended) { + if (X25_SK(sk)->neighbour->extended) { asmptr = skb_push(skb, X25_STD_MIN_LEN); - *asmptr++ = ((sk->protinfo.x25->lci >> 8) & 0x0F) | X25_GFI_EXTSEQ; - *asmptr++ = (sk->protinfo.x25->lci >> 0) & 0xFF; + *asmptr++ = ((X25_SK(sk)->lci >> 8) & 0x0F) | + X25_GFI_EXTSEQ; + *asmptr++ = (X25_SK(sk)->lci >> 0) & 0xFF; *asmptr++ = X25_INTERRUPT; } else { asmptr = skb_push(skb, X25_STD_MIN_LEN); - *asmptr++ = ((sk->protinfo.x25->lci >> 8) & 0x0F) | X25_GFI_STDSEQ; - *asmptr++ = (sk->protinfo.x25->lci >> 0) & 0xFF; + *asmptr++ = ((X25_SK(sk)->lci >> 8) & 0x0F) | + X25_GFI_STDSEQ; + *asmptr++ = (X25_SK(sk)->lci >> 0) & 0xFF; *asmptr++ = X25_INTERRUPT; } } else { - if (sk->protinfo.x25->neighbour->extended) { + if (X25_SK(sk)->neighbour->extended) { /* Build an Extended X.25 header */ asmptr = skb_push(skb, X25_EXT_MIN_LEN); - *asmptr++ = ((sk->protinfo.x25->lci >> 8) & 0x0F) | X25_GFI_EXTSEQ; - *asmptr++ = (sk->protinfo.x25->lci >> 0) & 0xFF; + *asmptr++ = ((X25_SK(sk)->lci >> 8) & 0x0F) | + X25_GFI_EXTSEQ; + *asmptr++ = (X25_SK(sk)->lci >> 0) & 0xFF; *asmptr++ = X25_DATA; *asmptr++ = X25_DATA; } else { /* Build an Standard X.25 header */ asmptr = skb_push(skb, X25_STD_MIN_LEN); - *asmptr++ = ((sk->protinfo.x25->lci >> 8) & 0x0F) | X25_GFI_STDSEQ; - *asmptr++ = (sk->protinfo.x25->lci >> 0) & 0xFF; + *asmptr++ = ((X25_SK(sk)->lci >> 8) & 0x0F) | + X25_GFI_STDSEQ; + *asmptr++ = (X25_SK(sk)->lci >> 0) & 0xFF; *asmptr++ = X25_DATA; } @@ -985,13 +988,14 @@ } if (msg->msg_flags & MSG_OOB) { - skb_queue_tail(&sk->protinfo.x25->interrupt_out_queue, skb); + skb_queue_tail(&X25_SK(sk)->interrupt_out_queue, skb); } else { len = x25_output(sk, skb); if(len<0){ kfree_skb(skb); } else { - if(sk->protinfo.x25->qbitincl) len++; + if (X25_SK(sk)->qbitincl) + len++; } } @@ -1034,17 +1038,17 @@ return -ENOTCONN; if (flags & MSG_OOB) { - if (sk->urginline || skb_peek(&sk->protinfo.x25->interrupt_in_queue) == NULL) + if (sk->urginline || !skb_peek(&X25_SK(sk)->interrupt_in_queue)) return -EINVAL; - skb = skb_dequeue(&sk->protinfo.x25->interrupt_in_queue); + skb = skb_dequeue(&X25_SK(sk)->interrupt_in_queue); skb_pull(skb, X25_STD_MIN_LEN); /* * No Q bit information on Interrupt data. */ - if (sk->protinfo.x25->qbitincl) { + if (X25_SK(sk)->qbitincl) { asmptr = skb_push(skb, 1); *asmptr = 0x00; } @@ -1057,9 +1061,10 @@ qbit = (skb->data[0] & X25_Q_BIT) == X25_Q_BIT; - skb_pull(skb, (sk->protinfo.x25->neighbour->extended) ? X25_EXT_MIN_LEN : X25_STD_MIN_LEN); + skb_pull(skb, (X25_SK(sk)->neighbour->extended) ? + X25_EXT_MIN_LEN : X25_STD_MIN_LEN); - if (sk->protinfo.x25->qbitincl) { + if (X25_SK(sk)->qbitincl) { asmptr = skb_push(skb, 1); *asmptr = qbit; } @@ -1081,7 +1086,7 @@ if (sx25 != NULL) { sx25->sx25_family = AF_X25; - sx25->sx25_addr = sk->protinfo.x25->dest_addr; + sx25->sx25_addr = X25_SK(sk)->dest_addr; } msg->msg_namelen = sizeof(struct sockaddr_x25); @@ -1151,7 +1156,7 @@ case SIOCX25GFACILITIES: { struct x25_facilities facilities; - facilities = sk->protinfo.x25->facilities; + facilities = X25_SK(sk)->facilities; return copy_to_user((void *)arg, &facilities, sizeof(facilities)) ? -EFAULT : 0; } @@ -1171,13 +1176,13 @@ return -EINVAL; if (facilities.reverse != 0 && facilities.reverse != 1) return -EINVAL; - sk->protinfo.x25->facilities = facilities; + X25_SK(sk)->facilities = facilities; return 0; } case SIOCX25GCALLUSERDATA: { struct x25_calluserdata calluserdata; - calluserdata = sk->protinfo.x25->calluserdata; + calluserdata = X25_SK(sk)->calluserdata; return copy_to_user((void *)arg, &calluserdata, sizeof(calluserdata)) ? -EFAULT : 0; } @@ -1187,13 +1192,13 @@ return -EFAULT; if (calluserdata.cudlength > X25_MAX_CUD_LEN) return -EINVAL; - sk->protinfo.x25->calluserdata = calluserdata; + X25_SK(sk)->calluserdata = calluserdata; return 0; } case SIOCX25GCAUSEDIAG: { struct x25_causediag causediag; - causediag = sk->protinfo.x25->causediag; + causediag = X25_SK(sk)->causediag; return copy_to_user((void *)arg, &causediag, sizeof(causediag)) ? -EFAULT : 0; } @@ -1219,25 +1224,28 @@ len += sprintf(buffer, "dest_addr src_addr dev lci st vs vr va t t2 t21 t22 t23 Snd-Q Rcv-Q inode\n"); for (s = x25_list; s != NULL; s = s->next) { - if (s->protinfo.x25->neighbour == NULL || (dev = s->protinfo.x25->neighbour->dev) == NULL) + if (!X25_SK(s)->neighbour || + (dev = X25_SK(s)->neighbour->dev) == NULL) devname = "???"; else - devname = s->protinfo.x25->neighbour->dev->name; + devname = X25_SK(s)->neighbour->dev->name; len += sprintf(buffer + len, "%-10s %-10s %-5s %3.3X %d %d %d %d %3lu %3lu %3lu %3lu %3lu %5d %5d %ld\n", - (s->protinfo.x25->dest_addr.x25_addr[0] == '\0') ? "*" : s->protinfo.x25->dest_addr.x25_addr, - (s->protinfo.x25->source_addr.x25_addr[0] == '\0') ? "*" : s->protinfo.x25->source_addr.x25_addr, + (X25_SK(s)->dest_addr.x25_addr[0] == '\0') ? "*" : + X25_SK(s)->dest_addr.x25_addr, + (X25_SK(s)->source_addr.x25_addr[0] == '\0') ? "*" : + X25_SK(s)->source_addr.x25_addr, devname, - s->protinfo.x25->lci & 0x0FFF, - s->protinfo.x25->state, - s->protinfo.x25->vs, - s->protinfo.x25->vr, - s->protinfo.x25->va, + X25_SK(s)->lci & 0x0FFF, + X25_SK(s)->state, + X25_SK(s)->vs, + X25_SK(s)->vr, + X25_SK(s)->va, x25_display_timer(s) / HZ, - s->protinfo.x25->t2 / HZ, - s->protinfo.x25->t21 / HZ, - s->protinfo.x25->t22 / HZ, - s->protinfo.x25->t23 / HZ, + X25_SK(s)->t2 / HZ, + X25_SK(s)->t21 / HZ, + X25_SK(s)->t22 / HZ, + X25_SK(s)->t23 / HZ, atomic_read(&s->wmem_alloc), atomic_read(&s->rmem_alloc), s->socket != NULL ? s->socket->inode->i_ino : 0L); @@ -1307,7 +1315,7 @@ struct sock *s; for( s=x25_list; s != NULL; s=s->next){ - if( s->protinfo.x25->neighbour == neigh ) + if (X25_SK(s)->neighbour == neigh) x25_disconnect(s, ENETUNREACH, 0, 0); } } diff -uNr linux-2.5.1/net/x25/x25_facilities.c linux-2.5.1.acme/net/x25/x25_facilities.c --- linux-2.5.1/net/x25/x25_facilities.c Wed Jan 24 21:28:36 2001 +++ linux-2.5.1.acme/net/x25/x25_facilities.c Wed Dec 19 23:44:48 2001 @@ -163,11 +163,11 @@ memset(&theirs, 0x00, sizeof(struct x25_facilities)); - ours = &sk->protinfo.x25->facilities; + ours = &X25_SK(sk)->facilities; *new = *ours; - len = x25_parse_facilities(skb, &theirs, &sk->protinfo.x25->vc_facil_mask); + len = x25_parse_facilities(skb, &theirs, &X25_SK(sk)->vc_facil_mask); /* * They want reverse charging, we won't accept it. diff -uNr linux-2.5.1/net/x25/x25_in.c linux-2.5.1.acme/net/x25/x25_in.c --- linux-2.5.1/net/x25/x25_in.c Wed Jan 24 21:28:36 2001 +++ linux-2.5.1.acme/net/x25/x25_in.c Wed Dec 19 23:44:48 2001 @@ -47,37 +47,40 @@ static int x25_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more) { struct sk_buff *skbo, *skbn = skb; + x25_cb *x25 = X25_SK(sk); if (more) { - sk->protinfo.x25->fraglen += skb->len; - skb_queue_tail(&sk->protinfo.x25->fragment_queue, skb); + x25->fraglen += skb->len; + skb_queue_tail(&x25->fragment_queue, skb); skb_set_owner_r(skb, sk); return 0; } - if (!more && sk->protinfo.x25->fraglen > 0) { /* End of fragment */ - int len = sk->protinfo.x25->fraglen + skb->len; + if (!more && x25->fraglen > 0) { /* End of fragment */ + int len = x25->fraglen + skb->len; if ((skbn = alloc_skb(len, GFP_ATOMIC)) == NULL){ kfree_skb(skb); return 1; } - skb_queue_tail(&sk->protinfo.x25->fragment_queue, skb); + skb_queue_tail(&x25->fragment_queue, skb); skbn->h.raw = skbn->data; - skbo = skb_dequeue(&sk->protinfo.x25->fragment_queue); + skbo = skb_dequeue(&x25->fragment_queue); memcpy(skb_put(skbn, skbo->len), skbo->data, skbo->len); kfree_skb(skbo); - while ((skbo = skb_dequeue(&sk->protinfo.x25->fragment_queue)) != NULL) { - skb_pull(skbo, (sk->protinfo.x25->neighbour->extended) ? X25_EXT_MIN_LEN : X25_STD_MIN_LEN); + while ((skbo = + skb_dequeue(&x25->fragment_queue)) != NULL) { + skb_pull(skbo, (x25->neighbour->extended) ? + X25_EXT_MIN_LEN : X25_STD_MIN_LEN); memcpy(skb_put(skbn, skbo->len), skbo->data, skbo->len); kfree_skb(skbo); } - sk->protinfo.x25->fraglen = 0; + x25->fraglen = 0; } skb_set_owner_r(skbn, sk); @@ -98,33 +101,37 @@ x25_address source_addr, dest_addr; switch (frametype) { + case X25_CALL_ACCEPTED: { + x25_cb *x25 = X25_SK(sk); - case X25_CALL_ACCEPTED: x25_stop_timer(sk); - sk->protinfo.x25->condition = 0x00; - sk->protinfo.x25->vs = 0; - sk->protinfo.x25->va = 0; - sk->protinfo.x25->vr = 0; - sk->protinfo.x25->vl = 0; - sk->protinfo.x25->state = X25_STATE_3; - sk->state = TCP_ESTABLISHED; + x25->condition = 0x00; + x25->vs = 0; + x25->va = 0; + x25->vr = 0; + x25->vl = 0; + x25->state = X25_STATE_3; + sk->state = TCP_ESTABLISHED; /* * Parse the data in the frame. */ skb_pull(skb, X25_STD_MIN_LEN); skb_pull(skb, x25_addr_ntoa(skb->data, &source_addr, &dest_addr)); - skb_pull(skb, x25_parse_facilities(skb, &sk->protinfo.x25->facilities, &sk->protinfo.x25->vc_facil_mask)); + skb_pull(skb, + x25_parse_facilities(skb, &x25->facilities, + &x25->vc_facil_mask)); /* * Copy any Call User Data. */ if (skb->len >= 0) { - memcpy(sk->protinfo.x25->calluserdata.cuddata, skb->data, skb->len); - sk->protinfo.x25->calluserdata.cudlength = skb->len; + memcpy(x25->calluserdata.cuddata, skb->data, + skb->len); + x25->calluserdata.cudlength = skb->len; } if (!sk->dead) sk->state_change(sk); break; - + } case X25_CLEAR_REQUEST: x25_write_internal(sk, X25_CLEAR_CONFIRMATION); x25_disconnect(sk, ECONNREFUSED, skb->data[3], skb->data[4]); @@ -171,19 +178,20 @@ { int queued = 0; int modulus; + x25_cb *x25 = X25_SK(sk); - modulus = (sk->protinfo.x25->neighbour->extended) ? X25_EMODULUS : X25_SMODULUS; + modulus = (x25->neighbour->extended) ? X25_EMODULUS : X25_SMODULUS; switch (frametype) { case X25_RESET_REQUEST: x25_write_internal(sk, X25_RESET_CONFIRMATION); x25_stop_timer(sk); - sk->protinfo.x25->condition = 0x00; - sk->protinfo.x25->vs = 0; - sk->protinfo.x25->vr = 0; - sk->protinfo.x25->va = 0; - sk->protinfo.x25->vl = 0; + x25->condition = 0x00; + x25->vs = 0; + x25->vr = 0; + x25->va = 0; + x25->vl = 0; x25_requeue_frames(sk); break; @@ -198,74 +206,73 @@ x25_clear_queues(sk); x25_write_internal(sk, X25_RESET_REQUEST); x25_start_t22timer(sk); - sk->protinfo.x25->condition = 0x00; - sk->protinfo.x25->vs = 0; - sk->protinfo.x25->vr = 0; - sk->protinfo.x25->va = 0; - sk->protinfo.x25->vl = 0; - sk->protinfo.x25->state = X25_STATE_4; + x25->condition = 0x00; + x25->vs = 0; + x25->vr = 0; + x25->va = 0; + x25->vl = 0; + x25->state = X25_STATE_4; } else { x25_frames_acked(sk, nr); if (frametype == X25_RNR) { - sk->protinfo.x25->condition |= X25_COND_PEER_RX_BUSY; + x25->condition |= X25_COND_PEER_RX_BUSY; } else { - sk->protinfo.x25->condition &= ~X25_COND_PEER_RX_BUSY; + x25->condition &= ~X25_COND_PEER_RX_BUSY; } } break; case X25_DATA: /* XXX */ - sk->protinfo.x25->condition &= ~X25_COND_PEER_RX_BUSY; - if ((ns!=sk->protinfo.x25->vr) || - !x25_validate_nr(sk, nr)) { + x25->condition &= ~X25_COND_PEER_RX_BUSY; + if ((ns != x25->vr) || !x25_validate_nr(sk, nr)) { x25_clear_queues(sk); x25_write_internal(sk, X25_RESET_REQUEST); x25_start_t22timer(sk); - sk->protinfo.x25->condition = 0x00; - sk->protinfo.x25->vs = 0; - sk->protinfo.x25->vr = 0; - sk->protinfo.x25->va = 0; - sk->protinfo.x25->vl = 0; - sk->protinfo.x25->state = X25_STATE_4; + x25->condition = 0x00; + x25->vs = 0; + x25->vr = 0; + x25->va = 0; + x25->vl = 0; + x25->state = X25_STATE_4; break; } x25_frames_acked(sk, nr); - if (ns == sk->protinfo.x25->vr) { + if (ns == x25->vr) { if (x25_queue_rx_frame(sk, skb, m) == 0) { - sk->protinfo.x25->vr = (sk->protinfo.x25->vr + 1) % modulus; + x25->vr = (x25->vr + 1) % modulus; queued = 1; } else { /* Should never happen */ x25_clear_queues(sk); x25_write_internal(sk, X25_RESET_REQUEST); x25_start_t22timer(sk); - sk->protinfo.x25->condition = 0x00; - sk->protinfo.x25->vs = 0; - sk->protinfo.x25->vr = 0; - sk->protinfo.x25->va = 0; - sk->protinfo.x25->vl = 0; - sk->protinfo.x25->state = X25_STATE_4; + x25->condition = 0x00; + x25->vs = 0; + x25->vr = 0; + x25->va = 0; + x25->vl = 0; + x25->state = X25_STATE_4; break; } if (atomic_read(&sk->rmem_alloc) > (sk->rcvbuf / 2)) - sk->protinfo.x25->condition |= X25_COND_OWN_RX_BUSY; + x25->condition |= X25_COND_OWN_RX_BUSY; } /* * If the window is full Ack it immediately, else * start the holdback timer. */ - if (((sk->protinfo.x25->vl + sk->protinfo.x25->facilities.winsize_in) % modulus) == sk->protinfo.x25->vr) { - sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING; + if (((x25->vl + x25->facilities.winsize_in) % modulus) == x25->vr) { + x25->condition &= ~X25_COND_ACK_PENDING; x25_stop_timer(sk); x25_enquiry_response(sk); } else { - sk->protinfo.x25->condition |= X25_COND_ACK_PENDING; + x25->condition |= X25_COND_ACK_PENDING; x25_start_t2timer(sk); } break; case X25_INTERRUPT_CONFIRMATION: - sk->protinfo.x25->intflag = 0; + x25->intflag = 0; break; case X25_INTERRUPT: @@ -273,7 +280,7 @@ queued = (sock_queue_rcv_skb(sk, skb) == 0); } else { skb_set_owner_r(skb, sk); - skb_queue_tail(&sk->protinfo.x25->interrupt_in_queue, skb); + skb_queue_tail(&x25->interrupt_in_queue, skb); queued = 1; } if (sk->proc != 0) { @@ -305,17 +312,19 @@ case X25_RESET_REQUEST: x25_write_internal(sk, X25_RESET_CONFIRMATION); - case X25_RESET_CONFIRMATION: + case X25_RESET_CONFIRMATION: { + x25_cb *x25 = X25_SK(sk); + x25_stop_timer(sk); - sk->protinfo.x25->condition = 0x00; - sk->protinfo.x25->va = 0; - sk->protinfo.x25->vr = 0; - sk->protinfo.x25->vs = 0; - sk->protinfo.x25->vl = 0; - sk->protinfo.x25->state = X25_STATE_3; + x25->condition = 0x00; + x25->va = 0; + x25->vr = 0; + x25->vs = 0; + x25->vl = 0; + x25->state = X25_STATE_3; x25_requeue_frames(sk); break; - + } case X25_CLEAR_REQUEST: x25_write_internal(sk, X25_CLEAR_CONFIRMATION); x25_disconnect(sk, 0, skb->data[3], skb->data[4]); @@ -333,12 +342,12 @@ { int queued = 0, frametype, ns, nr, q, d, m; - if (sk->protinfo.x25->state == X25_STATE_0) + if (X25_SK(sk)->state == X25_STATE_0) return 0; frametype = x25_decode(sk, skb, &ns, &nr, &q, &d, &m); - switch (sk->protinfo.x25->state) { + switch (X25_SK(sk)->state) { case X25_STATE_1: queued = x25_state1_machine(sk, skb, frametype); break; diff -uNr linux-2.5.1/net/x25/x25_out.c linux-2.5.1.acme/net/x25/x25_out.c --- linux-2.5.1/net/x25/x25_out.c Thu Apr 12 16:11:39 2001 +++ linux-2.5.1.acme/net/x25/x25_out.c Wed Dec 19 23:44:48 2001 @@ -65,11 +65,12 @@ { struct sk_buff *skbn; unsigned char header[X25_EXT_MIN_LEN]; - int err, frontlen, len, header_len, max_len; + int err, frontlen, len; int sent=0, noblock = X25_SKB_CB(skb)->flags & MSG_DONTWAIT; - - header_len = (sk->protinfo.x25->neighbour->extended) ? X25_EXT_MIN_LEN : X25_STD_MIN_LEN; - max_len = x25_pacsize_to_bytes(sk->protinfo.x25->facilities.pacsize_out); + x25_cb *x25 = X25_SK(sk); + int header_len = (x25->neighbour->extended) ? X25_EXT_MIN_LEN : + X25_STD_MIN_LEN; + int max_len = x25_pacsize_to_bytes(x25->facilities.pacsize_out); if (skb->len - header_len > max_len) { /* Save a copy of the Header */ @@ -101,7 +102,7 @@ memcpy(skbn->data, header, header_len); if (skb->len > 0) { - if (sk->protinfo.x25->neighbour->extended) + if (x25->neighbour->extended) skbn->data[3] |= X25_EXT_M_BIT; else skbn->data[2] |= X25_STD_M_BIT; @@ -125,20 +126,22 @@ */ static void x25_send_iframe(struct sock *sk, struct sk_buff *skb) { + x25_cb *x25 = X25_SK(sk); + if (skb == NULL) return; - if (sk->protinfo.x25->neighbour->extended) { - skb->data[2] = (sk->protinfo.x25->vs << 1) & 0xFE; + if (x25->neighbour->extended) { + skb->data[2] = (x25->vs << 1) & 0xFE; skb->data[3] &= X25_EXT_M_BIT; - skb->data[3] |= (sk->protinfo.x25->vr << 1) & 0xFE; + skb->data[3] |= (x25->vr << 1) & 0xFE; } else { skb->data[2] &= X25_STD_M_BIT; - skb->data[2] |= (sk->protinfo.x25->vs << 1) & 0x0E; - skb->data[2] |= (sk->protinfo.x25->vr << 5) & 0xE0; + skb->data[2] |= (x25->vs << 1) & 0x0E; + skb->data[2] |= (x25->vr << 5) & 0xE0; } - x25_transmit_link(skb, sk->protinfo.x25->neighbour); + x25_transmit_link(skb, x25->neighbour); } void x25_kick(struct sock *sk) @@ -146,34 +149,35 @@ struct sk_buff *skb, *skbn; unsigned short start, end; int modulus; + x25_cb *x25 = X25_SK(sk); - if (sk->protinfo.x25->state != X25_STATE_3) + if (x25->state != X25_STATE_3) return; /* * Transmit interrupt data. */ - if (!sk->protinfo.x25->intflag && skb_peek(&sk->protinfo.x25->interrupt_out_queue) != NULL) { - sk->protinfo.x25->intflag = 1; - skb = skb_dequeue(&sk->protinfo.x25->interrupt_out_queue); - x25_transmit_link(skb, sk->protinfo.x25->neighbour); + if (!x25->intflag && skb_peek(&x25->interrupt_out_queue) != NULL) { + x25->intflag = 1; + skb = skb_dequeue(&x25->interrupt_out_queue); + x25_transmit_link(skb, x25->neighbour); } - if (sk->protinfo.x25->condition & X25_COND_PEER_RX_BUSY) + if (x25->condition & X25_COND_PEER_RX_BUSY) return; if (skb_peek(&sk->write_queue) == NULL) return; - modulus = (sk->protinfo.x25->neighbour->extended) ? X25_EMODULUS : X25_SMODULUS; + modulus = (x25->neighbour->extended) ? X25_EMODULUS : X25_SMODULUS; - start = (skb_peek(&sk->protinfo.x25->ack_queue) == NULL) ? sk->protinfo.x25->va : sk->protinfo.x25->vs; - end = (sk->protinfo.x25->va + sk->protinfo.x25->facilities.winsize_out) % modulus; + start = (skb_peek(&x25->ack_queue) == NULL) ? x25->va : x25->vs; + end = (x25->va + x25->facilities.winsize_out) % modulus; if (start == end) return; - sk->protinfo.x25->vs = start; + x25->vs = start; /* * Transmit data until either we're out of data to send or @@ -195,17 +199,17 @@ */ x25_send_iframe(sk, skbn); - sk->protinfo.x25->vs = (sk->protinfo.x25->vs + 1) % modulus; + x25->vs = (x25->vs + 1) % modulus; /* * Requeue the original data frame. */ - skb_queue_tail(&sk->protinfo.x25->ack_queue, skb); + skb_queue_tail(&x25->ack_queue, skb); - } while (sk->protinfo.x25->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL); + } while (x25->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL); - sk->protinfo.x25->vl = sk->protinfo.x25->vr; - sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING; + x25->vl = x25->vr; + x25->condition &= ~X25_COND_ACK_PENDING; x25_stop_timer(sk); } @@ -217,13 +221,15 @@ void x25_enquiry_response(struct sock *sk) { - if (sk->protinfo.x25->condition & X25_COND_OWN_RX_BUSY) + x25_cb *x25 = X25_SK(sk); + + if (x25->condition & X25_COND_OWN_RX_BUSY) x25_write_internal(sk, X25_RNR); else x25_write_internal(sk, X25_RR); - sk->protinfo.x25->vl = sk->protinfo.x25->vr; - sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING; + x25->vl = x25->vr; + x25->condition &= ~X25_COND_ACK_PENDING; x25_stop_timer(sk); } diff -uNr linux-2.5.1/net/x25/x25_subr.c linux-2.5.1.acme/net/x25/x25_subr.c --- linux-2.5.1/net/x25/x25_subr.c Fri Jun 29 23:38:26 2001 +++ linux-2.5.1.acme/net/x25/x25_subr.c Wed Dec 19 23:44:48 2001 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -46,11 +47,13 @@ */ void x25_clear_queues(struct sock *sk) { + x25_cb *x25 = X25_SK(sk); + skb_queue_purge(&sk->write_queue); - skb_queue_purge(&sk->protinfo.x25->ack_queue); - skb_queue_purge(&sk->protinfo.x25->interrupt_in_queue); - skb_queue_purge(&sk->protinfo.x25->interrupt_out_queue); - skb_queue_purge(&sk->protinfo.x25->fragment_queue); + skb_queue_purge(&x25->ack_queue); + skb_queue_purge(&x25->interrupt_in_queue); + skb_queue_purge(&x25->interrupt_out_queue); + skb_queue_purge(&x25->fragment_queue); } @@ -62,19 +65,17 @@ void x25_frames_acked(struct sock *sk, unsigned short nr) { struct sk_buff *skb; - int modulus = sk->protinfo.x25->neighbour->extended ? X25_EMODULUS : - X25_SMODULUS; + x25_cb *x25 = X25_SK(sk); + int modulus = x25->neighbour->extended ? X25_EMODULUS : X25_SMODULUS; /* * Remove all the ack-ed frames from the ack queue. */ - if (sk->protinfo.x25->va != nr) - while (skb_peek(&sk->protinfo.x25->ack_queue) != NULL && - sk->protinfo.x25->va != nr) { - skb = skb_dequeue(&sk->protinfo.x25->ack_queue); + if (x25->va != nr) + while (skb_peek(&x25->ack_queue) && x25->va != nr) { + skb = skb_dequeue(&x25->ack_queue); kfree_skb(skb); - sk->protinfo.x25->va = (sk->protinfo.x25->va + 1) % - modulus; + x25->va = (x25->va + 1) % modulus; } } @@ -87,7 +88,7 @@ * up by x25_kick. This arrangement handles the possibility of an empty * output queue. */ - while ((skb = skb_dequeue(&sk->protinfo.x25->ack_queue)) != NULL) { + while ((skb = skb_dequeue(&X25_SK(sk)->ack_queue)) != NULL) { if (skb_prev == NULL) skb_queue_head(&sk->write_queue, skb); else @@ -102,16 +103,16 @@ */ int x25_validate_nr(struct sock *sk, unsigned short nr) { - unsigned short vc = sk->protinfo.x25->va; - int modulus = sk->protinfo.x25->neighbour->extended ? X25_EMODULUS : - X25_SMODULUS; + x25_cb *x25 = X25_SK(sk); + unsigned short vc = x25->va; + int modulus = x25->neighbour->extended ? X25_EMODULUS : X25_SMODULUS; - while (vc != sk->protinfo.x25->vs) { + while (vc != x25->vs) { if (nr == vc) return 1; vc = (vc + 1) % modulus; } - return nr == sk->protinfo.x25->vs ? 1 : 0; + return nr == x25->vs ? 1 : 0; } /* @@ -120,6 +121,7 @@ */ void x25_write_internal(struct sock *sk, int frametype) { + x25_cb *x25 = X25_SK(sk); struct sk_buff *skb; unsigned char *dptr; unsigned char facilities[X25_MAX_FAC_LEN]; @@ -173,10 +175,10 @@ */ dptr = skb_put(skb, 2); - lci1 = (sk->protinfo.x25->lci >> 8) & 0x0F; - lci2 = (sk->protinfo.x25->lci >> 0) & 0xFF; + lci1 = (x25->lci >> 8) & 0x0F; + lci2 = (x25->lci >> 0) & 0xFF; - if (sk->protinfo.x25->neighbour->extended) { + if (x25->neighbour->extended) { *dptr++ = lci1 | X25_GFI_EXTSEQ; *dptr++ = lci2; } else { @@ -192,27 +194,34 @@ case X25_CALL_REQUEST: dptr = skb_put(skb, 1); *dptr++ = X25_CALL_REQUEST; - len = x25_addr_aton(addresses, &sk->protinfo.x25->dest_addr, &sk->protinfo.x25->source_addr); + len = x25_addr_aton(addresses, &x25->dest_addr, + &x25->source_addr); dptr = skb_put(skb, len); memcpy(dptr, addresses, len); - len = x25_create_facilities(facilities, &sk->protinfo.x25->facilities, sk->protinfo.x25->neighbour->global_facil_mask); + len = x25_create_facilities(facilities, + &x25->facilities, + x25->neighbour->global_facil_mask); dptr = skb_put(skb, len); memcpy(dptr, facilities, len); - dptr = skb_put(skb, sk->protinfo.x25->calluserdata.cudlength); - memcpy(dptr, sk->protinfo.x25->calluserdata.cuddata, sk->protinfo.x25->calluserdata.cudlength); - sk->protinfo.x25->calluserdata.cudlength = 0; + dptr = skb_put(skb, x25->calluserdata.cudlength); + memcpy(dptr, x25->calluserdata.cuddata, + x25->calluserdata.cudlength); + x25->calluserdata.cudlength = 0; break; case X25_CALL_ACCEPTED: dptr = skb_put(skb, 2); *dptr++ = X25_CALL_ACCEPTED; *dptr++ = 0x00; /* Address lengths */ - len = x25_create_facilities(facilities, &sk->protinfo.x25->facilities, sk->protinfo.x25->vc_facil_mask); + len = x25_create_facilities(facilities, + &x25->facilities, + x25->vc_facil_mask); dptr = skb_put(skb, len); memcpy(dptr, facilities, len); - dptr = skb_put(skb, sk->protinfo.x25->calluserdata.cudlength); - memcpy(dptr, sk->protinfo.x25->calluserdata.cuddata, sk->protinfo.x25->calluserdata.cudlength); - sk->protinfo.x25->calluserdata.cudlength = 0; + dptr = skb_put(skb, x25->calluserdata.cudlength); + memcpy(dptr, x25->calluserdata.cuddata, + x25->calluserdata.cudlength); + x25->calluserdata.cudlength = 0; break; case X25_CLEAR_REQUEST: @@ -226,14 +235,14 @@ case X25_RR: case X25_RNR: case X25_REJ: - if (sk->protinfo.x25->neighbour->extended) { + if (x25->neighbour->extended) { dptr = skb_put(skb, 2); *dptr++ = frametype; - *dptr++ = (sk->protinfo.x25->vr << 1) & 0xFE; + *dptr++ = (x25->vr << 1) & 0xFE; } else { dptr = skb_put(skb, 1); *dptr = frametype; - *dptr++ |= (sk->protinfo.x25->vr << 5) & 0xE0; + *dptr++ |= (x25->vr << 5) & 0xE0; } break; @@ -245,7 +254,7 @@ break; } - x25_transmit_link(skb, sk->protinfo.x25->neighbour); + x25_transmit_link(skb, x25->neighbour); } /* @@ -275,7 +284,7 @@ return frame[2]; } - if (sk->protinfo.x25->neighbour->extended) { + if (X25_SK(sk)->neighbour->extended) { if (frame[2] == X25_RR || frame[2] == X25_RNR || frame[2] == X25_REJ) { @@ -291,7 +300,7 @@ } } - if (sk->protinfo.x25->neighbour->extended) { + if (X25_SK(sk)->neighbour->extended) { if ((frame[2] & 0x01) == X25_DATA) { *q = (frame[0] & X25_Q_BIT) == X25_Q_BIT; *d = (frame[0] & X25_D_BIT) == X25_D_BIT; @@ -320,14 +329,16 @@ void x25_disconnect(struct sock *sk, int reason, unsigned char cause, unsigned char diagnostic) { + x25_cb *x25 = X25_SK(sk); + x25_clear_queues(sk); x25_stop_timer(sk); - sk->protinfo.x25->lci = 0; - sk->protinfo.x25->state = X25_STATE_0; + x25->lci = 0; + x25->state = X25_STATE_0; - sk->protinfo.x25->causediag.cause = cause; - sk->protinfo.x25->causediag.diagnostic = diagnostic; + x25->causediag.cause = cause; + x25->causediag.diagnostic = diagnostic; sk->state = TCP_CLOSE; sk->err = reason; @@ -345,11 +356,13 @@ */ void x25_check_rbuf(struct sock *sk) { + x25_cb *x25 = X25_SK(sk); + if (atomic_read(&sk->rmem_alloc) < (sk->rcvbuf / 2) && - (sk->protinfo.x25->condition & X25_COND_OWN_RX_BUSY)) { - sk->protinfo.x25->condition &= ~X25_COND_OWN_RX_BUSY; - sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING; - sk->protinfo.x25->vl = sk->protinfo.x25->vr; + (x25->condition & X25_COND_OWN_RX_BUSY)) { + x25->condition &= ~X25_COND_OWN_RX_BUSY; + x25->condition &= ~X25_COND_ACK_PENDING; + x25->vl = x25->vr; x25_write_internal(sk, X25_RR); x25_stop_timer(sk); } diff -uNr linux-2.5.1/net/x25/x25_timer.c linux-2.5.1.acme/net/x25/x25_timer.c --- linux-2.5.1/net/x25/x25_timer.c Wed Jan 24 21:28:36 2001 +++ linux-2.5.1.acme/net/x25/x25_timer.c Wed Dec 19 23:44:48 2001 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -60,59 +61,67 @@ void x25_start_t2timer(struct sock *sk) { - del_timer(&sk->protinfo.x25->timer); + x25_cb *x25 = X25_SK(sk); - sk->protinfo.x25->timer.data = (unsigned long)sk; - sk->protinfo.x25->timer.function = &x25_timer_expiry; - sk->protinfo.x25->timer.expires = jiffies + sk->protinfo.x25->t2; + del_timer(&x25->timer); - add_timer(&sk->protinfo.x25->timer); + x25->timer.data = (unsigned long)sk; + x25->timer.function = &x25_timer_expiry; + x25->timer.expires = jiffies + x25->t2; + + add_timer(&x25->timer); } void x25_start_t21timer(struct sock *sk) { - del_timer(&sk->protinfo.x25->timer); + x25_cb *x25 = X25_SK(sk); + + del_timer(&x25->timer); - sk->protinfo.x25->timer.data = (unsigned long)sk; - sk->protinfo.x25->timer.function = &x25_timer_expiry; - sk->protinfo.x25->timer.expires = jiffies + sk->protinfo.x25->t21; + x25->timer.data = (unsigned long)sk; + x25->timer.function = &x25_timer_expiry; + x25->timer.expires = jiffies + x25->t21; - add_timer(&sk->protinfo.x25->timer); + add_timer(&x25->timer); } void x25_start_t22timer(struct sock *sk) { - del_timer(&sk->protinfo.x25->timer); + x25_cb *x25 = X25_SK(sk); + + del_timer(&x25->timer); - sk->protinfo.x25->timer.data = (unsigned long)sk; - sk->protinfo.x25->timer.function = &x25_timer_expiry; - sk->protinfo.x25->timer.expires = jiffies + sk->protinfo.x25->t22; + x25->timer.data = (unsigned long)sk; + x25->timer.function = &x25_timer_expiry; + x25->timer.expires = jiffies + x25->t22; - add_timer(&sk->protinfo.x25->timer); + add_timer(&x25->timer); } void x25_start_t23timer(struct sock *sk) { - del_timer(&sk->protinfo.x25->timer); + x25_cb *x25 = X25_SK(sk); - sk->protinfo.x25->timer.data = (unsigned long)sk; - sk->protinfo.x25->timer.function = &x25_timer_expiry; - sk->protinfo.x25->timer.expires = jiffies + sk->protinfo.x25->t23; + del_timer(&x25->timer); - add_timer(&sk->protinfo.x25->timer); + x25->timer.data = (unsigned long)sk; + x25->timer.function = &x25_timer_expiry; + x25->timer.expires = jiffies + x25->t23; + + add_timer(&x25->timer); } void x25_stop_timer(struct sock *sk) { - del_timer(&sk->protinfo.x25->timer); + del_timer(&X25_SK(sk)->timer); } unsigned long x25_display_timer(struct sock *sk) { - if (!timer_pending(&sk->protinfo.x25->timer)) + if (!timer_pending(&X25_SK(sk)->timer)) return 0; - return sk->protinfo.x25->timer.expires - jiffies; + return X25_SK(sk)->timer.expires - jiffies; } static void x25_heartbeat_expiry(unsigned long param) @@ -124,7 +133,7 @@ goto restart_heartbeat; } - switch (sk->protinfo.x25->state) { + switch (X25_SK(sk)->state) { case X25_STATE_0: /* Magic here: If we listen() and a new link dies before it @@ -154,11 +163,13 @@ */ static inline void x25_do_timer_expiry(struct sock * sk) { - switch (sk->protinfo.x25->state) { + x25_cb *x25 = X25_SK(sk); + + switch (x25->state) { case X25_STATE_3: /* T2 */ - if (sk->protinfo.x25->condition & X25_COND_ACK_PENDING) { - sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING; + if (x25->condition & X25_COND_ACK_PENDING) { + x25->condition &= ~X25_COND_ACK_PENDING; x25_enquiry_response(sk); } break; @@ -166,7 +177,7 @@ case X25_STATE_1: /* T21 */ case X25_STATE_4: /* T22 */ x25_write_internal(sk, X25_CLEAR_REQUEST); - sk->protinfo.x25->state = X25_STATE_2; + x25->state = X25_STATE_2; x25_start_t23timer(sk); break; @@ -182,7 +193,7 @@ bh_lock_sock(sk); if (sk->lock.users) { /* can currently only occur in state 3 */ - if (sk->protinfo.x25->state == X25_STATE_3) { + if (X25_SK(sk)->state == X25_STATE_3) { x25_start_t2timer(sk); } } else {