diff options
author | melifaro <melifaro@FreeBSD.org> | 2015-11-30 05:51:14 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2015-11-30 05:51:14 +0000 |
commit | e1984564835422629dc73f3551f3be70602c551a (patch) | |
tree | 0be60b29fa72a36767c89b7639430ba4896bcf2a /sys/netinet | |
parent | 48efdd4beccfc6adef1e3c7e8cb51a875a76a814 (diff) | |
download | FreeBSD-src-e1984564835422629dc73f3551f3be70602c551a.zip FreeBSD-src-e1984564835422629dc73f3551f3be70602c551a.tar.gz |
Add new rt_foreach_fib_walk_del() function for deleting route entries
by filter function instead of picking into routing table details in
each consumer.
Remove now-unused rt_expunge() (eliminating last external RTF_RNH_LOCKED
user).
This simplifies future nexthops/mulitipath changes and rtrequest1_fib()
locking refactoring.
Actual changes:
Add "rt_chain" field to permit rte grouping while doing batched delete
from routing table (thus growing rte 200->208 on amd64).
Add "rti_filter" / "rti_filterdata" / "rti_spare" fields to rt_addrinfo
to pass filter function to various routing subsystems in standard way.
Convert all rt_expunge() customers to new rt_addinfo-based api and eliminate
rt_expunge().
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/in_rmx.c | 46 |
1 files changed, 6 insertions, 40 deletions
diff --git a/sys/netinet/in_rmx.c b/sys/netinet/in_rmx.c index e17d36f..3834a57 100644 --- a/sys/netinet/in_rmx.c +++ b/sys/netinet/in_rmx.c @@ -150,56 +150,22 @@ in_detachhead(void **head, int off) * plug back in. */ struct in_ifadown_arg { - struct radix_node_head *rnh; struct ifaddr *ifa; int del; }; static int -in_ifadownkill(struct rtentry *rt, void *xap) +in_ifadownkill(const struct rtentry *rt, void *xap) { struct in_ifadown_arg *ap = xap; - RT_LOCK(rt); - if (rt->rt_ifa == ap->ifa && - (ap->del || !(rt->rt_flags & RTF_STATIC))) { - /* - * Aquire a reference so that it can later be freed - * as the refcount would be 0 here in case of at least - * ap->del. - */ - RT_ADDREF(rt); - /* - * Disconnect it from the tree and permit protocols - * to cleanup. - */ - rt_expunge(ap->rnh, rt); - /* - * At this point it is an rttrash node, and in case - * the above is the only reference we must free it. - * If we do not noone will have a pointer and the - * rtentry will be leaked forever. - * In case someone else holds a reference, we are - * fine as we only decrement the refcount. In that - * case if the other entity calls RT_REMREF, we - * will still be leaking but at least we tried. - */ - RTFREE_LOCKED(rt); + if (rt->rt_ifa != ap->ifa) return (0); - } - RT_UNLOCK(rt); - return 0; -} - -static void -in_setifarnh(struct radix_node_head *rnh, uint32_t fibnum, int af, - void *_arg) -{ - struct in_ifadown_arg *arg; - arg = (struct in_ifadown_arg *)_arg; + if ((rt->rt_flags & RTF_STATIC) != 0 && ap->del == 0) + return (0); - arg->rnh = rnh; + return (1); } void @@ -213,7 +179,7 @@ in_ifadown(struct ifaddr *ifa, int delete) arg.ifa = ifa; arg.del = delete; - rt_foreach_fib_walk(AF_INET, in_setifarnh, in_ifadownkill, &arg); + rt_foreach_fib_walk_del(AF_INET, in_ifadownkill, &arg); ifa->ifa_flags &= ~IFA_ROUTE; /* XXXlocking? */ } |