cups announcing wrong port numbers on avahi

Bug #792309 reported by Hadmut Danisch
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cups (Ubuntu)
Fix Released
Medium
Unassigned
Natty
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: cups

Hi,

I tried to figure out why my Apple iPad does not find the printers announced by my Ubuntu server automatically through cups, but does find them, if I add an entry manually to the avahi server.

As far as I could see the major difference seems to be that cups announces a wrong port number. cups announces Port 30466, where there isn't any open socket. If I add an entry manually, it announces the correct Port 631 and the iPad finds the printer.

It is most probably a problem of byte order, because

631 = hex 0x0277
30466 = hex 0x7702

regards
Hadmut

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: cups 1.4.6-5ubuntu1
ProcVersionSignature: Ubuntu 2.6.38-8.42-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic x86_64
Architecture: amd64
Date: Fri Jun 3 13:00:05 2011
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100427.1)
Lpstat:
 device for Deskjet-F2100-series: hp:/usb/Deskjet_F2100_series?serial=CN7CK4T2NP04TK
 device for HP-LaserJet-1300: socket://192.168.160.1:9100
 device for hp-LaserJet-1320-series: hp:/usb/hp_LaserJet_1320_series?serial=00CNM1G08790
 device for Laser: ///dev/null
 device for PDF: cups-pdf:/
MachineType: Gigabyte Technology Co., Ltd. GA-MA78G-DS3H
Papersize: a4
PpdFiles:
 PDF: Generic CUPS-PDF Printer
 HP-LaserJet-1300: HP LaserJet 1300 Series Postscript (recommended)
 hp-LaserJet-1320-series: HP LaserJet 1320 Foomatic/pxlmono (recommended)
 Deskjet-F2100-series: HP Deskjet f2100 Series hpijs, 3.10.6
ProcEnviron:
 LANGUAGE=en_US:en
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/tcsh
ProcKernelCmdLine: BOOT_IMAGE=/vmlinuz-2.6.38-8-generic root=/dev/mapper/raid2-ubuntu64 ro quiet splash vt.handoff=7
SourcePackage: cups
UpgradeStatus: Upgraded to natty on 2011-05-17 (16 days ago)
dmi.bios.date: 04/03/2008
dmi.bios.vendor: Award Software International, Inc.
dmi.bios.version: F2
dmi.board.name: GA-MA78G-DS3H
dmi.board.vendor: Gigabyte Technology Co., Ltd.
dmi.board.version: x.x
dmi.chassis.type: 3
dmi.chassis.vendor: Gigabyte Technology Co., Ltd.
dmi.modalias: dmi:bvnAwardSoftwareInternational,Inc.:bvrF2:bd04/03/2008:svnGigabyteTechnologyCo.,Ltd.:pnGA-MA78G-DS3H:pvr:rvnGigabyteTechnologyCo.,Ltd.:rnGA-MA78G-DS3H:rvrx.x:cvnGigabyteTechnologyCo.,Ltd.:ct3:cvr:
dmi.product.name: GA-MA78G-DS3H
dmi.sys.vendor: Gigabyte Technology Co., Ltd.

Revision history for this message
Hadmut Danisch (hadmut) wrote :
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim, there seems to be a byte-order problem in your Avahi patch. Can you have a look into this? Thanks.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

This bug can also have caused bug 711779.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

To reproduce without need of a printing client, run the command

avahi-browse -a -v -t -r

in a terminal window. Then look for entries arising from CUPS queues. They report "port = [30466]". Entries from IPP printers report correctly "port = [631]" (what CUPS as an IPP-based printing system should do as well).

