Module Name: src Committed By: knakahara Date: Mon Jun 13 08:37:15 UTC 2016
Modified Files: src/sys/netinet: ip_flow.c src/sys/netinet6: ip6_flow.c Log Message: eliminate unnecessary splnet To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/netinet/ip_flow.c cvs rdiff -u -r1.25 -r1.26 src/sys/netinet6/ip6_flow.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/ip_flow.c diff -u src/sys/netinet/ip_flow.c:1.70 src/sys/netinet/ip_flow.c:1.71 --- src/sys/netinet/ip_flow.c:1.70 Mon Jun 13 08:34:23 2016 +++ src/sys/netinet/ip_flow.c Mon Jun 13 08:37:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_flow.c,v 1.70 2016/06/13 08:34:23 knakahara Exp $ */ +/* $NetBSD: ip_flow.c,v 1.71 2016/06/13 08:37:15 knakahara Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.70 2016/06/13 08:34:23 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.71 2016/06/13 08:37:15 knakahara Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -357,7 +357,6 @@ ipflow_addstats(struct ipflow *ipf) static void ipflow_free(struct ipflow *ipf) { - int s; KASSERT(mutex_owned(&ipflow_lock)); @@ -366,9 +365,8 @@ ipflow_free(struct ipflow *ipf) * Once it's off the list, we can deal with it at normal * network IPL. */ - s = splnet(); IPFLOW_REMOVE(ipf); - splx(s); + ipflow_addstats(ipf); rtcache_free(&ipf->ipf_ro); ipflow_inuse--; @@ -383,7 +381,6 @@ ipflow_reap(bool just_one) while (just_one || ipflow_inuse > ip_maxflows) { struct ipflow *ipf, *maybe_ipf = NULL; - int s; ipf = LIST_FIRST(&ipflowlist); while (ipf != NULL) { @@ -412,9 +409,8 @@ ipflow_reap(bool just_one) /* * Remove the entry from the flow table. */ - s = splnet(); IPFLOW_REMOVE(ipf); - splx(s); + ipflow_addstats(ipf); rtcache_free(&ipf->ipf_ro); if (just_one) @@ -462,7 +458,6 @@ ipflow_create(const struct route *ro, st const struct ip *const ip = mtod(m, const struct ip *); struct ipflow *ipf; size_t hash; - int s; mutex_enter(&ipflow_lock); @@ -493,9 +488,8 @@ ipflow_create(const struct route *ro, st } memset(ipf, 0, sizeof(*ipf)); } else { - s = splnet(); IPFLOW_REMOVE(ipf); - splx(s); + ipflow_addstats(ipf); rtcache_free(&ipf->ipf_ro); ipf->ipf_uses = ipf->ipf_last_uses = 0; @@ -515,9 +509,7 @@ ipflow_create(const struct route *ro, st * Insert into the approriate bucket of the flow table. */ hash = ipflow_hash(ip); - s = splnet(); IPFLOW_INSERT(&ipflowtable[hash], ipf); - splx(s); out: KERNEL_UNLOCK_ONE(NULL); @@ -528,13 +520,12 @@ int ipflow_invalidate_all(int new_size) { struct ipflow *ipf, *next_ipf; - int s, error; + int error; error = 0; mutex_enter(&ipflow_lock); - s = splnet(); for (ipf = LIST_FIRST(&ipflowlist); ipf != NULL; ipf = next_ipf) { next_ipf = LIST_NEXT(ipf, ipf_list); ipflow_free(ipf); @@ -542,7 +533,6 @@ ipflow_invalidate_all(int new_size) if (new_size) error = ipflow_reinit(new_size); - splx(s); mutex_exit(&ipflow_lock); Index: src/sys/netinet6/ip6_flow.c diff -u src/sys/netinet6/ip6_flow.c:1.25 src/sys/netinet6/ip6_flow.c:1.26 --- src/sys/netinet6/ip6_flow.c:1.25 Mon Jun 13 08:34:23 2016 +++ src/sys/netinet6/ip6_flow.c Mon Jun 13 08:37:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ip6_flow.c,v 1.25 2016/06/13 08:34:23 knakahara Exp $ */ +/* $NetBSD: ip6_flow.c,v 1.26 2016/06/13 08:37:15 knakahara Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.25 2016/06/13 08:34:23 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.26 2016/06/13 08:37:15 knakahara Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -377,7 +377,6 @@ ip6flow_addstats(const struct ip6flow *i static void ip6flow_free(struct ip6flow *ip6f) { - int s; KASSERT(mutex_owned(&ip6flow_lock)); @@ -386,9 +385,8 @@ ip6flow_free(struct ip6flow *ip6f) * Once it's off the list, we can deal with it at normal * network IPL. */ - s = splnet(); IP6FLOW_REMOVE(ip6f); - splx(s); + ip6flow_inuse--; ip6flow_addstats(ip6f); rtcache_free(&ip6f->ip6f_ro); @@ -403,7 +401,6 @@ ip6flow_reap_locked(int just_one) while (just_one || ip6flow_inuse > ip6_maxflows) { struct ip6flow *ip6f, *maybe_ip6f = NULL; - int s; ip6f = LIST_FIRST(&ip6flowlist); while (ip6f != NULL) { @@ -432,9 +429,8 @@ ip6flow_reap_locked(int just_one) /* * Remove the entry from the flow table */ - s = splnet(); IP6FLOW_REMOVE(ip6f); - splx(s); + rtcache_free(&ip6f->ip6f_ro); if (just_one) { ip6flow_addstats(ip6f); @@ -500,7 +496,6 @@ ip6flow_create(const struct route *ro, s const struct ip6_hdr *ip6; struct ip6flow *ip6f; size_t hash; - int s; mutex_enter(&ip6flow_lock); @@ -542,9 +537,8 @@ ip6flow_create(const struct route *ro, s } memset(ip6f, 0, sizeof(*ip6f)); } else { - s = splnet(); IP6FLOW_REMOVE(ip6f); - splx(s); + ip6flow_addstats(ip6f); rtcache_free(&ip6f->ip6f_ro); ip6f->ip6f_uses = 0; @@ -566,9 +560,7 @@ ip6flow_create(const struct route *ro, s * Insert into the approriate bucket of the flow table. */ hash = ip6flow_hash(ip6); - s = splnet(); IP6FLOW_INSERT(&ip6flowtable[hash], ip6f); - splx(s); out: KERNEL_UNLOCK_ONE(NULL); @@ -583,13 +575,12 @@ int ip6flow_invalidate_all(int new_size) { struct ip6flow *ip6f, *next_ip6f; - int s, error; + int error; error = 0; mutex_enter(&ip6flow_lock); - s = splnet(); for (ip6f = LIST_FIRST(&ip6flowlist); ip6f != NULL; ip6f = next_ip6f) { next_ip6f = LIST_NEXT(ip6f, ip6f_list); ip6flow_free(ip6f); @@ -597,7 +588,6 @@ ip6flow_invalidate_all(int new_size) if (new_size) error = ip6flow_init_locked(new_size); - splx(s); mutex_exit(&ip6flow_lock);