tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: accept_filter, accf_http, setsockopt and the EINVAL error



On Sun, 28 Jun 2009, Sverre Froyen wrote:

> I was looking for ways to get to that conclusion more easily.  Updating the
> man pages would help.

Yes I think that was an oversight when it was ported, the attached patch
adds information to the setsockopt(2) manpage, does it look ok?

Also, accf_http(9) and accf_data(9) should properly be in section 4

iain
Index: getsockopt.2
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/getsockopt.2,v
retrieving revision 1.31
diff -u -r1.31 getsockopt.2
--- getsockopt.2        15 Mar 2009 08:05:22 -0000      1.31
+++ getsockopt.2        28 Jun 2009 17:51:21 -0000
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)getsockopt.2       8.4 (Berkeley) 5/2/95
 .\"
-.Dd December 16, 2007
+.Dd June 28, 2009
 .Dt GETSOCKOPT 2
 .Os
 .Sh NAME
@@ -149,7 +149,7 @@
 .Fn getsockopt
 and set with
 .Fn setsockopt .
-.Bl -column SO_OOBINLINE data -offset indent
+.Bl -column SO_ACCEPTFILTER data -offset indent
 .It Dv SO_DEBUG Ta "enables recording of debugging information"
 .It Dv SO_REUSEADDR Ta "enables local address reuse"
 .It Dv SO_REUSEPORT Ta "enables duplicate address and port bindings"
@@ -165,6 +165,7 @@
 .It Dv SO_SNDTIMEO Ta "set timeout value for output"
 .It Dv SO_RCVTIMEO Ta "set timeout value for input"
 .It Dv SO_TIMESTAMP Ta "enables reception of a timestamp with datagrams"
+.It Dv SO_ACCEPTFILTER Ta "set accept filter on listening socket"
 .It Dv SO_TYPE Ta "get the type of the socket (get only)"
 .It Dv SO_ERROR Ta "get and clear error on the socket (get only)"
 .El
@@ -327,6 +328,45 @@
 cmsg_type = SCM_TIMESTAMP
 .Ed
 .Pp
+.Dv SO_ACCEPTFILTER
+places an
+.Xr accept_filter 9
+on the socket, which will filter incoming connections on a listening
+socket before being presented for
+.Xr accept 2 .
+The
+.Fn setsockopt
+system call will fail if the socket already has a filter set, and
+.Xr listen 2
+must be called on the socket before trying to install a filter.
+The
+.Fa optval
+argument
+should point to a
+.Fa struct accept_filter_arg
+that will select and configure the
+.Xr accept_filter 9 ,
+defined as follows:
+.Bd -literal
+struct  accept_filter_arg {
+        char    af_name[16];
+        char    af_arg[256-16];
+};
+.Ed
+.Lp
+The
+.Fa af_name
+argument should be filled with the name of the accept filter
+that the application wishes to place on the listening socket.
+The optional argument
+.Fa af_arg
+can be passed to the accept filter specified by
+.Fa af_name
+to provide additional configuration options at attach time.
+Passing in an
+.Fa optval
+of NULL will remove the filter.
+.Pp
 Finally,
 .Dv SO_TYPE
 and
@@ -366,6 +406,11 @@
 this error may also be returned if
 .Fa optlen
 is not in a valid part of the process address space.
+.It Bq Er EINVAL
+The socket
+.Fa s 
+was not suitable for installing an
+.Xr accept_filter 9 .
 .El
 .Sh SEE ALSO
 .Xr ioctl 2 ,
@@ -385,7 +430,8 @@
 .Xr tcp 4 ,
 .Xr tp 4 ,
 .Xr unix 4 ,
-.Xr protocols 5
+.Xr protocols 5 ,
+.Xr accept_filter 9
 .Sh HISTORY
 The
 .Fn getsockopt


Home | Main Index | Thread Index | Old Index