您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ spin_lock_bh函数代码示例

51自学网 2021-06-03 08:10:11
  C++
这篇教程C++ spin_lock_bh函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中spin_lock_bh函数的典型用法代码示例。如果您正苦于以下问题:C++ spin_lock_bh函数的具体用法?C++ spin_lock_bh怎么用?C++ spin_lock_bh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了spin_lock_bh函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ipsec_sadb_cleanup

int ipsec_sadb_cleanup(__u8 proto){	int i;	int error = 0;	struct ipsec_sa *ips, **ipsprev, *tdbdel;        char sa[SATOA_BUF];	size_t sa_len;	KLIPS_PRINT(debug_xform,		    "klips_debug:ipsec_tdbcleanup: "		    "cleaning up proto=%d./n",		    proto);	spin_lock_bh(&tdb_lock);	for (i = 0; i < SADB_HASHMOD; i++) {		ipsprev = &(ipsec_sadb_hash[i]);		ips = ipsec_sadb_hash[i];		for(; ips;) {			sa_len = satoa(ips->ips_said, 0, sa, SATOA_BUF);			KLIPS_PRINT(debug_xform,				    "klips_debug:ipsec_tdbcleanup: "				    "checking SA:%s, hash=%d",				    sa_len ? sa : " (error)",				    i);			tdbdel = ips;			ips = tdbdel->ips_hnext;			if(ips) {				sa_len = satoa(ips->ips_said, 0, sa, SATOA_BUF);				KLIPS_PRINT(debug_xform,					    ", hnext=%s",					    sa_len ? sa : " (error)");			}			if(*ipsprev) {				sa_len = satoa((*ipsprev)->ips_said, 0, sa, SATOA_BUF);				KLIPS_PRINT(debug_xform,					    ", *ipsprev=%s",					    sa_len ? sa : " (error)");				if((*ipsprev)->ips_hnext) {					sa_len = satoa((*ipsprev)->ips_hnext->ips_said, 0, sa, SATOA_BUF);					KLIPS_PRINT(debug_xform,						    ", *ipsprev->ips_hnext=%s",						    sa_len ? sa : " (error)");				}			}			KLIPS_PRINT(debug_xform,				    "./n");			if(!proto || (proto == tdbdel->ips_said.proto)) {				sa_len = satoa(tdbdel->ips_said, 0, sa, SATOA_BUF);				KLIPS_PRINT(debug_xform,					    "klips_debug:ipsec_tdbcleanup: "					    "deleting SA chain:%s./n",					    sa_len ? sa : " (error)");				if((error = ipsec_sa_delchain(tdbdel))) {					SENDERR(-error);				}				ipsprev = &(ipsec_sadb_hash[i]);				ips = ipsec_sadb_hash[i];				KLIPS_PRINT(debug_xform,					    "klips_debug:ipsec_tdbcleanup: "					    "deleted SA chain:%s",					    sa_len ? sa : " (error)");				if(ips) {					sa_len = satoa(ips->ips_said, 0, sa, SATOA_BUF);					KLIPS_PRINT(debug_xform,						    ", tdbh[%d]=%s",						    i,						    sa_len ? sa : " (error)");				}				if(*ipsprev) {					sa_len = satoa((*ipsprev)->ips_said, 0, sa, SATOA_BUF);					KLIPS_PRINT(debug_xform,						    ", *ipsprev=%s",						    sa_len ? sa : " (error)");					if((*ipsprev)->ips_hnext) {						sa_len = satoa((*ipsprev)->ips_hnext->ips_said, 0, sa, SATOA_BUF);						KLIPS_PRINT(debug_xform,							    ", *ipsprev->ips_hnext=%s",							    sa_len ? sa : " (error)");					}				}				KLIPS_PRINT(debug_xform,					    "./n");			} else {				ipsprev = &tdbdel;			}		}	} errlab:	spin_unlock_bh(&tdb_lock);	return(error);}
开发者ID:ysleu,项目名称:RTL8685,代码行数:96,


示例2: autofw_expect

static voidautofw_expect(struct nf_conn *ct, struct nf_conntrack_expect *exp){	struct nf_nat_range pre_range;	u_int32_t newdstip, newsrcip;	u_int16_t port;	int ret;	struct nf_conn_help *help;	struct nf_conn *exp_ct = exp->master;	struct nf_conntrack_expect *newexp;	int count;	/* expect has been removed from expect list, but expect isn't free yet. */	help = nfct_help(exp_ct);	DEBUGP("autofw_nat_expected: got ");	NF_CT_DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);	spin_lock_bh(&nf_nat_autofw_lock);	port = ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u.all);	newdstip = exp->tuple.dst.u3.ip;	newsrcip = exp->tuple.src.u3.ip;	if (port < ntohs(help->help.ct_autofw_info.dport[0]) ||		port > ntohs(help->help.ct_autofw_info.dport[1])) {		spin_unlock_bh(&nf_nat_autofw_lock);			return;	}	/* Only need to do PRE_ROUTING */	port -= ntohs(help->help.ct_autofw_info.dport[0]);	port += ntohs(help->help.ct_autofw_info.to[0]);	pre_range.flags = IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED;	pre_range.min_ip = pre_range.max_ip = newdstip;	pre_range.min.all = pre_range.max.all = htons(port);	nf_nat_setup_info(ct, &pre_range, NF_IP_PRE_ROUTING);	spin_unlock_bh(&nf_nat_autofw_lock);	/* Add expect again */	/* alloc will set exp->master = exp_ct */	newexp = nf_conntrack_expect_alloc(exp_ct);	if (!newexp)		return;	newexp->tuple.src.u3.ip = exp->tuple.src.u3.ip;	newexp->tuple.dst.protonum = exp->tuple.dst.protonum;	newexp->mask.src.u3.ip = 0xFFFFFFFF;	newexp->mask.dst.protonum = 0xFF;	newexp->tuple.dst.u3.ip = exp->tuple.dst.u3.ip;	newexp->mask.dst.u3.ip = 0x0;	for (count = 1; count < NF_CT_TUPLE_L3SIZE; count++) {		newexp->tuple.src.u3.all[count] = 0x0;		newexp->tuple.dst.u3.all[count] = 0x0;	}	newexp->mask.dst.u.all = 0x0;	newexp->mask.src.u.all = 0x0;	newexp->mask.src.l3num = 0x0;	newexp->expectfn = autofw_expect;	newexp->helper = NULL;	newexp->flags = 0;	/*	 * exp->timeout.expires will set as	 * (jiffies + helper->timeout * HZ), when insert exp.	*/	ret = nf_conntrack_expect_related(newexp);	if (ret == 0)		nf_conntrack_expect_put(newexp);}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:74,


