Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: cgroup: Guard users of sock_cgroup_classid()

Exclude code that relies on sock_cgroup_classid() as preparation of
removal of the function.

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Michal Koutný and committed by
Pablo Neira Ayuso
08764531 3ba0032a

+10 -1
+1 -1
net/ipv4/inet_diag.c
··· 160 160 ext & (1 << (INET_DIAG_TCLASS - 1))) { 161 161 u32 classid = 0; 162 162 163 - #ifdef CONFIG_SOCK_CGROUP_DATA 163 + #ifdef CONFIG_CGROUP_NET_CLASSID 164 164 classid = sock_cgroup_classid(&sk->sk_cgrp_data); 165 165 #endif 166 166 /* Fallback to socket priority if class id isn't set.
+9
net/netfilter/xt_cgroup.c
··· 117 117 static bool 118 118 cgroup_mt_v0(const struct sk_buff *skb, struct xt_action_param *par) 119 119 { 120 + #ifdef CONFIG_CGROUP_NET_CLASSID 120 121 const struct xt_cgroup_info_v0 *info = par->matchinfo; 121 122 struct sock *sk = skb->sk; 122 123 ··· 126 125 127 126 return (info->id == sock_cgroup_classid(&skb->sk->sk_cgrp_data)) ^ 128 127 info->invert; 128 + #endif 129 + return false; 129 130 } 130 131 131 132 static bool cgroup_mt_v1(const struct sk_buff *skb, struct xt_action_param *par) ··· 143 140 if (ancestor) 144 141 return cgroup_is_descendant(sock_cgroup_ptr(skcd), ancestor) ^ 145 142 info->invert_path; 143 + #ifdef CONFIG_CGROUP_NET_CLASSID 146 144 else 147 145 return (info->classid == sock_cgroup_classid(skcd)) ^ 148 146 info->invert_classid; 147 + #endif 148 + return false; 149 149 } 150 150 151 151 static bool cgroup_mt_v2(const struct sk_buff *skb, struct xt_action_param *par) ··· 164 158 if (ancestor) 165 159 return cgroup_is_descendant(sock_cgroup_ptr(skcd), ancestor) ^ 166 160 info->invert_path; 161 + #ifdef CONFIG_CGROUP_NET_CLASSID 167 162 else 168 163 return (info->classid == sock_cgroup_classid(skcd)) ^ 169 164 info->invert_classid; 165 + #endif 166 + return false; 170 167 } 171 168 172 169 static void cgroup_mt_destroy_v1(const struct xt_mtdtor_param *par)