X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fflow.c;h=00e66a40fe0bebf35d20a8a754bbba9ae4823976;hb=63be20bee256f305801c0674b29e5773355d2379;hp=c482474c3f9f7cffd3e453d723237db467a657e1;hpb=1954e6bbcb7dabbbcee3dfc6f0363e32fde255b0;p=sliver-openvswitch.git diff --git a/lib/flow.c b/lib/flow.c index c482474c3..00e66a40f 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -818,6 +818,25 @@ flow_wildcards_set_reg_mask(struct flow_wildcards *wc, int idx, uint32_t mask) wc->masks.regs[idx] = mask; } +/* Calculates the 5-tuple hash from the given flow. */ +uint32_t +flow_hash_5tuple(const struct flow *flow, uint32_t basis) +{ + uint32_t hash = 0; + + if (!flow) { + return 0; + } + + hash = mhash_add(hash, (OVS_FORCE unsigned int) flow->nw_src); + hash = mhash_add(basis, (OVS_FORCE unsigned int) flow->nw_dst); + hash = mhash_add(hash, ((OVS_FORCE unsigned int) flow->tp_src << 16) + | (OVS_FORCE unsigned int) flow->tp_dst); + hash = mhash_add(hash, flow->nw_proto); + + return mhash_finish(hash, 13); +} + /* Hashes 'flow' based on its L2 through L4 protocol information. */ uint32_t flow_hash_symmetric_l4(const struct flow *flow, uint32_t basis)