Re: Proposed change to struct sockif
Re: Proposed change to struct sockif
- Subject: Re: Proposed change to struct sockif
- From: "Justin C. Walker" <email@hidden>
- Date: Fri, 21 Dec 2001 15:13:02 -0800
On Friday, December 21, 2001, at 08:32 , Josh Graessley wrote:
We've run in to an issue with the sockif structure.
The sf_sonewconn1 item in the structure is typed as follows:
struct socket *(*sf_sonewconn1)(struct socket *, int, struct
kextcb *);
The real sonewconn function takes a socket* of a socket listening for
connections, allocates a new socket*, fills it in and returns it.
If an sf_sonewconn1 is specified it is called in sonewconn just after
the
socket structure as been allocate. The new socket* is passed as the
first
parameter.
All of the other functions in that structure return an int. By
returning an
int, the other functions have the option of returning:
0 - no error, keep processing as usual
EJUSTRETURN - everything is fine, don't process any further, just return
Anything else - something went wrong, propagate the error
Due to the definition, sf_sonewconn1 can not tell the caller it just
wants
the caller to return as if everything had succeeded (EJUSTRETURN).
Is anyone using the sf_sonewconn1 item in the sockif structure? Does
anyone
see a need for a socket filter to return a different socket*? I'd like
to
change sf_sonewconn1 to:
int (*sf_sonewconn1)(struct socket *, int, struct kextcb *);
Or
int (*sf_sonewconn1)(struct socket **, int, struct kextcb *);
After off-line discussions, it seems like the right thing to do is to
use the first suggested form, and check the int return value:
- 0 => keep processing
- EJUSTRETURN => return the just-allocted socket ('so')
- other => return NULL (perhaps recording the error in
so_error; I haven't thought that through yet
The current situation is just bad code and bad thinking (I had an
ill-formed idea that the intercept function might want to create its own
socket, but it already has one which it can use). Also note that the
current code will return a random value if an intercept function returns
a non-null value (probably, that non-null value).
Good catch.
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | Men are from Earth.
| Women are from Earth.
| Deal with it.
*--------------------------------------*-------------------------------*