From owner-svn-src-all@FreeBSD.ORG Fri Jan 10 10:14:52 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7D08F44A; Fri, 10 Jan 2014 10:14:52 +0000 (UTC) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 160121CE7; Fri, 10 Jan 2014 10:14:51 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.7/8.14.7) with ESMTP id s0AAEgQV033425 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 10 Jan 2014 14:14:42 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.7/8.14.7/Submit) id s0AAEg0d033424; Fri, 10 Jan 2014 14:14:42 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Fri, 10 Jan 2014 14:14:42 +0400 From: Gleb Smirnoff To: "Alexander V. Chernikov" Subject: Re: svn commit: r260488 - head/sys/net Message-ID: <20140110101442.GB73147@FreeBSD.org> References: <201401091813.s09IDPlU058184@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201401091813.s09IDPlU058184@svn.freebsd.org> User-Agent: Mutt/1.5.22 (2013-10-16) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2014 10:14:52 -0000 Alexander, some nitpicking: On Thu, Jan 09, 2014 at 06:13:25PM +0000, Alexander V. Chernikov wrote: A> @@ -52,6 +53,7 @@ A> #include A> #include A> #include A> +#include A> A> #include A> #include A> @@ -86,6 +88,13 @@ A> #define RT_NUMFIBS 1 A> #endif A> A> +#if defined(INET) || defined(INET6) A> +#ifdef SCTP A> +extern void sctp_addr_change(struct ifaddr *ifa, int cmd); A> +#endif /* SCTP */ A> +#endif A> + A> + Can be simplified to one liner: #if (defined(INET) || defined(INET6)) && defined(SCTP) Same stands for same ifdef down below in code. And extra empty line shouldn't have been added. A> + A> +/* A> + * Announce interface address arrival/withdraw A> + * Returns 0 on success. A> + */ A> +int A> +rt_addrmsg(int cmd, struct ifaddr *ifa, int fibnum) A> +{ A> + A> + KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE, A> + ("unexpected cmd %u", cmd)); A> + A> + if (fibnum != RT_ALL_FIBS) { A> + KASSERT(fibnum >= 0 && fibnum < rt_numfibs, ("%s: " A> + "fibnum out of range 0 <= %d < %d", __func__, A> + fibnum, rt_numfibs)); A> + } A> + A> + return (rtsock_addrmsg(cmd, ifa, fibnum)); A> +} Second KASSERT together with if clause can be simplified to: KASSERT(fibnum == RT_ALL_FIBS || (fibnum >= 0 && fibnum < rt_numfibs), ... Same simplification can be done in rt_routemsg() and rt_newaddrmsg_fib(). A> + A> +/* A> + * Announce route addition/removal A> + * Users of this function MUST validate input data BEFORE calling. A> + * However we have to be able to handle invalid data: A> + * if some userland app sends us "invalid" route message (invalid mask, A> + * no dst, wrokg address families, etc...) we need to pass it back ^ typo A> + * to app (and any other rtsock consumers) with rtm_errno field set to A> + * non-zero value. A> + * Returns 0 on success. A> + */ A> +int A> +rtsock_routemsg(int cmd, struct ifnet *ifp, int error, struct rtentry *rt, A> + int fibnum) A> { A> + struct rt_addrinfo info; A> + struct sockaddr *sa; A> + struct mbuf *m; A> + struct rt_msghdr *rtm; A> A> - rt_newaddrmsg_fib(cmd, ifa, error, rt, RT_ALL_FIBS); A> + if (route_cb.any_count == 0) A> + return (0); A> + A> + bzero((caddr_t)&info, sizeof(info)); A> + info.rti_info[RTAX_NETMASK] = rt_mask(rt); A> + info.rti_info[RTAX_DST] = sa = rt_key(rt); A> + info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; A> + if ((m = rt_msg1(cmd, &info)) == NULL) A> + return (ENOBUFS); A> + rtm = mtod(m, struct rt_msghdr *); A> + rtm->rtm_index = ifp->if_index; A> + rtm->rtm_flags |= rt->rt_flags; A> + rtm->rtm_errno = error; A> + rtm->rtm_addrs = info.rti_addrs; A> + A> + if (fibnum != RT_ALL_FIBS) { A> + M_SETFIB(m, fibnum); A> + m->m_flags |= RTS_FILTER_FIB; A> + } A> + A> + rt_dispatch(m, sa ? sa->sa_family : AF_UNSPEC); A> + A> + return (0); A> } A> A> + Why extra line here? A> /* A> * This is the analogue to the rt_newaddrmsg which performs the same A> * function but for multicast group memberhips. This is easier since -- Totus tuus, Glebius.