Thread (1 message) 1 message, 1 author, 2012-10-17

Re: [PATCH v0 4/4] cgroup: net_cls: Rework update socket logic

From: John Fastabend <hidden>
Date: 2012-10-17 14:02:01
Also in: cgroups

Possibly related (same subject, not in this thread)

On 10/17/2012 6:04 AM, Daniel Wagner wrote:
From: Daniel Wagner <redacted>

The cgroup logic part of net_cls is very similar as the one in
net_prio. Let's stream line the net_cls logic with the net_prio one.
[...]

+static void cgrp_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
+{
+	struct task_struct *p;
+
+	cgroup_taskset_for_each(p, cgrp, tset) {
+		unsigned int fd;
+		struct fdtable *fdt;
+		struct files_struct *files;
+
+		task_lock(p);
+		files = p->files;
+		if (!files) {
+			task_unlock(p);
+			continue;
+		}
+
+		spin_lock(&files->file_lock);
+		fdt = files_fdtable(files);
+		for (fd = 0; fd < fdt->max_fds; fd++) {
+			struct file *file;
+			struct socket *sock;
+			int err;
+
+			file = fcheck_files(files, fd);
+			if (!file)
+				continue;
+
+			sock = sock_from_file(file, &err);
+			if (sock)
+				sock_update_classid(sock->sk, p);
+		}
+		spin_unlock(&files->file_lock);
This block should probably use iterate_fd() instead of open coding
this. See the latest net_prio_attach().

.John
+		task_unlock(p);
+	}
+}
+
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help