You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Randall Stewart <ra...@stewart.chicago.il.us> on 2002/10/10 14:23:13 UTC

sockets and such

Hi:

I am working on getting apache2 (2.0.43) to be able
to listen on SCTP sockets as well as TCP.

This involves a small amount of work expanding the
socket_t to have a protocol field.

One thing I noted in the file

server/mpm/experimental/perchild/perchild.c



There was a comment

/* XXX this REALLY needs to be uncommnted, but it is causing problems */

right before a

apr_table_do()...

in pass_request()

Now in my poking around I found what the problem was..

on the recvmsg() side of the socket  in receive_from_other_child()

the iov[] addresses were all
set to 0.

i.e.

iov[0].iov_base = headers;
...
iov[0].iov_base = request_body;

This is most likely the problem.. I have uncommented the line and fixed
the above.. Not sure how to test it yet...  but I will let you know if I
see any problems from it..

Oh, also, once I get SCTP awareness into apache2 .. who can I send
my changes to to possibly have a look at it to see if they
would like to add it to apache?

Thanks

R
-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)


Re: sockets and such

Posted by Randall Stewart <ra...@stewart.chicago.il.us>.
Jeff Trawick wrote:
> Randall Stewart <ra...@stewart.chicago.il.us> writes:
> 
> 
>>Oh, also, once I get SCTP awareness into apache2 .. who can I send
>>my changes to to possibly have a look at it to see if they
>>would like to add it to apache?
> 
> 
> APR patches discussed on dev@apr.apache.org, Apache patches discussed
> on dev@httpd.apache.org...
> 

Thanks

R

-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)


Re: sockets and such

Posted by Jeff Trawick <tr...@attglobal.net>.
Randall Stewart <ra...@stewart.chicago.il.us> writes:

> Oh, also, once I get SCTP awareness into apache2 .. who can I send
> my changes to to possibly have a look at it to see if they
> would like to add it to apache?

APR patches discussed on dev@apr.apache.org, Apache patches discussed
on dev@httpd.apache.org...

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: sockets and such

Posted by Randall Stewart <ra...@stewart.chicago.il.us>.
rbb@apache.org wrote:
> On Thu, 10 Oct 2002, Randall Stewart wrote:
> 
> 
>>rbb@apache.org wrote:
>>
>>>On Thu, 10 Oct 2002, Randall Stewart wrote:
>>>
>>>
>>>
>>>>Hi:
>>>>
>>>>I am working on getting apache2 (2.0.43) to be able
>>>>to listen on SCTP sockets as well as TCP.
>>>>
>>>>This involves a small amount of work expanding the
>>>>socket_t to have a protocol field.
>>>
>>>
>>>It should be possible to do this without any core changes, as an initial
>>>implementation.  One of the goals for Apache 2.0, was to allow the socket
>>>to be abstracted out of the server by a module.  If you create your own
>>>module, that implements listening for an SCTP socket, everything should
>>>just work.
>>>
>>>For an example of how to do this, take a look at perchild and how I
>>>inserted the Unix domain socket into the listen_rec list.
>>>
>>
>>Hmm. yes this was one of the things I have looked at.. it is not
>>quite as easy as that though..
>>
>>The problem is in the fact that SCTP and TCP both use SOCK_STREAM :>
>>
>>The TCP-Style interface (which is prefered here since apache expects the
>>listen/accept model) uses the same type. The only difference is
>>the protocol type (third argument to socket()). Now of course
>>all socket calls in apache2 use a ,0); as the last arg.. this is
>>a base problem. I think the right  fix is to add a protocol type
>>and maintain this...
> 
> 
> I'm sorry, I wasn't clear.  Because the server only opens the listening
> socket in one place, the easiest way to do this, is to completely ignore
> Apache.  Just write a module that opens the SCTP socket, and add it to the
> listen_rec list.  From that point on, whenever Apache receives a request
> over an SCTP socket, it will just use it.
> 
> A more long-term approach, is to integrate SCTP into APR, but I don't
> really know how prevalent SCTP is.  If it only works on a small set of
> platforms, then we are less likely to integrate it into APR, because by
> it's very definition, it isn't portable.  There is also the problem that
> the only source I have found for SCTP is under the GPL.
> 

That would be the linux variant... you can find a BSD variant
in the kame stack for Free/Net and Open BSD at

http://www.kame.net

IBM AIX has a stack as well.. proprietary of course
Sun SOLARIS also as a stack.. you used to be able to get the code
                                not sure if that holds now..
HP also has a stack.. not sure I think they bought
    theirs from one of the SCTP vendors..

