Re: Adding and Clearing bridge addresses

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

 



On 03/12/2013 03:23 PM, Daniel P. Berrange wrote:
On Tue, Mar 12, 2013 at 03:11:56PM -0400, Laine Stump wrote:
On 03/12/2013 01:45 PM, Gene Czarcinski wrote:
I have been working on this patch to have libvirt optionally set
static routes.

So I found the function that adds both IPv4 and IPv6 addresses to the
bridge in virnetdev.c. I found that besides the
virNetDevAddIPv4Address() there is also virNetDevCleanIPv4Address().
I patterned my virNetDevAddGateway() after the
virNetDevAddIPv4Address() function.

What I am puzzled about is that it appears that nobody calls the Clear
function.  What don't I understand?
Probably it's there just for completeness of API.

The thing that I find strange is that these functions include "IPv4" in
their names, in spite of working just as well for IPv6. It's very likely
that if I dig back through the blame history (which won't be simple
since the code has been moved into different files), I'll find that I
originally wrote it (I have a vague memory of it), but don't think I
would purposefully add IPv4 to the names... :-/
The virNetDevGetIPv4Address method uses an ioctl to get the address
and this only works on IPv4 addrs. The intent was to turn the other
two calls into ioctl() calls too, to kill off shell commands.

Setting IPv6 addresses would require netlink usage instead IIRC

I seem to recall some comments in some source code I have browsed in the last couple days which stated that ioctl was NOT to be used because it could not be guaranteed long term ... I think it was in libvert code but it may have been in NetworkManager code. When you jump around to different projects, the details get confusing.

Anyway, I like the way /usr/sbin/ip works because things just seem to work. A couple of things I have learned:

1. For IPv6 addr and route, the order does not seem to matter and the bridge can be offline.

2.  Both IPv4 and IPv6 addr can be done on the offline bridge.

3. To set an IPv4 static route, the addresses need to be defined and the bridge online (IPv6 is not so picky).

4. You better have the unmasked portion of the address specified zero for the route ... that is, it better be a network address rather than a host address [I need to add some checks for this rather than letter the system issue a cryptic error message]

5. I have yet to figure out how to test for dhcp, etc. when via is defined so that I can issue an error message when it is created/defined [the xml is being parsed and read in].

6. When the xml is being written for an IP definition, I currently error out. A better approach might be to issue an error message and suppress writing the xml. This needs further thought.

7. I have not come up with any tests. The only thing that might be meaningful is if a bad network definition was created so that it would get errors. I am not sure how to do this with the tests. There might be something in the networkxml2xmltest.

I should have something with works real soon and will send the patch up for review.

Gene


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]