From owner-freebsd-net@FreeBSD.ORG Tue Dec 23 16:53:02 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E0EF1065675; Tue, 23 Dec 2008 16:53:02 +0000 (UTC) (envelope-from tijl@ulyssis.org) Received: from mailrelay007.isp.belgacom.be (mailrelay007.isp.belgacom.be [195.238.6.173]) by mx1.freebsd.org (Postfix) with ESMTP id 1B9FD8FC12; Tue, 23 Dec 2008 16:53:00 +0000 (UTC) (envelope-from tijl@ulyssis.org) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApIFAHmmUElR92C8/2dsb2JhbACBbJMMqkBYkWqGQw Received: from 188.96-247-81.adsl-dyn.isp.belgacom.be (HELO kalimero.kotnet.org) ([81.247.96.188]) by relay.skynet.be with ESMTP; 23 Dec 2008 17:52:58 +0100 Received: from kalimero.kotnet.org (kalimero.kotnet.org [127.0.0.1]) by kalimero.kotnet.org (8.14.3/8.14.3) with ESMTP id mBNGoRx3004433; Tue, 23 Dec 2008 17:50:27 +0100 (CET) (envelope-from tijl@ulyssis.org) From: Tijl Coosemans To: "Li, Qing" , Gerald Pfeifer Date: Tue, 23 Dec 2008 17:50:24 +0100 User-Agent: KMail/1.9.10 References: <20081221125120.GO23166@droso.net> <200812221621.40722.tijl@ulyssis.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_SbRUJWpnEldcbHg" Message-Id: <200812231750.26602.tijl@ulyssis.org> Cc: Qing Li , freebsd-current@freebsd.org, freebsd-net@freebsd.org Subject: Re: HEADSUP: arp-v2 has been committed X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Dec 2008 16:53:02 -0000 --Boundary-00=_SbRUJWpnEldcbHg Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Tuesday 23 December 2008 03:27:21 Li, Qing wrote: >> I'm looking into the Wine case, but don't have any experience with >> the implementation of routing tables, so I need to have a few things >> spelled out. >> >> Wine currently uses: >> >> int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, >> RTF_LLINFO}; >> >> I take it this returns all the entries which have the RTF_LLINFO >> flag set? And to make this compile on CURRENT I have to change this >> into: >> >> #ifdef RTF_LLINFO >> int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, >> RTF_LLINFO}; >> #else >> int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, 0}; >> #endif >> >> Is AF_INET really the correct address family? What about AF_LINK and >> AF_ARP? Is using NET_RT_FLAGS with flags mask 0 exactly the same as >> using NET_RT_DUMP? > > AF_INET is the correct address family, which indicates the L2 > information (a.k.a RTF_LLINFO previously) should be retrieved from > the IPv4 ARP table. If the AF family were instead AF_INET6, then the > L2 information would be coming from the ND6 cache. > > NET_RT_DUMP walks the entire routing tree. Specifying specific flags > and using the NET_RT_FLAGS opcode retrieves routing entries that have > those bits set. > > NET_RT_FLAGS with mask 0 is an indication to the kernel the L2 table > should be retrieved. > > I am glad you asked these questions because after re-examining my > code, I realized I could make slight optimization and also need to > perform additional check against erroneous input. > >> Also, at some other place, Wine wants to retrieve gateway entries >> and it uses: >> >> int mib[6] = {CTL_NET, PF_ROUTE, 0, PF_INET, NET_RT_DUMP, 0}; >> ^ this should be AF_INET I think >> >> After that it runs over all entries counting only those which have >> RTF_GATEWAY set and RTF_MULTICAST unset. Is the output of this >> different now in CURRENT? > > No, the output of this command is still the same. NET_RT_DUMP obtains > the entire L3 table and filtering for RTF_GATEWAY non-multicast > routes have the same semantics. Those flags never apply to L2 entries. Thanks for answering my questions. I've attached the patch for Wine. --Boundary-00=_SbRUJWpnEldcbHg Content-Type: text/plain; charset="iso-8859-1"; name="patch-wine-iphlpapi-current" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-wine-iphlpapi-current" diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c index 3fc91eb..99e78a0 100644 --- a/dlls/iphlpapi/ipstats.c +++ b/dlls/iphlpapi/ipstats.c @@ -1250,7 +1250,11 @@ DWORD getRouteTable(PMIB_IPFORWARDTABLE *ppIpForwardTable, HANDLE heap, DWORD getNumArpEntries(void) { #if defined(HAVE_SYS_SYSCTL_H) && defined(NET_RT_DUMP) +#ifdef RTF_LLINFO int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, RTF_LLINFO}; +#else + int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, 0}; +#endif #define MIB_LEN (sizeof(mib) / sizeof(mib[0])) DWORD arpEntries = 0; size_t needed; @@ -1308,7 +1312,11 @@ DWORD getArpTable(PMIB_IPNETTABLE *ppIpNetTable, HANDLE heap, DWORD flags) #if defined(HAVE_SYS_SYSCTL_H) && defined(NET_RT_DUMP) if (table) { +#ifdef RTF_LLINFO int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, RTF_LLINFO}; +#else + int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, 0}; +#endif #define MIB_LEN (sizeof(mib) / sizeof(mib[0])) size_t needed; char *buf, *lim, *next; --Boundary-00=_SbRUJWpnEldcbHg--