aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/netprio_cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/netprio_cgroup.c')
-rw-r--r--net/core/netprio_cgroup.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index c75e3f9d060f..5ffd084c6a83 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -272,38 +272,24 @@ out_free_devname:
272 return ret; 272 return ret;
273} 273}
274 274
275static int update_netprio(const void *v, struct file *file, unsigned n)
276{
277 int err;
278 struct socket *sock = sock_from_file(file, &err);
279 if (sock)
280 sock->sk->sk_cgrp_prioidx = (u32)(unsigned long)v;
281 return 0;
282}
283
275void net_prio_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) 284void net_prio_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
276{ 285{
277 struct task_struct *p; 286 struct task_struct *p;
287 void *v;
278 288
279 cgroup_taskset_for_each(p, cgrp, tset) { 289 cgroup_taskset_for_each(p, cgrp, tset) {
280 unsigned int fd;
281 struct fdtable *fdt;
282 struct files_struct *files;
283
284 task_lock(p); 290 task_lock(p);
285 files = p->files; 291 v = (void *)(unsigned long)task_netprioidx(p);
286 if (!files) { 292 iterate_fd(p->files, 0, update_netprio, v);
287 task_unlock(p);
288 continue;
289 }
290
291 spin_lock(&files->file_lock);
292 fdt = files_fdtable(files);
293 for (fd = 0; fd < fdt->max_fds; fd++) {
294 struct file *file;
295 struct socket *sock;
296 int err;
297
298 file = fcheck_files(files, fd);
299 if (!file)
300 continue;
301
302 sock = sock_from_file(file, &err);
303 if (sock)
304 sock_update_netprioidx(sock->sk, p);
305 }
306 spin_unlock(&files->file_lock);
307 task_unlock(p); 293 task_unlock(p);
308 } 294 }
309} 295}