Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
1e731eaa
Commit
1e731eaa
authored
Jun 24, 2004
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge master.kernel.org:/home/acme/net-2.6
into nuts.davemloft.net:/disk1/BK/net-2.6
parents
e3a2c92a
2b0ee9c2
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
135 additions
and
148 deletions
+135
-148
include/net/inet_common.h
include/net/inet_common.h
+0
-13
include/net/sock.h
include/net/sock.h
+13
-0
net/core/sock.c
net/core/sock.c
+88
-0
net/ipv4/af_inet.c
net/ipv4/af_inet.c
+8
-95
net/ipv4/raw.c
net/ipv4/raw.c
+1
-1
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_ipv4.c
+3
-1
net/ipv4/udp.c
net/ipv4/udp.c
+1
-1
net/ipv6/af_inet6.c
net/ipv6/af_inet6.c
+7
-7
net/ipv6/raw.c
net/ipv6/raw.c
+1
-1
net/ipv6/tcp_ipv6.c
net/ipv6/tcp_ipv6.c
+2
-18
net/ipv6/udp.c
net/ipv6/udp.c
+1
-1
net/sctp/ipv6.c
net/sctp/ipv6.c
+4
-4
net/sctp/protocol.c
net/sctp/protocol.c
+4
-4
net/sctp/socket.c
net/sctp/socket.c
+2
-2
No files found.
include/net/inet_common.h
View file @
1e731eaa
...
...
@@ -20,27 +20,14 @@ extern int inet_dgram_connect(struct socket *sock,
int
addr_len
,
int
flags
);
extern
int
inet_accept
(
struct
socket
*
sock
,
struct
socket
*
newsock
,
int
flags
);
extern
int
inet_recvmsg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
ubuf
,
size_t
size
,
int
flags
);
extern
int
inet_sendmsg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
msg
,
size_t
size
);
extern
int
inet_shutdown
(
struct
socket
*
sock
,
int
how
);
extern
unsigned
int
inet_poll
(
struct
file
*
file
,
struct
socket
*
sock
,
struct
poll_table_struct
*
wait
);
extern
int
inet_setsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
optlen
);
extern
int
inet_getsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
);
extern
int
inet_listen
(
struct
socket
*
sock
,
int
backlog
);
extern
void
inet_sock_release
(
struct
sock
*
sk
);
extern
void
inet_sock_destruct
(
struct
sock
*
sk
);
extern
atomic_t
inet_sock_nr
;
...
...
include/net/sock.h
View file @
1e731eaa
...
...
@@ -770,6 +770,19 @@ extern ssize_t sock_no_sendpage(struct socket *sock,
int
offset
,
size_t
size
,
int
flags
);
/*
* Functions to fill in entries in struct proto_ops when a protocol
* uses the inet style.
*/
extern
int
sock_common_getsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
);
extern
int
sock_common_recvmsg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
msg
,
size_t
size
,
int
flags
);
extern
int
sock_common_setsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
optlen
);
extern
void
sk_common_release
(
struct
sock
*
sk
);
/*
* Default socket callbacks and setup code
*/
...
...
net/core/sock.c
View file @
1e731eaa
...
...
@@ -118,6 +118,7 @@
#include <net/protocol.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/xfrm.h>
#include <linux/ipsec.h>
#include <linux/filter.h>
...
...
@@ -1259,6 +1260,93 @@ void sock_disable_timestamp(struct sock *sk)
}
EXPORT_SYMBOL
(
sock_disable_timestamp
);
/*
* Get a socket option on an socket.
*
* FIX: POSIX 1003.1g is very ambiguous here. It states that
* asynchronous errors should be reported by getsockopt. We assume
* this means if you specify SO_ERROR (otherwise whats the point of it).
*/
int
sock_common_getsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
return
sk
->
sk_prot
->
getsockopt
(
sk
,
level
,
optname
,
optval
,
optlen
);
}
EXPORT_SYMBOL
(
sock_common_getsockopt
);
int
sock_common_recvmsg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
msg
,
size_t
size
,
int
flags
)
{
struct
sock
*
sk
=
sock
->
sk
;
int
addr_len
=
0
;
int
err
;
err
=
sk
->
sk_prot
->
recvmsg
(
iocb
,
sk
,
msg
,
size
,
flags
&
MSG_DONTWAIT
,
flags
&
~
MSG_DONTWAIT
,
&
addr_len
);
if
(
err
>=
0
)
msg
->
msg_namelen
=
addr_len
;
return
err
;
}
EXPORT_SYMBOL
(
sock_common_recvmsg
);
/*
* Set socket options on an inet socket.
*/
int
sock_common_setsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
return
sk
->
sk_prot
->
setsockopt
(
sk
,
level
,
optname
,
optval
,
optlen
);
}
EXPORT_SYMBOL
(
sock_common_setsockopt
);
void
sk_common_release
(
struct
sock
*
sk
)
{
if
(
sk
->
sk_prot
->
destroy
)
sk
->
sk_prot
->
destroy
(
sk
);
/*
* Observation: when sock_common_release is called, processes have
* no access to socket. But net still has.
* Step one, detach it from networking:
*
* A. Remove from hash tables.
*/
sk
->
sk_prot
->
unhash
(
sk
);
/*
* In this point socket cannot receive new packets, but it is possible
* that some packets are in flight because some CPU runs receiver and
* did hash table lookup before we unhashed socket. They will achieve
* receive queue and will be purged by socket destructor.
*
* Also we still have packets pending on receive queue and probably,
* our own packets waiting in device queues. sock_destroy will drain
* receive queue, but transmitted packets will delay socket destruction
* until the last reference will be released.
*/
sock_orphan
(
sk
);
xfrm_sk_free_policy
(
sk
);
#ifdef INET_REFCNT_DEBUG
if
(
atomic_read
(
&
sk
->
sk_refcnt
)
!=
1
)
printk
(
KERN_DEBUG
"Destruction of the socket %p delayed, c=%d
\n
"
,
sk
,
atomic_read
(
&
sk
->
sk_refcnt
));
#endif
sock_put
(
sk
);
}
EXPORT_SYMBOL
(
sk_common_release
);
EXPORT_SYMBOL
(
__lock_sock
);
EXPORT_SYMBOL
(
__release_sock
);
EXPORT_SYMBOL
(
sk_alloc
);
...
...
net/ipv4/af_inet.c
View file @
1e731eaa
...
...
@@ -166,79 +166,12 @@ void inet_sock_destruct(struct sock *sk)
#endif
}
void
inet_sock_release
(
struct
sock
*
sk
)
{
if
(
sk
->
sk_prot
->
destroy
)
sk
->
sk_prot
->
destroy
(
sk
);
/* Observation: when inet_sock_release is called, processes have
* no access to socket. But net still has.
* Step one, detach it from networking:
*
* A. Remove from hash tables.
*/
sk
->
sk_prot
->
unhash
(
sk
);
/* In this point socket cannot receive new packets,
* but it is possible that some packets are in flight
* because some CPU runs receiver and did hash table lookup
* before we unhashed socket. They will achieve receive queue
* and will be purged by socket destructor.
*
* Also we still have packets pending on receive
* queue and probably, our own packets waiting in device queues.
* sock_destroy will drain receive queue, but transmitted
* packets will delay socket destruction until the last reference
* will be released.
*/
sock_orphan
(
sk
);
xfrm_sk_free_policy
(
sk
);
#ifdef INET_REFCNT_DEBUG
if
(
atomic_read
(
&
sk
->
sk_refcnt
)
!=
1
)
printk
(
KERN_DEBUG
"Destruction inet %p delayed, c=%d
\n
"
,
sk
,
atomic_read
(
&
sk
->
sk_refcnt
));
#endif
sock_put
(
sk
);
}
/*
* The routines beyond this point handle the behaviour of an AF_INET
* socket object. Mostly it punts to the subprotocols of IP to do
* the work.
*/
/*
* Set socket options on an inet socket.
*/
int
inet_setsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
return
sk
->
sk_prot
->
setsockopt
(
sk
,
level
,
optname
,
optval
,
optlen
);
}
/*
* Get a socket option on an AF_INET socket.
*
* FIX: POSIX 1003.1g is very ambiguous here. It states that
* asynchronous errors should be reported by getsockopt. We assume
* this means if you specify SO_ERROR (otherwise whats the point of it).
*/
int
inet_getsockopt
(
struct
socket
*
sock
,
int
level
,
int
optname
,
char
__user
*
optval
,
int
__user
*
optlen
)
{
struct
sock
*
sk
=
sock
->
sk
;
return
sk
->
sk_prot
->
getsockopt
(
sk
,
level
,
optname
,
optval
,
optlen
);
}
/*
* Automatically bind an unbound socket.
*/
...
...
@@ -422,7 +355,7 @@ static int inet_create(struct socket *sock, int protocol)
if
(
sk
->
sk_prot
->
init
)
{
err
=
sk
->
sk_prot
->
init
(
sk
);
if
(
err
)
inet_sock
_release
(
sk
);
sk_common
_release
(
sk
);
}
out:
return
err
;
...
...
@@ -729,22 +662,6 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
return
0
;
}
int
inet_recvmsg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
msg
,
size_t
size
,
int
flags
)
{
struct
sock
*
sk
=
sock
->
sk
;
int
addr_len
=
0
;
int
err
;
err
=
sk
->
sk_prot
->
recvmsg
(
iocb
,
sk
,
msg
,
size
,
flags
&
MSG_DONTWAIT
,
flags
&
~
MSG_DONTWAIT
,
&
addr_len
);
if
(
err
>=
0
)
msg
->
msg_namelen
=
addr_len
;
return
err
;
}
int
inet_sendmsg
(
struct
kiocb
*
iocb
,
struct
socket
*
sock
,
struct
msghdr
*
msg
,
size_t
size
)
{
...
...
@@ -891,10 +808,10 @@ struct proto_ops inet_stream_ops = {
.
ioctl
=
inet_ioctl
,
.
listen
=
inet_listen
,
.
shutdown
=
inet_shutdown
,
.
setsockopt
=
inet
_setsockopt
,
.
getsockopt
=
inet
_getsockopt
,
.
setsockopt
=
sock_common
_setsockopt
,
.
getsockopt
=
sock_common
_getsockopt
,
.
sendmsg
=
inet_sendmsg
,
.
recvmsg
=
inet
_recvmsg
,
.
recvmsg
=
sock_common
_recvmsg
,
.
mmap
=
sock_no_mmap
,
.
sendpage
=
tcp_sendpage
};
...
...
@@ -906,16 +823,16 @@ struct proto_ops inet_dgram_ops = {
.
bind
=
inet_bind
,
.
connect
=
inet_dgram_connect
,
.
socketpair
=
sock_no_socketpair
,
.
accept
=
sock_no
_accept
,
.
accept
=
inet
_accept
,
.
getname
=
inet_getname
,
.
poll
=
datagram_poll
,
.
ioctl
=
inet_ioctl
,
.
listen
=
sock_no_listen
,
.
shutdown
=
inet_shutdown
,
.
setsockopt
=
inet
_setsockopt
,
.
getsockopt
=
inet
_getsockopt
,
.
setsockopt
=
sock_common
_setsockopt
,
.
getsockopt
=
sock_common
_getsockopt
,
.
sendmsg
=
inet_sendmsg
,
.
recvmsg
=
inet
_recvmsg
,
.
recvmsg
=
sock_common
_recvmsg
,
.
mmap
=
sock_no_mmap
,
.
sendpage
=
inet_sendpage
,
};
...
...
@@ -1242,17 +1159,13 @@ EXPORT_SYMBOL(inet_dgram_connect);
EXPORT_SYMBOL
(
inet_dgram_ops
);
EXPORT_SYMBOL
(
inet_family_ops
);
EXPORT_SYMBOL
(
inet_getname
);
EXPORT_SYMBOL
(
inet_getsockopt
);
EXPORT_SYMBOL
(
inet_ioctl
);
EXPORT_SYMBOL
(
inet_listen
);
EXPORT_SYMBOL
(
inet_recvmsg
);
EXPORT_SYMBOL
(
inet_register_protosw
);
EXPORT_SYMBOL
(
inet_release
);
EXPORT_SYMBOL
(
inet_sendmsg
);
EXPORT_SYMBOL
(
inet_setsockopt
);
EXPORT_SYMBOL
(
inet_shutdown
);
EXPORT_SYMBOL
(
inet_sock_destruct
);
EXPORT_SYMBOL
(
inet_sock_release
);
EXPORT_SYMBOL
(
inet_stream_connect
);
EXPORT_SYMBOL
(
inet_stream_ops
);
EXPORT_SYMBOL
(
inet_unregister_protosw
);
...
...
net/ipv4/raw.c
View file @
1e731eaa
...
...
@@ -480,7 +480,7 @@ static void raw_close(struct sock *sk, long timeout)
*/
ip_ra_control
(
sk
,
0
,
NULL
);
inet_sock
_release
(
sk
);
sk_common
_release
(
sk
);
}
/* This gets rid of all the nasties in af_inet. -DaveM */
...
...
net/ipv4/tcp_ipv4.c
View file @
1e731eaa
...
...
@@ -2094,7 +2094,7 @@ static int tcp_v4_init_sock(struct sock *sk)
return
0
;
}
static
int
tcp_v4_destroy_sock
(
struct
sock
*
sk
)
int
tcp_v4_destroy_sock
(
struct
sock
*
sk
)
{
struct
tcp_opt
*
tp
=
tcp_sk
(
sk
);
...
...
@@ -2118,6 +2118,8 @@ static int tcp_v4_destroy_sock(struct sock *sk)
return
0
;
}
EXPORT_SYMBOL
(
tcp_v4_destroy_sock
);
#ifdef CONFIG_PROC_FS
/* Proc filesystem TCP sock list dumping. */
...
...
net/ipv4/udp.c
View file @
1e731eaa
...
...
@@ -931,7 +931,7 @@ int udp_disconnect(struct sock *sk, int flags)
static
void
udp_close
(
struct
sock
*
sk
,
long
timeout
)
{
inet_sock
_release
(
sk
);
sk_common
_release
(
sk
);
}
/* return:
...
...
net/ipv6/af_inet6.c
View file @
1e731eaa
...
...
@@ -250,7 +250,7 @@ static int inet6_create(struct socket *sock, int protocol)
if
(
sk
->
sk_prot
->
init
)
{
int
err
=
sk
->
sk_prot
->
init
(
sk
);
if
(
err
!=
0
)
{
inet_sock
_release
(
sk
);
sk_common
_release
(
sk
);
return
err
;
}
}
...
...
@@ -510,10 +510,10 @@ struct proto_ops inet6_stream_ops = {
.
ioctl
=
inet6_ioctl
,
/* must change */
.
listen
=
inet_listen
,
/* ok */
.
shutdown
=
inet_shutdown
,
/* ok */
.
setsockopt
=
inet
_setsockopt
,
/* ok */
.
getsockopt
=
inet
_getsockopt
,
/* ok */
.
setsockopt
=
sock_common
_setsockopt
,
/* ok */
.
getsockopt
=
sock_common
_getsockopt
,
/* ok */
.
sendmsg
=
inet_sendmsg
,
/* ok */
.
recvmsg
=
inet_recvmsg
,
/* ok */
.
recvmsg
=
sock_common_recvmsg
,
/* ok */
.
mmap
=
sock_no_mmap
,
.
sendpage
=
tcp_sendpage
};
...
...
@@ -531,10 +531,10 @@ struct proto_ops inet6_dgram_ops = {
.
ioctl
=
inet6_ioctl
,
/* must change */
.
listen
=
sock_no_listen
,
/* ok */
.
shutdown
=
inet_shutdown
,
/* ok */
.
setsockopt
=
inet
_setsockopt
,
/* ok */
.
getsockopt
=
inet
_getsockopt
,
/* ok */
.
setsockopt
=
sock_common
_setsockopt
,
/* ok */
.
getsockopt
=
sock_common
_getsockopt
,
/* ok */
.
sendmsg
=
inet_sendmsg
,
/* ok */
.
recvmsg
=
inet_recvmsg
,
/* ok */
.
recvmsg
=
sock_common_recvmsg
,
/* ok */
.
mmap
=
sock_no_mmap
,
.
sendpage
=
sock_no_sendpage
,
};
...
...
net/ipv6/raw.c
View file @
1e731eaa
...
...
@@ -900,7 +900,7 @@ static void rawv6_close(struct sock *sk, long timeout)
if
(
inet_sk
(
sk
)
->
num
==
IPPROTO_RAW
)
ip6_ra_control
(
sk
,
-
1
,
NULL
);
inet_sock
_release
(
sk
);
sk_common
_release
(
sk
);
}
static
int
rawv6_init_sk
(
struct
sock
*
sk
)
...
...
net/ipv6/tcp_ipv6.c
View file @
1e731eaa
...
...
@@ -1892,25 +1892,9 @@ static int tcp_v6_init_sock(struct sock *sk)
static
int
tcp_v6_destroy_sock
(
struct
sock
*
sk
)
{
struct
tcp_opt
*
tp
=
tcp_sk
(
sk
);
tcp_clear_xmit_timers
(
sk
);
/* Cleanup up the write buffer. */
sk_stream_writequeue_purge
(
sk
);
/* Cleans up our, hopefully empty, out_of_order_queue. */
__skb_queue_purge
(
&
tp
->
out_of_order_queue
);
/* Clean prequeue, it must be empty really */
__skb_queue_purge
(
&
tp
->
ucopy
.
prequeue
);
/* Clean up a referenced TCP bind bucket. */
if
(
tcp_sk
(
sk
)
->
bind_hash
)
tcp_put_port
(
sk
);
atomic_dec
(
&
tcp_sockets_allocated
);
extern
int
tcp_v4_destroy_sock
(
struct
sock
*
sk
);
tcp_v4_destroy_sock
(
sk
);
return
inet6_destroy_sock
(
sk
);
}
...
...
net/ipv6/udp.c
View file @
1e731eaa
...
...
@@ -358,7 +358,7 @@ int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
static
void
udpv6_close
(
struct
sock
*
sk
,
long
timeout
)
{
inet_sock
_release
(
sk
);
sk_common
_release
(
sk
);
}
/*
...
...
net/sctp/ipv6.c
View file @
1e731eaa
...
...
@@ -641,7 +641,7 @@ struct sock *sctp_v6_create_accept_sk(struct sock *sk,
#endif
if
(
newsk
->
sk_prot
->
init
(
newsk
))
{
inet_sock
_release
(
newsk
);
sk_common
_release
(
newsk
);
newsk
=
NULL
;
}
...
...
@@ -882,10 +882,10 @@ static struct proto_ops inet6_seqpacket_ops = {
.
ioctl
=
inet6_ioctl
,
.
listen
=
sctp_inet_listen
,
.
shutdown
=
inet_shutdown
,
.
setsockopt
=
inet
_setsockopt
,
.
getsockopt
=
inet
_getsockopt
,
.
setsockopt
=
sock_common
_setsockopt
,
.
getsockopt
=
sock_common
_getsockopt
,
.
sendmsg
=
inet_sendmsg
,
.
recvmsg
=
inet
_recvmsg
,
.
recvmsg
=
sock_common
_recvmsg
,
.
mmap
=
sock_no_mmap
,
};
...
...
net/sctp/protocol.c
View file @
1e731eaa
...
...
@@ -603,7 +603,7 @@ struct sock *sctp_v4_create_accept_sk(struct sock *sk,
#endif
if
(
newsk
->
sk_prot
->
init
(
newsk
))
{
inet_sock
_release
(
newsk
);
sk_common
_release
(
newsk
);
newsk
=
NULL
;
}
...
...
@@ -846,10 +846,10 @@ struct proto_ops inet_seqpacket_ops = {
.
ioctl
=
inet_ioctl
,
.
listen
=
sctp_inet_listen
,
.
shutdown
=
inet_shutdown
,
/* Looks harmless. */
.
setsockopt
=
inet
_setsockopt
,
/* IP_SOL IP_OPTION is a problem. */
.
getsockopt
=
inet
_getsockopt
,
.
setsockopt
=
sock_common
_setsockopt
,
/* IP_SOL IP_OPTION is a problem. */
.
getsockopt
=
sock_common
_getsockopt
,
.
sendmsg
=
inet_sendmsg
,
.
recvmsg
=
inet
_recvmsg
,
.
recvmsg
=
sock_common
_recvmsg
,
.
mmap
=
sock_no_mmap
,
.
sendpage
=
sock_no_sendpage
,
};
...
...
net/sctp/socket.c
View file @
1e731eaa
...
...
@@ -945,11 +945,11 @@ SCTP_STATIC void sctp_close(struct sock *sk, long timeout)
sctp_local_bh_disable
();
sctp_bh_lock_sock
(
sk
);
/* Hold the sock, since
inet_sock
_release() will put sock_put()
/* Hold the sock, since
sk_common
_release() will put sock_put()
* and we have just a little more cleanup.
*/
sock_hold
(
sk
);
inet_sock
_release
(
sk
);
sk_common
_release
(
sk
);
sctp_bh_unlock_sock
(
sk
);
sctp_local_bh_enable
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment