Re: HEADSUP: arp-v2 has been committed

From: Tijl Coosemans <tijl_at_ulyssis.org>
Date: Tue, 23 Dec 2008 17:50:24 +0100
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.

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
_at__at_ -1250,7 +1250,11 _at__at_ 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;
_at__at_ -1308,7 +1312,11 _at__at_ 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;
Received on Tue Dec 23 2008 - 15:53:02 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:39 UTC