Make some functions static

- rtflushall
- rtcache_clear
- rtcache_invalidate

And pull these static inline functions in route.c

- rt_destroy
- rt_setkey
This commit is contained in:
ozaki-r 2015-04-30 09:57:38 +00:00
parent d36b8cce23
commit 4ba55ca742
2 changed files with 36 additions and 36 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#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);

View File

@ -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 *);