[libvirt] [PATCH] v1:Support for adding a static route to a bridge

Gene Czarcinski gene at czarc.net
Thu Mar 14 17:52:57 UTC 2013


On 03/13/2013 09:30 PM, Gene Czarcinski wrote:
> On 03/13/2013 04:04 PM, Gene Czarcinski wrote:
>> This patch adds support for adding a static route for
>> a network.  The "via" specifies the gateway's IP
>> address.  Both IPv4 and IPv6 static routes are
>> supported although it is expected that this
>> functionality will have more use with IPv6.
>>
>> Extensive tests are done to validate that the input
>> definitions are correct.  For example, for a static
>> route ip definition, the address must be for a network
>> and not a host.
> I have been doing some thinking about the submitted patch and, while 
> it works when everything is as it should be, I believe that there 
> should be some additional checks to ensure that no unexpected code 
> paths are taken (such as if someone would edit a network xml file with 
> vi rather than using virsh net-nedit).
OK, I have been doing more testing (and learning).  If you do everything 
"right", then the static route stuff works as it should and that is good.

However, if you do not do everything "right", then it should not screw 
everything up.

My first "don't do that" test was to specify a gateway address (IPv4 and 
IPv6 work the same) where the network was not defined on that device.  
When you do the virsh net-start, an error message appears in syslog and 
on the terminal which gives the entire command and says the network is 
(surprise) unreachable.  Ok, that is fine.  BUT, the bridge interface is 
left in a bad state ... it is still there but virsh net-destroy does not 
work but after correcting the definition, virsh net-start does not work 
either because the device is still in use.  A reboot was necessary to 
clear the condition.

My solution: when the network static route is added, ignore any errors.  
virsh & libvirt can now destroy the network and, after correcting the 
gateway address, virsh net-start works.

While the error message is still sent to syslog, it no longer appears on 
the terminal window.  Can someone point to me how I can get the error 
message displayed but without having any other effect.

This also brings up the question as to whether the error handling (err3) 
in NetworkStartNetworkVirtual() is correct.

I will also be adding a bunch of code to network_conf.c to attempt 
verifying that, if a static route is specified, an address has also been 
specified for the bridge and that the gateway address is on the network 
specified.  Lots of code but also meaningful error messages can then be 
generated.

Gene




More information about the libvir-list mailing list