From c62531a5c3239985541f5781ce1e92625543590b Mon Sep 17 00:00:00 2001 From: mpi Date: Thu, 8 Oct 2015 08:41:58 +0000 Subject: [PATCH] Use the radix API directly and get rid of the function pointers. There is no point in keeping an unused level of abstraction. ok mikeb@, claudio@ --- sys/kern/vfs_subr.c | 16 ++++++---------- sys/net/radix.c | 7 +------ sys/net/radix.h | 18 +----------------- sys/net/radix_mpath.c | 6 +++--- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index b3542a1c363..3e19fe56663 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.234 2015/10/07 11:57:44 mpi Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.235 2015/10/08 08:41:58 mpi Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -1389,8 +1389,7 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep, error = EINVAL; goto out; } - rn = (*rnh->rnh_addaddr)((caddr_t)saddr, (caddr_t)smask, rnh, - np->netc_rnodes, 0); + rn = rn_addroute(saddr, smask, rnh, np->netc_rnodes, 0); if (rn == 0 || np != (struct netcred *)rn) { /* already exists */ error = EPERM; goto out; @@ -1409,7 +1408,7 @@ vfs_free_netcred(struct radix_node *rn, void *w, u_int id) { struct radix_node_head *rnh = (struct radix_node_head *)w; - (*rnh->rnh_deladdr)(rn->rn_key, rn->rn_mask, rnh, NULL); + rn_delete(rn->rn_key, rn->rn_mask, rnh, NULL); free(rn, M_NETADDR, 0); return (0); } @@ -1423,7 +1422,7 @@ vfs_free_addrlist(struct netexport *nep) struct radix_node_head *rnh; if ((rnh = nep->ne_rtable_inet) != NULL) { - (*rnh->rnh_walktree)(rnh, vfs_free_netcred, rnh); + rn_walktree(rnh, vfs_free_netcred, rnh); free(rnh, M_RTABLE, 0); nep->ne_rtable_inet = NULL; } @@ -1468,11 +1467,8 @@ vfs_export_lookup(struct mount *mp, struct netexport *nep, struct mbuf *nam) rnh = NULL; break; } - if (rnh != NULL) { - np = (struct netcred *) - (*rnh->rnh_matchaddr)((caddr_t)saddr, - rnh); - } + if (rnh != NULL) + np = (struct netcred *)rn_match(saddr, rnh); } /* * If no address match, use the default if it exists. diff --git a/sys/net/radix.c b/sys/net/radix.c index cffbc4a340c..a4fb08073d3 100644 --- a/sys/net/radix.c +++ b/sys/net/radix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radix.c,v 1.49 2015/10/07 10:50:35 mpi Exp $ */ +/* $OpenBSD: radix.c,v 1.50 2015/10/08 08:41:58 mpi Exp $ */ /* $NetBSD: radix.c,v 1.20 2003/08/07 16:32:56 agc Exp $ */ /* @@ -1200,11 +1200,6 @@ rn_inithead0(struct radix_node_head *rnh, int offset) tt->rn_b = -1 - off; *ttt = *tt; ttt->rn_key = rn_ones; - rnh->rnh_addaddr = rn_addroute; - rnh->rnh_deladdr = rn_delete; - rnh->rnh_matchaddr = rn_match; - rnh->rnh_lookup = rn_lookup; - rnh->rnh_walktree = rn_walktree; rnh->rnh_treetop = t; return (1); } diff --git a/sys/net/radix.h b/sys/net/radix.h index cdb7ca9d995..b2360526be9 100644 --- a/sys/net/radix.h +++ b/sys/net/radix.h @@ -1,4 +1,4 @@ -/* $OpenBSD: radix.h,v 1.26 2015/09/04 08:43:39 mpi Exp $ */ +/* $OpenBSD: radix.h,v 1.27 2015/10/08 08:41:58 mpi Exp $ */ /* $NetBSD: radix.h,v 1.8 1996/02/13 22:00:37 christos Exp $ */ /* @@ -92,22 +92,6 @@ struct radix_node_head { struct radix_node *rnh_treetop; int rnh_addrsize; /* permit, but not require fixed keys */ int rnh_pktsize; /* permit, but not require fixed keys */ - /* add based on sockaddr */ - struct radix_node *(*rnh_addaddr)(void *v, void *mask, - struct radix_node_head *head, struct radix_node nodes[], - u_int8_t prio); - /* remove based on sockaddr */ - struct radix_node *(*rnh_deladdr)(void *v, void *mask, - struct radix_node_head *head, struct radix_node *rn); - /* locate based on sockaddr */ - struct radix_node *(*rnh_matchaddr)(void *v, - struct radix_node_head *head); - /* locate based on sockaddr */ - struct radix_node *(*rnh_lookup)(void *v, void *mask, - struct radix_node_head *head); - /* traverse tree */ - int (*rnh_walktree)(struct radix_node_head *, - int (*)(struct radix_node *, void *, u_int), void *); struct radix_node rnh_nodes[3];/* empty tree for common case */ int rnh_multipath; /* multipath? */ u_int rnh_rtableid; diff --git a/sys/net/radix_mpath.c b/sys/net/radix_mpath.c index e24d9c34b62..5bebeb6e3e8 100644 --- a/sys/net/radix_mpath.c +++ b/sys/net/radix_mpath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radix_mpath.c,v 1.33 2015/09/28 08:36:24 mpi Exp $ */ +/* $OpenBSD: radix_mpath.c,v 1.34 2015/10/08 08:41:58 mpi Exp $ */ /* $KAME: radix_mpath.c,v 1.13 2002/10/28 21:05:59 itojun Exp $ */ /* @@ -208,13 +208,13 @@ rt_mpath_conflict(struct radix_node_head *rnh, struct sockaddr *dst, char *p, *q, *eq; int same, l, skip; - rn1 = rnh->rnh_lookup(dst, netmask, rnh); + rn1 = rn_lookup(dst, netmask, rnh); if (!rn1) return 0; /* * unlike other functions we have in this file, we have to check - * all key/mask/gateway as rnh_lookup can match less specific entry. + * all key/mask/gateway as rn_lookup can match less specific entry. */ rt1 = (struct rtentry *)rn1; -- 2.20.1