Support matching IPv6 flow label.
[sliver-openvswitch.git] / lib / classifier.c
index 8ffc96f..7d7a449 100644 (file)
@@ -347,7 +347,6 @@ cls_rule_set_icmp_type(struct cls_rule *rule, uint8_t icmp_type)
 {
     rule->wc.wildcards &= ~FWW_TP_SRC;
     rule->flow.tp_src = htons(icmp_type);
-
 }
 
 void
@@ -407,6 +406,13 @@ cls_rule_set_ipv6_dst_masked(struct cls_rule *rule, const struct in6_addr *dst,
     }
 }
 
+void
+cls_rule_set_ipv6_label(struct cls_rule *rule, ovs_be32 ipv6_label)
+{
+    rule->wc.wildcards &= ~FWW_IPV6_LABEL;
+    rule->flow.ipv6_label = ipv6_label;
+}
+
 void
 cls_rule_set_nd_target(struct cls_rule *rule, const struct in6_addr *target)
 {
@@ -469,7 +475,7 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
 
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 3);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 4);
 
     if (rule->priority != OFP_DEFAULT_PRIORITY) {
         ds_put_format(s, "priority=%d,", rule->priority);
@@ -590,6 +596,9 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
     if (f->dl_type == htons(ETH_TYPE_IPV6)) {
         format_ipv6_netmask(s, "ipv6_src", &f->ipv6_src, &wc->ipv6_src_mask);
         format_ipv6_netmask(s, "ipv6_dst", &f->ipv6_dst, &wc->ipv6_dst_mask);
+        if (!(w & FWW_IPV6_LABEL)) {
+            ds_put_format(s, "ipv6_label=0x%05"PRIx32",", ntohl(f->ipv6_label));
+        }
     } else {
         format_ip_netmask(s, "nw_src", f->nw_src, wc->nw_src_mask);
         format_ip_netmask(s, "nw_dst", f->nw_dst, wc->nw_dst_mask);
@@ -1160,7 +1169,7 @@ flow_equal_except(const struct flow *a, const struct flow *b,
     const flow_wildcards_t wc = wildcards->wildcards;
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 3);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 4);
 
     for (i = 0; i < FLOW_N_REGS; i++) {
         if ((a->regs[i] ^ b->regs[i]) & wildcards->reg_masks[i]) {
@@ -1190,6 +1199,7 @@ flow_equal_except(const struct flow *a, const struct flow *b,
             && !((a->tos_frag ^ b->tos_frag) & wildcards->tos_frag_mask)
             && (wc & FWW_ARP_SHA || eth_addr_equals(a->arp_sha, b->arp_sha))
             && (wc & FWW_ARP_THA || eth_addr_equals(a->arp_tha, b->arp_tha))
+            && (wc & FWW_IPV6_LABEL || a->ipv6_label == b->ipv6_label)
             && ipv6_equal_except(&a->ipv6_src, &b->ipv6_src,
                     &wildcards->ipv6_src_mask)
             && ipv6_equal_except(&a->ipv6_dst, &b->ipv6_dst,