"ipp" tries to query a CUPS server with lots of SNMP requests #4106

Closed
michaelrsweet opened this Issue May 25, 2012 · 2 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented May 25, 2012

Version: 1.4.7
CUPS.org User: cumrprint

The operating system on which I have observed this (with Wireshark) is MacOS X 10.6. It may or may not occur under different OSs.

Email exchange with Michael Sweet, part of which is relevant:

I couldn't find it in the documentation, but it seems that using "ipp://server/queuename" should be used to talk to printers, while "http://server:631/printers/queuename" should be used to talk to a server. If this is documented, I would appreciate knowing where.

It isn't. RFC 3510 is notably lacking in any conformance requirements for the URI resource path, and RFC 2911 just talks about the printer URI in an abstract sense.

CUPS and Windows use "/printers/queuename" and "/printers/queuename/.printer", respectively, however there are printers that use this form as well and are not CUPS or Windows-based.

Most printers use "/ipp" or something similar.

"ipp" tries to query the printer with lots of SNMP requests. If it's used to talk to a server, and the server is not accepting SNMP requests, then significant timeout delay occurs.

Please file a bug for this; we should be saving the lack of results to the cache file so this only happens on the first print:

http://www.cups.org/str.php

"http" also generates SNMP requests, but only two.
http and ipp are the same backend and should be doing the same SNMP queries.

Is there any way to get the MacOS X CUPS client to not generate SNMP requests?
Add "*cupsSNMPSupplies: False" to the PPD file on the client. In this case I'd file a bug with Apple to track adding this for all shared printers:

http://bugreport.apple.com

Thanks!

Collaborator

michaelrsweet commented Sep 15, 2012

CUPS.org User: mike

Fixed in Subversion repository.

The change adds a new "snmp" option for all of the network backends. I was also able to key off the normal Bonjour shared printer URI path ("/cups" on the end) to add the "snmp" option to the resolved URI so that Bonjour shared printers do not use SNMP.

Collaborator

michaelrsweet commented Sep 15, 2012

"str4106.patch":

Index: backend/lpd.c

--- backend/lpd.c (revision 10596)
+++ backend/lpd.c (working copy)
@@ -126,6 +126,7 @@
int port; /* Port number /
char portname[256]; /
Port name (string) /
http_addrlist_t *addrlist; /
List of addresses for printer */

  • int snmp_enabled = 1; /* Is SNMP enabled? /
    int snmp_fd; /
    SNMP socket /
    int fd; /
    Print file /
    int status; /
    Status of LPD job */
    @@ -356,7 +357,8 @@
    */
 if (!value[0] || !_cups_strcasecmp(value, "on") ||
  •   !_cups_strcasecmp(value, "yes") || !_cups_strcasecmp(value, "true") ||
    
  •   !_cups_strcasecmp(value, "yes") ||
    
  •   !_cups_strcasecmp(value, "true") ||
    !_cups_strcasecmp(value, "rfc1179"))
    

    reserve = RESERVE_RFC1179;
    else if (!_cups_strcasecmp(value, "any"))
    @@ -371,7 +373,8 @@
    */

     manual_copies = !value[0] || !_cups_strcasecmp(value, "on") ||
    
  •       !_cups_strcasecmp(value, "yes") || !_cups_strcasecmp(value, "true");
    
  •       !_cups_strcasecmp(value, "yes") ||
    
  •       !_cups_strcasecmp(value, "true");
    

    }
    else if (!_cups_strcasecmp(name, "sanitize_title"))
    {
    @@ -380,8 +383,19 @@
    */

     sanitize_title = !value[0] || !_cups_strcasecmp(value, "on") ||
    
  •        !_cups_strcasecmp(value, "yes") || !_cups_strcasecmp(value, "true");
    
  •        !_cups_strcasecmp(value, "yes") ||
    
  •        !_cups_strcasecmp(value, "true");
    

    }

  •  else if (!_cups_strcasecmp(name, "snmp"))
    
  •  {
    
  •    /*
    
  •     \* Enable/disable SNMP stuff...
    
  •     */
    
  •     snmp_enabled = !value[0] || !_cups_strcasecmp(value, "on") ||
    
  •                    _cups_strcasecmp(value, "yes") ||
    
  •                    _cups_strcasecmp(value, "true");
    
  •  }
    

    else if (!_cups_strcasecmp(name, "timeout"))
    {
    /*
    @@ -428,7 +442,10 @@
    }
    }

  • snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family);

  • if (snmp_enabled)

  • snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family);

  • else

  • snmp_fd = -1;

/*

  • Wait for data from the filter...
    Index: backend/ipp.c

    --- backend/ipp.c (revision 10603)
    +++ backend/ipp.c (working copy)
    @@ -203,6 +203,7 @@
    value, / Value of option /
    sep; /
    Separator character /
    http_addrlist_t *addrlist; /
    Address of printer */

  • int snmp_enabled = 1; /* Is SNMP enabled? /
    int snmp_fd, /
    SNMP socket /
    start_count, /
    Page count via SNMP at start /
    page_count, /
    Page count via SNMP */
    @@ -508,6 +509,16 @@
    value);
    }
    }

  •  else if (!_cups_strcasecmp(name, "snmp"))
    
  •  {
    
  •    /*
    
  •     \* Enable/disable SNMP stuff...
    
  •     */
    
  •     snmp_enabled = !value[0] || !_cups_strcasecmp(value, "on") ||
    
  •                    _cups_strcasecmp(value, "yes") ||
    
  •                    _cups_strcasecmp(value, "true");
    
  •  }
    

    else if (!_cups_strcasecmp(name, "version"))
    {
    if (!strcmp(value, "1.0"))
    @@ -659,11 +670,14 @@

    • See if the printer supports SNMP...
      */
  • if ((snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family)) >= 0)

  • {

  • if (snmp_enabled)

  • snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family);

  • else

  • snmp_fd = -1;

  • if (snmp_fd >= 0)
    have_supplies = !backendSNMPSupplies(snmp_fd, &(addrlist->addr),
    &start_count, NULL);
  • }
    else
    have_supplies = start_count = 0;

