INET6_MATCH() runs without holding a lock on the socket. We probably need to annotate most reads. This patch makes INET6_MATCH() an inline function to ease our changes. v2: inline function only defined if IS_ENABLED(CONFIG_IPV6) Change the name to inet6_match(), this is no longer a macro.
Showing the changes to include (1 of 4 files). Show all
Unified · Split
| @@ -103,15 +103,25 @@ struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, · 102 unmodified lines | |||
| 103 | const int dif); | 103 | const int dif); |
| 104 | 104 | ||
| 105 | int inet6_hash(struct sock *sk); | 105 | int inet6_hash(struct sock *sk); |
| 106 | #endif /* IS_ENABLED(CONFIG_IPV6) */ | ||
| 107 | 106 | ||
| 108 | #define INET6_MATCH(__sk, __net, __saddr, __daddr, __ports, __dif, __sdif) \ | 107 | static inline bool inet6_match(struct net *net, const struct sock *sk, |
| 109 | (((__sk)->sk_portpair == (__ports)) && \ | 108 | const struct in6_addr *saddr, |
| 110 | ((__sk)->sk_family == AF_INET6) && \ | 109 | const struct in6_addr *daddr, |
| 111 | ipv6_addr_equal(&(__sk)->sk_v6_daddr, (__saddr)) && \ | 110 | const __portpair ports, |
| 112 | ipv6_addr_equal(&(__sk)->sk_v6_rcv_saddr, (__daddr)) && \ | 111 | const int dif, const int sdif) |
| 113 | (((__sk)->sk_bound_dev_if == (__dif)) || \ | 112 | { |
| 114 | ((__sk)->sk_bound_dev_if == (__sdif))) && \ | 113 | int bound_dev_if; |
| 115 | net_eq(sock_net(__sk), (__net))) | 114 | |
| 115 | if (!net_eq(sock_net(sk), net) || | ||
| 116 | sk->sk_family != AF_INET6 || | ||
| 117 | sk->sk_portpair != ports || | ||
| 118 | !ipv6_addr_equal(&sk->sk_v6_daddr, saddr) || | ||
| 119 | !ipv6_addr_equal(&sk->sk_v6_rcv_saddr, daddr)) | ||
| 120 | return false; | ||
| 121 | |||
| 122 | bound_dev_if = READ_ONCE(sk->sk_bound_dev_if); | ||
| 123 | return bound_dev_if == dif || bound_dev_if == sdif; | ||
| 124 | } | ||
| 125 | #endif /* IS_ENABLED(CONFIG_IPV6) */ | ||
| 116 | 126 | ||
| 117 | #endif /* _INET6_HASHTABLES_H */ | 127 | #endif /* _INET6_HASHTABLES_H */ |