From: Norbert Manthey <nmanthey@amazon.de>
To: unlisted-recipients:; (no To-header on input)
Cc: Norbert Manthey <nmanthey@amazon.de>,
"David S. Miller" <davem@davemloft.net>,
Simon Horman <simon.horman@netronome.com>,
Andrew Lunn <andrew@lunn.ch>,
Jakub Kicinski <jakub.kicinski@netronome.com>,
Tom Herbert <tom@quantonium.net>, John Crispin <john@phrozen.org>,
Eric Dumazet <edumazet@google.com>,
Sven Eckelmann <sven.eckelmann@openmesh.com>,
"WANG Cong" <xiyou.wangcong@gmail.com>,
David Ahern <dsahern@gmail.com>,
Jon Maloy <jon.maloy@ericsson.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [less-CONFIG_NET 2/7] net: reorder flow_dissector
Date: Wed, 6 Jun 2018 15:53:21 +0200 [thread overview]
Message-ID: <1528293206-24298-2-git-send-email-nmanthey@amazon.de> (raw)
In-Reply-To: <1528293206-24298-1-git-send-email-nmanthey@amazon.de>
This commit reorders the definitions, such that in the next step we
can easily cut the file into a commonly used part, as well as a part
that is only required in case CONFIG_NET is used.
This is part of the effort to split CONFIG_SECCOMP_FILTER and
CONFIG_NET.
Signed-off-by: Norbert Manthey <nmanthey@amazon.de>
---
net/core/flow_dissector.c | 206 +++++++++++++++++++++++-----------------------
1 file changed, 103 insertions(+), 103 deletions(-)
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index d29f09b..70e0679 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -1085,36 +1085,6 @@ static inline size_t flow_keys_hash_length(const struct flow_keys *flow)
return (sizeof(*flow) - diff) / sizeof(u32);
}
-__be32 flow_get_u32_src(const struct flow_keys *flow)
-{
- switch (flow->control.addr_type) {
- case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
- return flow->addrs.v4addrs.src;
- case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
- return (__force __be32)ipv6_addr_hash(
- &flow->addrs.v6addrs.src);
- case FLOW_DISSECTOR_KEY_TIPC:
- return flow->addrs.tipckey.key;
- default:
- return 0;
- }
-}
-EXPORT_SYMBOL(flow_get_u32_src);
-
-__be32 flow_get_u32_dst(const struct flow_keys *flow)
-{
- switch (flow->control.addr_type) {
- case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
- return flow->addrs.v4addrs.dst;
- case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
- return (__force __be32)ipv6_addr_hash(
- &flow->addrs.v6addrs.dst);
- default:
- return 0;
- }
-}
-EXPORT_SYMBOL(flow_get_u32_dst);
-
static inline void __flow_hash_consistentify(struct flow_keys *keys)
{
int addr_diff, i;
@@ -1162,49 +1132,6 @@ static inline u32 __flow_hash_from_keys(struct flow_keys *keys, u32 keyval)
return hash;
}
-u32 flow_hash_from_keys(struct flow_keys *keys)
-{
- __flow_hash_secret_init();
- return __flow_hash_from_keys(keys, hashrnd);
-}
-EXPORT_SYMBOL(flow_hash_from_keys);
-
-static inline u32 ___skb_get_hash(const struct sk_buff *skb,
- struct flow_keys *keys, u32 keyval)
-{
- skb_flow_dissect_flow_keys(skb, keys,
- FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL);
-
- return __flow_hash_from_keys(keys, keyval);
-}
-
-struct _flow_keys_digest_data {
- __be16 n_proto;
- u8 ip_proto;
- u8 padding;
- __be32 ports;
- __be32 src;
- __be32 dst;
-};
-
-void make_flow_keys_digest(struct flow_keys_digest *digest,
- const struct flow_keys *flow)
-{
- struct _flow_keys_digest_data *data =
- (struct _flow_keys_digest_data *)digest;
-
- BUILD_BUG_ON(sizeof(*data) > sizeof(*digest));
-
- memset(digest, 0, sizeof(*digest));
-
- data->n_proto = flow->basic.n_proto;
- data->ip_proto = flow->basic.ip_proto;
- data->ports = flow->ports.ports;
- data->src = flow->addrs.v4addrs.src;
- data->dst = flow->addrs.v4addrs.dst;
-}
-EXPORT_SYMBOL(make_flow_keys_digest);
-
static struct flow_dissector flow_keys_dissector_symmetric __read_mostly;
u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
@@ -1222,36 +1149,6 @@ u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
}
EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);
-/**
- * __skb_get_hash: calculate a flow hash
- * @skb: sk_buff to calculate flow hash from
- *
- * This function calculates a flow hash based on src/dst addresses
- * and src/dst port numbers. Sets hash in skb to non-zero hash value
- * on success, zero indicates no valid hash. Also, sets l4_hash in skb
- * if hash is a canonical 4-tuple hash over transport ports.
- */
-void __skb_get_hash(struct sk_buff *skb)
-{
- struct flow_keys keys;
- u32 hash;
-
- __flow_hash_secret_init();
-
- hash = ___skb_get_hash(skb, &keys, hashrnd);
-
- __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys));
-}
-EXPORT_SYMBOL(__skb_get_hash);
-
-__u32 skb_get_hash_perturb(const struct sk_buff *skb, u32 perturb)
-{
- struct flow_keys keys;
-
- return ___skb_get_hash(skb, &keys, perturb);
-}
-EXPORT_SYMBOL(skb_get_hash_perturb);
-
u32 __skb_get_poff(const struct sk_buff *skb, void *data,
const struct flow_keys *keys, int hlen)
{
@@ -1322,6 +1219,109 @@ u32 skb_get_poff(const struct sk_buff *skb)
return __skb_get_poff(skb, skb->data, &keys, skb_headlen(skb));
}
+__be32 flow_get_u32_src(const struct flow_keys *flow)
+{
+ switch (flow->control.addr_type) {
+ case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
+ return flow->addrs.v4addrs.src;
+ case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
+ return (__force __be32)ipv6_addr_hash(
+ &flow->addrs.v6addrs.src);
+ case FLOW_DISSECTOR_KEY_TIPC:
+ return flow->addrs.tipckey.key;
+ default:
+ return 0;
+ }
+}
+EXPORT_SYMBOL(flow_get_u32_src);
+
+__be32 flow_get_u32_dst(const struct flow_keys *flow)
+{
+ switch (flow->control.addr_type) {
+ case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
+ return flow->addrs.v4addrs.dst;
+ case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
+ return (__force __be32)ipv6_addr_hash(
+ &flow->addrs.v6addrs.dst);
+ default:
+ return 0;
+ }
+}
+EXPORT_SYMBOL(flow_get_u32_dst);
+
+u32 flow_hash_from_keys(struct flow_keys *keys)
+{
+ __flow_hash_secret_init();
+ return __flow_hash_from_keys(keys, hashrnd);
+}
+EXPORT_SYMBOL(flow_hash_from_keys);
+
+static inline u32 ___skb_get_hash(const struct sk_buff *skb,
+ struct flow_keys *keys, u32 keyval)
+{
+ skb_flow_dissect_flow_keys(skb, keys,
+ FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL);
+
+ return __flow_hash_from_keys(keys, keyval);
+}
+
+struct _flow_keys_digest_data {
+ __be16 n_proto;
+ u8 ip_proto;
+ u8 padding;
+ __be32 ports;
+ __be32 src;
+ __be32 dst;
+};
+
+void make_flow_keys_digest(struct flow_keys_digest *digest,
+ const struct flow_keys *flow)
+{
+ struct _flow_keys_digest_data *data =
+ (struct _flow_keys_digest_data *)digest;
+
+ BUILD_BUG_ON(sizeof(*data) > sizeof(*digest));
+
+ memset(digest, 0, sizeof(*digest));
+
+ data->n_proto = flow->basic.n_proto;
+ data->ip_proto = flow->basic.ip_proto;
+ data->ports = flow->ports.ports;
+ data->src = flow->addrs.v4addrs.src;
+ data->dst = flow->addrs.v4addrs.dst;
+}
+EXPORT_SYMBOL(make_flow_keys_digest);
+
+/**
+ * __skb_get_hash: calculate a flow hash
+ * @skb: sk_buff to calculate flow hash from
+ *
+ * This function calculates a flow hash based on src/dst addresses
+ * and src/dst port numbers. Sets hash in skb to non-zero hash value
+ * on success, zero indicates no valid hash. Also, sets l4_hash in skb
+ * if hash is a canonical 4-tuple hash over transport ports.
+ */
+void __skb_get_hash(struct sk_buff *skb)
+{
+ struct flow_keys keys;
+ u32 hash;
+
+ __flow_hash_secret_init();
+
+ hash = ___skb_get_hash(skb, &keys, hashrnd);
+
+ __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys));
+}
+EXPORT_SYMBOL(__skb_get_hash);
+
+__u32 skb_get_hash_perturb(const struct sk_buff *skb, u32 perturb)
+{
+ struct flow_keys keys;
+
+ return ___skb_get_hash(skb, &keys, perturb);
+}
+EXPORT_SYMBOL(skb_get_hash_perturb);
+
__u32 __get_hash_from_flowi6(const struct flowi6 *fl6, struct flow_keys *keys)
{
memset(keys, 0, sizeof(*keys));
--
2.7.4
Amazon Development Center Germany GmbH
Berlin - Dresden - Aachen
main office: Krausenstr. 38, 10117 Berlin
Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger
Ust-ID: DE289237879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B
next prev parent reply other threads:[~2018-06-06 13:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 13:52 Make CONFIG_NET and CONFIG_SECCOMP_FILTER independent of CONFIG_NET Norbert Manthey
2018-06-06 13:53 ` [less-CONFIG_NET 1/7] net: reorder filter code Norbert Manthey
2018-06-06 13:53 ` Norbert Manthey [this message]
2018-06-06 13:53 ` [less-CONFIG_NET 3/7] seccomp: include net and bpf files Norbert Manthey
2018-06-06 13:53 ` [less-CONFIG_NET 5/7] seccomp: cut off functions not required Norbert Manthey
2018-06-06 16:33 ` [less-CONFIG_NET 1/7] net: reorder filter code Willem de Bruijn
2018-06-06 18:19 ` Norbert Manthey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1528293206-24298-2-git-send-email-nmanthey@amazon.de \
--to=nmanthey@amazon.de \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=edumazet@google.com \
--cc=jakub.kicinski@netronome.com \
--cc=john@phrozen.org \
--cc=jon.maloy@ericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=simon.horman@netronome.com \
--cc=sven.eckelmann@openmesh.com \
--cc=tom@quantonium.net \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).