Date: Tue, 23 Dec 2008 17:50:24 +0100 From: Tijl Coosemans <tijl@ulyssis.org> To: "Li, Qing" <qing.li@bluecoat.com>, Gerald Pfeifer <gerald@pfeifer.com> Cc: Qing Li <qingli@freebsd.org>, freebsd-current@freebsd.org, freebsd-net@freebsd.org Subject: Re: HEADSUP: arp-v2 has been committed Message-ID: <200812231750.26602.tijl@ulyssis.org> In-Reply-To: <B583FBF374231F4A89607B4D08578A4302A8B8BE@bcs-mail03.internal.cacheflow.com> References: <20081221125120.GO23166@droso.net> <200812221621.40722.tijl@ulyssis.org> <B583FBF374231F4A89607B4D08578A4302A8B8BE@bcs-mail03.internal.cacheflow.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812231750.26602.tijl>