98
98
(flow->dl_type == htons(ETH_TYPE_RARP))) {
99
99
memset(&wc->masks.nw_src, 0xff, sizeof wc->masks.nw_src);
100
100
memset(&wc->masks.nw_dst, 0xff, sizeof wc->masks.nw_dst);
101
} else if (eth_type_mpls(flow->dl_type)) {
102
memset(&wc->masks.mpls_lse, 0xff, sizeof wc->masks.mpls_lse);
103
105
if (flow->dl_type == htons(ETH_TYPE_ARP) ||
109
111
if (is_ip_any(flow)) {
110
112
memset(&wc->masks.nw_tos, 0xff, sizeof wc->masks.nw_tos);
111
113
memset(&wc->masks.nw_ttl, 0xff, sizeof wc->masks.nw_ttl);
115
memset(&wc->masks.nw_frag, 0xff, sizeof wc->masks.nw_frag);
118
if (flow->nw_proto == IPPROTO_ICMP || flow->nw_proto == IPPROTO_ICMPV6 ||
119
(flow->tp_src || flow->tp_dst)) {
120
memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
121
memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
124
if (flow->nw_proto == IPPROTO_ICMPV6) {
125
memset(&wc->masks.arp_sha, 0xff, sizeof wc->masks.arp_sha);
126
memset(&wc->masks.arp_tha, 0xff, sizeof wc->masks.arp_tha);
116
memset(&wc->masks.nw_frag, 0xff, sizeof wc->masks.nw_frag);
119
if (flow->nw_proto == IPPROTO_ICMP ||
120
flow->nw_proto == IPPROTO_ICMPV6 ||
121
(flow->tp_src || flow->tp_dst)) {
122
memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
123
memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
126
if (flow->nw_proto == IPPROTO_ICMPV6) {
127
memset(&wc->masks.arp_sha, 0xff, sizeof wc->masks.arp_sha);
128
memset(&wc->masks.arp_tha, 0xff, sizeof wc->masks.arp_tha);
134
137
match_init_exact(struct match *match, const struct flow *flow)
136
ovs_be64 tun_id = flow->tunnel.tun_id;
138
139
match->flow = *flow;
139
140
match->flow.skb_priority = 0;
140
141
match->flow.skb_mark = 0;
141
memset(&match->flow.tunnel, 0, sizeof match->flow.tunnel);
142
match->flow.tunnel.tun_id = tun_id;
143
142
flow_wildcards_init_exact(&match->wc);
276
match_set_in_port(struct match *match, uint16_t ofp_port)
275
match_set_in_port(struct match *match, ofp_port_t ofp_port)
278
match->wc.masks.in_port = UINT16_MAX;
279
match->flow.in_port = ofp_port;
277
match->wc.masks.in_port.ofp_port = u16_to_ofp(UINT16_MAX);
278
match->flow.in_port.ofp_port = ofp_port;
460
459
match->wc.masks.vlan_tci |= htons(VLAN_CFI | VLAN_PCP_MASK);
462
/* Modifies 'match' so that the MPLS label is wildcarded. */
464
match_set_any_mpls_label(struct match *match)
466
match->wc.masks.mpls_lse &= ~htonl(MPLS_LABEL_MASK);
467
flow_set_mpls_label(&match->flow, htonl(0));
470
/* Modifies 'match' so that it matches only packets with an MPLS header whose
471
* label equals the low 20 bits of 'mpls_label'. */
473
match_set_mpls_label(struct match *match, ovs_be32 mpls_label)
475
match->wc.masks.mpls_lse |= htonl(MPLS_LABEL_MASK);
476
flow_set_mpls_label(&match->flow, mpls_label);
479
/* Modifies 'match' so that the MPLS TC is wildcarded. */
481
match_set_any_mpls_tc(struct match *match)
483
match->wc.masks.mpls_lse &= ~htonl(MPLS_TC_MASK);
484
flow_set_mpls_tc(&match->flow, 0);
487
/* Modifies 'match' so that it matches only packets with an MPLS header whose
488
* Traffic Class equals the low 3 bits of 'mpls_tc'. */
490
match_set_mpls_tc(struct match *match, uint8_t mpls_tc)
492
match->wc.masks.mpls_lse |= htonl(MPLS_TC_MASK);
493
flow_set_mpls_tc(&match->flow, mpls_tc);
496
/* Modifies 'match' so that the MPLS stack flag is wildcarded. */
498
match_set_any_mpls_bos(struct match *match)
500
match->wc.masks.mpls_lse &= ~htonl(MPLS_BOS_MASK);
501
flow_set_mpls_bos(&match->flow, 0);
504
/* Modifies 'match' so that it matches only packets with an MPLS header whose
505
* Stack Flag equals the lower bit of 'mpls_bos' */
507
match_set_mpls_bos(struct match *match, uint8_t mpls_bos)
509
match->wc.masks.mpls_lse |= htonl(MPLS_BOS_MASK);
510
flow_set_mpls_bos(&match->flow, mpls_bos);
464
514
match_set_tp_src(struct match *match, ovs_be16 tp_src)
783
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 18);
833
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 20);
785
835
if (priority != OFP_DEFAULT_PRIORITY) {
786
836
ds_put_format(s, "priority=%u,", priority);
832
882
ds_put_cstr(s, "arp,");
833
883
} else if (f->dl_type == htons(ETH_TYPE_RARP)) {
834
884
ds_put_cstr(s, "rarp,");
885
} else if (f->dl_type == htons(ETH_TYPE_MPLS)) {
886
ds_put_cstr(s, "mpls,");
887
} else if (f->dl_type == htons(ETH_TYPE_MPLS_MCAST)) {
888
ds_put_cstr(s, "mplsm,");
836
890
skip_type = false;
863
917
ntohll(f->metadata), ntohll(wc->masks.metadata));
866
if (wc->masks.in_port) {
920
if (wc->masks.in_port.ofp_port) {
867
921
ds_put_cstr(s, "in_port=");
868
ofputil_format_port(f->in_port, s);
922
ofputil_format_port(f->in_port.ofp_port, s);
869
923
ds_put_char(s, ',');
871
925
if (wc->masks.vlan_tci) {
940
994
if (wc->masks.nw_ttl) {
941
995
ds_put_format(s, "nw_ttl=%"PRIu8",", f->nw_ttl);
997
if (wc->masks.mpls_lse & htonl(MPLS_LABEL_MASK)) {
998
ds_put_format(s, "mpls_label=%"PRIu32",",
999
mpls_lse_to_label(f->mpls_lse));
1001
if (wc->masks.mpls_lse & htonl(MPLS_TC_MASK)) {
1002
ds_put_format(s, "mpls_tc=%"PRIu8",",
1003
mpls_lse_to_tc(f->mpls_lse));
1005
if (wc->masks.mpls_lse & htonl(MPLS_TTL_MASK)) {
1006
ds_put_format(s, "mpls_ttl=%"PRIu8",",
1007
mpls_lse_to_ttl(f->mpls_lse));
1009
if (wc->masks.mpls_lse & htonl(MPLS_BOS_MASK)) {
1010
ds_put_format(s, "mpls_bos=%"PRIu8",",
1011
mpls_lse_to_bos(f->mpls_lse));
943
1013
switch (wc->masks.nw_frag) {
944
1014
case FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER:
945
1015
ds_put_format(s, "nw_frag=%s,",