From 9f8eb4c6fbe3b494735a4c22e8e79ba2476a212b Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Wed, 7 Sep 2016 09:36:50 +0000 Subject: Rename rtable_mpath_next() into rtable_iterate() and make it do a proper reference count. rtable_iterate() frees the passed ``rt'' and returns the next one on the multipath list or NULL if there's none. ok dlg@ --- sys/net/if.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'sys/net/if.c') diff --git a/sys/net/if.c b/sys/net/if.c index b9946cf64db..953e7f9afcb 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.445 2016/09/05 13:09:32 claudio Exp $ */ +/* $OpenBSD: if.c,v 1.446 2016/09/07 09:36:49 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2447,7 +2447,7 @@ if_group_egress_build(void) #ifdef INET6 struct sockaddr_in6 sa_in6; #endif - struct rtentry *rt0, *rt; + struct rtentry *rt; TAILQ_FOREACH(ifg, &ifg_head, ifg_next) if (!strcmp(ifg->ifg_group, IFG_EGRESS)) @@ -2460,44 +2460,32 @@ if_group_egress_build(void) bzero(&sa_in, sizeof(sa_in)); sa_in.sin_len = sizeof(sa_in); sa_in.sin_family = AF_INET; - rt0 = rtable_lookup(0, sintosa(&sa_in), sintosa(&sa_in), NULL, RTP_ANY); - if (rt0 != NULL) { - rt = rt0; + rt = rtable_lookup(0, sintosa(&sa_in), sintosa(&sa_in), NULL, RTP_ANY); + if (rt != NULL) { do { ifp = if_get(rt->rt_ifidx); if (ifp != NULL) { if_addgroup(ifp, IFG_EGRESS); if_put(ifp); } -#ifndef SMALL_KERNEL - rt = rtable_mpath_next(rt); -#else - rt = NULL; -#endif + rt = rtable_iterate(rt); } while (rt != NULL); } - rtfree(rt0); #ifdef INET6 bcopy(&sa6_any, &sa_in6, sizeof(sa_in6)); - rt0 = rtable_lookup(0, sin6tosa(&sa_in6), sin6tosa(&sa_in6), NULL, + rt = rtable_lookup(0, sin6tosa(&sa_in6), sin6tosa(&sa_in6), NULL, RTP_ANY); - if (rt0 != NULL) { - rt = rt0; + if (rt != NULL) { do { ifp = if_get(rt->rt_ifidx); if (ifp != NULL) { if_addgroup(ifp, IFG_EGRESS); if_put(ifp); } -#ifndef SMALL_KERNEL - rt = rtable_mpath_next(rt); -#else - rt = NULL; -#endif + rt = rtable_iterate(rt); } while (rt != NULL); } - rtfree(rt0); #endif /* INET6 */ return (0); -- cgit v1.2.3