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);
+ }
+}
+