summaryrefslogtreecommitdiff
path: root/eppic_scripts
diff options
context:
space:
mode:
authorAruna Balakrishnaiah <aruna@linux.vnet.ibm.com>2014-02-27 15:32:37 +0900
committerAtsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>2014-03-10 13:10:18 +0900
commit6790dff93cf22725c5c19d93a1e406b45223289e (patch)
tree3ace8c96f2165f2b252a4a5041e1422e1200fec4 /eppic_scripts
parent2fb6959c3106c3e162d8cb2df7f8395609fe8b94 (diff)
[PATCH 08/11] eppic: Scrub socket buffers of guest network I/O.
vhost_net instance will be attached to the file's private data. To get to the right file check the fdtable for each task, if the file has registered its fops with vhost_net_open, if so we can retreive the file's private data. if (task->files->fdt->fd[i]->f_op->open == &vhost_net_open) struct vhost_net *net = f->private_data; struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_MAX]; struct vhost_virtqueue *vq = &nvq->vq; struct socket *sock = vq->private_data; struct sock *sk = sock->sk; struct sk_buff *next = sk->sk_receive_queue.next; struct sk_buff *prev = sk->sk_receive_queue.prev; Scrub next->data till the end of the sk_receive_queue and sk_write_queue list Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
Diffstat (limited to 'eppic_scripts')
-rw-r--r--eppic_scripts/vhost_net_buffers.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/eppic_scripts/vhost_net_buffers.c b/eppic_scripts/vhost_net_buffers.c
new file mode 100644
index 0000000..6c2b8df
--- /dev/null
+++ b/eppic_scripts/vhost_net_buffers.c
@@ -0,0 +1,95 @@
+string
+vhost_opt()
+{
+ return "l";
+}
+
+string
+vhost_usage()
+{
+ return "\n";
+}
+
+static void
+vhost_showusage()
+{
+ printf("usage : net_ %s", vhost_usage());
+}
+
+string
+vhost_help()
+{
+ return "Help";
+}
+
+void
+vhost_net(struct vhost_net *net)
+{
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ struct vhost_net_virtqueue *nvq = &net->vqs[i];
+ struct vhost_virtqueue *vq = &nvq->vq;
+ struct socket *sock = (struct socket *)vq->private_data;
+ struct sock *sk = sock->sk;
+
+ struct sk_buff_head *head = &(sk->sk_receive_queue);
+ struct sk_buff *next = sk->sk_receive_queue.next;
+
+ while (next != head)
+ {
+ struct sk_buff *buff = (struct sk_buff *) next;
+
+ memset((unsigned char *)buff->data, 'L', buff->data_len);
+ memset((char *)&(buff->data_len), 'L', 0x4);
+
+ next = buff->next;
+ }
+
+ head = (struct sk_buff_head *)&(sk->sk_write_queue);
+ next = (struct sk_buff *)sk->sk_write_queue.next;
+
+ while (next != head)
+ {
+ struct sk_buff *buff = (struct sk_buff *) next;
+
+ memset((char *)buff->data, 'L', buff->data_len);
+ memset((char *)&(buff->data_len), 'L', 0x4);
+
+ next = buff->next;
+
+ }
+ }
+}
+
+int
+vhost()
+{
+ struct list_head *head, *next;
+ struct task_struct *tsk;
+
+ tsk = &init_task;
+
+ head = (struct list_head *) &(tsk->tasks);
+ next = (struct list_head *) tsk->tasks.next;
+
+ while (next != head)
+ {
+ int i;
+ struct task_struct *task, *off = 0;
+
+ task = (struct task_struct *)((unsigned long)next - ((unsigned long)&(off->tasks)));
+
+ if (task->files && task->files->fdt) {
+ for (i = 0; i < task->files->fdt->max_fds; i++) {
+ if (task->files->fdt->fd[i] && task->files->fdt->fd[i]->f_op
+ && task->files->fdt->fd[i]->f_op->open == &vhost_net_open)
+ vhost_net((struct vhost_net *)task->files->fdt->fd[i]->private_data);
+ }
+ }
+
+ next = (struct list_head *)task->tasks.next;
+ }
+
+ return 1;
+}