Re: Problem with different TTL

Aurelien Requiem <[email protected]> Sun, 03 Jan 2010 08:09:56 +1100
Newsgroups gmane.network.dns.bind9.dlz
Message-ID <[email protected]>
Hi Tim,

My TTL is read properly from what I've noticed. The problem only occurs 
when both are different otherwise, if they are identical, all is ok.

I have attached the conf and the schema + data in the mail.

Regarding te sources. I did a quick research and maid the following 
modification to fallback in the "text file" mode.
This uses the 1st retrieved TTL from the DB to construct the answer. If 
a second record is found we don't check its TTL value, we don't use it 
and we don't raise the error.
Only the 1st TTL value will be returned for both records as in the text 
file.

--- lib/dns/sdlz.c.orig 2010-01-03 08:02:38.000000000 +1100
+++ lib/dns/sdlz.c      2010-01-03 08:02:52.000000000 +1100
@@ -1516,9 +1516,9 @@
                 ISC_LIST_INIT(rdatalist->rdata);
                 ISC_LINK_INIT(rdatalist, link);
                 ISC_LIST_APPEND(lookup->lists, rdatalist, link);
-       } else
+       } /* else
                 if (rdatalist->ttl != ttl)
-                       return (DNS_R_BADTTL);
+                       return (DNS_R_BADTTL); */

         rdata = isc_mem_get(mctx, sizeof(dns_rdata_t));
         if (rdata == NULL)

I might be wrong, but Tim, if you want to confirm...
I think the TTL values are properly read for the DB. At least the type 
seems to be ok "INT(11)".
I haven't noticed any extra spaces too.

Thanks

Aurelien

On 3/01/2010 6:26 AM, Tim Tessier wrote:
> I actually had a similar problem while I was building a driver for sqlite.
> Please verify that your ttl is actually correct and being read as a ttl
> value.
> I had an issue where the value being read into the ttl value was a fieldname
> instead of an actual ttl. It could be that somehow your values are being
> fudged
> in such a way that the proper values are not coming through to bind. For
> instance,
> if for some reason you have spaces or extra values in places.
>
> If you have the config file and a sample db to try I can attempt to help.
> Also, if you have the
> sources, you can try writing some extra data to the logs for your result
> sets to see if
> something is going wrong there.
>
> Thanks,
> Tim
> --------------------------------------------------
> From: "Aurelien Requiem"<[email protected]>
> Sent: Saturday, January 02, 2010 5:49 AM
> To:<[email protected]>
> Subject: [Bind-dlz-testers] Problem with different TTL
>
>    
>> Hello,
>>
>> I'm having a bit of trouble at the moment with records with different TTL.
>> for www.test.menfin.net, I return 2 records. If both TTL are the same,
>> everything is fine. If they are different, I have 2 behaviors
>> With a regular text file, the 1st record TTL is returned for both
>> records. If the query is answered by dlz, then nothing is returned.
>> In the logs : dns_sdlz_putrr returned error. Error code was: bad ttl
>>
>> I know this question has been discussed in the past, but I still don't
>> understand why such a difference between bind and dlz.
>> http://article.gmane.org/gmane.network.dns.bind9.dlz/439/
>>
>> If such behavior isn't a wanted/good thing, could it be possible to make
>> dlz behave like bind ?
>> Or maybe does anyone know if this has been fixed/changed in more recent
>> versions ?
>>
>> Regards.
>>
>> Environment :
>>      gentoo / bind 9.4.3-p4 (ipv6, dlz, mysql, ssl)
>>
>> Aurelien
>>
>> ------------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Verizon Developer Community
>> Take advantage of Verizon's best-in-class app development support
>> A streamlined, 14 day to market process makes app distribution fast and
>> easy
>> Join now and get one step closer to millions of Verizon customers
>> http://p.sf.net/sfu/verizon-dev2dev
>> _______________________________________________
>> Bind-dlz-testers mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/bind-dlz-test
>>      
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> Bind-dlz-testers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bind-dlz-testers
>

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev

