提交 c4619feb 编写于 作者: Z Ziyang Xuan 提交者: Jialin Zhang

raw: fix KABI for backporting raw RCU conversion patches

Offering: HULK
hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6ECEK
CVE: NA

--------------------------------

In order to fix softlockup problem in raw sockets because global rwlock,
backport "raw: RCU conversion" series patches. That will introduce KABI
changes. This patch is to fix KABI changes.
Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
上级 08cd98c8
...@@ -15,11 +15,12 @@ ...@@ -15,11 +15,12 @@
#include <net/inet_sock.h> #include <net/inet_sock.h>
#include <net/protocol.h> #include <net/protocol.h>
#include <net/raw_common.h>
#include <linux/icmp.h> #include <linux/icmp.h>
extern struct proto raw_prot; extern struct proto raw_prot;
extern struct raw_hashinfo raw_v4_hashinfo; extern struct raw_hashinfo_new raw_v4_hashinfo;
bool raw_v4_match(struct net *net, struct sock *sk, unsigned short num, bool raw_v4_match(struct net *net, struct sock *sk, unsigned short num,
__be32 raddr, __be32 laddr, int dif, int sdif); __be32 raddr, __be32 laddr, int dif, int sdif);
...@@ -29,22 +30,11 @@ int raw_local_deliver(struct sk_buff *, int); ...@@ -29,22 +30,11 @@ int raw_local_deliver(struct sk_buff *, int);
int raw_rcv(struct sock *, struct sk_buff *); int raw_rcv(struct sock *, struct sk_buff *);
#define RAW_HTABLE_SIZE MAX_INET_PROTOS
struct raw_hashinfo { struct raw_hashinfo {
spinlock_t lock; rwlock_t lock;
struct hlist_nulls_head ht[RAW_HTABLE_SIZE]; struct hlist_head ht[RAW_HTABLE_SIZE];
}; };
static inline void raw_hashinfo_init(struct raw_hashinfo *hashinfo)
{
int i;
spin_lock_init(&hashinfo->lock);
for (i = 0; i < RAW_HTABLE_SIZE; i++)
INIT_HLIST_NULLS_HEAD(&hashinfo->ht[i], i);
}
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
int raw_proc_init(void); int raw_proc_init(void);
void raw_proc_exit(void); void raw_proc_exit(void);
......
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef _RAW_COMMON_H
#define _RAW_COMMON_H
#define RAW_HTABLE_SIZE MAX_INET_PROTOS
struct raw_hashinfo_new {
spinlock_t lock;
struct hlist_nulls_head ht[RAW_HTABLE_SIZE];
};
static inline void raw_hashinfo_init(struct raw_hashinfo_new *hashinfo)
{
int i;
spin_lock_init(&hashinfo->lock);
for (i = 0; i < RAW_HTABLE_SIZE; i++)
INIT_HLIST_NULLS_HEAD(&hashinfo->ht[i], i);
}
#endif /* _RAW_COMMON_H */
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
#define _NET_RAWV6_H #define _NET_RAWV6_H
#include <net/protocol.h> #include <net/protocol.h>
#include <net/raw.h>
extern struct raw_hashinfo raw_v6_hashinfo; extern struct raw_hashinfo_new raw_v6_hashinfo;
bool raw_v6_match(struct net *net, struct sock *sk, unsigned short num, bool raw_v6_match(struct net *net, struct sock *sk, unsigned short num,
const struct in6_addr *loc_addr, const struct in6_addr *loc_addr,
const struct in6_addr *rmt_addr, int dif, int sdif); const struct in6_addr *rmt_addr, int dif, int sdif);
......
...@@ -1155,6 +1155,7 @@ struct request_sock_ops; ...@@ -1155,6 +1155,7 @@ struct request_sock_ops;
struct timewait_sock_ops; struct timewait_sock_ops;
struct inet_hashinfo; struct inet_hashinfo;
struct raw_hashinfo; struct raw_hashinfo;
struct raw_hashinfo_new;
struct smc_hashinfo; struct smc_hashinfo;
struct module; struct module;
...@@ -1269,7 +1270,8 @@ struct proto { ...@@ -1269,7 +1270,8 @@ struct proto {
union { union {
struct inet_hashinfo *hashinfo; struct inet_hashinfo *hashinfo;
struct udp_table *udp_table; struct udp_table *udp_table;
struct raw_hashinfo *raw_hash; KABI_REPLACE(struct raw_hashinfo *raw_hash,
struct raw_hashinfo_new *raw_hash)
struct smc_hashinfo *smc_hash; struct smc_hashinfo *smc_hash;
} h; } h;
......
...@@ -85,12 +85,12 @@ struct raw_frag_vec { ...@@ -85,12 +85,12 @@ struct raw_frag_vec {
int hlen; int hlen;
}; };
struct raw_hashinfo raw_v4_hashinfo; struct raw_hashinfo_new raw_v4_hashinfo;
EXPORT_SYMBOL_GPL(raw_v4_hashinfo); EXPORT_SYMBOL_GPL(raw_v4_hashinfo);
int raw_hash_sk(struct sock *sk) int raw_hash_sk(struct sock *sk)
{ {
struct raw_hashinfo *h = sk->sk_prot->h.raw_hash; struct raw_hashinfo_new *h = sk->sk_prot->h.raw_hash;
struct hlist_nulls_head *hlist; struct hlist_nulls_head *hlist;
hlist = &h->ht[inet_sk(sk)->inet_num & (RAW_HTABLE_SIZE - 1)]; hlist = &h->ht[inet_sk(sk)->inet_num & (RAW_HTABLE_SIZE - 1)];
...@@ -107,7 +107,7 @@ EXPORT_SYMBOL_GPL(raw_hash_sk); ...@@ -107,7 +107,7 @@ EXPORT_SYMBOL_GPL(raw_hash_sk);
void raw_unhash_sk(struct sock *sk) void raw_unhash_sk(struct sock *sk)
{ {
struct raw_hashinfo *h = sk->sk_prot->h.raw_hash; struct raw_hashinfo_new *h = sk->sk_prot->h.raw_hash;
spin_lock(&h->lock); spin_lock(&h->lock);
if (__sk_nulls_del_node_init_rcu(sk)) if (__sk_nulls_del_node_init_rcu(sk))
...@@ -944,7 +944,7 @@ struct proto raw_prot = { ...@@ -944,7 +944,7 @@ struct proto raw_prot = {
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static struct sock *raw_get_first(struct seq_file *seq, int bucket) static struct sock *raw_get_first(struct seq_file *seq, int bucket)
{ {
struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file)); struct raw_hashinfo_new *h = PDE_DATA(file_inode(seq->file));
struct raw_iter_state *state = raw_seq_private(seq); struct raw_iter_state *state = raw_seq_private(seq);
struct hlist_nulls_head *hlist; struct hlist_nulls_head *hlist;
struct hlist_nulls_node *hnode; struct hlist_nulls_node *hnode;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
static struct raw_hashinfo * static struct raw_hashinfo_new *
raw_get_hashinfo(const struct inet_diag_req_v2 *r) raw_get_hashinfo(const struct inet_diag_req_v2 *r)
{ {
if (r->sdiag_family == AF_INET) { if (r->sdiag_family == AF_INET) {
...@@ -56,7 +56,7 @@ static bool raw_lookup(struct net *net, struct sock *sk, ...@@ -56,7 +56,7 @@ static bool raw_lookup(struct net *net, struct sock *sk,
static struct sock *raw_sock_get(struct net *net, const struct inet_diag_req_v2 *r) static struct sock *raw_sock_get(struct net *net, const struct inet_diag_req_v2 *r)
{ {
struct raw_hashinfo *hashinfo = raw_get_hashinfo(r); struct raw_hashinfo_new *hashinfo = raw_get_hashinfo(r);
struct hlist_nulls_head *hlist; struct hlist_nulls_head *hlist;
struct hlist_nulls_node *hnode; struct hlist_nulls_node *hnode;
struct sock *sk; struct sock *sk;
...@@ -142,7 +142,7 @@ static void raw_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, ...@@ -142,7 +142,7 @@ static void raw_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
const struct inet_diag_req_v2 *r) const struct inet_diag_req_v2 *r)
{ {
bool net_admin = netlink_net_capable(cb->skb, CAP_NET_ADMIN); bool net_admin = netlink_net_capable(cb->skb, CAP_NET_ADMIN);
struct raw_hashinfo *hashinfo = raw_get_hashinfo(r); struct raw_hashinfo_new *hashinfo = raw_get_hashinfo(r);
struct net *net = sock_net(skb->sk); struct net *net = sock_net(skb->sk);
struct inet_diag_dump_data *cb_data; struct inet_diag_dump_data *cb_data;
struct hlist_nulls_head *hlist; struct hlist_nulls_head *hlist;
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include <net/rpl.h> #include <net/rpl.h>
#include <net/compat.h> #include <net/compat.h>
#include <net/xfrm.h> #include <net/xfrm.h>
#include <net/raw_common.h>
#include <net/rawv6.h> #include <net/rawv6.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#define ICMPV6_HDRLEN 4 /* ICMPv6 header, RFC 4443 Section 2.1 */ #define ICMPV6_HDRLEN 4 /* ICMPv6 header, RFC 4443 Section 2.1 */
struct raw_hashinfo raw_v6_hashinfo; struct raw_hashinfo_new raw_v6_hashinfo;
EXPORT_SYMBOL_GPL(raw_v6_hashinfo); EXPORT_SYMBOL_GPL(raw_v6_hashinfo);
bool raw_v6_match(struct net *net, struct sock *sk, unsigned short num, bool raw_v6_match(struct net *net, struct sock *sk, unsigned short num,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册