Skip to content

Commit

Permalink
now all layers kfifos has values
Browse files Browse the repository at this point in the history
  • Loading branch information
beraldoleal committed Jul 21, 2013
1 parent ce3e866 commit 138f492
Showing 1 changed file with 62 additions and 63 deletions.
125 changes: 62 additions & 63 deletions proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,87 +344,86 @@ unsigned int get_skb_len(struct sk_buff *skb)
return skb->len;
}

/* Top Halve.
* Work scheduled earlier is done now, here.
*/
static void netsfs_top(struct work_struct *work)

unsigned int netsfs_do(struct dentry *where, struct sk_buff *skb)
{
struct netsfs_skb_info *netsfsinfo;
struct dentry *network_dentry, *transport_dentry, *app_dentry;
struct sk_buff *copy, *temp_skb;
struct netsfs_dir_private *d_private;
unsigned int len;
struct sk_buff *skb, *temp_skb;
struct dentry *netsfs_root;
int ret = 0;

int ret;
struct netsfs_dir_private *root_private;
len = get_skb_len(skb);

netsfsinfo = container_of(work, struct netsfs_skb_info, my_work);
/* Update counters */
netsfs_inc_inode_size(where->d_inode, len);

if (where != get_root())
netsfs_create_files(where);

/* increment netsfs root counters in stats */
len = get_skb_len(netsfsinfo->skb);
netsfs_inc_inode_size(NULL, len);
//
/* Make a skb copy to pass to kfifo */
skb = skb_copy(netsfsinfo->skb, GFP_KERNEL);
if (skb == NULL)
goto free;
copy = skb_copy(skb, GFP_KERNEL);
if (copy == NULL)
return -ENOMEM;

netsfs_root = get_root();
spin_lock(&where->d_inode->i_lock);

spin_lock(&netsfs_root->d_inode->i_lock);
/* If kfifo is full, dequeue */
root_private = netsfs_root->d_inode->i_private;
if (cq_is_full(&root_private->queue_skbuff)) {
temp_skb = cq_get(&root_private->queue_skbuff);
d_private = where->d_inode->i_private;
if (cq_is_full(&d_private->queue_skbuff)) {
temp_skb = cq_get(&d_private->queue_skbuff);
kfree_skb(temp_skb);
}
/* Put skb in kfifo, this skb will be free in read function, or here
* in this same function when kfifo is full */
ret = cq_put(&d_private->queue_skbuff, copy);

/* Put skb in kfifo and only free when fifo is full */
ret = cq_put(&root_private->queue_skbuff, skb);
spin_unlock(&where->d_inode->i_lock);

spin_unlock(&netsfs_root->d_inode->i_lock);
if (ret == 0)
printk("[netsfs] Probably preempted and queue is full\n");

// /* Create L3 dir */
// netsfs_create_dir(get_ether_type(skb), NULL, &network_dentry);
//
// if (network_dentry) {
// /* Create L3 files */
// netsfs_create_files(network_dentry);
//
// netsfs_inc_inode_size(network_dentry->d_parent->d_inode, len);
// netsfs_inc_inode_size(network_dentry->d_inode, len);
//
// /* Put skbuff in kfifo and only free when fifo is full */
// d_private = network_dentry->d_inode->i_private;
// ret = cq_put(&d_private->queue_skbuff, skb);
//
// /* Create L4 dir */
// netsfs_create_dir(get_ip_protocol(skb), network_dentry, &transport_dentry);
// if (transport_dentry) {
// /* Create L4 files */
// netsfs_create_files(transport_dentry);
//
// netsfs_inc_inode_size(transport_dentry->d_inode, len);
//
//
//// /* TODO: Currently, L5 only for TCP. */
//// if (ip_hdr(skb->protocol) == IPPROTO_TCP) {
//// netsfs_create_dir(get_application_protocol(skb), transport_dentry, &app_dentry);
//// if (app_dentry) {
//// netsfs_create_files(app_dentry);
//// netsfs_inc_inode_size(app_dentry->d_inode, len);
//// }
//// }
// }

// kfree_skb(skb);

free:
return 0;
}


/* Top Halve.
* Work scheduled earlier is done now, here.
*/
static void netsfs_top(struct work_struct *work)
{
struct netsfs_skb_info *netsfsinfo;
struct dentry *network_dentry, *transport_dentry, *app_dentry;
struct dentry *netsfs_root;

netsfsinfo = container_of(work, struct netsfs_skb_info, my_work);

netsfs_root = get_root();
netsfs_do(netsfs_root, netsfsinfo->skb);

/* Create L3 dir */
netsfs_create_dir(get_ether_type(netsfsinfo->skb), netsfs_root, &network_dentry);


if (network_dentry) {
/* Create L3 files */
netsfs_do(network_dentry, netsfsinfo->skb);

/* Create L4 dir */
netsfs_create_dir(get_ip_protocol(netsfsinfo->skb), network_dentry, &transport_dentry);
if (transport_dentry) {
/* Create L4 files */
netsfs_do(transport_dentry, netsfsinfo->skb);

/* TODO: Currently, L5 only for TCP. */
if ((ip_hdr(netsfsinfo->skb)->protocol) == IPPROTO_TCP) {
netsfs_create_dir(get_application_protocol(netsfsinfo->skb), transport_dentry, &app_dentry);
if (app_dentry)
netsfs_do(app_dentry, netsfsinfo->skb);
}
}
}

kfree_skb(netsfsinfo->skb);
// kfree(netsfsinfo);
kfree( (void *) work);
}

Expand Down

0 comments on commit 138f492

Please sign in to comment.