diff options
author | Eric Dumazet <edumazet@google.com> | 2015-03-24 18:58:56 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-24 21:16:30 -0400 |
commit | fd3a154a00fb991872680f19021f5edbb40b4dbe (patch) | |
tree | 5d0b22e1e707f9ea3dcd0c3062eaaed59bc331e2 | |
parent | 39f8e58e53be32ab758d30536e0bd2e6ce766462 (diff) |
tcp: md5: get rid of tcp_v[46]_reqsk_md5_lookup()
With request socks convergence, we no longer need
different lookup methods. A request socket can
use generic lookup function.
Add const qualifier to 2nd tcp_v[46]_md5_lookup() parameter.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/tcp.h | 8 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 19 | ||||
-rw-r--r-- | net/ipv4/tcp_output.c | 2 | ||||
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 10 |
4 files changed, 12 insertions, 27 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 992be858c370..42690daa924e 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -1303,7 +1303,7 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, | |||
1303 | int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, | 1303 | int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, |
1304 | int family); | 1304 | int family); |
1305 | struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, | 1305 | struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, |
1306 | struct sock *addr_sk); | 1306 | const struct sock *addr_sk); |
1307 | 1307 | ||
1308 | #ifdef CONFIG_TCP_MD5SIG | 1308 | #ifdef CONFIG_TCP_MD5SIG |
1309 | struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, | 1309 | struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, |
@@ -1614,7 +1614,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, | |||
1614 | struct tcp_sock_af_ops { | 1614 | struct tcp_sock_af_ops { |
1615 | #ifdef CONFIG_TCP_MD5SIG | 1615 | #ifdef CONFIG_TCP_MD5SIG |
1616 | struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk, | 1616 | struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk, |
1617 | struct sock *addr_sk); | 1617 | const struct sock *addr_sk); |
1618 | int (*calc_md5_hash)(char *location, | 1618 | int (*calc_md5_hash)(char *location, |
1619 | const struct tcp_md5sig_key *md5, | 1619 | const struct tcp_md5sig_key *md5, |
1620 | const struct sock *sk, | 1620 | const struct sock *sk, |
@@ -1628,8 +1628,8 @@ struct tcp_sock_af_ops { | |||
1628 | struct tcp_request_sock_ops { | 1628 | struct tcp_request_sock_ops { |
1629 | u16 mss_clamp; | 1629 | u16 mss_clamp; |
1630 | #ifdef CONFIG_TCP_MD5SIG | 1630 | #ifdef CONFIG_TCP_MD5SIG |
1631 | struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk, | 1631 | struct tcp_md5sig_key *(*req_md5_lookup)(struct sock *sk, |
1632 | struct request_sock *req); | 1632 | const struct sock *addr_sk); |
1633 | int (*calc_md5_hash) (char *location, | 1633 | int (*calc_md5_hash) (char *location, |
1634 | const struct tcp_md5sig_key *md5, | 1634 | const struct tcp_md5sig_key *md5, |
1635 | const struct sock *sk, | 1635 | const struct sock *sk, |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 79d5c641688c..fc8995a702a6 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -898,10 +898,10 @@ struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, | |||
898 | const union tcp_md5_addr *addr, | 898 | const union tcp_md5_addr *addr, |
899 | int family) | 899 | int family) |
900 | { | 900 | { |
901 | struct tcp_sock *tp = tcp_sk(sk); | 901 | const struct tcp_sock *tp = tcp_sk(sk); |
902 | struct tcp_md5sig_key *key; | 902 | struct tcp_md5sig_key *key; |
903 | unsigned int size = sizeof(struct in_addr); | 903 | unsigned int size = sizeof(struct in_addr); |
904 | struct tcp_md5sig_info *md5sig; | 904 | const struct tcp_md5sig_info *md5sig; |
905 | 905 | ||
906 | /* caller either holds rcu_read_lock() or socket lock */ | 906 | /* caller either holds rcu_read_lock() or socket lock */ |
907 | md5sig = rcu_dereference_check(tp->md5sig_info, | 907 | md5sig = rcu_dereference_check(tp->md5sig_info, |
@@ -924,24 +924,15 @@ struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, | |||
924 | EXPORT_SYMBOL(tcp_md5_do_lookup); | 924 | EXPORT_SYMBOL(tcp_md5_do_lookup); |
925 | 925 | ||
926 | struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, | 926 | struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, |
927 | struct sock *addr_sk) | 927 | const struct sock *addr_sk) |
928 | { | 928 | { |
929 | union tcp_md5_addr *addr; | 929 | union tcp_md5_addr *addr; |
930 | 930 | ||
931 | addr = (union tcp_md5_addr *)&inet_sk(addr_sk)->inet_daddr; | 931 | addr = (union tcp_md5_addr *)&sk->sk_daddr; |
932 | return tcp_md5_do_lookup(sk, addr, AF_INET); | 932 | return tcp_md5_do_lookup(sk, addr, AF_INET); |
933 | } | 933 | } |
934 | EXPORT_SYMBOL(tcp_v4_md5_lookup); | 934 | EXPORT_SYMBOL(tcp_v4_md5_lookup); |
935 | 935 | ||
936 | static struct tcp_md5sig_key *tcp_v4_reqsk_md5_lookup(struct sock *sk, | ||
937 | struct request_sock *req) | ||
938 | { | ||
939 | union tcp_md5_addr *addr; | ||
940 | |||
941 | addr = (union tcp_md5_addr *)&inet_rsk(req)->ir_rmt_addr; | ||
942 | return tcp_md5_do_lookup(sk, addr, AF_INET); | ||
943 | } | ||
944 | |||
945 | /* This can be called on a newly created socket, from other files */ | 936 | /* This can be called on a newly created socket, from other files */ |
946 | int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, | 937 | int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, |
947 | int family, const u8 *newkey, u8 newkeylen, gfp_t gfp) | 938 | int family, const u8 *newkey, u8 newkeylen, gfp_t gfp) |
@@ -1247,7 +1238,7 @@ struct request_sock_ops tcp_request_sock_ops __read_mostly = { | |||
1247 | static const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = { | 1238 | static const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = { |
1248 | .mss_clamp = TCP_MSS_DEFAULT, | 1239 | .mss_clamp = TCP_MSS_DEFAULT, |
1249 | #ifdef CONFIG_TCP_MD5SIG | 1240 | #ifdef CONFIG_TCP_MD5SIG |
1250 | .md5_lookup = tcp_v4_reqsk_md5_lookup, | 1241 | .req_md5_lookup = tcp_v4_md5_lookup, |
1251 | .calc_md5_hash = tcp_v4_md5_hash_skb, | 1242 | .calc_md5_hash = tcp_v4_md5_hash_skb, |
1252 | #endif | 1243 | #endif |
1253 | .init_req = tcp_v4_init_req, | 1244 | .init_req = tcp_v4_init_req, |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 501cf9d401c3..2e69b8d16e68 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -2938,7 +2938,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst, | |||
2938 | 2938 | ||
2939 | #ifdef CONFIG_TCP_MD5SIG | 2939 | #ifdef CONFIG_TCP_MD5SIG |
2940 | rcu_read_lock(); | 2940 | rcu_read_lock(); |
2941 | md5 = tcp_rsk(req)->af_specific->md5_lookup(sk, req); | 2941 | md5 = tcp_rsk(req)->af_specific->req_md5_lookup(sk, req_to_sk(req)); |
2942 | #endif | 2942 | #endif |
2943 | tcp_header_size = tcp_synack_options(sk, req, mss, skb, &opts, md5, | 2943 | tcp_header_size = tcp_synack_options(sk, req, mss, skb, &opts, md5, |
2944 | foc) + sizeof(*th); | 2944 | foc) + sizeof(*th); |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 57d1c41404ec..a9568caf4675 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -486,17 +486,11 @@ static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk, | |||
486 | } | 486 | } |
487 | 487 | ||
488 | static struct tcp_md5sig_key *tcp_v6_md5_lookup(struct sock *sk, | 488 | static struct tcp_md5sig_key *tcp_v6_md5_lookup(struct sock *sk, |
489 | struct sock *addr_sk) | 489 | const struct sock *addr_sk) |
490 | { | 490 | { |
491 | return tcp_v6_md5_do_lookup(sk, &addr_sk->sk_v6_daddr); | 491 | return tcp_v6_md5_do_lookup(sk, &addr_sk->sk_v6_daddr); |
492 | } | 492 | } |
493 | 493 | ||
494 | static struct tcp_md5sig_key *tcp_v6_reqsk_md5_lookup(struct sock *sk, | ||
495 | struct request_sock *req) | ||
496 | { | ||
497 | return tcp_v6_md5_do_lookup(sk, &inet_rsk(req)->ir_v6_rmt_addr); | ||
498 | } | ||
499 | |||
500 | static int tcp_v6_parse_md5_keys(struct sock *sk, char __user *optval, | 494 | static int tcp_v6_parse_md5_keys(struct sock *sk, char __user *optval, |
501 | int optlen) | 495 | int optlen) |
502 | { | 496 | { |
@@ -720,7 +714,7 @@ static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = { | |||
720 | .mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - | 714 | .mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - |
721 | sizeof(struct ipv6hdr), | 715 | sizeof(struct ipv6hdr), |
722 | #ifdef CONFIG_TCP_MD5SIG | 716 | #ifdef CONFIG_TCP_MD5SIG |
723 | .md5_lookup = tcp_v6_reqsk_md5_lookup, | 717 | .req_md5_lookup = tcp_v6_md5_lookup, |
724 | .calc_md5_hash = tcp_v6_md5_hash_skb, | 718 | .calc_md5_hash = tcp_v6_md5_hash_skb, |
725 | #endif | 719 | #endif |
726 | .init_req = tcp_v6_init_req, | 720 | .init_req = tcp_v6_init_req, |