Changed in cups (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Tim Waugh (twaugh) wrote :

Oops, this came about because the libdns_sd and Avahi APIs differ in which byte order they require the port number. The Avahi API requires it in host order.

Remove the htons() calls from avahi_entry_group_add_service() and avahi_entry_group_add_service_strlst().

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim, thanks, this confirms which I have found out by simply guessing. I will apply it.

Changed in cups (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Fix committed to the CUPS BZR repository at Debian. So the next CUPS packages in Debian unstable and Ubuntu Oneiric will contain the fix.

Changed in cups (Ubuntu):
status: In Progress → Fix Committed
Changed in cups (Ubuntu Natty):
status: New → In Progress
importance: Undecided → Medium
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Uploaded the fixed CUPS package as an SRU for Natty to -proposed. Please test it as soon as it gets approved (a comment with testing instructions will get posted here). A debdiff of the changes is attached.

Changed in cups (Ubuntu Natty):
status: In Progress → Fix Committed
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

A fixed CUPS package for Natty is now uploaded the -proposed queue. As soon as it gets approved please test the new package. A comment with instructions will be posted here then. A debdiff of the changes is attached.

The new CUPS package does not fix only this bug, but in total five bugs (therefore the somewhat bigger debdiff): bug 711779, bug 782309, bug 790378, bug 792309, bug 793265. Any help on verifying these fixes is also welcome.

Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Accepted cups into natty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

tags: added: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cups - 1.4.6-7

---------------
cups (1.4.6-7) unstable; urgency=low

  * debian/patches/cups-avahi.dpatch: Updated Avahi patch so that it does
    not generate too long service names which Avahi does not accept. Printers
    did not get advertized via DNS-SD then. (LP: #793265).
  * debian/patches/cups-avahi.dpatch: Updated Avahi patch to add the text
    field entry "URF=none" and the service subtype "_universal" so that
    mDNS/Bonjour-advertized printers are recognized by AirPrint clients
    (iPhone/iPad with iOS 4.2 or newer). (LP: #711779).
  * debian/patches/cups-avahi.dpatch: In contrary to the libdns_sd API the
    Avahi API requires port numbers in host order and not in network order.
    This made the Avahi-based DNS-SD broadcasting of CUPS advertizing wronmg
    port numbers. Updated the Avahi patch to fix it. Thanks to Tim Waugh
    from Red Hat on confirming this (LP: #792309).
  * debian/local/filters/pdf-filters/pdftopdf/P2PResources.cxx: Fixed
    memory leak in pdftopdf filter which made the filter taking up several
    gigabytes when processing certain PDF files. Thanks to upstream
    author Koji Otani for the quick fix (LP: #790378).
  * debian/local/pstopdf.convs, debian/local/pstopdf.types: Do not apply
    the PDF printing workflow to PostScript input coming from the Adobe
    Reader. If this PostScript comes from an encrypted (DRM) PDF, it cannot
    be converted to PDF again by Ghostscript (LP: #782309).
 -- Martin Pitt <email address hidden> Tue, 07 Jun 2011 07:04:11 +0200

Changed in cups (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Hadmut Danisch (hadmut) wrote :

Thanks,

my iPad now finds all the printers my ubuntu machine offers.

(The next problem is that the default printer names like "Hewlett-Packard hp LaserJet 1320 series @ ..." are too long for the iPad and thus truncated, but that's a different Problem.)

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Hadmut, with this you confirmed the fix of this bug and bug 711779 (AirPrint). Thank you very much.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Hadmut, and are you actually able to print from your iPad?

Revision history for this message
Hadmut Danisch (hadmut) wrote :

Yes, works. Printing was not affected by the bug. It already worked before the patch, it was just a problem of finding the printer.

Ironically I did not even know that the ubuntu cups automatically does advertise it's printer over avahi. I had made a manual entry under /etc/avahi/services which worked immediately, but wanted to know what exactly is happening there for curiosity (I jost got my iPad a few days ago). By tcpdumping my iPad-Ubuntu-connection I found more avahi printer advertisings than I had configured manually and wondered where they come from and why my iPad doesn't offer them as printers to choose from. That's why I found a bug in a function that I didn't even know it exists in Ubuntu.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Hadmut, thanks. Now you can remove your manual entry in /etc/avahi/services and your iPad will see all your printers and you are able to print on all of them. Please check whether this will work.

We have enabled Avahi-based mDNS/DNS-SD printer broadcasting in Natty with the help of a patch from Red Hat's printing guru Tim Waugh. Unfortunately, it had bugs and so with the original Natty one could not really make use of it. See comment #11. Now with these bugs fixed (actual problems found by user-posted HOWTOs, see bug 711779) mDNS/DNS-SD printer broadcasting works correctly and is automatically available when one shares the local print queues.

Revision history for this message
Hadmut Danisch (hadmut) wrote :

Till, of course I have checked that and removed my manual entries before confirming the bug to be fixed.

With my manual entries still active (which's names slightly differed from what cups advertieses) my printers occured twice on the iPad.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Hadmut, OK, thank you very much.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cups - 1.4.6-5ubuntu1.2

---------------
cups (1.4.6-5ubuntu1.2) natty-proposed; urgency=low

  * debian/patches/cups-avahi.dpatch: Updated Avahi patch so that it does
    not generate too long service names which Avahi does not accept. Printers
    did not get advertized via DNS-SD then. (LP: #793265).
  * debian/patches/cups-avahi.dpatch: Updated Avahi patch to add the text
    field entry "URF=none" and the service subtype "_universal" so that
    mDNS/Bonjour-advertized printers are recognized by AirPrint clients
    (iPhone/iPad with iOS 4.2 or newer). (LP: #711779).
  * debian/patches/cups-avahi.dpatch: In contrary to the libdns_sd API the
    Avahi API requires port numbers in host order and not in network order.
    This made the Avahi-based DNS-SD broadcasting of CUPS advertizing wronmg
    port numbers. Updated the Avahi patch to fix it. Thanks to Tim Waugh
    from Red Hat on confirming this (LP: #792309).
  * debian/local/filters/pdf-filters/pdftopdf/P2PResources.cxx: Fixed
    memory leak in pdftopdf filter which made the filter taking up several
    gigabytes when processing certain PDF files. Thanks to upstream
    author Koji Otani for the quick fix (LP: #790378).
  * debian/local/pstopdf.convs, debian/local/pstopdf.types: Do not apply
    the PDF printing workflow to PostScript input coming from the Adobe
    Reader. If this PostScript comes from an encrypted (DRM) PDF, it cannot
    be converted to PDF again by Ghostscript (LP: #782309).
 -- Till Kamppeter <email address hidden> Mon, 5 Jun 2011 13:51:59 +0200

Changed in cups (Ubuntu Natty):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.