2 * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "byte-order.h"
21 #include "dynamic-string.h"
24 #include "tun-metadata.h"
26 /* Converts the flow in 'flow' into a match in 'match', with the given
29 match_init(struct match
*match
,
30 const struct flow
*flow
, const struct flow_wildcards
*wc
)
34 match_zero_wildcarded_fields(match
);
35 memset(&match
->tun_md
, 0, sizeof match
->tun_md
);
38 /* Converts a flow into a match. It sets the wildcard masks based on
39 * the packet contents. It will not set the mask for fields that do not
40 * make sense for the packet type. */
42 match_wc_init(struct match
*match
, const struct flow
*flow
)
46 flow_wildcards_init_for_packet(&match
->wc
, flow
);
47 WC_MASK_FIELD(&match
->wc
, regs
);
48 WC_MASK_FIELD(&match
->wc
, metadata
);
50 memset(&match
->tun_md
, 0, sizeof match
->tun_md
);
53 /* Initializes 'match' as a "catch-all" match that matches every packet. */
55 match_init_catchall(struct match
*match
)
57 memset(&match
->flow
, 0, sizeof match
->flow
);
58 flow_wildcards_init_catchall(&match
->wc
);
59 memset(&match
->tun_md
, 0, sizeof match
->tun_md
);
62 /* For each bit or field wildcarded in 'match', sets the corresponding bit or
63 * field in 'flow' to all-0-bits. It is important to maintain this invariant
64 * in a match that might be inserted into a classifier.
66 * It is never necessary to call this function directly for a match that is
67 * initialized or modified only by match_*() functions. It is useful to
68 * restore the invariant in a match whose 'wc' member is modified by hand.
71 match_zero_wildcarded_fields(struct match
*match
)
73 flow_zero_wildcards(&match
->flow
, &match
->wc
);
77 match_set_dp_hash(struct match
*match
, uint32_t value
)
79 match_set_dp_hash_masked(match
, value
, UINT32_MAX
);
83 match_set_dp_hash_masked(struct match
*match
, uint32_t value
, uint32_t mask
)
85 match
->wc
.masks
.dp_hash
= mask
;
86 match
->flow
.dp_hash
= value
& mask
;
90 match_set_recirc_id(struct match
*match
, uint32_t value
)
92 match
->flow
.recirc_id
= value
;
93 match
->wc
.masks
.recirc_id
= UINT32_MAX
;
97 match_set_conj_id(struct match
*match
, uint32_t value
)
99 match
->flow
.conj_id
= value
;
100 match
->wc
.masks
.conj_id
= UINT32_MAX
;
104 match_set_reg(struct match
*match
, unsigned int reg_idx
, uint32_t value
)
106 match_set_reg_masked(match
, reg_idx
, value
, UINT32_MAX
);
110 match_set_reg_masked(struct match
*match
, unsigned int reg_idx
,
111 uint32_t value
, uint32_t mask
)
113 ovs_assert(reg_idx
< FLOW_N_REGS
);
114 flow_wildcards_set_reg_mask(&match
->wc
, reg_idx
, mask
);
115 match
->flow
.regs
[reg_idx
] = value
& mask
;
119 match_set_xreg(struct match
*match
, unsigned int xreg_idx
, uint64_t value
)
121 match_set_xreg_masked(match
, xreg_idx
, value
, UINT64_MAX
);
125 match_set_xreg_masked(struct match
*match
, unsigned int xreg_idx
,
126 uint64_t value
, uint64_t mask
)
128 ovs_assert(xreg_idx
< FLOW_N_XREGS
);
129 flow_wildcards_set_xreg_mask(&match
->wc
, xreg_idx
, mask
);
130 flow_set_xreg(&match
->flow
, xreg_idx
, value
& mask
);
134 match_set_actset_output(struct match
*match
, ofp_port_t actset_output
)
136 match
->wc
.masks
.actset_output
= u16_to_ofp(UINT16_MAX
);
137 match
->flow
.actset_output
= actset_output
;
141 match_set_metadata(struct match
*match
, ovs_be64 metadata
)
143 match_set_metadata_masked(match
, metadata
, OVS_BE64_MAX
);
147 match_set_metadata_masked(struct match
*match
,
148 ovs_be64 metadata
, ovs_be64 mask
)
150 match
->wc
.masks
.metadata
= mask
;
151 match
->flow
.metadata
= metadata
& mask
;
155 match_set_tun_id(struct match
*match
, ovs_be64 tun_id
)
157 match_set_tun_id_masked(match
, tun_id
, OVS_BE64_MAX
);
161 match_set_tun_id_masked(struct match
*match
, ovs_be64 tun_id
, ovs_be64 mask
)
163 match
->wc
.masks
.tunnel
.tun_id
= mask
;
164 match
->flow
.tunnel
.tun_id
= tun_id
& mask
;
168 match_set_tun_src(struct match
*match
, ovs_be32 src
)
170 match_set_tun_src_masked(match
, src
, OVS_BE32_MAX
);
174 match_set_tun_src_masked(struct match
*match
, ovs_be32 src
, ovs_be32 mask
)
176 match
->wc
.masks
.tunnel
.ip_src
= mask
;
177 match
->flow
.tunnel
.ip_src
= src
& mask
;
181 match_set_tun_dst(struct match
*match
, ovs_be32 dst
)
183 match_set_tun_dst_masked(match
, dst
, OVS_BE32_MAX
);
187 match_set_tun_dst_masked(struct match
*match
, ovs_be32 dst
, ovs_be32 mask
)
189 match
->wc
.masks
.tunnel
.ip_dst
= mask
;
190 match
->flow
.tunnel
.ip_dst
= dst
& mask
;
194 match_set_tun_ttl(struct match
*match
, uint8_t ttl
)
196 match_set_tun_ttl_masked(match
, ttl
, UINT8_MAX
);
200 match_set_tun_ttl_masked(struct match
*match
, uint8_t ttl
, uint8_t mask
)
202 match
->wc
.masks
.tunnel
.ip_ttl
= mask
;
203 match
->flow
.tunnel
.ip_ttl
= ttl
& mask
;
207 match_set_tun_tos(struct match
*match
, uint8_t tos
)
209 match_set_tun_tos_masked(match
, tos
, UINT8_MAX
);
213 match_set_tun_tos_masked(struct match
*match
, uint8_t tos
, uint8_t mask
)
215 match
->wc
.masks
.tunnel
.ip_tos
= mask
;
216 match
->flow
.tunnel
.ip_tos
= tos
& mask
;
220 match_set_tun_flags(struct match
*match
, uint16_t flags
)
222 match_set_tun_flags_masked(match
, flags
, UINT16_MAX
);
226 match_set_tun_flags_masked(struct match
*match
, uint16_t flags
, uint16_t mask
)
228 match
->wc
.masks
.tunnel
.flags
= mask
;
229 match
->flow
.tunnel
.flags
= flags
& mask
;
233 match_set_tun_gbp_id_masked(struct match
*match
, ovs_be16 gbp_id
, ovs_be16 mask
)
235 match
->wc
.masks
.tunnel
.gbp_id
= mask
;
236 match
->flow
.tunnel
.gbp_id
= gbp_id
& mask
;
240 match_set_tun_gbp_id(struct match
*match
, ovs_be16 gbp_id
)
242 match_set_tun_gbp_id_masked(match
, gbp_id
, OVS_BE16_MAX
);
246 match_set_tun_gbp_flags_masked(struct match
*match
, uint8_t flags
, uint8_t mask
)
248 match
->wc
.masks
.tunnel
.gbp_flags
= mask
;
249 match
->flow
.tunnel
.gbp_flags
= flags
& mask
;
253 match_set_tun_gbp_flags(struct match
*match
, uint8_t flags
)
255 match_set_tun_gbp_flags_masked(match
, flags
, UINT8_MAX
);
259 match_set_in_port(struct match
*match
, ofp_port_t ofp_port
)
261 match
->wc
.masks
.in_port
.ofp_port
= u16_to_ofp(UINT16_MAX
);
262 match
->flow
.in_port
.ofp_port
= ofp_port
;
266 match_set_skb_priority(struct match
*match
, uint32_t skb_priority
)
268 match
->wc
.masks
.skb_priority
= UINT32_MAX
;
269 match
->flow
.skb_priority
= skb_priority
;
273 match_set_pkt_mark(struct match
*match
, uint32_t pkt_mark
)
275 match_set_pkt_mark_masked(match
, pkt_mark
, UINT32_MAX
);
279 match_set_pkt_mark_masked(struct match
*match
, uint32_t pkt_mark
, uint32_t mask
)
281 match
->flow
.pkt_mark
= pkt_mark
& mask
;
282 match
->wc
.masks
.pkt_mark
= mask
;
286 match_set_dl_type(struct match
*match
, ovs_be16 dl_type
)
288 match
->wc
.masks
.dl_type
= OVS_BE16_MAX
;
289 match
->flow
.dl_type
= dl_type
;
292 /* Modifies 'value_src' so that the Ethernet address must match 'value_dst'
293 * exactly. 'mask_dst' is set to all 1s. */
295 set_eth(const uint8_t value_src
[ETH_ADDR_LEN
],
296 uint8_t value_dst
[ETH_ADDR_LEN
],
297 uint8_t mask_dst
[ETH_ADDR_LEN
])
299 memcpy(value_dst
, value_src
, ETH_ADDR_LEN
);
300 memset(mask_dst
, 0xff, ETH_ADDR_LEN
);
303 /* Modifies 'value_src' so that the Ethernet address must match 'value_src'
304 * after each byte is ANDed with the appropriate byte in 'mask_src'.
305 * 'mask_dst' is set to 'mask_src' */
307 set_eth_masked(const uint8_t value_src
[ETH_ADDR_LEN
],
308 const uint8_t mask_src
[ETH_ADDR_LEN
],
309 uint8_t value_dst
[ETH_ADDR_LEN
],
310 uint8_t mask_dst
[ETH_ADDR_LEN
])
314 for (i
= 0; i
< ETH_ADDR_LEN
; i
++) {
315 value_dst
[i
] = value_src
[i
] & mask_src
[i
];
316 mask_dst
[i
] = mask_src
[i
];
320 /* Modifies 'rule' so that the source Ethernet address must match 'dl_src'
323 match_set_dl_src(struct match
*match
, const uint8_t dl_src
[ETH_ADDR_LEN
])
325 set_eth(dl_src
, match
->flow
.dl_src
, match
->wc
.masks
.dl_src
);
328 /* Modifies 'rule' so that the source Ethernet address must match 'dl_src'
329 * after each byte is ANDed with the appropriate byte in 'mask'. */
331 match_set_dl_src_masked(struct match
*match
,
332 const uint8_t dl_src
[ETH_ADDR_LEN
],
333 const uint8_t mask
[ETH_ADDR_LEN
])
335 set_eth_masked(dl_src
, mask
, match
->flow
.dl_src
, match
->wc
.masks
.dl_src
);
338 /* Modifies 'match' so that the Ethernet address must match 'dl_dst'
341 match_set_dl_dst(struct match
*match
, const uint8_t dl_dst
[ETH_ADDR_LEN
])
343 set_eth(dl_dst
, match
->flow
.dl_dst
, match
->wc
.masks
.dl_dst
);
346 /* Modifies 'match' so that the Ethernet address must match 'dl_dst' after each
347 * byte is ANDed with the appropriate byte in 'mask'.
349 * This function will assert-fail if 'mask' is invalid. Only 'mask' values
350 * accepted by flow_wildcards_is_dl_dst_mask_valid() are allowed. */
352 match_set_dl_dst_masked(struct match
*match
,
353 const uint8_t dl_dst
[ETH_ADDR_LEN
],
354 const uint8_t mask
[ETH_ADDR_LEN
])
356 set_eth_masked(dl_dst
, mask
, match
->flow
.dl_dst
, match
->wc
.masks
.dl_dst
);
360 match_set_dl_tci(struct match
*match
, ovs_be16 tci
)
362 match_set_dl_tci_masked(match
, tci
, htons(0xffff));
366 match_set_dl_tci_masked(struct match
*match
, ovs_be16 tci
, ovs_be16 mask
)
368 match
->flow
.vlan_tci
= tci
& mask
;
369 match
->wc
.masks
.vlan_tci
= mask
;
372 /* Modifies 'match' so that the VLAN VID is wildcarded. If the PCP is already
373 * wildcarded, then 'match' will match a packet regardless of whether it has an
374 * 802.1Q header or not. */
376 match_set_any_vid(struct match
*match
)
378 if (match
->wc
.masks
.vlan_tci
& htons(VLAN_PCP_MASK
)) {
379 match
->wc
.masks
.vlan_tci
&= ~htons(VLAN_VID_MASK
);
380 match
->flow
.vlan_tci
&= ~htons(VLAN_VID_MASK
);
382 match_set_dl_tci_masked(match
, htons(0), htons(0));
386 /* Modifies 'match' depending on 'dl_vlan':
388 * - If 'dl_vlan' is htons(OFP_VLAN_NONE), makes 'match' match only packets
389 * without an 802.1Q header.
391 * - Otherwise, makes 'match' match only packets with an 802.1Q header whose
392 * VID equals the low 12 bits of 'dl_vlan'.
395 match_set_dl_vlan(struct match
*match
, ovs_be16 dl_vlan
)
397 flow_set_dl_vlan(&match
->flow
, dl_vlan
);
398 if (dl_vlan
== htons(OFP10_VLAN_NONE
)) {
399 match
->wc
.masks
.vlan_tci
= OVS_BE16_MAX
;
401 match
->wc
.masks
.vlan_tci
|= htons(VLAN_VID_MASK
| VLAN_CFI
);
405 /* Sets the VLAN VID that 'match' matches to 'vid', which is interpreted as an
406 * OpenFlow 1.2 "vlan_vid" value, that is, the low 13 bits of 'vlan_tci' (VID
409 match_set_vlan_vid(struct match
*match
, ovs_be16 vid
)
411 match_set_vlan_vid_masked(match
, vid
, htons(VLAN_VID_MASK
| VLAN_CFI
));
415 /* Sets the VLAN VID that 'flow' matches to 'vid', which is interpreted as an
416 * OpenFlow 1.2 "vlan_vid" value, that is, the low 13 bits of 'vlan_tci' (VID
417 * plus CFI), with the corresponding 'mask'. */
419 match_set_vlan_vid_masked(struct match
*match
, ovs_be16 vid
, ovs_be16 mask
)
421 ovs_be16 pcp_mask
= htons(VLAN_PCP_MASK
);
422 ovs_be16 vid_mask
= htons(VLAN_VID_MASK
| VLAN_CFI
);
425 flow_set_vlan_vid(&match
->flow
, vid
& mask
);
426 match
->wc
.masks
.vlan_tci
= mask
| (match
->wc
.masks
.vlan_tci
& pcp_mask
);
429 /* Modifies 'match' so that the VLAN PCP is wildcarded. If the VID is already
430 * wildcarded, then 'match' will match a packet regardless of whether it has an
431 * 802.1Q header or not. */
433 match_set_any_pcp(struct match
*match
)
435 if (match
->wc
.masks
.vlan_tci
& htons(VLAN_VID_MASK
)) {
436 match
->wc
.masks
.vlan_tci
&= ~htons(VLAN_PCP_MASK
);
437 match
->flow
.vlan_tci
&= ~htons(VLAN_PCP_MASK
);
439 match_set_dl_tci_masked(match
, htons(0), htons(0));
443 /* Modifies 'match' so that it matches only packets with an 802.1Q header whose
444 * PCP equals the low 3 bits of 'dl_vlan_pcp'. */
446 match_set_dl_vlan_pcp(struct match
*match
, uint8_t dl_vlan_pcp
)
448 flow_set_vlan_pcp(&match
->flow
, dl_vlan_pcp
);
449 match
->wc
.masks
.vlan_tci
|= htons(VLAN_CFI
| VLAN_PCP_MASK
);
452 /* Modifies 'match' so that the MPLS label 'idx' matches 'lse' exactly. */
454 match_set_mpls_lse(struct match
*match
, int idx
, ovs_be32 lse
)
456 match
->wc
.masks
.mpls_lse
[idx
] = OVS_BE32_MAX
;
457 match
->flow
.mpls_lse
[idx
] = lse
;
460 /* Modifies 'match' so that the MPLS label is wildcarded. */
462 match_set_any_mpls_label(struct match
*match
, int idx
)
464 match
->wc
.masks
.mpls_lse
[idx
] &= ~htonl(MPLS_LABEL_MASK
);
465 flow_set_mpls_label(&match
->flow
, idx
, htonl(0));
468 /* Modifies 'match' so that it matches only packets with an MPLS header whose
469 * label equals the low 20 bits of 'mpls_label'. */
471 match_set_mpls_label(struct match
*match
, int idx
, ovs_be32 mpls_label
)
473 match
->wc
.masks
.mpls_lse
[idx
] |= htonl(MPLS_LABEL_MASK
);
474 flow_set_mpls_label(&match
->flow
, idx
, mpls_label
);
477 /* Modifies 'match' so that the MPLS TC is wildcarded. */
479 match_set_any_mpls_tc(struct match
*match
, int idx
)
481 match
->wc
.masks
.mpls_lse
[idx
] &= ~htonl(MPLS_TC_MASK
);
482 flow_set_mpls_tc(&match
->flow
, idx
, 0);
485 /* Modifies 'match' so that it matches only packets with an MPLS header whose
486 * Traffic Class equals the low 3 bits of 'mpls_tc'. */
488 match_set_mpls_tc(struct match
*match
, int idx
, uint8_t mpls_tc
)
490 match
->wc
.masks
.mpls_lse
[idx
] |= htonl(MPLS_TC_MASK
);
491 flow_set_mpls_tc(&match
->flow
, idx
, mpls_tc
);
494 /* Modifies 'match' so that the MPLS stack flag is wildcarded. */
496 match_set_any_mpls_bos(struct match
*match
, int idx
)
498 match
->wc
.masks
.mpls_lse
[idx
] &= ~htonl(MPLS_BOS_MASK
);
499 flow_set_mpls_bos(&match
->flow
, idx
, 0);
502 /* Modifies 'match' so that it matches only packets with an MPLS header whose
503 * Stack Flag equals the lower bit of 'mpls_bos' */
505 match_set_mpls_bos(struct match
*match
, int idx
, uint8_t mpls_bos
)
507 match
->wc
.masks
.mpls_lse
[idx
] |= htonl(MPLS_BOS_MASK
);
508 flow_set_mpls_bos(&match
->flow
, idx
, mpls_bos
);
511 /* Modifies 'match' so that the MPLS LSE is wildcarded. */
513 match_set_any_mpls_lse(struct match
*match
, int idx
)
515 match
->wc
.masks
.mpls_lse
[idx
] = htonl(0);
516 flow_set_mpls_lse(&match
->flow
, idx
, htonl(0));
520 match_set_tp_src(struct match
*match
, ovs_be16 tp_src
)
522 match_set_tp_src_masked(match
, tp_src
, OVS_BE16_MAX
);
526 match_set_tp_src_masked(struct match
*match
, ovs_be16 port
, ovs_be16 mask
)
528 match
->flow
.tp_src
= port
& mask
;
529 match
->wc
.masks
.tp_src
= mask
;
533 match_set_tp_dst(struct match
*match
, ovs_be16 tp_dst
)
535 match_set_tp_dst_masked(match
, tp_dst
, OVS_BE16_MAX
);
539 match_set_tp_dst_masked(struct match
*match
, ovs_be16 port
, ovs_be16 mask
)
541 match
->flow
.tp_dst
= port
& mask
;
542 match
->wc
.masks
.tp_dst
= mask
;
546 match_set_tcp_flags(struct match
*match
, ovs_be16 flags
)
548 match_set_tcp_flags_masked(match
, flags
, OVS_BE16_MAX
);
552 match_set_tcp_flags_masked(struct match
*match
, ovs_be16 flags
, ovs_be16 mask
)
554 match
->flow
.tcp_flags
= flags
& mask
;
555 match
->wc
.masks
.tcp_flags
= mask
;
559 match_set_nw_proto(struct match
*match
, uint8_t nw_proto
)
561 match
->flow
.nw_proto
= nw_proto
;
562 match
->wc
.masks
.nw_proto
= UINT8_MAX
;
566 match_set_nw_src(struct match
*match
, ovs_be32 nw_src
)
568 match
->flow
.nw_src
= nw_src
;
569 match
->wc
.masks
.nw_src
= OVS_BE32_MAX
;
573 match_set_nw_src_masked(struct match
*match
,
574 ovs_be32 nw_src
, ovs_be32 mask
)
576 match
->flow
.nw_src
= nw_src
& mask
;
577 match
->wc
.masks
.nw_src
= mask
;
581 match_set_nw_dst(struct match
*match
, ovs_be32 nw_dst
)
583 match
->flow
.nw_dst
= nw_dst
;
584 match
->wc
.masks
.nw_dst
= OVS_BE32_MAX
;
588 match_set_nw_dst_masked(struct match
*match
, ovs_be32 ip
, ovs_be32 mask
)
590 match
->flow
.nw_dst
= ip
& mask
;
591 match
->wc
.masks
.nw_dst
= mask
;
595 match_set_nw_dscp(struct match
*match
, uint8_t nw_dscp
)
597 match
->wc
.masks
.nw_tos
|= IP_DSCP_MASK
;
598 match
->flow
.nw_tos
&= ~IP_DSCP_MASK
;
599 match
->flow
.nw_tos
|= nw_dscp
& IP_DSCP_MASK
;
603 match_set_nw_ecn(struct match
*match
, uint8_t nw_ecn
)
605 match
->wc
.masks
.nw_tos
|= IP_ECN_MASK
;
606 match
->flow
.nw_tos
&= ~IP_ECN_MASK
;
607 match
->flow
.nw_tos
|= nw_ecn
& IP_ECN_MASK
;
611 match_set_nw_ttl(struct match
*match
, uint8_t nw_ttl
)
613 match
->wc
.masks
.nw_ttl
= UINT8_MAX
;
614 match
->flow
.nw_ttl
= nw_ttl
;
618 match_set_nw_frag(struct match
*match
, uint8_t nw_frag
)
620 match
->wc
.masks
.nw_frag
|= FLOW_NW_FRAG_MASK
;
621 match
->flow
.nw_frag
= nw_frag
;
625 match_set_nw_frag_masked(struct match
*match
,
626 uint8_t nw_frag
, uint8_t mask
)
628 match
->flow
.nw_frag
= nw_frag
& mask
;
629 match
->wc
.masks
.nw_frag
= mask
;
633 match_set_icmp_type(struct match
*match
, uint8_t icmp_type
)
635 match_set_tp_src(match
, htons(icmp_type
));
639 match_set_icmp_code(struct match
*match
, uint8_t icmp_code
)
641 match_set_tp_dst(match
, htons(icmp_code
));
645 match_set_arp_sha(struct match
*match
, const uint8_t sha
[ETH_ADDR_LEN
])
647 memcpy(match
->flow
.arp_sha
, sha
, ETH_ADDR_LEN
);
648 memset(match
->wc
.masks
.arp_sha
, UINT8_MAX
, ETH_ADDR_LEN
);
652 match_set_arp_sha_masked(struct match
*match
,
653 const uint8_t arp_sha
[ETH_ADDR_LEN
],
654 const uint8_t mask
[ETH_ADDR_LEN
])
656 set_eth_masked(arp_sha
, mask
,
657 match
->flow
.arp_sha
, match
->wc
.masks
.arp_sha
);
661 match_set_arp_tha(struct match
*match
, const uint8_t tha
[ETH_ADDR_LEN
])
663 memcpy(match
->flow
.arp_tha
, tha
, ETH_ADDR_LEN
);
664 memset(match
->wc
.masks
.arp_tha
, UINT8_MAX
, ETH_ADDR_LEN
);
668 match_set_arp_tha_masked(struct match
*match
,
669 const uint8_t arp_tha
[ETH_ADDR_LEN
],
670 const uint8_t mask
[ETH_ADDR_LEN
])
672 set_eth_masked(arp_tha
, mask
,
673 match
->flow
.arp_tha
, match
->wc
.masks
.arp_tha
);
677 match_set_ipv6_src(struct match
*match
, const struct in6_addr
*src
)
679 match
->flow
.ipv6_src
= *src
;
680 match
->wc
.masks
.ipv6_src
= in6addr_exact
;
684 match_set_ipv6_src_masked(struct match
*match
, const struct in6_addr
*src
,
685 const struct in6_addr
*mask
)
687 match
->flow
.ipv6_src
= ipv6_addr_bitand(src
, mask
);
688 match
->wc
.masks
.ipv6_src
= *mask
;
692 match_set_ipv6_dst(struct match
*match
, const struct in6_addr
*dst
)
694 match
->flow
.ipv6_dst
= *dst
;
695 match
->wc
.masks
.ipv6_dst
= in6addr_exact
;
699 match_set_ipv6_dst_masked(struct match
*match
, const struct in6_addr
*dst
,
700 const struct in6_addr
*mask
)
702 match
->flow
.ipv6_dst
= ipv6_addr_bitand(dst
, mask
);
703 match
->wc
.masks
.ipv6_dst
= *mask
;
707 match_set_ipv6_label(struct match
*match
, ovs_be32 ipv6_label
)
709 match
->wc
.masks
.ipv6_label
= OVS_BE32_MAX
;
710 match
->flow
.ipv6_label
= ipv6_label
;
715 match_set_ipv6_label_masked(struct match
*match
, ovs_be32 ipv6_label
,
718 match
->flow
.ipv6_label
= ipv6_label
& mask
;
719 match
->wc
.masks
.ipv6_label
= mask
;
723 match_set_nd_target(struct match
*match
, const struct in6_addr
*target
)
725 match
->flow
.nd_target
= *target
;
726 match
->wc
.masks
.nd_target
= in6addr_exact
;
730 match_set_nd_target_masked(struct match
*match
,
731 const struct in6_addr
*target
,
732 const struct in6_addr
*mask
)
734 match
->flow
.nd_target
= ipv6_addr_bitand(target
, mask
);
735 match
->wc
.masks
.nd_target
= *mask
;
738 /* Returns true if 'a' and 'b' wildcard the same fields and have the same
739 * values for fixed fields, otherwise false. */
741 match_equal(const struct match
*a
, const struct match
*b
)
743 return (flow_wildcards_equal(&a
->wc
, &b
->wc
)
744 && flow_equal(&a
->flow
, &b
->flow
));
747 /* Returns a hash value for the flow and wildcards in 'match', starting from
750 match_hash(const struct match
*match
, uint32_t basis
)
752 return flow_wildcards_hash(&match
->wc
, flow_hash(&match
->flow
, basis
));
756 match_has_default_recirc_id(const struct match
*m
)
758 return m
->flow
.recirc_id
== 0 && (m
->wc
.masks
.recirc_id
== UINT32_MAX
||
759 m
->wc
.masks
.recirc_id
== 0);
763 match_has_default_dp_hash(const struct match
*m
)
765 return ((m
->flow
.dp_hash
| m
->wc
.masks
.dp_hash
) == 0);
768 /* Return true if the hidden fields of the match are set to the default values.
769 * The default values equals to those set up by match_init_hidden_fields(). */
771 match_has_default_hidden_fields(const struct match
*m
)
773 return match_has_default_recirc_id(m
) && match_has_default_dp_hash(m
);
777 match_init_hidden_fields(struct match
*m
)
779 match_set_recirc_id(m
, 0);
780 match_set_dp_hash_masked(m
, 0, 0);
784 format_eth_masked(struct ds
*s
, const char *name
,
785 const uint8_t eth
[ETH_ADDR_LEN
],
786 const uint8_t mask
[ETH_ADDR_LEN
])
788 if (!eth_addr_is_zero(mask
)) {
789 ds_put_format(s
, "%s=", name
);
790 eth_format_masked(eth
, mask
, s
);
796 format_ip_netmask(struct ds
*s
, const char *name
, ovs_be32 ip
,
800 ds_put_format(s
, "%s=", name
);
801 ip_format_masked(ip
, netmask
, s
);
807 format_ipv6_netmask(struct ds
*s
, const char *name
,
808 const struct in6_addr
*addr
,
809 const struct in6_addr
*netmask
)
811 if (!ipv6_mask_is_any(netmask
)) {
812 ds_put_format(s
, "%s=", name
);
813 print_ipv6_masked(s
, addr
, netmask
);
819 format_be16_masked(struct ds
*s
, const char *name
,
820 ovs_be16 value
, ovs_be16 mask
)
822 if (mask
!= htons(0)) {
823 ds_put_format(s
, "%s=", name
);
824 if (mask
== OVS_BE16_MAX
) {
825 ds_put_format(s
, "%"PRIu16
, ntohs(value
));
827 ds_put_format(s
, "0x%"PRIx16
"/0x%"PRIx16
,
828 ntohs(value
), ntohs(mask
));
835 format_be32_masked(struct ds
*s
, const char *name
,
836 ovs_be32 value
, ovs_be32 mask
)
838 if (mask
!= htonl(0)) {
839 ds_put_format(s
, "%s=", name
);
840 if (mask
== OVS_BE32_MAX
) {
841 ds_put_format(s
, "%"PRIu32
, ntohl(value
));
843 ds_put_format(s
, "0x%"PRIx32
"/0x%"PRIx32
,
844 ntohl(value
), ntohl(mask
));
851 format_uint32_masked(struct ds
*s
, const char *name
,
852 uint32_t value
, uint32_t mask
)
855 ds_put_format(s
, "%s=%#"PRIx32
, name
, value
);
856 if (mask
!= UINT32_MAX
) {
857 ds_put_format(s
, "/%#"PRIx32
, mask
);
864 format_be64_masked(struct ds
*s
, const char *name
,
865 ovs_be64 value
, ovs_be64 mask
)
867 if (mask
!= htonll(0)) {
868 ds_put_format(s
, "%s=%#"PRIx64
, name
, ntohll(value
));
869 if (mask
!= OVS_BE64_MAX
) {
870 ds_put_format(s
, "/%#"PRIx64
, ntohll(mask
));
877 format_flow_tunnel(struct ds
*s
, const struct match
*match
)
879 const struct flow_wildcards
*wc
= &match
->wc
;
880 const struct flow_tnl
*tnl
= &match
->flow
.tunnel
;
882 format_be64_masked(s
, "tun_id", tnl
->tun_id
, wc
->masks
.tunnel
.tun_id
);
883 format_ip_netmask(s
, "tun_src", tnl
->ip_src
, wc
->masks
.tunnel
.ip_src
);
884 format_ip_netmask(s
, "tun_dst", tnl
->ip_dst
, wc
->masks
.tunnel
.ip_dst
);
886 if (wc
->masks
.tunnel
.gbp_id
) {
887 format_be16_masked(s
, "tun_gbp_id", tnl
->gbp_id
,
888 wc
->masks
.tunnel
.gbp_id
);
891 if (wc
->masks
.tunnel
.gbp_flags
) {
892 ds_put_format(s
, "tun_gbp_flags=%#"PRIx8
",", tnl
->gbp_flags
);
895 if (wc
->masks
.tunnel
.ip_tos
) {
896 ds_put_format(s
, "tun_tos=%"PRIx8
",", tnl
->ip_tos
);
898 if (wc
->masks
.tunnel
.ip_ttl
) {
899 ds_put_format(s
, "tun_ttl=%"PRIu8
",", tnl
->ip_ttl
);
901 if (wc
->masks
.tunnel
.flags
) {
902 format_flags(s
, flow_tun_flag_to_string
, tnl
->flags
, '|');
905 tun_metadata_match_format(s
, match
);
908 /* Appends a string representation of 'match' to 's'. If 'priority' is
909 * different from OFP_DEFAULT_PRIORITY, includes it in 's'. */
911 match_format(const struct match
*match
, struct ds
*s
, int priority
)
913 const struct flow_wildcards
*wc
= &match
->wc
;
914 size_t start_len
= s
->length
;
915 const struct flow
*f
= &match
->flow
;
916 bool skip_type
= false;
917 bool skip_proto
= false;
921 BUILD_ASSERT_DECL(FLOW_WC_SEQ
== 32);
923 if (priority
!= OFP_DEFAULT_PRIORITY
) {
924 ds_put_format(s
, "priority=%d,", priority
);
927 format_uint32_masked(s
, "pkt_mark", f
->pkt_mark
, wc
->masks
.pkt_mark
);
929 if (wc
->masks
.recirc_id
) {
930 format_uint32_masked(s
, "recirc_id", f
->recirc_id
,
931 wc
->masks
.recirc_id
);
934 if (wc
->masks
.dp_hash
) {
935 format_uint32_masked(s
, "dp_hash", f
->dp_hash
,
939 if (wc
->masks
.conj_id
) {
940 ds_put_format(s
, "conj_id=%"PRIu32
",", f
->conj_id
);
943 if (wc
->masks
.skb_priority
) {
944 ds_put_format(s
, "skb_priority=%#"PRIx32
",", f
->skb_priority
);
947 if (wc
->masks
.actset_output
) {
948 ds_put_cstr(s
, "actset_output=");
949 ofputil_format_port(f
->actset_output
, s
);
953 if (wc
->masks
.dl_type
) {
955 if (f
->dl_type
== htons(ETH_TYPE_IP
)) {
956 if (wc
->masks
.nw_proto
) {
958 if (f
->nw_proto
== IPPROTO_ICMP
) {
959 ds_put_cstr(s
, "icmp,");
960 } else if (f
->nw_proto
== IPPROTO_IGMP
) {
961 ds_put_cstr(s
, "igmp,");
962 } else if (f
->nw_proto
== IPPROTO_TCP
) {
963 ds_put_cstr(s
, "tcp,");
964 } else if (f
->nw_proto
== IPPROTO_UDP
) {
965 ds_put_cstr(s
, "udp,");
966 } else if (f
->nw_proto
== IPPROTO_SCTP
) {
967 ds_put_cstr(s
, "sctp,");
969 ds_put_cstr(s
, "ip,");
973 ds_put_cstr(s
, "ip,");
975 } else if (f
->dl_type
== htons(ETH_TYPE_IPV6
)) {
976 if (wc
->masks
.nw_proto
) {
978 if (f
->nw_proto
== IPPROTO_ICMPV6
) {
979 ds_put_cstr(s
, "icmp6,");
980 } else if (f
->nw_proto
== IPPROTO_TCP
) {
981 ds_put_cstr(s
, "tcp6,");
982 } else if (f
->nw_proto
== IPPROTO_UDP
) {
983 ds_put_cstr(s
, "udp6,");
984 } else if (f
->nw_proto
== IPPROTO_SCTP
) {
985 ds_put_cstr(s
, "sctp6,");
987 ds_put_cstr(s
, "ipv6,");
991 ds_put_cstr(s
, "ipv6,");
993 } else if (f
->dl_type
== htons(ETH_TYPE_ARP
)) {
994 ds_put_cstr(s
, "arp,");
995 } else if (f
->dl_type
== htons(ETH_TYPE_RARP
)) {
996 ds_put_cstr(s
, "rarp,");
997 } else if (f
->dl_type
== htons(ETH_TYPE_MPLS
)) {
998 ds_put_cstr(s
, "mpls,");
999 } else if (f
->dl_type
== htons(ETH_TYPE_MPLS_MCAST
)) {
1000 ds_put_cstr(s
, "mplsm,");
1005 for (i
= 0; i
< FLOW_N_REGS
; i
++) {
1006 #define REGNAME_LEN 20
1007 char regname
[REGNAME_LEN
];
1008 if (snprintf(regname
, REGNAME_LEN
, "reg%d", i
) >= REGNAME_LEN
) {
1009 strcpy(regname
, "reg?");
1011 format_uint32_masked(s
, regname
, f
->regs
[i
], wc
->masks
.regs
[i
]);
1014 format_flow_tunnel(s
, match
);
1016 format_be64_masked(s
, "metadata", f
->metadata
, wc
->masks
.metadata
);
1018 if (wc
->masks
.in_port
.ofp_port
) {
1019 ds_put_cstr(s
, "in_port=");
1020 ofputil_format_port(f
->in_port
.ofp_port
, s
);
1021 ds_put_char(s
, ',');
1023 if (wc
->masks
.vlan_tci
) {
1024 ovs_be16 vid_mask
= wc
->masks
.vlan_tci
& htons(VLAN_VID_MASK
);
1025 ovs_be16 pcp_mask
= wc
->masks
.vlan_tci
& htons(VLAN_PCP_MASK
);
1026 ovs_be16 cfi
= wc
->masks
.vlan_tci
& htons(VLAN_CFI
);
1028 if (cfi
&& f
->vlan_tci
& htons(VLAN_CFI
)
1029 && (!vid_mask
|| vid_mask
== htons(VLAN_VID_MASK
))
1030 && (!pcp_mask
|| pcp_mask
== htons(VLAN_PCP_MASK
))
1031 && (vid_mask
|| pcp_mask
)) {
1033 ds_put_format(s
, "dl_vlan=%"PRIu16
",",
1034 vlan_tci_to_vid(f
->vlan_tci
));
1037 ds_put_format(s
, "dl_vlan_pcp=%d,",
1038 vlan_tci_to_pcp(f
->vlan_tci
));
1040 } else if (wc
->masks
.vlan_tci
== htons(0xffff)) {
1041 ds_put_format(s
, "vlan_tci=0x%04"PRIx16
",", ntohs(f
->vlan_tci
));
1043 ds_put_format(s
, "vlan_tci=0x%04"PRIx16
"/0x%04"PRIx16
",",
1044 ntohs(f
->vlan_tci
), ntohs(wc
->masks
.vlan_tci
));
1047 format_eth_masked(s
, "dl_src", f
->dl_src
, wc
->masks
.dl_src
);
1048 format_eth_masked(s
, "dl_dst", f
->dl_dst
, wc
->masks
.dl_dst
);
1049 if (!skip_type
&& wc
->masks
.dl_type
) {
1050 ds_put_format(s
, "dl_type=0x%04"PRIx16
",", ntohs(f
->dl_type
));
1052 if (f
->dl_type
== htons(ETH_TYPE_IPV6
)) {
1053 format_ipv6_netmask(s
, "ipv6_src", &f
->ipv6_src
, &wc
->masks
.ipv6_src
);
1054 format_ipv6_netmask(s
, "ipv6_dst", &f
->ipv6_dst
, &wc
->masks
.ipv6_dst
);
1055 if (wc
->masks
.ipv6_label
) {
1056 if (wc
->masks
.ipv6_label
== OVS_BE32_MAX
) {
1057 ds_put_format(s
, "ipv6_label=0x%05"PRIx32
",",
1058 ntohl(f
->ipv6_label
));
1060 ds_put_format(s
, "ipv6_label=0x%05"PRIx32
"/0x%05"PRIx32
",",
1061 ntohl(f
->ipv6_label
),
1062 ntohl(wc
->masks
.ipv6_label
));
1065 } else if (f
->dl_type
== htons(ETH_TYPE_ARP
) ||
1066 f
->dl_type
== htons(ETH_TYPE_RARP
)) {
1067 format_ip_netmask(s
, "arp_spa", f
->nw_src
, wc
->masks
.nw_src
);
1068 format_ip_netmask(s
, "arp_tpa", f
->nw_dst
, wc
->masks
.nw_dst
);
1070 format_ip_netmask(s
, "nw_src", f
->nw_src
, wc
->masks
.nw_src
);
1071 format_ip_netmask(s
, "nw_dst", f
->nw_dst
, wc
->masks
.nw_dst
);
1073 if (!skip_proto
&& wc
->masks
.nw_proto
) {
1074 if (f
->dl_type
== htons(ETH_TYPE_ARP
) ||
1075 f
->dl_type
== htons(ETH_TYPE_RARP
)) {
1076 ds_put_format(s
, "arp_op=%"PRIu8
",", f
->nw_proto
);
1078 ds_put_format(s
, "nw_proto=%"PRIu8
",", f
->nw_proto
);
1081 if (f
->dl_type
== htons(ETH_TYPE_ARP
) ||
1082 f
->dl_type
== htons(ETH_TYPE_RARP
)) {
1083 format_eth_masked(s
, "arp_sha", f
->arp_sha
, wc
->masks
.arp_sha
);
1084 format_eth_masked(s
, "arp_tha", f
->arp_tha
, wc
->masks
.arp_tha
);
1086 if (wc
->masks
.nw_tos
& IP_DSCP_MASK
) {
1087 ds_put_format(s
, "nw_tos=%"PRIu8
",", f
->nw_tos
& IP_DSCP_MASK
);
1089 if (wc
->masks
.nw_tos
& IP_ECN_MASK
) {
1090 ds_put_format(s
, "nw_ecn=%"PRIu8
",", f
->nw_tos
& IP_ECN_MASK
);
1092 if (wc
->masks
.nw_ttl
) {
1093 ds_put_format(s
, "nw_ttl=%"PRIu8
",", f
->nw_ttl
);
1095 if (wc
->masks
.mpls_lse
[0] & htonl(MPLS_LABEL_MASK
)) {
1096 ds_put_format(s
, "mpls_label=%"PRIu32
",",
1097 mpls_lse_to_label(f
->mpls_lse
[0]));
1099 if (wc
->masks
.mpls_lse
[0] & htonl(MPLS_TC_MASK
)) {
1100 ds_put_format(s
, "mpls_tc=%"PRIu8
",",
1101 mpls_lse_to_tc(f
->mpls_lse
[0]));
1103 if (wc
->masks
.mpls_lse
[0] & htonl(MPLS_TTL_MASK
)) {
1104 ds_put_format(s
, "mpls_ttl=%"PRIu8
",",
1105 mpls_lse_to_ttl(f
->mpls_lse
[0]));
1107 if (wc
->masks
.mpls_lse
[0] & htonl(MPLS_BOS_MASK
)) {
1108 ds_put_format(s
, "mpls_bos=%"PRIu8
",",
1109 mpls_lse_to_bos(f
->mpls_lse
[0]));
1111 format_be32_masked(s
, "mpls_lse1", f
->mpls_lse
[1], wc
->masks
.mpls_lse
[1]);
1112 format_be32_masked(s
, "mpls_lse2", f
->mpls_lse
[2], wc
->masks
.mpls_lse
[2]);
1114 switch (wc
->masks
.nw_frag
) {
1115 case FLOW_NW_FRAG_ANY
| FLOW_NW_FRAG_LATER
:
1116 ds_put_format(s
, "nw_frag=%s,",
1117 f
->nw_frag
& FLOW_NW_FRAG_ANY
1118 ? (f
->nw_frag
& FLOW_NW_FRAG_LATER
? "later" : "first")
1119 : (f
->nw_frag
& FLOW_NW_FRAG_LATER
? "<error>" : "no"));
1122 case FLOW_NW_FRAG_ANY
:
1123 ds_put_format(s
, "nw_frag=%s,",
1124 f
->nw_frag
& FLOW_NW_FRAG_ANY
? "yes" : "no");
1127 case FLOW_NW_FRAG_LATER
:
1128 ds_put_format(s
, "nw_frag=%s,",
1129 f
->nw_frag
& FLOW_NW_FRAG_LATER
? "later" : "not_later");
1132 if (f
->dl_type
== htons(ETH_TYPE_IP
) &&
1133 f
->nw_proto
== IPPROTO_ICMP
) {
1134 format_be16_masked(s
, "icmp_type", f
->tp_src
, wc
->masks
.tp_src
);
1135 format_be16_masked(s
, "icmp_code", f
->tp_dst
, wc
->masks
.tp_dst
);
1136 } else if (f
->dl_type
== htons(ETH_TYPE_IP
) &&
1137 f
->nw_proto
== IPPROTO_IGMP
) {
1138 format_be16_masked(s
, "igmp_type", f
->tp_src
, wc
->masks
.tp_src
);
1139 format_be16_masked(s
, "igmp_code", f
->tp_dst
, wc
->masks
.tp_dst
);
1140 } else if (f
->dl_type
== htons(ETH_TYPE_IPV6
) &&
1141 f
->nw_proto
== IPPROTO_ICMPV6
) {
1142 format_be16_masked(s
, "icmp_type", f
->tp_src
, wc
->masks
.tp_src
);
1143 format_be16_masked(s
, "icmp_code", f
->tp_dst
, wc
->masks
.tp_dst
);
1144 format_ipv6_netmask(s
, "nd_target", &f
->nd_target
,
1145 &wc
->masks
.nd_target
);
1146 format_eth_masked(s
, "nd_sll", f
->arp_sha
, wc
->masks
.arp_sha
);
1147 format_eth_masked(s
, "nd_tll", f
->arp_tha
, wc
->masks
.arp_tha
);
1149 format_be16_masked(s
, "tp_src", f
->tp_src
, wc
->masks
.tp_src
);
1150 format_be16_masked(s
, "tp_dst", f
->tp_dst
, wc
->masks
.tp_dst
);
1152 if (is_ip_any(f
) && f
->nw_proto
== IPPROTO_TCP
&& wc
->masks
.tcp_flags
) {
1153 uint16_t mask
= TCP_FLAGS(wc
->masks
.tcp_flags
);
1155 if (mask
== TCP_FLAGS(OVS_BE16_MAX
)) {
1156 ds_put_cstr(s
, "tcp_flags=");
1158 format_flags(s
, packet_tcp_flag_to_string
, ntohs(f
->tcp_flags
),
1161 ds_put_cstr(s
, "0"); /* Zero flags. */
1164 format_flags_masked(s
, "tcp_flags", packet_tcp_flag_to_string
,
1165 ntohs(f
->tcp_flags
), mask
);
1169 if (s
->length
> start_len
) {
1174 /* Converts 'match' to a string and returns the string. If 'priority' is
1175 * different from OFP_DEFAULT_PRIORITY, includes it in the string. The caller
1176 * must free the string (with free()). */
1178 match_to_string(const struct match
*match
, int priority
)
1180 struct ds s
= DS_EMPTY_INITIALIZER
;
1181 match_format(match
, &s
, priority
);
1182 return ds_steal_cstr(&s
);
1186 match_print(const struct match
*match
)
1188 char *s
= match_to_string(match
, OFP_DEFAULT_PRIORITY
);
1193 /* Initializes 'dst' as a copy of 'src'. The caller must eventually free 'dst'
1194 * with minimatch_destroy(). */
1196 minimatch_init(struct minimatch
*dst
, const struct match
*src
)
1198 dst
->mask
= minimask_create(&src
->wc
);
1199 dst
->flow
= miniflow_create_with_minimask(&src
->flow
, dst
->mask
);
1202 /* Initializes 'dst' as a copy of 'src'. The caller must eventually free 'dst'
1203 * with minimatch_destroy(). */
1205 minimatch_clone(struct minimatch
*dst
, const struct minimatch
*src
)
1207 dst
->flow
= miniflow_clone(src
->flow
);
1208 dst
->mask
= minimask_clone(src
->mask
);
1211 /* Initializes 'dst' with the data in 'src', destroying 'src'. The caller must
1212 * eventually free 'dst' with minimatch_destroy(). */
1214 minimatch_move(struct minimatch
*dst
, struct minimatch
*src
)
1216 dst
->flow
= src
->flow
;
1217 dst
->mask
= src
->mask
;
1220 /* Frees any memory owned by 'match'. Does not free the storage in which
1221 * 'match' itself resides; the caller is responsible for that. */
1223 minimatch_destroy(struct minimatch
*match
)
1229 /* Initializes 'dst' as a copy of 'src'. */
1231 minimatch_expand(const struct minimatch
*src
, struct match
*dst
)
1233 miniflow_expand(src
->flow
, &dst
->flow
);
1234 minimask_expand(src
->mask
, &dst
->wc
);
1235 memset(&dst
->tun_md
, 0, sizeof dst
->tun_md
);
1238 /* Returns true if 'a' and 'b' match the same packets, false otherwise. */
1240 minimatch_equal(const struct minimatch
*a
, const struct minimatch
*b
)
1242 return minimask_equal(a
->mask
, b
->mask
)
1243 && miniflow_equal(a
->flow
, b
->flow
);
1246 /* Returns true if 'target' satisifies 'match', that is, if each bit for which
1247 * 'match' specifies a particular value has the correct value in 'target'.
1249 * This function is equivalent to miniflow_equal_flow_in_minimask(&match->flow,
1250 * target, &match->mask) but it is faster because of the invariant that
1251 * match->flow.map and match->mask.map are the same. */
1253 minimatch_matches_flow(const struct minimatch
*match
,
1254 const struct flow
*target
)
1256 const uint64_t *target_u64
= (const uint64_t *) target
;
1257 const uint64_t *flowp
= match
->flow
->values
;
1258 const uint64_t *maskp
= match
->mask
->masks
.values
;
1261 MAP_FOR_EACH_INDEX(idx
, match
->flow
->map
) {
1262 if ((*flowp
++ ^ target_u64
[idx
]) & *maskp
++) {
1270 /* Appends a string representation of 'match' to 's'. If 'priority' is
1271 * different from OFP_DEFAULT_PRIORITY, includes it in 's'. */
1273 minimatch_format(const struct minimatch
*match
, struct ds
*s
, int priority
)
1275 struct match megamatch
;
1277 minimatch_expand(match
, &megamatch
);
1278 match_format(&megamatch
, s
, priority
);
1281 /* Converts 'match' to a string and returns the string. If 'priority' is
1282 * different from OFP_DEFAULT_PRIORITY, includes it in the string. The caller
1283 * must free the string (with free()). */
1285 minimatch_to_string(const struct minimatch
*match
, int priority
)
1287 struct match megamatch
;
1289 minimatch_expand(match
, &megamatch
);
1290 return match_to_string(&megamatch
, priority
);