提交 fd9a08a7 编写于 作者: D Daniel Wagner 提交者: David S. Miller

cgroup: net_cls: Pass in task to sock_update_classid()

sock_update_classid() assumes that the update operation always are
applied on the current task. sock_update_classid() needs to know on
which tasks to work on in order to be able to migrate task between
cgroups using the struct cgroup_subsys attach() callback.
Signed-off-by: NDaniel Wagner <daniel.wagner@bmw-carit.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Glauber Costa <glommer@parallels.com>
Cc: Joe Perches <joe@perches.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: <netdev@vger.kernel.org>
Cc: <cgroups@vger.kernel.org>
Acked-by: NNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 3ace03cc
...@@ -587,7 +587,7 @@ static struct sk_buff *tun_alloc_skb(struct tun_struct *tun, ...@@ -587,7 +587,7 @@ static struct sk_buff *tun_alloc_skb(struct tun_struct *tun,
struct sk_buff *skb; struct sk_buff *skb;
int err; int err;
sock_update_classid(sk); sock_update_classid(sk, current);
/* Under a page? Don't bother with paged skb. */ /* Under a page? Don't bother with paged skb. */
if (prepad + len < PAGE_SIZE || !linear) if (prepad + len < PAGE_SIZE || !linear)
......
...@@ -24,7 +24,7 @@ struct cgroup_cls_state ...@@ -24,7 +24,7 @@ struct cgroup_cls_state
u32 classid; u32 classid;
}; };
extern void sock_update_classid(struct sock *sk); extern void sock_update_classid(struct sock *sk, struct task_struct *task);
#if IS_BUILTIN(CONFIG_NET_CLS_CGROUP) #if IS_BUILTIN(CONFIG_NET_CLS_CGROUP)
static inline u32 task_cls_classid(struct task_struct *p) static inline u32 task_cls_classid(struct task_struct *p)
......
...@@ -1217,11 +1217,11 @@ static void sk_prot_free(struct proto *prot, struct sock *sk) ...@@ -1217,11 +1217,11 @@ static void sk_prot_free(struct proto *prot, struct sock *sk)
#ifdef CONFIG_CGROUPS #ifdef CONFIG_CGROUPS
#if IS_ENABLED(CONFIG_NET_CLS_CGROUP) #if IS_ENABLED(CONFIG_NET_CLS_CGROUP)
void sock_update_classid(struct sock *sk) void sock_update_classid(struct sock *sk, struct task_struct *task)
{ {
u32 classid; u32 classid;
classid = task_cls_classid(current); classid = task_cls_classid(task);
if (classid != sk->sk_classid) if (classid != sk->sk_classid)
sk->sk_classid = classid; sk->sk_classid = classid;
} }
...@@ -1264,7 +1264,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority, ...@@ -1264,7 +1264,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
sock_net_set(sk, get_net(net)); sock_net_set(sk, get_net(net));
atomic_set(&sk->sk_wmem_alloc, 1); atomic_set(&sk->sk_wmem_alloc, 1);
sock_update_classid(sk); sock_update_classid(sk, current);
sock_update_netprioidx(sk, current); sock_update_netprioidx(sk, current);
} }
......
...@@ -620,7 +620,7 @@ static inline int __sock_sendmsg_nosec(struct kiocb *iocb, struct socket *sock, ...@@ -620,7 +620,7 @@ static inline int __sock_sendmsg_nosec(struct kiocb *iocb, struct socket *sock,
{ {
struct sock_iocb *si = kiocb_to_siocb(iocb); struct sock_iocb *si = kiocb_to_siocb(iocb);
sock_update_classid(sock->sk); sock_update_classid(sock->sk, current);
si->sock = sock; si->sock = sock;
si->scm = NULL; si->scm = NULL;
...@@ -784,7 +784,7 @@ static inline int __sock_recvmsg_nosec(struct kiocb *iocb, struct socket *sock, ...@@ -784,7 +784,7 @@ static inline int __sock_recvmsg_nosec(struct kiocb *iocb, struct socket *sock,
{ {
struct sock_iocb *si = kiocb_to_siocb(iocb); struct sock_iocb *si = kiocb_to_siocb(iocb);
sock_update_classid(sock->sk); sock_update_classid(sock->sk, current);
si->sock = sock; si->sock = sock;
si->scm = NULL; si->scm = NULL;
...@@ -896,7 +896,7 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos, ...@@ -896,7 +896,7 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
if (unlikely(!sock->ops->splice_read)) if (unlikely(!sock->ops->splice_read))
return -EINVAL; return -EINVAL;
sock_update_classid(sock->sk); sock_update_classid(sock->sk, current);
return sock->ops->splice_read(sock, ppos, pipe, len, flags); return sock->ops->splice_read(sock, ppos, pipe, len, flags);
} }
...@@ -3437,7 +3437,7 @@ EXPORT_SYMBOL(kernel_setsockopt); ...@@ -3437,7 +3437,7 @@ EXPORT_SYMBOL(kernel_setsockopt);
int kernel_sendpage(struct socket *sock, struct page *page, int offset, int kernel_sendpage(struct socket *sock, struct page *page, int offset,
size_t size, int flags) size_t size, int flags)
{ {
sock_update_classid(sock->sk); sock_update_classid(sock->sk, current);
if (sock->ops->sendpage) if (sock->ops->sendpage)
return sock->ops->sendpage(sock, page, offset, size, flags); return sock->ops->sendpage(sock, page, offset, size, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册