The only one so far absent from the pool is the MS company :-0 but
that may be changing along the way here..

In my playing here .. I got the configure.in to add a
APR_HAVE_NETINET_SCTP when present.. and then did some
of the underlying support work for the type..




> 
>>I am getting there.. but I still have a problem.. and this may
>>be a config issue.. drats that I did not compile it unchanged first :-0
>>I suppose I will have to go re-download a clean copy..
>>
>>I get everything working.. the TCP and SCTP sockets open up to
>>listen for HTTP requests.. but then somewhere along the line
>>the server does its exit.. I guess after forking its children.. but
>>at that point the SCTP socket closes.. so do the TCP ones as well :-0
>>
>>Thus I suspect a problem in my config...
> 
> 
> This doesn't sound like a config problem.  The Apache parent process
> starts, and then forks to make itself a daemon.  The forked process then
> reads the config, and sets itself and the children up.  That first child
> should never die, and that is where the socket is opened.  It sounds like
> there is some other problem here.

Could be.. I will keep slugging on it and find what I did wrong.. the
SCTP socket is being opened (along with the TCP socket) .. which is
what I want.. but I still have to figure out why it is not staying
open.. I would say it could be a socket api issue .. one of the
reasons I want to test this all.. but I have an earlier version
running with NOTHING but SCTP (by changing the little ,0 to
  ,IPPROTO_SCTP) in the apr...

Hmm.. I will dig some more and see if I can't figure it out..

Note: I do think the right solution is fixing the apr.. if we
       can be sure to carry the protocol type then all sorts
       of neat things can be done in the future to take advantage
       of the sctp streams feature...

R


> 
> Ryan
> 
> _______________________________________________________________________________
> Ryan Bloom                        	rbb@apache.org
> 550 Jean St
> Oakland CA 94610
> -------------------------------------------------------------------------------
> 
> 
> 
> 



-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)


Re: sockets and such

Posted by rb...@apache.org.
On Thu, 10 Oct 2002, Randall Stewart wrote:

> rbb@apache.org wrote:
> > On Thu, 10 Oct 2002, Randall Stewart wrote:
> > 
> > 
> >>Hi:
> >>
> >>I am working on getting apache2 (2.0.43) to be able
> >>to listen on SCTP sockets as well as TCP.
> >>
> >>This involves a small amount of work expanding the
> >>socket_t to have a protocol field.
> > 
> > 
> > It should be possible to do this without any core changes, as an initial
> > implementation.  One of the goals for Apache 2.0, was to allow the socket
> > to be abstracted out of the server by a module.  If you create your own
> > module, that implements listening for an SCTP socket, everything should
> > just work.
> > 
> > For an example of how to do this, take a look at perchild and how I
> > inserted the Unix domain socket into the listen_rec list.
> > 
> Hmm. yes this was one of the things I have looked at.. it is not
> quite as easy as that though..
> 
> The problem is in the fact that SCTP and TCP both use SOCK_STREAM :>
> 
> The TCP-Style interface (which is prefered here since apache expects the
> listen/accept model) uses the same type. The only difference is
> the protocol type (third argument to socket()). Now of course
> all socket calls in apache2 use a ,0); as the last arg.. this is
> a base problem. I think the right  fix is to add a protocol type
> and maintain this...

I'm sorry, I wasn't clear.  Because the server only opens the listening
socket in one place, the easiest way to do this, is to completely ignore
Apache.  Just write a module that opens the SCTP socket, and add it to the
listen_rec list.  From that point on, whenever Apache receives a request
over an SCTP socket, it will just use it.

A more long-term approach, is to integrate SCTP into APR, but I don't
really know how prevalent SCTP is.  If it only works on a small set of
platforms, then we are less likely to integrate it into APR, because by
it's very definition, it isn't portable.  There is also the problem that
the only source I have found for SCTP is under the GPL.

> I am getting there.. but I still have a problem.. and this may
> be a config issue.. drats that I did not compile it unchanged first :-0
> I suppose I will have to go re-download a clean copy..
> 
> I get everything working.. the TCP and SCTP sockets open up to
> listen for HTTP requests.. but then somewhere along the line
> the server does its exit.. I guess after forking its children.. but
> at that point the SCTP socket closes.. so do the TCP ones as well :-0
> 
> Thus I suspect a problem in my config...

This doesn't sound like a config problem.  The Apache parent process
starts, and then forks to make itself a daemon.  The forked process then
reads the config, and sets itself and the children up.  That first child
should never die, and that is where the socket is opened.  It sounds like
there is some other problem here.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
550 Jean St
Oakland CA 94610
-------------------------------------------------------------------------------



