Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set correct netmask for IPv6 #267

Closed
mkoe opened this issue Feb 4, 2020 · 1 comment · Fixed by #290
Closed

Unable to set correct netmask for IPv6 #267

mkoe opened this issue Feb 4, 2020 · 1 comment · Fixed by #290

Comments

@mkoe
Copy link

mkoe commented Feb 4, 2020

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.12
  • Ruby: ruby2.1 ( 2.1.5-2+deb8u8 )
  • Distribution: Debian (Jessie)
  • Module version: tag: v0.9.0 + branch: master

Tested with both moduleversions

How to reproduce (e.g Puppet code you use)

issues:

  1. cannot set a netmask like 64 128 or any other value for ipv6 addresses
  2. you can set a ipv4 netmask for a ipv6 addresse

how to reproduce
issues:

  1. set as ipaddress parameter a ipv6 ip and as a netmask parameter 64
  2. set a ipv6 ip and as a netmask parameter a valid ipv4 netmask eg. 255.255.255.0

What are you seeing

issue 1:
Config:

eth0:0:
    ensure: present
    ipaddress: XXXX:XXXX:XXXX:114::6
    netmask: 64
    family: 'inet6'
    method: 'static'
    onboot: true
    hotplug: true

Result error:

Error: Failed to apply catalog: Parameter netmask failed on Network_config[eth0:0]: Puppet::Type::Network_config::Netmask requires a valid netmask for the netmask property at

issue 2:
Config:

eth0:0:
    ensure: present
    ipaddress: XXXX:XXXX:XXXX:114::6
    netmask: 255.255.255.0
    family: 'inet6'
    method: 'static'
    onboot: true
    hotplug: true

Result /etc/network/interfaces:

iface eth2:0 inet6 static
address XXXX:XXXX:XXXX:114::6
netmask 255.0.0.0

What behaviour did you expect instead

Setting a correct IPv6 netmask like netmask 64
Not able to apply a IPv4 netmask to a IPv6 ip

Output log

Any additional information you'd like to impart

As a quick, dirty and incorrect fix:

--- a/lib/puppet/type/network_config.rb
+++ b/lib/puppet/type/network_config.rb
@@ -43,7 +43,7 @@ Puppet::Type.newtype(:network_config) do
     desc 'The subnet mask to apply to the interface'
     if defined? IPAddress
       validate do |value|
-        raise ArgumentError, "#{self.class} requires a valid netmask for the netmask property" unless IPAddress.valid_ipv4_netmask? value
+        raise ArgumentError, "#{self.class} requires a valid netmask ( #{value} ) for the netmask property" unless ( IPAddress.valid_ipv4_netmask? value or ( value >= 0 && value.to_i <= 128 ) )
         # provider.validate
       end
     end

This quickfix, dirtyfix and incorrectfix, would allow now to set a invalid ipv4 netmask too, but would also allow to set a correct ipv6 netmask.
It would:

  1. still allow to set a ipv4 netmask for ipv6 adresses
  2. allow to set a ipv6 netmask for ipv4 adresses

For clean fix for this, would result in a rewrite of the type, to check:

  1. which iptype
  2. check if netmask fits for that iptype
@ajurjevi
Copy link

Can someone address this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants