60 Commits

Author SHA1 Message Date
4915c21524 Add Multipath TCP (MPTCP) support (Proxy)
Multipath TCP (MPTCP), standardized in RFC8684 [1],
is a TCP extension that enables a TCP connection to
use different paths.

Multipath TCP has been used for several use cases.
On smartphones, MPTCP enables seamless handovers between
cellular and Wi-Fi networks while preserving established
connections. This use-case is what pushed Apple to use
MPTCP since 2013 in multiple applications [2]. On dual-stack
hosts, Multipath TCP enables the TCP connection to
automatically use the best performing path, either IPv4
or IPv6. If one path fails, MPTCP automatically uses
the other path.

To benefit from MPTCP, both the client and the server
have to support it. Multipath TCP is a backward-compatible
TCP extension that is enabled by default on recent
Linux distributions (Debian, Ubuntu, Redhat, ...). Multipath
TCP is included in the Linux kernel since version 5.6 [3].
To use it on Linux, an application must explicitly enable
it when creating the socket. No need to change anything
else in the application.

Adding the possibility to create MPTCP sockets would thus
be a really fine addition to httpd, by allowing clients
to make use of their different interfaces.

This patch introduces the possibilty to connect to backend
servers using MPTCP. Note however that these changes are
only available on Linux, as IPPROTO_MPTCP is Linux specific
for the time being.

For proxies, we can connect using MPTCP by passing the
\"multipathtcp\" parameter:

ProxyPass \"/example\" \"http://backend.example.com\" multipathtcp=On

We then store this information in the worker and create sockets
appropriately according to this value.

Link: https://www.rfc-editor.org/rfc/rfc8684.html [1]
Link: https://www.tessares.net/apples-mptcp-story-so-far/ [2]
Link: https://www.mptcp.dev [3]
Add Multipath TCP (MPTCP) support (Core)

Multipath TCP (MPTCP), standardized in RFC8684 [1],
is a TCP extension that enables a TCP connection to
use different paths.

Multipath TCP has been used for several use cases.
On smartphones, MPTCP enables seamless handovers between
cellular and Wi-Fi networks while preserving established
connections. This use-case is what pushed Apple to use
MPTCP since 2013 in multiple applications [2]. On dual-stack
hosts, Multipath TCP enables the TCP connection to
automatically use the best performing path, either IPv4
or IPv6. If one path fails, MPTCP automatically uses
the other path.

To benefit from MPTCP, both the client and the server
have to support it. Multipath TCP is a backward-compatible
TCP extension that is enabled by default on recent
Linux distributions (Debian, Ubuntu, Redhat, ...). Multipath
TCP is included in the Linux kernel since version 5.6 [3].
To use it on Linux, an application must explicitly enable
it when creating the socket. No need to change anything
else in the application.

Adding the possibility to create MPTCP sockets would thus
be a really fine addition to httpd, by allowing clients
to make use of their different interfaces.

This patch introduces the possibility to listen with MPTCP
sockets. Note however that these changes are only available
on Linux, as IPPROTO_MPTCP is Linux specific for the time being.

To do so, we extended the Listen directive to include
a \"multipathtcp\" option, allowing to create MPTCP sockets
instead of regular TCP ones:

Listen 80 options=multipathtcp

We then store this information in flags for the listen directive
and create sockets appropriately according to this value.

Link: https://www.rfc-editor.org/rfc/rfc8684.html [1]
Link: https://www.tessares.net/apples-mptcp-story-so-far/ [2]
Link: https://www.mptcp.dev [3]

Submitted by: Aperence <anthony.doeraene hotmail.com>
Github: closes #476


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1920586 13f79535-47bb-0310-9956-ffa450edef68
2024-09-12 07:59:22 +00:00
db0631ed09 Remove libsystemd dependency from main httpd binary
Until this change httpd was linking libsystemd to the main httpd binary. If you want to run lightweight version of httpd in container, sometimes you just want to install
httpd binary with as little dependencies as possible to make container small in size and do not pull uncencessary dependencies and libraries.

This change will move all systemd library calls from listen.c to mod_systemd module and remove systemd linking from the main httpd bin.
Fixed mixed declaration and wrongly declared variable.

Submitted by: Luboš Uhliarik <luhliari redhat.com>

