X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fmatch.c;h=e97b0b18f6c8ad1431d5f98f857cd718faf95a1a;hb=591cb419cf3694e0ae66a95973e73c61bad9e03d;hp=f4b0a6c147f9ae0e5b5f779cfb6141b0b2019e98;hpb=67680b012be30d9c26eab999b83b08c6eb32dbd2;p=sliver-openvswitch.git diff --git a/lib/match.c b/lib/match.c index f4b0a6c14..e97b0b18f 100644 --- a/lib/match.c +++ b/lib/match.c @@ -60,8 +60,8 @@ match_wc_init(struct match *match, const struct flow *flow) memset(&wc->masks.skb_priority, 0xff, sizeof wc->masks.skb_priority); } - if (flow->skb_mark) { - memset(&wc->masks.skb_mark, 0xff, sizeof wc->masks.skb_mark); + if (flow->pkt_mark) { + memset(&wc->masks.pkt_mark, 0xff, sizeof wc->masks.pkt_mark); } for (i = 0; i < FLOW_N_REGS; i++) { @@ -98,6 +98,8 @@ match_wc_init(struct match *match, const struct flow *flow) (flow->dl_type == htons(ETH_TYPE_RARP))) { memset(&wc->masks.nw_src, 0xff, sizeof wc->masks.nw_src); memset(&wc->masks.nw_dst, 0xff, sizeof wc->masks.nw_dst); + } else if (eth_type_mpls(flow->dl_type)) { + memset(&wc->masks.mpls_lse, 0xff, sizeof wc->masks.mpls_lse); } if (flow->dl_type == htons(ETH_TYPE_ARP) || @@ -109,21 +111,22 @@ match_wc_init(struct match *match, const struct flow *flow) if (is_ip_any(flow)) { memset(&wc->masks.nw_tos, 0xff, sizeof wc->masks.nw_tos); memset(&wc->masks.nw_ttl, 0xff, sizeof wc->masks.nw_ttl); - } - if (flow->nw_frag) { - memset(&wc->masks.nw_frag, 0xff, sizeof wc->masks.nw_frag); - } + if (flow->nw_frag) { + memset(&wc->masks.nw_frag, 0xff, sizeof wc->masks.nw_frag); + } - if (flow->nw_proto == IPPROTO_ICMP || flow->nw_proto == IPPROTO_ICMPV6 || - (flow->tp_src || flow->tp_dst)) { - memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src); - memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst); - } + if (flow->nw_proto == IPPROTO_ICMP || + flow->nw_proto == IPPROTO_ICMPV6 || + (flow->tp_src || flow->tp_dst)) { + memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src); + memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst); + } - if (flow->nw_proto == IPPROTO_ICMPV6) { - memset(&wc->masks.arp_sha, 0xff, sizeof wc->masks.arp_sha); - memset(&wc->masks.arp_tha, 0xff, sizeof wc->masks.arp_tha); + if (flow->nw_proto == IPPROTO_ICMPV6) { + memset(&wc->masks.arp_sha, 0xff, sizeof wc->masks.arp_sha); + memset(&wc->masks.arp_tha, 0xff, sizeof wc->masks.arp_tha); + } } return; @@ -133,13 +136,8 @@ match_wc_init(struct match *match, const struct flow *flow) void match_init_exact(struct match *match, const struct flow *flow) { - ovs_be64 tun_id = flow->tunnel.tun_id; - match->flow = *flow; match->flow.skb_priority = 0; - match->flow.skb_mark = 0; - memset(&match->flow.tunnel, 0, sizeof match->flow.tunnel); - match->flow.tunnel.tun_id = tun_id; flow_wildcards_init_exact(&match->wc); } @@ -273,10 +271,10 @@ match_set_tun_flags_masked(struct match *match, uint16_t flags, uint16_t mask) } void -match_set_in_port(struct match *match, uint16_t ofp_port) +match_set_in_port(struct match *match, ofp_port_t ofp_port) { - match->wc.masks.in_port = UINT16_MAX; - match->flow.in_port = ofp_port; + match->wc.masks.in_port.ofp_port = u16_to_ofp(UINT16_MAX); + match->flow.in_port.ofp_port = ofp_port; } void @@ -287,10 +285,16 @@ match_set_skb_priority(struct match *match, uint32_t skb_priority) } void -match_set_skb_mark(struct match *match, uint32_t skb_mark) +match_set_pkt_mark(struct match *match, uint32_t pkt_mark) +{ + match_set_pkt_mark_masked(match, pkt_mark, UINT32_MAX); +} + +void +match_set_pkt_mark_masked(struct match *match, uint32_t pkt_mark, uint32_t mask) { - match->wc.masks.skb_mark = UINT32_MAX; - match->flow.skb_mark = skb_mark; + match->flow.pkt_mark = pkt_mark & mask; + match->wc.masks.pkt_mark = mask; } void @@ -818,24 +822,6 @@ format_flow_tunnel(struct ds *s, const struct match *match) } } -static void -flow_format_mpls(const struct flow *flow, struct ds *s) -{ - if (flow->dl_type == htons(ETH_TYPE_MPLS)) { - ds_put_cstr(s, "mpls"); - } else if (flow->dl_type == htons(ETH_TYPE_MPLS_MCAST)) { - ds_put_cstr(s, "mplsm"); - } else { - return; - } - - ds_put_format(s, "(label:%"PRIu32",tc:%d,ttl:%d,bos:%d),", - mpls_lse_to_label(flow->mpls_lse), - mpls_lse_to_tc(flow->mpls_lse), - mpls_lse_to_ttl(flow->mpls_lse), - mpls_lse_to_bos(flow->mpls_lse)); -} - /* Appends a string representation of 'match' to 's'. If 'priority' is * different from OFP_DEFAULT_PRIORITY, includes it in 's'. */ void @@ -849,14 +835,22 @@ match_format(const struct match *match, struct ds *s, unsigned int priority) int i; - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 19); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 20); if (priority != OFP_DEFAULT_PRIORITY) { ds_put_format(s, "priority=%u,", priority); } - if (wc->masks.skb_mark) { - ds_put_format(s, "skb_mark=%#"PRIx32",", f->skb_mark); + switch (wc->masks.pkt_mark) { + case 0: + break; + case UINT32_MAX: + ds_put_format(s, "pkt_mark=%#"PRIx32",", f->pkt_mark); + break; + default: + ds_put_format(s, "pkt_mark=%#"PRIx32"/%#"PRIx32",", + f->pkt_mark, wc->masks.pkt_mark); + break; } if (wc->masks.skb_priority) { @@ -901,8 +895,10 @@ match_format(const struct match *match, struct ds *s, unsigned int priority) ds_put_cstr(s, "arp,"); } else if (f->dl_type == htons(ETH_TYPE_RARP)) { ds_put_cstr(s, "rarp,"); - } else if (f->mpls_depth) { - flow_format_mpls(f, s); + } else if (f->dl_type == htons(ETH_TYPE_MPLS)) { + ds_put_cstr(s, "mpls,"); + } else if (f->dl_type == htons(ETH_TYPE_MPLS_MCAST)) { + ds_put_cstr(s, "mplsm,"); } else { skip_type = false; } @@ -934,9 +930,9 @@ match_format(const struct match *match, struct ds *s, unsigned int priority) ntohll(f->metadata), ntohll(wc->masks.metadata)); break; } - if (wc->masks.in_port) { + if (wc->masks.in_port.ofp_port) { ds_put_cstr(s, "in_port="); - ofputil_format_port(f->in_port, s); + ofputil_format_port(f->in_port.ofp_port, s); ds_put_char(s, ','); } if (wc->masks.vlan_tci) { @@ -1019,6 +1015,10 @@ match_format(const struct match *match, struct ds *s, unsigned int priority) ds_put_format(s, "mpls_tc=%"PRIu8",", mpls_lse_to_tc(f->mpls_lse)); } + if (wc->masks.mpls_lse & htonl(MPLS_TTL_MASK)) { + ds_put_format(s, "mpls_ttl=%"PRIu8",", + mpls_lse_to_ttl(f->mpls_lse)); + } if (wc->masks.mpls_lse & htonl(MPLS_BOS_MASK)) { ds_put_format(s, "mpls_bos=%"PRIu8",", mpls_lse_to_bos(f->mpls_lse));