diff options
author | Changli Gao <xiaosuo@gmail.com> | 2010-07-10 16:41:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-12 23:21:46 -0400 |
commit | 7ba42910073f8432934d61a6c08b1023c408fb62 (patch) | |
tree | 4f74648133eaf6cbea26d59c43d34e7153648f5d /net/ipv4/af_inet.c | |
parent | 53d3176b282cc105493babb0fef36c8b873f6201 (diff) |
inet, inet6: make tcp_sendmsg() and tcp_sendpage() through inet_sendmsg() and inet_sendpage()
a new boolean flag no_autobind is added to structure proto to avoid the autobind
calls when the protocol is TCP. Then sock_rps_record_flow() is called int the
TCP's sendmsg() and sendpage() pathes.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
include/net/inet_common.h | 4 ++++
include/net/sock.h | 1 +
include/net/tcp.h | 8 ++++----
net/ipv4/af_inet.c | 15 +++++++++------
net/ipv4/tcp.c | 11 +++++------
net/ipv4/tcp_ipv4.c | 3 +++
net/ipv6/af_inet6.c | 8 ++++----
net/ipv6/tcp_ipv6.c | 3 +++
8 files changed, 33 insertions(+), 20 deletions(-)
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r-- | net/ipv4/af_inet.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 3ceb025b16f2..6a1100c25a9f 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -727,28 +727,31 @@ int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
727 | sock_rps_record_flow(sk); | 727 | sock_rps_record_flow(sk); |
728 | 728 | ||
729 | /* We may need to bind the socket. */ | 729 | /* We may need to bind the socket. */ |
730 | if (!inet_sk(sk)->inet_num && inet_autobind(sk)) | 730 | if (!inet_sk(sk)->inet_num && !sk->sk_prot->no_autobind && |
731 | inet_autobind(sk)) | ||
731 | return -EAGAIN; | 732 | return -EAGAIN; |
732 | 733 | ||
733 | return sk->sk_prot->sendmsg(iocb, sk, msg, size); | 734 | return sk->sk_prot->sendmsg(iocb, sk, msg, size); |
734 | } | 735 | } |
735 | EXPORT_SYMBOL(inet_sendmsg); | 736 | EXPORT_SYMBOL(inet_sendmsg); |
736 | 737 | ||
737 | static ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset, | 738 | ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset, |
738 | size_t size, int flags) | 739 | size_t size, int flags) |
739 | { | 740 | { |
740 | struct sock *sk = sock->sk; | 741 | struct sock *sk = sock->sk; |
741 | 742 | ||
742 | sock_rps_record_flow(sk); | 743 | sock_rps_record_flow(sk); |
743 | 744 | ||
744 | /* We may need to bind the socket. */ | 745 | /* We may need to bind the socket. */ |
745 | if (!inet_sk(sk)->inet_num && inet_autobind(sk)) | 746 | if (!inet_sk(sk)->inet_num && !sk->sk_prot->no_autobind && |
747 | inet_autobind(sk)) | ||
746 | return -EAGAIN; | 748 | return -EAGAIN; |
747 | 749 | ||
748 | if (sk->sk_prot->sendpage) | 750 | if (sk->sk_prot->sendpage) |
749 | return sk->sk_prot->sendpage(sk, page, offset, size, flags); | 751 | return sk->sk_prot->sendpage(sk, page, offset, size, flags); |
750 | return sock_no_sendpage(sock, page, offset, size, flags); | 752 | return sock_no_sendpage(sock, page, offset, size, flags); |
751 | } | 753 | } |
754 | EXPORT_SYMBOL(inet_sendpage); | ||
752 | 755 | ||
753 | int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | 756 | int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, |
754 | size_t size, int flags) | 757 | size_t size, int flags) |
@@ -894,10 +897,10 @@ const struct proto_ops inet_stream_ops = { | |||
894 | .shutdown = inet_shutdown, | 897 | .shutdown = inet_shutdown, |
895 | .setsockopt = sock_common_setsockopt, | 898 | .setsockopt = sock_common_setsockopt, |
896 | .getsockopt = sock_common_getsockopt, | 899 | .getsockopt = sock_common_getsockopt, |
897 | .sendmsg = tcp_sendmsg, | 900 | .sendmsg = inet_sendmsg, |
898 | .recvmsg = inet_recvmsg, | 901 | .recvmsg = inet_recvmsg, |
899 | .mmap = sock_no_mmap, | 902 | .mmap = sock_no_mmap, |
900 | .sendpage = tcp_sendpage, | 903 | .sendpage = inet_sendpage, |
901 | .splice_read = tcp_splice_read, | 904 | .splice_read = tcp_splice_read, |
902 | #ifdef CONFIG_COMPAT | 905 | #ifdef CONFIG_COMPAT |
903 | .compat_setsockopt = compat_sock_common_setsockopt, | 906 | .compat_setsockopt = compat_sock_common_setsockopt, |