Github: closes #312


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899784 13f79535-47bb-0310-9956-ffa450edef68
2022-04-12 15:43:04 +00:00
2f9cba2ad0 Add "v6only" Listen option to enable IPV6_V6ONLY in v4mapped builds
where it is otherwise always disabled.

* include/ap_listen.h: Define AP_LISTEN_V6ONLY.

* server/listen.c (make_sock): Set v6only_setting to 1 if
  AP_LISTEN_V6ONLY flag is set for the listener.
  (parse_listen_flags): Parse "v6only" flag.

PR: 54878


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879106 13f79535-47bb-0310-9956-ffa450edef68
2020-06-23 08:45:07 +00:00
a42f3692b1 Add optional options= argument to Listen to add listener-specific
socket options.

Reimplement "use_specific_errors" listener flag under generic
ap_listen_rec flags field holding all listener-specific options.

* include/ap_listen.h: Add AP_LISTEN_* flags.
  (ap_listen_rec): Rename use_specific_errors to flags.

* server/listen.c (make_sock): Set APR_SO_FREEBIND if
  AP_LISTEN_FREEBIND flag is set on listener; set APR_SO_REUSEPORT
  unconditionally if AP_LISTEN_REUSEPORT is set.
  (alloc_listener): Take flags argument.
  (ap_setup_listeners): Set AP_LISTEN_SPECIFIC_ERRORS flag here.
  (ap_set_listener): Parse optional options=... argument, catch
  typos and fail if protocol name contains a "=".
  (ap_duplicate_listeners): Duplicate flags.

Submitted by: jkaluza, Lubos Uhliarik <luhliari redhat.com>, jorton
PR: 61865
Github: closes #114


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1876865 13f79535-47bb-0310-9956-ffa450edef68
2020-04-23 08:26:26 +00:00
98e9503120 Add "AcceptErrorsNonFatal" directive
This tweaks accept() failure processing by having ap_unixd_accept
pass more errors up, and having the MPM's check against a macro
to see if they are in a whitelist of non ENETDOWN/EMFILE kind 
of potential process-wide errors.

Default behavior is still to exit.

edit: MMN bump in 1820099.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1820098 13f79535-47bb-0310-9956-ffa450edef68
2018-01-04 15:10:45 +00:00
f069dabada Off by one "make dox" warning
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1746171 13f79535-47bb-0310-9956-ffa450edef68
2016-05-30 19:24:34 +00:00
61d5a3c1ca MPMs, core: make duplicated listeners (SO_REUSEPORT) introduced in r1599531
less intrusive.

Submitted by: Yingqi Lu <yingqi.lu@intel.com>
Modified/Committed by: ylavic

Add ListenCoresBucketsRatio which is a configurable ratio between the number of
CPU cores (online) and the number of listeners buckets to create, defaulting to
zero (so that listeners buckets become an opt-in, ie. ncpus / ratio > 1).
This could also be made an opt-out by using the previous hardcoded value (8) as
default.

Make ap_close_listeners() act on all the listeners (including duplicated ones),
since the function is also called externally (eg. mod_cgid, mod_ssl_ct and
possibly any third party module) to cleanup opened descriptors when a process
is forked (the duplicated listeners are kept in a scoped/static variable).

Add ap_close_listeners_ex() to close a single bucket of listeners, used by the
children to close unused duplicates and internally by ap_close_listeners().

Make ap_duplicate_listeners() compute the number of buckets to be used, instead
of each MPM. This number is now based on the above ratio and will not change
unless asked to (given *num_buckets < 1, that is when the MPM does not run in
one-process mode nor after a graceful restart).

Remove some global variables (mpm_listen, enable_default_listeners) previously
used to communicate between MPMs and ap_listen, since ap_duplicate_listeners()
API can now be used to do so.
Also rename num_buckets as ap_num_listen_buckets, and prefix have_so_reuseport
with ap_ (both printed by ap_log_common(), hence kept global).
Detect ap_have_so_reuseport once only at startup.

Restore dummy_connection() as before r1599531 since sending POD signals should
not depend on the number of listeners buckets (there is still one single socket
receiving the connections).

