diff options
author | David S. Miller <davem@davemloft.net> | 2010-11-29 16:37:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-30 15:28:06 -0500 |
commit | 3f419d2d487821093ee46e898b5f8747f9edc9cd (patch) | |
tree | a3f7731eb0706c5ae6d0f4ec004ba0d08d7f951b /net/ipv4/tcp_ipv4.c | |
parent | b3419363808f2481b24a817f491878e1795db4c7 (diff) |
inet: Turn ->remember_stamp into ->get_peer in connection AF ops.
Then we can make a completely generic tcp_remember_stamp()
that uses ->get_peer() as a helper, minimizing the AF specific
code and minimizing the eventual code duplication when we implement
the ipv6 side of TW recycling.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 00285fcf6788..0ddf819cfb5d 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -1763,44 +1763,25 @@ do_time_wait: | |||
1763 | goto discard_it; | 1763 | goto discard_it; |
1764 | } | 1764 | } |
1765 | 1765 | ||
1766 | /* VJ's idea. Save last timestamp seen from this destination | 1766 | struct inet_peer *tcp_v4_get_peer(struct sock *sk, bool *release_it) |
1767 | * and hold it at least for normal timewait interval to use for duplicate | ||
1768 | * segment detection in subsequent connections, before they enter synchronized | ||
1769 | * state. | ||
1770 | */ | ||
1771 | |||
1772 | int tcp_v4_remember_stamp(struct sock *sk) | ||
1773 | { | 1767 | { |
1768 | struct rtable *rt = (struct rtable *) __sk_dst_get(sk); | ||
1774 | struct inet_sock *inet = inet_sk(sk); | 1769 | struct inet_sock *inet = inet_sk(sk); |
1775 | struct tcp_sock *tp = tcp_sk(sk); | 1770 | struct inet_peer *peer; |
1776 | struct rtable *rt = (struct rtable *)__sk_dst_get(sk); | ||
1777 | struct inet_peer *peer = NULL; | ||
1778 | int release_it = 0; | ||
1779 | 1771 | ||
1780 | if (!rt || rt->rt_dst != inet->inet_daddr) { | 1772 | if (!rt || rt->rt_dst != inet->inet_daddr) { |
1781 | peer = inet_getpeer_v4(inet->inet_daddr, 1); | 1773 | peer = inet_getpeer_v4(inet->inet_daddr, 1); |
1782 | release_it = 1; | 1774 | *release_it = true; |
1783 | } else { | 1775 | } else { |
1784 | if (!rt->peer) | 1776 | if (!rt->peer) |
1785 | rt_bind_peer(rt, 1); | 1777 | rt_bind_peer(rt, 1); |
1786 | peer = rt->peer; | 1778 | peer = rt->peer; |
1779 | *release_it = false; | ||
1787 | } | 1780 | } |
1788 | 1781 | ||
1789 | if (peer) { | 1782 | return peer; |
1790 | if ((s32)(peer->tcp_ts - tp->rx_opt.ts_recent) <= 0 || | ||
1791 | ((u32)get_seconds() - peer->tcp_ts_stamp > TCP_PAWS_MSL && | ||
1792 | peer->tcp_ts_stamp <= (u32)tp->rx_opt.ts_recent_stamp)) { | ||
1793 | peer->tcp_ts_stamp = (u32)tp->rx_opt.ts_recent_stamp; | ||
1794 | peer->tcp_ts = tp->rx_opt.ts_recent; | ||
1795 | } | ||
1796 | if (release_it) | ||
1797 | inet_putpeer(peer); | ||
1798 | return 1; | ||
1799 | } | ||
1800 | |||
1801 | return 0; | ||
1802 | } | 1783 | } |
1803 | EXPORT_SYMBOL(tcp_v4_remember_stamp); | 1784 | EXPORT_SYMBOL(tcp_v4_get_peer); |
1804 | 1785 | ||
1805 | int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw) | 1786 | int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw) |
1806 | { | 1787 | { |
@@ -1828,7 +1809,7 @@ const struct inet_connection_sock_af_ops ipv4_specific = { | |||
1828 | .rebuild_header = inet_sk_rebuild_header, | 1809 | .rebuild_header = inet_sk_rebuild_header, |
1829 | .conn_request = tcp_v4_conn_request, | 1810 | .conn_request = tcp_v4_conn_request, |
1830 | .syn_recv_sock = tcp_v4_syn_recv_sock, | 1811 | .syn_recv_sock = tcp_v4_syn_recv_sock, |
1831 | .remember_stamp = tcp_v4_remember_stamp, | 1812 | .get_peer = tcp_v4_get_peer, |
1832 | .net_header_len = sizeof(struct iphdr), | 1813 | .net_header_len = sizeof(struct iphdr), |
1833 | .setsockopt = ip_setsockopt, | 1814 | .setsockopt = ip_setsockopt, |
1834 | .getsockopt = ip_getsockopt, | 1815 | .getsockopt = ip_getsockopt, |