示例3: ath9k_wiphy_select

int ath9k_wiphy_select(struct ath_wiphy *aphy){	struct ath_softc *sc = aphy->sc;	bool now;	spin_lock_bh(&sc->wiphy_lock);	if (__ath9k_wiphy_scanning(sc)) {		/*		 * For now, we are using mac80211 sw scan and it expects to		 * have full control over channel changes, so avoid wiphy		 * scheduling during a scan. This could be optimized if the		 * scanning control were moved into the driver.		 */		spin_unlock_bh(&sc->wiphy_lock);		return -EBUSY;	}	if (__ath9k_wiphy_pausing(sc)) {		if (sc->wiphy_select_failures == 0)			sc->wiphy_select_first_fail = jiffies;		sc->wiphy_select_failures++;		if (time_after(jiffies, sc->wiphy_select_first_fail + HZ / 2))		{			printk(KERN_DEBUG "ath9k: Previous wiphy select timed "			       "out; disable/enable hw to recover/n");			__ath9k_wiphy_mark_all_paused(sc);			/*			 * TODO: this workaround to fix hardware is unlikely to			 * be specific to virtual wiphy changes. It can happen			 * on normal channel change, too, and as such, this			 * should really be made more generic. For example,			 * tricker radio disable/enable on GTT interrupt burst			 * (say, 10 GTT interrupts received without any TX			 * frame being completed)			 */			spin_unlock_bh(&sc->wiphy_lock);			ath_radio_disable(sc, aphy->hw);			ath_radio_enable(sc, aphy->hw);			/* Only the primary wiphy hw is used for queuing work */			ieee80211_queue_work(aphy->sc->hw,				   &aphy->sc->chan_work);			return -EBUSY; /* previous select still in progress */		}		spin_unlock_bh(&sc->wiphy_lock);		return -EBUSY; /* previous select still in progress */	}	sc->wiphy_select_failures = 0;	/* Store the new channel */	sc->chan_idx = aphy->chan_idx;	sc->chan_is_ht = aphy->chan_is_ht;	sc->next_wiphy = aphy;	__ath9k_wiphy_pause_all(sc);	now = !__ath9k_wiphy_pausing(aphy->sc);	spin_unlock_bh(&sc->wiphy_lock);	if (now) {		/* Ready to request channel change immediately */		ieee80211_queue_work(aphy->sc->hw, &aphy->sc->chan_work);	}	/*	 * wiphys will be unpaused in ath9k_tx_status() once channel has been	 * changed if any wiphy needs time to become paused.	 */	return 0;}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:68,


示例4: dev_mc_upload

void dev_mc_upload(struct net_device *dev){    spin_lock_bh(&dev->xmit_lock);    __dev_mc_upload(dev);    spin_unlock_bh(&dev->xmit_lock);}
开发者ID:Dronevery,项目名称:JetsonTK1-kernel,代码行数:6,


示例5: ax25_linkfail_release

void ax25_linkfail_release(struct ax25_linkfail *lf){    spin_lock_bh(&linkfail_lock);    hlist_del_init(&lf->lf_node);    spin_unlock_bh(&linkfail_lock);}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:6,


示例6: iwl_mvm_reorder

