Commit cea97609 authored by David Ahern's avatar David Ahern Committed by David S. Miller

ipv4/tcp: Use local variable for tcp_md5_addr

Extract the typecast to (union tcp_md5_addr *) to a local variable
rather than the current long, inline declaration with function calls.

No functional change intended.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 98c81476
...@@ -701,9 +701,13 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb) ...@@ -701,9 +701,13 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb)
rcu_read_lock(); rcu_read_lock();
hash_location = tcp_parse_md5sig_option(th); hash_location = tcp_parse_md5sig_option(th);
if (sk && sk_fullsock(sk)) { if (sk && sk_fullsock(sk)) {
key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *) const union tcp_md5_addr *addr;
&ip_hdr(skb)->saddr, AF_INET);
addr = (union tcp_md5_addr *)&ip_hdr(skb)->saddr;
key = tcp_md5_do_lookup(sk, addr, AF_INET);
} else if (hash_location) { } else if (hash_location) {
const union tcp_md5_addr *addr;
/* /*
* active side is lost. Try to find listening socket through * active side is lost. Try to find listening socket through
* source port, and then find md5 key through listening socket. * source port, and then find md5 key through listening socket.
...@@ -720,8 +724,8 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb) ...@@ -720,8 +724,8 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb)
if (!sk1) if (!sk1)
goto out; goto out;
key = tcp_md5_do_lookup(sk1, (union tcp_md5_addr *) addr = (union tcp_md5_addr *)&ip_hdr(skb)->saddr;
&ip_hdr(skb)->saddr, AF_INET); key = tcp_md5_do_lookup(sk1, addr, AF_INET);
if (!key) if (!key)
goto out; goto out;
...@@ -905,6 +909,8 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) ...@@ -905,6 +909,8 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb)
static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
struct request_sock *req) struct request_sock *req)
{ {
const union tcp_md5_addr *addr;
/* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV
* sk->sk_state == TCP_SYN_RECV -> for Fast Open. * sk->sk_state == TCP_SYN_RECV -> for Fast Open.
*/ */
...@@ -916,14 +922,14 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, ...@@ -916,14 +922,14 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
* exception of <SYN> segments, MUST be right-shifted by * exception of <SYN> segments, MUST be right-shifted by
* Rcv.Wind.Shift bits: * Rcv.Wind.Shift bits:
*/ */
addr = (union tcp_md5_addr *)&ip_hdr(skb)->saddr;
tcp_v4_send_ack(sk, skb, seq, tcp_v4_send_ack(sk, skb, seq,
tcp_rsk(req)->rcv_nxt, tcp_rsk(req)->rcv_nxt,
req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale, req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale,
tcp_time_stamp_raw() + tcp_rsk(req)->ts_off, tcp_time_stamp_raw() + tcp_rsk(req)->ts_off,
req->ts_recent, req->ts_recent,
0, 0,
tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&ip_hdr(skb)->saddr, tcp_md5_do_lookup(sk, addr, AF_INET),
AF_INET),
inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0, inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0,
ip_hdr(skb)->tos); ip_hdr(skb)->tos);
} }
...@@ -1149,6 +1155,7 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname, ...@@ -1149,6 +1155,7 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname,
{ {
struct tcp_md5sig cmd; struct tcp_md5sig cmd;
struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr; struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr;
const union tcp_md5_addr *addr;
u8 prefixlen = 32; u8 prefixlen = 32;
if (optlen < sizeof(cmd)) if (optlen < sizeof(cmd))
...@@ -1167,16 +1174,16 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname, ...@@ -1167,16 +1174,16 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname,
return -EINVAL; return -EINVAL;
} }
addr = (union tcp_md5_addr *)&sin->sin_addr.s_addr;
if (!cmd.tcpm_keylen) if (!cmd.tcpm_keylen)
return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin->sin_addr.s_addr, return tcp_md5_do_del(sk, addr, AF_INET, prefixlen);
AF_INET, prefixlen);
if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN) if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)
return -EINVAL; return -EINVAL;
return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin->sin_addr.s_addr, return tcp_md5_do_add(sk, addr, AF_INET, prefixlen,
AF_INET, prefixlen, cmd.tcpm_key, cmd.tcpm_keylen, cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
GFP_KERNEL);
} }
static int tcp_v4_md5_hash_headers(struct tcp_md5sig_pool *hp, static int tcp_v4_md5_hash_headers(struct tcp_md5sig_pool *hp,
...@@ -1301,11 +1308,12 @@ static bool tcp_v4_inbound_md5_hash(const struct sock *sk, ...@@ -1301,11 +1308,12 @@ static bool tcp_v4_inbound_md5_hash(const struct sock *sk,
struct tcp_md5sig_key *hash_expected; struct tcp_md5sig_key *hash_expected;
const struct iphdr *iph = ip_hdr(skb); const struct iphdr *iph = ip_hdr(skb);
const struct tcphdr *th = tcp_hdr(skb); const struct tcphdr *th = tcp_hdr(skb);
const union tcp_md5_addr *addr;
int genhash; int genhash;
unsigned char newhash[16]; unsigned char newhash[16];
hash_expected = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&iph->saddr, addr = (union tcp_md5_addr *)&iph->saddr;
AF_INET); hash_expected = tcp_md5_do_lookup(sk, addr, AF_INET);
hash_location = tcp_parse_md5sig_option(th); hash_location = tcp_parse_md5sig_option(th);
/* We've parsed the options - do we have a hash? */ /* We've parsed the options - do we have a hash? */
...@@ -1419,6 +1427,7 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, ...@@ -1419,6 +1427,7 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
struct tcp_sock *newtp; struct tcp_sock *newtp;
struct sock *newsk; struct sock *newsk;
#ifdef CONFIG_TCP_MD5SIG #ifdef CONFIG_TCP_MD5SIG
const union tcp_md5_addr *addr;
struct tcp_md5sig_key *key; struct tcp_md5sig_key *key;
#endif #endif
struct ip_options_rcu *inet_opt; struct ip_options_rcu *inet_opt;
...@@ -1468,8 +1477,8 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, ...@@ -1468,8 +1477,8 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
#ifdef CONFIG_TCP_MD5SIG #ifdef CONFIG_TCP_MD5SIG
/* Copy over the MD5 key from the original socket */ /* Copy over the MD5 key from the original socket */
key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&newinet->inet_daddr, addr = (union tcp_md5_addr *)&newinet->inet_daddr;
AF_INET); key = tcp_md5_do_lookup(sk, addr, AF_INET);
if (key) { if (key) {
/* /*
* We're using one, so create a matching key * We're using one, so create a matching key
...@@ -1477,8 +1486,8 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, ...@@ -1477,8 +1486,8 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
* memory, then we end up not copying the key * memory, then we end up not copying the key
* across. Shucks. * across. Shucks.
*/ */
tcp_md5_do_add(newsk, (union tcp_md5_addr *)&newinet->inet_daddr, tcp_md5_do_add(newsk, addr, AF_INET, 32,
AF_INET, 32, key->key, key->keylen, GFP_ATOMIC); key->key, key->keylen, GFP_ATOMIC);
sk_nocaps_add(newsk, NETIF_F_GSO_MASK); sk_nocaps_add(newsk, NETIF_F_GSO_MASK);
} }
#endif #endif
......
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