libvirt/docs/schemas/network.rng
Gene Czarcinski ccff335f83 Support for static routes on a virtual bridge
network: static route support for <network>

This patch adds the <route> subelement of <network> to define a static
route.  the address and prefix (or netmask) attribute identify the
destination network, and the gateway attribute specifies the next hop
address (which must be directly reachable from the containing
<network>) which is to receive the packets destined for
"address/(prefix|netmask)".

These attributes are translated into an "ip route add" command that is
executed when the network is started. The command used is of the
following form:

  ip route add <address>/<prefix> via <gateway> \
               dev <virbr-bridge> proto static metric <metric>

Tests are done to validate that the input data are correct.  For
example, for a static route ip definition, the address must be a
network address and not a host address.  Additional checks are added
to ensure that the specified gateway is directly reachable via this
network (i.e. that the gateway IP address is in the same subnet as one
of the IP's defined for the network).

prefix='0' is supported for both family='ipv4' address='0.0.0.0'
netmask='0.0.0.0' or prefix='0', and for family='ipv6' address='::',
prefix=0', although care should be taken to not override a desired
system default route.

Anytime an attempt is made to define a static route which *exactly*
duplicates an existing static route (for example, address=::,
prefix=0, metric=1), the following error message will be sent to
syslog:

    RTNETLINK answers: File exists

This can be overridden by decreasing the metric value for the route
that should be preferred, or increasing the metric for the route that
shouldn't be preferred (and is thus in place only in anticipation that
the preferred route may be removed in the future).  Caution should be
used when manipulating route metrics, especially for a default route.

Note: The use of the command-line interface should be replaced by
direct use of libnl so that error conditions can be handled better.  But,
that is being left as an exercise for another day.

Signed-off-by: Gene Czarcinski <gene@czarc.net>
Signed-off-by: Laine Stump <laine@laine.org>
2013-05-13 16:14:40 -04:00

345 lines
11 KiB
XML