For each MPM (concerned), move the bucket data (pod, listeners and eventually
accept mutex) into a struct and instanciate an array of them (sized by the
number of buckets), for each child to use its own data according to its bucket
index, and the parent to maintain the whole.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1635521 13f79535-47bb-0310-9956-ffa450edef68
2014-10-30 15:24:58 +00:00
c539206da2 Optimize w/ duplicated listeners and use of SO_REUSEPORT
where available.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1599531 13f79535-47bb-0310-9956-ffa450edef68
2014-06-03 13:07:29 +00:00
1951a037bf More cleanup: Expand tabs and some more indentation fixes
No functional change


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1174929 13f79535-47bb-0310-9956-ffa450edef68
2011-09-23 18:08:42 +00:00
103f776c25 Cleanup effort in prep for GA push:
Trim trailing whitespace... no func change



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1174748 13f79535-47bb-0310-9956-ffa450edef68
2011-09-23 13:38:09 +00:00
256f3e913b fix wrong name in function prototype which led to
unresolved reference at link time

hint at adding some doc as well


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@806315 13f79535-47bb-0310-9956-ffa450edef68
2009-08-20 19:25:49 +00:00
b102bce05c Don't require all listeners to be created equal ...
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@806010 13f79535-47bb-0310-9956-ffa450edef68
2009-08-19 23:55:14 +00:00
56acf588e4 * Add extern "C" linkage to several headers to make it easier to use
them in C++ code.

PR: 42286
Submitted by: Davi Arnaut <davi haxent.com.br>
Reviewed by: rpluem


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@535169 13f79535-47bb-0310-9956-ffa450edef68
2007-05-04 11:11:26 +00:00
de659cbed0 update license header text
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@420983 13f79535-47bb-0310-9956-ffa450edef68
2006-07-11 20:33:53 +00:00
dd95d7c37c Update the copyright year in all .c, .h and .xml files
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@395228 13f79535-47bb-0310-9956-ffa450edef68
2006-04-19 12:11:27 +00:00
8c1e315d3f Doxygen fixup / cleanup
submited by: Neale Ranns neale ranns.org
reviewed by: Ian Holsman



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@263931 13f79535-47bb-0310-9956-ffa450edef68
2005-08-28 23:03:59 +00:00
ea08df890e Correct the function prototype/declaration
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@239732 13f79535-47bb-0310-9956-ffa450edef68
2005-08-24 19:06:40 +00:00
d6f8c966b0 Provide a function for closing all of the listeners.
* This is useful for properly implementing a graceful stop and restart
    where we want child processess to be able to carry on serving a request 
    but "de-listen" from a port. So that another instance entirely can be 
    started in our place, or to unbind from a "Listen" directive an admin 
    has removed from the configuration.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@239710 13f79535-47bb-0310-9956-ffa450edef68
2005-08-24 16:51:20 +00:00
6a23d6ebeb Merge the listen-protocol sandbox branch to trunk.
I will be adding documentation for the new directives hopefully in the next day or so.

* server/core.c: Added 'Protocol' to the core module config
                 Added ap_{set,get}_server_protocol API.
                 Added new directive: 'AcceptFilter'.
                 Enable 'httpready' by default on systems that support it.  Use dataready filters for others.

* server/listen.c: Attempt to inherit protocols from Listener Records to Server configs.
                   The 'Listen' directive can now optionally take a protocol arg
                   Move bits that determined which accept filter is applied to core.c.
                   Added bits to find the correct accept filter based on the core's configuration.

* include/{ap_listen.h,http_core.h}: Add Protocol to respective structures.

* include/http_core.h: Add the accf_map table to the core_server_config structure

* include/ap_mmn.h: Minor MMN Bump for the new interfacces.

* modules/ssl/ssl_engine_init.c: Use the new protocol framework to enable mod_ssl for 'https' websites.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@190563 13f79535-47bb-0310-9956-ffa450edef68
2005-06-14 09:21:18 +00:00
8f193f8538 The SPMT_OS2_MPM doesn't exist. The warning is also wrong, since both winnt and prefork MPMs call this function.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@168139 13f79535-47bb-0310-9956-ffa450edef68
2005-05-04 16:02:44 +00:00
a80f8410bd Add ReceiveBufferSize directive to control the TCP receive buffer.
Submitted by: Eric Covener <covener gmail.com>
Reviewed by:  Justin Erenkrantz (with minor formatting tweaks)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@157583 13f79535-47bb-0310-9956-ffa450edef68
2005-03-15 20:04:58 +00:00
905cdf9f0b Update copyright year to 2005 and standardize on current copyright owner line.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@151408 13f79535-47bb-0310-9956-ffa450edef68
2005-02-04 20:28:49 +00:00
a756d60d81 Fix gcc "no previous prototype" warnings after reorganisation:
* server/core_filters.c (ap_core_input_filter, ap_core_output_filter,
ap_net_time_filter): Renamed to add ap_ prefixes for global symbols.

