aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavem <davem>2002-02-01 22:01:03 +0000
committerdavem <davem>2002-02-01 22:01:03 +0000
commit3f9e36af4c1157eea3eb1be9950a9fd075298d43 (patch)
treef03a9a0d6a3b904bd6973a41c7764f5556504b02
parentbcbcab1aa878e19941c4d585ab4c114c52838591 (diff)
downloadnetdev-vger-cvs-3f9e36af4c1157eea3eb1be9950a9fd075298d43.tar.gz
Move protocol specific state out of struct sock.
This is phase 1. Work by Arnaldo Carvalho de Melo.
-rw-r--r--drivers/net/pppoe.c69
-rw-r--r--drivers/net/pppox.c6
-rw-r--r--include/asm-sparc/checksum.h3
-rw-r--r--include/asm-sparc64/checksum.h5
-rw-r--r--include/linux/atalk.h2
-rw-r--r--include/linux/atmdev.h3
-rw-r--r--include/linux/if_ec.h2
-rw-r--r--include/linux/if_pppox.h20
-rw-r--r--include/linux/if_wanpipe.h3
-rw-r--r--include/linux/igmp.h2
-rw-r--r--include/linux/ip.h34
-rw-r--r--include/linux/ipv6.h77
-rw-r--r--include/linux/tcp.h197
-rw-r--r--include/net/af_unix.h28
-rw-r--r--include/net/ax25.h2
-rw-r--r--include/net/checksum.h1
-rw-r--r--include/net/dn.h4
-rw-r--r--include/net/dn_nsp.h12
-rw-r--r--include/net/dn_route.h2
-rw-r--r--include/net/icmp.h19
-rw-r--r--include/net/inet_ecn.h6
-rw-r--r--include/net/ip.h7
-rw-r--r--include/net/ip6_route.h4
-rw-r--r--include/net/ipx.h16
-rw-r--r--include/net/irda/irda.h2
-rw-r--r--include/net/netrom.h2
-rw-r--r--include/net/rose.h2
-rw-r--r--include/net/route.h2
-rw-r--r--include/net/sock.h490
-rw-r--r--include/net/spx.h2
-rw-r--r--include/net/tcp.h42
-rw-r--r--include/net/udp.h2
-rw-r--r--include/net/x25.h2
-rw-r--r--net/802/cl2llc.c4
-rw-r--r--net/appletalk/ddp.c165
-rw-r--r--net/atm/common.c5
-rw-r--r--net/atm/mpc.c2
-rw-r--r--net/atm/pvc.c7
-rw-r--r--net/atm/resources.c20
-rw-r--r--net/atm/svc.c7
-rw-r--r--net/ax25/af_ax25.c287
-rw-r--r--net/ax25/ax25_ds_in.c1
-rw-r--r--net/ax25/ax25_ds_timer.c1
-rw-r--r--net/ax25/ax25_in.c3
-rw-r--r--net/ax25/ax25_std_in.c1
-rw-r--r--net/ax25/ax25_std_timer.c1
-rw-r--r--net/ax25/ax25_subr.c1
-rw-r--r--net/bluetooth/af_bluetooth.c6
-rw-r--r--net/bluetooth/hci_sock.c4
-rw-r--r--net/bluetooth/l2cap_core.c4
-rw-r--r--net/core/datagram.c1
-rw-r--r--net/core/sock.c44
-rw-r--r--net/decnet/af_decnet.c10
-rw-r--r--net/decnet/dn_nsp_in.c6
-rw-r--r--net/decnet/dn_nsp_out.c5
-rw-r--r--net/econet/af_econet.c39
-rw-r--r--net/ipv4/af_inet.c78
-rw-r--r--net/ipv4/icmp.c13
-rw-r--r--net/ipv4/igmp.c19
-rw-r--r--net/ipv4/ip_output.c45
-rw-r--r--net/ipv4/ip_sockglue.c111
-rw-r--r--net/ipv4/ipconfig.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c1
-rw-r--r--net/ipv4/netfilter/ip_nat_snmp_basic.c3
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c1
-rw-r--r--net/ipv4/raw.c40
-rw-r--r--net/ipv4/syncookies.c10
-rw-r--r--net/ipv4/tcp.c63
-rw-r--r--net/ipv4/tcp_diag.c18
-rw-r--r--net/ipv4/tcp_input.c239
-rw-r--r--net/ipv4/tcp_ipv4.c98
-rw-r--r--net/ipv4/tcp_minisocks.c23
-rw-r--r--net/ipv4/tcp_output.c51
-rw-r--r--net/ipv4/tcp_timer.c24
-rw-r--r--net/ipv4/udp.c33
-rw-r--r--net/ipv6/af_inet6.c121
-rw-r--r--net/ipv6/datagram.c19
-rw-r--r--net/ipv6/ip6_flowlabel.c9
-rw-r--r--net/ipv6/ip6_output.c21
-rw-r--r--net/ipv6/ipv6_sockglue.c10
-rw-r--r--net/ipv6/mcast.c15
-rw-r--r--net/ipv6/ndisc.c6
-rw-r--r--net/ipv6/proc.c4
-rw-r--r--net/ipv6/raw.c58
-rw-r--r--net/ipv6/tcp_ipv6.c227
-rw-r--r--net/ipv6/udp.c97
-rw-r--r--net/ipx/af_ipx.c224
-rw-r--r--net/ipx/af_spx.c47
-rw-r--r--net/irda/af_irda.c56
-rw-r--r--net/khttpd/accept.c4
-rw-r--r--net/khttpd/datasending.c6
-rw-r--r--net/khttpd/prototypes.h1
-rw-r--r--net/khttpd/waitheaders.c4
-rw-r--r--net/netlink/af_netlink.c190
-rw-r--r--net/netrom/af_netrom.c241
-rw-r--r--net/netrom/nr_in.c85
-rw-r--r--net/netrom/nr_out.c70
-rw-r--r--net/netrom/nr_subr.c73
-rw-r--r--net/netrom/nr_timer.c99
-rw-r--r--net/packet/af_packet.c123
-rw-r--r--net/rose/af_rose.c364
-rw-r--r--net/rose/rose_in.c113
-rw-r--r--net/rose/rose_out.c37
-rw-r--r--net/rose/rose_route.c22
-rw-r--r--net/rose/rose_subr.c52
-rw-r--r--net/rose/rose_timer.c91
-rw-r--r--net/socket.c2
-rw-r--r--net/sunrpc/svcsock.c1
-rw-r--r--net/sunrpc/xprt.c1
-rw-r--r--net/unix/af_unix.c186
-rw-r--r--net/unix/garbage.c23
-rw-r--r--net/wanrouter/af_wanpipe.c217
-rw-r--r--net/x25/af_x25.c203
-rw-r--r--net/x25/x25_facilities.c5
-rw-r--r--net/x25/x25_in.c147
-rw-r--r--net/x25/x25_out.c64
-rw-r--r--net/x25/x25_subr.c102
-rw-r--r--net/x25/x25_timer.c71
118 files changed, 3279 insertions, 2800 deletions
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index a5e3595d5..ffb77a36f 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -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 @@ end:
***********************************************************************/
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
diff --git a/drivers/net/pppox.c b/drivers/net/pppox.c
index ab01ac9f5..71647eb18 100644
--- a/drivers/net/pppox.c
+++ b/drivers/net/pppox.c
@@ -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) {
diff --git a/include/asm-sparc/checksum.h b/include/asm-sparc/checksum.h
index 9fdd6e952..629a5ef23 100644
--- a/include/asm-sparc/checksum.h
+++ b/include/asm-sparc/checksum.h
@@ -1,4 +1,4 @@
-/* $Id: checksum.h,v 1.32 2001-10-30 04:32:24 davem Exp $ */
+/* $Id: checksum.h,v 1.33 2002-02-01 22:01:05 davem Exp $ */
#ifndef __SPARC_CHECKSUM_H
#define __SPARC_CHECKSUM_H
@@ -16,6 +16,7 @@
* RFC1071 Computing the Internet Checksum
*/
+#include <linux/in6.h>
#include <asm/uaccess.h>
#include <asm/cprefix.h>
diff --git a/include/asm-sparc64/checksum.h b/include/asm-sparc64/checksum.h
index 501ec4dbe..2ee3622e3 100644
--- a/include/asm-sparc64/checksum.h
+++ b/include/asm-sparc64/checksum.h
@@ -1,4 +1,4 @@
-/* $Id: checksum.h,v 1.17 2001-04-24 01:09:12 davem Exp $ */
+/* $Id: checksum.h,v 1.18 2002-02-01 22:01:05 davem Exp $ */
#ifndef __SPARC64_CHECKSUM_H
#define __SPARC64_CHECKSUM_H
@@ -16,7 +16,8 @@
* RFC1071 Computing the Internet Checksum
*/
-#include <asm/uaccess.h>
+#include <linux/in6.h>
+#include <asm/uaccess.h>
/* computes the checksum of a memory block at buff, length len,
* and adds in "sum" (32-bit)
diff --git a/include/linux/atalk.h b/include/linux/atalk.h
index 5c2c0c355..c76adf7fd 100644
--- a/include/linux/atalk.h
+++ b/include/linux/atalk.h
@@ -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__ */
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index 6cbbfc53e..61f9ed77c 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.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 \
diff --git a/include/linux/if_ec.h b/include/linux/if_ec.h
index 74818238a..8e2e4a1fe 100644
--- a/include/linux/if_ec.h
+++ b/include/linux/if_ec.h
@@ -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 */
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
index c73f6839f..64b16b277 100644
--- a/include/linux/if_pppox.h
+++ b/include/linux/if_pppox.h
@@ -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);
diff --git a/include/linux/if_wanpipe.h b/include/linux/if_wanpipe.h
index 484a7675a..544d818d9 100644
--- a/include/linux/if_wanpipe.h
+++ b/include/linux/if_wanpipe.h
@@ -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
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index 3dbedb416..76cf68f03 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -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
diff --git a/include/linux/ip.h b/include/linux/ip.h
index 7b642728a..97e388ade 100644
--- a/include/linux/ip.h
+++ b/include/linux/ip.h
@@ -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 {
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 84564bae7..b897a14b5 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -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
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index b30e5d354..f23f093bd 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -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 */
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 818df92a3..646042b59 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.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
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 0957d1aae..334127932 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -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 *);
diff --git a/include/net/checksum.h b/include/net/checksum.h
index 6a16809c9..cbad33338 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -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>
diff --git a/include/net/dn.h b/include/net/dn.h
index a88b6f5e9..b21eb8c29 100644
--- a/include/net/dn.h
+++ b/include/net/dn.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
diff --git a/include/net/dn_nsp.h b/include/net/dn_nsp.h
index 3948c30a3..ea45833ad 100644
--- a/include/net/dn_nsp.h
+++ b/include/net/dn_nsp.h
@@ -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);
}
/*
diff --git a/include/net/dn_route.h b/include/net/dn_route.h
index 30ec0d245..16686ea1e 100644
--- a/include/net/dn_route.h
+++ b/include/net/dn_route.h
@@ -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;
diff --git a/include/net/icmp.h b/include/net/icmp.h
index 460cb2c37..f757af415 100644
--- a/include/net/icmp.h
+++ b/include/net/icmp.h
@@ -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 */
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index ae82d3b32..a375d675f 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.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)
diff --git a/include/net/ip.h b/include/net/ip.h
index 2931015ea..705fed205 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -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);
}
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 2ea9eefcb..89ab4a416 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -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);
diff --git a/include/net/ipx.h b/include/net/ipx.h
index 78c193718..3e013f3f4 100644
--- a/include/net/ipx.h
+++ b/include/net/ipx.h
@@ -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
diff --git a/include/net/irda/irda.h b/include/net/irda/irda.h
index c3896b397..42a0c802c 100644
--- a/include/net/irda/irda.h
+++ b/include/net/irda/irda.h
@@ -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
diff --git a/include/net/netrom.h b/include/net/netrom.h
index 21c9f8b86..b83879018 100644
--- a/include/net/netrom.h
+++ b/include/net/netrom.h
@@ -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;
diff --git a/include/net/rose.h b/include/net/rose.h
index f1f893e27..fffbd5d5e 100644
--- a/include/net/rose.h
+++ b/include/net/rose.h
@@ -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;
diff --git a/include/net/route.h b/include/net/route.h
index fd55294bb..d6812d468 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -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
{
diff --git a/include/net/sock.h b/include/net/sock.h
index e4b723ca4..b0f7b2bc5 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -24,6 +24,11 @@
* Alan Cox : Eliminate low level recv/recvfrom
* David S. Miller : New socket lookup architecture.
* Steve Whitehouse: Default routines for sock_ops
+ * Arnaldo C. Melo : removed net_pinfo, tp_pinfo and made
+ * protinfo be just a void pointer, as the
+ * protocol specific parts were moved to
+ * respective headers and ipv4/v6, etc now
+ * use private slabcaches for its socks
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -36,68 +41,9 @@
#include <linux/config.h>
#include <linux/timer.h>
#include <linux/cache.h>
-#include <linux/in.h> /* struct sockaddr_in */
-
-#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
-#include <linux/in6.h> /* struct sockaddr_in6 */
-#include <linux/ipv6.h> /* dest_cache, inet6_options */
-#include <linux/icmpv6.h>
-#include <net/if_inet6.h> /* struct ipv6_mc_socklist */
-#endif
-
-#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE)
-#include <linux/icmp.h>
-#endif
-#include <linux/tcp.h> /* struct tcphdr */
#include <linux/netdevice.h>
#include <linux/skbuff.h> /* struct sk_buff */
-#include <net/protocol.h> /* struct inet_protocol */
-#if defined(CONFIG_X25) || defined(CONFIG_X25_MODULE)
-#include <net/x25.h>
-#endif
-#if defined(CONFIG_WAN_ROUTER) || defined(CONFIG_WAN_ROUTER_MODULE)
-#include <linux/if_wanpipe.h>
-#endif
-
-#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
-#include <net/ax25.h>
-#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
-#include <net/netrom.h>
-#endif
-#if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE)
-#include <net/rose.h>
-#endif
-#endif
-
-#if defined(CONFIG_PPPOE) || defined(CONFIG_PPPOE_MODULE)
-#include <linux/if_pppox.h>
-#include <linux/ppp_channel.h> /* struct ppp_channel */
-#endif
-
-#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE)
-#if defined(CONFIG_SPX) || defined(CONFIG_SPX_MODULE)
-#include <net/spx.h>
-#else
-#include <net/ipx.h>
-#endif /* CONFIG_SPX */
-#endif /* CONFIG_IPX */
-
-#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE)
-#include <linux/atalk.h>
-#endif
-
-#if defined(CONFIG_DECNET) || defined(CONFIG_DECNET_MODULE)
-#include <net/dn.h>
-#endif
-
-#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
-#include <net/irda/irda.h>
-#endif
-
-#if defined(CONFIG_ATM) || defined(CONFIG_ATM_MODULE)
-struct atm_vcc;
-#endif
#ifdef CONFIG_FILTER
#include <linux/filter.h>
@@ -106,362 +52,12 @@ struct atm_vcc;
#include <asm/atomic.h>
#include <net/dst.h>
-
-/* The AF_UNIX specific socket options */
-struct unix_opt {
- struct unix_address *addr;
- struct dentry * dentry;
- struct vfsmount * mnt;
- struct semaphore readsem;
- struct sock * other;
- struct sock ** list;
- struct sock * gc_tree;
- atomic_t inflight;
- rwlock_t lock;
- wait_queue_head_t peer_wait;
-};
-
-
-/* Once the IPX ncpd patches are in these are going into protinfo. */
-#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE)
-struct ipx_opt {
- ipx_address dest_addr;
- ipx_interface *intrfc;
- unsigned short port;
-#ifdef CONFIG_IPX_INTERN
- unsigned char node[IPX_NODE_LEN];
-#endif
- unsigned short type;
-/*
- * To handle special ncp connection-handling sockets for mars_nwe,
- * the connection number must be stored in the socket.
- */
- unsigned short ipx_ncp_conn;
-};
-#endif
-
-#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
-struct ipv6_pinfo {
- struct in6_addr saddr;
- struct in6_addr rcv_saddr;
- struct in6_addr daddr;
- struct in6_addr *daddr_cache;
-
- __u32 flow_label;
- __u32 frag_size;
- int hop_limit;
- int mcast_hops;
- int mcast_oif;
-
- /* pktoption flags */
- union {
- struct {
- __u8 srcrt:2,
- rxinfo:1,
- rxhlim:1,
- hopopts:1,
- dstopts:1,
- authhdr:1,
- rxflow:1;
- } bits;
- __u8 all;
- } rxopt;
-
- /* sockopt flags */
- __u8 mc_loop:1,
- recverr:1,
- sndflow:1,
- pmtudisc:2;
-
- struct ipv6_mc_socklist *ipv6_mc_list;
- struct ipv6_fl_socklist *ipv6_fl_list;
- __u32 dst_cookie;
-
- struct ipv6_txoptions *opt;
- struct sk_buff *pktoptions;
-};
-
-struct raw6_opt {
- __u32 checksum; /* perform checksum */
- __u32 offset; /* checksum offset */
-
- struct icmp6_filter filter;
-};
-
-#endif /* IPV6 */
-
-#if defined(CONFIG_INET) || defined(CONFIG_INET_MODULE)
-struct raw_opt {
- struct icmp_filter filter;
-};
-#endif
-
-#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE)
-struct inet_opt
-{
- int ttl; /* TTL setting */
- int tos; /* TOS */
- unsigned cmsg_flags;
- struct ip_options *opt;
- unsigned char hdrincl; /* Include headers ? */
- __u8 mc_ttl; /* Multicasting TTL */
- __u8 mc_loop; /* Loopback */
- unsigned recverr : 1,
- freebind : 1;
- __u16 id; /* ID counter for DF pkts */
- __u8 pmtudisc;
- int mc_index; /* Multicast device index */
- __u32 mc_addr;
- struct ip_mc_socklist *mc_list; /* Group array */
-};
-#endif
-
-#if defined(CONFIG_PPPOE) || defined (CONFIG_PPPOE_MODULE)
-struct pppoe_opt
-{
- struct net_device *dev; /* device associated with socket*/
- struct pppoe_addr pa; /* what this socket is bound to*/
- struct sockaddr_pppox relay; /* what socket data will be
- relayed to (PPPoE relaying) */
-};
-
-struct pppox_opt
-{
- struct ppp_channel chan;
- struct sock *sk;
- struct pppox_opt *next; /* for hash table */
- union {
- struct pppoe_opt pppoe;
- } proto;
-};
-#define pppoe_dev proto.pppoe.dev
-#define pppoe_pa proto.pppoe.pa
-#define pppoe_relay proto.pppoe.relay
-#endif
-
-/* This defines a selective acknowledgement block. */
-struct tcp_sack_block {
- __u32 start_seq;
- __u32 end_seq;
-};
-
-struct tcp_opt {
- int tcp_header_len; /* Bytes of tcp header to send */
-
-/*
- * Header prediction flags
- * 0x5?10 << 16 + snd_wnd in net byte order
- */
- __u32 pred_flags;
-
-/*
- * RFC793 variables by their proper names. This means you can
- * read the code and the spec side by side (and laugh ...)
- * See RFC793 and RFC1122. The RFC writes these in capitals.
- */
- __u32 rcv_nxt; /* What we want to receive next */
- __u32 snd_nxt; /* Next sequence we send */
-
- __u32 snd_una; /* First byte we want an ack for */
- __u32 snd_sml; /* Last byte of the most recently transmitted small packet */
- __u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
- __u32 lsndtime; /* timestamp of last sent data packet (for restart window) */
-
- /* Delayed ACK control data */
- struct {
- __u8 pending; /* ACK is pending */
- __u8 quick; /* Scheduled number of quick acks */
- __u8 pingpong; /* The session is interactive */
- __u8 blocked; /* Delayed ACK was blocked by socket lock*/
- __u32 ato; /* Predicted tick of soft clock */
- unsigned long timeout; /* Currently scheduled timeout */
- __u32 lrcvtime; /* timestamp of last received data packet*/
- __u16 last_seg_size; /* Size of last incoming segment */
- __u16 rcv_mss; /* MSS used for delayed ACK decisions */
- } ack;
-
- /* Data for direct copy to user */
- struct {
- struct sk_buff_head prequeue;
- int memory;
- struct task_struct *task;
- struct iovec *iov;
- int len;
- } ucopy;
-
- __u32 snd_wl1; /* Sequence for window update */
- __u32 snd_wnd; /* The window we expect to receive */
- __u32 max_window; /* Maximal window ever seen from peer */
- __u32 pmtu_cookie; /* Last pmtu seen by socket */
- __u16 mss_cache; /* Cached effective mss, not including SACKS */
- __u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
- __u16 ext_header_len; /* Network protocol overhead (IP/IPv6 options) */
- __u8 ca_state; /* State of fast-retransmit machine */
- __u8 retransmits; /* Number of unrecovered RTO timeouts. */
-
- __u8 reordering; /* Packet reordering metric. */
- __u8 queue_shrunk; /* Write queue has been shrunk recently.*/
- __u8 defer_accept; /* User waits for some data after accept() */
-
-/* RTT measurement */
- __u8 backoff; /* backoff */
- __u32 srtt; /* smothed round trip time << 3 */
- __u32 mdev; /* medium deviation */
- __u32 mdev_max; /* maximal mdev for the last rtt period */
- __u32 rttvar; /* smoothed mdev_max */
- __u32 rtt_seq; /* sequence number to update rttvar */
- __u32 rto; /* retransmit timeout */
-
- __u32 packets_out; /* Packets which are "in flight" */
- __u32 left_out; /* Packets which leaved network */
- __u32 retrans_out; /* Retransmitted packets out */
-
-
-/*
- * Slow start and congestion control (see also Nagle, and Karn & Partridge)
- */
- __u32 snd_ssthresh; /* Slow start size threshold */
- __u32 snd_cwnd; /* Sending congestion window */
- __u16 snd_cwnd_cnt; /* Linear increase counter */
- __u16 snd_cwnd_clamp; /* Do not allow snd_cwnd to grow above this */
- __u32 snd_cwnd_used;
- __u32 snd_cwnd_stamp;
-
- /* Two commonly used timers in both sender and receiver paths. */
- unsigned long timeout;
- struct timer_list retransmit_timer; /* Resend (no ack) */
- struct timer_list delack_timer; /* Ack delay */
-
- struct sk_buff_head out_of_order_queue; /* Out of order segments go here */
-
- struct tcp_func *af_specific; /* Operations which are AF_INET{4,6} specific */
- struct sk_buff *send_head; /* Front of stuff to transmit */
- struct page *sndmsg_page; /* Cached page for sendmsg */
- u32 sndmsg_off; /* Cached offset for sendmsg */
-
- __u32 rcv_wnd; /* Current receiver window */
- __u32 rcv_wup; /* rcv_nxt on last window update sent */
- __u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
- __u32 pushed_seq; /* Last pushed seq, required to talk to windows */
- __u32 copied_seq; /* Head of yet unread data */
-/*
- * Options received (usually on last packet, some only on SYN packets).
- */
- char tstamp_ok, /* TIMESTAMP seen on SYN packet */
- wscale_ok, /* Wscale seen on SYN packet */
- sack_ok; /* SACK seen on SYN packet */
- char saw_tstamp; /* Saw TIMESTAMP on last packet */
- __u8 snd_wscale; /* Window scaling received from sender */
- __u8 rcv_wscale; /* Window scaling to send to receiver */
- __u8 nonagle; /* Disable Nagle algorithm? */
- __u8 keepalive_probes; /* num of allowed keep alive probes */
-
-/* PAWS/RTTM data */
- __u32 rcv_tsval; /* Time stamp value */
- __u32 rcv_tsecr; /* Time stamp echo reply */
- __u32 ts_recent; /* Time stamp to echo next */
- long ts_recent_stamp;/* Time we stored ts_recent (for aging) */
-
-/* SACKs data */
- __u16 user_mss; /* mss requested by user in ioctl */
- __u8 dsack; /* D-SACK is scheduled */
- __u8 eff_sacks; /* Size of SACK array to send with next packet */
- struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */
- struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/
-
- __u32 window_clamp; /* Maximal window to advertise */
- __u32 rcv_ssthresh; /* Current window clamp */
- __u8 probes_out; /* unanswered 0 window probes */
- __u8 num_sacks; /* Number of SACK blocks */
- __u16 advmss; /* Advertised MSS */
-
- __u8 syn_retries; /* num of allowed syn retries */
- __u8 ecn_flags; /* ECN status bits. */
- __u16 prior_ssthresh; /* ssthresh saved at recovery start */
- __u32 lost_out; /* Lost packets */
- __u32 sacked_out; /* SACK'd packets */
- __u32 fackets_out; /* FACK'd packets */
- __u32 high_seq; /* snd_nxt at onset of congestion */
-
- __u32 retrans_stamp; /* Timestamp of the last retransmit,
- * also used in SYN-SENT to remember stamp of
- * the first SYN. */
- __u32 undo_marker; /* tracking retrans started here. */
- int undo_retrans; /* number of undoable retransmissions. */
- __u32 urg_seq; /* Seq of received urgent pointer */
- __u16 urg_data; /* Saved octet of OOB data and control flags */
- __u8 pending; /* Scheduled timer event */
- __u8 urg_mode; /* In urgent mode */
- __u32 snd_up; /* Urgent pointer */
-
- /* The syn_wait_lock is necessary only to avoid tcp_get_info having
- * to grab the main lock sock while browsing the listening hash
- * (otherwise it's deadlock prone).
- * This lock is acquired in read mode only from tcp_get_info() and
- * it's acquired in write mode _only_ from code that is actively
- * changing the syn_wait_queue. All readers that are holding
- * the master sock lock don't need to grab this lock in read mode
- * too as the syn_wait_queue writes are always protected from
- * the main sock lock.
- */
- rwlock_t syn_wait_lock;
- struct tcp_listen_opt *listen_opt;
-
- /* FIFO of established children */
- struct open_request *accept_queue;
- struct open_request *accept_queue_tail;
-
- int write_pending; /* A write to socket waits to start. */
-
- unsigned int keepalive_time; /* time before keep alive takes place */
- unsigned int keepalive_intvl; /* time interval between keep alive probes */
- int linger2;
-
- unsigned long last_synq_overflow;
-};
-
-
/*
* This structure really needs to be cleaned up.
* Most of it is for TCP, and not used by any of
* the other protocols.
*/
-/*
- * The idea is to start moving to a newer struct gradualy
- *
- * IMHO the newer struct should have the following format:
- *
- * struct sock {
- * sockmem [mem, proto, callbacks]
- *
- * union or struct {
- * ax25;
- * } ll_pinfo;
- *
- * union {
- * ipv4;
- * ipv6;
- * ipx;
- * netrom;
- * rose;
- * x25;
- * } net_pinfo;
- *
- * union {
- * tcp;
- * udp;
- * spx;
- * netrom;
- * } tp_pinfo;
- *
- * }
- *
- * The idea failed because IPv6 transition asssumes dual IP/IPv6 sockets.
- * So, net_pinfo is IPv6 are really, and protinfo unifies all another
- * private areas.
- */
-
/* Define this to get the sk->debug debugging facility. */
#define SOCK_DEBUGGING
#ifdef SOCK_DEBUGGING
@@ -567,26 +163,6 @@ struct sock {
struct proto *prot;
-#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
- union {
- struct ipv6_pinfo af_inet6;
- } net_pinfo;
-#endif
-
- union {
- struct tcp_opt af_tcp;
-#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE)
- struct raw_opt tp_raw4;
-#endif
-#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
- struct raw6_opt tp_raw;
-#endif /* CONFIG_IPV6 */
-#if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE)
- struct spx_opt af_spx;
-#endif /* CONFIG_SPX */
-
- } tp_pinfo;
-
int err, err_soft; /* Soft holds errors that don't
cause failure but are the cause
of a persistent failure not just
@@ -610,54 +186,11 @@ struct sock {
/* This is where all the private (optional) areas that don't
* overlap will eventually live.
*/
- union {
- void *destruct_hook;
- struct unix_opt af_unix;
-#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE)
- struct inet_opt af_inet;
-#endif
-#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE)
- struct atalk_sock af_at;
-#endif
-#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE)
- struct ipx_opt af_ipx;
-#endif
-#if defined (CONFIG_DECNET) || defined(CONFIG_DECNET_MODULE)
- struct dn_scp dn;
-#endif
-#if defined (CONFIG_PACKET) || defined(CONFIG_PACKET_MODULE)
- struct packet_opt *af_packet;
-#endif
-#if defined(CONFIG_X25) || defined(CONFIG_X25_MODULE)
- x25_cb *x25;
-#endif
-#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
- ax25_cb *ax25;
-#endif
-#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
- nr_cb *nr;
-#endif
-#if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE)
- rose_cb *rose;
-#endif
-#if defined(CONFIG_PPPOE) || defined(CONFIG_PPPOE_MODULE)
- struct pppox_opt *pppox;
-#endif
- struct netlink_opt *af_netlink;
-#if defined(CONFIG_ECONET) || defined(CONFIG_ECONET_MODULE)
- struct econet_opt *af_econet;
-#endif
-#if defined(CONFIG_ATM) || defined(CONFIG_ATM_MODULE)
- struct atm_vcc *af_atm;
-#endif
-#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
- struct irda_sock *irda;
-#endif
-#if defined(CONFIG_WAN_ROUTER) || defined(CONFIG_WAN_ROUTER_MODULE)
- struct wanpipe_opt *af_wanpipe;
-#endif
- } protinfo;
-
+ void *protinfo;
+ /* slabcache this instance wass allocated from, its sk_cachep for most
+ * protocols, but a private slab for protocols such as IPv4, IPv6, SPX
+ * and Unix */
+ kmem_cache_t *slab;
/* This part is used for the timeout functions. */
struct timer_list timer; /* This is the sock cleanup timer. */
@@ -803,7 +336,8 @@ do { spin_lock_bh(&((__sk)->lock.slock)); \
#define bh_lock_sock(__sk) spin_lock(&((__sk)->lock.slock))
#define bh_unlock_sock(__sk) spin_unlock(&((__sk)->lock.slock))
-extern struct sock * sk_alloc(int family, int priority, int zero_it);
+extern struct sock * sk_alloc(int family, int priority, int zero_it,
+ kmem_cache_t *slab);
extern void sk_free(struct sock *sk);
extern struct sk_buff *sock_wmalloc(struct sock *sk,
diff --git a/include/net/spx.h b/include/net/spx.h
index a449b891b..951953d0a 100644
--- a/include/net/spx.h
+++ b/include/net/spx.h
@@ -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 ??) */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 2cd60784a..bccbac72b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -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);
diff --git a/include/net/udp.h b/include/net/udp.h
index d27b8e7ef..c7049c5b4 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -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 */
diff --git a/include/net/x25.h b/include/net/x25.h
index 2e1e88426..4d5c3a84e 100644
--- a/include/net/x25.h
+++ b/include/net/x25.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;
diff --git a/net/802/cl2llc.c b/net/802/cl2llc.c
index a1e32480e..c1b2ca810 100644
--- a/net/802/cl2llc.c
+++ b/net/802/cl2llc.c
@@ -96,7 +96,7 @@ int llc_data_request(llcptr lp, struct sk_buff *skb)
else
llc_interpret_pseudo_code(lp, REJECT1, skb, NO_FRAME);
break;
- default:;
+ default:
}
if(lp->llc_callbacks)
{
@@ -497,7 +497,7 @@ void llc_interpret_pseudo_code(llcptr lp, int pc_label, struct sk_buff *skb,
else
lp->f_flag = fr->i_hdr.i_pflag;
break;
- default:;
+ default:
}
pc++;
}
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index e011a9cc6..a8b7826fc 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -62,6 +62,7 @@
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/in.h>
+#include <linux/tcp.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/if_ether.h>
@@ -152,16 +153,18 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to,
spin_lock_bh(&atalk_sockets_lock);
for (s = atalk_sockets; s; s = s->next) {
- if (to->sat_port != s->protinfo.af_at.src_port)
+ struct atalk_sock *at = at_sk(s);
+
+ if (to->sat_port != at->src_port)
continue;
if (to->sat_addr.s_net == ATADDR_ANYNET &&
to->sat_addr.s_node == ATADDR_BCAST &&
- s->protinfo.af_at.src_net == atif->address.s_net)
+ at->src_net == atif->address.s_net)
break;
- if (to->sat_addr.s_net == s->protinfo.af_at.src_net &&
- (to->sat_addr.s_node == s->protinfo.af_at.src_node ||
+ if (to->sat_addr.s_net == at->src_net &&
+ (to->sat_addr.s_node == at->src_node ||
to->sat_addr.s_node == ATADDR_BCAST ||
to->sat_addr.s_node == ATADDR_ANYNODE))
break;
@@ -170,7 +173,7 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to,
* that the node is appropriately set. */
if (to->sat_addr.s_node == ATADDR_ANYNODE &&
to->sat_addr.s_net != ATADDR_ANYNET &&
- atif->address.s_node == s->protinfo.af_at.src_node) {
+ atif->address.s_node == at->src_node) {
to->sat_addr.s_node = atif->address.s_node;
break;
}
@@ -192,11 +195,14 @@ static struct sock *atalk_find_or_insert_socket(struct sock *sk,
struct sock *s;
spin_lock_bh(&atalk_sockets_lock);
- for (s = atalk_sockets; s; s = s->next)
- if (s->protinfo.af_at.src_net == sat->sat_addr.s_net &&
- s->protinfo.af_at.src_node == sat->sat_addr.s_node &&
- s->protinfo.af_at.src_port == sat->sat_port)
+ for (s = atalk_sockets; s; s = s->next) {
+ struct atalk_sock *at = at_sk(s);
+
+ if (at->src_net == sat->sat_addr.s_net &&
+ at->src_node == sat->sat_addr.s_node &&
+ at->src_port == sat->sat_port)
break;
+ }
if (!s) {
/* Wheee, it's free, assign and insert. */
@@ -255,15 +261,14 @@ static int atalk_get_info(char *buffer, char **start, off_t offset, int length)
spin_lock_bh(&atalk_sockets_lock);
for (s = atalk_sockets; s; s = s->next) {
+ struct atalk_sock *at = at_sk(s);
+
len += sprintf(buffer + len,"%02X ", s->type);
len += sprintf(buffer + len,"%04X:%02X:%02X ",
- ntohs(s->protinfo.af_at.src_net),
- s->protinfo.af_at.src_node,
- s->protinfo.af_at.src_port);
+ ntohs(at->src_net), at->src_node, at->src_port);
len += sprintf(buffer + len,"%04X:%02X:%02X ",
- ntohs(s->protinfo.af_at.dest_net),
- s->protinfo.af_at.dest_node,
- s->protinfo.af_at.dest_port);
+ ntohs(at->dest_net), at->dest_node,
+ at->dest_port);
len += sprintf(buffer + len,"%08X:%08X ",
atomic_read(&s->wmem_alloc),
atomic_read(&s->rmem_alloc));
@@ -1112,42 +1117,33 @@ unsigned short atalk_checksum(struct ddpehdr *ddp, int len)
*/
static int atalk_create(struct socket *sock, int protocol)
{
- struct sock *sk = sk_alloc(PF_APPLETALK, GFP_KERNEL, 1);
-
- if (!sk)
- return -ENOMEM;
-
- switch (sock->type) {
- /*
- * We permit SOCK_DGRAM and RAW is an extension. It is
- * trivial to do and gives you the full ELAP frame.
- * Should be handy for CAP 8)
- */
- case SOCK_RAW:
- case SOCK_DGRAM:
- sock->ops = &atalk_dgram_ops;
- break;
-
- case SOCK_STREAM:
- /*
- * TODO: if you want to implement ADSP, here's the
- * place to start
- */
- /*
- sock->ops = &atalk_stream_ops;
- break;
- */
- default:
- sk_free(sk);
- return -ESOCKTNOSUPPORT;
- }
+ struct sock *sk;
+ struct atalk_sock *at;
+ int rc = -ESOCKTNOSUPPORT;
MOD_INC_USE_COUNT;
+ /*
+ * We permit SOCK_DGRAM and RAW is an extension. It is trivial to do
+ * and gives you the full ELAP frame. Should be handy for CAP 8)
+ */
+ if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
+ goto decmod;
+ rc = -ENOMEM;
+ sk = sk_alloc(PF_APPLETALK, GFP_KERNEL, 1, NULL);
+ if (!sk)
+ goto decmod;
+ at = at_sk(sk) = kmalloc(sizeof(*at), GFP_KERNEL);
+ if (!at)
+ goto outsk;
+ rc = 0;
+ sock->ops = &atalk_dgram_ops;
sock_init_data(sock, sk);
- sk->destruct = NULL;
/* Checksums on by default */
sk->zapped = 1;
- return 0;
+out: return rc;
+outsk: sk_free(sk);
+decmod: MOD_DEC_USE_COUNT;
+ goto out;
}
/* Free a socket. No work needed */
@@ -1156,15 +1152,13 @@ static int atalk_release(struct socket *sock)
struct sock *sk = sock->sk;
if (!sk)
- return 0;
-
+ goto out;
if (!sk->dead)
sk->state_change(sk);
-
sk->dead = 1;
sock->sk = NULL;
atalk_destroy_socket(sk);
- return 0;
+out: return 0;
}
/*
@@ -1185,10 +1179,11 @@ static int atalk_pick_and_bind_port(struct sock *sk, struct sockaddr_at *sat)
sat->sat_port < ATPORT_LAST;
sat->sat_port++) {
for (s = atalk_sockets; s; s = s->next) {
- if (s->protinfo.af_at.src_net == sat->sat_addr.s_net &&
- s->protinfo.af_at.src_node ==
- sat->sat_addr.s_node &&
- s->protinfo.af_at.src_port == sat->sat_port)
+ struct atalk_sock *at = at_sk(s);
+
+ if (at->src_net == sat->sat_addr.s_net &&
+ at->src_node == sat->sat_addr.s_node &&
+ at->src_port == sat->sat_port)
goto try_next_port;
}
@@ -1198,7 +1193,7 @@ static int atalk_pick_and_bind_port(struct sock *sk, struct sockaddr_at *sat)
atalk_sockets->pprev = &sk->next;
atalk_sockets = sk;
sk->pprev = &atalk_sockets;
- sk->protinfo.af_at.src_port = sat->sat_port;
+ at_sk(sk)->src_port = sat->sat_port;
retval = 0;
goto out;
@@ -1213,6 +1208,7 @@ out: spin_unlock_bh(&atalk_sockets_lock);
static int atalk_autobind(struct sock *sk)
{
+ struct atalk_sock *at = at_sk(sk);
struct sockaddr_at sat;
int n;
struct at_addr *ap = atalk_find_primary();
@@ -1220,8 +1216,8 @@ static int atalk_autobind(struct sock *sk)
if (!ap || ap->s_net == htons(ATADDR_ANYNET))
return -EADDRNOTAVAIL;
- sk->protinfo.af_at.src_net = sat.sat_addr.s_net = ap->s_net;
- sk->protinfo.af_at.src_node = sat.sat_addr.s_node = ap->s_node;
+ at->src_net = sat.sat_addr.s_net = ap->s_net;
+ at->src_node = sat.sat_addr.s_node = ap->s_node;
n = atalk_pick_and_bind_port(sk, &sat);
if (n < 0)
@@ -1236,6 +1232,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sockaddr_at *addr = (struct sockaddr_at *)uaddr;
struct sock *sk = sock->sk;
+ struct atalk_sock *at = at_sk(sk);
if (!sk->zapped || addr_len != sizeof(struct sockaddr_at))
return -EINVAL;
@@ -1249,15 +1246,15 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
if (!ap)
return -EADDRNOTAVAIL;
- sk->protinfo.af_at.src_net = addr->sat_addr.s_net = ap->s_net;
- sk->protinfo.af_at.src_node = addr->sat_addr.s_node= ap->s_node;
+ at->src_net = addr->sat_addr.s_net = ap->s_net;
+ at->src_node = addr->sat_addr.s_node= ap->s_node;
} else {
if (!atalk_find_interface(addr->sat_addr.s_net,
addr->sat_addr.s_node))
return -EADDRNOTAVAIL;
- sk->protinfo.af_at.src_net = addr->sat_addr.s_net;
- sk->protinfo.af_at.src_node = addr->sat_addr.s_node;
+ at->src_net = addr->sat_addr.s_net;
+ at->src_node = addr->sat_addr.s_node;
}
if (addr->sat_port == ATADDR_ANYPORT) {
@@ -1266,7 +1263,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
if (n < 0)
return n;
} else {
- sk->protinfo.af_at.src_port = addr->sat_port;
+ at->src_port = addr->sat_port;
if (atalk_find_or_insert_socket(sk, addr))
return -EADDRINUSE;
@@ -1281,6 +1278,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
int addr_len, int flags)
{
struct sock *sk = sock->sk;
+ struct atalk_sock *at = at_sk(sk);
struct sockaddr_at *addr;
sk->state = TCP_CLOSE;
@@ -1312,9 +1310,9 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
if (!atrtr_get_dev(&addr->sat_addr))
return -ENETUNREACH;
- sk->protinfo.af_at.dest_port = addr->sat_port;
- sk->protinfo.af_at.dest_net = addr->sat_addr.s_net;
- sk->protinfo.af_at.dest_node = addr->sat_addr.s_node;
+ at->dest_port = addr->sat_port;
+ at->dest_net = addr->sat_addr.s_net;
+ at->dest_node = addr->sat_addr.s_node;
sock->state = SS_CONNECTED;
sk->state = TCP_ESTABLISHED;
@@ -1331,6 +1329,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
{
struct sockaddr_at sat;
struct sock *sk = sock->sk;
+ struct atalk_sock *at = at_sk(sk);
if (sk->zapped)
if (atalk_autobind(sk) < 0)
@@ -1342,13 +1341,13 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
if (sk->state != TCP_ESTABLISHED)
return -ENOTCONN;
- sat.sat_addr.s_net = sk->protinfo.af_at.dest_net;
- sat.sat_addr.s_node = sk->protinfo.af_at.dest_node;
- sat.sat_port = sk->protinfo.af_at.dest_port;
+ sat.sat_addr.s_net = at->dest_net;
+ sat.sat_addr.s_node = at->dest_node;
+ sat.sat_port = at->dest_port;
} else {
- sat.sat_addr.s_net = sk->protinfo.af_at.src_net;
- sat.sat_addr.s_node = sk->protinfo.af_at.src_node;
- sat.sat_port = sk->protinfo.af_at.src_port;
+ sat.sat_addr.s_net = at->src_net;
+ sat.sat_addr.s_node = at->src_node;
+ sat.sat_port = at->src_port;
}
sat.sat_family = AF_APPLETALK;
@@ -1597,6 +1596,7 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ struct atalk_sock *at = at_sk(sk);
struct sockaddr_at *usat = (struct sockaddr_at *)msg->msg_name;
int flags = msg->msg_flags;
int loopback = 0;
@@ -1635,10 +1635,10 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len,
if (sk->state != TCP_ESTABLISHED)
return -ENOTCONN;
usat = &local_satalk;
- usat->sat_family = AF_APPLETALK;
- usat->sat_port = sk->protinfo.af_at.dest_port;
- usat->sat_addr.s_node = sk->protinfo.af_at.dest_node;
- usat->sat_addr.s_net = sk->protinfo.af_at.dest_net;
+ usat->sat_family = AF_APPLETALK;
+ usat->sat_port = at->dest_port;
+ usat->sat_addr.s_node = at->dest_node;
+ usat->sat_addr.s_net = at->dest_net;
}
/* Build a packet */
@@ -1657,7 +1657,7 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct at_addr at_hint;
at_hint.s_node = 0;
- at_hint.s_net = sk->protinfo.af_at.src_net;
+ at_hint.s_net = at->src_net;
rt = atrtr_find(&at_hint);
if (!rt)
@@ -1693,11 +1693,11 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len,
*((__u16 *)ddp) = ntohs(*((__u16 *)ddp));
ddp->deh_dnet = usat->sat_addr.s_net;
- ddp->deh_snet = sk->protinfo.af_at.src_net;
+ ddp->deh_snet = at->src_net;
ddp->deh_dnode = usat->sat_addr.s_node;
- ddp->deh_snode = sk->protinfo.af_at.src_node;
+ ddp->deh_snode = at->src_node;
ddp->deh_dport = usat->sat_port;
- ddp->deh_sport = sk->protinfo.af_at.src_port;
+ ddp->deh_sport = at->src_port;
SOCK_DEBUG(sk, "SK %p: Copy user data (%d bytes).\n", sk, len);
@@ -1894,10 +1894,9 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg)
return put_user(amount, (int *)arg);
}
-static struct net_proto_family atalk_family_ops =
-{
- PF_APPLETALK,
- atalk_create
+static struct net_proto_family atalk_family_ops = {
+ family: PF_APPLETALK,
+ create: atalk_create,
};
static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops)=
diff --git a/net/atm/common.c b/net/atm/common.c
index 5e9ff984b..1a9a2e2ae 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -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);
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index c36bbaaeb..66c4286ee 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -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>
diff --git a/net/atm/pvc.c b/net/atm/pvc.c
index 708ba7a1b..5f83cd5e6 100644
--- a/net/atm/pvc.c
+++ b/net/atm/pvc.c
@@ -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,
};
diff --git a/net/atm/resources.c b/net/atm/resources.c
index 2249f9b54..c04f8b10e 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -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);
}
diff --git a/net/atm/svc.c b/net/atm/svc.c
index 83c0ee7f3..cd00bc5be 100644
--- a/net/atm/svc.c
+++ b/net/atm/svc.c
@@ -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,
};
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 59e1cf120..1640edb37 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -134,6 +134,7 @@
#include <linux/netfilter.h>
#include <linux/sysctl.h>
#include <linux/init.h>
+#include <net/tcp.h>
#include <net/ip.h>
#include <net/arp.h>
@@ -161,7 +162,7 @@ void ax25_free_cb(ax25_cb *ax25)
static void ax25_free_sock(struct sock *sk)
{
- ax25_free_cb(sk->protinfo.ax25);
+ ax25_free_cb(ax25_sk(sk));
}
/*
@@ -423,9 +424,11 @@ void ax25_destroy_socket(ax25_cb *ax25) /* Not static as it's used by the timer
if (ax25->sk != NULL) {
while ((skb = skb_dequeue(&ax25->sk->receive_queue)) != NULL) {
if (skb->sk != ax25->sk) { /* A pending connection */
+ ax25_cb *sax25 = ax25_sk(skb->sk);
+
skb->sk->dead = 1; /* Queue the unaccepted socket for death */
- ax25_start_heartbeat(skb->sk->protinfo.ax25);
- skb->sk->protinfo.ax25->state = AX25_STATE_0;
+ ax25_start_heartbeat(sax25);
+ sax25->state = AX25_STATE_0;
}
kfree_skb(skb);
@@ -631,6 +634,7 @@ ax25_cb *ax25_create_cb(void)
static int ax25_setsockopt(struct socket *sock, int level, int optname, char *optval, int optlen)
{
struct sock *sk = sock->sk;
+ ax25_cb *ax25 = ax25_sk(sk);
struct net_device *dev;
char devname[IFNAMSIZ];
int opt;
@@ -646,69 +650,69 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, char *op
switch (optname) {
case AX25_WINDOW:
- if (sk->protinfo.ax25->modulus == AX25_MODULUS) {
+ if (ax25->modulus == AX25_MODULUS) {
if (opt < 1 || opt > 7)
return -EINVAL;
} else {
if (opt < 1 || opt > 63)
return -EINVAL;
}
- sk->protinfo.ax25->window = opt;
+ ax25->window = opt;
return 0;
case AX25_T1:
if (opt < 1)
return -EINVAL;
- sk->protinfo.ax25->rtt = (opt * HZ) / 2;
- sk->protinfo.ax25->t1 = opt * HZ;
+ ax25->rtt = (opt * HZ) / 2;
+ ax25->t1 = opt * HZ;
return 0;
case AX25_T2:
if (opt < 1)
return -EINVAL;
- sk->protinfo.ax25->t2 = opt * HZ;
+ ax25->t2 = opt * HZ;
return 0;
case AX25_N2:
if (opt < 1 || opt > 31)
return -EINVAL;
- sk->protinfo.ax25->n2 = opt;
+ ax25->n2 = opt;
return 0;
case AX25_T3:
if (opt < 1)
return -EINVAL;
- sk->protinfo.ax25->t3 = opt * HZ;
+ ax25->t3 = opt * HZ;
return 0;
case AX25_IDLE:
if (opt < 0)
return -EINVAL;
- sk->protinfo.ax25->idle = opt * 60 * HZ;
+ ax25->idle = opt * 60 * HZ;
return 0;
case AX25_BACKOFF:
if (opt < 0 || opt > 2)
return -EINVAL;
- sk->protinfo.ax25->backoff = opt;
+ ax25->backoff = opt;
return 0;
case AX25_EXTSEQ:
- sk->protinfo.ax25->modulus = opt ? AX25_EMODULUS : AX25_MODULUS;
+ ax25->modulus = opt ? AX25_EMODULUS : AX25_MODULUS;
return 0;
case AX25_PIDINCL:
- sk->protinfo.ax25->pidincl = opt ? 1 : 0;
+ ax25->pidincl = opt ? 1 : 0;
return 0;
case AX25_IAMDIGI:
- sk->protinfo.ax25->iamdigi = opt ? 1 : 0;
+ ax25->iamdigi = opt ? 1 : 0;
return 0;
case AX25_PACLEN:
if (opt < 16 || opt > 65535)
return -EINVAL;
- sk->protinfo.ax25->paclen = opt;
+ ax25->paclen = opt;
return 0;
case SO_BINDTODEVICE:
@@ -723,8 +727,8 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, char *op
(sock->state != SS_UNCONNECTED || sk->state == TCP_LISTEN))
return -EADDRNOTAVAIL;
- sk->protinfo.ax25->ax25_dev = ax25_dev_ax25dev(dev);
- ax25_fillin_cb(sk->protinfo.ax25, sk->protinfo.ax25->ax25_dev);
+ ax25->ax25_dev = ax25_dev_ax25dev(dev);
+ ax25_fillin_cb(ax25, ax25->ax25_dev);
return 0;
default:
@@ -735,6 +739,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, char *op
static int ax25_getsockopt(struct socket *sock, int level, int optname, char *optval, int *optlen)
{
struct sock *sk = sock->sk;
+ ax25_cb *ax25 = ax25_sk(sk);
struct ax25_dev *ax25_dev;
char devname[IFNAMSIZ];
void *valptr;
@@ -755,51 +760,51 @@ static int ax25_getsockopt(struct socket *sock, int level, int optname, char *op
switch (optname) {
case AX25_WINDOW:
- val = sk->protinfo.ax25->window;
+ val = ax25->window;
break;
case AX25_T1:
- val = sk->protinfo.ax25->t1 / HZ;
+ val = ax25->t1 / HZ;
break;
case AX25_T2:
- val = sk->protinfo.ax25->t2 / HZ;
+ val = ax25->t2 / HZ;
break;
case AX25_N2:
- val = sk->protinfo.ax25->n2;
+ val = ax25->n2;
break;
case AX25_T3:
- val = sk->protinfo.ax25->t3 / HZ;
+ val = ax25->t3 / HZ;
break;
case AX25_IDLE:
- val = sk->protinfo.ax25->idle / (60 * HZ);
+ val = ax25->idle / (60 * HZ);
break;
case AX25_BACKOFF:
- val = sk->protinfo.ax25->backoff;
+ val = ax25->backoff;
break;
case AX25_EXTSEQ:
- val = (sk->protinfo.ax25->modulus == AX25_EMODULUS);
+ val = (ax25->modulus == AX25_EMODULUS);
break;
case AX25_PIDINCL:
- val = sk->protinfo.ax25->pidincl;
+ val = ax25->pidincl;
break;
case AX25_IAMDIGI:
- val = sk->protinfo.ax25->iamdigi;
+ val = ax25->iamdigi;
break;
case AX25_PACLEN:
- val = sk->protinfo.ax25->paclen;
+ val = ax25->paclen;
break;
case SO_BINDTODEVICE:
- ax25_dev = sk->protinfo.ax25->ax25_dev;
+ ax25_dev = ax25->ax25_dev;
if (ax25_dev != NULL && ax25_dev->dev != NULL) {
strncpy(devname, ax25_dev->dev->name, IFNAMSIZ);
@@ -884,10 +889,11 @@ int ax25_create(struct socket *sock, int protocol)
return -ESOCKTNOSUPPORT;
}
- if ((sk = sk_alloc(PF_AX25, GFP_ATOMIC, 1)) == NULL)
+ if ((sk = sk_alloc(PF_AX25, GFP_ATOMIC, 1, NULL)) == NULL)
return -ENOMEM;
- if ((ax25 = ax25_create_cb()) == NULL) {
+ ax25 = ax25_sk(sk) = ax25_create_cb();
+ if (!ax25) {
sk_free(sk);
return -ENOMEM;
}
@@ -898,8 +904,7 @@ int ax25_create(struct socket *sock, int protocol)
sock->ops = &ax25_proto_ops;
sk->protocol = protocol;
- ax25->sk = sk;
- sk->protinfo.ax25 = ax25;
+ ax25->sk = sk;
return 0;
}
@@ -907,9 +912,9 @@ int ax25_create(struct socket *sock, int protocol)
struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
{
struct sock *sk;
- ax25_cb *ax25;
+ ax25_cb *ax25, *oax25;
- if ((sk = sk_alloc(PF_AX25, GFP_ATOMIC, 1)) == NULL)
+ if ((sk = sk_alloc(PF_AX25, GFP_ATOMIC, 1, NULL)) == NULL)
return NULL;
if ((ax25 = ax25_create_cb()) == NULL) {
@@ -942,33 +947,35 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
sk->sleep = osk->sleep;
sk->zapped = osk->zapped;
- ax25->modulus = osk->protinfo.ax25->modulus;
- ax25->backoff = osk->protinfo.ax25->backoff;
- ax25->pidincl = osk->protinfo.ax25->pidincl;
- ax25->iamdigi = osk->protinfo.ax25->iamdigi;
- ax25->rtt = osk->protinfo.ax25->rtt;
- ax25->t1 = osk->protinfo.ax25->t1;
- ax25->t2 = osk->protinfo.ax25->t2;
- ax25->t3 = osk->protinfo.ax25->t3;
- ax25->n2 = osk->protinfo.ax25->n2;
- ax25->idle = osk->protinfo.ax25->idle;
- ax25->paclen = osk->protinfo.ax25->paclen;
- ax25->window = osk->protinfo.ax25->window;
+ oax25 = ax25_sk(osk);
+
+ ax25->modulus = oax25->modulus;
+ ax25->backoff = oax25->backoff;
+ ax25->pidincl = oax25->pidincl;
+ ax25->iamdigi = oax25->iamdigi;
+ ax25->rtt = oax25->rtt;
+ ax25->t1 = oax25->t1;
+ ax25->t2 = oax25->t2;
+ ax25->t3 = oax25->t3;
+ ax25->n2 = oax25->n2;
+ ax25->idle = oax25->idle;
+ ax25->paclen = oax25->paclen;
+ ax25->window = oax25->window;
ax25->ax25_dev = ax25_dev;
- ax25->source_addr = osk->protinfo.ax25->source_addr;
+ ax25->source_addr = oax25->source_addr;
- if (osk->protinfo.ax25->digipeat != NULL) {
+ if (oax25->digipeat != NULL) {
if ((ax25->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
sk_free(sk);
return NULL;
}
- memcpy(ax25->digipeat, osk->protinfo.ax25->digipeat, sizeof(ax25_digi));
+ memcpy(ax25->digipeat, oax25->digipeat, sizeof(ax25_digi));
}
- sk->protinfo.ax25 = ax25;
- ax25->sk = sk;
+ ax25_sk(sk) = ax25;
+ ax25->sk = sk;
return sk;
}
@@ -976,45 +983,51 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
static int ax25_release(struct socket *sock)
{
struct sock *sk = sock->sk;
+ ax25_cb *ax25;
if (sk == NULL) return 0;
+ ax25 = ax25_sk(sk);
+
if (sk->type == SOCK_SEQPACKET) {
- switch (sk->protinfo.ax25->state) {
+ switch (ax25->state) {
case AX25_STATE_0:
- ax25_disconnect(sk->protinfo.ax25, 0);
- ax25_destroy_socket(sk->protinfo.ax25);
+ ax25_disconnect(ax25, 0);
+ ax25_destroy_socket(ax25);
break;
case AX25_STATE_1:
case AX25_STATE_2:
- ax25_send_control(sk->protinfo.ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);
- ax25_disconnect(sk->protinfo.ax25, 0);
- ax25_destroy_socket(sk->protinfo.ax25);
+ ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);
+ ax25_disconnect(ax25, 0);
+ ax25_destroy_socket(ax25);
break;
case AX25_STATE_3:
case AX25_STATE_4:
- ax25_clear_queues(sk->protinfo.ax25);
- sk->protinfo.ax25->n2count = 0;
- switch (sk->protinfo.ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) {
+ ax25_clear_queues(ax25);
+ ax25->n2count = 0;
+ switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) {
case AX25_PROTO_STD_SIMPLEX:
case AX25_PROTO_STD_DUPLEX:
- ax25_send_control(sk->protinfo.ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);
- ax25_stop_t2timer(sk->protinfo.ax25);
- ax25_stop_t3timer(sk->protinfo.ax25);
- ax25_stop_idletimer(sk->protinfo.ax25);
+ ax25_send_control(ax25,
+ AX25_DISC,
+ AX25_POLLON,
+ AX25_COMMAND);
+ ax25_stop_t2timer(ax25);
+ ax25_stop_t3timer(ax25);
+ ax25_stop_idletimer(ax25);
break;
#ifdef CONFIG_AX25_DAMA_SLAVE
case AX25_PROTO_DAMA_SLAVE:
- ax25_stop_t3timer(sk->protinfo.ax25);
- ax25_stop_idletimer(sk->protinfo.ax25);
+ ax25_stop_t3timer(ax25);
+ ax25_stop_idletimer(ax25);
break;
#endif
}
- ax25_calculate_t1(sk->protinfo.ax25);
- ax25_start_t1timer(sk->protinfo.ax25);
- sk->protinfo.ax25->state = AX25_STATE_2;
+ ax25_calculate_t1(ax25);
+ ax25_start_t1timer(ax25);
+ ax25->state = AX25_STATE_2;
sk->state = TCP_CLOSE;
sk->shutdown |= SEND_SHUTDOWN;
sk->state_change(sk);
@@ -1030,7 +1043,7 @@ static int ax25_release(struct socket *sock)
sk->shutdown |= SEND_SHUTDOWN;
sk->state_change(sk);
sk->dead = 1;
- ax25_destroy_socket(sk->protinfo.ax25);
+ ax25_destroy_socket(ax25);
}
sock->sk = NULL;
@@ -1048,6 +1061,7 @@ static int ax25_release(struct socket *sock)
static int ax25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sock *sk = sock->sk;
+ ax25_cb *ax25 = ax25_sk(sk);
struct full_sockaddr_ax25 *addr = (struct full_sockaddr_ax25 *)uaddr;
ax25_address *call;
ax25_dev *ax25_dev = NULL;
@@ -1074,15 +1088,15 @@ static int ax25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
return -EACCES;
if (call == NULL)
- sk->protinfo.ax25->source_addr = addr->fsa_ax25.sax25_call;
+ ax25->source_addr = addr->fsa_ax25.sax25_call;
else
- sk->protinfo.ax25->source_addr = *call;
+ ax25->source_addr = *call;
/*
* User already set interface with SO_BINDTODEVICE
*/
- if (sk->protinfo.ax25->ax25_dev != NULL)
+ if (ax25->ax25_dev != NULL)
goto done;
if (addr_len > sizeof(struct sockaddr_ax25) && addr->fsa_ax25.sax25_ndigis == 1) {
@@ -1095,10 +1109,10 @@ static int ax25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
}
if (ax25_dev != NULL)
- ax25_fillin_cb(sk->protinfo.ax25, ax25_dev);
+ ax25_fillin_cb(ax25, ax25_dev);
done:
- ax25_insert_socket(sk->protinfo.ax25);
+ ax25_insert_socket(ax25);
sk->zapped = 0;
return 0;
}
@@ -1109,6 +1123,7 @@ done:
static int ax25_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags)
{
struct sock *sk = sock->sk;
+ ax25_cb *ax25 = ax25_sk(sk);
struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)uaddr;
ax25_digi *digi = NULL;
int ct = 0, err;
@@ -1157,9 +1172,9 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
if (fsa->fsa_ax25.sax25_family != AF_AX25)
return -EINVAL;
- if (sk->protinfo.ax25->digipeat != NULL) {
- kfree(sk->protinfo.ax25->digipeat);
- sk->protinfo.ax25->digipeat = NULL;
+ if (ax25->digipeat != NULL) {
+ kfree(ax25->digipeat);
+ ax25->digipeat = NULL;
}
/*
@@ -1177,7 +1192,8 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
digi->lastrepeat = -1;
while (ct < fsa->fsa_ax25.sax25_ndigis) {
- if ((fsa->fsa_digipeater[ct].ax25_call[6] & AX25_HBIT) && sk->protinfo.ax25->iamdigi) {
+ if ((fsa->fsa_digipeater[ct].ax25_call[6] &
+ AX25_HBIT) && ax25->iamdigi) {
digi->repeated[ct] = 1;
digi->lastrepeat = ct;
} else {
@@ -1197,22 +1213,24 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
/* check if we can remove this feature. It is broken. */
printk(KERN_WARNING "ax25_connect(): %s uses autobind, please contact jreuter@yaina.de\n",
current->comm);
- if ((err = ax25_rt_autobind(sk->protinfo.ax25, &fsa->fsa_ax25.sax25_call)) < 0)
+ if ((err = ax25_rt_autobind(ax25, &fsa->fsa_ax25.sax25_call)) < 0)
return err;
- ax25_fillin_cb(sk->protinfo.ax25, sk->protinfo.ax25->ax25_dev);
- ax25_insert_socket(sk->protinfo.ax25);
+ ax25_fillin_cb(ax25, ax25->ax25_dev);
+ ax25_insert_socket(ax25);
} else {
- if (sk->protinfo.ax25->ax25_dev == NULL)
+ if (ax25->ax25_dev == NULL)
return -EHOSTUNREACH;
}
- if (sk->type == SOCK_SEQPACKET && ax25_find_cb(&sk->protinfo.ax25->source_addr, &fsa->fsa_ax25.sax25_call, digi, sk->protinfo.ax25->ax25_dev->dev) != NULL) {
+ if (sk->type == SOCK_SEQPACKET &&
+ ax25_find_cb(&ax25->source_addr, &fsa->fsa_ax25.sax25_call, digi,
+ ax25->ax25_dev->dev)) {
if (digi != NULL) kfree(digi);
return -EADDRINUSE; /* Already such a connection */
}
- sk->protinfo.ax25->dest_addr = fsa->fsa_ax25.sax25_call;
- sk->protinfo.ax25->digipeat = digi;
+ ax25->dest_addr = fsa->fsa_ax25.sax25_call;
+ ax25->digipeat = digi;
/* First the easy one */
if (sk->type != SOCK_SEQPACKET) {
@@ -1225,27 +1243,28 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
sock->state = SS_CONNECTING;
sk->state = TCP_SYN_SENT;
- switch (sk->protinfo.ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) {
+ switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) {
case AX25_PROTO_STD_SIMPLEX:
case AX25_PROTO_STD_DUPLEX:
- ax25_std_establish_data_link(sk->protinfo.ax25);
+ ax25_std_establish_data_link(ax25);
break;
#ifdef CONFIG_AX25_DAMA_SLAVE
case AX25_PROTO_DAMA_SLAVE:
- sk->protinfo.ax25->modulus = AX25_MODULUS;
- sk->protinfo.ax25->window = sk->protinfo.ax25->ax25_dev->values[AX25_VALUES_WINDOW];
- if (sk->protinfo.ax25->ax25_dev->dama.slave)
- ax25_ds_establish_data_link(sk->protinfo.ax25);
+ ax25->modulus = AX25_MODULUS;
+ ax25->window =
+ ax25->ax25_dev->values[AX25_VALUES_WINDOW];
+ if (ax25->ax25_dev->dama.slave)
+ ax25_ds_establish_data_link(ax25);
else
- ax25_std_establish_data_link(sk->protinfo.ax25);
+ ax25_std_establish_data_link(ax25);
break;
#endif
}
- sk->protinfo.ax25->state = AX25_STATE_1;
+ ax25->state = AX25_STATE_1;
- ax25_start_heartbeat(sk->protinfo.ax25);
+ ax25_start_heartbeat(ax25);
/* Now the loop */
if (sk->state != TCP_ESTABLISHED && (flags & O_NONBLOCK))
@@ -1327,6 +1346,7 @@ static int ax25_accept(struct socket *sock, struct socket *newsock, int flags)
static int ax25_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer)
{
struct sock *sk = sock->sk;
+ ax25_cb *ax25 = ax25_sk(sk);
struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)uaddr;
unsigned char ndigi, i;
@@ -1335,21 +1355,23 @@ static int ax25_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_
return -ENOTCONN;
fsa->fsa_ax25.sax25_family = AF_AX25;
- fsa->fsa_ax25.sax25_call = sk->protinfo.ax25->dest_addr;
+ fsa->fsa_ax25.sax25_call = ax25->dest_addr;
fsa->fsa_ax25.sax25_ndigis = 0;
- if (sk->protinfo.ax25->digipeat != NULL) {
- ndigi = sk->protinfo.ax25->digipeat->ndigi;
+ if (ax25->digipeat != NULL) {
+ ndigi = ax25->digipeat->ndigi;
fsa->fsa_ax25.sax25_ndigis = ndigi;
for (i = 0; i < ndigi; i++)
- fsa->fsa_digipeater[i] = sk->protinfo.ax25->digipeat->calls[i];
+ fsa->fsa_digipeater[i] =
+ ax25->digipeat->calls[i];
}
} else {
fsa->fsa_ax25.sax25_family = AF_AX25;
- fsa->fsa_ax25.sax25_call = sk->protinfo.ax25->source_addr;
+ fsa->fsa_ax25.sax25_call = ax25->source_addr;
fsa->fsa_ax25.sax25_ndigis = 1;
- if (sk->protinfo.ax25->ax25_dev != NULL) {
- memcpy(&fsa->fsa_digipeater[0], sk->protinfo.ax25->ax25_dev->dev->dev_addr, AX25_ADDR_LEN);
+ if (ax25->ax25_dev != NULL) {
+ memcpy(&fsa->fsa_digipeater[0],
+ ax25->ax25_dev->dev->dev_addr, AX25_ADDR_LEN);
} else {
fsa->fsa_digipeater[0] = null_ax25_address;
}
@@ -1361,6 +1383,7 @@ static int ax25_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_
static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ ax25_cb *ax25 = ax25_sk(sk);
struct sockaddr_ax25 *usax = (struct sockaddr_ax25 *)msg->msg_name;
int err;
struct sockaddr_ax25 sax;
@@ -1383,7 +1406,7 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
return -EPIPE;
}
- if (sk->protinfo.ax25->ax25_dev == NULL)
+ if (ax25->ax25_dev == NULL)
return -ENETUNREACH;
if (usax != NULL) {
@@ -1424,7 +1447,7 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
}
sax = *usax;
- if (sk->type == SOCK_SEQPACKET && ax25cmp(&sk->protinfo.ax25->dest_addr, &sax.sax25_call) != 0)
+ if (sk->type == SOCK_SEQPACKET && ax25cmp(&ax25->dest_addr, &sax.sax25_call) != 0)
return -EISCONN;
if (usax->sax25_ndigis == 0)
dp = NULL;
@@ -1439,8 +1462,8 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
if (sk->state != TCP_ESTABLISHED)
return -ENOTCONN;
sax.sax25_family = AF_AX25;
- sax.sax25_call = sk->protinfo.ax25->dest_addr;
- dp = sk->protinfo.ax25->digipeat;
+ sax.sax25_call = ax25->dest_addr;
+ dp = ax25->digipeat;
}
SOCK_DEBUG(sk, "AX.25: sendto: Addresses built.\n");
@@ -1463,7 +1486,7 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
skb->nh.raw = skb->data;
/* Add the PID if one is not supplied by the user in the skb */
- if (!sk->protinfo.ax25->pidincl) {
+ if (!ax25->pidincl) {
asmptr = skb_push(skb, 1);
*asmptr = sk->protocol;
}
@@ -1477,7 +1500,8 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
return -ENOTCONN;
}
- ax25_output(sk->protinfo.ax25, sk->protinfo.ax25->paclen, skb); /* Shove it onto the queue and kick */
+ /* Shove it onto the queue and kick */
+ ax25_output(ax25, ax25->paclen, skb);
return len;
} else {
@@ -1489,7 +1513,9 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
SOCK_DEBUG(sk, "Num digipeaters=%d\n", dp->ndigi);
/* Build an AX.25 header */
- asmptr += (lv = ax25_addr_build(asmptr, &sk->protinfo.ax25->source_addr, &sax.sax25_call, dp, AX25_COMMAND, AX25_MODULUS));
+ asmptr += (lv = ax25_addr_build(asmptr, &ax25->source_addr,
+ &sax.sax25_call, dp,
+ AX25_COMMAND, AX25_MODULUS));
SOCK_DEBUG(sk, "Built header (%d bytes)\n",lv);
@@ -1500,7 +1526,7 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
*asmptr = AX25_UI;
/* Datagram frames go straight out of the door as UI */
- skb->dev = sk->protinfo.ax25->ax25_dev->dev;
+ skb->dev = ax25->ax25_dev->dev;
ax25_queue_xmit(skb);
@@ -1526,7 +1552,7 @@ static int ax25_recvmsg(struct socket *sock, struct msghdr *msg, int size, int f
if ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL)
return er;
- if (!sk->protinfo.ax25->pidincl)
+ if (!ax25_sk(sk)->pidincl)
skb_pull(skb, 1); /* Remove PID */
skb->h.raw = skb->data;
@@ -1639,27 +1665,28 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case SIOCAX25GETINFO:
case SIOCAX25GETINFOOLD: {
+ ax25_cb *ax25 = ax25_sk(sk);
struct ax25_info_struct ax25_info;
- ax25_info.t1 = sk->protinfo.ax25->t1 / HZ;
- ax25_info.t2 = sk->protinfo.ax25->t2 / HZ;
- ax25_info.t3 = sk->protinfo.ax25->t3 / HZ;
- ax25_info.idle = sk->protinfo.ax25->idle / (60 * HZ);
- ax25_info.n2 = sk->protinfo.ax25->n2;
- ax25_info.t1timer = ax25_display_timer(&sk->protinfo.ax25->t1timer) / HZ;
- ax25_info.t2timer = ax25_display_timer(&sk->protinfo.ax25->t2timer) / HZ;
- ax25_info.t3timer = ax25_display_timer(&sk->protinfo.ax25->t3timer) / HZ;
- ax25_info.idletimer = ax25_display_timer(&sk->protinfo.ax25->idletimer) / (60 * HZ);
- ax25_info.n2count = sk->protinfo.ax25->n2count;
- ax25_info.state = sk->protinfo.ax25->state;
+ ax25_info.t1 = ax25->t1 / HZ;
+ ax25_info.t2 = ax25->t2 / HZ;
+ ax25_info.t3 = ax25->t3 / HZ;
+ ax25_info.idle = ax25->idle / (60 * HZ);
+ ax25_info.n2 = ax25->n2;
+ ax25_info.t1timer = ax25_display_timer(&ax25->t1timer) / HZ;
+ ax25_info.t2timer = ax25_display_timer(&ax25->t2timer) / HZ;
+ ax25_info.t3timer = ax25_display_timer(&ax25->t3timer) / HZ;
+ ax25_info.idletimer = ax25_display_timer(&ax25->idletimer) / (60 * HZ);
+ ax25_info.n2count = ax25->n2count;
+ ax25_info.state = ax25->state;
ax25_info.rcv_q = atomic_read(&sk->rmem_alloc);
ax25_info.snd_q = atomic_read(&sk->wmem_alloc);
- ax25_info.vs = sk->protinfo.ax25->vs;
- ax25_info.vr = sk->protinfo.ax25->vr;
- ax25_info.va = sk->protinfo.ax25->va;
- ax25_info.vs_max = sk->protinfo.ax25->vs; /* reserved */
- ax25_info.paclen = sk->protinfo.ax25->paclen;
- ax25_info.window = sk->protinfo.ax25->window;
+ ax25_info.vs = ax25->vs;
+ ax25_info.vr = ax25->vr;
+ ax25_info.va = ax25->va;
+ ax25_info.vs_max = ax25->vs; /* reserved */
+ ax25_info.paclen = ax25->paclen;
+ ax25_info.window = ax25->window;
/* old structure? */
if (cmd == SIOCAX25GETINFOOLD) {
diff --git a/net/ax25/ax25_ds_in.c b/net/ax25/ax25_ds_in.c
index 6c65baea5..2ae715ec3 100644
--- a/net/ax25/ax25_ds_in.c
+++ b/net/ax25/ax25_ds_in.c
@@ -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>
diff --git a/net/ax25/ax25_ds_timer.c b/net/ax25/ax25_ds_timer.c
index 3c5b2ea9c..b11045192 100644
--- a/net/ax25/ax25_ds_timer.c
+++ b/net/ax25/ax25_ds_timer.c
@@ -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>
diff --git a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c
index 22a83a2d9..2abbd886c 100644
--- a/net/ax25/ax25_in.c
+++ b/net/ax25/ax25_in.c
@@ -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);
diff --git a/net/ax25/ax25_std_in.c b/net/ax25/ax25_std_in.c
index d1cfc3ff9..b68155f38 100644
--- a/net/ax25/ax25_std_in.c
+++ b/net/ax25/ax25_std_in.c
@@ -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>
diff --git a/net/ax25/ax25_std_timer.c b/net/ax25/ax25_std_timer.c
index 5a2d8771c..741e08d23 100644
--- a/net/ax25/ax25_std_timer.c
+++ b/net/ax25/ax25_std_timer.c
@@ -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>
diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index 3ac22ea07..c49892720 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -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>
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index bd88913d4..a83c891a0 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -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)
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 89a892f79..36b767a46 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -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 = {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 094feb068..8e674b55d 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -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 = {
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 709166f70..5d0c4104a 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -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>
diff --git a/net/core/sock.c b/net/core/sock.c
index e28084155..18416e41e 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -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 @@ lenout:
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)
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index ca33e3274..9bafdda7e 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -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;
}
diff --git a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c
index b028a3ba0..115febdf2 100644
--- a/net/decnet/dn_nsp_in.c
+++ b/net/decnet/dn_nsp_in.c
@@ -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);
}
diff --git a/net/decnet/dn_nsp_out.c b/net/decnet/dn_nsp_out.c
index 76faff30e..d77ba3c65 100644
--- a/net/decnet/dn_nsp_out.c
+++ b/net/decnet/dn_nsp_out.c
@@ -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)
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c
index d54391b27..e9fa912af 100644
--- a/net/econet/af_econet.c
+++ b/net/econet/af_econet.c
@@ -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))
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index b57940a0d..3b8491c9f 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -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 @@ out:
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...
*/
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 6e7de5a31..d3bf90d2b 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -3,7 +3,7 @@
*
* Alan Cox, <alan@redhat.com>
*
- * Version: $Id: icmp.c,v 1.84 2002-01-30 01:40:01 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
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index c81ba1b5a..c1c33a902 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -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 @@ done:
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);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 9f2863faf..a776cb9ab 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -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 @@ fragment:
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 @@ packet_routed:
/* 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);
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index ce22254a5..abf6d064f 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -5,7 +5,7 @@
*
* The IP to API glue.
*
- * Version: $Id: ip_sockglue.c,v 1.61 2001-10-20 00:00:11 davem Exp $
+ * Version: $Id: ip_sockglue.c,v 1.62 2002-02-01 22:01:04 davem Exp $
*
* Authors: see ip.c
*
@@ -110,7 +110,8 @@ void ip_cmsg_recv_retopts(struct msghdr *msg, struct sk_buff *skb)
void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb)
{
- unsigned flags = skb->sk->protinfo.af_inet.cmsg_flags;
+ struct inet_opt *inet = inet_sk(skb->sk);
+ unsigned flags = inet->cmsg_flags;
/* Ordered by supposed usage frequency */
if (flags & 1)
@@ -234,9 +235,10 @@ int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct s
void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
u16 port, u32 info, u8 *payload)
{
+ struct inet_opt *inet = inet_sk(sk);
struct sock_exterr_skb *serr;
- if (!sk->protinfo.af_inet.recverr)
+ if (!inet->recverr)
return;
skb = skb_clone(skb, GFP_ATOMIC);
@@ -262,11 +264,12 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
void ip_local_error(struct sock *sk, int err, u32 daddr, u16 port, u32 info)
{
+ struct inet_opt *inet = inet_sk(sk);
struct sock_exterr_skb *serr;
struct iphdr *iph;
struct sk_buff *skb;
- if (!sk->protinfo.af_inet.recverr)
+ if (!inet->recverr)
return;
skb = alloc_skb(sizeof(struct iphdr), GFP_ATOMIC);
@@ -340,11 +343,13 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len)
sin = &errhdr.offender;
sin->sin_family = AF_UNSPEC;
if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP) {
+ struct inet_opt *inet = inet_sk(sk);
+
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = skb->nh.iph->saddr;
sin->sin_port = 0;
memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
- if (sk->protinfo.af_inet.cmsg_flags)
+ if (inet->cmsg_flags)
ip_cmsg_recv(msg, skb);
}
@@ -380,6 +385,7 @@ out:
int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen)
{
+ struct inet_opt *inet = inet_sk(sk);
int val=0,err;
if (level != SOL_IP)
@@ -425,7 +431,7 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt
if (err)
break;
if (sk->type == SOCK_STREAM) {
- struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
+ struct tcp_opt *tp = tcp_sk(sk);
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
if (sk->family == PF_INET ||
(!((1<<sk->state)&(TCPF_LISTEN|TCPF_CLOSE))
@@ -438,53 +444,53 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt
}
#endif
}
- opt = xchg(&sk->protinfo.af_inet.opt, opt);
+ opt = xchg(&inet->opt, opt);
if (opt)
kfree(opt);
break;
}
case IP_PKTINFO:
if (val)
- sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_PKTINFO;
+ inet->cmsg_flags |= IP_CMSG_PKTINFO;
else
- sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_PKTINFO;
+ inet->cmsg_flags &= ~IP_CMSG_PKTINFO;
break;
case IP_RECVTTL:
if (val)
- sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_TTL;
+ inet->cmsg_flags |= IP_CMSG_TTL;
else
- sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_TTL;
+ inet->cmsg_flags &= ~IP_CMSG_TTL;
break;
case IP_RECVTOS:
if (val)
- sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_TOS;
+ inet->cmsg_flags |= IP_CMSG_TOS;
else
- sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_TOS;
+ inet->cmsg_flags &= ~IP_CMSG_TOS;
break;
case IP_RECVOPTS:
if (val)
- sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_RECVOPTS;
+ inet->cmsg_flags |= IP_CMSG_RECVOPTS;
else
- sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_RECVOPTS;
+ inet->cmsg_flags &= ~IP_CMSG_RECVOPTS;
break;
case IP_RETOPTS:
if (val)
- sk->protinfo.af_inet.cmsg_flags |= IP_CMSG_RETOPTS;
+ inet->cmsg_flags |= IP_CMSG_RETOPTS;
else
- sk->protinfo.af_inet.cmsg_flags &= ~IP_CMSG_RETOPTS;
+ inet->cmsg_flags &= ~IP_CMSG_RETOPTS;
break;
case IP_TOS: /* This sets both TOS and Precedence */
if (sk->type == SOCK_STREAM) {
val &= ~3;
- val |= sk->protinfo.af_inet.tos & 3;
+ val |= inet->tos & 3;
}
if (IPTOS_PREC(val) >= IPTOS_PREC_CRITIC_ECP &&
!capable(CAP_NET_ADMIN)) {
err = -EPERM;
break;
}
- if (sk->protinfo.af_inet.tos != val) {
- sk->protinfo.af_inet.tos=val;
+ if (inet->tos != val) {
+ inet->tos = val;
sk->priority = rt_tos2priority(val);
sk_dst_reset(sk);
}
@@ -496,22 +502,22 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt
val = sysctl_ip_default_ttl;
if(val<1||val>255)
goto e_inval;
- sk->protinfo.af_inet.ttl=val;
+ inet->ttl = val;
break;
case IP_HDRINCL:
if(sk->type!=SOCK_RAW) {
err = -ENOPROTOOPT;
break;
}
- sk->protinfo.af_inet.hdrincl=val?1:0;
+ inet->hdrincl = val ? 1 : 0;
break;
case IP_MTU_DISCOVER:
if (val<0 || val>2)
goto e_inval;
- sk->protinfo.af_inet.pmtudisc = val;
+ inet->pmtudisc = val;
break;
case IP_RECVERR:
- sk->protinfo.af_inet.recverr = !!val;
+ inet->recverr = !!val;
if (!val)
skb_queue_purge(&sk->error_queue);
break;
@@ -524,12 +530,12 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt
val = 1;
if (val < 0 || val > 255)
goto e_inval;
- sk->protinfo.af_inet.mc_ttl=val;
+ inet->mc_ttl = val;
break;
case IP_MULTICAST_LOOP:
if (optlen<1)
goto e_inval;
- sk->protinfo.af_inet.mc_loop = val ? 1 : 0;
+ inet->mc_loop = !!val;
break;
case IP_MULTICAST_IF:
{
@@ -555,8 +561,8 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt
if (!mreq.imr_ifindex) {
if (mreq.imr_address.s_addr == INADDR_ANY) {
- sk->protinfo.af_inet.mc_index = 0;
- sk->protinfo.af_inet.mc_addr = 0;
+ inet->mc_index = 0;
+ inet->mc_addr = 0;
err = 0;
break;
}
@@ -577,8 +583,8 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt
if (sk->bound_dev_if && mreq.imr_ifindex != sk->bound_dev_if)
break;
- sk->protinfo.af_inet.mc_index = mreq.imr_ifindex;
- sk->protinfo.af_inet.mc_addr = mreq.imr_address.s_addr;
+ inet->mc_index = mreq.imr_ifindex;
+ inet->mc_addr = mreq.imr_address.s_addr;
err = 0;
break;
}
@@ -613,7 +619,7 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt
case IP_FREEBIND:
if (optlen<1)
goto e_inval;
- sk->protinfo.af_inet.freebind = !!val;
+ inet->freebind = !!val;
break;
default:
@@ -640,6 +646,7 @@ e_inval:
int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen)
{
+ struct inet_opt *inet = inet_sk(sk);
int val;
int len;
@@ -666,10 +673,10 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op
unsigned char optbuf[sizeof(struct ip_options)+40];
struct ip_options * opt = (struct ip_options*)optbuf;
opt->optlen = 0;
- if (sk->protinfo.af_inet.opt)
- memcpy(optbuf, sk->protinfo.af_inet.opt,
+ if (inet->opt)
+ memcpy(optbuf, inet->opt,
sizeof(struct ip_options)+
- sk->protinfo.af_inet.opt->optlen);
+ inet->opt->optlen);
release_sock(sk);
if (opt->optlen == 0)
@@ -685,31 +692,31 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op
return 0;
}
case IP_PKTINFO:
- val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_PKTINFO) != 0;
+ val = (inet->cmsg_flags & IP_CMSG_PKTINFO) != 0;
break;
case IP_RECVTTL:
- val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_TTL) != 0;
+ val = (inet->cmsg_flags & IP_CMSG_TTL) != 0;
break;
case IP_RECVTOS:
- val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_TOS) != 0;
+ val = (inet->cmsg_flags & IP_CMSG_TOS) != 0;
break;
case IP_RECVOPTS:
- val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_RECVOPTS) != 0;
+ val = (inet->cmsg_flags & IP_CMSG_RECVOPTS) != 0;
break;
case IP_RETOPTS:
- val = (sk->protinfo.af_inet.cmsg_flags & IP_CMSG_RETOPTS) != 0;
+ val = (inet->cmsg_flags & IP_CMSG_RETOPTS) != 0;
break;
case IP_TOS:
- val=sk->protinfo.af_inet.tos;
+ val = inet->tos;
break;
case IP_TTL:
- val=sk->protinfo.af_inet.ttl;
+ val = inet->ttl;
break;
case IP_HDRINCL:
- val=sk->protinfo.af_inet.hdrincl;
+ val = inet->hdrincl;
break;
case IP_MTU_DISCOVER:
- val=sk->protinfo.af_inet.pmtudisc;
+ val = inet->pmtudisc;
break;
case IP_MTU:
{
@@ -727,19 +734,19 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op
break;
}
case IP_RECVERR:
- val=sk->protinfo.af_inet.recverr;
+ val = inet->recverr;
break;
case IP_MULTICAST_TTL:
- val=sk->protinfo.af_inet.mc_ttl;
+ val = inet->mc_ttl;
break;
case IP_MULTICAST_LOOP:
- val=sk->protinfo.af_inet.mc_loop;
+ val = inet->mc_loop;
break;
case IP_MULTICAST_IF:
{
struct in_addr addr;
len = min_t(unsigned int, len, sizeof(struct in_addr));
- addr.s_addr = sk->protinfo.af_inet.mc_addr;
+ addr.s_addr = inet->mc_addr;
release_sock(sk);
if(put_user(len, optlen))
@@ -761,23 +768,23 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op
msg.msg_controllen = len;
msg.msg_flags = 0;
- if (sk->protinfo.af_inet.cmsg_flags&IP_CMSG_PKTINFO) {
+ if (inet->cmsg_flags & IP_CMSG_PKTINFO) {
struct in_pktinfo info;
info.ipi_addr.s_addr = sk->rcv_saddr;
info.ipi_spec_dst.s_addr = sk->rcv_saddr;
- info.ipi_ifindex = sk->protinfo.af_inet.mc_index;
+ info.ipi_ifindex = inet->mc_index;
put_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info);
}
- if (sk->protinfo.af_inet.cmsg_flags&IP_CMSG_TTL) {
- int hlim = sk->protinfo.af_inet.mc_ttl;
+ if (inet->cmsg_flags & IP_CMSG_TTL) {
+ int hlim = inet->mc_ttl;
put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim);
}
len -= msg.msg_controllen;
return put_user(len, optlen);
}
case IP_FREEBIND:
- val = sk->protinfo.af_inet.freebind;
+ val = inet->freebind;
break;
default:
#ifdef CONFIG_NETFILTER
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 852967b89..53dc51a10 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -1,5 +1,5 @@
/*
- * $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 */
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 939f52abc..97f23d5c4 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -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>
diff --git a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c
index 9d74357f0..eaf18396f 100644
--- a/net/ipv4/netfilter/ip_nat_snmp_basic.c
+++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c
@@ -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>
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index b9c5c45ad..c145b33c1 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -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>
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 31ccbec64..c2e4c5fd7 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -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 @@ out:
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 @@ back_from_confirm:
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;
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index dbd6a7ac9..5cb677f61 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -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;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3ed875e58..5f5d63aea 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -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 @@ adjudge_to_death:
*/
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 @@ out:
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)
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index db0b553d6..d5403e7cc 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -1,7 +1,7 @@
/*
* 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;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index b986f2a2e..24c719043 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5,7 +5,7 @@
*
* Implementation of the Transmission Control Protocol(TCP).
*
- * Version: $Id: tcp_input.c,v 1.242 2001-12-11 06:11:53 davem Exp $
+ * Version: $Id: tcp_input.c,v 1.243 2002-02-01 22:01:04 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -190,8 +190,8 @@ static __inline__ int tcp_in_quickack_mode(struct tcp_opt *tp)
static void tcp_fixup_sndbuf(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
- int sndmem = tp->mss_clamp+MAX_TCP_HEADER+16+sizeof(struct sk_buff);
+ int sndmem = tcp_sk(sk)->mss_clamp + MAX_TCP_HEADER + 16 +
+ sizeof(struct sk_buff);
if (sk->sndbuf < 3*sndmem)
sk->sndbuf = min(3*sndmem, sysctl_tcp_wmem[2]);
@@ -268,8 +268,8 @@ tcp_grow_window(struct sock *sk, struct tcp_opt *tp, struct sk_buff *skb)
static void tcp_fixup_rcvbuf(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
- int rcvmem = tp->advmss+MAX_TCP_HEADER+16+sizeof(struct sk_buff);
+ struct tcp_opt *tp = tcp_sk(sk);
+ int rcvmem = tp->advmss + MAX_TCP_HEADER + 16 + sizeof(struct sk_buff);
/* Try to select rcvbuf so that 4 mss-sized segments
* will fit to window and correspoding skbs will fit to our rcvbuf.
@@ -286,7 +286,7 @@ static void tcp_fixup_rcvbuf(struct sock *sk)
*/
static void tcp_init_buffer_space(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
int maxwin;
if (!(sk->userlocks&SOCK_RCVBUF_LOCK))
@@ -299,15 +299,17 @@ static void tcp_init_buffer_space(struct sock *sk)
if (tp->window_clamp >= maxwin) {
tp->window_clamp = maxwin;
- if (sysctl_tcp_app_win && maxwin>4*tp->advmss)
- tp->window_clamp = max(maxwin-(maxwin>>sysctl_tcp_app_win), 4*tp->advmss);
+ if (sysctl_tcp_app_win && maxwin > 4 * tp->advmss)
+ tp->window_clamp = max(maxwin -
+ (maxwin >> sysctl_tcp_app_win),
+ 4 * tp->advmss);
}
/* Force reservation of one segment. */
if (sysctl_tcp_app_win &&
- tp->window_clamp > 2*tp->advmss &&
+ tp->window_clamp > 2 * tp->advmss &&
tp->window_clamp + tp->advmss > maxwin)
- tp->window_clamp = max(2*tp->advmss, maxwin-tp->advmss);
+ tp->window_clamp = max(2 * tp->advmss, maxwin - tp->advmss);
tp->rcv_ssthresh = min(tp->rcv_ssthresh, tp->window_clamp);
tp->snd_cwnd_stamp = tcp_time_stamp;
@@ -512,7 +514,7 @@ static __inline__ void tcp_bound_rto(struct tcp_opt *tp)
*/
void tcp_update_metrics(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);
dst_confirm(dst);
@@ -562,8 +564,8 @@ void tcp_update_metrics(struct sock *sk)
/* Slow start still did not finish. */
if (dst->ssthresh &&
!(dst->mxlock&(1<<RTAX_SSTHRESH)) &&
- (tp->snd_cwnd>>1) > dst->ssthresh)
- dst->ssthresh = (tp->snd_cwnd>>1);
+ (tp->snd_cwnd >> 1) > dst->ssthresh)
+ dst->ssthresh = tp->snd_cwnd >> 1;
if (!(dst->mxlock&(1<<RTAX_CWND)) &&
tp->snd_cwnd > dst->cwnd)
dst->cwnd = tp->snd_cwnd;
@@ -571,15 +573,16 @@ void tcp_update_metrics(struct sock *sk)
tp->ca_state == TCP_CA_Open) {
/* Cong. avoidance phase, cwnd is reliable. */
if (!(dst->mxlock&(1<<RTAX_SSTHRESH)))
- dst->ssthresh = max(tp->snd_cwnd>>1, tp->snd_ssthresh);
+ dst->ssthresh = max(tp->snd_cwnd >> 1,
+ tp->snd_ssthresh);
if (!(dst->mxlock&(1<<RTAX_CWND)))
- dst->cwnd = (dst->cwnd + tp->snd_cwnd)>>1;
+ dst->cwnd = (dst->cwnd + tp->snd_cwnd) >> 1;
} else {
/* Else slow start did not finish, cwnd is non-sense,
ssthresh may be also invalid.
*/
if (!(dst->mxlock&(1<<RTAX_CWND)))
- dst->cwnd = (dst->cwnd + tp->snd_ssthresh)>>1;
+ dst->cwnd = (dst->cwnd + tp->snd_ssthresh) >> 1;
if (dst->ssthresh &&
!(dst->mxlock&(1<<RTAX_SSTHRESH)) &&
tp->snd_ssthresh > dst->ssthresh)
@@ -620,7 +623,7 @@ __u32 tcp_init_cwnd(struct tcp_opt *tp)
static void tcp_init_metrics(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);
if (dst == NULL)
@@ -643,7 +646,7 @@ static void tcp_init_metrics(struct sock *sk)
if (dst->rtt == 0)
goto reset;
- if (!tp->srtt && dst->rtt < (TCP_TIMEOUT_INIT<<3))
+ if (!tp->srtt && dst->rtt < (TCP_TIMEOUT_INIT << 3))
goto reset;
/* Initial rtt is determined from SYN,SYN-ACK.
@@ -762,7 +765,7 @@ static void tcp_update_reordering(struct tcp_opt *tp, int metric, int ts)
static int
tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_una)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
unsigned char *ptr = ack_skb->h.raw + TCP_SKB_CB(ack_skb)->sacked;
struct tcp_sack_block *sp = (struct tcp_sack_block *)(ptr+2);
int num_sacks = (ptr[1] - TCPOLEN_SACK_BASE)>>3;
@@ -810,7 +813,7 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
* account more or less fresh ones, they can
* contain valid SACK info.
*/
- if (before(ack, prior_snd_una-tp->max_window))
+ if (before(ack, prior_snd_una - tp->max_window))
return 0;
}
@@ -930,7 +933,9 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
if ((TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_RETRANS) &&
after(lost_retrans, TCP_SKB_CB(skb)->ack_seq) &&
(IsFack(tp) ||
- !before(lost_retrans, TCP_SKB_CB(skb)->ack_seq+tp->reordering*tp->mss_cache))) {
+ !before(lost_retrans,
+ TCP_SKB_CB(skb)->ack_seq + tp->reordering *
+ tp->mss_cache))) {
TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS;
tp->retrans_out--;
@@ -947,7 +952,7 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
tp->left_out = tp->sacked_out + tp->lost_out;
if (reord < tp->fackets_out && tp->ca_state != TCP_CA_Loss)
- tcp_update_reordering(tp, (tp->fackets_out+1)-reord, 0);
+ tcp_update_reordering(tp, (tp->fackets_out + 1) - reord, 0);
#if FASTRETRANS_DEBUG > 0
BUG_TRAP((int)tp->sacked_out >= 0);
@@ -977,19 +982,18 @@ void tcp_clear_retrans(struct tcp_opt *tp)
*/
void tcp_enter_loss(struct sock *sk, int how)
{
- struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
+ struct tcp_opt *tp = tcp_sk(sk);
struct sk_buff *skb;
int cnt = 0;
/* Reduce ssthresh if it has not yet been made inside this window. */
- if (tp->ca_state <= TCP_CA_Disorder ||
- tp->snd_una == tp->high_seq ||
+ if (tp->ca_state <= TCP_CA_Disorder || tp->snd_una == tp->high_seq ||
(tp->ca_state == TCP_CA_Loss && !tp->retransmits)) {
tp->prior_ssthresh = tcp_current_ssthresh(tp);
tp->snd_ssthresh = tcp_recalc_ssthresh(tp);
}
- tp->snd_cwnd = 1;
- tp->snd_cwnd_cnt = 0;
+ tp->snd_cwnd = 1;
+ tp->snd_cwnd_cnt = 0;
tp->snd_cwnd_stamp = tcp_time_stamp;
tcp_clear_retrans(tp);
@@ -1015,7 +1019,8 @@ void tcp_enter_loss(struct sock *sk, int how)
}
tcp_sync_left_out(tp);
- tp->reordering = min_t(unsigned int, tp->reordering, sysctl_tcp_reordering);
+ tp->reordering = min_t(unsigned int, tp->reordering,
+ sysctl_tcp_reordering);
tp->ca_state = TCP_CA_Loss;
tp->high_seq = tp->snd_nxt;
TCP_ECN_queue_cwr(tp);
@@ -1493,7 +1498,7 @@ static void
tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una,
int prior_packets, int flag)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
int is_dupack = (tp->snd_una == prior_snd_una && !(flag&FLAG_NOT_DUP));
/* Some technical things:
@@ -1735,13 +1740,13 @@ static __inline__ void tcp_ack_packets_out(struct sock *sk, struct tcp_opt *tp)
/* Remove acknowledged frames from the retransmission queue. */
static int tcp_clean_rtx_queue(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
struct sk_buff *skb;
__u32 now = tcp_time_stamp;
int acked = 0;
__s32 seq_rtt = -1;
- while((skb=skb_peek(&sk->write_queue)) && (skb != tp->send_head)) {
+ while((skb = skb_peek(&sk->write_queue)) && (skb != tp->send_head)) {
struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
__u8 sacked = scb->sacked;
@@ -1784,7 +1789,7 @@ static int tcp_clean_rtx_queue(struct sock *sk)
}
} else if (seq_rtt < 0)
seq_rtt = now - scb->when;
- if(tp->fackets_out)
+ if (tp->fackets_out)
tp->fackets_out--;
tp->packets_out--;
__skb_unlink(skb, skb->list);
@@ -1800,17 +1805,20 @@ static int tcp_clean_rtx_queue(struct sock *sk)
BUG_TRAP((int)tp->sacked_out >= 0);
BUG_TRAP((int)tp->lost_out >= 0);
BUG_TRAP((int)tp->retrans_out >= 0);
- if (tp->packets_out==0 && tp->sack_ok) {
+ if (!tp->packets_out && tp->sack_ok) {
if (tp->lost_out) {
- printk(KERN_DEBUG "Leak l=%u %d\n", tp->lost_out, tp->ca_state);
+ printk(KERN_DEBUG "Leak l=%u %d\n", tp->lost_out,
+ tp->ca_state);
tp->lost_out = 0;
}
if (tp->sacked_out) {
- printk(KERN_DEBUG "Leak s=%u %d\n", tp->sacked_out, tp->ca_state);
+ printk(KERN_DEBUG "Leak s=%u %d\n", tp->sacked_out,
+ tp->ca_state);
tp->sacked_out = 0;
}
if (tp->retrans_out) {
- printk(KERN_DEBUG "Leak r=%u %d\n", tp->retrans_out, tp->ca_state);
+ printk(KERN_DEBUG "Leak r=%u %d\n", tp->retrans_out,
+ tp->ca_state);
tp->retrans_out = 0;
}
}
@@ -1820,11 +1828,12 @@ static int tcp_clean_rtx_queue(struct sock *sk)
static void tcp_ack_probe(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
/* Was it a usable window open? */
- if (!after(TCP_SKB_CB(tp->send_head)->end_seq, tp->snd_una + tp->snd_wnd)) {
+ if (!after(TCP_SKB_CB(tp->send_head)->end_seq,
+ tp->snd_una + tp->snd_wnd)) {
tp->backoff = 0;
tcp_clear_xmit_timer(sk, TCP_TIME_PROBE0);
/* Socket must be waked up by subsequent tcp_data_snd_check().
@@ -1897,7 +1906,7 @@ static int tcp_ack_update_window(struct sock *sk, struct tcp_opt *tp,
/* This routine deals with incoming acks, but not outgoing ones. */
static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
u32 prior_snd_una = tp->snd_una;
u32 ack_seq = TCP_SKB_CB(skb)->seq;
u32 ack = TCP_SKB_CB(skb)->ack_seq;
@@ -1943,7 +1952,8 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
*/
sk->err_soft = 0;
tp->rcv_tstamp = tcp_time_stamp;
- if ((prior_packets = tp->packets_out) == 0)
+ prior_packets = tp->packets_out;
+ if (!prior_packets)
goto no_queue;
prior_in_flight = tcp_packets_in_flight(tp);
@@ -1953,12 +1963,13 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
if (tcp_ack_is_dubious(tp, flag)) {
/* Advanve CWND, if state allows this. */
- if ((flag&FLAG_DATA_ACKED) && prior_in_flight >= tp->snd_cwnd &&
+ if ((flag & FLAG_DATA_ACKED) &&
+ prior_in_flight >= tp->snd_cwnd &&
tcp_may_raise_cwnd(tp, flag))
tcp_cong_avoid(tp);
tcp_fastretrans_alert(sk, prior_snd_una, prior_packets, flag);
} else {
- if ((flag&FLAG_DATA_ACKED) && prior_in_flight >= tp->snd_cwnd)
+ if ((flag & FLAG_DATA_ACKED) && prior_in_flight >= tp->snd_cwnd)
tcp_cong_avoid(tp);
}
@@ -2230,7 +2241,7 @@ static void tcp_reset(struct sock *sk)
*/
static void tcp_fin(struct sk_buff *skb, struct sock *sk, struct tcphdr *th)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
tcp_schedule_ack(tp);
@@ -2333,7 +2344,7 @@ static __inline__ void tcp_dsack_extend(struct tcp_opt *tp, u32 seq, u32 end_seq
static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
@@ -2396,7 +2407,7 @@ static __inline__ void tcp_sack_swap(struct tcp_sack_block *sack1, struct tcp_sa
static void tcp_sack_new_ofo_skb(struct sock *sk, u32 seq, u32 end_seq)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
struct tcp_sack_block *sp = &tp->selective_acks[0];
int cur_sacks = tp->num_sacks;
int this_sack;
@@ -2434,7 +2445,7 @@ new_sack:
sp->start_seq = seq;
sp->end_seq = end_seq;
tp->num_sacks++;
- tp->eff_sacks = min(tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+ tp->eff_sacks = min(tp->num_sacks + tp->dsack, 4 - tp->tstamp_ok);
}
/* RCV.NXT advances, some SACKs should be eaten. */
@@ -2480,7 +2491,7 @@ static void tcp_sack_remove(struct tcp_opt *tp)
*/
static void tcp_ofo_queue(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
__u32 dsack_high = tp->rcv_nxt;
struct sk_buff *skb;
@@ -2524,7 +2535,7 @@ static int tcp_prune_queue(struct sock *sk);
static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
{
struct tcphdr *th = skb->h.th;
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
int eaten = -1;
if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq)
@@ -2537,7 +2548,8 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
if (tp->dsack) {
tp->dsack = 0;
- tp->eff_sacks = min_t(unsigned int, tp->num_sacks, 4-tp->tstamp_ok);
+ tp->eff_sacks = min_t(unsigned int, tp->num_sacks,
+ 4 - tp->tstamp_ok);
}
/* Queue data for delivery to the user.
@@ -2550,16 +2562,16 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
/* Ok. In sequence. In window. */
if (tp->ucopy.task == current &&
- tp->copied_seq == tp->rcv_nxt &&
- tp->ucopy.len &&
- sk->lock.users &&
- !tp->urg_data) {
- int chunk = min_t(unsigned int, skb->len, tp->ucopy.len);
+ tp->copied_seq == tp->rcv_nxt && tp->ucopy.len &&
+ sk->lock.users && !tp->urg_data) {
+ int chunk = min_t(unsigned int, skb->len,
+ tp->ucopy.len);
__set_current_state(TASK_RUNNING);
local_bh_enable();
- if (skb_copy_datagram_iovec(skb, 0, tp->ucopy.iov, chunk)) {
+ if (skb_copy_datagram_iovec(skb, 0, tp->ucopy.iov,
+ chunk)) {
sk->err = EFAULT;
sk->error_report(sk);
}
@@ -2592,11 +2604,11 @@ queue_and_out:
/* RFC2581. 4.2. SHOULD send immediate ACK, when
* gap in queue is filled.
*/
- if (skb_queue_len(&tp->out_of_order_queue) == 0)
+ if (!skb_queue_len(&tp->out_of_order_queue))
tp->ack.pingpong = 0;
}
- if(tp->num_sacks)
+ if (tp->num_sacks)
tcp_sack_remove(tp);
tcp_fast_path_check(sk, tp);
@@ -2622,7 +2634,7 @@ drop:
}
/* Out of window. F.e. zero window probe. */
- if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt+tcp_receive_window(tp)))
+ if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt + tcp_receive_window(tp)))
goto out_of_window;
tcp_enter_quickack_mode(tp);
@@ -2660,25 +2672,26 @@ drop:
tcp_set_owner_r(skb, sk);
- if (skb_peek(&tp->out_of_order_queue) == NULL) {
+ if (!skb_peek(&tp->out_of_order_queue)) {
/* Initial out of order segment, build 1 SACK. */
- if(tp->sack_ok) {
+ if (tp->sack_ok) {
tp->num_sacks = 1;
- tp->dsack = 0;
+ tp->dsack = 0;
tp->eff_sacks = 1;
tp->selective_acks[0].start_seq = TCP_SKB_CB(skb)->seq;
- tp->selective_acks[0].end_seq = TCP_SKB_CB(skb)->end_seq;
+ tp->selective_acks[0].end_seq =
+ TCP_SKB_CB(skb)->end_seq;
}
__skb_queue_head(&tp->out_of_order_queue,skb);
} else {
- struct sk_buff *skb1=tp->out_of_order_queue.prev;
+ struct sk_buff *skb1 = tp->out_of_order_queue.prev;
u32 seq = TCP_SKB_CB(skb)->seq;
u32 end_seq = TCP_SKB_CB(skb)->end_seq;
if (seq == TCP_SKB_CB(skb1)->end_seq) {
__skb_append(skb1, skb);
- if (tp->num_sacks == 0 ||
+ if (!tp->num_sacks ||
tp->selective_acks[0].end_seq != seq)
goto add_sack;
@@ -2691,7 +2704,8 @@ drop:
do {
if (!after(TCP_SKB_CB(skb1)->seq, seq))
break;
- } while ((skb1=skb1->prev) != (struct sk_buff*)&tp->out_of_order_queue);
+ } while ((skb1 = skb1->prev) !=
+ (struct sk_buff*)&tp->out_of_order_queue);
/* Do skb overlap to previous one? */
if (skb1 != (struct sk_buff*)&tp->out_of_order_queue &&
@@ -2712,7 +2726,8 @@ drop:
__skb_insert(skb, skb1, skb1->next, &tp->out_of_order_queue);
/* And clean segments covered by new one as whole. */
- while ((skb1 = skb->next) != (struct sk_buff*)&tp->out_of_order_queue &&
+ while ((skb1 = skb->next) !=
+ (struct sk_buff*)&tp->out_of_order_queue &&
after(end_seq, TCP_SKB_CB(skb1)->seq)) {
if (before(end_seq, TCP_SKB_CB(skb1)->end_seq)) {
tcp_dsack_extend(tp, TCP_SKB_CB(skb1)->seq, end_seq);
@@ -2828,7 +2843,7 @@ tcp_collapse(struct sock *sk, struct sk_buff *head,
*/
static void tcp_collapse_ofo_queue(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(&tp->out_of_order_queue);
struct sk_buff *head;
u32 start, end;
@@ -2873,7 +2888,7 @@ static void tcp_collapse_ofo_queue(struct sock *sk)
*/
static int tcp_prune_queue(struct sock *sk)
{
- struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
+ struct tcp_opt *tp = tcp_sk(sk);
SOCK_DEBUG(sk, "prune_queue: c=%x\n", tp->copied_seq);
@@ -2882,7 +2897,7 @@ static int tcp_prune_queue(struct sock *sk)
if (atomic_read(&sk->rmem_alloc) >= sk->rcvbuf)
tcp_clamp_window(sk, tp);
else if (tcp_memory_pressure)
- tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U*tp->advmss);
+ tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U * tp->advmss);
tcp_collapse_ofo_queue(sk);
tcp_collapse(sk, sk->receive_queue.next,
@@ -2898,7 +2913,8 @@ static int tcp_prune_queue(struct sock *sk)
/* First, purge the out_of_order queue. */
if (skb_queue_len(&tp->out_of_order_queue)) {
- net_statistics[smp_processor_id()*2].OfoPruned += skb_queue_len(&tp->out_of_order_queue);
+ net_statistics[smp_processor_id() * 2].OfoPruned +=
+ skb_queue_len(&tp->out_of_order_queue);
__skb_queue_purge(&tp->out_of_order_queue);
/* Reset SACK state. A conforming SACK implementation will
@@ -2906,7 +2922,7 @@ static int tcp_prune_queue(struct sock *sk)
* is in a sad state like this, we care only about integrity
* of the connection not performance.
*/
- if(tp->sack_ok)
+ if (tp->sack_ok)
tcp_sack_reset(tp);
tcp_mem_reclaim(sk);
}
@@ -2932,7 +2948,7 @@ static int tcp_prune_queue(struct sock *sk)
*/
void tcp_cwnd_application_limited(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
if (tp->ca_state == TCP_CA_Open &&
sk->socket && !test_bit(SOCK_NOSPACE, &sk->socket->flags)) {
@@ -2940,7 +2956,7 @@ void tcp_cwnd_application_limited(struct sock *sk)
u32 win_used = max(tp->snd_cwnd_used, 2U);
if (win_used < tp->snd_cwnd) {
tp->snd_ssthresh = tcp_current_ssthresh(tp);
- tp->snd_cwnd = (tp->snd_cwnd+win_used)>>1;
+ tp->snd_cwnd = (tp->snd_cwnd + win_used) >> 1;
}
tp->snd_cwnd_used = 0;
}
@@ -2954,16 +2970,16 @@ void tcp_cwnd_application_limited(struct sock *sk)
*/
static void tcp_new_space(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
if (tp->packets_out < tp->snd_cwnd &&
!(sk->userlocks&SOCK_SNDBUF_LOCK) &&
!tcp_memory_pressure &&
atomic_read(&tcp_memory_allocated) < sysctl_tcp_mem[0]) {
- int sndmem, demanded;
-
- sndmem = tp->mss_clamp+MAX_TCP_HEADER+16+sizeof(struct sk_buff);
- demanded = max_t(unsigned int, tp->snd_cwnd, tp->reordering+1);
+ int sndmem = tp->mss_clamp + MAX_TCP_HEADER + 16 +
+ sizeof(struct sk_buff),
+ demanded = max_t(unsigned int, tp->snd_cwnd,
+ tp->reordering + 1);
sndmem *= 2*demanded;
if (sndmem > sk->sndbuf)
sk->sndbuf = min(sndmem, sysctl_tcp_wmem[2]);
@@ -2975,7 +2991,7 @@ static void tcp_new_space(struct sock *sk)
static inline void tcp_check_space(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
if (tp->queue_shrunk) {
tp->queue_shrunk = 0;
@@ -2986,7 +3002,7 @@ static inline void tcp_check_space(struct sock *sk)
static void __tcp_data_snd_check(struct sock *sk, struct sk_buff *skb)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
if (after(TCP_SKB_CB(skb)->end_seq, tp->snd_una + tp->snd_wnd) ||
tcp_packets_in_flight(tp) >= tp->snd_cwnd ||
@@ -2996,7 +3012,8 @@ static void __tcp_data_snd_check(struct sock *sk, struct sk_buff *skb)
static __inline__ void tcp_data_snd_check(struct sock *sk)
{
- struct sk_buff *skb = sk->tp_pinfo.af_tcp.send_head;
+ struct tcp_opt *tp = tcp_sk(sk);
+ struct sk_buff *skb = tp->send_head;
if (skb != NULL)
__tcp_data_snd_check(sk, skb);
@@ -3008,7 +3025,7 @@ static __inline__ void tcp_data_snd_check(struct sock *sk)
*/
static __inline__ void __tcp_ack_snd_check(struct sock *sk, int ofo_possible)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
/* More than one full frame received... */
if (((tp->rcv_nxt - tp->rcv_wup) > tp->ack.rcv_mss
@@ -3020,7 +3037,7 @@ static __inline__ void __tcp_ack_snd_check(struct sock *sk, int ofo_possible)
tcp_in_quickack_mode(tp) ||
/* We have out of order data. */
(ofo_possible &&
- skb_peek(&tp->out_of_order_queue) != NULL)) {
+ skb_peek(&tp->out_of_order_queue))) {
/* Then ack it now */
tcp_send_ack(sk);
} else {
@@ -3031,7 +3048,7 @@ static __inline__ void __tcp_ack_snd_check(struct sock *sk, int ofo_possible)
static __inline__ void tcp_ack_snd_check(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
if (!tcp_ack_scheduled(tp)) {
/* We sent a data segment already. */
return;
@@ -3051,7 +3068,7 @@ static __inline__ void tcp_ack_snd_check(struct sock *sk)
static void tcp_check_urg(struct sock * sk, struct tcphdr * th)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
u32 ptr = ntohs(th->urg_ptr);
if (ptr && !sysctl_tcp_stdurg)
@@ -3114,8 +3131,8 @@ static void tcp_check_urg(struct sock * sk, struct tcphdr * th)
}
}
- tp->urg_data = TCP_URG_NOTYET;
- tp->urg_seq = ptr;
+ tp->urg_data = TCP_URG_NOTYET;
+ tp->urg_seq = ptr;
/* Disable header prediction. */
tp->pred_flags = 0;
@@ -3124,7 +3141,7 @@ static void tcp_check_urg(struct sock * sk, struct tcphdr * th)
/* This is the 'fast' part of urgent handling. */
static inline void tcp_urg(struct sock *sk, struct sk_buff *skb, struct tcphdr *th)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
/* Check if we get a new urgent pointer - normally not. */
if (th->urg)
@@ -3132,7 +3149,8 @@ static inline void tcp_urg(struct sock *sk, struct sk_buff *skb, struct tcphdr *
/* Do we wait for any urgent data? - normally not... */
if (tp->urg_data == TCP_URG_NOTYET) {
- u32 ptr = tp->urg_seq - ntohl(th->seq) + (th->doff*4) - th->syn;
+ u32 ptr = tp->urg_seq - ntohl(th->seq) + (th->doff * 4) -
+ th->syn;
/* Is the urgent pointer pointing into this packet? */
if (ptr < skb->len) {
@@ -3148,7 +3166,7 @@ static inline void tcp_urg(struct sock *sk, struct sk_buff *skb, struct tcphdr *
static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
int chunk = skb->len - hlen;
int err;
@@ -3156,11 +3174,12 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen)
if (skb->ip_summed==CHECKSUM_UNNECESSARY)
err = skb_copy_datagram_iovec(skb, hlen, tp->ucopy.iov, chunk);
else
- err = skb_copy_and_csum_datagram_iovec(skb, hlen, tp->ucopy.iov);
+ err = skb_copy_and_csum_datagram_iovec(skb, hlen,
+ tp->ucopy.iov);
if (!err) {
update:
- tp->ucopy.len -= chunk;
+ tp->ucopy.len -= chunk;
tp->copied_seq += chunk;
local_bh_disable();
return 0;
@@ -3223,7 +3242,7 @@ tcp_checksum_complete_user(struct sock *sk, struct sk_buff *skb)
int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
struct tcphdr *th, unsigned len)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
/*
* Header prediction.
@@ -3441,7 +3460,7 @@ discard:
static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
struct tcphdr *th, unsigned len)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
int saved_clamp = tp->mss_clamp;
tcp_parse_options(skb, tp, 0);
@@ -3462,7 +3481,8 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
goto reset_and_undo;
if (tp->saw_tstamp && tp->rcv_tsecr &&
- !between(tp->rcv_tsecr, tp->retrans_stamp, tcp_time_stamp)) {
+ !between(tp->rcv_tsecr, tp->retrans_stamp,
+ tcp_time_stamp)) {
NET_INC_STATS_BH(PAWSActiveRejected);
goto reset_and_undo;
}
@@ -3505,8 +3525,8 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
/* Ok.. it's good. Set up sequence numbers and
* move to established.
*/
- tp->rcv_nxt = TCP_SKB_CB(skb)->seq+1;
- tp->rcv_wup = TCP_SKB_CB(skb)->seq+1;
+ tp->rcv_nxt = TCP_SKB_CB(skb)->seq + 1;
+ tp->rcv_wup = TCP_SKB_CB(skb)->seq + 1;
/* RFC1323: The window in SYN & SYN/ACK segments is
* never scaled.
@@ -3514,16 +3534,16 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
tp->snd_wnd = ntohs(th->window);
tcp_init_wl(tp, TCP_SKB_CB(skb)->ack_seq, TCP_SKB_CB(skb)->seq);
- if (tp->wscale_ok == 0) {
+ if (!tp->wscale_ok) {
tp->snd_wscale = tp->rcv_wscale = 0;
tp->window_clamp = min(tp->window_clamp, 65535U);
}
if (tp->saw_tstamp) {
- tp->tstamp_ok = 1;
+ tp->tstamp_ok = 1;
tp->tcp_header_len =
sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED;
- tp->advmss -= TCPOLEN_TSTAMP_ALIGNED;
+ tp->advmss -= TCPOLEN_TSTAMP_ALIGNED;
tcp_store_ts_recent(tp);
} else {
tp->tcp_header_len = sizeof(struct tcphdr);
@@ -3540,7 +3560,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
if (sk->keepopen)
tcp_reset_keepalive_timer(sk, keepalive_time_when(tp));
- if (tp->snd_wscale == 0)
+ if (!tp->snd_wscale)
__tcp_fast_path_on(tp, tp->snd_wnd);
else
tp->pred_flags = 0;
@@ -3567,7 +3587,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
*/
tcp_schedule_ack(tp);
tp->ack.lrcvtime = tcp_time_stamp;
- tp->ack.ato = TCP_ATO_MIN;
+ tp->ack.ato = TCP_ATO_MIN;
tcp_incr_quickack(tp);
tcp_enter_quickack_mode(tp);
tcp_reset_xmit_timer(sk, TCP_TIME_DACK, TCP_DELACK_MAX);
@@ -3619,8 +3639,8 @@ discard:
/* RFC1323: The window in SYN & SYN/ACK segments is
* never scaled.
*/
- tp->snd_wnd = ntohs(th->window);
- tp->snd_wl1 = TCP_SKB_CB(skb)->seq;
+ tp->snd_wnd = ntohs(th->window);
+ tp->snd_wl1 = TCP_SKB_CB(skb)->seq;
tp->max_window = tp->snd_wnd;
tcp_sync_mss(sk, tp->pmtu_cookie);
@@ -3670,7 +3690,7 @@ reset_and_undo:
int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
struct tcphdr *th, unsigned len)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
int queued = 0;
tp->saw_tstamp = 0;
@@ -3778,14 +3798,17 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
}
tp->snd_una = TCP_SKB_CB(skb)->ack_seq;
- tp->snd_wnd = ntohs(th->window) << tp->snd_wscale;
- tcp_init_wl(tp, TCP_SKB_CB(skb)->ack_seq, TCP_SKB_CB(skb)->seq);
+ tp->snd_wnd = ntohs(th->window) <<
+ tp->snd_wscale;
+ tcp_init_wl(tp, TCP_SKB_CB(skb)->ack_seq,
+ TCP_SKB_CB(skb)->seq);
/* tcp_ack considers this ACK as duplicate
* and does not calculate rtt.
* Fix it at least with timestamps.
*/
- if (tp->saw_tstamp && tp->rcv_tsecr && !tp->srtt)
+ if (tp->saw_tstamp && tp->rcv_tsecr &&
+ !tp->srtt)
tcp_ack_saw_tstamp(tp, 0);
if (tp->tstamp_ok)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 4f8dcdd10..3e342bd23 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -5,7 +5,7 @@
*
* Implementation of the Transmission Control Protocol(TCP).
*
- * Version: $Id: tcp_ipv4.c,v 1.239 2002-01-30 01:40:01 davem Exp $
+ * Version: $Id: tcp_ipv4.c,v 1.240 2002-02-01 22:01:04 davem Exp $
*
* IPv4 specific functions
*
@@ -549,7 +549,7 @@ static int tcp_v4_check_established(struct sock *sk)
tw = (struct tcp_tw_bucket*)sk2;
if(TCP_IPV4_MATCH(sk2, acookie, saddr, daddr, ports, dif)) {
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
/* With PAWS, it is safe from the viewpoint
of data integrity. Even without PAWS it
@@ -566,9 +566,10 @@ static int tcp_v4_check_established(struct sock *sk)
timestamp retrieved from peer table.
*/
if (tw->ts_recent_stamp) {
- if ((tp->write_seq = tw->snd_nxt+65535+2) == 0)
+ if ((tp->write_seq =
+ tw->snd_nxt + 65535 + 2) == 0)
tp->write_seq = 1;
- tp->ts_recent = tw->ts_recent;
+ tp->ts_recent = tw->ts_recent;
tp->ts_recent_stamp = tw->ts_recent_stamp;
sock_hold(sk2);
skp = &head->chain;
@@ -644,7 +645,8 @@ int tcp_v4_hash_connecting(struct sock *sk)
/* This will initiate an outgoing connection. */
int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct inet_opt *inet = inet_sk(sk);
+ struct tcp_opt *tp = tcp_sk(sk);
struct sockaddr_in *usin = (struct sockaddr_in *) uaddr;
struct sk_buff *buff;
struct rtable *rt;
@@ -659,10 +661,10 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
return(-EAFNOSUPPORT);
nexthop = daddr = usin->sin_addr.s_addr;
- if (sk->protinfo.af_inet.opt && sk->protinfo.af_inet.opt->srr) {
+ if (inet->opt && inet->opt->srr) {
if (daddr == 0)
return -EINVAL;
- nexthop = sk->protinfo.af_inet.opt->faddr;
+ nexthop = inet->opt->faddr;
}
tmp = ip_route_connect(&rt, nexthop, sk->saddr,
@@ -678,7 +680,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
__sk_dst_set(sk, &rt->u.dst);
sk->route_caps = rt->u.dst.dev->features;
- if (!sk->protinfo.af_inet.opt || !sk->protinfo.af_inet.opt->srr)
+ if (!inet->opt || !inet->opt->srr)
daddr = rt->rt_dst;
err = -ENOBUFS;
@@ -693,9 +695,9 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (tp->ts_recent_stamp && sk->daddr != daddr) {
/* Reset inherited state */
- tp->ts_recent = 0;
+ tp->ts_recent = 0;
tp->ts_recent_stamp = 0;
- tp->write_seq = 0;
+ tp->write_seq = 0;
}
if (sysctl_tcp_tw_recycle &&
@@ -719,12 +721,13 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (!tp->write_seq)
tp->write_seq = secure_tcp_sequence_number(sk->saddr, sk->daddr,
- sk->sport, usin->sin_port);
+ sk->sport,
+ usin->sin_port);
tp->ext_header_len = 0;
- if (sk->protinfo.af_inet.opt)
- tp->ext_header_len = sk->protinfo.af_inet.opt->optlen;
- sk->protinfo.af_inet.id = tp->write_seq^jiffies;
+ if (inet->opt)
+ tp->ext_header_len = inet->opt->optlen;
+ inet->id = tp->write_seq ^ jiffies;
tp->mss_clamp = 536;
@@ -778,7 +781,7 @@ static struct open_request *tcp_v4_search_req(struct tcp_opt *tp,
static void tcp_v4_synq_add(struct sock *sk, struct open_request *req)
{
- struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
+ struct tcp_opt *tp = tcp_sk(sk);
struct tcp_listen_opt *lopt = tp->listen_opt;
unsigned h = tcp_v4_synq_hash(req->af.v4_req.rmt_addr, req->rmt_port);
@@ -799,10 +802,12 @@ static void tcp_v4_synq_add(struct sock *sk, struct open_request *req)
/*
* This routine does path mtu discovery as defined in RFC1191.
*/
-static inline void do_pmtu_discovery(struct sock *sk, struct iphdr *ip, unsigned mtu)
+static inline void do_pmtu_discovery(struct sock *sk, struct iphdr *iph,
+ unsigned mtu)
{
struct dst_entry *dst;
- struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
+ struct inet_opt *inet = inet_sk(sk);
+ struct tcp_opt *tp = tcp_sk(sk);
/* We are not interested in TCP_LISTEN and open_requests (SYN-ACKs
* send out by Linux are always <576bytes so they should go through
@@ -828,7 +833,7 @@ static inline void do_pmtu_discovery(struct sock *sk, struct iphdr *ip, unsigned
if (mtu < dst->pmtu && ip_dont_fragment(sk, dst))
sk->err_soft = EMSGSIZE;
- if (sk->protinfo.af_inet.pmtudisc != IP_PMTUDISC_DONT &&
+ if (inet->pmtudisc != IP_PMTUDISC_DONT &&
tp->pmtu_cookie > dst->pmtu) {
tcp_sync_mss(sk, dst->pmtu);
@@ -862,6 +867,7 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)
struct iphdr *iph = (struct iphdr*)skb->data;
struct tcphdr *th = (struct tcphdr*)(skb->data+(iph->ihl<<2));
struct tcp_opt *tp;
+ struct inet_opt *inet;
int type = skb->h.icmph->type;
int code = skb->h.icmph->code;
struct sock *sk;
@@ -893,9 +899,10 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)
if (sk->state == TCP_CLOSE)
goto out;
- tp = &sk->tp_pinfo.af_tcp;
+ tp = tcp_sk(sk);
seq = ntohl(th->seq);
- if (sk->state != TCP_LISTEN && !between(seq, tp->snd_una, tp->snd_nxt)) {
+ if (sk->state != TCP_LISTEN &&
+ !between(seq, tp->snd_una, tp->snd_nxt)) {
NET_INC_STATS(OutOfWindowIcmps);
goto out;
}
@@ -994,7 +1001,8 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)
* --ANK (980905)
*/
- if (sk->lock.users == 0 && sk->protinfo.af_inet.recverr) {
+ inet = inet_sk(sk);
+ if (sk->lock.users == 0 && inet->recverr) {
sk->err = err;
sk->error_report(sk);
} else { /* Only an error on timeout */
@@ -1313,7 +1321,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
tcp_clear_options(&tp);
tp.mss_clamp = 536;
- tp.user_mss = sk->tp_pinfo.af_tcp.user_mss;
+ tp.user_mss = tcp_sk(sk)->user_mss;
tcp_parse_options(skb, &tp, 0);
@@ -1421,6 +1429,7 @@ struct sock * tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
struct open_request *req,
struct dst_entry *dst)
{
+ struct inet_opt *newinet;
struct tcp_opt *newtp;
struct sock *newsk;
@@ -1438,18 +1447,19 @@ struct sock * tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
newsk->dst_cache = dst;
newsk->route_caps = dst->dev->features;
- newtp = &(newsk->tp_pinfo.af_tcp);
+ newtp = tcp_sk(newsk);
newsk->daddr = req->af.v4_req.rmt_addr;
newsk->saddr = req->af.v4_req.loc_addr;
newsk->rcv_saddr = req->af.v4_req.loc_addr;
- newsk->protinfo.af_inet.opt = req->af.v4_req.opt;
+ newinet = inet_sk(newsk);
+ newinet->opt = req->af.v4_req.opt;
req->af.v4_req.opt = NULL;
- newsk->protinfo.af_inet.mc_index = tcp_v4_iif(skb);
- newsk->protinfo.af_inet.mc_ttl = skb->nh.iph->ttl;
+ newinet->mc_index = tcp_v4_iif(skb);
+ newinet->mc_ttl = skb->nh.iph->ttl;
newtp->ext_header_len = 0;
- if (newsk->protinfo.af_inet.opt)
- newtp->ext_header_len = newsk->protinfo.af_inet.opt->optlen;
- newsk->protinfo.af_inet.id = newtp->write_seq^jiffies;
+ if (newinet->opt)
+ newtp->ext_header_len = newinet->opt->optlen;
+ newinet->id = newtp->write_seq ^ jiffies;
tcp_sync_mss(newsk, dst->pmtu);
newtp->advmss = dst->advmss;
@@ -1473,7 +1483,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk,struct sk_buff *skb)
struct open_request *req, **prev;
struct tcphdr *th = skb->h.th;
struct iphdr *iph = skb->nh.iph;
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
struct sock *nsk;
/* Find possible connection requests. */
@@ -1723,18 +1733,19 @@ static void __tcp_v4_rehash(struct sock *sk)
static int tcp_v4_reselect_saddr(struct sock *sk)
{
+ struct inet_opt *inet = inet_sk(sk);
int err;
struct rtable *rt;
__u32 old_saddr = sk->saddr;
__u32 new_saddr;
__u32 daddr = sk->daddr;
- if(sk->protinfo.af_inet.opt && sk->protinfo.af_inet.opt->srr)
- daddr = sk->protinfo.af_inet.opt->faddr;
+ if (inet->opt && inet->opt->srr)
+ daddr = inet->opt->faddr;
/* Query new route. */
err = ip_route_connect(&rt, daddr, 0,
- RT_TOS(sk->protinfo.af_inet.tos)|sk->localroute,
+ RT_TOS(inet->tos) | sk->localroute,
sk->bound_dev_if);
if (err)
return err;
@@ -1770,6 +1781,7 @@ static int tcp_v4_reselect_saddr(struct sock *sk)
int tcp_v4_rebuild_header(struct sock *sk)
{
+ struct inet_opt *inet = inet_sk(sk);
struct rtable *rt = (struct rtable *)__sk_dst_check(sk, 0);
u32 daddr;
int err;
@@ -1780,8 +1792,8 @@ int tcp_v4_rebuild_header(struct sock *sk)
/* Reroute. */
daddr = sk->daddr;
- if(sk->protinfo.af_inet.opt && sk->protinfo.af_inet.opt->srr)
- daddr = sk->protinfo.af_inet.opt->faddr;
+ if (inet->opt && inet->opt->srr)
+ daddr = inet->opt->faddr;
err = ip_route_output(&rt, daddr, sk->saddr,
RT_CONN_FLAGS(sk), sk->bound_dev_if);
@@ -1820,7 +1832,7 @@ static void v4_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr)
int tcp_v4_remember_stamp(struct sock *sk)
{
- struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
+ struct tcp_opt *tp = tcp_sk(sk);
struct rtable *rt = (struct rtable*)__sk_dst_get(sk);
struct inet_peer *peer = NULL;
int release_it = 0;
@@ -1890,7 +1902,7 @@ struct tcp_func ipv4_specific = {
*/
static int tcp_v4_init_sock(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
skb_queue_head_init(&tp->out_of_order_queue);
tcp_init_xmit_timers(sk);
@@ -1920,7 +1932,7 @@ static int tcp_v4_init_sock(struct sock *sk)
sk->write_space = tcp_write_space;
sk->use_write_queue = 1;
- sk->tp_pinfo.af_tcp.af_specific = &ipv4_specific;
+ tp->af_specific = &ipv4_specific;
sk->sndbuf = sysctl_tcp_wmem[1];
sk->rcvbuf = sysctl_tcp_rmem[1];
@@ -1932,7 +1944,7 @@ static int tcp_v4_init_sock(struct sock *sk)
static int tcp_v4_destroy_sock(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
tcp_clear_xmit_timers(sk);
@@ -1950,7 +1962,7 @@ static int tcp_v4_destroy_sock(struct sock *sk)
tcp_put_port(sk);
/* If sendmsg cached page exists, toss it. */
- if (tp->sndmsg_page != NULL)
+ if (tp->sndmsg_page)
__free_page(tp->sndmsg_page);
atomic_dec(&tcp_sockets_allocated);
@@ -1989,7 +2001,7 @@ static void get_tcp_sock(struct sock *sp, char *tmpbuf, int i)
__u16 destp, srcp;
int timer_active;
unsigned long timer_expires;
- struct tcp_opt *tp = &sp->tp_pinfo.af_tcp;
+ struct tcp_opt *tp = tcp_sk(sp);
dest = sp->daddr;
src = sp->rcv_saddr;
@@ -2070,7 +2082,7 @@ int tcp_get_info(char *buffer, char **start, off_t offset, int length)
for (sk = tcp_listening_hash[i]; sk; sk = sk->next, num++) {
struct open_request *req;
int uid;
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
if (!TCP_INET_FAMILY(sk->family))
goto skip_listen;
@@ -2197,7 +2209,7 @@ void __init tcp_v4_init(struct net_proto_family *ops)
if (err < 0)
panic("Failed to create the TCP control socket.\n");
tcp_socket->sk->allocation=GFP_ATOMIC;
- tcp_socket->sk->protinfo.af_inet.ttl = MAXTTL;
+ inet_sk(tcp_socket->sk)->ttl = MAXTTL;
/* Unhash it so that IP input processing does not even
* see it, we do not wish this socket to see incoming
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 72cf82541..542b4efd6 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -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;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 3d6ec27c3..87e273095 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -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 @@ err_out:
*/
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);
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 44c78b8f9..b86dfbffa 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -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 @@ out_unlock:
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 @@ out_unlock:
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. */
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 20ac76a06..d27575b0b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -5,7 +5,7 @@
*
* The User Datagram Protocol (UDP).
*
- * Version: $Id: udp.c,v 1.101 2002-01-12 07:39:45 davem Exp $
+ * Version: $Id: udp.c,v 1.102 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 @@
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <net/snmp.h>
-#include <net/ip.h>
+#include <net/tcp.h>
#include <net/protocol.h>
#include <linux/skbuff.h>
#include <net/sock.h>
@@ -293,6 +293,7 @@ static inline struct sock *udp_v4_mcast_next(struct sock *sk,
void udp_err(struct sk_buff *skb, u32 info)
{
+ struct inet_opt *inet;
struct iphdr *iph = (struct iphdr*)skb->data;
struct udphdr *uh = (struct udphdr*)(skb->data+(iph->ihl<<2));
int type = skb->h.icmph->type;
@@ -309,6 +310,7 @@ void udp_err(struct sk_buff *skb, u32 info)
err = 0;
harderr = 0;
+ inet = inet_sk(sk);
switch (type) {
default:
@@ -323,7 +325,7 @@ void udp_err(struct sk_buff *skb, u32 info)
break;
case ICMP_DEST_UNREACH:
if (code == ICMP_FRAG_NEEDED) { /* Path MTU discovery */
- if (sk->protinfo.af_inet.pmtudisc != IP_PMTUDISC_DONT) {
+ if (inet->pmtudisc != IP_PMTUDISC_DONT) {
err = EMSGSIZE;
harderr = 1;
break;
@@ -342,7 +344,7 @@ void udp_err(struct sk_buff *skb, u32 info)
* RFC1122: OK. Passes ICMP errors back to application, as per
* 4.1.3.3.
*/
- if (!sk->protinfo.af_inet.recverr) {
+ if (!inet->recverr) {
if (!harderr || sk->state != TCP_ESTABLISHED)
goto out;
} else {
@@ -415,6 +417,7 @@ static int udp_getfrag_nosum(const void *p, char * to, unsigned int offset, unsi
int udp_sendmsg(struct sock *sk, struct msghdr *msg, int len)
{
+ struct inet_opt *inet = inet_sk(sk);
int ulen = len + sizeof(struct udphdr);
struct ipcm_cookie ipc;
struct udpfakehdr ufh;
@@ -487,7 +490,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, int len)
connected = 0;
}
if (!ipc.opt)
- ipc.opt = sk->protinfo.af_inet.opt;
+ ipc.opt = inet->opt;
ufh.saddr = ipc.addr;
ipc.addr = daddr = ufh.daddr;
@@ -498,7 +501,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, int len)
daddr = ipc.opt->faddr;
connected = 0;
}
- tos = RT_TOS(sk->protinfo.af_inet.tos);
+ tos = RT_TOS(inet->tos);
if (sk->localroute || (msg->msg_flags&MSG_DONTROUTE) ||
(ipc.opt && ipc.opt->is_strictroute)) {
tos |= RTO_ONLINK;
@@ -507,9 +510,9 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, int len)
if (MULTICAST(daddr)) {
if (!ipc.oif)
- ipc.oif = sk->protinfo.af_inet.mc_index;
+ ipc.oif = inet->mc_index;
if (!ufh.saddr)
- ufh.saddr = sk->protinfo.af_inet.mc_addr;
+ ufh.saddr = inet->mc_addr;
connected = 0;
}
@@ -627,6 +630,7 @@ static __inline__ int udp_checksum_complete(struct sk_buff *skb)
int udp_recvmsg(struct sock *sk, struct msghdr *msg, int len,
int noblock, int flags, int *addr_len)
{
+ struct inet_opt *inet = inet_sk(sk);
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
struct sk_buff *skb;
int copied, err;
@@ -678,7 +682,7 @@ int udp_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);
err = copied;
@@ -710,6 +714,7 @@ csum_copy_err:
int udp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{
+ struct inet_opt *inet = inet_sk(sk);
struct sockaddr_in *usin = (struct sockaddr_in *) uaddr;
struct rtable *rt;
int err;
@@ -738,7 +743,7 @@ int udp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
sk->daddr = rt->rt_dst;
sk->dport = usin->sin_port;
sk->state = TCP_ESTABLISHED;
- sk->protinfo.af_inet.id = jiffies;
+ inet->id = jiffies;
sk_dst_set(sk, &rt->u.dst);
return(0);
@@ -758,8 +763,12 @@ int udp_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
}
if (!(sk->userlocks&SOCK_BINDPORT_LOCK)) {
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index c7fdba836..0c18c25d7 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -7,7 +7,7 @@
*
* Adapted from linux/net/ipv4/af_inet.c
*
- * $Id: af_inet6.c,v 1.65 2001-10-02 02:22:36 davem Exp $
+ * $Id: af_inet6.c,v 1.66 2002-02-01 22:01:04 davem Exp $
*
* Fixes:
* piggy, Karl Knutson : Socket protocol table
@@ -92,6 +92,11 @@ extern void ipv6_sysctl_unregister(void);
atomic_t inet6_sock_nr;
#endif
+/* Per protocol sock slabcache */
+kmem_cache_t *tcp6_sk_cachep;
+kmem_cache_t *udp6_sk_cachep;
+kmem_cache_t *raw6_sk_cachep;
+
/* The inetsw table contains everything that inet_create needs to
* build a new socket.
*/
@@ -107,13 +112,50 @@ static void inet6_sock_destruct(struct sock *sk)
MOD_DEC_USE_COUNT;
}
+static __inline__ kmem_cache_t *inet6_sk_slab(int protocol)
+{
+ kmem_cache_t* rc = tcp6_sk_cachep;
+
+ if (protocol == IPPROTO_UDP)
+ rc = udp6_sk_cachep;
+ else if (protocol == IPPROTO_RAW)
+ rc = raw6_sk_cachep;
+ return rc;
+}
+
+static __inline__ int inet6_sk_size(int protocol)
+{
+ int rc = sizeof(struct tcp6_sock);
+
+ if (protocol == IPPROTO_UDP)
+ rc = sizeof(struct udp6_sock);
+ else if (protocol == IPPROTO_RAW)
+ rc = sizeof(struct raw6_sock);
+ return rc;
+}
+
+static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)
+{
+ struct ipv6_pinfo *rc = (&((struct tcp6_sock *)sk)->inet6);
+
+ if (sk->protocol == IPPROTO_UDP)
+ rc = (&((struct udp6_sock *)sk)->inet6);
+ else if (sk->protocol == IPPROTO_RAW)
+ rc = (&((struct raw6_sock *)sk)->inet6);
+ return rc;
+}
+
static int inet6_create(struct socket *sock, int protocol)
{
+ struct inet_opt *inet;
+ struct ipv6_pinfo *np;
struct sock *sk;
+ struct tcp6_sock* tcp6sk;
struct list_head *p;
struct inet_protosw *answer;
- sk = sk_alloc(PF_INET6, GFP_KERNEL, 1);
+ sk = sk_alloc(PF_INET6, GFP_KERNEL, inet6_sk_size(protocol),
+ inet6_sk_slab(protocol));
if (sk == NULL)
goto do_oom;
@@ -155,10 +197,12 @@ static int inet6_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;
}
sk->destruct = inet6_sock_destruct;
@@ -168,25 +212,27 @@ static int inet6_create(struct socket *sock, int protocol)
sk->backlog_rcv = answer->prot->backlog_rcv;
- sk->net_pinfo.af_inet6.hop_limit = -1;
- sk->net_pinfo.af_inet6.mcast_hops = -1;
- sk->net_pinfo.af_inet6.mc_loop = 1;
- sk->net_pinfo.af_inet6.pmtudisc = IPV6_PMTUDISC_WANT;
+ tcp6sk = (struct tcp6_sock *)sk;
+ tcp6sk->pinet6 = np = inet6_sk_generic(sk);
+ np->hop_limit = -1;
+ np->mcast_hops = -1;
+ np->mc_loop = 1;
+ np->pmtudisc = IPV6_PMTUDISC_WANT;
/* Init the ipv4 part of the socket since we can have sockets
* using v6 API for ipv4.
*/
- sk->protinfo.af_inet.ttl = 64;
+ inet->ttl = 64;
- sk->protinfo.af_inet.mc_loop = 1;
- sk->protinfo.af_inet.mc_ttl = 1;
- sk->protinfo.af_inet.mc_index = 0;
- sk->protinfo.af_inet.mc_list = NULL;
+ inet->mc_loop = 1;
+ inet->mc_ttl = 1;
+ inet->mc_index = 0;
+ inet->mc_list = NULL;
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;
#ifdef INET_REFCNT_DEBUG
@@ -232,6 +278,7 @@ static int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sockaddr_in6 *addr=(struct sockaddr_in6 *)uaddr;
struct sock *sk = sock->sk;
+ struct ipv6_pinfo *np = inet6_sk(sk);
__u32 v4addr = 0;
unsigned short snum;
int addr_type = 0;
@@ -296,17 +343,17 @@ static int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
sk->rcv_saddr = v4addr;
sk->saddr = v4addr;
- ipv6_addr_copy(&sk->net_pinfo.af_inet6.rcv_saddr, &addr->sin6_addr);
+ ipv6_addr_copy(&np->rcv_saddr, &addr->sin6_addr);
if (!(addr_type & IPV6_ADDR_MULTICAST))
- ipv6_addr_copy(&sk->net_pinfo.af_inet6.saddr, &addr->sin6_addr);
+ ipv6_addr_copy(&np->saddr, &addr->sin6_addr);
/* Make sure we are allowed to bind here. */
if (sk->prot->get_port(sk, snum) != 0) {
sk->rcv_saddr = 0;
sk->saddr = 0;
- memset(&sk->net_pinfo.af_inet6.rcv_saddr, 0, sizeof(struct in6_addr));
- memset(&sk->net_pinfo.af_inet6.saddr, 0, sizeof(struct in6_addr));
+ memset(&np->rcv_saddr, 0, sizeof(struct in6_addr));
+ memset(&np->saddr, 0, sizeof(struct in6_addr));
release_sock(sk);
return -EADDRINUSE;
@@ -339,6 +386,7 @@ static int inet6_release(struct socket *sock)
int inet6_destroy_sock(struct sock *sk)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sk_buff *skb;
struct ipv6_txoptions *opt;
@@ -350,7 +398,7 @@ int inet6_destroy_sock(struct sock *sk)
/* Release rx options */
- if ((skb = xchg(&sk->net_pinfo.af_inet6.pktoptions, NULL)) != NULL)
+ if ((skb = xchg(&np->pktoptions, NULL)) != NULL)
kfree_skb(skb);
/* Free flowlabels */
@@ -358,7 +406,7 @@ int inet6_destroy_sock(struct sock *sk)
/* Free tx options */
- if ((opt = xchg(&sk->net_pinfo.af_inet6.opt, NULL)) != NULL)
+ if ((opt = xchg(&np->opt, NULL)) != NULL)
sock_kfree_s(sk, opt, opt->tot_len);
return 0;
@@ -373,6 +421,7 @@ static int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
{
struct sockaddr_in6 *sin=(struct sockaddr_in6 *)uaddr;
struct sock *sk = sock->sk;
+ struct ipv6_pinfo *np = inet6_sk(sk);
sin->sin6_family = AF_INET6;
sin->sin6_flowinfo = 0;
@@ -383,18 +432,15 @@ static int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
if (((1<<sk->state)&(TCPF_CLOSE|TCPF_SYN_SENT)) && peer == 1)
return -ENOTCONN;
sin->sin6_port = sk->dport;
- memcpy(&sin->sin6_addr, &sk->net_pinfo.af_inet6.daddr,
- sizeof(struct in6_addr));
- if (sk->net_pinfo.af_inet6.sndflow)
- sin->sin6_flowinfo = sk->net_pinfo.af_inet6.flow_label;
+ memcpy(&sin->sin6_addr, &np->daddr, sizeof(struct in6_addr));
+ if (np->sndflow)
+ sin->sin6_flowinfo = np->flow_label;
} else {
- if (ipv6_addr_type(&sk->net_pinfo.af_inet6.rcv_saddr) == IPV6_ADDR_ANY)
- memcpy(&sin->sin6_addr,
- &sk->net_pinfo.af_inet6.saddr,
+ if (ipv6_addr_type(&np->rcv_saddr) == IPV6_ADDR_ANY)
+ memcpy(&sin->sin6_addr, &np->saddr,
sizeof(struct in6_addr));
else
- memcpy(&sin->sin6_addr,
- &sk->net_pinfo.af_inet6.rcv_saddr,
+ memcpy(&sin->sin6_addr, &np->rcv_saddr,
sizeof(struct in6_addr));
sin->sin6_port = sk->sport;
@@ -502,8 +548,8 @@ struct proto_ops inet6_dgram_ops = {
};
struct net_proto_family inet6_family_ops = {
- PF_INET6,
- inet6_create
+ family: PF_INET6,
+ create: inet6_create,
};
#ifdef MODULE
@@ -606,6 +652,19 @@ static int __init inet6_init(void)
printk(KERN_CRIT "inet6_proto_init: size fault\n");
return -EINVAL;
}
+ /* allocate our sock slab caches */
+ tcp6_sk_cachep = kmem_cache_create("tcp6_sock",
+ sizeof(struct tcp6_sock), 0,
+ SLAB_HWCACHE_ALIGN, 0, 0);
+ udp6_sk_cachep = kmem_cache_create("udp6_sock",
+ sizeof(struct udp6_sock), 0,
+ SLAB_HWCACHE_ALIGN, 0, 0);
+ raw6_sk_cachep = kmem_cache_create("raw6_sock",
+ sizeof(struct raw6_sock), 0,
+ SLAB_HWCACHE_ALIGN, 0, 0);
+ if (!tcp6_sk_cachep || !udp6_sk_cachep || !raw6_sk_cachep)
+ printk(KERN_CRIT __FUNCTION__
+ ": Can't create protocol sock SLAB caches!\n");
/* Register the socket-side information for inet6_create. */
for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 2c50bd625..fd77c805c 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -5,7 +5,7 @@
* Authors:
* Pedro Roque <roque@di.fc.ul.pt>
*
- * $Id: datagram.c,v 1.23 2001-09-01 00:31:50 davem Exp $
+ * $Id: datagram.c,v 1.24 2002-02-01 22:01:04 davem Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -35,10 +35,11 @@
void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
u16 port, u32 info, u8 *payload)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct icmp6hdr *icmph = (struct icmp6hdr *)skb->h.raw;
struct sock_exterr_skb *serr;
- if (!sk->net_pinfo.af_inet6.recverr)
+ if (!np->recverr)
return;
skb = skb_clone(skb, GFP_ATOMIC);
@@ -65,11 +66,12 @@ void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sock_exterr_skb *serr;
struct ipv6hdr *iph;
struct sk_buff *skb;
- if (!sk->net_pinfo.af_inet6.recverr)
+ if (!np->recverr)
return;
skb = alloc_skb(sizeof(struct ipv6hdr), GFP_ATOMIC);
@@ -103,6 +105,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
*/
int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sock_exterr_skb *serr;
struct sk_buff *skb, *skb2;
struct sockaddr_in6 *sin;
@@ -139,7 +142,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
sin->sin6_scope_id = 0;
if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) {
memcpy(&sin->sin6_addr, skb->nh.raw + serr->addr_offset, 16);
- if (sk->net_pinfo.af_inet6.sndflow)
+ if (np->sndflow)
sin->sin6_flowinfo = *(u32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK;
if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
@@ -160,17 +163,19 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
sin->sin6_flowinfo = 0;
if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) {
memcpy(&sin->sin6_addr, &skb->nh.ipv6h->saddr, 16);
- if (sk->net_pinfo.af_inet6.rxopt.all)
+ if (np->rxopt.all)
datagram_recv_ctl(sk, msg, skb);
if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
sin->sin6_scope_id = opt->iif;
}
} else {
+ struct inet_opt *inet = inet_sk(sk);
+
ipv6_addr_set(&sin->sin6_addr, 0, 0,
__constant_htonl(0xffff),
skb->nh.iph->saddr);
- if (sk->protinfo.af_inet.cmsg_flags)
+ if (inet->cmsg_flags)
ip_cmsg_recv(msg, skb);
}
}
@@ -203,7 +208,7 @@ out:
int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
{
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
if (np->rxopt.bits.rxinfo) {
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index c87c1d447..f2d309fe7 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.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 @@ done:
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;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 313e7c2dc..4964e2f3a 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -5,7 +5,7 @@
* Authors:
* Pedro Roque <roque@di.fc.ul.pt>
*
- * $Id: ip6_output.c,v 1.33 2001-09-20 00:35:35 davem Exp $
+ * $Id: ip6_output.c,v 1.34 2002-02-01 22:01:04 davem Exp $
*
* Based on linux/net/ipv4/ip_output.c
*
@@ -34,6 +34,7 @@
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/in6.h>
+#include <linux/tcp.h>
#include <linux/route.h>
#include <linux/netfilter.h>
@@ -105,8 +106,9 @@ int ip6_output(struct sk_buff *skb)
skb->dev = dev;
if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr)) {
- if (!(dev->flags&IFF_LOOPBACK) &&
- (skb->sk == NULL || skb->sk->net_pinfo.af_inet6.mc_loop) &&
+ struct ipv6_pinfo* np = skb->sk ? inet6_sk(skb->sk) : NULL;
+
+ if (!(dev->flags & IFF_LOOPBACK) && (!np || np->mc_loop) &&
ipv6_chk_mcast_addr(dev, &skb->nh.ipv6h->daddr)) {
struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
@@ -182,7 +184,7 @@ static inline int ip6_maybe_reroute(struct sk_buff *skb)
int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
struct ipv6_txoptions *opt)
{
- struct ipv6_pinfo * np = sk ? &sk->net_pinfo.af_inet6 : NULL;
+ struct ipv6_pinfo *np = sk ? inet6_sk(sk) : NULL;
struct in6_addr *first_hop = fl->nl_u.ip6_u.daddr;
struct dst_entry *dst = skb->dst;
struct ipv6hdr *hdr;
@@ -258,7 +260,7 @@ int ip6_nd_hdr(struct sock *sk, struct sk_buff *skb, struct net_device *dev,
struct in6_addr *saddr, struct in6_addr *daddr,
int proto, int len)
{
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6hdr *hdr;
int totlen;
@@ -500,7 +502,8 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
struct flowi *fl, unsigned length,
struct ipv6_txoptions *opt, int hlimit, int flags)
{
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct inet_opt *inet = inet_sk(sk);
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct in6_addr *final_dst = NULL;
struct dst_entry *dst;
int err = 0;
@@ -582,7 +585,7 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
jumbolen = 0;
- if (!sk->protinfo.af_inet.hdrincl) {
+ if (!inet->hdrincl) {
pktlength += sizeof(struct ipv6hdr);
if (opt)
pktlength += opt->opt_flen + opt->opt_nflen;
@@ -642,7 +645,7 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
hdr = (struct ipv6hdr *) skb->tail;
skb->nh.ipv6h = hdr;
- if (!sk->protinfo.af_inet.hdrincl) {
+ if (!inet->hdrincl) {
ip6_bld_1(sk, skb, fl, hlimit,
jumbolen ? sizeof(struct ipv6hdr) : pktlength);
@@ -667,7 +670,7 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
kfree_skb(skb);
}
} else {
- if (sk->protinfo.af_inet.hdrincl || jumbolen ||
+ if (inet->hdrincl || jumbolen ||
np->pmtudisc == IPV6_PMTUDISC_DO) {
ipv6_local_error(sk, EMSGSIZE, fl, mtu);
err = -EMSGSIZE;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 97cf0864f..979886e13 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -7,7 +7,7 @@
*
* Based on linux/net/ipv4/ip_sockglue.c
*
- * $Id: ipv6_sockglue.c,v 1.40 2001-09-18 22:29:10 davem Exp $
+ * $Id: ipv6_sockglue.c,v 1.41 2002-02-01 22:01:04 davem Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -122,7 +122,7 @@ int ip6_ra_control(struct sock *sk, int sel, void (*destructor)(struct sock *))
int ipv6_setsockopt(struct sock *sk, int level, int optname, char *optval,
int optlen)
{
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
int val, valbool;
int retv = -ENOPROTOOPT;
@@ -166,7 +166,7 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, char *optval,
ipv6_sock_mc_close(sk);
if (sk->protocol == IPPROTO_TCP) {
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
local_bh_disable();
sock_prot_dec_use(sk->prot);
@@ -281,7 +281,7 @@ update:
retv = 0;
if (sk->type == SOCK_STREAM) {
if (opt) {
- struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
+ struct tcp_opt *tp = tcp_sk(sk);
if (!((1<<sk->state)&(TCPF_LISTEN|TCPF_CLOSE))
&& sk->daddr != LOOPBACK4_IPV6) {
tp->ext_header_len = opt->opt_flen + opt->opt_nflen;
@@ -401,7 +401,7 @@ e_inval:
int ipv6_getsockopt(struct sock *sk, int level, int optname, char *optval,
int *optlen)
{
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
int len;
int val;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index a5639f449..a4bc89d1a 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -5,7 +5,7 @@
* Authors:
* Pedro Roque <roque@di.fc.ul.pt>
*
- * $Id: mcast.c,v 1.38 2001-08-15 07:36:31 davem Exp $
+ * $Id: mcast.c,v 1.39 2002-02-01 22:01:04 davem Exp $
*
* Based on linux/ipv4/igmp.c and linux/ipv4/ip_sockglue.c
*
@@ -77,7 +77,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr)
{
struct net_device *dev = NULL;
struct ipv6_mc_socklist *mc_lst;
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
int err;
if (!(ipv6_addr_type(addr) & IPV6_ADDR_MULTICAST))
@@ -136,7 +136,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr)
*/
int ipv6_sock_mc_drop(struct sock *sk, int ifindex, struct in6_addr *addr)
{
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6_mc_socklist *mc_lst, **lnk;
write_lock_bh(&ipv6_sk_mc_lock);
@@ -163,7 +163,7 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, struct in6_addr *addr)
void ipv6_sock_mc_close(struct sock *sk)
{
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6_mc_socklist *mc_lst;
write_lock_bh(&ipv6_sk_mc_lock);
@@ -188,10 +188,11 @@ void ipv6_sock_mc_close(struct sock *sk)
int inet6_mc_check(struct sock *sk, struct in6_addr *addr)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6_mc_socklist *mc;
read_lock(&ipv6_sk_mc_lock);
- for (mc = sk->net_pinfo.af_inet6.ipv6_mc_list; mc; mc=mc->next) {
+ for (mc = np->ipv6_mc_list; mc; mc = mc->next) {
if (ipv6_addr_cmp(&mc->addr, addr) == 0) {
read_unlock(&ipv6_sk_mc_lock);
return 1;
@@ -748,6 +749,7 @@ done:
int __init igmp6_init(struct net_proto_family *ops)
{
+ struct ipv6_pinfo *np;
struct sock *sk;
int err;
@@ -774,7 +776,8 @@ int __init igmp6_init(struct net_proto_family *ops)
sk->allocation = GFP_ATOMIC;
sk->prot->unhash(sk);
- sk->net_pinfo.af_inet6.hop_limit = 1;
+ np = inet6_sk(sk);
+ np->hop_limit = 1;
#ifdef CONFIG_PROC_FS
create_proc_read_entry("net/igmp6", 0, 0, igmp6_read_proc, NULL);
#endif
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 838f7eebc..7513f0196 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1211,6 +1211,7 @@ int ndisc_rcv(struct sk_buff *skb)
int __init ndisc_init(struct net_proto_family *ops)
{
+ struct ipv6_pinfo *np;
struct sock *sk;
int err;
@@ -1234,10 +1235,11 @@ int __init ndisc_init(struct net_proto_family *ops)
}
sk = ndisc_socket->sk;
+ np = inet6_sk(sk);
sk->allocation = GFP_ATOMIC;
- sk->net_pinfo.af_inet6.hop_limit = 255;
+ np->hop_limit = 255;
/* Do not loopback ndisc messages */
- sk->net_pinfo.af_inet6.mc_loop = 0;
+ np->mc_loop = 0;
sk->prot->unhash(sk);
/*
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 09e606df9..7331c5e78 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -7,7 +7,7 @@
* PROC file system. This is very similar to the IPv4 version,
* except it reports the sockets in the INET6 address family.
*
- * Version: $Id: proc.c,v 1.16 2002-01-24 15:45:51 davem Exp $
+ * Version: $Id: proc.c,v 1.17 2002-02-01 22:01:04 davem Exp $
*
* Authors: David S. Miller (davem@caip.rutgers.edu)
*
@@ -19,7 +19,7 @@
#include <linux/sched.h>
#include <linux/socket.h>
#include <linux/net.h>
-#include <linux/in6.h>
+#include <linux/ipv6.h>
#include <linux/stddef.h>
#include <net/sock.h>
#include <net/tcp.h>
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 795fa8551..abd15bb2b 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -7,7 +7,7 @@
*
* Adapted from linux/net/ipv4/raw.c
*
- * $Id: raw.c,v 1.50 2001-09-18 22:29:10 davem Exp $
+ * $Id: raw.c,v 1.51 2002-02-01 22:01:04 davem Exp $
*
* Fixes:
* Hideaki YOSHIFUJI : sin6_scope_id support
@@ -86,14 +86,14 @@ struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num,
for(s = sk; s; s = s->next) {
if(s->num == num) {
- struct ipv6_pinfo *np = &s->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(s);
if (!ipv6_addr_any(&np->daddr) &&
ipv6_addr_cmp(&np->daddr, rmt_addr))
continue;
if (!ipv6_addr_any(&np->rcv_saddr)) {
- if (ipv6_addr_cmp(&np->rcv_saddr, loc_addr) == 0)
+ if (!ipv6_addr_cmp(&np->rcv_saddr, loc_addr))
break;
if ((addr_type & IPV6_ADDR_MULTICAST) &&
inet6_mc_check(s, loc_addr))
@@ -113,9 +113,8 @@ struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num,
static __inline__ int icmpv6_filter(struct sock *sk, struct sk_buff *skb)
{
struct icmp6hdr *icmph;
- struct raw6_opt *opt;
+ struct raw6_opt *opt = raw6_sk(sk);
- opt = &sk->tp_pinfo.tp_raw;
if (pskb_may_pull(skb, sizeof(struct icmp6hdr))) {
__u32 *data = &opt->filter.data[0];
int bit_nr;
@@ -187,6 +186,7 @@ out:
/* This cleans up af_inet6 a bit. -DaveM */
static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sockaddr_in6 *addr = (struct sockaddr_in6 *) uaddr;
__u32 v4addr = 0;
int addr_type;
@@ -235,9 +235,9 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
sk->rcv_saddr = v4addr;
sk->saddr = v4addr;
- ipv6_addr_copy(&sk->net_pinfo.af_inet6.rcv_saddr, &addr->sin6_addr);
+ ipv6_addr_copy(&np->rcv_saddr, &addr->sin6_addr);
if (!(addr_type & IPV6_ADDR_MULTICAST))
- ipv6_addr_copy(&sk->net_pinfo.af_inet6.saddr, &addr->sin6_addr);
+ ipv6_addr_copy(&np->saddr, &addr->sin6_addr);
err = 0;
out:
release_sock(sk);
@@ -248,6 +248,8 @@ void rawv6_err(struct sock *sk, struct sk_buff *skb,
struct inet6_skb_parm *opt,
int type, int code, int offset, u32 info)
{
+ struct inet_opt *inet = inet_sk(sk);
+ struct ipv6_pinfo *np = inet6_sk(sk);
int err;
int harderr;
@@ -256,21 +258,21 @@ void rawv6_err(struct sock *sk, struct sk_buff *skb,
2. Socket is connected (otherwise the error indication
is useless without recverr and error is hard.
*/
- if (!sk->net_pinfo.af_inet6.recverr && sk->state != TCP_ESTABLISHED)
+ if (!np->recverr && sk->state != TCP_ESTABLISHED)
return;
harderr = icmpv6_err_convert(type, code, &err);
if (type == ICMPV6_PKT_TOOBIG)
- harderr = (sk->net_pinfo.af_inet6.pmtudisc == IPV6_PMTUDISC_DO);
+ harderr = (np->pmtudisc == IPV6_PMTUDISC_DO);
- if (sk->net_pinfo.af_inet6.recverr) {
+ if (np->recverr) {
u8 *payload = skb->data;
- if (!sk->protinfo.af_inet.hdrincl)
+ if (!inet->hdrincl)
payload += offset;
ipv6_icmp_error(sk, skb, err, 0, ntohl(info), payload);
}
- if (sk->net_pinfo.af_inet6.recverr || harderr) {
+ if (np->recverr || harderr) {
sk->err = err;
sk->error_report(sk);
}
@@ -298,7 +300,9 @@ static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
*/
int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
{
- if (sk->protinfo.af_inet.hdrincl) {
+ struct inet_opt *inet = inet_sk(sk);
+
+ if (inet->hdrincl) {
__skb_push(skb, skb->nh.raw - skb->data);
skb->h.raw = skb->nh.raw;
}
@@ -316,6 +320,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
int rawv6_recvmsg(struct sock *sk, struct msghdr *msg, int len,
int noblock, int flags, int *addr_len)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)msg->msg_name;
struct sk_buff *skb;
int copied, err;
@@ -358,7 +363,7 @@ int rawv6_recvmsg(struct sock *sk, struct msghdr *msg, int len,
sock_recv_timestamp(msg, sk, skb);
- if (sk->net_pinfo.af_inet6.rxopt.all)
+ if (np->rxopt.all)
datagram_recv_ctl(sk, msg, skb);
err = copied;
@@ -405,7 +410,7 @@ static int rawv6_frag_cksum(const void *data, struct in6_addr *addr,
struct in6_addr *daddr;
sk = hdr->sk;
- opt = &sk->tp_pinfo.tp_raw;
+ opt = raw6_sk(sk);
if (hdr->daddr)
daddr = hdr->daddr;
@@ -434,7 +439,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, int len)
{
struct ipv6_txoptions opt_space;
struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name;
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6_txoptions *opt = NULL;
struct ip6_flowlabel *flowlabel = NULL;
struct flowi fl;
@@ -491,8 +496,8 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, int len)
/* Otherwise it will be difficult to maintain sk->dst_cache. */
if (sk->state == TCP_ESTABLISHED &&
- !ipv6_addr_cmp(daddr, &sk->net_pinfo.af_inet6.daddr))
- daddr = &sk->net_pinfo.af_inet6.daddr;
+ !ipv6_addr_cmp(daddr, &np->daddr))
+ daddr = &np->daddr;
if (addr_len >= sizeof(struct sockaddr_in6) &&
sin6->sin6_scope_id &&
@@ -503,7 +508,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, int len)
return(-EINVAL);
proto = sk->num;
- daddr = &(sk->net_pinfo.af_inet6.daddr);
+ daddr = &np->daddr;
fl.fl6_flowlabel = np->flow_label;
}
@@ -541,7 +546,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, int len)
if (flowlabel)
opt = fl6_merge_options(&opt_space, flowlabel, opt);
- raw_opt = &sk->tp_pinfo.tp_raw;
+ raw_opt = raw6_sk(sk);
fl.proto = proto;
fl.fl6_dst = daddr;
@@ -583,7 +588,7 @@ static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
case ICMPV6_FILTER:
if (optlen > sizeof(struct icmp6_filter))
optlen = sizeof(struct icmp6_filter);
- if (copy_from_user(&sk->tp_pinfo.tp_raw.filter, optval, optlen))
+ if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
return -EFAULT;
return 0;
default:
@@ -608,7 +613,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
len = sizeof(struct icmp6_filter);
if (put_user(len, optlen))
return -EFAULT;
- if (copy_to_user(optval, &sk->tp_pinfo.tp_raw.filter, len))
+ if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
return -EFAULT;
return 0;
default:
@@ -622,7 +627,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
static int rawv6_setsockopt(struct sock *sk, int level, int optname,
char *optval, int optlen)
{
- struct raw6_opt *opt = &sk->tp_pinfo.tp_raw;
+ struct raw6_opt *opt = raw6_sk(sk);
int val;
switch(level) {
@@ -665,7 +670,7 @@ static int rawv6_setsockopt(struct sock *sk, int level, int optname,
static int rawv6_getsockopt(struct sock *sk, int level, int optname,
char *optval, int *optlen)
{
- struct raw6_opt *opt = &sk->tp_pinfo.tp_raw;
+ struct raw6_opt *opt = raw6_sk(sk);
int val, len;
switch(level) {
@@ -752,11 +757,12 @@ static int rawv6_init_sk(struct sock *sk)
static void get_raw6_sock(struct sock *sp, char *tmpbuf, int i)
{
+ struct ipv6_pinfo *np = inet6_sk(sp);
struct in6_addr *dest, *src;
__u16 destp, srcp;
- dest = &sp->net_pinfo.af_inet6.daddr;
- src = &sp->net_pinfo.af_inet6.rcv_saddr;
+ dest = &np->daddr;
+ src = &np->rcv_saddr;
destp = 0;
srcp = sp->num;
sprintf(tmpbuf,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 4af8d5232..fe7d1af14 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -5,7 +5,7 @@
* Authors:
* Pedro Roque <roque@di.fc.ul.pt>
*
- * $Id: tcp_ipv6.c,v 1.143 2001-12-21 05:05:41 davem Exp $
+ * $Id: tcp_ipv6.c,v 1.144 2002-02-01 22:01:04 davem Exp $
*
* Based on:
* linux/net/ipv4/tcp.c
@@ -47,6 +47,7 @@
#include <net/addrconf.h>
#include <net/ip6_route.h>
#include <net/inet_ecn.h>
+#include <net/protocol.h>
#include <asm/uaccess.h>
@@ -75,8 +76,9 @@ static __inline__ int tcp_v6_hashfn(struct in6_addr *laddr, u16 lport,
static __inline__ int tcp_v6_sk_hashfn(struct sock *sk)
{
- struct in6_addr *laddr = &sk->net_pinfo.af_inet6.rcv_saddr;
- struct in6_addr *faddr = &sk->net_pinfo.af_inet6.daddr;
+ struct ipv6_pinfo *np = inet6_sk(sk);
+ struct in6_addr *laddr = &np->rcv_saddr;
+ struct in6_addr *faddr = &np->daddr;
__u16 lport = sk->num;
__u16 fport = sk->dport;
return tcp_v6_hashfn(laddr, lport, faddr, fport);
@@ -136,12 +138,15 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum)
if (tb->fastreuse != 0 && sk->reuse != 0 && sk->state != TCP_LISTEN) {
goto success;
} else {
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sock *sk2 = tb->owners;
int sk_reuse = sk->reuse;
- int addr_type = ipv6_addr_type(&sk->net_pinfo.af_inet6.rcv_saddr);
+ int addr_type = ipv6_addr_type(&np->rcv_saddr);
/* We must walk the whole port owner list in this case. -DaveM */
for( ; sk2 != NULL; sk2 = sk2->bind_next) {
+ struct ipv6_pinfo *np2 = inet6_sk(sk2);
+
if (sk != sk2 &&
sk->bound_dev_if == sk2->bound_dev_if) {
if (!sk_reuse ||
@@ -150,9 +155,9 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum)
/* NOTE: IPv6 tw bucket have different format */
if (!sk2->rcv_saddr ||
addr_type == IPV6_ADDR_ANY ||
- !ipv6_addr_cmp(&sk->net_pinfo.af_inet6.rcv_saddr,
+ !ipv6_addr_cmp(&np->rcv_saddr,
sk2->state != TCP_TIME_WAIT ?
- &sk2->net_pinfo.af_inet6.rcv_saddr :
+ &np2->rcv_saddr :
&((struct tcp_tw_bucket*)sk)->v6_rcv_saddr) ||
(addr_type==IPV6_ADDR_MAPPED && sk2->family==AF_INET &&
sk->rcv_saddr==sk2->rcv_saddr))
@@ -228,7 +233,9 @@ static __inline__ void __tcp_v6_hash(struct sock *sk)
static void tcp_v6_hash(struct sock *sk)
{
if(sk->state != TCP_CLOSE) {
- if (sk->tp_pinfo.af_tcp.af_specific == &ipv6_mapped) {
+ struct tcp_opt *tp = tcp_sk(sk);
+
+ if (tp->af_specific == &ipv6_mapped) {
tcp_prot.hash(sk);
return;
}
@@ -249,11 +256,11 @@ static struct sock *tcp_v6_lookup_listener(struct in6_addr *daddr, unsigned shor
sk = tcp_listening_hash[tcp_lhashfn(hnum)];
for(; sk; sk = sk->next) {
if((sk->num == hnum) && (sk->family == PF_INET6)) {
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
score = 1;
- if(!ipv6_addr_any(&np->rcv_saddr)) {
- if(ipv6_addr_cmp(&np->rcv_saddr, daddr))
+ if (!ipv6_addr_any(&np->rcv_saddr)) {
+ if (ipv6_addr_cmp(&np->rcv_saddr, daddr))
continue;
score++;
}
@@ -417,8 +424,9 @@ static __u32 tcp_v6_init_sequence(struct sock *sk, struct sk_buff *skb)
static int tcp_v6_check_established(struct sock *sk)
{
- struct in6_addr *daddr = &sk->net_pinfo.af_inet6.rcv_saddr;
- struct in6_addr *saddr = &sk->net_pinfo.af_inet6.daddr;
+ struct ipv6_pinfo *np = inet6_sk(sk);
+ struct in6_addr *daddr = &np->rcv_saddr;
+ struct in6_addr *saddr = &np->daddr;
int dif = sk->bound_dev_if;
u32 ports = TCP_COMBINED_PORTS(sk->dport, sk->num);
int hash = tcp_v6_hashfn(daddr, sk->num, saddr, sk->dport);
@@ -436,7 +444,7 @@ static int tcp_v6_check_established(struct sock *sk)
!ipv6_addr_cmp(&tw->v6_daddr, saddr) &&
!ipv6_addr_cmp(&tw->v6_rcv_saddr, daddr) &&
sk2->bound_dev_if == sk->bound_dev_if) {
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
if (tw->ts_recent_stamp) {
/* See comment in tcp_ipv4.c */
@@ -514,8 +522,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
int addr_len)
{
struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
- struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
+ struct ipv6_pinfo *np = inet6_sk(sk);
+ struct tcp_opt *tp = tcp_sk(sk);
struct in6_addr *saddr = NULL;
struct in6_addr saddr_buf;
struct flowi fl;
@@ -574,7 +582,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
return -EINVAL;
}
- if (tp->ts_recent_stamp && ipv6_addr_cmp(&np->daddr, &usin->sin6_addr)) {
+ if (tp->ts_recent_stamp &&
+ ipv6_addr_cmp(&np->daddr, &usin->sin6_addr)) {
tp->ts_recent = 0;
tp->ts_recent_stamp = 0;
tp->write_seq = 0;
@@ -597,20 +606,20 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
sin.sin_port = usin->sin6_port;
sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];
- sk->tp_pinfo.af_tcp.af_specific = &ipv6_mapped;
+ tp->af_specific = &ipv6_mapped;
sk->backlog_rcv = tcp_v4_do_rcv;
err = tcp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
if (err) {
tp->ext_header_len = exthdrlen;
- sk->tp_pinfo.af_tcp.af_specific = &ipv6_specific;
+ tp->af_specific = &ipv6_specific;
sk->backlog_rcv = tcp_v6_do_rcv;
goto failure;
} else {
- ipv6_addr_set(&np->saddr, 0, 0, __constant_htonl(0x0000FFFF),
+ ipv6_addr_set(&np->saddr, 0, 0, htonl(0x0000FFFF),
sk->saddr);
- ipv6_addr_set(&np->rcv_saddr, 0, 0, __constant_htonl(0x0000FFFF),
+ ipv6_addr_set(&np->rcv_saddr, 0, 0, htonl(0x0000FFFF),
sk->rcv_saddr);
}
@@ -628,7 +637,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
fl.uli_u.ports.sport = sk->sport;
if (np->opt && np->opt->srcrt) {
- struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
+ struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
fl.nl_u.ip6_u.daddr = rt0->addr;
}
@@ -657,7 +666,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
tp->ext_header_len = 0;
if (np->opt)
- tp->ext_header_len = np->opt->opt_flen+np->opt->opt_nflen;
+ tp->ext_header_len = np->opt->opt_flen + np->opt->opt_nflen;
tp->mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);
err = -ENOBUFS;
@@ -720,14 +729,14 @@ void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
if (sk->state == TCP_CLOSE)
goto out;
- tp = &sk->tp_pinfo.af_tcp;
+ tp = tcp_sk(sk);
seq = ntohl(th->seq);
if (sk->state != TCP_LISTEN && !between(seq, tp->snd_una, tp->snd_nxt)) {
NET_INC_STATS_BH(OutOfWindowIcmps);
goto out;
}
- np = &sk->net_pinfo.af_inet6;
+ np = inet6_sk(sk);
if (type == ICMPV6_PKT_TOOBIG) {
struct dst_entry *dst = NULL;
@@ -829,6 +838,7 @@ out:
static int tcp_v6_send_synack(struct sock *sk, struct open_request *req,
struct dst_entry *dst)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sk_buff * skb;
struct ipv6_txoptions *opt = NULL;
struct flowi fl;
@@ -843,9 +853,9 @@ static int tcp_v6_send_synack(struct sock *sk, struct open_request *req,
fl.uli_u.ports.sport = sk->sport;
if (dst == NULL) {
- opt = sk->net_pinfo.af_inet6.opt;
+ opt = np->opt;
if (opt == NULL &&
- sk->net_pinfo.af_inet6.rxopt.bits.srcrt == 2 &&
+ np->rxopt.bits.srcrt == 2 &&
req->af.v6_req.pktopts) {
struct sk_buff *pktopts = req->af.v6_req.pktopts;
struct inet6_skb_parm *rxopt = (struct inet6_skb_parm *)pktopts->cb;
@@ -879,7 +889,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct open_request *req,
done:
dst_release(dst);
- if (opt && opt != sk->net_pinfo.af_inet6.opt)
+ if (opt && opt != np->opt)
sock_kfree_s(sk, opt, opt->tot_len);
return err;
}
@@ -900,14 +910,15 @@ static struct or_calltable or_ipv6 = {
static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb;
- if (sk->net_pinfo.af_inet6.rxopt.all) {
- if ((opt->hop && sk->net_pinfo.af_inet6.rxopt.bits.hopopts) ||
+ if (np->rxopt.all) {
+ if ((opt->hop && np->rxopt.bits.hopopts) ||
((IPV6_FLOWINFO_MASK&*(u32*)skb->nh.raw) &&
- sk->net_pinfo.af_inet6.rxopt.bits.rxflow) ||
- (opt->srcrt && sk->net_pinfo.af_inet6.rxopt.bits.srcrt) ||
- ((opt->dst1 || opt->dst0) && sk->net_pinfo.af_inet6.rxopt.bits.dstopts))
+ np->rxopt.bits.rxflow) ||
+ (opt->srcrt && np->rxopt.bits.srcrt) ||
+ ((opt->dst1 || opt->dst0) && np->rxopt.bits.dstopts))
return 1;
}
return 0;
@@ -917,7 +928,7 @@ static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
static void tcp_v6_send_check(struct sock *sk, struct tcphdr *th, int len,
struct sk_buff *skb)
{
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
if (skb->ip_summed == CHECKSUM_HW) {
th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 0);
@@ -1084,7 +1095,7 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
{
struct open_request *req, **prev;
struct tcphdr *th = skb->h.th;
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
struct sock *nsk;
/* Find possible connection requests. */
@@ -1116,7 +1127,7 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
static void tcp_v6_synq_add(struct sock *sk, struct open_request *req)
{
- struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
+ struct tcp_opt *tp = tcp_sk(sk);
struct tcp_listen_opt *lopt = tp->listen_opt;
unsigned h = tcp_v6_synq_hash(&req->af.v6_req.rmt_addr, req->rmt_port);
@@ -1139,7 +1150,8 @@ static void tcp_v6_synq_add(struct sock *sk, struct open_request *req)
*/
static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
{
- struct tcp_opt tp;
+ struct ipv6_pinfo *np = inet6_sk(sk);
+ struct tcp_opt tmptp, *tp = tcp_sk(sk);
struct open_request *req = NULL;
__u32 isn = TCP_SKB_CB(skb)->when;
@@ -1166,14 +1178,14 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
if (req == NULL)
goto drop;
- tcp_clear_options(&tp);
- tp.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);
- tp.user_mss = sk->tp_pinfo.af_tcp.user_mss;
+ tcp_clear_options(&tmptp);
+ tmptp.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);
+ tmptp.user_mss = tp->user_mss;
- tcp_parse_options(skb, &tp, 0);
+ tcp_parse_options(skb, &tmptp, 0);
- tp.tstamp_ok = tp.saw_tstamp;
- tcp_openreq_init(req, &tp, skb);
+ tmptp.tstamp_ok = tmptp.saw_tstamp;
+ tcp_openreq_init(req, &tmptp, skb);
req->class = &or_ipv6;
ipv6_addr_copy(&req->af.v6_req.rmt_addr, &skb->nh.ipv6h->saddr);
@@ -1181,8 +1193,8 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
TCP_ECN_create_request(req, skb->h.th);
req->af.v6_req.pktopts = NULL;
if (ipv6_opt_accepted(sk, skb) ||
- sk->net_pinfo.af_inet6.rxopt.bits.rxinfo ||
- sk->net_pinfo.af_inet6.rxopt.bits.rxhlim) {
+ np->rxopt.bits.rxinfo ||
+ np->rxopt.bits.rxhlim) {
atomic_inc(&skb->users);
req->af.v6_req.pktopts = skb;
}
@@ -1216,8 +1228,9 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
struct open_request *req,
struct dst_entry *dst)
{
- struct ipv6_pinfo *np;
+ struct ipv6_pinfo *newnp, *np = inet6_sk(sk);
struct flowi fl;
+ struct inet_opt *newinet;
struct tcp_opt *newtp;
struct sock *newsk;
struct ipv6_txoptions *opt;
@@ -1232,22 +1245,23 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
if (newsk == NULL)
return NULL;
- np = &newsk->net_pinfo.af_inet6;
+ newnp = inet6_sk(newsk);
+ newtp = tcp_sk(newsk);
- ipv6_addr_set(&np->daddr, 0, 0, __constant_htonl(0x0000FFFF),
+ ipv6_addr_set(&newnp->daddr, 0, 0, htonl(0x0000FFFF),
newsk->daddr);
- ipv6_addr_set(&np->saddr, 0, 0, __constant_htonl(0x0000FFFF),
+ ipv6_addr_set(&newnp->saddr, 0, 0, htonl(0x0000FFFF),
newsk->saddr);
- ipv6_addr_copy(&np->rcv_saddr, &np->saddr);
+ ipv6_addr_copy(&newnp->rcv_saddr, &newnp->saddr);
- newsk->tp_pinfo.af_tcp.af_specific = &ipv6_mapped;
+ newtp->af_specific = &ipv6_mapped;
newsk->backlog_rcv = tcp_v4_do_rcv;
- newsk->net_pinfo.af_inet6.pktoptions = NULL;
- newsk->net_pinfo.af_inet6.opt = NULL;
- newsk->net_pinfo.af_inet6.mcast_oif = tcp_v6_iif(skb);
- newsk->net_pinfo.af_inet6.mcast_hops = skb->nh.ipv6h->hop_limit;
+ newnp->pktoptions = NULL;
+ newnp->opt = NULL;
+ newnp->mcast_oif = tcp_v6_iif(skb);
+ newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
/* Charge newly allocated IPv6 socket. Though it is mapped,
* it is IPv6 yet.
@@ -1261,17 +1275,17 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
worked with IPv6 af_tcp.af_specific.
Sync it now.
*/
- tcp_sync_mss(newsk, newsk->tp_pinfo.af_tcp.pmtu_cookie);
+ tcp_sync_mss(newsk, newtp->pmtu_cookie);
return newsk;
}
- opt = sk->net_pinfo.af_inet6.opt;
+ opt = np->opt;
if (tcp_acceptq_is_full(sk))
goto out_overflow;
- if (sk->net_pinfo.af_inet6.rxopt.bits.srcrt == 2 &&
+ if (np->rxopt.bits.srcrt == 2 &&
opt == NULL && req->af.v6_req.pktopts) {
struct inet6_skb_parm *rxopt = (struct inet6_skb_parm *)req->af.v6_req.pktopts->cb;
if (rxopt->srcrt)
@@ -1310,35 +1324,36 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
ip6_dst_store(newsk, dst, NULL);
sk->route_caps = dst->dev->features&~NETIF_F_IP_CSUM;
- newtp = &(newsk->tp_pinfo.af_tcp);
-
- np = &newsk->net_pinfo.af_inet6;
- ipv6_addr_copy(&np->daddr, &req->af.v6_req.rmt_addr);
- ipv6_addr_copy(&np->saddr, &req->af.v6_req.loc_addr);
- ipv6_addr_copy(&np->rcv_saddr, &req->af.v6_req.loc_addr);
+ newtp = tcp_sk(newsk);
+ newinet = inet_sk(newsk);
+ newnp = inet6_sk(newsk);
+ ipv6_addr_copy(&newnp->daddr, &req->af.v6_req.rmt_addr);
+ ipv6_addr_copy(&newnp->saddr, &req->af.v6_req.loc_addr);
+ ipv6_addr_copy(&newnp->rcv_saddr, &req->af.v6_req.loc_addr);
newsk->bound_dev_if = req->af.v6_req.iif;
/* Now IPv6 options...
First: no IPv4 options.
*/
- newsk->protinfo.af_inet.opt = NULL;
+ newinet->opt = NULL;
/* Clone RX bits */
- np->rxopt.all = sk->net_pinfo.af_inet6.rxopt.all;
+ newnp->rxopt.all = np->rxopt.all;
/* Clone pktoptions received with SYN */
- np->pktoptions = NULL;
+ newnp->pktoptions = NULL;
if (req->af.v6_req.pktopts) {
- np->pktoptions = skb_clone(req->af.v6_req.pktopts, GFP_ATOMIC);
+ newnp->pktoptions = skb_clone(req->af.v6_req.pktopts,
+ GFP_ATOMIC);
kfree_skb(req->af.v6_req.pktopts);
req->af.v6_req.pktopts = NULL;
- if (np->pktoptions)
- skb_set_owner_r(np->pktoptions, newsk);
+ if (newnp->pktoptions)
+ skb_set_owner_r(newnp->pktoptions, newsk);
}
- np->opt = NULL;
- np->mcast_oif = tcp_v6_iif(skb);
- np->mcast_hops = skb->nh.ipv6h->hop_limit;
+ newnp->opt = NULL;
+ newnp->mcast_oif = tcp_v6_iif(skb);
+ newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
/* Clone native IPv6 options from listening socket (if any)
@@ -1347,22 +1362,23 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
to newsk.
*/
if (opt) {
- np->opt = ipv6_dup_options(newsk, opt);
- if (opt != sk->net_pinfo.af_inet6.opt)
+ newnp->opt = ipv6_dup_options(newsk, opt);
+ if (opt != np->opt)
sock_kfree_s(sk, opt, opt->tot_len);
}
newtp->ext_header_len = 0;
- if (np->opt)
- newtp->ext_header_len = np->opt->opt_nflen + np->opt->opt_flen;
+ if (newnp->opt)
+ newtp->ext_header_len = newnp->opt->opt_nflen +
+ newnp->opt->opt_flen;
tcp_sync_mss(newsk, dst->pmtu);
newtp->advmss = dst->advmss;
tcp_initialize_rcv_mss(newsk);
- newsk->daddr = LOOPBACK4_IPV6;
- newsk->saddr = LOOPBACK4_IPV6;
- newsk->rcv_saddr= LOOPBACK4_IPV6;
+ newsk->daddr = LOOPBACK4_IPV6;
+ newsk->saddr = LOOPBACK4_IPV6;
+ newsk->rcv_saddr = LOOPBACK4_IPV6;
__tcp_v6_hash(newsk);
tcp_inherit_port(sk, newsk);
@@ -1373,7 +1389,7 @@ out_overflow:
NET_INC_STATS_BH(ListenOverflows);
out:
NET_INC_STATS_BH(ListenDrops);
- if (opt && opt != sk->net_pinfo.af_inet6.opt)
+ if (opt && opt != np->opt)
sock_kfree_s(sk, opt, opt->tot_len);
dst_release(dst);
return NULL;
@@ -1410,6 +1426,8 @@ static int tcp_v6_checksum_init(struct sk_buff *skb)
*/
static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
+ struct tcp_opt *tp;
#ifdef CONFIG_FILTER
struct sk_filter *filter;
#endif
@@ -1452,7 +1470,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
by tcp. Feel free to propose better solution.
--ANK (980728)
*/
- if (sk->net_pinfo.af_inet6.rxopt.all)
+ if (np->rxopt.all)
opt_skb = skb_clone(skb, GFP_ATOMIC);
if (sk->state == TCP_ESTABLISHED) { /* Fast path */
@@ -1515,18 +1533,19 @@ ipv6_pktoptions:
3. socket is not in passive state.
4. Finally, it really contains options, which user wants to receive.
*/
- if (TCP_SKB_CB(opt_skb)->end_seq == sk->tp_pinfo.af_tcp.rcv_nxt &&
+ tp = tcp_sk(sk);
+ if (TCP_SKB_CB(opt_skb)->end_seq == tp->rcv_nxt &&
!((1<<sk->state)&(TCPF_CLOSE|TCPF_LISTEN))) {
- if (sk->net_pinfo.af_inet6.rxopt.bits.rxinfo)
- sk->net_pinfo.af_inet6.mcast_oif = tcp_v6_iif(opt_skb);
- if (sk->net_pinfo.af_inet6.rxopt.bits.rxhlim)
- sk->net_pinfo.af_inet6.mcast_hops = opt_skb->nh.ipv6h->hop_limit;
+ if (np->rxopt.bits.rxinfo)
+ np->mcast_oif = tcp_v6_iif(opt_skb);
+ if (np->rxopt.bits.rxhlim)
+ np->mcast_hops = opt_skb->nh.ipv6h->hop_limit;
if (ipv6_opt_accepted(sk, opt_skb)) {
skb_set_owner_r(opt_skb, sk);
- opt_skb = xchg(&sk->net_pinfo.af_inet6.pktoptions, opt_skb);
+ opt_skb = xchg(&np->pktoptions, opt_skb);
} else {
__kfree_skb(opt_skb);
- opt_skb = xchg(&sk->net_pinfo.af_inet6.pktoptions, NULL);
+ opt_skb = xchg(&np->pktoptions, NULL);
}
}
@@ -1656,7 +1675,7 @@ static int tcp_v6_rebuild_header(struct sock *sk)
{
int err;
struct dst_entry *dst;
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
dst = __sk_dst_check(sk, np->dst_cookie);
@@ -1695,7 +1714,7 @@ static int tcp_v6_rebuild_header(struct sock *sk)
static int tcp_v6_xmit(struct sk_buff *skb)
{
struct sock *sk = skb->sk;
- struct ipv6_pinfo * np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct flowi fl;
struct dst_entry *dst;
@@ -1737,7 +1756,7 @@ static int tcp_v6_xmit(struct sk_buff *skb)
static void v6_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr)
{
- struct ipv6_pinfo * np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) uaddr;
sin6->sin6_family = AF_INET6;
@@ -1799,7 +1818,7 @@ static struct tcp_func ipv6_mapped = {
*/
static int tcp_v6_init_sock(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
skb_queue_head_init(&tp->out_of_order_queue);
tcp_init_xmit_timers(sk);
@@ -1826,7 +1845,7 @@ static int tcp_v6_init_sock(struct sock *sk)
sk->state = TCP_CLOSE;
- sk->tp_pinfo.af_tcp.af_specific = &ipv6_specific;
+ tp->af_specific = &ipv6_specific;
sk->write_space = tcp_write_space;
sk->use_write_queue = 1;
@@ -1841,7 +1860,7 @@ static int tcp_v6_init_sock(struct sock *sk)
static int tcp_v6_destroy_sock(struct sock *sk)
{
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
tcp_clear_xmit_timers(sk);
@@ -1905,10 +1924,11 @@ static void get_tcp6_sock(struct sock *sp, char *tmpbuf, int i)
__u16 destp, srcp;
int timer_active;
unsigned long timer_expires;
- struct tcp_opt *tp = &sp->tp_pinfo.af_tcp;
+ struct tcp_opt *tp = tcp_sk(sp);
+ struct ipv6_pinfo *np = inet6_sk(sp);
- dest = &sp->net_pinfo.af_inet6.daddr;
- src = &sp->net_pinfo.af_inet6.rcv_saddr;
+ dest = &np->daddr;
+ src = &np->rcv_saddr;
destp = ntohs(sp->dport);
srcp = ntohs(sp->sport);
if (tp->pending == TCP_TIME_RETRANS) {
@@ -2004,7 +2024,7 @@ int tcp6_get_info(char *buffer, char **start, off_t offset, int length)
for (sk = tcp_listening_hash[i]; sk; sk = sk->next, num++) {
struct open_request *req;
int uid;
- struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+ struct tcp_opt *tp = tcp_sk(sk);
if (sk->family != PF_INET6)
continue;
@@ -2122,13 +2142,10 @@ struct proto tcpv6_prot = {
static struct inet6_protocol tcpv6_protocol =
{
- tcp_v6_rcv, /* TCP handler */
- tcp_v6_err, /* TCP error control */
- NULL, /* next */
- IPPROTO_TCP, /* protocol ID */
- 0, /* copy */
- NULL, /* data */
- "TCPv6" /* name */
+ handler: tcp_v6_rcv,
+ err_handler: tcp_v6_err,
+ protocol: IPPROTO_TCP,
+ name: "TCPv6",
};
extern struct proto_ops inet6_stream_ops;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 63092324a..4b30849a2 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -7,7 +7,7 @@
*
* Based on linux/ipv4/udp.c
*
- * $Id: udp.c,v 1.64 2001-09-01 00:31:50 davem Exp $
+ * $Id: udp.c,v 1.65 2002-02-01 22:01:04 davem Exp $
*
* Fixes:
* Hideaki YOSHIFUJI : sin6_scope_id support
@@ -98,18 +98,20 @@ gotit:
udp_port_rover = snum = result;
} else {
struct sock *sk2;
- int addr_type = ipv6_addr_type(&sk->net_pinfo.af_inet6.rcv_saddr);
+ struct ipv6_pinfo *np = inet6_sk(sk);
+ int addr_type = ipv6_addr_type(&np->rcv_saddr);
for (sk2 = udp_hash[snum & (UDP_HTABLE_SIZE - 1)];
sk2 != NULL;
sk2 = sk2->next) {
+ struct ipv6_pinfo *np2 = inet6_sk(sk2);
+
if (sk2->num == snum &&
sk2 != sk &&
sk2->bound_dev_if == sk->bound_dev_if &&
(!sk2->rcv_saddr ||
addr_type == IPV6_ADDR_ANY ||
- !ipv6_addr_cmp(&sk->net_pinfo.af_inet6.rcv_saddr,
- &sk2->net_pinfo.af_inet6.rcv_saddr) ||
+ !ipv6_addr_cmp(&np->rcv_saddr, &np2->rcv_saddr) ||
(addr_type == IPV6_ADDR_MAPPED &&
sk2->family == AF_INET &&
sk->rcv_saddr == sk2->rcv_saddr)) &&
@@ -167,20 +169,20 @@ static struct sock *udp_v6_lookup(struct in6_addr *saddr, u16 sport,
for(sk = udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]; sk != NULL; sk = sk->next) {
if((sk->num == hnum) &&
(sk->family == PF_INET6)) {
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
int score = 0;
if(sk->dport) {
if(sk->dport != sport)
continue;
score++;
}
- if(!ipv6_addr_any(&np->rcv_saddr)) {
- if(ipv6_addr_cmp(&np->rcv_saddr, daddr))
+ if (!ipv6_addr_any(&np->rcv_saddr)) {
+ if (ipv6_addr_cmp(&np->rcv_saddr, daddr))
continue;
score++;
}
- if(!ipv6_addr_any(&np->daddr)) {
- if(ipv6_addr_cmp(&np->daddr, saddr))
+ if (!ipv6_addr_any(&np->daddr)) {
+ if (ipv6_addr_cmp(&np->daddr, saddr))
continue;
score++;
}
@@ -211,7 +213,7 @@ static struct sock *udp_v6_lookup(struct in6_addr *saddr, u16 sport,
int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{
struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct in6_addr *daddr;
struct in6_addr saddr;
struct dst_entry *dst;
@@ -266,19 +268,15 @@ ipv4_connected:
if (err < 0)
return err;
- ipv6_addr_set(&np->daddr, 0, 0,
- __constant_htonl(0x0000ffff),
- sk->daddr);
+ ipv6_addr_set(&np->daddr, 0, 0, htonl(0x0000ffff), sk->daddr);
- if(ipv6_addr_any(&np->saddr)) {
- ipv6_addr_set(&np->saddr, 0, 0,
- __constant_htonl(0x0000ffff),
+ if (ipv6_addr_any(&np->saddr)) {
+ ipv6_addr_set(&np->saddr, 0, 0, htonl(0x0000ffff),
sk->saddr);
}
- if(ipv6_addr_any(&np->rcv_saddr)) {
- ipv6_addr_set(&np->rcv_saddr, 0, 0,
- __constant_htonl(0x0000ffff),
+ if (ipv6_addr_any(&np->rcv_saddr)) {
+ ipv6_addr_set(&np->rcv_saddr, 0, 0, htonl(0x0000ffff),
sk->rcv_saddr);
}
return 0;
@@ -322,7 +320,7 @@ ipv4_connected:
fl.fl6_dst = rt0->addr;
}
} else if (np->opt && np->opt->srcrt) {
- struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
+ struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
fl.fl6_dst = rt0->addr;
}
@@ -341,10 +339,10 @@ ipv4_connected:
err = ipv6_get_saddr(dst, daddr, &saddr);
if (err == 0) {
- if(ipv6_addr_any(&np->saddr))
+ if (ipv6_addr_any(&np->saddr))
ipv6_addr_copy(&np->saddr, &saddr);
- if(ipv6_addr_any(&np->rcv_saddr)) {
+ if (ipv6_addr_any(&np->rcv_saddr)) {
ipv6_addr_copy(&np->rcv_saddr, &saddr);
sk->rcv_saddr = LOOPBACK4_IPV6;
}
@@ -368,6 +366,7 @@ static void udpv6_close(struct sock *sk, long timeout)
int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, int len,
int noblock, int flags, int *addr_len)
{
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sk_buff *skb;
int copied, err;
@@ -416,15 +415,17 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, int len,
sin6->sin6_scope_id = 0;
if (skb->protocol == __constant_htons(ETH_P_IP)) {
+ struct inet_opt *inet = inet_sk(sk);
+
ipv6_addr_set(&sin6->sin6_addr, 0, 0,
__constant_htonl(0xffff), skb->nh.iph->saddr);
- if (sk->protinfo.af_inet.cmsg_flags)
+ if (inet->cmsg_flags)
ip_cmsg_recv(msg, skb);
} else {
memcpy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr,
sizeof(struct in6_addr));
- if (sk->net_pinfo.af_inet6.rxopt.all)
+ if (np->rxopt.all)
datagram_recv_ctl(sk, msg, skb);
if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
@@ -464,6 +465,7 @@ csum_copy_err:
void udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
int type, int code, int offset, __u32 info)
{
+ struct ipv6_pinfo *np;
struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data;
struct net_device *dev = skb->dev;
struct in6_addr *saddr = &hdr->saddr;
@@ -477,15 +479,15 @@ void udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
if (sk == NULL)
return;
- if (!icmpv6_err_convert(type, code, &err) &&
- !sk->net_pinfo.af_inet6.recverr)
+ np = inet6_sk(sk);
+
+ if (!icmpv6_err_convert(type, code, &err) && !np->recverr)
goto out;
- if (sk->state!=TCP_ESTABLISHED &&
- !sk->net_pinfo.af_inet6.recverr)
+ if (sk->state != TCP_ESTABLISHED && !np->recverr)
goto out;
- if (sk->net_pinfo.af_inet6.recverr)
+ if (np->recverr)
ipv6_icmp_error(sk, skb, err, uh->dest, ntohl(info), (u8 *)(uh+1));
sk->err = err;
@@ -527,20 +529,20 @@ static struct sock *udp_v6_mcast_next(struct sock *sk,
unsigned short num = ntohs(loc_port);
for(; s; s = s->next) {
if(s->num == num) {
- struct ipv6_pinfo *np = &s->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(s);
if(s->dport) {
if(s->dport != rmt_port)
continue;
}
- if(!ipv6_addr_any(&np->daddr) &&
- ipv6_addr_cmp(&np->daddr, rmt_addr))
+ if (!ipv6_addr_any(&np->daddr) &&
+ ipv6_addr_cmp(&np->daddr, rmt_addr))
continue;
if (s->bound_dev_if && s->bound_dev_if != dif)
continue;
- if(!ipv6_addr_any(&np->rcv_saddr)) {
- if(ipv6_addr_cmp(&np->rcv_saddr, loc_addr) == 0)
+ if (!ipv6_addr_any(&np->rcv_saddr)) {
+ if (!ipv6_addr_cmp(&np->rcv_saddr, loc_addr))
return s;
}
if(!inet6_mc_check(s, loc_addr))
@@ -755,7 +757,7 @@ static int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, int ulen)
{
struct ipv6_txoptions opt_space;
struct udpv6fakehdr udh;
- struct ipv6_pinfo *np = &sk->net_pinfo.af_inet6;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) msg->msg_name;
struct ipv6_txoptions *opt = NULL;
struct ip6_flowlabel *flowlabel = NULL;
@@ -805,8 +807,8 @@ static int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, int ulen)
/* Otherwise it will be difficult to maintain sk->dst_cache. */
if (sk->state == TCP_ESTABLISHED &&
- !ipv6_addr_cmp(daddr, &sk->net_pinfo.af_inet6.daddr))
- daddr = &sk->net_pinfo.af_inet6.daddr;
+ !ipv6_addr_cmp(daddr, &np->daddr))
+ daddr = &np->daddr;
if (addr_len >= sizeof(struct sockaddr_in6) &&
sin6->sin6_scope_id &&
@@ -817,7 +819,7 @@ static int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, int ulen)
return -ENOTCONN;
udh.uh.dest = sk->dport;
- daddr = &sk->net_pinfo.af_inet6.daddr;
+ daddr = &np->daddr;
fl.fl6_flowlabel = np->flow_label;
}
@@ -891,15 +893,11 @@ static int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, int ulen)
return ulen;
}
-static struct inet6_protocol udpv6_protocol =
-{
- udpv6_rcv, /* UDP handler */
- udpv6_err, /* UDP error control */
- NULL, /* next */
- IPPROTO_UDP, /* protocol ID */
- 0, /* copy */
- NULL, /* data */
- "UDPv6" /* name */
+static struct inet6_protocol udpv6_protocol = {
+ handler: udpv6_rcv,
+ err_handler: udpv6_err,
+ protocol: IPPROTO_UDP,
+ name: "UDPv6",
};
#define LINE_LEN 190
@@ -907,11 +905,12 @@ static struct inet6_protocol udpv6_protocol =
static void get_udp6_sock(struct sock *sp, char *tmpbuf, int i)
{
+ struct ipv6_pinfo *np = inet6_sk(sp);
struct in6_addr *dest, *src;
__u16 destp, srcp;
- dest = &sp->net_pinfo.af_inet6.daddr;
- src = &sp->net_pinfo.af_inet6.rcv_saddr;
+ dest = &np->daddr;
+ src = &np->rcv_saddr;
destp = ntohs(sp->dport);
srcp = ntohs(sp->sport);
sprintf(tmpbuf,
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index 163dc0bdc..ac2ea3636 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -73,6 +73,9 @@
* Petr Vandrovec for review and good suggestions. (acme)
* Revision 047: Cleanups, CodingStyle changes, move the ncp connection
* hack out of line (acme)
+ * Revision 048: Use sk->protinfo to store the pointer to IPX private
+ * area, remove af_ipx from sk->protinfo and move ipx_opt
+ * to include/net/ipx.h, use IPX_SK like DecNET, etc
*
* Protect the module by a MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT
* pair. Also, now usage count is managed this way
@@ -103,6 +106,7 @@
#include <linux/netdevice.h>
#include <net/ipx.h>
#include <linux/inet.h>
+#include <linux/tcp.h>
#include <linux/route.h>
#include <net/sock.h>
#include <asm/uaccess.h>
@@ -151,8 +155,6 @@ static spinlock_t ipx_interfaces_lock = SPIN_LOCK_UNLOCKED;
static ipx_interface *ipx_primary_net;
static ipx_interface *ipx_internal_net;
-#define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0]))
-
#undef IPX_REFCNT_DEBUG
#ifdef IPX_REFCNT_DEBUG
atomic_t ipx_sock_nr;
@@ -218,10 +220,9 @@ static inline void __ipxitf_put(ipx_interface *intrfc)
void ipx_remove_socket(struct sock *sk)
{
struct sock *s;
- ipx_interface *intrfc;
-
/* Determine interface with which socket is associated */
- intrfc = sk->protinfo.af_ipx.intrfc;
+ ipx_interface *intrfc = ipx_sk(sk)->intrfc;
+
if (!intrfc)
goto out;
@@ -323,7 +324,7 @@ static void ipxitf_insert_socket(ipx_interface *intrfc, struct sock *sk)
ipxitf_hold(intrfc);
sock_hold(sk);
spin_lock_bh(&intrfc->if_sklist_lock);
- sk->protinfo.af_ipx.intrfc = intrfc;
+ ipx_sk(sk)->intrfc = intrfc;
sk->next = NULL;
if (!intrfc->if_sklist)
intrfc->if_sklist = sk;
@@ -343,7 +344,7 @@ static struct sock *__ipxitf_find_socket(ipx_interface *intrfc,
{
struct sock *s = intrfc->if_sklist;
- while (s && s->protinfo.af_ipx.port != port)
+ while (s && ipx_sk(s)->port != port)
s = s->next;
return s;
@@ -375,8 +376,10 @@ static struct sock *ipxitf_find_internal_socket(ipx_interface *intrfc,
s = intrfc->if_sklist;
while (s) {
- if (s->protinfo.af_ipx.port == port &&
- !memcmp(node, s->protinfo.af_ipx.node, IPX_NODE_LEN))
+ struct ipx_opt *ipxs = ipx_sk(s);
+
+ if (ipxs->port == port &&
+ !memcmp(node, ipxs->node, IPX_NODE_LEN))
break;
s = s->next;
}
@@ -399,10 +402,12 @@ static void __ipxitf_down(ipx_interface *intrfc)
spin_lock_bh(&intrfc->if_sklist_lock);
/* error sockets */
for (s = intrfc->if_sklist; s;) {
+ struct ipx_opt *ipxs = ipx_sk(s);
+
s->err = ENOLINK;
s->error_report(s);
- s->protinfo.af_ipx.intrfc = NULL;
- s->protinfo.af_ipx.port = 0;
+ ipxs->intrfc = NULL;
+ ipxs->port = 0;
s->zapped = 1; /* Indicates it is no longer bound */
t = s;
s = s->next;
@@ -491,10 +496,11 @@ static int ipxitf_demux_socket(ipx_interface *intrfc, struct sk_buff *skb,
s = intrfc->if_sklist;
while (s) {
- if (s->protinfo.af_ipx.port == ipx->ipx_dest.sock &&
+ struct ipx_opt *ipxs = ipx_sk(s);
+
+ if (ipxs->port == ipx->ipx_dest.sock &&
(is_broadcast || !memcmp(ipx->ipx_dest.node,
- s->protinfo.af_ipx.node,
- IPX_NODE_LEN))) {
+ ipxs->node, IPX_NODE_LEN))) {
/* We found a socket to which to send */
struct sk_buff *skb1;
@@ -550,7 +556,7 @@ static struct sock *ncp_connection_hack(ipx_interface *intrfc,
* SIOCIPXNCPCONN. */
spin_lock_bh(&intrfc->if_sklist_lock);
for (sk = intrfc->if_sklist;
- sk && sk->protinfo.af_ipx.ipx_ncp_conn != connection;
+ sk && ipx_sk(sk)->ipx_ncp_conn != connection;
sk = sk->next);
if (sk)
sock_hold(sk);
@@ -769,7 +775,7 @@ static int ipxitf_send(ipx_interface *intrfc, struct sk_buff *skb, char *node)
/* set up data link and physical headers */
skb->dev = dev;
- skb->protocol = __constant_htons(ETH_P_IPX);
+ skb->protocol = htons(ETH_P_IPX);
dl->datalink_header(dl, skb, dest_node);
/* Send it out */
@@ -1042,17 +1048,13 @@ static int ipx_map_frame_type(unsigned char type)
switch (type) {
case IPX_FRAME_ETHERII:
- ret = __constant_htons(ETH_P_IPX);
- break;
+ ret = htons(ETH_P_IPX); break;
case IPX_FRAME_8022:
- ret = __constant_htons(ETH_P_802_2);
- break;
+ ret = htons(ETH_P_802_2); break;
case IPX_FRAME_SNAP:
- ret = __constant_htons(ETH_P_SNAP);
- break;
+ ret = htons(ETH_P_SNAP); break;
case IPX_FRAME_8023:
- ret = __constant_htons(ETH_P_802_3);
- break;
+ ret = htons(ETH_P_802_3); break;
}
return ret;
@@ -1096,12 +1098,12 @@ static int ipxitf_create(ipx_interface_definition *idef)
"obsolete Use 802.2 instead.\n");
/* fall through */
case IPX_FRAME_8022:
- dlink_type = __constant_htons(ETH_P_802_2);
+ dlink_type = htons(ETH_P_802_2);
datalink = p8022_datalink;
break;
case IPX_FRAME_ETHERII:
if (dev->type != ARPHRD_IEEE802) {
- dlink_type = __constant_htons(ETH_P_IPX);
+ dlink_type = htons(ETH_P_IPX);
datalink = pEII_datalink;
break;
} else
@@ -1110,11 +1112,11 @@ static int ipxitf_create(ipx_interface_definition *idef)
"instead.\n");
/* fall through */
case IPX_FRAME_SNAP:
- dlink_type = __constant_htons(ETH_P_SNAP);
+ dlink_type = htons(ETH_P_SNAP);
datalink = pSNAP_datalink;
break;
case IPX_FRAME_8023:
- dlink_type = __constant_htons(ETH_P_802_3);
+ dlink_type = htons(ETH_P_802_3);
datalink = p8023_datalink;
break;
case IPX_FRAME_NONE:
@@ -1489,7 +1491,7 @@ static __u16 ipx_cksum(struct ipxhdr *packet, int length)
sum += *p++;
/* Add on the last part word if it exists */
- if (packet->ipx_pktsize & __constant_htons(1))
+ if (packet->ipx_pktsize & htons(1))
sum += ntohs(0xff00) & *p;
/* Do final fixup */
@@ -1509,6 +1511,7 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
struct iovec *iov, int len, int noblock)
{
struct sk_buff *skb;
+ struct ipx_opt *ipxs = ipx_sk(sk);
ipx_interface *intrfc;
struct ipxhdr *ipx;
int size;
@@ -1548,21 +1551,21 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
IPX_SKB_CB(skb)->last_hop.index = -1;
#ifdef CONFIG_IPX_INTERN
- IPX_SKB_CB(skb)->ipx_source_net = sk->protinfo.af_ipx.intrfc->if_netnum;
- memcpy(ipx->ipx_source.node, sk->protinfo.af_ipx.node, IPX_NODE_LEN);
+ IPX_SKB_CB(skb)->ipx_source_net = ipxs->intrfc->if_netnum;
+ memcpy(ipx->ipx_source.node, ipxs->node, IPX_NODE_LEN);
#else
- err = ntohs(sk->protinfo.af_ipx.port);
+ err = ntohs(ipxs->port);
if (err == 0x453 || err == 0x452) {
/* RIP/SAP special handling for mars_nwe */
IPX_SKB_CB(skb)->ipx_source_net = intrfc->if_netnum;
memcpy(ipx->ipx_source.node, intrfc->if_node, IPX_NODE_LEN);
} else {
- IPX_SKB_CB(skb)->ipx_source_net =
- sk->protinfo.af_ipx.intrfc->if_netnum;
- memcpy(ipx->ipx_source.node, sk->protinfo.af_ipx.intrfc->if_node, IPX_NODE_LEN);
+ IPX_SKB_CB(skb)->ipx_source_net = ipxs->intrfc->if_netnum;
+ memcpy(ipx->ipx_source.node, ipxs->intrfc->if_node,
+ IPX_NODE_LEN);
}
#endif /* CONFIG_IPX_INTERN */
- ipx->ipx_source.sock = sk->protinfo.af_ipx.port;
+ ipx->ipx_source.sock = ipxs->port;
IPX_SKB_CB(skb)->ipx_dest_net = usipx->sipx_network;
memcpy(ipx->ipx_dest.node, usipx->sipx_node, IPX_NODE_LEN);
ipx->ipx_dest.sock = usipx->sipx_port;
@@ -1743,21 +1746,19 @@ static int ipx_get_info(char *buffer, char **start, off_t offset, int length)
ipxitf_hold(i);
spin_lock_bh(&i->if_sklist_lock);
for (s = i->if_sklist; s; s = s->next) {
+ struct ipx_opt *ipxs = ipx_sk(s);
#ifdef CONFIG_IPX_INTERN
len += sprintf(buffer + len,
"%08lX:%02X%02X%02X%02X%02X%02X:%04X ",
- (unsigned long) htonl(s->protinfo.af_ipx.intrfc->if_netnum),
- s->protinfo.af_ipx.node[0],
- s->protinfo.af_ipx.node[1],
- s->protinfo.af_ipx.node[2],
- s->protinfo.af_ipx.node[3],
- s->protinfo.af_ipx.node[4],
- s->protinfo.af_ipx.node[5],
- htons(s->protinfo.af_ipx.port));
+ (unsigned long)htonl(ipxs->intrfc->if_netnum),
+ ipxs->node[0], ipxs->node[1],
+ ipxs->node[2], ipxs->node[3],
+ ipxs->node[4], ipxs->node[5],
+ htons(ipxs->port));
#else
len += sprintf(buffer + len, "%08lX:%04X ",
(unsigned long) htonl(i->if_netnum),
- htons(s->protinfo.af_ipx.port));
+ htons(ipxs->port));
#endif /* CONFIG_IPX_INTERN */
if (s->state != TCP_ESTABLISHED)
len += sprintf(buffer + len, "%-28s",
@@ -1765,14 +1766,14 @@ static int ipx_get_info(char *buffer, char **start, off_t offset, int length)
else {
len += sprintf(buffer + len,
"%08lX:%02X%02X%02X%02X%02X%02X:%04X ",
- (unsigned long) htonl(s->protinfo.af_ipx.dest_addr.net),
- s->protinfo.af_ipx.dest_addr.node[0],
- s->protinfo.af_ipx.dest_addr.node[1],
- s->protinfo.af_ipx.dest_addr.node[2],
- s->protinfo.af_ipx.dest_addr.node[3],
- s->protinfo.af_ipx.dest_addr.node[4],
- s->protinfo.af_ipx.dest_addr.node[5],
- htons(s->protinfo.af_ipx.dest_addr.sock));
+ (unsigned long)htonl(ipxs->dest_addr.net),
+ ipxs->dest_addr.node[0],
+ ipxs->dest_addr.node[1],
+ ipxs->dest_addr.node[2],
+ ipxs->dest_addr.node[3],
+ ipxs->dest_addr.node[4],
+ ipxs->dest_addr.node[5],
+ htons(ipxs->dest_addr.sock));
}
len += sprintf(buffer + len, "%08X %08X ",
@@ -1868,7 +1869,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname,
if (!(level == SOL_IPX && optname == IPX_TYPE))
goto out;
- sk->protinfo.af_ipx.type = opt;
+ ipx_sk(sk)->type = opt;
ret = 0;
out: return ret;
}
@@ -1884,7 +1885,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
if (!(level == SOL_IPX && optname == IPX_TYPE))
goto out;
- val = sk->protinfo.af_ipx.type;
+ val = ipx_sk(sk)->type;
ret = -EFAULT;
if (get_user(len, optlen))
@@ -1906,14 +1907,19 @@ out: return ret;
static int ipx_create(struct socket *sock, int protocol)
{
int ret = -ESOCKTNOSUPPORT;
+ struct ipx_opt *ipx = NULL;
struct sock *sk;
+ MOD_INC_USE_COUNT;
switch (sock->type) {
case SOCK_DGRAM:
- sk = sk_alloc(PF_IPX, GFP_KERNEL, 1);
+ sk = sk_alloc(PF_IPX, GFP_KERNEL, 1, NULL);
ret = -ENOMEM;
if (!sk)
- goto out;
+ goto decmod;
+ ipx = ipx_sk(sk) = kmalloc(sizeof(*ipx), GFP_KERNEL);
+ if (!ipx)
+ goto outsk;
sock->ops = &ipx_dgram_ops;
break;
@@ -1924,12 +1930,12 @@ static int ipx_create(struct socket *sock, int protocol)
*/
if (spx_family_ops) {
ret = spx_family_ops->create(sock, protocol);
- goto out;
+ goto decmod;
}
/* Fall through if SPX is not loaded */
case SOCK_STREAM: /* Allow higher levels to piggyback */
default:
- goto out;
+ goto decmod;
}
#ifdef IPX_REFCNT_DEBUG
atomic_inc(&ipx_sock_nr);
@@ -1937,12 +1943,12 @@ static int ipx_create(struct socket *sock, int protocol)
atomic_read(&ipx_sock_nr));
#endif
sock_init_data(sock, sk);
- sk->destruct = NULL;
- sk->no_check = 1; /* Checksum off by default */
-
- MOD_INC_USE_COUNT;
+ sk->no_check = 1; /* Checksum off by default */
ret = 0;
out: return ret;
+outsk: sk_free(sk);
+decmod: MOD_DEC_USE_COUNT;
+ goto out;
}
static int ipx_release(struct socket *sock)
@@ -1991,6 +1997,7 @@ static unsigned short ipx_first_free_socketnum(ipx_interface *intrfc)
static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sock *sk = sock->sk;
+ struct ipx_opt *ipxs = ipx_sk(sk);
ipx_interface *intrfc;
struct sockaddr_ipx *addr = (struct sockaddr_ipx *)uaddr;
int ret = -EINVAL;
@@ -2016,7 +2023,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
!capable(CAP_NET_ADMIN))
goto out_put;
- sk->protinfo.af_ipx.port = addr->sipx_port;
+ ipxs->port = addr->sipx_port;
#ifdef CONFIG_IPX_INTERN
if (intrfc == ipx_internal_net) {
@@ -2029,16 +2036,13 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
if (!memcmp(addr->sipx_node, ipx_broadcast_node, IPX_NODE_LEN))
goto out_put;
if (!memcmp(addr->sipx_node, ipx_this_node, IPX_NODE_LEN))
- memcpy(sk->protinfo.af_ipx.node, intrfc->if_node,
- IPX_NODE_LEN);
+ memcpy(ipxs->node, intrfc->if_node, IPX_NODE_LEN);
else
- memcpy(sk->protinfo.af_ipx.node, addr->sipx_node,
- IPX_NODE_LEN);
+ memcpy(ipxs->node, addr->sipx_node, IPX_NODE_LEN);
ret = -EADDRINUSE;
- if (ipxitf_find_internal_socket(intrfc,
- sk->protinfo.af_ipx.node,
- sk->protinfo.af_ipx.port)) {
+ if (ipxitf_find_internal_socket(intrfc, ipxs->node,
+ ipxs->port)) {
SOCK_DEBUG(sk,
"IPX: bind failed because port %X in use.\n",
ntohs((int)addr->sipx_port));
@@ -2050,8 +2054,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
* with the ipx routing ioctl()
*/
- memcpy(sk->protinfo.af_ipx.node, intrfc->if_node,
- IPX_NODE_LEN);
+ memcpy(ipxs->node, intrfc->if_node, IPX_NODE_LEN);
ret = -EADDRINUSE;
if (ipxitf_find_socket(intrfc, addr->sipx_port)) {
@@ -2090,6 +2093,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
int addr_len, int flags)
{
struct sock *sk = sock->sk;
+ struct ipx_opt *ipxs = ipx_sk(sk);
struct sockaddr_ipx *addr;
int ret = -EINVAL;
ipx_route *rt;
@@ -2102,7 +2106,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
addr = (struct sockaddr_ipx *)uaddr;
/* put the autobinding in */
- if (!sk->protinfo.af_ipx.port) {
+ if (!ipxs->port) {
struct sockaddr_ipx uaddr;
uaddr.sipx_port = 0;
@@ -2110,9 +2114,9 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
#ifdef CONFIG_IPX_INTERN
ret = -ENETDOWN;
- if (!sk->protinfo.af_ipx.intrfc)
+ if (!ipxs->intrfc)
goto out; /* Someone zonked the iface */
- memcpy(uaddr.sipx_node, sk->protinfo.af_ipx.intrfc->if_node,
+ memcpy(uaddr.sipx_node, ipxs->intrfc->if_node,
IPX_NODE_LEN);
#endif /* CONFIG_IPX_INTERN */
@@ -2129,11 +2133,10 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
if (!rt && !(!addr->sipx_network && ipx_primary_net))
goto out;
- sk->protinfo.af_ipx.dest_addr.net = addr->sipx_network;
- sk->protinfo.af_ipx.dest_addr.sock = addr->sipx_port;
- memcpy(sk->protinfo.af_ipx.dest_addr.node,
- addr->sipx_node, IPX_NODE_LEN);
- sk->protinfo.af_ipx.type = addr->sipx_type;
+ ipxs->dest_addr.net = addr->sipx_network;
+ ipxs->dest_addr.sock = addr->sipx_port;
+ memcpy(ipxs->dest_addr.node, addr->sipx_node, IPX_NODE_LEN);
+ ipxs->type = addr->sipx_type;
if (sock->type == SOCK_DGRAM) {
sock->state = SS_CONNECTED;
@@ -2153,6 +2156,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
ipx_address *addr;
struct sockaddr_ipx sipx;
struct sock *sk = sock->sk;
+ struct ipx_opt *ipxs = ipx_sk(sk);
int ret;
*uaddr_len = sizeof(struct sockaddr_ipx);
@@ -2162,20 +2166,17 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
if (sk->state != TCP_ESTABLISHED)
goto out;
- addr = &sk->protinfo.af_ipx.dest_addr;
+ addr = &ipxs->dest_addr;
sipx.sipx_network = addr->net;
sipx.sipx_port = addr->sock;
memcpy(sipx.sipx_node, addr->node, IPX_NODE_LEN);
} else {
- if (sk->protinfo.af_ipx.intrfc) {
- sipx.sipx_network =
- sk->protinfo.af_ipx.intrfc->if_netnum;
+ if (ipxs->intrfc) {
+ sipx.sipx_network = ipxs->intrfc->if_netnum;
#ifdef CONFIG_IPX_INTERN
- memcpy(sipx.sipx_node, sk->protinfo.af_ipx.node,
- IPX_NODE_LEN);
+ memcpy(sipx.sipx_node, ipxs->node, IPX_NODE_LEN);
#else
- memcpy(sipx.sipx_node,
- sk->protinfo.af_ipx.intrfc->if_node,
+ memcpy(sipx.sipx_node, ipxs->intrfc->if_node,
IPX_NODE_LEN);
#endif /* CONFIG_IPX_INTERN */
@@ -2184,11 +2185,11 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
memset(sipx.sipx_node, '\0', IPX_NODE_LEN);
}
- sipx.sipx_port = sk->protinfo.af_ipx.port;
+ sipx.sipx_port = ipxs->port;
}
sipx.sipx_family = AF_IPX;
- sipx.sipx_type = sk->protinfo.af_ipx.type;
+ sipx.sipx_type = ipxs->type;
memcpy(uaddr, &sipx, sizeof(sipx));
ret = 0;
@@ -2251,6 +2252,7 @@ static int ipx_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ struct ipx_opt *ipxs = ipx_sk(sk);
struct sockaddr_ipx *usipx = (struct sockaddr_ipx *)msg->msg_name;
struct sockaddr_ipx local_sipx;
int ret = -EINVAL;
@@ -2263,17 +2265,16 @@ static int ipx_sendmsg(struct socket *sock, struct msghdr *msg, int len,
goto out;
if (usipx) {
- if (!sk->protinfo.af_ipx.port) {
+ if (!ipxs->port) {
struct sockaddr_ipx uaddr;
uaddr.sipx_port = 0;
uaddr.sipx_network = 0;
#ifdef CONFIG_IPX_INTERN
ret = -ENETDOWN;
- if (!sk->protinfo.af_ipx.intrfc)
+ if (!ipxs->intrfc)
goto out; /* Someone zonked the iface */
- memcpy(uaddr.sipx_node,
- sk->protinfo.af_ipx.intrfc->if_node,
+ memcpy(uaddr.sipx_node, ipxs->intrfc->if_node,
IPX_NODE_LEN);
#endif
ret = ipx_bind(sock, (struct sockaddr *)&uaddr,
@@ -2293,11 +2294,10 @@ static int ipx_sendmsg(struct socket *sock, struct msghdr *msg, int len,
usipx = &local_sipx;
usipx->sipx_family = AF_IPX;
- usipx->sipx_type = sk->protinfo.af_ipx.type;
- usipx->sipx_port = sk->protinfo.af_ipx.dest_addr.sock;
- usipx->sipx_network = sk->protinfo.af_ipx.dest_addr.net;
- memcpy(usipx->sipx_node, sk->protinfo.af_ipx.dest_addr.node,
- IPX_NODE_LEN);
+ usipx->sipx_type = ipxs->type;
+ usipx->sipx_port = ipxs->dest_addr.sock;
+ usipx->sipx_network = ipxs->dest_addr.net;
+ memcpy(usipx->sipx_node, ipxs->dest_addr.node, IPX_NODE_LEN);
}
ret = ipxrtr_route_packet(sk, usipx, msg->msg_iov, len,
@@ -2312,13 +2312,14 @@ static int ipx_recvmsg(struct socket *sock, struct msghdr *msg, int size,
int flags, struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ struct ipx_opt *ipxs = ipx_sk(sk);
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)msg->msg_name;
struct ipxhdr *ipx = NULL;
struct sk_buff *skb;
int copied, err;
/* put the autobinding in */
- if (!sk->protinfo.af_ipx.port) {
+ if (!ipxs->port) {
struct sockaddr_ipx uaddr;
uaddr.sipx_port = 0;
@@ -2326,10 +2327,9 @@ static int ipx_recvmsg(struct socket *sock, struct msghdr *msg, int size,
#ifdef CONFIG_IPX_INTERN
err = -ENETDOWN;
- if (!sk->protinfo.af_ipx.intrfc)
+ if (!ipxs->intrfc)
goto out; /* Someone zonked the iface */
- memcpy(uaddr.sipx_node,
- sk->protinfo.af_ipx.intrfc->if_node, IPX_NODE_LEN);
+ memcpy(uaddr.sipx_node, ipxs->intrfc->if_node, IPX_NODE_LEN);
#endif /* CONFIG_IPX_INTERN */
err = ipx_bind(sock, (struct sockaddr *)&uaddr,
@@ -2423,7 +2423,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
*/
if (!capable(CAP_NET_ADMIN))
return -EPERM;
- return get_user(sk->protinfo.af_ipx.ipx_ncp_conn,
+ return get_user(ipx_sk(sk)->ipx_ncp_conn,
(const unsigned short *)(arg));
case SIOCGSTAMP: {
@@ -2536,10 +2536,14 @@ extern void destroy_8023_client(struct datalink_proto *);
static unsigned char ipx_8022_type = 0xE0;
static unsigned char ipx_snap_id[5] = { 0x0, 0x0, 0x0, 0x81, 0x37 };
-static char banner[] __initdata =
- KERN_INFO "NET4: Linux IPX 0.47 for NET4.0\n"
+static char ipx_banner[] __initdata =
+ KERN_INFO "NET4: Linux IPX 0.48 for NET4.0\n"
KERN_INFO "IPX Portions Copyright (c) 1995 Caldera, Inc.\n" \
KERN_INFO "IPX Portions Copyright (c) 2000, 2001 Conectiva, Inc.\n";
+static char ipx_llc_err_msg[] __initdata =
+ KERN_CRIT "IPX: Unable to register with 802.2\n";
+static char ipx_snap_err_msg[] __initdata =
+ KERN_CRIT "IPX: Unable to register with SNAP\n";
static int __init ipx_init(void)
{
@@ -2553,11 +2557,11 @@ static int __init ipx_init(void)
p8022_datalink = register_8022_client(ipx_8022_type, ipx_rcv);
if (!p8022_datalink)
- printk(KERN_CRIT "IPX: Unable to register with 802.2\n");
+ printk(ipx_llc_err_msg);
pSNAP_datalink = register_snap_client(ipx_snap_id, ipx_rcv);
if (!pSNAP_datalink)
- printk(KERN_CRIT "IPX: Unable to register with SNAP\n");
+ printk(ipx_snap_err_msg);
register_netdevice_notifier(&ipx_dev_notifier);
ipx_register_sysctl();
@@ -2566,7 +2570,7 @@ static int __init ipx_init(void)
proc_net_create("ipx_interface", 0, ipx_interface_get_info);
proc_net_create("ipx_route", 0, ipx_rt_get_info);
#endif
- printk(banner);
+ printk(ipx_banner);
return 0;
}
diff --git a/net/ipx/af_spx.c b/net/ipx/af_spx.c
index 3b5bf6660..e60f1a869 100644
--- a/net/ipx/af_spx.c
+++ b/net/ipx/af_spx.c
@@ -20,6 +20,8 @@
* Added spx_datagram_poll() so that select()
* works now on SPX sockets. Added updating
* of the alloc count to follow rmt_seq.
+ * Arnaldo C. Melo : Use a private slabcache for the old tp_pinfo
+ * struct sock member, use spx_sk and ipx_sk
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -34,6 +36,7 @@
#include <linux/module.h>
#include <net/ipx.h>
#include <net/spx.h>
+#include <net/tcp.h>
#include <net/sock.h>
#include <asm/byteorder.h>
#include <asm/uaccess.h>
@@ -60,7 +63,7 @@ extern void ipx_remove_socket(struct sock *sk);
static unsigned int spx_datagram_poll(struct file * file, struct socket *sock, poll_table *wait)
{
struct sock *sk = sock->sk;
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
unsigned int mask;
poll_wait(file, sk->sleep, wait);
@@ -95,7 +98,7 @@ static unsigned int spx_datagram_poll(struct file * file, struct socket *sock, p
/* Create the SPX specific data */
static int spx_sock_init(struct sock *sk)
{
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
pdata->state = SPX_CLOSED;
pdata->sequence = 0;
@@ -159,7 +162,7 @@ static int spx_create(struct socket *sock, int protocol)
void spx_close_socket(struct sock *sk)
{
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
pdata->state = SPX_CLOSED;
sk->state = TCP_CLOSE;
@@ -169,7 +172,7 @@ void spx_close_socket(struct sock *sk)
void spx_destroy_socket(struct sock *sk)
{
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
struct sk_buff *skb;
ipx_remove_socket(sk);
@@ -190,7 +193,7 @@ void spx_destroy_socket(struct sock *sk)
static int spx_release(struct socket *sock)
{
struct sock *sk = sock->sk;
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
if(sk == NULL)
return (0);
@@ -285,7 +288,7 @@ static int spx_accept(struct socket *sock, struct socket *newsock, int flags)
sk->ack_backlog--;
newsock->sk = newsk;
newsk->state = TCP_ESTABLISHED;
- newsk->protinfo.af_ipx.dest_addr = newsk->tp_pinfo.af_spx.dest_addr;
+ ipx_sk(newsk)->dest_addr = spx_sk(newsk)->dest_addr;
return (0);
}
@@ -295,7 +298,7 @@ static int spx_connect(struct socket *sock, struct sockaddr *uaddr,
int addr_len, int flags)
{
struct sock *sk = sock->sk;
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
struct sockaddr_ipx src;
struct sk_buff *skb;
int size, err;
@@ -313,7 +316,7 @@ static int spx_connect(struct socket *sock, struct sockaddr *uaddr,
if(err)
return (err);
- pdata->dest_addr = sk->protinfo.af_ipx.dest_addr;
+ pdata->dest_addr = ipx_sk(sk)->dest_addr;
pdata->state = SPX_CONNECTING;
sock->state = SS_CONNECTING;
sk->state = TCP_SYN_SENT;
@@ -423,7 +426,7 @@ static int spx_route_skb(struct spx_opt *pdata, struct sk_buff *skb, int type)
/* SPX packet transmit engine */
static int spx_transmit(struct sock *sk, struct sk_buff *skb, int type, int len)
{
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
struct ipxspxhdr *ipxh;
unsigned long flags;
int err;
@@ -520,7 +523,7 @@ static int spx_transmit(struct sock *sk, struct sk_buff *skb, int type, int len)
static void spx_watchdog(unsigned long data)
{
struct sock *sk = (struct sock*)data;
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
del_timer(&pdata->watchdog);
if(pdata->state == SPX_CLOSED)
@@ -541,7 +544,7 @@ static void spx_watchdog(unsigned long data)
static void spx_retransmit(unsigned long data)
{
struct sock *sk = (struct sock*)data;
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
struct sk_buff *skb;
unsigned long flags;
int err;
@@ -614,7 +617,7 @@ void spx_rcv(struct sock *sk, int bytes)
{
struct sk_buff *skb;
struct ipxspxhdr *ipxh;
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
skb = skb_dequeue(&sk->receive_queue);
if(skb == NULL)
@@ -736,7 +739,7 @@ static int spx_sendmsg(struct socket *sock, struct msghdr *msg, int len,
if(flags&~MSG_DONTWAIT)
return (-EINVAL);
- offset = ipx_if_offset(sk->tp_pinfo.af_spx.dest_addr.net);
+ offset = ipx_if_offset(spx_sk(sk)->dest_addr.net);
size = offset + sizeof(struct ipxspxhdr) + len;
cli();
@@ -770,7 +773,7 @@ static int spx_recvmsg(struct socket *sock, struct msghdr *msg, int size,
struct sk_buff *skb;
struct ipxspxhdr *ispxh;
struct sock *sk = sock->sk;
- struct spx_opt *pdata = &sk->tp_pinfo.af_spx;
+ struct spx_opt *pdata = spx_sk(sk);
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)msg->msg_name;
int copied, err;
@@ -906,8 +909,10 @@ static struct proto_ops SOCKOPS_WRAPPED(spx_ops) = {
SOCKOPS_WRAP(spx, PF_IPX);
static struct net_proto_family spx_family_ops = {
- family: PF_IPX,
- create: spx_create,
+ family: PF_IPX,
+ create: spx_create,
+ sk_size: sizeof(struct sock) + sizeof(struct ipx_opt) +
+ sizeof(struct spx_opt),
};
static char banner[] __initdata = KERN_INFO "NET4: Sequenced Packet eXchange (SPX) 0.02 for Linux NET4.0\n";
@@ -918,6 +923,16 @@ static int __init spx_proto_init(void)
connids = (__u16)jiffies; /* initalize random */
+ /* allocate our sock slab cache */
+
+ spx_family_ops.sk_cachep = kmem_cache_create("spx_sock",
+ spx_family_ops.sk_size,
+ 0, SLAB_HWCACHE_ALIGN,
+ 0, 0);
+ if (!spx_family_ops.sk_cachep)
+ printk(KERN_CRIT __FUNCTION__
+ ": Cannot create spx_sock SLAB cache!\n");
+
error = ipx_register_spx(&ipx_operations, &spx_family_ops);
if (error)
printk(KERN_ERR "SPX: unable to register with IPX.\n");
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index d4b7b21f5..657bb24ca 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -56,6 +56,7 @@
#include <asm/uaccess.h>
#include <net/sock.h>
+#include <net/tcp.h>
#include <net/irda/irda.h>
#include <net/irda/iriap.h>
@@ -728,7 +729,7 @@ static int irda_getname(struct socket *sock, struct sockaddr *uaddr,
{
struct sockaddr_irda saddr;
struct sock *sk = sock->sk;
- struct irda_sock *self = sk->protinfo.irda;
+ struct irda_sock *self = irda_sk(sk);
if (peer) {
if (sk->state != TCP_ESTABLISHED)
@@ -789,10 +790,9 @@ static int irda_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sock *sk = sock->sk;
struct sockaddr_irda *addr = (struct sockaddr_irda *) uaddr;
- struct irda_sock *self;
+ struct irda_sock *self = irda_sk(sk);
int err;
- self = sk->protinfo.irda;
ASSERT(self != NULL, return -1;);
IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
@@ -845,15 +845,14 @@ static int irda_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
*/
static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
{
- struct irda_sock *self, *new;
struct sock *sk = sock->sk;
+ struct irda_sock *new, *self = irda_sk(sk);
struct sock *newsk;
struct sk_buff *skb;
int err;
IRDA_DEBUG(2, __FUNCTION__ "()\n");
- self = sk->protinfo.irda;
ASSERT(self != NULL, return -1;);
err = irda_create(newsock, sk->protocol);
@@ -891,7 +890,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
newsk = newsock->sk;
newsk->state = TCP_ESTABLISHED;
- new = newsk->protinfo.irda;
+ new = irda_sk(newsk);
ASSERT(new != NULL, return -1;);
/* Now attach up the new socket */
@@ -953,10 +952,8 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr,
{
struct sock *sk = sock->sk;
struct sockaddr_irda *addr = (struct sockaddr_irda *) uaddr;
- struct irda_sock *self;
+ struct irda_sock *self = irda_sk(sk);
int err;
-
- self = sk->protinfo.irda;
IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
@@ -1078,11 +1075,11 @@ static int irda_create(struct socket *sock, int protocol)
}
/* Allocate networking socket */
- if ((sk = sk_alloc(PF_IRDA, GFP_ATOMIC, 1)) == NULL)
+ if ((sk = sk_alloc(PF_IRDA, GFP_ATOMIC, 1, NULL)) == NULL)
return -ENOMEM;
/* Allocate IrDA socket */
- self = kmalloc(sizeof(struct irda_sock), GFP_ATOMIC);
+ self = irda_sk(sk) = kmalloc(sizeof(struct irda_sock), GFP_ATOMIC);
if (self == NULL) {
sk_free(sk);
return -ENOMEM;
@@ -1098,7 +1095,6 @@ static int irda_create(struct socket *sock, int protocol)
sk->family = PF_IRDA;
sk->protocol = protocol;
/* Link networking socket and IrDA socket structs together */
- sk->protinfo.irda = self;
self->sk = sk;
switch (sock->type) {
@@ -1208,9 +1204,9 @@ static int irda_release(struct socket *sock)
sk->state_change(sk);
/* Destroy IrDA socket */
- irda_destroy_socket(sk->protinfo.irda);
+ irda_destroy_socket(irda_sk(sk));
/* Prevent sock_def_destruct() to create havoc */
- sk->protinfo.irda = NULL;
+ irda_sk(sk) = NULL;
sock_orphan(sk);
sock->sk = NULL;
@@ -1281,7 +1277,7 @@ static int irda_sendmsg(struct socket *sock, struct msghdr *msg, int len,
if (sk->state != TCP_ESTABLISHED)
return -ENOTCONN;
- self = sk->protinfo.irda;
+ self = irda_sk(sk);
ASSERT(self != NULL, return -1;);
/* Check if IrTTP is wants us to slow down */
@@ -1334,14 +1330,13 @@ static int irda_sendmsg(struct socket *sock, struct msghdr *msg, int len,
static int irda_recvmsg_dgram(struct socket *sock, struct msghdr *msg,
int size, int flags, struct scm_cookie *scm)
{
- struct irda_sock *self;
struct sock *sk = sock->sk;
+ struct irda_sock *self = irda_sk(sk);
struct sk_buff *skb;
int copied, err;
IRDA_DEBUG(4, __FUNCTION__ "()\n");
- self = sk->protinfo.irda;
ASSERT(self != NULL, return -1;);
skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
@@ -1404,15 +1399,14 @@ static void irda_data_wait(struct sock *sk)
static int irda_recvmsg_stream(struct socket *sock, struct msghdr *msg,
int size, int flags, struct scm_cookie *scm)
{
- struct irda_sock *self;
struct sock *sk = sock->sk;
+ struct irda_sock *self = irda_sk(sk);
int noblock = flags & MSG_DONTWAIT;
int copied = 0;
int target = 1;
IRDA_DEBUG(3, __FUNCTION__ "()\n");
- self = sk->protinfo.irda;
ASSERT(self != NULL, return -1;);
if (sock->flags & __SO_ACCEPTCON)
@@ -1531,7 +1525,7 @@ static int irda_sendmsg_dgram(struct socket *sock, struct msghdr *msg,
if (sk->state != TCP_ESTABLISHED)
return -ENOTCONN;
- self = sk->protinfo.irda;
+ self = irda_sk(sk);
ASSERT(self != NULL, return -1;);
/*
@@ -1594,7 +1588,7 @@ static int irda_sendmsg_ultra(struct socket *sock, struct msghdr *msg,
return -EPIPE;
}
- self = sk->protinfo.irda;
+ self = irda_sk(sk);
ASSERT(self != NULL, return -1;);
/*
@@ -1636,10 +1630,9 @@ static int irda_sendmsg_ultra(struct socket *sock, struct msghdr *msg,
*/
static int irda_shutdown(struct socket *sock, int how)
{
- struct irda_sock *self;
struct sock *sk = sock->sk;
+ struct irda_sock *self = irda_sk(sk);
- self = sk->protinfo.irda;
ASSERT(self != NULL, return -1;);
IRDA_DEBUG(1, __FUNCTION__ "(%p)\n", self);
@@ -1677,12 +1670,11 @@ static unsigned int irda_poll(struct file * file, struct socket *sock,
poll_table *wait)
{
struct sock *sk = sock->sk;
+ struct irda_sock *self = irda_sk(sk);
unsigned int mask;
- struct irda_sock *self;
IRDA_DEBUG(4, __FUNCTION__ "()\n");
- self = sk->protinfo.irda;
poll_wait(file, sk->sleep, wait);
mask = 0;
@@ -1808,13 +1800,12 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
char *optval, int optlen)
{
struct sock *sk = sock->sk;
- struct irda_sock *self;
+ struct irda_sock *self = irda_sk(sk);
struct irda_ias_set *ias_opt;
struct ias_object *ias_obj;
struct ias_attrib * ias_attr; /* Attribute in IAS object */
int opt;
- self = sk->protinfo.irda;
ASSERT(self != NULL, return -1;);
IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
@@ -2107,7 +2098,7 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
char *optval, int *optlen)
{
struct sock *sk = sock->sk;
- struct irda_sock *self;
+ struct irda_sock *self = irda_sk(sk);
struct irda_device_list list;
struct irda_device_info *discoveries;
struct irda_ias_set * ias_opt; /* IAS get/query params */
@@ -2119,8 +2110,6 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
int err;
int offset, total;
- self = sk->protinfo.irda;
-
IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
if (level != SOL_IRLMP)
@@ -2408,10 +2397,9 @@ bed:
return 0;
}
-static struct net_proto_family irda_family_ops =
-{
- PF_IRDA,
- irda_create
+static struct net_proto_family irda_family_ops = {
+ family: PF_IRDA,
+ create: irda_create,
};
static struct proto_ops SOCKOPS_WRAPPED(irda_stream_ops) = {
diff --git a/net/khttpd/accept.c b/net/khttpd/accept.c
index 97dd21709..7ca8d4574 100644
--- a/net/khttpd/accept.c
+++ b/net/khttpd/accept.c
@@ -42,6 +42,7 @@ Return value:
int AcceptConnections(const int CPUNR, struct socket *Socket)
{
+ struct tcp_opt *tp;
struct http_request *NewRequest;
struct socket *NewSock;
int count = 0;
@@ -57,13 +58,14 @@ int AcceptConnections(const int CPUNR, struct socket *Socket)
if (Socket==NULL) return 0;
+ tp = tcp_sk(Socket->sk);
/*
Quick test to see if there are connections on the queue.
This is cheaper than accept() itself because this saves us
the allocation of a new socket. (Which doesn't seem to be
used anyway)
*/
- if (Socket->sk->tp_pinfo.af_tcp.accept_queue==NULL)
+ if (tp->accept_queue==NULL)
{
return 0;
}
diff --git a/net/khttpd/datasending.c b/net/khttpd/datasending.c
index 91d57f907..d1663cc21 100644
--- a/net/khttpd/datasending.c
+++ b/net/khttpd/datasending.c
@@ -171,8 +171,10 @@ int DataSending(const int CPUNR)
if (CurrentRequest->sock->sk->state == TCP_ESTABLISHED ||
CurrentRequest->sock->sk->state == TCP_CLOSE_WAIT)
{
- CurrentRequest->sock->sk->tp_pinfo.af_tcp.nonagle = 0;
- tcp_push_pending_frames(CurrentRequest->sock->sk,&(CurrentRequest->sock->sk->tp_pinfo.af_tcp));
+ struct tcp_opt *tp =
+ tcp_sk(CurrentRequest->sock->sk);
+ tp->nonagle = 0;
+ tcp_push_pending_frames(CurrentRequest->sock->sk, tp);
}
release_sock(CurrentRequest->sock->sk);
diff --git a/net/khttpd/prototypes.h b/net/khttpd/prototypes.h
index c47830886..47e959e8e 100644
--- a/net/khttpd/prototypes.h
+++ b/net/khttpd/prototypes.h
@@ -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"
diff --git a/net/khttpd/waitheaders.c b/net/khttpd/waitheaders.c
index a4d39da4a..1e8831afa 100644
--- a/net/khttpd/waitheaders.c
+++ b/net/khttpd/waitheaders.c
@@ -255,7 +255,9 @@ static int DecodeHeader(const int CPUNR, struct http_request *Request)
}
else /* Normal Case */
{
- Request->sock->sk->tp_pinfo.af_tcp.nonagle = 2; /* this is TCP_CORK */
+ struct tcp_opt *tp = tcp_sk(Request->sock->sk);
+
+ tp->nonagle = 2; /* this is TCP_CORK */
if (Request->HTTPVER!=9) /* HTTP/0.9 doesn't allow a header */
SendHTTPHeader(Request);
}
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 6805ea3db..6700570c7 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -11,6 +11,8 @@
*
* Tue Jun 26 14:36:48 MEST 2001 Herbert "herp" Rosmanith
* added netlink_proto_exit
+ * Tue Jan 22 18:32:44 BRST 2002 Arnaldo C. de Melo <acme@conectiva.com.br>
+ * use nlk_sk, as sk->protinfo is on a diet 8)
*
*/
@@ -62,6 +64,8 @@ struct netlink_opt
void (*data_ready)(struct sock *sk, int bytes);
};
+#define nlk_sk(__sk) ((struct netlink_opt *)(__sk)->protinfo)
+
static struct sock *nl_table[MAX_LINKS];
static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait);
@@ -87,9 +91,9 @@ static void netlink_sock_destruct(struct sock *sk)
}
BUG_TRAP(atomic_read(&sk->rmem_alloc)==0);
BUG_TRAP(atomic_read(&sk->wmem_alloc)==0);
- BUG_TRAP(sk->protinfo.af_netlink->cb==NULL);
+ BUG_TRAP(!nlk_sk(sk)->cb);
- kfree(sk->protinfo.af_netlink);
+ kfree(nlk_sk(sk));
atomic_dec(&netlink_sock_nr);
#ifdef NETLINK_REFCNT_DEBUG
@@ -154,7 +158,7 @@ static __inline__ struct sock *netlink_lookup(int protocol, u32 pid)
read_lock(&nl_table_lock);
for (sk=nl_table[protocol]; sk; sk=sk->next) {
- if (sk->protinfo.af_netlink->pid == pid) {
+ if (nlk_sk(sk)->pid == pid) {
sock_hold(sk);
read_unlock(&nl_table_lock);
return sk;
@@ -174,13 +178,13 @@ static int netlink_insert(struct sock *sk, u32 pid)
netlink_table_grab();
for (osk=nl_table[sk->protocol]; osk; osk=osk->next) {
- if (osk->protinfo.af_netlink->pid == pid)
+ if (nlk_sk(osk)->pid == pid)
break;
}
if (osk == NULL) {
err = -EBUSY;
- if (sk->protinfo.af_netlink->pid == 0) {
- sk->protinfo.af_netlink->pid = pid;
+ if (nlk_sk(sk)->pid == 0) {
+ nlk_sk(sk)->pid = pid;
sk->next = nl_table[sk->protocol];
nl_table[sk->protocol] = sk;
sock_hold(sk);
@@ -209,6 +213,7 @@ static void netlink_remove(struct sock *sk)
static int netlink_create(struct socket *sock, int protocol)
{
struct sock *sk;
+ struct netlink_opt *nlk;
sock->state = SS_UNCONNECTED;
@@ -220,21 +225,21 @@ static int netlink_create(struct socket *sock, int protocol)
sock->ops = &netlink_ops;
- sk = sk_alloc(PF_NETLINK, GFP_KERNEL, 1);
+ sk = sk_alloc(PF_NETLINK, GFP_KERNEL, 1, NULL);
if (!sk)
return -ENOMEM;
sock_init_data(sock,sk);
- sk->protinfo.af_netlink = kmalloc(sizeof(struct netlink_opt), GFP_KERNEL);
- if (sk->protinfo.af_netlink == NULL) {
+ nlk = nlk_sk(sk) = kmalloc(sizeof(*nlk), GFP_KERNEL);
+ if (!nlk) {
sk_free(sk);
return -ENOMEM;
}
- memset(sk->protinfo.af_netlink, 0, sizeof(struct netlink_opt));
+ memset(nlk, 0, sizeof(*nlk));
- spin_lock_init(&sk->protinfo.af_netlink->cb_lock);
- init_waitqueue_head(&sk->protinfo.af_netlink->wait);
+ spin_lock_init(&nlk->cb_lock);
+ init_waitqueue_head(&nlk->wait);
sk->destruct = netlink_sock_destruct;
atomic_inc(&netlink_sock_nr);
@@ -245,27 +250,29 @@ static int netlink_create(struct socket *sock, int protocol)
static int netlink_release(struct socket *sock)
{
struct sock *sk = sock->sk;
+ struct netlink_opt *nlk;
if (!sk)
return 0;
netlink_remove(sk);
+ nlk = nlk_sk(sk);
- spin_lock(&sk->protinfo.af_netlink->cb_lock);
- if (sk->protinfo.af_netlink->cb) {
- sk->protinfo.af_netlink->cb->done(sk->protinfo.af_netlink->cb);
- netlink_destroy_callback(sk->protinfo.af_netlink->cb);
- sk->protinfo.af_netlink->cb = NULL;
+ spin_lock(&nlk->cb_lock);
+ if (nlk->cb) {
+ nlk->cb->done(nlk->cb);
+ netlink_destroy_callback(nlk->cb);
+ nlk->cb = NULL;
__sock_put(sk);
}
- spin_unlock(&sk->protinfo.af_netlink->cb_lock);
+ spin_unlock(&nlk->cb_lock);
/* OK. Socket is unlinked, and, therefore,
no new packets will arrive */
sock_orphan(sk);
sock->sk = NULL;
- wake_up_interruptible_all(&sk->protinfo.af_netlink->wait);
+ wake_up_interruptible_all(&nlk->wait);
skb_queue_purge(&sk->write_queue);
@@ -283,7 +290,7 @@ static int netlink_autobind(struct socket *sock)
retry:
netlink_table_grab();
for (osk=nl_table[sk->protocol]; osk; osk=osk->next) {
- if (osk->protinfo.af_netlink->pid == pid) {
+ if (nlk_sk(osk)->pid == pid) {
/* Bind collision, search negative pid values. */
if (pid > 0)
pid = -4096;
@@ -297,15 +304,16 @@ retry:
err = netlink_insert(sk, pid);
if (err == -EADDRINUSE)
goto retry;
- sk->protinfo.af_netlink->groups = 0;
+ nlk_sk(sk)->groups = 0;
return 0;
}
static int netlink_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
{
struct sock *sk = sock->sk;
+ struct netlink_opt *nlk = nlk_sk(sk);
+ struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
int err;
- struct sockaddr_nl *nladdr=(struct sockaddr_nl *)addr;
if (nladdr->nl_family != AF_NETLINK)
return -EINVAL;
@@ -314,23 +322,23 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, int addr_len
if (nladdr->nl_groups && !capable(CAP_NET_ADMIN))
return -EPERM;
- if (sk->protinfo.af_netlink->pid) {
- if (nladdr->nl_pid != sk->protinfo.af_netlink->pid)
+ if (nlk->pid) {
+ if (nladdr->nl_pid != nlk->pid)
return -EINVAL;
- sk->protinfo.af_netlink->groups = nladdr->nl_groups;
+ nlk->groups = nladdr->nl_groups;
return 0;
}
if (nladdr->nl_pid == 0) {
err = netlink_autobind(sock);
if (err == 0)
- sk->protinfo.af_netlink->groups = nladdr->nl_groups;
+ nlk->groups = nladdr->nl_groups;
return err;
}
err = netlink_insert(sk, nladdr->nl_pid);
if (err == 0)
- sk->protinfo.af_netlink->groups = nladdr->nl_groups;
+ nlk->groups = nladdr->nl_groups;
return err;
}
@@ -339,11 +347,12 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
{
int err = 0;
struct sock *sk = sock->sk;
+ struct netlink_opt *nlk = nlk_sk(sk);
struct sockaddr_nl *nladdr=(struct sockaddr_nl*)addr;
if (addr->sa_family == AF_UNSPEC) {
- sk->protinfo.af_netlink->dst_pid = 0;
- sk->protinfo.af_netlink->dst_groups = 0;
+ nlk->dst_pid = 0;
+ nlk->dst_groups = 0;
return 0;
}
if (addr->sa_family != AF_NETLINK)
@@ -353,12 +362,12 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
if (nladdr->nl_groups && !capable(CAP_NET_ADMIN))
return -EPERM;
- if (!sk->protinfo.af_netlink->pid)
+ if (!nlk->pid)
err = netlink_autobind(sock);
if (err == 0) {
- sk->protinfo.af_netlink->dst_pid = nladdr->nl_pid;
- sk->protinfo.af_netlink->dst_groups = nladdr->nl_groups;
+ nlk->dst_pid = nladdr->nl_pid;
+ nlk->dst_groups = nladdr->nl_groups;
}
return 0;
@@ -367,24 +376,25 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
static int netlink_getname(struct socket *sock, struct sockaddr *addr, int *addr_len, int peer)
{
struct sock *sk = sock->sk;
+ struct netlink_opt *nlk = nlk_sk(sk);
struct sockaddr_nl *nladdr=(struct sockaddr_nl *)addr;
nladdr->nl_family = AF_NETLINK;
*addr_len = sizeof(*nladdr);
if (peer) {
- nladdr->nl_pid = sk->protinfo.af_netlink->dst_pid;
- nladdr->nl_groups = sk->protinfo.af_netlink->dst_groups;
+ nladdr->nl_pid = nlk->dst_pid;
+ nladdr->nl_groups = nlk->dst_groups;
} else {
- nladdr->nl_pid = sk->protinfo.af_netlink->pid;
- nladdr->nl_groups = sk->protinfo.af_netlink->groups;
+ nladdr->nl_pid = nlk->pid;
+ nladdr->nl_groups = nlk->groups;
}
return 0;
}
static void netlink_overrun(struct sock *sk)
{
- if (!test_and_set_bit(0, &sk->protinfo.af_netlink->state)) {
+ if (!test_and_set_bit(0, &nlk_sk(sk)->state)) {
sk->err = ENOBUFS;
sk->error_report(sk);
}
@@ -393,6 +403,7 @@ static void netlink_overrun(struct sock *sk)
int netlink_unicast(struct sock *ssk, struct sk_buff *skb, u32 pid, int nonblock)
{
struct sock *sk;
+ struct netlink_opt *nlk;
int len = skb->len;
int protocol = ssk->protocol;
long timeo;
@@ -404,20 +415,21 @@ retry:
sk = netlink_lookup(protocol, pid);
if (sk == NULL)
goto no_dst;
+ nlk = nlk_sk(sk);
#ifdef NL_EMULATE_DEV
- if (sk->protinfo.af_netlink->handler) {
+ if (nlk->handler) {
skb_orphan(skb);
- len = sk->protinfo.af_netlink->handler(protocol, skb);
+ len = nlk->handler(protocol, skb);
sock_put(sk);
return len;
}
#endif
if (atomic_read(&sk->rmem_alloc) > sk->rcvbuf ||
- test_bit(0, &sk->protinfo.af_netlink->state)) {
+ test_bit(0, &nlk->state)) {
if (!timeo) {
- if (ssk->protinfo.af_netlink->pid == 0)
+ if (!nlk->pid)
netlink_overrun(sk);
sock_put(sk);
kfree_skb(skb);
@@ -425,15 +437,15 @@ retry:
}
__set_current_state(TASK_INTERRUPTIBLE);
- add_wait_queue(&sk->protinfo.af_netlink->wait, &wait);
+ add_wait_queue(&nlk->wait, &wait);
if ((atomic_read(&sk->rmem_alloc) > sk->rcvbuf ||
- test_bit(0, &sk->protinfo.af_netlink->state)) &&
+ test_bit(0, &nlk->state)) &&
!sk->dead)
timeo = schedule_timeout(timeo);
__set_current_state(TASK_RUNNING);
- remove_wait_queue(&sk->protinfo.af_netlink->wait, &wait);
+ remove_wait_queue(&nlk->wait, &wait);
sock_put(sk);
if (signal_pending(current)) {
@@ -457,15 +469,16 @@ no_dst:
static __inline__ int netlink_broadcast_deliver(struct sock *sk, struct sk_buff *skb)
{
+ struct netlink_opt *nlk = nlk_sk(sk);
#ifdef NL_EMULATE_DEV
- if (sk->protinfo.af_netlink->handler) {
+ if (nlk->handler) {
skb_orphan(skb);
- sk->protinfo.af_netlink->handler(sk->protocol, skb);
+ nlk->handler(sk->protocol, skb);
return 0;
} else
#endif
if (atomic_read(&sk->rmem_alloc) <= sk->rcvbuf &&
- !test_bit(0, &sk->protinfo.af_netlink->state)) {
+ !test_bit(0, &nlk->state)) {
skb_orphan(skb);
skb_set_owner_r(skb, sk);
skb_queue_tail(&sk->receive_queue, skb);
@@ -488,11 +501,12 @@ void netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
netlink_lock_table();
for (sk = nl_table[protocol]; sk; sk = sk->next) {
+ struct netlink_opt *nlk = nlk_sk(sk);
+
if (ssk == sk)
continue;
- if (sk->protinfo.af_netlink->pid == pid ||
- !(sk->protinfo.af_netlink->groups&group))
+ if (nlk->pid == pid || !(nlk->groups & group))
continue;
if (failure) {
@@ -534,11 +548,11 @@ void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
read_lock(&nl_table_lock);
for (sk = nl_table[protocol]; sk; sk = sk->next) {
+ struct netlink_opt *nlk = nlk_sk(sk);
if (ssk == sk)
continue;
- if (sk->protinfo.af_netlink->pid == pid ||
- !(sk->protinfo.af_netlink->groups&group))
+ if (nlk->pid == pid || !(nlk->groups & group))
continue;
sk->err = code;
@@ -551,6 +565,7 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ struct netlink_opt *nlk = nlk_sk(sk);
struct sockaddr_nl *addr=msg->msg_name;
u32 dst_pid;
u32 dst_groups;
@@ -568,11 +583,11 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, int len,
if (dst_groups && !capable(CAP_NET_ADMIN))
return -EPERM;
} else {
- dst_pid = sk->protinfo.af_netlink->dst_pid;
- dst_groups = sk->protinfo.af_netlink->dst_groups;
+ dst_pid = nlk->dst_pid;
+ dst_groups = nlk->dst_groups;
}
- if (!sk->protinfo.af_netlink->pid) {
+ if (!nlk->pid) {
err = netlink_autobind(sock);
if (err)
goto out;
@@ -586,8 +601,8 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, int len,
if (skb==NULL)
goto out;
- NETLINK_CB(skb).pid = sk->protinfo.af_netlink->pid;
- NETLINK_CB(skb).groups = sk->protinfo.af_netlink->groups;
+ NETLINK_CB(skb).pid = nlk->pid;
+ NETLINK_CB(skb).groups = nlk->groups;
NETLINK_CB(skb).dst_pid = dst_pid;
NETLINK_CB(skb).dst_groups = dst_groups;
memcpy(NETLINK_CREDS(skb), &scm->creds, sizeof(struct ucred));
@@ -619,6 +634,7 @@ static int netlink_recvmsg(struct socket *sock, struct msghdr *msg, int len,
int flags, struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ struct netlink_opt *nlk = nlk_sk(sk);
int noblock = flags&MSG_DONTWAIT;
int copied;
struct sk_buff *skb;
@@ -655,30 +671,31 @@ static int netlink_recvmsg(struct socket *sock, struct msghdr *msg, int len,
scm->creds = *NETLINK_CREDS(skb);
skb_free_datagram(sk, skb);
- if (sk->protinfo.af_netlink->cb
- && atomic_read(&sk->rmem_alloc) <= sk->rcvbuf/2)
+ if (nlk->cb && atomic_read(&sk->rmem_alloc) <= sk->rcvbuf / 2)
netlink_dump(sk);
out:
if (skb_queue_len(&sk->receive_queue) <= sk->rcvbuf/2) {
if (skb_queue_len(&sk->receive_queue) == 0)
- clear_bit(0, &sk->protinfo.af_netlink->state);
- if (!test_bit(0, &sk->protinfo.af_netlink->state))
- wake_up_interruptible(&sk->protinfo.af_netlink->wait);
+ clear_bit(0, &nlk->state);
+ if (!test_bit(0, &nlk->state))
+ wake_up_interruptible(&nlk->wait);
}
return err ? : copied;
}
void netlink_data_ready(struct sock *sk, int len)
{
- if (sk->protinfo.af_netlink->data_ready)
- sk->protinfo.af_netlink->data_ready(sk, len);
+ struct netlink_opt *nlk = nlk_sk(sk);
+
+ if (nlk->data_ready)
+ nlk->data_ready(sk, len);
if (skb_queue_len(&sk->receive_queue) <= sk->rcvbuf/2) {
if (skb_queue_len(&sk->receive_queue) == 0)
- clear_bit(0, &sk->protinfo.af_netlink->state);
- if (!test_bit(0, &sk->protinfo.af_netlink->state))
- wake_up_interruptible(&sk->protinfo.af_netlink->wait);
+ clear_bit(0, &nlk->state);
+ if (!test_bit(0, &nlk->state))
+ wake_up_interruptible(&nlk->wait);
}
}
@@ -709,7 +726,7 @@ netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len))
sk = sock->sk;
sk->data_ready = netlink_data_ready;
if (input)
- sk->protinfo.af_netlink->data_ready = input;
+ nlk_sk(sk)->data_ready = input;
netlink_insert(sk, 0);
return sk;
@@ -729,6 +746,7 @@ static void netlink_destroy_callback(struct netlink_callback *cb)
static int netlink_dump(struct sock *sk)
{
+ struct netlink_opt *nlk = nlk_sk(sk);
struct netlink_callback *cb;
struct sk_buff *skb;
struct nlmsghdr *nlh;
@@ -738,11 +756,11 @@ static int netlink_dump(struct sock *sk)
if (!skb)
return -ENOBUFS;
- spin_lock(&sk->protinfo.af_netlink->cb_lock);
+ spin_lock(&nlk->cb_lock);
- cb = sk->protinfo.af_netlink->cb;
+ cb = nlk->cb;
if (cb == NULL) {
- spin_unlock(&sk->protinfo.af_netlink->cb_lock);
+ spin_unlock(&nlk->cb_lock);
kfree_skb(skb);
return -EINVAL;
}
@@ -750,7 +768,7 @@ static int netlink_dump(struct sock *sk)
len = cb->dump(skb, cb);
if (len > 0) {
- spin_unlock(&sk->protinfo.af_netlink->cb_lock);
+ spin_unlock(&nlk->cb_lock);
skb_queue_tail(&sk->receive_queue, skb);
sk->data_ready(sk, len);
return 0;
@@ -763,8 +781,8 @@ static int netlink_dump(struct sock *sk)
sk->data_ready(sk, skb->len);
cb->done(cb);
- sk->protinfo.af_netlink->cb = NULL;
- spin_unlock(&sk->protinfo.af_netlink->cb_lock);
+ nlk->cb = NULL;
+ spin_unlock(&nlk->cb_lock);
netlink_destroy_callback(cb);
sock_put(sk);
@@ -778,6 +796,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
{
struct netlink_callback *cb;
struct sock *sk;
+ struct netlink_opt *nlk;
cb = kmalloc(sizeof(*cb), GFP_KERNEL);
if (cb == NULL)
@@ -795,16 +814,17 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
netlink_destroy_callback(cb);
return -ECONNREFUSED;
}
+ nlk = nlk_sk(sk);
/* A dump is in progress... */
- spin_lock(&sk->protinfo.af_netlink->cb_lock);
- if (sk->protinfo.af_netlink->cb) {
- spin_unlock(&sk->protinfo.af_netlink->cb_lock);
+ spin_lock(&nlk->cb_lock);
+ if (nlk->cb) {
+ spin_unlock(&nlk->cb_lock);
netlink_destroy_callback(cb);
sock_put(sk);
return -EBUSY;
}
- sk->protinfo.af_netlink->cb = cb;
- spin_unlock(&sk->protinfo.af_netlink->cb_lock);
+ nlk->cb = cb;
+ spin_unlock(&nlk->cb_lock);
netlink_dump(sk);
return 0;
@@ -848,7 +868,7 @@ int netlink_attach(int unit, int (*function)(int, struct sk_buff *skb))
struct sock *sk = netlink_kernel_create(unit, NULL);
if (sk == NULL)
return -ENOBUFS;
- sk->protinfo.af_netlink->handler = function;
+ nlk_sk(sk)->handler = function;
write_lock_bh(&nl_emu_lock);
netlink_kernel[unit] = sk->socket;
write_unlock_bh(&nl_emu_lock);
@@ -907,14 +927,16 @@ static int netlink_read_proc(char *buffer, char **start, off_t offset,
for (i=0; i<MAX_LINKS; i++) {
read_lock(&nl_table_lock);
for (s = nl_table[i]; s; s = s->next) {
+ struct netlink_opt *nlk = nlk_sk(s);
+
len+=sprintf(buffer+len,"%p %-3d %-6d %08x %-8d %-8d %p %d",
s,
s->protocol,
- s->protinfo.af_netlink->pid,
- s->protinfo.af_netlink->groups,
+ nlk->pid,
+ nlk->groups,
atomic_read(&s->rmem_alloc),
atomic_read(&s->wmem_alloc),
- s->protinfo.af_netlink->cb,
+ nlk->cb,
atomic_read(&s->refcnt)
);
@@ -967,8 +989,8 @@ struct proto_ops netlink_ops = {
};
struct net_proto_family netlink_family_ops = {
- PF_NETLINK,
- netlink_create
+ family: PF_NETLINK,
+ create: netlink_create,
};
static int __init netlink_proto_init(void)
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index f37bb2433..bcfbf5f4b 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -62,6 +62,7 @@
#include <net/netrom.h>
#include <linux/proc_fs.h>
#include <net/ip.h>
+#include <net/tcp.h>
#include <net/arp.h>
#include <linux/init.h>
@@ -97,22 +98,23 @@ static struct sock *nr_alloc_sock(void)
struct sock *sk;
nr_cb *nr;
- if ((sk = sk_alloc(PF_NETROM, GFP_ATOMIC, 1)) == NULL)
- return NULL;
-
- if ((nr = kmalloc(sizeof(*nr), GFP_ATOMIC)) == NULL) {
- sk_free(sk);
- return NULL;
- }
-
MOD_INC_USE_COUNT;
+ if ((sk = sk_alloc(PF_NETROM, GFP_ATOMIC, 1, NULL)) == NULL)
+ goto decmod;
+
+ nr = nr_sk(sk) = kmalloc(sizeof(*nr), GFP_ATOMIC);
+ if (!nr)
+ goto frees;
memset(nr, 0x00, sizeof(*nr));
- sk->protinfo.nr = nr;
nr->sk = sk;
- return sk;
+out: return sk;
+frees: sk_free(sk);
+ sk = NULL;
+decmod: MOD_DEC_USE_COUNT;
+ goto out;
}
/*
@@ -152,7 +154,7 @@ static void nr_kill_by_device(struct net_device *dev)
struct sock *s;
for (s = nr_list; s != NULL; s = s->next) {
- if (s->protinfo.nr->device == dev)
+ if (nr_sk(s)->device == dev)
nr_disconnect(s, ENETUNREACH);
}
}
@@ -201,7 +203,8 @@ static struct sock *nr_find_listener(ax25_address *addr)
cli();
for (s = nr_list; s != NULL; s = s->next) {
- if (ax25cmp(&s->protinfo.nr->source_addr, addr) == 0 && s->state == TCP_LISTEN) {
+ if (!ax25cmp(&nr_sk(s)->source_addr, addr) &&
+ s->state == TCP_LISTEN) {
restore_flags(flags);
return s;
}
@@ -223,7 +226,9 @@ static struct sock *nr_find_socket(unsigned char index, unsigned char id)
cli();
for (s = nr_list; s != NULL; s = s->next) {
- if (s->protinfo.nr->my_index == index && s->protinfo.nr->my_id == id) {
+ nr_cb *nr = nr_sk(s);
+
+ if (nr->my_index == index && nr->my_id == id) {
restore_flags(flags);
return s;
}
@@ -246,7 +251,10 @@ static struct sock *nr_find_peer(unsigned char index, unsigned char id, ax25_add
cli();
for (s = nr_list; s != NULL; s = s->next) {
- if (s->protinfo.nr->your_index == index && s->protinfo.nr->your_id == id && ax25cmp(&s->protinfo.nr->dest_addr, dest) == 0) {
+ nr_cb *nr = nr_sk(s);
+
+ if (nr->your_index == index && nr->your_id == id &&
+ !ax25cmp(&nr->dest_addr, dest)) {
restore_flags(flags);
return s;
}
@@ -318,7 +326,7 @@ void nr_destroy_socket(struct sock *sk) /* Not static as it's used by the timer
if (skb->sk != sk) { /* A pending connection */
skb->sk->dead = 1; /* Queue the unaccepted socket for death */
nr_start_heartbeat(skb->sk);
- skb->sk->protinfo.nr->state = NR_STATE_0;
+ nr_sk(skb->sk)->state = NR_STATE_0;
}
kfree_skb(skb);
@@ -347,6 +355,7 @@ static int nr_setsockopt(struct socket *sock, int level, int optname,
char *optval, int optlen)
{
struct sock *sk = sock->sk;
+ nr_cb *nr = nr_sk(sk);
int opt;
if (level != SOL_NETROM)
@@ -362,31 +371,31 @@ static int nr_setsockopt(struct socket *sock, int level, int optname,
case NETROM_T1:
if (opt < 1)
return -EINVAL;
- sk->protinfo.nr->t1 = opt * HZ;
+ nr->t1 = opt * HZ;
return 0;
case NETROM_T2:
if (opt < 1)
return -EINVAL;
- sk->protinfo.nr->t2 = opt * HZ;
+ nr->t2 = opt * HZ;
return 0;
case NETROM_N2:
if (opt < 1 || opt > 31)
return -EINVAL;
- sk->protinfo.nr->n2 = opt;
+ nr->n2 = opt;
return 0;
case NETROM_T4:
if (opt < 1)
return -EINVAL;
- sk->protinfo.nr->t4 = opt * HZ;
+ nr->t4 = opt * HZ;
return 0;
case NETROM_IDLE:
if (opt < 0)
return -EINVAL;
- sk->protinfo.nr->idle = opt * 60 * HZ;
+ nr->idle = opt * 60 * HZ;
return 0;
default:
@@ -398,6 +407,7 @@ static int nr_getsockopt(struct socket *sock, int level, int optname,
char *optval, int *optlen)
{
struct sock *sk = sock->sk;
+ nr_cb *nr = nr_sk(sk);
int val = 0;
int len;
@@ -412,23 +422,23 @@ static int nr_getsockopt(struct socket *sock, int level, int optname,
switch (optname) {
case NETROM_T1:
- val = sk->protinfo.nr->t1 / HZ;
+ val = nr->t1 / HZ;
break;
case NETROM_T2:
- val = sk->protinfo.nr->t2 / HZ;
+ val = nr->t2 / HZ;
break;
case NETROM_N2:
- val = sk->protinfo.nr->n2;
+ val = nr->n2;
break;
case NETROM_T4:
- val = sk->protinfo.nr->t4 / HZ;
+ val = nr->t4 / HZ;
break;
case NETROM_IDLE:
- val = sk->protinfo.nr->idle / (60 * HZ);
+ val = nr->idle / (60 * HZ);
break;
default:
@@ -448,7 +458,7 @@ static int nr_listen(struct socket *sock, int backlog)
struct sock *sk = sock->sk;
if (sk->state != TCP_LISTEN) {
- memset(&sk->protinfo.nr->user_addr, '\0', AX25_ADDR_LEN);
+ memset(&nr_sk(sk)->user_addr, 0, AX25_ADDR_LEN);
sk->max_ack_backlog = backlog;
sk->state = TCP_LISTEN;
return 0;
@@ -468,7 +478,7 @@ static int nr_create(struct socket *sock, int protocol)
if ((sk = nr_alloc_sock()) == NULL)
return -ENOMEM;
- nr = sk->protinfo.nr;
+ nr = nr_sk(sk);
sock_init_data(sock, sk);
@@ -500,7 +510,7 @@ static int nr_create(struct socket *sock, int protocol)
static struct sock *nr_make_new(struct sock *osk)
{
struct sock *sk;
- nr_cb *nr;
+ nr_cb *nr, *onr;
if (osk->type != SOCK_SEQPACKET)
return NULL;
@@ -508,7 +518,7 @@ static struct sock *nr_make_new(struct sock *osk)
if ((sk = nr_alloc_sock()) == NULL)
return NULL;
- nr = sk->protinfo.nr;
+ nr = nr_sk(sk);
sock_init_data(NULL, sk);
@@ -532,15 +542,17 @@ static struct sock *nr_make_new(struct sock *osk)
init_timer(&nr->t4timer);
init_timer(&nr->idletimer);
- nr->t1 = osk->protinfo.nr->t1;
- nr->t2 = osk->protinfo.nr->t2;
- nr->n2 = osk->protinfo.nr->n2;
- nr->t4 = osk->protinfo.nr->t4;
- nr->idle = osk->protinfo.nr->idle;
- nr->window = osk->protinfo.nr->window;
+ onr = nr_sk(osk);
+
+ nr->t1 = onr->t1;
+ nr->t2 = onr->t2;
+ nr->n2 = onr->n2;
+ nr->t4 = onr->t4;
+ nr->idle = onr->idle;
+ nr->window = onr->window;
- nr->device = osk->protinfo.nr->device;
- nr->bpqext = osk->protinfo.nr->bpqext;
+ nr->device = onr->device;
+ nr->bpqext = onr->bpqext;
return sk;
}
@@ -548,10 +560,13 @@ static struct sock *nr_make_new(struct sock *osk)
static int nr_release(struct socket *sock)
{
struct sock *sk = sock->sk;
+ nr_cb *nr;
if (sk == NULL) return 0;
- switch (sk->protinfo.nr->state) {
+ nr = nr_sk(sk);
+
+ switch (nr->state) {
case NR_STATE_0:
case NR_STATE_1:
@@ -562,19 +577,19 @@ static int nr_release(struct socket *sock)
case NR_STATE_3:
nr_clear_queues(sk);
- sk->protinfo.nr->n2count = 0;
+ nr->n2count = 0;
nr_write_internal(sk, NR_DISCREQ);
nr_start_t1timer(sk);
nr_stop_t2timer(sk);
nr_stop_t4timer(sk);
nr_stop_idletimer(sk);
- sk->protinfo.nr->state = NR_STATE_2;
- sk->state = TCP_CLOSE;
- sk->shutdown |= SEND_SHUTDOWN;
+ nr->state = NR_STATE_2;
+ sk->state = TCP_CLOSE;
+ sk->shutdown |= SEND_SHUTDOWN;
sk->state_change(sk);
- sk->dead = 1;
- sk->destroy = 1;
- sk->socket = NULL;
+ sk->dead = 1;
+ sk->destroy = 1;
+ sk->socket = NULL;
break;
default:
@@ -590,6 +605,7 @@ static int nr_release(struct socket *sock)
static int nr_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sock *sk = sock->sk;
+ nr_cb *nr = nr_sk(sk);
struct full_sockaddr_ax25 *addr = (struct full_sockaddr_ax25 *)uaddr;
struct net_device *dev;
ax25_address *user, *source;
@@ -618,8 +634,8 @@ full_sockaddr_ax25))
if (addr->fsa_ax25.sax25_ndigis == 1) {
if (!capable(CAP_NET_BIND_SERVICE))
return -EACCES;
- sk->protinfo.nr->user_addr = addr->fsa_digipeater[0];
- sk->protinfo.nr->source_addr = addr->fsa_ax25.sax25_call;
+ nr->user_addr = addr->fsa_digipeater[0];
+ nr->source_addr = addr->fsa_ax25.sax25_call;
} else {
source = &addr->fsa_ax25.sax25_call;
@@ -629,11 +645,11 @@ full_sockaddr_ax25))
user = source;
}
- sk->protinfo.nr->user_addr = *user;
- sk->protinfo.nr->source_addr = *source;
+ nr->user_addr = *user;
+ nr->source_addr = *source;
}
- sk->protinfo.nr->device = dev;
+ nr->device = dev;
nr_insert_socket(sk);
sk->zapped = 0;
@@ -645,6 +661,7 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
int addr_len, int flags)
{
struct sock *sk = sock->sk;
+ nr_cb *nr = nr_sk(sk);
struct sockaddr_ax25 *addr = (struct sockaddr_ax25 *)uaddr;
ax25_address *user, *source = NULL;
struct net_device *dev;
@@ -685,19 +702,19 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
user = source;
}
- sk->protinfo.nr->user_addr = *user;
- sk->protinfo.nr->source_addr = *source;
- sk->protinfo.nr->device = dev;
+ nr->user_addr = *user;
+ nr->source_addr = *source;
+ nr->device = dev;
nr_insert_socket(sk); /* Finish the bind */
}
- sk->protinfo.nr->dest_addr = addr->sax25_call;
+ nr->dest_addr = addr->sax25_call;
circuit = nr_find_next_circuit();
- sk->protinfo.nr->my_index = circuit / 256;
- sk->protinfo.nr->my_id = circuit % 256;
+ nr->my_index = circuit / 256;
+ nr->my_id = circuit % 256;
circuit++;
@@ -707,7 +724,7 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
nr_establish_data_link(sk);
- sk->protinfo.nr->state = NR_STATE_1;
+ nr->state = NR_STATE_1;
nr_start_heartbeat(sk);
@@ -794,19 +811,20 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
{
struct full_sockaddr_ax25 *sax = (struct full_sockaddr_ax25 *)uaddr;
struct sock *sk = sock->sk;
+ nr_cb *nr = nr_sk(sk);
if (peer != 0) {
if (sk->state != TCP_ESTABLISHED)
return -ENOTCONN;
sax->fsa_ax25.sax25_family = AF_NETROM;
sax->fsa_ax25.sax25_ndigis = 1;
- sax->fsa_ax25.sax25_call = sk->protinfo.nr->user_addr;
- sax->fsa_digipeater[0] = sk->protinfo.nr->dest_addr;
+ sax->fsa_ax25.sax25_call = nr->user_addr;
+ sax->fsa_digipeater[0] = nr->dest_addr;
*uaddr_len = sizeof(struct full_sockaddr_ax25);
} else {
sax->fsa_ax25.sax25_family = AF_NETROM;
sax->fsa_ax25.sax25_ndigis = 0;
- sax->fsa_ax25.sax25_call = sk->protinfo.nr->source_addr;
+ sax->fsa_ax25.sax25_call = nr->source_addr;
*uaddr_len = sizeof(struct sockaddr_ax25);
}
@@ -817,6 +835,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
{
struct sock *sk;
struct sock *make;
+ nr_cb *nr_make;
ax25_address *src, *dest, *user;
unsigned short circuit_index, circuit_id;
unsigned short peer_circuit_index, peer_circuit_id;
@@ -874,9 +893,9 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
skb->h.raw = skb->data;
if (frametype == NR_CONNACK && skb->len == 22)
- sk->protinfo.nr->bpqext = 1;
+ nr_sk(sk)->bpqext = 1;
else
- sk->protinfo.nr->bpqext = 0;
+ nr_sk(sk)->bpqext = 0;
return nr_process_rx_frame(sk, skb);
}
@@ -916,42 +935,43 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
make->state = TCP_ESTABLISHED;
/* Fill in his circuit details */
- make->protinfo.nr->source_addr = *dest;
- make->protinfo.nr->dest_addr = *src;
- make->protinfo.nr->user_addr = *user;
+ nr_make = nr_sk(make);
+ nr_make->source_addr = *dest;
+ nr_make->dest_addr = *src;
+ nr_make->user_addr = *user;
- make->protinfo.nr->your_index = circuit_index;
- make->protinfo.nr->your_id = circuit_id;
+ nr_make->your_index = circuit_index;
+ nr_make->your_id = circuit_id;
circuit = nr_find_next_circuit();
- make->protinfo.nr->my_index = circuit / 256;
- make->protinfo.nr->my_id = circuit % 256;
+ nr_make->my_index = circuit / 256;
+ nr_make->my_id = circuit % 256;
circuit++;
/* Window negotiation */
- if (window < make->protinfo.nr->window)
- make->protinfo.nr->window = window;
+ if (window < nr_make->window)
+ nr_make->window = window;
/* L4 timeout negotiation */
if (skb->len == 37) {
timeout = skb->data[36] * 256 + skb->data[35];
- if (timeout * HZ < make->protinfo.nr->t1)
- make->protinfo.nr->t1 = timeout * HZ;
- make->protinfo.nr->bpqext = 1;
+ if (timeout * HZ < nr_make->t1)
+ nr_make->t1 = timeout * HZ;
+ nr_make->bpqext = 1;
} else {
- make->protinfo.nr->bpqext = 0;
+ nr_make->bpqext = 0;
}
nr_write_internal(make, NR_CONNACK);
- make->protinfo.nr->condition = 0x00;
- make->protinfo.nr->vs = 0;
- make->protinfo.nr->va = 0;
- make->protinfo.nr->vr = 0;
- make->protinfo.nr->vl = 0;
- make->protinfo.nr->state = NR_STATE_3;
+ nr_make->condition = 0x00;
+ nr_make->vs = 0;
+ nr_make->va = 0;
+ nr_make->vr = 0;
+ nr_make->vl = 0;
+ nr_make->state = NR_STATE_3;
sk->ack_backlog++;
make->pair = sk;
@@ -971,6 +991,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
static int nr_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ nr_cb *nr = nr_sk(sk);
struct sockaddr_ax25 *usax = (struct sockaddr_ax25 *)msg->msg_name;
int err;
struct sockaddr_ax25 sax;
@@ -989,14 +1010,14 @@ static int nr_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct s
return -EPIPE;
}
- if (sk->protinfo.nr->device == NULL)
+ if (nr->device == NULL)
return -ENETUNREACH;
if (usax) {
if (msg->msg_namelen < sizeof(sax))
return -EINVAL;
sax = *usax;
- if (ax25cmp(&sk->protinfo.nr->dest_addr, &sax.sax25_call) != 0)
+ if (ax25cmp(&nr->dest_addr, &sax.sax25_call) != 0)
return -EISCONN;
if (sax.sax25_family != AF_NETROM)
return -EINVAL;
@@ -1004,7 +1025,7 @@ static int nr_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct s
if (sk->state != TCP_ESTABLISHED)
return -ENOTCONN;
sax.sax25_family = AF_NETROM;
- sax.sax25_call = sk->protinfo.nr->dest_addr;
+ sax.sax25_call = nr->dest_addr;
}
SOCK_DEBUG(sk, "NET/ROM: sendto: Addresses built.\n");
@@ -1027,8 +1048,8 @@ static int nr_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct s
/* Build a NET/ROM Transport header */
- *asmptr++ = sk->protinfo.nr->your_index;
- *asmptr++ = sk->protinfo.nr->your_id;
+ *asmptr++ = nr->your_index;
+ *asmptr++ = nr->your_id;
*asmptr++ = 0; /* To be filled in later */
*asmptr++ = 0; /* Ditto */
*asmptr++ = NR_INFO;
@@ -1171,37 +1192,39 @@ static int nr_get_info(char *buffer, char **start, off_t offset, int length)
len += sprintf(buffer, "user_addr dest_node src_node dev my your st vs vr va t1 t2 t4 idle n2 wnd Snd-Q Rcv-Q inode\n");
for (s = nr_list; s != NULL; s = s->next) {
- if ((dev = s->protinfo.nr->device) == NULL)
+ nr_cb *nr = nr_sk(s);
+
+ if ((dev = nr->device) == NULL)
devname = "???";
else
devname = dev->name;
len += sprintf(buffer + len, "%-9s ",
- ax2asc(&s->protinfo.nr->user_addr));
+ ax2asc(&nr->user_addr));
len += sprintf(buffer + len, "%-9s ",
- ax2asc(&s->protinfo.nr->dest_addr));
+ ax2asc(&nr->dest_addr));
len += sprintf(buffer + len, "%-9s %-3s %02X/%02X %02X/%02X %2d %3d %3d %3d %3lu/%03lu %2lu/%02lu %3lu/%03lu %3lu/%03lu %2d/%02d %3d %5d %5d %ld\n",
- ax2asc(&s->protinfo.nr->source_addr),
+ ax2asc(&nr->source_addr),
devname,
- s->protinfo.nr->my_index,
- s->protinfo.nr->my_id,
- s->protinfo.nr->your_index,
- s->protinfo.nr->your_id,
- s->protinfo.nr->state,
- s->protinfo.nr->vs,
- s->protinfo.nr->vr,
- s->protinfo.nr->va,
- ax25_display_timer(&s->protinfo.nr->t1timer) / HZ,
- s->protinfo.nr->t1 / HZ,
- ax25_display_timer(&s->protinfo.nr->t2timer) / HZ,
- s->protinfo.nr->t2 / HZ,
- ax25_display_timer(&s->protinfo.nr->t4timer) / HZ,
- s->protinfo.nr->t4 / HZ,
- ax25_display_timer(&s->protinfo.nr->idletimer) / (60 * HZ),
- s->protinfo.nr->idle / (60 * HZ),
- s->protinfo.nr->n2count,
- s->protinfo.nr->n2,
- s->protinfo.nr->window,
+ nr->my_index,
+ nr->my_id,
+ nr->your_index,
+ nr->your_id,
+ nr->state,
+ nr->vs,
+ nr->vr,
+ nr->va,
+ ax25_display_timer(&nr->t1timer) / HZ,
+ nr->t1 / HZ,
+ ax25_display_timer(&nr->t2timer) / HZ,
+ nr->t2 / HZ,
+ ax25_display_timer(&nr->t4timer) / HZ,
+ nr->t4 / HZ,
+ ax25_display_timer(&nr->idletimer) / (60 * HZ),
+ nr->idle / (60 * HZ),
+ nr->n2count,
+ nr->n2,
+ nr->window,
atomic_read(&s->wmem_alloc),
atomic_read(&s->rmem_alloc),
s->socket != NULL ? s->socket->inode->i_ino : 0L);
diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c
index 29762e929..5e28d34ee 100644
--- a/net/netrom/nr_in.c
+++ b/net/netrom/nr_in.c
@@ -39,6 +39,7 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
+#include <net/tcp.h>
#include <net/ip.h> /* For ip_rcv */
#include <asm/uaccess.h>
#include <asm/system.h>
@@ -50,32 +51,33 @@
static int nr_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
{
struct sk_buff *skbo, *skbn = skb;
+ nr_cb *nr = nr_sk(sk);
skb_pull(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
nr_start_idletimer(sk);
if (more) {
- sk->protinfo.nr->fraglen += skb->len;
- skb_queue_tail(&sk->protinfo.nr->frag_queue, skb);
+ nr->fraglen += skb->len;
+ skb_queue_tail(&nr->frag_queue, skb);
return 0;
}
- if (!more && sk->protinfo.nr->fraglen > 0) { /* End of fragment */
- sk->protinfo.nr->fraglen += skb->len;
- skb_queue_tail(&sk->protinfo.nr->frag_queue, skb);
+ if (!more && nr->fraglen > 0) { /* End of fragment */
+ nr->fraglen += skb->len;
+ skb_queue_tail(&nr->frag_queue, skb);
- if ((skbn = alloc_skb(sk->protinfo.nr->fraglen, GFP_ATOMIC)) == NULL)
+ if ((skbn = alloc_skb(nr->fraglen, GFP_ATOMIC)) == NULL)
return 1;
skbn->h.raw = skbn->data;
- while ((skbo = skb_dequeue(&sk->protinfo.nr->frag_queue)) != NULL) {
+ while ((skbo = skb_dequeue(&nr->frag_queue)) != NULL) {
memcpy(skb_put(skbn, skbo->len), skbo->data, skbo->len);
kfree_skb(skbo);
}
- sk->protinfo.nr->fraglen = 0;
+ nr->fraglen = 0;
}
return sock_queue_rcv_skb(sk, skbn);
@@ -90,22 +92,25 @@ static int nr_state1_machine(struct sock *sk, struct sk_buff *skb, int frametype
{
switch (frametype) {
- case NR_CONNACK:
+ case NR_CONNACK: {
+ nr_cb *nr = nr_sk(sk);
+
nr_stop_t1timer(sk);
nr_start_idletimer(sk);
- sk->protinfo.nr->your_index = skb->data[17];
- sk->protinfo.nr->your_id = skb->data[18];
- sk->protinfo.nr->vs = 0;
- sk->protinfo.nr->va = 0;
- sk->protinfo.nr->vr = 0;
- sk->protinfo.nr->vl = 0;
- sk->protinfo.nr->state = NR_STATE_3;
- sk->protinfo.nr->n2count = 0;
- sk->protinfo.nr->window = skb->data[20];
- sk->state = TCP_ESTABLISHED;
+ nr->your_index = skb->data[17];
+ nr->your_id = skb->data[18];
+ nr->vs = 0;
+ nr->va = 0;
+ nr->vr = 0;
+ nr->vl = 0;
+ nr->state = NR_STATE_3;
+ nr->n2count = 0;
+ nr->window = skb->data[20];
+ sk->state = TCP_ESTABLISHED;
if (!sk->dead)
sk->state_change(sk);
break;
+ }
case NR_CONNACK | NR_CHOKE_FLAG:
nr_disconnect(sk, ECONNREFUSED);
@@ -152,6 +157,7 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb, int frametype
*/
static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype)
{
+ nr_cb *nrom = nr_sk(sk);
struct sk_buff_head temp_queue;
struct sk_buff *skbn;
unsigned short save_vr;
@@ -182,10 +188,10 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
case NR_INFOACK | NR_NAK_FLAG:
case NR_INFOACK | NR_NAK_FLAG | NR_CHOKE_FLAG:
if (frametype & NR_CHOKE_FLAG) {
- sk->protinfo.nr->condition |= NR_COND_PEER_RX_BUSY;
+ nrom->condition |= NR_COND_PEER_RX_BUSY;
nr_start_t4timer(sk);
} else {
- sk->protinfo.nr->condition &= ~NR_COND_PEER_RX_BUSY;
+ nrom->condition &= ~NR_COND_PEER_RX_BUSY;
nr_stop_t4timer(sk);
}
if (!nr_validate_nr(sk, nr)) {
@@ -195,7 +201,7 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
nr_frames_acked(sk, nr);
nr_send_nak_frame(sk);
} else {
- if (sk->protinfo.nr->condition & NR_COND_PEER_RX_BUSY) {
+ if (nrom->condition & NR_COND_PEER_RX_BUSY) {
nr_frames_acked(sk, nr);
} else {
nr_check_iframes_acked(sk, nr);
@@ -212,10 +218,10 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
case NR_INFO | NR_NAK_FLAG | NR_MORE_FLAG:
case NR_INFO | NR_NAK_FLAG | NR_CHOKE_FLAG | NR_MORE_FLAG:
if (frametype & NR_CHOKE_FLAG) {
- sk->protinfo.nr->condition |= NR_COND_PEER_RX_BUSY;
+ nrom->condition |= NR_COND_PEER_RX_BUSY;
nr_start_t4timer(sk);
} else {
- sk->protinfo.nr->condition &= ~NR_COND_PEER_RX_BUSY;
+ nrom->condition &= ~NR_COND_PEER_RX_BUSY;
nr_stop_t4timer(sk);
}
if (nr_validate_nr(sk, nr)) {
@@ -223,7 +229,7 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
nr_frames_acked(sk, nr);
nr_send_nak_frame(sk);
} else {
- if (sk->protinfo.nr->condition & NR_COND_PEER_RX_BUSY) {
+ if (nrom->condition & NR_COND_PEER_RX_BUSY) {
nr_frames_acked(sk, nr);
} else {
nr_check_iframes_acked(sk, nr);
@@ -231,19 +237,19 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
}
}
queued = 1;
- skb_queue_head(&sk->protinfo.nr->reseq_queue, skb);
- if (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY)
+ skb_queue_head(&nrom->reseq_queue, skb);
+ if (nrom->condition & NR_COND_OWN_RX_BUSY)
break;
skb_queue_head_init(&temp_queue);
do {
- save_vr = sk->protinfo.nr->vr;
- while ((skbn = skb_dequeue(&sk->protinfo.nr->reseq_queue)) != NULL) {
+ save_vr = nrom->vr;
+ while ((skbn = skb_dequeue(&nrom->reseq_queue)) != NULL) {
ns = skbn->data[17];
- if (ns == sk->protinfo.nr->vr) {
+ if (ns == nrom->vr) {
if (nr_queue_rx_frame(sk, skbn, frametype & NR_MORE_FLAG) == 0) {
- sk->protinfo.nr->vr = (sk->protinfo.nr->vr + 1) % NR_MODULUS;
+ nrom->vr = (nrom->vr + 1) % NR_MODULUS;
} else {
- sk->protinfo.nr->condition |= NR_COND_OWN_RX_BUSY;
+ nrom->condition |= NR_COND_OWN_RX_BUSY;
skb_queue_tail(&temp_queue, skbn);
}
} else if (nr_in_rx_window(sk, ns)) {
@@ -253,17 +259,17 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
}
}
while ((skbn = skb_dequeue(&temp_queue)) != NULL) {
- skb_queue_tail(&sk->protinfo.nr->reseq_queue, skbn);
+ skb_queue_tail(&nrom->reseq_queue, skbn);
}
- } while (save_vr != sk->protinfo.nr->vr);
+ } while (save_vr != nrom->vr);
/*
* Window is full, ack it immediately.
*/
- if (((sk->protinfo.nr->vl + sk->protinfo.nr->window) % NR_MODULUS) == sk->protinfo.nr->vr) {
+ if (((nrom->vl + nrom->window) % NR_MODULUS) == nrom->vr) {
nr_enquiry_response(sk);
} else {
- if (!(sk->protinfo.nr->condition & NR_COND_ACK_PENDING)) {
- sk->protinfo.nr->condition |= NR_COND_ACK_PENDING;
+ if (!(nrom->condition & NR_COND_ACK_PENDING)) {
+ nrom->condition |= NR_COND_ACK_PENDING;
nr_start_t2timer(sk);
}
}
@@ -279,14 +285,15 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
/* Higher level upcall for a LAPB frame */
int nr_process_rx_frame(struct sock *sk, struct sk_buff *skb)
{
+ nr_cb *nr = nr_sk(sk);
int queued = 0, frametype;
- if (sk->protinfo.nr->state == NR_STATE_0)
+ if (nr->state == NR_STATE_0)
return 0;
frametype = skb->data[19];
- switch (sk->protinfo.nr->state) {
+ switch (nr->state) {
case NR_STATE_1:
queued = nr_state1_machine(sk, skb, frametype);
break;
diff --git a/net/netrom/nr_out.c b/net/netrom/nr_out.c
index d602377f4..10996ba5e 100644
--- a/net/netrom/nr_out.c
+++ b/net/netrom/nr_out.c
@@ -91,13 +91,15 @@ void nr_output(struct sock *sk, struct sk_buff *skb)
*/
static void nr_send_iframe(struct sock *sk, struct sk_buff *skb)
{
+ nr_cb *nr = nr_sk(sk);
+
if (skb == NULL)
return;
- skb->data[2] = sk->protinfo.nr->vs;
- skb->data[3] = sk->protinfo.nr->vr;
+ skb->data[2] = nr->vs;
+ skb->data[3] = nr->vr;
- if (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY)
+ if (nr->condition & NR_COND_OWN_RX_BUSY)
skb->data[4] |= NR_CHOKE_FLAG;
nr_start_idletimer(sk);
@@ -108,48 +110,50 @@ static void nr_send_iframe(struct sock *sk, struct sk_buff *skb)
void nr_send_nak_frame(struct sock *sk)
{
struct sk_buff *skb, *skbn;
+ nr_cb *nr = nr_sk(sk);
- if ((skb = skb_peek(&sk->protinfo.nr->ack_queue)) == NULL)
+ if ((skb = skb_peek(&nr->ack_queue)) == NULL)
return;
if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL)
return;
- skbn->data[2] = sk->protinfo.nr->va;
- skbn->data[3] = sk->protinfo.nr->vr;
+ skbn->data[2] = nr->va;
+ skbn->data[3] = nr->vr;
- if (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY)
+ if (nr->condition & NR_COND_OWN_RX_BUSY)
skbn->data[4] |= NR_CHOKE_FLAG;
nr_transmit_buffer(sk, skbn);
- sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING;
- sk->protinfo.nr->vl = sk->protinfo.nr->vr;
+ nr->condition &= ~NR_COND_ACK_PENDING;
+ nr->vl = nr->vr;
nr_stop_t1timer(sk);
}
void nr_kick(struct sock *sk)
{
+ nr_cb *nr = nr_sk(sk);
struct sk_buff *skb, *skbn;
unsigned short start, end;
- if (sk->protinfo.nr->state != NR_STATE_3)
+ if (nr->state != NR_STATE_3)
return;
- if (sk->protinfo.nr->condition & NR_COND_PEER_RX_BUSY)
+ if (nr->condition & NR_COND_PEER_RX_BUSY)
return;
if (skb_peek(&sk->write_queue) == NULL)
return;
- start = (skb_peek(&sk->protinfo.nr->ack_queue) == NULL) ? sk->protinfo.nr->va : sk->protinfo.nr->vs;
- end = (sk->protinfo.nr->va + sk->protinfo.nr->window) % NR_MODULUS;
+ start = (skb_peek(&nr->ack_queue) == NULL) ? nr->va : nr->vs;
+ end = (nr->va + nr->window) % NR_MODULUS;
if (start == end)
return;
- sk->protinfo.nr->vs = start;
+ nr->vs = start;
/*
* Transmit data until either we're out of data to send or
@@ -174,17 +178,17 @@ void nr_kick(struct sock *sk)
*/
nr_send_iframe(sk, skbn);
- sk->protinfo.nr->vs = (sk->protinfo.nr->vs + 1) % NR_MODULUS;
+ nr->vs = (nr->vs + 1) % NR_MODULUS;
/*
* Requeue the original data frame.
*/
- skb_queue_tail(&sk->protinfo.nr->ack_queue, skb);
+ skb_queue_tail(&nr->ack_queue, skb);
- } while (sk->protinfo.nr->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL);
+ } while (nr->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL);
- sk->protinfo.nr->vl = sk->protinfo.nr->vr;
- sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING;
+ nr->vl = nr->vr;
+ nr->condition &= ~NR_COND_ACK_PENDING;
if (!nr_t1timer_running(sk))
nr_start_t1timer(sk);
@@ -192,6 +196,7 @@ void nr_kick(struct sock *sk)
void nr_transmit_buffer(struct sock *sk, struct sk_buff *skb)
{
+ nr_cb *nr = nr;
unsigned char *dptr;
/*
@@ -199,13 +204,13 @@ void nr_transmit_buffer(struct sock *sk, struct sk_buff *skb)
*/
dptr = skb_push(skb, NR_NETWORK_LEN);
- memcpy(dptr, &sk->protinfo.nr->source_addr, AX25_ADDR_LEN);
+ memcpy(dptr, &nr->source_addr, AX25_ADDR_LEN);
dptr[6] &= ~AX25_CBIT;
dptr[6] &= ~AX25_EBIT;
dptr[6] |= AX25_SSSID_SPARE;
dptr += AX25_ADDR_LEN;
- memcpy(dptr, &sk->protinfo.nr->dest_addr, AX25_ADDR_LEN);
+ memcpy(dptr, &nr->dest_addr, AX25_ADDR_LEN);
dptr[6] &= ~AX25_CBIT;
dptr[6] |= AX25_EBIT;
dptr[6] |= AX25_SSSID_SPARE;
@@ -226,8 +231,10 @@ void nr_transmit_buffer(struct sock *sk, struct sk_buff *skb)
void nr_establish_data_link(struct sock *sk)
{
- sk->protinfo.nr->condition = 0x00;
- sk->protinfo.nr->n2count = 0;
+ nr_cb *nr = nr_sk(sk);
+
+ nr->condition = 0x00;
+ nr->n2count = 0;
nr_write_internal(sk, NR_CONNREQ);
@@ -242,29 +249,32 @@ void nr_establish_data_link(struct sock *sk)
*/
void nr_enquiry_response(struct sock *sk)
{
+ nr_cb *nr = nr_sk(sk);
int frametype = NR_INFOACK;
- if (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY) {
+ if (nr->condition & NR_COND_OWN_RX_BUSY) {
frametype |= NR_CHOKE_FLAG;
} else {
- if (skb_peek(&sk->protinfo.nr->reseq_queue) != NULL)
+ if (skb_peek(&nr->reseq_queue) != NULL)
frametype |= NR_NAK_FLAG;
}
nr_write_internal(sk, frametype);
- sk->protinfo.nr->vl = sk->protinfo.nr->vr;
- sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING;
+ nr->vl = nr->vr;
+ nr->condition &= ~NR_COND_ACK_PENDING;
}
void nr_check_iframes_acked(struct sock *sk, unsigned short nr)
{
- if (sk->protinfo.nr->vs == nr) {
+ nr_cb *nrom = nr_sk(sk);
+
+ if (nrom->vs == nr) {
nr_frames_acked(sk, nr);
nr_stop_t1timer(sk);
- sk->protinfo.nr->n2count = 0;
+ nrom->n2count = 0;
} else {
- if (sk->protinfo.nr->va != nr) {
+ if (nrom->va != nr) {
nr_frames_acked(sk, nr);
nr_start_t1timer(sk);
}
diff --git a/net/netrom/nr_subr.c b/net/netrom/nr_subr.c
index bd30fa7ad..f9c4fba77 100644
--- a/net/netrom/nr_subr.c
+++ b/net/netrom/nr_subr.c
@@ -30,6 +30,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>
@@ -42,10 +43,12 @@
*/
void nr_clear_queues(struct sock *sk)
{
+ nr_cb *nr = nr_sk(sk);
+
skb_queue_purge(&sk->write_queue);
- skb_queue_purge(&sk->protinfo.nr->ack_queue);
- skb_queue_purge(&sk->protinfo.nr->reseq_queue);
- skb_queue_purge(&sk->protinfo.nr->frag_queue);
+ skb_queue_purge(&nr->ack_queue);
+ skb_queue_purge(&nr->reseq_queue);
+ skb_queue_purge(&nr->frag_queue);
}
/*
@@ -55,16 +58,17 @@ void nr_clear_queues(struct sock *sk)
*/
void nr_frames_acked(struct sock *sk, unsigned short nr)
{
+ nr_cb *nrom = nr_sk(sk);
struct sk_buff *skb;
/*
* Remove all the ack-ed frames from the ack queue.
*/
- if (sk->protinfo.nr->va != nr) {
- while (skb_peek(&sk->protinfo.nr->ack_queue) != NULL && sk->protinfo.nr->va != nr) {
- skb = skb_dequeue(&sk->protinfo.nr->ack_queue);
+ if (nrom->va != nr) {
+ while (skb_peek(&nrom->ack_queue) != NULL && nrom->va != nr) {
+ skb = skb_dequeue(&nrom->ack_queue);
kfree_skb(skb);
- sk->protinfo.nr->va = (sk->protinfo.nr->va + 1) % NR_MODULUS;
+ nrom->va = (nrom->va + 1) % NR_MODULUS;
}
}
}
@@ -78,7 +82,7 @@ void nr_requeue_frames(struct sock *sk)
{
struct sk_buff *skb, *skb_prev = NULL;
- while ((skb = skb_dequeue(&sk->protinfo.nr->ack_queue)) != NULL) {
+ while ((skb = skb_dequeue(&nr_sk(sk)->ack_queue)) != NULL) {
if (skb_prev == NULL)
skb_queue_head(&sk->write_queue, skb);
else
@@ -93,16 +97,15 @@ void nr_requeue_frames(struct sock *sk)
*/
int nr_validate_nr(struct sock *sk, unsigned short nr)
{
- unsigned short vc = sk->protinfo.nr->va;
+ nr_cb *nrom = nr_sk(sk);
+ unsigned short vc = nrom->va;
- while (vc != sk->protinfo.nr->vs) {
+ while (vc != nrom->vs) {
if (nr == vc) return 1;
vc = (vc + 1) % NR_MODULUS;
}
- if (nr == sk->protinfo.nr->vs) return 1;
-
- return 0;
+ return nr == nrom->vs;
}
/*
@@ -110,8 +113,9 @@ int nr_validate_nr(struct sock *sk, unsigned short nr)
*/
int nr_in_rx_window(struct sock *sk, unsigned short ns)
{
- unsigned short vc = sk->protinfo.nr->vr;
- unsigned short vt = (sk->protinfo.nr->vl + sk->protinfo.nr->window) % NR_MODULUS;
+ nr_cb *nr = nr_sk(sk);
+ unsigned short vc = nr->vr;
+ unsigned short vt = (nr->vl + nr->window) % NR_MODULUS;
while (vc != vt) {
if (ns == vc) return 1;
@@ -127,6 +131,7 @@ int nr_in_rx_window(struct sock *sk, unsigned short ns)
*/
void nr_write_internal(struct sock *sk, int frametype)
{
+ nr_cb *nr = nr_sk(sk);
struct sk_buff *skb;
unsigned char *dptr;
int len, timeout;
@@ -138,7 +143,7 @@ void nr_write_internal(struct sock *sk, int frametype)
len += 17;
break;
case NR_CONNACK:
- len += (sk->protinfo.nr->bpqext) ? 2 : 1;
+ len += (nr->bpqext) ? 2 : 1;
break;
case NR_DISCREQ:
case NR_DISCACK:
@@ -162,19 +167,19 @@ void nr_write_internal(struct sock *sk, int frametype)
switch (frametype & 0x0F) {
case NR_CONNREQ:
- timeout = sk->protinfo.nr->t1 / HZ;
- *dptr++ = sk->protinfo.nr->my_index;
- *dptr++ = sk->protinfo.nr->my_id;
+ timeout = nr->t1 / HZ;
+ *dptr++ = nr->my_index;
+ *dptr++ = nr->my_id;
*dptr++ = 0;
*dptr++ = 0;
*dptr++ = frametype;
- *dptr++ = sk->protinfo.nr->window;
- memcpy(dptr, &sk->protinfo.nr->user_addr, AX25_ADDR_LEN);
+ *dptr++ = nr->window;
+ memcpy(dptr, &nr->user_addr, AX25_ADDR_LEN);
dptr[6] &= ~AX25_CBIT;
dptr[6] &= ~AX25_EBIT;
dptr[6] |= AX25_SSSID_SPARE;
dptr += AX25_ADDR_LEN;
- memcpy(dptr, &sk->protinfo.nr->source_addr, AX25_ADDR_LEN);
+ memcpy(dptr, &nr->source_addr, AX25_ADDR_LEN);
dptr[6] &= ~AX25_CBIT;
dptr[6] &= ~AX25_EBIT;
dptr[6] |= AX25_SSSID_SPARE;
@@ -184,29 +189,29 @@ void nr_write_internal(struct sock *sk, int frametype)
break;
case NR_CONNACK:
- *dptr++ = sk->protinfo.nr->your_index;
- *dptr++ = sk->protinfo.nr->your_id;
- *dptr++ = sk->protinfo.nr->my_index;
- *dptr++ = sk->protinfo.nr->my_id;
+ *dptr++ = nr->your_index;
+ *dptr++ = nr->your_id;
+ *dptr++ = nr->my_index;
+ *dptr++ = nr->my_id;
*dptr++ = frametype;
- *dptr++ = sk->protinfo.nr->window;
- if (sk->protinfo.nr->bpqext) *dptr++ = sysctl_netrom_network_ttl_initialiser;
+ *dptr++ = nr->window;
+ if (nr->bpqext) *dptr++ = sysctl_netrom_network_ttl_initialiser;
break;
case NR_DISCREQ:
case NR_DISCACK:
- *dptr++ = sk->protinfo.nr->your_index;
- *dptr++ = sk->protinfo.nr->your_id;
+ *dptr++ = nr->your_index;
+ *dptr++ = nr->your_id;
*dptr++ = 0;
*dptr++ = 0;
*dptr++ = frametype;
break;
case NR_INFOACK:
- *dptr++ = sk->protinfo.nr->your_index;
- *dptr++ = sk->protinfo.nr->your_id;
+ *dptr++ = nr->your_index;
+ *dptr++ = nr->your_id;
*dptr++ = 0;
- *dptr++ = sk->protinfo.nr->vr;
+ *dptr++ = nr->vr;
*dptr++ = frametype;
break;
}
@@ -275,7 +280,7 @@ void nr_disconnect(struct sock *sk, int reason)
nr_clear_queues(sk);
- sk->protinfo.nr->state = NR_STATE_0;
+ nr_sk(sk)->state = NR_STATE_0;
sk->state = TCP_CLOSE;
sk->err = reason;
diff --git a/net/netrom/nr_timer.c b/net/netrom/nr_timer.c
index 116770434..ba9c70e50 100644
--- a/net/netrom/nr_timer.c
+++ b/net/netrom/nr_timer.c
@@ -30,6 +30,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>
@@ -45,47 +46,55 @@ static void nr_idletimer_expiry(unsigned long);
void nr_start_t1timer(struct sock *sk)
{
- del_timer(&sk->protinfo.nr->t1timer);
+ nr_cb *nr = nr_sk(sk);
- sk->protinfo.nr->t1timer.data = (unsigned long)sk;
- sk->protinfo.nr->t1timer.function = &nr_t1timer_expiry;
- sk->protinfo.nr->t1timer.expires = jiffies + sk->protinfo.nr->t1;
+ del_timer(&nr->t1timer);
- add_timer(&sk->protinfo.nr->t1timer);
+ nr->t1timer.data = (unsigned long)sk;
+ nr->t1timer.function = &nr_t1timer_expiry;
+ nr->t1timer.expires = jiffies + nr->t1;
+
+ add_timer(&nr->t1timer);
}
void nr_start_t2timer(struct sock *sk)
{
- del_timer(&sk->protinfo.nr->t2timer);
+ nr_cb *nr = nr_sk(sk);
+
+ del_timer(&nr->t2timer);
- sk->protinfo.nr->t2timer.data = (unsigned long)sk;
- sk->protinfo.nr->t2timer.function = &nr_t2timer_expiry;
- sk->protinfo.nr->t2timer.expires = jiffies + sk->protinfo.nr->t2;
+ nr->t2timer.data = (unsigned long)sk;
+ nr->t2timer.function = &nr_t2timer_expiry;
+ nr->t2timer.expires = jiffies + nr->t2;
- add_timer(&sk->protinfo.nr->t2timer);
+ add_timer(&nr->t2timer);
}
void nr_start_t4timer(struct sock *sk)
{
- del_timer(&sk->protinfo.nr->t4timer);
+ nr_cb *nr = nr_sk(sk);
- sk->protinfo.nr->t4timer.data = (unsigned long)sk;
- sk->protinfo.nr->t4timer.function = &nr_t4timer_expiry;
- sk->protinfo.nr->t4timer.expires = jiffies + sk->protinfo.nr->t4;
+ del_timer(&nr->t4timer);
- add_timer(&sk->protinfo.nr->t4timer);
+ nr->t4timer.data = (unsigned long)sk;
+ nr->t4timer.function = &nr_t4timer_expiry;
+ nr->t4timer.expires = jiffies + nr->t4;
+
+ add_timer(&nr->t4timer);
}
void nr_start_idletimer(struct sock *sk)
{
- del_timer(&sk->protinfo.nr->idletimer);
+ nr_cb *nr = nr_sk(sk);
+
+ del_timer(&nr->idletimer);
- if (sk->protinfo.nr->idle > 0) {
- sk->protinfo.nr->idletimer.data = (unsigned long)sk;
- sk->protinfo.nr->idletimer.function = &nr_idletimer_expiry;
- sk->protinfo.nr->idletimer.expires = jiffies + sk->protinfo.nr->idle;
+ if (nr->idle > 0) {
+ nr->idletimer.data = (unsigned long)sk;
+ nr->idletimer.function = &nr_idletimer_expiry;
+ nr->idletimer.expires = jiffies + nr->idle;
- add_timer(&sk->protinfo.nr->idletimer);
+ add_timer(&nr->idletimer);
}
}
@@ -102,22 +111,22 @@ void nr_start_heartbeat(struct sock *sk)
void nr_stop_t1timer(struct sock *sk)
{
- del_timer(&sk->protinfo.nr->t1timer);
+ del_timer(&nr_sk(sk)->t1timer);
}
void nr_stop_t2timer(struct sock *sk)
{
- del_timer(&sk->protinfo.nr->t2timer);
+ del_timer(&nr_sk(sk)->t2timer);
}
void nr_stop_t4timer(struct sock *sk)
{
- del_timer(&sk->protinfo.nr->t4timer);
+ del_timer(&nr_sk(sk)->t4timer);
}
void nr_stop_idletimer(struct sock *sk)
{
- del_timer(&sk->protinfo.nr->idletimer);
+ del_timer(&nr_sk(sk)->idletimer);
}
void nr_stop_heartbeat(struct sock *sk)
@@ -127,14 +136,15 @@ void nr_stop_heartbeat(struct sock *sk)
int nr_t1timer_running(struct sock *sk)
{
- return timer_pending(&sk->protinfo.nr->t1timer);
+ return timer_pending(&nr_sk(sk)->t1timer);
}
static void nr_heartbeat_expiry(unsigned long param)
{
struct sock *sk = (struct sock *)param;
+ nr_cb *nr = nr_sk(sk);
- switch (sk->protinfo.nr->state) {
+ switch (nr->state) {
case NR_STATE_0:
/* Magic here: If we listen() and a new link dies before it
@@ -150,10 +160,10 @@ static void nr_heartbeat_expiry(unsigned long param)
* Check for the state of the receive buffer.
*/
if (atomic_read(&sk->rmem_alloc) < (sk->rcvbuf / 2) &&
- (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY)) {
- sk->protinfo.nr->condition &= ~NR_COND_OWN_RX_BUSY;
- sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING;
- sk->protinfo.nr->vl = sk->protinfo.nr->vr;
+ (nr->condition & NR_COND_OWN_RX_BUSY)) {
+ nr->condition &= ~NR_COND_OWN_RX_BUSY;
+ nr->condition &= ~NR_COND_ACK_PENDING;
+ nr->vl = nr->vr;
nr_write_internal(sk, NR_INFOACK);
break;
}
@@ -166,9 +176,10 @@ static void nr_heartbeat_expiry(unsigned long param)
static void nr_t2timer_expiry(unsigned long param)
{
struct sock *sk = (struct sock *)param;
+ nr_cb *nr = nr_sk(sk);
- if (sk->protinfo.nr->condition & NR_COND_ACK_PENDING) {
- sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING;
+ if (nr->condition & NR_COND_ACK_PENDING) {
+ nr->condition &= ~NR_COND_ACK_PENDING;
nr_enquiry_response(sk);
}
}
@@ -177,18 +188,19 @@ static void nr_t4timer_expiry(unsigned long param)
{
struct sock *sk = (struct sock *)param;
- sk->protinfo.nr->condition &= ~NR_COND_PEER_RX_BUSY;
+ nr_sk(sk)->condition &= ~NR_COND_PEER_RX_BUSY;
}
static void nr_idletimer_expiry(unsigned long param)
{
struct sock *sk = (struct sock *)param;
+ nr_cb *nr = nr_sk(sk);
nr_clear_queues(sk);
- sk->protinfo.nr->n2count = 0;
+ nr->n2count = 0;
nr_write_internal(sk, NR_DISCREQ);
- sk->protinfo.nr->state = NR_STATE_2;
+ nr->state = NR_STATE_2;
nr_start_t1timer(sk);
nr_stop_t2timer(sk);
@@ -207,35 +219,36 @@ static void nr_idletimer_expiry(unsigned long param)
static void nr_t1timer_expiry(unsigned long param)
{
struct sock *sk = (struct sock *)param;
+ nr_cb *nr = nr_sk(sk);
- switch (sk->protinfo.nr->state) {
+ switch (nr->state) {
case NR_STATE_1:
- if (sk->protinfo.nr->n2count == sk->protinfo.nr->n2) {
+ if (nr->n2count == nr->n2) {
nr_disconnect(sk, ETIMEDOUT);
return;
} else {
- sk->protinfo.nr->n2count++;
+ nr->n2count++;
nr_write_internal(sk, NR_CONNREQ);
}
break;
case NR_STATE_2:
- if (sk->protinfo.nr->n2count == sk->protinfo.nr->n2) {
+ if (nr->n2count == nr->n2) {
nr_disconnect(sk, ETIMEDOUT);
return;
} else {
- sk->protinfo.nr->n2count++;
+ nr->n2count++;
nr_write_internal(sk, NR_DISCREQ);
}
break;
case NR_STATE_3:
- if (sk->protinfo.nr->n2count == sk->protinfo.nr->n2) {
+ if (nr->n2count == nr->n2) {
nr_disconnect(sk, ETIMEDOUT);
return;
} else {
- sk->protinfo.nr->n2count++;
+ nr->n2count++;
nr_requeue_frames(sk);
}
break;
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 1b3bee5eb..a9739bd55 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -5,7 +5,7 @@
*
* PACKET - implements raw packet sockets.
*
- * Version: $Id: af_packet.c,v 1.59 2001-12-21 04:56:17 davem Exp $
+ * Version: $Id: af_packet.c,v 1.60 2002-02-01 22:01:05 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -199,6 +199,8 @@ struct packet_opt
#endif
};
+#define pkt_sk(__sk) ((struct packet_opt *)(__sk)->protinfo)
+
void packet_sock_destruct(struct sock *sk)
{
BUG_TRAP(atomic_read(&sk->rmem_alloc)==0);
@@ -209,8 +211,8 @@ void packet_sock_destruct(struct sock *sk)
return;
}
- if (sk->protinfo.destruct_hook)
- kfree(sk->protinfo.destruct_hook);
+ if (pkt_sk(sk))
+ kfree(pkt_sk(sk));
atomic_dec(&packet_socks_nr);
#ifdef PACKET_REFCNT_DEBUG
printk(KERN_DEBUG "PACKET socket %p is free, %d are alive\n", sk, atomic_read(&packet_socks_nr));
@@ -413,7 +415,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
goto drop;
sk = (struct sock *) pt->data;
- po = sk->protinfo.af_packet;
+ po = pkt_sk(sk);
skb->dev = dev;
@@ -528,7 +530,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct pack
goto drop;
sk = (struct sock *) pt->data;
- po = sk->protinfo.af_packet;
+ po = pkt_sk(sk);
if (dev->hard_header) {
if (sk->type != SOCK_DGRAM)
@@ -676,7 +678,7 @@ static int packet_sendmsg(struct socket *sock, struct msghdr *msg, int len,
*/
if (saddr == NULL) {
- ifindex = sk->protinfo.af_packet->ifindex;
+ ifindex = pkt_sk(sk)->ifindex;
proto = sk->num;
addr = NULL;
} else {
@@ -761,6 +763,7 @@ out:
static int packet_release(struct socket *sock)
{
struct sock *sk = sock->sk;
+ struct packet_opt *po = pkt_sk(sk);
struct sock **skp;
if (!sk)
@@ -780,12 +783,12 @@ static int packet_release(struct socket *sock)
* Unhook packet receive handler.
*/
- if (sk->protinfo.af_packet->running) {
+ if (po->running) {
/*
* Remove the protocol hook
*/
- dev_remove_pack(&sk->protinfo.af_packet->prot_hook);
- sk->protinfo.af_packet->running = 0;
+ dev_remove_pack(&po->prot_hook);
+ po->running = 0;
__sock_put(sk);
}
@@ -794,7 +797,7 @@ static int packet_release(struct socket *sock)
#endif
#ifdef CONFIG_PACKET_MMAP
- if (sk->protinfo.af_packet->pg_vec) {
+ if (po->pg_vec) {
struct tpacket_req req;
memset(&req, 0, sizeof(req));
packet_set_ring(sk, &req, 1);
@@ -822,46 +825,47 @@ static int packet_release(struct socket *sock)
static int packet_do_bind(struct sock *sk, struct net_device *dev, int protocol)
{
+ struct packet_opt *po = pkt_sk(sk);
/*
* Detach an existing hook if present.
*/
lock_sock(sk);
- spin_lock(&sk->protinfo.af_packet->bind_lock);
- if (sk->protinfo.af_packet->running) {
- dev_remove_pack(&sk->protinfo.af_packet->prot_hook);
+ spin_lock(&po->bind_lock);
+ if (po->running) {
+ dev_remove_pack(&po->prot_hook);
__sock_put(sk);
- sk->protinfo.af_packet->running = 0;
+ po->running = 0;
}
sk->num = protocol;
- sk->protinfo.af_packet->prot_hook.type = protocol;
- sk->protinfo.af_packet->prot_hook.dev = dev;
+ po->prot_hook.type = protocol;
+ po->prot_hook.dev = dev;
- sk->protinfo.af_packet->ifindex = dev ? dev->ifindex : 0;
+ po->ifindex = dev ? dev->ifindex : 0;
if (protocol == 0)
goto out_unlock;
if (dev) {
if (dev->flags&IFF_UP) {
- dev_add_pack(&sk->protinfo.af_packet->prot_hook);
+ dev_add_pack(&po->prot_hook);
sock_hold(sk);
- sk->protinfo.af_packet->running = 1;
+ po->running = 1;
} else {
sk->err = ENETDOWN;
if (!sk->dead)
sk->error_report(sk);
}
} else {
- dev_add_pack(&sk->protinfo.af_packet->prot_hook);
+ dev_add_pack(&po->prot_hook);
sock_hold(sk);
- sk->protinfo.af_packet->running = 1;
+ po->running = 1;
}
out_unlock:
- spin_unlock(&sk->protinfo.af_packet->bind_lock);
+ spin_unlock(&po->bind_lock);
release_sock(sk);
return 0;
}
@@ -936,6 +940,7 @@ out:
static int packet_create(struct socket *sock, int protocol)
{
struct sock *sk;
+ struct packet_opt *po;
int err;
if (!capable(CAP_NET_RAW))
@@ -951,7 +956,7 @@ static int packet_create(struct socket *sock, int protocol)
MOD_INC_USE_COUNT;
err = -ENOBUFS;
- sk = sk_alloc(PF_PACKET, GFP_KERNEL, 1);
+ sk = sk_alloc(PF_PACKET, GFP_KERNEL, 1, NULL);
if (sk == NULL)
goto out;
@@ -962,10 +967,10 @@ static int packet_create(struct socket *sock, int protocol)
#endif
sock_init_data(sock,sk);
- sk->protinfo.af_packet = kmalloc(sizeof(struct packet_opt), GFP_KERNEL);
- if (sk->protinfo.af_packet == NULL)
+ po = pkt_sk(sk) = kmalloc(sizeof(*po), GFP_KERNEL);
+ if (!po)
goto out_free;
- memset(sk->protinfo.af_packet, 0, sizeof(struct packet_opt));
+ memset(po, 0, sizeof(*po));
sk->family = PF_PACKET;
sk->num = protocol;
@@ -976,19 +981,19 @@ static int packet_create(struct socket *sock, int protocol)
* Attach a protocol block
*/
- spin_lock_init(&sk->protinfo.af_packet->bind_lock);
- sk->protinfo.af_packet->prot_hook.func = packet_rcv;
+ spin_lock_init(&po->bind_lock);
+ po->prot_hook.func = packet_rcv;
#ifdef CONFIG_SOCK_PACKET
if (sock->type == SOCK_PACKET)
- sk->protinfo.af_packet->prot_hook.func = packet_rcv_spkt;
+ po->prot_hook.func = packet_rcv_spkt;
#endif
- sk->protinfo.af_packet->prot_hook.data = (void *)sk;
+ po->prot_hook.data = (void *)sk;
if (protocol) {
- sk->protinfo.af_packet->prot_hook.type = protocol;
- dev_add_pack(&sk->protinfo.af_packet->prot_hook);
+ po->prot_hook.type = protocol;
+ dev_add_pack(&po->prot_hook);
sock_hold(sk);
- sk->protinfo.af_packet->running = 1;
+ po->running = 1;
}
write_lock_bh(&packet_sklist_lock);
@@ -1023,7 +1028,7 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, int len,
#if 0
/* What error should we return now? EUNATTACH? */
- if (sk->protinfo.af_packet->ifindex < 0)
+ if (pkt_sk(sk)->ifindex < 0)
return -ENODEV;
#endif
@@ -1101,7 +1106,7 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr,
return -EOPNOTSUPP;
uaddr->sa_family = AF_PACKET;
- dev = dev_get_by_index(sk->protinfo.af_packet->ifindex);
+ dev = dev_get_by_index(pkt_sk(sk)->ifindex);
if (dev) {
strncpy(uaddr->sa_data, dev->name, 15);
dev_put(dev);
@@ -1118,15 +1123,16 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr,
{
struct net_device *dev;
struct sock *sk = sock->sk;
+ struct packet_opt *po = pkt_sk(sk);
struct sockaddr_ll *sll = (struct sockaddr_ll*)uaddr;
if (peer)
return -EOPNOTSUPP;
sll->sll_family = AF_PACKET;
- sll->sll_ifindex = sk->protinfo.af_packet->ifindex;
+ sll->sll_ifindex = po->ifindex;
sll->sll_protocol = sk->num;
- dev = dev_get_by_index(sk->protinfo.af_packet->ifindex);
+ dev = dev_get_by_index(po->ifindex);
if (dev) {
sll->sll_hatype = dev->type;
sll->sll_halen = dev->addr_len;
@@ -1171,6 +1177,7 @@ static void packet_dev_mclist(struct net_device *dev, struct packet_mclist *i, i
static int packet_mc_add(struct sock *sk, struct packet_mreq *mreq)
{
+ struct packet_opt *po = pkt_sk(sk);
struct packet_mclist *ml, *i;
struct net_device *dev;
int err;
@@ -1192,7 +1199,7 @@ static int packet_mc_add(struct sock *sk, struct packet_mreq *mreq)
goto done;
err = 0;
- for (ml=sk->protinfo.af_packet->mclist; ml; ml=ml->next) {
+ for (ml = po->mclist; ml; ml = ml->next) {
if (ml->ifindex == mreq->mr_ifindex &&
ml->type == mreq->mr_type &&
ml->alen == mreq->mr_alen &&
@@ -1209,8 +1216,8 @@ static int packet_mc_add(struct sock *sk, struct packet_mreq *mreq)
i->alen = mreq->mr_alen;
memcpy(i->addr, mreq->mr_address, i->alen);
i->count = 1;
- i->next = sk->protinfo.af_packet->mclist;
- sk->protinfo.af_packet->mclist = i;
+ i->next = po->mclist;
+ po->mclist = i;
packet_dev_mc(dev, i, +1);
done:
@@ -1224,7 +1231,7 @@ static int packet_mc_drop(struct sock *sk, struct packet_mreq *mreq)
rtnl_lock();
- for (mlp=&sk->protinfo.af_packet->mclist; (ml=*mlp)!=NULL; mlp=&ml->next) {
+ for (mlp = &pkt_sk(sk)->mclist; (ml = *mlp) != NULL; mlp = &ml->next) {
if (ml->ifindex == mreq->mr_ifindex &&
ml->type == mreq->mr_type &&
ml->alen == mreq->mr_alen &&
@@ -1249,15 +1256,17 @@ static int packet_mc_drop(struct sock *sk, struct packet_mreq *mreq)
static void packet_flush_mclist(struct sock *sk)
{
+ struct packet_opt *po = pkt_sk(sk);
struct packet_mclist *ml;
- if (sk->protinfo.af_packet->mclist == NULL)
+ if (!po->mclist)
return;
rtnl_lock();
- while ((ml=sk->protinfo.af_packet->mclist) != NULL) {
+ while ((ml = po->mclist) != NULL) {
struct net_device *dev;
- sk->protinfo.af_packet->mclist = ml->next;
+
+ po->mclist = ml->next;
if ((dev = dev_get_by_index(ml->ifindex)) != NULL) {
packet_dev_mc(dev, ml, -1);
dev_put(dev);
@@ -1314,7 +1323,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char *optval, int
if (copy_from_user(&val,optval,sizeof(val)))
return -EFAULT;
- sk->protinfo.af_packet->copy_thresh = val;
+ pkt_sk(sk)->copy_thresh = val;
return 0;
}
#endif
@@ -1328,6 +1337,7 @@ int packet_getsockopt(struct socket *sock, int level, int optname,
{
int len;
struct sock *sk = sock->sk;
+ struct packet_opt *po = pkt_sk(sk);
if (level != SOL_PACKET)
return -ENOPROTOOPT;
@@ -1346,8 +1356,8 @@ int packet_getsockopt(struct socket *sock, int level, int optname,
if (len > sizeof(struct tpacket_stats))
len = sizeof(struct tpacket_stats);
spin_lock_bh(&sk->receive_queue.lock);
- st = sk->protinfo.af_packet->stats;
- memset(&sk->protinfo.af_packet->stats, 0, sizeof(st));
+ st = po->stats;
+ memset(&po->stats, 0, sizeof(st));
spin_unlock_bh(&sk->receive_queue.lock);
st.tp_packets += st.tp_drops;
@@ -1368,12 +1378,11 @@ int packet_getsockopt(struct socket *sock, int level, int optname,
static int packet_notifier(struct notifier_block *this, unsigned long msg, void *data)
{
struct sock *sk;
- struct packet_opt *po;
struct net_device *dev = (struct net_device*)data;
read_lock(&packet_sklist_lock);
for (sk = packet_sklist; sk; sk = sk->next) {
- po = sk->protinfo.af_packet;
+ struct packet_opt *po = pkt_sk(sk);
switch (msg) {
case NETDEV_DOWN:
@@ -1552,7 +1561,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
unsigned int packet_poll(struct file * file, struct socket *sock, poll_table *wait)
{
struct sock *sk = sock->sk;
- struct packet_opt *po = sk->protinfo.af_packet;
+ struct packet_opt *po = pkt_sk(sk);
unsigned int mask = datagram_poll(file, sock, wait);
spin_lock_bh(&sk->receive_queue.lock);
@@ -1579,7 +1588,7 @@ static void packet_mm_open(struct vm_area_struct *vma)
struct sock *sk = sock->sk;
if (sk)
- atomic_inc(&sk->protinfo.af_packet->mapped);
+ atomic_inc(&pkt_sk(sk)->mapped);
}
static void packet_mm_close(struct vm_area_struct *vma)
@@ -1590,7 +1599,7 @@ static void packet_mm_close(struct vm_area_struct *vma)
struct sock *sk = sock->sk;
if (sk)
- atomic_dec(&sk->protinfo.af_packet->mapped);
+ atomic_dec(&pkt_sk(sk)->mapped);
}
static struct vm_operations_struct packet_mmap_ops = {
@@ -1620,7 +1629,7 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing
{
unsigned long *pg_vec = NULL;
struct tpacket_hdr **io_vec = NULL;
- struct packet_opt *po = sk->protinfo.af_packet;
+ struct packet_opt *po = pkt_sk(sk);
int order = 0;
int err = 0;
@@ -1742,7 +1751,7 @@ out:
static int packet_mmap(struct file *file, struct socket *sock, struct vm_area_struct *vma)
{
struct sock *sk = sock->sk;
- struct packet_opt *po = sk->protinfo.af_packet;
+ struct packet_opt *po = pkt_sk(sk);
unsigned long size;
unsigned long start;
int err = -EINVAL;
@@ -1846,13 +1855,15 @@ static int packet_read_proc(char *buffer, char **start, off_t offset,
read_lock(&packet_sklist_lock);
for (s = packet_sklist; s; s = s->next) {
+ struct packet_opt *po = pkt_sk(s);
+
len+=sprintf(buffer+len,"%p %-6d %-4d %04x %-5d %1d %-6u %-6u %-6lu",
s,
atomic_read(&s->refcnt),
s->type,
ntohs(s->num),
- s->protinfo.af_packet->ifindex,
- s->protinfo.af_packet->running,
+ po->ifindex,
+ po->running,
atomic_read(&s->rmem_alloc),
sock_i_uid(s),
sock_i_ino(s)
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index d721721e8..3fb813998 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -53,6 +53,7 @@
#include <linux/notifier.h>
#include <net/rose.h>
#include <linux/proc_fs.h>
+#include <net/tcp.h>
#include <net/ip.h>
#include <net/arp.h>
@@ -148,22 +149,22 @@ static struct sock *rose_alloc_sock(void)
struct sock *sk;
rose_cb *rose;
- if ((sk = sk_alloc(PF_ROSE, GFP_ATOMIC, 1)) == NULL)
- return NULL;
-
- if ((rose = kmalloc(sizeof(*rose), GFP_ATOMIC)) == NULL) {
- sk_free(sk);
- return NULL;
- }
-
MOD_INC_USE_COUNT;
- memset(rose, 0x00, sizeof(*rose));
+ if ((sk = sk_alloc(PF_ROSE, GFP_ATOMIC, 1, NULL)) == NULL)
+ goto decmod;
- sk->protinfo.rose = rose;
- rose->sk = sk;
+ rose = rose_sk(sk) = kmalloc(sizeof(*rose), GFP_ATOMIC);
+ if (!rose)
+ goto frees;
- return sk;
+ memset(rose, 0x00, sizeof(*rose));
+ rose->sk = sk;
+out: return sk;
+frees: sk_free(sk);
+ sk = NULL;
+decmod: MOD_DEC_USE_COUNT;
+ goto out;
}
/*
@@ -204,10 +205,12 @@ void rose_kill_by_neigh(struct rose_neigh *neigh)
struct sock *s;
for (s = rose_list; s != NULL; s = s->next) {
- if (s->protinfo.rose->neighbour == neigh) {
+ rose_cb *rose = rose_sk(s);
+
+ if (rose->neighbour == neigh) {
rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
- s->protinfo.rose->neighbour->use--;
- s->protinfo.rose->neighbour = NULL;
+ rose->neighbour->use--;
+ rose->neighbour = NULL;
}
}
}
@@ -220,10 +223,12 @@ static void rose_kill_by_device(struct net_device *dev)
struct sock *s;
for (s = rose_list; s != NULL; s = s->next) {
- if (s->protinfo.rose->device == dev) {
+ rose_cb *rose = rose_sk(s);
+
+ if (rose->device == dev) {
rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
- s->protinfo.rose->neighbour->use--;
- s->protinfo.rose->device = NULL;
+ rose->neighbour->use--;
+ rose->device = NULL;
}
}
}
@@ -278,14 +283,22 @@ static struct sock *rose_find_listener(rose_address *addr, ax25_address *call)
save_flags(flags); cli();
for (s = rose_list; s != NULL; s = s->next) {
- if (rosecmp(&s->protinfo.rose->source_addr, addr) == 0 && ax25cmp(&s->protinfo.rose->source_call, call) == 0 && s->protinfo.rose->source_ndigis == 0 && s->state == TCP_LISTEN) {
+ rose_cb *rose = rose_sk(s);
+
+ if (!rosecmp(&rose->source_addr, addr) &&
+ !ax25cmp(&rose->source_call, call) &&
+ !rose->source_ndigis && s->state == TCP_LISTEN) {
restore_flags(flags);
return s;
}
}
for (s = rose_list; s != NULL; s = s->next) {
- if (rosecmp(&s->protinfo.rose->source_addr, addr) == 0 && ax25cmp(&s->protinfo.rose->source_call, &null_ax25_address) == 0 && s->state == TCP_LISTEN) {
+ rose_cb *rose = rose_sk(s);
+
+ if (!rosecmp(&rose->source_addr, addr) &&
+ !ax25cmp(&rose->source_call, &null_ax25_address) &&
+ s->state == TCP_LISTEN) {
restore_flags(flags);
return s;
}
@@ -306,7 +319,9 @@ struct sock *rose_find_socket(unsigned int lci, struct rose_neigh *neigh)
save_flags(flags); cli();
for (s = rose_list; s != NULL; s = s->next) {
- if (s->protinfo.rose->lci == lci && s->protinfo.rose->neighbour == neigh) {
+ rose_cb *rose = rose_sk(s);
+
+ if (rose->lci == lci && rose->neighbour == neigh) {
restore_flags(flags);
return s;
}
@@ -374,7 +389,7 @@ void rose_destroy_socket(struct sock *sk) /* Not static as it's used by the time
if (skb->sk != sk) { /* A pending connection */
skb->sk->dead = 1; /* Queue the unaccepted socket for death */
rose_start_heartbeat(skb->sk);
- skb->sk->protinfo.rose->state = ROSE_STATE_0;
+ rose_sk(skb->sk)->state = ROSE_STATE_0;
}
kfree_skb(skb);
@@ -403,6 +418,7 @@ static int rose_setsockopt(struct socket *sock, int level, int optname,
char *optval, int optlen)
{
struct sock *sk = sock->sk;
+ rose_cb *rose = rose_sk(sk);
int opt;
if (level != SOL_ROSE)
@@ -416,41 +432,41 @@ static int rose_setsockopt(struct socket *sock, int level, int optname,
switch (optname) {
case ROSE_DEFER:
- sk->protinfo.rose->defer = opt ? 1 : 0;
+ rose->defer = opt ? 1 : 0;
return 0;
case ROSE_T1:
if (opt < 1)
return -EINVAL;
- sk->protinfo.rose->t1 = opt * HZ;
+ rose->t1 = opt * HZ;
return 0;
case ROSE_T2:
if (opt < 1)
return -EINVAL;
- sk->protinfo.rose->t2 = opt * HZ;
+ rose->t2 = opt * HZ;
return 0;
case ROSE_T3:
if (opt < 1)
return -EINVAL;
- sk->protinfo.rose->t3 = opt * HZ;
+ rose->t3 = opt * HZ;
return 0;
case ROSE_HOLDBACK:
if (opt < 1)
return -EINVAL;
- sk->protinfo.rose->hb = opt * HZ;
+ rose->hb = opt * HZ;
return 0;
case ROSE_IDLE:
if (opt < 0)
return -EINVAL;
- sk->protinfo.rose->idle = opt * 60 * HZ;
+ rose->idle = opt * 60 * HZ;
return 0;
case ROSE_QBITINCL:
- sk->protinfo.rose->qbitincl = opt ? 1 : 0;
+ rose->qbitincl = opt ? 1 : 0;
return 0;
default:
@@ -462,6 +478,7 @@ static int rose_getsockopt(struct socket *sock, int level, int optname,
char *optval, int *optlen)
{
struct sock *sk = sock->sk;
+ rose_cb *rose = rose_sk(sk);
int val = 0;
int len;
@@ -476,31 +493,31 @@ static int rose_getsockopt(struct socket *sock, int level, int optname,
switch (optname) {
case ROSE_DEFER:
- val = sk->protinfo.rose->defer;
+ val = rose->defer;
break;
case ROSE_T1:
- val = sk->protinfo.rose->t1 / HZ;
+ val = rose->t1 / HZ;
break;
case ROSE_T2:
- val = sk->protinfo.rose->t2 / HZ;
+ val = rose->t2 / HZ;
break;
case ROSE_T3:
- val = sk->protinfo.rose->t3 / HZ;
+ val = rose->t3 / HZ;
break;
case ROSE_HOLDBACK:
- val = sk->protinfo.rose->hb / HZ;
+ val = rose->hb / HZ;
break;
case ROSE_IDLE:
- val = sk->protinfo.rose->idle / (60 * HZ);
+ val = rose->idle / (60 * HZ);
break;
case ROSE_QBITINCL:
- val = sk->protinfo.rose->qbitincl;
+ val = rose->qbitincl;
break;
default:
@@ -520,10 +537,12 @@ static int rose_listen(struct socket *sock, int backlog)
struct sock *sk = sock->sk;
if (sk->state != TCP_LISTEN) {
- sk->protinfo.rose->dest_ndigis = 0;
- memset(&sk->protinfo.rose->dest_addr, '\0', ROSE_ADDR_LEN);
- memset(&sk->protinfo.rose->dest_call, '\0', AX25_ADDR_LEN);
- memset(sk->protinfo.rose->dest_digis, '\0', AX25_ADDR_LEN*ROSE_MAX_DIGIS);
+ rose_cb *rose = rose_sk(sk);
+
+ rose->dest_ndigis = 0;
+ memset(&rose->dest_addr, 0, ROSE_ADDR_LEN);
+ memset(&rose->dest_call, 0, AX25_ADDR_LEN);
+ memset(rose->dest_digis, 0, AX25_ADDR_LEN * ROSE_MAX_DIGIS);
sk->max_ack_backlog = backlog;
sk->state = TCP_LISTEN;
return 0;
@@ -543,7 +562,7 @@ static int rose_create(struct socket *sock, int protocol)
if ((sk = rose_alloc_sock()) == NULL)
return -ENOMEM;
- rose = sk->protinfo.rose;
+ rose = rose_sk(sk);
sock_init_data(sock, sk);
@@ -573,7 +592,7 @@ static int rose_create(struct socket *sock, int protocol)
static struct sock *rose_make_new(struct sock *osk)
{
struct sock *sk;
- rose_cb *rose;
+ rose_cb *rose, *orose;
if (osk->type != SOCK_SEQPACKET)
return NULL;
@@ -581,7 +600,7 @@ static struct sock *rose_make_new(struct sock *osk)
if ((sk = rose_alloc_sock()) == NULL)
return NULL;
- rose = sk->protinfo.rose;
+ rose = rose_sk(sk);
sock_init_data(NULL, sk);
@@ -605,15 +624,15 @@ static struct sock *rose_make_new(struct sock *osk)
init_timer(&rose->timer);
init_timer(&rose->idletimer);
- rose->t1 = osk->protinfo.rose->t1;
- rose->t2 = osk->protinfo.rose->t2;
- rose->t3 = osk->protinfo.rose->t3;
- rose->hb = osk->protinfo.rose->hb;
- rose->idle = osk->protinfo.rose->idle;
-
- rose->defer = osk->protinfo.rose->defer;
- rose->device = osk->protinfo.rose->device;
- rose->qbitincl = osk->protinfo.rose->qbitincl;
+ orose = rose_sk(osk);
+ rose->t1 = orose->t1;
+ rose->t2 = orose->t2;
+ rose->t3 = orose->t3;
+ rose->hb = orose->hb;
+ rose->idle = orose->idle;
+ rose->defer = orose->defer;
+ rose->device = orose->device;
+ rose->qbitincl = orose->qbitincl;
return sk;
}
@@ -621,10 +640,13 @@ static struct sock *rose_make_new(struct sock *osk)
static int rose_release(struct socket *sock)
{
struct sock *sk = sock->sk;
+ rose_cb *rose;
if (sk == NULL) return 0;
- switch (sk->protinfo.rose->state) {
+ rose = rose_sk(sk);
+
+ switch (rose->state) {
case ROSE_STATE_0:
rose_disconnect(sk, 0, -1, -1);
@@ -632,7 +654,7 @@ static int rose_release(struct socket *sock)
break;
case ROSE_STATE_2:
- sk->protinfo.rose->neighbour->use--;
+ rose->neighbour->use--;
rose_disconnect(sk, 0, -1, -1);
rose_destroy_socket(sk);
break;
@@ -645,12 +667,12 @@ static int rose_release(struct socket *sock)
rose_stop_idletimer(sk);
rose_write_internal(sk, ROSE_CLEAR_REQUEST);
rose_start_t3timer(sk);
- sk->protinfo.rose->state = ROSE_STATE_2;
- sk->state = TCP_CLOSE;
- sk->shutdown |= SEND_SHUTDOWN;
+ rose->state = ROSE_STATE_2;
+ sk->state = TCP_CLOSE;
+ sk->shutdown |= SEND_SHUTDOWN;
sk->state_change(sk);
- sk->dead = 1;
- sk->destroy = 1;
+ sk->dead = 1;
+ sk->destroy = 1;
break;
default:
@@ -666,6 +688,7 @@ static int rose_release(struct socket *sock)
static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sock *sk = sock->sk;
+ rose_cb *rose = rose_sk(sk);
struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr;
struct net_device *dev;
ax25_address *user, *source;
@@ -699,18 +722,18 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
user = source;
}
- sk->protinfo.rose->source_addr = addr->srose_addr;
- sk->protinfo.rose->source_call = *user;
- sk->protinfo.rose->device = dev;
- sk->protinfo.rose->source_ndigis = addr->srose_ndigis;
+ rose->source_addr = addr->srose_addr;
+ rose->source_call = *user;
+ rose->device = dev;
+ rose->source_ndigis = addr->srose_ndigis;
if (addr_len == sizeof(struct full_sockaddr_rose)) {
struct full_sockaddr_rose *full_addr = (struct full_sockaddr_rose *)uaddr;
for (n = 0 ; n < addr->srose_ndigis ; n++)
- sk->protinfo.rose->source_digis[n] = full_addr->srose_digis[n];
+ rose->source_digis[n] = full_addr->srose_digis[n];
} else {
- if (sk->protinfo.rose->source_ndigis == 1) {
- sk->protinfo.rose->source_digis[0] = addr->srose_digi;
+ if (rose->source_ndigis == 1) {
+ rose->source_digis[0] = addr->srose_digi;
}
}
@@ -724,6 +747,7 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags)
{
struct sock *sk = sock->sk;
+ rose_cb *rose = rose_sk(sk);
struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr;
unsigned char cause, diagnostic;
ax25_address *user;
@@ -759,13 +783,16 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
return -EINVAL;
/* Source + Destination digis should not exceed ROSE_MAX_DIGIS */
- if ((sk->protinfo.rose->source_ndigis + addr->srose_ndigis) > ROSE_MAX_DIGIS)
+ if ((rose->source_ndigis + addr->srose_ndigis) > ROSE_MAX_DIGIS)
return -EINVAL;
- if ((sk->protinfo.rose->neighbour = rose_get_neigh(&addr->srose_addr, &cause, &diagnostic)) == NULL)
+ rose->neighbour = rose_get_neigh(&addr->srose_addr, &cause,
+ &diagnostic);
+ if (!rose->neighbour)
return -ENETUNREACH;
- if ((sk->protinfo.rose->lci = rose_new_lci(sk->protinfo.rose->neighbour)) == 0)
+ rose->lci = rose_new_lci(rose->neighbour);
+ if (!rose->lci)
return -ENETUNREACH;
if (sk->zapped) { /* Must bind first - autobinding in this may or may not work */
@@ -777,25 +804,25 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
if ((user = ax25_findbyuid(current->euid)) == NULL)
return -EINVAL;
- memcpy(&sk->protinfo.rose->source_addr, dev->dev_addr, ROSE_ADDR_LEN);
- sk->protinfo.rose->source_call = *user;
- sk->protinfo.rose->device = dev;
+ memcpy(&rose->source_addr, dev->dev_addr, ROSE_ADDR_LEN);
+ rose->source_call = *user;
+ rose->device = dev;
rose_insert_socket(sk); /* Finish the bind */
}
- sk->protinfo.rose->dest_addr = addr->srose_addr;
- sk->protinfo.rose->dest_call = addr->srose_call;
- sk->protinfo.rose->rand = ((int)sk->protinfo.rose & 0xFFFF) + sk->protinfo.rose->lci;
- sk->protinfo.rose->dest_ndigis = addr->srose_ndigis;
+ rose->dest_addr = addr->srose_addr;
+ rose->dest_call = addr->srose_call;
+ rose->rand = ((int)rose & 0xFFFF) + rose->lci;
+ rose->dest_ndigis = addr->srose_ndigis;
if (addr_len == sizeof(struct full_sockaddr_rose)) {
struct full_sockaddr_rose *full_addr = (struct full_sockaddr_rose *)uaddr;
for (n = 0 ; n < addr->srose_ndigis ; n++)
- sk->protinfo.rose->dest_digis[n] = full_addr->srose_digis[n];
+ rose->dest_digis[n] = full_addr->srose_digis[n];
} else {
- if (sk->protinfo.rose->dest_ndigis == 1) {
- sk->protinfo.rose->dest_digis[0] = addr->srose_digi;
+ if (rose->dest_ndigis == 1) {
+ rose->dest_digis[0] = addr->srose_digi;
}
}
@@ -803,9 +830,9 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
sock->state = SS_CONNECTING;
sk->state = TCP_SYN_SENT;
- sk->protinfo.rose->state = ROSE_STATE_1;
+ rose->state = ROSE_STATE_1;
- sk->protinfo.rose->neighbour->use++;
+ rose->neighbour->use++;
rose_write_internal(sk, ROSE_CALL_REQUEST);
rose_start_heartbeat(sk);
@@ -895,24 +922,25 @@ static int rose_getname(struct socket *sock, struct sockaddr *uaddr,
{
struct full_sockaddr_rose *srose = (struct full_sockaddr_rose *)uaddr;
struct sock *sk = sock->sk;
+ rose_cb *rose = rose_sk(sk);
int n;
if (peer != 0) {
if (sk->state != TCP_ESTABLISHED)
return -ENOTCONN;
srose->srose_family = AF_ROSE;
- srose->srose_addr = sk->protinfo.rose->dest_addr;
- srose->srose_call = sk->protinfo.rose->dest_call;
- srose->srose_ndigis = sk->protinfo.rose->dest_ndigis;
- for (n = 0 ; n < sk->protinfo.rose->dest_ndigis ; n++)
- srose->srose_digis[n] = sk->protinfo.rose->dest_digis[n];
+ srose->srose_addr = rose->dest_addr;
+ srose->srose_call = rose->dest_call;
+ srose->srose_ndigis = rose->dest_ndigis;
+ for (n = 0; n < rose->dest_ndigis; n++)
+ srose->srose_digis[n] = rose->dest_digis[n];
} else {
srose->srose_family = AF_ROSE;
- srose->srose_addr = sk->protinfo.rose->source_addr;
- srose->srose_call = sk->protinfo.rose->source_call;
- srose->srose_ndigis = sk->protinfo.rose->source_ndigis;
- for (n = 0 ; n < sk->protinfo.rose->source_ndigis ; n++)
- srose->srose_digis[n] = sk->protinfo.rose->source_digis[n];
+ srose->srose_addr = rose->source_addr;
+ srose->srose_call = rose->source_call;
+ srose->srose_ndigis = rose->source_ndigis;
+ for (n = 0; n < rose->source_ndigis; n++)
+ srose->srose_digis[n] = rose->source_digis[n];
}
*uaddr_len = sizeof(struct full_sockaddr_rose);
@@ -923,6 +951,7 @@ int rose_rx_call_request(struct sk_buff *skb, struct net_device *dev, struct ros
{
struct sock *sk;
struct sock *make;
+ rose_cb *make_rose;
struct rose_facilities_struct facilities;
int n, len;
@@ -952,37 +981,38 @@ int rose_rx_call_request(struct sk_buff *skb, struct net_device *dev, struct ros
skb->sk = make;
make->state = TCP_ESTABLISHED;
+ make_rose = rose_sk(make);
- make->protinfo.rose->lci = lci;
- make->protinfo.rose->dest_addr = facilities.dest_addr;
- make->protinfo.rose->dest_call = facilities.dest_call;
- make->protinfo.rose->dest_ndigis = facilities.dest_ndigis;
+ make_rose->lci = lci;
+ make_rose->dest_addr = facilities.dest_addr;
+ make_rose->dest_call = facilities.dest_call;
+ make_rose->dest_ndigis = facilities.dest_ndigis;
for (n = 0 ; n < facilities.dest_ndigis ; n++)
- make->protinfo.rose->dest_digis[n] = facilities.dest_digis[n];
- make->protinfo.rose->source_addr = facilities.source_addr;
- make->protinfo.rose->source_call = facilities.source_call;
- make->protinfo.rose->source_ndigis = facilities.source_ndigis;
+ make_rose->dest_digis[n] = facilities.dest_digis[n];
+ make_rose->source_addr = facilities.source_addr;
+ make_rose->source_call = facilities.source_call;
+ make_rose->source_ndigis = facilities.source_ndigis;
for (n = 0 ; n < facilities.source_ndigis ; n++)
- make->protinfo.rose->source_digis[n]= facilities.source_digis[n];
- make->protinfo.rose->neighbour = neigh;
- make->protinfo.rose->device = dev;
- make->protinfo.rose->facilities = facilities;
+ make_rose->source_digis[n]= facilities.source_digis[n];
+ make_rose->neighbour = neigh;
+ make_rose->device = dev;
+ make_rose->facilities = facilities;
- make->protinfo.rose->neighbour->use++;
+ make_rose->neighbour->use++;
- if (sk->protinfo.rose->defer) {
- make->protinfo.rose->state = ROSE_STATE_5;
+ if (rose_sk(sk)->defer) {
+ make_rose->state = ROSE_STATE_5;
} else {
rose_write_internal(make, ROSE_CALL_ACCEPTED);
- make->protinfo.rose->state = ROSE_STATE_3;
+ make_rose->state = ROSE_STATE_3;
rose_start_idletimer(make);
}
- make->protinfo.rose->condition = 0x00;
- make->protinfo.rose->vs = 0;
- make->protinfo.rose->va = 0;
- make->protinfo.rose->vr = 0;
- make->protinfo.rose->vl = 0;
+ make_rose->condition = 0x00;
+ make_rose->vs = 0;
+ make_rose->va = 0;
+ make_rose->vr = 0;
+ make_rose->vl = 0;
sk->ack_backlog++;
make->pair = sk;
@@ -1002,6 +1032,7 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ rose_cb *rose = rose_sk(sk);
struct sockaddr_rose *usrose = (struct sockaddr_rose *)msg->msg_name;
int err;
struct full_sockaddr_rose srose;
@@ -1020,7 +1051,7 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, int len,
return -EPIPE;
}
- if (sk->protinfo.rose->neighbour == NULL || sk->protinfo.rose->device == NULL)
+ if (rose->neighbour == NULL || rose->device == NULL)
return -ENETUNREACH;
if (usrose != NULL) {
@@ -1028,14 +1059,15 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, int len,
return -EINVAL;
memset(&srose, 0, sizeof(struct full_sockaddr_rose));
memcpy(&srose, usrose, msg->msg_namelen);
- if (rosecmp(&sk->protinfo.rose->dest_addr, &srose.srose_addr) != 0 ||
- ax25cmp(&sk->protinfo.rose->dest_call, &srose.srose_call) != 0)
+ if (rosecmp(&rose->dest_addr, &srose.srose_addr) != 0 ||
+ ax25cmp(&rose->dest_call, &srose.srose_call) != 0)
return -EISCONN;
- if (srose.srose_ndigis != sk->protinfo.rose->dest_ndigis)
+ if (srose.srose_ndigis != rose->dest_ndigis)
return -EISCONN;
- if (srose.srose_ndigis == sk->protinfo.rose->dest_ndigis) {
+ if (srose.srose_ndigis == rose->dest_ndigis) {
for (n = 0 ; n < srose.srose_ndigis ; n++)
- if (ax25cmp(&sk->protinfo.rose->dest_digis[n], &srose.srose_digis[n]) != 0)
+ if (ax25cmp(&rose->dest_digis[n],
+ &srose.srose_digis[n]))
return -EISCONN;
}
if (srose.srose_family != AF_ROSE)
@@ -1045,11 +1077,11 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, int len,
return -ENOTCONN;
srose.srose_family = AF_ROSE;
- srose.srose_addr = sk->protinfo.rose->dest_addr;
- srose.srose_call = sk->protinfo.rose->dest_call;
- srose.srose_ndigis = sk->protinfo.rose->dest_ndigis;
- for (n = 0 ; n < sk->protinfo.rose->dest_ndigis ; n++)
- srose.srose_digis[n] = sk->protinfo.rose->dest_digis[n];
+ srose.srose_addr = rose->dest_addr;
+ srose.srose_call = rose->dest_call;
+ srose.srose_ndigis = rose->dest_ndigis;
+ for (n = 0 ; n < rose->dest_ndigis ; n++)
+ srose.srose_digis[n] = rose->dest_digis[n];
}
SOCK_DEBUG(sk, "ROSE: sendto: Addresses built.\n");
@@ -1076,7 +1108,7 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, int len,
* If the Q BIT Include socket option is in force, the first
* byte of the user data is the logical value of the Q Bit.
*/
- if (sk->protinfo.rose->qbitincl) {
+ if (rose->qbitincl) {
qbit = skb->data[0];
skb_pull(skb, 1);
}
@@ -1089,8 +1121,8 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, int len,
SOCK_DEBUG(sk, "ROSE: Building Network Header.\n");
/* Build a ROSE Network header */
- asmptr[0] = ((sk->protinfo.rose->lci >> 8) & 0x0F) | ROSE_GFI;
- asmptr[1] = (sk->protinfo.rose->lci >> 0) & 0xFF;
+ asmptr[0] = ((rose->lci >> 8) & 0x0F) | ROSE_GFI;
+ asmptr[1] = (rose->lci >> 0) & 0xFF;
asmptr[2] = ROSE_DATA;
if (qbit)
@@ -1164,6 +1196,7 @@ static int rose_recvmsg(struct socket *sock, struct msghdr *msg, int size,
int flags, struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ rose_cb *rose = rose_sk(sk);
struct sockaddr_rose *srose = (struct sockaddr_rose *)msg->msg_name;
int copied, qbit;
unsigned char *asmptr;
@@ -1185,7 +1218,7 @@ static int rose_recvmsg(struct socket *sock, struct msghdr *msg, int size,
skb_pull(skb, ROSE_MIN_LEN);
- if (sk->protinfo.rose->qbitincl) {
+ if (rose->qbitincl) {
asmptr = skb_push(skb, 1);
*asmptr = qbit;
}
@@ -1202,18 +1235,18 @@ static int rose_recvmsg(struct socket *sock, struct msghdr *msg, int size,
if (srose != NULL) {
srose->srose_family = AF_ROSE;
- srose->srose_addr = sk->protinfo.rose->dest_addr;
- srose->srose_call = sk->protinfo.rose->dest_call;
- srose->srose_ndigis = sk->protinfo.rose->dest_ndigis;
+ srose->srose_addr = rose->dest_addr;
+ srose->srose_call = rose->dest_call;
+ srose->srose_ndigis = rose->dest_ndigis;
if (msg->msg_namelen >= sizeof(struct full_sockaddr_rose)) {
struct full_sockaddr_rose *full_srose = (struct full_sockaddr_rose *)msg->msg_name;
- for (n = 0 ; n < sk->protinfo.rose->dest_ndigis ; n++)
- full_srose->srose_digis[n] = sk->protinfo.rose->dest_digis[n];
+ for (n = 0 ; n < rose->dest_ndigis ; n++)
+ full_srose->srose_digis[n] = rose->dest_digis[n];
msg->msg_namelen = sizeof(struct full_sockaddr_rose);
} else {
- if (sk->protinfo.rose->dest_ndigis >= 1) {
+ if (rose->dest_ndigis >= 1) {
srose->srose_ndigis = 1;
- srose->srose_digi = sk->protinfo.rose->dest_digis[0];
+ srose->srose_digi = rose->dest_digis[0];
}
msg->msg_namelen = sizeof(struct sockaddr_rose);
}
@@ -1228,6 +1261,7 @@ static int rose_recvmsg(struct socket *sock, struct msghdr *msg, int size,
static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
struct sock *sk = sock->sk;
+ rose_cb *rose = rose_sk(sk);
switch (cmd) {
case TIOCOUTQ: {
@@ -1275,8 +1309,8 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case SIOCRSGCAUSE: {
struct rose_cause_struct rose_cause;
- rose_cause.cause = sk->protinfo.rose->cause;
- rose_cause.diagnostic = sk->protinfo.rose->diagnostic;
+ rose_cause.cause = rose->cause;
+ rose_cause.diagnostic = rose->diagnostic;
return copy_to_user((void *)arg, &rose_cause, sizeof(struct rose_cause_struct)) ? -EFAULT : 0;
}
@@ -1284,8 +1318,8 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
struct rose_cause_struct rose_cause;
if (copy_from_user(&rose_cause, (void *)arg, sizeof(struct rose_cause_struct)))
return -EFAULT;
- sk->protinfo.rose->cause = rose_cause.cause;
- sk->protinfo.rose->diagnostic = rose_cause.diagnostic;
+ rose->cause = rose_cause.cause;
+ rose->diagnostic = rose_cause.diagnostic;
return 0;
}
@@ -1303,15 +1337,15 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
return copy_to_user((void *)arg, &rose_callsign, sizeof(ax25_address)) ? -EFAULT : 0;
case SIOCRSACCEPT:
- if (sk->protinfo.rose->state == ROSE_STATE_5) {
+ if (rose->state == ROSE_STATE_5) {
rose_write_internal(sk, ROSE_CALL_ACCEPTED);
rose_start_idletimer(sk);
- sk->protinfo.rose->condition = 0x00;
- sk->protinfo.rose->vs = 0;
- sk->protinfo.rose->va = 0;
- sk->protinfo.rose->vr = 0;
- sk->protinfo.rose->vl = 0;
- sk->protinfo.rose->state = ROSE_STATE_3;
+ rose->condition = 0x00;
+ rose->vs = 0;
+ rose->va = 0;
+ rose->vr = 0;
+ rose->vl = 0;
+ rose->state = ROSE_STATE_3;
}
return 0;
@@ -1337,37 +1371,39 @@ static int rose_get_info(char *buffer, char **start, off_t offset, int length)
len += sprintf(buffer, "dest_addr dest_call src_addr src_call dev lci neigh st vs vr va t t1 t2 t3 hb idle Snd-Q Rcv-Q inode\n");
for (s = rose_list; s != NULL; s = s->next) {
- if ((dev = s->protinfo.rose->device) == NULL)
+ rose_cb *rose = rose_sk(s);
+
+ if ((dev = rose->device) == NULL)
devname = "???";
else
devname = dev->name;
len += sprintf(buffer + len, "%-10s %-9s ",
- rose2asc(&s->protinfo.rose->dest_addr),
- ax2asc(&s->protinfo.rose->dest_call));
+ rose2asc(&rose->dest_addr),
+ ax2asc(&rose->dest_call));
- if (ax25cmp(&s->protinfo.rose->source_call, &null_ax25_address) == 0)
+ if (ax25cmp(&rose->source_call, &null_ax25_address) == 0)
callsign = "??????-?";
else
- callsign = ax2asc(&s->protinfo.rose->source_call);
+ callsign = ax2asc(&rose->source_call);
len += sprintf(buffer + len, "%-10s %-9s %-5s %3.3X %05d %d %d %d %d %3lu %3lu %3lu %3lu %3lu %3lu/%03lu %5d %5d %ld\n",
- rose2asc(&s->protinfo.rose->source_addr),
+ rose2asc(&rose->source_addr),
callsign,
devname,
- s->protinfo.rose->lci & 0x0FFF,
- (s->protinfo.rose->neighbour) ? s->protinfo.rose->neighbour->number : 0,
- s->protinfo.rose->state,
- s->protinfo.rose->vs,
- s->protinfo.rose->vr,
- s->protinfo.rose->va,
- ax25_display_timer(&s->protinfo.rose->timer) / HZ,
- s->protinfo.rose->t1 / HZ,
- s->protinfo.rose->t2 / HZ,
- s->protinfo.rose->t3 / HZ,
- s->protinfo.rose->hb / HZ,
- ax25_display_timer(&s->protinfo.rose->idletimer) / (60 * HZ),
- s->protinfo.rose->idle / (60 * HZ),
+ rose->lci & 0x0FFF,
+ (rose->neighbour) ? rose->neighbour->number : 0,
+ rose->state,
+ rose->vs,
+ rose->vr,
+ rose->va,
+ ax25_display_timer(&rose->timer) / HZ,
+ rose->t1 / HZ,
+ rose->t2 / HZ,
+ rose->t3 / HZ,
+ rose->hb / HZ,
+ ax25_display_timer(&rose->idletimer) / (60 * HZ),
+ rose->idle / (60 * HZ),
atomic_read(&s->wmem_alloc),
atomic_read(&s->rmem_alloc),
s->socket != NULL ? s->socket->inode->i_ino : 0L);
diff --git a/net/rose/rose_in.c b/net/rose/rose_in.c
index 03a0cb9b1..4c5bbb54d 100644
--- a/net/rose/rose_in.c
+++ b/net/rose/rose_in.c
@@ -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/system.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
@@ -51,17 +52,19 @@
*/
static int rose_state1_machine(struct sock *sk, struct sk_buff *skb, int frametype)
{
+ rose_cb *rose = rose_sk(sk);
+
switch (frametype) {
case ROSE_CALL_ACCEPTED:
rose_stop_timer(sk);
rose_start_idletimer(sk);
- sk->protinfo.rose->condition = 0x00;
- sk->protinfo.rose->vs = 0;
- sk->protinfo.rose->va = 0;
- sk->protinfo.rose->vr = 0;
- sk->protinfo.rose->vl = 0;
- sk->protinfo.rose->state = ROSE_STATE_3;
+ rose->condition = 0x00;
+ rose->vs = 0;
+ rose->va = 0;
+ rose->vr = 0;
+ rose->vl = 0;
+ rose->state = ROSE_STATE_3;
sk->state = TCP_ESTABLISHED;
if (!sk->dead)
sk->state_change(sk);
@@ -70,7 +73,7 @@ static int rose_state1_machine(struct sock *sk, struct sk_buff *skb, int framety
case ROSE_CLEAR_REQUEST:
rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION);
rose_disconnect(sk, ECONNREFUSED, skb->data[3], skb->data[4]);
- sk->protinfo.rose->neighbour->use--;
+ rose->neighbour->use--;
break;
default:
@@ -87,17 +90,19 @@ static int rose_state1_machine(struct sock *sk, struct sk_buff *skb, int framety
*/
static int rose_state2_machine(struct sock *sk, struct sk_buff *skb, int frametype)
{
+ rose_cb *rose = rose_sk(sk);
+
switch (frametype) {
case ROSE_CLEAR_REQUEST:
rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION);
rose_disconnect(sk, 0, skb->data[3], skb->data[4]);
- sk->protinfo.rose->neighbour->use--;
+ rose->neighbour->use--;
break;
case ROSE_CLEAR_CONFIRMATION:
rose_disconnect(sk, 0, -1, -1);
- sk->protinfo.rose->neighbour->use--;
+ rose->neighbour->use--;
break;
default:
@@ -114,6 +119,7 @@ static int rose_state2_machine(struct sock *sk, struct sk_buff *skb, int framety
*/
static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype, int ns, int nr, int q, int d, int m)
{
+ rose_cb *rose = rose_sk(sk);
int queued = 0;
switch (frametype) {
@@ -122,88 +128,88 @@ static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int framety
rose_stop_timer(sk);
rose_start_idletimer(sk);
rose_write_internal(sk, ROSE_RESET_CONFIRMATION);
- sk->protinfo.rose->condition = 0x00;
- sk->protinfo.rose->vs = 0;
- sk->protinfo.rose->vr = 0;
- sk->protinfo.rose->va = 0;
- sk->protinfo.rose->vl = 0;
+ rose->condition = 0x00;
+ rose->vs = 0;
+ rose->vr = 0;
+ rose->va = 0;
+ rose->vl = 0;
rose_requeue_frames(sk);
break;
case ROSE_CLEAR_REQUEST:
rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION);
rose_disconnect(sk, 0, skb->data[3], skb->data[4]);
- sk->protinfo.rose->neighbour->use--;
+ rose->neighbour->use--;
break;
case ROSE_RR:
case ROSE_RNR:
if (!rose_validate_nr(sk, nr)) {
rose_write_internal(sk, ROSE_RESET_REQUEST);
- sk->protinfo.rose->condition = 0x00;
- sk->protinfo.rose->vs = 0;
- sk->protinfo.rose->vr = 0;
- sk->protinfo.rose->va = 0;
- sk->protinfo.rose->vl = 0;
- sk->protinfo.rose->state = ROSE_STATE_4;
+ rose->condition = 0x00;
+ rose->vs = 0;
+ rose->vr = 0;
+ rose->va = 0;
+ rose->vl = 0;
+ rose->state = ROSE_STATE_4;
rose_start_t2timer(sk);
rose_stop_idletimer(sk);
} else {
rose_frames_acked(sk, nr);
if (frametype == ROSE_RNR) {
- sk->protinfo.rose->condition |= ROSE_COND_PEER_RX_BUSY;
+ rose->condition |= ROSE_COND_PEER_RX_BUSY;
} else {
- sk->protinfo.rose->condition &= ~ROSE_COND_PEER_RX_BUSY;
+ rose->condition &= ~ROSE_COND_PEER_RX_BUSY;
}
}
break;
case ROSE_DATA: /* XXX */
- sk->protinfo.rose->condition &= ~ROSE_COND_PEER_RX_BUSY;
+ rose->condition &= ~ROSE_COND_PEER_RX_BUSY;
if (!rose_validate_nr(sk, nr)) {
rose_write_internal(sk, ROSE_RESET_REQUEST);
- sk->protinfo.rose->condition = 0x00;
- sk->protinfo.rose->vs = 0;
- sk->protinfo.rose->vr = 0;
- sk->protinfo.rose->va = 0;
- sk->protinfo.rose->vl = 0;
- sk->protinfo.rose->state = ROSE_STATE_4;
+ rose->condition = 0x00;
+ rose->vs = 0;
+ rose->vr = 0;
+ rose->va = 0;
+ rose->vl = 0;
+ rose->state = ROSE_STATE_4;
rose_start_t2timer(sk);
rose_stop_idletimer(sk);
break;
}
rose_frames_acked(sk, nr);
- if (ns == sk->protinfo.rose->vr) {
+ if (ns == rose->vr) {
rose_start_idletimer(sk);
if (sock_queue_rcv_skb(sk, skb) == 0) {
- sk->protinfo.rose->vr = (sk->protinfo.rose->vr + 1) % ROSE_MODULUS;
+ rose->vr = (rose->vr + 1) % ROSE_MODULUS;
queued = 1;
} else {
/* Should never happen ! */
rose_write_internal(sk, ROSE_RESET_REQUEST);
- sk->protinfo.rose->condition = 0x00;
- sk->protinfo.rose->vs = 0;
- sk->protinfo.rose->vr = 0;
- sk->protinfo.rose->va = 0;
- sk->protinfo.rose->vl = 0;
- sk->protinfo.rose->state = ROSE_STATE_4;
+ rose->condition = 0x00;
+ rose->vs = 0;
+ rose->vr = 0;
+ rose->va = 0;
+ rose->vl = 0;
+ rose->state = ROSE_STATE_4;
rose_start_t2timer(sk);
rose_stop_idletimer(sk);
break;
}
if (atomic_read(&sk->rmem_alloc) > (sk->rcvbuf / 2))
- sk->protinfo.rose->condition |= ROSE_COND_OWN_RX_BUSY;
+ rose->condition |= ROSE_COND_OWN_RX_BUSY;
}
/*
* If the window is full, ack the frame, else start the
* acknowledge hold back timer.
*/
- if (((sk->protinfo.rose->vl + sysctl_rose_window_size) % ROSE_MODULUS) == sk->protinfo.rose->vr) {
- sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
+ if (((rose->vl + sysctl_rose_window_size) % ROSE_MODULUS) == rose->vr) {
+ rose->condition &= ~ROSE_COND_ACK_PENDING;
rose_stop_timer(sk);
rose_enquiry_response(sk);
} else {
- sk->protinfo.rose->condition |= ROSE_COND_ACK_PENDING;
+ rose->condition |= ROSE_COND_ACK_PENDING;
rose_start_hbtimer(sk);
}
break;
@@ -223,6 +229,8 @@ static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int framety
*/
static int rose_state4_machine(struct sock *sk, struct sk_buff *skb, int frametype)
{
+ rose_cb *rose = rose_sk(sk);
+
switch (frametype) {
case ROSE_RESET_REQUEST:
@@ -230,19 +238,19 @@ static int rose_state4_machine(struct sock *sk, struct sk_buff *skb, int framety
case ROSE_RESET_CONFIRMATION:
rose_stop_timer(sk);
rose_start_idletimer(sk);
- sk->protinfo.rose->condition = 0x00;
- sk->protinfo.rose->va = 0;
- sk->protinfo.rose->vr = 0;
- sk->protinfo.rose->vs = 0;
- sk->protinfo.rose->vl = 0;
- sk->protinfo.rose->state = ROSE_STATE_3;
+ rose->condition = 0x00;
+ rose->va = 0;
+ rose->vr = 0;
+ rose->vs = 0;
+ rose->vl = 0;
+ rose->state = ROSE_STATE_3;
rose_requeue_frames(sk);
break;
case ROSE_CLEAR_REQUEST:
rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION);
rose_disconnect(sk, 0, skb->data[3], skb->data[4]);
- sk->protinfo.rose->neighbour->use--;
+ rose->neighbour->use--;
break;
default:
@@ -262,7 +270,7 @@ static int rose_state5_machine(struct sock *sk, struct sk_buff *skb, int framety
if (frametype == ROSE_CLEAR_REQUEST) {
rose_write_internal(sk, ROSE_CLEAR_CONFIRMATION);
rose_disconnect(sk, 0, skb->data[3], skb->data[4]);
- sk->protinfo.rose->neighbour->use--;
+ rose_sk(sk)->neighbour->use--;
}
return 0;
@@ -271,14 +279,15 @@ static int rose_state5_machine(struct sock *sk, struct sk_buff *skb, int framety
/* Higher level upcall for a LAPB frame */
int rose_process_rx_frame(struct sock *sk, struct sk_buff *skb)
{
+ rose_cb *rose = rose_sk(sk);
int queued = 0, frametype, ns, nr, q, d, m;
- if (sk->protinfo.rose->state == ROSE_STATE_0)
+ if (rose->state == ROSE_STATE_0)
return 0;
frametype = rose_decode(skb, &ns, &nr, &q, &d, &m);
- switch (sk->protinfo.rose->state) {
+ switch (rose->state) {
case ROSE_STATE_1:
queued = rose_state1_machine(sk, skb, frametype);
break;
diff --git a/net/rose/rose_out.c b/net/rose/rose_out.c
index c91e96d5c..5f7f78852 100644
--- a/net/rose/rose_out.c
+++ b/net/rose/rose_out.c
@@ -42,38 +42,41 @@
*/
static void rose_send_iframe(struct sock *sk, struct sk_buff *skb)
{
+ rose_cb *rose = rose_sk(sk);
+
if (skb == NULL)
return;
- skb->data[2] |= (sk->protinfo.rose->vr << 5) & 0xE0;
- skb->data[2] |= (sk->protinfo.rose->vs << 1) & 0x0E;
+ skb->data[2] |= (rose->vr << 5) & 0xE0;
+ skb->data[2] |= (rose->vs << 1) & 0x0E;
rose_start_idletimer(sk);
- rose_transmit_link(skb, sk->protinfo.rose->neighbour);
+ rose_transmit_link(skb, rose->neighbour);
}
void rose_kick(struct sock *sk)
{
+ rose_cb *rose = rose_sk(sk);
struct sk_buff *skb, *skbn;
unsigned short start, end;
- if (sk->protinfo.rose->state != ROSE_STATE_3)
+ if (rose->state != ROSE_STATE_3)
return;
- if (sk->protinfo.rose->condition & ROSE_COND_PEER_RX_BUSY)
+ if (rose->condition & ROSE_COND_PEER_RX_BUSY)
return;
if (skb_peek(&sk->write_queue) == NULL)
return;
- start = (skb_peek(&sk->protinfo.rose->ack_queue) == NULL) ? sk->protinfo.rose->va : sk->protinfo.rose->vs;
- end = (sk->protinfo.rose->va + sysctl_rose_window_size) % ROSE_MODULUS;
+ start = (skb_peek(&rose->ack_queue) == NULL) ? rose->va : rose->vs;
+ end = (rose->va + sysctl_rose_window_size) % ROSE_MODULUS;
if (start == end)
return;
- sk->protinfo.rose->vs = start;
+ rose->vs = start;
/*
* Transmit data until either we're out of data to send or
@@ -95,17 +98,17 @@ void rose_kick(struct sock *sk)
*/
rose_send_iframe(sk, skbn);
- sk->protinfo.rose->vs = (sk->protinfo.rose->vs + 1) % ROSE_MODULUS;
+ rose->vs = (rose->vs + 1) % ROSE_MODULUS;
/*
* Requeue the original data frame.
*/
- skb_queue_tail(&sk->protinfo.rose->ack_queue, skb);
+ skb_queue_tail(&rose->ack_queue, skb);
- } while (sk->protinfo.rose->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL);
+ } while (rose->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL);
- sk->protinfo.rose->vl = sk->protinfo.rose->vr;
- sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
+ rose->vl = rose->vr;
+ rose->condition &= ~ROSE_COND_ACK_PENDING;
rose_stop_timer(sk);
}
@@ -117,13 +120,15 @@ void rose_kick(struct sock *sk)
void rose_enquiry_response(struct sock *sk)
{
- if (sk->protinfo.rose->condition & ROSE_COND_OWN_RX_BUSY)
+ rose_cb *rose = rose_sk(sk);
+
+ if (rose->condition & ROSE_COND_OWN_RX_BUSY)
rose_write_internal(sk, ROSE_RNR);
else
rose_write_internal(sk, ROSE_RR);
- sk->protinfo.rose->vl = sk->protinfo.rose->vr;
- sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
+ rose->vl = rose->vr;
+ rose->condition &= ~ROSE_COND_ACK_PENDING;
rose_stop_timer(sk);
}
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 67eef2cdf..e004ea29a 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -36,6 +36,7 @@
#include <linux/if_arp.h>
#include <linux/skbuff.h>
#include <net/sock.h>
+#include <net/tcp.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <linux/fcntl.h>
@@ -809,20 +810,21 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
*/
if ((sk = rose_find_socket(lci, rose_neigh)) != NULL) {
if (frametype == ROSE_CALL_REQUEST) {
+ rose_cb *rose = rose_sk(sk);
/* Remove an existing unused socket */
rose_clear_queues(sk);
- sk->protinfo.rose->cause = ROSE_NETWORK_CONGESTION;
- sk->protinfo.rose->diagnostic = 0;
- sk->protinfo.rose->neighbour->use--;
- sk->protinfo.rose->neighbour = NULL;
- sk->protinfo.rose->lci = 0;
- sk->protinfo.rose->state = ROSE_STATE_0;
- sk->state = TCP_CLOSE;
- sk->err = 0;
- sk->shutdown |= SEND_SHUTDOWN;
+ rose->cause = ROSE_NETWORK_CONGESTION;
+ rose->diagnostic = 0;
+ rose->neighbour->use--;
+ rose->neighbour = NULL;
+ rose->lci = 0;
+ rose->state = ROSE_STATE_0;
+ sk->state = TCP_CLOSE;
+ sk->err = 0;
+ sk->shutdown |= SEND_SHUTDOWN;
if (!sk->dead)
sk->state_change(sk);
- sk->dead = 1;
+ sk->dead = 1;
}
else {
skb->h.raw = skb->data;
diff --git a/net/rose/rose_subr.c b/net/rose/rose_subr.c
index e38b4dd46..08b21f2fa 100644
--- a/net/rose/rose_subr.c
+++ b/net/rose/rose_subr.c
@@ -30,6 +30,7 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
+#include <net/tcp.h>
#include <asm/system.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
@@ -42,7 +43,7 @@
void rose_clear_queues(struct sock *sk)
{
skb_queue_purge(&sk->write_queue);
- skb_queue_purge(&sk->protinfo.rose->ack_queue);
+ skb_queue_purge(&rose_sk(sk)->ack_queue);
}
/*
@@ -53,15 +54,16 @@ void rose_clear_queues(struct sock *sk)
void rose_frames_acked(struct sock *sk, unsigned short nr)
{
struct sk_buff *skb;
+ rose_cb *rose = rose_sk(sk);
/*
* Remove all the ack-ed frames from the ack queue.
*/
- if (sk->protinfo.rose->va != nr) {
- while (skb_peek(&sk->protinfo.rose->ack_queue) != NULL && sk->protinfo.rose->va != nr) {
- skb = skb_dequeue(&sk->protinfo.rose->ack_queue);
+ if (rose->va != nr) {
+ while (skb_peek(&rose->ack_queue) != NULL && rose->va != nr) {
+ skb = skb_dequeue(&rose->ack_queue);
kfree_skb(skb);
- sk->protinfo.rose->va = (sk->protinfo.rose->va + 1) % ROSE_MODULUS;
+ rose->va = (rose->va + 1) % ROSE_MODULUS;
}
}
}
@@ -75,7 +77,7 @@ void rose_requeue_frames(struct sock *sk)
* up by rose_kick. This arrangement handles the possibility of an
* empty output queue.
*/
- while ((skb = skb_dequeue(&sk->protinfo.rose->ack_queue)) != NULL) {
+ while ((skb = skb_dequeue(&rose_sk(sk)->ack_queue)) != NULL) {
if (skb_prev == NULL)
skb_queue_head(&sk->write_queue, skb);
else
@@ -90,16 +92,15 @@ void rose_requeue_frames(struct sock *sk)
*/
int rose_validate_nr(struct sock *sk, unsigned short nr)
{
- unsigned short vc = sk->protinfo.rose->va;
+ rose_cb *rose = rose_sk(sk);
+ unsigned short vc = rose->va;
- while (vc != sk->protinfo.rose->vs) {
+ while (vc != rose->vs) {
if (nr == vc) return 1;
vc = (vc + 1) % ROSE_MODULUS;
}
- if (nr == sk->protinfo.rose->vs) return 1;
-
- return 0;
+ return nr == rose->vs;
}
/*
@@ -108,6 +109,7 @@ int rose_validate_nr(struct sock *sk, unsigned short nr)
*/
void rose_write_internal(struct sock *sk, int frametype)
{
+ rose_cb *rose = rose_sk(sk);
struct sk_buff *skb;
unsigned char *dptr;
unsigned char lci1, lci2;
@@ -119,7 +121,7 @@ void rose_write_internal(struct sock *sk, int frametype)
switch (frametype) {
case ROSE_CALL_REQUEST:
len += 1 + ROSE_ADDR_LEN + ROSE_ADDR_LEN;
- faclen = rose_create_facilities(buffer, sk->protinfo.rose);
+ faclen = rose_create_facilities(buffer, rose);
len += faclen;
break;
case ROSE_CALL_ACCEPTED:
@@ -139,8 +141,8 @@ void rose_write_internal(struct sock *sk, int frametype)
dptr = skb_put(skb, skb_tailroom(skb));
- lci1 = (sk->protinfo.rose->lci >> 8) & 0x0F;
- lci2 = (sk->protinfo.rose->lci >> 0) & 0xFF;
+ lci1 = (rose->lci >> 8) & 0x0F;
+ lci2 = (rose->lci >> 0) & 0xFF;
switch (frametype) {
@@ -149,9 +151,9 @@ void rose_write_internal(struct sock *sk, int frametype)
*dptr++ = lci2;
*dptr++ = frametype;
*dptr++ = 0xAA;
- memcpy(dptr, &sk->protinfo.rose->dest_addr, ROSE_ADDR_LEN);
+ memcpy(dptr, &rose->dest_addr, ROSE_ADDR_LEN);
dptr += ROSE_ADDR_LEN;
- memcpy(dptr, &sk->protinfo.rose->source_addr, ROSE_ADDR_LEN);
+ memcpy(dptr, &rose->source_addr, ROSE_ADDR_LEN);
dptr += ROSE_ADDR_LEN;
memcpy(dptr, buffer, faclen);
dptr += faclen;
@@ -169,8 +171,8 @@ void rose_write_internal(struct sock *sk, int frametype)
*dptr++ = ROSE_GFI | lci1;
*dptr++ = lci2;
*dptr++ = frametype;
- *dptr++ = sk->protinfo.rose->cause;
- *dptr++ = sk->protinfo.rose->diagnostic;
+ *dptr++ = rose->cause;
+ *dptr++ = rose->diagnostic;
break;
case ROSE_RESET_REQUEST:
@@ -186,7 +188,7 @@ void rose_write_internal(struct sock *sk, int frametype)
*dptr++ = ROSE_GFI | lci1;
*dptr++ = lci2;
*dptr = frametype;
- *dptr++ |= (sk->protinfo.rose->vr << 5) & 0xE0;
+ *dptr++ |= (rose->vr << 5) & 0xE0;
break;
case ROSE_CLEAR_CONFIRMATION:
@@ -202,7 +204,7 @@ void rose_write_internal(struct sock *sk, int frametype)
return;
}
- rose_transmit_link(skb, sk->protinfo.rose->neighbour);
+ rose_transmit_link(skb, rose->neighbour);
}
int rose_decode(struct sk_buff *skb, int *ns, int *nr, int *q, int *d, int *m)
@@ -497,19 +499,21 @@ int rose_create_facilities(unsigned char *buffer, rose_cb *rose)
void rose_disconnect(struct sock *sk, int reason, int cause, int diagnostic)
{
+ rose_cb *rose = rose_sk(sk);
+
rose_stop_timer(sk);
rose_stop_idletimer(sk);
rose_clear_queues(sk);
- sk->protinfo.rose->lci = 0;
- sk->protinfo.rose->state = ROSE_STATE_0;
+ rose->lci = 0;
+ rose->state = ROSE_STATE_0;
if (cause != -1)
- sk->protinfo.rose->cause = cause;
+ rose->cause = cause;
if (diagnostic != -1)
- sk->protinfo.rose->diagnostic = diagnostic;
+ rose->diagnostic = diagnostic;
sk->state = TCP_CLOSE;
sk->err = reason;
diff --git a/net/rose/rose_timer.c b/net/rose/rose_timer.c
index 7eeb43897..3de5e475b 100644
--- a/net/rose/rose_timer.c
+++ b/net/rose/rose_timer.c
@@ -30,6 +30,7 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
+#include <net/tcp.h>
#include <asm/system.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
@@ -53,58 +54,68 @@ void rose_start_heartbeat(struct sock *sk)
void rose_start_t1timer(struct sock *sk)
{
- del_timer(&sk->protinfo.rose->timer);
+ rose_cb *rose = rose_sk(sk);
- sk->protinfo.rose->timer.data = (unsigned long)sk;
- sk->protinfo.rose->timer.function = &rose_timer_expiry;
- sk->protinfo.rose->timer.expires = jiffies + sk->protinfo.rose->t1;
+ del_timer(&rose->timer);
- add_timer(&sk->protinfo.rose->timer);
+ rose->timer.data = (unsigned long)sk;
+ rose->timer.function = &rose_timer_expiry;
+ rose->timer.expires = jiffies + rose->t1;
+
+ add_timer(&rose->timer);
}
void rose_start_t2timer(struct sock *sk)
{
- del_timer(&sk->protinfo.rose->timer);
+ rose_cb *rose = rose_sk(sk);
+
+ del_timer(&rose->timer);
- sk->protinfo.rose->timer.data = (unsigned long)sk;
- sk->protinfo.rose->timer.function = &rose_timer_expiry;
- sk->protinfo.rose->timer.expires = jiffies + sk->protinfo.rose->t2;
+ rose->timer.data = (unsigned long)sk;
+ rose->timer.function = &rose_timer_expiry;
+ rose->timer.expires = jiffies + rose->t2;
- add_timer(&sk->protinfo.rose->timer);
+ add_timer(&rose->timer);
}
void rose_start_t3timer(struct sock *sk)
{
- del_timer(&sk->protinfo.rose->timer);
+ rose_cb *rose = rose_sk(sk);
+
+ del_timer(&rose->timer);
- sk->protinfo.rose->timer.data = (unsigned long)sk;
- sk->protinfo.rose->timer.function = &rose_timer_expiry;
- sk->protinfo.rose->timer.expires = jiffies + sk->protinfo.rose->t3;
+ rose->timer.data = (unsigned long)sk;
+ rose->timer.function = &rose_timer_expiry;
+ rose->timer.expires = jiffies + rose->t3;
- add_timer(&sk->protinfo.rose->timer);
+ add_timer(&rose->timer);
}
void rose_start_hbtimer(struct sock *sk)
{
- del_timer(&sk->protinfo.rose->timer);
+ rose_cb *rose = rose_sk(sk);
- sk->protinfo.rose->timer.data = (unsigned long)sk;
- sk->protinfo.rose->timer.function = &rose_timer_expiry;
- sk->protinfo.rose->timer.expires = jiffies + sk->protinfo.rose->hb;
+ del_timer(&rose->timer);
- add_timer(&sk->protinfo.rose->timer);
+ rose->timer.data = (unsigned long)sk;
+ rose->timer.function = &rose_timer_expiry;
+ rose->timer.expires = jiffies + rose->hb;
+
+ add_timer(&rose->timer);
}
void rose_start_idletimer(struct sock *sk)
{
- del_timer(&sk->protinfo.rose->idletimer);
+ rose_cb *rose = rose_sk(sk);
+
+ del_timer(&rose->idletimer);
- if (sk->protinfo.rose->idle > 0) {
- sk->protinfo.rose->idletimer.data = (unsigned long)sk;
- sk->protinfo.rose->idletimer.function = &rose_idletimer_expiry;
- sk->protinfo.rose->idletimer.expires = jiffies + sk->protinfo.rose->idle;
+ if (rose->idle > 0) {
+ rose->idletimer.data = (unsigned long)sk;
+ rose->idletimer.function = &rose_idletimer_expiry;
+ rose->idletimer.expires = jiffies + rose->idle;
- add_timer(&sk->protinfo.rose->idletimer);
+ add_timer(&rose->idletimer);
}
}
@@ -115,19 +126,20 @@ void rose_stop_heartbeat(struct sock *sk)
void rose_stop_timer(struct sock *sk)
{
- del_timer(&sk->protinfo.rose->timer);
+ del_timer(&rose_sk(sk)->timer);
}
void rose_stop_idletimer(struct sock *sk)
{
- del_timer(&sk->protinfo.rose->idletimer);
+ del_timer(&rose_sk(sk)->idletimer);
}
static void rose_heartbeat_expiry(unsigned long param)
{
struct sock *sk = (struct sock *)param;
+ rose_cb *rose = rose_sk(sk);
- switch (sk->protinfo.rose->state) {
+ switch (rose->state) {
case ROSE_STATE_0:
/* Magic here: If we listen() and a new link dies before it
@@ -143,10 +155,10 @@ static void rose_heartbeat_expiry(unsigned long param)
* Check for the state of the receive buffer.
*/
if (atomic_read(&sk->rmem_alloc) < (sk->rcvbuf / 2) &&
- (sk->protinfo.rose->condition & ROSE_COND_OWN_RX_BUSY)) {
- sk->protinfo.rose->condition &= ~ROSE_COND_OWN_RX_BUSY;
- sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
- sk->protinfo.rose->vl = sk->protinfo.rose->vr;
+ (rose->condition & ROSE_COND_OWN_RX_BUSY)) {
+ rose->condition &= ~ROSE_COND_OWN_RX_BUSY;
+ rose->condition &= ~ROSE_COND_ACK_PENDING;
+ rose->vl = rose->vr;
rose_write_internal(sk, ROSE_RR);
rose_stop_timer(sk); /* HB */
break;
@@ -160,24 +172,25 @@ static void rose_heartbeat_expiry(unsigned long param)
static void rose_timer_expiry(unsigned long param)
{
struct sock *sk = (struct sock *)param;
+ rose_cb *rose = rose_sk(sk);
- switch (sk->protinfo.rose->state) {
+ switch (rose->state) {
case ROSE_STATE_1: /* T1 */
case ROSE_STATE_4: /* T2 */
rose_write_internal(sk, ROSE_CLEAR_REQUEST);
- sk->protinfo.rose->state = ROSE_STATE_2;
+ rose->state = ROSE_STATE_2;
rose_start_t3timer(sk);
break;
case ROSE_STATE_2: /* T3 */
- sk->protinfo.rose->neighbour->use--;
+ rose->neighbour->use--;
rose_disconnect(sk, ETIMEDOUT, -1, -1);
break;
case ROSE_STATE_3: /* HB */
- if (sk->protinfo.rose->condition & ROSE_COND_ACK_PENDING) {
- sk->protinfo.rose->condition &= ~ROSE_COND_ACK_PENDING;
+ if (rose->condition & ROSE_COND_ACK_PENDING) {
+ rose->condition &= ~ROSE_COND_ACK_PENDING;
rose_enquiry_response(sk);
}
break;
@@ -191,7 +204,7 @@ static void rose_idletimer_expiry(unsigned long param)
rose_clear_queues(sk);
rose_write_internal(sk, ROSE_CLEAR_REQUEST);
- sk->protinfo.rose->state = ROSE_STATE_2;
+ rose_sk(sk)->state = ROSE_STATE_2;
rose_start_t3timer(sk);
diff --git a/net/socket.c b/net/socket.c
index 0be746b10..d5a92b558 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -131,7 +131,7 @@ static struct file_operations socket_file_ops = {
* The protocol list. Each protocol is registered in here.
*/
-static struct net_proto_family *net_families[NPROTO];
+struct net_proto_family *net_families[NPROTO];
#ifdef CONFIG_SMP
static atomic_t net_family_lockct = ATOMIC_INIT(0);
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index aaf8660da..3aabbbf08 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -26,6 +26,7 @@
#include <linux/in.h>
#include <linux/inet.h>
#include <linux/udp.h>
+#include <linux/tcp.h>
#include <linux/version.h>
#include <linux/unistd.h>
#include <linux/slab.h>
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 18ddb790d..fb70c6c76 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -56,6 +56,7 @@
#include <linux/net.h>
#include <linux/mm.h>
#include <linux/udp.h>
+#include <linux/tcp.h>
#include <linux/unistd.h>
#include <linux/sunrpc/clnt.h>
#include <linux/file.h>
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 8c690dcb7..31c967d19 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -8,7 +8,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Version: $Id: af_unix.c,v 1.131 2002-01-14 07:08:27 davem Exp $
+ * Version: $Id: af_unix.c,v 1.132 2002-02-01 22:01:05 davem Exp $
*
* Fixes:
* Linus Torvalds : Assorted bug cures.
@@ -109,18 +109,19 @@
#include <linux/poll.h>
#include <linux/smp_lock.h>
#include <linux/rtnetlink.h>
-
-#include <asm/checksum.h>
+#include <net/checksum.h>
int sysctl_unix_max_dgram_qlen = 10;
+kmem_cache_t *unix_sk_cachep;
+
unix_socket *unix_socket_table[UNIX_HASH_SIZE+1];
rwlock_t unix_table_lock = RW_LOCK_UNLOCKED;
static atomic_t unix_nr_socks = ATOMIC_INIT(0);
#define unix_sockets_unbound (unix_socket_table[UNIX_HASH_SIZE])
-#define UNIX_ABSTRACT(sk) ((sk)->protinfo.af_unix.addr->hash!=UNIX_HASH_SIZE)
+#define UNIX_ABSTRACT(sk) (unix_sk(sk)->addr->hash != UNIX_HASH_SIZE)
/*
* SMP locking strategy:
@@ -201,7 +202,9 @@ static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp)
static void __unix_remove_socket(unix_socket *sk)
{
- unix_socket **list = sk->protinfo.af_unix.list;
+ struct unix_sock *u = unix_sk(sk);
+ unix_socket **list = u->list;
+
if (list) {
if (sk->next)
sk->next->prev = sk->prev;
@@ -209,7 +212,7 @@ static void __unix_remove_socket(unix_socket *sk)
sk->prev->next = sk->next;
if (*list == sk)
*list = sk->next;
- sk->protinfo.af_unix.list = NULL;
+ u->list = NULL;
sk->prev = NULL;
sk->next = NULL;
__sock_put(sk);
@@ -218,9 +221,10 @@ static void __unix_remove_socket(unix_socket *sk)
static void __unix_insert_socket(unix_socket **list, unix_socket *sk)
{
- BUG_TRAP(sk->protinfo.af_unix.list==NULL);
+ struct unix_sock *u = unix_sk(sk);
+ BUG_TRAP(!u->list);
- sk->protinfo.af_unix.list = list;
+ u->list = list;
sk->prev = NULL;
sk->next = *list;
if (*list)
@@ -249,11 +253,13 @@ static unix_socket *__unix_find_socket_byname(struct sockaddr_un *sunname,
unix_socket *s;
for (s=unix_socket_table[hash^type]; s; s=s->next) {
- if(s->protinfo.af_unix.addr->len==len &&
- memcmp(s->protinfo.af_unix.addr->name, sunname, len) == 0)
- return s;
+ struct unix_sock *u = unix_sk(s);
+
+ if (u->addr->len == len &&
+ !memcmp(u->addr->name, sunname, len))
+ break;
}
- return NULL;
+ return s;
}
static inline unix_socket *
@@ -277,7 +283,7 @@ static unix_socket *unix_find_socket_byinode(struct inode *i)
read_lock(&unix_table_lock);
for (s=unix_socket_table[i->i_ino & (UNIX_HASH_SIZE-1)]; s; s=s->next)
{
- struct dentry *dentry = s->protinfo.af_unix.dentry;
+ struct dentry *dentry = unix_sk(s)->dentry;
if(dentry && dentry->d_inode == i)
{
@@ -313,7 +319,7 @@ static void unix_dgram_disconnected(struct sock *sk, struct sock *other)
{
if (skb_queue_len(&sk->receive_queue)) {
skb_queue_purge(&sk->receive_queue);
- wake_up_interruptible_all(&sk->protinfo.af_unix.peer_wait);
+ wake_up_interruptible_all(&unix_sk(sk)->peer_wait);
/* If one link of bidirectional dgram pipe is disconnected,
* we signal error. Messages are lost. Do not make this,
@@ -328,18 +334,20 @@ static void unix_dgram_disconnected(struct sock *sk, struct sock *other)
static void unix_sock_destructor(struct sock *sk)
{
+ struct unix_sock *u = unix_sk(sk);
+
skb_queue_purge(&sk->receive_queue);
BUG_TRAP(atomic_read(&sk->wmem_alloc) == 0);
- BUG_TRAP(sk->protinfo.af_unix.list==NULL);
+ BUG_TRAP(!u->list);
BUG_TRAP(sk->socket==NULL);
if (sk->dead==0) {
printk("Attempt to release alive unix socket: %p\n", sk);
return;
}
- if (sk->protinfo.af_unix.addr)
- unix_release_addr(sk->protinfo.af_unix.addr);
+ if (u->addr)
+ unix_release_addr(u->addr);
atomic_dec(&unix_nr_socks);
#ifdef UNIX_REFCNT_DEBUG
@@ -350,6 +358,7 @@ static void unix_sock_destructor(struct sock *sk)
static int unix_release_sock (unix_socket *sk, int embrion)
{
+ struct unix_sock *u = unix_sk(sk);
struct dentry *dentry;
struct vfsmount *mnt;
unix_socket *skpair;
@@ -362,15 +371,15 @@ static int unix_release_sock (unix_socket *sk, int embrion)
unix_state_wlock(sk);
sock_orphan(sk);
sk->shutdown = SHUTDOWN_MASK;
- dentry = sk->protinfo.af_unix.dentry;
- sk->protinfo.af_unix.dentry=NULL;
- mnt = sk->protinfo.af_unix.mnt;
- sk->protinfo.af_unix.mnt=NULL;
+ dentry = u->dentry;
+ u->dentry = NULL;
+ mnt = u->mnt;
+ u->mnt = NULL;
state = sk->state;
sk->state = TCP_CLOSE;
unix_state_wunlock(sk);
- wake_up_interruptible_all(&sk->protinfo.af_unix.peer_wait);
+ wake_up_interruptible_all(&u->peer_wait);
skpair=unix_peer(sk);
@@ -430,18 +439,19 @@ static int unix_listen(struct socket *sock, int backlog)
{
int err;
struct sock *sk = sock->sk;
+ struct unix_sock *u = unix_sk(sk);
err = -EOPNOTSUPP;
if (sock->type!=SOCK_STREAM)
goto out; /* Only stream sockets accept */
err = -EINVAL;
- if (!sk->protinfo.af_unix.addr)
+ if (!u->addr)
goto out; /* No listens on an unbound socket */
unix_state_wlock(sk);
if (sk->state != TCP_CLOSE && sk->state != TCP_LISTEN)
goto out_unlock;
if (backlog > sk->max_ack_backlog)
- wake_up_interruptible_all(&sk->protinfo.af_unix.peer_wait);
+ wake_up_interruptible_all(&u->peer_wait);
sk->max_ack_backlog=backlog;
sk->state=TCP_LISTEN;
/* set credentials so connect can copy them */
@@ -462,12 +472,14 @@ extern struct proto_ops unix_dgram_ops;
static struct sock * unix_create1(struct socket *sock)
{
struct sock *sk;
+ struct unix_sock *u;
if (atomic_read(&unix_nr_socks) >= 2*files_stat.max_files)
return NULL;
MOD_INC_USE_COUNT;
- sk = sk_alloc(PF_UNIX, GFP_KERNEL, 1);
+ sk = sk_alloc(PF_UNIX, GFP_KERNEL, sizeof(struct unix_sock),
+ unix_sk_cachep);
if (!sk) {
MOD_DEC_USE_COUNT;
return NULL;
@@ -481,13 +493,14 @@ static struct sock * unix_create1(struct socket *sock)
sk->max_ack_backlog = sysctl_unix_max_dgram_qlen;
sk->destruct = unix_sock_destructor;
- sk->protinfo.af_unix.dentry=NULL;
- sk->protinfo.af_unix.mnt=NULL;
- sk->protinfo.af_unix.lock = RW_LOCK_UNLOCKED;
- atomic_set(&sk->protinfo.af_unix.inflight, sock ? 0 : -1);
- init_MUTEX(&sk->protinfo.af_unix.readsem);/* single task reading lock */
- init_waitqueue_head(&sk->protinfo.af_unix.peer_wait);
- sk->protinfo.af_unix.list=NULL;
+ u = unix_sk(sk);
+ u->dentry = NULL;
+ u->mnt = NULL;
+ u->list = NULL;
+ rwlock_init(&u->lock);
+ atomic_set(&u->inflight, sock ? 0 : -1);
+ init_MUTEX(&u->readsem); /* single task reading lock */
+ init_waitqueue_head(&u->peer_wait);
unix_insert_socket(&unix_sockets_unbound, sk);
return sk;
@@ -535,14 +548,15 @@ static int unix_release(struct socket *sock)
static int unix_autobind(struct socket *sock)
{
struct sock *sk = sock->sk;
+ struct unix_sock *u = unix_sk(sk);
static u32 ordernum = 1;
struct unix_address * addr;
int err;
- down(&sk->protinfo.af_unix.readsem);
+ down(&u->readsem);
err = 0;
- if (sk->protinfo.af_unix.addr)
+ if (u->addr)
goto out;
err = -ENOMEM;
@@ -572,13 +586,12 @@ retry:
addr->hash ^= sk->type;
__unix_remove_socket(sk);
- sk->protinfo.af_unix.addr = addr;
+ u->addr = addr;
__unix_insert_socket(&unix_socket_table[addr->hash], sk);
write_unlock(&unix_table_lock);
err = 0;
-out:
- up(&sk->protinfo.af_unix.readsem);
+out: up(&u->readsem);
return err;
}
@@ -632,6 +645,7 @@ fail:
static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sock *sk = sock->sk;
+ struct unix_sock *u = unix_sk(sk);
struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr;
struct dentry * dentry = NULL;
struct nameidata nd;
@@ -654,10 +668,10 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
goto out;
addr_len = err;
- down(&sk->protinfo.af_unix.readsem);
+ down(&u->readsem);
err = -EINVAL;
- if (sk->protinfo.af_unix.addr)
+ if (u->addr)
goto out_up;
err = -ENOMEM;
@@ -735,19 +749,19 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
list = &unix_socket_table[addr->hash];
} else {
list = &unix_socket_table[dentry->d_inode->i_ino & (UNIX_HASH_SIZE-1)];
- sk->protinfo.af_unix.dentry = nd.dentry;
- sk->protinfo.af_unix.mnt = nd.mnt;
+ u->dentry = nd.dentry;
+ u->mnt = nd.mnt;
}
err = 0;
__unix_remove_socket(sk);
- sk->protinfo.af_unix.addr = addr;
+ u->addr = addr;
__unix_insert_socket(list, sk);
out_unlock:
write_unlock(&unix_table_lock);
out_up:
- up(&sk->protinfo.af_unix.readsem);
+ up(&u->readsem);
out:
return err;
@@ -779,7 +793,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
goto out;
alen = err;
- if (sock->passcred && !sk->protinfo.af_unix.addr &&
+ if (sock->passcred && !unix_sk(sk)->addr &&
(err = unix_autobind(sock)) != 0)
goto out;
@@ -826,11 +840,12 @@ out:
static long unix_wait_for_peer(unix_socket *other, long timeo)
{
+ struct unix_sock *u = unix_sk(other);
int sched;
DECLARE_WAITQUEUE(wait, current);
__set_current_state(TASK_INTERRUPTIBLE);
- add_wait_queue_exclusive(&other->protinfo.af_unix.peer_wait, &wait);
+ add_wait_queue_exclusive(&u->peer_wait, &wait);
sched = (!other->dead &&
!(other->shutdown&RCV_SHUTDOWN) &&
@@ -842,7 +857,7 @@ static long unix_wait_for_peer(unix_socket *other, long timeo)
timeo = schedule_timeout(timeo);
__set_current_state(TASK_RUNNING);
- remove_wait_queue(&other->protinfo.af_unix.peer_wait, &wait);
+ remove_wait_queue(&u->peer_wait, &wait);
return timeo;
}
@@ -851,6 +866,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
{
struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr;
struct sock *sk = sock->sk;
+ struct unix_sock *u = unix_sk(sk), *newu, *otheru;
struct sock *newsk = NULL;
unix_socket *other = NULL;
struct sk_buff *skb = NULL;
@@ -864,8 +880,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
goto out;
addr_len = err;
- if (sock->passcred && !sk->protinfo.af_unix.addr &&
- (err = unix_autobind(sock)) != 0)
+ if (sock->passcred && !u->addr && (err = unix_autobind(sock)) != 0)
goto out;
timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
@@ -965,17 +980,18 @@ restart:
newsk->peercred.pid = current->pid;
newsk->peercred.uid = current->euid;
newsk->peercred.gid = current->egid;
- newsk->sleep = &newsk->protinfo.af_unix.peer_wait;
+ newu = unix_sk(newsk);
+ newsk->sleep = &newu->peer_wait;
+ otheru = unix_sk(other);
/* copy address information from listening to new sock*/
- if (other->protinfo.af_unix.addr)
- {
- atomic_inc(&other->protinfo.af_unix.addr->refcnt);
- newsk->protinfo.af_unix.addr=other->protinfo.af_unix.addr;
+ if (otheru->addr) {
+ atomic_inc(&otheru->addr->refcnt);
+ newu->addr = otheru->addr;
}
- if (other->protinfo.af_unix.dentry) {
- newsk->protinfo.af_unix.dentry=dget(other->protinfo.af_unix.dentry);
- newsk->protinfo.af_unix.mnt=mntget(other->protinfo.af_unix.mnt);
+ if (otheru->dentry) {
+ newu->dentry = dget(otheru->dentry);
+ newu->mnt = mntget(otheru->mnt);
}
/* Set credentials */
@@ -993,7 +1009,7 @@ restart:
__skb_queue_tail(&other->receive_queue,skb);
/* Undo artificially decreased inflight after embrion
* is installed to listening socket. */
- atomic_inc(&newsk->protinfo.af_unix.inflight);
+ atomic_inc(&newu->inflight);
spin_unlock(&other->receive_queue.lock);
unix_state_runlock(other);
other->data_ready(other, 0);
@@ -1066,7 +1082,7 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags)
tsk = skb->sk;
skb_free_datagram(sk, skb);
- wake_up_interruptible(&sk->protinfo.af_unix.peer_wait);
+ wake_up_interruptible(&unix_sk(sk)->peer_wait);
/* attach accepted sock to socket */
unix_state_wlock(tsk);
@@ -1083,6 +1099,7 @@ out:
static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer)
{
struct sock *sk = sock->sk;
+ struct unix_sock *u = unix_sk(sk);
struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr;
int err = 0;
@@ -1098,12 +1115,12 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_
}
unix_state_rlock(sk);
- if (!sk->protinfo.af_unix.addr) {
+ if (!u->addr) {
sunaddr->sun_family = AF_UNIX;
sunaddr->sun_path[0] = 0;
*uaddr_len = sizeof(short);
} else {
- struct unix_address *addr = sk->protinfo.af_unix.addr;
+ struct unix_address *addr = u->addr;
*uaddr_len = addr->len;
memcpy(sunaddr, addr->name, *uaddr_len);
@@ -1156,6 +1173,7 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ struct unix_sock *u = unix_sk(sk);
struct sockaddr_un *sunaddr=msg->msg_name;
unix_socket *other = NULL;
int namelen = 0; /* fake GCC */
@@ -1181,8 +1199,7 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg, int len,
goto out;
}
- if (sock->passcred && !sk->protinfo.af_unix.addr &&
- (err = unix_autobind(sock)) != 0)
+ if (sock->passcred && !u->addr && (err = unix_autobind(sock)) != 0)
goto out;
err = -EMSGSIZE;
@@ -1383,12 +1400,12 @@ out_err:
static void unix_copy_addr(struct msghdr *msg, struct sock *sk)
{
+ struct unix_sock *u = unix_sk(sk);
+
msg->msg_namelen = sizeof(short);
- if (sk->protinfo.af_unix.addr) {
- msg->msg_namelen=sk->protinfo.af_unix.addr->len;
- memcpy(msg->msg_name,
- sk->protinfo.af_unix.addr->name,
- sk->protinfo.af_unix.addr->len);
+ if (u->addr) {
+ msg->msg_namelen = u->addr->len;
+ memcpy(msg->msg_name, u->addr->name, u->addr->len);
}
}
@@ -1396,6 +1413,7 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, int size,
int flags, struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ struct unix_sock *u = unix_sk(sk);
int noblock = flags & MSG_DONTWAIT;
struct sk_buff *skb;
int err;
@@ -1410,7 +1428,7 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, int size,
if (!skb)
goto out;
- wake_up_interruptible(&sk->protinfo.af_unix.peer_wait);
+ wake_up_interruptible(&u->peer_wait);
if (msg->msg_name)
unix_copy_addr(msg, skb->sk);
@@ -1497,6 +1515,7 @@ static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size
int flags, struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ struct unix_sock *u = unix_sk(sk);
struct sockaddr_un *sunaddr=msg->msg_name;
int copied = 0;
int check_creds = 0;
@@ -1521,7 +1540,7 @@ static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size
* while sleeps in memcpy_tomsg
*/
- down(&sk->protinfo.af_unix.readsem);
+ down(&u->readsem);
do
{
@@ -1545,7 +1564,7 @@ static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size
err = -EAGAIN;
if (!timeo)
break;
- up(&sk->protinfo.af_unix.readsem);
+ up(&u->readsem);
timeo = unix_stream_data_wait(sk, timeo);
@@ -1553,7 +1572,7 @@ static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size
err = sock_intr_errno(timeo);
goto out;
}
- down(&sk->protinfo.af_unix.readsem);
+ down(&u->readsem);
continue;
}
@@ -1619,7 +1638,7 @@ static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size
}
} while (size);
- up(&sk->protinfo.af_unix.readsem);
+ up(&u->readsem);
out:
return copied ? : err;
}
@@ -1748,6 +1767,7 @@ static int unix_read_proc(char *buffer, char **start, off_t offset,
read_lock(&unix_table_lock);
forall_unix_sockets (i,s)
{
+ struct unix_sock *u = unix_sk(s);
unix_state_rlock(s);
len+=sprintf(buffer+len,"%p: %08X %08X %08X %04X %02X %5ld",
@@ -1761,16 +1781,15 @@ static int unix_read_proc(char *buffer, char **start, off_t offset,
(s->state == TCP_ESTABLISHED ? SS_CONNECTING : SS_DISCONNECTING),
sock_i_ino(s));
- if (s->protinfo.af_unix.addr)
- {
+ if (u->addr) {
buffer[len++] = ' ';
- memcpy(buffer+len, s->protinfo.af_unix.addr->name->sun_path,
- s->protinfo.af_unix.addr->len-sizeof(short));
+ memcpy(buffer+len, u->addr->name->sun_path,
+ u->addr->len-sizeof(short));
if (!UNIX_ABSTRACT(s))
len--;
else
buffer[len] = '@';
- len += s->protinfo.af_unix.addr->len - sizeof(short);
+ len += u->addr->len - sizeof(short);
}
unix_state_runlock(s);
@@ -1841,8 +1860,8 @@ struct proto_ops unix_dgram_ops = {
};
struct net_proto_family unix_family_ops = {
- family: PF_UNIX,
- create: unix_create
+ family: PF_UNIX,
+ create: unix_create,
};
#ifdef CONFIG_SYSCTL
@@ -1865,6 +1884,14 @@ static int __init af_unix_init(void)
printk(KERN_CRIT "unix_proto_init: panic\n");
return -1;
}
+ /* allocate our sock slab cache */
+ unix_sk_cachep = kmem_cache_create("unix_sock",
+ sizeof(struct unix_sock), 0,
+ SLAB_HWCACHE_ALIGN, 0, 0);
+ if (!unix_sk_cachep)
+ printk(KERN_CRIT __FUNCTION__
+ ": Cannot create unix_sock SLAB cache!\n");
+
sock_register(&unix_family_ops);
#ifdef CONFIG_PROC_FS
create_proc_read_entry("net/unix", 0, 0, unix_read_proc, NULL);
@@ -1878,6 +1905,7 @@ static void __exit af_unix_exit(void)
sock_unregister(PF_UNIX);
unix_sysctl_unregister();
remove_proc_entry("net/unix", 0);
+ kmem_cache_destroy(unix_sk_cachep);
}
module_init(af_unix_init);
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 457515db9..2da09d89f 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -122,7 +122,7 @@ void unix_inflight(struct file *fp)
{
unix_socket *s=unix_get_socket(fp);
if(s) {
- atomic_inc(&s->protinfo.af_unix.inflight);
+ atomic_inc(&unix_sk(s)->inflight);
atomic_inc(&unix_tot_inflight);
}
}
@@ -131,7 +131,7 @@ void unix_notinflight(struct file *fp)
{
unix_socket *s=unix_get_socket(fp);
if(s) {
- atomic_dec(&s->protinfo.af_unix.inflight);
+ atomic_dec(&unix_sk(s)->inflight);
atomic_dec(&unix_tot_inflight);
}
}
@@ -144,7 +144,7 @@ void unix_notinflight(struct file *fp)
extern inline unix_socket *pop_stack(void)
{
unix_socket *p=gc_current;
- gc_current = p->protinfo.af_unix.gc_tree;
+ gc_current = unix_sk(p)->gc_tree;
return p;
}
@@ -155,10 +155,12 @@ extern inline int empty_stack(void)
extern inline void maybe_unmark_and_push(unix_socket *x)
{
- if (x->protinfo.af_unix.gc_tree != GC_ORPHAN)
+ struct unix_sock *u = unix_sk(x);
+
+ if (u->gc_tree != GC_ORPHAN)
return;
sock_hold(x);
- x->protinfo.af_unix.gc_tree = gc_current;
+ u->gc_tree = gc_current;
gc_current = x;
}
@@ -184,7 +186,7 @@ void unix_gc(void)
forall_unix_sockets(i, s)
{
- s->protinfo.af_unix.gc_tree=GC_ORPHAN;
+ unix_sk(s)->gc_tree = GC_ORPHAN;
}
/*
* Everything is now marked
@@ -219,7 +221,7 @@ void unix_gc(void)
*/
if(s->socket && s->socket->file)
open_count = file_count(s->socket->file);
- if (open_count > atomic_read(&s->protinfo.af_unix.inflight))
+ if (open_count > atomic_read(&unix_sk(s)->inflight))
maybe_unmark_and_push(s);
}
@@ -277,8 +279,9 @@ void unix_gc(void)
forall_unix_sockets(i, s)
{
- if (s->protinfo.af_unix.gc_tree == GC_ORPHAN)
- {
+ struct unix_sock *u = unix_sk(s);
+
+ if (u->gc_tree == GC_ORPHAN) {
struct sk_buff *nextsk;
spin_lock(&s->receive_queue.lock);
skb=skb_peek(&s->receive_queue);
@@ -297,7 +300,7 @@ void unix_gc(void)
}
spin_unlock(&s->receive_queue.lock);
}
- s->protinfo.af_unix.gc_tree = GC_ORPHAN;
+ u->gc_tree = GC_ORPHAN;
}
read_unlock(&unix_table_lock);
diff --git a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c
index 5170a3cc9..13771099c 100644
--- a/net/wanrouter/af_wanpipe.c
+++ b/net/wanrouter/af_wanpipe.c
@@ -326,7 +326,7 @@ static int wanpipe_rcv(struct sk_buff *skb, netdevice_t *dev, struct sock *sk)
static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk)
{
-
+ wanpipe_opt *wp = wp_sk(sk), *newwp;
struct wan_sockaddr_ll *sll = (struct wan_sockaddr_ll*)skb->cb;
struct sock *newsk;
netdevice_t *dev;
@@ -337,7 +337,7 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk)
/* Find a free device, if none found, all svc's are busy
*/
- card = (sdla_t*)sk->protinfo.af_wanpipe->card;
+ card = (sdla_t*)wp->card;
if (!card){
printk(KERN_INFO "wansock: LISTEN ERROR, No Card\n");
return -ENODEV;
@@ -364,7 +364,8 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk)
/* Initialize the new sock structure
*/
newsk->bound_dev_if = dev->ifindex;
- newsk->protinfo.af_wanpipe->card = sk->protinfo.af_wanpipe->card;
+ newwp = wp_sk(newsk);
+ newwp->card = wp->card;
/* Insert the sock into the main wanpipe
* sock list.
@@ -389,8 +390,8 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk)
* whic lcn to clear
*/
- newsk->protinfo.af_wanpipe->lcn = mbox_ptr->cmd.lcn;
- newsk->protinfo.af_wanpipe->mbox = (void *)mbox_ptr;
+ newwp->lcn = mbox_ptr->cmd.lcn;
+ newwp->mbox = (void *)mbox_ptr;
DBG_PRINTK(KERN_INFO "NEWSOCK : Device %s, bind to lcn %i\n",
dev->name,mbox_ptr->cmd.lcn);
@@ -497,7 +498,7 @@ static struct sock *wanpipe_alloc_socket(void)
struct sock *sk;
struct wanpipe_opt *wan_opt;
- if ((sk = sk_alloc(PF_WANPIPE, GFP_ATOMIC, 1)) == NULL)
+ if ((sk = sk_alloc(PF_WANPIPE, GFP_ATOMIC, 1, NULL)) == NULL)
return NULL;
if ((wan_opt = kmalloc(sizeof(struct wanpipe_opt), GFP_ATOMIC)) == NULL) {
@@ -506,13 +507,12 @@ static struct sock *wanpipe_alloc_socket(void)
}
memset(wan_opt, 0x00, sizeof(struct wanpipe_opt));
- sk->protinfo.af_wanpipe = wan_opt;
- sk->protinfo.destruct_hook = wan_opt;
+ wp_sk(sk) = wan_opt;
/* Use timer to send data to the driver. This will act
* as a BH handler for sendmsg functions */
- sk->protinfo.af_wanpipe->tx_timer.data=(unsigned long)sk;
- sk->protinfo.af_wanpipe->tx_timer.function=wanpipe_delayed_transmit;
+ wan_opt->tx_timer.data = (unsigned long)sk;
+ wan_opt->tx_timer.function = wanpipe_delayed_transmit;
MOD_INC_USE_COUNT;
@@ -542,6 +542,7 @@ static struct sock *wanpipe_alloc_socket(void)
static int wanpipe_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct scm_cookie *scm)
{
+ wanpipe_opt *wp;
struct sock *sk = sock->sk;
struct wan_sockaddr_ll *saddr=(struct wan_sockaddr_ll *)msg->msg_name;
struct sk_buff *skb;
@@ -647,12 +648,13 @@ static int wanpipe_sendmsg(struct socket *sock, struct msghdr *msg, int len,
}
skb_queue_tail(&sk->write_queue,skb);
- atomic_inc(&sk->protinfo.af_wanpipe->packet_sent);
+ wp = wp_sk(sk);
+ atomic_inc(&wp->packet_sent);
- if (!(test_and_set_bit(0,&sk->protinfo.af_wanpipe->timer))){
- del_timer(&sk->protinfo.af_wanpipe->tx_timer);
- sk->protinfo.af_wanpipe->tx_timer.expires=jiffies+1;
- add_timer(&sk->protinfo.af_wanpipe->tx_timer);
+ if (!(test_and_set_bit(0, &wp->timer))){
+ del_timer(&wp->tx_timer);
+ wp->tx_timer.expires = jiffies + 1;
+ add_timer(&wp->tx_timer);
}
return(len);
@@ -683,17 +685,18 @@ static void wanpipe_delayed_transmit (unsigned long data)
{
struct sock *sk=(struct sock *)data;
struct sk_buff *skb;
- netdevice_t *dev = sk->protinfo.af_wanpipe->dev;
- sdla_t *card = (sdla_t*)sk->protinfo.af_wanpipe->card;
+ wanpipe_opt *wp = wp_sk(sk);
+ netdevice_t *dev = wp->dev;
+ sdla_t *card = (sdla_t*)wp->card;
if (!card || !dev){
- clear_bit (0,&sk->protinfo.af_wanpipe->timer);
+ clear_bit(0, &wp->timer);
DBG_PRINTK(KERN_INFO "wansock: Transmit delay, no dev or card\n");
return;
}
if (sk->state != WANSOCK_CONNECTED || !sk->zapped){
- clear_bit (0,&sk->protinfo.af_wanpipe->timer);
+ clear_bit(0, &wp->timer);
DBG_PRINTK(KERN_INFO "wansock: Tx Timer, State not CONNECTED\n");
return;
}
@@ -703,8 +706,8 @@ static void wanpipe_delayed_transmit (unsigned long data)
* pending command will never get a free buffer
* to execute */
if (atomic_read(&card->u.x.command_busy)){
- sk->protinfo.af_wanpipe->tx_timer.expires=jiffies+SLOW_BACKOFF;
- add_timer(&sk->protinfo.af_wanpipe->tx_timer);
+ wp->tx_timer.expires = jiffies + SLOW_BACKOFF;
+ add_timer(&wp->tx_timer);
DBG_PRINTK(KERN_INFO "wansock: Tx Timer, command bys BACKOFF\n");
return;
}
@@ -712,8 +715,8 @@ static void wanpipe_delayed_transmit (unsigned long data)
if (test_and_set_bit(0,&wanpipe_tx_critical)){
printk(KERN_INFO "WanSock: Tx timer critical %s\n",dev->name);
- sk->protinfo.af_wanpipe->tx_timer.expires=jiffies+SLOW_BACKOFF;
- add_timer(&sk->protinfo.af_wanpipe->tx_timer);
+ wp->tx_timer.expires = jiffies + SLOW_BACKOFF;
+ add_timer(&wp->tx_timer);
return;
}
@@ -733,18 +736,18 @@ static void wanpipe_delayed_transmit (unsigned long data)
* if more packets, re-trigger the transmit routine
* other wise exit
*/
- atomic_dec(&sk->protinfo.af_wanpipe->packet_sent);
+ atomic_dec(&wp->packet_sent);
if (skb_peek(&sk->write_queue) == NULL){
/* If there is nothing to send, kick
* the poll routine, which will trigger
* the application to send more data */
sk->data_ready(sk,0);
- clear_bit (0,&sk->protinfo.af_wanpipe->timer);
+ clear_bit(0, &wp->timer);
}else{
/* Reschedule as fast as possible */
- sk->protinfo.af_wanpipe->tx_timer.expires=jiffies+1;
- add_timer(&sk->protinfo.af_wanpipe->tx_timer);
+ wp->tx_timer.expires = jiffies + 1;
+ add_timer(&wp->tx_timer);
}
}
}
@@ -758,7 +761,7 @@ static void wanpipe_delayed_transmit (unsigned long data)
* chan->command is used to indicate to the driver that
* command is pending for exection. The acutal command
* structure is placed into a sock mbox structure
- * (sk->protinfo.af_wanpipe->mbox).
+ * (wp_sk(sk)->mbox).
*
* The sock private structure, mbox is
* used as shared memory between sock and the driver.
@@ -774,6 +777,7 @@ static void wanpipe_delayed_transmit (unsigned long data)
static int execute_command(struct sock *sk, unsigned char cmd, unsigned int flags)
{
+ wanpipe_opt *wp = wp_sk(sk);
netdevice_t *dev;
wanpipe_common_t *chan=NULL;
int err=0;
@@ -798,15 +802,14 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int fla
return -EINVAL;
}
- if (!sk->protinfo.af_wanpipe->mbox){
+ if (!wp->mbox) {
printk(KERN_INFO "wansock: In execute without MBOX\n");
return -EINVAL;
}
- ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.command=cmd;
- ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.lcn =
- sk->protinfo.af_wanpipe->lcn;
- ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.result=0x7F;
+ ((mbox_cmd_t*)wp->mbox)->cmd.command = cmd;
+ ((mbox_cmd_t*)wp->mbox)->cmd.lcn = wp->lcn;
+ ((mbox_cmd_t*)wp->mbox)->cmd.result = 0x7F;
if (flags & O_NONBLOCK){
@@ -819,7 +822,7 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int fla
add_wait_queue(sk->sleep,&wait);
current->state = TASK_INTERRUPTIBLE;
for (;;){
- if (((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.result != 0x7F) {
+ if (((mbox_cmd_t*)wp->mbox)->cmd.result != 0x7F) {
err = 0;
break;
}
@@ -845,17 +848,16 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int fla
static void wanpipe_destroy_timer(unsigned long data)
{
struct sock *sk=(struct sock *)data;
+ wanpipe_opt *wp = wp_sk(sk);
if ((!atomic_read(&sk->wmem_alloc) && !atomic_read(&sk->rmem_alloc)) ||
- (++sk->protinfo.af_wanpipe->force == 5)) {
+ (++wp->force == 5)) {
if (atomic_read(&sk->wmem_alloc) || atomic_read(&sk->rmem_alloc))
printk(KERN_INFO "wansock: Warning, Packet Discarded due to sock shutdown!\n");
- if (sk->protinfo.af_wanpipe){
- kfree(sk->protinfo.af_wanpipe);
- sk->protinfo.af_wanpipe=NULL;
- }
+ kfree(wp);
+ wp_sk(sk) = NULL;
#ifdef LINUX_2_4
if (atomic_read(&sk->refcnt) != 1){
@@ -891,7 +893,7 @@ static void wanpipe_unlink_driver (struct sock *sk)
sk->zapped=0;
sk->state = WANSOCK_DISCONNECTED;
- sk->protinfo.af_wanpipe->dev = NULL;
+ wp_sk(sk)->dev = NULL;
dev = dev_get_by_index(sk->bound_dev_if);
if (!dev){
@@ -928,15 +930,16 @@ static void wanpipe_unlink_driver (struct sock *sk)
static void wanpipe_link_driver (netdevice_t *dev, struct sock *sk)
{
+ wanpipe_opt *wp = wp_sk(sk);
wanpipe_common_t *chan = dev->priv;
if (!chan)
return;
set_bit(0,&chan->common_critical);
chan->sk=sk;
chan->func=wanpipe_rcv;
- chan->mbox=sk->protinfo.af_wanpipe->mbox;
- chan->tx_timer = &sk->protinfo.af_wanpipe->tx_timer;
- sk->protinfo.af_wanpipe->dev=dev;
+ chan->mbox = wp->mbox;
+ chan->tx_timer = &wp->tx_timer;
+ wp->dev = dev;
sk->zapped = 1;
clear_bit(0,&chan->common_critical);
}
@@ -974,12 +977,14 @@ static int wanpipe_release(struct socket *sock, struct socket *peersock)
#ifndef LINUX_2_4
struct sk_buff *skb;
#endif
+ wanpipe_opt *wp;
struct sock *sk = sock->sk;
struct sock **skp;
if (!sk)
return 0;
+ wp = wp_sk(sk);
check_write_queue(sk);
/* Kill the tx timer, if we don't kill it now, the timer
@@ -987,7 +992,7 @@ static int wanpipe_release(struct socket *sock, struct socket *peersock)
* try to access the sock which has been killed and cause
* kernel panic */
- del_timer(&sk->protinfo.af_wanpipe->tx_timer);
+ del_timer(&wp->tx_timer);
/*
* Unhook packet receive handler.
@@ -1060,10 +1065,8 @@ static int wanpipe_release(struct socket *sock, struct socket *peersock)
return 0;
}
- if (sk->protinfo.af_wanpipe){
- kfree(sk->protinfo.af_wanpipe);
- sk->protinfo.af_wanpipe=NULL;
- }
+ kfree(wp);
+ wp_sk(sk) = NULL;
#ifdef LINUX_2_4
if (atomic_read(&sk->refcnt) != 1){
@@ -1113,6 +1116,7 @@ static void check_write_queue(struct sock *sk)
static void release_driver(struct sock *sk)
{
+ wanpipe_opt *wp;
struct sk_buff *skb=NULL;
struct sock *deadsk=NULL;
@@ -1134,12 +1138,11 @@ static void release_driver(struct sock *sk)
sk->state = WANSOCK_DISCONNECTED;
sk->bound_dev_if = 0;
sk->zapped=0;
+ wp = wp_sk(sk);
- if (sk->protinfo.af_wanpipe){
- if (sk->protinfo.af_wanpipe->mbox){
- kfree(sk->protinfo.af_wanpipe->mbox);
- sk->protinfo.af_wanpipe->mbox=NULL;
- }
+ if (wp && wp->mbox) {
+ kfree(wp->mbox);
+ wp->mbox = NULL;
}
}
@@ -1244,9 +1247,9 @@ static void wanpipe_kill_sock_timer (unsigned long data)
return;
}
- if (sk->protinfo.af_wanpipe){
- kfree(sk->protinfo.af_wanpipe);
- sk->protinfo.af_wanpipe=NULL;
+ if (wp_sk(sk)) {
+ kfree(wp_sk(sk));
+ wp_sk(sk) = NULL;
}
#ifdef LINUX_2_4
@@ -1288,9 +1291,9 @@ static void wanpipe_kill_sock_accept (struct sock *sk)
sk->socket = NULL;
- if (sk->protinfo.af_wanpipe){
- kfree(sk->protinfo.af_wanpipe);
- sk->protinfo.af_wanpipe=NULL;
+ if (wp_sk(sk)) {
+ kfree(wp_sk(sk));
+ wp_sk(sk) = NULL;
}
#ifdef LINUX_2_4
@@ -1317,9 +1320,9 @@ static void wanpipe_kill_sock_irq (struct sock *sk)
sk->socket = NULL;
- if (sk->protinfo.af_wanpipe){
- kfree(sk->protinfo.af_wanpipe);
- sk->protinfo.af_wanpipe=NULL;
+ if (wp_sk(sk)) {
+ kfree(wp_sk(sk));
+ wp_sk(sk) = NULL;
}
#ifdef LINUX_2_4
@@ -1386,7 +1389,7 @@ static int wanpipe_do_bind(struct sock *sk, netdevice_t *dev, int protocol)
/* X25 Specific option */
if (sk->num == htons(X25_PROT))
- sk->protinfo.af_wanpipe->svc = chan->svc;
+ wp_sk(sk)->svc = chan->svc;
} else {
sk->err = ENETDOWN;
@@ -1440,7 +1443,7 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
printk(KERN_INFO "wansock: Wanpipe card not found: %s\n",sll->sll_card);
return -ENODEV;
}else{
- sk->protinfo.af_wanpipe->card = (void *)card;
+ wp_sk(sk)->card = (void *)card;
}
if (!strcmp(sll->sll_device,"svc_listen")){
@@ -1808,7 +1811,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void
for (sk = wanpipe_sklist; sk; sk = sk->next) {
- if ((po = sk->protinfo.af_wanpipe)==NULL)
+ if ((po = wp_sk(sk)) == NULL)
continue;
if (dev == NULL)
continue;
@@ -2005,6 +2008,7 @@ static int wanpipe_debug (struct sock *origsk, void *arg)
wan_debug_t *dbg_data = (wan_debug_t *)arg;
for (sk = wanpipe_sklist; sk; sk = sk->next){
+ wanpipe_opt *wp = wp_sk(sk);
if (sk == origsk){
continue;
@@ -2024,8 +2028,7 @@ static int wanpipe_debug (struct sock *origsk, void *arg)
return err;
if ((err=put_user(sk_count, &dbg_data->debug[cnt].sk_count)))
return err;
- if ((err=put_user(sk->protinfo.af_wanpipe->poll_cnt,
- &dbg_data->debug[cnt].poll_cnt)))
+ if ((err=put_user(wp->poll_cnt, &dbg_data->debug[cnt].poll_cnt)))
return err;
if ((err=put_user(sk->bound_dev_if, &dbg_data->debug[cnt].bound)))
return err;
@@ -2048,8 +2051,8 @@ static int wanpipe_debug (struct sock *origsk, void *arg)
return err;
- if (sk->protinfo.af_wanpipe){
- sdla_t *card = (sdla_t*)sk->protinfo.af_wanpipe->card;
+ if (wp){
+ sdla_t *card = (sdla_t*)wp->card;
if (card){
if ((err=put_user(atomic_read(&card->u.x.command_busy),
@@ -2057,11 +2060,11 @@ static int wanpipe_debug (struct sock *origsk, void *arg)
return err;
}
- if ((err=put_user(sk->protinfo.af_wanpipe->lcn,
- &dbg_data->debug[cnt].lcn)))
+ if ((err=put_user(wp->lcn,
+ &dbg_data->debug[cnt].lcn)))
return err;
- if (sk->protinfo.af_wanpipe->mbox){
+ if (wp->mbox) {
if ((err=put_user(1, &dbg_data->debug[cnt].mbox)))
return err;
}
@@ -2096,11 +2099,11 @@ static int get_ioctl_cmd (struct sock *sk, void *arg)
if (usr_data == NULL)
return -EINVAL;
- if (!sk->protinfo.af_wanpipe->mbox){
+ if (!wp_sk(sk)->mbox) {
return -EINVAL;
}
- mbox_ptr = (mbox_cmd_t *)sk->protinfo.af_wanpipe->mbox;
+ mbox_ptr = (mbox_cmd_t *)wp_sk(sk)->mbox;
if ((err=put_user(mbox_ptr->cmd.qdm, &usr_data->hdr.qdm)))
return err;
@@ -2140,7 +2143,7 @@ static int set_ioctl_cmd (struct sock *sk, void *arg)
mbox_cmd_t *mbox_ptr;
int err;
- if (!sk->protinfo.af_wanpipe->mbox){
+ if (!wp_sk(sk)->mbox) {
void *mbox_ptr;
netdevice_t *dev = dev_get_by_index(sk->bound_dev_if);
if (!dev)
@@ -2152,12 +2155,12 @@ static int set_ioctl_cmd (struct sock *sk, void *arg)
return -ENOMEM;
memset(mbox_ptr, 0, sizeof(mbox_cmd_t));
- sk->protinfo.af_wanpipe->mbox = mbox_ptr;
+ wp_sk(sk)->mbox = mbox_ptr;
wanpipe_link_driver(dev,sk);
}
- mbox_ptr = (mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox;
+ mbox_ptr = (mbox_cmd_t*)wp_sk(sk)->mbox;
memset(mbox_ptr, 0, sizeof(mbox_cmd_t));
if (usr_data == NULL){
@@ -2204,7 +2207,7 @@ unsigned int wanpipe_poll(struct file * file, struct socket *sock, poll_table *w
struct sock *sk = sock->sk;
unsigned int mask;
- ++sk->protinfo.af_wanpipe->poll_cnt;
+ ++wp_sk(sk)->poll_cnt;
poll_wait(file, sk->sleep, wait);
mask = 0;
@@ -2240,7 +2243,7 @@ unsigned int wanpipe_poll(struct file * file, struct socket *sock, poll_table *w
* transmit queue */
if (sk->num == htons(X25_PROT)){
- if (atomic_read(&sk->protinfo.af_wanpipe->packet_sent))
+ if (atomic_read(&wp_sk(sk)->packet_sent))
return mask;
}
@@ -2294,9 +2297,8 @@ static int wanpipe_listen(struct socket *sock, int backlog)
static int wanpipe_link_card (struct sock *sk)
{
- sdla_t *card;
+ sdla_t *card = (sdla_t*)wp_sk(sk)->card;
- card = (sdla_t*)sk->protinfo.af_wanpipe->card;
if (!card)
return -ENOMEM;
@@ -2321,9 +2323,7 @@ static int wanpipe_link_card (struct sock *sk)
static void wanpipe_unlink_card (struct sock *sk)
{
- sdla_t *card;
-
- card = (sdla_t*)sk->protinfo.af_wanpipe->card;
+ sdla_t *card = (sdla_t*)wp_sk(sk)->card;
if (card){
card->sk=NULL;
@@ -2342,7 +2342,8 @@ static void wanpipe_unlink_card (struct sock *sk)
static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
{
int err = -EINVAL;
- mbox_cmd_t *mbox_ptr = (mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox;
+ wanpipe_opt *wp = wp_sk(sk);
+ mbox_cmd_t *mbox_ptr = (mbox_cmd_t*)wp->mbox;
if (!mbox_ptr){
printk(KERN_INFO "NO MBOX PTR !!!!!\n");
@@ -2373,16 +2374,15 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
* it is done in wanpipe_listen_rcv().
*/
if (sk->state == WANSOCK_CONNECTED){
- sk->protinfo.af_wanpipe->lcn =
- ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.lcn;
+ wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn;
DBG_PRINTK(KERN_INFO "\nwansock: Accept OK %i\n",
- sk->protinfo.af_wanpipe->lcn );
+ wp->lcn);
err = 0;
}else{
DBG_PRINTK (KERN_INFO "\nwansock: Accept Failed %i\n",
- sk->protinfo.af_wanpipe->lcn);
- sk->protinfo.af_wanpipe->lcn = 0;
+ wp->lcn);
+ wp->lcn = 0;
err = -ECONNREFUSED;
}
break;
@@ -2400,7 +2400,7 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
* is transmitted, or clear a call and drop packets */
if (atomic_read(&sk->wmem_alloc) || check_driver_busy(sk)){
- mbox_cmd_t *mbox = sk->protinfo.af_wanpipe->mbox;
+ mbox_cmd_t *mbox = wp->mbox;
if (mbox->cmd.qdm & 0x80){
mbox->cmd.result = 0x35;
err = -EAGAIN;
@@ -2417,8 +2417,8 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
err = -ECONNREFUSED;
if (sk->state == WANSOCK_DISCONNECTED){
DBG_PRINTK(KERN_INFO "\nwansock: CLEAR OK %i\n",
- sk->protinfo.af_wanpipe->lcn);
- sk->protinfo.af_wanpipe->lcn=0;
+ wp->lcn);
+ wp->lcn = 0;
err = 0;
}
break;
@@ -2436,7 +2436,7 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
* is transmitted, or reset a call and drop packets */
if (atomic_read(&sk->wmem_alloc) || check_driver_busy(sk)){
- mbox_cmd_t *mbox = sk->protinfo.af_wanpipe->mbox;
+ mbox_cmd_t *mbox = wp->mbox;
if (mbox->cmd.qdm & 0x80){
mbox->cmd.result = 0x35;
err = -EAGAIN;
@@ -2461,18 +2461,16 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
if (sk->state == WANSOCK_CONNECTED){
- sk->protinfo.af_wanpipe->lcn =
- ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.lcn;
+ wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn;
DBG_PRINTK(KERN_INFO "\nwansock: PLACE CALL OK %i\n",
- sk->protinfo.af_wanpipe->lcn);
+ wp->lcn);
err = 0;
}else if (sk->state == WANSOCK_CONNECTING && (flags & O_NONBLOCK)){
- sk->protinfo.af_wanpipe->lcn =
- ((mbox_cmd_t*)sk->protinfo.af_wanpipe->mbox)->cmd.lcn;
+ wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn;
DBG_PRINTK(KERN_INFO "\nwansock: Place Call OK: Waiting %i\n",
- sk->protinfo.af_wanpipe->lcn);
+ wp->lcn);
err = 0;
@@ -2583,7 +2581,8 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags
kfree_skb(skb);
- DBG_PRINTK(KERN_INFO "\nwansock: ACCEPT Got LCN %i\n",newsk->protinfo.af_wanpipe->lcn);
+ DBG_PRINTK(KERN_INFO "\nwansock: ACCEPT Got LCN %i\n",
+ wp_sk(newsk)->lcn);
return 0;
}
@@ -2660,10 +2659,10 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr
sock->state = SS_CONNECTING;
sk->state = WANSOCK_CONNECTING;
- if (!sk->protinfo.af_wanpipe->mbox){
- if (sk->protinfo.af_wanpipe->svc){
+ if (!wp_sk(sk)->mbox) {
+ if (wp_sk (sk)->svc)
return -EINVAL;
- }else{
+ else {
int err;
if ((err=set_ioctl_cmd(sk,NULL)) < 0)
return err;
@@ -2733,14 +2732,12 @@ struct proto_ops wanpipe_ops = {
static struct net_proto_family wanpipe_family_ops = {
- PF_WANPIPE,
- wanpipe_create
+ family: PF_WANPIPE,
+ create: wanpipe_create,
};
-struct notifier_block wanpipe_netdev_notifier={
- wanpipe_notifier,
- NULL,
- 0
+struct notifier_block wanpipe_netdev_notifier = {
+ notifier_call: wanpipe_notifier,
};
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index cbd52721c..9a59cfd7e 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -46,6 +46,7 @@
#include <linux/if_arp.h>
#include <linux/skbuff.h>
#include <net/sock.h>
+#include <net/tcp.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <linux/fcntl.h>
@@ -181,8 +182,7 @@ static void x25_kill_by_device(struct net_device *dev)
struct sock *s;
for (s = x25_list; s != NULL; s = s->next)
- if (s->protinfo.x25->neighbour &&
- s->protinfo.x25->neighbour->dev == dev)
+ if (x25_sk(s)->neighbour && x25_sk(s)->neighbour->dev == dev)
x25_disconnect(s, ENETUNREACH, 0, 0);
}
@@ -247,7 +247,7 @@ static struct sock *x25_find_listener(x25_address *addr)
cli();
for (s = x25_list; s != NULL; s = s->next) {
- if ((strcmp(addr->x25_addr, s->protinfo.x25->source_addr.x25_addr) == 0 ||
+ if ((!strcmp(addr->x25_addr, x25_sk(s)->source_addr.x25_addr) ||
strcmp(addr->x25_addr, null_x25_address.x25_addr) == 0) &&
s->state == TCP_LISTEN) {
restore_flags(flags);
@@ -271,7 +271,7 @@ struct sock *x25_find_socket(unsigned int lci, struct x25_neigh *neigh)
cli();
for (s = x25_list; s != NULL; s = s->next) {
- if (s->protinfo.x25->lci == lci && s->protinfo.x25->neighbour == neigh) {
+ if (x25_sk(s)->lci == lci && x25_sk(s)->neighbour == neigh) {
restore_flags(flags);
return s;
}
@@ -333,7 +333,7 @@ void x25_destroy_socket(struct sock *sk) /* Not static as it's used by the timer
if (skb->sk != sk) { /* A pending connection */
skb->sk->dead = 1; /* Queue the unaccepted socket for death */
x25_start_heartbeat(skb->sk);
- skb->sk->protinfo.x25->state = X25_STATE_0;
+ x25_sk(skb->sk)->state = X25_STATE_0;
}
kfree_skb(skb);
@@ -376,7 +376,7 @@ static int x25_setsockopt(struct socket *sock, int level, int optname,
switch (optname) {
case X25_QBITINCL:
- sk->protinfo.x25->qbitincl = opt ? 1 : 0;
+ x25_sk(sk)->qbitincl = opt ? 1 : 0;
return 0;
default:
@@ -399,7 +399,7 @@ static int x25_getsockopt(struct socket *sock, int level, int optname,
switch (optname) {
case X25_QBITINCL:
- val = sk->protinfo.x25->qbitincl;
+ val = x25_sk(sk)->qbitincl;
break;
default:
@@ -422,7 +422,7 @@ static int x25_listen(struct socket *sock, int backlog)
struct sock *sk = sock->sk;
if (sk->state != TCP_LISTEN) {
- memset(&sk->protinfo.x25->dest_addr, '\0', X25_ADDR_LEN);
+ memset(&x25_sk(sk)->dest_addr, 0, X25_ADDR_LEN);
sk->max_ack_backlog = backlog;
sk->state = TCP_LISTEN;
return 0;
@@ -436,20 +436,18 @@ static struct sock *x25_alloc_socket(void)
struct sock *sk;
x25_cb *x25;
- if ((sk = sk_alloc(AF_X25, GFP_ATOMIC, 1)) == NULL)
- return NULL;
+ MOD_INC_USE_COUNT;
- if ((x25 = kmalloc(sizeof(*x25), GFP_ATOMIC)) == NULL) {
- sk_free(sk);
- return NULL;
- }
+ if ((sk = sk_alloc(AF_X25, GFP_ATOMIC, 1, NULL)) == NULL)
+ goto decmod;
- memset(x25, 0x00, sizeof(*x25));
+ x25 = x25_sk(sk) = kmalloc(sizeof(*x25), GFP_ATOMIC);
+ if (!x25)
+ goto frees;
- x25->sk = sk;
- sk->protinfo.x25 = x25;
+ memset(x25, 0x00, sizeof(*x25));
- MOD_INC_USE_COUNT;
+ x25->sk = sk;
sock_init_data(NULL, sk);
@@ -457,8 +455,11 @@ static struct sock *x25_alloc_socket(void)
skb_queue_head_init(&x25->fragment_queue);
skb_queue_head_init(&x25->interrupt_in_queue);
skb_queue_head_init(&x25->interrupt_out_queue);
-
- return sk;
+out: return sk;
+frees: sk_free(sk);
+ sk = NULL;
+decmod: MOD_DEC_USE_COUNT;
+ goto out;
}
static int x25_create(struct socket *sock, int protocol)
@@ -472,7 +473,7 @@ static int x25_create(struct socket *sock, int protocol)
if ((sk = x25_alloc_socket()) == NULL)
return -ENOMEM;
- x25 = sk->protinfo.x25;
+ x25 = x25_sk(sk);
sock_init_data(sock, sk);
@@ -501,7 +502,7 @@ static int x25_create(struct socket *sock, int protocol)
static struct sock *x25_make_new(struct sock *osk)
{
struct sock *sk;
- x25_cb *x25;
+ x25_cb *x25, *ox25;
if (osk->type != SOCK_SEQPACKET)
return NULL;
@@ -509,7 +510,7 @@ static struct sock *x25_make_new(struct sock *osk)
if ((sk = x25_alloc_socket()) == NULL)
return NULL;
- x25 = sk->protinfo.x25;
+ x25 = x25_sk(sk);
sk->type = osk->type;
sk->socket = osk->socket;
@@ -523,14 +524,13 @@ static struct sock *x25_make_new(struct sock *osk)
sk->zapped = osk->zapped;
sk->backlog_rcv = osk->backlog_rcv;
- x25->t21 = osk->protinfo.x25->t21;
- x25->t22 = osk->protinfo.x25->t22;
- x25->t23 = osk->protinfo.x25->t23;
- x25->t2 = osk->protinfo.x25->t2;
-
- x25->facilities = osk->protinfo.x25->facilities;
-
- x25->qbitincl = osk->protinfo.x25->qbitincl;
+ ox25 = x25_sk(osk);
+ x25->t21 = ox25->t21;
+ x25->t22 = ox25->t22;
+ x25->t23 = ox25->t23;
+ x25->t2 = ox25->t2;
+ x25->facilities = ox25->facilities;
+ x25->qbitincl = ox25->qbitincl;
init_timer(&x25->timer);
@@ -540,10 +540,13 @@ static struct sock *x25_make_new(struct sock *osk)
static int x25_release(struct socket *sock)
{
struct sock *sk = sock->sk;
+ x25_cb *x25;
if (sk == NULL) return 0;
- switch (sk->protinfo.x25->state) {
+ x25 = x25_sk(sk);
+
+ switch (x25->state) {
case X25_STATE_0:
case X25_STATE_2:
@@ -557,7 +560,7 @@ static int x25_release(struct socket *sock)
x25_clear_queues(sk);
x25_write_internal(sk, X25_CLEAR_REQUEST);
x25_start_t23timer(sk);
- sk->protinfo.x25->state = X25_STATE_2;
+ x25->state = X25_STATE_2;
sk->state = TCP_CLOSE;
sk->shutdown |= SEND_SHUTDOWN;
sk->state_change(sk);
@@ -589,7 +592,7 @@ static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
if (addr->sx25_family != AF_X25)
return -EINVAL;
- sk->protinfo.x25->source_addr = addr->sx25_addr;
+ x25_sk(sk)->source_addr = addr->sx25_addr;
x25_insert_socket(sk);
@@ -603,6 +606,7 @@ static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
static int x25_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags)
{
struct sock *sk = sock->sk;
+ x25_cb *x25 = x25_sk(sk);
struct sockaddr_x25 *addr = (struct sockaddr_x25 *)uaddr;
struct net_device *dev;
@@ -631,28 +635,27 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len
if ((dev = x25_get_route(&addr->sx25_addr)) == NULL)
return -ENETUNREACH;
- if ((sk->protinfo.x25->neighbour = x25_get_neigh(dev)) == NULL)
+ if ((x25->neighbour = x25_get_neigh(dev)) == NULL)
return -ENETUNREACH;
- x25_limit_facilities(&sk->protinfo.x25->facilities,
- sk->protinfo.x25->neighbour);
+ x25_limit_facilities(&x25->facilities, x25->neighbour);
- if ((sk->protinfo.x25->lci = x25_new_lci(sk->protinfo.x25->neighbour)) == 0)
+ if ((x25->lci = x25_new_lci(x25->neighbour)) == 0)
return -ENETUNREACH;
if (sk->zapped) /* Must bind first - autobinding does not work */
return -EINVAL;
- if (strcmp(sk->protinfo.x25->source_addr.x25_addr, null_x25_address.x25_addr) == 0)
- memset(&sk->protinfo.x25->source_addr, '\0', X25_ADDR_LEN);
+ if (!strcmp(x25->source_addr.x25_addr, null_x25_address.x25_addr))
+ memset(&x25->source_addr, '\0', X25_ADDR_LEN);
- sk->protinfo.x25->dest_addr = addr->sx25_addr;
+ x25->dest_addr = addr->sx25_addr;
/* Move to connecting socket, start sending Connect Requests */
sock->state = SS_CONNECTING;
sk->state = TCP_SYN_SENT;
- sk->protinfo.x25->state = X25_STATE_1;
+ x25->state = X25_STATE_1;
x25_write_internal(sk, X25_CALL_REQUEST);
@@ -743,13 +746,14 @@ static int x25_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_l
{
struct sockaddr_x25 *sx25 = (struct sockaddr_x25 *)uaddr;
struct sock *sk = sock->sk;
+ x25_cb *x25 = x25_sk(sk);
if (peer != 0) {
if (sk->state != TCP_ESTABLISHED)
return -ENOTCONN;
- sx25->sx25_addr = sk->protinfo.x25->dest_addr;
+ sx25->sx25_addr = x25->dest_addr;
} else {
- sx25->sx25_addr = sk->protinfo.x25->source_addr;
+ sx25->sx25_addr = x25->source_addr;
}
sx25->sx25_family = AF_X25;
@@ -762,6 +766,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *neigh, unsigned i
{
struct sock *sk;
struct sock *make;
+ x25_cb *makex25;
x25_address source_addr, dest_addr;
struct x25_facilities facilities;
int len;
@@ -821,12 +826,13 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *neigh, unsigned i
skb->sk = make;
make->state = TCP_ESTABLISHED;
- make->protinfo.x25->lci = lci;
- make->protinfo.x25->dest_addr = dest_addr;
- make->protinfo.x25->source_addr = source_addr;
- make->protinfo.x25->neighbour = neigh;
- make->protinfo.x25->facilities = facilities;
- make->protinfo.x25->vc_facil_mask = sk->protinfo.x25->vc_facil_mask;
+ makex25 = x25_sk(make);
+ makex25->lci = lci;
+ makex25->dest_addr = dest_addr;
+ makex25->source_addr = source_addr;
+ makex25->neighbour = neigh;
+ makex25->facilities = facilities;
+ makex25->vc_facil_mask = x25_sk(sk)->vc_facil_mask;
x25_write_internal(make, X25_CALL_ACCEPTED);
@@ -834,11 +840,11 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *neigh, unsigned i
* Incoming Call User Data.
*/
if (skb->len >= 0) {
- memcpy(make->protinfo.x25->calluserdata.cuddata, skb->data, skb->len);
- make->protinfo.x25->calluserdata.cudlength = skb->len;
+ memcpy(makex25->calluserdata.cuddata, skb->data, skb->len);
+ makex25->calluserdata.cudlength = skb->len;
}
- make->protinfo.x25->state = X25_STATE_3;
+ makex25->state = X25_STATE_3;
sk->ack_backlog++;
make->pair = sk;
@@ -858,6 +864,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *neigh, unsigned i
static int x25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ x25_cb *x25 = x25_sk(sk);
struct sockaddr_x25 *usx25 = (struct sockaddr_x25 *)msg->msg_name;
int err;
struct sockaddr_x25 sx25;
@@ -880,14 +887,14 @@ static int x25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
return -EPIPE;
}
- if (sk->protinfo.x25->neighbour == NULL)
+ if (x25->neighbour == NULL)
return -ENETUNREACH;
if (usx25 != NULL) {
if (msg->msg_namelen < sizeof(sx25))
return -EINVAL;
sx25 = *usx25;
- if (strcmp(sk->protinfo.x25->dest_addr.x25_addr, sx25.sx25_addr.x25_addr) != 0)
+ if (strcmp(x25->dest_addr.x25_addr, sx25.sx25_addr.x25_addr))
return -EISCONN;
if (sx25.sx25_family != AF_X25)
return -EINVAL;
@@ -901,7 +908,7 @@ static int x25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
return -ENOTCONN;
sx25.sx25_family = AF_X25;
- sx25.sx25_addr = sk->protinfo.x25->dest_addr;
+ sx25.sx25_addr = x25->dest_addr;
}
SOCK_DEBUG(sk, "x25_sendmsg: sendto: Addresses built.\n");
@@ -933,7 +940,7 @@ static int x25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
* If the Q BIT Include socket option is in force, the first
* byte of the user data is the logical value of the Q Bit.
*/
- if (sk->protinfo.x25->qbitincl) {
+ if (x25->qbitincl) {
qbit = skb->data[0];
skb_pull(skb, 1);
}
@@ -944,30 +951,30 @@ static int x25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
SOCK_DEBUG(sk, "x25_sendmsg: Building X.25 Header.\n");
if (msg->msg_flags & MSG_OOB) {
- if (sk->protinfo.x25->neighbour->extended) {
+ if (x25->neighbour->extended) {
asmptr = skb_push(skb, X25_STD_MIN_LEN);
- *asmptr++ = ((sk->protinfo.x25->lci >> 8) & 0x0F) | X25_GFI_EXTSEQ;
- *asmptr++ = (sk->protinfo.x25->lci >> 0) & 0xFF;
+ *asmptr++ = ((x25->lci >> 8) & 0x0F) | X25_GFI_EXTSEQ;
+ *asmptr++ = (x25->lci >> 0) & 0xFF;
*asmptr++ = X25_INTERRUPT;
} else {
asmptr = skb_push(skb, X25_STD_MIN_LEN);
- *asmptr++ = ((sk->protinfo.x25->lci >> 8) & 0x0F) | X25_GFI_STDSEQ;
- *asmptr++ = (sk->protinfo.x25->lci >> 0) & 0xFF;
+ *asmptr++ = ((x25->lci >> 8) & 0x0F) | X25_GFI_STDSEQ;
+ *asmptr++ = (x25->lci >> 0) & 0xFF;
*asmptr++ = X25_INTERRUPT;
}
} else {
- if (sk->protinfo.x25->neighbour->extended) {
+ if (x25->neighbour->extended) {
/* Build an Extended X.25 header */
asmptr = skb_push(skb, X25_EXT_MIN_LEN);
- *asmptr++ = ((sk->protinfo.x25->lci >> 8) & 0x0F) | X25_GFI_EXTSEQ;
- *asmptr++ = (sk->protinfo.x25->lci >> 0) & 0xFF;
+ *asmptr++ = ((x25->lci >> 8) & 0x0F) | X25_GFI_EXTSEQ;
+ *asmptr++ = (x25->lci >> 0) & 0xFF;
*asmptr++ = X25_DATA;
*asmptr++ = X25_DATA;
} else {
/* Build an Standard X.25 header */
asmptr = skb_push(skb, X25_STD_MIN_LEN);
- *asmptr++ = ((sk->protinfo.x25->lci >> 8) & 0x0F) | X25_GFI_STDSEQ;
- *asmptr++ = (sk->protinfo.x25->lci >> 0) & 0xFF;
+ *asmptr++ = ((x25->lci >> 8) & 0x0F) | X25_GFI_STDSEQ;
+ *asmptr++ = (x25->lci >> 0) & 0xFF;
*asmptr++ = X25_DATA;
}
@@ -984,13 +991,14 @@ static int x25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
}
if (msg->msg_flags & MSG_OOB) {
- skb_queue_tail(&sk->protinfo.x25->interrupt_out_queue, skb);
+ skb_queue_tail(&x25->interrupt_out_queue, skb);
} else {
len = x25_output(sk, skb);
if(len<0){
kfree_skb(skb);
} else {
- if(sk->protinfo.x25->qbitincl) len++;
+ if (x25->qbitincl)
+ len++;
}
}
@@ -1019,6 +1027,7 @@ static int x25_sendmsg(struct socket *sock, struct msghdr *msg, int len, struct
static int x25_recvmsg(struct socket *sock, struct msghdr *msg, int size, int flags, struct scm_cookie *scm)
{
struct sock *sk = sock->sk;
+ x25_cb *x25 = x25_sk(sk);
struct sockaddr_x25 *sx25 = (struct sockaddr_x25 *)msg->msg_name;
int copied, qbit;
struct sk_buff *skb;
@@ -1033,17 +1042,17 @@ static int x25_recvmsg(struct socket *sock, struct msghdr *msg, int size, int fl
return -ENOTCONN;
if (flags & MSG_OOB) {
- if (sk->urginline || skb_peek(&sk->protinfo.x25->interrupt_in_queue) == NULL)
+ if (sk->urginline || !skb_peek(&x25->interrupt_in_queue))
return -EINVAL;
- skb = skb_dequeue(&sk->protinfo.x25->interrupt_in_queue);
+ skb = skb_dequeue(&x25->interrupt_in_queue);
skb_pull(skb, X25_STD_MIN_LEN);
/*
* No Q bit information on Interrupt data.
*/
- if (sk->protinfo.x25->qbitincl) {
+ if (x25->qbitincl) {
asmptr = skb_push(skb, 1);
*asmptr = 0x00;
}
@@ -1056,9 +1065,10 @@ static int x25_recvmsg(struct socket *sock, struct msghdr *msg, int size, int fl
qbit = (skb->data[0] & X25_Q_BIT) == X25_Q_BIT;
- skb_pull(skb, (sk->protinfo.x25->neighbour->extended) ? X25_EXT_MIN_LEN : X25_STD_MIN_LEN);
+ skb_pull(skb, x25->neighbour->extended ?
+ X25_EXT_MIN_LEN : X25_STD_MIN_LEN);
- if (sk->protinfo.x25->qbitincl) {
+ if (x25->qbitincl) {
asmptr = skb_push(skb, 1);
*asmptr = qbit;
}
@@ -1080,7 +1090,7 @@ static int x25_recvmsg(struct socket *sock, struct msghdr *msg, int size, int fl
if (sx25 != NULL) {
sx25->sx25_family = AF_X25;
- sx25->sx25_addr = sk->protinfo.x25->dest_addr;
+ sx25->sx25_addr = x25->dest_addr;
}
msg->msg_namelen = sizeof(struct sockaddr_x25);
@@ -1097,6 +1107,7 @@ static int x25_recvmsg(struct socket *sock, struct msghdr *msg, int size, int fl
static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
struct sock *sk = sock->sk;
+ x25_cb *x25 = x25_sk(sk);
switch (cmd) {
case TIOCOUTQ: {
@@ -1150,7 +1161,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case SIOCX25GFACILITIES: {
struct x25_facilities facilities;
- facilities = sk->protinfo.x25->facilities;
+ facilities = x25->facilities;
return copy_to_user((void *)arg, &facilities, sizeof(facilities)) ? -EFAULT : 0;
}
@@ -1170,13 +1181,13 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
return -EINVAL;
if (facilities.reverse != 0 && facilities.reverse != 1)
return -EINVAL;
- sk->protinfo.x25->facilities = facilities;
+ x25->facilities = facilities;
return 0;
}
case SIOCX25GCALLUSERDATA: {
struct x25_calluserdata calluserdata;
- calluserdata = sk->protinfo.x25->calluserdata;
+ calluserdata = x25->calluserdata;
return copy_to_user((void *)arg, &calluserdata, sizeof(calluserdata)) ? -EFAULT : 0;
}
@@ -1186,13 +1197,13 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
return -EFAULT;
if (calluserdata.cudlength > X25_MAX_CUD_LEN)
return -EINVAL;
- sk->protinfo.x25->calluserdata = calluserdata;
+ x25->calluserdata = calluserdata;
return 0;
}
case SIOCX25GCAUSEDIAG: {
struct x25_causediag causediag;
- causediag = sk->protinfo.x25->causediag;
+ causediag = x25->causediag;
return copy_to_user((void *)arg, &causediag, sizeof(causediag)) ? -EFAULT : 0;
}
@@ -1218,25 +1229,29 @@ static int x25_get_info(char *buffer, char **start, off_t offset, int length)
len += sprintf(buffer, "dest_addr src_addr dev lci st vs vr va t t2 t21 t22 t23 Snd-Q Rcv-Q inode\n");
for (s = x25_list; s != NULL; s = s->next) {
- if (s->protinfo.x25->neighbour == NULL || (dev = s->protinfo.x25->neighbour->dev) == NULL)
+ x25_cb *x25 = x25_sk(s);
+
+ if (!x25->neighbour || (dev = x25->neighbour->dev) == NULL)
devname = "???";
else
- devname = s->protinfo.x25->neighbour->dev->name;
+ devname = x25->neighbour->dev->name;
len += sprintf(buffer + len, "%-10s %-10s %-5s %3.3X %d %d %d %d %3lu %3lu %3lu %3lu %3lu %5d %5d %ld\n",
- (s->protinfo.x25->dest_addr.x25_addr[0] == '\0') ? "*" : s->protinfo.x25->dest_addr.x25_addr,
- (s->protinfo.x25->source_addr.x25_addr[0] == '\0') ? "*" : s->protinfo.x25->source_addr.x25_addr,
+ !x25->dest_addr.x25_addr[0] ? "*" :
+ x25->dest_addr.x25_addr,
+ !x25->source_addr.x25_addr[0] ? "*" :
+ x25->source_addr.x25_addr,
devname,
- s->protinfo.x25->lci & 0x0FFF,
- s->protinfo.x25->state,
- s->protinfo.x25->vs,
- s->protinfo.x25->vr,
- s->protinfo.x25->va,
+ x25->lci & 0x0FFF,
+ x25->state,
+ x25->vs,
+ x25->vr,
+ x25->va,
x25_display_timer(s) / HZ,
- s->protinfo.x25->t2 / HZ,
- s->protinfo.x25->t21 / HZ,
- s->protinfo.x25->t22 / HZ,
- s->protinfo.x25->t23 / HZ,
+ x25->t2 / HZ,
+ x25->t21 / HZ,
+ x25->t22 / HZ,
+ x25->t23 / HZ,
atomic_read(&s->wmem_alloc),
atomic_read(&s->rmem_alloc),
s->socket != NULL ? s->socket->inode->i_ino : 0L);
@@ -1306,7 +1321,7 @@ void x25_kill_by_neigh(struct x25_neigh *neigh)
struct sock *s;
for( s=x25_list; s != NULL; s=s->next){
- if( s->protinfo.x25->neighbour == neigh )
+ if (x25_sk(s)->neighbour == neigh)
x25_disconnect(s, ENETUNREACH, 0, 0);
}
}
diff --git a/net/x25/x25_facilities.c b/net/x25/x25_facilities.c
index 95411fa4b..f64683906 100644
--- a/net/x25/x25_facilities.c
+++ b/net/x25/x25_facilities.c
@@ -156,17 +156,18 @@ int x25_create_facilities(unsigned char *buffer, struct x25_facilities *faciliti
*/
int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk, struct x25_facilities *new)
{
+ x25_cb *x25 = x25_sk(sk);
struct x25_facilities *ours;
struct x25_facilities theirs;
int len;
memset(&theirs, 0x00, sizeof(struct x25_facilities));
- ours = &sk->protinfo.x25->facilities;
+ ours = &x25->facilities;
*new = *ours;
- len = x25_parse_facilities(skb, &theirs, &sk->protinfo.x25->vc_facil_mask);
+ len = x25_parse_facilities(skb, &theirs, &x25->vc_facil_mask);
/*
* They want reverse charging, we won't accept it.
diff --git a/net/x25/x25_in.c b/net/x25/x25_in.c
index 93fa6d7ef..0df826f47 100644
--- a/net/x25/x25_in.c
+++ b/net/x25/x25_in.c
@@ -37,6 +37,7 @@
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/ip.h> /* For ip_rcv */
+#include <net/tcp.h>
#include <asm/system.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
@@ -46,37 +47,40 @@
static int x25_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
{
struct sk_buff *skbo, *skbn = skb;
+ x25_cb *x25 = x25_sk(sk);
if (more) {
- sk->protinfo.x25->fraglen += skb->len;
- skb_queue_tail(&sk->protinfo.x25->fragment_queue, skb);
+ x25->fraglen += skb->len;
+ skb_queue_tail(&x25->fragment_queue, skb);
skb_set_owner_r(skb, sk);
return 0;
}
- if (!more && sk->protinfo.x25->fraglen > 0) { /* End of fragment */
- int len = sk->protinfo.x25->fraglen + skb->len;
+ if (!more && x25->fraglen > 0) { /* End of fragment */
+ int len = x25->fraglen + skb->len;
if ((skbn = alloc_skb(len, GFP_ATOMIC)) == NULL){
kfree_skb(skb);
return 1;
}
- skb_queue_tail(&sk->protinfo.x25->fragment_queue, skb);
+ skb_queue_tail(&x25->fragment_queue, skb);
skbn->h.raw = skbn->data;
- skbo = skb_dequeue(&sk->protinfo.x25->fragment_queue);
+ skbo = skb_dequeue(&x25->fragment_queue);
memcpy(skb_put(skbn, skbo->len), skbo->data, skbo->len);
kfree_skb(skbo);
- while ((skbo = skb_dequeue(&sk->protinfo.x25->fragment_queue)) != NULL) {
- skb_pull(skbo, (sk->protinfo.x25->neighbour->extended) ? X25_EXT_MIN_LEN : X25_STD_MIN_LEN);
+ while ((skbo =
+ skb_dequeue(&x25->fragment_queue)) != NULL) {
+ skb_pull(skbo, (x25->neighbour->extended) ?
+ X25_EXT_MIN_LEN : X25_STD_MIN_LEN);
memcpy(skb_put(skbn, skbo->len), skbo->data, skbo->len);
kfree_skb(skbo);
}
- sk->protinfo.x25->fraglen = 0;
+ x25->fraglen = 0;
}
skb_set_owner_r(skbn, sk);
@@ -97,33 +101,37 @@ static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametyp
x25_address source_addr, dest_addr;
switch (frametype) {
+ case X25_CALL_ACCEPTED: {
+ x25_cb *x25 = x25_sk(sk);
- case X25_CALL_ACCEPTED:
x25_stop_timer(sk);
- sk->protinfo.x25->condition = 0x00;
- sk->protinfo.x25->vs = 0;
- sk->protinfo.x25->va = 0;
- sk->protinfo.x25->vr = 0;
- sk->protinfo.x25->vl = 0;
- sk->protinfo.x25->state = X25_STATE_3;
- sk->state = TCP_ESTABLISHED;
+ x25->condition = 0x00;
+ x25->vs = 0;
+ x25->va = 0;
+ x25->vr = 0;
+ x25->vl = 0;
+ x25->state = X25_STATE_3;
+ sk->state = TCP_ESTABLISHED;
/*
* Parse the data in the frame.
*/
skb_pull(skb, X25_STD_MIN_LEN);
skb_pull(skb, x25_addr_ntoa(skb->data, &source_addr, &dest_addr));
- skb_pull(skb, x25_parse_facilities(skb, &sk->protinfo.x25->facilities, &sk->protinfo.x25->vc_facil_mask));
+ skb_pull(skb,
+ x25_parse_facilities(skb, &x25->facilities,
+ &x25->vc_facil_mask));
/*
* Copy any Call User Data.
*/
if (skb->len >= 0) {
- memcpy(sk->protinfo.x25->calluserdata.cuddata, skb->data, skb->len);
- sk->protinfo.x25->calluserdata.cudlength = skb->len;
+ memcpy(x25->calluserdata.cuddata, skb->data,
+ skb->len);
+ x25->calluserdata.cudlength = skb->len;
}
if (!sk->dead)
sk->state_change(sk);
break;
-
+ }
case X25_CLEAR_REQUEST:
x25_write_internal(sk, X25_CLEAR_CONFIRMATION);
x25_disconnect(sk, ECONNREFUSED, skb->data[3], skb->data[4]);
@@ -170,19 +178,20 @@ static int x25_state3_machine(struct sock *sk, struct sk_buff *skb, int frametyp
{
int queued = 0;
int modulus;
+ x25_cb *x25 = x25_sk(sk);
- modulus = (sk->protinfo.x25->neighbour->extended) ? X25_EMODULUS : X25_SMODULUS;
+ modulus = (x25->neighbour->extended) ? X25_EMODULUS : X25_SMODULUS;
switch (frametype) {
case X25_RESET_REQUEST:
x25_write_internal(sk, X25_RESET_CONFIRMATION);
x25_stop_timer(sk);
- sk->protinfo.x25->condition = 0x00;
- sk->protinfo.x25->vs = 0;
- sk->protinfo.x25->vr = 0;
- sk->protinfo.x25->va = 0;
- sk->protinfo.x25->vl = 0;
+ x25->condition = 0x00;
+ x25->vs = 0;
+ x25->vr = 0;
+ x25->va = 0;
+ x25->vl = 0;
x25_requeue_frames(sk);
break;
@@ -197,74 +206,73 @@ static int x25_state3_machine(struct sock *sk, struct sk_buff *skb, int frametyp
x25_clear_queues(sk);
x25_write_internal(sk, X25_RESET_REQUEST);
x25_start_t22timer(sk);
- sk->protinfo.x25->condition = 0x00;
- sk->protinfo.x25->vs = 0;
- sk->protinfo.x25->vr = 0;
- sk->protinfo.x25->va = 0;
- sk->protinfo.x25->vl = 0;
- sk->protinfo.x25->state = X25_STATE_4;
+ x25->condition = 0x00;
+ x25->vs = 0;
+ x25->vr = 0;
+ x25->va = 0;
+ x25->vl = 0;
+ x25->state = X25_STATE_4;
} else {
x25_frames_acked(sk, nr);
if (frametype == X25_RNR) {
- sk->protinfo.x25->condition |= X25_COND_PEER_RX_BUSY;
+ x25->condition |= X25_COND_PEER_RX_BUSY;
} else {
- sk->protinfo.x25->condition &= ~X25_COND_PEER_RX_BUSY;
+ x25->condition &= ~X25_COND_PEER_RX_BUSY;
}
}
break;
case X25_DATA: /* XXX */
- sk->protinfo.x25->condition &= ~X25_COND_PEER_RX_BUSY;
- if ((ns!=sk->protinfo.x25->vr) ||
- !x25_validate_nr(sk, nr)) {
+ x25->condition &= ~X25_COND_PEER_RX_BUSY;
+ if ((ns != x25->vr) || !x25_validate_nr(sk, nr)) {
x25_clear_queues(sk);
x25_write_internal(sk, X25_RESET_REQUEST);
x25_start_t22timer(sk);
- sk->protinfo.x25->condition = 0x00;
- sk->protinfo.x25->vs = 0;
- sk->protinfo.x25->vr = 0;
- sk->protinfo.x25->va = 0;
- sk->protinfo.x25->vl = 0;
- sk->protinfo.x25->state = X25_STATE_4;
+ x25->condition = 0x00;
+ x25->vs = 0;
+ x25->vr = 0;
+ x25->va = 0;
+ x25->vl = 0;
+ x25->state = X25_STATE_4;
break;
}
x25_frames_acked(sk, nr);
- if (ns == sk->protinfo.x25->vr) {
+ if (ns == x25->vr) {
if (x25_queue_rx_frame(sk, skb, m) == 0) {
- sk->protinfo.x25->vr = (sk->protinfo.x25->vr + 1) % modulus;
+ x25->vr = (x25->vr + 1) % modulus;
queued = 1;
} else {
/* Should never happen */
x25_clear_queues(sk);
x25_write_internal(sk, X25_RESET_REQUEST);
x25_start_t22timer(sk);
- sk->protinfo.x25->condition = 0x00;
- sk->protinfo.x25->vs = 0;
- sk->protinfo.x25->vr = 0;
- sk->protinfo.x25->va = 0;
- sk->protinfo.x25->vl = 0;
- sk->protinfo.x25->state = X25_STATE_4;
+ x25->condition = 0x00;
+ x25->vs = 0;
+ x25->vr = 0;
+ x25->va = 0;
+ x25->vl = 0;
+ x25->state = X25_STATE_4;
break;
}
if (atomic_read(&sk->rmem_alloc) > (sk->rcvbuf / 2))
- sk->protinfo.x25->condition |= X25_COND_OWN_RX_BUSY;
+ x25->condition |= X25_COND_OWN_RX_BUSY;
}
/*
* If the window is full Ack it immediately, else
* start the holdback timer.
*/
- if (((sk->protinfo.x25->vl + sk->protinfo.x25->facilities.winsize_in) % modulus) == sk->protinfo.x25->vr) {
- sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING;
+ if (((x25->vl + x25->facilities.winsize_in) % modulus) == x25->vr) {
+ x25->condition &= ~X25_COND_ACK_PENDING;
x25_stop_timer(sk);
x25_enquiry_response(sk);
} else {
- sk->protinfo.x25->condition |= X25_COND_ACK_PENDING;
+ x25->condition |= X25_COND_ACK_PENDING;
x25_start_t2timer(sk);
}
break;
case X25_INTERRUPT_CONFIRMATION:
- sk->protinfo.x25->intflag = 0;
+ x25->intflag = 0;
break;
case X25_INTERRUPT:
@@ -272,7 +280,7 @@ static int x25_state3_machine(struct sock *sk, struct sk_buff *skb, int frametyp
queued = (sock_queue_rcv_skb(sk, skb) == 0);
} else {
skb_set_owner_r(skb, sk);
- skb_queue_tail(&sk->protinfo.x25->interrupt_in_queue, skb);
+ skb_queue_tail(&x25->interrupt_in_queue, skb);
queued = 1;
}
if (sk->proc != 0) {
@@ -304,17 +312,19 @@ static int x25_state4_machine(struct sock *sk, struct sk_buff *skb, int frametyp
case X25_RESET_REQUEST:
x25_write_internal(sk, X25_RESET_CONFIRMATION);
- case X25_RESET_CONFIRMATION:
+ case X25_RESET_CONFIRMATION: {
+ x25_cb *x25 = x25_sk(sk);
+
x25_stop_timer(sk);
- sk->protinfo.x25->condition = 0x00;
- sk->protinfo.x25->va = 0;
- sk->protinfo.x25->vr = 0;
- sk->protinfo.x25->vs = 0;
- sk->protinfo.x25->vl = 0;
- sk->protinfo.x25->state = X25_STATE_3;
+ x25->condition = 0x00;
+ x25->va = 0;
+ x25->vr = 0;
+ x25->vs = 0;
+ x25->vl = 0;
+ x25->state = X25_STATE_3;
x25_requeue_frames(sk);
break;
-
+ }
case X25_CLEAR_REQUEST:
x25_write_internal(sk, X25_CLEAR_CONFIRMATION);
x25_disconnect(sk, 0, skb->data[3], skb->data[4]);
@@ -330,14 +340,15 @@ static int x25_state4_machine(struct sock *sk, struct sk_buff *skb, int frametyp
/* Higher level upcall for a LAPB frame */
int x25_process_rx_frame(struct sock *sk, struct sk_buff *skb)
{
+ x25_cb *x25 = x25_sk(sk);
int queued = 0, frametype, ns, nr, q, d, m;
- if (sk->protinfo.x25->state == X25_STATE_0)
+ if (x25->state == X25_STATE_0)
return 0;
frametype = x25_decode(sk, skb, &ns, &nr, &q, &d, &m);
- switch (sk->protinfo.x25->state) {
+ switch (x25->state) {
case X25_STATE_1:
queued = x25_state1_machine(sk, skb, frametype);
break;
diff --git a/net/x25/x25_out.c b/net/x25/x25_out.c
index e56b2d1ee..c4024538d 100644
--- a/net/x25/x25_out.c
+++ b/net/x25/x25_out.c
@@ -64,11 +64,12 @@ int x25_output(struct sock *sk, struct sk_buff *skb)
{
struct sk_buff *skbn;
unsigned char header[X25_EXT_MIN_LEN];
- int err, frontlen, len, header_len, max_len;
+ int err, frontlen, len;
int sent=0, noblock = X25_SKB_CB(skb)->flags & MSG_DONTWAIT;
-
- header_len = (sk->protinfo.x25->neighbour->extended) ? X25_EXT_MIN_LEN : X25_STD_MIN_LEN;
- max_len = x25_pacsize_to_bytes(sk->protinfo.x25->facilities.pacsize_out);
+ x25_cb *x25 = x25_sk(sk);
+ int header_len = x25->neighbour->extended ? X25_EXT_MIN_LEN :
+ X25_STD_MIN_LEN;
+ int max_len = x25_pacsize_to_bytes(x25->facilities.pacsize_out);
if (skb->len - header_len > max_len) {
/* Save a copy of the Header */
@@ -100,7 +101,7 @@ int x25_output(struct sock *sk, struct sk_buff *skb)
memcpy(skbn->data, header, header_len);
if (skb->len > 0) {
- if (sk->protinfo.x25->neighbour->extended)
+ if (x25->neighbour->extended)
skbn->data[3] |= X25_EXT_M_BIT;
else
skbn->data[2] |= X25_STD_M_BIT;
@@ -124,20 +125,22 @@ int x25_output(struct sock *sk, struct sk_buff *skb)
*/
static void x25_send_iframe(struct sock *sk, struct sk_buff *skb)
{
+ x25_cb *x25 = x25_sk(sk);
+
if (skb == NULL)
return;
- if (sk->protinfo.x25->neighbour->extended) {
- skb->data[2] = (sk->protinfo.x25->vs << 1) & 0xFE;
+ if (x25->neighbour->extended) {
+ skb->data[2] = (x25->vs << 1) & 0xFE;
skb->data[3] &= X25_EXT_M_BIT;
- skb->data[3] |= (sk->protinfo.x25->vr << 1) & 0xFE;
+ skb->data[3] |= (x25->vr << 1) & 0xFE;
} else {
skb->data[2] &= X25_STD_M_BIT;
- skb->data[2] |= (sk->protinfo.x25->vs << 1) & 0x0E;
- skb->data[2] |= (sk->protinfo.x25->vr << 5) & 0xE0;
+ skb->data[2] |= (x25->vs << 1) & 0x0E;
+ skb->data[2] |= (x25->vr << 5) & 0xE0;
}
- x25_transmit_link(skb, sk->protinfo.x25->neighbour);
+ x25_transmit_link(skb, x25->neighbour);
}
void x25_kick(struct sock *sk)
@@ -145,34 +148,35 @@ void x25_kick(struct sock *sk)
struct sk_buff *skb, *skbn;
unsigned short start, end;
int modulus;
+ x25_cb *x25 = x25_sk(sk);
- if (sk->protinfo.x25->state != X25_STATE_3)
+ if (x25->state != X25_STATE_3)
return;
/*
* Transmit interrupt data.
*/
- if (!sk->protinfo.x25->intflag && skb_peek(&sk->protinfo.x25->interrupt_out_queue) != NULL) {
- sk->protinfo.x25->intflag = 1;
- skb = skb_dequeue(&sk->protinfo.x25->interrupt_out_queue);
- x25_transmit_link(skb, sk->protinfo.x25->neighbour);
+ if (!x25->intflag && skb_peek(&x25->interrupt_out_queue) != NULL) {
+ x25->intflag = 1;
+ skb = skb_dequeue(&x25->interrupt_out_queue);
+ x25_transmit_link(skb, x25->neighbour);
}
- if (sk->protinfo.x25->condition & X25_COND_PEER_RX_BUSY)
+ if (x25->condition & X25_COND_PEER_RX_BUSY)
return;
if (skb_peek(&sk->write_queue) == NULL)
return;
- modulus = (sk->protinfo.x25->neighbour->extended) ? X25_EMODULUS : X25_SMODULUS;
+ modulus = (x25->neighbour->extended) ? X25_EMODULUS : X25_SMODULUS;
- start = (skb_peek(&sk->protinfo.x25->ack_queue) == NULL) ? sk->protinfo.x25->va : sk->protinfo.x25->vs;
- end = (sk->protinfo.x25->va + sk->protinfo.x25->facilities.winsize_out) % modulus;
+ start = (skb_peek(&x25->ack_queue) == NULL) ? x25->va : x25->vs;
+ end = (x25->va + x25->facilities.winsize_out) % modulus;
if (start == end)
return;
- sk->protinfo.x25->vs = start;
+ x25->vs = start;
/*
* Transmit data until either we're out of data to send or
@@ -194,17 +198,17 @@ void x25_kick(struct sock *sk)
*/
x25_send_iframe(sk, skbn);
- sk->protinfo.x25->vs = (sk->protinfo.x25->vs + 1) % modulus;
+ x25->vs = (x25->vs + 1) % modulus;
/*
* Requeue the original data frame.
*/
- skb_queue_tail(&sk->protinfo.x25->ack_queue, skb);
+ skb_queue_tail(&x25->ack_queue, skb);
- } while (sk->protinfo.x25->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL);
+ } while (x25->vs != end && (skb = skb_dequeue(&sk->write_queue)) != NULL);
- sk->protinfo.x25->vl = sk->protinfo.x25->vr;
- sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING;
+ x25->vl = x25->vr;
+ x25->condition &= ~X25_COND_ACK_PENDING;
x25_stop_timer(sk);
}
@@ -216,13 +220,15 @@ void x25_kick(struct sock *sk)
void x25_enquiry_response(struct sock *sk)
{
- if (sk->protinfo.x25->condition & X25_COND_OWN_RX_BUSY)
+ x25_cb *x25 = x25_sk(sk);
+
+ if (x25->condition & X25_COND_OWN_RX_BUSY)
x25_write_internal(sk, X25_RNR);
else
x25_write_internal(sk, X25_RR);
- sk->protinfo.x25->vl = sk->protinfo.x25->vr;
- sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING;
+ x25->vl = x25->vr;
+ x25->condition &= ~X25_COND_ACK_PENDING;
x25_stop_timer(sk);
}
diff --git a/net/x25/x25_subr.c b/net/x25/x25_subr.c
index 0c41d5c60..1a14269bc 100644
--- a/net/x25/x25_subr.c
+++ b/net/x25/x25_subr.c
@@ -34,6 +34,7 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
+#include <net/tcp.h>
#include <asm/system.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
@@ -45,11 +46,13 @@
*/
void x25_clear_queues(struct sock *sk)
{
+ x25_cb *x25 = x25_sk(sk);
+
skb_queue_purge(&sk->write_queue);
- skb_queue_purge(&sk->protinfo.x25->ack_queue);
- skb_queue_purge(&sk->protinfo.x25->interrupt_in_queue);
- skb_queue_purge(&sk->protinfo.x25->interrupt_out_queue);
- skb_queue_purge(&sk->protinfo.x25->fragment_queue);
+ skb_queue_purge(&x25->ack_queue);
+ skb_queue_purge(&x25->interrupt_in_queue);
+ skb_queue_purge(&x25->interrupt_out_queue);
+ skb_queue_purge(&x25->fragment_queue);
}
@@ -61,19 +64,17 @@ void x25_clear_queues(struct sock *sk)
void x25_frames_acked(struct sock *sk, unsigned short nr)
{
struct sk_buff *skb;
- int modulus = sk->protinfo.x25->neighbour->extended ? X25_EMODULUS :
- X25_SMODULUS;
+ x25_cb *x25 = x25_sk(sk);
+ int modulus = x25->neighbour->extended ? X25_EMODULUS : X25_SMODULUS;
/*
* Remove all the ack-ed frames from the ack queue.
*/
- if (sk->protinfo.x25->va != nr)
- while (skb_peek(&sk->protinfo.x25->ack_queue) != NULL &&
- sk->protinfo.x25->va != nr) {
- skb = skb_dequeue(&sk->protinfo.x25->ack_queue);
+ if (x25->va != nr)
+ while (skb_peek(&x25->ack_queue) && x25->va != nr) {
+ skb = skb_dequeue(&x25->ack_queue);
kfree_skb(skb);
- sk->protinfo.x25->va = (sk->protinfo.x25->va + 1) %
- modulus;
+ x25->va = (x25->va + 1) % modulus;
}
}
@@ -86,7 +87,7 @@ void x25_requeue_frames(struct sock *sk)
* up by x25_kick. This arrangement handles the possibility of an empty
* output queue.
*/
- while ((skb = skb_dequeue(&sk->protinfo.x25->ack_queue)) != NULL) {
+ while ((skb = skb_dequeue(&x25_sk(sk)->ack_queue)) != NULL) {
if (skb_prev == NULL)
skb_queue_head(&sk->write_queue, skb);
else
@@ -101,16 +102,16 @@ void x25_requeue_frames(struct sock *sk)
*/
int x25_validate_nr(struct sock *sk, unsigned short nr)
{
- unsigned short vc = sk->protinfo.x25->va;
- int modulus = sk->protinfo.x25->neighbour->extended ? X25_EMODULUS :
- X25_SMODULUS;
+ x25_cb *x25 = x25_sk(sk);
+ unsigned short vc = x25->va;
+ int modulus = x25->neighbour->extended ? X25_EMODULUS : X25_SMODULUS;
- while (vc != sk->protinfo.x25->vs) {
+ while (vc != x25->vs) {
if (nr == vc) return 1;
vc = (vc + 1) % modulus;
}
- return nr == sk->protinfo.x25->vs ? 1 : 0;
+ return nr == x25->vs ? 1 : 0;
}
/*
@@ -119,6 +120,7 @@ int x25_validate_nr(struct sock *sk, unsigned short nr)
*/
void x25_write_internal(struct sock *sk, int frametype)
{
+ x25_cb *x25 = x25_sk(sk);
struct sk_buff *skb;
unsigned char *dptr;
unsigned char facilities[X25_MAX_FAC_LEN];
@@ -172,10 +174,10 @@ void x25_write_internal(struct sock *sk, int frametype)
*/
dptr = skb_put(skb, 2);
- lci1 = (sk->protinfo.x25->lci >> 8) & 0x0F;
- lci2 = (sk->protinfo.x25->lci >> 0) & 0xFF;
+ lci1 = (x25->lci >> 8) & 0x0F;
+ lci2 = (x25->lci >> 0) & 0xFF;
- if (sk->protinfo.x25->neighbour->extended) {
+ if (x25->neighbour->extended) {
*dptr++ = lci1 | X25_GFI_EXTSEQ;
*dptr++ = lci2;
} else {
@@ -191,27 +193,34 @@ void x25_write_internal(struct sock *sk, int frametype)
case X25_CALL_REQUEST:
dptr = skb_put(skb, 1);
*dptr++ = X25_CALL_REQUEST;
- len = x25_addr_aton(addresses, &sk->protinfo.x25->dest_addr, &sk->protinfo.x25->source_addr);
+ len = x25_addr_aton(addresses, &x25->dest_addr,
+ &x25->source_addr);
dptr = skb_put(skb, len);
memcpy(dptr, addresses, len);
- len = x25_create_facilities(facilities, &sk->protinfo.x25->facilities, sk->protinfo.x25->neighbour->global_facil_mask);
+ len = x25_create_facilities(facilities,
+ &x25->facilities,
+ x25->neighbour->global_facil_mask);
dptr = skb_put(skb, len);
memcpy(dptr, facilities, len);
- dptr = skb_put(skb, sk->protinfo.x25->calluserdata.cudlength);
- memcpy(dptr, sk->protinfo.x25->calluserdata.cuddata, sk->protinfo.x25->calluserdata.cudlength);
- sk->protinfo.x25->calluserdata.cudlength = 0;
+ dptr = skb_put(skb, x25->calluserdata.cudlength);
+ memcpy(dptr, x25->calluserdata.cuddata,
+ x25->calluserdata.cudlength);
+ x25->calluserdata.cudlength = 0;
break;
case X25_CALL_ACCEPTED:
dptr = skb_put(skb, 2);
*dptr++ = X25_CALL_ACCEPTED;
*dptr++ = 0x00; /* Address lengths */
- len = x25_create_facilities(facilities, &sk->protinfo.x25->facilities, sk->protinfo.x25->vc_facil_mask);
+ len = x25_create_facilities(facilities,
+ &x25->facilities,
+ x25->vc_facil_mask);
dptr = skb_put(skb, len);
memcpy(dptr, facilities, len);
- dptr = skb_put(skb, sk->protinfo.x25->calluserdata.cudlength);
- memcpy(dptr, sk->protinfo.x25->calluserdata.cuddata, sk->protinfo.x25->calluserdata.cudlength);
- sk->protinfo.x25->calluserdata.cudlength = 0;
+ dptr = skb_put(skb, x25->calluserdata.cudlength);
+ memcpy(dptr, x25->calluserdata.cuddata,
+ x25->calluserdata.cudlength);
+ x25->calluserdata.cudlength = 0;
break;
case X25_CLEAR_REQUEST:
@@ -225,14 +234,14 @@ void x25_write_internal(struct sock *sk, int frametype)
case X25_RR:
case X25_RNR:
case X25_REJ:
- if (sk->protinfo.x25->neighbour->extended) {
+ if (x25->neighbour->extended) {
dptr = skb_put(skb, 2);
*dptr++ = frametype;
- *dptr++ = (sk->protinfo.x25->vr << 1) & 0xFE;
+ *dptr++ = (x25->vr << 1) & 0xFE;
} else {
dptr = skb_put(skb, 1);
*dptr = frametype;
- *dptr++ |= (sk->protinfo.x25->vr << 5) & 0xE0;
+ *dptr++ |= (x25->vr << 5) & 0xE0;
}
break;
@@ -244,7 +253,7 @@ void x25_write_internal(struct sock *sk, int frametype)
break;
}
- x25_transmit_link(skb, sk->protinfo.x25->neighbour);
+ x25_transmit_link(skb, x25->neighbour);
}
/*
@@ -253,6 +262,7 @@ void x25_write_internal(struct sock *sk, int frametype)
int x25_decode(struct sock *sk, struct sk_buff *skb, int *ns, int *nr, int *q,
int *d, int *m)
{
+ x25_cb *x25 = x25_sk(sk);
unsigned char *frame = skb->data;
*ns = *nr = *q = *d = *m = 0;
@@ -274,7 +284,7 @@ int x25_decode(struct sock *sk, struct sk_buff *skb, int *ns, int *nr, int *q,
return frame[2];
}
- if (sk->protinfo.x25->neighbour->extended) {
+ if (x25->neighbour->extended) {
if (frame[2] == X25_RR ||
frame[2] == X25_RNR ||
frame[2] == X25_REJ) {
@@ -290,7 +300,7 @@ int x25_decode(struct sock *sk, struct sk_buff *skb, int *ns, int *nr, int *q,
}
}
- if (sk->protinfo.x25->neighbour->extended) {
+ if (x25->neighbour->extended) {
if ((frame[2] & 0x01) == X25_DATA) {
*q = (frame[0] & X25_Q_BIT) == X25_Q_BIT;
*d = (frame[0] & X25_D_BIT) == X25_D_BIT;
@@ -319,14 +329,16 @@ int x25_decode(struct sock *sk, struct sk_buff *skb, int *ns, int *nr, int *q,
void x25_disconnect(struct sock *sk, int reason, unsigned char cause,
unsigned char diagnostic)
{
+ x25_cb *x25 = x25_sk(sk);
+
x25_clear_queues(sk);
x25_stop_timer(sk);
- sk->protinfo.x25->lci = 0;
- sk->protinfo.x25->state = X25_STATE_0;
+ x25->lci = 0;
+ x25->state = X25_STATE_0;
- sk->protinfo.x25->causediag.cause = cause;
- sk->protinfo.x25->causediag.diagnostic = diagnostic;
+ x25->causediag.cause = cause;
+ x25->causediag.diagnostic = diagnostic;
sk->state = TCP_CLOSE;
sk->err = reason;
@@ -344,11 +356,13 @@ void x25_disconnect(struct sock *sk, int reason, unsigned char cause,
*/
void x25_check_rbuf(struct sock *sk)
{
+ x25_cb *x25 = x25_sk(sk);
+
if (atomic_read(&sk->rmem_alloc) < (sk->rcvbuf / 2) &&
- (sk->protinfo.x25->condition & X25_COND_OWN_RX_BUSY)) {
- sk->protinfo.x25->condition &= ~X25_COND_OWN_RX_BUSY;
- sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING;
- sk->protinfo.x25->vl = sk->protinfo.x25->vr;
+ (x25->condition & X25_COND_OWN_RX_BUSY)) {
+ x25->condition &= ~X25_COND_OWN_RX_BUSY;
+ x25->condition &= ~X25_COND_ACK_PENDING;
+ x25->vl = x25->vr;
x25_write_internal(sk, X25_RR);
x25_stop_timer(sk);
}
diff --git a/net/x25/x25_timer.c b/net/x25/x25_timer.c
index b808490b3..5568d19b1 100644
--- a/net/x25/x25_timer.c
+++ b/net/x25/x25_timer.c
@@ -32,6 +32,7 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
+#include <net/tcp.h>
#include <asm/system.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
@@ -59,59 +60,69 @@ void x25_stop_heartbeat(struct sock *sk)
void x25_start_t2timer(struct sock *sk)
{
- del_timer(&sk->protinfo.x25->timer);
+ x25_cb *x25 = x25_sk(sk);
- sk->protinfo.x25->timer.data = (unsigned long)sk;
- sk->protinfo.x25->timer.function = &x25_timer_expiry;
- sk->protinfo.x25->timer.expires = jiffies + sk->protinfo.x25->t2;
+ del_timer(&x25->timer);
- add_timer(&sk->protinfo.x25->timer);
+ x25->timer.data = (unsigned long)sk;
+ x25->timer.function = &x25_timer_expiry;
+ x25->timer.expires = jiffies + x25->t2;
+
+ add_timer(&x25->timer);
}
void x25_start_t21timer(struct sock *sk)
{
- del_timer(&sk->protinfo.x25->timer);
+ x25_cb *x25 = x25_sk(sk);
+
+ del_timer(&x25->timer);
- sk->protinfo.x25->timer.data = (unsigned long)sk;
- sk->protinfo.x25->timer.function = &x25_timer_expiry;
- sk->protinfo.x25->timer.expires = jiffies + sk->protinfo.x25->t21;
+ x25->timer.data = (unsigned long)sk;
+ x25->timer.function = &x25_timer_expiry;
+ x25->timer.expires = jiffies + x25->t21;
- add_timer(&sk->protinfo.x25->timer);
+ add_timer(&x25->timer);
}
void x25_start_t22timer(struct sock *sk)
{
- del_timer(&sk->protinfo.x25->timer);
+ x25_cb *x25 = x25_sk(sk);
+
+ del_timer(&x25->timer);
- sk->protinfo.x25->timer.data = (unsigned long)sk;
- sk->protinfo.x25->timer.function = &x25_timer_expiry;
- sk->protinfo.x25->timer.expires = jiffies + sk->protinfo.x25->t22;
+ x25->timer.data = (unsigned long)sk;
+ x25->timer.function = &x25_timer_expiry;
+ x25->timer.expires = jiffies + x25->t22;
- add_timer(&sk->protinfo.x25->timer);
+ add_timer(&x25->timer);
}
void x25_start_t23timer(struct sock *sk)
{
- del_timer(&sk->protinfo.x25->timer);
+ x25_cb *x25 = x25_sk(sk);
- sk->protinfo.x25->timer.data = (unsigned long)sk;
- sk->protinfo.x25->timer.function = &x25_timer_expiry;
- sk->protinfo.x25->timer.expires = jiffies + sk->protinfo.x25->t23;
+ del_timer(&x25->timer);
- add_timer(&sk->protinfo.x25->timer);
+ x25->timer.data = (unsigned long)sk;
+ x25->timer.function = &x25_timer_expiry;
+ x25->timer.expires = jiffies + x25->t23;
+
+ add_timer(&x25->timer);
}
void x25_stop_timer(struct sock *sk)
{
- del_timer(&sk->protinfo.x25->timer);
+ del_timer(&x25_sk(sk)->timer);
}
unsigned long x25_display_timer(struct sock *sk)
{
- if (!timer_pending(&sk->protinfo.x25->timer))
+ x25_cb *x25 = x25_sk(sk);
+
+ if (!timer_pending(&x25->timer))
return 0;
- return sk->protinfo.x25->timer.expires - jiffies;
+ return x25->timer.expires - jiffies;
}
static void x25_heartbeat_expiry(unsigned long param)
@@ -123,7 +134,7 @@ static void x25_heartbeat_expiry(unsigned long param)
goto restart_heartbeat;
}
- switch (sk->protinfo.x25->state) {
+ switch (x25_sk(sk)->state) {
case X25_STATE_0:
/* Magic here: If we listen() and a new link dies before it
@@ -153,11 +164,13 @@ static void x25_heartbeat_expiry(unsigned long param)
*/
static inline void x25_do_timer_expiry(struct sock * sk)
{
- switch (sk->protinfo.x25->state) {
+ x25_cb *x25 = x25_sk(sk);
+
+ switch (x25->state) {
case X25_STATE_3: /* T2 */
- if (sk->protinfo.x25->condition & X25_COND_ACK_PENDING) {
- sk->protinfo.x25->condition &= ~X25_COND_ACK_PENDING;
+ if (x25->condition & X25_COND_ACK_PENDING) {
+ x25->condition &= ~X25_COND_ACK_PENDING;
x25_enquiry_response(sk);
}
break;
@@ -165,7 +178,7 @@ static inline void x25_do_timer_expiry(struct sock * sk)
case X25_STATE_1: /* T21 */
case X25_STATE_4: /* T22 */
x25_write_internal(sk, X25_CLEAR_REQUEST);
- sk->protinfo.x25->state = X25_STATE_2;
+ x25->state = X25_STATE_2;
x25_start_t23timer(sk);
break;
@@ -181,7 +194,7 @@ static void x25_timer_expiry(unsigned long param)
bh_lock_sock(sk);
if (sk->lock.users) { /* can currently only occur in state 3 */
- if (sk->protinfo.x25->state == X25_STATE_3) {
+ if (x25_sk(sk)->state == X25_STATE_3) {
x25_start_t2timer(sk);
}
} else {