diff options
Diffstat (limited to 'scripts/vyatta-interfaces.pl')
-rw-r--r-- | scripts/vyatta-interfaces.pl | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 3794769..0c219c1 100644 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -184,6 +184,14 @@ sub is_domain_name_set { return $domainname; } +sub is_ethernet_mtu_set { + my $intf = shift; + my $config = new VyattaConfig; + $config->setLevel("interfaces ethernet $intf"); + my $interface_mtu = undef; + $interface_mtu = $config->returnValue("mtu"); + return $interface_mtu; +} sub dhcp_update_config { my ($conf_file, $intf) = @_; @@ -198,39 +206,20 @@ sub dhcp_update_config { $output .= "\trequest subnet-mask, broadcast-address, routers, domain-name-servers"; my $domainname = is_domain_name_set(); if (!defined($domainname)) { - $output .= ", domain-name;\n"; - } else { - $output .= ";\n"; + $output .= ", domain-name"; + } + if ($intf =~ m/^eth[0-9]+$/) { + my $interface_mtu = is_ethernet_mtu_set($intf); + if (!defined($interface_mtu)) { + $output .= ", interface-mtu"; + } } - + $output .= ";\n"; $output .= "}\n\n"; dhcp_write_file($conf_file, $output); } -sub is_ip_v4_or_v6 { - my $addr = shift; - - my $ip = NetAddr::IP->new($addr); - if (defined $ip && $ip->version() == 4) { - # - # the call to IP->new() will accept 1.1 and consider - # it to be 1.1.0.0, so add a check to force all - # 4 octets to be defined - # - if ($addr !~ /\d+\.\d+\.\d+\.\d+/) { - return undef; - } - return 4; - } - $ip = NetAddr::IP->new6($addr); - if (defined $ip && $ip->version() == 6) { - return 6; - } - - return undef; -} - sub generate_dhclient_intf_files { my $intf = shift; @@ -456,7 +445,7 @@ sub op_dhcp_command { print "$intf is not using DHCP to get an IP address\n"; exit 1; } - + my $tmp_dhclient_dir = '/var/run/vyatta/dhclient/'; my $release_file = $tmp_dhclient_dir . 'dhclient_release_' . $intf; if ($op_command eq "dhcp-release") { @@ -473,13 +462,13 @@ sub op_dhcp_command { exit 0; } } elsif ($op_command eq "dhcp-renew") { - print "Renewing DHCP lease on $intf ...\n"; + print "Renewing DHCP lease on $intf ...\n"; run_dhclient($intf); system ("rm -f $release_file\;"); exit 0; } - - exit 0; + + exit 0; } |