aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/flow_dissector.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/flow_dissector.c')
-rw-r--r--net/core/flow_dissector.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index f0516d9280c3..0985b9b14b80 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -8,6 +8,16 @@
#include <linux/ppp_defs.h>
#include <net/flow_keys.h>
+/* copy saddr & daddr, possibly using 64bit load/store
+ * Equivalent to : flow->src = iph->saddr;
+ * flow->dst = iph->daddr;
+ */
+static void iph_to_flow_copy_addrs(struct flow_keys *flow, const struct iphdr *iph)
+{
+ BUILD_BUG_ON(offsetof(typeof(*flow), dst) !=
+ offsetof(typeof(*flow), src) + sizeof(flow->src));
+ memcpy(&flow->src, &iph->saddr, sizeof(flow->src) + sizeof(flow->dst));
+}
bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow)
{
@@ -31,8 +41,7 @@ ip:
ip_proto = 0;
else
ip_proto = iph->protocol;
- flow->src = iph->saddr;
- flow->dst = iph->daddr;
+ iph_to_flow_copy_addrs(flow, iph);
nhoff += iph->ihl * 4;
break;
}