mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 01:51:26 +00:00
bundle: add nw_src/dst hash method
Add only nw_src or nw_dst hash feature to bundle and multipath. Signed-off-by: wenxu <wenxu@ucloud.cn> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
parent
4d232c7509
commit
417cfdb60c
4
NEWS
4
NEWS
@ -10,7 +10,6 @@ Post-v2.7.0
|
||||
Log level can be changed in a usual OVS way using
|
||||
'ovs-appctl vlog' commands for 'dpdk' module. Lower bound
|
||||
still can be configured via extra arguments for DPDK EAL.
|
||||
- The "learn" action now supports a "limit" option (see ovs-ofctl(8)).
|
||||
- New support for multiple VLANs (802.1ad or "QinQ"), including a new
|
||||
"dot1q-tunnel" port VLAN mode.
|
||||
- OVN:
|
||||
@ -19,6 +18,9 @@ Post-v2.7.0
|
||||
* Allow ovn-controller SSL configuration to be obtained from vswitchd
|
||||
database.
|
||||
- Add the command 'ovs-appctl stp/show' (see ovs-vswitchd(8)).
|
||||
- OpenFlow:
|
||||
* Bundles now support hashing by just nw_src or nw_dst.
|
||||
* The "learn" action now supports a "limit" option (see ovs-ofctl(8)).
|
||||
|
||||
v2.7.0 - 21 Feb 2017
|
||||
---------------------
|
||||
|
@ -103,8 +103,13 @@ enum nx_hash_fields {
|
||||
* - NXM_OF_TCP_SRC / NXM_OF_TCP_DST
|
||||
* - NXM_OF_UDP_SRC / NXM_OF_UDP_DST
|
||||
*/
|
||||
NX_HASH_FIELDS_SYMMETRIC_L3L4_UDP
|
||||
NX_HASH_FIELDS_SYMMETRIC_L3L4_UDP,
|
||||
|
||||
/* Network source address (NXM_OF_IP_SRC) only. */
|
||||
NX_HASH_FIELDS_NW_SRC,
|
||||
|
||||
/* Network destination address (NXM_OF_IP_DST) only. */
|
||||
NX_HASH_FIELDS_NW_DST
|
||||
|
||||
};
|
||||
|
||||
|
@ -191,6 +191,10 @@ bundle_parse__(const char *s, char **save_ptr,
|
||||
bundle->fields = NX_HASH_FIELDS_SYMMETRIC_L3L4;
|
||||
} else if (!strcasecmp(fields, "symmetric_l3l4+udp")) {
|
||||
bundle->fields = NX_HASH_FIELDS_SYMMETRIC_L3L4_UDP;
|
||||
} else if (!strcasecmp(fields, "nw_src")) {
|
||||
bundle->fields = NX_HASH_FIELDS_NW_SRC;
|
||||
} else if (!strcasecmp(fields, "nw_dst")) {
|
||||
bundle->fields = NX_HASH_FIELDS_NW_DST;
|
||||
} else {
|
||||
return xasprintf("%s: unknown fields `%s'", s, fields);
|
||||
}
|
||||
|
40
lib/flow.c
40
lib/flow.c
@ -2002,6 +2002,22 @@ flow_mask_hash_fields(const struct flow *flow, struct flow_wildcards *wc,
|
||||
}
|
||||
break;
|
||||
|
||||
case NX_HASH_FIELDS_NW_SRC:
|
||||
if (flow->dl_type == htons(ETH_TYPE_IP)) {
|
||||
memset(&wc->masks.nw_src, 0xff, sizeof wc->masks.nw_src);
|
||||
} else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
|
||||
memset(&wc->masks.ipv6_src, 0xff, sizeof wc->masks.ipv6_src);
|
||||
}
|
||||
break;
|
||||
|
||||
case NX_HASH_FIELDS_NW_DST:
|
||||
if (flow->dl_type == htons(ETH_TYPE_IP)) {
|
||||
memset(&wc->masks.nw_dst, 0xff, sizeof wc->masks.nw_dst);
|
||||
} else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
|
||||
memset(&wc->masks.ipv6_dst, 0xff, sizeof wc->masks.ipv6_dst);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
OVS_NOT_REACHED();
|
||||
}
|
||||
@ -2026,6 +2042,24 @@ flow_hash_fields(const struct flow *flow, enum nx_hash_fields fields,
|
||||
case NX_HASH_FIELDS_SYMMETRIC_L3L4_UDP:
|
||||
return flow_hash_symmetric_l3l4(flow, basis, true);
|
||||
|
||||
case NX_HASH_FIELDS_NW_SRC:
|
||||
if (flow->dl_type == htons(ETH_TYPE_IP)) {
|
||||
return jhash_bytes(&flow->nw_src, sizeof flow->nw_src, basis);
|
||||
} else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
|
||||
return jhash_bytes(&flow->ipv6_src, sizeof flow->ipv6_src, basis);
|
||||
} else {
|
||||
return basis;
|
||||
}
|
||||
|
||||
case NX_HASH_FIELDS_NW_DST:
|
||||
if (flow->dl_type == htons(ETH_TYPE_IP)) {
|
||||
return jhash_bytes(&flow->nw_dst, sizeof flow->nw_dst, basis);
|
||||
} else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
|
||||
return jhash_bytes(&flow->ipv6_dst, sizeof flow->ipv6_dst, basis);
|
||||
} else {
|
||||
return basis;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
OVS_NOT_REACHED();
|
||||
@ -2040,6 +2074,8 @@ flow_hash_fields_to_str(enum nx_hash_fields fields)
|
||||
case NX_HASH_FIELDS_SYMMETRIC_L4: return "symmetric_l4";
|
||||
case NX_HASH_FIELDS_SYMMETRIC_L3L4: return "symmetric_l3l4";
|
||||
case NX_HASH_FIELDS_SYMMETRIC_L3L4_UDP: return "symmetric_l3l4+udp";
|
||||
case NX_HASH_FIELDS_NW_SRC: return "nw_src";
|
||||
case NX_HASH_FIELDS_NW_DST: return "nw_dst";
|
||||
default: return "<unknown>";
|
||||
}
|
||||
}
|
||||
@ -2051,7 +2087,9 @@ flow_hash_fields_valid(enum nx_hash_fields fields)
|
||||
return fields == NX_HASH_FIELDS_ETH_SRC
|
||||
|| fields == NX_HASH_FIELDS_SYMMETRIC_L4
|
||||
|| fields == NX_HASH_FIELDS_SYMMETRIC_L3L4
|
||||
|| fields == NX_HASH_FIELDS_SYMMETRIC_L3L4_UDP;
|
||||
|| fields == NX_HASH_FIELDS_SYMMETRIC_L3L4_UDP
|
||||
|| fields == NX_HASH_FIELDS_NW_SRC
|
||||
|| fields == NX_HASH_FIELDS_NW_DST;
|
||||
}
|
||||
|
||||
/* Returns a hash value for the bits of 'flow' that are active based on
|
||||
|
@ -168,6 +168,10 @@ multipath_parse__(struct ofpact_multipath *mp, const char *s_, char *s)
|
||||
mp->fields = NX_HASH_FIELDS_SYMMETRIC_L3L4;
|
||||
} else if (!strcasecmp(fields, "symmetric_l3l4+udp")) {
|
||||
mp->fields = NX_HASH_FIELDS_SYMMETRIC_L3L4_UDP;
|
||||
} else if (!strcasecmp(fields, "nw_src")) {
|
||||
mp->fields = NX_HASH_FIELDS_NW_SRC;
|
||||
} else if (!strcasecmp(fields, "nw_dst")) {
|
||||
mp->fields = NX_HASH_FIELDS_NW_DST;
|
||||
} else {
|
||||
return xasprintf("%s: unknown fields `%s'", s_, fields);
|
||||
}
|
||||
|
@ -1384,6 +1384,10 @@ and IPv6, which hash to a constant zero.
|
||||
Like \fBsymmetric_l3l4+udp\fR, but UDP ports are included in the hash.
|
||||
This is a more effective hash when asymmetric UDP protocols such as
|
||||
VXLAN are not a consideration.
|
||||
.IP \fBnw_src\fR
|
||||
Hashes Network source address only.
|
||||
.IP \fBnw_dst\fR
|
||||
Hashes Network destination address only.
|
||||
.RE
|
||||
.IP
|
||||
\fIalgorithm\fR must be one of \fBmodulo_n\fR,
|
||||
@ -1399,8 +1403,8 @@ slaves represented as \fIslave_type\fR. Currently the only supported
|
||||
\fIslave_type\fR is \fBofport\fR. Thus, each \fIs1\fR through \fIsN\fR should
|
||||
be an OpenFlow port number. Outputs to the selected slave.
|
||||
.IP
|
||||
Currently, \fIfields\fR must be either \fBeth_src\fR, \fBsymmetric_l4\fR, \fBsymmetric_l3l4\fR, or \fBsymmetric_l3l4+udp\fR,
|
||||
and \fIalgorithm\fR must be one of \fBhrw\fR and \fBactive_backup\fR.
|
||||
Currently, \fIfields\fR must be either \fBeth_src\fR, \fBsymmetric_l4\fR, \fBsymmetric_l3l4\fR, \fBsymmetric_l3l4+udp\fR,
|
||||
\fBnw_src\fR, or \fBnw_dst\fR, and \fIalgorithm\fR must be one of \fBhrw\fR and \fBactive_backup\fR.
|
||||
.IP
|
||||
Example: \fBbundle(eth_src,0,hrw,ofport,slaves:4,8)\fR uses an Ethernet source
|
||||
hash with basis 0, to select between OpenFlow ports 4 and 8 using the Highest
|
||||
|
Loading…
x
Reference in New Issue
Block a user