From b22da3d8526a935aa31e086e63f60ff3246cb61c Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Sat, 09 Dec 2023 07:24:11 +0000 Subject: [PATCH] add stmac read mac form eeprom --- kernel/fs/nfs/dns_resolve.c | 32 +++++++++++++++++++++----------- 1 files changed, 21 insertions(+), 11 deletions(-) diff --git a/kernel/fs/nfs/dns_resolve.c b/kernel/fs/nfs/dns_resolve.c index 060c658..e87d500 100644 --- a/kernel/fs/nfs/dns_resolve.c +++ b/kernel/fs/nfs/dns_resolve.c @@ -22,7 +22,8 @@ char *ip_addr = NULL; int ip_len; - ip_len = dns_query(NULL, name, namelen, NULL, &ip_addr, NULL); + ip_len = dns_query(net, NULL, name, namelen, NULL, &ip_addr, NULL, + false); if (ip_len > 0) ret = rpc_pton(net, ip_addr, ip_len, sa, salen); else @@ -38,7 +39,6 @@ #include <linux/string.h> #include <linux/kmod.h> #include <linux/slab.h> -#include <linux/module.h> #include <linux/socket.h> #include <linux/seq_file.h> #include <linux/inet.h> @@ -65,6 +65,7 @@ struct sockaddr_storage addr; size_t addrlen; + struct rcu_head rcu_head; }; @@ -91,7 +92,7 @@ key = container_of(ckey, struct nfs_dns_ent, h); kfree(new->hostname); - new->hostname = kstrndup(key->hostname, key->namelen, GFP_KERNEL); + new->hostname = kmemdup_nul(key->hostname, key->namelen, GFP_KERNEL); if (new->hostname) { new->namelen = key->namelen; nfs_dns_ent_update(cnew, ckey); @@ -101,13 +102,21 @@ } } +static void nfs_dns_ent_free_rcu(struct rcu_head *head) +{ + struct nfs_dns_ent *item; + + item = container_of(head, struct nfs_dns_ent, rcu_head); + kfree(item->hostname); + kfree(item); +} + static void nfs_dns_ent_put(struct kref *ref) { struct nfs_dns_ent *item; item = container_of(ref, struct nfs_dns_ent, h.ref); - kfree(item->hostname); - kfree(item); + call_rcu(&item->rcu_head, nfs_dns_ent_free_rcu); } static struct cache_head *nfs_dns_ent_alloc(void) @@ -142,12 +151,13 @@ struct cache_head *ch) { struct nfs_dns_ent *key = container_of(ch, struct nfs_dns_ent, h); - int ret; - ret = nfs_cache_upcall(cd, key->hostname); - if (ret) - ret = sunrpc_cache_pipe_upcall(cd, ch); - return ret; + if (test_and_set_bit(CACHE_PENDING, &ch->flags)) + return 0; + if (!nfs_cache_upcall(cd, key->hostname)) + return 0; + clear_bit(CACHE_PENDING, &ch->flags); + return sunrpc_cache_pipe_upcall_timeout(cd, ch); } static int nfs_dns_match(struct cache_head *ca, @@ -195,7 +205,7 @@ { struct cache_head *ch; - ch = sunrpc_cache_lookup(cd, + ch = sunrpc_cache_lookup_rcu(cd, &key->h, nfs_dns_hash(key)); if (!ch) -- Gitblit v1.6.2