diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-11-23 02:00:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-11-23 02:00:47 +0000 |
commit | 06615f62b17d7de6e12d2f5ec6b88cf30af08413 (patch) | |
tree | 8766f208847d4876a6db619aebbf54d53b76eb44 /net/ipv4 | |
parent | fa9bdb574f4febb751848a685d9a9017e04e1d53 (diff) |
Merge with Linux 2.4.0-test10.
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/af_inet.c | 45 | ||||
-rw-r--r-- | net/ipv4/arp.c | 2 | ||||
-rw-r--r-- | net/ipv4/inetpeer.c | 2 | ||||
-rw-r--r-- | net/ipv4/ip_forward.c | 16 | ||||
-rw-r--r-- | net/ipv4/ip_gre.c | 2 | ||||
-rw-r--r-- | net/ipv4/ip_input.c | 8 | ||||
-rw-r--r-- | net/ipv4/ip_nat_dumb.c | 5 | ||||
-rw-r--r-- | net/ipv4/ip_output.c | 2 | ||||
-rw-r--r-- | net/ipv4/ip_sockglue.c | 34 | ||||
-rw-r--r-- | net/ipv4/ipip.c | 4 | ||||
-rw-r--r-- | net/ipv4/netfilter/ip_nat_standalone.c | 2 | ||||
-rw-r--r-- | net/ipv4/protocol.c | 2 | ||||
-rw-r--r-- | net/ipv4/raw.c | 8 | ||||
-rw-r--r-- | net/ipv4/route.c | 2 | ||||
-rw-r--r-- | net/ipv4/sysctl_net_ipv4.c | 8 | ||||
-rw-r--r-- | net/ipv4/tcp.c | 4 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 52 | ||||
-rw-r--r-- | net/ipv4/tcp_output.c | 4 | ||||
-rw-r--r-- | net/ipv4/tcp_timer.c | 2 | ||||
-rw-r--r-- | net/ipv4/udp.c | 29 | ||||
-rw-r--r-- | net/ipv4/utils.c | 2 |
21 files changed, 133 insertions, 102 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 69c6ff036..584814ad8 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.114 2000/09/18 05:59:48 davem Exp $ + * Version: $Id: af_inet.c,v 1.121 2000/10/24 21:26:18 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -107,6 +107,9 @@ #ifdef CONFIG_KMOD #include <linux/kmod.h> #endif +#ifdef CONFIG_NET_DIVERT +#include <linux/divert.h> +#endif /* CONFIG_NET_DIVERT */ #if defined(CONFIG_NET_RADIO) || defined(CONFIG_NET_PCMCIA_RADIO) #include <linux/wireless.h> /* Note : will define WIRELESS_EXT */ #endif /* CONFIG_NET_RADIO || CONFIG_NET_PCMCIA_RADIO */ @@ -444,6 +447,9 @@ int inet_release(struct socket *sock) return(0); } +/* It is off by default, see below. */ +int sysctl_ip_nonlocal_bind; + static int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct sockaddr_in *addr=(struct sockaddr_in *)uaddr; @@ -461,6 +467,21 @@ static int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr); + /* Not specified by any standard per-se, however it breaks too + * many applications when removed. It is unfortunate since + * allowing applications to make a non-local bind solves + * several problems with systems using dynamic addressing. + * (ie. your servers still start up even if your ISDN link + * is temporarily down) + */ + if (sysctl_ip_nonlocal_bind == 0 && + sk->protinfo.af_inet.freebind == 0 && + addr->sin_addr.s_addr != INADDR_ANY && + chk_addr_ret != RTN_LOCAL && + chk_addr_ret != RTN_MULTICAST && + chk_addr_ret != RTN_BROADCAST) + return -EADDRNOTAVAIL; + snum = ntohs(addr->sin_port); if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) return -EACCES; @@ -750,14 +771,15 @@ int inet_shutdown(struct socket *sock, int how) } switch (sk->state) { - default: + case TCP_CLOSE: + err = -ENOTCONN; + /* Hack to wake up other listeners, who can poll for + POLLHUP, even on eg. unconnected UDP sockets -- RR */ + default: sk->shutdown |= how; if (sk->prot->shutdown) sk->prot->shutdown(sk, how); break; - case TCP_CLOSE: - err = -ENOTCONN; - break; /* Remaining two branches are temporary solution for missing * close() in multithreaded environment. It is _not_ a good idea, @@ -847,6 +869,13 @@ static int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) if (br_ioctl_hook != NULL) return br_ioctl_hook(arg); #endif + case SIOCGIFDIVERT: + case SIOCSIFDIVERT: +#ifdef CONFIG_NET_DIVERT + return(divert_ioctl(cmd, (struct divert_cf *) arg)); +#else + return -ENOPKG; +#endif /* CONFIG_NET_DIVERT */ return -ENOPKG; case SIOCADDDLCI: @@ -946,7 +975,7 @@ extern void tcp_v4_init(struct net_proto_family *); * Called by socket.c on kernel startup. */ -void __init inet_proto_init(struct net_proto *pro) +static int __init inet_init(void) { struct sk_buff *dummy_skb; struct inet_protocol *p; @@ -956,7 +985,7 @@ void __init inet_proto_init(struct net_proto *pro) if (sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb)) { printk(KERN_CRIT "inet_proto_init: panic\n"); - return; + return -EINVAL; } /* @@ -1030,4 +1059,6 @@ void __init inet_proto_init(struct net_proto *pro) proc_net_create ("tcp", 0, tcp_get_info); proc_net_create ("udp", 0, udp_get_info); #endif /* CONFIG_PROC_FS */ + return 0; } +module_init(inet_init); diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index c173b9eb3..b410d1de4 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1,6 +1,6 @@ /* linux/net/inet/arp.c * - * Version: $Id: arp.c,v 1.88 2000/08/02 06:05:02 davem Exp $ + * Version: $Id: arp.c,v 1.90 2000/10/04 09:20:56 anton Exp $ * * Copyright (C) 1994 by Florian La Roche * diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c index cda89659c..8c103857c 100644 --- a/net/ipv4/inetpeer.c +++ b/net/ipv4/inetpeer.c @@ -3,7 +3,7 @@ * * This source is covered by the GNU GPL, the same as all kernel sources. * - * Version: $Id: inetpeer.c,v 1.2 2000/05/03 06:37:06 davem Exp $ + * Version: $Id: inetpeer.c,v 1.3 2000/10/03 07:29:00 anton Exp $ * * Authors: Andrey V. Savochkin <saw@msu.ru> */ diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c index 7d8efb6dd..7df6e72e3 100644 --- a/net/ipv4/ip_forward.c +++ b/net/ipv4/ip_forward.c @@ -5,7 +5,7 @@ * * The IP forwarding functionality. * - * Version: $Id: ip_forward.c,v 1.46 2000/01/09 02:19:37 davem Exp $ + * Version: $Id: ip_forward.c,v 1.47 2000/10/24 22:54:26 davem Exp $ * * Authors: see ip.c * @@ -63,13 +63,11 @@ static inline int ip_forward_finish(struct sk_buff *skb) dst_release(old_dst); } #endif - ip_send(skb); - return 0; + return (ip_send(skb)); } ip_forward_options(skb); - ip_send(skb); - return 0; + return (ip_send(skb)); } int ip_forward(struct sk_buff *skb) @@ -81,7 +79,7 @@ int ip_forward(struct sk_buff *skb) unsigned short mtu; if (IPCB(skb)->opt.router_alert && ip_call_ra_chain(skb)) - return 0; + return NET_RX_SUCCESS; if (skb->pkt_type != PACKET_HOST) goto drop; @@ -119,7 +117,7 @@ int ip_forward(struct sk_buff *skb) /* We are about to mangle packet. Copy it! */ if ((skb = skb_cow(skb, dev2->hard_header_len)) == NULL) - return -1; + return NET_RX_DROP; iph = skb->nh.iph; opt = &(IPCB(skb)->opt); @@ -138,7 +136,7 @@ int ip_forward(struct sk_buff *skb) if (rt->rt_flags & RTCF_NAT) { if (ip_do_nat(skb)) { kfree_skb(skb); - return -1; + return NET_RX_BAD; } } #endif @@ -163,5 +161,5 @@ too_many_hops: icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0); drop: kfree_skb(skb); - return -1; + return NET_RX_DROP; } diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index e7167aa65..f7b73adb8 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -1266,7 +1266,9 @@ int __init ipgre_init(void) #ifdef MODULE register_netdev(&ipgre_fb_tunnel_dev); #else + rtnl_lock(); register_netdevice(&ipgre_fb_tunnel_dev); + rtnl_unlock(); #endif inet_add_protocol(&ipgre_protocol); diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index bb76f7ce5..873030d0a 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -5,7 +5,7 @@ * * The Internet Protocol (IP) module. * - * Version: $Id: ip_input.c,v 1.49 2000/08/21 20:41:55 davem Exp $ + * Version: $Id: ip_input.c,v 1.50 2000/10/24 22:54:26 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -341,7 +341,7 @@ static inline int ip_rcv_finish(struct sk_buff *skb) skb = skb_cow(skb, skb_headroom(skb)); if (skb == NULL) - return 0; + return NET_RX_DROP; iph = skb->nh.iph; skb->ip_summed = 0; @@ -372,7 +372,7 @@ inhdr_error: IP_INC_STATS_BH(IpInHdrErrors); drop: kfree_skb(skb); - return(0); + return NET_RX_DROP; } /* @@ -429,6 +429,6 @@ inhdr_error: drop: kfree_skb(skb); out: - return(0); + return NET_RX_DROP; } diff --git a/net/ipv4/ip_nat_dumb.c b/net/ipv4/ip_nat_dumb.c index b45377af4..88e3ff9e2 100644 --- a/net/ipv4/ip_nat_dumb.c +++ b/net/ipv4/ip_nat_dumb.c @@ -5,7 +5,7 @@ * * Dumb Network Address Translation. * - * Version: $Id: ip_nat_dumb.c,v 1.9 1999/08/20 11:05:46 davem Exp $ + * Version: $Id: ip_nat_dumb.c,v 1.10 2000/10/24 22:54:26 davem Exp $ * * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> * @@ -152,8 +152,9 @@ ip_do_nat(struct sk_buff *skb) break; } } - return 0; + return NET_RX_SUCCESS; truncated: + /* should be return NET_RX_BAD; */ return -EINVAL; } diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 056767890..ce7618fe1 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.85 2000/08/31 23:39:12 davem Exp $ + * Version: $Id: ip_output.c,v 1.87 2000/10/25 20:07:22 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index a82e4be1f..f87921077 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.52 2000/09/09 08:26:04 davem Exp $ + * Version: $Id: ip_sockglue.c,v 1.53 2000/10/22 16:06:56 davem Exp $ * * Authors: see ip.c * @@ -372,21 +372,23 @@ out: /* * Socket option code for IP. This is the end of the line after any TCP,UDP etc options on * an IP socket. - * - * We implement IP_TOS (type of service), IP_TTL (time to live). */ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen) { int val=0,err; - if (optname == IP_PKTINFO || optname == IP_RECVTTL || - optname == IP_RECVTOS || optname == IP_RECVOPTS || - optname == IP_RETOPTS || optname == IP_TOS || - optname == IP_TTL || optname == IP_HDRINCL || - optname == IP_MTU_DISCOVER || optname == IP_RECVERR || - optname == IP_MULTICAST_TTL || optname == IP_MULTICAST_LOOP || - optname == IP_ROUTER_ALERT) { + if (level != SOL_IP) + return -ENOPROTOOPT; + + if (((1<<optname) & ((1<<IP_PKTINFO) | (1<<IP_RECVTTL) | + (1<<IP_RECVOPTS) | (1<<IP_RECVTOS) | + (1<<IP_RETOPTS) | (1<<IP_TOS) | + (1<<IP_TTL) | (1<<IP_HDRINCL) | + (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) | + (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND))) || + optname == IP_MULTICAST_TTL || + optname == IP_MULTICAST_LOOP) { if (optlen >= sizeof(int)) { if (get_user(val, (int *) optval)) return -EFAULT; @@ -400,9 +402,6 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt } /* If optlen==0, it is equivalent to val == 0 */ - - if (level != SOL_IP) - return -ENOPROTOOPT; #ifdef CONFIG_IP_MROUTE if (optname >= MRT_BASE && optname <= (MRT_BASE + 10)) @@ -612,6 +611,12 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int opt case IP_ROUTER_ALERT: err = ip_ra_control(sk, val ? 1 : 0, NULL); break; + + case IP_FREEBIND: + if (optlen<1) + goto e_inval; + sk->protinfo.af_inet.freebind = !!val; + break; default: #ifdef CONFIG_NETFILTER @@ -771,6 +776,9 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op len -= msg.msg_controllen; return put_user(len, optlen); } + case IP_FREEBIND: + val = sk->protinfo.af_inet.freebind; + break; default: #ifdef CONFIG_NETFILTER val = nf_getsockopt(sk, PF_INET, optname, optval, diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index eae29c0b0..a8cb239a8 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -1,7 +1,7 @@ /* * Linux NET3: IP/IP protocol decoder. * - * Version: $Id: ipip.c,v 1.39 2000/08/25 02:15:47 davem Exp $ + * Version: $Id: ipip.c,v 1.40 2000/10/28 17:19:25 davem Exp $ * * Authors: * Sam Lantinga (slouken@cs.ucdavis.edu) 02/01/95 @@ -894,7 +894,9 @@ int __init ipip_init(void) #ifdef MODULE register_netdev(&ipip_fb_tunnel_dev); #else + rtnl_lock(); register_netdevice(&ipip_fb_tunnel_dev); + rtnl_unlock(); #endif inet_add_protocol(&ipip_protocol); diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c index 10d09a6bd..e5fbe41af 100644 --- a/net/ipv4/netfilter/ip_nat_standalone.c +++ b/net/ipv4/netfilter/ip_nat_standalone.c @@ -72,7 +72,7 @@ ip_nat_fn(unsigned int hooknum, unreliable. */ if (!ct) { if (net_ratelimit()) - printk("NAT: %u dropping untracked packet %p %u %u.%u.%u.%u -> %u.%u.%u.%u\n", + printk(KERN_DEBUG "NAT: %u dropping untracked packet %p %u %u.%u.%u.%u -> %u.%u.%u.%u\n", hooknum, *pskb, (*pskb)->nh.iph->protocol, diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c index db57fedb9..cacd7a3f8 100644 --- a/net/ipv4/protocol.c +++ b/net/ipv4/protocol.c @@ -5,7 +5,7 @@ * * INET protocol dispatch tables. * - * Version: $Id: protocol.c,v 1.11 2000/02/22 23:54:26 davem Exp $ + * Version: $Id: protocol.c,v 1.12 2000/10/03 07:29:00 anton Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 81f20361a..675154d91 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.53 2000/08/09 11:59:04 davem Exp $ + * Version: $Id: raw.c,v 1.55 2000/10/24 22:54:26 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -227,11 +227,11 @@ static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb) { IP_INC_STATS(IpInDiscards); kfree_skb(skb); - return -1; + return NET_RX_DROP; } IP_INC_STATS(IpInDelivers); - return 0; + return NET_RX_SUCCESS; } /* @@ -653,7 +653,7 @@ int raw_get_info(char *buffer, char **start, off_t offset, int length) if (sk->family != PF_INET) continue; pos += 128; - if (pos < offset) + if (pos <= offset) continue; get_raw_sock(sk, tmpbuf, i); len += sprintf(buffer+len, "%-127s\n", tmpbuf); diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 4734d8087..cacf36b71 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -5,7 +5,7 @@ * * ROUTE - implementation of the IP router. * - * Version: $Id: route.c,v 1.90 2000/08/31 23:39:12 davem Exp $ + * Version: $Id: route.c,v 1.91 2000/10/03 07:29:00 anton Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index d9f05c671..68d536e10 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -1,7 +1,7 @@ /* * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem. * - * $Id: sysctl_net_ipv4.c,v 1.46 2000/09/16 09:38:30 davem Exp $ + * $Id: sysctl_net_ipv4.c,v 1.47 2000/10/19 15:51:02 davem Exp $ * * Begun April 1, 1996, Mike Shaver. * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS] @@ -15,6 +15,9 @@ #include <net/route.h> #include <net/tcp.h> +/* From af_inet.c */ +extern int sysctl_ip_nonlocal_bind; + /* From icmp.c */ extern int sysctl_icmp_echo_ignore_all; extern int sysctl_icmp_echo_ignore_broadcasts; @@ -110,6 +113,9 @@ ctl_table ipv4_table[] = { {NET_IPV4_NO_PMTU_DISC, "ip_no_pmtu_disc", &ipv4_config.no_pmtu_disc, sizeof(int), 0644, NULL, &proc_dointvec}, + {NET_IPV4_NONLOCAL_BIND, "ip_nonlocal_bind", + &sysctl_ip_nonlocal_bind, sizeof(int), 0644, NULL, + &proc_dointvec}, {NET_IPV4_TCP_SYN_RETRIES, "tcp_syn_retries", &sysctl_tcp_syn_retries, sizeof(int), 0644, NULL, &proc_dointvec}, {NET_TCP_SYNACK_RETRIES, "tcp_synack_retries", diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 05027bc93..0f97c2d27 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.174 2000/09/18 05:59:48 davem Exp $ + * Version: $Id: tcp.c,v 1.176 2000/10/06 22:45:41 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -1026,7 +1026,7 @@ int tcp_sendmsg(struct sock *sk, struct msghdr *msg, int size) skb = NULL; if (tcp_memory_free(sk)) - skb = tcp_alloc_skb(sk, tmp, GFP_KERNEL); + skb = tcp_alloc_skb(sk, tmp, sk->allocation); if (skb == NULL) { /* If we didn't get any memory, we need to sleep. */ set_bit(SOCK_ASYNC_NOSPACE, &sk->socket->flags); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index d2a79b4b1..1a0f278b4 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.213 2000/09/18 05:59:48 davem Exp $ + * Version: $Id: tcp_ipv4.c,v 1.218 2000/10/18 18:04:22 davem Exp $ * * IPv4 specific functions * @@ -75,37 +75,21 @@ static struct socket *tcp_socket=&tcp_inode.u.socket_i; void tcp_v4_send_check(struct sock *sk, struct tcphdr *th, int len, struct sk_buff *skb); -/* This is for sockets with full identity only. Sockets here will always - * be without wildcards and will have the following invariant: - * TCP_ESTABLISHED <= sk->state < TCP_CLOSE - * - * First half of the table is for sockets not in TIME_WAIT, second half - * is for TIME_WAIT sockets only. - */ -struct tcp_ehash_bucket *tcp_ehash; - -/* Ok, let's try this, I give up, we do need a local binding - * TCP hash as well as the others for fast bind/connect. - */ -struct tcp_bind_hashbucket *tcp_bhash; - -int tcp_bhash_size; -int tcp_ehash_size; - -/* All sockets in TCP_LISTEN state will be in here. This is the only table - * where wildcard'd TCP sockets can exist. Hash function here is just local - * port number. +/* + * ALL members must be initialised to prevent gcc-2.7.2.3 miscompilation */ -struct sock *tcp_listening_hash[TCP_LHTABLE_SIZE]; -char __tcp_clean_cacheline_pad[(SMP_CACHE_BYTES - - (((sizeof(void *) * (TCP_LHTABLE_SIZE + 2)) + - (sizeof(int) * 2)) % SMP_CACHE_BYTES))] = { 0, }; - -rwlock_t tcp_lhash_lock = RW_LOCK_UNLOCKED; -atomic_t tcp_lhash_users = ATOMIC_INIT(0); -DECLARE_WAIT_QUEUE_HEAD(tcp_lhash_wait); - -spinlock_t tcp_portalloc_lock = SPIN_LOCK_UNLOCKED; +struct tcp_hashinfo __cacheline_aligned tcp_hashinfo = { + __tcp_ehash: NULL, + __tcp_bhash: NULL, + __tcp_bhash_size: 0, + __tcp_ehash_size: 0, + __tcp_listening_hash: { NULL, }, + __tcp_lhash_lock: RW_LOCK_UNLOCKED, + __tcp_lhash_users: ATOMIC_INIT(0), + __tcp_lhash_wait: + __WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.__tcp_lhash_wait), + __tcp_portalloc_lock: SPIN_LOCK_UNLOCKED +}; /* * This array holds the first and last local port number. @@ -2113,7 +2097,7 @@ skip_listen: continue; pos += TMPSZ; - if (pos < offset) + if (pos <= offset) continue; get_openreq(sk, req, tmpbuf, num, uid); len += sprintf(buffer+len, "%-*s\n", TMPSZ-1, tmpbuf); @@ -2145,7 +2129,7 @@ skip_listen: if (!TCP_INET_FAMILY(sk->family)) continue; pos += TMPSZ; - if (pos < offset) + if (pos <= offset) continue; get_tcp_sock(sk, tmpbuf, num); len += sprintf(buffer+len, "%-*s\n", TMPSZ-1, tmpbuf); @@ -2160,7 +2144,7 @@ skip_listen: if (!TCP_INET_FAMILY(tw->family)) continue; pos += TMPSZ; - if (pos < offset) + if (pos <= offset) continue; get_timewait_sock(tw, tmpbuf, num); len += sprintf(buffer+len, "%-*s\n", TMPSZ-1, tmpbuf); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 8dca4474b..7b6f45428 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.127 2000/08/15 20:15:23 davem Exp $ + * Version: $Id: tcp_output.c,v 1.128 2000/10/29 01:51:09 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -318,7 +318,7 @@ void tcp_send_skb(struct sock *sk, struct sk_buff *skb, int force_queue, unsigne if (!force_queue && tp->send_head == NULL && tcp_snd_test(tp, skb, cur_mss, 1)) { /* Send it out now. */ TCP_SKB_CB(skb)->when = tcp_time_stamp; - if (tcp_transmit_skb(sk, skb_clone(skb, GFP_KERNEL)) == 0) { + if (tcp_transmit_skb(sk, skb_clone(skb, sk->allocation)) == 0) { tp->snd_nxt = TCP_SKB_CB(skb)->end_seq; tcp_minshall_update(tp, cur_mss, skb); if (tp->packets_out++ == 0) diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 5e5af83c2..f57aeb32e 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.79 2000/08/11 00:13:36 davem Exp $ + * Version: $Id: tcp_timer.c,v 1.80 2000/10/03 07:29:01 anton Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index ff8a3d109..e098b9ff2 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.87 2000/09/20 02:11:34 davem Exp $ + * Version: $Id: udp.c,v 1.90 2000/10/18 18:04:22 davem Exp $ * * Authors: Ross Biro, <bir7@leland.Stanford.Edu> * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> @@ -677,8 +677,6 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, int len, if (flags & MSG_ERRQUEUE) return ip_recv_error(sk, msg, len); - - retry: /* * From here the generic datagram does a lot of the work. Come * the finished NET3, it will do _ALL_ the work! @@ -734,21 +732,22 @@ out: csum_copy_err: UDP_INC_STATS_BH(UdpInErrors); - if (flags&(MSG_PEEK|MSG_DONTWAIT)) { - struct sk_buff *skb2; - + /* Clear queue. */ + if (flags&MSG_PEEK) { + int clear = 0; spin_lock_irq(&sk->receive_queue.lock); - skb2 = skb_peek(&sk->receive_queue); - if ((flags & MSG_PEEK) && skb == skb2) { + if (skb == skb_peek(&sk->receive_queue)) { __skb_unlink(skb, &sk->receive_queue); + clear = 1; } spin_unlock_irq(&sk->receive_queue.lock); - skb_free_datagram(sk, skb); - if ((flags & MSG_DONTWAIT) && !skb2) - return -EAGAIN; - } else - skb_free_datagram(sk, skb); - goto retry; + if (clear) + kfree_skb(skb); + } + + skb_free_datagram(sk, skb); + + return -EAGAIN; } int udp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) @@ -1029,7 +1028,7 @@ int udp_get_info(char *buffer, char **start, off_t offset, int length) if (sk->family != PF_INET) continue; pos += 128; - if (pos < offset) + if (pos <= offset) continue; get_udp_sock(sk, tmpbuf, i); len += sprintf(buffer+len, "%-127s\n", tmpbuf); diff --git a/net/ipv4/utils.c b/net/ipv4/utils.c index c6494d87f..a5a9c3873 100644 --- a/net/ipv4/utils.c +++ b/net/ipv4/utils.c @@ -6,7 +6,7 @@ * Various kernel-resident INET utility functions; mainly * for format conversion and debugging output. * - * Version: $Id: utils.c,v 1.7 1999/06/09 10:11:05 davem Exp $ + * Version: $Id: utils.c,v 1.8 2000/10/03 07:29:01 anton Exp $ * * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> * |