On Thu, Jul 28, 2016 at 05:56:08PM -0700, Jarno Rajahalme wrote: > Change mf_are_prereqs_ok() take a flow_wildcards pointer, so that the > wildcards can be set at the same time as the prerequisiteis are > checked. This makes it easier to write more obviously correct code. > > Remove the functions mf_mask_field_and_prereqs() and > mf_mask_field_and_prereqs__(), and make the callers first check the > prerequisites, while supplying 'wc' to mf_are_prereqs_ok(), and if > successful, mask the bits of the field that were read or set using > mf_mask_field_masked(). > > Signed-off-by: Jarno Rajahalme <ja...@ovn.org>
Some of these new functions are very similar! How about: diff --git a/lib/flow.h b/lib/flow.h index e3f88b2..6a2a5bf 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -868,40 +868,35 @@ static inline bool is_ip_any(const struct flow *flow) return dl_type_is_ip_any(flow->dl_type); } -static inline bool is_tcp(const struct flow *flow, - struct flow_wildcards *wc) +static inline bool is_ip_proto(const struct flow *flow, uint8_t ip_proto, + struct flow_wildcards *wc) { if (is_ip_any(flow)) { if (wc) { WC_MASK_FIELD(wc, nw_proto); } - return flow->nw_proto == IPPROTO_TCP; + return flow->nw_proto == ip_proto; } return false; } +static inline bool is_tcp(const struct flow *flow, + struct flow_wildcards *wc) +{ + return is_ip_proto(flow, IPPROTO_TCP, wc); +} + static inline bool is_udp(const struct flow *flow, struct flow_wildcards *wc) { - if (is_ip_any(flow)) { - if (wc) { - WC_MASK_FIELD(wc, nw_proto); - } - return flow->nw_proto == IPPROTO_UDP; - } - return false; + return is_ip_proto(flow, IPPROTO_UDP, wc); + } static inline bool is_sctp(const struct flow *flow, struct flow_wildcards *wc) { - if (is_ip_any(flow)) { - if (wc) { - WC_MASK_FIELD(wc, nw_proto); - } - return flow->nw_proto == IPPROTO_SCTP; - } - return false; + return is_ip_proto(flow, IPPROTO_SCTP, wc); } static inline bool is_icmpv4(const struct flow *flow, I don't know what the comment about nw_frag means here, do you? /* A flow may wildcard nw_frag. Do nothing if the packet does not have * the fields. */ or even the older one: /* A flow may wildcard nw_frag. Do nothing if setting a transport * header field on a packet that does not have them. */ Acked-by: Ben Pfaff <b...@ovn.org> _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev