Commit e210f5c4 authored by David S. Miller's avatar David S. Miller

Split protocol specific information out from struct sock.

Work done by Arnaldo Carvalho de Melo.
parent 2672019f
......@@ -1042,9 +1042,10 @@ P: James Morris
M: jamesm@intercode.com.au
P: Harald Welte
M: laforge@gnumonks.org
W: http://netfilter.samba.org
W: http://netfilter.kernelnotes.org
W: http://netfilter.filewatcher.org
P: Jozsef Kadlecsik
M: kadlec@blackhole.kfki.hu
W: http://www.netfilter.org/
W: http://www.iptables.org/
L: netfilter@lists.samba.org
S: Supported
......
......@@ -7,6 +7,7 @@
*
* Version: 0.6.9
*
* 220102 : Fix module use count on failure in pppoe_create, pppox_sk -acme
* 030700 : Fixed connect logic to allow for disconnect.
* 270700 : Fixed potential SMP problems; we must protect against
* simultaneous invocation of ppp_input
......@@ -34,7 +35,7 @@
*
* Author: Michal Ostrowski <mostrows@speakeasy.net>
* Contributors:
* Arnaldo Carvalho de Melo <acme@xconectiva.com.br>
* Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* David S. Miller (davem@redhat.com)
*
* License:
......@@ -127,7 +128,8 @@ static int hash_item(unsigned long sid, unsigned char *addr)
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 +342,7 @@ static struct notifier_block pppoe_notifier = {
***********************************************************************/
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 +470,10 @@ struct packet_type pppoed_ptype = {
**********************************************************************/
void pppoe_sock_destruct(struct sock *sk)
{
if (sk->protinfo.destruct_hook)
kfree(sk->protinfo.destruct_hook);
struct pppox_opt *po = pppox_sk(sk);
if (po)
kfree(po);
MOD_DEC_USE_COUNT;
}
......@@ -481,14 +485,15 @@ void pppoe_sock_destruct(struct sock *sk)
**********************************************************************/
static int pppoe_create(struct socket *sock)
{
int error = 0;
int error = -ENOMEM;
struct sock *sk;
struct pppox_opt *po;
MOD_INC_USE_COUNT;
sk = sk_alloc(PF_PPPOX, GFP_KERNEL, 1);
sk = sk_alloc(PF_PPPOX, GFP_KERNEL, 1, NULL);
if (!sk)
return -ENOMEM;
goto decmod;
sock_init_data(sock, sk);
......@@ -505,24 +510,17 @@ static int pppoe_create(struct socket *sock)
sk->type = SOCK_STREAM;
sk->destruct = pppoe_sock_destruct;
sk->protinfo.pppox = kmalloc(sizeof(struct pppox_opt), GFP_KERNEL);
if (!sk->protinfo.pppox) {
error = -ENOMEM;
goto free_sk;
}
memset((void *) sk->protinfo.pppox, 0, sizeof(struct pppox_opt));
sk->protinfo.pppox->sk = sk;
/* Delete the protinfo when it is time to do so. */
sk->protinfo.destruct_hook = sk->protinfo.pppox;
po = pppox_sk(sk) = kmalloc(sizeof(*po), GFP_KERNEL);
if (!po)
goto frees;
memset(po, 0, sizeof(*po));
po->sk = sk;
error = 0;
sock->sk = sk;
return 0;
free_sk:
sk_free(sk);
return error;
out: return error;
frees: sk_free(sk);
decmod: MOD_DEC_USE_COUNT;
goto out;
}
int pppoe_release(struct socket *sock)
......@@ -542,7 +540,7 @@ int pppoe_release(struct socket *sock)
/* 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 +566,7 @@ int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr,
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 +655,7 @@ int pppoe_getname(struct socket *sock, struct sockaddr *uaddr,
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 +670,10 @@ int pppoe_ioctl(struct socket *sock, unsigned int cmd,
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;
......@@ -776,6 +773,7 @@ int pppoe_sendmsg(struct socket *sock, struct msghdr *m,
{
struct sk_buff *skb = NULL;
struct sock *sk = sock->sk;
struct pppox_opt *po = pppox_sk(sk);
int error = 0;
struct pppoe_hdr hdr;
struct pppoe_hdr *ph;
......@@ -794,7 +792,7 @@ int pppoe_sendmsg(struct socket *sock, struct msghdr *m,
lock_sock(sk);
dev = sk->protinfo.pppox->pppoe_dev;
dev = po->pppoe_dev;
error = -EMSGSIZE;
if (total_len > (dev->mtu + dev->hard_header_len))
......@@ -829,8 +827,7 @@ int pppoe_sendmsg(struct socket *sock, struct msghdr *m,
error = total_len;
dev->hard_header(skb, dev, ETH_P_PPP_SES,
sk->protinfo.pppox->pppoe_pa.remote,
NULL, total_len);
po->pppoe_pa.remote, NULL, total_len);
memcpy(ph, &hdr, sizeof(struct pppoe_hdr));
......@@ -851,7 +848,8 @@ int pppoe_sendmsg(struct socket *sock, struct msghdr *m,
***********************************************************************/
int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)
{
struct net_device *dev = sk->protinfo.pppox->pppoe_dev;
struct pppox_opt *po = pppox_sk(sk);
struct net_device *dev = po->pppoe_dev;
struct pppoe_hdr hdr;
struct pppoe_hdr *ph;
int headroom = skb_headroom(skb);
......@@ -897,8 +895,7 @@ int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)
skb2->dev = dev;
dev->hard_header(skb2, dev, ETH_P_PPP_SES,
sk->protinfo.pppox->pppoe_pa.remote,
NULL, data_len);
po->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
......
......@@ -68,7 +68,7 @@ void pppox_unbind_sock(struct sock *sk)
/* 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,11 +81,9 @@ static int pppox_ioctl(struct socket* sock, unsigned int cmd,
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);
switch (cmd) {
......
......@@ -176,5 +176,7 @@ extern void aarp_device_down(struct net_device *dev);
extern void aarp_cleanup_module(void);
#endif /* MODULE */
#define at_sk(__sk) ((struct atalk_sock *)(__sk)->protinfo)
#endif /* __KERNEL__ */
#endif /* __LINUX_ATALK_H__ */
......@@ -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 \
......
......@@ -55,6 +55,8 @@ struct econet_opt
unsigned char net;
};
#define ec_sk(__sk) ((struct econet_opt *)(__sk)->protinfo)
struct ec_device
{
unsigned char station, net; /* Econet protocol address */
......
......@@ -113,6 +113,26 @@ struct pppoe_hdr {
} __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);
......
......@@ -123,6 +123,9 @@ struct wanpipe_opt
unsigned char force; /* Used to force sock release */
atomic_t packet_sent;
};
#define wp_sk(__sk) ((struct wanpipe_opt *)(__sk)->protinfo)
#endif
#endif
......@@ -76,6 +76,8 @@ struct igmphdr
*/
#ifdef __KERNEL__
#include <linux/skbuff.h>
#include <linux/in.h>
/* ip_mc_socklist is real list now. Speed is not argument;
this list never used in fast path code
......
......@@ -89,6 +89,9 @@
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
#ifdef __KERNEL__
#include <linux/types.h>
#include <net/sock.h>
#include <linux/igmp.h>
struct ip_options {
__u32 faddr; /* Saved first hop address */
......@@ -111,6 +114,37 @@ struct ip_options {
};
#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 */
};
struct ipv6_pinfo;
/* WARNING: don't change the layout of the members in inet_sock! */
struct inet_sock {
struct sock sk;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
struct ipv6_pinfo *pinet6;
#endif
struct inet_opt inet;
};
#define inet_sk(__sk) (&((struct inet_sock *)__sk)->inet)
#endif
struct iphdr {
......
......@@ -101,6 +101,10 @@ struct ipv6hdr {
};
#ifdef __KERNEL__
#include <linux/in6.h> /* struct sockaddr_in6 */
#include <linux/icmpv6.h>
#include <net/if_inet6.h> /* struct ipv6_mc_socklist */
#include <linux/tcp.h>
/*
This structure contains results of exthdrs parsing
......@@ -118,6 +122,79 @@ struct inet6_skb_parm
__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;
};
/* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
struct raw6_sock {
struct sock sk;
struct ipv6_pinfo *pinet6;
struct inet_opt inet;
struct raw6_opt raw6;
struct ipv6_pinfo inet6;
};
struct udp6_sock {
struct sock sk;
struct ipv6_pinfo *pinet6;
struct inet_opt inet;
struct ipv6_pinfo inet6;
};
struct tcp6_sock {
struct sock sk;
struct ipv6_pinfo *pinet6;
struct inet_opt inet;
struct tcp_opt tcp;
struct ipv6_pinfo inet6;
};
#define inet6_sk(__sk) ((struct raw6_sock *)__sk)->pinet6
#define raw6_sk(__sk) (&((struct raw6_sock *)__sk)->raw6)
#endif
#endif
......@@ -17,8 +17,10 @@
#ifndef _LINUX_TCP_H
#define _LINUX_TCP_H
#include <linux/types.h>
#include <linux/skbuff.h>
#include <asm/byteorder.h>
#include <net/sock.h>
#include <linux/ip.h>
struct tcphdr {
__u16 source;
......@@ -185,4 +187,197 @@ struct tcp_info
__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;
};
/* WARNING: don't change the layout of the members in tcp_sock! */
struct tcp_sock {
struct sock sk;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
struct ipv6_pinfo *pinet6;
#endif
struct inet_opt inet;
struct tcp_opt tcp;
};
#define tcp_sk(__sk) (&((struct tcp_sock *)__sk)->tcp)
#endif /* _LINUX_TCP_H */
......@@ -34,9 +34,27 @@ struct unix_skb_parms
#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 socket */
struct unix_sock {
/* WARNING: sk has to be the first member */
struct sock sk;
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_sock *)__sk)
#endif
#endif
......@@ -194,6 +194,8 @@ typedef struct ax25_cb {
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 *);
......
......@@ -29,6 +29,7 @@
#include <asm/types.h>
#include <asm/byteorder.h>
#include <net/ip.h>
#include <linux/in6.h>
#include <asm/uaccess.h>
#include <asm/checksum.h>
......
......@@ -9,8 +9,6 @@ typedef unsigned short dn_address;
#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;
......@@ -135,6 +133,8 @@ struct dn_scp /* Session Control Port */
};
#define DN_SK(__sk) ((struct dn_scp *)(__sk)->protinfo)
/*
* src,dst : Source and Destination DECnet addresses
* hops : Number of hops through the network
......
......@@ -150,7 +150,7 @@ struct srcobj_fmt
* 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 before(unsigned short seq1, unsigned short seq2)
}
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 @@ static __inline__ int after(unsigned short seq1, unsigned short seq2)
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__ void seq_add(unsigned short *seq, unsigned short off)
static __inline__ int seq_next(unsigned short seq1, unsigned short seq2)
{
return equal(seq1 + 1, seq2);
return dn_equal(seq1 + 1, seq2);
}
/*
......
......@@ -113,7 +113,7 @@ static inline void dn_rt_finish_output(struct sk_buff *skb, char *dst)
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;
......
......@@ -23,6 +23,7 @@
#include <net/sock.h>
#include <net/protocol.h>
#include <linux/ip.h>
struct icmp_err {
int errno;
......@@ -43,4 +44,22 @@ extern void icmp_init(struct net_proto_family *ops);
/* Move into dst.h ? */
extern int xrlim_allow(struct dst_entry *dst, int timeout);
struct raw_opt {
struct icmp_filter filter;
};
struct ipv6_pinfo;
/* WARNING: don't change the layout of the members in raw_sock! */
struct raw_sock {
struct sock sk;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
struct ipv6_pinfo *pinet6;
#endif
struct inet_opt inet;
struct raw_opt raw4;
};
#define raw4_sk(__sk) (&((struct raw_sock *)__sk)->raw4)
#endif /* _ICMP_H */
......@@ -24,15 +24,15 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
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 { inet_sk(sk)->tos |= 2; } while (0)
#define INET_ECN_dontxmit(sk) do { inet_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(inet_sk(sk)->tos)) \
(label) |= __constant_htons(2 << 4); \
} while (0)
......
......@@ -26,6 +26,7 @@
#include <linux/types.h>
#include <linux/socket.h>
#include <linux/ip.h>
#include <linux/in.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/in_route.h>
......@@ -181,8 +182,8 @@ int ip_decrease_ttl(struct iphdr *iph)
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 (inet_sk(sk)->pmtudisc == IP_PMTUDISC_DO ||
(inet_sk(sk)->pmtudisc == IP_PMTUDISC_WANT &&
!(dst->mxlock&(1<<RTAX_MTU))));
}
......@@ -196,7 +197,7 @@ static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, str
* does not change, they drop every other packet in
* a TCP stream using header compression.
*/
iph->id = ((sk && sk->daddr) ? htons(sk->protinfo.af_inet.id++) : 0);
iph->id = (sk && sk->daddr) ? htons(inet_sk(sk)->id++) : 0;
} else
__ip_select_ident(iph, dst);
}
......
......@@ -11,6 +11,8 @@
#include <net/flow.h>
#include <net/ip6_fib.h>
#include <linux/tcp.h>
#include <linux/ip.h>
struct pol_chain {
int type;
......@@ -97,7 +99,7 @@ extern rwlock_t rt6_lock;
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 = inet6_sk(sk);
struct rt6_info *rt = (struct rt6_info *) dst;
write_lock(&sk->dst_lock);
......
......@@ -86,6 +86,22 @@ struct ipx_cb {
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
......
......@@ -168,6 +168,8 @@ struct irda_sock {
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
......
......@@ -74,6 +74,8 @@ typedef struct {
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;
......
......@@ -138,6 +138,8 @@ typedef struct {
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;
......
......@@ -43,7 +43,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(inet_sk(sk)->tos) | sk->localroute)
struct rt_key
{
......
This diff is collapsed.
......@@ -48,6 +48,8 @@ struct spx_opt
struct sk_buff_head retransmit_queue;
};
#define spx_sk(__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 ??) */
......
......@@ -29,6 +29,9 @@
#include <linux/slab.h>
#include <net/checksum.h>
#include <net/sock.h>
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
#include <linux/ipv6.h>
#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
......@@ -134,6 +137,9 @@ extern struct tcp_hashinfo {
#define tcp_lhash_wait (tcp_hashinfo.__tcp_lhash_wait)
#define tcp_portalloc_lock (tcp_hashinfo.__tcp_portalloc_lock)
/* SLAB cache for TCP socks */
extern kmem_cache_t *tcp_sk_cachep;
extern kmem_cache_t *tcp_bucket_cachep;
extern struct tcp_bind_bucket *tcp_bucket_create(struct tcp_bind_hashbucket *head,
unsigned short snum);
......@@ -242,11 +248,11 @@ extern void tcp_tw_deschedule(struct tcp_tw_bucket *tw);
(!((__sk)->bound_dev_if) || ((__sk)->bound_dev_if == (__dif))))
#endif /* 64-bit arch */
#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)) && \
#define TCP_IPV6_MATCH(__sk, __saddr, __daddr, __ports, __dif) \
(((*((__u32 *)&((__sk)->dport)))== (__ports)) && \
((__sk)->family == AF_INET6) && \
!ipv6_addr_cmp(&inet6_sk(__sk)->daddr, (__saddr)) && \
!ipv6_addr_cmp(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \
(!((__sk)->bound_dev_if) || ((__sk)->bound_dev_if == (__dif))))
/* These can have wildcards, don't try too hard. */
......@@ -824,7 +830,7 @@ extern const char timer_bug_msg[];
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_sk(sk);
switch (what) {
case TCP_TIME_RETRANS:
......@@ -859,7 +865,7 @@ static inline void tcp_clear_xmit_timer(struct sock *sk, int what)
*/
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_sk(sk);
if (when > TCP_RTO_MAX) {
#ifdef TCP_DEBUG
......@@ -895,7 +901,7 @@ static inline void tcp_reset_xmit_timer(struct sock *sk, int what, unsigned long
static __inline__ unsigned int tcp_current_mss(struct sock *sk)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
struct dst_entry *dst = __sk_dst_get(sk);
int mss_now = tp->mss_cache;
......@@ -918,7 +924,7 @@ static __inline__ unsigned int tcp_current_mss(struct sock *sk)
static inline void tcp_initialize_rcv_mss(struct sock *sk)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
unsigned int hint = min(tp->advmss, tp->mss_cache);
hint = min(hint, tp->rcv_wnd/2);
......@@ -1321,7 +1327,7 @@ static __inline__ void tcp_prequeue_init(struct tcp_opt *tp)
*/
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_sk(sk);
if (tp->ucopy.task) {
__skb_queue_tail(&tp->ucopy.prequeue, skb);
......@@ -1572,7 +1578,7 @@ static inline int tcp_acceptq_is_full(struct sock *sk)
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_sk(sk);
req->sk = child;
tcp_acceptq_added(sk);
......@@ -1598,7 +1604,7 @@ struct tcp_listen_opt
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_sk(sk)->listen_opt;
if (--lopt->qlen == 0)
tcp_delete_keepalive_timer(sk);
......@@ -1608,7 +1614,7 @@ tcp_synq_removed(struct sock *sk, struct open_request *req)
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_sk(sk)->listen_opt;
if (lopt->qlen++ == 0)
tcp_reset_keepalive_timer(sk, TCP_TIMEOUT_INIT);
......@@ -1617,17 +1623,17 @@ static inline void tcp_synq_added(struct sock *sk)
static inline int tcp_synq_len(struct sock *sk)
{
return sk->tp_pinfo.af_tcp.listen_opt->qlen;
return tcp_sk(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_sk(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_sk(sk)->listen_opt->max_qlen_log;
}
static inline void tcp_synq_unlink(struct tcp_opt *tp, struct open_request *req,
......@@ -1641,7 +1647,7 @@ static inline void tcp_synq_unlink(struct tcp_opt *tp, struct open_request *req,
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_sk(sk), req, prev);
tcp_synq_removed(sk, req);
tcp_openreq_free(req);
}
......@@ -1667,7 +1673,7 @@ static __inline__ void tcp_openreq_init(struct open_request *req,
static inline void tcp_free_skb(struct sock *sk, struct sk_buff *skb)
{
sk->tp_pinfo.af_tcp.queue_shrunk = 1;
tcp_sk(sk)->queue_shrunk = 1;
sk->wmem_queued -= skb->truesize;
sk->forward_alloc += skb->truesize;
__kfree_skb(skb);
......
......@@ -74,4 +74,6 @@ extern struct udp_mib udp_statistics[NR_CPUS*2];
#define UDP_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_statistics, field)
#define UDP_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_statistics, field)
#define udp_sock inet_sock
#endif /* _UDP_H */
......@@ -139,6 +139,8 @@ typedef struct {
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;
......
This diff is collapsed.
......@@ -105,7 +105,7 @@ int atm_create(struct socket *sock,int protocol,int family)
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;
......@@ -133,10 +133,9 @@ int atm_create(struct socket *sock,int protocol,int family)
void atm_release_vcc_sk(struct sock *sk,int free_sk)
{
struct atm_vcc *vcc;
struct atm_vcc *vcc = atm_sk(sk);
struct sk_buff *skb;
vcc = sk->protinfo.af_atm;
clear_bit(ATM_VF_READY,&vcc->flags);
if (vcc->dev) {
if (vcc->dev->ops->close) vcc->dev->ops->close(vcc);
......
......@@ -13,7 +13,7 @@
#include <linux/ip.h>
#include <asm/byteorder.h>
#include <asm/uaccess.h>
#include <asm/checksum.h> /* for ip_fast_csum() */
#include <net/checksum.h> /* for ip_fast_csum() */
#include <net/arp.h>
#include <net/dst.h>
#include <linux/proc_fs.h>
......
......@@ -111,11 +111,8 @@ static int pvc_create(struct socket *sock,int protocol)
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,
};
......
......@@ -2,6 +2,11 @@
/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
/* Fixes
* Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 2002/01 - don't free the whole struct sock on sk->destruct time,
* use the default destruct function initialized by sock_init_data */
#include <linux/config.h>
#include <linux/ctype.h>
......@@ -138,28 +143,19 @@ void shutdown_atm_dev(struct atm_dev *dev)
atm_dev_deregister(dev);
}
/* Handler for sk->destruct, invoked by sk_free() */
static void atm_free_sock(struct sock *sk)
{
kfree(sk->protinfo.af_atm);
}
struct sock *alloc_atm_vcc_sk(int family)
{
struct sock *sk;
struct atm_vcc *vcc;
sk = sk_alloc(family, GFP_KERNEL, 1);
sk = sk_alloc(family, GFP_KERNEL, 1, NULL);
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;
}
sock_init_data(NULL,sk);
sk->destruct = atm_free_sock;
memset(vcc,0,sizeof(*vcc));
vcc->sk = sk;
if (nodev_vccs) nodev_vccs->prev = vcc;
......@@ -185,7 +181,7 @@ static void unlink_vcc(struct atm_vcc *vcc,struct atm_dev *hold_dev)
void free_atm_vcc_sk(struct sock *sk)
{
unlink_vcc(sk->protinfo.af_atm,NULL);
unlink_vcc(atm_sk(sk), NULL);
sk_free(sk);
}
......
......@@ -430,11 +430,8 @@ static int svc_create(struct socket *sock,int protocol)
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,
};
......
This diff is collapsed.
......@@ -38,6 +38,7 @@
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/ip.h> /* For ip_rcv */
#include <net/tcp.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <linux/fcntl.h>
......
......@@ -25,6 +25,7 @@
#include <linux/string.h>
#include <linux/sockios.h>
#include <linux/net.h>
#include <net/tcp.h>
#include <net/ax25.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
......
......@@ -57,6 +57,7 @@
#include <linux/netfilter.h>
#include <net/sock.h>
#include <net/ip.h> /* For ip_rcv */
#include <net/tcp.h>
#include <net/arp.h> /* For arp_rcv */
#include <asm/uaccess.h>
#include <asm/system.h>
......@@ -388,7 +389,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev, ax25_address *d
return 0;
}
ax25 = make->protinfo.ax25;
ax25 = ax25_sk(make);
skb_set_owner_r(skb, make);
skb_queue_head(&sk->receive_queue, skb);
......
......@@ -53,6 +53,7 @@
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/ip.h> /* For ip_rcv */
#include <net/tcp.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <linux/fcntl.h>
......
......@@ -37,6 +37,7 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/tcp.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <linux/fcntl.h>
......
......@@ -48,6 +48,7 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/tcp.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <linux/fcntl.h>
......
......@@ -122,9 +122,9 @@ void bluez_sock_unlink(struct bluez_sock_list *l, struct sock *sk)
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)
......
......@@ -453,7 +453,7 @@ static int hci_sock_create(struct socket *sock, int protocol)
sock->ops = &hci_sock_ops;
if (!(sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, 1)))
if (!(sk = sk_alloc(PF_BLUETOOTH, GFP_KERNEL, 1, NULL)))
return -ENOMEM;
sock->state = SS_UNCONNECTED;
......@@ -519,7 +519,7 @@ static int hci_sock_dev_event(struct notifier_block *this, unsigned long event,
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 = {
......
......@@ -640,7 +640,7 @@ static struct sock *l2cap_sock_alloc(struct socket *sock, int proto, int prio)
{
struct sock *sk;
if (!(sk = sk_alloc(PF_BLUETOOTH, prio, 1)))
if (!(sk = sk_alloc(PF_BLUETOOTH, prio, 1, NULL)))
return NULL;
sock_init_data(sock, sk);
......@@ -2238,7 +2238,7 @@ struct proto_ops l2cap_sock_ops = {
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 = {
......
......@@ -33,6 +33,7 @@
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/inet.h>
#include <linux/tcp.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
#include <linux/poll.h>
......
......@@ -7,7 +7,7 @@
* handler for protocols to use and generic option handler.
*
*
* Version: $Id: sock.c,v 1.116 2001/11/08 04:20:06 davem Exp $
* Version: $Id: sock.c,v 1.117 2002/02/01 22:01:03 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
......@@ -574,19 +574,33 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
static kmem_cache_t *sk_cachep;
/*
* All socket objects are allocated here. This is for future
* usage.
/**
* sk_alloc - All socket objects are allocated here
* @family - protocol family
* @priority - for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc)
* @zero_it - zeroes the allocated sock
* @slab - alternate slab
*
* All socket objects are allocated here. If @zero_it is non-zero
* it should have the size of the are to be zeroed, because the
* private slabcaches have different sizes of the generic struct sock.
* 1 has been kept as a way to say sizeof(struct sock).
*/
struct sock *sk_alloc(int family, int priority, int zero_it)
struct sock *sk_alloc(int family, int priority, int zero_it, kmem_cache_t *slab)
{
struct sock *sk = kmem_cache_alloc(sk_cachep, priority);
if(sk && zero_it) {
memset(sk, 0, sizeof(struct sock));
sk->family = family;
sock_lock_init(sk);
struct sock *sk;
if (!slab)
slab = sk_cachep;
sk = kmem_cache_alloc(slab, priority);
if (sk) {
if (zero_it) {
memset(sk, 0,
zero_it == 1 ? sizeof(struct sock) : zero_it);
sk->family = family;
sock_lock_init(sk);
}
sk->slab = slab;
}
return sk;
......@@ -612,7 +626,7 @@ void sk_free(struct sock *sk)
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(sk->slab, sk);
}
void __init sk_init(void)
......@@ -1160,8 +1174,8 @@ void sock_def_write_space(struct sock *sk)
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)
......
......@@ -113,6 +113,7 @@ Version 0.0.6 2.1.110 07-aug-98 Eduardo Marcelo Serrat
#include <linux/route.h>
#include <linux/netfilter.h>
#include <net/sock.h>
#include <net/tcp.h>
#include <asm/system.h>
#include <asm/ioctls.h>
#include <linux/mm.h>
......@@ -472,14 +473,17 @@ struct sock *dn_alloc_sock(struct socket *sock, int gfp)
struct sock *sk;
struct dn_scp *scp;
if ((sk = sk_alloc(PF_DECnet, gfp, 1)) == NULL)
if ((sk = sk_alloc(PF_DECnet, gfp, 1, NULL)) == 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;
......@@ -540,6 +544,8 @@ struct sock *dn_alloc_sock(struct socket *sock, int gfp)
MOD_INC_USE_COUNT;
return sk;
free_sock:
sk_free(sk);
no_sock:
return NULL;
}
......
......@@ -59,6 +59,7 @@
#include <linux/inet.h>
#include <linux/route.h>
#include <net/sock.h>
#include <net/tcp.h>
#include <asm/system.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
......@@ -71,6 +72,7 @@
#include <linux/netfilter_decnet.h>
#include <net/neighbour.h>
#include <net/dst.h>
#include <net/dn.h>
#include <net/dn_nsp.h>
#include <net/dn_dev.h>
#include <net/dn_route.h>
......@@ -99,7 +101,7 @@ static void dn_ack(struct sock *sk, struct sk_buff *skb, unsigned short ack)
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);
}
......@@ -107,7 +109,7 @@ static void dn_ack(struct sock *sk, struct sk_buff *skb, unsigned short ack)
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);
}
......
......@@ -63,6 +63,7 @@
#include <linux/if_packet.h>
#include <net/neighbour.h>
#include <net/dst.h>
#include <net/dn.h>
#include <net/dn_nsp.h>
#include <net/dn_dev.h>
#include <net/dn_route.h>
......@@ -401,7 +402,7 @@ int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff
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); */
......@@ -438,7 +439,7 @@ int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff
* 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)
......
......@@ -167,6 +167,7 @@ static int econet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len
{
struct sockaddr_ec *sec = (struct sockaddr_ec *)uaddr;
struct sock *sk=sock->sk;
struct econet_opt *eo = ec_sk(sk);
/*
* Check legality
......@@ -176,10 +177,10 @@ static int econet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len
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;
eo->cb = sec->cb;
eo->port = sec->port;
eo->station = sec->addr.station;
eo->net = sec->addr.net;
return 0;
}
......@@ -265,10 +266,12 @@ static int econet_sendmsg(struct socket *sock, struct msghdr *msg, int len,
*/
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;
struct econet_opt *eo = ec_sk(sk);
addr.station = eo->station;
addr.net = eo->net;
port = eo->port;
cb = eo->cb;
} else {
if (msg->msg_namelen < sizeof(struct sockaddr_ec))
return -EINVAL;
......@@ -449,15 +452,16 @@ static int econet_getname(struct socket *sock, struct sockaddr *uaddr,
int *uaddr_len, int peer)
{
struct sock *sk = sock->sk;
struct econet_opt *eo = ec_sk(sk);
struct sockaddr_ec *sec = (struct sockaddr_ec *)uaddr;
if (peer)
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->sec_family = AF_ECONET;
sec->port = eo->port;
sec->addr.station = eo->station;
sec->addr.net = eo->net;
*uaddr_len = sizeof(*sec);
return 0;
......@@ -525,6 +529,7 @@ static int econet_release(struct socket *sock)
static int econet_create(struct socket *sock, int protocol)
{
struct sock *sk;
struct econet_opt *eo;
int err;
/* Econet only provides datagram services. */
......@@ -535,7 +540,7 @@ static int econet_create(struct socket *sock, int protocol)
MOD_INC_USE_COUNT;
err = -ENOBUFS;
sk = sk_alloc(PF_ECONET, GFP_KERNEL, 1);
sk = sk_alloc(PF_ECONET, GFP_KERNEL, 1, NULL);
if (sk == NULL)
goto out;
......@@ -543,10 +548,10 @@ static int econet_create(struct socket *sock, int protocol)
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)
eo = ec_sk(sk) = kmalloc(sizeof(*eo), GFP_KERNEL);
if (!eo)
goto out_free;
memset(sk->protinfo.af_econet, 0, sizeof(struct econet_opt));
memset(eo, 0, sizeof(*eo));
sk->zapped=0;
sk->family = PF_ECONET;
sk->num = protocol;
......@@ -731,7 +736,7 @@ static struct sock *ec_listening_socket(unsigned char port, unsigned char
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))
......
......@@ -5,7 +5,7 @@
*
* PF_INET protocol family socket handler.
*
* Version: $Id: af_inet.c,v 1.136 2001/11/06 22:21:08 davem Exp $
* Version: $Id: af_inet.c,v 1.137 2002/02/01 22:01:03 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
......@@ -147,6 +147,11 @@ int (*br_ioctl_hook)(unsigned long);
int (*vlan_ioctl_hook)(unsigned long arg);
#endif
/* Per protocol sock slabcache */
kmem_cache_t *tcp_sk_cachep;
static kmem_cache_t *udp_sk_cachep;
static kmem_cache_t *raw4_sk_cachep;
/* The inetsw table contains everything that inet_create needs to
* build a new socket.
*/
......@@ -156,6 +161,8 @@ struct list_head inetsw[SOCK_MAX];
void inet_sock_destruct(struct sock *sk)
{
struct inet_opt *inet = inet_sk(sk);
__skb_queue_purge(&sk->receive_queue);
__skb_queue_purge(&sk->error_queue);
......@@ -175,8 +182,8 @@ void inet_sock_destruct(struct sock *sk)
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 (inet->opt)
kfree(inet->opt);
dst_release(sk->dst_cache);
#ifdef INET_REFCNT_DEBUG
atomic_dec(&inet_sock_nr);
......@@ -312,6 +319,28 @@ int inet_listen(struct socket *sock, int backlog)
return err;
}
static __inline__ kmem_cache_t *inet_sk_slab(int protocol)
{
kmem_cache_t* rc = tcp_sk_cachep;
if (protocol == IPPROTO_UDP)
rc = udp_sk_cachep;
else if (protocol == IPPROTO_RAW)
rc = raw4_sk_cachep;
return rc;
}
static __inline__ int inet_sk_size(int protocol)
{
int rc = sizeof(struct tcp_sock);
if (protocol == IPPROTO_UDP)
rc = sizeof(struct udp_sock);
else if (protocol == IPPROTO_RAW)
rc = sizeof(struct raw_sock);
return rc;
}
/*
* Create an inet socket.
*/
......@@ -321,9 +350,11 @@ static int inet_create(struct socket *sock, int protocol)
struct sock *sk;
struct list_head *p;
struct inet_protosw *answer;
struct inet_opt *inet;
sock->state = SS_UNCONNECTED;
sk = sk_alloc(PF_INET, GFP_KERNEL, 1);
sk = sk_alloc(PF_INET, GFP_KERNEL, inet_sk_size(protocol),
inet_sk_slab(protocol));
if (sk == NULL)
goto do_oom;
......@@ -363,18 +394,20 @@ static int inet_create(struct socket *sock, int protocol)
if (INET_PROTOSW_REUSE & answer->flags)
sk->reuse = 1;
inet = inet_sk(sk);
if (SOCK_RAW == sock->type) {
sk->num = protocol;
if (IPPROTO_RAW == protocol)
sk->protinfo.af_inet.hdrincl = 1;
inet->hdrincl = 1;
}
if (ipv4_config.no_pmtu_disc)
sk->protinfo.af_inet.pmtudisc = IP_PMTUDISC_DONT;
inet->pmtudisc = IP_PMTUDISC_DONT;
else
sk->protinfo.af_inet.pmtudisc = IP_PMTUDISC_WANT;
inet->pmtudisc = IP_PMTUDISC_WANT;
sk->protinfo.af_inet.id = 0;
inet->id = 0;
sock_init_data(sock,sk);
......@@ -386,12 +419,12 @@ static int inet_create(struct socket *sock, int protocol)
sk->backlog_rcv = sk->prot->backlog_rcv;
sk->protinfo.af_inet.ttl = sysctl_ip_default_ttl;
inet->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;
inet->mc_loop = 1;
inet->mc_ttl = 1;
inet->mc_index = 0;
inet->mc_list = NULL;
#ifdef INET_REFCNT_DEBUG
atomic_inc(&inet_sock_nr);
......@@ -474,6 +507,7 @@ static int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sockaddr_in *addr=(struct sockaddr_in *)uaddr;
struct sock *sk=sock->sk;
struct inet_opt *inet = inet_sk(sk);
unsigned short snum;
int chk_addr_ret;
int err;
......@@ -495,7 +529,7 @@ static int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
* is temporarily down)
*/
if (sysctl_ip_nonlocal_bind == 0 &&
sk->protinfo.af_inet.freebind == 0 &&
inet->freebind == 0 &&
addr->sin_addr.s_addr != INADDR_ANY &&
chk_addr_ret != RTN_LOCAL &&
chk_addr_ret != RTN_MULTICAST &&
......@@ -992,8 +1026,8 @@ struct proto_ops inet_dgram_ops = {
};
struct net_proto_family inet_family_ops = {
family: PF_INET,
create: inet_create
family: PF_INET,
create: inet_create,
};
......@@ -1120,6 +1154,18 @@ static int __init inet_init(void)
return -EINVAL;
}
tcp_sk_cachep = kmem_cache_create("tcp_sock",
sizeof(struct tcp_sock), 0,
SLAB_HWCACHE_ALIGN, 0, 0);
udp_sk_cachep = kmem_cache_create("udp_sock",
sizeof(struct udp_sock), 0,
SLAB_HWCACHE_ALIGN, 0, 0);
raw4_sk_cachep = kmem_cache_create("raw4_sock",
sizeof(struct raw_sock), 0,
SLAB_HWCACHE_ALIGN, 0, 0);
if (!tcp_sk_cachep || !udp_sk_cachep || !raw4_sk_cachep)
printk(KERN_CRIT __FUNCTION__
": Can't create protocol sock SLAB caches!\n");
/*
* Tell SOCKET that we are alive...
*/
......
......@@ -3,7 +3,7 @@
*
* Alan Cox, <alan@redhat.com>
*
* Version: $Id: icmp.c,v 1.83 2001/12/13 09:00:19 davem Exp $
* Version: $Id: icmp.c,v 1.85 2002/02/01 22:01:03 davem Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -338,6 +338,7 @@ static int icmp_glue_bits(const void *p, char *to, unsigned int offset, unsigned
static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
{
struct sock *sk=icmp_socket->sk;
struct inet_opt *inet = inet_sk(sk);
struct ipcm_cookie ipc;
struct rtable *rt = (struct rtable*)skb->dst;
u32 daddr;
......@@ -352,7 +353,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
icmp_param->csum=0;
icmp_out_count(icmp_param->data.icmph.type);
sk->protinfo.af_inet.tos = skb->nh.iph->tos;
inet->tos = skb->nh.iph->tos;
daddr = ipc.addr = rt->rt_src;
ipc.opt = NULL;
if (icmp_param->replyopts.optlen) {
......@@ -496,7 +497,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, u32 info)
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;
inet_sk(icmp_socket->sk)->tos = tos;
ipc.addr = iph->saddr;
ipc.opt = &icmp_param.replyopts;
if (icmp_param.replyopts.srr) {
......@@ -978,14 +979,16 @@ static struct icmp_control icmp_pointers[NR_ICMP_TYPES+1] = {
void __init icmp_init(struct net_proto_family *ops)
{
struct inet_opt *inet;
int err = sock_create(PF_INET, SOCK_RAW, IPPROTO_ICMP, &icmp_socket);
if (err < 0)
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;
inet = inet_sk(icmp_socket->sk);
inet->ttl = MAXTTL;
inet->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
......
......@@ -8,7 +8,7 @@
* the older version didn't come out right using gcc 2.5.8, the newer one
* seems to fall out with gcc 2.6.2.
*
* Version: $Id: igmp.c,v 1.46 2001/07/27 09:27:29 davem Exp $
* Version: $Id: igmp.c,v 1.47 2002/02/01 22:01:03 davem Exp $
*
* Authors:
* Alan Cox <Alan.Cox@linux.org>
......@@ -644,6 +644,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
u32 addr = imr->imr_multiaddr.s_addr;
struct ip_mc_socklist *iml, *i;
struct in_device *in_dev;
struct inet_opt *inet = inet_sk(sk);
int count = 0;
if (!MULTICAST(addr))
......@@ -668,7 +669,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
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 = inet->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 +684,9 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
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 = inet->mc_list;
iml->count = 1;
sk->protinfo.af_inet.mc_list = iml;
inet->mc_list = iml;
ip_mc_inc_group(in_dev, addr);
iml = NULL;
err = 0;
......@@ -703,10 +704,11 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
{
struct inet_opt *inet = inet_sk(sk);
struct ip_mc_socklist *iml, **imlp;
rtnl_lock();
for (imlp=&sk->protinfo.af_inet.mc_list; (iml=*imlp)!=NULL; imlp=&iml->next) {
for (imlp = &inet->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)) {
......@@ -738,15 +740,16 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
void ip_mc_drop_socket(struct sock *sk)
{
struct inet_opt *inet = inet_sk(sk);
struct ip_mc_socklist *iml;
if (sk->protinfo.af_inet.mc_list == NULL)
if (inet->mc_list == NULL)
return;
rtnl_lock();
while ((iml=sk->protinfo.af_inet.mc_list) != NULL) {
while ((iml = inet->mc_list) != NULL) {
struct in_device *in_dev;
sk->protinfo.af_inet.mc_list = iml->next;
inet->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);
......
......@@ -5,7 +5,7 @@
*
* The Internet Protocol (IP) output module.
*
* Version: $Id: ip_output.c,v 1.99 2001/10/15 12:34:50 davem Exp $
* Version: $Id: ip_output.c,v 1.100 2002/02/01 22:01:03 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
......@@ -122,6 +122,7 @@ output_maybe_reroute(struct sk_buff *skb)
int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
u32 saddr, u32 daddr, struct ip_options *opt)
{
struct inet_opt *inet = inet_sk(sk);
struct rtable *rt = (struct rtable *)skb->dst;
struct iphdr *iph;
......@@ -133,11 +134,11 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
iph->version = 4;
iph->ihl = 5;
iph->tos = sk->protinfo.af_inet.tos;
iph->tos = inet->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 = inet->ttl;
iph->daddr = rt->rt_dst;
iph->saddr = rt->rt_src;
iph->protocol = sk->protocol;
......@@ -214,7 +215,7 @@ int ip_mc_output(struct sk_buff *skb)
*/
if (rt->rt_flags&RTCF_MULTICAST) {
if ((!sk || sk->protinfo.af_inet.mc_loop)
if ((!sk || inet_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 +342,8 @@ static inline int ip_queue_xmit2(struct sk_buff *skb)
int ip_queue_xmit(struct sk_buff *skb)
{
struct sock *sk = skb->sk;
struct ip_options *opt = sk->protinfo.af_inet.opt;
struct inet_opt *inet = inet_sk(sk);
struct ip_options *opt = inet->opt;
struct rtable *rt;
struct iphdr *iph;
......@@ -381,10 +383,10 @@ int ip_queue_xmit(struct sk_buff *skb)
/* 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) | (inet->tos & 0xff));
iph->tot_len = htons(skb->len);
iph->frag_off = 0;
iph->ttl = sk->protinfo.af_inet.ttl;
iph->ttl = inet->ttl;
iph->protocol = sk->protocol;
iph->saddr = rt->rt_src;
iph->daddr = rt->rt_dst;
......@@ -436,6 +438,7 @@ static int ip_build_xmit_slow(struct sock *sk,
struct rtable *rt,
int flags)
{
struct inet_opt *inet = inet_sk(sk);
unsigned int fraglen, maxfraglen, fragheaderlen;
int err;
int offset, mf;
......@@ -499,7 +502,7 @@ static int ip_build_xmit_slow(struct sock *sk,
* Don't fragment packets for path mtu discovery.
*/
if (offset > 0 && sk->protinfo.af_inet.pmtudisc==IP_PMTUDISC_DO) {
if (offset > 0 && inet->pmtudisc == IP_PMTUDISC_DO) {
ip_local_error(sk, EMSGSIZE, rt->rt_dst, sk->dport, mtu);
return -EMSGSIZE;
}
......@@ -510,7 +513,7 @@ static int ip_build_xmit_slow(struct sock *sk,
* Begin outputting the bytes.
*/
id = sk->protinfo.af_inet.id++;
id = inet->id++;
do {
char *data;
......@@ -553,7 +556,7 @@ static int ip_build_xmit_slow(struct sock *sk,
ip_options_build(skb, opt,
ipc->addr, rt, offset);
}
iph->tos = sk->protinfo.af_inet.tos;
iph->tos = inet->tos;
iph->tot_len = htons(fraglen - fragheaderlen + iph->ihl*4);
iph->frag_off = htons(offset>>3)|mf|df;
iph->id = id;
......@@ -573,9 +576,9 @@ static int ip_build_xmit_slow(struct sock *sk,
mf = htons(IP_MF);
}
if (rt->rt_type == RTN_MULTICAST)
iph->ttl = sk->protinfo.af_inet.mc_ttl;
iph->ttl = inet->mc_ttl;
else
iph->ttl = sk->protinfo.af_inet.ttl;
iph->ttl = inet->ttl;
iph->protocol = sk->protocol;
iph->check = 0;
iph->saddr = rt->rt_src;
......@@ -603,7 +606,7 @@ static int ip_build_xmit_slow(struct sock *sk,
skb->dst->dev, output_maybe_reroute);
if (err) {
if (err > 0)
err = sk->protinfo.af_inet.recverr ? net_xmit_errno(err) : 0;
err = inet->recverr ? net_xmit_errno(err) : 0;
if (err)
goto error;
}
......@@ -635,6 +638,7 @@ int ip_build_xmit(struct sock *sk,
struct rtable *rt,
int flags)
{
struct inet_opt *inet = inet_sk(sk);
int err;
struct sk_buff *skb;
int df;
......@@ -645,7 +649,7 @@ int ip_build_xmit(struct sock *sk,
* choice RAW frames within 20 bytes of maximum size(rare) to the long path
*/
if (!sk->protinfo.af_inet.hdrincl) {
if (!inet->hdrincl) {
length += sizeof(struct iphdr);
/*
......@@ -687,16 +691,16 @@ int ip_build_xmit(struct sock *sk,
skb->nh.iph = iph = (struct iphdr *)skb_put(skb, length);
if(!sk->protinfo.af_inet.hdrincl) {
if (!inet->hdrincl) {
iph->version=4;
iph->ihl=5;
iph->tos=sk->protinfo.af_inet.tos;
iph->tos = inet->tos;
iph->tot_len = htons(length);
iph->frag_off = df;
iph->ttl=sk->protinfo.af_inet.mc_ttl;
iph->ttl = inet->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 = inet->ttl;
iph->protocol=sk->protocol;
iph->saddr=rt->rt_src;
iph->daddr=rt->rt_dst;
......@@ -713,7 +717,7 @@ int ip_build_xmit(struct sock *sk,
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 = inet->recverr ? net_xmit_errno(err) : 0;
if (err)
goto error;
out:
......@@ -943,6 +947,7 @@ static int ip_reply_glue_bits(const void *dptr, char *to, unsigned int offset,
void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *arg,
unsigned int len)
{
struct inet_opt *inet = inet_sk(sk);
struct {
struct ip_options opt;
char data[40];
......@@ -974,7 +979,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
with locally disabled BH and that sk cannot be already spinlocked.
*/
bh_lock_sock(sk);
sk->protinfo.af_inet.tos = skb->nh.iph->tos;
inet->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);
......
This diff is collapsed.
/*
* $Id: ipconfig.c,v 1.45 2002/01/08 16:00:20 davem Exp $
* $Id: ipconfig.c,v 1.46 2002/02/01 22:01:04 davem Exp $
*
* Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or
* user-supplied information to configure own IP address and routes.
......@@ -53,7 +53,7 @@
#include <net/ipconfig.h>
#include <asm/uaccess.h>
#include <asm/checksum.h>
#include <net/checksum.h>
#include <asm/processor.h>
/* Define this to allow debugging output */
......
......@@ -11,6 +11,7 @@
#include <linux/version.h>
#include <linux/config.h>
#include <linux/types.h>
#include <linux/icmp.h>
#include <linux/ip.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
......
......@@ -52,10 +52,11 @@
#include <linux/netfilter_ipv4/ip_nat_helper.h>
#include <linux/brlock.h>
#include <linux/types.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <net/udp.h>
#include <asm/uaccess.h>
#include <asm/checksum.h>
#include <net/checksum.h>
......
......@@ -9,6 +9,7 @@
#include <linux/config.h>
#include <linux/types.h>
#include <linux/icmp.h>
#include <linux/ip.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
......
......@@ -5,7 +5,7 @@
*
* RAW - implementation of IP "raw" sockets.
*
* Version: $Id: raw.c,v 1.63 2001/07/10 04:29:01 davem Exp $
* Version: $Id: raw.c,v 1.64 2002/02/01 22:01:04 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
......@@ -55,7 +55,7 @@
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/mroute.h>
#include <net/ip.h>
#include <net/tcp.h>
#include <net/protocol.h>
#include <linux/skbuff.h>
#include <net/sock.h>
......@@ -122,7 +122,7 @@ static __inline__ int icmp_filter(struct sock *sk, struct sk_buff *skb)
type = skb->h.icmph->type;
if (type < 32) {
__u32 data = sk->tp_pinfo.tp_raw4.filter.data;
__u32 data = raw4_sk(sk)->filter.data;
return ((1 << type) & data) != 0;
}
......@@ -176,6 +176,7 @@ struct sock *raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash)
void raw_err (struct sock *sk, struct sk_buff *skb, u32 info)
{
struct inet_opt *inet = inet_sk(sk);
int type = skb->h.icmph->type;
int code = skb->h.icmph->code;
int err = 0;
......@@ -186,7 +187,7 @@ void raw_err (struct sock *sk, struct sk_buff *skb, u32 info)
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 (!inet->recverr && sk->state != TCP_ESTABLISHED)
return;
switch (type) {
......@@ -207,22 +208,21 @@ void raw_err (struct sock *sk, struct sk_buff *skb, u32 info)
err = icmp_err_convert[code].errno;
harderr = icmp_err_convert[code].fatal;
if (code == ICMP_FRAG_NEEDED) {
harderr = sk->protinfo.af_inet.pmtudisc !=
IP_PMTUDISC_DONT;
harderr = inet->pmtudisc != IP_PMTUDISC_DONT;
err = EMSGSIZE;
}
}
if (sk->protinfo.af_inet.recverr) {
if (inet->recverr) {
struct iphdr *iph = (struct iphdr*)skb->data;
u8 *payload = skb->data + (iph->ihl << 2);
if (sk->protinfo.af_inet.hdrincl)
if (inet->hdrincl)
payload = skb->data;
ip_icmp_error(sk, skb, err, 0, info, payload);
}
if (sk->protinfo.af_inet.recverr || harderr) {
if (inet->recverr || harderr) {
sk->err = err;
sk->error_report(sk);
}
......@@ -304,6 +304,7 @@ static int raw_getrawfrag(const void *p, char *to, unsigned int offset,
static int raw_sendmsg(struct sock *sk, struct msghdr *msg, int len)
{
struct inet_opt *inet = inet_sk(sk);
struct ipcm_cookie ipc;
struct rawfakehdr rfh;
struct rtable *rt = NULL;
......@@ -382,14 +383,14 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, int len)
ipc.addr = daddr;
if (!ipc.opt)
ipc.opt = sk->protinfo.af_inet.opt;
ipc.opt = inet->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 (inet->hdrincl)
goto done;
if (ipc.opt->srr) {
if (!daddr)
......@@ -397,15 +398,15 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, int len)
daddr = ipc.opt->faddr;
}
}
tos = RT_TOS(sk->protinfo.af_inet.tos) | sk->localroute;
tos = RT_TOS(inet->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 = inet->mc_index;
if (!rfh.saddr)
rfh.saddr = sk->protinfo.af_inet.mc_addr;
rfh.saddr = inet->mc_addr;
}
err = ip_route_output(&rt, daddr, rfh.saddr, tos, ipc.oif);
......@@ -426,7 +427,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, int len)
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, inet->hdrincl ? raw_getrawfrag :
raw_getfrag, &rfh, len, &ipc, rt, msg->msg_flags);
done:
......@@ -484,6 +485,7 @@ out: return ret;
int raw_recvmsg(struct sock *sk, struct msghdr *msg, int len,
int noblock, int flags, int *addr_len)
{
struct inet_opt *inet = inet_sk(sk);
int copied = 0;
int err = -EOPNOTSUPP;
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
......@@ -522,7 +524,7 @@ int raw_recvmsg(struct sock *sk, struct msghdr *msg, int len,
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 (inet->cmsg_flags)
ip_cmsg_recv(msg, skb);
done:
skb_free_datagram(sk, skb);
......@@ -531,7 +533,7 @@ out: return err ? : copied;
static int raw_init(struct sock *sk)
{
struct raw_opt *tp = &(sk->tp_pinfo.tp_raw4);
struct raw_opt *tp = raw4_sk(sk);
if (sk->num == IPPROTO_ICMP)
memset(&tp->filter, 0, sizeof(tp->filter));
return 0;
......@@ -541,7 +543,7 @@ static int raw_seticmpfilter(struct sock *sk, char *optval, int optlen)
{
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_sk(sk)->filter, optval, optlen))
return -EFAULT;
return 0;
}
......@@ -559,7 +561,7 @@ static int raw_geticmpfilter(struct sock *sk, char *optval, int *optlen)
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_sk(sk)->filter, len))
goto out;
ret = 0;
out: return ret;
......
......@@ -9,7 +9,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* $Id: syncookies.c,v 1.17 2001/10/26 14:55:41 davem Exp $
* $Id: syncookies.c,v 1.18 2002/02/01 22:01:04 davem Exp $
*
* Missing: IPv6 support.
*/
......@@ -48,11 +48,12 @@ static __u16 const msstab[] = {
*/
__u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
{
struct tcp_opt *tp = tcp_sk(sk);
int mssind;
const __u16 mss = *mssp;
sk->tp_pinfo.af_tcp.last_synq_overflow = jiffies;
tp->last_synq_overflow = jiffies;
/* XXX sort msstab[] by probability? Binary search? */
for (mssind = 0; mss > msstab[mssind + 1]; mssind++)
......@@ -98,7 +99,7 @@ static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb,
struct open_request *req,
struct dst_entry *dst)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
struct sock *child;
child = tp->af_specific->syn_recv_sock(sk, skb, req, dst);
......@@ -113,6 +114,7 @@ static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb,
struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
struct ip_options *opt)
{
struct tcp_opt *tp = tcp_sk(sk);
__u32 cookie = ntohl(skb->h.th->ack_seq) - 1;
struct sock *ret = sk;
struct open_request *req;
......@@ -123,7 +125,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
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, tp->last_synq_overflow + TCP_TIMEOUT_INIT) ||
(mss = cookie_check(skb, cookie)) == 0) {
NET_INC_STATS_BH(SyncookiesFailed);
goto out;
......
......@@ -5,7 +5,7 @@
*
* Implementation of the Transmission Control Protocol(TCP).
*
* Version: $Id: tcp.c,v 1.215 2001/10/31 08:17:58 davem Exp $
* Version: $Id: tcp.c,v 1.216 2002/02/01 22:01:04 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
......@@ -363,7 +363,7 @@ void tcp_rfree(struct sk_buff *skb)
*/
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_sk(sk)->accept_queue ? (POLLIN | POLLRDNORM) : 0;
}
/*
......@@ -377,7 +377,7 @@ unsigned int tcp_poll(struct file * file, struct socket *sock, poll_table *wait)
{
unsigned int mask;
struct sock *sk = sock->sk;
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
poll_wait(file, sk->sleep, wait);
if (sk->state == TCP_LISTEN)
......@@ -477,7 +477,7 @@ void tcp_write_space(struct sock *sk)
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_sk(sk);
int answ;
switch(cmd) {
......@@ -524,7 +524,7 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
int tcp_listen_start(struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
struct tcp_listen_opt *lopt;
sk->max_ack_backlog = 0;
......@@ -576,7 +576,7 @@ int tcp_listen_start(struct sock *sk)
static void tcp_listen_stop (struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
struct tcp_listen_opt *lopt = tp->listen_opt;
struct open_request *acc_req = tp->accept_queue;
struct open_request *req;
......@@ -647,6 +647,7 @@ static void tcp_listen_stop (struct sock *sk)
*/
static int wait_for_tcp_connect(struct sock * sk, int flags, long *timeo_p)
{
struct tcp_opt *tp = tcp_sk(sk);
struct task_struct *tsk = current;
DECLARE_WAITQUEUE(wait, tsk);
......@@ -663,7 +664,7 @@ static int wait_for_tcp_connect(struct sock * sk, int flags, long *timeo_p)
__set_task_state(tsk, TASK_INTERRUPTIBLE);
add_wait_queue(sk->sleep, &wait);
sk->tp_pinfo.af_tcp.write_pending++;
tp->write_pending++;
release_sock(sk);
*timeo_p = schedule_timeout(*timeo_p);
......@@ -671,7 +672,7 @@ static int wait_for_tcp_connect(struct sock * sk, int flags, long *timeo_p)
__set_task_state(tsk, TASK_RUNNING);
remove_wait_queue(sk->sleep, &wait);
sk->tp_pinfo.af_tcp.write_pending--;
tp->write_pending--;
}
return 0;
}
......@@ -686,6 +687,7 @@ static inline int tcp_memory_free(struct sock *sk)
*/
static int wait_for_tcp_memory(struct sock * sk, long *timeo)
{
struct tcp_opt *tp = tcp_sk(sk);
int err = 0;
long vm_wait = 0;
long current_timeo = *timeo;
......@@ -711,12 +713,12 @@ static int wait_for_tcp_memory(struct sock * sk, long *timeo)
break;
set_bit(SOCK_NOSPACE, &sk->socket->flags);
sk->tp_pinfo.af_tcp.write_pending++;
tp->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--;
tp->write_pending--;
if (vm_wait) {
vm_wait -= current_timeo;
......@@ -825,7 +827,7 @@ static int tcp_error(struct sock *sk, int flags, int err)
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_sk(sk);
int mss_now;
int err;
ssize_t copied;
......@@ -950,8 +952,8 @@ ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset, size_t
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_sk(sk)->sndmsg_page)
#define TCP_OFF(sk) (tcp_sk(sk)->sndmsg_off)
static inline int
tcp_copy_to_page(struct sock *sk, char *from, struct sk_buff *skb,
......@@ -1008,15 +1010,13 @@ static inline int select_size(struct sock *sk, struct tcp_opt *tp)
int tcp_sendmsg(struct sock *sk, struct msghdr *msg, int size)
{
struct iovec *iov;
struct tcp_opt *tp;
struct tcp_opt *tp = tcp_sk(sk);
struct sk_buff *skb;
int iovlen, flags;
int mss_now;
int err, copied;
long timeo;
tp = &(sk->tp_pinfo.af_tcp);
lock_sock(sk);
TCP_CHECK_TIMER(sk);
......@@ -1216,7 +1216,7 @@ static int tcp_recv_urg(struct sock * sk, long timeo,
struct msghdr *msg, int len, int flags,
int *addr_len)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
/* No URG data to read. */
if (sk->urginline || !tp->urg_data || tp->urg_data == TCP_URG_READ)
......@@ -1277,7 +1277,7 @@ static inline void tcp_eat_skb(struct sock *sk, struct sk_buff * skb)
*/
static void cleanup_rbuf(struct sock *sk, int copied)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
int time_to_ack = 0;
#if TCP_DEBUG
......@@ -1362,7 +1362,7 @@ static long tcp_data_wait(struct sock *sk, long timeo)
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_sk(sk);
net_statistics[smp_processor_id()*2+1].TCPPrequeued += skb_queue_len(&tp->ucopy.prequeue);
......@@ -1387,7 +1387,7 @@ static void tcp_prequeue_process(struct sock *sk)
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_sk(sk);
int copied = 0;
u32 peek_seq;
u32 *seq;
......@@ -1936,7 +1936,7 @@ void tcp_close(struct sock *sk, long timeout)
*/
if (sk->state == TCP_FIN_WAIT2) {
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
if (tp->linger2 < 0) {
tcp_set_state(sk, TCP_CLOSE);
tcp_send_active_reset(sk, GFP_ATOMIC);
......@@ -1988,7 +1988,7 @@ extern __inline__ int tcp_need_reset(int state)
int tcp_disconnect(struct sock *sk, int flags)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
int old_state;
int err = 0;
......@@ -2021,8 +2021,12 @@ int tcp_disconnect(struct sock *sk, int flags)
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) {
struct ipv6_pinfo *np = inet6_sk(sk);
memset(&np->saddr, 0, 16);
memset(&np->rcv_saddr, 0, 16);
}
#endif
}
......@@ -2057,6 +2061,7 @@ int tcp_disconnect(struct sock *sk, int flags)
*/
static int wait_for_connect(struct sock * sk, long timeo)
{
struct tcp_opt *tp = tcp_sk(sk);
DECLARE_WAITQUEUE(wait, current);
int err;
......@@ -2078,11 +2083,11 @@ static int wait_for_connect(struct sock * sk, long timeo)
for (;;) {
current->state = TASK_INTERRUPTIBLE;
release_sock(sk);
if (sk->tp_pinfo.af_tcp.accept_queue == NULL)
if (tp->accept_queue == NULL)
timeo = schedule_timeout(timeo);
lock_sock(sk);
err = 0;
if (sk->tp_pinfo.af_tcp.accept_queue)
if (tp->accept_queue)
break;
err = -EINVAL;
if (sk->state != TCP_LISTEN)
......@@ -2105,7 +2110,7 @@ static int wait_for_connect(struct sock * sk, long timeo)
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_sk(sk);
struct open_request *req;
struct sock *newsk;
int error;
......@@ -2157,7 +2162,7 @@ struct sock *tcp_accept(struct sock *sk, int flags, int *err)
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_sk(sk);
int val;
int err = 0;
......@@ -2316,7 +2321,7 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char *optval,
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_sk(sk);
int val, len;
if(level != SOL_TCP)
......
/*
* tcp_diag.c Module for monitoring TCP sockets.
*
* Version: $Id: tcp_diag.c,v 1.2 2001/11/05 09:42:22 davem Exp $
* Version: $Id: tcp_diag.c,v 1.3 2002/02/01 22:01:04 davem Exp $
*
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
*
......@@ -44,7 +44,7 @@ static struct sock *tcpnl;
static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
int ext, u32 pid, u32 seq)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
struct tcpdiagmsg *r;
struct nlmsghdr *nlh;
struct tcp_info *info = NULL;
......@@ -96,8 +96,10 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
#ifdef CONFIG_IPV6
if (r->tcpdiag_family == AF_INET6) {
memcpy(r->id.tcpdiag_src, &sk->net_pinfo.af_inet6.rcv_saddr, 16);
memcpy(r->id.tcpdiag_dst, &sk->net_pinfo.af_inet6.daddr, 16);
struct ipv6_pinfo *np = inet6_sk(sk);
memcpy(r->id.tcpdiag_src, &np->rcv_saddr, 16);
memcpy(r->id.tcpdiag_dst, &np->daddr, 16);
}
#endif
......@@ -329,10 +331,12 @@ int tcpdiag_bc_run(char *bc, int len, struct sock *sk)
#ifdef CONFIG_IPV6
if (sk->family == AF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk);
if (op->code == TCPDIAG_BC_S_COND)
addr = (u32*)&sk->net_pinfo.af_inet6.rcv_saddr;
addr = (u32*)&np->rcv_saddr;
else
addr = (u32*)&sk->net_pinfo.af_inet6.daddr;
addr = (u32*)&np->daddr;
} else
#endif
{
......@@ -441,7 +445,7 @@ int tcpdiag_dump(struct sk_buff *skb, struct netlink_callback *cb)
goto skip_listen_ht;
tcp_listen_lock();
for (i = s_i; i < TCP_LHTABLE_SIZE; i++) {
struct sock *sk = tcp_listening_hash[i];
struct sock *sk;
if (i > s_i)
s_num = 0;
......
This diff is collapsed.
This diff is collapsed.
......@@ -5,7 +5,7 @@
*
* Implementation of the Transmission Control Protocol(TCP).
*
* Version: $Id: tcp_minisocks.c,v 1.14 2001/09/21 21:27:34 davem Exp $
* Version: $Id: tcp_minisocks.c,v 1.15 2002/02/01 22:01:04 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
......@@ -347,7 +347,7 @@ static void __tcp_tw_hashdance(struct sock *sk, struct tcp_tw_bucket *tw)
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_sk(sk);
int recycle_ok = 0;
if (sysctl_tcp_tw_recycle && tp->ts_recent_stamp)
......@@ -383,11 +383,11 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
if(tw->family == PF_INET6) {
memcpy(&tw->v6_daddr,
&sk->net_pinfo.af_inet6.daddr,
struct ipv6_pinfo *np = inet6_sk(sk);
memcpy(&tw->v6_daddr, &np->daddr,
sizeof(struct in6_addr));
memcpy(&tw->v6_rcv_saddr,
&sk->net_pinfo.af_inet6.rcv_saddr,
memcpy(&tw->v6_rcv_saddr, &np->rcv_saddr,
sizeof(struct in6_addr));
}
#endif
......@@ -641,7 +641,10 @@ SMP_TIMER_DEFINE(tcp_twcal_tick, tcp_twcal_tasklet);
*/
struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, struct sk_buff *skb)
{
struct sock *newsk = sk_alloc(PF_INET, GFP_ATOMIC, 0);
/* allocate the newsk from the same slab of the master sock,
* if not, at sk_free time we'll try to free it from the wrong
* slabcache (i.e. is it TCPv4 or v6?) -acme */
struct sock *newsk = sk_alloc(PF_INET, GFP_ATOMIC, 0, sk->slab);
if(newsk != NULL) {
struct tcp_opt *newtp;
......@@ -649,7 +652,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
struct sk_filter *filter;
#endif
memcpy(newsk, sk, sizeof(*newsk));
memcpy(newsk, sk, sizeof(struct tcp_sock));
newsk->state = TCP_SYN_RECV;
/* SANITY */
......@@ -684,7 +687,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
#endif
/* Now setup tcp_opt */
newtp = &(newsk->tp_pinfo.af_tcp);
newtp = tcp_sk(newsk);
newtp->pred_flags = 0;
newtp->rcv_nxt = req->rcv_isn + 1;
newtp->snd_nxt = req->snt_isn + 1;
......@@ -797,7 +800,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb,
struct open_request **prev)
{
struct tcphdr *th = skb->h.th;
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
u32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK);
int paws_reject = 0;
struct tcp_opt ttp;
......
......@@ -5,7 +5,7 @@
*
* Implementation of the Transmission Control Protocol(TCP).
*
* Version: $Id: tcp_output.c,v 1.145 2002/01/11 08:45:37 davem Exp $
* Version: $Id: tcp_output.c,v 1.146 2002/02/01 22:01:04 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
......@@ -84,7 +84,7 @@ static __inline__ __u32 tcp_acceptable_seq(struct sock *sk, struct tcp_opt *tp)
*/
static __u16 tcp_advertise_mss(struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
struct dst_entry *dst = __sk_dst_get(sk);
int mss = tp->advmss;
......@@ -132,7 +132,7 @@ static __inline__ void tcp_event_data_sent(struct tcp_opt *tp, struct sk_buff *s
static __inline__ void tcp_event_ack_sent(struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
tcp_dec_quickack_mode(tp);
tcp_clear_xmit_timer(sk, TCP_TIME_DACK);
......@@ -145,7 +145,7 @@ static __inline__ void tcp_event_ack_sent(struct sock *sk)
*/
static __inline__ u16 tcp_select_window(struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
u32 cur_win = tcp_receive_window(tp);
u32 new_win = __tcp_select_window(sk);
......@@ -188,7 +188,7 @@ static __inline__ u16 tcp_select_window(struct sock *sk)
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_sk(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 @@ int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb)
*/
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_sk(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_send_skb(struct sock *sk, struct sk_buff *skb, int force_queue, unsigne
*/
void tcp_push_one(struct sock *sk, unsigned cur_mss)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
struct sk_buff *skb = tp->send_head;
if (tcp_snd_test(tp, skb, cur_mss, 1)) {
......@@ -418,7 +418,7 @@ static void skb_split(struct sk_buff *skb, struct sk_buff *skb1, u32 len)
*/
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_sk(sk);
struct sk_buff *buff;
int nsize = skb->len - len;
u16 flags;
......@@ -501,7 +501,7 @@ static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len)
int tcp_sync_mss(struct sock *sk, u32 pmtu)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
int mss_now;
/* Calculate base mss without TCP options:
......@@ -509,7 +509,6 @@ int tcp_sync_mss(struct sock *sk, u32 pmtu)
*/
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_sync_mss(struct sock *sk, u32 pmtu)
*/
int tcp_write_xmit(struct sock *sk, int nonagle)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
unsigned int mss_now;
/* If we are closed, the bytes will have to remain here.
......@@ -642,7 +641,7 @@ int tcp_write_xmit(struct sock *sk, int nonagle)
*/
u32 __tcp_select_window(struct sock *sk)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(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 @@ u32 __tcp_select_window(struct sock *sk)
/* 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_sk(sk);
struct sk_buff *next_skb = skb->next;
/* The first test we must make is that neither of these two
......@@ -764,7 +763,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m
*/
void tcp_simple_retransmit(struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
struct sk_buff *skb;
unsigned int mss = tcp_current_mss(sk);
int lost = 0;
......@@ -810,7 +809,7 @@ void tcp_simple_retransmit(struct sock *sk)
*/
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_sk(sk);
unsigned int cur_mss = tcp_current_mss(sk);
int err;
......@@ -909,7 +908,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
*/
void tcp_xmit_retransmit_queue(struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
struct sk_buff *skb;
int packet_cnt = tp->lost_out;
......@@ -989,7 +988,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
*/
void tcp_send_fin(struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
struct sk_buff *skb = skb_peek_tail(&sk->write_queue);
unsigned int mss_now;
......@@ -1033,7 +1032,7 @@ void tcp_send_fin(struct sock *sk)
*/
void tcp_send_active_reset(struct sock *sk, int priority)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
struct sk_buff *skb;
/* NOTE: No TCP options attached and we never retransmit this. */
......@@ -1084,7 +1083,7 @@ int tcp_send_synack(struct sock *sk)
}
TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ACK;
TCP_ECN_send_synack(&sk->tp_pinfo.af_tcp, skb);
TCP_ECN_send_synack(tcp_sk(sk), skb);
}
TCP_SKB_CB(skb)->when = tcp_time_stamp;
return tcp_transmit_skb(sk, skb_clone(skb, GFP_ATOMIC));
......@@ -1096,7 +1095,7 @@ int tcp_send_synack(struct sock *sk)
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_sk(sk);
struct tcphdr *th;
int tcp_header_size;
struct sk_buff *skb;
......@@ -1159,7 +1158,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
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_sk(sk);
/* Reserve space for headers. */
skb_reserve(buff, MAX_TCP_HEADER);
......@@ -1246,7 +1245,7 @@ int tcp_connect(struct sock *sk, struct sk_buff *buff)
*/
void tcp_send_delayed_ack(struct sock *sk)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
int ato = tp->ack.ato;
unsigned long timeout;
......@@ -1299,7 +1298,7 @@ void tcp_send_ack(struct sock *sk)
{
/* 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_sk(sk);
struct sk_buff *buff;
/* We are not putting this on the write queue, so
......@@ -1340,7 +1339,7 @@ void tcp_send_ack(struct sock *sk)
*/
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_sk(sk);
struct sk_buff *skb;
/* We don't queue it, tcp_transmit_skb() sets ownership. */
......@@ -1367,7 +1366,7 @@ static int tcp_xmit_probe_skb(struct sock *sk, int urgent)
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_sk(sk);
struct sk_buff *skb;
if ((skb = tp->send_head) != NULL &&
......@@ -1412,7 +1411,7 @@ int tcp_write_wakeup(struct sock *sk)
*/
void tcp_send_probe0(struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(sk);
int err;
err = tcp_write_wakeup(sk);
......
......@@ -5,7 +5,7 @@
*
* Implementation of the Transmission Control Protocol(TCP).
*
* Version: $Id: tcp_timer.c,v 1.87 2001/09/21 21:27:34 davem Exp $
* Version: $Id: tcp_timer.c,v 1.88 2002/02/01 22:01:04 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
......@@ -45,7 +45,7 @@ const char timer_bug_msg[] = KERN_DEBUG "tcpbug: unknown timer value\n";
void tcp_init_xmit_timers(struct sock *sk)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
init_timer(&tp->retransmit_timer);
tp->retransmit_timer.function=&tcp_write_timer;
......@@ -64,7 +64,7 @@ void tcp_init_xmit_timers(struct sock *sk)
void tcp_clear_xmit_timers(struct sock *sk)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
tp->pending = 0;
if (timer_pending(&tp->retransmit_timer) &&
......@@ -103,7 +103,7 @@ static void tcp_write_err(struct sock *sk)
*/
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_sk(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 @@ static int tcp_orphan_retries(struct sock *sk, int alive)
/* 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_sk(sk);
int retry_until;
if ((1<<sk->state)&(TCPF_SYN_SENT|TCPF_SYN_RECV)) {
......@@ -210,7 +210,7 @@ static int tcp_write_timeout(struct sock *sk)
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_sk(sk);
bh_lock_sock(sk);
if (sk->lock.users) {
......@@ -271,7 +271,7 @@ static void tcp_delack_timer(unsigned long data)
static void tcp_probe_timer(struct sock *sk)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
int max_probes;
if (tp->packets_out || !tp->send_head) {
......@@ -319,7 +319,7 @@ static void tcp_probe_timer(struct sock *sk)
static void tcp_retransmit_timer(struct sock *sk)
{
struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
struct tcp_opt *tp = tcp_sk(sk);
if (tp->packets_out == 0)
goto out;
......@@ -415,7 +415,7 @@ out:;
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_sk(sk);
int event;
bh_lock_sock(sk);
......@@ -461,7 +461,7 @@ static void tcp_write_timer(unsigned long data)
static void tcp_synack_timer(struct sock *sk)
{
struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
struct tcp_opt *tp = tcp_sk(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 @@ void tcp_set_keepalive(struct sock *sk, int val)
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_sk(sk)));
else if (!val)
tcp_delete_keepalive_timer(sk);
}
......@@ -574,7 +574,7 @@ void tcp_set_keepalive(struct sock *sk, int val)
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_sk(sk);
__u32 elapsed;
/* Only process if socket is not in use. */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -5,7 +5,7 @@
* Authors:
* Pedro Roque <roque@di.fc.ul.pt>
*
* $Id: icmp.c,v 1.37 2001/09/18 22:29:10 davem Exp $
* $Id: icmp.c,v 1.38 2002/02/08 03:57:19 davem Exp $
*
* Based on net/ipv4/icmp.c
*
......
......@@ -180,7 +180,7 @@ static int fl_intern(struct ip6_flowlabel *fl, __u32 label)
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 = inet6_sk(sk);
label &= IPV6_FLOWLABEL_MASK;
......@@ -197,7 +197,7 @@ struct ip6_flowlabel * fl6_sock_lookup(struct sock *sk, u32 label)
void fl6_free_socklist(struct sock *sk)
{
struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6_fl_socklist *sfl;
while ((sfl = np->ipv6_fl_list) != NULL) {
......@@ -354,6 +354,7 @@ fl_create(struct in6_flowlabel_req *freq, char *optval, int optlen, int *err_p)
static int mem_check(struct sock *sk)
{
struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6_fl_socklist *sfl;
int room = FL_MAX_SIZE - atomic_read(&fl_size);
int count = 0;
......@@ -361,7 +362,7 @@ static int mem_check(struct sock *sk)
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 = np->ipv6_fl_list; sfl; sfl = sfl->next)
count++;
if (room <= 0 ||
......@@ -404,7 +405,7 @@ static int ipv6_opt_cmp(struct ipv6_txoptions *o1, struct ipv6_txoptions *o2)
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 = inet6_sk(sk);
struct in6_flowlabel_req freq;
struct ipv6_fl_socklist *sfl1=NULL;
struct ipv6_fl_socklist *sfl, **sflp;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -9,6 +9,7 @@
#include <linux/types.h>
#include <linux/wait.h>
#include <net/sock.h>
#include <net/tcp.h>
#include <asm/uaccess.h>
#include "structure.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment