From 4ba55ca7424985b90cb7f69083ca7c4331c47bfb Mon Sep 17 00:00:00 2001 From: ozaki-r Date: Thu, 30 Apr 2015 09:57:38 +0000 Subject: [PATCH] Make some functions static - rtflushall - rtcache_clear - rtcache_invalidate And pull these static inline functions in route.c - rt_destroy - rt_setkey --- sys/net/route.c | 40 +++++++++++++++++++++++++++++++++++----- sys/net/route.h | 32 +------------------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index 7d4d867088f9..ecbc88b15cac 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.143 2015/04/28 02:56:58 ozaki-r Exp $ */ +/* $NetBSD: route.c,v 1.144 2015/04/30 09:57:38 ozaki-r Exp $ */ /*- * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -94,7 +94,7 @@ #include "opt_route.h" #include -__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.143 2015/04/28 02:56:58 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.144 2015/04/30 09:57:38 ozaki-r Exp $"); #include #ifdef RTFLUSH_DEBUG @@ -144,10 +144,14 @@ static kauth_listener_t route_listener; static int rtdeletemsg(struct rtentry *); static int rtflushclone1(struct rtentry *, void *); static void rtflushclone(sa_family_t family, struct rtentry *); +static void rtflushall(int); static void rt_maskedcopy(const struct sockaddr *, struct sockaddr *, const struct sockaddr *); +static void rtcache_clear(struct route *); +static void rtcache_invalidate(struct dom_rtlist *); + #ifdef RTFLUSH_DEBUG static void sysctl_net_rtcache_setup(struct sysctllog **); static void @@ -168,6 +172,32 @@ sysctl_net_rtcache_setup(struct sysctllog **clog) } #endif /* RTFLUSH_DEBUG */ +static inline void +rt_destroy(struct rtentry *rt) +{ + if (rt->_rt_key != NULL) + sockaddr_free(rt->_rt_key); + if (rt->rt_gateway != NULL) + sockaddr_free(rt->rt_gateway); + if (rt_gettag(rt) != NULL) + sockaddr_free(rt_gettag(rt)); + rt->_rt_key = rt->rt_gateway = rt->rt_tag = NULL; +} + +static inline const struct sockaddr * +rt_setkey(struct rtentry *rt, const struct sockaddr *key, int flags) +{ + if (rt->_rt_key == key) + goto out; + + if (rt->_rt_key != NULL) + sockaddr_free(rt->_rt_key); + rt->_rt_key = sockaddr_dup(key, flags); +out: + rt->rt_nodes->rn_key = (const char *)rt->_rt_key; + return rt->_rt_key; +} + struct ifaddr * rt_get_ifa(struct rtentry *rt) { @@ -291,7 +321,7 @@ rt_init(void) route_listener_cb, NULL); } -void +static void rtflushall(int family) { struct domain *dom; @@ -1385,7 +1415,7 @@ rtcache_copy(struct route *new_ro, const struct route *old_ro) static struct dom_rtlist invalid_routes = LIST_HEAD_INITIALIZER(dom_rtlist); -void +static void rtcache_invalidate(struct dom_rtlist *rtlist) { struct route *ro; @@ -1400,7 +1430,7 @@ rtcache_invalidate(struct dom_rtlist *rtlist) } } -void +static void rtcache_clear(struct route *ro) { rtcache_invariants(ro); diff --git a/sys/net/route.h b/sys/net/route.h index b03d31ad31a3..3fd5f7ebf428 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $NetBSD: route.h,v 1.90 2015/04/06 09:45:58 ozaki-r Exp $ */ +/* $NetBSD: route.h,v 1.91 2015/04/30 09:57:38 ozaki-r Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -358,7 +358,6 @@ extern struct route_info route_info; extern struct rtstat rtstat; struct socket; -struct dom_rtlist; void rt_init(void); @@ -379,7 +378,6 @@ void rt_timer_timer(void *); void rt_newmsg(int, struct rtentry *); struct rtentry * rtalloc1(const struct sockaddr *, int); -void rtflushall(int); void rtfree(struct rtentry *); int rtinit(struct ifaddr *, int, int); void rtredirect(const struct sockaddr *, const struct sockaddr *, @@ -403,40 +401,12 @@ const struct sockaddr * struct sockaddr * rt_gettag(struct rtentry *); -static inline void -rt_destroy(struct rtentry *rt) -{ - if (rt->_rt_key != NULL) - sockaddr_free(rt->_rt_key); - if (rt->rt_gateway != NULL) - sockaddr_free(rt->rt_gateway); - if (rt_gettag(rt) != NULL) - sockaddr_free(rt_gettag(rt)); - rt->_rt_key = rt->rt_gateway = rt->rt_tag = NULL; -} - -static inline const struct sockaddr * -rt_setkey(struct rtentry *rt, const struct sockaddr *key, int flags) -{ - if (rt->_rt_key == key) - goto out; - - if (rt->_rt_key != NULL) - sockaddr_free(rt->_rt_key); - rt->_rt_key = sockaddr_dup(key, flags); -out: - rt->rt_nodes->rn_key = (const char *)rt->_rt_key; - return rt->_rt_key; -} - -void rtcache_clear(struct route *); void rtcache_copy(struct route *, const struct route *); void rtcache_free(struct route *); struct rtentry * rtcache_init(struct route *); struct rtentry * rtcache_init_noclone(struct route *); -void rtcache_invalidate(struct dom_rtlist *); struct rtentry * rtcache_lookup2(struct route *, const struct sockaddr *, int, int *);