/* * Returns true if the MPDU was buffered/dropped, false if it should be passed * to upper layer. */static bool iwl_mvm_reorder(struct iwl_mvm *mvm,			    struct napi_struct *napi,			    int queue,			    struct ieee80211_sta *sta,			    struct sk_buff *skb,			    struct iwl_rx_mpdu_desc *desc){	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;	struct iwl_mvm_sta *mvm_sta;	struct iwl_mvm_baid_data *baid_data;	struct iwl_mvm_reorder_buffer *buffer;	struct sk_buff *tail;	u32 reorder = le32_to_cpu(desc->reorder_data);	bool amsdu = desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU;	bool last_subframe =		desc->amsdu_info & IWL_RX_MPDU_AMSDU_LAST_SUBFRAME;	u8 tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;	u8 sub_frame_idx = desc->amsdu_info &			   IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK;	int index;	u16 nssn, sn;	u8 baid;	baid = (reorder & IWL_RX_MPDU_REORDER_BAID_MASK) >>		IWL_RX_MPDU_REORDER_BAID_SHIFT;	if (baid == IWL_RX_REORDER_DATA_INVALID_BAID)		return false;	/* no sta yet */	if (WARN_ON(IS_ERR_OR_NULL(sta)))		return false;	mvm_sta = iwl_mvm_sta_from_mac80211(sta);	/* not a data packet */	if (!ieee80211_is_data_qos(hdr->frame_control) ||	    is_multicast_ether_addr(hdr->addr1))		return false;	if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))		return false;	baid_data = rcu_dereference(mvm->baid_map[baid]);	if (WARN(!baid_data,		 "Received baid %d, but no data exists for this BAID/n", baid))		return false;	if (WARN(tid != baid_data->tid || mvm_sta->sta_id != baid_data->sta_id,		 "baid 0x%x is mapped to sta:%d tid:%d, but was received for sta:%d tid:%d/n",		 baid, baid_data->sta_id, baid_data->tid, mvm_sta->sta_id,		 tid))		return false;	nssn = reorder & IWL_RX_MPDU_REORDER_NSSN_MASK;	sn = (reorder & IWL_RX_MPDU_REORDER_SN_MASK) >>		IWL_RX_MPDU_REORDER_SN_SHIFT;	buffer = &baid_data->reorder_buf[queue];	spin_lock_bh(&buffer->lock);	/*	 * If there was a significant jump in the nssn - adjust.	 * If the SN is smaller than the NSSN it might need to first go into	 * the reorder buffer, in which case we just release up to it and the	 * rest of the function will take of storing it and releasing up to the	 * nssn	 */	if (!iwl_mvm_is_sn_less(nssn, buffer->head_sn + buffer->buf_size,				buffer->buf_size)) {		u16 min_sn = ieee80211_sn_less(sn, nssn) ? sn : nssn;		iwl_mvm_release_frames(mvm, sta, napi, buffer, min_sn);	}	/* drop any oudated packets */	if (ieee80211_sn_less(sn, buffer->head_sn))		goto drop;	/* release immediately if allowed by nssn and no stored frames */	if (!buffer->num_stored && ieee80211_sn_less(sn, nssn)) {		if (iwl_mvm_is_sn_less(buffer->head_sn, nssn,				       buffer->buf_size) &&		   (!amsdu || last_subframe))			buffer->head_sn = nssn;		/* No need to update AMSDU last SN - we are moving the head */		spin_unlock_bh(&buffer->lock);		return false;	}	index = sn % buffer->buf_size;	/*	 * Check if we already stored this frame	 * As AMSDU is either received or not as whole, logic is simple:	 * If we have frames in that position in the buffer and the last frame//.........这里部分代码省略.........
开发者ID:AK101111,项目名称:linux,代码行数:101,


示例7: ip6mr_cache_unresolved

static intip6mr_cache_unresolved(mifi_t mifi, struct sk_buff *skb){	int err;	struct mfc6_cache *c;	spin_lock_bh(&mfc_unres_lock);	for (c = mfc_unres_queue; c; c = c->next) {		if (ipv6_addr_equal(&c->mf6c_mcastgrp, &ipv6_hdr(skb)->daddr) &&		    ipv6_addr_equal(&c->mf6c_origin, &ipv6_hdr(skb)->saddr))			break;	}	if (c == NULL) {		/*		 *	Create a new entry if allowable		 */		if (atomic_read(&cache_resolve_queue_len) >= 10 ||		    (c = ip6mr_cache_alloc_unres()) == NULL) {			spin_unlock_bh(&mfc_unres_lock);			kfree_skb(skb);			return -ENOBUFS;		}		/*		 *	Fill in the new cache entry		 */		c->mf6c_parent = -1;		c->mf6c_origin = ipv6_hdr(skb)->saddr;		c->mf6c_mcastgrp = ipv6_hdr(skb)->daddr;		/*		 *	Reflect first query at pim6sd		 */		if ((err = ip6mr_cache_report(skb, mifi, MRT6MSG_NOCACHE)) < 0) {			/* If the report failed throw the cache entry			   out - Brad Parker			 */			spin_unlock_bh(&mfc_unres_lock);			kmem_cache_free(mrt_cachep, c);			kfree_skb(skb);			return err;		}		atomic_inc(&cache_resolve_queue_len);		c->next = mfc_unres_queue;		mfc_unres_queue = c;		ipmr_do_expire_process(1);	}	/*	 *	See if we can append the packet	 */	if (c->mfc_un.unres.unresolved.qlen > 3) {		kfree_skb(skb);		err = -ENOBUFS;	} else {		skb_queue_tail(&c->mfc_un.unres.unresolved, skb);		err = 0;	}	spin_unlock_bh(&mfc_unres_lock);	return err;}
开发者ID:mpalmer,项目名称:linux-2.6,代码行数:68,


示例8: brcms_ops_bss_info_changed

