netadm-devel Mailing List for netadm
Status: Beta
Brought to you by:
linuxpark
You can subscribe to this list here.
2006 |
Jan
(4) |
Feb
(78) |
Mar
(70) |
Apr
(32) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Jeho-Park <jhp...@ke...> - 2006-05-30 00:59:56
|
hi there nf-hipac-0.9.1 was made to apply it to the kernel 2.6.13, so it need some modification here is my patched nf-hipac 0.9.1 patch. some small bits were changed http://www.kernelproject.org/people/jhpark/nf-hipac-0.9.1-to-linux-2.6.16.16.patch thanks Jeho-Park -- Jeho-Park <jhp...@ke...> or <lin...@in...> |
From: linuxpark <lin...@us...> - 2006-05-13 18:29:12
|
Update of /cvsroot/netadm/gwc/pf In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1885/pf Modified Files: sysklog.c Log Message: MOD: integrate every data concerned about each log type. Index: sysklog.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/sysklog.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sysklog.c 8 May 2006 07:05:59 -0000 1.5 --- sysklog.c 13 May 2006 18:29:06 -0000 1.6 *************** *** 30,33 **** --- 30,34 ---- #include <linux/poll.h> #include <linux/fs.h> + #include <linux/mount.h> #include <asm/io.h> #include <linux/proc_fs.h> *************** *** 36,39 **** --- 37,41 ---- #include "../include/global.h" + static const char gwc_klog_driver_name[] = "gwc-klog"; static const char gwc_klog_driver_string[] = "gwc kernel log module"; *************** *** 55,59 **** * 3. Add proc handlers * ! * --LP */ #ifndef SET_MODULE_OWNER --- 57,61 ---- * 3. Add proc handlers * ! * --LP (LinuxPark, Jeho-Park) */ #ifndef SET_MODULE_OWNER *************** *** 69,91 **** #endif ! static spinlock_t logbuf_lock [MAXSYSIDX]; ! static wait_queue_head_t log_wait [MAXSYSIDX]; ! ! static spinlock_t ratelimit_lock [MAXSYSIDX]; ! static unsigned long last_msg [MAXSYSIDX]; ! ! static unsigned long toks [MAXSYSIDX]; ! static int missed [MAXSYSIDX]; ! /* ! * The indices into log_buf are not constrained to log_buf_len - they ! * must be masked before subscripting ! */ ! static unsigned long log_start [MAXSYSIDX]; ! static unsigned long log_end [MAXSYSIDX]; ! static char __log_buf[MAXSYSIDX][__SYS_LOG_BUFLEN]; ! static char *log_buf [MAXSYSIDX]; ! static int log_buf_len = __SYS_LOG_BUFLEN; ! static unsigned long logged_chars[MAXSYSIDX]; static void init_gwc_logbuf (void ) { --- 71,117 ---- #endif ! static int gwcklog_chrdevtab_slot = 0; ! struct gwcklog_chrdev { ! int idx; ! unsigned int major; ! char *devname; ! }; ! static struct gwcklog_chrdev gwcklog_chrdevtab [MAXSYSIDX]; ! ! typedef struct { ! ! unsigned long log_start; ! unsigned long log_end; ! ! char __log_buf [__SYS_LOG_BUFLEN]; ! char *log_buf; ! int log_buf_len; ! unsigned long logged_chars; ! ! spinlock_t logbuf_lock; ! spinlock_t ratelimit_lock; ! wait_queue_head_t log_wait; ! ! unsigned long last_msg; ! unsigned long toks; ! int missed; ! ! } gwcklog_t; ! ! static gwcklog_t gwcklog [MAXSYSIDX]; ! ! ! static inline int get_gwcklog_idx (const char *devname) { ! int i; ! ! for (i = 0; i < gwcklog_chrdevtab_slot; i++) { ! if ( !strcmp (gwcklog_chrdevtab [i].devname, devname)) { ! return i; ! } ! } ! ! return -1; ! } static void init_gwc_logbuf (void ) { *************** *** 93,116 **** for (i = 0; i < MAXSYSIDX; i++) { ! logbuf_lock [i] = SPIN_LOCK_UNLOCKED; ! log_buf [i] = __log_buf [i]; ! ratelimit_lock [i] = SPIN_LOCK_UNLOCKED; ! toks [i] = 10 * 5 * HZ; } } #undef LOG_BUF_MASK ! #define LOG_BUF_MASK (log_buf_len-1) #undef LOG_BUF ! #define LOG_BUF(idx, w) (log_buf[idx][(w) & LOG_BUF_MASK]) ! static void init_gwc_wait_queue_heads (wait_queue_head_t *wq, int max) { int i; ! for (i = 0; i < max; i++) { ! wq[i].lock = SPIN_LOCK_UNLOCKED; ! wq[i].task_list.next = wq[i].task_list.prev = &wq[i].task_list; } } /* * Commands to do_gwc_sysklog: --- 119,146 ---- for (i = 0; i < MAXSYSIDX; i++) { ! gwcklog [i].logbuf_lock = SPIN_LOCK_UNLOCKED; ! gwcklog [i].ratelimit_lock = SPIN_LOCK_UNLOCKED; ! gwcklog [i].log_buf_len = __SYS_LOG_BUFLEN; ! gwcklog [i].log_buf = gwcklog [i].__log_buf; ! gwcklog [i].toks = 10 * 5 * HZ; } } #undef LOG_BUF_MASK ! #define LOG_BUF_MASK(idx) (gwcklog [idx].log_buf_len-1) #undef LOG_BUF ! #define LOG_BUF(idx, w) gwcklog [idx].log_buf [(w) & LOG_BUF_MASK (idx)] ! static void init_gwc_wait_queue_heads (void ) { int i; ! for (i = 0; i < MAXSYSIDX; i++) { ! gwcklog [i].log_wait.lock = SPIN_LOCK_UNLOCKED; ! gwcklog [i].log_wait.task_list.next = ! gwcklog [i].log_wait.task_list.prev = ! &gwcklog [i].log_wait.task_list; } } + /* * Commands to do_gwc_sysklog: *************** *** 128,132 **** * 10 -- Return size of the log buffer */ - int do_gwc_sysklog(int idx, int type, char __user * buf, int len) { --- 158,161 ---- *************** *** 174,193 **** goto out; } ! error = wait_event_interruptible(log_wait[idx], (log_start[idx] - log_end[idx])); if (error) goto out; i = 0; ! spin_lock_irq(&logbuf_lock[idx]); ! while (!error && (log_start[idx] != log_end[idx]) && i < len) { ! c = LOG_BUF(idx, log_start[idx]); ! log_start[idx]++; ! spin_unlock_irq(&logbuf_lock[idx]); error = __put_user(c,buf); buf++; i++; cond_resched(); ! spin_lock_irq(&logbuf_lock[idx]); } ! spin_unlock_irq(&logbuf_lock[idx]); if (!error) error = i; --- 203,223 ---- goto out; } ! error = wait_event_interruptible (gwcklog [idx].log_wait, ! (gwcklog [idx].log_start - gwcklog [idx].log_end)); if (error) goto out; i = 0; ! spin_lock_irq(&gwcklog [idx].logbuf_lock); ! while (!error && (gwcklog [idx].log_start != gwcklog [idx].log_end) && i < len) { ! c = LOG_BUF(idx, gwcklog [idx].log_start); ! gwcklog [idx].log_start++; ! spin_unlock_irq(&gwcklog [idx].logbuf_lock); error = __put_user(c,buf); buf++; i++; cond_resched(); ! spin_lock_irq(&gwcklog [idx].logbuf_lock); } ! spin_unlock_irq(&gwcklog [idx].logbuf_lock); if (!error) error = i; *************** *** 208,219 **** } count = len; ! if (count > log_buf_len) ! count = log_buf_len; ! spin_lock_irq(&logbuf_lock[idx]); ! if (count > logged_chars[idx]) ! count = logged_chars[idx]; if (do_clear) ! logged_chars[idx] = 0; ! limit = log_end [idx]; /* * __put_user() could sleep, and while we sleep --- 238,249 ---- } count = len; ! if (count > gwcklog [idx].log_buf_len) ! count = gwcklog [idx].log_buf_len; ! spin_lock_irq(&gwcklog [idx].logbuf_lock); ! if (count > gwcklog [idx].logged_chars) ! count = gwcklog [idx].logged_chars; if (do_clear) ! gwcklog [idx].logged_chars = 0; ! limit = gwcklog [idx].log_end; /* * __put_user() could sleep, and while we sleep *************** *** 224,236 **** for(i = 0; i < count && !error; i++) { j = limit-1-i; ! if (j + log_buf_len < log_end [idx]) break; c = LOG_BUF(idx, j); ! spin_unlock_irq(&logbuf_lock[idx]); error = __put_user(c,&buf[count-1-i]); cond_resched(); ! spin_lock_irq(&logbuf_lock [idx]); } ! spin_unlock_irq(&logbuf_lock[idx]); if (error) break; --- 254,266 ---- for(i = 0; i < count && !error; i++) { j = limit-1-i; ! if (j + gwcklog [idx].log_buf_len < gwcklog [idx].log_end) break; c = LOG_BUF(idx, j); ! spin_unlock_irq(&gwcklog [idx].logbuf_lock); error = __put_user(c,&buf[count-1-i]); cond_resched(); ! spin_lock_irq(&gwcklog [idx].logbuf_lock); } ! spin_unlock_irq(&gwcklog [idx].logbuf_lock); if (error) break; *************** *** 250,261 **** break; case 5: /* Clear ring buffer */ ! logged_chars[idx] = 0; break; case 9: /* Number of chars in the log buffer */ ! error = log_end[idx] - log_start[idx]; break; case 10: /* Size of the log buffer */ ! error = log_buf_len; break; default: --- 280,291 ---- break; case 5: /* Clear ring buffer */ ! gwcklog [idx].logged_chars = 0; break; case 9: /* Number of chars in the log buffer */ ! error = gwcklog[idx].log_end - gwcklog [idx].log_start; break; case 10: /* Size of the log buffer */ ! error = gwcklog [idx].log_buf_len; break; default: *************** *** 269,279 **** static void emit_log_char(int idx, char c) { ! LOG_BUF(idx, log_end[idx]) = c; ! log_end[idx]++; ! if (log_end[idx] - log_start[idx] > log_buf_len) ! log_start[idx] = log_end[idx] - log_buf_len; ! if (logged_chars[idx] < log_buf_len) ! logged_chars[idx]++; } --- 299,309 ---- static void emit_log_char(int idx, char c) { ! LOG_BUF(idx, gwcklog [idx].log_end) = c; ! gwcklog [idx].log_end++; ! if (gwcklog [idx].log_end - gwcklog [idx].log_start > gwcklog [idx].log_buf_len) ! gwcklog[idx].log_start = gwcklog [idx].log_end - gwcklog [idx].log_buf_len; ! if (gwcklog [idx].logged_chars < gwcklog [idx].log_buf_len) ! gwcklog [idx].logged_chars++; } *************** *** 294,298 **** /* If a crash is occurring, make sure we can't deadlock */ ! spin_lock_init(&logbuf_lock [idx]); } --- 324,328 ---- /* If a crash is occurring, make sure we can't deadlock */ ! spin_lock_init(&gwcklog [idx].logbuf_lock); } *************** *** 316,335 **** unsigned long now = jiffies; ! spin_lock_irqsave(&ratelimit_lock[idx], flags); ! toks[idx] += now - last_msg [idx]; ! last_msg [idx] = now; ! if (toks[idx] > (ratelimit_burst * ratelimit_jiffies)) ! toks [idx] = ratelimit_burst * ratelimit_jiffies; ! if (toks [idx] >= ratelimit_jiffies) { ! int lost = missed [idx]; ! missed [idx] = 0; ! toks [idx] -= ratelimit_jiffies; ! spin_unlock_irqrestore(&ratelimit_lock[idx], flags); if (lost) gwc_printk (idx, "gwc_printk: %d messages suppressed.\n", lost); return 1; } ! missed [idx]++; ! spin_unlock_irqrestore(&ratelimit_lock[idx], flags); return 0; } --- 346,365 ---- unsigned long now = jiffies; ! spin_lock_irqsave(&gwcklog [idx].ratelimit_lock, flags); ! gwcklog [idx].toks += now - gwcklog [idx].last_msg; ! gwcklog [idx].last_msg = now; ! if (gwcklog [idx].toks > (ratelimit_burst * ratelimit_jiffies)) ! gwcklog [idx].toks = ratelimit_burst * ratelimit_jiffies; ! if (gwcklog [idx].toks >= ratelimit_jiffies) { ! int lost = gwcklog [idx].missed; ! gwcklog [idx].missed = 0; ! gwcklog [idx].toks -= ratelimit_jiffies; ! spin_unlock_irqrestore(&gwcklog [idx].ratelimit_lock, flags); if (lost) gwc_printk (idx, "gwc_printk: %d messages suppressed.\n", lost); return 1; } ! gwcklog [idx].missed ++; ! spin_unlock_irqrestore(&gwcklog [idx].ratelimit_lock, flags); return 0; } *************** *** 375,379 **** /* This stops the holder of console_sem just where we want him */ ! spin_lock_irqsave(&logbuf_lock[idx], flags); printk_cpu = smp_processor_id(); --- 405,409 ---- /* This stops the holder of console_sem just where we want him */ ! spin_lock_irqsave(&gwcklog [idx].logbuf_lock, flags); printk_cpu = smp_processor_id(); *************** *** 394,402 **** unsigned long long t; unsigned long nanosec_rem; ! /***********************************************************************************/ ! /* TODO: ! * force the log level token to be ! * before the time output. ! * *********************************************************************************/ if (p[0] == '<' && p[1] >='0' && p[1] <= '9' && p[2] == '>') { --- 424,433 ---- unsigned long long t; unsigned long nanosec_rem; ! ! #if 0 /* TODO: *******************************************/ ! /* */ ! /* setup <format> */ ! /* */ ! /***************************************************/ if (p[0] == '<' && p[1] >='0' && p[1] <= '9' && p[2] == '>') { *************** *** 408,411 **** --- 439,444 ---- + '0'; } + #endif + loglev_char = 'G'; t = gwc_printk_clock(); nanosec_rem = do_div(t, 1000000000); *************** *** 446,455 **** */ printk_cpu = UINT_MAX; ! spin_unlock_irqrestore(&logbuf_lock, flags); goto out; } printk_cpu = UINT_MAX; ! spin_unlock_irqrestore(&logbuf_lock, flags); out: --- 479,488 ---- */ printk_cpu = UINT_MAX; ! spin_unlock_irqrestore(&gwcklog [idx].logbuf_lock, flags); goto out; } printk_cpu = UINT_MAX; ! spin_unlock_irqrestore(&gwcklog [idx].logbuf_lock, flags); out: *************** *** 465,472 **** --- 498,507 ---- va_list args; int r; + /* #ifdef USE_GWCPK_RATELIMIT if (gwc_printk_ratelimit(idx)) return 0; #endif + */ if ( idx <= MINSYSIDX || idx >= MAXSYSIDX ) { gwc_printk (GWC_KSYS_IDX, "Wrong idx (%d) received\n", idx); *************** *** 478,482 **** va_end(args); ! wake_up_interruptible (&log_wait[idx]); return r; } --- 513,517 ---- va_end(args); ! wake_up_interruptible (&gwcklog [idx].log_wait); return r; } *************** *** 484,561 **** /* ! * gwc kctl file handler lists * - * @sys_xxxmsg_{open|release|read|poll|} */ ! static int gwc_pf_open(struct inode * inode, struct file * file) { ! return do_gwc_sysklog(GWC_PF_IDX, 1, NULL, 0); } ! static int gwc_pf_release(struct inode * inode, struct file * file) { ! (void) do_gwc_sysklog(GWC_PF_IDX, 0, NULL, 0); ! return 0; } ! static ssize_t gwc_pf_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { ! if ((file->f_flags & O_NONBLOCK) && !do_gwc_sysklog(GWC_PF_IDX, 9, NULL, 0)) ! return -EAGAIN; ! return do_gwc_sysklog(GWC_PF_IDX, 2, buf, count); } ! static unsigned int gwc_pf_poll(struct file *file, poll_table *wait) { ! poll_wait(file, &log_wait[GWC_PF_IDX], wait); ! if (do_gwc_sysklog(GWC_PF_IDX, 9, NULL, 0)) ! return POLLIN | POLLRDNORM; ! return 0; } ! struct file_operations gwc_pf_operations = { ! .read = gwc_pf_read, ! .poll = gwc_pf_poll, ! .open = gwc_pf_open, ! .release = gwc_pf_release, }; ! static int gwc_sys_open(struct inode * inode, struct file * file) ! { ! return do_gwc_sysklog(GWC_KSYS_IDX, 1, NULL, 0); ! } ! static int gwc_sys_release(struct inode * inode, struct file * file) ! { ! (void) do_gwc_sysklog(GWC_KSYS_IDX, 0, NULL, 0); ! return 0; ! } ! static ssize_t gwc_sys_read(struct file *file, char __user *buf, ! size_t count, loff_t *ppos) ! { ! if ((file->f_flags & O_NONBLOCK) && !do_gwc_sysklog(GWC_KSYS_IDX, 9, NULL, 0)) ! return -EAGAIN; ! return do_gwc_sysklog(GWC_KSYS_IDX, 2, buf, count); } ! static unsigned int gwc_sys_poll(struct file *file, poll_table *wait) ! { ! poll_wait(file, &log_wait[GWC_KSYS_IDX], wait); ! if (do_gwc_sysklog(GWC_KSYS_IDX, 9, NULL, 0)) ! return POLLIN | POLLRDNORM; ! return 0; ! } ! struct file_operations gwc_sys_operations = { ! .read = gwc_sys_read, ! .poll = gwc_sys_poll, ! .open = gwc_sys_open, ! .release = gwc_sys_release, ! }; static void init_gwc_kctl (void) { --- 519,636 ---- /* ! * gwc klog generic file handler lists * */ ! static int gwcklog_generic_open(struct inode * inode, struct file * file) { ! int idx; ! ! if ((file->f_flags & O_ACCMODE) & (O_WRONLY | O_RDWR)) { ! printk ("%s: Device does not allow writing mode\n", gwc_klog_driver_name); ! return -EROFS; ! } ! ! idx = get_gwcklog_idx ( file->f_dentry->d_iname ); ! if ( idx < 0 ) ! return -ENXIO; ! ! return do_gwc_sysklog(idx, 1, NULL, 0); } ! static int gwcklog_generic_release(struct inode * inode, struct file * file) { ! int idx = get_gwcklog_idx ( file->f_dentry->d_iname ); ! if ( idx < 0 ) ! return -ENXIO; ! ! (void) do_gwc_sysklog(idx, 0, NULL, 0); ! return 0; } ! static ssize_t gwcklog_generic_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { ! int idx = get_gwcklog_idx ( file->f_dentry->d_iname ); ! if ( idx < 0 ) ! return -ENXIO; ! ! if ((file->f_flags & O_NONBLOCK) && !do_gwc_sysklog(idx, 9, NULL, 0)) ! return -EAGAIN; ! ! return do_gwc_sysklog(idx, 2, buf, count); } ! static unsigned int gwcklog_generic_poll(struct file *file, poll_table *wait) { ! int idx = get_gwcklog_idx ( file->f_dentry->d_iname ); ! if ( idx < 0 ) ! return -ENXIO; ! ! poll_wait(file, &gwcklog [idx].log_wait, wait); ! if (do_gwc_sysklog(idx, 9, NULL, 0)) ! return POLLIN | POLLRDNORM; ! ! return 0; } ! struct file_operations gwcklog_generic_operations = { ! .read = gwcklog_generic_read, ! .poll = gwcklog_generic_poll, ! .open = gwcklog_generic_open, ! .release = gwcklog_generic_release, }; + int register_gwcklog_chrdev (unsigned int major, const char *devname) { + int ret; ! if (gwcklog_chrdevtab_slot + MINGWCLOG_MAJORNUM > MAXGWCLOG_MAJORNUM ) { ! printk (KERN_ERR "%s: chrdevtab overflow\n", gwc_klog_driver_name); ! return -EMFILE; ! } ! gwcklog_chrdevtab[gwcklog_chrdevtab_slot].idx = gwcklog_chrdevtab_slot; ! gwcklog_chrdevtab[gwcklog_chrdevtab_slot].major = major; ! gwcklog_chrdevtab[gwcklog_chrdevtab_slot].devname = ! (char *)kmalloc (strlen (devname), GFP_KERNEL); ! ! if (!gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname) { ! printk (KERN_ERR "%s: Failed to alloc mem\n", gwc_klog_driver_name); ! return -ENOMEM; ! } ! strcpy (gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname, devname); ! if ((ret = register_chrdev(gwcklog_chrdevtab [gwcklog_chrdevtab_slot].major, ! gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname, ! &gwcklog_generic_operations)) < 0 ) { ! printk ("%s: Failed to register gwc chrdev [%s]: %d\n", ! gwc_klog_driver_name, ! gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname, ret); ! kfree (gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname); ! return ret; ! } ! ++gwcklog_chrdevtab_slot; ! return ret; } + EXPORT_SYMBOL_GPL (register_gwcklog_chrdev); ! int unregister_gwcklog_chrdev (unsigned int major, const char *devname) { ! int ret; ! if (gwcklog_chrdevtab_slot - 1 < 0 ) { ! printk (KERN_ERR "%s: gwcklog_chrdevtab underflow\n", gwc_klog_driver_name); ! return -ENODEV; ! } ! ! if ((ret = unregister_chrdev(major, devname) < 0)) { ! printk(KERN_WARNING "%s: Failed to Unregister %s: %d\n", ! gwc_klog_driver_name, devname, ret); ! return ret; ! } ! kfree (gwcklog_chrdevtab [--gwcklog_chrdevtab_slot].devname); ! return ret; ! } ! EXPORT_SYMBOL_GPL (unregister_gwcklog_chrdev); static void init_gwc_kctl (void) { *************** *** 591,595 **** int i; ! if (register_chrdev(GWC_PF_MAJORNUM, GWC_PF_DNAME, &gwc_pf_operations) < 0) { printk(KERN_WARNING "%s: Failed to Registrate %s\n", gwc_klog_driver_name, GWC_PF_DNAME); --- 666,670 ---- int i; ! if (register_gwcklog_chrdev (GWC_PF_MAJORNUM, GWC_PF_DNAME) < 0 ) { printk(KERN_WARNING "%s: Failed to Registrate %s\n", gwc_klog_driver_name, GWC_PF_DNAME); *************** *** 597,601 **** } ! if (register_chrdev(GWC_SYS_MAJORNUM, GWC_SYS_DNAME, &gwc_sys_operations) < 0) { printk(KERN_WARNING "%s: Failed to Registrate %s\n", gwc_klog_driver_name, GWC_SYS_DNAME); --- 672,676 ---- } ! if (register_gwcklog_chrdev (GWC_SYS_MAJORNUM, GWC_SYS_DNAME) < 0 ) { printk(KERN_WARNING "%s: Failed to Registrate %s\n", gwc_klog_driver_name, GWC_SYS_DNAME); *************** *** 617,631 **** #else ! printk (KERN_INFO "%s: Unloading gwc kctl module ...\n", gwc_klog_driver_name); ! if (unregister_chrdev(GWC_PF_MAJORNUM, GWC_PF_DNAME) < 0) { printk(KERN_WARNING "%s: Failed to Unregister %s\n", gwc_klog_driver_name, GWC_PF_DNAME); } ! if (unregister_chrdev(GWC_SYS_MAJORNUM, GWC_SYS_DNAME) < 0) { printk(KERN_WARNING "%s: Failed to Unregister %s\n", gwc_klog_driver_name, GWC_SYS_DNAME); } - printk (KERN_INFO "%s: Success to unregister gwc kctl module ...\n", gwc_klog_driver_name); #endif --- 692,704 ---- #else ! if ( unregister_gwcklog_chrdev (GWC_PF_MAJORNUM, GWC_PF_DNAME) < 0 ) { printk(KERN_WARNING "%s: Failed to Unregister %s\n", gwc_klog_driver_name, GWC_PF_DNAME); } ! if (unregister_gwcklog_chrdev(GWC_SYS_MAJORNUM, GWC_SYS_DNAME) < 0) { printk(KERN_WARNING "%s: Failed to Unregister %s\n", gwc_klog_driver_name, GWC_SYS_DNAME); } #endif *************** *** 635,643 **** gwc_klog_init(void) { ! printk (KERN_INFO "Registering %s-%s ...\n", gwc_klog_driver_name, gwc_klog_driver_version); ! init_gwc_wait_queue_heads (log_wait, MAXSYSIDX); init_gwc_logbuf (); init_gwc_kctl (); --- 708,717 ---- gwc_klog_init(void) { ! printk (KERN_INFO "%s: Registering %s-%s ...\n", ! gwc_klog_driver_name, gwc_klog_driver_name, gwc_klog_driver_version); ! init_gwc_wait_queue_heads (); init_gwc_logbuf (); init_gwc_kctl (); *************** *** 649,653 **** gwc_klog_exit(void) { ! printk (KERN_INFO "Unregistering %s-%s ...\n", gwc_klog_driver_name, gwc_klog_driver_version); --- 723,728 ---- gwc_klog_exit(void) { ! printk (KERN_INFO "%s: Unregistering %s-%s ...\n", ! gwc_klog_driver_name, gwc_klog_driver_name, gwc_klog_driver_version); |
From: linuxpark <lin...@us...> - 2006-05-13 18:29:12
|
Update of /cvsroot/netadm/gwc/include In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1885/include Modified Files: global.h Log Message: MOD: integrate every data concerned about each log type. Index: global.h =================================================================== RCS file: /cvsroot/netadm/gwc/include/global.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** global.h 6 May 2006 23:43:23 -0000 1.9 --- global.h 13 May 2006 18:29:06 -0000 1.10 *************** *** 93,96 **** --- 93,100 ---- #define GWC_PF_LOG "gwc_pf.log" #define GWC_KSYS_LOG "gwc_ksys.log" + + #define MINGWCLOG_MAJORNUM 220 + #define MAXGWCLOG_MAJORNUM 240 + #define GWC_PF_MAJORNUM 220 #define GWC_SYS_MAJORNUM 221 |
From: jeho-park <lin...@gm...> - 2006-05-12 14:22:44
|
Old: cvs.sourceforge.net New: netadm.cvs.sourceforge.net |
From: linuxpark <lin...@us...> - 2006-05-09 16:02:00
|
Update of /cvsroot/netadm/gwc/pf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20195 Modified Files: pf.c sysklog.c Log Message: FIX: idx lookup exception & log format. Index: pf.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/pf.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pf.c 8 May 2006 07:05:59 -0000 1.13 --- pf.c 9 May 2006 16:01:52 -0000 1.14 *************** *** 167,174 **** int i; ! /* TODO : remove me */ ! #if 1 ! gwc_printk (GWC_KSYS_IDX, "This is KSYS test, gwc_ksys.log .. remove this debug code\n"); ! #endif for( i = 0; i <= blk_hash_mask; i++){ --- 167,172 ---- int i; ! /* TODO : gwc_printk test code: default: on remove me ! */ ! gwc_printk (GWC_PF_IDX , "This is PF test, gwc_pf.log .. remove this debug code\n"); for( i = 0; i <= blk_hash_mask; i++){ *************** *** 182,188 **** } /* TODO : remove me */ ! #if 1 ! gwc_printk (GWC_PF_IDX , "This is PF test, gwc_pf.log .. remove this debug code\n"); ! #endif return 1; --- 180,184 ---- } /* TODO : remove me */ ! gwc_printk (GWC_KSYS_IDX, "This is KSYS test, gwc_ksys.log .. remove this debug code\n"); return 1; Index: sysklog.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/sysklog.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sysklog.c 8 May 2006 16:53:27 -0000 1.6 --- sysklog.c 9 May 2006 16:01:52 -0000 1.7 *************** *** 78,82 **** char *devname; }; - static struct gwcklog_chrdev gwcklog_chrdevtab [MAXSYSIDX]; --- 78,81 ---- *************** *** 90,103 **** int log_buf_len; unsigned long logged_chars; ! spinlock_t logbuf_lock; spinlock_t ratelimit_lock; - wait_queue_head_t log_wait; ! unsigned long last_msg; - unsigned long toks; - int missed; --- 89,99 ---- int log_buf_len; unsigned long logged_chars; ! spinlock_t logbuf_lock; spinlock_t ratelimit_lock; wait_queue_head_t log_wait; ! unsigned long last_msg; unsigned long toks; int missed; *************** *** 108,118 **** static inline int get_gwcklog_idx (const char *devname) { ! int i = -1; ! for (i = 0; i < gwcklog_chrdevtab_slot; i++) ! if ( !strcmp (gwcklog_chrdevtab [i].devname, devname)) ! break; ! return i; } --- 104,116 ---- static inline int get_gwcklog_idx (const char *devname) { ! int i; ! for (i = 0; i < gwcklog_chrdevtab_slot; i++) { ! if ( !strcmp (gwcklog_chrdevtab [i].devname, devname)) { ! return i; ! } ! } ! return -1; } *************** *** 426,434 **** unsigned long long t; unsigned long nanosec_rem; ! /***********************************************************************************/ ! /* TODO: ! * force the log level token to be ! * before the time output. ! * *********************************************************************************/ if (p[0] == '<' && p[1] >='0' && p[1] <= '9' && p[2] == '>') { --- 424,433 ---- unsigned long long t; unsigned long nanosec_rem; ! ! #if 0 /* TODO: *******************************************/ ! /* */ ! /* setup <format> */ ! /* */ ! /***************************************************/ if (p[0] == '<' && p[1] >='0' && p[1] <= '9' && p[2] == '>') { *************** *** 440,443 **** --- 439,444 ---- + '0'; } + #endif + loglev_char = 'G'; t = gwc_printk_clock(); nanosec_rem = do_div(t, 1000000000); *************** *** 521,525 **** static int gwcklog_generic_open(struct inode * inode, struct file * file) { ! int idx = get_gwcklog_idx ( file->f_dentry->d_iname ); if ( idx < 0 ) return -ENXIO; --- 522,533 ---- static int gwcklog_generic_open(struct inode * inode, struct file * file) { ! int idx; ! ! if ((file->f_flags & O_ACCMODE) & (O_WRONLY | O_RDWR)) { ! printk ("%s: Device does not allow writing mode\n", gwc_klog_driver_name); ! return -EROFS; ! } ! ! idx = get_gwcklog_idx ( file->f_dentry->d_iname ); if ( idx < 0 ) return -ENXIO; *************** *** 575,579 **** if (gwcklog_chrdevtab_slot + MINGWCLOG_MAJORNUM > MAXGWCLOG_MAJORNUM ) { ! printk (KERN_ERR "chrdevtab overflow\n"); return -EMFILE; } --- 583,587 ---- if (gwcklog_chrdevtab_slot + MINGWCLOG_MAJORNUM > MAXGWCLOG_MAJORNUM ) { ! printk (KERN_ERR "%s: chrdevtab overflow\n", gwc_klog_driver_name); return -EMFILE; } *************** *** 585,592 **** if (!gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname) { ! printk (KERN_ERR "Failed to alloc mem\n"); return -ENOMEM; } - strcpy (gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname, devname); --- 593,599 ---- if (!gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname) { ! printk (KERN_ERR "%s: Failed to alloc mem\n", gwc_klog_driver_name); return -ENOMEM; } strcpy (gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname, devname); *************** *** 594,598 **** gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname, &gwcklog_generic_operations)) < 0 ) { ! printk ("Failed to register gwc chrdev [%s]: %d\n", gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname, ret); kfree (gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname); --- 601,606 ---- gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname, &gwcklog_generic_operations)) < 0 ) { ! printk ("%s: Failed to register gwc chrdev [%s]: %d\n", ! gwc_klog_driver_name, gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname, ret); kfree (gwcklog_chrdevtab [gwcklog_chrdevtab_slot].devname); *************** *** 609,613 **** if (gwcklog_chrdevtab_slot - 1 < 0 ) { ! printk (KERN_ERR "gwcklog_chrdevtab underflow\n"); return -ENODEV; } --- 617,621 ---- if (gwcklog_chrdevtab_slot - 1 < 0 ) { ! printk (KERN_ERR "%s: gwcklog_chrdevtab underflow\n", gwc_klog_driver_name); return -ENODEV; } *************** *** 698,702 **** gwc_klog_init(void) { ! printk (KERN_INFO "Registering %s-%s ...\n", gwc_klog_driver_name, gwc_klog_driver_version); --- 706,711 ---- gwc_klog_init(void) { ! printk (KERN_INFO "%s: Registering %s-%s ...\n", ! gwc_klog_driver_name, gwc_klog_driver_name, gwc_klog_driver_version); *************** *** 712,716 **** gwc_klog_exit(void) { ! printk (KERN_INFO "Unregistering %s-%s ...\n", gwc_klog_driver_name, gwc_klog_driver_version); --- 721,726 ---- gwc_klog_exit(void) { ! printk (KERN_INFO "%s: Unregistering %s-%s ...\n", ! gwc_klog_driver_name, gwc_klog_driver_name, gwc_klog_driver_version); |
From: linuxpark <lin...@us...> - 2006-05-09 01:17:46
|
Update of /cvsroot/netadm/gwc/gwcklogd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11615/gwcklogd Added Files: Makefile gwcklogd.c gwcklogd.h Log Message: Initial Check in gwcklogd : kernel log daemon just only for receiving kernel module logs and saving these log to /usr/local/gwc/log/~ --- NEW FILE: gwcklogd.c --- /* Title : gwcklogd.c Author : Jeho-Park <de...@sk...> Created date : 2006. 05. 06. (sat) 01:50:54 KST Description : user log daemon for gwc kernel logging This code is mainly based on klogd.c ~/.vimrc Local variables: c-indent-level: 8 c-basic-offset: 8 tab-width: 4 End: */ #ident "@(#) $Header: /cvsroot/netadm/gwc/gwcklogd/gwcklogd.c,v 1.1 2006/05/06 15:48:47 linuxpark Exp $" #include <stdio.h> #include <unistd.h> #include <signal.h> #include <errno.h> #include <sys/fcntl.h> #include <sys/stat.h> #include <sys/file.h> #include <linux/time.h> #include <stdarg.h> #include <paths.h> #include <stdlib.h> #include <syslog.h> #include <string.h> #include "global.h" #include "gwcklogd.h" #include "sysutil.h" #include "sysnio.h" #define LOG_BUFFER_SIZE 4096 #define LOG_LINE_LENGTH 1000 static char *PidFile = _PATH_VARRUN "gwcklogd.pid"; static int kmsg; static int change_state = 0; static int terminate = 0; static int caught_TSTP = 0; static int one_shot = 0; static int no_fork = 0; #ifdef RUNWITH_SYSLOGD /* i dont need to run with syslogd --LP (linuxpark, Jeho Park )*/ static char log_buffer[LOG_BUFFER_SIZE]; #endif static FILE *output_file = (FILE *) 0; static int debugging = 0; /* sig handler */ void restart(int sig); void stop_logging(int sig); void stop_daemon(int sig); static void closelogsrc(void); static void signaldaemon(int); static void changelog(void); static enum src get_klog_src(void); #ifdef RUNWITH_SYSLOGD static void logline(char *ptr, int len); #endif static void Syslog(int priority, char *fmt, ...); static enum src { none, proc, kernel } logsrc; enum parse_state_enum { PARSING_TEXT, PARSING_SYMSTART, /* at < */ PARSING_SYMBOL, PARSING_SYMEND /* at ] */ }; typedef int (*klog_cmdcb_t) (void *arg); typedef struct { int idx; int fd; int log_fd; char devname[MAXPATHLEN/4]; char log_file [MINBUF]; klog_cmdcb_t func; } gwc_klog_cmd_t; int gwcklog_pf (void *arg); int gwcklog_sys (void *arg); gwc_klog_cmd_t klogcmdtab [MAXSYSIDX] = { { GWC_PF_IDX, -1, -1, GWC_PF_DNAME, " ", gwcklog_pf }, { GWC_KSYS_IDX, -1, -1, GWC_SYS_DNAME, " ", gwcklog_sys }, }; int wlog (int idx, char *buf) { int ret; if (klogcmdtab[idx].log_fd < 0 ) { switch (idx) { case GWC_PF_IDX: sprintf (klogcmdtab[idx].log_file, "%s/log/%s", SZMAINPATH, GWC_PF_LOG); break; case GWC_KSYS_IDX: sprintf (klogcmdtab[idx].log_file, "%s/log/%s", SZMAINPATH, GWC_KSYS_LOG); break; default: return -1; break; } klogcmdtab[idx].log_fd = open (klogcmdtab[idx].log_file, O_CREAT | O_RDWR | O_APPEND | O_SYNC, 0600); if (klogcmdtab [idx].log_fd < 0 ) { out ("Failed to open %s: %s\n", klogcmdtab[idx].log_file, strerror(errno)); return -1; } if ( sys_blockingmode ( klogcmdtab[idx].log_fd, TRUE) < 0 ) { out ("Failed to make blocking idx [%d] devname[%s] error[%s]\n", idx, klogcmdtab[idx].devname, strerror(errno)); close ( klogcmdtab[idx].log_fd); klogcmdtab[idx].log_fd = -1; } } ret = write (klogcmdtab [idx].log_fd, buf, strlen (buf)); if (ret < 0 ) { out ("Failed to write to %s(%d): %s\n", klogcmdtab[idx].log_file, klogcmdtab[idx].log_fd, strerror(errno)); } return ret; } int rlog (int fd, char *buf, int bufsiz) { int ret; int i; char *p; if ((ret = read (fd, buf, bufsiz)) < 0 ) { for (i = 0; i < MAXSYSIDX; i++) if (klogcmdtab[i].fd == fd) break; out ("Failed to read from %s: %d \n", klogcmdtab[i].devname, ret); } /* TODO: "How about accumulated log lines" * * device accumulated about 1.6M log, when gwcklogd first start, he will read * accumulated log at one time * but i now eat accumulated log --LP */ if ( ret > MAXFNLEN ) { return -1; } p = strchr (buf, '\n'); if (!p) { out ("Get some agly log (no newline) from log device (nread:%d)\n", ret); return -1; } /* i don't have interest after newline */ *(p+1) = '\0'; #if 0 /* Check point : what i have gotten from log device --LP */ printf ("Log:%s\n", ret, buf); #endif return ret; } int gwcklog_pf (void *arg) { int ret; char buf[BUFLEN]; ret = rlog (klogcmdtab [GWC_PF_IDX].fd, buf, sizeof (buf)); if (ret > 0 ) { /* TODO: If you want to save love to Database, here is that point * but i just save this log to our gwc log files /usr/local/gwc/log/~ --LP */ ret = wlog (GWC_PF_IDX, buf); } else { return -1; } return ret; } int gwcklog_sys (void *arg) { int ret; char buf[BUFLEN]; ret = rlog (klogcmdtab [GWC_KSYS_IDX].fd, buf, sizeof (buf)); if (ret > 0) { /* TODO: If you want to save love to Database, here is that point * but i just save this log to our gwc log files /usr/local/gwc/log/~ --LP */ ret = wlog (GWC_KSYS_IDX, buf); } else { return -1; } return ret; } static int read_pid (char *pidfile) { FILE *f; int pid; if (!(f=fopen(pidfile,"r"))) return 0; fscanf(f,"%d", &pid); fclose(f); return pid; } static int check_pid (char *pidfile) { int pid = read_pid(pidfile); /* Amazing ! _I_ am already holding the pid file... */ if ((!pid) || (pid == getpid ())) return 0; if (kill(pid, 0) && errno == ESRCH) return 0; return pid; } static int write_pid (char *pidfile) { FILE *f; int fd; int pid; if ( ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1) || ((f = fdopen(fd, "r+")) == NULL) ) { out ("Can't open or create %s. :%s \n", pidfile, strerror(errno)); return 0; } if (flock(fd, LOCK_EX|LOCK_NB) == -1) { fscanf(f, "%d", &pid); fclose(f); out ("Can't lock, lock is held by pid %d.\n", pid); return 0; } pid = getpid(); if (!fprintf(f, "%d\n", pid)) { out ("Can't write pid , %s.\n", strerror(errno)); close(fd); return 0; } fflush(f); if (flock(fd, LOCK_UN) == -1) { out ("Can't unlock pidfile %s, %s.\n", pidfile, strerror(errno)); close(fd); return 0; } close(fd); return pid; } static int remove_pid (char *pidfile) { return unlink (pidfile); } static void exitprog(void) { int i; closelogsrc(); Syslog(LOG_INFO, "Kernel log daemon terminating."); if ( output_file != (FILE *) 0 ) { fclose(output_file); } for (i = 0; i < MAXSYSIDX; i++) { close (klogcmdtab[i].fd); close (klogcmdtab[i].log_fd); } closelog(); (void) remove_pid(PidFile); exit(1); } static void closelogsrc(void) { switch ( logsrc ) { case kernel: Syslog(LOG_INFO, "Kernel logging (ksyslog) stopped."); break; case proc: close(kmsg); Syslog(LOG_INFO, "Kernel logging (proc) stopped."); break; case none: break; } if ( output_file != (FILE *) 0 ) fflush(output_file); return; } void restart(int sig) { signal(SIGCONT, restart); change_state = 1; caught_TSTP = 0; return; } void stop_logging(int sig) { signal(SIGTSTP, stop_logging); change_state = 1; caught_TSTP = 1; return; } void stop_daemon(int sig) { exitprog(); return; } static void signaldaemon(int sig) { int pid = check_pid(PidFile); kill(pid, sig); return; } static void changelog(void) { if (terminate) exitprog(); Syslog(LOG_INFO, "gwcklogd %s.%s, ---------- state change ----------\n", VERSION, PATCHLEVEL); if (caught_TSTP) { closelogsrc(); logsrc = none; change_state = 0; return; } if ( logsrc != none ) { Syslog(LOG_INFO, "Kernel logging re-started after SIGSTOP."); change_state = 0; return; } /* Restart logging. */ logsrc = get_klog_src(); change_state = 0; return; } static enum src get_klog_src(void) { int i; if ( (kmsg = open(_PATH_KLOG, O_RDONLY)) < 0 ) { out ("klogd: Cannot open proc file system, %d - %s.\n", errno, strerror(errno)); for (i = 0; i < MAXSYSIDX; i++) { close (klogcmdtab[i].fd); close (klogcmdtab[i].log_fd); } exit(1); } Syslog(LOG_INFO, "klogd %s.%s, log source = %s started.", VERSION, PATCHLEVEL, _PATH_KLOG); return (proc); } static void Syslog(int priority, char *fmt, ...) { va_list ap; char *argl; /* Handle output to a file. */ if ( output_file != (FILE *) 0 ) { va_start(ap, fmt); vfprintf(output_file, fmt, ap); va_end(ap); fputc('\n', output_file); fflush(output_file); if (!one_shot) fsync(fileno(output_file)); return; } /* Output using syslog. */ if (!strcmp(fmt, "%s")) { va_start(ap, fmt); argl = va_arg(ap, char *); if (argl[0] == '<' && argl[1] && argl[2] == '>') { switch ( argl[1] ) { case '0': priority = LOG_EMERG; break; case '1': priority = LOG_ALERT; break; case '2': priority = LOG_CRIT; break; case '3': priority = LOG_ERR; break; case '4': priority = LOG_WARNING; break; case '5': priority = LOG_NOTICE; break; case '6': priority = LOG_INFO; break; case '7': default: priority = LOG_DEBUG; } argl += 3; } #ifdef RUNWITH_SYSLOGD /* If you want, send syslogd with uncommenting this line below. --LP */ syslog(priority, fmt, argl); /* org */ #endif /* fprintf (stdout, fmt, argl); my debug code --LP */ out (fmt, argl); va_end(ap); /* putchar ('\n'); org */ out ("\n"); /* mine --LP */ return; } va_start(ap, fmt); #ifdef RUNWITH_SYSLOGD vsyslog(priority, fmt, ap); #endif argl = va_arg(ap, char *); fprintf (stdout, fmt, argl); va_end(ap); return; } #ifdef RUNWITH_SYSLOGD static int copyin( char *line, int space, const char *ptr, int len, const char *delim ) { int i; int count; count = len < space ? len : space; for(i=0; i<count && !strchr(delim, *ptr); i++ ) { *line++ = *ptr++; } return i; } #endif #ifdef RUNWITH_SYSLOGD static void logline (char *ptr, int len) { static char line_buff[LOG_LINE_LENGTH]; static char *line = line_buff; static enum parse_state_enum parse_state = PARSING_TEXT; static int space = sizeof(line_buff)-1; int delta = 0; /* number of chars copied */ char *save_ptr = ptr; /* save start of input line */ int save_len = len; /* save length at start of input line */ while( len > 0 ) { if( space == 0 ) { /* line buffer is full */ /* ** Line too long. Start a new line. */ *line = 0; /* force null terminator */ if ( debugging ) { out ("Line buffer full:\n"); out ("\tLine: %s\n", line); } Syslog( LOG_INFO, "%s", line_buff ); line = line_buff; space = sizeof(line_buff)-1; parse_state = PARSING_TEXT; save_ptr = ptr; save_len = len; } switch( parse_state ) { case PARSING_TEXT: delta = copyin( line, space, ptr, len, "\n[%" ); line += delta; ptr += delta; space -= delta; len -= delta; if( !space || !len ) break; /* full line_buff or end of input buffer */ /* zero byte */ if( *ptr == '\0' ) { ptr++; /* skip zero byte */ space -= 1; len -= 1; break; } /* newline */ if( *ptr == '\n' ) { ptr++; /* skip newline */ space -= 1; len -= 1; *line = 0; /* force null terminator */ Syslog( LOG_INFO, "%s", line_buff ); line = line_buff; space = sizeof(line_buff)-1; break; } /* possible kernel symbol */ if( *ptr == '[' ) { *line++ = *ptr++; space -= 1; len -= 1; break; } /* dangerous printf marker */ if( *ptr == '%' ) { delta = 0; while (len && *ptr == '%') { *line++ = *ptr++; /* copy it in */ space -= 1; len -= 1; delta++; } /* odd amount of %'s */ if (delta % 2) { if (space) { *line++ = '%'; /* so simply add one */ space -= 1; } else { *line++ = '\0'; /* remove the last one / terminate the string */ } } } break; /* end of PARSING_TEXT */ case PARSING_SYMSTART: break; case PARSING_SYMBOL: break; case PARSING_SYMEND: break; default: /* Can't get here! */ parse_state = PARSING_TEXT; } } return; } #endif int main( int argc, char ** argv) { int ch; int use_output = 0; char *log_level = NULL; char *output = NULL; fd_set sock_set; struct timeval tv; struct timeval *ptv; int i; char path[MAXPATHLEN]; int ret; #ifdef USE_SYSLOG char *cp; char ident[MINBUF]; #endif chdir ("/"); /* Parse the command-line. */ while ((ch = getopt(argc, argv, "c:df:iIk:nopsvx")) != EOF) { switch((char)ch) { case 'c': /* Set console message level. */ log_level = optarg; break; case 'd': /* Activity debug mode. */ debugging = 1; break; case 'f': /* Define an output file. */ output = optarg; use_output++; break; case 'i': /* Reload module symbols. */ signaldaemon(SIGUSR1); return(0); case 'I': signaldaemon(SIGUSR2); return(0); case 'n': /* don't fork */ no_fork++; break; case 'o': /* One-shot mode. */ one_shot = 1; break; case 'v': printf("gwcklogd %s.%s\n", VERSION, PATCHLEVEL); exit (1); } } #ifdef USE_SYSLOG if ((cp = strrchr(argv[0], '/')) != NULL) cp++; else cp = argv[0]; sprintf(ident, "%s", cp); sysl_open(ident, SYSL_DAEMON); #endif /* * The following code allows klogd to auto-background itself. */ if ( (!one_shot) && (!no_fork) ) { if (!check_pid(PidFile)) { if ( fork() == 0 ) { int fl; int num_fds = getdtablesize(); /* This is the child closing its file descriptors. */ for (fl= 0; fl <= num_fds; ++fl) { if ( fileno(stdout) == fl && use_output ) if ( strcmp(output, "stdout") == 0 ) continue; close(fl); } setsid(); } else { /* bye son */ exit(0); } } else { out ("klogd: Already running.\n"); exit(1); } } /* tuck my process id away */ if (!check_pid(PidFile)) { if (!write_pid(PidFile)) exitprog(); } else { out ("klogd: Already running.\n"); exitprog(); } /* Signal setups. */ for (ch= 1; ch < NSIG; ++ch) { signal(ch, SIG_IGN); } signal(SIGINT, stop_daemon); signal(SIGKILL, stop_daemon); signal(SIGTERM, stop_daemon); signal(SIGHUP, stop_daemon); signal(SIGTSTP, stop_logging); signal(SIGCONT, restart); /* Open outputs. */ if ( strcmp(output, "-") == 0 ) { output_file = stdout; } else if ( (output_file = fopen(output, "w")) == (FILE *) 0 ) { out ("klogd: Cannot open output file %s - %s\n", output, strerror(errno)); return 1; } /* Determine where kernel logging information is to come from. */ for (i = 0; i < MAXSYSIDX; i++) { sprintf (path, "%s/%s", DEV_DIR, klogcmdtab[i].devname); klogcmdtab[i].fd = open (path, O_RDONLY); if (klogcmdtab[i].fd < 0 ) { out ("Failed to open fd[%d] {%s}: %s\n", i, klogcmdtab[i].devname, strerror(errno)); goto exit; } else { if ( sys_blockingmode ( klogcmdtab[i].fd, FALSE) < 0 ) { out ("Failed to make blocking fd[%d] {%s}: %s\n", i, klogcmdtab[i].devname, strerror(errno)); goto exit; } } } /* The main loop. */ while (1) { FD_ZERO(&sock_set); for (i = 0; i < MAXSYSIDX; i++) { FD_SET( klogcmdtab[i].fd, &sock_set); } if ( change_state ) changelog(); tv.tv_sec = GWC_KLOGD_TIMEOUT * 60L; tv.tv_usec = 0; ptv = &tv; ret = select(klogcmdtab [MAXSYSIDX].fd + 1, &sock_set, NULL, NULL, ptv); if ((ret < 0 ) && (errno != EAGAIN)) { out ("select failed: %s\n", strerror(errno)); goto exit; } else if (!ret) { out ("Timeout: continue ...\n"); continue; } else { for (i = 0; i < MAXSYSIDX; i++) { if( FD_ISSET(klogcmdtab[i].fd, &sock_set) ) { ret = klogcmdtab[i].func (NULL); if (ret < 0 ) { out ("Failed to save log : idx:%d, devname:%d fd:%d file:%s\n", i, klogcmdtab[i].devname, klogcmdtab[i].fd, klogcmdtab[i].log_file ); } break; } } } } exit: /* TODO: close syslog */ #ifdef USE_SYSLOG sysl_close(); #endif for (i = 0; i < MAXSYSIDX; i++) { if (klogcmdtab[i].fd > 0 ) { close (klogcmdtab[i].fd); } close (klogcmdtab[i].log_fd); } exit(0); } --- NEW FILE: gwcklogd.h --- /* Title : gwcklogd.h Author : Jeho-Park <de...@sk...> Created date : 2006. 05. 06. (sat) 00:58:44 KST Description : */ #ident "@(#) $Header: /cvsroot/netadm/gwc/gwcklogd/gwcklogd.h,v 1.1 2006/05/06 15:48:47 linuxpark Exp $" #ifndef __SYS_GWCKLOGD_H #define __SYS_GWCKLOGD_H #define VERSION "0.0.1" #define PATCHLEVEL "0" #undef _PATH_KLOG #define _PATH_KLOG "/proc/gwc/syskmsg" #endif /* __SYS_GWCKLOGD_H */ --- NEW FILE: Makefile --- # # Title : Makefile # Author : Jeho-Park <de...@sk...> # Created date : 2006. 05. 05. (Fri) 20:20:20 KST # Description : Makefile for gwcklogd # #ident "@(#) $Header: /cvsroot/netadm/gwc/gwcklogd/Makefile,v 1.1 2006/05/06 15:48:46 linuxpark Exp $" include ../Makefile.tmpl TARGET = gwcklogd OBJECTS = gwcklogd.o all: $(TARGET) $(TARGET): $(OBJECTS) $(CC) -o $@ $(OBJECTS) $(LIBSYS) .c.o: $(CC) $(CFLAGS) $(INCLUDE) -c $< tags: ctags *.c *.h clean: rm -f ${TARGET} *.o depend: $(MAKEDEPEND) -- $(CFLAGS) -- *.c rm -f Makefile.bak # DO NOT DELETE THIS LINE -- make depend depends on it. |
From: linuxpark <lin...@us...> - 2006-05-09 01:12:42
|
Update of /cvsroot/netadm/gwc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25430 Modified Files: README.ko Log Message: MOD: line feedback Index: README.ko =================================================================== RCS file: /cvsroot/netadm/gwc/README.ko,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** README.ko 30 Apr 2006 18:47:24 -0000 1.5 --- README.ko 7 May 2006 16:34:22 -0000 1.6 *************** *** 4,9 **** ¹Ú Á¦È£, <de...@sk...> - - [¸ñÂ÷] 1. ÇÊ¿ä ¿ä±¸ »çÇ×. --- 4,7 ---- *************** *** 15,19 **** 1. ÇÊ¿ä ¿ä±¸ »çÇ×. ----------------------------------------------------- - 1-1. Debian. a. libgtk1.0-dev ¶Ç´Âlibgtk2.0-dev ÆÐŰÁö --- 13,16 ---- *************** *** 29,48 **** 2. ±âÁ¸ gwc AP Á¦¾î¸ðµâ ÇÁ·Î±×·¥ ¾ðÀνºÅç ------------------------------------------------------ - #cd {gwc ¼Ò½º µð·ºÅ丮} #make uninstall - - 3. ¼Ò½º ÄÄÆÄÀÏ ------------------------------------------------------ - #make clean && make - - 4. ¼³Ä¡ ¹× ¼³Á¤ ------------------------------------------------------ - # make install --- 26,38 ---- |
From: linuxpark <lin...@us...> - 2006-05-09 01:05:46
|
Update of /cvsroot/netadm/gwc/pf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17018/pf Modified Files: Makefile sysklog.c Log Message: MOD: make enable logr ratelimit. (not not complete) Index: Makefile =================================================================== RCS file: /cvsroot/netadm/gwc/pf/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile 6 May 2006 15:21:07 -0000 1.6 --- Makefile 6 May 2006 23:43:23 -0000 1.7 *************** *** 8,11 **** --- 8,22 ---- #ident "@(#) $Header$" + + # \ \ + # gwc_printk ratelimit functionality + # /-----------------------------------/ + # + # If you use this function, you can setup the rate in include/global.h + # MACROS: + # GWCPK_JIFFIES (kernel jiffies, default: 1 HZ), + # GWCPK_BURST (message count limit for GWCPK_JIFFIES, default: 10 messages) + DUSE_GWCPK_RATELIMIT = 1 + obj-m += sysktimer.o obj-m += pf.o *************** *** 13,16 **** --- 24,32 ---- KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) + + ifdef DUSE_GWCPK_RATELIMIT + CFLAGS += -DUSE_GWCPK_RATELIMIT + endif + all: default Index: sysklog.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/sysklog.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sysklog.c 6 May 2006 20:48:08 -0000 1.3 --- sysklog.c 6 May 2006 23:43:23 -0000 1.4 *************** *** 71,74 **** --- 71,80 ---- static spinlock_t logbuf_lock [MAXSYSIDX]; static wait_queue_head_t log_wait [MAXSYSIDX]; + + static spinlock_t ratelimit_lock [MAXSYSIDX]; + static unsigned long last_msg [MAXSYSIDX]; + + static unsigned long toks [MAXSYSIDX]; + static int missed [MAXSYSIDX]; /* *************** *** 89,92 **** --- 95,100 ---- logbuf_lock [i] = SPIN_LOCK_UNLOCKED; log_buf [i] = __log_buf [i]; + ratelimit_lock [i] = SPIN_LOCK_UNLOCKED; + toks [i] = 10 * 5 * HZ; } } *************** *** 259,271 **** } - #if 0 /* i don't have interest this syscall 3 --LP */ - #ifdef CONFIG_GWC_SYSLOG_SYSCALL - asmlinkage long sys_gwc_syslog(int idx, int type, char __user * buf, int len) - { - return do_gwc_sysklog(idx, type, buf, len); - } - #endif /* #ifdef CONFIG_GWC_SYSLOG_SYSCALL */ - #endif - static void emit_log_char(int idx, char c) { --- 267,270 ---- *************** *** 312,352 **** * attack impossible. */ ! int __gwc_printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst) { - static DEFINE_SPINLOCK(ratelimit_lock); - static unsigned long toks = 10*5*HZ; - static unsigned long last_msg; - static int missed; unsigned long flags; unsigned long now = jiffies; ! spin_lock_irqsave(&ratelimit_lock, flags); ! toks += now - last_msg; ! last_msg = now; ! if (toks > (ratelimit_burst * ratelimit_jiffies)) ! toks = ratelimit_burst * ratelimit_jiffies; ! if (toks >= ratelimit_jiffies) { ! int lost = missed; ! missed = 0; ! toks -= ratelimit_jiffies; ! spin_unlock_irqrestore(&ratelimit_lock, flags); if (lost) ! printk(KERN_WARNING "printk: %d messages suppressed.\n", lost); return 1; } ! missed++; ! spin_unlock_irqrestore(&ratelimit_lock, flags); return 0; } /* minimum time in jiffies between messages */ ! static int printk_ratelimit_jiffies = 1*HZ; /* number of messages we send before ratelimiting */ ! static int printk_ratelimit_burst = 1; ! int gwc_printk_ratelimit(void) { ! return __gwc_printk_ratelimit(printk_ratelimit_jiffies, printk_ratelimit_burst); } --- 311,356 ---- * attack impossible. */ ! int __gwc_printk_ratelimit(int idx, int ratelimit_jiffies, int ratelimit_burst) { unsigned long flags; unsigned long now = jiffies; ! spin_lock_irqsave(&ratelimit_lock[idx], flags); ! toks[idx] += now - last_msg [idx]; ! last_msg [idx] = now; ! if (toks[idx] > (ratelimit_burst * ratelimit_jiffies)) ! toks [idx] = ratelimit_burst * ratelimit_jiffies; ! if (toks [idx] >= ratelimit_jiffies) { ! int lost = missed [idx]; ! missed [idx] = 0; ! toks [idx] -= ratelimit_jiffies; ! spin_unlock_irqrestore(&ratelimit_lock[idx], flags); if (lost) ! gwc_printk (idx, "gwc_printk: %d messages suppressed.\n", lost); return 1; } ! missed [idx]++; ! spin_unlock_irqrestore(&ratelimit_lock[idx], flags); return 0; } + /* + * printk_ratelimit_jiffies: 1 * HZ (5sec) + * printk_ratelimit_burst: 10 occur + * means we don't allow above 10 messages for 1 sec + * + * As a result, we can't not see same message 10 times for 1 sec. + * --LP (linuxpark or Jeho-Park) + */ + /* minimum time in jiffies between messages */ ! static int printk_ratelimit_jiffies = GWCPK_JIFFIES * HZ; /* number of messages we send before ratelimiting */ ! static int printk_ratelimit_burst = GWCPK_BURST; ! int gwc_printk_ratelimit(int idx) { ! return __gwc_printk_ratelimit(idx, printk_ratelimit_jiffies, printk_ratelimit_burst); } *************** *** 407,411 **** nanosec_rem = do_div(t, 1000000000); tlen = sprintf(tbuf, ! "<%c>[%5lu.%06lu] ", loglev_char, (unsigned long)t, --- 411,415 ---- nanosec_rem = do_div(t, 1000000000); tlen = sprintf(tbuf, ! "<%c>[sec:%5lu:nanosec:%06lu] ", loglev_char, (unsigned long)t, *************** *** 461,464 **** --- 465,476 ---- va_list args; int r; + #ifdef USE_GWCPK_RATELIMIT + if (gwc_printk_ratelimit(idx)) + return 0; + #endif + if ( idx <= MINSYSIDX || idx >= MAXSYSIDX ) { + gwc_printk (GWC_KSYS_IDX, "Wrong idx (%d) received\n", idx); + return 0; + } va_start(args, fmt); *************** *** 630,634 **** init_gwc_logbuf (); init_gwc_kctl (); - gwc_printk_ratelimit (); return 0; } --- 642,645 ---- |
From: linuxpark <lin...@us...> - 2006-05-09 00:59:35
|
Update of /cvsroot/netadm/gwc/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28605/include Modified Files: global.h sysutil.h Log Message: ADD1: sysklog.ko, gwcklogd. MOD1: make deactivate gwcguid. MOD2: scripts/gwc, scripts/install.sh according to ADD1 and MOD1. FIX1: fix select maxfd from klogcmdtab[MAXSYSIDX] to klogcmdtab [MAXSYSIDX -1]. DEL1: remove debug code. ADD2: CHANGES according to ADD1, MOD1 MOD3: change syslog.conf to be able to handling gwcklogd log to local1 (gwc.log). OTHERS: comment and my email address. Index: sysutil.h =================================================================== RCS file: /cvsroot/netadm/gwc/include/sysutil.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sysutil.h 6 Apr 2006 15:09:37 -0000 1.5 --- sysutil.h 6 May 2006 17:33:33 -0000 1.6 *************** *** 14,17 **** --- 14,18 ---- #include <stdarg.h> #include "sysipc.h" + #include "slog.h" #define NIPQUAD(addr) \ *************** *** 28,32 **** #ifdef TC_DEBUG ! #define tcdprintf( fmt, args... ) printf( "tc(%d): " fmt, __LINE__,##args) #else --- 29,33 ---- #ifdef TC_DEBUG ! #define tcdprintf( fmt, args... ) printf( "tc(%d): " fmt, __LINE__, ##args) #else Index: global.h =================================================================== RCS file: /cvsroot/netadm/gwc/include/global.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** global.h 30 Apr 2006 18:47:25 -0000 1.7 --- global.h 6 May 2006 17:33:33 -0000 1.8 *************** *** 62,65 **** --- 62,66 ---- #define MAXBUF 8192 #define MINBUF MAXBUF/32 /* 256 */ + #define MAXPATHLEN MINBUF #define BUFLEN 8192/4 #define MAXFNLEN 256 *************** *** 77,79 **** --- 78,98 ---- #define SZKMODNODE DEVICE_NAME + /* sysklog.ko and gwcklogd reference these macro definition below --LP */ + #define MAXLOGLINE MAXBUF + #define GWC_PF_IDX 0 + #define GWC_KSYS_IDX 1 + #define MAXSYSIDX (GWC_KSYS_IDX + 1) + #define DEV_DIR "/dev" + #define GWC_PROC_DIR "gwc" + #define PF_PROC_ENTRY "gwc_pf" + #define SYS_PROC_ENTRY "gwc_ksys" + #define GWC_PF_DNAME PF_PROC_ENTRY + #define GWC_SYS_DNAME SYS_PROC_ENTRY + #define GWC_PF_LOG "gwc_pf.log" + #define GWC_KSYS_LOG "gwc_ksys.log" + #define GWC_PF_MAJORNUM 220 + #define GWC_SYS_MAJORNUM 221 + #define GWC_KLOGD_TIMEOUT 10 + #define GWC_KLOGDPROC_TIMEOUT 2 + #endif /* __SYS_GLOBAL_H */ |
From: linuxpark <lin...@us...> - 2006-05-09 00:59:34
|
Update of /cvsroot/netadm/gwc/pf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28605/pf Modified Files: pf.c sysklog.c Log Message: ADD1: sysklog.ko, gwcklogd. MOD1: make deactivate gwcguid. MOD2: scripts/gwc, scripts/install.sh according to ADD1 and MOD1. FIX1: fix select maxfd from klogcmdtab[MAXSYSIDX] to klogcmdtab [MAXSYSIDX -1]. DEL1: remove debug code. ADD2: CHANGES according to ADD1, MOD1 MOD3: change syslog.conf to be able to handling gwcklogd log to local1 (gwc.log). OTHERS: comment and my email address. Index: pf.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/pf.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pf.c 6 May 2006 15:21:07 -0000 1.10 --- pf.c 6 May 2006 17:33:33 -0000 1.11 *************** *** 166,170 **** --- 166,173 ---- struct blk *blkh, **blkhp; int i; + static int j =0; + /* TODO : remove me */ + gwc_printk (GWC_KSYS_IDX, "This is KSYS test, gwc_ksys.log .. remove this debug code\n"); for( i = 0; i <= blk_hash_mask; i++){ *************** *** 177,180 **** --- 180,185 ---- spin_unlock(&blk_hash_table[i].lock); } + /* TODO : remove me */ + gwc_printk (GWC_PF_IDX, "This is PF test, gwc_pf.log .. remove this debug code\n"); return 1; Index: sysklog.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/sysklog.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sysklog.c 6 May 2006 15:17:47 -0000 1.1 --- sysklog.c 6 May 2006 17:33:33 -0000 1.2 *************** *** 134,138 **** switch (type) { case 0: /* Close log */ - dprintk("\n"); if (kctl_rcnt [idx] <= 0 ) { printk ("%s: Device(type: %d) already released for reading\n", --- 134,137 ---- *************** *** 146,150 **** case 1: /* Open log */ - dprintk("\n"); if (kctl_rcnt [idx]) { printk ("%s: Device(type: %d) already open for reading\n", --- 145,148 ---- *************** *** 188,196 **** break; case 4: /* Read/clear last kernel messages */ - dprintk("\n"); /* TODO: delete me --LP */ do_clear = 1; /* FALL THRU */ case 3: /* Read last kernel messages */ - dprintk("\n");/* TODO: delete me --LP */ error = -EINVAL; if (!buf || len < 0) --- 186,192 ---- *************** *** 517,529 **** static int gwc_sys_open(struct inode * inode, struct file * file) { ! dprintk ("\n"); ! return do_gwc_sysklog(GWC_KSYS_IDX, 1, NULL, 0); } static int gwc_sys_release(struct inode * inode, struct file * file) { ! dprintk ("\n"); ! (void) do_gwc_sysklog(GWC_KSYS_IDX, 0, NULL, 0); ! return 0; } --- 513,523 ---- static int gwc_sys_open(struct inode * inode, struct file * file) { ! return do_gwc_sysklog(GWC_KSYS_IDX, 1, NULL, 0); } static int gwc_sys_release(struct inode * inode, struct file * file) { ! (void) do_gwc_sysklog(GWC_KSYS_IDX, 0, NULL, 0); ! return 0; } *************** *** 531,537 **** size_t count, loff_t *ppos) { ! if ((file->f_flags & O_NONBLOCK) && !do_gwc_sysklog(GWC_KSYS_IDX, 9, NULL, 0)) ! return -EAGAIN; ! return do_gwc_sysklog(GWC_KSYS_IDX, 2, buf, count); } --- 525,532 ---- size_t count, loff_t *ppos) { ! if ((file->f_flags & O_NONBLOCK) && !do_gwc_sysklog(GWC_KSYS_IDX, 9, NULL, 0)) ! return -EAGAIN; ! ! return do_gwc_sysklog(GWC_KSYS_IDX, 2, buf, count); } *************** *** 540,546 **** static int i = 0; - printk ("------->wait ... (%d)\n", i++); poll_wait(file, &log_wait[GWC_KSYS_IDX], wait); - printk ("-------------------->cool !(%d)\n", i++); if (do_gwc_sysklog(GWC_KSYS_IDX, 9, NULL, 0)) --- 535,539 ---- |
From: linuxpark <lin...@us...> - 2006-05-09 00:57:21
|
Update of /cvsroot/netadm/gwc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28605 Modified Files: CHANGES Makefile Makefile.tmpl Log Message: ADD1: sysklog.ko, gwcklogd. MOD1: make deactivate gwcguid. MOD2: scripts/gwc, scripts/install.sh according to ADD1 and MOD1. FIX1: fix select maxfd from klogcmdtab[MAXSYSIDX] to klogcmdtab [MAXSYSIDX -1]. DEL1: remove debug code. ADD2: CHANGES according to ADD1, MOD1 MOD3: change syslog.conf to be able to handling gwcklogd log to local1 (gwc.log). OTHERS: comment and my email address. Index: CHANGES =================================================================== RCS file: /cvsroot/netadm/gwc/CHANGES,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CHANGES 30 Apr 2006 18:47:24 -0000 1.6 --- CHANGES 6 May 2006 17:33:33 -0000 1.7 *************** *** 1,4 **** --- 1,10 ---- Changes in gwc-v0.1-pre3 ------------------------ + ADD: sysklog.ko, gwcklod, this is only for handling gwc kernel modules log. + ADD: gwcsh: command shell. this replace gwcguid GUI daemon. + MOD: deactivate gwcguid. + + Changes in gwc-v0.1-pre3 + ------------------------ ADD: gwcsh which is shell, this will replace with gwcguid daemon. MOD: make disable gwcguid - there is no one to develop GUI Index: Makefile.tmpl =================================================================== RCS file: /cvsroot/netadm/gwc/Makefile.tmpl,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.tmpl 30 Apr 2006 18:47:24 -0000 1.6 --- Makefile.tmpl 6 May 2006 17:33:33 -0000 1.7 *************** *** 1,8 **** - # # Title : Makefile.tmpl # Author : Jeho-Park <lin...@gm...> # Created date : 2006. 01. 31. (thu) 01:40:38 KST # Description : config of Makefile - # #ident "@(#) $Header$" --- 1,6 ---- *************** *** 29,32 **** --- 27,32 ---- #SIGPW_CONTROL += -DCLIENT_PW_CONTROL + # For Debugging '-g' + #CFLAGS = -g -Wall $(USR_DEBUG_LEVEL) $(SIGPW_CONTROL) CFLAGS = -O -Wall $(USR_DEBUG_LEVEL) $(SIGPW_CONTROL) GTKLDFLAGS = `pkg-config --libs gtk+-2.0` Index: Makefile =================================================================== RCS file: /cvsroot/netadm/gwc/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile 30 Apr 2006 18:47:24 -0000 1.3 --- Makefile 6 May 2006 17:33:33 -0000 1.4 *************** *** 12,17 **** gwcsh \ gwcadmd \ ! gwcguid \ ! sample \ pf --- 12,16 ---- gwcsh \ gwcadmd \ ! gwcklogd \ pf |
From: linuxpark <lin...@us...> - 2006-05-09 00:57:21
|
Update of /cvsroot/netadm/gwc/gwcklogd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28605/gwcklogd Modified Files: gwcklogd.c Log Message: ADD1: sysklog.ko, gwcklogd. MOD1: make deactivate gwcguid. MOD2: scripts/gwc, scripts/install.sh according to ADD1 and MOD1. FIX1: fix select maxfd from klogcmdtab[MAXSYSIDX] to klogcmdtab [MAXSYSIDX -1]. DEL1: remove debug code. ADD2: CHANGES according to ADD1, MOD1 MOD3: change syslog.conf to be able to handling gwcklogd log to local1 (gwc.log). OTHERS: comment and my email address. Index: gwcklogd.c =================================================================== RCS file: /cvsroot/netadm/gwc/gwcklogd/gwcklogd.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gwcklogd.c 6 May 2006 15:48:47 -0000 1.1 --- gwcklogd.c 6 May 2006 17:33:33 -0000 1.2 *************** *** 41,46 **** static int terminate = 0; static int caught_TSTP = 0; - static int one_shot = 0; - static int no_fork = 0; #ifdef RUNWITH_SYSLOGD /* i dont need to run with syslogd --LP (linuxpark, Jeho Park )*/ static char log_buffer[LOG_BUFFER_SIZE]; --- 41,44 ---- *************** *** 281,285 **** closelogsrc(); ! Syslog(LOG_INFO, "Kernel log daemon terminating."); if ( output_file != (FILE *) 0 ) { --- 279,283 ---- closelogsrc(); ! Syslog(LOG_INFO, "gwcklogd: gwc Kernel log daemon terminating."); if ( output_file != (FILE *) 0 ) { *************** *** 410,416 **** fflush(output_file); - if (!one_shot) - fsync(fileno(output_file)); - return; } --- 408,411 ---- *************** *** 626,632 **** int main( int argc, char ** argv) { int ch; - int use_output = 0; char *log_level = NULL; - char *output = NULL; fd_set sock_set; struct timeval tv; --- 621,625 ---- *************** *** 642,646 **** chdir ("/"); /* Parse the command-line. */ ! while ((ch = getopt(argc, argv, "c:df:iIk:nopsvx")) != EOF) { switch((char)ch) { --- 635,639 ---- chdir ("/"); /* Parse the command-line. */ ! while ((ch = getopt(argc, argv, "c:d:iIk:psvx")) != EOF) { switch((char)ch) { *************** *** 654,662 **** break; - case 'f': /* Define an output file. */ - output = optarg; - use_output++; - break; - case 'i': /* Reload module symbols. */ signaldaemon(SIGUSR1); --- 647,650 ---- *************** *** 667,678 **** return(0); - case 'n': /* don't fork */ - no_fork++; - break; - - case 'o': /* One-shot mode. */ - one_shot = 1; - break; - case 'v': printf("gwcklogd %s.%s\n", VERSION, PATCHLEVEL); --- 655,658 ---- *************** *** 694,733 **** * The following code allows klogd to auto-background itself. */ ! if ( (!one_shot) && (!no_fork) ) { ! ! if (!check_pid(PidFile)) { ! ! if ( fork() == 0 ) { ! int fl; ! int num_fds = getdtablesize(); ! /* This is the child closing its file descriptors. */ ! for (fl= 0; fl <= num_fds; ++fl) { ! ! if ( fileno(stdout) == fl && use_output ) ! if ( strcmp(output, "stdout") == 0 ) ! continue; ! ! close(fl); ! } ! setsid(); ! ! } else { ! /* bye son */ ! exit(0); } ! ! } else { ! out ("klogd: Already running.\n"); ! exit(1); } } /* tuck my process id away */ if (!check_pid(PidFile)) { ! if (!write_pid(PidFile)) exitprog(); } else { ! out ("klogd: Already running.\n"); exitprog(); } --- 674,710 ---- * The following code allows klogd to auto-background itself. */ ! if (!check_pid(PidFile)) { ! if ( fork() == 0 ) { ! int fl; ! int num_fds = getdtablesize(); ! /* This is the child closing its file descriptors. */ ! for (fl= 2; fl <= num_fds; ++fl) { ! #if 0 ! if ( fileno(stdout) == fl && use_output ) ! if ( strcmp(output, "stdout") == 0 ) ! continue; ! #endif ! close(fl); } ! setsid(); ! ! } else { ! /* bye son */ ! exit(0); } + } else { + out ("Some other gwcklogd Already running.\n"); + exit(1); } /* tuck my process id away */ if (!check_pid(PidFile)) { ! if (!write_pid(PidFile)) { ! out ("Failed to write pid, exit ...\n"); exitprog(); + } } else { ! out ("Some other gwcklogd Already running.\n"); exitprog(); } *************** *** 745,749 **** --- 722,728 ---- signal(SIGCONT, restart); + out ("1.\n"); /* Open outputs. */ + #if 0 if ( strcmp(output, "-") == 0 ) { output_file = stdout; *************** *** 752,756 **** return 1; } ! /* Determine where kernel logging information is to come from. */ for (i = 0; i < MAXSYSIDX; i++) { --- 731,736 ---- return 1; } ! #endif ! out ("2.\n"); /* Determine where kernel logging information is to come from. */ for (i = 0; i < MAXSYSIDX; i++) { *************** *** 761,766 **** if (klogcmdtab[i].fd < 0 ) { ! out ("Failed to open fd[%d] {%s}: %s\n", ! i, klogcmdtab[i].devname, strerror(errno)); goto exit; --- 741,746 ---- if (klogcmdtab[i].fd < 0 ) { ! out ("Failed to open idx [%d] {%s}: %s\n", ! i, path, strerror(errno)); goto exit; *************** *** 774,777 **** --- 754,766 ---- } + for (i = 0; i < MAXSYSIDX; i++) { + out ("idx: %d, fd: %d, logfd: %d, devname: %s, log_file: %s\n", + klogcmdtab[i].idx, + klogcmdtab[i].fd, + klogcmdtab[i].log_fd, + klogcmdtab[i].devname, + klogcmdtab[i].log_file); + } + out ("gwcklogd: Starting ...\n"); /* The main loop. */ while (1) { *************** *** 779,793 **** FD_ZERO(&sock_set); for (i = 0; i < MAXSYSIDX; i++) { FD_SET( klogcmdtab[i].fd, &sock_set); } ! ! if ( change_state ) changelog(); ! tv.tv_sec = GWC_KLOGD_TIMEOUT * 60L; tv.tv_usec = 0; ptv = &tv; ! ret = select(klogcmdtab [MAXSYSIDX].fd + 1, &sock_set, NULL, NULL, ptv); if ((ret < 0 ) && (errno != EAGAIN)) { --- 768,788 ---- FD_ZERO(&sock_set); for (i = 0; i < MAXSYSIDX; i++) { + if (klogcmdtab[i].fd <= 0 ) + break; + FD_SET( klogcmdtab[i].fd, &sock_set); } ! #if 0 ! if ( change_state ) { ! out ("Changelog.\n"); changelog(); ! } ! #endif tv.tv_sec = GWC_KLOGD_TIMEOUT * 60L; tv.tv_usec = 0; ptv = &tv; ! out ("select ...\n"); ! ret = select(klogcmdtab [MAXSYSIDX -1 ].fd + 1, &sock_set, NULL, NULL, ptv); if ((ret < 0 ) && (errno != EAGAIN)) { *************** *** 801,809 **** } else { ! for (i = 0; i < MAXSYSIDX; i++) { if( FD_ISSET(klogcmdtab[i].fd, &sock_set) ) { ret = klogcmdtab[i].func (NULL); if (ret < 0 ) { --- 796,806 ---- } else { ! ! out ("receive kernel log\n"); for (i = 0; i < MAXSYSIDX; i++) { if( FD_ISSET(klogcmdtab[i].fd, &sock_set) ) { + out ("find idx [%d]\n", i); ret = klogcmdtab[i].func (NULL); if (ret < 0 ) { *************** *** 815,818 **** --- 812,817 ---- klogcmdtab[i].log_file ); + } else { + out ("success to handling kernel log\n"); } break; |
From: linuxpark <lin...@us...> - 2006-05-09 00:47:21
|
Update of /cvsroot/netadm/gwc/pf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30930 Modified Files: Makefile pf.c pf.h sysktimer.c sysktimer.h Log Message: MOD: replace printk to gwc_printk for more leveling our gwc log to /usr/local/gwc/log each will be save as their name gwc_pf.log, gwc_ksys.log. Index: sysktimer.h =================================================================== RCS file: /cvsroot/netadm/gwc/pf/sysktimer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sysktimer.h 18 Mar 2006 17:45:41 -0000 1.4 --- sysktimer.h 6 May 2006 15:21:07 -0000 1.5 *************** *** 1,7 **** ! /* ! * filename : sysktimer.h ! * 2006. 02. 28. (thu) 08:39:39 KST ! * jeho park <lin...@us...> ! */ #include <linux/init.h> #include <linux/module.h> --- 1,11 ---- ! /* ! Title : sysktimer.h ! Author : Jeho-Park <de...@sk...> ! Created date : 2006. 05. 05. (Fri) 18:09:07 KST ! Description : header of sysktimer in gwc modules ! ! */ ! #ident "@(#) $Header$" ! #include <linux/init.h> #include <linux/module.h> Index: pf.h =================================================================== RCS file: /cvsroot/netadm/gwc/pf/pf.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pf.h 18 Mar 2006 17:45:41 -0000 1.5 --- pf.h 6 May 2006 15:21:07 -0000 1.6 *************** *** 1,5 **** /* Title : pf.h ! Author : Jeho-Park <lin...@us...> Created date : 2006. 01. 31. (thu) 01:39:30 KST Description : --- 1,5 ---- /* Title : pf.h ! Author : Jeho-Park <de...@sk...> Created date : 2006. 01. 31. (thu) 01:39:30 KST Description : *************** *** 12,15 **** --- 12,16 ---- #include <linux/udp.h> #include <linux/types.h> + #include "sysklog.h" #if !defined(PFINFO) *************** *** 126,130 **** __u32 daddr, __u16 dport) { ! printk ("%s: %s %u.%u.%u.%u/%d -- %s --> %u.%u.%u.%u/%d\n", DEVICE_NAME, str, --- 127,131 ---- __u32 daddr, __u16 dport) { ! gwc_printk (GWC_PF_IDX, "%s: %s %u.%u.%u.%u/%d -- %s --> %u.%u.%u.%u/%d\n", DEVICE_NAME, str, *************** *** 139,152 **** dump_tcp(struct sk_buff *skb) { ! const struct iphdr *ip = skb->nh.iph; ! struct tcphdr *tcp; ! tcp = (struct tcphdr *) ((__u32 *) ip + ip->ihl); ! printk("%s: src(%u.%u.%u.%u/%hu)->dst(%u.%u.%u.%u/%hu)," "key.tos(0x%2.2hX)\n", DEVICE_NAME, NIPQUAD(ip->saddr), ntohs(tcp->source), NIPQUAD(ip->daddr), ntohs(tcp->dest), ip->tos); ! return 0; } --- 140,153 ---- dump_tcp(struct sk_buff *skb) { ! const struct iphdr *ip = skb->nh.iph; ! struct tcphdr *tcp; ! tcp = (struct tcphdr *) ((__u32 *) ip + ip->ihl); ! gwc_printk (GWC_PF_IDX, "%s: src(%u.%u.%u.%u/%hu)->dst(%u.%u.%u.%u/%hu)," "key.tos(0x%2.2hX)\n", DEVICE_NAME, NIPQUAD(ip->saddr), ntohs(tcp->source), NIPQUAD(ip->daddr), ntohs(tcp->dest), ip->tos); ! return 0; } *************** *** 154,165 **** dump_udp(struct sk_buff *skb) { ! const struct iphdr *ip = skb->nh.iph; ! struct udphdr *uh = (struct udphdr *) ((char *) ip + ip->ihl * 4); ! printk("%s: src(%u.%u.%u.%u/%hu)->dst(%u.%u.%u.%u/%hu)\n", DEVICE_NAME, NIPQUAD(ip->saddr), ntohs(uh->source), NIPQUAD(ip->daddr), ntohs(uh->dest)); ! return 0; } --- 155,166 ---- dump_udp(struct sk_buff *skb) { ! const struct iphdr *ip = skb->nh.iph; ! struct udphdr *uh = (struct udphdr *) ((char *) ip + ip->ihl * 4); ! gwc_printk (GWC_PF_IDX, "%s: src(%u.%u.%u.%u/%hu)->dst(%u.%u.%u.%u/%hu)\n", DEVICE_NAME, NIPQUAD(ip->saddr), ntohs(uh->source), NIPQUAD(ip->daddr), ntohs(uh->dest)); ! return 0; } *************** *** 173,180 **** print_MAC(unsigned char *p) { ! int i; ! for (i = 0; i < ETH_ALEN; i++, p++) ! printk("%02x%c", *p, i == ETH_ALEN - 1 ? ' ' : ':'); } --- 174,181 ---- print_MAC(unsigned char *p) { ! int i; ! for (i = 0; i < ETH_ALEN; i++, p++) ! gwc_printk (GWC_PF_IDX, "%02x%c", *p, i == ETH_ALEN - 1 ? ' ' : ':'); } *************** *** 182,197 **** sprint_MAC(char *buf, unsigned char *p) { ! int i; ! int n = 0; ! for (i = 0; i < ETH_ALEN; i++, p++) ! n += sprintf(buf + n, "%02x%c", *p, ! i == ETH_ALEN - 1 ? ' ' : ':'); ! } ! #define dprintk( fmt, args... ) do { \ ! if ( debug ) \ ! printk("%s: [%s:%d] " fmt, \ ! DEVICE_NAME, __FUNCTION__, __LINE__, ##args); \ ! } while(0) ! #endif /* __ASRV_PFILTER_H */ --- 183,193 ---- sprint_MAC(char *buf, unsigned char *p) { ! int i; ! int n = 0; ! for (i = 0; i < ETH_ALEN; i++, p++) ! n += sprintf(buf + n, "%02x%c", *p, ! i == ETH_ALEN - 1 ? ' ' : ':'); ! } ! #endif /* __SYS_PF_H */ Index: pf.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/pf.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pf.c 13 Apr 2006 14:01:45 -0000 1.9 --- pf.c 6 May 2006 15:21:07 -0000 1.10 *************** *** 1,5 **** /* Title : pf.c ! Author : Jeho-Park <lin...@us...> Created date : 2006. 01. 31. (thu) 01:39:30 KST Description : pf module --- 1,5 ---- /* Title : pf.c ! Author : Jeho-Park <de...@sk...> Created date : 2006. 01. 31. (thu) 01:39:30 KST Description : pf module *************** *** 45,57 **** #include "../include/global.h" #include "../include/sysdef.h" #include "pf.h" #include "sysktimer.h" ! #define DRIVER_AUTHOR "jeho park <lin...@gm...>" #define DRIVER_VERSION "gwc-pf-" SZSYSVERSION #define DRIVER_DESC "pf of gwc in netadm project " DRIVER_VERSION static pid_t tid; /* timer thread id */ static sysktimer_t *pf_ktimer = NULL; - static int debug __initdata = 0; static int kuio_rdopen = 0; static int kuio_wdopen = 0; --- 45,61 ---- #include "../include/global.h" #include "../include/sysdef.h" + #include "sysklog.h" #include "pf.h" #include "sysktimer.h" ! ! #define DRIVER_AUTHOR "jeho park <de...@sk...>" #define DRIVER_VERSION "gwc-pf-" SZSYSVERSION #define DRIVER_DESC "pf of gwc in netadm project " DRIVER_VERSION + static unsigned long debug = DBG_GENERAL; + module_param(debug, ulong, 0644); + MODULE_PARM_DESC(debug, "debug bitmap"); static pid_t tid; /* timer thread id */ static sysktimer_t *pf_ktimer = NULL; static int kuio_rdopen = 0; static int kuio_wdopen = 0; *************** *** 107,116 **** spin_unlock(&blk_hash_table[hash].lock); *blkhp = blkh; ! printk("%s: We meet any collision\n", DEVICE_NAME); return -1; } chain_length++; ! printk("%s: chain length(%d)\n", DEVICE_NAME, chain_length); blkhp = &blkh->next; } --- 111,120 ---- spin_unlock(&blk_hash_table[hash].lock); *blkhp = blkh; ! gwc_printk(GWC_KSYS_IDX, "%s: We meet any collision\n", DEVICE_NAME); return -1; } chain_length++; ! gwc_printk(GWC_KSYS_IDX, "%s: chain length(%d)\n", DEVICE_NAME, chain_length); blkhp = &blkh->next; } *************** *** 126,130 **** blknode = kmem_cache_alloc(kmem_cachep, in_interrupt()? SLAB_ATOMIC:SLAB_KERNEL); if (!blknode) { ! printk("%s: Failed to alloc blk from cache mem\n", DEVICE_NAME); return NULL; } --- 130,134 ---- blknode = kmem_cache_alloc(kmem_cachep, in_interrupt()? SLAB_ATOMIC:SLAB_KERNEL); if (!blknode) { ! gwc_printk(GWC_KSYS_IDX, "%s: Failed to alloc blk from cache mem\n", DEVICE_NAME); return NULL; } *************** *** 144,148 **** while( (blkh = *blkhp) != NULL){ blkhp = &blkh->next; ! printk("kmem_cache_free\n"); kmem_cache_free(kmem_cachep, blkh); } --- 148,152 ---- while( (blkh = *blkhp) != NULL){ blkhp = &blkh->next; ! gwc_printk(GWC_KSYS_IDX, "kmem_cache_free\n"); kmem_cache_free(kmem_cachep, blkh); } *************** *** 151,158 **** if ( kmem_cache_destroy(kmem_cachep) ) { ! printk ("%s: Failed to destroy cache memory\n", DEVICE_NAME); return -1; } else { ! printk ("%s: Success to destroy cache memory\n", DEVICE_NAME); } return 1; --- 155,162 ---- if ( kmem_cache_destroy(kmem_cachep) ) { ! gwc_printk(GWC_KSYS_IDX, "%s: Failed to destroy cache memory\n", DEVICE_NAME); return -1; } else { ! gwc_printk(GWC_KSYS_IDX, "%s: Success to destroy cache memory\n", DEVICE_NAME); } return 1; *************** *** 184,188 **** key_hp = blk_alloc(); if(!key_hp) { ! printk("%s : %s Failed to blk_alloc\n", DEVICE_NAME, __FUNCTION__ ); return -1; } --- 188,192 ---- key_hp = blk_alloc(); if(!key_hp) { ! gwc_printk(GWC_KSYS_IDX, "%s : %s Failed to blk_alloc\n", DEVICE_NAME, __FUNCTION__ ); return -1; } *************** *** 225,229 **** if (!blkh) { spin_unlock(&blk_hash_table[hash].lock); ! print_connection ("There is no such info", p->saddr, p->sport, p->protocol, --- 229,233 ---- if (!blkh) { spin_unlock(&blk_hash_table[hash].lock); ! print_connection ( "There is no such info", p->saddr, p->sport, p->protocol, *************** *** 262,269 **** 0, SLAB_HWCACHE_ALIGN, NULL, NULL); if(!kmem_cachep){ ! printk("%s: Failed to allocate block_host_cache\n", DEVICE_NAME); if (kmem_cache_destroy(kmem_cachep)) ! printk("%s: Not all blk_hash's were freed\n", DEVICE_NAME); return -1; --- 266,273 ---- 0, SLAB_HWCACHE_ALIGN, NULL, NULL); if(!kmem_cachep){ ! gwc_printk(GWC_KSYS_IDX, "%s: Failed to allocate block_host_cache\n", DEVICE_NAME); if (kmem_cache_destroy(kmem_cachep)) ! gwc_printk(GWC_KSYS_IDX, "%s: Not all blk_hash's were freed\n", DEVICE_NAME); return -1; *************** *** 284,294 **** }while( blk_hash_table==NULL && --order > 0 ); ! printk("%s: num_physpages (%ld) PAGE_SHIFT (%d) goal(%d) blk_hash_mask(%x)\n", DEVICE_NAME, num_physpages, PAGE_SHIFT, goal, blk_hash_mask); if(!blk_hash_table) { ! printk("%s: Failed to alloc blk hash table\n",DEVICE_NAME); } else { ! printk("%s: blk_hash_table of %u buckets, %ldKbytes\n", DEVICE_NAME, blk_hash_mask, (long)(blk_hash_mask * sizeof(struct blk_hash_bucket))/1024); --- 288,298 ---- }while( blk_hash_table==NULL && --order > 0 ); ! gwc_printk(GWC_KSYS_IDX, "%s: num_physpages (%ld) PAGE_SHIFT (%d) goal(%d) blk_hash_mask(%x)\n", DEVICE_NAME, num_physpages, PAGE_SHIFT, goal, blk_hash_mask); if(!blk_hash_table) { ! gwc_printk(GWC_KSYS_IDX, "%s: Failed to alloc blk hash table\n",DEVICE_NAME); } else { ! gwc_printk(GWC_KSYS_IDX, "%s: blk_hash_table of %u buckets, %ldKbytes\n", DEVICE_NAME, blk_hash_mask, (long)(blk_hash_mask * sizeof(struct blk_hash_bucket))/1024); *************** *** 301,305 **** } ! printk("%s: Success to initialize blk hash table \n",DEVICE_NAME); return 1; } --- 305,309 ---- } ! gwc_printk(GWC_KSYS_IDX, "%s: Success to initialize blk hash table \n",DEVICE_NAME); return 1; } *************** *** 430,439 **** { ! printk("%s: Device open (%d, %d)\n", KUIO_DEVICE_NAME, MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); if ((filp->f_flags & O_ACCMODE) & (O_WRONLY | O_RDWR)) { ! if (kuio_wdopen) { ! printk("%s: Device already open for writing\n", KUIO_DEVICE_NAME); return -EBUSY; } else --- 434,444 ---- { ! gwc_printk(GWC_KSYS_IDX, "%s: Device open (%d, %d)\n", KUIO_DEVICE_NAME, MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); if ((filp->f_flags & O_ACCMODE) & (O_WRONLY | O_RDWR)) { ! ! if (kuio_wdopen) { ! gwc_printk(GWC_KSYS_IDX, "%s: Device already open for writing\n", KUIO_DEVICE_NAME); return -EBUSY; } else *************** *** 442,446 **** else { if (kuio_rdopen) { ! printk("%s: Device already open for reading\n", KUIO_DEVICE_NAME); return -EBUSY; } else --- 447,451 ---- else { if (kuio_rdopen) { ! gwc_printk(GWC_KSYS_IDX, "%s: Device already open for reading\n", KUIO_DEVICE_NAME); return -EBUSY; } else *************** *** 456,460 **** { ! printk("%s: Device release (%d, %d)\n", KUIO_DEVICE_NAME, MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); --- 461,465 ---- { ! gwc_printk(GWC_KSYS_IDX, "%s: Device release (%d, %d)\n", KUIO_DEVICE_NAME, MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); *************** *** 569,572 **** --- 574,578 ---- }; + static int init_kuio(void) *************** *** 574,586 **** int ret; ! printk("%s: Loading kernel vs user IO module ... \n", KUIO_DEVICE_NAME); if ((ret = register_chrdev(KUIO_MAJOR_NUM, KUIO_DEVICE_NAME,&device_fops)) < 0) { ! printk("%s: Registration failed (%d)\n", KUIO_DEVICE_NAME, ret); return ret; } ! printk("%s: Registered with major Number = %d\n", KUIO_DEVICE_NAME, KUIO_MAJOR_NUM); return 0; } --- 580,592 ---- int ret; ! gwc_printk(GWC_KSYS_IDX, "%s: Loading kernel vs user IO module ... \n", KUIO_DEVICE_NAME); if ((ret = register_chrdev(KUIO_MAJOR_NUM, KUIO_DEVICE_NAME,&device_fops)) < 0) { ! gwc_printk(GWC_KSYS_IDX, "%s: Registration failed (%d)\n", KUIO_DEVICE_NAME, ret); return ret; } ! gwc_printk(GWC_KSYS_IDX, "%s: Registered with major Number = %d\n", KUIO_DEVICE_NAME, KUIO_MAJOR_NUM); return 0; } *************** *** 591,597 **** int ret; ! printk("%s: Unloading kernel vs user I/O module ...\n", KUIO_DEVICE_NAME); if ((ret = unregister_chrdev(KUIO_MAJOR_NUM, DEVICE_NAME)) < 0) ! printk("%s: Device unregistration failed (%d)\n", KUIO_DEVICE_NAME, ret); } --- 597,603 ---- int ret; ! gwc_printk(GWC_KSYS_IDX, "%s: Unloading kernel vs user I/O module ...\n", KUIO_DEVICE_NAME); if ((ret = unregister_chrdev(KUIO_MAJOR_NUM, DEVICE_NAME)) < 0) ! gwc_printk(GWC_KSYS_IDX, "%s: Device unregistration failed (%d)\n", KUIO_DEVICE_NAME, ret); } *************** *** 599,603 **** init_pf(void) { ! printk("%s: Register nfhook ...\n", DEVICE_NAME); iphook_tab.hook = ip_hook_func; iphook_tab.hooknum = NF_IP_PRE_ROUTING; --- 605,609 ---- init_pf(void) { ! gwc_printk(GWC_KSYS_IDX, "%s: Register nfhook ...\n", DEVICE_NAME); iphook_tab.hook = ip_hook_func; iphook_tab.hooknum = NF_IP_PRE_ROUTING; *************** *** 612,616 **** exit_pf(void) { ! printk("%s: Unregister nfhook modules...\n", DEVICE_NAME); nf_unregister_hook(&iphook_tab); return 0; --- 618,622 ---- exit_pf(void) { ! gwc_printk(GWC_KSYS_IDX, "%s: Unregister nfhook modules...\n", DEVICE_NAME); nf_unregister_hook(&iphook_tab); return 0; *************** *** 621,625 **** { ! printk("%s: Loading %s module ...\n", DEVICE_NAME, DEVICE_NAME); if ( init_blk_hash_table() < 0 ) { --- 627,631 ---- { ! gwc_printk(GWC_KSYS_IDX, "%s: Loading %s module ...\n", DEVICE_NAME, DEVICE_NAME); if ( init_blk_hash_table() < 0 ) { *************** *** 632,641 **** pf_ktimer = init_sysktimer (update_eat, NULL, 0, 0, 1000000000); if (!pf_ktimer) { ! printk("%s: Failed to init sysktimer\n", DEVICE_NAME); return 1; } if ((tid = register_sysktimer (pf_ktimer)) < 0 ) { ! printk("%s: Failed to register sysktimer\n", DEVICE_NAME); } --- 638,647 ---- pf_ktimer = init_sysktimer (update_eat, NULL, 0, 0, 1000000000); if (!pf_ktimer) { ! gwc_printk(GWC_KSYS_IDX, "%s: Failed to init sysktimer\n", DEVICE_NAME); return 1; } if ((tid = register_sysktimer (pf_ktimer)) < 0 ) { ! gwc_printk(GWC_KSYS_IDX, "%s: Failed to register sysktimer\n", DEVICE_NAME); } *************** *** 650,661 **** if ( tid > 1 && ((ret = unregister_sysktimer(tid, pf_ktimer))) < 0 ) { ! printk("%s: Failed to unregister timer (%d)\n", DEVICE_NAME, ret); } ! printk("%s: Unloading %s modules...\n", DEVICE_NAME, DEVICE_NAME); exit_pf(); if ( free_blk_hash_table() < 0 ) { ! printk ("%s: Failed to free all resources\n", DEVICE_NAME); } exit_kuio(); --- 656,667 ---- if ( tid > 1 && ((ret = unregister_sysktimer(tid, pf_ktimer))) < 0 ) { ! gwc_printk(GWC_KSYS_IDX, "%s: Failed to unregister timer (%d)\n", DEVICE_NAME, ret); } ! gwc_printk(GWC_KSYS_IDX, "%s: Unloading %s modules...\n", DEVICE_NAME, DEVICE_NAME); exit_pf(); if ( free_blk_hash_table() < 0 ) { ! gwc_printk (GWC_KSYS_IDX, "%s: Failed to free all resources\n", DEVICE_NAME); } exit_kuio(); *************** *** 663,668 **** module_exit(gwc_pf_exit); - module_param(debug, int, 0444); - MODULE_PARM_DESC(debug, "enable pfilter debug output (default 0 off)"); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); --- 669,672 ---- Index: sysktimer.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/sysktimer.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sysktimer.c 18 Mar 2006 17:45:41 -0000 1.4 --- sysktimer.c 6 May 2006 15:21:07 -0000 1.5 *************** *** 1,7 **** ! /* ! * filename : sysktimer.c ! * 2006. 02. 28. (thu) 08:38:14 KST ! * jeho park <lin...@us...> ! */ #include <linux/init.h> --- 1,10 ---- ! /* ! Title : sysktimer.c ! Author : Jeho-Park <de...@sk...> ! Created date : 2006. 05. 05. (Fri) 18:08:22 KST ! Description : dynamic kernel timer of gwc ! ! */ ! #ident "@(#) $Header$" #include <linux/init.h> *************** *** 13,21 **** #include <linux/interrupt.h> #include <linux/kthread.h> #include "sysktimer.h" ! #define DRIVER_AUTHOR "jeho park <lin...@gm...>" #define DRIVER_VERSION "gwc-timer-" SZSYSVERSION #define DRIVER_DESC "gwc of netadm project " DRIVER_VERSION static int netadm_timer_thread (void *data) { --- 16,28 ---- #include <linux/interrupt.h> #include <linux/kthread.h> + #include "sysklog.h" #include "sysktimer.h" ! #define DRIVER_AUTHOR "jeho park <de...@sk...>" #define DRIVER_VERSION "gwc-timer-" SZSYSVERSION #define DRIVER_DESC "gwc of netadm project " DRIVER_VERSION + static unsigned long debug = DBG_GENERAL; + module_param(debug, ulong, 0644); + MODULE_PARM_DESC(debug, "debug bitmap"); static int netadm_timer_thread (void *data) { *************** *** 28,37 **** if (!p) { ret = -1; ! printk("null timer struct.\n"); } if ( p->t_time < 0 || p->t.tv_sec < 0 || p->t.tv_nsec < 0) { ret = -1; ! printk("invalid argument.\n"); } --- 35,44 ---- if (!p) { ret = -1; ! gwc_printk(GWC_KSYS_IDX,"null timer struct.\n"); } if ( p->t_time < 0 || p->t.tv_sec < 0 || p->t.tv_nsec < 0) { ret = -1; ! gwc_printk(GWC_KSYS_IDX,"invalid argument.\n"); } *************** *** 39,43 **** return ret; ! printk("%s timer start, timeout time: %d\n", DRIVER_VERSION, p->t_time); expire = timespec_to_jiffies(&p->t) + (p->t.tv_sec || p->t.tv_nsec); --- 46,50 ---- return ret; ! gwc_printk(GWC_KSYS_IDX,"%s timer start, timeout time: %d\n", DRIVER_VERSION, p->t_time); expire = timespec_to_jiffies(&p->t) + (p->t.tv_sec || p->t.tv_nsec); *************** *** 45,49 **** if ( p->t_time > 0 && jiffies > ( p->t_time * HZ + i_time) ) { ! printk("%s: timer timeout(%d)...\n", DRIVER_VERSION, p->t_time); break; } --- 52,56 ---- if ( p->t_time > 0 && jiffies > ( p->t_time * HZ + i_time) ) { ! gwc_printk(GWC_KSYS_IDX,"%s: timer timeout(%d)...\n", DRIVER_VERSION, p->t_time); break; } *************** *** 58,62 **** * i definitly assumed it was stemed from mine */ ! printk("%s: timer exit by user request\n", DRIVER_VERSION); return 1; } --- 65,69 ---- * i definitly assumed it was stemed from mine */ ! gwc_printk(GWC_KSYS_IDX,"%s: timer exit by user request\n", DRIVER_VERSION); return 1; } *************** *** 76,80 **** in_interrupt()? GFP_ATOMIC : GFP_KERNEL); if (!sysktimer) { ! printk("%s: Failed to kmalloc\n", DRIVER_VERSION); return NULL; } --- 83,87 ---- in_interrupt()? GFP_ATOMIC : GFP_KERNEL); if (!sysktimer) { ! gwc_printk(GWC_KSYS_IDX,"%s: Failed to kmalloc\n", DRIVER_VERSION); return NULL; } *************** *** 90,94 **** sysktimer->t.tv_nsec = p_nsec; ! printk("%s: successfully initialized sysktimer data\n", DRIVER_VERSION); return sysktimer; } --- 97,101 ---- sysktimer->t.tv_nsec = p_nsec; ! gwc_printk(GWC_KSYS_IDX,"%s: successfully initialized sysktimer data\n", DRIVER_VERSION); return sysktimer; } *************** *** 100,104 **** tsk = kthread_create ( netadm_timer_thread, timer, "%s", DRIVER_VERSION); if (IS_ERR(tsk)) { ! printk("can't create netadm_timer\n"); return -EAGAIN; } --- 107,111 ---- tsk = kthread_create ( netadm_timer_thread, timer, "%s", DRIVER_VERSION); if (IS_ERR(tsk)) { ! gwc_printk(GWC_KSYS_IDX,"can't create netadm_timer\n"); return -EAGAIN; } *************** *** 117,124 **** ret = kthread_stop(tsk); if (ret < 0 ) { ! printk("%s: Failed to stop task(%d)\n", DRIVER_VERSION, pid); } else { ! printk("%s: Success to stop pid(%d)\n", DRIVER_VERSION, pid); } --- 124,131 ---- ret = kthread_stop(tsk); if (ret < 0 ) { ! gwc_printk(GWC_KSYS_IDX,"%s: Failed to stop task(%d)\n", DRIVER_VERSION, pid); } else { ! gwc_printk(GWC_KSYS_IDX,"%s: Success to stop pid(%d)\n", DRIVER_VERSION, pid); } *************** *** 127,131 **** } else { ! printk("%s: There is no suck task(%d), sysktimer(%s)\n", DRIVER_VERSION, pid, sysktimer? "not null must be free":"null"); } --- 134,138 ---- } else { ! gwc_printk(GWC_KSYS_IDX,"%s: There is no suck task(%d), sysktimer(%s)\n", DRIVER_VERSION, pid, sysktimer? "not null must be free":"null"); } *************** *** 137,141 **** static int __init init_netadm_timer(void) { ! printk("%s: register netadm timer\n", DRIVER_VERSION); return 0; } --- 144,148 ---- static int __init init_netadm_timer(void) { ! gwc_printk(GWC_KSYS_IDX,"%s: register netadm timer\n", DRIVER_VERSION); return 0; } *************** *** 144,148 **** static void __exit exit_netadm_timer(void) { ! printk("%s: unregister netadm timer\n", DRIVER_VERSION); } --- 151,155 ---- static void __exit exit_netadm_timer(void) { ! gwc_printk(GWC_KSYS_IDX,"%s: unregister netadm timer\n", DRIVER_VERSION); } Index: Makefile =================================================================== RCS file: /cvsroot/netadm/gwc/pf/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 30 Apr 2006 18:47:25 -0000 1.5 --- Makefile 6 May 2006 15:21:07 -0000 1.6 *************** *** 2,6 **** # # Title : Makefile ! # Author : Jeho-Park <lin...@gm...> # Created date : 2006. 01. 31. (thu) 01:40:38 KST # Description : Makefile for pf --- 2,6 ---- # # Title : Makefile ! # Author : Jeho-Park <de...@sk...> # Created date : 2006. 01. 31. (thu) 01:40:38 KST # Description : Makefile for pf *************** *** 10,13 **** --- 10,14 ---- obj-m += sysktimer.o obj-m += pf.o + obj-m += sysklog.o KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) |
From: linuxpark <lin...@us...> - 2006-05-09 00:47:16
|
Update of /cvsroot/netadm/gwc/pf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26320a Added Files: sysklog.h sysklog.c Log Message: Initial Check-In sysklog : kernel logging module just only for gwc kernel modules kernel module must not use printk instead, use "gwc_printk" int gwc_printk (flag, fmt, args ...) flag: definition: include/global.h GWC_PF_IDX : packet or session log, log file: gwc_pf.log GWC_KSYS_IDX : system log, log file: gwc_ksys.log fmt, args : it is same as printk () example) gwc_printk (GWC_PF_IDX, "%s: some ugly packet IP: %u.%u.%u.%u received\n", DEVICE_NAME, NIPQUAD (addr)); --- NEW FILE: sysklog.c --- /* Title : sysklog.c Author : Jeho-Park <de...@sk...> Created date : 2006. 05. 05. (Fri) 15:02:31 KST Description : gwc kernel log module for logging other modules of gwc's idea and base code was from linux/kernel/printk.c and fs/proc/misc.c */ #ident "@(#) $Header: /cvsroot/netadm/gwc/pf/sysklog.c,v 1.1 2006/05/06 15:17:47 linuxpark Exp $" #include <linux/kernel.h> #include <linux/mm.h> #include <linux/tty.h> #include <linux/tty_driver.h> #include <linux/smp_lock.h> #include <linux/console.h> #include <linux/init.h> #include <linux/module.h> #include <linux/interrupt.h> /* For in_interrupt() */ #include <linux/sched.h> #include <linux/config.h> #include <linux/delay.h> #include <linux/smp.h> #include <linux/security.h> #include <linux/syscalls.h> #include <asm/uaccess.h> #include <linux/slab.h> #include <linux/types.h> #include <linux/errno.h> #include <linux/time.h> #include <linux/poll.h> #include <linux/fs.h> #include <asm/io.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> #include "sysklog.h" #include "../include/global.h" static const char gwc_klog_driver_name[] = "gwc-klog"; static const char gwc_klog_driver_string[] = "gwc kernel log module"; #define gwc_klog_driver_version "0.0.1" MODULE_AUTHOR("jeho park <de...@sk...>"); MODULE_DESCRIPTION("gwc kernel log module"); MODULE_LICENSE("GPL"); MODULE_VERSION(gwc_klog_driver_version); static unsigned long debug = DBG_GENERAL; module_param(debug, ulong, 0644); MODULE_PARM_DESC(debug, "debug bitmap"); /* We show everything that is MORE important than this.. */ /* * TODO: if you want more sub entry, follow these step * 1. Add index GWC_XXX_IDX and recount MAXSYSIDX * 2. Add proc entry * 3. Add proc handlers * * --LP */ #ifndef SET_MODULE_OWNER #define SET_MODULE_OWNER(p) do { p->owner = THIS_MODULE; } while (0) #endif #if defined (USE_KLOG_PROC) && defined (CONFIG_PROC_FS) static struct proc_dir_entry *proc_gwc_root; static struct proc_dir_entry *gwc_pf_entry; static struct proc_dir_entry *gwc_sysk_entry; #else static int kctl_rcnt [MAXSYSIDX]; #endif static spinlock_t logbuf_lock [MAXSYSIDX]; static wait_queue_head_t log_wait [MAXSYSIDX]; /* * The indices into log_buf are not constrained to log_buf_len - they * must be masked before subscripting */ static unsigned long log_start [MAXSYSIDX]; static unsigned long log_end [MAXSYSIDX]; static char __log_buf[MAXSYSIDX][__SYS_LOG_BUFLEN]; static char *log_buf [MAXSYSIDX]; static int log_buf_len = __SYS_LOG_BUFLEN; static unsigned long logged_chars[MAXSYSIDX]; static void init_gwc_logbuf (void ) { int i; for (i = 0; i < MAXSYSIDX; i++) { logbuf_lock [i] = SPIN_LOCK_UNLOCKED; log_buf [i] = __log_buf [i]; } } #undef LOG_BUF_MASK #define LOG_BUF_MASK (log_buf_len-1) #undef LOG_BUF #define LOG_BUF(idx, w) (log_buf[idx][(w) & LOG_BUF_MASK]) static void init_gwc_wait_queue_heads (wait_queue_head_t *wq, int max) { int i; for (i = 0; i < max; i++) { wq[i].lock = SPIN_LOCK_UNLOCKED; wq[i].task_list.next = wq[i].task_list.prev = &wq[i].task_list; } } /* * Commands to do_gwc_sysklog: * * 0 -- Close the log. Currently a NOP. * 1 -- Open the log. Currently a NOP. * 2 -- Read from the log. * 3 -- Read all messages remaining in the ring buffer. * 4 -- Read and clear all messages remaining in the ring buffer * 5 -- Clear ring buffer. * 6 -- Disable printk's to console * 7 -- Enable printk's to console * 8 -- Set level of messages printed to console * 9 -- Return number of unread characters in the log buffer * 10 -- Return size of the log buffer */ int do_gwc_sysklog(int idx, int type, char __user * buf, int len) { unsigned long i, j, limit, count; int do_clear = 0; char c; int error = 0; error = security_syslog(type); if (error) return error; switch (type) { case 0: /* Close log */ dprintk("\n"); if (kctl_rcnt [idx] <= 0 ) { printk ("%s: Device(type: %d) already released for reading\n", gwc_klog_driver_name, kctl_rcnt [idx]); return error; } else { --kctl_rcnt [idx]; } module_put(THIS_MODULE); break; case 1: /* Open log */ dprintk("\n"); if (kctl_rcnt [idx]) { printk ("%s: Device(type: %d) already open for reading\n", gwc_klog_driver_name, kctl_rcnt [idx]); return -EBUSY; } else { ++kctl_rcnt [idx]; } try_module_get(THIS_MODULE); break; case 2: /* Read from log */ error = -EINVAL; if (!buf || len < 0) goto out; error = 0; if (!len) goto out; if (!access_ok(VERIFY_WRITE, buf, len)) { error = -EFAULT; goto out; } error = wait_event_interruptible(log_wait[idx], (log_start[idx] - log_end[idx])); if (error) goto out; i = 0; spin_lock_irq(&logbuf_lock[idx]); while (!error && (log_start[idx] != log_end[idx]) && i < len) { c = LOG_BUF(idx, log_start[idx]); log_start[idx]++; spin_unlock_irq(&logbuf_lock[idx]); error = __put_user(c,buf); buf++; i++; cond_resched(); spin_lock_irq(&logbuf_lock[idx]); } spin_unlock_irq(&logbuf_lock[idx]); if (!error) error = i; break; case 4: /* Read/clear last kernel messages */ dprintk("\n"); /* TODO: delete me --LP */ do_clear = 1; /* FALL THRU */ case 3: /* Read last kernel messages */ dprintk("\n");/* TODO: delete me --LP */ error = -EINVAL; if (!buf || len < 0) goto out; error = 0; if (!len) goto out; if (!access_ok(VERIFY_WRITE, buf, len)) { error = -EFAULT; goto out; } count = len; if (count > log_buf_len) count = log_buf_len; spin_lock_irq(&logbuf_lock[idx]); if (count > logged_chars[idx]) count = logged_chars[idx]; if (do_clear) logged_chars[idx] = 0; limit = log_end [idx]; /* * __put_user() could sleep, and while we sleep * printk() could overwrite the messages * we try to copy to user space. Therefore * the messages are copied in reverse. <manfreds> */ for(i = 0; i < count && !error; i++) { j = limit-1-i; if (j + log_buf_len < log_end [idx]) break; c = LOG_BUF(idx, j); spin_unlock_irq(&logbuf_lock[idx]); error = __put_user(c,&buf[count-1-i]); cond_resched(); spin_lock_irq(&logbuf_lock [idx]); } spin_unlock_irq(&logbuf_lock[idx]); if (error) break; error = i; if(i != count) { int offset = count-error; /* buffer overflow during copy, correct user buffer. */ for(i=0;i<error;i++) { if (__get_user(c,&buf[i+offset]) || __put_user(c,&buf[i])) { error = -EFAULT; break; } cond_resched(); } } break; case 5: /* Clear ring buffer */ logged_chars[idx] = 0; break; case 9: /* Number of chars in the log buffer */ error = log_end[idx] - log_start[idx]; break; case 10: /* Size of the log buffer */ error = log_buf_len; break; default: error = -EINVAL; break; } out: return error; } #if 0 /* i don't have interest this syscall 3 --LP */ #ifdef CONFIG_GWC_SYSLOG_SYSCALL asmlinkage long sys_gwc_syslog(int idx, int type, char __user * buf, int len) { return do_gwc_sysklog(idx, type, buf, len); } #endif /* #ifdef CONFIG_GWC_SYSLOG_SYSCALL */ #endif static void emit_log_char(int idx, char c) { LOG_BUF(idx, log_end[idx]) = c; log_end[idx]++; if (log_end[idx] - log_start[idx] > log_buf_len) log_start[idx] = log_end[idx] - log_buf_len; if (logged_chars[idx] < log_buf_len) logged_chars[idx]++; } /* * Zap console related locks when oopsing. Only zap at most once * every 10 seconds, to leave time for slow consoles to print a * full oops. */ static void zap_locks(int idx) { static unsigned long oops_timestamp; if (time_after_eq(jiffies, oops_timestamp) && !time_after(jiffies, oops_timestamp + 30*HZ)) return; oops_timestamp = jiffies; /* If a crash is occurring, make sure we can't deadlock */ spin_lock_init(&logbuf_lock [idx]); } static int printk_time = 1; __attribute__((weak)) unsigned long long gwc_printk_clock(void) { return (unsigned long long)jiffies * (1000000000 / HZ); } /* * gwc_printk rate limiting, lifted from the networking subsystem. * * This enforces a rate limit: not more than one kernel message * every printk_ratelimit_jiffies to make a denial-of-service * attack impossible. */ int __gwc_printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst) { static DEFINE_SPINLOCK(ratelimit_lock); static unsigned long toks = 10*5*HZ; static unsigned long last_msg; static int missed; unsigned long flags; unsigned long now = jiffies; spin_lock_irqsave(&ratelimit_lock, flags); toks += now - last_msg; last_msg = now; if (toks > (ratelimit_burst * ratelimit_jiffies)) toks = ratelimit_burst * ratelimit_jiffies; if (toks >= ratelimit_jiffies) { int lost = missed; missed = 0; toks -= ratelimit_jiffies; spin_unlock_irqrestore(&ratelimit_lock, flags); if (lost) printk(KERN_WARNING "printk: %d messages suppressed.\n", lost); return 1; } missed++; spin_unlock_irqrestore(&ratelimit_lock, flags); return 0; } /* minimum time in jiffies between messages */ static int printk_ratelimit_jiffies = 1*HZ; /* number of messages we send before ratelimiting */ static int printk_ratelimit_burst = 1; int gwc_printk_ratelimit(void) { return __gwc_printk_ratelimit(printk_ratelimit_jiffies, printk_ratelimit_burst); } /* cpu currently holding logbuf_lock */ static volatile unsigned int printk_cpu = UINT_MAX; asmlinkage int gwc_vprintk(int idx, const char *fmt, va_list args) { unsigned long flags; int printed_len; char *p; static char printk_buf[1024]; static int log_level_unknown = 1; preempt_disable(); if (unlikely(oops_in_progress) && printk_cpu == smp_processor_id()) /* If a crash is occurring during printk() on this CPU, * make sure we can't deadlock */ zap_locks(idx); /* This stops the holder of console_sem just where we want him */ spin_lock_irqsave(&logbuf_lock[idx], flags); printk_cpu = smp_processor_id(); /* Emit the output into the temporary buffer */ printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args); /* * Copy the output into log_buf. If the caller didn't provide * appropriate log level tags, we insert them here */ for (p = printk_buf; *p; p++) { if (log_level_unknown) { /* log_level_unknown signals the start of a new line */ if (printk_time) { int loglev_char; char tbuf[50], *tp; unsigned tlen; unsigned long long t; unsigned long nanosec_rem; /***********************************************************************************/ /* TODO: * force the log level token to be * before the time output. * *********************************************************************************/ if (p[0] == '<' && p[1] >='0' && p[1] <= '9' && p[2] == '>') { loglev_char = p[1]; p += 3; printed_len += 3; } else { loglev_char = default_message_loglevel + '0'; } t = gwc_printk_clock(); nanosec_rem = do_div(t, 1000000000); tlen = sprintf(tbuf, "<%c>[%5lu.%06lu] ", loglev_char, (unsigned long)t, nanosec_rem/1000); for (tp = tbuf; tp < tbuf + tlen; tp++) emit_log_char(idx, *tp); printed_len += tlen - 3; } else { if (p[0] != '<' || p[1] < '0' || p[1] > '9' || p[2] != '>') { emit_log_char(idx, '<'); emit_log_char(idx, default_message_loglevel + '0'); emit_log_char(idx, '>'); } printed_len += 3; } log_level_unknown = 0; if (!*p) break; } emit_log_char(idx, *p); if (*p == '\n') log_level_unknown = 1; } if (!cpu_online(smp_processor_id())) { /* * Some console drivers may assume that per-cpu resources have * been allocated. So don't allow them to be called by this * CPU until it is officially up. We shouldn't be calling into * random console drivers on a CPU which doesn't exist yet.. */ printk_cpu = UINT_MAX; spin_unlock_irqrestore(&logbuf_lock, flags); goto out; } printk_cpu = UINT_MAX; spin_unlock_irqrestore(&logbuf_lock, flags); out: preempt_enable(); return printed_len; } /* * This is gwc_printk. It can be called from any context. We want it to work. */ asmlinkage int gwc_printk(int idx, const char *fmt, ...) { va_list args; int r; va_start(args, fmt); r = gwc_vprintk(idx, fmt, args); va_end(args); wake_up_interruptible (&log_wait[idx]); return r; } EXPORT_SYMBOL_GPL (gwc_printk); /* * gwc kctl file handler lists * * @sys_xxxmsg_{open|release|read|poll|} */ static int gwc_pf_open(struct inode * inode, struct file * file) { return do_gwc_sysklog(GWC_PF_IDX, 1, NULL, 0); } static int gwc_pf_release(struct inode * inode, struct file * file) { (void) do_gwc_sysklog(GWC_PF_IDX, 0, NULL, 0); return 0; } static ssize_t gwc_pf_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { if ((file->f_flags & O_NONBLOCK) && !do_gwc_sysklog(GWC_PF_IDX, 9, NULL, 0)) return -EAGAIN; return do_gwc_sysklog(GWC_PF_IDX, 2, buf, count); } static unsigned int gwc_pf_poll(struct file *file, poll_table *wait) { poll_wait(file, &log_wait[GWC_PF_IDX], wait); if (do_gwc_sysklog(GWC_PF_IDX, 9, NULL, 0)) return POLLIN | POLLRDNORM; return 0; } struct file_operations gwc_pf_operations = { .read = gwc_pf_read, .poll = gwc_pf_poll, .open = gwc_pf_open, .release = gwc_pf_release, }; static int gwc_sys_open(struct inode * inode, struct file * file) { dprintk ("\n"); return do_gwc_sysklog(GWC_KSYS_IDX, 1, NULL, 0); } static int gwc_sys_release(struct inode * inode, struct file * file) { dprintk ("\n"); (void) do_gwc_sysklog(GWC_KSYS_IDX, 0, NULL, 0); return 0; } static ssize_t gwc_sys_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { if ((file->f_flags & O_NONBLOCK) && !do_gwc_sysklog(GWC_KSYS_IDX, 9, NULL, 0)) return -EAGAIN; return do_gwc_sysklog(GWC_KSYS_IDX, 2, buf, count); } static unsigned int gwc_sys_poll(struct file *file, poll_table *wait) { static int i = 0; printk ("------->wait ... (%d)\n", i++); poll_wait(file, &log_wait[GWC_KSYS_IDX], wait); printk ("-------------------->cool !(%d)\n", i++); if (do_gwc_sysklog(GWC_KSYS_IDX, 9, NULL, 0)) return POLLIN | POLLRDNORM; return 0; } struct file_operations gwc_sys_operations = { .read = gwc_sys_read, .poll = gwc_sys_poll, .open = gwc_sys_open, .release = gwc_sys_release, }; static void init_gwc_kctl (void) { #if defined (USE_KLOG_PROC) && defined (CONFIG_PROC_FS) proc_gwc_root = proc_mkdir(GWC_PROC_DIR, &proc_root); if (proc_gwc_root) { SET_MODULE_OWNER(proc_gwc_root); } else { printk (KERN_WARNING "%s: Failed to create \'%s\' proc dir\n", gwc_klog_driver_name, GWC_PROC_DIR); return; } gwc_pf_entry = create_proc_entry(PF_PROC_ENTRY, S_IFREG | S_IRUSR, proc_gwc_root); if (gwc_pf_entry) { gwc_pf_entry->proc_fops = &gwc_pf_operations; SET_MODULE_OWNER(gwc_pf_entry); } else { printk (KERN_WARNING "%s: Failed to create \'%s\' proc entry\n", gwc_klog_driver_name, PF_PROC_ENTRY); } gwc_sysk_entry = create_proc_entry("syskmsg", S_IFREG | S_IRUSR, proc_gwc_root); if (gwc_sysk_entry) { gwc_sysk_entry->proc_fops = &gwc_sys_operations; SET_MODULE_OWNER(gwc_sysk_entry); } else { printk (KERN_WARNING "%s: Failed to create \'%s\' proc entry\n", gwc_klog_driver_name, SYS_PROC_ENTRY); } #else int i; if (register_chrdev(GWC_PF_MAJORNUM, GWC_PF_DNAME, &gwc_pf_operations) < 0) { printk(KERN_WARNING "%s: Failed to Registrate %s\n", gwc_klog_driver_name, GWC_PF_DNAME); return; } if (register_chrdev(GWC_SYS_MAJORNUM, GWC_SYS_DNAME, &gwc_sys_operations) < 0) { printk(KERN_WARNING "%s: Failed to Registrate %s\n", gwc_klog_driver_name, GWC_SYS_DNAME); return; } for (i = 0; i < MAXSYSIDX; i++) kctl_rcnt [i] = 0; #endif printk (KERN_INFO "%s: Success to load gwc kctl module ...\n", gwc_klog_driver_name); } static void destroy_gwc_proc (void) { #if defined (USE_KLOG_PROC) && defined (CONFIG_PROC_FS) remove_proc_entry (PF_PROC_ENTRY, proc_gwc_root); remove_proc_entry (SYS_PROC_ENTRY, proc_gwc_root); remove_proc_entry (GWC_PROC_DIR, &proc_root); #else printk (KERN_INFO "%s: Unloading gwc kctl module ...\n", gwc_klog_driver_name); if (unregister_chrdev(GWC_PF_MAJORNUM, GWC_PF_DNAME) < 0) { printk(KERN_WARNING "%s: Failed to Unregister %s\n", gwc_klog_driver_name, GWC_PF_DNAME); } if (unregister_chrdev(GWC_SYS_MAJORNUM, GWC_SYS_DNAME) < 0) { printk(KERN_WARNING "%s: Failed to Unregister %s\n", gwc_klog_driver_name, GWC_SYS_DNAME); } printk (KERN_INFO "%s: Success to unregister gwc kctl module ...\n", gwc_klog_driver_name); #endif } static int gwc_klog_init(void) { printk (KERN_INFO "Registering %s-%s ...\n", gwc_klog_driver_name, gwc_klog_driver_version); init_gwc_wait_queue_heads (log_wait, MAXSYSIDX); init_gwc_logbuf (); init_gwc_kctl (); gwc_printk_ratelimit (); return 0; } module_init(gwc_klog_init); static void __exit gwc_klog_exit(void) { printk (KERN_INFO "Unregistering %s-%s ...\n", gwc_klog_driver_name, gwc_klog_driver_version); destroy_gwc_proc (); } module_exit(gwc_klog_exit); --- NEW FILE: sysklog.h --- /* Title : sysklog.h Author : Jeho-Park <de...@sk...> Created date : 2006. 05. 05. (Fri) 15:02:31 KST Description : gwc kernel log module header for logging other modules of gwc's idea and base code was from linux/kernel/printk.c and fs/proc/misc.c */ #ident "@(#) $Header: /cvsroot/netadm/gwc/pf/sysklog.h,v 1.1 2006/05/06 15:17:47 linuxpark Exp $" #ifndef __SYS_SYSKLOG_H #define __SYS_SYSKLOG_H #include "../include/global.h" #define __SYS_LOG_BUFLEN (1 << CONFIG_LOG_BUF_SHIFT) /* We show everything that is MORE important than this.. */ /* * TODO: if you want more sub entry, follow these step * 1. Add index GWC_XXX_IDX and recount MAXSYSIDX * 2. Add proc entry * 3. Add proc handlers * * --LP */ #ifndef SET_MODULE_OWNER #define SET_MODULE_OWNER(p) do { p->owner = THIS_MODULE; } while (0) #endif /* * Commands to do_gwc_sysklog: * * 0 -- Close the log. Currently a NOP. * 1 -- Open the log. Currently a NOP. * 2 -- Read from the log. * 3 -- Read all messages remaining in the ring buffer. * 4 -- Read and clear all messages remaining in the ring buffer * 5 -- Clear ring buffer. * 6 -- Disable printk's to console * 7 -- Enable printk's to console * 8 -- Set level of messages printed to console * 9 -- Return number of unread characters in the log buffer * 10 -- Return size of the log buffer */ #if 0 int do_gwc_sysklog(int idx, int type, char __user * buf, int len); #endif #ifdef CONFIG_GWC_SYSLOG_SYSCALL asmlinkage long sys_gwc_syslog(int idx, int type, char __user * buf, int len); #endif /* #ifdef CONFIG_GWC_SYSLOG_SYSCALL */ /* * This is gwc_printk. It can be called from any context. We want it to work. * * We try to grab the console_sem. If we succeed, it's easy - we log the output and * call the console drivers. If we fail to get the semaphore we place the output * into the log buffer and return. The current holder of the console_sem will * notice the new output in release_console_sem() and will send it to the * consoles before releasing the semaphore. * * One effect of this deferred printing is that code which calls printk() and * then changes console_loglevel may break. This is because console_loglevel * is inspected when the actual printing occurs. */ asmlinkage int gwc_printk(int idx, const char *fmt, ...); #if 0 /* TODO: compile error --LP */ static inline int gwc_pflog ( const char *fmt, args...) { return gwc_printk (GWC_PF_IDX, fmt, args); } static inline int gwc_sysklog ( const char *fmt, args...) { return gwc_printk (GWC_KSYS_IDX, fmt, args); } #define gwc_pflog ( fmt, args...) do { \ gwc_printk (GWC_PF_IDX, fmt, ##args) \ } while (0) #define gwc_syslog ( fmt, args...) do { \ gwc_printk (GWC_KSYS_IDX, fmt, ##args) \ } while (0) #endif #define DBG_GENERAL 0 #define dprintk(fmt, args... ) do { \ if (debug) \ printk ("gwc-klog-%s: [%s:%d] " fmt, \ gwc_klog_driver_version, __FUNCTION__, __LINE__, ##args); \ } while(0) #endif /* __SYS_SYSKLOG_H */ |
From: linuxpark <lin...@us...> - 2006-05-08 23:59:02
|
Update of /cvsroot/netadm/gwc/pf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25226 Modified Files: pf.c Log Message: DEL: no needed auto variable. Index: pf.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/pf.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pf.c 6 May 2006 17:33:33 -0000 1.11 --- pf.c 6 May 2006 18:28:58 -0000 1.12 *************** *** 166,170 **** struct blk *blkh, **blkhp; int i; - static int j =0; /* TODO : remove me */ --- 166,169 ---- |
From: linuxpark <lin...@us...> - 2006-05-08 17:59:53
|
Update of /cvsroot/netadm/gwc/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17018/include Modified Files: global.h Log Message: MOD: make enable logr ratelimit. (not not complete) Index: global.h =================================================================== RCS file: /cvsroot/netadm/gwc/include/global.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** global.h 6 May 2006 17:33:33 -0000 1.8 --- global.h 6 May 2006 23:43:23 -0000 1.9 *************** *** 80,85 **** --- 80,87 ---- /* sysklog.ko and gwcklogd reference these macro definition below --LP */ #define MAXLOGLINE MAXBUF + #define MINSYSIDX -1 #define GWC_PF_IDX 0 #define GWC_KSYS_IDX 1 + /* TODO: more class, if needed */ #define MAXSYSIDX (GWC_KSYS_IDX + 1) #define DEV_DIR "/dev" *************** *** 96,98 **** --- 98,104 ---- #define GWC_KLOGDPROC_TIMEOUT 2 + /* GWCPK_BURST ( 25 msg ) / GWCPK_JIFFIES( 5 sec ) = 5 (msg /1sec) */ + #define GWCPK_JIFFIES 5 /* 1 sec = 1 * HZ , kernel define 5 */ + #define GWCPK_BURST 10 /* 10 message */ + #endif /* __SYS_GLOBAL_H */ |
From: linuxpark <lin...@us...> - 2006-05-08 17:59:51
|
Update of /cvsroot/netadm/gwc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17018 Modified Files: Makefile.tmpl Log Message: MOD: make enable logr ratelimit. (not not complete) Index: Makefile.tmpl =================================================================== RCS file: /cvsroot/netadm/gwc/Makefile.tmpl,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile.tmpl 6 May 2006 17:33:33 -0000 1.7 --- Makefile.tmpl 6 May 2006 23:43:23 -0000 1.8 *************** *** 15,24 **** INCLUDE = -I. -I../include ! #USR_DEBUG_LEVEL += -DUSE_IF_HOSTNAME ! #USR_DEBUG_LEVEL += -DUSE_IF_NETMASK ! #USR_DEBUG_LEVEL += -DHAVE_SOCKADDR_SA_LEN ! #USR_DEBUG_LEVEL += -DTC_DEBUG ! #USR_DEBUG_LEVEL += -DDEBUG ! USR_DEBUG_LEVEL += -DUSE_SYSLOG # DON'T USE LIMIT CLIENT POWER --- 15,42 ---- INCLUDE = -I. -I../include ! #DFLAGS += -DUSE_IF_HOSTNAME ! #DFLAGS += -DUSE_IF_NETMASK ! #DFLAGS += -DHAVE_SOCKADDR_SA_LEN ! #DFLAGS += -DTC_DEBUG ! ! # \ \ ! # DEBUG functionality ! # /-----------------------------------/ ! # If you want all of output to go to stdout, ! # disable USE_SYSLOG and then uncomment the definition below. ! #DFLAGS += -DDEBUG ! ! # \ \ ! # USE_SYSLOG functionality ! # /-----------------------------------/ ! # This MACRO will make all of output of out () function to syslog which ! # and disable dprintf and dprintk macro function ! DFLAGS += -DUSE_SYSLOG ! ! # \ \ ! # gwc_printk ratelimit functionality ! # /-----------------------------------/ ! # ! # If you use this function, you must uncomment USE_GWCPK_RATELIMIT" in pf/Makefile # DON'T USE LIMIT CLIENT POWER *************** *** 28,33 **** # For Debugging '-g' ! #CFLAGS = -g -Wall $(USR_DEBUG_LEVEL) $(SIGPW_CONTROL) ! CFLAGS = -O -Wall $(USR_DEBUG_LEVEL) $(SIGPW_CONTROL) GTKLDFLAGS = `pkg-config --libs gtk+-2.0` GTKCFLAGS = `pkg-config --cflags gtk+-2.0` --- 46,51 ---- # For Debugging '-g' ! #CFLAGS = -g -Wall $(DFLAGS) $(SIGPW_CONTROL) ! CFLAGS = -O -Wall $(DFLAGS) $(SIGPW_CONTROL) GTKLDFLAGS = `pkg-config --libs gtk+-2.0` GTKCFLAGS = `pkg-config --cflags gtk+-2.0` |
From: linuxpark <lin...@us...> - 2006-05-08 17:59:20
|
Update of /cvsroot/netadm/gwc/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17018/scripts Modified Files: gwc Log Message: MOD: make enable logr ratelimit. (not not complete) Index: gwc =================================================================== RCS file: /cvsroot/netadm/gwc/scripts/gwc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** gwc 6 May 2006 17:33:33 -0000 1.8 --- gwc 6 May 2006 23:43:23 -0000 1.9 *************** *** 250,253 **** --- 250,254 ---- exit_ipc stop gwcadmd + stop gwcklogd rmmod pf rmmod sysktimer *************** *** 263,267 **** rmmod sch_prio rmmod sch_sfq - stop gwcklogd rmmod sysklog printf "\n" --- 264,267 ---- |
From: linuxpark <lin...@us...> - 2006-05-08 17:58:42
|
Update of /cvsroot/netadm/gwc/gwcklogd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5943 Modified Files: gwcklogd.c Log Message: MOD: some other function which was used to run with syslogd through "/dev/log" was moved to the routine of "RUNWITH_SYSLOGD" defined code. Index: gwcklogd.c =================================================================== RCS file: /cvsroot/netadm/gwc/gwcklogd/gwcklogd.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gwcklogd.c 6 May 2006 17:33:33 -0000 1.2 --- gwcklogd.c 6 May 2006 17:49:48 -0000 1.3 *************** *** 39,45 **** static int kmsg; static int change_state = 0; - static int terminate = 0; static int caught_TSTP = 0; #ifdef RUNWITH_SYSLOGD /* i dont need to run with syslogd --LP (linuxpark, Jeho Park )*/ static char log_buffer[LOG_BUFFER_SIZE]; #endif --- 39,45 ---- static int kmsg; static int change_state = 0; static int caught_TSTP = 0; #ifdef RUNWITH_SYSLOGD /* i dont need to run with syslogd --LP (linuxpark, Jeho Park )*/ + static int terminate = 0; static char log_buffer[LOG_BUFFER_SIZE]; #endif *************** *** 52,58 **** static void closelogsrc(void); static void signaldaemon(int); - static void changelog(void); - static enum src get_klog_src(void); #ifdef RUNWITH_SYSLOGD static void logline(char *ptr, int len); #endif --- 52,58 ---- static void closelogsrc(void); static void signaldaemon(int); #ifdef RUNWITH_SYSLOGD + static enum src get_klog_src(void); + static void changelog(void); static void logline(char *ptr, int len); #endif *************** *** 347,350 **** --- 347,351 ---- } + #ifdef RUNWITH_SYSLOGD static void changelog(void) { *************** *** 374,378 **** } - static enum src get_klog_src(void) { int i; --- 375,378 ---- *************** *** 394,397 **** --- 394,398 ---- return (proc); } + #endif *************** *** 618,621 **** --- 619,635 ---- } #endif + + void dump_klogcmdtab () { + #ifdef DEBUG + for (i = 0; i < MAXSYSIDX; i++) { + out ("idx: %d, fd: %d, logfd: %d, devname: %s, log_file: %s\n", + klogcmdtab[i].idx, + klogcmdtab[i].fd, + klogcmdtab[i].log_fd, + klogcmdtab[i].devname, + klogcmdtab[i].log_file); + } + #endif + } int main( int argc, char ** argv) { *************** *** 681,689 **** /* This is the child closing its file descriptors. */ for (fl= 2; fl <= num_fds; ++fl) { - #if 0 - if ( fileno(stdout) == fl && use_output ) - if ( strcmp(output, "stdout") == 0 ) - continue; - #endif close(fl); } --- 695,698 ---- *************** *** 722,736 **** signal(SIGCONT, restart); - out ("1.\n"); - /* Open outputs. */ - #if 0 - if ( strcmp(output, "-") == 0 ) { - output_file = stdout; - } else if ( (output_file = fopen(output, "w")) == (FILE *) 0 ) { - out ("klogd: Cannot open output file %s - %s\n", output, strerror(errno)); - return 1; - } - #endif - out ("2.\n"); /* Determine where kernel logging information is to come from. */ for (i = 0; i < MAXSYSIDX; i++) { --- 731,734 ---- *************** *** 753,766 **** } } ! ! for (i = 0; i < MAXSYSIDX; i++) { ! out ("idx: %d, fd: %d, logfd: %d, devname: %s, log_file: %s\n", ! klogcmdtab[i].idx, ! klogcmdtab[i].fd, ! klogcmdtab[i].log_fd, ! klogcmdtab[i].devname, ! klogcmdtab[i].log_file); ! } out ("gwcklogd: Starting ...\n"); /* The main loop. */ while (1) { --- 751,758 ---- } } ! ! dump_klogcmdtab (); out ("gwcklogd: Starting ...\n"); + /* The main loop. */ while (1) { *************** *** 773,782 **** FD_SET( klogcmdtab[i].fd, &sock_set); } ! #if 0 ! if ( change_state ) { ! out ("Changelog.\n"); ! changelog(); ! } ! #endif tv.tv_sec = GWC_KLOGD_TIMEOUT * 60L; tv.tv_usec = 0; --- 765,769 ---- FD_SET( klogcmdtab[i].fd, &sock_set); } ! tv.tv_sec = GWC_KLOGD_TIMEOUT * 60L; tv.tv_usec = 0; *************** *** 791,795 **** } else if (!ret) { - out ("Timeout: continue ...\n"); continue; --- 778,781 ---- *************** *** 797,806 **** } else { - out ("receive kernel log\n"); for (i = 0; i < MAXSYSIDX; i++) { if( FD_ISSET(klogcmdtab[i].fd, &sock_set) ) { - out ("find idx [%d]\n", i); ret = klogcmdtab[i].func (NULL); if (ret < 0 ) { --- 783,790 ---- *************** *** 812,817 **** klogcmdtab[i].log_file ); - } else { - out ("success to handling kernel log\n"); } break; --- 796,799 ---- |
From: linuxpark <lin...@us...> - 2006-05-08 17:57:15
|
Update of /cvsroot/netadm/gwc/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10695/scripts Modified Files: gwc Log Message: MOD: modify time field of gwc sysklog kernel logger. Index: gwc =================================================================== RCS file: /cvsroot/netadm/gwc/scripts/gwc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** gwc 6 May 2006 23:43:23 -0000 1.9 --- gwc 8 May 2006 07:06:00 -0000 1.10 *************** *** 227,234 **** 'start') check_dev - reflesh_syslogd insmod ${MODDIR}/sysklog.ko debug=${DEBUG} insmod ${MODDIR}/sysktimer.ko debug=${DEBUG} insmod ${MODDIR}/pf.ko debug=${DEBUG} reload ip_tables reload iptable_filter --- 227,237 ---- 'start') check_dev insmod ${MODDIR}/sysklog.ko debug=${DEBUG} + start gwcklogd + reflesh_syslogd insmod ${MODDIR}/sysktimer.ko debug=${DEBUG} insmod ${MODDIR}/pf.ko debug=${DEBUG} + init_ipc + start gwcadmd reload ip_tables reload iptable_filter *************** *** 242,254 **** reload sch_prio reload sch_sfq - init_ipc - start gwcadmd - start gwcklogd printf "\n" ;; 'stop') - exit_ipc - stop gwcadmd - stop gwcklogd rmmod pf rmmod sysktimer --- 245,251 ---- *************** *** 264,267 **** --- 261,267 ---- rmmod sch_prio rmmod sch_sfq + exit_ipc + stop gwcadmd + stop gwcklogd rmmod sysklog printf "\n" |
From: linuxpark <lin...@us...> - 2006-05-08 17:52:50
|
Update of /cvsroot/netadm/gwc/pf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27258 Modified Files: sysklog.c Log Message: DEL: remove no needed auto var. Index: sysklog.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/sysklog.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sysklog.c 6 May 2006 17:33:33 -0000 1.2 --- sysklog.c 6 May 2006 20:48:08 -0000 1.3 *************** *** 533,538 **** static unsigned int gwc_sys_poll(struct file *file, poll_table *wait) { - static int i = 0; - poll_wait(file, &log_wait[GWC_KSYS_IDX], wait); --- 533,536 ---- |
From: linuxpark <lin...@us...> - 2006-05-08 17:47:58
|
Update of /cvsroot/netadm/gwc/gwcklogd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11261/gwcklogd Log Message: Directory /cvsroot/netadm/gwc/gwcklogd added to the repository |
From: linuxpark <lin...@us...> - 2006-05-08 17:45:35
|
Update of /cvsroot/netadm/gwc/gwcklogd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26611 Modified Files: gwcklogd.c Log Message: ADD: add newline in terminate message. Index: gwcklogd.c =================================================================== RCS file: /cvsroot/netadm/gwc/gwcklogd/gwcklogd.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gwcklogd.c 6 May 2006 18:27:32 -0000 1.4 --- gwcklogd.c 6 May 2006 18:31:45 -0000 1.5 *************** *** 279,283 **** closelogsrc(); ! Syslog(LOG_INFO, "gwcklogd: gwc Kernel log daemon terminating."); if ( output_file != (FILE *) 0 ) { --- 279,283 ---- closelogsrc(); ! Syslog(LOG_INFO, "gwcklogd: gwc Kernel log daemon terminating.\n"); if ( output_file != (FILE *) 0 ) { |
From: linuxpark <lin...@us...> - 2006-05-08 17:25:16
|
Update of /cvsroot/netadm/gwc/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28605/scripts Modified Files: gwc install.sh syslog.conf Log Message: ADD1: sysklog.ko, gwcklogd. MOD1: make deactivate gwcguid. MOD2: scripts/gwc, scripts/install.sh according to ADD1 and MOD1. FIX1: fix select maxfd from klogcmdtab[MAXSYSIDX] to klogcmdtab [MAXSYSIDX -1]. DEL1: remove debug code. ADD2: CHANGES according to ADD1, MOD1 MOD3: change syslog.conf to be able to handling gwcklogd log to local1 (gwc.log). OTHERS: comment and my email address. Index: syslog.conf =================================================================== RCS file: /cvsroot/netadm/gwc/scripts/syslog.conf,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** syslog.conf 6 Apr 2006 15:15:48 -0000 1.4 --- syslog.conf 6 May 2006 17:33:33 -0000 1.5 *************** *** 8,18 **** local0.* /usr/local/gwc/log/gwcadmd.log ! local1.* /usr/local/gwc/log/gwcguid.log - # Kernel Mode log - kern.* /usr/local/gwc/log/pf.log # Global Console ! *.err;kern.notice;auth.notice;local0.none;local1.none /dev/console ! *.err;kern.debug;daemon.notice;mail.crit /var/log/messages #*.alert;kern.err;daemon.err;local0.none operator --- 8,16 ---- local0.* /usr/local/gwc/log/gwcadmd.log ! local1.* /usr/local/gwc/log/gwc.log # Global Console ! #*.err;kern.notice;auth.notice;local0.none;local1.none /dev/console ! *.err;kern.*;daemon.notice;mail.crit /var/log/messages #*.alert;kern.err;daemon.err;local0.none operator Index: gwc =================================================================== RCS file: /cvsroot/netadm/gwc/scripts/gwc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gwc 30 Apr 2006 19:34:18 -0000 1.7 --- gwc 6 May 2006 17:33:33 -0000 1.8 *************** *** 22,25 **** --- 22,43 ---- TC_CMD="/sbin/tc" + PF_DEV="/dev/pf" + PF_MAJOR_NUM=253 + PF_MINOR_NUM=0 + + GWC_PF_LDEV="/dev/gwc_pf" + GWC_PF_MAJORNUM=220 + GWC_PF_MINORNUM=0 + + GWC_KSYS_LDEV="/dev/gwc_ksys" + GWC_KSYS_MAJORNUM=221 + GWC_KSYS_MINORNUM=0 + + # mknod ${PF_DEV} c ${PF_MAJOR_NUM} ${PF_MINOR_NUM} + # mknod ${GWC_PF_LDEV} c ${GWC_PF_MAJORNUM} ${GWC_PF_MINORNUM} + # mknod ${GWC_KSYS_LDEV} c ${GWC_KSYS_MAJORNUM} ${GWC_KSYS_MINORNUM} + + DEBUG="1" + killproc() { pid=`/bin/ps -e | *************** *** 191,203 **** } case "$1" in 'start') ! reflesh_syslogd ! init_ipc ! start gwcadmd ! #start gwcguid ! insmod ${MODDIR}/sysktimer.ko ! insmod ${MODDIR}/pf.ko debug=0 reload ip_tables reload iptable_filter --- 209,234 ---- } + check_dev () { + + if [ ! -f ${PF_DEV} ]; then + mknod ${PF_DEV} c ${PF_MAJOR_NUM} ${PF_MINOR_NUM} + fi + + if [ ! -f ${GWC_PF_LDEV} ]; then + mknod ${GWC_PF_LDEV} c ${GWC_PF_MAJORNUM} ${GWC_PF_MINORNUM} + fi + + if [ ! -f ${GWC_KSYS_LDEV} ]; then + mknod ${GWC_KSYS_LDEV} c ${GWC_KSYS_MAJORNUM} ${GWC_KSYS_MINORNUM} + fi + } + case "$1" in 'start') ! check_dev reflesh_syslogd ! insmod ${MODDIR}/sysklog.ko debug=${DEBUG} ! insmod ${MODDIR}/sysktimer.ko debug=${DEBUG} ! insmod ${MODDIR}/pf.ko debug=${DEBUG} reload ip_tables reload iptable_filter *************** *** 211,214 **** --- 242,248 ---- reload sch_prio reload sch_sfq + init_ipc + start gwcadmd + start gwcklogd printf "\n" ;; *************** *** 216,220 **** exit_ipc stop gwcadmd - #stop gwcguid rmmod pf rmmod sysktimer --- 250,253 ---- *************** *** 230,233 **** --- 263,268 ---- rmmod sch_prio rmmod sch_sfq + stop gwcklogd + rmmod sysklog printf "\n" ;; Index: install.sh =================================================================== RCS file: /cvsroot/netadm/gwc/scripts/install.sh,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** install.sh 30 Apr 2006 19:34:19 -0000 1.18 --- install.sh 6 May 2006 17:33:33 -0000 1.19 *************** *** 3,7 **** # # Title : install.sh ! # Author : Jeho-Park <lin...@gm...> # Created date : 2006. 01. 31. (thu) 01:40:38 KST # Description : --- 3,7 ---- # # Title : install.sh ! # Author : Jeho-Park <de...@sk...> # Created date : 2006. 01. 31. (thu) 01:40:38 KST # Description : *************** *** 29,35 **** --- 29,48 ---- TMP_CONFIG=config.$$ MODDIR=${MAINDIR}/modules + + # network kernel module. PF_DEV="/dev/pf" PF_MAJOR_NUM=253 PF_MINOR_NUM=0 + + # char device for logging gwc packet log of pf.ko. + GWC_PF_LDEV="/dev/gwc_pf" + GWC_PF_MAJORNUM=220 + GWC_PF_MINORNUM=0 + + # char device for logging system log of all gwc kernel module. + GWC_KSYS_LDEV="/dev/gwc_ksys" + GWC_KSYS_MAJORNUM=221 + GWC_KSYS_MINORNUM=0 + KERN=/lib/modules/`uname -r` *************** *** 197,202 **** rm -f ${BINDIR}/gwccli rm -f ${BINDIR}/gwcsh ! rm -f ${BINDIR}/gwcguid rm -f ${BINDIR}/gwcadmd xecho "Removing shell scripts and config files..." log "Removing shell scripts and config files..." --- 210,216 ---- rm -f ${BINDIR}/gwccli rm -f ${BINDIR}/gwcsh ! # rm -f ${BINDIR}/gwcguid rm -f ${BINDIR}/gwcadmd + rm -f ${BINDIR}/gwcklogd xecho "Removing shell scripts and config files..." log "Removing shell scripts and config files..." *************** *** 210,213 **** --- 224,229 ---- rm -rf ${SNMP_INSTALL_PATH}/${SNMP_NAME} rm -rf ${PF_DEV} + rm -rf ${GWC_PF_LDEV} + rm -rf ${GWC_KSYS_LDEV} } *************** *** 252,259 **** ${INST} -m 700 -o root -g root gwccli/gwccli ${BINDIR} ${INST} -m 700 -o root -g root gwcsh/gwcsh ${BINDIR} ! ${INST} -m 700 -o root -g root gwcguid/gwcguid ${BINDIR} ${INST} -m 700 -o root -g root gwcadmd/gwcadmd ${BINDIR} ${INST} -m 644 -o root -g root pf/pf.ko ${MODDIR} ${INST} -m 644 -o root -g root pf/sysktimer.ko ${MODDIR} ${INST} -m 700 -o root -g root scripts/${RUNSHELL} ${BINDIR} ${INST} -m 644 -o root -g root scripts/syslog.conf /etc --- 268,277 ---- ${INST} -m 700 -o root -g root gwccli/gwccli ${BINDIR} ${INST} -m 700 -o root -g root gwcsh/gwcsh ${BINDIR} ! # ${INST} -m 700 -o root -g root gwcguid/gwcguid ${BINDIR} ${INST} -m 700 -o root -g root gwcadmd/gwcadmd ${BINDIR} + ${INST} -m 700 -o root -g root gwcklogd/gwcklogd ${BINDIR} ${INST} -m 644 -o root -g root pf/pf.ko ${MODDIR} ${INST} -m 644 -o root -g root pf/sysktimer.ko ${MODDIR} + ${INST} -m 644 -o root -g root pf/sysklog.ko ${MODDIR} ${INST} -m 700 -o root -g root scripts/${RUNSHELL} ${BINDIR} ${INST} -m 644 -o root -g root scripts/syslog.conf /etc *************** *** 262,266 **** --- 280,288 ---- rm -f ./${TMP_CONFIG} chmod -R og-s ${MAINDIR} + mknod ${PF_DEV} c ${PF_MAJOR_NUM} ${PF_MINOR_NUM} + mknod ${GWC_PF_LDEV} c ${GWC_PF_MAJORNUM} ${GWC_PF_MINORNUM} + mknod ${GWC_KSYS_LDEV} c ${GWC_KSYS_MAJORNUM} ${GWC_KSYS_MINORNUM} + tar jxvf scripts/${SNMP_ARCH_FILE} mv ${SNMP_NAME} ${SNMP_INSTALL_PATH} *************** *** 283,288 **** check_usr xecho "is stopped..." ! killproc gwcguid killproc gwcadmd rmmod pf return --- 305,311 ---- check_usr xecho "is stopped..." ! # killproc gwcguid killproc gwcadmd + killproc gwcklogd rmmod pf return *************** *** 308,314 **** exit 1 fi ! if [ ! -f gwcguid/gwcguid ]; then ! ERROR="gwcguid binary does not exist, compile first! abort install ..." $DIALOG --infobox "${ERROR}" 5 75 sleep 2 --- 331,348 ---- exit 1 fi + # + # todays, we don't support GUI interface. --LP (Linuxpark or called Jeho-Park) + # + # if [ ! -f gwcguid/gwcguid ]; then + # ERROR="gwcguid binary does not exist, compile first! abort install ..." + # $DIALOG --infobox "${ERROR}" 5 75 + # sleep 2 + # abort_install + # log "$ERROR" + # exit 1 + # fi ! if [ ! -f gwcadmd/gwcadmd ]; then ! ERROR="gwcadmd binary does not exist, compile first! abort install ..." $DIALOG --infobox "${ERROR}" 5 75 sleep 2 *************** *** 317,323 **** exit 1 fi ! ! if [ ! -f gwcadmd/gwcadmd ]; then ! ERROR="gwcadmd binary does not exist, compile first! abort install ..." $DIALOG --infobox "${ERROR}" 5 75 sleep 2 --- 351,357 ---- exit 1 fi ! ! if [ ! -f gwcklogd/gwcklogd ]; then ! ERROR="gwcklogd binary does not exist, compile first! abort install ..." $DIALOG --infobox "${ERROR}" 5 75 sleep 2 *************** *** 328,331 **** --- 362,374 ---- if [ $KVER == 2 ]; then + if [ ! -f pf/sysklog.ko ]; then + ERROR="sysklog module does not exist, compile first! abort install ..." + $DIALOG --infobox "${ERROR}" 5 75 + sleep 2 + abort_install + log "$ERROR" + exit 1 + fi + if [ ! -f pf/pf.ko ]; then ERROR="pf module does not exist, compile first! abort install ..." *************** *** 518,529 **** %s/%s { Main start|stop script } %s/gwcadmd { Admin main Daemon } %s/gwccli { Cli command being able to replace of gwcguid } %s/gwcsh { gwc shell for interfacing with main admin daemon(gwcadmd) } ! %s/pf { kernel module for controlling flow or modifying TCP header } netadm-gwc log ---------------------------- ! %s/log" ${PROD} ${MAINDIR} ${CONFDIR} ${BINDIR} ${RUNSHELL} ${BINDIR} ${BINDIR} ${BINDIR} ${MODDIR} ${MAINDIR}) $DIALOG --msgbox "$msg" 28 80 || acex 0 --- 561,577 ---- %s/%s { Main start|stop script } %s/gwcadmd { Admin main Daemon } + %s/gwcklogd { kernel log daemon only for gwc kernel module's log } %s/gwccli { Cli command being able to replace of gwcguid } %s/gwcsh { gwc shell for interfacing with main admin daemon(gwcadmd) } ! %s/pf.ko { kernel module for controlling flow or modifying TCP header } + %s/sysklog.ko + { kernel module for logging of gwc kernel modules } + %s/sysktimer.ko + { kernel module for dynamic kernel timer thread } netadm-gwc log ---------------------------- ! %s/log" ${PROD} ${MAINDIR} ${CONFDIR} ${BINDIR} ${BINDIR} ${RUNSHELL} ${BINDIR} ${BINDIR} ${BINDIR} ${MODDIR} ${MODDIR} ${MODDIR} ${MAINDIR}) $DIALOG --msgbox "$msg" 28 80 || acex 0 |
From: linuxpark <lin...@us...> - 2006-05-08 17:24:55
|
Update of /cvsroot/netadm/gwc/gwcklogd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24709 Modified Files: gwcklogd.c Log Message: MOD: close exception. Index: gwcklogd.c =================================================================== RCS file: /cvsroot/netadm/gwc/gwcklogd/gwcklogd.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gwcklogd.c 6 May 2006 17:49:48 -0000 1.3 --- gwcklogd.c 6 May 2006 18:27:32 -0000 1.4 *************** *** 286,291 **** for (i = 0; i < MAXSYSIDX; i++) { ! close (klogcmdtab[i].fd); ! close (klogcmdtab[i].log_fd); } --- 286,294 ---- for (i = 0; i < MAXSYSIDX; i++) { ! if (klogcmdtab[i].fd > 0) ! close (klogcmdtab[i].fd); ! ! if (klogcmdtab[i].log_fd > 0) ! close (klogcmdtab[i].log_fd); } |