X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=lib%2Flearning-switch.c;h=c1cd909f5ed47586b1c14c2c779e082f32c6d30a;hb=36a16881d032fce280e54de2f261640a52bf04c7;hp=f52d3c9d2d69b074c5141609f2e9004344b39ab6;hpb=f702893a7cc2380b2640e1ccb3a987d46766c685;p=openvswitch diff --git a/lib/learning-switch.c b/lib/learning-switch.c index f52d3c9d..c1cd909f 100644 --- a/lib/learning-switch.c +++ b/lib/learning-switch.c @@ -112,6 +112,7 @@ struct lswitch * lswitch_create(struct rconn *rconn, const struct lswitch_config *cfg) { struct lswitch *sw; + uint32_t ofpfw; sw = xzalloc(sizeof *sw); sw->rconn = rconn; @@ -123,24 +124,26 @@ lswitch_create(struct rconn *rconn, const struct lswitch_config *cfg) : NULL); sw->action_normal = cfg->mode == LSW_NORMAL; - flow_wildcards_init_exact(&sw->wc); - if (cfg->wildcards) { - uint32_t ofpfw; - - if (cfg->wildcards == UINT32_MAX) { - /* Try to wildcard as many fields as possible, but we cannot - * wildcard all fields. We need in_port to detect moves. We need - * Ethernet source and dest and VLAN VID to do L2 learning. */ - ofpfw = (OFPFW10_DL_TYPE | OFPFW10_DL_VLAN_PCP - | OFPFW10_NW_SRC_ALL | OFPFW10_NW_DST_ALL - | OFPFW10_NW_TOS | OFPFW10_NW_PROTO - | OFPFW10_TP_SRC | OFPFW10_TP_DST); - } else { - ofpfw = cfg->wildcards; - } + switch (cfg->wildcards) { + case 0: + ofpfw = 0; + break; - ofputil_wildcard_from_ofpfw10(ofpfw, &sw->wc); + case UINT32_MAX: + /* Try to wildcard as many fields as possible, but we cannot + * wildcard all fields. We need in_port to detect moves. We need + * Ethernet source and dest and VLAN VID to do L2 learning. */ + ofpfw = (OFPFW10_DL_TYPE | OFPFW10_DL_VLAN_PCP + | OFPFW10_NW_SRC_ALL | OFPFW10_NW_DST_ALL + | OFPFW10_NW_TOS | OFPFW10_NW_PROTO + | OFPFW10_TP_SRC | OFPFW10_TP_DST); + break; + + default: + ofpfw = cfg->wildcards; + break; } + ofputil_wildcard_from_ofpfw10(ofpfw, &sw->wc); sw->default_queue = cfg->default_queue; hmap_init(&sw->queue_numbers); @@ -573,6 +576,7 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh) * new flow. */ memset(&fm, 0, sizeof fm); cls_rule_init(&flow, &sw->wc, 0, &fm.cr); + ofputil_normalize_rule_quiet(&fm.cr); fm.table_id = 0xff; fm.command = OFPFC_ADD; fm.idle_timeout = sw->max_idle;