static voidbrcms_ops_bss_info_changed(struct ieee80211_hw *hw,                           struct ieee80211_vif *vif,                           struct ieee80211_bss_conf *info, u32 changed){    struct brcms_info *wl = hw->priv;    struct bcma_device *core = wl->wlc->hw->d11core;    if (changed & BSS_CHANGED_ASSOC) {        /* association status changed (associated/disassociated)         * also implies a change in the AID.         */        brcms_err(core, "%s: %s: %sassociated/n", KBUILD_MODNAME,                  __func__, info->assoc ? "" : "dis");        spin_lock_bh(&wl->lock);        brcms_c_associate_upd(wl->wlc, info->assoc);        spin_unlock_bh(&wl->lock);    }    if (changed & BSS_CHANGED_ERP_SLOT) {        s8 val;        /* slot timing changed */        if (info->use_short_slot)            val = 1;        else            val = 0;        spin_lock_bh(&wl->lock);        brcms_c_set_shortslot_override(wl->wlc, val);        spin_unlock_bh(&wl->lock);    }    if (changed & BSS_CHANGED_HT) {        /* 802.11n parameters changed */        u16 mode = info->ht_operation_mode;        spin_lock_bh(&wl->lock);        brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_CFG,                               mode & IEEE80211_HT_OP_MODE_PROTECTION);        brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_NONGF,                               mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);        brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_OBSS,                               mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT);        spin_unlock_bh(&wl->lock);    }    if (changed & BSS_CHANGED_BASIC_RATES) {        struct ieee80211_supported_band *bi;        u32 br_mask, i;        u16 rate;        struct brcm_rateset rs;        int error;        /* retrieve the current rates */        spin_lock_bh(&wl->lock);        brcms_c_get_current_rateset(wl->wlc, &rs);        spin_unlock_bh(&wl->lock);        br_mask = info->basic_rates;        bi = hw->wiphy->bands[brcms_c_get_curband(wl->wlc)];        for (i = 0; i < bi->n_bitrates; i++) {            /* convert to internal rate value */            rate = (bi->bitrates[i].bitrate << 1) / 10;            /* set/clear basic rate flag */            brcms_set_basic_rate(&rs, rate, br_mask & 1);            br_mask >>= 1;        }        /* update the rate set */        spin_lock_bh(&wl->lock);        error = brcms_c_set_rateset(wl->wlc, &rs);        spin_unlock_bh(&wl->lock);        if (error)            brcms_err(core, "changing basic rates failed: %d/n",                      error);    }    if (changed & BSS_CHANGED_BEACON_INT) {        /* Beacon interval changed */        spin_lock_bh(&wl->lock);        brcms_c_set_beacon_period(wl->wlc, info->beacon_int);        spin_unlock_bh(&wl->lock);    }    if (changed & BSS_CHANGED_BSSID) {        /* BSSID changed, for whatever reason (IBSS and managed mode) */        spin_lock_bh(&wl->lock);        brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid);        spin_unlock_bh(&wl->lock);    }    if (changed & BSS_CHANGED_BEACON)        /* Beacon data changed, retrieve new beacon (beaconing modes) */        brcms_err(core, "%s: beacon changed/n", __func__);    if (changed & BSS_CHANGED_BEACON_ENABLED) {        /* Beaconing should be enabled/disabled (beaconing modes) */        brcms_err(core, "%s: Beacon enabled: %s/n", __func__,                  info->enable_beacon ? "true" : "false");    }    if (changed & BSS_CHANGED_CQM) {        /* Connection quality monitor config changed */        brcms_err(core, "%s: cqm change: threshold %d, hys %d "//.........这里部分代码省略.........
开发者ID:kennethlyn,项目名称:parallella-lcd-linux,代码行数:101,


示例9: tcf_ipt_init

static inttcf_ipt_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,             int ovr, int bind){	struct rtattr *tb[TCA_IPT_MAX];	struct tcf_ipt *p;	struct ipt_entry_target *td, *t;	char *tname;	int ret = 0, err;	u32 hook = 0;	u32 index = 0;	if (rta == NULL || rtattr_parse_nested(tb, TCA_IPT_MAX, rta) < 0)		return -EINVAL;	if (tb[TCA_IPT_HOOK-1] == NULL ||	    RTA_PAYLOAD(tb[TCA_IPT_HOOK-1]) < sizeof(u32))		return -EINVAL;	if (tb[TCA_IPT_TARG-1] == NULL ||	    RTA_PAYLOAD(tb[TCA_IPT_TARG-1]) < sizeof(*t))		return -EINVAL;	td = (struct ipt_entry_target *)RTA_DATA(tb[TCA_IPT_TARG-1]);	if (RTA_PAYLOAD(tb[TCA_IPT_TARG-1]) < td->u.target_size)		return -EINVAL;	if (tb[TCA_IPT_INDEX-1] != NULL &&	    RTA_PAYLOAD(tb[TCA_IPT_INDEX-1]) >= sizeof(u32))		index = *(u32 *)RTA_DATA(tb[TCA_IPT_INDEX-1]);	p = tcf_hash_check(index, a, ovr, bind);	if (p == NULL) {		p = tcf_hash_create(index, est, a, sizeof(*p), ovr, bind);		if (p == NULL)			return -ENOMEM;		ret = ACT_P_CREATED;	} else {		if (!ovr) {			tcf_ipt_release(p, bind);			return -EEXIST;		}	}	hook = *(u32 *)RTA_DATA(tb[TCA_IPT_HOOK-1]);	err = -ENOMEM;	tname = kmalloc(IFNAMSIZ, GFP_KERNEL);	if (tname == NULL)		goto err1;	if (tb[TCA_IPT_TABLE - 1] == NULL ||	    rtattr_strlcpy(tname, tb[TCA_IPT_TABLE-1], IFNAMSIZ) >= IFNAMSIZ)		strcpy(tname, "mangle");	t = kmalloc(td->u.target_size, GFP_KERNEL);	if (t == NULL)		goto err2;	memcpy(t, td, td->u.target_size);	if ((err = ipt_init_target(t, tname, hook)) < 0)		goto err3;	spin_lock_bh(&p->lock);	if (ret != ACT_P_CREATED) {		ipt_destroy_target(p->t);		kfree(p->tname);		kfree(p->t);	}	p->tname = tname;	p->t     = t;	p->hook  = hook;	spin_unlock_bh(&p->lock);	if (ret == ACT_P_CREATED)		tcf_hash_insert(p);	return ret;err3:	kfree(t);err2:	kfree(tname);err1:	kfree(p);	return err;}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:82,


示例10: tcf_pedit_init

static int tcf_pedit_init(struct rtattr *rta, struct rtattr *est,			  struct tc_action *a, int ovr, int bind){	struct rtattr *tb[TCA_PEDIT_MAX];	struct tc_pedit *parm;	int ret = 0;	struct tcf_pedit *p;	struct tcf_common *pc;	struct tc_pedit_key *keys = NULL;	int ksize;	if (rta == NULL || rtattr_parse_nested(tb, TCA_PEDIT_MAX, rta) < 0)		return -EINVAL;	if (tb[TCA_PEDIT_PARMS - 1] == NULL ||	    RTA_PAYLOAD(tb[TCA_PEDIT_PARMS-1]) < sizeof(*parm))		return -EINVAL;	parm = RTA_DATA(tb[TCA_PEDIT_PARMS-1]);	ksize = parm->nkeys * sizeof(struct tc_pedit_key);	if (RTA_PAYLOAD(tb[TCA_PEDIT_PARMS-1]) < sizeof(*parm) + ksize)		return -EINVAL;	pc = tcf_hash_check(parm->index, a, bind, &pedit_hash_info);	if (!pc) {		if (!parm->nkeys)			return -EINVAL;		pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,				     &pedit_idx_gen, &pedit_hash_info);		if (unlikely(!pc))			return -ENOMEM;		p = to_pedit(pc);		keys = kmalloc(ksize, GFP_KERNEL);		if (keys == NULL) {			kfree(pc);			return -ENOMEM;		}		ret = ACT_P_CREATED;	} else {		p = to_pedit(pc);		if (!ovr) {			tcf_hash_release(pc, bind, &pedit_hash_info);			return -EEXIST;		}		if (p->tcfp_nkeys && p->tcfp_nkeys != parm->nkeys) {			keys = kmalloc(ksize, GFP_KERNEL);			if (keys == NULL)				return -ENOMEM;		}	}	spin_lock_bh(&p->tcf_lock);	p->tcfp_flags = parm->flags;	p->tcf_action = parm->action;	if (keys) {		kfree(p->tcfp_keys);		p->tcfp_keys = keys;		p->tcfp_nkeys = parm->nkeys;	}	memcpy(p->tcfp_keys, parm->keys, ksize);	spin_unlock_bh(&p->tcf_lock);	if (ret == ACT_P_CREATED)		tcf_hash_insert(pc, &pedit_hash_info);	return ret;}
开发者ID:Mr-Aloof,项目名称:wl500g,代码行数:64,


