本文整理汇总了C++中skb_shared函数的典型用法代码示例。如果您正苦于以下问题:C++ skb_shared函数的具体用法?C++ skb_shared怎么用?C++ skb_shared使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skb_shared函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ebt_target_snat
static int ebt_target_snat(struct sk_buff **pskb, unsigned int hooknr,
const struct net_device *in, const struct net_device *out,
const void *data, unsigned int datalen)
{
struct ebt_nat_info *info = (struct ebt_nat_info *) data;
if (skb_shared(*pskb) || skb_cloned(*pskb)) {
struct sk_buff *nskb;
nskb = skb_copy(*pskb, GFP_ATOMIC);
if (!nskb)
return NF_DROP;
if ((*pskb)->sk)
skb_set_owner_w(nskb, (*pskb)->sk);
kfree_skb(*pskb);
*pskb = nskb;
}
memcpy(eth_hdr(*pskb)->h_source, info->mac, ETH_ALEN);
if (!(info->target & NAT_ARP_BIT) &&
eth_hdr(*pskb)->h_proto == htons(ETH_P_ARP)) {
struct arphdr _ah, *ap;
ap = skb_header_pointer(*pskb, 0, sizeof(_ah), &_ah);
if (ap == NULL)
return EBT_DROP;
if (ap->ar_hln != ETH_ALEN)
goto out;
if (skb_store_bits(*pskb, sizeof(_ah), info->mac,ETH_ALEN))
return EBT_DROP;
}
out:
return info->target | ~EBT_VERDICT_BITS;
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:33,代码来源:ebt_snat.c
示例2: __gmac_recv
/**
* @brief Protocol drivers Receive function
*
* @param skb
* @param dev
* @param type
* @param orig_dev
*
* @return int
*/
int
__gmac_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *type, struct net_device *orig_dev)
{
athhdr_t *ath;
ethhdr_t *eth;
hif_gmac_node_t *node = NULL;
a_uint32_t idx = 0;
hif_gmac_softc_t *sc = __gmac_pkt.af_packet_priv;
if (skb_shared(skb))
skb = skb_unshare(skb, GFP_ATOMIC);
eth = eth_hdr(skb); /* Linux specific */
ath = ath_hdr(skb);
/* printk("%s\n",__func__); */
/**
* Query MAC Table
*/
node = __gmac_qry_tbl(eth->h_source);
idx = ((node->hdr.ath.type.proto == ath->type.proto) &&
chk_ucast(eth->h_dest));
sc->recv_fn[idx](skb, node, ath->type.proto);
return 0;
}
开发者ID:jorneytu,项目名称:wlan,代码行数:39,代码来源:if_ath_gmac.c
示例3: osif_send_to_nss
void
osif_send_to_nss(os_if_t osif, struct sk_buff *skb, int nwifi)
{
struct net_device *dev = OSIF_TO_NETDEV(osif);
osif_dev *osifp = (osif_dev *) osif;
if(!osifp->nssctx){
goto out;
}
skb->next =NULL;
if (skb_shared(skb)){
goto out;
}
if (nwifi) {
if (nss_tx_virt_if_rx_nwifibuf(osifp->nssctx, skb)) {
goto out ;
}
} else {
if(nss_tx_virt_if_rxbuf(osifp->nssctx, skb)){
goto out;
}
}
return ;
out:
if (nwifi) {
transcap_nwifi_to_8023(skb);
skb->protocol = eth_type_trans(skb, dev);
}
skb->dev = dev;
netif_rx(skb);
return ;
}
开发者ID:KHATEEBNSIT,项目名称:AP,代码行数:35,代码来源:osif_nss.c
示例4: skb_recycle_check
/**
* skb_recycle_check - check if skb can be reused for receive
* @skb: buffer
* @skb_size: minimum receive buffer size
*
* Checks that the skb passed in is not shared or cloned, and
* that it is linear and its head portion at least as large as
* skb_size so that it can be recycled as a receive buffer.
* If these conditions are met, this function does any necessary
* reference count dropping and cleans up the skbuff as if it
* just came from __alloc_skb().
*/
bool skb_recycle_check(struct sk_buff *skb, int skb_size)
{
struct skb_shared_info *shinfo;
// if (irqs_disabled())
// return false;
if (skb_is_nonlinear(skb) || skb->fclone != SKB_FCLONE_UNAVAILABLE)
return false;
skb_size = SKB_DATA_ALIGN(skb_size + NET_SKB_PAD);
if (skb_end_pointer(skb) - skb->head < skb_size)
return false;
if (skb_shared(skb) || skb_cloned(skb))
return false;
skb_release_head_state(skb);
shinfo = skb_shinfo(skb);
memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
atomic_set(&shinfo->dataref, 1);
memset(skb, 0, offsetof(struct sk_buff, tail));
skb->data = skb->head + NET_SKB_PAD;
skb_reset_tail_pointer(skb);
return true;
} EXPORT_SYMBOL(skb_recycle_check);
开发者ID:foxwolf,项目名称:yjd,代码行数:41,代码来源:skbuff.c
示例5:
static struct sock *run_bpf(struct sock_reuseport *reuse, u16 socks,
struct bpf_prog *prog, struct sk_buff *skb,
int hdr_len)
{
struct sk_buff *nskb = NULL;
u32 index;
if (skb_shared(skb)) {
nskb = skb_clone(skb, GFP_ATOMIC);
if (!nskb)
return NULL;
skb = nskb;
}
/* temporarily advance data past protocol header */
if (!pskb_pull(skb, hdr_len)) {
kfree_skb(nskb);
return NULL;
}
index = bpf_prog_run_save_cb(prog, skb);
__skb_push(skb, hdr_len);
consume_skb(nskb);
if (index >= socks)
return NULL;
return reuse->socks[index];
}
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:29,代码来源:sock_reuseport.c
示例6: ip_vs_make_skb_writable
int ip_vs_make_skb_writable(struct sk_buff **pskb, int writable_len)
{
struct sk_buff *skb = *pskb;
/* skb is already used, better copy skb and its payload */
if (unlikely(skb_shared(skb) || skb->sk))
goto copy_skb;
/* skb data is already used, copy it */
if (unlikely(skb_cloned(skb)))
goto copy_data;
return pskb_may_pull(skb, writable_len);
copy_data:
if (unlikely(writable_len > skb->len))
return 0;
return !pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
copy_skb:
if (unlikely(writable_len > skb->len))
return 0;
skb = skb_copy(skb, GFP_ATOMIC);
if (!skb)
return 0;
BUG_ON(skb_is_nonlinear(skb));
/* Rest of kernel will get very unhappy if we pass it a
suddenly-orphaned skbuff */
if ((*pskb)->sk)
skb_set_owner_w(skb, (*pskb)->sk);
kfree_skb(*pskb);
*pskb = skb;
return 1;
}
开发者ID:smx-smx,项目名称:dsl-n55u,代码行数:35,代码来源:ip_vs_core.c
示例7: genl_exec
int genl_exec(genl_exec_func_t func, void *data)
{
int ret;
mutex_lock(&genl_exec_lock);
init_completion(&done);
skb_get(genlmsg_skb);
genlmsg_put(genlmsg_skb, 0, 0, &genl_exec_family,
NLM_F_REQUEST, GENL_EXEC_RUN);
genl_exec_function = func;
genl_exec_data = data;
/* There is no need to send msg to current namespace. */
ret = genlmsg_unicast(&init_net, genlmsg_skb, 0);
if (!ret) {
wait_for_completion(&done);
ret = genl_exec_function_ret;
} else {
pr_err("genl_exec send error %d\n", ret);
}
/* Wait for genetlink to kfree skb. */
while (skb_shared(genlmsg_skb))
cpu_relax();
genlmsg_skb->data = genlmsg_skb->head;
skb_reset_tail_pointer(genlmsg_skb);
mutex_unlock(&genl_exec_lock);
return ret;
}
开发者ID:yeasy,项目名称:openvswitch-lc,代码行数:35,代码来源:genl_exec.c
示例8: ERR_PTR
static struct sk_buff *skb_set_peeked(struct sk_buff *skb)
{
struct sk_buff *nskb;
if (skb->peeked)
return skb;
/* We have to unshare an skb before modifying it. */
if (!skb_shared(skb))
goto done;
nskb = skb_clone(skb, GFP_ATOMIC);
if (!nskb)
return ERR_PTR(-ENOMEM);
skb->prev->next = nskb;
skb->next->prev = nskb;
nskb->prev = skb->prev;
nskb->next = skb->next;
consume_skb(skb);
skb = nskb;
done:
skb->peeked = 1;
return skb;
}
开发者ID:Taran2ul,项目名称:rt-n56u,代码行数:28,代码来源:datagram.c
示例9: ethertap_rx_skb
static __inline__ int ethertap_rx_skb(struct sk_buff *skb, struct net_device *dev)
{
struct net_local *lp = (struct net_local *)dev->priv;
#ifdef CONFIG_ETHERTAP_MC
struct ethhdr *eth = (struct ethhdr*)(skb->data + 2);
#endif
int len = skb->len;
if (len < 16) {
printk(KERN_DEBUG "%s : rx len = %d\n", dev->name, len);
kfree_skb(skb);
return -EINVAL;
}
if (NETLINK_CREDS(skb)->uid) {
printk(KERN_INFO "%s : user %d\n", dev->name, NETLINK_CREDS(skb)->uid);
kfree_skb(skb);
return -EPERM;
}
#ifdef CONFIG_ETHERTAP_MC
if (!(dev->flags&(IFF_NOARP|IFF_PROMISC))) {
int drop = 0;
if (eth->h_dest[0]&1) {
if (!(ethertap_mc_hash(eth->h_dest)&lp->groups))
drop = 1;
} else if (memcmp(eth->h_dest, dev->dev_addr, 6) != 0)
drop = 1;
if (drop) {
if (ethertap_debug > 3)
printk(KERN_DEBUG "%s : not for us\n", dev->name);
kfree_skb(skb);
return -EINVAL;
}
}
#endif
if (skb_shared(skb)) {
struct sk_buff *skb2 = skb;
skb = skb_clone(skb, GFP_KERNEL); /* Clone the buffer */
if (skb==NULL) {
kfree_skb(skb2);
return -ENOBUFS;
}
kfree_skb(skb2);
} else
skb_orphan(skb);
skb_pull(skb, 2);
skb->dev = dev;
skb->protocol=eth_type_trans(skb,dev);
memset(skb->cb, 0, sizeof(skb->cb));
lp->stats.rx_packets++;
lp->stats.rx_bytes+=len;
netif_rx(skb);
dev->last_rx = jiffies;
return len;
}
开发者ID:xricson,项目名称:knoppix,代码行数:59,代码来源:ethertap.c
示例10: offsetof
struct sk_buff *hieth_platdev_alloc_skb(struct hieth_netdev_local *ld)
{
struct sk_buff *skb;
int i;
skb = ld->rx_pool.sk_pool[ld->rx_pool.next_free_skb++];
if (ld->rx_pool.next_free_skb == CONFIG_HIETH_MAX_RX_POOLS)
ld->rx_pool.next_free_skb = 0;
/*current skb is used by kernel or other process,find another skb*/
if (skb_shared(skb) || (atomic_read(&(skb_shinfo(skb)->dataref)) > 1)) {
for (i = 0; i < CONFIG_HIETH_MAX_RX_POOLS; i++) {
skb = ld->rx_pool.sk_pool[ld->rx_pool.next_free_skb++];
if (ld->rx_pool.next_free_skb ==
CONFIG_HIETH_MAX_RX_POOLS)
ld->rx_pool.next_free_skb = 0;
if ((skb_shared(skb) == 0) &&
(atomic_read(&(skb_shinfo(skb)->dataref)) <= 1))
break;
}
if (i == CONFIG_HIETH_MAX_RX_POOLS) {
ld->stat.rx_pool_dry_times++;
hieth_trace(7, "%ld: no free skb\n",
ld->stat.rx_pool_dry_times);
return NULL;
}
}
memset(skb, 0, offsetof(struct sk_buff, tail));
skb->data = skb->tail = skb->head;
skb->end = skb->data + (skb->truesize - sizeof(struct sk_buff));
skb->len = 0;
skb->data_len = 0;
skb->cloned = 0;
atomic_inc(&skb->users);
return skb;
}
开发者ID:jorneytu,项目名称:code,代码行数:46,代码来源:net.c
示例11: target
static unsigned int
target(struct sk_buff **pskb,
const struct net_device *in, const struct net_device *out,
unsigned int hooknum, const struct xt_target *target,
const void *targinfo)
{
const struct arpt_mangle *mangle = targinfo;
struct arphdr *arp;
unsigned char *arpptr;
int pln, hln;
if (skb_shared(*pskb) || skb_cloned(*pskb)) {
struct sk_buff *nskb;
nskb = skb_copy(*pskb, GFP_ATOMIC);
if (!nskb)
return NF_DROP;
if ((*pskb)->sk)
skb_set_owner_w(nskb, (*pskb)->sk);
kfree_skb(*pskb);
*pskb = nskb;
}
arp = (*pskb)->nh.arph;
arpptr = (*pskb)->nh.raw + sizeof(*arp);
pln = arp->ar_pln;
hln = arp->ar_hln;
/* We assume that pln and hln were checked in the match */
if (mangle->flags & ARPT_MANGLE_SDEV) {
if (ARPT_DEV_ADDR_LEN_MAX < hln ||
(arpptr + hln > (**pskb).tail))
return NF_DROP;
memcpy(arpptr, mangle->src_devaddr, hln);
}
arpptr += hln;
if (mangle->flags & ARPT_MANGLE_SIP) {
if (ARPT_MANGLE_ADDR_LEN_MAX < pln ||
(arpptr + pln > (**pskb).tail))
return NF_DROP;
memcpy(arpptr, &mangle->u_s.src_ip, pln);
}
arpptr += pln;
if (mangle->flags & ARPT_MANGLE_TDEV) {
if (ARPT_DEV_ADDR_LEN_MAX < hln ||
(arpptr + hln > (**pskb).tail))
return NF_DROP;
memcpy(arpptr, mangle->tgt_devaddr, hln);
}
arpptr += hln;
if (mangle->flags & ARPT_MANGLE_TIP) {
if (ARPT_MANGLE_ADDR_LEN_MAX < pln ||
(arpptr + pln > (**pskb).tail))
return NF_DROP;
memcpy(arpptr, &mangle->u_t.tgt_ip, pln);
}
return mangle->target;
}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:57,代码来源:arpt_mangle.c
示例12: ethertap_start_xmit
static int ethertap_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct net_local *lp = (struct net_local *)dev->priv;
#ifdef CONFIG_ETHERTAP_MC
struct ethhdr *eth = (struct ethhdr*)skb->data;
#endif
if (skb_headroom(skb) < 2) {
static int once;
struct sk_buff *skb2;
if (!once) {
once = 1;
printk(KERN_DEBUG "%s: not aligned xmit by protocol %04x\n", dev->name, skb->protocol);
}
skb2 = skb_realloc_headroom(skb, 2);
dev_kfree_skb(skb);
if (skb2 == NULL)
return 0;
skb = skb2;
}
__skb_push(skb, 2);
/* Make the same thing, which loopback does. */
if (skb_shared(skb)) {
struct sk_buff *skb2 = skb;
skb = skb_clone(skb, GFP_ATOMIC); /* Clone the buffer */
if (skb==NULL) {
dev_kfree_skb(skb2);
return 0;
}
dev_kfree_skb(skb2);
}
/* ... but do not orphan it here, netlink does it in any case. */
lp->stats.tx_bytes+=skb->len;
lp->stats.tx_packets++;
#ifndef CONFIG_ETHERTAP_MC
netlink_broadcast(lp->nl, skb, 0, ~0, GFP_ATOMIC);
#else
if (dev->flags&IFF_NOARP) {
netlink_broadcast(lp->nl, skb, 0, ~0, GFP_ATOMIC);
return 0;
}
if (!(eth->h_dest[0]&1)) {
/* Unicast packet */
__u32 pid;
memcpy(&pid, eth->h_dest+2, 4);
netlink_unicast(lp->nl, skb, ntohl(pid), MSG_DONTWAIT);
} else
netlink_broadcast(lp->nl, skb, 0, ethertap_mc_hash(eth->h_dest), GFP_ATOMIC);
#endif
return 0;
}
开发者ID:xricson,项目名称:knoppix,代码行数:57,代码来源:ethertap.c
示例13: efx_end_loopback
static int efx_end_loopback(struct efx_tx_queue *tx_queue,
struct efx_loopback_self_tests *lb_tests)
{
struct efx_nic *efx = tx_queue->efx;
struct efx_loopback_state *state = efx->loopback_selftest;
struct sk_buff *skb;
int tx_done = 0, rx_good, rx_bad;
int i, rc = 0;
if (efx_dev_registered(efx))
netif_tx_lock_bh(efx->net_dev);
/* Count the number of tx completions, and decrement the refcnt. Any
* skbs not already completed will be free'd when the queue is flushed */
for (i=0; i < state->packet_count; i++) {
skb = state->skbs[i];
if (skb && !skb_shared(skb))
++tx_done;
dev_kfree_skb_any(skb);
}
if (efx_dev_registered(efx))
netif_tx_unlock_bh(efx->net_dev);
/* Check TX completion and received packet counts */
rx_good = atomic_read(&state->rx_good);
rx_bad = atomic_read(&state->rx_bad);
if (tx_done != state->packet_count) {
/* Don't free the skbs; they will be picked up on TX
* overflow or channel teardown.
*/
EFX_ERR(efx, "TX queue %d saw only %d out of an expected %d "
"TX completion events in %s loopback test\n",
tx_queue->queue, tx_done, state->packet_count,
LOOPBACK_MODE(efx));
rc = -ETIMEDOUT;
/* Allow to fall through so we see the RX errors as well */
}
/* We may always be up to a flush away from our desired packet total */
if (rx_good != state->packet_count) {
EFX_LOG(efx, "TX queue %d saw only %d out of an expected %d "
"received packets in %s loopback test\n",
tx_queue->queue, rx_good, state->packet_count,
LOOPBACK_MODE(efx));
rc = -ETIMEDOUT;
/* Fall through */
}
/* Update loopback test structure */
lb_tests->tx_sent[tx_queue->queue] += state->packet_count;
lb_tests->tx_done[tx_queue->queue] += tx_done;
lb_tests->rx_good += rx_good;
lb_tests->rx_bad += rx_bad;
return rc;
}
开发者ID:Oxel40,项目名称:ev3sources,代码行数:57,代码来源:selftest.c
示例14: imq_nf_queue
static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info,
void *data)
{
struct net_device *dev;
struct net_device_stats *stats;
struct sk_buff *skb2 = NULL;
struct Qdisc *q;
unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
int ret = -1;
if (index > numdevs)
return -1;
dev = imq_devs + index;
if (!(dev->flags & IFF_UP)) {
skb->imq_flags = 0;
nf_reinject(skb, info, NF_ACCEPT);
return 0;
}
dev->last_rx = jiffies;
if (skb->destructor) {
skb2 = skb;
skb = skb_clone(skb, GFP_ATOMIC);
if (!skb)
return -1;
}
skb_push(skb, IMQ_HH_LEN(info));
skb->nf_info = info;
stats = (struct net_device_stats *)dev->priv;
stats->rx_bytes+= skb->len;
stats->rx_packets++;
spin_lock_bh(&dev->queue_lock);
q = dev->qdisc;
if (q->enqueue) {
q->enqueue(skb_get(skb), q);
if (skb_shared(skb)) {
skb->destructor = imq_skb_destructor;
kfree_skb(skb);
ret = 0;
}
}
qdisc_run(dev);
spin_unlock_bh(&dev->queue_lock);
if (skb2)
kfree_skb(ret ? skb : skb2);
return ret;
}
开发者ID:jameshilliard,项目名称:core1-tar4F9632C8CCCE,代码行数:55,代码来源:imq.c
示例15: imq_nf_queue
static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, unsigned queue_num, void *data)
{
struct net_device *dev;
struct net_device_stats *stats;
struct sk_buff *skb2 = NULL;
struct Qdisc *q;
unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
int ret = -1;
if (index > numdevs)
return -1;
dev = imq_devs + index;
if (!(dev->flags & IFF_UP)) {
skb->imq_flags = 0;
nf_reinject(skb, info, NF_ACCEPT);
return 0;
}
dev->last_rx = jiffies;
if (skb->destructor) {
skb2 = skb;
skb = skb_clone(skb, GFP_ATOMIC);
if (!skb)
return -1;
}
skb->nf_info = info;
stats = (struct net_device_stats *)dev->priv;
stats->rx_bytes+= skb->len;
stats->rx_packets++;
spin_lock_bh(&dev->queue_lock);
q = dev->qdisc;
if (q->enqueue) {
q->enqueue(skb_get(skb), q);
if (skb_shared(skb)) {
skb->destructor = imq_skb_destructor;
kfree_skb(skb);
ret = 0;
}
}
if (spin_is_locked(&dev->_xmit_lock))
netif_schedule(dev);
else
while (!netif_queue_stopped(dev) && qdisc_restart1(dev) < 0)
/* NOTHING */;
spin_unlock_bh(&dev->queue_lock);
if (skb2)
kfree_skb(ret ? skb : skb2);
return ret;
}
开发者ID:cilynx,项目名称:dd-wrt,代码行数:55,代码来源:imq.c
示例16: parse_udp_packet
static bool parse_udp_packet(struct sk_buff *skb, struct iphdr **piph, struct udphdr **puh, int *pulen)
{
int proto, len, ulen;
struct iphdr *iph;
struct udphdr *uh;
proto = ntohs(eth_hdr(skb)->h_proto);
if (proto != ETH_P_IP)
return false;
if (skb->pkt_type == PACKET_OTHERHOST)
return false;
if (skb_shared(skb))
return false;
if (!pskb_may_pull(skb, sizeof(struct iphdr)))
return false;
iph = (struct iphdr *)skb->data;
if (iph->ihl < 5 || iph->version != 4)
return false;
if (!pskb_may_pull(skb, iph->ihl * 4))
return false;
iph = (struct iphdr *)skb->data;
if (ip_fast_csum((u8 *)iph, iph->ihl) != 0)
return false;
len = ntohs(iph->tot_len);
if (skb->len < len || len < iph->ihl * 4)
return false;
/*
* Our transport medium may have padded the buffer out.
* Now We trim to the true length of the frame.
*/
if (pskb_trim_rcsum(skb, len))
return false;
iph = (struct iphdr *)skb->data;
if (iph->protocol != IPPROTO_UDP)
return false;
len -= iph->ihl * 4;
uh = (struct udphdr *)(((char *)iph) + iph->ihl * 4);
ulen = ntohs(uh->len);
if (ulen != len)
return false;
*piph = iph;
*puh = uh;
*pulen = ulen;
return true;
}
开发者ID:lzto,项目名称:kgdboe,代码行数:53,代码来源:netpoll_wrapper.c
示例17: fail_if_shared
/**
* Apparently, as of 2007, Netfilter modules can assume they are the sole owners
* of their skbs (http://lists.openwall.net/netdev/2007/10/14/13).
* I can sort of confirm it by noticing that if it's not the case, editing the
* sk_buff structs themselves would be overly cumbersome (since they'd have to
* operate on a clone, and bouncing the clone back to Netfilter is kind of
* outside Netfilter's design).
* This is relevant because we need to call pskb_may_pull(), which might
* eventually call pskb_expand_head(), and that panics if the packet is shared.
* Therefore, I think this validation (with messy WARN included) is fair.
*/
static verdict fail_if_shared(struct xlation *state)
{
if (WARN(skb_shared(state->in.skb), "The packet is shared!"))
return drop(state, JSTAT_SKB_SHARED);
/*
* Keep in mind... "shared" and "cloned" are different concepts.
* We know the sk_buff struct is unique, but somebody else might have an
* active pointer towards the data area.
*/
return VERDICT_CONTINUE;
}
开发者ID:NICMx,项目名称:Jool,代码行数:23,代码来源:packet.c
示例18: irlan_eth_xmit
/*
* Function irlan_eth_tx (skb)
*
* Transmits ethernet frames over IrDA link.
*
*/
static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb,
struct net_device *dev)
{
struct irlan_cb *self = netdev_priv(dev);
int ret;
unsigned int len;
/* skb headroom large enough to contain all IrDA-headers? */
if ((skb_headroom(skb) < self->max_header_size) || (skb_shared(skb))) {
struct sk_buff *new_skb =
skb_realloc_headroom(skb, self->max_header_size);
/* We have to free the original skb anyway */
dev_kfree_skb(skb);
/* Did the realloc succeed? */
if (new_skb == NULL)
return NETDEV_TX_OK;
/* Use the new skb instead */
skb = new_skb;
}
dev->trans_start = jiffies;
len = skb->len;
/* Now queue the packet in the transport layer */
if (self->use_udata)
ret = irttp_udata_request(self->tsap_data, skb);
else
ret = irttp_data_request(self->tsap_data, skb);
if (ret < 0) {
/*
* IrTTPs tx queue is full, so we just have to
* drop the frame! You might think that we should
* just return -1 and don't deallocate the frame,
* but that is dangerous since it's possible that
* we have replaced the original skb with a new
* one with larger headroom, and that would really
* confuse do_dev_queue_xmit() in dev.c! I have
* tried :-) DB
*/
/* irttp_data_request already free the packet */
dev->stats.tx_dropped++;
} else {
dev->stats.tx_packets++;
dev->stats.tx_bytes += len;
}
return NETDEV_TX_OK;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:58,代码来源:irlan_eth.c
示例19: cfpkt_add_body
int cfpkt_add_body(struct cfpkt *pkt, const void *data, u16 len)
{
struct sk_buff *skb = pkt_to_skb(pkt);
struct sk_buff *lastskb;
u8 *to;
u16 addlen = 0;
if (unlikely(is_erronous(pkt)))
return -EPROTO;
lastskb = skb;
/* Check whether we need to add space at the tail */
if (unlikely(skb_tailroom(skb) < len)) {
if (likely(len < PKT_LEN_WHEN_EXTENDING))
addlen = PKT_LEN_WHEN_EXTENDING;
else
addlen = len;
}
/* Check whether we need to change the SKB before writing to the tail */
if (unlikely((addlen > 0) || skb_cloned(skb) || skb_shared(skb))) {
/* Make sure data is writable */
if (unlikely(skb_cow_data(skb, addlen, &lastskb) < 0)) {
PKT_ERROR(pkt, "cfpkt_add_body: cow failed\n");
return -EPROTO;
}
/*
* Is the SKB non-linear after skb_cow_data()? If so, we are
* going to add data to the last SKB, so we need to adjust
* lengths of the top SKB.
*/
if (lastskb != skb) {
pr_warning("CAIF: %s(): Packet is non-linear\n",
__func__);
skb->len += len;
skb->data_len += len;
}
}
/* All set to put the last SKB and optionally write data there. */
to = skb_put(lastskb, len);
if (likely(data))
memcpy(to, data, len);
return 0;
}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:48,代码来源:cfpkt_skbuff.c
示例20: ebt_target_vlan
static int
ebt_target_vlan(struct sk_buff **pskb, unsigned int hooknr,
const struct net_device *in,
const struct net_device *out,
const void *data, unsigned int datalen)
{
struct ebt_vlan_t_info *info = (struct ebt_vlan_t_info *) data;
struct vlan_hdr *vh, frame;
unsigned short TCITmp;
/* raw socket (tcpdump) may have clone of incoming
skb: don't disturb it --RR */
if (skb_shared(*pskb)||(skb_cloned(*pskb) && !(*pskb)->sk)) {
struct sk_buff *nskb = skb_copy(*pskb, GFP_ATOMIC);
if (!nskb)
return NF_DROP;
kfree_skb(*pskb);
*pskb = nskb;
}
if ((*pskb)->protocol == __constant_htons(ETH_P_8021Q)) {
vh = skb_header_pointer(*pskb, 0, sizeof(frame), &frame);
if (GET_BITMASK(EBT_VLAN_TARGET_ID))
{
TCITmp = ntohs (vh->h_vlan_TCI) & ~VLAN_TARGET_VID_MASK;
vh->h_vlan_TCI = htons(TCITmp | info->id);
}
if (GET_BITMASK(EBT_VLAN_TARGET_PRIO))
{
TCITmp = ntohs (vh->h_vlan_TCI) & ~VLAN_TARGET_PRI_MASK;
vh->h_vlan_TCI = htons(TCITmp | (info->prio << 13));
}
}
(*pskb)->nfcache |= NFC_ALTERED;
return info->target;
}
开发者ID:earthGavinLee,项目名称:hg556a_source,代码行数:47,代码来源:ebt_vlan_t.c
注:本文中的skb_shared函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论