Merge pull request #132 from ifupdown-ng/bugfix/ipv6-default-netmask
fix ipv6 default netmask
This commit is contained in:
commit
43159fec82
3 changed files with 21 additions and 2 deletions
|
@ -93,7 +93,7 @@ lif_address_format_cidr(const struct lif_interface *iface, struct lif_dict_entry
|
|||
if (!addr->netmask)
|
||||
{
|
||||
/* if netmask is not set, default to 255.255.255.0, ifupdown does so too */
|
||||
addr->netmask = 24;
|
||||
addr->netmask = addr->domain == AF_INET6 ? 64 : 24;
|
||||
|
||||
struct lif_dict_entry *entry = lif_dict_find(&iface->vars, "netmask");
|
||||
if (entry != NULL)
|
||||
|
|
5
tests/fixtures/without-netmask.interfaces
vendored
Normal file
5
tests/fixtures/without-netmask.interfaces
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
iface v6
|
||||
address 2001:470:1f10::1
|
||||
|
||||
iface v4
|
||||
address 203.0.113.2
|
|
@ -36,7 +36,9 @@ tests_init \
|
|||
vlan_complex_learned_dependency \
|
||||
wireguard \
|
||||
allow_undefined_positive \
|
||||
allow_undefined_negative
|
||||
allow_undefined_negative \
|
||||
default_netmask_v4 \
|
||||
default_netmask_v6
|
||||
|
||||
noargs_body() {
|
||||
atf_check -s exit:1 -e ignore ifquery -S/dev/null
|
||||
|
@ -242,3 +244,15 @@ allow_undefined_negative_body() {
|
|||
-e ignore \
|
||||
ifquery -i /dev/null -p address foo
|
||||
}
|
||||
|
||||
default_netmask_v4_body() {
|
||||
atf_check -s exit:0 \
|
||||
-o match:"203.0.113.2/24" \
|
||||
ifquery -i $FIXTURES/without-netmask.interfaces -p address v4
|
||||
}
|
||||
|
||||
default_netmask_v6_body() {
|
||||
atf_check -s exit:0 \
|
||||
-o match:"2001:470:1f10::1/64" \
|
||||
ifquery -i $FIXTURES/without-netmask.interfaces -p address v6
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue