Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / include / net / tux.h
1 #ifndef _NET_TUX_H
2 #define _NET_TUX_H
3
4 /*
5  * TUX - Integrated Application Protocols Layer and Object Cache
6  *
7  * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
8  *
9  * tux.h: main structure definitions and function prototypes
10  */
11
12 #define __KERNEL_SYSCALLS__
13
14 #include <linux/mm.h>
15 #include <linux/net.h>
16 #include <linux/wait.h>
17 #include <linux/namei.h>
18 #include <linux/file.h>
19 #include <linux/mman.h>
20 #include <linux/swap.h>
21 #include <linux/ctype.h>
22 #include <linux/config.h>
23 #include <linux/module.h>
24 #include <linux/kernel.h>
25 #include <linux/unistd.h>
26 #include <linux/sysctl.h>
27 #include <linux/proc_fs.h>
28 #include <linux/pagemap.h>
29 #include <linux/vmalloc.h>
30 #include <linux/utsname.h>
31 #include <linux/smp_lock.h>
32 #include <linux/kernel_stat.h>
33 #include <linux/kernel_stat.h>
34 #include <linux/time.h>
35 #include <asm/div64.h>
36 #include <asm/unaligned.h>
37 #include <linux/compiler.h>
38 #include <linux/mount.h>
39 #include <linux/zlib.h>
40 #include <linux/syscalls.h>
41 #include <linux/cpumask.h>
42
43 #include <net/tcp.h>
44 #include <net/tux_u.h>
45
46 /* Maximum number of threads: */
47 #define CONFIG_TUX_NUMTHREADS 16
48
49 /* Number of cachemiss/IO threads: */
50 #define NR_IO_THREADS 64
51
52 /* Maximum number of listen sockets per thread: */
53 #define CONFIG_TUX_NUMSOCKETS 16
54
55 extern spinlock_t tux_module_lock;
56 extern struct module *tux_module;
57 extern asmlinkage long (*sys_tux_ptr) (unsigned int action, user_req_t *u_info);
58
59 #undef Dprintk
60
61 extern int tux_TDprintk;
62 extern int tux_Dprintk;
63
64 #ifdef CONFIG_TUX_DEBUG
65 # define TUX_BUG() BUG()
66
67 # define TUX_DPRINTK 1
68 # define TDprintk(x...) do { if (tux_TDprintk) { printk("<%ld:%s:%d>: ", jiffies, __FILE__, __LINE__); printk(x); } } while (0)
69 # define Dprintk(x...) do { if (tux_Dprintk == 1) TDprintk(x); } while (0)
70 #else
71 # define TUX_DPRINTK 0
72 # define Dprintk(x...) do { } while (0)
73 # define TDprintk(x...) do { } while (0)
74 //# define TUX_BUG() BUG()
75 # define TUX_BUG() do { } while (0)
76 #endif
77
78 #if 1
79 # define INC_STAT(x) do { } while (0)
80 # define DEC_STAT(x) do { } while (0)
81 # define ADD_STAT(x,y) do { } while (0)
82 # define SUB_STAT(x,y) do { } while (0)
83 #else
84 # define INC_STAT(x) atomic_inc((atomic_t *)&kstat.x)
85 # define DEC_STAT(x) atomic_dec((atomic_t *)&kstat.x)
86 # define ADD_STAT(y,x) atomic_add(y,(atomic_t *)&kstat.x)
87 # define SUB_STAT(y,x) atomic_sub(y,(atomic_t *)&kstat.x)
88 #endif
89
90 // lru needs this:
91
92 # define DEBUG_DEL_LIST(x...) do { INIT_LIST_HEAD((x)); } while (0)
93
94
95 #define LOG_LEN (8*1024*1024UL)
96
97 struct tux_req_struct;
98 typedef struct tux_req_struct tux_req_t;
99 typedef struct tux_threadinfo threadinfo_t;
100
101 extern struct address_space_operations url_aops;
102
103 typedef struct tcapi_template_s {
104         char *vfs_name;
105         struct list_head modules;
106         int (*query) (tux_req_t *req);
107         struct module *mod;
108         unsigned int userspace_id;
109 } tcapi_template_t;
110
111 typedef struct mimetype_s {
112         struct list_head list;
113
114         char *ext;
115         unsigned int ext_len;
116         char *type;
117         unsigned int type_len;
118         char *expire_str;
119         unsigned int expire_str_len;
120
121         unsigned int special;
122 } mimetype_t;
123
124 typedef struct tux_attribute_s {
125         mimetype_t *mime;
126         tcapi_template_t *tcapi;
127 } tux_attribute_t;
128
129 #define MAX_TUX_ATOMS 8
130
131 typedef void (atom_func_t)(tux_req_t *req, int cachemiss);
132
133 typedef struct tux_proto_s
134 {
135         unsigned int defer_accept;
136         unsigned int can_redirect;
137         void (*got_request) (tux_req_t *req);
138         int (*parse_message) (tux_req_t *req, const int total_len);
139         atom_func_t *illegal_request;
140         atom_func_t *request_timeout;
141         void (*pre_log) (tux_req_t *req);
142         int (*check_req_err) (tux_req_t *req, int cachemiss);
143         char * (*print_dir_line) (tux_req_t *req, char *tmp, char *d_name, int d_len, int d_type, struct dentry *dentry, struct inode *inode);
144         const char *name;
145         struct nameidata main_docroot;
146 } tux_proto_t;
147
148 typedef struct tux_socket_s {
149         tux_proto_t *proto;
150         unsigned int ip;
151         unsigned short port;
152         struct proc_dir_entry *entry;
153 } tux_socket_t;
154
155 extern tux_socket_t tux_listen [CONFIG_TUX_NUMTHREADS][CONFIG_TUX_NUMSOCKETS];
156
157
158 typedef struct abuf_s {
159         struct page *page;
160         char *buf;
161         unsigned int size;
162         unsigned int max_len;
163         unsigned int offset;
164         unsigned int left;
165         unsigned long flags;
166 } abuf_t;
167
168 struct linux_dirent64 {
169         u64             d_ino;
170         s64             d_off;
171         unsigned short  d_reclen;
172         unsigned char   d_type;
173         char            d_name[0];
174 };
175
176 struct getdents_callback64 {
177         struct linux_dirent64 * current_dir;
178         struct linux_dirent64 * previous;
179         int count;
180         int error;
181 };
182
183 #define TUX_MAGIC 0x12457801
184
185 #define MAX_TUX_ATOMS 8
186
187 struct tux_req_struct
188 {
189         tux_proto_t *proto;
190
191         int atom_idx;
192         atom_func_t *atoms [MAX_TUX_ATOMS];
193         struct list_head work;
194
195         struct list_head all;
196         struct list_head free;
197         struct list_head lru;
198
199         unsigned long idle_input;
200         unsigned long wait_output_space;
201
202         struct socket *sock;
203         struct dentry *dentry;
204         struct vfsmount *mnt;
205         struct dentry *docroot_dentry;
206         struct vfsmount *docroot_mnt;
207         struct dentry *cwd_dentry;
208         struct vfsmount *cwd_mnt;
209
210         struct file *in_file;
211         int fd;
212         read_descriptor_t desc;
213         u32 client_addr;
214         u32 client_port;
215         unsigned int virtual;
216
217         loff_t total_file_len;
218         unsigned int lendigits;
219         loff_t offset_start;
220         loff_t offset_end;
221         loff_t output_len;
222
223         loff_t ftp_offset_start;
224
225         time_t mtime;
226         unsigned int etaglen;
227         char etag [40];
228
229         char usermode;
230         unsigned int usermodule_idx;
231         struct dentry *module_dentry;
232         struct vfsmount *module_mnt;
233         char *userbuf;
234         unsigned int userlen;
235
236         tux_attribute_t *attr;
237
238         threadinfo_t *ti;
239         wait_queue_t sleep;
240         wait_queue_t ftp_sleep;
241
242         abuf_t abuf;
243         /*
244          * Parsed request fields. In-line strings are zero-delimited.
245          */
246         const char *headers;
247         unsigned int headers_len;
248
249         unsigned int parsed_len;
250
251         // FTP part
252         ftp_command_t ftp_command;
253         u32 ftp_user_addr;
254         u16 ftp_user_port;
255
256         struct socket *data_sock;
257         unsigned int prev_pos;
258
259         // ls handing:
260         struct linux_dirent64 *dirp0;
261         unsigned int curroff, total;
262
263 #define MAX_USERNAME_LEN 16
264         char username[MAX_USERNAME_LEN];
265         unsigned int username_len;
266
267         // HTTP part
268         http_method_t method;
269         const char *method_str;
270         unsigned int method_len;
271
272         http_version_t version;
273         const char *version_str;
274         unsigned int version_len;
275
276         /* requested URI: */
277
278         const char *uri_str;
279         unsigned int uri_len;
280
281         /* Objectname (filename/scriptname) this URI refers to: */
282
283 #define MAX_OBJECTNAME_LEN 256
284         char objectname[MAX_OBJECTNAME_LEN + 4]; // space for .gz as well
285         unsigned int objectname_len;
286
287         /* Query string within the URI: */
288
289         const char *query_str;
290         unsigned int query_len;
291
292         /* Cookies: */
293
294         const char *cookies_str;
295         unsigned int cookies_len;
296         unsigned int parse_cookies;
297
298         /* Content-TYpe */
299         const char *content_type_str;
300         unsigned int content_type_len;
301
302         /* Content-Length: */
303
304         const char *contentlen_str;
305         unsigned int contentlen_len;
306         unsigned int content_len;
307
308         /* User-Agent: */
309
310         const char *user_agent_str;
311         unsigned int user_agent_len;
312
313         /* Accept: */
314
315         const char *accept_str;
316         unsigned int accept_len;
317
318         /* Accept-Charset: */
319
320         const char *accept_charset_str;
321         unsigned int accept_charset_len;
322
323         /* Accept-Language: */
324
325         const char *accept_language_str;
326         unsigned int accept_language_len;
327
328         /* Cache-Control: */
329
330         const char *cache_control_str;
331         unsigned int cache_control_len;
332
333         /* If-Modified-Since: */
334
335         const char *if_modified_since_str;
336         unsigned int if_modified_since_len;
337
338         /* If-None-Match: */
339         const char *if_none_match_str;
340         unsigned int if_none_match_len;
341
342         /* If-Range: */
343
344         const char *if_range_str;
345         unsigned int if_range_len;
346
347         /* Negotiate: */
348
349         const char *negotiate_str;
350         unsigned int negotiate_len;
351
352         /* Pragma: */
353
354         const char *pragma_str;
355         unsigned int pragma_len;
356
357         /* Referer: */
358
359         const char *referer_str;
360         unsigned int referer_len;
361
362         /* Accept-Encoding: */
363
364         const char *accept_encoding_str;
365         unsigned int accept_encoding_len;
366         unsigned int may_send_gzip;
367         unsigned int content_gzipped;
368
369         /* Host */
370
371 #define MAX_HOST_LEN 128
372         char host[MAX_HOST_LEN];
373         unsigned int host_len;
374
375         /* POSTed data: */
376
377         const char *post_data_str;
378         unsigned int post_data_len;
379
380         unsigned int status;
381
382         /* the file being sent */
383
384         unsigned int bytes_sent;
385 #ifdef CONFIG_TUX_DEBUG
386         unsigned int bytes_expected;
387 #endif
388         unsigned long first_timestamp;
389         unsigned int body_len;
390
391         unsigned int user_error;
392
393         char error;
394         char postponed;
395
396         char had_cachemiss;
397         char lookup_dir;
398         char lookup_404;
399
400         char keep_alive;
401         struct timer_list keepalive_timer;
402         unsigned int total_bytes;
403         struct timer_list output_timer;
404
405         unsigned int nr_keepalives;
406
407         unsigned int event;
408         u64 private;
409
410         unsigned int magic;
411         void (*real_data_ready)(struct sock *sk, int space);
412         void (*real_state_change)(struct sock *sk);
413         void (*real_write_space)(struct sock *sk);
414         void (*real_error_report)(struct sock *sk);
415         void (*real_destruct)(struct sock *sk);
416
417         void (*ftp_real_data_ready)(struct sock *sk, int space);
418         void (*ftp_real_state_change)(struct sock *sk);
419         void (*ftp_real_write_space)(struct sock *sk);
420         void (*ftp_real_error_report)(struct sock *sk);
421         void (*ftp_real_create_child)(struct sock *sk, struct sock *newsk);
422         void (*ftp_real_destruct)(struct sock *sk);
423
424 #ifdef CONFIG_TUX_EXTENDED_LOG
425         unsigned long accept_timestamp;
426         unsigned long parse_timestamp;
427         unsigned long output_timestamp;
428         unsigned long flush_timestamp;
429 # define SET_TIMESTAMP(x) do { (x) = jiffies; } while (0)
430 #else
431 # define SET_TIMESTAMP(x) do { } while (0)
432 #endif
433
434 };
435
436 extern void add_tux_atom (tux_req_t *req, atom_func_t *event_done);
437 extern void del_tux_atom (tux_req_t *req);
438 extern void tux_schedule_atom (tux_req_t *req, int cachemiss);
439 extern void add_req_to_workqueue (tux_req_t *req);
440
441
442 typedef struct iothread_s
443 {
444         spinlock_t async_lock;
445         threadinfo_t *ti;
446         struct list_head async_queue;
447         wait_queue_head_t async_sleep;
448         unsigned int nr_async_pending;
449         unsigned int threads;
450         unsigned int shutdown;
451         wait_queue_head_t wait_shutdown;
452 } iothread_t;
453
454 typedef struct tux_listen_s
455 {
456         tux_proto_t *proto;
457         struct socket *sock;
458         unsigned int cloned;
459 } tux_listen_t;
460
461 struct tux_threadinfo
462 {
463         tux_req_t *userspace_req;
464         unsigned int started;
465         struct task_struct *thread;
466         iothread_t *iot;
467         wait_queue_t wait_event [CONFIG_TUX_NUMSOCKETS];
468         wait_queue_t stop;
469         unsigned int pid;
470
471         struct page *header_cache;
472         unsigned int header_offset;
473
474         unsigned int nr_requests;
475         struct list_head all_requests;
476
477         unsigned int nr_free_requests;
478         spinlock_t free_requests_lock;
479         struct list_head free_requests;
480
481         spinlock_t work_lock;
482         struct list_head work_pending;
483         struct list_head lru;
484         unsigned int nr_lru;
485
486         unsigned int listen_error;
487         tux_listen_t listen[CONFIG_TUX_NUMSOCKETS];
488
489         struct semaphore gzip_sem;
490         z_stream gzip_state;
491
492         unsigned int cpu;
493         unsigned int __padding[16];
494 };
495
496 typedef enum special_mimetypes {
497         NORMAL_MIME_TYPE,
498         MIME_TYPE_REDIRECT,
499         MIME_TYPE_CGI,
500         MIME_TYPE_MODULE,
501 } special_mimetypes_t;
502
503 #ifdef CONFIG_TUX_DEBUG
504 #if 0
505 extern inline void url_hist_hit (int size)
506 {
507         unsigned int idx = size/1024;
508
509         if (idx >= URL_HIST_SIZE)
510                 idx = URL_HIST_SIZE-1;
511         kstat.url_hist_hits[idx]++;
512 }
513 extern inline void url_hist_miss (int size)
514 {
515         unsigned int idx = size/1024;
516
517         if (idx >= URL_HIST_SIZE)
518                 idx = URL_HIST_SIZE-1;
519         kstat.url_hist_misses[idx]++;
520 }
521 #endif
522 extern void __check_req_list (tux_req_t *req, struct list_head *list);
523 # define check_req_list __check_req_list
524 #else
525 # define check_req_list(req, list) do { } while (0)
526 #endif
527
528 #define url_hist_hit(size) do { } while (0)
529 #define url_hist_miss(size) do { } while (0)
530
531 extern char tux_common_docroot[200];
532 extern char tux_http_subdocroot[200];
533 extern char tux_ftp_subdocroot[200];
534 extern char tux_logfile[200];
535 extern char tux_cgiroot[200];
536 extern char tux_404_page[200];
537 extern char tux_default_vhost[200];
538 extern char tux_extra_html_header[600];
539 extern unsigned int tux_extra_html_header_size;
540 extern int tux_cgi_uid;
541 extern int tux_cgi_gid;
542 extern unsigned int tux_clientport;
543 extern unsigned int tux_logging;
544 extern unsigned int tux_threads;
545 extern unsigned int tux_keepalive_timeout;
546 extern unsigned int tux_max_output_bandwidth;
547 extern unsigned int tux_max_backlog;
548 extern unsigned int tux_max_connect;
549 extern unsigned int tux_mode_forbidden;
550 extern unsigned int tux_mode_allowed;
551 extern unsigned int tux_logentry_align_order;
552 extern unsigned int tux_nonagle;
553 extern unsigned int tux_ack_pingpong;
554 extern unsigned int tux_push_all;
555 extern unsigned int tux_zerocopy_parse;
556 extern unsigned int tux_generate_etags;
557 extern unsigned int tux_generate_last_mod;
558 extern unsigned int tux_generate_cache_control;
559 extern unsigned int tux_ip_logging;
560 extern unsigned int tux_ftp_wait_close;
561 extern unsigned int tux_ftp_log_retr_only;
562 extern unsigned int tux_hide_unreadable;
563
564 typedef enum virtual_server {
565         TUX_VHOST_NONE,
566         TUX_VHOST_HOST,
567         TUX_VHOST_IP,
568         TUX_VHOST_IP_HOST,
569 } virtual_server_t;
570
571 extern unsigned int tux_virtual_server;
572 extern unsigned int mass_hosting_hash;
573 extern unsigned int strip_host_tail;
574 extern unsigned int tux_ftp_virtual_server;
575
576 extern unsigned int tux_max_object_size;
577 extern unsigned int tux_max_free_requests;
578 extern unsigned int tux_defer_accept;
579
580 extern struct socket * start_listening(tux_socket_t *listen, int nr);
581 extern void stop_listening(struct socket **sock);
582 extern void start_sysctl(void);
583 extern void end_sysctl(void);
584 extern void flush_request (tux_req_t *req, int cachemiss);
585 extern void unlink_tux_socket (tux_req_t *req);
586 extern void unlink_tux_data_socket (tux_req_t *req);
587 extern void unlink_tux_listen_socket (tux_req_t *req);
588 extern void link_tux_ftp_accept_socket (tux_req_t *req, struct socket *sock);
589 extern void link_tux_data_socket (tux_req_t *req, struct socket *sock);
590 extern void tux_push_req (tux_req_t *req);
591 extern int send_sync_buf (tux_req_t *req, struct socket *sock, const char *buf, const size_t length, unsigned long flags);
592 extern void __send_async_message (tux_req_t *req, const char *message, int status, unsigned int size, int push);
593 #define send_async_message(req,str,status,push) \
594                 __send_async_message(req,str,status,strlen(str),push)
595
596 extern void send_success (tux_req_t *req, struct socket *sock);
597 extern void send_async_err_not_found (tux_req_t *req);
598 extern void send_async_timed_out (tux_req_t *req);
599
600 extern void kfree_req (tux_req_t *req);
601 extern int accept_requests (threadinfo_t *ti);
602 extern int process_requests (threadinfo_t *ti, tux_req_t **user_req);
603 extern int flush_freequeue (threadinfo_t * ti);
604 extern int tux_flush_workqueue (threadinfo_t *ti);
605 extern tux_req_t * pick_userspace_req (threadinfo_t *ti);
606 extern atom_func_t redirect_request;
607 extern atom_func_t parse_request;
608 extern void queue_cachemiss (tux_req_t *req);
609 extern int start_cachemiss_threads (threadinfo_t *ti);
610 extern void stop_cachemiss_threads (threadinfo_t *ti);
611 struct file * tux_open_file(char *filename, int mode);
612 extern void start_log_thread (void);
613 extern void stop_log_thread (void);
614 extern void add_mimetype (char *new_ext, char *new_type, char *new_expire);
615 extern void free_mimetypes (void);
616 extern int lookup_object (tux_req_t *req, const unsigned int flag);
617 extern int handle_gzip_req (tux_req_t *req, unsigned int flags);
618 extern struct dentry * tux_lookup (tux_req_t *req, const char *filename, const unsigned int flag, struct vfsmount **mnt);
619 extern tcapi_template_t * lookup_tuxmodule (const char *filename);
620 extern int register_tuxmodule (tcapi_template_t *tcapi);
621 extern tcapi_template_t * unregister_tuxmodule (char *vfs_name);
622 extern tcapi_template_t * get_first_usermodule (void);
623 extern int user_register_module (user_req_t *u_info);
624 extern int user_unregister_module (user_req_t *u_info);
625 extern void unregister_all_tuxmodules (void);
626
627 typedef struct exec_param_s {
628         char *command;
629         char **argv;
630         char **envp;
631         unsigned int pipe_fds;
632 } exec_param_t;
633
634 extern pid_t tux_exec_process (char *command, char **argv, char **envp, int pipe_fds, exec_param_t *param, int wait);
635
636 extern void start_external_cgi (tux_req_t *req);
637 extern tcapi_template_t extcgi_tcapi;
638
639 extern void queue_output_req (tux_req_t *req, threadinfo_t *ti);
640 extern void queue_userspace_req (tux_req_t *req, threadinfo_t *ti);
641
642
643 extern void __log_request (tux_req_t *req);
644 extern inline void log_request (tux_req_t *req)
645 {
646         if (tux_logging)
647                 __log_request(req);
648 }
649
650 extern int __connection_too_fast (tux_req_t *req);
651
652 #define connection_too_fast(req)                                \
653         ({                                                      \
654                 int __ret = 1;                                  \
655                 if (unlikely(tux_max_output_bandwidth))         \
656                         __ret = __connection_too_fast(req);     \
657                 __ret;                                          \
658         })
659
660 extern void trunc_headers (tux_req_t *req);
661 extern int generic_send_file (tux_req_t *req, struct socket *sock, int cachemiss);
662 extern int tux_fetch_file (tux_req_t *req, int nonblock);
663
664 extern void postpone_request (tux_req_t *req);
665 extern int continue_request (int fd);
666 extern void tux_push_pending (struct sock *sk);
667 extern void zap_request (tux_req_t *req, int cachemiss);
668 extern int add_output_space_event (tux_req_t *req, struct socket *sock);
669
670 extern void reap_kids (void);
671 extern void unuse_frag (struct sk_buff *skb, skb_frag_t *frag);
672 extern skb_frag_t * build_dynbuf_frag (tux_req_t *req, unsigned int size);
673 extern int tux_permission (struct inode *inode);
674 extern void flush_all_signals (void);
675
676 #define D() Dprintk("{%s:%d}\n", __FILE__, __LINE__)
677
678 extern int nr_async_io_pending (void);
679
680 extern void __add_keepalive_timer (tux_req_t *req);
681 #define add_keepalive_timer(req)                                        \
682 do {                                                                    \
683         if (tux_keepalive_timeout) {                                    \
684                 Dprintk("add_keepalive_timer(%p).\n", (req));           \
685                 __add_keepalive_timer(req);                             \
686         }                                                               \
687 } while (0)
688 extern void __del_keepalive_timer (tux_req_t *req);
689 #define del_keepalive_timer(req)                                        \
690 do {                                                                    \
691         if (tux_keepalive_timeout) {                                    \
692                 Dprintk("del_keepalive_timer(%p).\n", (req));           \
693                 __del_keepalive_timer(req);                             \
694         }                                                               \
695 } while (0)
696
697 extern void del_output_timer (tux_req_t *req);
698 extern void output_timeout (tux_req_t *req);
699
700 extern void print_req (tux_req_t *req);
701
702 extern char tux_date [DATE_LEN];
703
704
705 extern int nr_async_io_pending (void);
706 extern void tux_exit (void);
707 extern char * get_abuf (tux_req_t *req, unsigned int max_size);
708 extern void send_abuf (tux_req_t *req, unsigned int size, unsigned long flags);
709
710
711 extern int idle_event (tux_req_t *req);
712 extern int output_space_event (tux_req_t *req);
713 extern cpumask_t tux_log_cpu_mask;
714 extern unsigned int tux_compression;
715 extern unsigned int tux_noid;
716 extern unsigned int tux_cgi_inherit_cpu;
717 extern unsigned int tux_zerocopy_header;
718 extern unsigned int tux_zerocopy_sendfile;
719 extern cpumask_t tux_cgi_cpu_mask;
720 extern tux_proto_t tux_proto_http;
721 extern tux_proto_t tux_proto_ftp;
722 extern unsigned int tux_all_userspace;
723 extern unsigned int tux_ignore_query;
724 extern unsigned int tux_redirect_logging;
725 extern unsigned int tux_referer_logging;
726 extern unsigned int tux_log_incomplete;
727 extern unsigned int tux_max_header_len;
728 extern unsigned int tux_cpu_offset;
729 extern unsigned int tux_ftp_login_message;
730
731 extern void drop_permissions (void);
732 extern int query_extcgi (tux_req_t *req);
733 extern int tux_chroot (char *dir);
734
735 extern void install_req_dentry (tux_req_t *req, struct dentry *dentry, struct vfsmount *mnt);
736 extern void release_req_dentry (tux_req_t *req);
737 extern void unidle_req (tux_req_t *req);
738 extern int nr_requests_used (void);
739
740 #define req_err(req) do { (req)->error = 1; Dprintk("request %p error at %s:%d.\n", req, __FILE__, __LINE__); } while (0)
741
742 #define enough_wspace(sk) (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
743 #define clear_keepalive(req) do { (req)->keep_alive = 0; Dprintk("keepalive cleared for req %p.\n", req); } while (0)
744
745 extern int print_all_requests (threadinfo_t *ti);
746 extern unsigned int tux_max_keepalives;
747 extern int time_unix2ls (time_t zulu, char *buf);
748 extern void last_mod_time(char * curr, const time_t t);
749 extern int mdtm_time(char * curr, const time_t t);
750 extern time_t parse_time(const char *str, const int str_len);
751
752 extern unsigned int nr_tux_threads;
753 extern threadinfo_t threadinfo[CONFIG_TUX_NUMTHREADS];
754
755 #define switch_docroot(req) do { if (((req)->docroot_dentry != current->fs->root) || ((req)->docroot_mnt != current->fs->rootmnt)) __switch_docroot(req); } while (0)
756 extern void __switch_docroot(tux_req_t *req);
757 extern void list_directory (tux_req_t *req, int cachemiss);
758 extern char * tux_print_path (tux_req_t *req, struct dentry *dentry, struct vfsmount *mnt, char *buf, unsigned int max_len);
759
760 extern unsigned int tux_http_dir_indexing;
761
762 int tux_gzip_compress (tux_req_t *req, unsigned char *data_in, unsigned char *data_out, __u32 *in_len, __u32 *out_len);
763
764 struct dentry * __tux_lookup (tux_req_t *req, const char *filename,
765                          struct nameidata *base, struct vfsmount **mnt);
766
767 /* error codes for req->error */
768 #define TUX_ERROR_REDIRECT     1
769 #define TUX_ERROR_UNUSED       2
770 #define TUX_ERROR_CONN_CLOSE   3
771 #define TUX_ERROR_CONN_TIMEOUT 4
772
773 extern void __put_data_sock (tux_req_t *req);
774
775 static inline void put_data_sock (tux_req_t *req)
776 {
777         if (req->data_sock)
778                 __put_data_sock(req);
779 }
780
781 #define socket_input(sock) \
782         (!skb_queue_empty(&(sock)->sk->sk_receive_queue) || \
783                 !skb_queue_empty(&(sock)->sk->sk_error_queue))
784
785 #define tux_kmalloc(size)                                               \
786 ({                                                                      \
787         void *__ptr;                                                    \
788                                                                         \
789         while (!(__ptr = kmalloc(size, GFP_KERNEL))) {                  \
790                 if (net_ratelimit())                                    \
791                         printk(KERN_WARNING "tux: OOM at %s:%d (%d bytes).\n", \
792                                 __FILE__, __LINE__, size);              \
793                 current->state = TASK_UNINTERRUPTIBLE;                  \
794                 schedule_timeout(1);                                    \
795         }                                                               \
796         __ptr;                                                          \
797 })
798
799 #define tux_close(fd) sys_close(fd)
800
801 extern int init_tux_request_slabs(void);
802 extern void free_tux_request_slabs(void);
803
804 #endif