lib/match.c
/* A match on 'field' is being added to or has been added to 'match'.  If
 * 'field' is a data field, and 'match' does not already match on packet_type,
 * this function make it match on the Ethernet packet_type.
 *
 * This function is useful because OpenFlow implicitly applies to Ethernet
 * packets when there's no explicit packet_type, but matching on a metadata
 * field doesn't imply anything about the packet_type and falsely inferring
 * that it does can cause harm.  A flow that matches only on metadata fields,
 * for example, should be able to match more than just Ethernet flows.  There
 * are also important reasons that a catch-all match (one with no field matches
 * at all) should not imply a packet_type(0,0) match.  For example, a "flow
 * dump" request that matches on no fields should return every flow in the
 * switch, not just the flows that match on Ethernet.  As a second example,
 * OpenFlow 1.2+ special-cases "table miss" flows, that is catch-all flows with
 * priority 0, and inferring a match on packet_type(0,0) causes such a flow not
 * to be a table miss flow.  */
A match on 'field' is being added to or has been added to 'match'.  If
'field' is a data field, and 'match' does not already match on packet_type,
this function make it match on the Ethernet packet_type.

This function is useful because OpenFlow implicitly applies to Ethernet
packets when there's no explicit packet_type, but matching on a metadata
field doesn't imply anything about the packet_type and falsely inferring
that it does can cause harm.  A flow that matches only on metadata fields,
for example, should be able to match more than just Ethernet flows.  There
are also important reasons that a catch-all match (one with no field matches
at all) should not imply a packet_type(0,0) match.  For example, a "flow
dump" request that matches on no fields should return every flow in the
switch, not just the flows that match on Ethernet.  As a second example,
OpenFlow 1.2+ special-cases "table miss" flows, that is catch-all flows with
priority 0, and inferring a match on packet_type(0,0) causes such a flow not
to be a table miss flow.
A match on ' field ' is being added to or has been added to ' match ' . If ' field ' is a data field and ' match ' does not already match on packet_type this function make it match on the Ethernet packet_type . This function is useful because OpenFlow implicitly applies to Ethernet packets when there ' s no explicit packet_type but matching on a metadata field doesn ' t imply anything about the packet_type and falsely inferring that it does can cause harm . A flow that matches only on metadata fields for example should be able to match more than just Ethernet flows . There are also important reasons that a catch - all match ( one with no field matches at all ) should not imply a packet_type ( 0 0 ) match . For example a " flow dump " request that matches on no fields should return every flow in the switch not just the flows that match on Ethernet . As a second example OpenFlow 1 . 2 + special - cases " table miss " flows that is catch - all flows with priority 0 and inferring a match on packet_type ( 0 0 ) causes such a flow not to be a table miss flow .
void
match_add_ethernet_prereq(struct match *match, const struct mf_field *field)
{
    if (field->prereqs != MFP_NONE) {
        match_set_default_packet_type(match);
    }
}
void match_add_ethernet_prereq ( struct match * match , const struct mf_field * field ) { if ( field -> prereqs != MFP_NONE ) { match_set_default_packet_type ( match ) ; } }
A match on 'field' is being added to or has been added to 'match'.
A match on ' field ' is being added to or has been added to ' match ' .