<?xml version="1.0"?>
<!-- A Relax NG schema for the libvirt network XML format -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<ref name="network"/>
</start>
<include href='basictypes.rng'/>
<include href='networkcommon.rng'/>
<define name="network">
<element name="network">
<optional>
<attribute name="connections">
<data type="unsignedInt"/>
</attribute>
</optional>
<!-- Enables IPv6 guest-to-guest communications on a network
with no gateways addresses specified -->
<optional>
<attribute name="ipv6">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</attribute>
</optional>
<interleave>
<!-- The name of the network, used to refer to it through the API
and in virsh -->
<element name="name">
<text/>
</element>
<!-- <uuid> element -->
<optional>
<element name="uuid"><ref name="UUID"/></element>
</optional>
<!-- <bridge> element -->
<optional>
<!-- The name of the network to be set up; this will back
the network on the host -->
<element name="bridge">
<optional>
<attribute name="name">
<ref name="deviceName"/>
</attribute>
</optional>
<optional>
<attribute name="stp">
<choice>
<value>on</value>
<value>off</value>
</choice>
</attribute>
</optional>
<optional>
<attribute name="delay">
<data type="integer"/>
</attribute>
</optional>
</element>
</optional>
<!-- <mac> element -->
<optional>
<element name="mac">
<attribute name="address"><ref name="uniMacAddr"/></attribute>
<empty/>
</element>
</optional>
<!-- <forward> element -->
<optional>
<!-- The device through which the bridge is connected to the
rest of the network -->
<element name="forward">
<optional>
<attribute name="dev">
<ref name="deviceName"/>
</attribute>
</optional>
<optional>
<attribute name="mode">
<choice>
<value>nat</value>
<value>route</value>
<value>bridge</value>
<value>passthrough</value>
<value>private</value>
<value>vepa</value>
<value>hostdev</value>
</choice>
</attribute>
</optional>
<optional>
<attribute name="managed">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</attribute>
</optional>
<interleave>
<choice>
<group>
<zeroOrMore>
<element name='interface'>
<attribute name='dev'>
<ref name='deviceName'/>
</attribute>
<optional>
<attribute name="connections">
<data type="unsignedInt"/>
</attribute>
</optional>
</element>
</zeroOrMore>
</group>
<group>
<zeroOrMore>
<element name='address'>
<attribute name='type'>
<value>pci</value>
</attribute>
<ref name="pciaddress"/>
<optional>
<attribute name="connections">
<data type="unsignedInt"/>
</attribute>
</optional>
</element>
</zeroOrMore>
</group>
</choice>
<optional>
<element name='pf'>
<attribute name='dev'>
<ref name='deviceName'/>
</attribute>
</element>
</optional>
<optional>
<element name="driver">
<attribute name="name">
<choice>
<value>kvm</value>
<value>vfio</value>
</choice>
</attribute>
<empty/>
</element>
</optional>
</interleave>
</element>
</optional>
<!-- <virtualport> element -->
<optional>
<ref name="virtualPortProfile"/>
</optional>
<!-- <portgroup> elements -->
<zeroOrMore>
<element name="portgroup">
<attribute name="name">
<ref name="deviceName"/>
</attribute>
<optional>
<attribute name="default">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</attribute>
</optional>
<interleave>
<optional>
<ref name="virtualPortProfile"/>
</optional>
<optional>
<ref name="bandwidth"/>
</optional>
<optional>
<ref name="vlan"/>
</optional>
</interleave>
</element>
</zeroOrMore>
<!-- <domain> element -->
<optional>
<element name="domain">
<attribute name="name"><ref name="dnsName"/></attribute>
</element>
</optional>
<!-- Define the DNS related elements like TXT records
and other features in the <dns> element -->
<optional>
<element name="dns">
<zeroOrMore>
<element name="txt">
<attribute name="name"><ref name="dnsName"/></attribute>
<attribute name="value"><text/></attribute>
</element>
</zeroOrMore>
<zeroOrMore>
<element name="srv">
<attribute name="service"><text/></attribute>
<attribute name="protocol"><ref name="protocol"/></attribute>
<optional>
<attribute name="domain"><ref name="dnsName"/></attribute>
<attribute name="target"><text/></attribute>
<attribute name="port"><ref name="unsignedShort"/></attribute>
<attribute name="priority"><ref name="unsignedShort"/></attribute>
<attribute name="weight"><ref name="unsignedShort"/></attribute>
</optional>
</element>
</zeroOrMore>
<zeroOrMore>
<element name="host">
<attribute name="ip"><ref name="ipAddr"/></attribute>
<oneOrMore>
<element name="hostname"><ref name="dnsName"/></element>
</oneOrMore>
</element>
</zeroOrMore>
</element>
</optional>
<optional>
<ref name="bandwidth"/>
</optional>
<optional>
<ref name="vlan"/>
</optional>
<optional>
<element name="link">
<attribute name="state">
<choice>
<value>up</value>
<value>down</value>
</choice>
</attribute>
<empty/>
</element>
</optional>
<!-- <ip> element -->
<zeroOrMore>
<!-- The IP element sets up NAT'ing and an optional DHCP server
local to the host. -->
<element name="ip">
<optional>
<attribute name="address"><ref name="ipAddr"/></attribute>
</optional>
<optional>
<choice>
<attribute name="netmask"><ref name="ipv4Addr"/></attribute>
<attribute name="prefix"><ref name="ipPrefix"/></attribute>
</choice>
</optional>
<optional>
<attribute name="family"><ref name="addr-family"/></attribute>
</optional>
<optional>
<element name="tftp">
<attribute name="root"><text/></attribute>
</element>
</optional>
<optional>
<!-- Define the range(s) of IP addresses that the DHCP
server should hand out -->
<element name="dhcp">
<zeroOrMore>
<element name="range">
<attribute name="start"><ref name="ipAddr"/></attribute>
<attribute name="end"><ref name="ipAddr"/></attribute>
</element>
</zeroOrMore>
<zeroOrMore>
<element name="host">
<choice>
<group>
<choice>
<attribute name="mac"><ref name="uniMacAddr"/></attribute>
<attribute name="id"><ref name="DUID"/></attribute>
</choice>
<optional>
<attribute name="name"><text/></attribute>
</optional>
</group>
<attribute name="name"><text/></attribute>
</choice>
<attribute name="ip"><ref name="ipAddr"/></attribute>
</element>
</zeroOrMore>
<optional>
<element name="bootp">
<attribute name="file"><ref name="filePath"/></attribute>
<optional>
<attribute name="server"><ref name="dnsName"/></attribute>
</optional>
</element>
</optional>
</element>
</optional>
</element>
</zeroOrMore>
<!-- <route> element -->
<zeroOrMore>
<!-- The (static) route element specifies a network address and gateway
address to access that network. Both the network address and
the gateway address must be specified. -->
<element name="route">
<optional>
<attribute name="family"><ref name="addr-family"/></attribute>
</optional>
<attribute name="address"><ref name="ipAddr"/></attribute>
<optional>
<choice>
<attribute name="netmask"><ref name="ipv4Addr"/></attribute>
<attribute name="prefix"><ref name="ipPrefix"/></attribute>
</choice>
</optional>
<attribute name="gateway"><ref name="ipAddr"/></attribute>
<optional>
<attribute name="metric"><ref name="unsignedInt"/></attribute>
</optional>
</element>
</zeroOrMore>
</interleave>
</element>
</define>
</grammar>