Commit a30aad50 authored by Alexey Kodanev's avatar Alexey Kodanev Committed by David S. Miller

tcp: rename *_sequence_number() to *_seq_and_tsoff()

The functions that are returning tcp sequence number also setup
TS offset value, so rename them to better describe their purpose.

No functional changes in this patch.
Suggested-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarAlexey Kodanev <alexey.kodanev@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9efd3831
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport); u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
__be16 dport); __be16 dport);
u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, u32 secure_tcp_seq_and_tsoff(__be32 saddr, __be32 daddr,
__be16 sport, __be16 dport, u32 *tsoff);
u32 secure_tcpv6_seq_and_tsoff(const __be32 *saddr, const __be32 *daddr,
__be16 sport, __be16 dport, u32 *tsoff); __be16 sport, __be16 dport, u32 *tsoff);
u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr,
__be16 sport, __be16 dport, u32 *tsoff);
u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
__be16 sport, __be16 dport); __be16 sport, __be16 dport);
u64 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr, u64 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,
......
...@@ -1816,7 +1816,7 @@ struct tcp_request_sock_ops { ...@@ -1816,7 +1816,7 @@ struct tcp_request_sock_ops {
struct dst_entry *(*route_req)(const struct sock *sk, struct flowi *fl, struct dst_entry *(*route_req)(const struct sock *sk, struct flowi *fl,
const struct request_sock *req, const struct request_sock *req,
bool *strict); bool *strict);
__u32 (*init_seq)(const struct sk_buff *skb, u32 *tsoff); __u32 (*init_seq_tsoff)(const struct sk_buff *skb, u32 *tsoff);
int (*send_synack)(const struct sock *sk, struct dst_entry *dst, int (*send_synack)(const struct sock *sk, struct dst_entry *dst,
struct flowi *fl, struct request_sock *req, struct flowi *fl, struct request_sock *req,
struct tcp_fastopen_cookie *foc, struct tcp_fastopen_cookie *foc,
......
...@@ -45,8 +45,8 @@ static u32 seq_scale(u32 seq) ...@@ -45,8 +45,8 @@ static u32 seq_scale(u32 seq)
#endif #endif
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr, u32 secure_tcpv6_seq_and_tsoff(const __be32 *saddr, const __be32 *daddr,
__be16 sport, __be16 dport, u32 *tsoff) __be16 sport, __be16 dport, u32 *tsoff)
{ {
const struct { const struct {
struct in6_addr saddr; struct in6_addr saddr;
...@@ -66,7 +66,7 @@ u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr, ...@@ -66,7 +66,7 @@ u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr,
*tsoff = sysctl_tcp_timestamps == 1 ? (hash >> 32) : 0; *tsoff = sysctl_tcp_timestamps == 1 ? (hash >> 32) : 0;
return seq_scale(hash); return seq_scale(hash);
} }
EXPORT_SYMBOL(secure_tcpv6_sequence_number); EXPORT_SYMBOL(secure_tcpv6_seq_and_tsoff);
u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
__be16 dport) __be16 dport)
...@@ -89,14 +89,13 @@ EXPORT_SYMBOL(secure_ipv6_port_ephemeral); ...@@ -89,14 +89,13 @@ EXPORT_SYMBOL(secure_ipv6_port_ephemeral);
#ifdef CONFIG_INET #ifdef CONFIG_INET
/* secure_tcp_sequence_number(a, b, 0, d) == secure_ipv4_port_ephemeral(a, b, d), /* secure_tcp_seq_and_tsoff(a, b, 0, d) == secure_ipv4_port_ephemeral(a, b, d),
* but fortunately, `sport' cannot be 0 in any circumstances. If this changes, * but fortunately, `sport' cannot be 0 in any circumstances. If this changes,
* it would be easy enough to have the former function use siphash_4u32, passing * it would be easy enough to have the former function use siphash_4u32, passing
* the arguments as separate u32. * the arguments as separate u32.
*/ */
u32 secure_tcp_seq_and_tsoff(__be32 saddr, __be32 daddr,
u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport, u32 *tsoff)
__be16 sport, __be16 dport, u32 *tsoff)
{ {
u64 hash; u64 hash;
net_secret_init(); net_secret_init();
......
...@@ -6324,7 +6324,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, ...@@ -6324,7 +6324,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
goto drop_and_free; goto drop_and_free;
if (isn && tmp_opt.tstamp_ok) if (isn && tmp_opt.tstamp_ok)
af_ops->init_seq(skb, &tcp_rsk(req)->ts_off); af_ops->init_seq_tsoff(skb, &tcp_rsk(req)->ts_off);
if (!want_cookie && !isn) { if (!want_cookie && !isn) {
/* VJ's idea. We save last timestamp seen /* VJ's idea. We save last timestamp seen
...@@ -6366,7 +6366,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, ...@@ -6366,7 +6366,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
goto drop_and_release; goto drop_and_release;
} }
isn = af_ops->init_seq(skb, &tcp_rsk(req)->ts_off); isn = af_ops->init_seq_tsoff(skb, &tcp_rsk(req)->ts_off);
} }
if (!dst) { if (!dst) {
dst = af_ops->route_req(sk, &fl, req, NULL); dst = af_ops->route_req(sk, &fl, req, NULL);
......
...@@ -94,12 +94,12 @@ static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key, ...@@ -94,12 +94,12 @@ static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
struct inet_hashinfo tcp_hashinfo; struct inet_hashinfo tcp_hashinfo;
EXPORT_SYMBOL(tcp_hashinfo); EXPORT_SYMBOL(tcp_hashinfo);
static u32 tcp_v4_init_sequence(const struct sk_buff *skb, u32 *tsoff) static u32 tcp_v4_init_seq_and_tsoff(const struct sk_buff *skb, u32 *tsoff)
{ {
return secure_tcp_sequence_number(ip_hdr(skb)->daddr, return secure_tcp_seq_and_tsoff(ip_hdr(skb)->daddr,
ip_hdr(skb)->saddr, ip_hdr(skb)->saddr,
tcp_hdr(skb)->dest, tcp_hdr(skb)->dest,
tcp_hdr(skb)->source, tsoff); tcp_hdr(skb)->source, tsoff);
} }
int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp) int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
...@@ -236,11 +236,11 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -236,11 +236,11 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
rt = NULL; rt = NULL;
if (likely(!tp->repair)) { if (likely(!tp->repair)) {
seq = secure_tcp_sequence_number(inet->inet_saddr, seq = secure_tcp_seq_and_tsoff(inet->inet_saddr,
inet->inet_daddr, inet->inet_daddr,
inet->inet_sport, inet->inet_sport,
usin->sin_port, usin->sin_port,
&tp->tsoffset); &tp->tsoffset);
if (!tp->write_seq) if (!tp->write_seq)
tp->write_seq = seq; tp->write_seq = seq;
} }
...@@ -1249,7 +1249,7 @@ static const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = { ...@@ -1249,7 +1249,7 @@ static const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = {
.cookie_init_seq = cookie_v4_init_sequence, .cookie_init_seq = cookie_v4_init_sequence,
#endif #endif
.route_req = tcp_v4_route_req, .route_req = tcp_v4_route_req,
.init_seq = tcp_v4_init_sequence, .init_seq_tsoff = tcp_v4_init_seq_and_tsoff,
.send_synack = tcp_v4_send_synack, .send_synack = tcp_v4_send_synack,
}; };
......
...@@ -101,12 +101,12 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb) ...@@ -101,12 +101,12 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
} }
} }
static u32 tcp_v6_init_sequence(const struct sk_buff *skb, u32 *tsoff) static u32 tcp_v6_init_seq_and_tsoff(const struct sk_buff *skb, u32 *tsoff)
{ {
return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32, return secure_tcpv6_seq_and_tsoff(ipv6_hdr(skb)->daddr.s6_addr32,
ipv6_hdr(skb)->saddr.s6_addr32, ipv6_hdr(skb)->saddr.s6_addr32,
tcp_hdr(skb)->dest, tcp_hdr(skb)->dest,
tcp_hdr(skb)->source, tsoff); tcp_hdr(skb)->source, tsoff);
} }
static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
...@@ -287,11 +287,11 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -287,11 +287,11 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
sk_set_txhash(sk); sk_set_txhash(sk);
if (likely(!tp->repair)) { if (likely(!tp->repair)) {
seq = secure_tcpv6_sequence_number(np->saddr.s6_addr32, seq = secure_tcpv6_seq_and_tsoff(np->saddr.s6_addr32,
sk->sk_v6_daddr.s6_addr32, sk->sk_v6_daddr.s6_addr32,
inet->inet_sport, inet->inet_sport,
inet->inet_dport, inet->inet_dport,
&tp->tsoffset); &tp->tsoffset);
if (!tp->write_seq) if (!tp->write_seq)
tp->write_seq = seq; tp->write_seq = seq;
} }
...@@ -755,7 +755,7 @@ static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = { ...@@ -755,7 +755,7 @@ static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = {
.cookie_init_seq = cookie_v6_init_sequence, .cookie_init_seq = cookie_v6_init_sequence,
#endif #endif
.route_req = tcp_v6_route_req, .route_req = tcp_v6_route_req,
.init_seq = tcp_v6_init_sequence, .init_seq_tsoff = tcp_v6_init_seq_and_tsoff,
.send_synack = tcp_v6_send_synack, .send_synack = tcp_v6_send_synack,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment