"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "apache2/mod_qos.c" between
mod_qos-11.67.tar.gz and mod_qos-11.68.tar.gz

About: mod_qos is a quality of service module for the Apache web server implementing control mechanisms that can provide different priority to different HTTP requests (for e.g. to protect the server resources and to mitigate DOS attacks).

mod_qos.c  (mod_qos-11.67):mod_qos.c  (mod_qos-11.68)
skipping to change at line 45 skipping to change at line 45
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
*/ */
/************************************************************************ /************************************************************************
* Version * Version
***********************************************************************/ ***********************************************************************/
static const char revision[] = "$Id: mod_qos.c 2619 2021-08-06 20:12:30Z pbuchbi static const char revision[] = "$Id: mod_qos.c 2626 2021-09-20 18:55:41Z pbuchbi
nder $"; nder $";
static const char g_revision[] = "11.67"; static const char g_revision[] = "11.68";
/************************************************************************ /************************************************************************
* Includes * Includes
***********************************************************************/ ***********************************************************************/
/* std */ /* std */
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
skipping to change at line 1030 skipping to change at line 1030
unsigned int conn; unsigned int conn;
unsigned int tid; unsigned int tid;
unsigned int unique_id_counter; unsigned int unique_id_counter;
} qos_unique_id_t; } qos_unique_id_t;
/************************************************************************ /************************************************************************
* globals * globals
***********************************************************************/ ***********************************************************************/
module AP_MODULE_DECLARE_DATA qos_module; module AP_MODULE_DECLARE_DATA qos_module;
static int m_apache_2_4_49 = 0;
static int m_retcode = HTTP_INTERNAL_SERVER_ERROR; static int m_retcode = HTTP_INTERNAL_SERVER_ERROR;
static int m_worker_mpm = 1; // note: mod_qos is fully tested for Apache 2.2 wor ker MPM only static int m_worker_mpm = 1; // note: mod_qos is fully tested for Apache 2.2 wor ker MPM only
static int m_event_mpm = 0; static int m_event_mpm = 0;
static unsigned int m_hostcode = 0; static unsigned int m_hostcode = 0;
static int m_generation = 0; // parent process (restart generation) static int m_generation = 0; // parent process (restart generation)
static int m_qos_cc_partition = QSMOD; static int m_qos_cc_partition = QSMOD;
static qos_unique_id_t m_unique_id; static qos_unique_id_t m_unique_id;
static const char qos_basis_64[] = static const char qos_basis_64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
skipping to change at line 3517 skipping to change at line 3518
ap_get_status_line(500), CRLF CRLF, NULL); ap_get_status_line(500), CRLF CRLF, NULL);
apr_bucket *e = apr_bucket_pool_create(line, strlen(line), c->pool, c->bucket_ alloc); apr_bucket *e = apr_bucket_pool_create(line, strlen(line), c->pool, c->bucket_ alloc);
apr_bucket_brigade *bb = apr_brigade_create(c->pool, c->bucket_alloc); apr_bucket_brigade *bb = apr_brigade_create(c->pool, c->bucket_alloc);
c->keepalive = AP_CONN_CLOSE; c->keepalive = AP_CONN_CLOSE;
c->aborted = 1; c->aborted = 1;
if(c->cs) { if(c->cs) {
c->cs->state = CONN_STATE_LINGER; c->cs->state = CONN_STATE_LINGER;
} }
apr_table_set(c->notes, QS_CONN_ABORT, QS_CONN_ABORT); apr_table_set(c->notes, QS_CONN_ABORT, QS_CONN_ABORT);
if (m_apache_2_4_49 == 1) {
return DECLINED;
}
//apr_brigade_cleanup(bb);
APR_BRIGADE_INSERT_HEAD(bb, e); APR_BRIGADE_INSERT_HEAD(bb, e);
e = apr_bucket_flush_create(c->bucket_alloc); e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
ap_pass_brigade(c->output_filters, bb); ap_pass_brigade(c->output_filters, bb);
// e = apr_bucket_flush_create(c->bucket_alloc);
// APR_BRIGADE_INSERT_TAIL(bb, e);
// if(socket) { // if(socket) {
// // speed up connection termination // // speed up connection termination
// qos_ifctx_t *inctx = qos_get_ifctx(c->input_filters); // qos_ifctx_t *inctx = qos_get_ifctx(c->input_filters);
//#ifdef QS_INTERNAL_TEST //#ifdef QS_INTERNAL_TEST
// struct timespec delay; // struct timespec delay;
// delay.tv_sec = 0; // delay.tv_sec = 0;
// delay.tv_nsec = 1000000; // 1ms to allow testing // delay.tv_nsec = 1000000; // 1ms to allow testing
// nanosleep(&delay, NULL); // nanosleep(&delay, NULL);
//#endif //#endif
skipping to change at line 6317 skipping to change at line 6320
eventSet = get_qs_event(r, eventName); eventSet = get_qs_event(r, eventName);
if(eventSet) { if(eventSet) {
char *seenEvent; char *seenEvent;
if(strcasecmp(eventName, QS_LIMIT_DEFAULT) == 0) { if(strcasecmp(eventName, QS_LIMIT_DEFAULT) == 0) {
// backward compat/event forwarding // backward compat/event forwarding
seenEvent = apr_pstrcat(r->pool, QS_LIMIT_SEEN, NULL); seenEvent = apr_pstrcat(r->pool, QS_LIMIT_SEEN, NULL);
} else { } else {
seenEvent = apr_pstrcat(r->pool, QS_LIMIT_SEEN, eventName, NULL); seenEvent = apr_pstrcat(r->pool, QS_LIMIT_SEEN, eventName, NULL);
} }
if(apr_table_get(r->subprocess_env, seenEvent) == NULL) { if(apr_table_get(r->subprocess_env, seenEvent) == NULL) {
// first occurrance // first occurrence
apr_table_set(r->subprocess_env, seenEvent, ""); apr_table_set(r->subprocess_env, seenEvent, "");
if((*clientEntryFromHdr)->limit[limitTableIndex].limit == 0) { if((*clientEntryFromHdr)->limit[limitTableIndex].limit == 0) {
/* .start timer */ /* .start timer */
(*clientEntryFromHdr)->limit[limitTableIndex].limitTime = now; (*clientEntryFromHdr)->limit[limitTableIndex].limitTime = now;
} }
/* increment limit event */ /* increment limit event */
(*clientEntryFromHdr)->limit[limitTableIndex].limit += eventSet; (*clientEntryFromHdr)->limit[limitTableIndex].limit += eventSet;
} }
} }
skipping to change at line 6994 skipping to change at line 6997
unsigned long search = *pA; unsigned long search = *pA;
if((search >= pB->start) && (search <= pB->end)) return 0; if((search >= pB->start) && (search <= pB->end)) return 0;
if(search > pB->start) return 1; if(search > pB->start) return 1;
if(search < pB->start) return -1; if(search < pB->start) return -1;
return -1; // error return -1; // error
} }
/** /**
* Translates an IP address (from geo csv) to a numeric value. * Translates an IP address (from geo csv) to a numeric value.
* *
* @param pool To dup the string whike parsing. * @param pool To dup the string while parsing.
* @param ip * @param ip
* @return * @return
*/ */
static unsigned long qos_geo_str2long(apr_pool_t *pool, const char *ip) { static unsigned long qos_geo_str2long(apr_pool_t *pool, const char *ip) {
char *p; char *p;
char *i = apr_pstrdup(pool, ip); char *i = apr_pstrdup(pool, ip);
unsigned long addr = 0; unsigned long addr = 0;
p = strchr(i, '.'); p = strchr(i, '.');
if(!p) return 0; if(!p) return 0;
skipping to change at line 8124 skipping to change at line 8127
if(strcasecmp(ap_show_mpm(), "prefork") == 0) { if(strcasecmp(ap_show_mpm(), "prefork") == 0) {
// mod_qos is fully tested for MPM worker (and works with event) // mod_qos is fully tested for MPM worker (and works with event)
m_worker_mpm = 0; // disable child cleanup m_worker_mpm = 0; // disable child cleanup
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, bs, ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, bs,
QOS_LOG_PFX(009)"loaded MPM is '%s'" QOS_LOG_PFX(009)"loaded MPM is '%s'"
" but mod_qos should be used with MPM 'Worker' or 'Event' only. ", " but mod_qos should be used with MPM 'Worker' or 'Event' only. ",
ap_show_mpm()); ap_show_mpm());
} }
ap_get_server_revision(&version); ap_get_server_revision(&version);
if(version.major == 2 && version.minor == 4 && version.patch >= 49) {
// compat: prevents Apache segfault on connection close
m_apache_2_4_49 = 1;
}
if(version.major != 2 || (version.minor != 2 && version.minor != 4)) { if(version.major != 2 || (version.minor != 2 && version.minor != 4)) {
// 2.2 and 2.4 should be ok / older or newer versions are not tested // 2.2 and 2.4 should be ok / older or newer versions are not tested
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, bs, ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, bs,
QOS_LOG_PFX(009)"server version is %d.%d" QOS_LOG_PFX(009)"server version is %d.%d"
" but mod_qos should be used with Apache 2.2 or 2.4 only.", " but mod_qos should be used with Apache 2.2 or 2.4 only.",
version.major, version.minor); version.major, version.minor);
} }
} }
/** /**
skipping to change at line 8751 skipping to change at line 8758
QS_CONN_REMOTEIP(c) == NULL ? "-" : QS_CONN_REMOTEIP(c)); QS_CONN_REMOTEIP(c) == NULL ? "-" : QS_CONN_REMOTEIP(c));
} }
if(!sconf->log_only) { if(!sconf->log_only) {
apr_table_set(c->notes, QS_BLOCK_SEEN, ""); // suppress NullConnection messages apr_table_set(c->notes, QS_BLOCK_SEEN, ""); // suppress NullConnection messages
c->keepalive = AP_CONN_CLOSE; c->keepalive = AP_CONN_CLOSE;
c->aborted = 1; c->aborted = 1;
if(c->cs) { if(c->cs) {
c->cs->state = CONN_STATE_LINGER; c->cs->state = CONN_STATE_LINGER;
} }
apr_table_set(c->notes, QS_CONN_ABORT, QS_CONN_ABORT); apr_table_set(c->notes, QS_CONN_ABORT, QS_CONN_ABORT);
ret = m_retcode; if (m_apache_2_4_49 == 1) {
ret = DECLINED;
} else {
ret = m_retcode;
}
} }
} else { } else {
/* release */ /* release */
if((*clientEntry)->blockMsg > QS_LOG_REPEAT) { if((*clientEntry)->blockMsg > QS_LOG_REPEAT) {
// write remaining log lines // write remaining log lines
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, c->base_server, ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, c->base_server,
QOS_LOG_PFX(060)"access denied (previously), QS_ClientEve ntBlockCount rule: " QOS_LOG_PFX(060)"access denied (previously), QS_ClientEve ntBlockCount rule: "
"max=%d, current=%d, " "max=%d, current=%d, "
"message repeated %d times, " "message repeated %d times, "
"c=%s", "c=%s",
skipping to change at line 14738 skipping to change at line 14749
" Deletes the header if the action 'drop' has been specified.") , " Deletes the header if the action 'drop' has been specified.") ,
AP_INIT_TAKE2("QS_SetEnvResHeaderMatch", qos_event_setenvresheadermatch_cmd, N ULL, AP_INIT_TAKE2("QS_SetEnvResHeaderMatch", qos_event_setenvresheadermatch_cmd, N ULL,
RSRC_CONF, RSRC_CONF,
"QS_SetEnvResHeaderMatch <header name> <regex>, sets the defined " "QS_SetEnvResHeaderMatch <header name> <regex>, sets the defined "
" HTTP response header to the request environment variables" " HTTP response header to the request environment variables"
" if the specified regular expression (pcre) matches the header value."), " if the specified regular expression (pcre) matches the header value."),
AP_INIT_TAKE3("QS_SetEnvRes", qos_setenvres_cmd, NULL, AP_INIT_TAKE3("QS_SetEnvRes", qos_setenvres_cmd, NULL,
RSRC_CONF, RSRC_CONF,
"QS_SetEnvRes <variable> <regex> <variable2>[=<value>], sets the environmet" "QS_SetEnvRes <variable> <regex> <variable2>[=<value>], sets the environment"
" variable2 if the regular expression matches against the value of" " variable2 if the regular expression matches against the value of"
" the environment variable. Occurrences of $1..$9 within the val ue" " the environment variable. Occurrences of $1..$9 within the val ue"
" and replace them by parenthesized subexpressions of the regula r expression."), " and replace them by parenthesized subexpressions of the regula r expression."),
AP_INIT_TAKE3("QS_RedirectIf", qos_redirectif_cmd, NULL, AP_INIT_TAKE3("QS_RedirectIf", qos_redirectif_cmd, NULL,
RSRC_CONF|ACCESS_CONF, RSRC_CONF|ACCESS_CONF,
"QS_RedirectIf <variable> <regex> [<code>:]<url>," "QS_RedirectIf <variable> <regex> [<code>:]<url>,"
" redirects the client to the configured url" " redirects the client to the configured url"
" if the regular expression matches" " if the regular expression matches"
" the value of the the environment variable."), " the value of the the environment variable."),
skipping to change at line 15015 skipping to change at line 15026
/************************************************************************ /************************************************************************
* apache module definition * apache module definition
***********************************************************************/ ***********************************************************************/
module AP_MODULE_DECLARE_DATA qos_module ={ module AP_MODULE_DECLARE_DATA qos_module ={
STANDARD20_MODULE_STUFF, STANDARD20_MODULE_STUFF,
qos_dir_config_create, /**< dir config creator */ qos_dir_config_create, /**< dir config creator */
qos_dir_config_merge, /**< dir merger */ qos_dir_config_merge, /**< dir merger */
qos_srv_config_create, /**< server config */ qos_srv_config_create, /**< server config */
qos_srv_config_merge, /**< server merger */ qos_srv_config_merge, /**< server merger */
qos_config_cmds, /**< command table */ qos_config_cmds, /**< command table */
qos_register_hooks, /**< hook registery */ qos_register_hooks, /**< hook registration */
}; };
 End of changes. 11 change blocks. 
10 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)