tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: following rn_dupedkey chains in rtsock.c
On Thu, Mar 24, 2011 at 11:12:35AM -0500, David Young wrote:
> In either case, there is no point following the rn_dupedkey chain. We
> can compare the rtentry's mask with the query mask and be done with it.
> This code,
>
> for (rn = rt->rt_nodes; rn; rn = rn->rn_dupedkey)
> if (info.rti_info[RTAX_NETMASK] ==
> (const struct sockaddr *)rn->rn_mask)
> break;
> if (rn == NULL)
> senderr(ETOOMANYREFS);
> rt = (struct rtentry *)rn;
>
> becomes this code,
>
> if (info.rti_info[RTAX_NETMASK] != rt_mask(rt))
> senderr(ETOOMANYREFS);
I have attached a much better patch. It avoids the intern_netmask()
call, and then I can delete intern_netmask(). That's 19 lines of code
saved, and no more fiddling with radix_nodes in rtsock.c.
Dave
--
David Young OJC Technologies
dyoung%ojctech.com@localhost Urbana, IL * (217) 344-0444 x24
Index: rtsock.c
===================================================================
RCS file: /cvsroot/src/sys/net/rtsock.c,v
retrieving revision 1.134
diff -u -p -r1.134 rtsock.c
--- rtsock.c 10 Feb 2011 07:42:18 -0000 1.134
+++ rtsock.c 24 Mar 2011 18:43:31 -0000
@@ -231,19 +231,6 @@ COMPATNAME(route_usrreq)(struct socket *
return error;
}
-static const struct sockaddr *
-intern_netmask(const struct sockaddr *mask)
-{
- struct radix_node *rn;
- extern struct radix_node_head *mask_rnhead;
-
- if (mask != NULL &&
- (rn = rn_search(mask, mask_rnhead->rnh_treetop)))
- mask = (const struct sockaddr *)rn->rn_key;
-
- return mask;
-}
-
/*ARGSUSED*/
int
COMPATNAME(route_output)(struct mbuf *m, ...)
@@ -356,15 +345,9 @@ COMPATNAME(route_output)(struct mbuf *m,
if (memcmp(info.rti_info[RTAX_DST], rt_getkey(rt),
info.rti_info[RTAX_DST]->sa_len) != 0)
senderr(ESRCH);
- info.rti_info[RTAX_NETMASK] = intern_netmask(
- info.rti_info[RTAX_NETMASK]);
- for (rn = rt->rt_nodes; rn; rn = rn->rn_dupedkey)
- if (info.rti_info[RTAX_NETMASK] ==
- (const struct sockaddr *)rn->rn_mask)
- break;
- if (rn == NULL)
+ if (info.rti_info[RTAX_NETMASK] == NULL &&
+ rt_mask(rt) != NULL)
senderr(ETOOMANYREFS);
- rt = (struct rtentry *)rn;
}
switch (rtm->rtm_type) {
Home |
Main Index |
Thread Index |
Old Index