@@ -17,6 +17,7 @@
#include <linux/hardirq.h>
#include <linux/rcupdate.h>
+#if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
struct netprio_map {
struct rcu_head rcu;
@@ -24,19 +25,26 @@ struct netprio_map {
u32 priomap[];
};
-#ifdef CONFIG_CGROUPS
-
struct cgroup_netprio_state {
struct cgroup_subsys_state css;
u32 prioidx;
};
-#ifndef CONFIG_NETPRIO_CGROUP
-extern int net_prio_subsys_id;
-#endif
-
extern void sock_update_netprioidx(struct sock *sk, struct task_struct *task);
+#else
+
+static inline void sock_update_netprioidx(struct sock *sk, struct task_struct *task)
+{
+}
+
+static inline u32 task_netprioidx(struct task_struct *p)
+{
+ return 0;
+}
+
+#endif
+
#if IS_BUILTIN(CONFIG_NETPRIO_CGROUP)
static inline u32 task_netprioidx(struct task_struct *p)
@@ -54,6 +62,8 @@ static inline u32 task_netprioidx(struct task_struct *p)
#elif IS_MODULE(CONFIG_NETPRIO_CGROUP)
+extern int net_prio_subsys_id;
+
static inline u32 task_netprioidx(struct task_struct *p)
{
struct cgroup_netprio_state *state;
@@ -72,17 +82,6 @@ static inline u32 task_netprioidx(struct task_struct *p)
return idx;
}
-#else
-
-static inline u32 task_netprioidx(struct task_struct *p)
-{
- return 0;
-}
-
#endif /* CONFIG_NETPRIO_CGROUP */
-#else
-#define sock_update_netprioidx(sk, task)
-#endif
-
#endif /* _NET_CLS_CGROUP_H */
@@ -342,7 +342,7 @@ struct cgroup_subsys net_prio_subsys = {
.create = cgrp_create,
.destroy = cgrp_destroy,
.attach = net_prio_attach,
-#ifdef CONFIG_NETPRIO_CGROUP
+#if IS_BUILTIN(CONFIG_NETPRIO_CGROUP)
.subsys_id = net_prio_subsys_id,
#endif
.base_cftypes = ss_files,
@@ -382,7 +382,7 @@ static int __init init_cgroup_netprio(void)
ret = cgroup_load_subsys(&net_prio_subsys);
if (ret)
goto out;
-#ifndef CONFIG_NETPRIO_CGROUP
+#if IS_MODULE(CONFIG_NETPRIO_CGROUP)
smp_wmb();
net_prio_subsys_id = net_prio_subsys.subsys_id;
#endif
@@ -402,7 +402,7 @@ static void __exit exit_cgroup_netprio(void)
cgroup_unload_subsys(&net_prio_subsys);
-#ifndef CONFIG_NETPRIO_CGROUP
+#if IS_MODULE(CONFIG_NETPRIO_CGROUP)
net_prio_subsys_id = -1;
synchronize_rcu();
#endif
@@ -331,7 +331,7 @@ EXPORT_SYMBOL(__sk_backlog_rcv);
int net_cls_subsys_id = -1;
EXPORT_SYMBOL_GPL(net_cls_subsys_id);
#endif
-#if !defined(CONFIG_NETPRIO_CGROUP)
+#if IS_MODULE(CONFIG_NETPRIO_CGROUP)
int net_prio_subsys_id = -1;
EXPORT_SYMBOL_GPL(net_prio_subsys_id);
#endif
@@ -1238,6 +1238,7 @@ void sock_update_classid(struct sock *sk, struct task_struct *task)
EXPORT_SYMBOL(sock_update_classid);
#endif
+#if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
void sock_update_netprioidx(struct sock *sk, struct task_struct *task)
{
if (in_interrupt())
@@ -1247,6 +1248,7 @@ void sock_update_netprioidx(struct sock *sk, struct task_struct *task)
}
EXPORT_SYMBOL_GPL(sock_update_netprioidx);
#endif
+#endif
/**
* sk_alloc - All socket objects are allocated here