tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: getifaddrs(3) returns 2 AF_LINK instances for the same interface



David Young wrote:
I think that the kernel is doing the right thing.

In your patch, maybe you have equated IFADDR_FIRST(ifp) with ifp->if_dl?
That hasn't been true for a long time.

So something like this?

Index: sys/net/rtsock.c
===================================================================
RCS file: /cvsroot/src/sys/net/rtsock.c,v
retrieving revision 1.125
diff -u -p -r1.125 rtsock.c
--- sys/net/rtsock.c    2 Apr 2009 21:02:06 -0000       1.125
+++ sys/net/rtsock.c    17 Apr 2009 19:51:33 -0000
@@ -1061,7 +1061,8 @@ sysctl_iflist(int af, struct rt_walkarg
                        }
                }
                IFADDR_FOREACH(ifa, ifp) {
-                       if (af && af != ifa->ifa_addr->sa_family)
+                       if (ifa == ifp->if_dl ||
+                           (af && af != ifa->ifa_addr->sa_family))
                                continue;
                        info.rti_info[RTAX_IFA] = ifa->ifa_addr;
                        info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;

Thanks

Roy


Home | Main Index | Thread Index | Old Index