On Feb 21, 2013, at 2:12 PM, Josh Graessley <jgraessley@apple.com> wrote:
On Feb 21, 2013, at 1:05 PM, Philip Prindeville <philipp_subx@redfish-solutions.com> wrote:
I was porting some code (for the Poco toolkit) to examine kernel routing tables in a platform-independent way, and noticed that while OpenBSD, Linux, and even Win32 all expose routing metrics to user-space, this doesn't seem to happen in Darwin.
For instance, in OpenBSD, the rt_msghdr includes the rt_priority field (as uint8_t):
http://fxr.watson.org/fxr/source/net/route.h?v=OPENBSD#L123
But the rt_msghdr2 in XNU 10.8.2 doesn't seem to include any priority (nor does the substructure rt_metrics):
http://fxr.watson.org/fxr/source/bsd/net/route.h?v=xnu-2050.18.24#L264
I've RTFM'd several times but can't figure out how to calculate, from within user-space, how route-selection happens in the kernel.
Is there some out-of-band mechanism for getting this information? I was using sysctl() on CTL_NET.PF_ROUTE.0.0.NET_RT_DUMP2.0 but this seems to be a dead-end.
I have some applications that rely on understanding kernel routing to operate correctly and I'm blocked on porting them to MacOS X until I can figure out, for instance, which interface on a multi homed host will the kernel use on an active (outbound) unbound connection when contacting a remote host (especially important in the case of NATting so I know which gateway's external address to advertise, for instance).
Why do you need a priority? When you perform a route lookup, that route that matches is the one that will be used.
-josh
If it's not an explicit match, and I have multiple default routes, then it might match more than one. This is the case if I'm using Ethernet, Wifi, and VPN tunneling all simultaneously for instance. -Philip _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com