本文整理汇总了C++中skb_get函数的典型用法代码示例。如果您正苦于以下问题:C++ skb_get函数的具体用法?C++ skb_get怎么用?C++ skb_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skb_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rxrpc_get_skb
/*
* Note the addition of a ref on a socket buffer.
*/
void rxrpc_get_skb(struct sk_buff *skb, enum rxrpc_skb_trace op)
{
const void *here = __builtin_return_address(0);
int n = atomic_inc_return(select_skb_count(op));
trace_rxrpc_skb(skb, op, refcount_read(&skb->users), n, here);
skb_get(skb);
}
示例2: skb_clone_fraglist
static void skb_clone_fraglist(struct sk_buff *skb)
{
struct sk_buff *list;
skb_walk_frags(skb, list)
skb_get(list);
}
示例3: ircomm_lmp_connect_response
/*
* Function ircomm_lmp_connect_response (self, skb)
*
*
*
*/
static int ircomm_lmp_connect_response(struct ircomm_cb *self,
struct sk_buff *userdata)
{
struct sk_buff *tx_skb;
int ret;
IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
/* Any userdata supplied? */
if (userdata == NULL) {
tx_skb = dev_alloc_skb(64);
if (!tx_skb)
return -ENOMEM;
/* Reserve space for MUX and LAP header */
skb_reserve(tx_skb, LMP_MAX_HEADER);
} else {
/*
* Check that the client has reserved enough space for
* headers
*/
ASSERT(skb_headroom(userdata) >= LMP_MAX_HEADER, return -1;);
/* Don't forget to refcount it - should be NULL anyway */
skb_get(userdata);
tx_skb = userdata;
}
示例4: recv_handler
static void recv_handler(struct sk_buff *__skb)
{
struct sk_buff * skb = NULL; //socket buffer
struct nlmsghdr * nlhdr = NULL; //netlink message header
struct cn_msg * cmsg = NULL; //netlink connector message
struct w1_netlink_msg * w1msg = NULL; //w1 netlink message
struct w1_netlink_cmd * w1cmd = NULL; //w1 netlink command
int minSize = sizeof(struct nlmsghdr) + sizeof(struct cn_msg)
+ sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
int len;
//must be done here:
skb = skb_get(__skb);
nlhdr = (struct nlmsghdr *)skb->data;
if (nlhdr->nlmsg_len < minSize)
{
printk("Corrupt w1 netlink message.\n");
return;
}
len = nlhdr->nlmsg_len - NLMSG_LENGTH(0);
printk("Got a netlink msg, it's length is %d.\n", len);
cmsg = NLMSG_DATA(nlhdr);
on_w1_msg_received(cmsg);
}
示例5: skb_clone_fraglist
static void skb_clone_fraglist(struct sk_buff *skb)
{
struct sk_buff *list;
for (list = skb_shinfo(skb)->frag_list; list; list = list->next)
skb_get(list);
}
示例6: connection_process
int connection_process(struct connection *conn, struct sk_buff *skb)
{
int ret = 0;
do {
if (mutex_lock_interruptible(&(conn->data_lock))) {
MCDRV_DBG_ERROR("Interrupted getting data semaphore!");
ret = -1;
break;
}
kfree_skb(conn->skb);
/* Get a reference to the incomming skb */
conn->skb = skb_get(skb);
if (conn->skb) {
conn->data_msg = nlmsg_hdr(conn->skb);
conn->data_len = NLMSG_PAYLOAD(conn->data_msg, 0);
conn->data_start = NLMSG_DATA(conn->data_msg);
up(&(conn->data_available_sem));
}
mutex_unlock(&(conn->data_lock));
ret = 0;
} while (0);
return ret;
}
示例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;
}
示例8: nl_data_ready
void nl_data_ready(struct sk_buff *__skb)
{
struct sk_buff *skb;
struct nlmsghdr *nlh;
char str[100];
// struct completion cmpl;
int i=10;
skb = skb_get (__skb);
if(skb->len >= NLMSG_SPACE(0)){
nlh = nlmsg_hdr(skb);
memcpy(str, NLMSG_DATA(nlh), sizeof(str));
printk("Message received:%s\n",str) ;
pid = nlh->nlmsg_pid;
while(i--){
//init_completion(&cmpl);
//wait_for_completion_timeout(&cmpl,3 * HZ);
sendnlmsg();
break;
}
flag = 1;
kfree_skb(skb);
}
}
示例9: kernel_receive
void kernel_receive(struct sk_buff *__skb) //内核从用户空间接收数据
{
struct sk_buff *skb;
struct nlmsghdr *nlh = NULL;
char *data = "This is eric's test message from kernel";
printk( "[kernel recv] begin kernel_receive\n");
skb = skb_get(__skb);
if(skb->len >= sizeof(struct nlmsghdr)){
nlh = (struct nlmsghdr *)skb->data;
if((nlh->nlmsg_len >= sizeof(struct nlmsghdr))
&& (__skb->len >= nlh->nlmsg_len)){
user_process.pid = nlh->nlmsg_pid;
printk( "[kernel recv] data receive from user are:%s\n", (char *)NLMSG_DATA(nlh));
printk( "[kernel recv] user_pid:%d\n", user_process.pid);
// send_to_user(data);
}
}else{
printk( "[kernel recv] data receive from user are:%s\n",(char *)NLMSG_DATA(nlmsg_hdr(__skb)));
// send_to_user(data);
}
kfree_skb(skb);
}
示例10: handle_fragments
/* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero
* value if 'skb' is freed.
*/
static int handle_fragments(struct net *net, struct sw_flow_key *key,
u16 zone, struct sk_buff *skb)
{
struct ovs_gso_cb ovs_cb = *OVS_GSO_CB(skb);
if (!skb->dev) {
OVS_NLERR(true, "%s: skb has no dev; dropping", __func__);
return -EINVAL;
}
if (key->eth.type == htons(ETH_P_IP)) {
enum ip_defrag_users user = IP_DEFRAG_CONNTRACK_IN + zone;
int err;
memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
err = ip_defrag(skb, user);
if (err)
return err;
ovs_cb.dp_cb.mru = IPCB(skb)->frag_max_size;
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
} else if (key->eth.type == htons(ETH_P_IPV6)) {
enum ip6_defrag_users user = IP6_DEFRAG_CONNTRACK_IN + zone;
struct sk_buff *reasm;
memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
reasm = nf_ct_frag6_gather(skb, user);
if (!reasm)
return -EINPROGRESS;
if (skb == reasm) {
kfree_skb(skb);
return -EINVAL;
}
/* Don't free 'skb' even though it is one of the original
* fragments, as we're going to morph it into the head.
*/
skb_get(skb);
nf_ct_frag6_consume_orig(reasm);
key->ip.proto = ipv6_hdr(reasm)->nexthdr;
skb_morph(skb, reasm);
skb->next = reasm->next;
consume_skb(reasm);
ovs_cb.dp_cb.mru = IP6CB(skb)->frag_max_size;
#endif /* IP frag support */
} else {
kfree_skb(skb);
return -EPFNOSUPPORT;
}
key->ip.frag = OVS_FRAG_TYPE_NONE;
skb_clear_hash(skb);
skb->ignore_df = 1;
*OVS_GSO_CB(skb) = ovs_cb;
return 0;
}
示例11: wil_txdesc_debugfs_show
/*---------Tx/Rx descriptor------------*/
static int wil_txdesc_debugfs_show(struct seq_file *s, void *data)
{
struct wil6210_priv *wil = s->private;
struct vring *vring;
bool tx = (dbg_vring_index < WIL6210_MAX_TX_RINGS);
if (tx)
vring = &(wil->vring_tx[dbg_vring_index]);
else
vring = &wil->vring_rx;
if (!vring->va) {
if (tx)
seq_printf(s, "No Tx[%2d] VRING\n", dbg_vring_index);
else
seq_puts(s, "No Rx VRING\n");
return 0;
}
if (dbg_txdesc_index < vring->size) {
/* use struct vring_tx_desc for Rx as well,
* only field used, .dma.length, is the same
*/
volatile struct vring_tx_desc *d =
&(vring->va[dbg_txdesc_index].tx);
volatile u32 *u = (volatile u32 *)d;
struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb;
if (tx)
seq_printf(s, "Tx[%2d][%3d] = {\n", dbg_vring_index,
dbg_txdesc_index);
else
seq_printf(s, "Rx[%3d] = {\n", dbg_txdesc_index);
seq_printf(s, " MAC = 0x%08x 0x%08x 0x%08x 0x%08x\n",
u[0], u[1], u[2], u[3]);
seq_printf(s, " DMA = 0x%08x 0x%08x 0x%08x 0x%08x\n",
u[4], u[5], u[6], u[7]);
seq_printf(s, " SKB = 0x%p\n", skb);
if (skb) {
skb_get(skb);
wil_seq_print_skb(s, skb);
kfree_skb(skb);
}
seq_printf(s, "}\n");
} else {
if (tx)
seq_printf(s, "[%2d] TxDesc index (%d) >= size (%d)\n",
dbg_vring_index, dbg_txdesc_index,
vring->size);
else
seq_printf(s, "RxDesc index (%d) >= size (%d)\n",
dbg_txdesc_index, vring->size);
}
return 0;
}
示例12: 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;
}
示例13: 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;
}
示例14: hns3_lp_run_test
/**
* hns3_lp_run_test - run loopback test
* @ndev: net device
* @mode: loopback type
*/
static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode)
{
struct hns3_nic_priv *priv = netdev_priv(ndev);
struct sk_buff *skb;
u32 i, good_cnt;
int ret_val = 0;
skb = alloc_skb(HNS3_NIC_LB_TEST_PACKET_SIZE + ETH_HLEN + NET_IP_ALIGN,
GFP_KERNEL);
if (!skb)
return HNS3_NIC_LB_TEST_NO_MEM_ERR;
skb->dev = ndev;
hns3_lp_setup_skb(skb);
skb->queue_mapping = HNS3_NIC_LB_TEST_RING_ID;
good_cnt = 0;
for (i = 0; i < HNS3_NIC_LB_TEST_PKT_NUM; i++) {
netdev_tx_t tx_ret;
skb_get(skb);
tx_ret = hns3_nic_net_xmit(skb, ndev);
if (tx_ret == NETDEV_TX_OK)
good_cnt++;
else
netdev_err(ndev, "hns3_lb_run_test xmit failed: %d\n",
tx_ret);
}
if (good_cnt != HNS3_NIC_LB_TEST_PKT_NUM) {
ret_val = HNS3_NIC_LB_TEST_TX_CNT_ERR;
netdev_err(ndev, "mode %d sent fail, cnt=0x%x, budget=0x%x\n",
mode, good_cnt, HNS3_NIC_LB_TEST_PKT_NUM);
goto out;
}
/* Allow 200 milliseconds for packets to go from Tx to Rx */
msleep(200);
good_cnt = hns3_lb_check_rx_ring(priv, HNS3_NIC_LB_TEST_PKT_NUM);
if (good_cnt != HNS3_NIC_LB_TEST_PKT_NUM) {
ret_val = HNS3_NIC_LB_TEST_RX_CNT_ERR;
netdev_err(ndev, "mode %d recv fail, cnt=0x%x, budget=0x%x\n",
mode, good_cnt, HNS3_NIC_LB_TEST_PKT_NUM);
}
out:
hns3_lb_clear_tx_ring(priv, HNS3_NIC_LB_TEST_RING_ID,
HNS3_NIC_LB_TEST_RING_ID,
HNS3_NIC_LB_TEST_PKT_NUM);
kfree_skb(skb);
return ret_val;
}
示例15: efx_begin_loopback
static int efx_begin_loopback(struct efx_tx_queue *tx_queue)
{
struct efx_nic *efx = tx_queue->efx;
struct efx_loopback_state *state = efx->loopback_selftest;
struct efx_loopback_payload *payload;
struct sk_buff *skb;
int i;
netdev_tx_t rc;
/* Transmit N copies of buffer */
for (i = 0; i < state->packet_count; i++) {
/* Allocate an skb, holding an extra reference for
* transmit completion counting */
skb = alloc_skb(sizeof(state->payload), GFP_KERNEL);
if (!skb)
return -ENOMEM;
state->skbs[i] = skb;
skb_get(skb);
/* Copy the payload in, incrementing the source address to
* exercise the rss vectors */
payload = ((struct efx_loopback_payload *)
skb_put(skb, sizeof(state->payload)));
memcpy(payload, &state->payload, sizeof(state->payload));
payload->ip.saddr = htonl(INADDR_LOOPBACK | (i << 2));
/* Ensure everything we've written is visible to the
* interrupt handler. */
smp_wmb();
if (efx_dev_registered(efx))
netif_tx_lock_bh(efx->net_dev);
rc = efx_enqueue_skb(tx_queue, skb);
if (efx_dev_registered(efx))
netif_tx_unlock_bh(efx->net_dev);
if (rc != NETDEV_TX_OK) {
EFX_ERR(efx, "TX queue %d could not transmit packet %d "
"of %d in %s loopback test\n", tx_queue->queue,
i + 1, state->packet_count, LOOPBACK_MODE(efx));
/* Defer cleaning up the other skbs for the caller */
kfree_skb(skb);
return -EPIPE;
}
}
return 0;
}