Blob Blame History Raw
From: Jiri Pirko <jiri@mellanox.com>
Date: Fri, 13 Oct 2017 14:00:58 +0200
Subject: net: sched: store net pointer in block and introduce qdisc_net helper
Patch-mainline: v4.15-rc1
Git-commit: 855319becbcffec6988a4e781a861b69a71c5b58
References: bsc#1109837

Store net pointer in the block structure. Along the way, introduce
qdisc_net helper which allows to easily obtain net pointer for
qdisc instance.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 include/net/pkt_sched.h   |    7 +++++++
 include/net/sch_generic.h |    1 +
 net/sched/cls_api.c       |    1 +
 3 files changed, 9 insertions(+)

--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -4,7 +4,9 @@
 #include <linux/jiffies.h>
 #include <linux/ktime.h>
 #include <linux/if_vlan.h>
+#include <linux/netdevice.h>
 #include <net/sch_generic.h>
+#include <net/net_namespace.h>
 #include <uapi/linux/pkt_sched.h>
 
 #define DEFAULT_TX_QUEUE_LEN	1000
@@ -146,4 +148,9 @@ static inline bool is_classid_clsact_egr
 	       TC_H_MIN(classid) == TC_H_MIN(TC_H_MIN_EGRESS);
 }
 
+static inline struct net *qdisc_net(struct Qdisc *q)
+{
+	return dev_net(q->dev_queue->dev);
+}
+
 #endif
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -272,6 +272,7 @@ struct tcf_chain {
 struct tcf_block {
 	struct list_head chain_list;
 	struct work_struct work;
+	struct net *net;
 	struct Qdisc *q;
 };
 
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -266,6 +266,7 @@ int tcf_block_get(struct tcf_block **p_b
 		goto err_chain_create;
 	}
 	tcf_chain_filter_chain_ptr_set(chain, p_filter_chain);
+	block->net = qdisc_net(q);
 	block->q = q;
 	*p_block = block;
 	return 0;