示例11: help

static int help(struct sk_buff *skb,		unsigned int protoff,		struct nf_conn *ct,		enum ip_conntrack_info ctinfo){	unsigned int dataoff, datalen;	struct tcphdr _tcph, *th;	char *sb_ptr;	int ret = NF_ACCEPT;	int dir = CTINFO2DIR(ctinfo);	struct nf_ct_sane_master *ct_sane_info;	struct nf_conntrack_expect *exp;	struct nf_conntrack_tuple *tuple;	struct sane_request *req;	struct sane_reply_net_start *reply;	int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;	ct_sane_info = &nfct_help(ct)->help.ct_sane_info;	/* Until there's been traffic both ways, don't look in packets. */	if (ctinfo != IP_CT_ESTABLISHED &&	    ctinfo != IP_CT_ESTABLISHED_REPLY)		return NF_ACCEPT;	/* Not a full tcp header? */	th = skb_header_pointer(skb, protoff, sizeof(_tcph), &_tcph);	if (th == NULL)		return NF_ACCEPT;	/* No data? */	dataoff = protoff + th->doff * 4;	if (dataoff >= skb->len)		return NF_ACCEPT;	datalen = skb->len - dataoff;	spin_lock_bh(&nf_sane_lock);	sb_ptr = skb_header_pointer(skb, dataoff, datalen, sane_buffer);	BUG_ON(sb_ptr == NULL);	if (dir == IP_CT_DIR_ORIGINAL) {		if (datalen != sizeof(struct sane_request))			goto out;		req = (struct sane_request *)sb_ptr;		if (req->RPC_code != htonl(SANE_NET_START)) {			/* Not an interesting command */			ct_sane_info->state = SANE_STATE_NORMAL;			goto out;		}		/* We're interested in the next reply */		ct_sane_info->state = SANE_STATE_START_REQUESTED;		goto out;	}	/* Is it a reply to an uninteresting command? */	if (ct_sane_info->state != SANE_STATE_START_REQUESTED)		goto out;	/* It's a reply to SANE_NET_START. */	ct_sane_info->state = SANE_STATE_NORMAL;	if (datalen < sizeof(struct sane_reply_net_start)) {		pr_debug("nf_ct_sane: NET_START reply too short/n");		goto out;	}	reply = (struct sane_reply_net_start *)sb_ptr;	if (reply->status != htonl(SANE_STATUS_SUCCESS)) {		/* saned refused the command */		pr_debug("nf_ct_sane: unsuccessful SANE_STATUS = %u/n",			 ntohl(reply->status));		goto out;	}	/* Invalid saned reply? Ignore it. */	if (reply->zero != 0)		goto out;	exp = nf_conntrack_expect_alloc(ct);	if (exp == NULL) {		ret = NF_DROP;		goto out;	}	tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;	nf_conntrack_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, family,				 &tuple->src.u3, &tuple->dst.u3,				 IPPROTO_TCP, NULL, &reply->port);	pr_debug("nf_ct_sane: expect: ");	NF_CT_DUMP_TUPLE(&exp->tuple);	/* Can't expect this?  Best to drop packet now. */	if (nf_conntrack_expect_related(exp) != 0)		ret = NF_DROP;	nf_conntrack_expect_put(exp);out://.........这里部分代码省略.........
开发者ID:Mr-Aloof,项目名称:wl500g,代码行数:101,


示例12: esp6_output

