REORG: tcp-rules: move tcp rules processing to their own file

There's no more reason to keep tcp rules processing inside proto_tcp.c
given that there is nothing in common there except these 3 letters : tcp.
The tcp rules are in fact connection, session and content processing rules.
Let's move them to "tcp-rules" and let them live their life there.
This commit is contained in:
Willy Tarreau 2016-11-25 15:49:32 +01:00
parent d39ad449b9
commit 397131093f
11 changed files with 1264 additions and 1190 deletions

View File

@ -771,7 +771,7 @@ OBJS = src/haproxy.o src/base64.o src/protocol.o \
src/time.o src/fd.o src/pipe.o src/regex.o src/cfgparse.o src/server.o \
src/checks.o src/queue.o src/frontend.o src/proxy.o src/peers.o \
src/arg.o src/stick_table.o src/proto_uxst.o src/connection.o \
src/proto_http.o src/raw_sock.o src/backend.o \
src/proto_http.o src/raw_sock.o src/backend.o src/tcp_rules.o \
src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o src/lb_fas.o \
src/stream_interface.o src/stats.o src/proto_tcp.o src/applet.o \
src/session.o src/stream.o src/hdr_idx.o src/ev_select.o src/signal.o \

View File

@ -36,29 +36,10 @@ int tcp_connect_probe(struct connection *conn);
int tcp_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
int tcp_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
int tcp_drain(int fd);
int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit);
int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit);
int tcp_exec_l4_rules(struct session *sess);
int tcp_exec_l5_rules(struct session *sess);
/* TCP keywords. */
void tcp_req_conn_keywords_register(struct action_kw_list *kw_list);
void tcp_req_sess_keywords_register(struct action_kw_list *kw_list);
void tcp_req_cont_keywords_register(struct action_kw_list *kw_list);
void tcp_res_cont_keywords_register(struct action_kw_list *kw_list);
/* Export some samples. */
int smp_fetch_src(const struct arg *args, struct sample *smp, const char *kw, void *private);
/* for a tcp-request action ACT_TCP_TRK_*, return a tracking index starting at
* zero for SC0. Unknown actions also return zero.
*/
static inline int tcp_trk_idx(int trk_action)
{
return trk_action - ACT_ACTION_TRK_SC0;
}
#endif /* _PROTO_PROTO_TCP_H */
/*

55
include/proto/tcp_rules.h Normal file
View File

@ -0,0 +1,55 @@
/*
* include/proto/tcp_rules.h
* This file contains "tcp" rules definitions
*
* Copyright (C) 2000-2016 Willy Tarreau - w@1wt.eu
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, version 2.1
* exclusively.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _PROTO_TCP_RULES_H
#define _PROTO_TCP_RULES_H
#include <common/config.h>
#include <types/action.h>
#include <types/task.h>
#include <proto/stick_table.h>
int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit);
int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit);
int tcp_exec_l4_rules(struct session *sess);
int tcp_exec_l5_rules(struct session *sess);
void tcp_req_conn_keywords_register(struct action_kw_list *kw_list);
void tcp_req_sess_keywords_register(struct action_kw_list *kw_list);
void tcp_req_cont_keywords_register(struct action_kw_list *kw_list);
void tcp_res_cont_keywords_register(struct action_kw_list *kw_list);
/* for a tcp-request action ACT_TCP_TRK_*, return a tracking index starting at
* zero for SC0. Unknown actions also return zero.
*/
static inline int tcp_trk_idx(int trk_action)
{
return trk_action - ACT_ACTION_TRK_SC0;
}
#endif /* _PROTO_TCP_RULES_H */
/*
* Local variables:
* c-indent-level: 8
* c-basic-offset: 8
* End:
*/

View File

@ -81,8 +81,9 @@
#include <proto/server.h>
#include <proto/stream.h>
#include <proto/raw_sock.h>
#include <proto/task.h>
#include <proto/stick_table.h>
#include <proto/task.h>
#include <proto/tcp_rules.h>
#ifdef USE_OPENSSL
#include <types/ssl_sock.h>

View File

@ -44,7 +44,6 @@
#include <proto/pattern.h>
#include <proto/payload.h>
#include <proto/proto_http.h>
#include <proto/proto_tcp.h>
#include <proto/raw_sock.h>
#include <proto/sample.h>
#include <proto/server.h>
@ -53,6 +52,7 @@
#include <proto/ssl_sock.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
#include <proto/tcp_rules.h>
#include <proto/vars.h>
/* Lua uses longjmp to perform yield or throwing errors. This

File diff suppressed because it is too large Load Diff

View File

@ -22,11 +22,11 @@
#include <proto/listener.h>
#include <proto/log.h>
#include <proto/proto_http.h>
#include <proto/proto_tcp.h>
#include <proto/proxy.h>
#include <proto/raw_sock.h>
#include <proto/session.h>
#include <proto/stream.h>
#include <proto/tcp_rules.h>
#include <proto/vars.h>
struct pool_head *pool2_session;

View File

@ -24,12 +24,12 @@
#include <ebsttree.h>
#include <types/cli.h>
#include <types/global.h>
#include <types/stats.h>
#include <proto/arg.h>
#include <proto/cli.h>
#include <proto/proto_http.h>
#include <proto/proto_tcp.h>
#include <proto/proxy.h>
#include <proto/sample.h>
#include <proto/stream.h>
@ -37,7 +37,7 @@
#include <proto/stick_table.h>
#include <proto/task.h>
#include <proto/peers.h>
#include <types/global.h>
#include <proto/tcp_rules.h>
/* structure used to return a table key built from a sample */
struct stktable_key *static_table_key;

View File

@ -57,6 +57,7 @@
#include <proto/stick_table.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
#include <proto/tcp_rules.h>
#include <proto/vars.h>
struct pool_head *pool2_stream;

1196
src/tcp_rules.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,9 +7,9 @@
#include <proto/arg.h>
#include <proto/proto_http.h>
#include <proto/proto_tcp.h>
#include <proto/sample.h>
#include <proto/stream.h>
#include <proto/tcp_rules.h>
#include <proto/vars.h>
/* This contains a pool of struct vars */