hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/include/net/inet6_hashtables.h
....@@ -1,14 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * INET An implementation of the TCP/IP protocol suite for the LINUX
34 * operating system. INET is implemented using the BSD Socket
45 * interface as the means of communication with the user level.
56 *
67 * Authors: Lotsa people, from code originally in tcp
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License
10
- * as published by the Free Software Foundation; either version
11
- * 2 of the License, or (at your option) any later version.
128 */
139
1410 #ifndef _INET6_HASHTABLES_H
....@@ -89,9 +85,8 @@
8985 int iif, int sdif,
9086 bool *refcounted)
9187 {
92
- struct sock *sk = skb_steal_sock(skb);
88
+ struct sock *sk = skb_steal_sock(skb, refcounted);
9389
94
- *refcounted = true;
9590 if (sk)
9691 return sk;
9792
....@@ -108,16 +103,24 @@
108103 const int dif);
109104
110105 int inet6_hash(struct sock *sk);
111
-#endif /* IS_ENABLED(CONFIG_IPV6) */
112106
113
-#define INET6_MATCH(__sk, __net, __saddr, __daddr, __ports, __dif, __sdif) \
114
- (((__sk)->sk_portpair == (__ports)) && \
115
- ((__sk)->sk_family == AF_INET6) && \
116
- ipv6_addr_equal(&(__sk)->sk_v6_daddr, (__saddr)) && \
117
- ipv6_addr_equal(&(__sk)->sk_v6_rcv_saddr, (__daddr)) && \
118
- (!(__sk)->sk_bound_dev_if || \
119
- ((__sk)->sk_bound_dev_if == (__dif)) || \
120
- ((__sk)->sk_bound_dev_if == (__sdif))) && \
121
- net_eq(sock_net(__sk), (__net)))
107
+static inline bool inet6_match(struct net *net, const struct sock *sk,
108
+ const struct in6_addr *saddr,
109
+ const struct in6_addr *daddr,
110
+ const __portpair ports,
111
+ const int dif, const int sdif)
112
+{
113
+ if (!net_eq(sock_net(sk), net) ||
114
+ sk->sk_family != AF_INET6 ||
115
+ sk->sk_portpair != ports ||
116
+ !ipv6_addr_equal(&sk->sk_v6_daddr, saddr) ||
117
+ !ipv6_addr_equal(&sk->sk_v6_rcv_saddr, daddr))
118
+ return false;
119
+
120
+ /* READ_ONCE() paired with WRITE_ONCE() in sock_bindtoindex_locked() */
121
+ return inet_sk_bound_dev_eq(net, READ_ONCE(sk->sk_bound_dev_if), dif,
122
+ sdif);
123
+}
124
+#endif /* IS_ENABLED(CONFIG_IPV6) */
122125
123126 #endif /* _INET6_HASHTABLES_H */