Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Net-ISC-DHCPd CPAN distribution.

Report information
The Basics
Id: 80371
Status: open
Priority: 0/
Queue: Net-ISC-DHCPd

People
Owner: RDRAKE [...] cpan.org
Requestors: barzog [...] telecom.by
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: bug in Net::ISC::DHCPd::OMAPI::Actions->read
Date: Wed, 24 Oct 2012 11:26:05 +0300
To: bug-Net-ISC-DHCPd [...] rt.cpan.org
From: Oleg Gawriloff <barzog [...] telecom.by>
According to docs read should return 0 when lease is not found on the server. Instead it returns 1. Sample: #!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Net::ISC::DHCPd; use Data::Dumper; my ($dhcpd,$lease,%lease_attrs,$tmp); $dhcpd=Net::ISC::DHCPd->new(omapi=>{key=>'omapi_key <some Show quoted text
key>',server=>'<some ip>',port=>9991});
$dhcpd->omapi->connect(); $lease_attrs{'ip_address'}='1.1.1.1'; $lease=$dhcpd->omapi->new_object(lease=>%lease_attrs); $tmp=$lease->read; print "R: $tmp D:\n".Dumper(\$lease)."\n"; exit(0); So, 1.1.1.1 is not in leases file: R: 1 D: $VAR1 = \bless( { 'extra_attributes' => {}, 'errstr' => '', 'parent' => bless( { 'errstr' => '', '_pid' => 28345, 'server' => '<some ip>', '_fh' => bless( \*Symbol::GEN0, 'IO::Pty' ), 'port' => 9991, 'key' => 'omapi_key <some key>' }, 'Net::ISC::DHCPd::OMAPI' ), 'ip_address' => '1.1.1.1' }, 'Net::ISC::DHCPd::OMAPI::Lease' ); -- Signed, Oleg Gawriloff.
Subject: bug in Net::ISC::DHCPd::OMAPI::Lease->write
Date: Wed, 24 Oct 2012 11:44:27 +0300
To: bug-Net-ISC-DHCPd [...] rt.cpan.org
From: Oleg Gawriloff <barzog [...] telecom.by>
According to docs it should be possible to read and update lease in one session. But in fact it gives omapi error can\'t open object: key conflict (only shown after adding print "A9: ".Dumper(\@out)."\n"; in /usr/lib/perl5/vendor_perl/5.12.4/Net/ISC/DHCPd/OMAPI/Actions.pm after # set attributes @out = $self->_cmd(@cmd); So the code: #!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Net::ISC::DHCPd; use Data::Dumper; my ($dhcpd,$lease,%lease_attrs,$tmp); $dhcpd=Net::ISC::DHCPd->new(omapi=>{key=>'omapi_key <some Show quoted text
key>',server=>'<some ip>',port=>9991});
$dhcpd->omapi->connect(); $lease_attrs{'ip_address'}='1.1.1.1'; $lease=$dhcpd->omapi->new_object(lease=>%lease_attrs); $tmp=$lease->read; if ($tmp) { $tmp->ends(0); $tmp->write; } exit(0); does not to anything. But if we do following: #!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Net::ISC::DHCPd; use Data::Dumper; my ($dhcpd,$lease,%lease_attrs,$tmp,$dhcpd_new); $dhcpd=Net::ISC::DHCPd->new(omapi=>{key=>'omapi_key <some Show quoted text
key>',server=>'<some ip>',port=>9991}); $dhcpd->omapi->connect();
$lease_attrs{'ip_address'}='1.1.1.1'; $lease=$dhcpd->omapi->new_object(lease=>%lease_attrs); $tmp=$lease->read; if ($tmp) { $dhcpd_new=Net::ISC::DHCPd->new(omapi=>{key=>'omapi_key <some Show quoted text
key>',server=>'<some ip>',port=>9991});
$dhcpd_new->omapi->connect(); $lease_attrs{'ip_address'}='1.1.1.1'; $lease_attrs{'ends'}=0; $lease=$dhcpd_new->omapi->new_object(lease=>%lease_attrs); $tmp->write; } exit(0); all works perfectly. -- Signed, Oleg Gawriloff.
I have no idea if this is a bug in my code or omapi. I'm more than happy to apply a patch if you know what is wrong, but I've stopped using ISC dhcpd so I can't really test/debug this myself. What should we do from here? I really don't think it should be required to create a new omapi object. It doesn't make any sense.
Could you send me the debug output after downloading 0.14 and running the same code with DHCP_OMAPI_DEBUG=1 ?
Subject: Re: [rt.cpan.org #80371] bug in Net::ISC::DHCPd::OMAPI::Actions->read
Date: Fri, 26 Oct 2012 08:52:47 +0300
To: bug-Net-ISC-DHCPd [...] rt.cpan.org
From: Oleg Gawriloff <barzog [...] telecom.by>
25.10.2012 20:51, Jan Henning Thorsen via RT пишет: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=80371 > > > Could you send me the debug output after downloading 0.14 and running the > same code with DHCP_OMAPI_DEBUG=1 ?
Here's output: When searching for unknown ip (A is $lease->read): $ port 9991 $ server <some ip> $ key omapi_key <some key> $ connect obj: <null$ new lease $ set ip-address = 10.3.148.0 obj: lease $ open obj: lease ip-address = 0a:03:94:00 $ close can't open object: not found obj: lease ip-address = 0a:03:94:00 A: 1 Information NOT found. When searching for known ip: $ port 9991 $ server 172.16.2.85 $ key omapi_key 5ZN5WGwkqFBfr8uA44IT8+4WF5EryhYX4XTr1kxx8OqVbhg/pfF4koCDBs0joriRHNHtBl4DSGTS5T1SPTyzag== $ connect obj: <null> $ new lease obj: lease $ set ip-address = 10.3.148.7 obj: lease ip-address = 0a:03:94:07 $ open obj: lease ip-address = 0a:03:94:07 state = 00:00:00:02 dhcp-client-identifier = 01:1c:6f:65:47:ff:83 client-hostname = "by171to01" subnet = 00:00:00:03 pool = 00:00:00:04 hardware-address = 1c:6f:65:47:ff:83 hardware-type = 00:00:00:01 ends = 50:8a:8e:88 starts = 50:89:e5:c8 tstp = 00:00:00:00 tsfp = 00:00:00:00 atsfp = 00:00:00:00 cltt = 50:89:e5:c8 flags = 00 portid = "0.4.6.83.1.3" switchid = "0.6.0.18.207.249.231.192" clientip = "10.3.148.7" clientmac = "1c.6f.65.47.ff.83" $ close obj: <null> A: 19 MAC: 1c:6f:65:47:ff:83 IP: 10.3.148.7 State: active Starts: 04:22:16 26-10-2012 FET Last transaction: 04:22:16 26-10-2012 FET Ends: 16:22:16 26-10-2012 FET Client hostname: by171to01 Client id: 01:1c:6f:65:47:ff:83 I think that problem is in that omshell returns local set attribs and module does not parse error "can't open object: not found". -- Signed, Oleg Gawriloff.
Subject: Re: [rt.cpan.org #80372] bug in Net::ISC::DHCPd::OMAPI::Lease->write
Date: Fri, 26 Oct 2012 09:09:46 +0300
To: bug-Net-ISC-DHCPd [...] rt.cpan.org
From: Oleg Gawriloff <barzog [...] telecom.by>
25.10.2012 20:38, Jan Henning Thorsen via RT пишет: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=80372 > > > I have no idea if this is a bug in my code or omapi. I'm more than happy > to apply a patch if you know what is wrong, but I've stopped using ISC > dhcpd so I can't really test/debug this myself. > > What should we do from here? I really don't think it should be required > to create a new omapi object. It doesn't make any sense.
According to output: 1. There is unneed close. We not finished working with lease. 2. state attribute is read-only (and not accept text state anyway) 3. at the end it can't find object to update (I think because of setting client-hostname which gives key conflict error) $ port 9991 $ server <some ip> $ key omapi_key <some pass> $ connect obj: <null> $ new lease obj: lease $ set ip-address = 10.3.148.7 obj: lease ip-address = 0a:03:94:07 $ open obj: lease ip-address = 0a:03:94:07 state = 00:00:00:02 dhcp-client-identifier = 01:1c:6f:65:47:ff:83 client-hostname = "by171to01" subnet = 00:00:00:03 pool = 00:00:00:04 hardware-address = 1c:6f:65:47:ff:83 hardware-type = 00:00:00:01 ends = 50:8a:8e:88 starts = 50:89:e5:c8 tstp = 00:00:00:00 tsfp = 00:00:00:00 atsfp = 00:00:00:00 cltt = 50:89:e5:c8 flags = 00 portid = "0.4.6.83.1.3" switchid = "0.6.0.18.207.249.231.192" clientip = "10.3.148.7" clientmac = "1c.6f.65.47.ff.83" $ close obj: <null> A: 19 $ new lease obj: lease $ set dhcp-client-identifier = "01:1c:6f:65:47:ff:83" obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" $ set state = active invalid value. usage: set <name> = <value$ set hardware-address = 1c:6f:65:47:ff:83 obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" $ set ip-address = 10.3.148.7 obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" hardware-address = 1c:6f:65:47:ff:83 $ open obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" hardware-address = 1c:6f:65:47:ff:83 ip-address = 0a:03:94:07 $ set client-hostname = "by171to01" can't open object: key conflict obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" hardware-address = 1c:6f:65:47:ff:83 ip-address = 0a:03:94:07 $ set hardware-type = 1 obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" hardware-address = 1c:6f:65:47:ff:83 ip-address = 0a:03:94:07 client-hostname = "by171to01" $ set dhcp-client-identifier = "01:1c:6f:65:47:ff:83" obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" hardware-address = 1c:6f:65:47:ff:83 ip-address = 0a:03:94:07 client-hostname = "by171to01" hardware-type = 1 $ set hardware-address = 1c:6f:65:47:ff:83 obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" hardware-address = 1c:6f:65:47:ff:83 ip-address = 0a:03:94:07 client-hostname = "by171to01" hardware-type = 1 $ set ends = 0 obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" hardware-address = 1c:6f:65:47:ff:83 ip-address = 0a:03:94:07 client-hostname = "by171to01" hardware-type = 1 $ update obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" hardware-address = 1c:6f:65:47:ff:83 ip-address = 0a:03:94:07 client-hostname = "by171to01" hardware-type = 1 ends = 0 $ close can't update object: not found obj: lease dhcp-client-identifier = "01:1c:6f:65:47:ff:83" hardware-address = 1c:6f:65:47:ff:83 ip-address = 0a:03:94:07 client-hostname = "by171to01" hardware-type = 1 ends = 0 -- Signed, Oleg Gawriloff.
Thanks! I will try to look into the issue in the beginning of next week.
Thanks! I will try to look into the issue in the beginning of next week.
On Fri Oct 26 04:06:31 2012, JHTHORSEN wrote: Show quoted text
> Thanks! I will try to look into the issue in the beginning of next week.
I merged the two OMAPI issues, read and write because I'm going to work on them together. I plan to look at this right after working on Failover peers.
Show quoted text
> According to output: > 1. There is unneed close. We not finished working with lease. > 2. state attribute is read-only (and not accept text state anyway) > 3. at the end it can't find object to update (I think because of setting > client-hostname which gives key conflict error) >
Exactly as you said, there is a bad test which made the read of no lease information seem to return zero: $ new lease obj: lease $ set ip-address = 10.19.83.200 obj: lease ip-address = 0a:13:53:c8 $ set state = abandoned invalid value. usage: set <name> = <value> obj: lease ip-address = 0a:13:53:c8 $ set hardware-address = 00:13:02:b8:a9:1b obj: lease ip-address = 0a:13:53:c8 hardware-address = 00:13:02:b8:a9:1b $ open obj: lease ip-address = 0a:13:53:c8 hardware-address = 00:13:02:b8:a9:1b state = 00:00:00:01 subnet = 00:00:00:03 pool = 00:00:00:04 hardware-type = 00:00:00:01 ends = 4a:61:6f:e1 starts = 4a:60:1e:61 tstp = 4a:61:6f:e1 tsfp = 00:00:00:00 atsfp = 00:00:00:00 cltt = 4a:60:1e:61 flags = 00 hw_addr = 00:13:02:b8:a9:1b leasetime = 00:01:51:80 $ close obj: <nullok 14 - lease could not be found The reality is the close shouldn't be needed. The "open" tells you if you found a lease or not. It may be needed by this script because it's unable to determine state (this is just a guess.. it might work perfectly fine with no close) The reason the read is returning 1 is because omapi returns the values you assigned when you set everything, so we're getting the IP address back. The error checking is to see if values don't match. Instead of that we need to watch for object not found and other errors.