int esp6_output(struct sk_buff *skb){	int err;	int hdr_len = 0;	struct dst_entry *dst = skb->dst;	struct xfrm_state *x  = dst->xfrm;	struct ipv6hdr *iph = NULL, *top_iph;	struct ipv6_esp_hdr *esph;	struct crypto_tfm *tfm;	struct esp_data *esp;	struct sk_buff *trailer;	int blksize;	int clen;	int alen;	int nfrags;	u8 *prevhdr;	u8 nexthdr = 0;	/* First, if the skb is not checksummed, complete checksum. */	if (skb->ip_summed == CHECKSUM_HW && skb_checksum_help(skb) == NULL) {		err = -EINVAL;		goto error_nolock;	}	spin_lock_bh(&x->lock);	err = xfrm_check_output(x, skb, AF_INET6);	if (err)		goto error;	err = -ENOMEM;	/* Strip IP header in transport mode. Save it. */	if (!x->props.mode) {		hdr_len = ip6_find_1stfragopt(skb, &prevhdr);		nexthdr = *prevhdr;		*prevhdr = IPPROTO_ESP;		iph = kmalloc(hdr_len, GFP_ATOMIC);		if (!iph) {			err = -ENOMEM;			goto error;		}		memcpy(iph, skb->nh.raw, hdr_len);		__skb_pull(skb, hdr_len);	}	/* Now skb is pure payload to encrypt */	/* Round to block size */	clen = skb->len;	esp = x->data;	alen = esp->auth.icv_trunc_len;	tfm = esp->conf.tfm;	blksize = (crypto_tfm_alg_blocksize(tfm) + 3) & ~3;	clen = (clen + 2 + blksize-1)&~(blksize-1);	if (esp->conf.padlen)		clen = (clen + esp->conf.padlen-1)&~(esp->conf.padlen-1);	if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0) {		if (!x->props.mode && iph) kfree(iph);		goto error;	}	/* Fill padding... */	do {		int i;		for (i=0; i<clen-skb->len - 2; i++)			*(u8*)(trailer->tail + i) = i+1;	} while (0);	*(u8*)(trailer->tail + clen-skb->len - 2) = (clen - skb->len)-2;	pskb_put(skb, trailer, clen - skb->len);	if (x->props.mode) {		iph = skb->nh.ipv6h;		top_iph = (struct ipv6hdr*)skb_push(skb, x->props.header_len);		esph = (struct ipv6_esp_hdr*)(top_iph+1);		*(u8*)(trailer->tail - 1) = IPPROTO_IPV6;		top_iph->version = 6;		top_iph->priority = iph->priority;		top_iph->flow_lbl[0] = iph->flow_lbl[0];		top_iph->flow_lbl[1] = iph->flow_lbl[1];		top_iph->flow_lbl[2] = iph->flow_lbl[2];		if (x->props.flags & XFRM_STATE_NOECN)			IP6_ECN_clear(top_iph);		top_iph->nexthdr = IPPROTO_ESP;		top_iph->payload_len = htons(skb->len + alen - sizeof(struct ipv6hdr));		top_iph->hop_limit = iph->hop_limit;		ipv6_addr_copy(&top_iph->saddr,			       (struct in6_addr *)&x->props.saddr);		ipv6_addr_copy(&top_iph->daddr,			       (struct in6_addr *)&x->id.daddr);	} else { 		esph = (struct ipv6_esp_hdr*)skb_push(skb, x->props.header_len);		skb->h.raw = (unsigned char*)esph;		top_iph = (struct ipv6hdr*)skb_push(skb, hdr_len);		memcpy(top_iph, iph, hdr_len);		kfree(iph);		top_iph->payload_len = htons(skb->len + alen - sizeof(struct ipv6hdr));		*(u8*)(trailer->tail - 1) = nexthdr;	}//.........这里部分代码省略.........
开发者ID:xricson,项目名称:knoppix,代码行数:101,


示例13: ipv6_recv_error

/* *	Handle MSG_ERRQUEUE */int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len){	struct ipv6_pinfo *np = inet6_sk(sk);	struct sock_exterr_skb *serr;	struct sk_buff *skb, *skb2;	struct sockaddr_in6 *sin;	struct {		struct sock_extended_err ee;		struct sockaddr_in6	 offender;	} errhdr;	int err;	int copied;	err = -EAGAIN;	skb = skb_dequeue(&sk->sk_error_queue);	if (skb == NULL)		goto out;	copied = skb->len;	if (copied > len) {		msg->msg_flags |= MSG_TRUNC;		copied = len;	}	err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);	if (err)		goto out_free_skb;	sock_recv_timestamp(msg, sk, skb);	serr = SKB_EXT_ERR(skb);	sin = (struct sockaddr_in6 *)msg->msg_name;	if (sin) {		const unsigned char *nh = skb_network_header(skb);		sin->sin6_family = AF_INET6;		sin->sin6_flowinfo = 0;		sin->sin6_port = serr->port;		sin->sin6_scope_id = 0;		if (skb->protocol == htons(ETH_P_IPV6)) {			ipv6_addr_copy(&sin->sin6_addr,				  (struct in6_addr *)(nh + serr->addr_offset));			if (np->sndflow)				sin->sin6_flowinfo =					(*(__be32 *)(nh + serr->addr_offset - 24) &					 IPV6_FLOWINFO_MASK);			if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)				sin->sin6_scope_id = IP6CB(skb)->iif;		} else {			ipv6_addr_set_v4mapped(*(__be32 *)(nh + serr->addr_offset),					       &sin->sin6_addr);		}	}	memcpy(&errhdr.ee, &serr->ee, sizeof(struct sock_extended_err));	sin = &errhdr.offender;	sin->sin6_family = AF_UNSPEC;	if (serr->ee.ee_origin != SO_EE_ORIGIN_LOCAL) {		sin->sin6_family = AF_INET6;		sin->sin6_flowinfo = 0;		sin->sin6_scope_id = 0;		if (skb->protocol == htons(ETH_P_IPV6)) {			ipv6_addr_copy(&sin->sin6_addr, &ipv6_hdr(skb)->saddr);			if (np->rxopt.all)				datagram_recv_ctl(sk, msg, skb);			if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)				sin->sin6_scope_id = IP6CB(skb)->iif;		} else {			struct inet_sock *inet = inet_sk(sk);			ipv6_addr_set_v4mapped(ip_hdr(skb)->saddr,					       &sin->sin6_addr);			if (inet->cmsg_flags)				ip_cmsg_recv(msg, skb);		}	}	put_cmsg(msg, SOL_IPV6, IPV6_RECVERR, sizeof(errhdr), &errhdr);	/* Now we could try to dump offended packet options */	msg->msg_flags |= MSG_ERRQUEUE;	err = copied;	/* Reset and regenerate socket error */	spin_lock_bh(&sk->sk_error_queue.lock);	sk->sk_err = 0;	if ((skb2 = skb_peek(&sk->sk_error_queue)) != NULL) {		sk->sk_err = SKB_EXT_ERR(skb2)->ee.ee_errno;		spin_unlock_bh(&sk->sk_error_queue.lock);		sk->sk_error_report(sk);	} else {		spin_unlock_bh(&sk->sk_error_queue.lock);	}out_free_skb:	kfree_skb(skb);out://.........这里部分代码省略.........
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:101,


