diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2006-03-06 13:22:21 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2006-03-06 13:22:21 +0000 |
commit | 6457be566dedd330ad31b8ca0dbb339f7af3c4d2 (patch) | |
tree | 900efc122174038fce00d83a2a6ed84630e67ed1 | |
parent | 521c0ce1324fe01b78d315656458af3a171c86c7 (diff) |
KNF, cleanup etc, no binary change
-rw-r--r-- | sys/net/route.c | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 5497fa883c3..060f2288eef 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.63 2006/02/01 13:47:22 claudio Exp $ */ +/* $OpenBSD: route.c,v 1.64 2006/03/06 13:22:20 henning Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -124,26 +124,26 @@ #ifdef IPSEC #include <netinet/ip_ipsp.h> -extern struct ifnet encif; -struct ifaddr * encap_findgwifa(struct sockaddr *); +extern struct ifnet encif; +struct ifaddr *encap_findgwifa(struct sockaddr *); #endif #define SA(p) ((struct sockaddr *)(p)) -struct route_cb route_cb; -struct rtstat rtstat; -struct radix_node_head *rt_tables[AF_MAX+1]; +struct route_cb route_cb; +struct rtstat rtstat; +struct radix_node_head *rt_tables[AF_MAX+1]; -int rttrash; /* routes not in table but not freed */ -struct sockaddr wildcard; /* zero valued cookie for wildcard searches */ +int rttrash; /* routes not in table but not freed */ +struct sockaddr wildcard; /* zero cookie for wildcard searches */ -struct pool rtentry_pool; /* pool for rtentry structures */ -struct pool rttimer_pool; /* pool for rttimer structures */ +struct pool rtentry_pool; /* pool for rtentry structures */ +struct pool rttimer_pool; /* pool for rttimer structures */ -int okaytoclone(u_int, int); -int rtdeletemsg(struct rtentry *); -int rtflushclone1(struct radix_node *, void *); -void rtflushclone(struct radix_node_head *, struct rtentry *); +int okaytoclone(u_int, int); +int rtdeletemsg(struct rtentry *); +int rtflushclone1(struct radix_node *, void *); +void rtflushclone(struct radix_node_head *, struct rtentry *); #define LABELID_MAX 50000 @@ -206,12 +206,12 @@ okaytoclone(u_int flags, int howstrict) struct rtentry * rtalloc2(struct sockaddr *dst, int report, int howstrict) { - struct radix_node_head *rnh = rt_tables[dst->sa_family]; - struct rtentry *rt; - struct radix_node *rn; - struct rtentry *newrt = 0; - struct rt_addrinfo info; - int s = splnet(), err = 0, msgtype = RTM_MISS; + struct radix_node_head *rnh = rt_tables[dst->sa_family]; + struct rtentry *rt; + struct radix_node *rn; + struct rtentry *newrt = 0; + struct rt_addrinfo info; + int s = splnet(), err = 0, msgtype = RTM_MISS; if (rnh && (rn = rnh->rnh_matchaddr((caddr_t)dst, rnh)) && ((rn->rn_flags & RNF_ROOT) == 0)) { @@ -257,12 +257,12 @@ rtalloc(struct route *ro) struct rtentry * rtalloc1(struct sockaddr *dst, int report) { - struct radix_node_head *rnh = rt_tables[dst->sa_family]; - struct rtentry *rt; - struct radix_node *rn; - struct rtentry *newrt = 0; - struct rt_addrinfo info; - int s = splsoftnet(), err = 0, msgtype = RTM_MISS; + struct radix_node_head *rnh = rt_tables[dst->sa_family]; + struct rtentry *rt; + struct radix_node *rn; + struct rtentry *newrt = 0; + struct rt_addrinfo info; + int s = splsoftnet(), err = 0, msgtype = RTM_MISS; if (rnh && (rn = rnh->rnh_matchaddr((caddr_t)dst, rnh)) && ((rn->rn_flags & RNF_ROOT) == 0)) { @@ -285,7 +285,7 @@ rtalloc1(struct sockaddr *dst, int report) info.rti_info[RTAX_NETMASK] = rt_mask(rt); info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; if (rt->rt_ifp != NULL) { - info.rti_info[RTAX_IFP] = + info.rti_info[RTAX_IFP] = TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr; info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; } @@ -294,7 +294,7 @@ rtalloc1(struct sockaddr *dst, int report) rt->rt_refcnt++; } else { if (dst->sa_family != PF_KEY) - rtstat.rts_unreach++; + rtstat.rts_unreach++; /* * IP encapsulation does lots of lookups where we don't need nor want * the RTM_MISSes that would be generated. It causes RTM_MISS storms @@ -313,14 +313,14 @@ rtalloc1(struct sockaddr *dst, int report) void rtfree(struct rtentry *rt) { - struct ifaddr *ifa; + struct ifaddr *ifa; if (rt == NULL) panic("rtfree"); rt->rt_refcnt--; if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_UP) == 0) { if (rt->rt_nodes->rn_flags & (RNF_ACTIVE | RNF_ROOT)) - panic ("rtfree 2"); + panic("rtfree 2"); rttrash--; if (rt->rt_refcnt < 0) { printf("rtfree: %p not freed (neg refs)\n", rt); @@ -360,11 +360,11 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway, struct sockaddr *netmask, int flags, struct sockaddr *src, struct rtentry **rtp) { - struct rtentry *rt; - int error = 0; - u_int32_t *stat = NULL; - struct rt_addrinfo info; - struct ifaddr *ifa; + struct rtentry *rt; + int error = 0; + u_int32_t *stat = NULL; + struct rt_addrinfo info; + struct ifaddr *ifa; splassert(IPL_SOFTNET); @@ -408,10 +408,10 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway, * Changing from route to net => route to host. * Create new route, rather than smashing route to net. */ - create: +create: if (rt) rtfree(rt); - flags |= RTF_GATEWAY | RTF_DYNAMIC; + flags |= RTF_GATEWAY | RTF_DYNAMIC; bzero(&info, sizeof(info)); info.rti_info[RTAX_DST] = dst; info.rti_info[RTAX_GATEWAY] = gateway; @@ -461,8 +461,8 @@ out: int rtdeletemsg(struct rtentry *rt) { - int error; - struct rt_addrinfo info; + int error; + struct rt_addrinfo info; /* * Request the new route so that the entry is not actually @@ -489,7 +489,7 @@ rtdeletemsg(struct rtentry *rt) int rtflushclone1(struct radix_node *rn, void *arg) { - struct rtentry *rt, *parent; + struct rtentry *rt, *parent; rt = (struct rtentry *)rn; parent = (struct rtentry *)arg; @@ -523,7 +523,7 @@ rtioctl(u_long req, caddr_t data, struct proc *p) struct ifaddr * ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway) { - struct ifaddr *ifa; + struct ifaddr *ifa; #ifdef IPSEC /* @@ -533,7 +533,7 @@ ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway) * enc0. */ if (dst && (dst->sa_family == PF_KEY)) - return encap_findgwifa(gateway); + return (encap_findgwifa(gateway)); #endif if ((flags & RTF_GATEWAY) == 0) { @@ -545,7 +545,7 @@ ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway) * we can use the local address. */ ifa = NULL; - if (flags & RTF_HOST) + if (flags & RTF_HOST) ifa = ifa_ifwithdstaddr(dst); if (ifa == NULL) ifa = ifa_ifwithaddr(gateway); @@ -560,7 +560,7 @@ ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway) if (ifa == NULL) ifa = ifa_ifwithnet(gateway); if (ifa == NULL) { - struct rtentry *rt = rtalloc1(gateway, 0); + struct rtentry *rt = rtalloc1(gateway, 0); if (rt == NULL) return (NULL); rt->rt_refcnt--; @@ -572,7 +572,7 @@ ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway) return (NULL); } if (ifa->ifa_addr->sa_family != dst->sa_family) { - struct ifaddr *oifa = ifa; + struct ifaddr *oifa = ifa; ifa = ifaof_ifpforaddr(dst, ifa->ifa_ifp); if (ifa == NULL) ifa = oifa; @@ -586,7 +586,7 @@ int rtrequest(int req, struct sockaddr *dst, struct sockaddr *gateway, struct sockaddr *netmask, int flags, struct rtentry **ret_nrt) { - struct rt_addrinfo info; + struct rt_addrinfo info; bzero(&info, sizeof(info)); info.rti_flags = flags; @@ -610,8 +610,8 @@ rtrequest(int req, struct sockaddr *dst, struct sockaddr *gateway, int rt_getifa(struct rt_addrinfo *info) { - struct ifaddr *ifa; - int error = 0; + struct ifaddr *ifa; + int error = 0; /* * ifp may be specified by sockaddr_dl when protocol address @@ -624,7 +624,7 @@ rt_getifa(struct rt_addrinfo *info) if (info->rti_ifa == NULL && ifaaddr != NULL) info->rti_ifa = ifa_ifwithaddr(ifaaddr); if (info->rti_ifa == NULL) { - struct sockaddr *sa; + struct sockaddr *sa; sa = ifaaddr != NULL ? ifaaddr : (gateway != NULL ? gateway : dst); @@ -646,12 +646,12 @@ rt_getifa(struct rt_addrinfo *info) int rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) { - int s = splsoftnet(); int error = 0; - struct rtentry *rt, *crt; - struct radix_node *rn; - struct radix_node_head *rnh; - struct ifaddr *ifa; - struct sockaddr *ndst; + int s = splsoftnet(); int error = 0; + struct rtentry *rt, *crt; + struct radix_node *rn; + struct radix_node_head *rnh; + struct ifaddr *ifa; + struct sockaddr *ndst; struct sockaddr_rtlabel *sa_rl; #define senderr(x) { error = x ; goto bad; } @@ -684,7 +684,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) rtflushclone(rnh, rt); } if (rn->rn_flags & (RNF_ACTIVE | RNF_ROOT)) - panic ("rtrequest delete"); + panic("rtrequest delete"); rt = (struct rtentry *)rn; if (rt->rt_gwroute) { rt = rt->rt_gwroute; RTFREE(rt); @@ -819,9 +819,9 @@ bad: int rt_setgate(struct rtentry *rt0, struct sockaddr *dst, struct sockaddr *gate) { - caddr_t new, old; - int dlen = ROUNDUP(dst->sa_len), glen = ROUNDUP(gate->sa_len); - struct rtentry *rt = rt0; + caddr_t new, old; + int dlen = ROUNDUP(dst->sa_len), glen = ROUNDUP(gate->sa_len); + struct rtentry *rt = rt0; if (rt->rt_gateway == NULL || glen > ROUNDUP(rt->rt_gateway->sa_len)) { old = (caddr_t)rt_key(rt); @@ -864,13 +864,13 @@ rt_setgate(struct rtentry *rt0, struct sockaddr *dst, struct sockaddr *gate) void rt_maskedcopy(struct sockaddr *src, struct sockaddr *dst, - struct sockaddr *netmask) + struct sockaddr *netmask) { - u_char *cp1 = (u_char *)src; - u_char *cp2 = (u_char *)dst; - u_char *cp3 = (u_char *)netmask; - u_char *cplim = cp2 + *cp3; - u_char *cplim2 = cp2 + *cp1; + u_char *cp1 = (u_char *)src; + u_char *cp2 = (u_char *)dst; + u_char *cp3 = (u_char *)netmask; + u_char *cplim = cp2 + *cp3; + u_char *cplim2 = cp2 + *cp1; *cp2++ = *cp1++; *cp2++ = *cp1++; /* copies sa_len & sa_family */ cp3 += 2; @@ -889,13 +889,13 @@ rt_maskedcopy(struct sockaddr *src, struct sockaddr *dst, int rtinit(struct ifaddr *ifa, int cmd, int flags) { - struct rtentry *rt; - struct sockaddr *dst; - struct sockaddr *deldst; - struct mbuf *m = NULL; - struct rtentry *nrt = NULL; - int error; - struct rt_addrinfo info; + struct rtentry *rt; + struct sockaddr *dst; + struct sockaddr *deldst; + struct mbuf *m = NULL; + struct rtentry *nrt = NULL; + int error; + struct rt_addrinfo info; dst = flags & RTF_HOST ? ifa->ifa_dstaddr : ifa->ifa_addr; if (cmd == RTM_DELETE) { @@ -941,7 +941,7 @@ rtinit(struct ifaddr *ifa, int cmd, int flags) rt->rt_refcnt--; if (rt->rt_ifa != ifa) { printf("rtinit: wrong ifa (%p) was (%p)\n", - ifa, rt->rt_ifa); + ifa, rt->rt_ifa); if (rt->rt_ifa->ifa_rtrequest) rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, NULL); IFAFREE(rt->rt_ifa); @@ -965,16 +965,16 @@ rtinit(struct ifaddr *ifa, int cmd, int flags) * for multiple queues for efficiency's sake... */ -LIST_HEAD(, rttimer_queue) rttimer_queue_head; -static int rt_init_done = 0; +LIST_HEAD(, rttimer_queue) rttimer_queue_head; +static int rt_init_done = 0; #define RTTIMER_CALLOUT(r) { \ if (r->rtt_func != NULL) { \ (*r->rtt_func)(r->rtt_rt, r); \ } else { \ rtrequest((int) RTM_DELETE, \ - (struct sockaddr *)rt_key(r->rtt_rt), \ - 0, 0, 0, 0); \ + (struct sockaddr *)rt_key(r->rtt_rt), \ + 0, 0, 0, 0); \ } \ } @@ -988,7 +988,7 @@ static int rt_init_done = 0; void rt_timer_init() { - static struct timeout rt_timer_timeout; + static struct timeout rt_timer_timeout; KASSERT(rt_init_done == 0); @@ -1004,14 +1004,14 @@ rt_timer_init() struct rttimer_queue * rt_timer_queue_create(u_int timeout) { - struct rttimer_queue *rtq; + struct rttimer_queue *rtq; if (rt_init_done == 0) rt_timer_init(); R_Malloc(rtq, struct rttimer_queue *, sizeof *rtq); if (rtq == NULL) - return (NULL); + return (NULL); Bzero(rtq, sizeof *rtq); rtq->rtq_timeout = timeout; @@ -1032,7 +1032,7 @@ rt_timer_queue_change(struct rttimer_queue *rtq, long timeout) void rt_timer_queue_destroy(struct rttimer_queue *rtq, int destroy) { - struct rttimer *r; + struct rttimer *r; while ((r = TAILQ_FIRST(&rtq->rtq_head)) != NULL) { LIST_REMOVE(r, rtt_link); @@ -1060,10 +1060,10 @@ rt_timer_count(struct rttimer_queue *rtq) return (rtq->rtq_count); } -void +void rt_timer_remove_all(struct rtentry *rt) { - struct rttimer *r; + struct rttimer *r; while ((r = LIST_FIRST(&rt->rt_timer)) != NULL) { LIST_REMOVE(r, rtt_link); @@ -1076,12 +1076,12 @@ rt_timer_remove_all(struct rtentry *rt) } } -int +int rt_timer_add(struct rtentry *rt, void (*func)(struct rtentry *, struct rttimer *), struct rttimer_queue *queue) { - struct rttimer *r; - long current_time; + struct rttimer *r; + long current_time; current_time = time_uptime; rt->rt_rmx.rmx_expire = time_second + queue->rtq_timeout; @@ -1116,7 +1116,7 @@ rt_timer_add(struct rtentry *rt, void (*func)(struct rtentry *, LIST_INSERT_HEAD(&rt->rt_timer, r, rtt_link); TAILQ_INSERT_TAIL(&queue->rtq_head, r, rtt_next); r->rtt_queue->rtq_count++; - + return (0); } @@ -1124,16 +1124,16 @@ rt_timer_add(struct rtentry *rt, void (*func)(struct rtentry *, void rt_timer_timer(void *arg) { - struct timeout *to = (struct timeout *)arg; - struct rttimer_queue *rtq; - struct rttimer *r; - long current_time; - int s; + struct timeout *to = (struct timeout *)arg; + struct rttimer_queue *rtq; + struct rttimer *r; + long current_time; + int s; current_time = time_uptime; s = splsoftnet(); - for (rtq = LIST_FIRST(&rttimer_queue_head); rtq != NULL; + for (rtq = LIST_FIRST(&rttimer_queue_head); rtq != NULL; rtq = LIST_NEXT(rtq, rtq_link)) { while ((r = TAILQ_FIRST(&rtq->rtq_head)) != NULL && (r->rtt_time + rtq->rtq_timeout) < current_time) { |