[Netadm-devel] gwc/pf pf.c,1.5,1.6 pf.h,1.3,1.4 sysktimer.c,1.2,1.3 sysktimer.h,1.2,1.3
Status: Beta
Brought to you by:
linuxpark
From: linuxpark <lin...@us...> - 2006-03-10 16:48:54
|
Update of /cvsroot/netadm/gwc/pf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14956 Modified Files: pf.c pf.h sysktimer.c sysktimer.h Log Message: MOD: modify pf for new version(gwc-v0.1-pre3) modify all of pf. especially. from now, it include session info. Index: sysktimer.h =================================================================== RCS file: /cvsroot/netadm/gwc/pf/sysktimer.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sysktimer.h 28 Feb 2006 01:00:09 -0000 1.2 --- sysktimer.h 10 Mar 2006 16:48:49 -0000 1.3 *************** *** 12,17 **** #include <linux/interrupt.h> ! #ifndef __SYS_TIMER_H ! #define __SYS_TIMER_H struct sys_timer_t { --- 12,17 ---- #include <linux/interrupt.h> ! #ifndef __SYS_KTIMER_H ! #define __SYS_KTIMER_H struct sys_timer_t { Index: pf.h =================================================================== RCS file: /cvsroot/netadm/gwc/pf/pf.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pf.h 28 Feb 2006 00:49:54 -0000 1.3 --- pf.h 10 Mar 2006 16:48:49 -0000 1.4 *************** *** 24,39 **** #endif #define KUIO_MAJOR_NUM 253 ! #define BLOCK_HOST 0x0001 ! #define MODIFY_SEQ 0x0002 struct host { ! __u32 saddr; ! __u8 type; ! __u32 pktcnt; ! __u32 max_pktrate; }; struct blk_key{ ! __u32 saddr; }; --- 24,96 ---- #endif #define KUIO_MAJOR_NUM 253 ! ! sys_strmap_t map_truefalse[] = { ! { "true", TRUE }, ! { "false", FALSE }, ! { 0 } ! }; ! ! sys_strmap_t map_nettype [] = { ! { "net", SYS_NT_NET }, ! { "host", SYS_NT_HOST }, ! { 0 } ! }; ! ! sys_strmap_t map_prototype [] = { ! { "tcp", SYS_PROTO_TCP }, ! { "udp", SYS_PROTO_UDP }, ! { "icmp", SYS_PROTO_ICMP }, ! { 0 } ! }; ! ! sys_strmap_t map_icmptype [] = { ! { "unreach", SYS_ICMP_UNREACH }, ! { "echo", SYS_ICMP_ECHO }, ! { "echorep", SYS_ICMP_ECHOREP }, ! { "squench", SYS_ICMP_SQUENCH }, ! { "redir", SYS_ICMP_REDIR }, ! { "timex", SYS_ICMP_TIMEX }, ! { "paramprob", SYS_ICMP_PARAMPROB }, ! { "timest", SYS_ICMP_TIMEST }, ! { "timestrep", SYS_ICMP_TIMESTREP }, ! { "inforeq", SYS_ICMP_INFOREQ }, ! { "inforep", SYS_ICMP_INFOREP }, ! { "maskreq", SYS_ICMP_MASKREQ }, ! { "maskrep", SYS_ICMP_MASKREP }, ! { 0 } ! }; ! ! sys_strmap_t map_thput_unit [] = { ! { "bps", SYS_FLOW_BPS }, ! { "kbps", SYS_FLOW_KBPS }, ! { "mbps", SYS_FLOW_MBPS }, ! { "byte", SYS_FLOW_BYTE }, ! { "kbyte", SYS_FLOW_KBYTE }, ! { "mbyte", SYS_FLOW_MBYTE }, ! { 0 } ! }; ! ! sys_strmap_t map_fc_rule [] = { ! { "fc", FC_PR_CONTROL }, ! { "mh", FC_PR_MOD_HEADER }, ! { 0 } ! }; ! ! char * mapidtostr(sys_strmap_t * map, int id); ! int mapstrtoid(sys_strmap_t * map, char *str); struct host { ! int ifindex; ! __u8 protocol; ! __u8 rule; ! __u32 saddr; ! __u32 daddr; ! __u32 quota; ! __u32 eat; }; struct blk_key{ ! __u16 sport; ! __u16 dport; }; *************** *** 51,64 **** unsigned blk_hash_mask; ! static __inline__ unsigned blk_hash_code (u32 saddr) { ! u32 daddr = 0x1289CD94; ! u8 tos = 0x07; ! unsigned hash = ((daddr & 0xF0F0F0F0) >> 4) | ((daddr & 0x0F0F0F0F) << 4); ! hash ^= saddr ^ tos; hash ^= (hash >> 16); return (hash ^ (hash >> 8)) & blk_hash_mask; } static __inline__ int dump_tcp(struct sk_buff *skb) --- 108,140 ---- unsigned blk_hash_mask; ! static __inline__ unsigned blk_hash_code (int ifindex, ! u32 saddr, ! u32 daddr, ! u8 protocol ! ) { unsigned hash = ((daddr & 0xF0F0F0F0) >> 4) | ((daddr & 0x0F0F0F0F) << 4); ! ifindex <<= 16; ! ifindex |= protocol; ! hash ^= saddr ^ ifindex; hash ^= (hash >> 16); return (hash ^ (hash >> 8)) & blk_hash_mask; } + static __inline__ void + print_connection (const char *str, + __u32 saddr, __u16 sport, + __u8 proto, + __u32 daddr, __u16 dport) + { + printk ("%s: %s %u.%u.%u.%u/%d -- %s --> %u.%u.%u.%u/%d\n", + DEVICE_NAME, + str, + NIPQUAD(saddr), + sport, + mapidtostr (map_prototype, proto), + NIPQUAD(daddr), + dport); + } + static __inline__ int dump_tcp(struct sk_buff *skb) Index: pf.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/pf.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pf.c 5 Mar 2006 01:11:00 -0000 1.5 --- pf.c 10 Mar 2006 16:48:49 -0000 1.6 *************** *** 2,6 **** Title : pf.c ! Author : Jeho-Park <ne...@ke...> Created date : 2006. 01. 31. (thu) 01:39:30 KST Description : pf module --- 2,6 ---- Title : pf.c ! Author : Jeho-Park <lin...@gm...> Created date : 2006. 01. 31. (thu) 01:39:30 KST Description : pf module *************** *** 26,29 **** --- 26,30 ---- #include <linux/in.h> #include <linux/tcp.h> + #include <linux/udp.h> #include <linux/stddef.h> #include <linux/fs.h> *************** *** 39,54 **** #include <linux/if_arp.h> #endif #include <linux/fcntl.h> #include <linux/errno.h> #include "pf.h" - #include "sysioctl.h" #include "sysktimer.h" - #include "../include/global.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 int debug __initdata = 0; static int kuio_rdopen = 0; --- 40,56 ---- #include <linux/if_arp.h> #endif + #include <linux/icmp.h> #include <linux/fcntl.h> #include <linux/errno.h> + #include <linux/string.h> + #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 int debug __initdata = 0; static int kuio_rdopen = 0; *************** *** 56,59 **** --- 58,91 ---- static struct nf_hook_ops iphook_tab; + char * mapidtostr(sys_strmap_t * map, int id) + { + + while (map->str) { + if (map->id == id) + return map->str; + + map++; + } + + return NULL; + } + EXPORT_SYMBOL_GPL (mapidtostr); + + int mapstrtoid(sys_strmap_t * map, char *str) + { + + while (map->str) { + if (!strcmp(map->str, str)) { + return map->id; + } + + map++; + } + + return -1; + } + EXPORT_SYMBOL_GPL (mapstrtoid); + + /* block list hash table */ static struct blk_hash_bucket *blk_hash_table; *************** *** 70,81 **** while( (blkh = *blkhp) != NULL){ ! if( blkh->key.saddr == blk->key.saddr ){ *blkhp = blkh->next; blkh->next = blk_hash_table[hash].chain; blk_hash_table[hash].chain = blkh; - /* need jiffies ?*/ spin_unlock(&blk_hash_table[hash].lock); *blkhp = blkh; ! printk("%s:%s: We meet any collision\n", DEVICE_NAME, __FUNCTION__); return -1; } --- 102,113 ---- while( (blkh = *blkhp) != NULL){ ! /* Bad Case: Meet Collision & absoletely same */ ! if((blkh->key.sport & blk->key.sport)&&(blkh->key.dport&blk->key.dport)){ *blkhp = blkh->next; blkh->next = blk_hash_table[hash].chain; blk_hash_table[hash].chain = blkh; spin_unlock(&blk_hash_table[hash].lock); *blkhp = blkh; ! printk("%s: We meet any collision\n", DEVICE_NAME); return -1; } *************** *** 102,113 **** memset (blknode, 0, sizeof (struct blk)); return blknode; - #if 0 - new->host = (struct host *) kmalloc(sizeof (struct host), - in_interrupt()? GFP_ATOMIC : GFP_KERNEL); - if (!new->host) { - printk("%s: Failed to alloc host\n", DEVICE_NAME); - return NULL; - } - #endif } --- 134,137 ---- *************** *** 122,128 **** while( (blkh = *blkhp) != NULL){ blkhp = &blkh->next; - #if 0 - kfree (blkh->host); /* FIXME */ - #endif printk("kmem_cache_free\n"); kmem_cache_free(kmem_cachep, blkh); --- 146,149 ---- *************** *** 140,144 **** } ! static int update_pktcnt( void *arg ){ struct blk *blkh, **blkhp; int i; --- 161,165 ---- } ! static int update_eat ( void *arg ){ struct blk *blkh, **blkhp; int i; *************** *** 147,154 **** spin_lock(&blk_hash_table[i].lock); - blkhp = &blk_hash_table[i].chain; while( (blkh = *blkhp) != NULL){ ! blkh->host.pktcnt = 0; blkhp = &blkh->next; } --- 168,174 ---- spin_lock(&blk_hash_table[i].lock); blkhp = &blk_hash_table[i].chain; while( (blkh = *blkhp) != NULL){ ! blkh->host.eat = 0; blkhp = &blkh->next; } *************** *** 159,163 **** } ! static int register_host( u32 saddr, u8 type, u32 max_pktrate){ struct blk *key_hp; int ret; --- 179,183 ---- } ! static int register_host(int ifindex, kuio_msg_t *p) { struct blk *key_hp; int ret; *************** *** 166,220 **** key_hp = blk_alloc(); if(!key_hp) { ! printk("%s : %s Failed to blk_alloc\n",DEVICE_NAME, __FUNCTION__ ); return -1; } ! key_hp->key.saddr = key_hp->host.saddr = saddr; ! key_hp->host.type = type; ! key_hp->host.pktcnt = 0; ! key_hp->host.max_pktrate = max_pktrate; ! hash = blk_hash_code(key_hp->key.saddr); return ret = blk_intern_hash (hash, key_hp); } ! static int unregister_host (u32 saddr) { ! struct blk *blkh, *pre_blkh; unsigned hash; ! hash = blk_hash_code(saddr); ! spin_lock(&blk_hash_table[hash].lock); ! pre_blkh = blk_hash_table[hash].chain; ! blkh = pre_blkh->next; ! while ( (saddr != blkh->key.saddr) && blkh != NULL) { ! pre_blkh = pre_blkh->next; ! blkh = pre_blkh->next; } ! if (blkh == NULL) { spin_unlock(&blk_hash_table[hash].lock); ! printk ("%s: There is no such host %u.%u.%u.%u\n", DEVICE_NAME, NIPQUAD(saddr)); return -1; } pre_blkh->next = blkh->next; ! kmem_cache_free( kmem_cachep, blkh); spin_unlock(&blk_hash_table[hash].lock); ! printk ("%s: Successfully unregistered host %u.%u.%u.%u\n", DEVICE_NAME, NIPQUAD(saddr)); return 1; } ! static int find_host (u32 saddr) { struct blk *blkh; unsigned hash; ! hash = blk_hash_code(saddr); spin_lock(&blk_hash_table[hash].lock); for( blkh = blk_hash_table[hash].chain; blkh; blkh = blkh->next){ ! ! if ( blkh->key.saddr == saddr ) { spin_unlock(&blk_hash_table[hash].lock); return 1; --- 186,253 ---- key_hp = blk_alloc(); if(!key_hp) { ! printk("%s : %s Failed to blk_alloc\n", DEVICE_NAME, __FUNCTION__ ); return -1; } ! key_hp->key.sport = p->sport; ! key_hp->key.dport = p->dport; ! key_hp->host.ifindex = ifindex; ! key_hp->host.protocol = p->protocol; ! key_hp->host.rule = p->rule; ! key_hp->host.saddr = p->saddr; ! key_hp->host.daddr = p->daddr; ! key_hp->host.quota = p->quota; ! key_hp->host.eat = 0; ! hash = blk_hash_code(key_hp->host.ifindex, ! key_hp->host.saddr, ! key_hp->host.daddr, ! key_hp->host.protocol ! ); return ret = blk_intern_hash (hash, key_hp); } ! static int unregister_host(int ifindex, kuio_msg_t *p) { ! struct blk *blkh; ! struct blk *pre_blkh; unsigned hash; ! hash = blk_hash_code(ifindex, p->saddr, p->daddr, p->protocol); ! spin_lock(&blk_hash_table[hash].lock); ! for( pre_blkh = blk_hash_table[hash].chain, blkh = pre_blkh->next; ! blkh; ! pre_blkh = pre_blkh->next, blkh = pre_blkh->next){ ! if ( blkh->key.sport == p->sport && blkh->key.dport == p->dport ) { ! break; ! } } ! if (!blkh) { spin_unlock(&blk_hash_table[hash].lock); ! print_connection ("There is no such info", ! p->saddr, p->sport, ! p->protocol, ! p->daddr, p->dport); return -1; } pre_blkh->next = blkh->next; ! kmem_cache_free(kmem_cachep, blkh); spin_unlock(&blk_hash_table[hash].lock); ! return 1; } ! static int find_host (int ifindex, kuio_msg_t *p) { struct blk *blkh; unsigned hash; ! hash = blk_hash_code(ifindex, p->saddr, p->daddr, p->protocol); spin_lock(&blk_hash_table[hash].lock); for( blkh = blk_hash_table[hash].chain; blkh; blkh = blkh->next){ ! if ( blkh->key.sport == p->sport && blkh->key.dport == p->dport ) { spin_unlock(&blk_hash_table[hash].lock); return 1; *************** *** 228,232 **** int goal, order, i; ! kmem_cachep = kmem_cache_create("cherokee-pf", sizeof(struct blk), 0, SLAB_HWCACHE_ALIGN, NULL, NULL); if(!kmem_cachep){ printk("%s: Failed to allocate block_host_cache\n", DEVICE_NAME); --- 261,266 ---- int goal, order, i; ! kmem_cachep = kmem_cache_create(DRIVER_VERSION, sizeof(struct blk), ! 0, SLAB_HWCACHE_ALIGN, NULL, NULL); if(!kmem_cachep){ printk("%s: Failed to allocate block_host_cache\n", DEVICE_NAME); *************** *** 274,278 **** static void init_systimer (struct sys_timer_t * t) { ! t->func = update_pktcnt; /* handler */ t->data = NULL; /* param of handler */ t->t_time = 0; /* total time endless */ --- 308,312 ---- static void init_systimer (struct sys_timer_t * t) { ! t->func = update_eat; /* handler */ t->data = NULL; /* param of handler */ t->t_time = 0; /* total time endless */ *************** *** 281,284 **** --- 315,390 ---- } + /* process_packet + * : This is called with lock state of spinlock in a bucket + */ + static inline int process_packet (struct blk_hash_bucket *bucket, + struct sk_buff *skb, + struct blk *n) + { + const struct iphdr *ip = skb->nh.iph; + struct udphdr *udph; + struct tcphdr *tcph; + struct icmphdr _icmph, *icmph; + + switch (ip->protocol) { + + case IPPROTO_UDP: + udph = (struct udphdr *) ((char *) ip + ip->ihl * 4); + + if (udph->source != n->key.sport || udph->dest != n->key.dport) + goto EXIT_ACCEPT; + + break; + + case IPPROTO_TCP: + tcph = (struct tcphdr *) ((__u32 *) ip + ip->ihl); + + if (tcph->source != n->key.sport || tcph->dest != n->key.dport) + goto EXIT_ACCEPT; + + break; + + case IPPROTO_ICMP: + icmph = skb_header_pointer(skb, ip->ihl * 4, sizeof (_icmph), &_icmph); + if (icmph->type != n->key.dport) + goto EXIT_ACCEPT; + + break; + + default: + /* This will not happen */ + goto EXIT_ACCEPT; + } + + n->host.eat += skb->len; + if (n->host.rule & FC_PR_CONTROL) { + if (!n->host.quota || n->host.eat > n->host.quota ) { + print_connection ("Maximum quota reached", + n->host.saddr, n->key.sport, + n->host.protocol, + n->host.daddr, n->key.dport); + goto EXIT_SCHEDULE; + } + } + else if (n->host.rule & FC_PR_MOD_HEADER ) { + /* TODO: */ + print_connection ("Modify packet", + n->host.saddr, n->key.sport, + n->host.protocol, + n->host.daddr, n->key.dport); + } + /* TODO: NAT */ + + + EXIT_ACCEPT: + spin_unlock (&bucket->lock); + return NF_ACCEPT; + + EXIT_SCHEDULE: + spin_unlock (&bucket->lock); + /* TODO: NF_DROP -> insert_pending (skb, ...) */ + return NF_DROP; + } + static unsigned int ip_hook_func (unsigned int hooknum, *************** *** 289,341 **** struct sk_buff *sb = *skb; const struct iphdr *ip = sb->nh.iph; - struct tcphdr *tcph; struct blk *blkh; - struct host *hp; unsigned hash; - static int i = 0; - struct net_device * indev; ! if (!(i++ %10) && ip->protocol == IPPROTO_ICMP) { ! indev = __dev_get_by_name (in->name); ! printk("%d: dev:%s, ifindex: %d iflink: %d/ from kernel:%s(%d)\n", ! i, ! in->name, ! in->ifindex, ! in->iflink, ! indev->name, ! indev->ifindex ! ); ! } ! hash = blk_hash_code(ip->saddr); spin_lock (&blk_hash_table[hash].lock); ! for( blkh = blk_hash_table[hash].chain; blkh; blkh = blkh->next){ ! ! if ( blkh->key.saddr == ip->saddr ) { ! hp = &blkh->host; ! ! if (hp->type == BLOCK_HOST) { ! ! /* Block host or Flow control */ ! if (!hp->max_pktrate || hp->pktcnt > hp->max_pktrate) { ! ! ++hp->pktcnt; ! printk("Drop | SFlow Control %u.%u.%u.%u [%d/%d] \n", ! NIPQUAD(hp->saddr), hp->pktcnt, hp->max_pktrate); ! spin_unlock (&blk_hash_table[hash].lock); ! return NF_DROP; ! } ! ++hp->pktcnt; ! } else { ! /* modify TCP seq */ ! if (ip->protocol == IPPROTO_TCP) { ! tcph =(void *) (sb)->data +sb->nh.iph->ihl * 4; ! tcph->seq += 3; ! printk("[Modify TCP seq] %u.%u.%u.%u old seq : 0x%x, new seq 0x%x\n", ! NIPQUAD(hp->saddr),tcph->seq - 3, tcph->seq); ! } ! } } } spin_unlock (&blk_hash_table[hash].lock); --- 395,412 ---- struct sk_buff *sb = *skb; const struct iphdr *ip = sb->nh.iph; struct blk *blkh; unsigned hash; ! hash = blk_hash_code(in->ifindex, ip->saddr, ip->daddr, ip->protocol); spin_lock (&blk_hash_table[hash].lock); ! for( blkh = blk_hash_table[hash].chain; blkh; blkh = blkh->next) { ! if ( blkh->host.protocol != ip->protocol ) { ! spin_unlock (&blk_hash_table[hash].lock); ! return NF_ACCEPT; } + + return process_packet (&blk_hash_table[hash], sb, blkh); } spin_unlock (&blk_hash_table[hash].lock); *************** *** 347,373 **** { ! 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 ! ++kuio_wdopen; ! } ! ! else { ! if (kuio_rdopen) { ! printk("%s: Device already open for reading\n", ! KUIO_DEVICE_NAME); ! return -EBUSY; ! } else ! ++kuio_rdopen; ! } ! try_module_get(THIS_MODULE); ! return 0; } --- 418,441 ---- { ! 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 ! ++kuio_wdopen; ! } ! else { ! if (kuio_rdopen) { ! printk("%s: Device already open for reading\n", KUIO_DEVICE_NAME); ! return -EBUSY; ! } else ! ++kuio_rdopen; ! } ! try_module_get(THIS_MODULE); ! return 0; } *************** *** 375,388 **** device_release(struct inode *inode, struct file *filp) { - printk("%s: Device release (%d, %d)\n", - KUIO_DEVICE_NAME, MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); ! if ((filp->f_flags & O_ACCMODE) & (O_WRONLY | O_RDWR)) ! --kuio_wdopen; ! else ! --kuio_rdopen; ! module_put(THIS_MODULE); ! return 0; } --- 443,457 ---- device_release(struct inode *inode, struct file *filp) { ! printk("%s: Device release (%d, %d)\n", ! KUIO_DEVICE_NAME, MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); ! ! if ((filp->f_flags & O_ACCMODE) & (O_WRONLY | O_RDWR)) ! --kuio_wdopen; ! else ! --kuio_rdopen; ! module_put(THIS_MODULE); ! return 0; } *************** *** 391,402 **** unsigned int cmd, unsigned long arg) { ! kuio_msg_t kuio_msg, *pmsg = &kuio_msg; ! #if 0 ! int err; ! #endif ! int size; ! int ret; ! __u32 src; ! __u32 max_pktrate; if (_IOC_TYPE(cmd) != IOCTLPF_MAGIC) --- 460,467 ---- unsigned int cmd, unsigned long arg) { ! kuio_msg_t kuio_msg, *p = &kuio_msg; ! int size; ! int ret; ! int ifindex; if (_IOC_TYPE(cmd) != IOCTLPF_MAGIC) *************** *** 408,476 **** size = sizeof (kuio_msg_t); - #if 0/* get rid of verify_area it may be obsolete from 2.6.x */ - - if (size) { - err = 0; - - if (_IOC_DIR(cmd) & _IOC_WRITE) - err = verify_area(VERIFY_READ, (void *) arg, size); - - if (err) - return err; - } - #endif - switch (cmd) { ! case IOCTLPF_REGISTER_SRCBLOCK: ! ret = copy_from_user((void *) pmsg, (const void *) arg, size); ! src = (pmsg->ip); ! max_pktrate = (pmsg->max_pktrate); /* register host and seq flag */ ! if ( find_host (src) > 0 ) { ! printk ("%s: %u.%u.%u.%u was already registered\n", DEVICE_NAME, NIPQUAD(src)); return -EBADSLT; ! } else { ! if ( register_host (src, BLOCK_HOST, max_pktrate) < 0 ) { return -EFAULT; } else ! printk ("%s: Success to register %u.%u.%u.%u\n", DEVICE_NAME, NIPQUAD(src)); } break; ! ! case IOCTLPF_REGISTER_MODSEQ: ! ! ret = copy_from_user((void *) pmsg, (const void *) arg, size); ! src = (pmsg->ip); ! ! /* register host and seq flag */ ! if ( find_host (src) > 0 ) { ! printk ("%s: %u.%u.%u.%u was already registered\n", DEVICE_NAME, NIPQUAD(src)); ! return -EBADSLT; ! ! } else { ! ! if ( register_host (src, MODIFY_SEQ, 0) < 0 ) { ! return -EFAULT; ! } ! else ! printk ("%s: Success to register %u.%u.%u.%u\n", DEVICE_NAME, NIPQUAD(src)); ! } ! ! break; ! ! case IOCTLPF_UNREGISTER_HOST: ! ret = copy_from_user((void *) pmsg, (const void *) arg, size); ! src = (pmsg->ip); ! ret = unregister_host (src); ! if ( ret < 0 ) return -EFAULT; break; --- 473,528 ---- size = sizeof (kuio_msg_t); switch (cmd) { ! case IOCTLPF_REGISTER_MODSEQ: ! ! case IOCTLPF_REGISTER_NET: ! ret = copy_from_user((void *) p, (const void *) arg, size); ! ifindex = (__dev_get_by_name ((char *)p->indev))->ifindex; /* register host and seq flag */ ! if (find_host (ifindex, p) > 0 ) { ! print_connection ("Already exist", ! p->saddr, p->sport, ! p->protocol, ! p->daddr, p->dport); return -EBADSLT; ! } else { ! if ( register_host (ifindex, p) < 0 ) { ! print_connection ("Failed to register", ! p->saddr, p->sport, ! p->protocol, ! p->daddr, p->dport); return -EFAULT; } else ! print_connection ("Success to register", ! p->saddr, p->sport, ! p->protocol, ! p->daddr, p->dport); } break; ! ! case IOCTLPF_UNREGISTER_NET: ! ret = copy_from_user((void *) p, (const void *) arg, size); ! ifindex = (__dev_get_by_name ((char *)p->indev))->ifindex; ! if ( unregister_host (ifindex, p) < 0 ) { ! print_connection ("Failed to delete", ! p->saddr, p->sport, ! p->protocol, ! p->daddr, p->dport); return -EFAULT; + } + else { + print_connection ("Success to delete", + p->saddr, p->sport, + p->protocol, + p->daddr, p->dport); + } break; *************** *** 518,522 **** } ! printk("%s: Registered with major Number = %d\n", KUIO_DEVICE_NAME,KUIO_MAJOR_NUM); return 0; } --- 570,574 ---- } ! printk("%s: Registered with major Number = %d\n", KUIO_DEVICE_NAME, KUIO_MAJOR_NUM); return 0; } *************** *** 527,533 **** int ret; ! printk("%s: Unloading kernel vs user I/O module\n", DEVICE_NAME); if ((ret = unregister_chrdev(KUIO_MAJOR_NUM, DEVICE_NAME)) < 0) ! printk("%s: Device unregistration failed (%d)\n", DEVICE_NAME, ret); } --- 579,585 ---- 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); } *************** *** 601,603 **** MODULE_LICENSE("GPL"); MODULE_VERSION(DRIVER_VERSION); - --- 653,654 ---- Index: sysktimer.c =================================================================== RCS file: /cvsroot/netadm/gwc/pf/sysktimer.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sysktimer.c 28 Feb 2006 01:00:09 -0000 1.2 --- sysktimer.c 10 Mar 2006 16:48:49 -0000 1.3 *************** *** 40,44 **** return ret; ! printk("%s start, total time: %d\n", __FUNCTION__, p->t_time); expire = timespec_to_jiffies(&p->t) + (p->t.tv_sec || p->t.tv_nsec); --- 40,44 ---- return ret; ! printk("%s thread start, total time: %d\n", DRIVER_VERSION, p->t_time); expire = timespec_to_jiffies(&p->t) + (p->t.tv_sec || p->t.tv_nsec); *************** *** 59,63 **** * i definitly assumed it was stemed from mine */ ! printk("%s exit\n", __FUNCTION__); return 1; } --- 59,63 ---- * i definitly assumed it was stemed from mine */ ! printk("%s thread exit\n", DRIVER_VERSION); return 1; } |