Re: sockets and such

Posted by Randall Stewart <ra...@stewart.chicago.il.us>.
Ryan:

Thanks for the fast response..

Now for some thoughts..


rbb@apache.org wrote:
> On Thu, 10 Oct 2002, Randall Stewart wrote:
> 
> 
>>Hi:
>>
>>I am working on getting apache2 (2.0.43) to be able
>>to listen on SCTP sockets as well as TCP.
>>
>>This involves a small amount of work expanding the
>>socket_t to have a protocol field.
> 
> 
> It should be possible to do this without any core changes, as an initial
> implementation.  One of the goals for Apache 2.0, was to allow the socket
> to be abstracted out of the server by a module.  If you create your own
> module, that implements listening for an SCTP socket, everything should
> just work.
> 
> For an example of how to do this, take a look at perchild and how I
> inserted the Unix domain socket into the listen_rec list.
> 
Hmm. yes this was one of the things I have looked at.. it is not
quite as easy as that though..

The problem is in the fact that SCTP and TCP both use SOCK_STREAM :>

The TCP-Style interface (which is prefered here since apache expects the
listen/accept model) uses the same type. The only difference is
the protocol type (third argument to socket()). Now of course
all socket calls in apache2 use a ,0); as the last arg.. this is
a base problem. I think the right  fix is to add a protocol type
and maintain this...

I am getting there.. but I still have a problem.. and this may
be a config issue.. drats that I did not compile it unchanged first :-0
I suppose I will have to go re-download a clean copy..

I get everything working.. the TCP and SCTP sockets open up to
listen for HTTP requests.. but then somewhere along the line
the server does its exit.. I guess after forking its children.. but
at that point the SCTP socket closes.. so do the TCP ones as well :-0

Thus I suspect a problem in my config...


> 
>>/* XXX this REALLY needs to be uncommnted, but it is causing problems */
>>
>>right before a
>>
>>apr_table_do()...
>>
>>in pass_request()
>>
>>Now in my poking around I found what the problem was..
>>
>>on the recvmsg() side of the socket  in receive_from_other_child()
>>
>>the iov[] addresses were all
>>set to 0.
>>
>>i.e.
>>
>>iov[0].iov_base = headers;
>>...
>>iov[0].iov_base = request_body;
>>
>>This is most likely the problem.. I have uncommented the line and fixed
>>the above.. Not sure how to test it yet...  but I will let you know if I
>>see any problems from it..
> 
> 
> THANK YOU!  I forgot about that bug, but this does look like the
> problem.  I spent all of my time looking at pass_request(), and completely
> ignored receive_from_other_child().   :-(
> 

Yeah, when I saw this and later saw the comment I knew that this
was one of those ugly ones that make you look in the wrong place :-0

R


> Ryan
> _______________________________________________________________________________
> Ryan Bloom                        	rbb@apache.org
> 550 Jean St
> Oakland CA 94610
> -------------------------------------------------------------------------------
> 
> 
> 
> 



-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)


Re: sockets and such

Posted by rb...@apache.org.
On Thu, 10 Oct 2002, Randall Stewart wrote:

> Hi:
> 
> I am working on getting apache2 (2.0.43) to be able
> to listen on SCTP sockets as well as TCP.
> 
> This involves a small amount of work expanding the
> socket_t to have a protocol field.

It should be possible to do this without any core changes, as an initial
implementation.  One of the goals for Apache 2.0, was to allow the socket
to be abstracted out of the server by a module.  If you create your own
module, that implements listening for an SCTP socket, everything should
just work.

For an example of how to do this, take a look at perchild and how I
inserted the Unix domain socket into the listen_rec list.

> /* XXX this REALLY needs to be uncommnted, but it is causing problems */
> 
> right before a
> 
> apr_table_do()...
> 
> in pass_request()
> 
> Now in my poking around I found what the problem was..
> 
> on the recvmsg() side of the socket  in receive_from_other_child()
> 
> the iov[] addresses were all
> set to 0.
> 
> i.e.
> 
> iov[0].iov_base = headers;
> ...
> iov[0].iov_base = request_body;
> 
> This is most likely the problem.. I have uncommented the line and fixed
> the above.. Not sure how to test it yet...  but I will let you know if I
> see any problems from it..

THANK YOU!  I forgot about that bug, but this does look like the
problem.  I spent all of my time looking at pass_request(), and completely
ignored receive_from_other_child().   :-(

Ryan
_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
550 Jean St
Oakland CA 94610
-------------------------------------------------------------------------------