* include/ap_listen.h: Don't export ap_listen_open at all, it's not
used outside server/listen.c any more.

* server/listen.c (open_listeners): Renamed from ap_listen_open.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@109498 13f79535-47bb-0310-9956-ffa450edef68
2004-12-02 13:28:04 +00:00
9bc839ed59 Declare the ap_set_listen* functions with AP_DECLARE_NONSTD for Win32 support.
(I think this is what is needed for Win32, but I'm not quite sure.)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@106988 13f79535-47bb-0310-9956-ffa450edef68
2004-11-30 06:29:56 +00:00
503cf34e74 Properly export ap_listen_* functions.
* server/listen.c: Add AP_DECLARE as appropriate.
* include/ap_listen.h: Add AP_DECLARE as appropriate.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@106843 13f79535-47bb-0310-9956-ffa450edef68
2004-11-28 19:37:41 +00:00
eeb57c17ad fix name of The Apache Software Foundation
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102619 13f79535-47bb-0310-9956-ffa450edef68
2004-02-09 20:40:53 +00:00
129635b965 fix copyright dates according to the first check in
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102548 13f79535-47bb-0310-9956-ffa450edef68
2004-02-07 19:27:57 +00:00
4f02cb1e18 apply Apache License, Version 2.0
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102525 13f79535-47bb-0310-9956-ffa450edef68
2004-02-06 22:58:42 +00:00
fb07607180 update license to 2004.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102135 13f79535-47bb-0310-9956-ffa450edef68
2004-01-01 13:26:26 +00:00
742af25096 finished that boring job:
update license to 2003.

Happy New Year! ;-))


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98573 13f79535-47bb-0310-9956-ffa450edef68
2003-02-03 17:53:28 +00:00
845cbfd508 Update our copyright for this year.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93918 13f79535-47bb-0310-9956-ffa450edef68
2002-03-13 20:48:07 +00:00
22eea3fa9c Fixed ap_listeners so that it will be included in the AWK generated export lists
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91948 13f79535-47bb-0310-9956-ffa450edef68
2001-11-14 18:19:32 +00:00
91aa604600 Allow modules that add sockets to the ap_listeners list to
define the function that should be used to accept on that
socket.  Each MPM can define their own function to use for
the accept function with the MPM_ACCEPT_FUNC macro.  This
also abstracts out all of the Unix accept error handling
logic, which has become out of synch across Unix MPMs.

The code flow is much easier now for different transports:

1)  During pre-config, post-config or while parsing the config
    file, add a socket to the ap_listeners list, making sure to
    define an accept function at the same time.

2)  MPMs find the correct listener, and call the accept function
    that was defined in step 1.

3)  That accept function returns a void pointer, which is passed
    to the create_connection hook.

4)  create_connection adds the correct low-level filters.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91916 13f79535-47bb-0310-9956-ffa450edef68
2001-11-13 22:42:38 +00:00
aefc6b1525 Remove commas from the end of the macros that define
directives that are used by MPMs.  Previous to this patch,
you would use these macros without commans, which was unlike
any other directives. Now, after the macro, you must have
a comma.  This makes the macros look more like the rest of the
directives.

I know this is cosmetic, and I was going to leave it alone, but when
I found out that it bothered Cliff too, I decided to fix it after all.

