gluon-next-node: make IPv4 next-node address optional

If next_node.ip4 is not set or gluon-next-node is not used, prefix4 will
now be optional as well.
This commit is contained in:
Matthias Schiffer 2016-09-10 17:15:16 +02:00
parent ea95dceb10
commit b902ddd8df
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
3 changed files with 13 additions and 5 deletions

View File

@ -19,7 +19,6 @@ need_string 'timezone'
need_string_array('ntp_servers', false)
need_string_match('prefix4', '^%d+.%d+.%d+.%d+/%d+$')
need_string_match('prefix6', '^[%x:]+/%d+$')

View File

@ -1,4 +1,7 @@
need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$')
if need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$', false) then
need_string_match('prefix4', '^%d+.%d+.%d+.%d+/%d+$')
end
need_string_match('next_node.ip6', '^[%x:]+$')
need_string_match('next_node.mac', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')

View File

@ -17,14 +17,20 @@ c:section('network', 'device', 'local_node_dev',
}
)
local prefix4 = ip.IPv4(site.prefix4)
local ip4, netmask
if site.next_node.ip4 then
ip4 = site.next_node.ip4
netmask = ip.IPv4(site.prefix4):mask():string()
end
c:delete('network', 'local_node')
c:section('network', 'interface', 'local_node',
{
ifname = 'local-node',
proto = 'static',
ipaddr = site.next_node.ip4,
netmask = prefix4:mask():string(),
ipaddr = ip4,
netmask = netmask,
ip6addr = site.next_node.ip6 .. '/128',
}
)