From owner-svn-src-stable@FreeBSD.ORG Tue Sep 15 19:58:34 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50075106566C; Tue, 15 Sep 2009 19:58:34 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D5A08FC0C; Tue, 15 Sep 2009 19:58:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8FJwYgM001416; Tue, 15 Sep 2009 19:58:34 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8FJwYH3001414; Tue, 15 Sep 2009 19:58:34 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200909151958.n8FJwYH3001414@svn.freebsd.org> From: Qing Li Date: Tue, 15 Sep 2009 19:58:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197231 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2009 19:58:34 -0000 Author: qingli Date: Tue Sep 15 19:58:33 2009 New Revision: 197231 URL: http://svn.freebsd.org/changeset/base/197231 Log: MFC r196714 This patch fixes the following issues: - Routing messages are not generated when adding and removing interface address aliases. - Loopback route installed for an interface address alias is not deleted from the routing table when that address alias is removed from the associated interface. - Function in_ifscrub() is called extraneously. Reviewed by: gnn, kmacy, sam Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/in.c Modified: stable/8/sys/netinet/in.c ============================================================================== --- stable/8/sys/netinet/in.c Tue Sep 15 19:56:35 2009 (r197230) +++ stable/8/sys/netinet/in.c Tue Sep 15 19:58:33 2009 (r197231) @@ -536,7 +536,6 @@ in_control(struct socket *so, u_long cmd hostIsNew = 0; } if (ifra->ifra_mask.sin_len) { - in_ifscrub(ifp, ia); ia->ia_sockmask = ifra->ifra_mask; ia->ia_sockmask.sin_family = AF_INET; ia->ia_subnetmask = @@ -545,7 +544,6 @@ in_control(struct socket *so, u_long cmd } if ((ifp->if_flags & IFF_POINTOPOINT) && (ifra->ifra_dstaddr.sin_family == AF_INET)) { - in_ifscrub(ifp, ia); ia->ia_dstaddr = ifra->ifra_dstaddr; maskIsNew = 1; /* We lie; but the effect's the same */ } @@ -991,6 +989,40 @@ in_addprefix(struct in_ifaddr *target, i IN_IFADDR_RUNLOCK(); return (EEXIST); } else { + struct route pfx_ro; + struct sockaddr_in *pfx_addr; + struct rtentry msg_rt; + + /* QL: XXX + * This is a bit questionable because there is no + * additional route entry added for an address alias. + * Therefore this route report is inaccurate. Perhaps + * it's better to supply a empty rtentry as how it + * is done in in_scrubprefix(). + */ + bzero(&pfx_ro, sizeof(pfx_ro)); + pfx_addr = (struct sockaddr_in *)(&pfx_ro.ro_dst); + pfx_addr->sin_len = sizeof(*pfx_addr); + pfx_addr->sin_family = AF_INET; + pfx_addr->sin_addr = prefix; + rtalloc_ign_fib(&pfx_ro, 0, 0); + if (pfx_ro.ro_rt != NULL) { + msg_rt = *pfx_ro.ro_rt; + /* QL: XXX + * Point the gateway to the given interface + * address as if a new prefix route entry has + * been added through the new address alias. + * All other parts of the rtentry is accurate, + * e.g., rt_key, rt_mask, rt_ifp etc. + */ + msg_rt.rt_gateway = + (struct sockaddr *)&ia->ia_addr; + rt_newaddrmsg(RTM_ADD, + (struct ifaddr *)target, + 0, &msg_rt); + RTFREE(pfx_ro.ro_rt); + } + IN_IFADDR_RUNLOCK(); return (0); } @@ -1024,9 +1056,6 @@ in_scrubprefix(struct in_ifaddr *target) struct rt_addrinfo info; struct sockaddr_dl null_sdl; - if ((target->ia_flags & IFA_ROUTE) == 0) - return (0); - /* * Remove the loopback route to the interface address. * The "useloopback" setting is not consulted because if the @@ -1054,6 +1083,20 @@ in_scrubprefix(struct in_ifaddr *target) log(LOG_INFO, "in_scrubprefix: deletion failed\n"); } + if ((target->ia_flags & IFA_ROUTE) == 0) { + struct rtentry rt; + + /* QL: XXX + * Report a blank rtentry when a route has not been + * installed for the given interface address. + */ + bzero(&rt, sizeof(rt)); + rt_newaddrmsg(RTM_DELETE, + (struct ifaddr *)target, + 0, &rt); + return (0); + } + if (rtinitflags(target)) prefix = target->ia_dstaddr.sin_addr; else {