httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 39498] - accept_filter in apr assumes if found in sys/socket.h it is loaded
Date Sun, 07 May 2006 23:17:37 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39498>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39498





------- Additional Comments From otto.hirr@olabinc.com  2006-05-07 23:17 -------
What I'm driving at is that configure makes a blind assumption that if 
SO_ACCEPTFILTER is defined, that it is available in the system, which is not 
the case. To be available, it either needs to be (1) manually loaded via 
kldload, or (2) loaded at boot time by having the administrator modify 
loader.conf, or (3) recompile the kernel and have it static within.

At configure time, prior to compilation of http source, the configure script 
could first check for SO_ACCEPTFILTER, then if it is defined, emit a small c 
program, compile, and observe the result to determine if it is REALLY 
available. Such a program as found below seems to make this determination. I 
ran it on one machine that had accf_http.ko loaded, and it ran with exit of 0, 
that is it was able to set the accept filter. Running on another machine that 
had the kernel module, but not loaded, resulted in the failure of setsockopt() 
with an errno of 2, which is the very thing that is being observed.

It is my belief that there are many people out there that compile up the code 
and expect it to work without emission of warnings. This kind of check at 
source compile time would clean this up. It could make a comment to the user 
attempting to compile httpd, that the option would be available, but is being 
turned off unless either the re-configure with the kernel module already loaded 
or forced via configure option.

/* Debugging of
    Failed to enable the '%s' Accept Filter
    is defined in server/listen.c
    the call is to apr_socket_accept_filter()
    defined in srclib/apr/network_io/unix/sockopt.c

 */
#include <sys/types.h>
#include <sys/module.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <netinet/in.h>
#include <errno.h>

main () {

    int sock;
    sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
    if (sock < 0) {
        printf( "socket(): failed: errno: %d\n", errno );
        exit( -1 );
    }

    struct sockaddr_in saddr;
    bzero( &saddr, sizeof (saddr));
    saddr.sin_family      = AF_INET;
    saddr.sin_addr.s_addr = htonl( INADDR_ANY );
    saddr.sin_port        = 6543;

    if ( bind( sock, (struct sockaddr *) &saddr, sizeof(saddr)) ) {
        printf( "bind(): failed: errno: %d\n", errno );
        exit( -1 );
    }

    if ( listen( sock, 5 )) {
        printf( "listen(): failed: errno: %d\n", errno );
        exit( -1 );
    }

    struct accept_filter_arg af;
    bzero( &af, sizeof (af) );
    strncpy( af.af_name, "httpready",  16 );

    if ((setsockopt( sock, SOL_SOCKET, SO_ACCEPTFILTER,
          &af, sizeof (af) )) < 0) {
        printf( "setsocketopt(): failed: errno: %d\n", errno );
        exit( -1 );
    }
    exit( 0 );
}


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message