From owner-svn-src-stable-11@freebsd.org Fri Jan 13 08:27:09 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1F1A5CADF08; Fri, 13 Jan 2017 08:27:09 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED69C1D49; Fri, 13 Jan 2017 08:27:08 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0D8R8p3044907; Fri, 13 Jan 2017 08:27:08 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0D8R8pb044906; Fri, 13 Jan 2017 08:27:08 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201701130827.v0D8R8pb044906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 13 Jan 2017 08:27:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r312022 - stable/11/usr.sbin/route6d X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2017 08:27:09 -0000 Author: ngie Date: Fri Jan 13 08:27:07 2017 New Revision: 312022 URL: https://svnweb.freebsd.org/changeset/base/312022 Log: MFC r311711,r311712,r311713: r311711: Clean up trailing whitespace r311712: Sort #includes r311713: Use nitems(mib) instead of hardcoding mib's length Modified: stable/11/usr.sbin/route6d/route6d.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/route6d/route6d.c ============================================================================== --- stable/11/usr.sbin/route6d/route6d.c Fri Jan 13 08:24:41 2017 (r312021) +++ stable/11/usr.sbin/route6d/route6d.c Fri Jan 13 08:27:07 2017 (r312022) @@ -4,7 +4,7 @@ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -34,44 +34,40 @@ static const char _rcsid[] = "$KAME: route6d.c,v 1.104 2003/10/31 00:30:20 itojun Exp $"; #endif -#include - -#include -#include -#include -#include -#include -#include -#ifdef __STDC__ -#include -#else -#include -#endif -#include -#include -#include -#include -#ifdef HAVE_POLL_H -#include -#endif - -#include #include #include -#include #include +#include #include #include +#include #include #include #include #include #include #include -#include +#include +#include +#include #include - -#include +#include +#ifdef HAVE_POLL_H +#include +#endif +#include +#include +#ifdef __STDC__ +#include +#else +#include +#endif +#include +#include +#include +#include +#include +#include #include "route6d.h" @@ -106,7 +102,7 @@ struct ifc { /* Configuration of an in }; TAILQ_HEAD(, ifc) ifc_head = TAILQ_HEAD_INITIALIZER(ifc_head); -struct ifac { /* Adddress associated to an interface */ +struct ifac { /* Adddress associated to an interface */ TAILQ_ENTRY(ifac) ifac_next; struct ifc *ifac_ifc; /* back pointer */ @@ -673,7 +669,7 @@ init(void) fatal("rip IPV6_PKTINFO"); /*NOTREACHED*/ } -#endif +#endif #ifdef IPV6_RECVPKTINFO if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, @@ -819,8 +815,8 @@ ripsend(struct ifc *ifcp, struct sockadd * Request from non-link local address is not * a regular route6d update. */ - maxrte = (IFMINMTU - sizeof(struct ip6_hdr) - - sizeof(struct udphdr) - + maxrte = (IFMINMTU - sizeof(struct ip6_hdr) - + sizeof(struct udphdr) - sizeof(struct rip6) + sizeof(struct netinfo6)) / sizeof(struct netinfo6); nh = NULL; @@ -868,8 +864,8 @@ ripsend(struct ifc *ifcp, struct sockadd return; } - maxrte = (ifcp->ifc_mtu - sizeof(struct ip6_hdr) - - sizeof(struct udphdr) - + maxrte = (ifcp->ifc_mtu - sizeof(struct ip6_hdr) - + sizeof(struct udphdr) - sizeof(struct rip6) + sizeof(struct netinfo6)) / sizeof(struct netinfo6); @@ -953,13 +949,13 @@ out_filter(struct riprt *rrt, struct ifc /* * -A: filter out less specific routes, if we have aggregated * route configured. - */ + */ TAILQ_FOREACH(iffp, &ifcp->ifc_iff_head, iff_next) { if (iffp->iff_type != 'A') continue; if (rrt->rrt_info.rip6_plen <= iffp->iff_plen) continue; - ia = rrt->rrt_info.rip6_dest; + ia = rrt->rrt_info.rip6_dest; applyplen(&ia, iffp->iff_plen); if (IN6_ARE_ADDR_EQUAL(&ia, &iffp->iff_addr)) return 0; @@ -995,7 +991,7 @@ out_filter(struct riprt *rrt, struct ifc continue; if (rrt->rrt_info.rip6_plen < iffp->iff_plen) continue; - ia = rrt->rrt_info.rip6_dest; + ia = rrt->rrt_info.rip6_dest; applyplen(&ia, iffp->iff_plen); if (IN6_ARE_ADDR_EQUAL(&ia, &iffp->iff_addr)) { ok = 1; @@ -1195,8 +1191,8 @@ riprecv(void) } else { riprequest(NULL, np, nn, &fsock); } - return; - } + return; + } if (!IN6_IS_ADDR_LINKLOCAL(&fsock.sin6_addr)) { trace(1, "Response from non-ll addr: %s\n", @@ -1223,7 +1219,7 @@ riprecv(void) * source address to be forwarded to a different link. * So we also check whether the destination address is a link-local * address or the hop limit is 255. Note that RFC2080 does not require - * the specific hop limit for a unicast response, so we cannot assume + * the specific hop limit for a unicast response, so we cannot assume * the limitation. */ if (!IN6_IS_ADDR_LINKLOCAL(&pi->ipi6_addr) && *hlimp != 255) { @@ -1245,7 +1241,7 @@ riprecv(void) return; /* The packet is from me; ignore */ if (rp->rip6_cmd != RIP6_RESPONSE) { trace(1, "Invalid command %d\n", rp->rip6_cmd); - return; + return; } /* -N: no use */ @@ -1323,7 +1319,7 @@ riprecv(void) /* special rule: ::/0 means default, not "in /0" */ if (iffp->iff_plen == 0 && np->rip6_plen > 0) continue; - ia = np->rip6_dest; + ia = np->rip6_dest; applyplen(&ia, iffp->iff_plen); if (IN6_ARE_ADDR_EQUAL(&ia, &iffp->iff_addr)) { ok = 1; @@ -1374,7 +1370,7 @@ riprecv(void) } else if (nq->rip6_metric == np->rip6_metric && np->rip6_metric < HOPCNT_INFINITY6) { if (rrt->rrt_index == ifcp->ifc_index && - IN6_ARE_ADDR_EQUAL(&nh, &rrt->rrt_gw)) { + IN6_ARE_ADDR_EQUAL(&nh, &rrt->rrt_gw)) { /* same metric, same route from same gw */ rrt->rrt_t = t; } else if (rrt->rrt_t < t_half_lifetime) { @@ -1389,7 +1385,7 @@ riprecv(void) rrt->rrt_t = t; } } - /* + /* * if nq->rip6_metric == HOPCNT_INFINITY6 then * do not update age value. Do nothing. */ @@ -1667,7 +1663,7 @@ ifremove(int ifindex) break; } if (ifcp == NULL) - return; + return; tracet(1, "ifremove: %s is departed.\n", ifcp->ifc_name); TAILQ_REMOVE(&ifc_head, ifcp, ifc_next); @@ -1824,7 +1820,7 @@ rtrecv(void) #if 0 if (rta[RTAX_DST] == NULL) { trace(1, "\tno destination, ignored\n"); - continue; + continue; } if (rta[RTAX_DST]->sin6_family != AF_INET6) { trace(1, "\taf mismatch, ignored\n"); @@ -2422,7 +2418,7 @@ getifmtu(int ifindex) mib[3] = AF_INET6; mib[4] = NET_RT_IFLIST; mib[5] = ifindex; - if (sysctl(mib, 6, NULL, &msize, NULL, 0) < 0) { + if (sysctl(mib, nitems(mib), NULL, &msize, NULL, 0) < 0) { fatal("sysctl estimate NET_RT_IFLIST"); /*NOTREACHED*/ } @@ -2430,7 +2426,7 @@ getifmtu(int ifindex) fatal("malloc"); /*NOTREACHED*/ } - if (sysctl(mib, 6, buf, &msize, NULL, 0) < 0) { + if (sysctl(mib, nitems(mib), buf, &msize, NULL, 0) < 0) { fatal("sysctl NET_RT_IFLIST"); /*NOTREACHED*/ } @@ -2602,7 +2598,7 @@ krtread(int again) free(buf); buf = NULL; } - if (sysctl(mib, 6, NULL, &msize, NULL, 0) < 0) { + if (sysctl(mib, nitems(mib), NULL, &msize, NULL, 0) < 0) { errmsg = "sysctl estimate"; continue; } @@ -2610,7 +2606,7 @@ krtread(int again) errmsg = "malloc"; continue; } - if (sysctl(mib, 6, buf, &msize, NULL, 0) < 0) { + if (sysctl(mib, nitems(mib), buf, &msize, NULL, 0) < 0) { errmsg = "sysctl NET_RT_DUMP"; continue; } @@ -3238,7 +3234,7 @@ ifonly: #if 0 /* * When the address has already been registered in the - * kernel routing table, it should be removed + * kernel routing table, it should be removed */ delroute(&rrt->rrt_info, &gw); #else @@ -3319,7 +3315,7 @@ mask2len(const struct in6_addr *addr, in { int i = 0, j; const u_char *p = (const u_char *)addr; - + for (j = 0; j < lenlim; j++, p++) { if (*p != 0xff) break; @@ -3446,7 +3442,7 @@ ripsuptrig(void) time_t t; double r = rand(); - t = (int)(RIP_TRIG_INT6_MIN + + t = (int)(RIP_TRIG_INT6_MIN + (RIP_TRIG_INT6_MAX - RIP_TRIG_INT6_MIN) * (r / RAND_MAX)); sup_trig_update = time(NULL) + t; return t;