HEADSUP: arp-v2 has been committed
Tijl Coosemans
tijl at ulyssis.org
Tue Dec 23 16:53:02 UTC 2008
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.
-------------- next part --------------
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;
More information about the freebsd-current
mailing list