LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Need to know Linux internals on multiple IPv6 addresses on single interface. (https://www.linuxquestions.org/questions/linux-software-2/need-to-know-linux-internals-on-multiple-ipv6-addresses-on-single-interface-899295/)

itismohit 08-24-2011 10:46 PM

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.

Skaperen 08-26-2011 01:48 PM

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.

itismohit 08-29-2011 04:58 AM

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,
Mohit

Skaperen 08-29-2011 10:12 AM

Quote:

Originally Posted by itismohit (Post 4455983)
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]

itismohit 08-30-2011 07:20 AM

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.

Thanks anyways for your help.

Skaperen 08-30-2011 01:11 PM

Quote:

Originally Posted by itismohit (Post 4456981)
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 (Post 4456981)
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:
Code:

lorentz/root /home/root 210# ifconfig eth1:alongalias 10.20.30.40 netmask 255.0.0.0
lorentz/root /home/root 211# ifconfig eth1:alongalias
eth1:alongalias Link encap:Ethernet  HWaddr 00:25:90:14:c4:59 
          inet addr:10.20.30.40  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:17 Memory:fbde0000-fbe00000

lorentz/root /home/root 212#



All times are GMT -5. The time now is 05:30 PM.