+/* Given a flow, checks that the source field represented by 'src_header'
+ * in the range ['ofs', 'ofs' + 'n_bits') is valid. */
+int
+nxm_src_check(ovs_be32 src_header, unsigned int ofs, unsigned int n_bits,
+ const struct flow *flow)
+{
+ const struct nxm_field *src = nxm_field_lookup(ntohl(src_header));
+
+ if (!n_bits) {
+ VLOG_WARN_RL(&rl, "zero bit source field");
+ } else if (!field_ok(src, flow, ofs + n_bits)) {
+ VLOG_WARN_RL(&rl, "invalid source field");
+ } else {
+ return 0;