Send Data(IP Packets) to Ethernet Rx Buffer using SK Buffer

bhargavram.chowadry

New Member
Joined
Apr 3, 2019
Messages
1
Reaction score
0
Credits
0
Our requirement is to collect ethernet (IP) packets as data & forward that data to ethernet Rx buffer so that it can be read by standard socket interface from user space. Currently we are creating the IP packets by assigning dummy values with proper header, checksum & size & trying to write into Ethernet Port Rx Buffer.
The below mentioned sequence was followed to test this :
1. Create a SK buffer using dev_alloc_skb
2. Frame the ethernet packet by assigning IP parameters.
3. Copy the packet data using skb_put() to the skb buffer .
4. Send it to the Ethernet Port Rx buffer using netif_receive_skb().
During this process, our packets are getting dropped after executing netif_receive_skb.

Please let us know methods to resolve this issue & also suggest any other/better mechanism to address this requirement.



///////////////////////////////////////////// Receive packet funtion //////////////////////////////////////////////////////////////////////////////////
void Receive_A_pkt(struct net_device *dev) {
struct sk_buff *skb;
struct dpaa_priv *priv = netdev_priv(dev);
struct sk_buff *pkt = create_a_pkt(dev); // to create udp packet
if(!pkt)
return (-1);
/*
* The packet has been retrieved from the transmission
* medium. Build ans skb around it, so upper layers can handle it
*/
skb = dev_alloc_skb(pkt->data_len + 2); //alocating the buffer for the packet

/* Checking if the packet allocation process went wrong */
if (!skb) {
if (printk_ratelimit())
printk(KERN_NOTICE "Eth rx: low on mem - packet dropped\n");
// priv->stats.rx_dropped++;
goto out;
}
memcpy(skb_put(skb, pkt->data_len), pkt->data, pkt->data_len); //No problems, so we can copy the packet to the buffer.

/* Write metadata, and then pass to the receive level */
skb->dev = dev;
skb->protocol = eth_type_trans(skb, dev);
skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */
// priv->percpu_priv->rx_packets++;
// priv->percpu_priv->rx_bytes += pkt->datalen;
// netif_rx(skb);


if (unlikely(netif_receive_skb(skb) == NET_RX_DROP)) {
//percpu_stats->rx_dropped++;
//return qman_cb_dqrr_consume;
printk(KERN_INFO "Eth rx: packet dropped\n");
}

out:
return;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 

Members online


Latest posts

Top