Submitted by:	Ryan Bloom and Cliff Woolley


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91896 13f79535-47bb-0310-9956-ffa450edef68
2001-11-13 06:04:25 +00:00
9692f107c1 *) Reimplement the Windows MPM (mpm_winnt.c) to eliminate calling
DuplicateHandle on an IOCompletionPort (a practice which
     MS "discourages"). The new model does not rely on associating
     the completion port with the listening sockets, thus the
     completion port can be completely managed within the child
     process.  A dedicated thread accepts connections off the network,
     then calls PostQueuedCompletionStatus() to wake up worker
     threads blocked on the completion port.
     [Bill Stoddard]


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88498 13f79535-47bb-0310-9956-ffa450edef68
2001-03-12 17:29:02 +00:00
381f88d56a Update copyright to 2001
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88184 13f79535-47bb-0310-9956-ffa450edef68
2001-02-16 04:26:53 +00:00
84fc13acf9 Include mpm.h so the tests for SPMT_OS2_MPM actually work.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87452 13f79535-47bb-0310-9956-ffa450edef68
2000-12-20 14:27:02 +00:00
b5440c348a Force all Apache functions to be linked into the executable, whether they
are used or not.  This uses the same mechanism that is used for APR
and APR-util.  This may not be the correct solution, but it works, and that
is what I really care about.  This also renames CHARSET_EBCDIC to
AP_CHARSET_EBCDIC.  This is for namespace correctness, but it also makes
the exports script a bit easier.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87424 13f79535-47bb-0310-9956-ffa450edef68
2000-12-19 17:05:48 +00:00
b43e31de42 tweak the responsibilities of make_sock() and alloc_listener()
because we need to resolve the hostname (i.e., call apr_getaddrinfo())
before creating the socket so that we get a socket of the appropriate
family

also, simplify some of the address displays in some error logs


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87371 13f79535-47bb-0310-9956-ffa450edef68
2000-12-16 14:49:18 +00:00
6af2db3795 Remove an unnecessary header file.
PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87152 13f79535-47bb-0310-9956-ffa450edef68
2000-12-01 23:26:04 +00:00
2318bf5ab4 Missed these first time round... More apr_port_t changes.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86867 13f79535-47bb-0310-9956-ffa450edef68
2000-11-08 11:42:21 +00:00
7b90751801 Change prefork to use the same listen api as the rest of the unix mpms
(ap_setup_listeners).  This eliminates the need to force a recompile of
listen.c when you switch to/from using prefork.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86179 13f79535-47bb-0310-9956-ffa450edef68
2000-09-08 14:59:46 +00:00
059d8dd212 prefix libapr functions and types with apr_
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85976 13f79535-47bb-0310-9956-ffa450edef68
2000-08-02 05:27:38 +00:00
24eefbcefe Document ap_listen.h using ScanDoc.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85935 13f79535-47bb-0310-9956-ffa450edef68
2000-07-29 18:23:38 +00:00
1610c8d4f5 OS/2: Put back creation of listeners in main thread in spmt_os2 MPM.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85856 13f79535-47bb-0310-9956-ffa450edef68
2000-07-16 07:12:42 +00:00
d2c1911754 Fix the prefork MPM to make it compile and work again out-of-the-box.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85832 13f79535-47bb-0310-9956-ffa450edef68
2000-07-13 16:05:07 +00:00
c481bb225a Move setup_listeners to listen.c. This renames it to ap_setup_listeners,
and removes the duplicated code from all effected MPMs.  The only this
doesn't touch, is Windows.  That MPM was using a different setup_listeners.
If one of the Windows guys would like to modify the WinNT MPM to use the
same setup_lsiteners, that would be VERY cool.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85809 13f79535-47bb-0310-9956-ffa450edef68
2000-07-10 21:37:23 +00:00
c0a4cb7873 More consification, correct command initialisation.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85599 13f79535-47bb-0310-9956-ffa450edef68
2000-06-17 16:29:53 +00:00
40b92feb96 Fixes to allow Apache to run as a Win95 service... highlights
main_win32.h : Moved delarations to a header, by request
  ap_listen.h :  References types declared in http_config.h
  http_main.h :  Add the Win32 flavor entry point declaration
  apr.hw :       Cleanup the redundancy department of redundancy 
  win32/proc.c : Double null termination was required here
  
  Everything else should be obvious and isolated to Win32.
  Build files will be committed seperately.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85253 13f79535-47bb-0310-9956-ffa450edef68
2000-05-19 05:01:53 +00:00
2a98ce1a7a Update to Apache Software License version 1.1
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84877 13f79535-47bb-0310-9956-ffa450edef68
2000-03-31 07:19:05 +00:00