A patch to work ndp -p or ndp -r command

$Id: ndp_pr.html,v 1.2 2008/01/08 04:08:13 t-momose Exp $

Notice

The problem described in this page is already solved in Leopard(10.5). You don't need to worry about the problem if you are Leopard user. The problem is applicable for prior Lepard, and the patch put here is applicable only for Tiger.

Problem Description

From begining IPv6 support to Tiger(10.4) in MacOS X, 'ndp -p' and 'ndp -r' doesn't work. These command are useful to see the current prefix list and the curret default routel list. Especially, it would be helpful for trouble shooting when some bad nodes advertise bad router advertisement messages.
But, on MacOS X, when invoking this command, you will get the following messages:
	% ndp -p
	sysctl(ICMPV6CTL_ND6_PRLIST): No such file or directory.
	% ndp -r
	sysctl(ICMPV6CTL_ND6_DRLIST): No such file or directory.

Reasons of this Problem

Ndp(8) command just issues sysctl(3) function with net.inet6.icmp6.{drlist, prlist} mib. This should be processed in the kernel, but the kernel cannot handle it because, strangely, the correspondent part to process them are commented out.
At ${darwin}/bsd/netinet6/nd6.c:
#ifndef __APPLE__
static int nd6_sysctl_drlist SYSCTL_HANDLER_ARGS;
static int nd6_sysctl_prlist SYSCTL_HANDLER_ARGS;
SYSCTL_DECL(_net_inet6_icmp6);
SYSCTL_NODE(_net_inet6_icmp6, ICMPV6CTL_ND6_DRLIST, nd6_drlist,
        CTLFLAG_RD, nd6_sysctl_drlist, "");
SYSCTL_NODE(_net_inet6_icmp6, ICMPV6CTL_ND6_PRLIST, nd6_prlist,
        CTLFLAG_RD, nd6_sysctl_prlist, "");
I don't know why this part is commented out.

How to solve

The only way to solve the problem is to replace the kernel which is enabled above part. In darwin, you should modify $(darwin)/bsd/kern/sysctl_init.c as well to add new sysctl.
Or apply this patch.
And build the kernel.
I confirm it works on darwin 8.1(xnu-792.1.5) and 8.2(xnu-792.2.4).
MOMOSE Tsuyoshi