Index: backend/socket.c

--- backend/socket.c (revision 10596)
+++ backend/socket.c (working copy)
@@ -87,6 +87,7 @@
http_addrlist_t addrlist, / Address list /
*addr; /
Connected address /
char addrname[256]; /
Address name */

  • int snmp_enabled = 1; /* Is SNMP enabled? /
    int snmp_fd, /
    SNMP socket /
    start_count, /
    Page count via SNMP at start /
    page_count, /
    Page count via SNMP */
    @@ -246,6 +247,16 @@
    waiteof = !value[0] || !_cups_strcasecmp(value, "on") ||
    !_cups_strcasecmp(value, "yes") || !_cups_strcasecmp(value, "true");
    }

  •  else if (!_cups_strcasecmp(name, "snmp"))
    
  •  {
    
  •    /*
    
  •     \* Enable/disable SNMP stuff...
    
  •     */
    
  •     snmp_enabled = !value[0] || !_cups_strcasecmp(value, "on") ||
    
  •                    _cups_strcasecmp(value, "yes") ||
    
  •                    _cups_strcasecmp(value, "true");
    
  •  }
    

    else if (!_cups_strcasecmp(name, "contimeout"))
    {
    /*
    @@ -286,11 +297,14 @@

    • See if the printer supports SNMP...
      */
  • if ((snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family)) >= 0)

  • {

  • if (snmp_enabled)

  • snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family);

  • else

  • snmp_fd = -1;

  • if (snmp_fd >= 0)
    have_supplies = !backendSNMPSupplies(snmp_fd, &(addrlist->addr),
    &start_count, NULL);
  • }
    else
    have_supplies = start_count = 0;

Index: doc/help/network.html

--- doc/help/network.html (revision 10596)
+++ doc/help/network.html (working copy)
@@ -93,16 +93,22 @@

 socket://ip-address-or-hostname
-socket://ip-address-or-hostname/?waiteof=false
+socket://ip-address-or-hostname/?option=value
+socket://ip-address-or-hostname/?option=value&option=value
 socket://ip-address-or-hostname:port-number
