From owner-svn-src-head@FreeBSD.ORG Tue Jun 25 00:10:50 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 95C93B4F; Tue, 25 Jun 2013 00:10:50 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6EE5617E2; Tue, 25 Jun 2013 00:10:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5P0Ao2M087959; Tue, 25 Jun 2013 00:10:50 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5P0Aosi087956; Tue, 25 Jun 2013 00:10:50 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <201306250010.r5P0Aosi087956@svn.freebsd.org> From: Qing Li Date: Tue, 25 Jun 2013 00:10:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r252184 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jun 2013 00:10:50 -0000 Author: qingli Date: Tue Jun 25 00:10:49 2013 New Revision: 252184 URL: http://svnweb.freebsd.org/changeset/base/252184 Log: Due to the routing related networking kernel redesign work in FBSD 8.0, interface routes have been returened to the applications without the RTF_GATEWAY bit. This incompatibility has caused some issues with Zebra, Qugga and the like. This patch provides the RTF_GATEWAY flag bit in returned interface routes so to behave similarly to pre 8.0 systems. Reviewed by: hrs Verified by: mackn at opendns dot com Modified: head/sys/net/route.h head/sys/net/rtsock.c Modified: head/sys/net/route.h ============================================================================== --- head/sys/net/route.h Mon Jun 24 23:41:16 2013 (r252183) +++ head/sys/net/route.h Tue Jun 25 00:10:49 2013 (r252184) @@ -185,6 +185,9 @@ struct ortentry { #define RTF_RNH_LOCKED 0x40000000 /* radix node head is locked */ +#define RTF_GWFLAG_COMPAT 0x80000000 /* a compatibility bit for interacting + with existing routing apps */ + /* Mask of RTF flags that are allowed to be modified by RTM_CHANGE. */ #define RTF_FMASK \ (RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_BLACKHOLE | \ Modified: head/sys/net/rtsock.c ============================================================================== --- head/sys/net/rtsock.c Mon Jun 24 23:41:16 2013 (r252183) +++ head/sys/net/rtsock.c Tue Jun 25 00:10:49 2013 (r252184) @@ -652,8 +652,10 @@ route_output(struct mbuf *m, struct sock */ if (gw_ro.ro_rt != NULL && gw_ro.ro_rt->rt_gateway->sa_family == AF_LINK && - gw_ro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK) + gw_ro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK) { info.rti_flags &= ~RTF_GATEWAY; + info.rti_flags |= RTF_GWFLAG_COMPAT; + } if (gw_ro.ro_rt != NULL) RTFREE(gw_ro.ro_rt); } @@ -853,7 +855,11 @@ route_output(struct mbuf *m, struct sock Free(rtm); rtm = new_rtm; } (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL); - rtm->rtm_flags = rt->rt_flags; + if (rt->rt_flags & RTF_GWFLAG_COMPAT) + rtm->rtm_flags = RTF_GATEWAY | + (rt->rt_flags & ~RTF_GWFLAG_COMPAT); + else + rtm->rtm_flags = rt->rt_flags; rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx); rtm->rtm_addrs = info.rti_addrs; break; @@ -905,6 +911,7 @@ route_output(struct mbuf *m, struct sock RT_UNLOCK(rt); senderr(error); } + rt->rt_flags &= ~RTF_GATEWAY; rt->rt_flags |= (RTF_GATEWAY & info.rti_flags); } if (info.rti_ifa != NULL && @@ -1591,7 +1598,11 @@ sysctl_dumpentry(struct radix_node *rn, if (w->w_req && w->w_tmem) { struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem; - rtm->rtm_flags = rt->rt_flags; + if (rt->rt_flags & RTF_GWFLAG_COMPAT) + rtm->rtm_flags = RTF_GATEWAY | + (rt->rt_flags & ~RTF_GWFLAG_COMPAT); + else + rtm->rtm_flags = rt->rt_flags; /* * let's be honest about this being a retarded hack */