lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon,  2 Mar 2015 18:40:16 +0100
From:	Florian Westphal <fw@...len.de>
To:	<netdev@...r.kernel.org>
Cc:	Florian Westphal <fw@...len.de>
Subject: [PATCH RFC 02/14] net: sched: reduce qdisc size to 24 byte

Its fine as-is, BUT infiniband cb includes qdisc_skb_cb
as first member so it can preserve its cb even if skb is
enqueued in a packet scheduler.

And I haven't found a way to change infiniband so that
it doesn't have to do that yet.
The infiniband cb is currently exactly 48 bytes, reducing
qdisc_cb also reduces ipoib_cb struct to 44 bytes as a result.

Reducing qdisc_cb means we can no longer use flow_keys struct
in sfq, but thats easy to work around, we don't need all its fields.

Signed-off-by: Florian Westphal <fw@...len.de>
---
 include/net/sch_generic.h |  2 +-
 net/sched/sch_sfq.c       | 29 ++++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index c605d30..baf7e96 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -252,7 +252,7 @@ struct qdisc_skb_cb {
 	unsigned int		pkt_len;
 	u16			slave_dev_queue_mapping;
 	u16			_pad;
-#define QDISC_CB_PRIV_LEN 20
+#define QDISC_CB_PRIV_LEN 16
 	unsigned char		data[QDISC_CB_PRIV_LEN];
 };
 
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index b877140..06485e8 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -158,10 +158,18 @@ static inline struct sfq_head *sfq_dep_head(struct sfq_sched_data *q, sfq_index
 
 /*
  * In order to be able to quickly rehash our queue when timer changes
- * q->perturbation, we store flow_keys in skb->cb[]
+ * q->perturbation, we store a few flow keys in skb->cb[]
+ *
+ * We're not using flow_key directly due to cb[] size limitation.
  */
+struct sfq_flow_keys {
+	__be32 src;
+	__be32 dst;
+	__be32 ports;
+};
+
 struct sfq_skb_cb {
-       struct flow_keys        keys;
+	struct sfq_flow_keys keys;
 };
 
 static inline struct sfq_skb_cb *sfq_skb_cb(const struct sk_buff *skb)
@@ -173,15 +181,26 @@ static inline struct sfq_skb_cb *sfq_skb_cb(const struct sk_buff *skb)
 static unsigned int sfq_hash(const struct sfq_sched_data *q,
 			     const struct sk_buff *skb)
 {
-	const struct flow_keys *keys = &sfq_skb_cb(skb)->keys;
+	const struct sfq_flow_keys *keys = &sfq_skb_cb(skb)->keys;
 	unsigned int hash;
 
 	hash = jhash_3words((__force u32)keys->dst,
-			    (__force u32)keys->src ^ keys->ip_proto,
+			    (__force u32)keys->src,
 			    (__force u32)keys->ports, q->perturbation);
 	return hash & (q->divisor - 1);
 }
 
+static void sfq_flow_dissect(const struct sk_buff *skb, struct sfq_flow_keys *flow)
+{
+	struct flow_keys flowk;
+
+	if (skb_flow_dissect(skb, &flowk)) {
+		flow->src = flowk.src ^ flowk.ip_proto,
+		flow->dst = flowk.dst;
+		flow->ports = flowk.ports;
+	}
+}
+
 static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch,
 				 int *qerr)
 {
@@ -197,7 +216,7 @@ static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch,
 
 	fl = rcu_dereference_bh(q->filter_list);
 	if (!fl) {
-		skb_flow_dissect(skb, &sfq_skb_cb(skb)->keys);
+		sfq_flow_dissect(skb, &sfq_skb_cb(skb)->keys);
 		return sfq_hash(q, skb) + 1;
 	}
 
-- 
2.0.5

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