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

On Fri, Apr 17, 2009 at 10:38:32PM +0100, Roy Marples wrote:
> David Young wrote:
> > I don't know.  You will have to find out.  IIRC, one of the AF_LINK
> > records produced by getifaddrs(3) has the wrong netmask (should be
> > all-1s), and the other has the struct if_data filled out.  I don't know
> > remember what other differences there are.
> Do you mean the AF_LINK with the netmask is wrong?

The AF_LINK with the right netmask is right.
I think that I mis-spoke when I said that it should be all-1s.

> >> How is userland supposed to pick the right AF_LINK or are they both right?
> > 
> > I guess it depends on your purposes which is right.  There may be more
> > than two AF_LINK ifaddrs on an interface, BTW.
> You mean two different if_data structures?
> In simple terms, >1 hardware address? Interesting. So I need to check
> for dups regardless of this outcome then.

It depends on your particular application what is a duplicate, or
whether there is a duplicate at all.

> >>> Have another look at the doco and source for getifaddrs(3).  I think
> >>> that if there is a bug, you will find it there.
> >> I have checked and the last change of note was over 7 years ago.
> >> So are you suggesting that getifaddrs(3) should ignore the _IFINFO  
> >> message or somehow merge it into the _NEWADDR one - if it's present?
> > 
> > Based on my recollections, above, my guess is that getifaddrs(3) should
> > merge the messages.
> If we can have different AF_LINK addrs on the same interface then I how
> would I know which AF_LINK addr was in _IFINFO so I could merge in the
> correct data?

Compare the address in the _IFINFO message with the _NEWADDR message.

If you tell me what you're trying to do, I may be able to help you
better. :-)


David Young             OJC Technologies      Urbana, IL * (217) 278-3933

Home | Main Index | Thread Index | Old Index