summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bigonville <bigon@bigon.be>2013-12-26 18:10:42 +0100
committerLaurent Bigonville <bigon@bigon.be>2013-12-26 18:10:42 +0100
commit9b4301465a3217edf3cba6a9472095a424ab64b8 (patch)
tree15c52c043e33dced3df0ce292f96519d9ec7f321
parent6cd6720c55d1adfc3ed863e7bc21a2f1311ecf5b (diff)
downloadavahi-9b4301465a3217edf3cba6a9472095a424ab64b8.tar.gz
debian/patches/avahi-core-reserve-space-for-record-data-when-size-estimate.patch: avahi-core: reserve space for record data when size estimate. This prevents avahi-daemon from falling into an invalid loop when many CUPS/IPP printer shares get registered (Closes: #693604)
-rw-r--r--debian/changelog6
-rw-r--r--debian/patches/avahi-core-reserve-space-for-record-data-when-size-estimate.patch124
-rw-r--r--debian/patches/series1
3 files changed, 130 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index 337fdff..068abc2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,8 +3,12 @@ avahi (0.6.31-4) UNRELEASED; urgency=medium
* d/p/so_reuseport-may-not-exist-in-running-kernel.patch: Do not exit
avahi-daemon if we cannot set SO_REUSEPORT on the socket. This patch has
be taken from Ubuntu, thanks to them (Closes: #732009)
+ * debian/patches/avahi-core-reserve-space-for-record-data-when-size-estimate.patch:
+ avahi-core: reserve space for record data when size estimate. This
+ prevents avahi-daemon from falling into an invalid loop when many CUPS/IPP
+ printer shares get registered (Closes: #693604)
- -- Laurent Bigonville <bigon@debian.org> Thu, 19 Dec 2013 19:18:20 +0100
+ -- Laurent Bigonville <bigon@debian.org> Thu, 26 Dec 2013 18:09:19 +0100
avahi (0.6.31-3) unstable; urgency=low
diff --git a/debian/patches/avahi-core-reserve-space-for-record-data-when-size-estimate.patch b/debian/patches/avahi-core-reserve-space-for-record-data-when-size-estimate.patch
new file mode 100644
index 0000000..c10d891
--- /dev/null
+++ b/debian/patches/avahi-core-reserve-space-for-record-data-when-size-estimate.patch
@@ -0,0 +1,124 @@
+From joeyli.kernel@gmail.com Sun Sep 9 19:27:56 2012
+From: joeyli.kernel@gmail.com (Lee, Chun-Yi)
+Date: Mon, 10 Sep 2012 10:27:56 +0800
+Subject: [avahi] [PATCH] avahi-core: reserve space for record data when size
+ estimate
+Message-ID: <1347244076-1332-1-git-send-email-jlee@suse.com>
+
+From: "Lee, Chun-Yi" <jlee@suse.com>
+
+When we tested put a lot of airprint service files(have 45 to 60 flies), found there have cpu loadinghigh problem when start avahi-daemon with those service files.
+
+After traced source code, there have problem in probe-sched.c::elapse_callback causes doesn't have any probe job set to DONE so the daemon unlimited send out DNS package.
+The root cause is when compare with the free package space in packet_add_probe_query before attach job key, the free package space doesn't include any record data that will attached after all keys attached. This defect causes whole DNS package is filled by job key, but doesn't remain enough space for any rdata. Then, that means have no job set to DONE.
+
+This patch add a new res_size member to AvahiDnsPacket, it used to sum the reserve size for record data the will attached after all keys attached. It can avoid keys consume whole size until p->size larger then p->max_size.
+
+Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
+---
+ avahi-core/dns.c | 20 ++++++++++++++++++++
+ avahi-core/dns.h | 4 +++-
+ avahi-core/probe-sched.c | 10 ++++++++--
+ 3 files changed, 31 insertions(+), 3 deletions(-)
+
+diff --git a/avahi-core/dns.c b/avahi-core/dns.c
+index 2fcd91f..523afdc 100644
+--- a/avahi-core/dns.c
++++ b/avahi-core/dns.c
+@@ -55,6 +55,7 @@ AvahiDnsPacket* avahi_dns_packet_new(unsigned mtu) {
+
+ p->size = p->rindex = AVAHI_DNS_PACKET_HEADER_SIZE;
+ p->max_size = max_size;
++ p->res_size = 0;
+ p->name_table = NULL;
+ p->data = NULL;
+
+@@ -833,6 +834,25 @@ size_t avahi_dns_packet_space(AvahiDnsPacket *p) {
+ return p->max_size - p->size;
+ }
+
++size_t avahi_dns_packet_reserve_size(AvahiDnsPacket *p, size_t res_size) {
++ assert(p);
++
++ assert(p->size + p->res_size <= p->max_size);
++
++ if ((p->size + p->res_size + res_size) <= p->max_size)
++ p->res_size += res_size;
++
++ return p->res_size;
++}
++
++size_t avahi_dns_packet_reserved_space(AvahiDnsPacket *p) {
++ assert(p);
++
++ assert(p->size + p->res_size <= p->max_size);
++
++ return p->max_size - p->size - p->res_size;
++}
++
+ int avahi_rdata_parse(AvahiRecord *record, const void* rdata, size_t size) {
+ int ret;
+ AvahiDnsPacket p;
+diff --git a/avahi-core/dns.h b/avahi-core/dns.h
+index 52e8d88..13b1ac2 100644
+--- a/avahi-core/dns.h
++++ b/avahi-core/dns.h
+@@ -30,7 +30,7 @@
+ #define AVAHI_DNS_PACKET_SIZE_MAX (AVAHI_DNS_PACKET_HEADER_SIZE + 256 + 2 + 2 + 4 + 2 + AVAHI_DNS_RDATA_MAX)
+
+ typedef struct AvahiDnsPacket {
+- size_t size, rindex, max_size;
++ size_t size, rindex, max_size, res_size;
+ AvahiHashmap *name_table; /* for name compression */
+ uint8_t *data;
+ } AvahiDnsPacket;
+@@ -78,6 +78,8 @@ int avahi_dns_packet_skip(AvahiDnsPacket *p, size_t length);
+
+ int avahi_dns_packet_is_empty(AvahiDnsPacket *p);
+ size_t avahi_dns_packet_space(AvahiDnsPacket *p);
++size_t avahi_dns_packet_reserve_size(AvahiDnsPacket *p, size_t res_size);
++size_t avahi_dns_packet_reserved_space(AvahiDnsPacket *p);
+
+ #define AVAHI_DNS_FIELD_ID 0
+ #define AVAHI_DNS_FIELD_FLAGS 1
+diff --git a/avahi-core/probe-sched.c b/avahi-core/probe-sched.c
+index 1e63411..63cb817 100644
+--- a/avahi-core/probe-sched.c
++++ b/avahi-core/probe-sched.c
+@@ -179,7 +179,7 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava
+ avahi_record_get_estimate_size(pj->record);
+
+ /* Too large */
+- if (size > avahi_dns_packet_space(p))
++ if (size > avahi_dns_packet_reserved_space(p))
+ return 0;
+
+ /* Create the probe query */
+@@ -189,6 +189,9 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava
+ b = !!avahi_dns_packet_append_key(p, k, 0);
+ assert(b);
+
++ /* reserve size for record data */
++ avahi_dns_packet_reserve_size(p, avahi_record_get_estimate_size(pj->record));
++
+ /* Mark this job for addition to the packet */
+ pj->chosen = 1;
+
+@@ -202,9 +205,12 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava
+ continue;
+
+ /* This job wouldn't fit in */
+- if (avahi_record_get_estimate_size(pj->record) > avahi_dns_packet_space(p))
++ if (avahi_record_get_estimate_size(pj->record) > avahi_dns_packet_reserved_space(p))
+ break;
+
++ /* reserve size for record data */
++ avahi_dns_packet_reserve_size(p, avahi_record_get_estimate_size(pj->record));
++
+ /* Mark this job for addition to the packet */
+ pj->chosen = 1;
+ }
+--
+1.7.10.4
+
+
diff --git a/debian/patches/series b/debian/patches/series
index 89c6630..4b5ead2 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,4 +1,5 @@
# Debian patches for Avahi
01_avahi-daemon.conf.patch
+avahi-core-reserve-space-for-record-data-when-size-estimate.patch
so_reuseport-may-not-exist-in-running-kernel.patch
no-deprecations.patch