u32 netmode_gateway_rcv(u32 hooknum, struct sk_buff **pskb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { s32 ret = ERROR_SUCCESS; struct sk_buff *skb = *pskb; (void)hooknum; (void)in; if(CONPLAT_SKB_FROM_WAN_OR_LAN != skb->ucpktflag) { return NF_ACCEPT; } ckdc_counter_inc(nm,netmode_rcv); ret = netmode_iftable_find(skb, out, NETMODE_GATEWAY_FLAG); if(ERROR_SUCCESS != ret) { ckdc_counter_inc(nm,netmode_send); return NF_ACCEPT; } local_bh_disable(); netmode_skb_dpi_process(skb, 0, NETMODE_GATEWAY_FLAG, okfn); __local_bh_enable(); return NF_STOLEN; }
/* * Use tpi to get a pending interrupt, call the interrupt handler and * return a pointer to the subchannel structure. */ static inline int cio_tpi(void) { struct tpi_info *tpi_info; struct subchannel *sch; struct irb *irb; tpi_info = (struct tpi_info *) __LC_SUBCHANNEL_ID; if (tpi (NULL) != 1) return 0; irb = (struct irb *) __LC_IRB; /* Store interrupt response block to lowcore. */ if (tsch (tpi_info->irq, irb) != 0) /* Not status pending or not operational. */ return 1; sch = (struct subchannel *)(unsigned long)tpi_info->intparm; if (!sch) return 1; local_bh_disable(); irq_enter (); spin_lock(&sch->lock); memcpy (&sch->schib.scsw, &irb->scsw, sizeof (struct scsw)); if (sch->driver && sch->driver->irq) sch->driver->irq(&sch->dev); spin_unlock(&sch->lock); irq_exit (); __local_bh_enable(); return 1; }
void do_softirq(void) { unsigned pending = local_softirq_pending(); unsigned allowed = 1 << SCHED_SOFTIRQ | 1 << HRTIMER_SOFTIRQ; struct softirq_action *h; unsigned long flags; __local_bh_disable(SOFTIRQ_OFFSET); local_irq_save(flags); while ((pending = local_softirq_pending())) { /* * For now we only support SCHED_SOFTIRQ * and HRTIMER_SOFTIRQ */ BUG_ON((~allowed) & pending); cpumask_clear_cpu(smp_processor_id(), &linsched_cpu_softirq_raised); set_softirq_pending(0); h = softirq_vec; do { if (pending & 1) h->action(h); h++; pending >>= 1; } while (pending); } local_irq_restore(flags); __local_bh_enable(SOFTIRQ_OFFSET); }
void addrpool_parse_free(struct addrpool_trie_info* trie_free) { u32 i; __local_bh_enable(); msleep(100); local_bh_disable(); if(trie_free->rule) { for(i=0; i<trie_free->size.numrules; i++) { if(trie_free->rule[i].field) free(trie_free->rule[i].field); } free(trie_free->rule); } if(trie_free->ruleid) free(trie_free->ruleid); if(trie_free->node) free(trie_free->node); trie_free->size.numrules = 0; _trie_free(trie_free->trie, conplat_free); trie_free->trie = NULL; }
s32 netmode_transparent_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { s32 ret = 0; (void)dev; (void)pt; (void)orig_dev; if(netmode_is_need_cap(skb, dev)) { return 1; } if((CONPLAT_SKB_FROM_INLINE != skb->ucpktflag) && (CONPLAT_INLINE_SKB_FROM_LOCAL != skb->ucpktflag)) { return 0; } ckdc_counter_inc(nm,netmode_rcv); ret = acl_rfc_proc(skb, dev, NULL); if (NF_DROP == ret) { kfree_skb(skb); ckdc_counter_inc(nm,netmode_drop); return 1; } ret = netmode_iftable_find(skb, NULL, NETMODE_TRANSPARENT_FLAG); if(ERROR_SUCCESS != ret) { kfree_skb(skb); ckdc_counter_inc(nm,netmode_drop); return 1; } local_bh_disable(); ret = netmode_ucpktflag_proc(&skb, NETMODE_TRANSPARENT_FLAG, NULL); if(0 != ret) { goto dpi_process; } if(radius_auditing_is_enable(skb)) { radius_auditing_handle_radius(skb->data, skb->h.uh->len - sizeof(struct udphdr)); } /*域监听处理*/ domain_listen_handle_skb(skb); dpi_process: netmode_skb_dpi_process(skb, ret, NETMODE_TRANSPARENT_FLAG, NULL); __local_bh_enable(); return 1; }
asmlinkage void do_softirq() { int cpu = smp_processor_id(); __u32 pending; long flags; __u32 mask; if (in_interrupt()) return; local_irq_save(flags); pending = softirq_pending(cpu); if (pending) { struct softirq_action *h; mask = ~pending; local_bh_disable(); restart: /* Reset the pending bitmask before enabling irqs */ softirq_pending(cpu) = 0; local_irq_enable(); h = softirq_vec; do { if (pending & 1) h->action(h); h++; pending >>= 1; } while (pending); local_irq_disable(); pending = softirq_pending(cpu); if (pending & mask) { mask &= ~pending; goto restart; } __local_bh_enable(); if (pending) wakeup_softirqd(cpu); } local_irq_restore(flags); }
static inline void invoke_softirq(void) { if (!force_irqthreads) { #ifdef __ARCH_IRQ_EXIT_IRQS_DISABLED __do_softirq(); #else do_softirq(); #endif } else { __local_bh_disable((unsigned long)__builtin_return_address(0), SOFTIRQ_OFFSET); wakeup_softirqd(); __local_bh_enable(SOFTIRQ_OFFSET); } }
/* Called at irq disabled */ asmlinkage void __do_dpc_irq(void) { struct dpc_irq_action *h; u32 pending; int max_restart = MAX_SOFTIRQ_RESTART; int cpu; /* Get mask */ pending = local_dpc_irq_pending(); __local_bh_disable((unsigned long)__builtin_return_address(0), SOFTIRQ_OFFSET); cpu = smp_processor_id(); restart: /* Reset the pending bit mask before enabling irqs */ set_dpc_irq_pending(0); local_irq_enable(); /* Handle it */ h = dpc_irq_vec; do { if (pending & 1) { unsigned int vec_nr = h - dpc_irq_vec; int prev_count = hal_preempt_count(); h->action(h); if (unlikely(prev_count != hal_preempt_count())) { hal_preempt_count() = prev_count; } //TODO: RCU } h++; pending >>= 1; } while (pending); local_irq_disable(); pending = local_dpc_irq_pending(); if (pending && --max_restart) goto restart; if (pending) wakeup_dpc_thread(); __local_bh_enable(SOFTIRQ_OFFSET); }
/***************************************************************************** 函 数 名: acl_rfc_prepare_user_data 功能描述: 准备执行RFC算法,初始化各变量 输入参数: 无 输出参数: cnt ---- 规则数 返 回 值: ERROR_SUCCESS ---- 未查到 else ---- 找到的规则的动作位置 ----------------------------------------------------------------------------- 最近一次修改记录: 修改作者: Fuzhiqing 修改目的: 合并本函数与acl_rfc_init函数 修改日期: 2011-09-24 *****************************************************************************/ s32 acl_rfc_prepare_user_data(void) { /*先将acl_policy_rfc_ready置0同时sleep 100ms,确保没有报文再访问rfc表再对rfc表进行重新编译*/ acl_rfc_ready = ACL_RFC_NOT_READY; /*函数里会sleep,因此需要先打开软中断*/ __local_bh_enable(); msleep(100); local_bh_disable(); printk("<3>Start to compile RFC ACL...\n"); gs_rfc_rule_num = 0; memset (gs_action_bitmap, 0, sizeof(gs_action_bitmap)); memset (g_acl_rfc_result, 0, sizeof(g_acl_rfc_result)); gs_current_num = 0; memset(&gs_cur_rule_prio, 0, sizeof(gs_cur_rule_prio)); memset(&acl_rfc_k_size, 0, sizeof(acl_rfc_k_size)); return ERROR_SUCCESS; }
asmlinkage void __do_softirq(void) { struct softirq_action *h; __u32 pending; int max_restart = MAX_SOFTIRQ_RESTART; int cpu; pending = local_softirq_pending(); local_bh_disable(); cpu = smp_processor_id(); restart: /* Reset the pending bitmask before enabling irqs */ set_softirq_pending(0); local_irq_enable(); h = softirq_vec; do { if (pending & 1) { trace_kernel_soft_irq_entry((void*)(h - softirq_vec)); h->action(h); trace_kernel_soft_irq_exit((void*)(h - softirq_vec)); rcu_bh_qsctr_inc(cpu); } h++; pending >>= 1; } while (pending); local_irq_disable(); pending = local_softirq_pending(); if (pending && --max_restart) goto restart; if (pending) wakeup_softirqd(); __local_bh_enable(); }
u32 netmode_bridge_rcv(u32 hooknum, struct sk_buff **pskb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { s32 ret; struct sk_buff *skb = *pskb; (void)hooknum; (void)in; (void)out; if((CONPLAT_SKB_FROM_WAN_OR_LAN != skb->ucpktflag) && (CONPLAT_BR_SKB_FROM_LOCAL != skb->ucpktflag)) { return NF_ACCEPT; } ckdc_counter_inc(nm,netmode_rcv); ret = netmode_iftable_find(skb, NULL, NETMODE_BRIDGE_FLAG); if(ERROR_SUCCESS != ret) { ckdc_counter_inc(nm,netmode_send); return NF_ACCEPT; } local_bh_disable(); ret = netmode_ucpktflag_proc(&skb, NETMODE_BRIDGE_FLAG, okfn); if(0 != ret) { goto dpi_process; } dpi_process: netmode_skb_dpi_process(skb, ret, NETMODE_BRIDGE_FLAG, okfn); __local_bh_enable(); return NF_STOLEN; }
s32 bypass_syscall_callback(unsigned int cmd, void* buf, unsigned int size) { drv_bypass_vip_rule_s * iplist; u32 ret = ERROR_SUCCESS; u32 ipnum = 0; if(buf == NULL) { return 1; } local_bh_disable(); switch(cmd) { case BYPASS_CMD_INIT_BYPASS: ret = bypass_timer_init(); break; case BYPASS_CMD_WEB_EXEC_BYPASS: ret = bypass_web_exec(); break; case BYPASS_CMD_COPY_IPLIST: iplist = (drv_bypass_vip_rule_s *)buf; ipnum = size/sizeof(drv_bypass_vip_rule_s); ret = bypass_iplist_to_kernel(iplist, ipnum); break; case BYPASS_CMD_ENABLE: ret = bypass_enable(); break; case BYPASS_CMD_DISABLE: ret = bypass_disable(); break; default: DEBUG_PRINT("unkown cmd receive:%s,%dn",__FUNCTION__,__LINE__); break; } __local_bh_enable(); return 0; }
/******************************************************************************* 函数名称 : trans_tech_syscall 功能描述 : 过渡技术系统调用 输入参数 : 无 输出参数 : 无 返 回 值 : 无 -------------------------------------------------------------------------------- 最近一次修改记录 : 修改作者 : 杜杰 修改目的 : 新生成函数 修改日期 : 2012-8-16 *******************************************************************************/ s32 trans_tech_syscall(u32 cmd, void* buf, u32 size) { s32 ret = 0; local_bh_disable(); switch (cmd) { case IP6_6RD_SYSCALL_ADD: if( size != sizeof(struct ipv6_rapid_cfg) ) { ret = -1; break; } ip6_rapid_add_parm((struct ipv6_rapid_cfg *)buf); break; case IP6_6RD_SYSCALL_ENABLE: ip6_6rd_clear_logic(); g_6rd_switch_flag = *(s32 *)buf; break; case TRANS_TECH_DS_LITE_ADD: ret = ds_lite_set_conf((u8 *)buf); break; case TRANS_TECH_DS_LITE_CLEAN: ret = ds_lite_conf_clear(); break; case TRANS_TECH_DS_LITE_SWITCH_ENABLE: ds_lite_enable_change((u32 *)buf); break; case TRANS_TECH_DS_LITE_PRINT: ds_lite_print(); break; default: ret = -1; } __local_bh_enable(); return ret; }
u32 netmode_br_transparent_rcv(u32 hooknum, struct sk_buff **pskb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { s32 ret; s32 webauth_ret; struct sk_buff *skb = *pskb; u16 etype; u32 br_ip; struct ethhdr * eth; struct iphdr * iph; (void)hooknum; (void)in; (void)out; if (0 == smp_processor_id()) { skb->pkt_type = PACKET_HOST; return NF_ACCEPT; } if((CONPLAT_SKB_FROM_WAN_OR_LAN != skb->ucpktflag) && (CONPLAT_BR_SKB_FROM_LOCAL != skb->ucpktflag)) { return NF_ACCEPT; } ckdc_counter_inc(nm,netmode_rcv); ret = netmode_iftable_find(skb, NULL, NETMODE_BR_TRANSPARENT_FLAG); if(ERROR_SUCCESS != ret) { kfree_skb(skb); ckdc_counter_inc(nm,netmode_drop); return NF_STOLEN; } eth = (struct ethhdr *)skb->mac.raw; etype = eth->h_proto; iph = (struct iphdr *)skb->nh.iph; /*带tag报文上送桥接口,也走此流程*/ if (ETH_P_IP == ntohs(etype) && ERROR_SUCCESS == br_get_ip(skb, &br_ip) && iph->daddr == htonl(br_ip)) { return webauth_br_transparent_flow_distribute(skb); } local_bh_disable(); ret = netmode_ucpktflag_proc(&skb, NETMODE_BR_TRANSPARENT_FLAG, okfn); if(0 != ret) { goto dpi_process; } if ((ETH_P_ARP != skb->protocol) && webauth_this_proto_need_auth(skb) && !webauth_vlan_is_pass(skb) ) { webauth_ret = (s32)webauth_pre_routing(NF_IP_PRE_ROUTING, &skb, NULL, NULL, NULL); if (NF_DROP == webauth_ret) { kfree_skb(skb); ckdc_counter_inc(nm,netmode_drop); __local_bh_enable(); return NF_STOLEN; } if (NF_STOLEN == webauth_ret) { __local_bh_enable(); return NF_STOLEN; } if(NF_REPEAT == webauth_ret) { webauth_ret = (s32)web_listen_pre_routing(NF_IP_PRE_ROUTING, &skb, NULL, NULL, NULL); if (NF_DROP == webauth_ret) { kfree_skb(skb); ckdc_counter_inc(nm,netmode_drop); __local_bh_enable(); return NF_STOLEN; } if (NF_STOLEN == webauth_ret) { __local_bh_enable(); return NF_STOLEN; } } } dpi_process: netmode_skb_dpi_process(skb, ret, NETMODE_BR_TRANSPARENT_FLAG, okfn); __local_bh_enable(); return NF_STOLEN; }
/* * Special-case - softirqs can safely be enabled in * cond_resched_softirq(), or by __do_softirq(), * without processing still-pending softirqs: */ void _local_bh_enable(void) { WARN_ON_ONCE(in_irq()); __local_bh_enable(SOFTIRQ_DISABLE_OFFSET); }
asmlinkage void __do_softirq(void) { struct softirq_action *h; __u32 pending; unsigned long end = jiffies + MAX_SOFTIRQ_TIME; int cpu; unsigned long old_flags = current->flags; int max_restart = MAX_SOFTIRQ_RESTART; /* * Mask out PF_MEMALLOC s current task context is borrowed for the * softirq. A softirq handled such as network RX might set PF_MEMALLOC * again if the socket is related to swap */ current->flags &= ~PF_MEMALLOC; pending = local_softirq_pending(); account_system_vtime(current); __local_bh_disable((unsigned long)__builtin_return_address(0), SOFTIRQ_OFFSET); lockdep_softirq_enter(); cpu = smp_processor_id(); restart: /* Reset the pending bitmask before enabling irqs */ set_softirq_pending(0); local_irq_enable(); h = softirq_vec; do { if (pending & 1) { unsigned int vec_nr = h - softirq_vec; int prev_count = preempt_count(); kstat_incr_softirqs_this_cpu(vec_nr); trace_softirq_entry(vec_nr); h->action(h); trace_softirq_exit(vec_nr); if (unlikely(prev_count != preempt_count())) { printk(KERN_ERR "huh, entered softirq %u %s %p" "with preempt_count %08x," " exited with %08x?\n", vec_nr, softirq_to_name[vec_nr], h->action, prev_count, preempt_count()); preempt_count_set(prev_count); } rcu_bh_qs(cpu); } h++; pending >>= 1; } while (pending); local_irq_disable(); pending = local_softirq_pending(); if (pending) { if (time_before(jiffies, end) && !need_resched() && --max_restart) goto restart; wakeup_softirqd(); } lockdep_softirq_exit(); account_system_vtime(current); __local_bh_enable(SOFTIRQ_OFFSET); tsk_restore_flags(current, old_flags, PF_MEMALLOC); }
/* * Special-case - softirqs can safely be enabled in * cond_resched_softirq(), or by __do_softirq(), * without processing still-pending softirqs: */ void _local_bh_enable(void) { __local_bh_enable(SOFTIRQ_DISABLE_OFFSET); }
asmlinkage void __do_softirq(void) { unsigned long end = jiffies + MAX_SOFTIRQ_TIME; unsigned long old_flags = current->flags; int max_restart = MAX_SOFTIRQ_RESTART; struct softirq_action *h; bool in_hardirq; __u32 pending; int softirq_bit; int cpu; /* * Mask out PF_MEMALLOC s current task context is borrowed for the * softirq. A softirq handled such as network RX might set PF_MEMALLOC * again if the socket is related to swap */ current->flags &= ~PF_MEMALLOC; pending = local_softirq_pending(); account_irq_enter_time(current); __local_bh_disable_ip(_RET_IP_, SOFTIRQ_OFFSET); in_hardirq = lockdep_softirq_start(); cpu = smp_processor_id(); restart: /* Reset the pending bitmask before enabling irqs */ set_softirq_pending(0); local_irq_enable(); h = softirq_vec; while ((softirq_bit = ffs(pending))) { unsigned int vec_nr; int prev_count; h += softirq_bit - 1; vec_nr = h - softirq_vec; prev_count = preempt_count(); kstat_incr_softirqs_this_cpu(vec_nr); trace_softirq_entry(vec_nr); h->action(h); trace_softirq_exit(vec_nr); if (unlikely(prev_count != preempt_count())) { pr_err("huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n", vec_nr, softirq_to_name[vec_nr], h->action, prev_count, preempt_count()); preempt_count_set(prev_count); } rcu_bh_qs(cpu); h++; pending >>= softirq_bit; } local_irq_disable(); pending = local_softirq_pending(); if (pending) { if (time_before(jiffies, end) && !need_resched() && --max_restart) goto restart; wakeup_softirqd(); } lockdep_softirq_end(in_hardirq); account_irq_exit_time(current); __local_bh_enable(SOFTIRQ_OFFSET); WARN_ON_ONCE(in_interrupt()); tsk_restore_flags(current, old_flags, PF_MEMALLOC); }
asmlinkage void __do_softirq(void) { struct softirq_action *h; __u32 pending; unsigned long end = jiffies + MAX_SOFTIRQ_TIME; int cpu; pending = local_softirq_pending(); account_system_vtime(current); __local_bh_disable((unsigned long)__builtin_return_address(0), SOFTIRQ_OFFSET); lockdep_softirq_enter(); cpu = smp_processor_id(); restart: /* Reset the pending bitmask before enabling irqs */ set_softirq_pending(0); local_irq_enable(); h = softirq_vec; do { if (pending & 1) { unsigned int vec_nr = h - softirq_vec; int prev_count = preempt_count(); kstat_incr_softirqs_this_cpu(vec_nr); trace_softirq_entry(vec_nr); h->action(h); trace_softirq_exit(vec_nr); if (unlikely(prev_count != preempt_count())) { printk(KERN_ERR "huh, entered softirq %u %s %p" "with preempt_count %08x," " exited with %08x?\n", vec_nr, softirq_to_name[vec_nr], h->action, prev_count, preempt_count()); preempt_count_set(prev_count); } rcu_bh_qs(cpu); } h++; pending >>= 1; } while (pending); local_irq_disable(); pending = local_softirq_pending(); if (pending) { if (time_before(jiffies, end) && !need_resched()) goto restart; wakeup_softirqd(); } lockdep_softirq_exit(); account_system_vtime(current); __local_bh_enable(SOFTIRQ_OFFSET); }
/******************************************************************************* 函数名称 : dot1x_syscall 功能描述 : dot1x系统调用回调函数 输入参数 : cmd -------- 命令字 buf -------- 缓冲区 size -------- 大小 输出参数 : 返 回 值 : ERROR_SUCCESS -------- 表项删除成功 ERROR_FAIL -------- 表项删除失败 -------------------------------------------------------------------------------- 最近一次修改记录 : 修改作者 : 魏甲博 修改目的 : 新添加函数 修改日期 : 2010-11-22 *******************************************************************************/ s32 dot1x_syscall(unsigned int cmd, void* buf, unsigned int size) { s32 retcode = ERROR_SUCCESS; struct dot1x_if_cfg *cfg = NULL; cfg = (struct dot1x_if_cfg *)buf; #ifndef CONFIG_SMP local_bh_disable(); #endif switch(cmd) { case DOT1XAUTH_SYSCALL_SET_ENABLE: { if (size != sizeof(s32)) { retcode = ERROR_FAIL; break; } /* 802.1x全局使能开关 */ retcode = dot1x_global_enable_switch(*((s32 *)buf)); break; } case DOT1XAUTH_SYSCALL_SET_IF_CFG: { if (size != sizeof(struct dot1x_if_cfg)) { retcode = ERROR_FAIL; break; } /* 配置接口规则 */ retcode = dot1x_add_if_cfg((struct dot1x_if_cfg *)buf); break; } case DOT1XAUTH_SYSCALL_SET_BASEIF: { if (size != sizeof(struct dot1x_base_if_info)) { retcode = ERROR_FAIL; break; } /*配置端口*/ retcode = dot1x_port_cfg((struct dot1x_base_if_info *)buf); break; } case DOT1XAUTH_SYSCALL_SET_BASEMAC: { if (size != sizeof(struct dot1x_base_mac_info)) { retcode = ERROR_FAIL; break; } /*配置端口*/ retcode = dot1x_mac_cfg((struct dot1x_base_mac_info *)buf); break; } default: retcode = ERROR_FAIL; break; } #ifndef CONFIG_SMP __local_bh_enable(); #endif return retcode; }