+/* Calculates the 5-tuple hash from the given flow. */
+uint32_t
+miniflow_hash_5tuple(const struct miniflow *flow, uint32_t basis)
+{
+ uint32_t hash = 0;
+
+ if (!flow) {
+ return 0;
+ }
+
+ hash = mhash_add(basis,
+ miniflow_get_u32(flow, offsetof(struct flow, nw_src)));
+ hash = mhash_add(hash,
+ miniflow_get_u32(flow, offsetof(struct flow, nw_dst)));
+ hash = mhash_add(hash,
+ miniflow_get_u32(flow, offsetof(struct flow, tp_src)));
+ hash = mhash_add(hash,
+ miniflow_get_u8(flow, offsetof(struct flow, nw_proto)));
+
+ return mhash_finish(hash, 13);
+}
+
+BUILD_ASSERT_DECL(offsetof(struct flow, tp_src) + 2
+ == offsetof(struct flow, tp_dst) &&
+ offsetof(struct flow, tp_src) / 4
+ == offsetof(struct flow, tp_dst) / 4);
+