-socket://ip-address-or-hostname:port-number/?waiteof=false
+socket://ip-address-or-hostname:port-number/?option=value
+socket://ip-address-or-hostname:port-number/?option=value&option=value
 

+

The "contimeout" option controls the number of seconds that the backend will wait to obtain a connection to the printer. The default is 1 week.


+
+

The "snmp" option controls whether the socket backend queries for supply and page count information via SNMP.


+

The "waiteof" option controls whether the socket backend waits for the printer to complete the printing of the job. The default is to wait.

Internet Printing Protocol (IPP)

-

IPP is the only protocol that CUPS supports natively and is supported by some network printers and print servers. However, since many printers do not implement IPP properly, only use IPP when the vendor actually documents official support for it. IPP printing normally happens over port 631 and uses the http and ipp URI schemes:


+

IPP is the only protocol that CUPS supports natively and is supported by some network printers and print servers. However, since many printers do not implement IPP properly, only use IPP when the vendor actually documents official support for it. IPP printing normally happens over port 631 and uses the http, ipp, and ipps URI schemes:

 http://ip-address-or-hostname:port-number/resource
@@ -114,6 +120,12 @@
 ipp://ip-address-or-hostname:port-number/resource
 ipp://ip-address-or-hostname:port-number/resource?option=value
 ipp://ip-address-or-hostname:port-number/resource?option=value&option=value
+ipps://ip-address-or-hostname/resource
+ipps://ip-address-or-hostname/resource?option=value
+ipps://ip-address-or-hostname/resource?option=value&option=value
+ipps://ip-address-or-hostname:port-number/resource
+ipps://ip-address-or-hostname:port-number/resource?option=value
+ipps://ip-address-or-hostname:port-number/resource?option=value&option=value
 

The ipp backend supports many options, which are summarized in Table 2.

@@ -148,16 +160,20 @@ Specifies that the connection to the IPP server should be encrypted using TLS. - snmp=false - Specifies that SNMP supply and page count queries should not be performed. + + version=1.0 - Specifies that version 1.0 of the IPP protocol should be used instead of the default version 1.1. - Specifies that version 1.0 of the IPP protocol should be used instead of the default version 2.0. - version=2.0 - Specifies that version 2.0 of the IPP protocol should be used instead of the default version 1.1. - version=1.1 - Specifies that version 1.1 of the IPP protocol should be used instead of the default version 2.0. version=2.1 - Specifies that version 2.1 of the IPP protocol should be used instead of the default version 1.1. - Specifies that version 2.1 of the IPP protocol should be used instead of the default version 2.0. waitjob=false @@ -267,6 +283,10 @@ Specifies that the job title string should be restricted to ASCII characters. - snmp=false - Specifies that SNMP supply and page count queries should not be performed. + + timeout=seconds Specifies the number of seconds to wait for LPD commands to complete. Index: cups/http-support.c =================================================================== --- cups/http-support.c (revision 10596) +++ cups/http-support.c (working copy) @@ -82,6 +82,7 @@ char _buffer; /_ Pointer to buffer _/ size_t bufsize; /_ Size of buffer _/ int options; /_ Options passed to _httpResolveURI */ - const char _resource; /_ Resource from URI */ } _http_uribuf_t;

@@ -1523,6 +1524,7 @@
uribuf.buffer = resolved_uri;
uribuf.bufsize = resolved_size;
uribuf.options = options;

  • uribuf.resource = resource;

resolved_uri[0] = '\0';

@@ -2064,8 +2066,14 @@

  • Assemble the final device URI...
    */

  • httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize, scheme,

  •              NULL, hostTarget, ntohs(port), resource);
    
  • if ((!strcmp(scheme, "ipp") || !strcmp(scheme, "ipps")) &&

  •  !strcmp(uribuf->resource, "/cups"))
    
  • httpAssembleURIf(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize,

  •                 scheme, NULL, hostTarget, ntohs(port), "%s?snmp=false",
    
  •                 resource);
    
  • else

  • httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize,

  •                scheme, NULL, hostTarget, ntohs(port), resource);
    

    DEBUG_printf(("8http_resolve_cb: Resolved URI is "%s"...", uribuf->buffer));
    }

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment