Need to know Linux internals on multiple IPv6 addresses on single interface.
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Need to know Linux internals on multiple IPv6 addresses on single interface.
Hi,
Thanks for the time in advance...
What I Need...
I need to understand how linux manages multiple IPv6 addresses on a single interface without using aliases unlike IPv4 where aliases are used. Is there an internal indexing on multiple IP's on same interface?
Why I Need this...
I am trying to write a piece of code for assigning multiple global virtual IPv6 address to an interface in a cluster environment. I need to return an integral handle to the calling app. This handle will then be used to find out which ip address was assigned and be deleted if required.
Prototype for the function is as follows :
int32 addVirtualIp(char *interface, char *ipaddress);
Returns handle, to be used to delete the assignment later.
-1 on failure.
The method used in IPv4 using alias interface names was a bad hack. With IPv6 you simply add and delete IPv6 addresses. I'm hoping they will make this work with IPv4, too, soon. It sort of works now (you can actually add them) but not really (they don't do what is expected).
With IPv6 this is very simple. You add or delete what you want to be there or not be there.
In your code, if a calling app is asking for an IPv6 address to be dynamically assigned, and needs a handle to find out which address ... just give it the IPv6 address itself. If you have a size limit on handles that prevents this, then store the IPv6 addresses in a file in some directory designated for this purpose, and pass it the name of the file, letting it read the IPv6 address from there and remove the file.
Thanks for your inputs.
You are right, I can write the IP to a file, or as I need to return an integer I can write the map (key{unique handle}, value{ipv6 address}) to the file.
But I don't want to do that. That's the whole point. I don't want any I/O operations.
The kernel must be maintaining this information, and there has to be some unique identifier, which the kernel must be using to maintain the information. That's exactly what I am looking for.
Thanks for your inputs.
You are right, I can write the IP to a file, or as I need to return an integer I can write the map (key{unique handle}, value{ipv6 address}) to the file.
But I don't want to do that. That's the whole point. I don't want any I/O operations.
The kernel must be maintaining this information, and there has to be some unique identifier, which the kernel must be using to maintain the information. That's exactly what I am looking for.
The IP addresses are most likely a linked list. The kernel doesn't need any "handle" or "tag" or "identifier". If it needs to see if any interface has [fc00::1234] it can just scan all of them sequentially and that's not a performance hit in most cases (it doesn't need to do this with traffic, but might with neighbor discovery, or ARP for v4).
So, basically, there won't be any such identifier, anymore. These I/O operations you are trying to avoid ... isn't that also involved in passing the interface alias name? Or is the interface alias name short enough to allow avoiding I/O where the full IPv6 address is too long?[/QUOTE]
Actually, I am working on a middleware and the API, I am exposing to the applications requires an integral handle.
Now, for IPv4 the address is assigned to an alias say, eth1:2, Now 1 & 2 can be used to uniquely identify the logical interface and the associated address. So I am keeping 0x00000102 in my integer and using this to later fetch the information. And I am looking for a similar solution for IPv6.
Now, as you said, if there is nothing that can work like this, then I probably would have to devise some compression/decompression algorithm b/w
128 bit ipv6 address and 32 bit handle.
Actually, I am working on a middleware and the API, I am exposing to the applications requires an integral handle.
Now, for IPv4 the address is assigned to an alias say, eth1:2, Now 1 & 2 can be used to uniquely identify the logical interface and the associated address. So I am keeping 0x00000102 in my integer and using this to later fetch the information. And I am looking for a similar solution for IPv6.
If it requires the handle be an interface name, then it is a bad API design that assumed things that not only were not guaranteed, but did not exist in other Unix systems, and have come to pass that they are not so in Linux, either.
Quote:
Originally Posted by itismohit
Now, as you said, if there is nothing that can work like this, then I probably would have to devise some compression/decompression algorithm b/w
128 bit ipv6 address and 32 bit handle.
So the API is just passing data between two components you are coding, and is limited to 32 bits? Interface names can be longer. The alias hack is NOT limited to 32 bits or to numbers. Characters can be used, and it appears the entire interface name limit is 15 characters:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.