Re: query whether IP address is bound?

Felipe Gasper <felipe-c4PQK5fb7feI/[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <[email protected]>
Hi David,

Yeah I was a bit afraid D-Bus wouldn’t be authoritative enough of a source for the information, but I thought it worth asking anyway.

ioctl has the same problem for me as RtNetlink, where it only knows how to list the IP addresses rather than doing a lookup. But, I suppose that’s it.

Thank you!

-FG

> On Nov 23, 2018, at 10:23 AM, David Sommerseth <[email protected]> wrote:
> 
>> On 23/11/2018 14:59, Felipe Gasper wrote:
>> Hi all,
>> 
>> I’m looking for a way to query whether the (Linux) kernel has a specific
>> IP address bound. Forking is not an option. I’d like to avoid directly
>> enumerating every IP address on the machine, which appears to be the only way
>> that RtNetlink facilitates this. (I’d love to be contradicted on that!)
> 
> I believe this is basically going outside the scope of D-Bus itself, but I've
> played with similar things as I did some contribution to python-ethtool way
> too many years ago.
> 
> Basically, the Linux kernel provides two ways to retrieve IP and network
> configurations. You've found one, using Netlink and the other one is an older
> approach using ioctl calls.  The latter one is not recommended as it does not
> really support IPv6 and also handles multiple IP addresses on a single
> interface in a horrendous way - often you cannot get all the information you
> need.  The Netlink interface (while quite tricky to work with, due to the
> flexibility of the protocol) is by far the best approach.  Also worth
> thinet-tools uses ioctl calls, iirc and iproute2 uses Netlink.
> 
> There are some Netlink libraries which tries to make things easier.  I've
> played with the libnl libraries, and I find them cumbersome and needlessly
> complicated, due to this callback approach.  In the OpenVPN community we have
> some code for review which implements a simpler interface to Netlink (it is
> even called that: SITNL - Simplified Interface To NetLink) [1].  It does not
> implement the code to retrieve IP addresses (only adding and removing them),
> but you might get some inspiration from this code.
> 
> [1] <https://patchwork.openvpn.net/patch/551/>
> 
> 
>> Does the usual suite of D-Bus interfaces on a Linux machine have any
>> function that checks this? I’m looking through NetworkManager but only see
>> logic for listing the addresses. Or do folks here have any other ideas for
>> how I might approach this?
> Querying NetworkManager probably works reasonably well on systems which uses
> NM for managing the various devices.  But if an interface is configured to be
> managed outside if NM, you might not get this information from NM.  In
> addition, there are systems who don't have NM installed as well.
> 
> 
> -- 
> kind regards,
> 
> David Sommerseth
> OpenVPN Inc
> 

_______________________________________________
dbus mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dbus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.