示例14: poll_routine

static void poll_routine(unsigned long __opaque){    struct timer_list *timer = &poll_timer;    UserPtrs ufuncs;    int offset = (2*HZ);    //printk("Came to poll_routine with %x/n", (u32)(__opaque));    /* Register with DMA incase not already done so */    if(DriverState < POLLING)    {        spin_lock_bh(&RawLock);        printk("Calling DmaRegister on engine %d and %d/n", ENGINE_TX, ENGINE_RX);        DriverState = REGISTERED;        ufuncs.UserInit = myInit;        ufuncs.UserPutPkt = myPutTxPkt;        ufuncs.UserSetState = mySetState;        ufuncs.UserGetState = myGetState;        ufuncs.privData = 0x54545454;        spin_unlock_bh(&RawLock);        if((handle[0] = DmaRegister(ENGINE_TX, MYBAR, &ufuncs, BUFSIZE)) == NULL)        {            printk("Register for engine %d failed. Stopping./n", ENGINE_TX);            spin_lock_bh(&RawLock);            DriverState = UNINITIALIZED;            spin_unlock_bh(&RawLock);            return;     // This polling will not happen again.        }                printk("Handle for engine %d is %p/n", ENGINE_TX, handle[0]);        spin_lock_bh(&RawLock);        ufuncs.UserInit = myInit;        ufuncs.UserPutPkt = myPutRxPkt;        ufuncs.UserGetPkt = myGetRxPkt;        ufuncs.UserSetState = mySetState;        ufuncs.UserGetState = myGetState;        ufuncs.privData = 0x54545456;        spin_unlock_bh(&RawLock);        if((handle[2] = DmaRegister(ENGINE_RX, MYBAR, &ufuncs, BUFSIZE)) == NULL)        {            printk("Register for engine %d failed. Stopping./n", ENGINE_RX);            spin_lock_bh(&RawLock);            DriverState = UNINITIALIZED;            spin_unlock_bh(&RawLock);            return;     // This polling will not happen again.        }        printk("Handle for engine %d is %p/n", ENGINE_RX, handle[2]);        /* Reschedule poll routine */        timer->expires = jiffies + offset;        add_timer(timer); //guodebug: add_timer    }    else if(DriverState == REGISTERED)    {        /* Only if the test mode is set, and only for TX direction */        if((RawTestMode & TEST_START) &&            (RawTestMode & (ENABLE_PKTCHK|ENABLE_LOOPBACK)))        {            spin_lock_bh(&RawLock);            /* First change the state */            RawTestMode &= ~TEST_START;            RawTestMode |= TEST_IN_PROGRESS;            spin_unlock_bh(&RawLock);            /* Now, queue up one packet to start the transmission */            DmaSetupTransmit(handle[0], 1);            /* For the first packet, give some gap before the next TX */            offset = HZ;        }        else if(RawTestMode & TEST_IN_PROGRESS)        {            int avail;            int times;            for(times = 0; times < 9; times++)            {                avail = (TxBufs.TotalNum - TxBufs.AllocNum);                if(avail <= 0) break;                /* Queue up many packets to continue the transmission */                if(DmaSetupTransmit(handle[0], 100) == 0) break;            }            /* Do the next TX as soon as possible */            offset = 0;        }        /* Reschedule poll routine */        timer->expires = jiffies + offset;        add_timer(timer); //guodebug: add_timer    }}
开发者ID:uestcmy,项目名称:5000_test_20140305,代码行数:98,


示例15: ax25_linkfail_register

void ax25_linkfail_register(struct ax25_linkfail *lf){    spin_lock_bh(&linkfail_lock);    hlist_add_head(&lf->lf_node, &ax25_linkfail_list);    spin_unlock_bh(&linkfail_lock);}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:6,


示例16: mySetState

int mySetState(void * hndl, UserState * ustate, unsigned int privdata){    int val;    static unsigned int testmode;    log_verbose(KERN_INFO "Reached mySetState with privdata %x/n", privdata);        /* Check driver state */    if(DriverState != REGISTERED)    {        printk("Driver does not seem to be ready/n");        return EFAULT;    }    /* Check handle value */    if((hndl != handle[0]) && (hndl != handle[2]))    {        printk("Came with wrong handle/n");        return EBADF;    }    /* Valid only for TX engine */    if(privdata == 0x54545454)    {        spin_lock_bh(&RawLock);        /* Set up the value to be written into the register */        RawTestMode = ustate->TestMode;        if(RawTestMode & TEST_START)         {            testmode = 0;            if(RawTestMode & ENABLE_LOOPBACK) testmode |= LOOPBACK;#ifndef XAUI            if(RawTestMode & ENABLE_PKTCHK) testmode |= PKTCHKR;            if(RawTestMode & ENABLE_PKTGEN) testmode |= PKTGENR;#endif        }        else        {            /* Deliberately not clearing the loopback bit, incase a             * loopback test was going on - allows the loopback path             * to drain off packets. Just stopping the source of packets.             */#ifndef XAUI            if(RawTestMode & ENABLE_PKTCHK) testmode &= ~PKTCHKR;            if(RawTestMode & ENABLE_PKTGEN) testmode &= ~PKTGENR;#endif        }        printk("SetState TX with RawTestMode %x, reg value %x/n",                                                     RawTestMode, testmode);        /* Now write the registers */        if(RawTestMode & TEST_START)        {#ifndef XAUI            if(!(RawTestMode & (ENABLE_PKTCHK|ENABLE_PKTGEN|ENABLE_LOOPBACK)))            {                printk("%s Driver: TX Test Start with wrong mode %x/n",                                                 MYNAME, testmode);                RawTestMode = 0;                spin_unlock_bh(&RawLock);                return EBADRQC;            }#endif            printk("%s Driver: Starting the test - mode %x, reg %x/n",                                             MYNAME, RawTestMode, testmode);            /* Next, set packet sizes. Ensure they don't exceed PKTSIZEs */            RawMinPktSize = ustate->MinPktSize;            RawMaxPktSize = ustate->MaxPktSize;#ifndef XAUI            /* Set RX packet size for memory path */            val = RawMaxPktSize;            if(val % BYTEMULTIPLE)                val -= (val % BYTEMULTIPLE);            printk("Reg %x = %x/n", PKT_SIZE_ADDRESS, val);            RawMinPktSize = RawMaxPktSize = val;            /* Now ensure the sizes remain within bounds */            if(RawMaxPktSize > MAXPKTSIZE)                RawMinPktSize = RawMaxPktSize = MAXPKTSIZE;            if(RawMinPktSize < MINPKTSIZE)                RawMinPktSize = RawMaxPktSize = MINPKTSIZE;            if(RawMinPktSize > RawMaxPktSize)                RawMinPktSize = RawMaxPktSize;            val = RawMaxPktSize;            printk("========Reg %x = %d/n", PKT_SIZE_ADDRESS, val);            XIo_Out32(TXbarbase+PKT_SIZE_ADDRESS, val);            printk("RxPktSize %d/n", val);#else            /* Now ensure the sizes remain within bounds */            if(RawMaxPktSize > MAXPKTSIZE)                RawMaxPktSize = MAXPKTSIZE;            if(RawMinPktSize < MINPKTSIZE)                RawMinPktSize = MINPKTSIZE;//.........这里部分代码省略.........
开发者ID:uestcmy,项目名称:5000_test_20140305,代码行数:101,


示例17: help

static int help(struct sk_buff **pskb,		struct ip_conntrack *ct, enum ip_conntrack_info ctinfo){	unsigned int dataoff;	struct tcphdr _tcph, *th;	char *data, *data_limit, *ib_ptr;	int dir = CTINFO2DIR(ctinfo);	struct ip_conntrack_expect *exp;	u32 seq;	u_int32_t dcc_ip;	u_int16_t dcc_port;	int i, ret = NF_ACCEPT;	char *addr_beg_p, *addr_end_p;	typeof(ip_nat_irc_hook) ip_nat_irc;	DEBUGP("entered/n");	/* If packet is coming from IRC server */	if (dir == IP_CT_DIR_REPLY)		return NF_ACCEPT;	/* Until there's been traffic both ways, don't look in packets. */	if (ctinfo != IP_CT_ESTABLISHED	    && ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {		DEBUGP("Conntrackinfo = %u/n", ctinfo);		return NF_ACCEPT;	}	/* Not a full tcp header? */	th = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl*4,				sizeof(_tcph), &_tcph);	if (th == NULL)		return NF_ACCEPT;	/* No data? */	dataoff = (*pskb)->nh.iph->ihl*4 + th->doff*4;	if (dataoff >= (*pskb)->len)		return NF_ACCEPT;	spin_lock_bh(&irc_buffer_lock);	ib_ptr = skb_header_pointer(*pskb, dataoff,				    (*pskb)->len - dataoff, irc_buffer);	BUG_ON(ib_ptr == NULL);	data = ib_ptr;	data_limit = ib_ptr + (*pskb)->len - dataoff;	/* strlen("/1DCC SENT t AAAAAAAA P/1/n")=24	 * 5+MINMATCHLEN+strlen("t AAAAAAAA P/1/n")=14 */	while (data < (data_limit - (19 + MINMATCHLEN))) {		if (memcmp(data, "/1DCC ", 5)) {			data++;			continue;		}		data += 5;		/* we have at least (19+MINMATCHLEN)-5 bytes valid data left */		DEBUGP("DCC found in master %u.%u.%u.%u:%u %u.%u.%u.%u:%u.../n",			NIPQUAD(iph->saddr), ntohs(th->source),			NIPQUAD(iph->daddr), ntohs(th->dest));		for (i = 0; i < ARRAY_SIZE(dccprotos); i++) {			if (memcmp(data, dccprotos[i], strlen(dccprotos[i]))) {				/* no match */				continue;			}			DEBUGP("DCC %s detected/n", dccprotos[i]);			data += strlen(dccprotos[i]);			/* we have at least			 * (19+MINMATCHLEN)-5-dccprotos[i].matchlen bytes valid			 * data left (== 14/13 bytes) */			if (parse_dcc((char *)data, data_limit, &dcc_ip,				       &dcc_port, &addr_beg_p, &addr_end_p)) {				/* unable to parse */				DEBUGP("unable to parse dcc command/n");				continue;			}			DEBUGP("DCC bound ip/port: %u.%u.%u.%u:%u/n",				HIPQUAD(dcc_ip), dcc_port);			/* dcc_ip can be the internal OR external (NAT'ed) IP			 * Tiago Sousa <[email
C++ spin_lock_init函数代码示例
C++ spin_lock函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。