_______________________________________________
Bind-dlz-testers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bind-dlz-testers
named_conf.txt (text/plain, 1.3 KB)
        dlz "dlz-mysql master" {
                database "mysql
                {host=127.0.0.1 dbname=stromboli_dns user=my_user pass=my_pass ssl=false compress=false}
                {SELECT name FROM domains WHERE name = '%zone%'}
                {SELECT ttl, records.type as type, prio, IF(records.type = 'TXT', CONCAT('\"',content,'\"'), content) 
                        FROM domains, records 
                        WHERE records.domain_id=domains.id AND domains.name='%zone%' AND records.name='%record%' AND NOT (records.type = 'SOA' or records.type = 'NS')}
                {SELECT ttl, records.type as type, content, primary_ns, resp_contact, serial, refresh, retry, expire, minimum 
                        FROM domains, records 
                        WHERE records.domain_id=domains.id AND domains.name='%zone%' AND (records.type = 'SOA' OR records.type='NS')}
                {SELECT ttl, records.type as type, name, mx_priority, IF(records.type = 'TXT', CONCAT('\"',content,'\"'), content), resp_contact, serial, refresh, retry, expire, minimum 
                        FROM domains, records
                        WHERE records.domain_id=domains.id AND domains.name='%zone%' AND records.type <> 'SOA' AND records.type <> 'NS'}
                {SELECT zone FROM xfr where zone='%zone%' AND client = '%client%'}
                {}";
        };
db_schema.txt (text/plain, 3.8 KB)
CREATE TABLE `domains` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL,
  `master` varchar(128) default NULL,
  `last_check` int(11) default NULL,
  `type` varchar(6) NOT NULL,
  `notified_serial` int(11) default NULL,
  `account` varchar(40) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name_index` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

INSERT INTO `domains` (`id`, `name`, `master`, `last_check`, `type`, `notified_serial`, `account`) VALUES (1,'test.menfin.net',NULL,NULL,'MASTER',NULL,NULL);

CREATE TABLE `records` (
  `id` int(11) NOT NULL auto_increment,
  `domain_id` int(11) default NULL,
  `name` varchar(255) NOT NULL default '@',
  `type` varchar(6) NOT NULL,
  `content` text,
  `ttl` int(11) NOT NULL default '86400',
  `prio` int(11) default NULL,
  `primary_ns` varchar(255) default NULL,
  `resp_contact` varchar(255) default NULL,
  `serial` bigint(20) default NULL,
  `refresh` int(11) default NULL,
  `retry` int(11) default NULL,
  `expire` int(11) default NULL,
  `minimum` int(11) default NULL,
  `change_date` int(11) default NULL,
  PRIMARY KEY  (`id`),
  KEY `rec_name_index` (`name`),
  KEY `nametype_index` (`name`,`type`),
  KEY `domain_id` (`domain_id`),
  CONSTRAINT `records_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=latin1

INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `prio`, `primary_ns`, `resp_contact`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `change_date`) VALUES (13,1,'@','SOA',NULL,86400,NULL,'ns1.ns.com.','hostmaster.ns.com.',2007080601,10800,7200,604800,86400,NULL);
INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `prio`, `primary_ns`, `resp_contact`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `change_date`) VALUES (14,1,'@','NS','ns1.ns.com.',86400,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `prio`, `primary_ns`, `resp_contact`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `change_date`) VALUES (15,1,'@','NS','ns2.ns.com.',86400,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `prio`, `primary_ns`, `resp_contact`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `change_date`) VALUES (16,1,'@','MX','mail1.mail.com.',45,10,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `prio`, `primary_ns`, `resp_contact`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `change_date`) VALUES (17,1,'@','MX','mail3.mail.com.',45,20,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `prio`, `primary_ns`, `resp_contact`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `change_date`) VALUES (18,1,'@','A','123.45.67.89',42,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `prio`, `primary_ns`, `resp_contact`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `change_date`) VALUES (19,1,'www','A','192.168.1.2',900,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `prio`, `primary_ns`, `resp_contact`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `change_date`) VALUES (20,1,'www','A','192.168.1.3',3600,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `prio`, `primary_ns`, `resp_contact`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `change_date`) VALUES (21,1,'www2','CNAME','www',300,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);