From: Justin Pettit Date: Thu, 10 Nov 2011 01:10:27 +0000 (-0800) Subject: Prepend "nw_" to "frag" and "tos" elements. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eadef313296eac5c2fa99bc1d7a32e514a7989bf;p=openvswitch Prepend "nw_" to "frag" and "tos" elements. Most of the members in structures referring to network elements indicate the layer (e.g., "tl_", "nw_", "tp_"). The "frag" and "tos" members didn't, so this commit add them. --- diff --git a/lib/classifier.c b/lib/classifier.c index 842166cd..253a4d8b 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -320,17 +320,17 @@ cls_rule_set_nw_dst_masked(struct cls_rule *rule, ovs_be32 ip, ovs_be32 mask) void cls_rule_set_nw_dscp(struct cls_rule *rule, uint8_t nw_dscp) { - rule->wc.tos_mask |= IP_DSCP_MASK; - rule->flow.tos &= ~IP_DSCP_MASK; - rule->flow.tos |= nw_dscp & IP_DSCP_MASK; + rule->wc.nw_tos_mask |= IP_DSCP_MASK; + rule->flow.nw_tos &= ~IP_DSCP_MASK; + rule->flow.nw_tos |= nw_dscp & IP_DSCP_MASK; } void cls_rule_set_nw_ecn(struct cls_rule *rule, uint8_t nw_ecn) { - rule->wc.tos_mask |= IP_ECN_MASK; - rule->flow.tos &= ~IP_ECN_MASK; - rule->flow.tos |= nw_ecn & IP_ECN_MASK; + rule->wc.nw_tos_mask |= IP_ECN_MASK; + rule->flow.nw_tos &= ~IP_ECN_MASK; + rule->flow.nw_tos |= nw_ecn & IP_ECN_MASK; } void @@ -341,17 +341,18 @@ cls_rule_set_nw_ttl(struct cls_rule *rule, uint8_t nw_ttl) } void -cls_rule_set_frag(struct cls_rule *rule, uint8_t frag) +cls_rule_set_nw_frag(struct cls_rule *rule, uint8_t nw_frag) { - rule->wc.frag_mask |= FLOW_FRAG_MASK; - rule->flow.frag = frag; + rule->wc.nw_frag_mask |= FLOW_NW_FRAG_MASK; + rule->flow.nw_frag = nw_frag; } void -cls_rule_set_frag_masked(struct cls_rule *rule, uint8_t frag, uint8_t mask) +cls_rule_set_nw_frag_masked(struct cls_rule *rule, + uint8_t nw_frag, uint8_t mask) { - rule->flow.frag = frag & mask; - rule->wc.frag_mask = mask; + rule->flow.nw_frag = nw_frag & mask; + rule->wc.nw_frag_mask = mask; } void @@ -632,31 +633,31 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s) ETH_ADDR_ARGS(f->arp_tha)); } } - if (wc->tos_mask & IP_DSCP_MASK) { - ds_put_format(s, "nw_tos=%"PRIu8",", f->tos & IP_DSCP_MASK); + if (wc->nw_tos_mask & IP_DSCP_MASK) { + ds_put_format(s, "nw_tos=%"PRIu8",", f->nw_tos & IP_DSCP_MASK); } - if (wc->tos_mask & IP_ECN_MASK) { - ds_put_format(s, "nw_ecn=%"PRIu8",", f->tos & IP_ECN_MASK); + if (wc->nw_tos_mask & IP_ECN_MASK) { + ds_put_format(s, "nw_ecn=%"PRIu8",", f->nw_tos & IP_ECN_MASK); } if (!(w & FWW_NW_TTL)) { ds_put_format(s, "nw_ttl=%"PRIu8",", f->nw_ttl); } - switch (wc->frag_mask) { - case FLOW_FRAG_ANY | FLOW_FRAG_LATER: - ds_put_format(s, "frag=%s,", - f->frag & FLOW_FRAG_ANY - ? (f->frag & FLOW_FRAG_LATER ? "later" : "first") - : (f->frag & FLOW_FRAG_LATER ? "" : "no")); + switch (wc->nw_frag_mask) { + case FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER: + ds_put_format(s, "nw_frag=%s,", + f->nw_frag & FLOW_NW_FRAG_ANY + ? (f->nw_frag & FLOW_NW_FRAG_LATER ? "later" : "first") + : (f->nw_frag & FLOW_NW_FRAG_LATER ? "" : "no")); break; - case FLOW_FRAG_ANY: - ds_put_format(s, "frag=%s,", - f->frag & FLOW_FRAG_ANY ? "yes" : "no"); + case FLOW_NW_FRAG_ANY: + ds_put_format(s, "nw_frag=%s,", + f->nw_frag & FLOW_NW_FRAG_ANY ? "yes" : "no"); break; - case FLOW_FRAG_LATER: - ds_put_format(s, "frag=%s,", - f->frag & FLOW_FRAG_LATER ? "later" : "not_later"); + case FLOW_NW_FRAG_LATER: + ds_put_format(s, "nw_frag=%s,", + f->nw_frag & FLOW_NW_FRAG_LATER ? "later" : "not_later"); break; } if (f->nw_proto == IPPROTO_ICMP) { @@ -1215,8 +1216,8 @@ flow_equal_except(const struct flow *a, const struct flow *b, || !((a->dl_dst[0] ^ b->dl_dst[0]) & 0x01)) && (wc & FWW_NW_PROTO || a->nw_proto == b->nw_proto) && (wc & FWW_NW_TTL || a->nw_ttl == b->nw_ttl) - && !((a->tos ^ b->tos) & wildcards->tos_mask) - && !((a->frag ^ b->frag) & wildcards->frag_mask) + && !((a->nw_tos ^ b->nw_tos) & wildcards->nw_tos_mask) + && !((a->nw_frag ^ b->nw_frag) & wildcards->nw_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) diff --git a/lib/classifier.h b/lib/classifier.h index d6ab74e8..797afce7 100644 --- a/lib/classifier.h +++ b/lib/classifier.h @@ -119,8 +119,9 @@ bool cls_rule_set_nw_dst_masked(struct cls_rule *, ovs_be32 ip, ovs_be32 mask); void cls_rule_set_nw_dscp(struct cls_rule *, uint8_t); void cls_rule_set_nw_ecn(struct cls_rule *, uint8_t); void cls_rule_set_nw_ttl(struct cls_rule *, uint8_t); -void cls_rule_set_frag(struct cls_rule *, uint8_t frag); -void cls_rule_set_frag_masked(struct cls_rule *, uint8_t frag, uint8_t mask); +void cls_rule_set_nw_frag(struct cls_rule *, uint8_t nw_frag); +void cls_rule_set_nw_frag_masked(struct cls_rule *, + uint8_t nw_frag, uint8_t mask); void cls_rule_set_icmp_type(struct cls_rule *, uint8_t); void cls_rule_set_icmp_code(struct cls_rule *, uint8_t); void cls_rule_set_arp_sha(struct cls_rule *, const uint8_t[6]); diff --git a/lib/flow.c b/lib/flow.c index e1ce19b9..f928cbeb 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -148,7 +148,7 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow) flow->ipv6_dst = nh->ip6_dst; tc_flow = get_unaligned_be32(&nh->ip6_flow); - flow->tos = ntohl(tc_flow) >> 4; + flow->nw_tos = ntohl(tc_flow) >> 4; flow->ipv6_label = tc_flow & htonl(IPV6_LABEL_MASK); flow->nw_ttl = nh->ip6_hlim; flow->nw_proto = IPPROTO_NONE; @@ -203,9 +203,9 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow) } /* We only process the first fragment. */ - flow->frag = FLOW_FRAG_ANY; + flow->nw_frag = FLOW_NW_FRAG_ANY; if ((frag_hdr->ip6f_offlg & IP6F_OFF_MASK) != htons(0)) { - flow->frag |= FLOW_FRAG_LATER; + flow->nw_frag |= FLOW_NW_FRAG_LATER; nexthdr = IPPROTO_FRAGMENT; break; } @@ -370,11 +370,11 @@ flow_extract(struct ofpbuf *packet, uint32_t priority, ovs_be64 tun_id, flow->nw_dst = get_unaligned_be32(&nh->ip_dst); flow->nw_proto = nh->ip_proto; - flow->tos = nh->ip_tos; + flow->nw_tos = nh->ip_tos; if (IP_IS_FRAGMENT(nh->ip_frag_off)) { - flow->frag = FLOW_FRAG_ANY; + flow->nw_frag = FLOW_NW_FRAG_ANY; if (nh->ip_frag_off & htons(IP_FRAG_OFF_MASK)) { - flow->frag |= FLOW_FRAG_LATER; + flow->nw_frag |= FLOW_NW_FRAG_LATER; } } flow->nw_ttl = nh->ip_ttl; @@ -476,11 +476,11 @@ flow_zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards) if (wc & FWW_IPV6_LABEL) { flow->ipv6_label = htonl(0); } - flow->tos &= wildcards->tos_mask; + flow->nw_tos &= wildcards->nw_tos_mask; if (wc & FWW_NW_TTL) { flow->nw_ttl = 0; } - flow->frag &= wildcards->frag_mask; + flow->nw_frag &= wildcards->nw_frag_mask; if (wc & FWW_ARP_SHA) { memset(flow->arp_sha, 0, sizeof flow->arp_sha); } @@ -533,7 +533,7 @@ flow_format(struct ds *ds, const struct flow *flow) ds_put_format(ds, " label%#"PRIx32" proto%"PRIu8" tos%#"PRIx8 " ttl%"PRIu8" ipv6", ntohl(flow->ipv6_label), flow->nw_proto, - flow->tos, flow->nw_ttl); + flow->nw_tos, flow->nw_ttl); print_ipv6_addr(ds, &flow->ipv6_src); ds_put_cstr(ds, "->"); print_ipv6_addr(ds, &flow->ipv6_dst); @@ -541,13 +541,13 @@ flow_format(struct ds *ds, const struct flow *flow) } else { ds_put_format(ds, " proto%"PRIu8" tos%#"PRIx8" ttl%"PRIu8 " ip"IP_FMT"->"IP_FMT, - flow->nw_proto, flow->tos, flow->nw_ttl, + flow->nw_proto, flow->nw_tos, flow->nw_ttl, IP_ARGS(&flow->nw_src), IP_ARGS(&flow->nw_dst)); } - if (flow->frag) { + if (flow->nw_frag) { ds_put_format(ds, " frag(%s)", - flow->frag == FLOW_FRAG_ANY ? "first" - : flow->frag == (FLOW_FRAG_ANY | FLOW_FRAG_LATER) + flow->nw_frag == FLOW_NW_FRAG_ANY ? "first" + : flow->nw_frag == (FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER) ? "later" : ""); } if (flow->tp_src || flow->tp_dst) { @@ -585,8 +585,8 @@ flow_wildcards_init_catchall(struct flow_wildcards *wc) wc->ipv6_dst_mask = in6addr_any; memset(wc->reg_masks, 0, sizeof wc->reg_masks); wc->vlan_tci_mask = htons(0); - wc->tos_mask = 0; - wc->frag_mask = 0; + wc->nw_tos_mask = 0; + wc->nw_frag_mask = 0; memset(wc->zeros, 0, sizeof wc->zeros); } @@ -605,8 +605,8 @@ flow_wildcards_init_exact(struct flow_wildcards *wc) wc->ipv6_dst_mask = in6addr_exact; memset(wc->reg_masks, 0xff, sizeof wc->reg_masks); wc->vlan_tci_mask = htons(UINT16_MAX); - wc->tos_mask = UINT8_MAX; - wc->frag_mask = UINT8_MAX; + wc->nw_tos_mask = UINT8_MAX; + wc->nw_frag_mask = UINT8_MAX; memset(wc->zeros, 0, sizeof wc->zeros); } @@ -626,8 +626,8 @@ flow_wildcards_is_exact(const struct flow_wildcards *wc) || wc->vlan_tci_mask != htons(UINT16_MAX) || !ipv6_mask_is_exact(&wc->ipv6_src_mask) || !ipv6_mask_is_exact(&wc->ipv6_dst_mask) - || wc->tos_mask != UINT8_MAX - || wc->frag_mask != UINT8_MAX) { + || wc->nw_tos_mask != UINT8_MAX + || wc->nw_frag_mask != UINT8_MAX) { return false; } @@ -656,8 +656,8 @@ flow_wildcards_is_catchall(const struct flow_wildcards *wc) || wc->vlan_tci_mask != htons(0) || !ipv6_mask_is_any(&wc->ipv6_src_mask) || !ipv6_mask_is_any(&wc->ipv6_dst_mask) - || wc->tos_mask != 0 - || wc->frag_mask != 0) { + || wc->nw_tos_mask != 0 + || wc->nw_frag_mask != 0) { return false; } @@ -1019,19 +1019,19 @@ flow_compose(struct ofpbuf *b, const struct flow *flow) b->l3 = ip = ofpbuf_put_zeros(b, sizeof *ip); ip->ip_ihl_ver = IP_IHL_VER(5, 4); - ip->ip_tos = flow->tos; + ip->ip_tos = flow->nw_tos; ip->ip_proto = flow->nw_proto; ip->ip_src = flow->nw_src; ip->ip_dst = flow->nw_dst; - if (flow->frag & FLOW_FRAG_ANY) { + if (flow->nw_frag & FLOW_NW_FRAG_ANY) { ip->ip_frag_off |= htons(IP_MORE_FRAGMENTS); - if (flow->frag & FLOW_FRAG_LATER) { + if (flow->nw_frag & FLOW_NW_FRAG_LATER) { ip->ip_frag_off |= htons(100); } } - if (!(flow->frag & FLOW_FRAG_ANY) - || !(flow->frag & FLOW_FRAG_LATER)) { + if (!(flow->nw_frag & FLOW_NW_FRAG_ANY) + || !(flow->nw_frag & FLOW_NW_FRAG_LATER)) { if (flow->nw_proto == IPPROTO_TCP) { struct tcp_header *tcp; diff --git a/lib/flow.h b/lib/flow.h index e02cff67..443986e6 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -45,12 +45,12 @@ BUILD_ASSERT_DECL(FLOW_N_REGS <= NXM_NX_MAX_REGS); #define FLOW_DL_TYPE_NONE 0x5ff /* Fragment bits, used for IPv4 and IPv6, always zero for non-IP flows. */ -#define FLOW_FRAG_ANY (1 << 0) /* Set for any IP fragment. */ -#define FLOW_FRAG_LATER (1 << 1) /* Set for IP fragment with nonzero offset. */ -#define FLOW_FRAG_MASK (FLOW_FRAG_ANY | FLOW_FRAG_LATER) +#define FLOW_NW_FRAG_ANY (1 << 0) /* Set for any IP frag. */ +#define FLOW_NW_FRAG_LATER (1 << 1) /* Set for IP frag with nonzero offset. */ +#define FLOW_NW_FRAG_MASK (FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER) -BUILD_ASSERT_DECL(FLOW_FRAG_ANY == NX_IP_FRAG_ANY); -BUILD_ASSERT_DECL(FLOW_FRAG_LATER == NX_IP_FRAG_LATER); +BUILD_ASSERT_DECL(FLOW_NW_FRAG_ANY == NX_IP_FRAG_ANY); +BUILD_ASSERT_DECL(FLOW_NW_FRAG_LATER == NX_IP_FRAG_LATER); struct flow { ovs_be64 tun_id; /* Encapsulating tunnel ID. */ @@ -70,11 +70,11 @@ struct flow { uint8_t dl_src[6]; /* Ethernet source address. */ uint8_t dl_dst[6]; /* Ethernet destination address. */ uint8_t nw_proto; /* IP protocol or low 8 bits of ARP opcode. */ - uint8_t tos; /* IP ToS. */ + uint8_t nw_tos; /* IP ToS (including DSCP and ECN). */ uint8_t arp_sha[6]; /* ARP/ND source hardware address. */ uint8_t arp_tha[6]; /* ARP/ND target hardware address. */ uint8_t nw_ttl; /* IP TTL/Hop Limit. */ - uint8_t frag; /* FLOW_FRAG_* flags. */ + uint8_t nw_frag; /* FLOW_FRAG_* flags. */ uint8_t reserved[6]; /* Reserved for 64-bit packing. */ }; @@ -82,8 +82,8 @@ struct flow { * flow", followed by FLOW_PAD_SIZE bytes of padding. */ #define FLOW_SIG_SIZE (110 + FLOW_N_REGS * 4) #define FLOW_PAD_SIZE 6 -BUILD_ASSERT_DECL(offsetof(struct flow, frag) == FLOW_SIG_SIZE - 1); -BUILD_ASSERT_DECL(sizeof(((struct flow *)0)->frag) == 1); +BUILD_ASSERT_DECL(offsetof(struct flow, nw_frag) == FLOW_SIG_SIZE - 1); +BUILD_ASSERT_DECL(sizeof(((struct flow *)0)->nw_frag) == 1); BUILD_ASSERT_DECL(sizeof(struct flow) == FLOW_SIG_SIZE + FLOW_PAD_SIZE); /* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */ @@ -163,8 +163,8 @@ struct flow_wildcards { struct in6_addr ipv6_src_mask; /* 1-bit in each signficant ipv6_src bit. */ struct in6_addr ipv6_dst_mask; /* 1-bit in each signficant ipv6_dst bit. */ ovs_be16 vlan_tci_mask; /* 1-bit in each significant vlan_tci bit. */ - uint8_t tos_mask; /* 1-bit in each significant tos bit. */ - uint8_t frag_mask; /* 1-bit in each significant frag bit. */ + uint8_t nw_tos_mask; /* 1-bit in each significant nw_tos bit. */ + uint8_t nw_frag_mask; /* 1-bit in each significant nw_frag bit. */ uint8_t zeros[4]; /* Padding field set to zero. */ }; diff --git a/lib/meta-flow.c b/lib/meta-flow.c index 2df1cb48..5569e15a 100644 --- a/lib/meta-flow.c +++ b/lib/meta-flow.c @@ -438,11 +438,11 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc) return ipv6_mask_is_any(&wc->ipv6_dst_mask); case MFF_IP_DSCP: - return !(wc->tos_mask & IP_DSCP_MASK); + return !(wc->nw_tos_mask & IP_DSCP_MASK); case MFF_IP_ECN: - return !(wc->tos_mask & IP_ECN_MASK); + return !(wc->nw_tos_mask & IP_ECN_MASK); case MFF_IP_FRAG: - return !(wc->frag_mask & FLOW_FRAG_MASK); + return !(wc->nw_frag_mask & FLOW_NW_FRAG_MASK); case MFF_ARP_SPA: return !wc->nw_src_mask; @@ -543,13 +543,13 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc, break; case MFF_IP_DSCP: - mask->u8 = wc->tos_mask & IP_DSCP_MASK; + mask->u8 = wc->nw_tos_mask & IP_DSCP_MASK; break; case MFF_IP_ECN: - mask->u8 = wc->tos_mask & IP_ECN_MASK; + mask->u8 = wc->nw_tos_mask & IP_ECN_MASK; break; case MFF_IP_FRAG: - mask->u8 = wc->frag_mask & FLOW_FRAG_MASK; + mask->u8 = wc->nw_frag_mask & FLOW_NW_FRAG_MASK; break; case MFF_ARP_SPA: @@ -719,7 +719,7 @@ mf_is_value_valid(const struct mf_field *mf, const union mf_value *value) case MFF_IP_ECN: return !(value->u8 & ~IP_ECN_MASK); case MFF_IP_FRAG: - return !(value->u8 & ~FLOW_FRAG_MASK); + return !(value->u8 & ~FLOW_NW_FRAG_MASK); case MFF_ARP_OP: return !(value->be16 & htons(0xff00)); @@ -824,11 +824,11 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow, break; case MFF_IP_DSCP: - value->u8 = flow->tos & IP_DSCP_MASK; + value->u8 = flow->nw_tos & IP_DSCP_MASK; break; case MFF_IP_ECN: - value->u8 = flow->tos & IP_ECN_MASK; + value->u8 = flow->nw_tos & IP_ECN_MASK; break; case MFF_IP_TTL: @@ -836,7 +836,7 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow, break; case MFF_IP_FRAG: - value->u8 = flow->frag; + value->u8 = flow->nw_frag; break; case MFF_ARP_OP: @@ -995,7 +995,7 @@ mf_set_value(const struct mf_field *mf, break; case MFF_IP_FRAG: - cls_rule_set_frag(rule, value->u8); + cls_rule_set_nw_frag(rule, value->u8); break; case MFF_ARP_OP: @@ -1158,13 +1158,13 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule *rule) break; case MFF_IP_DSCP: - rule->wc.tos_mask |= IP_DSCP_MASK; - rule->flow.tos &= ~IP_DSCP_MASK; + rule->wc.nw_tos_mask |= IP_DSCP_MASK; + rule->flow.nw_tos &= ~IP_DSCP_MASK; break; case MFF_IP_ECN: - rule->wc.tos_mask |= IP_ECN_MASK; - rule->flow.tos &= ~IP_ECN_MASK; + rule->wc.nw_tos_mask |= IP_ECN_MASK; + rule->flow.nw_tos &= ~IP_ECN_MASK; break; case MFF_IP_TTL: @@ -1173,8 +1173,8 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule *rule) break; case MFF_IP_FRAG: - rule->wc.frag_mask |= FLOW_FRAG_MASK; - rule->flow.frag &= ~FLOW_FRAG_MASK; + rule->wc.nw_frag_mask |= FLOW_NW_FRAG_MASK; + rule->flow.nw_frag &= ~FLOW_NW_FRAG_MASK; break; case MFF_ARP_OP: @@ -1321,7 +1321,7 @@ mf_set(const struct mf_field *mf, break; case MFF_IP_FRAG: - cls_rule_set_frag_masked(rule, value->u8, mask->u8); + cls_rule_set_nw_frag_masked(rule, value->u8, mask->u8); break; case MFF_ARP_SPA: @@ -1486,7 +1486,7 @@ mf_random_value(const struct mf_field *mf, union mf_value *value) break; case MFF_IP_FRAG: - value->u8 &= FLOW_FRAG_MASK; + value->u8 &= FLOW_NW_FRAG_MASK; break; case MFF_ARP_OP: @@ -1659,8 +1659,8 @@ struct frag_handling { }; static const struct frag_handling all_frags[] = { -#define A FLOW_FRAG_ANY -#define L FLOW_FRAG_LATER +#define A FLOW_NW_FRAG_ANY +#define L FLOW_NW_FRAG_LATER /* name mask value */ { "no", A|L, 0 }, @@ -1685,7 +1685,7 @@ mf_from_frag_string(const char *s, uint8_t *valuep, uint8_t *maskp) if (!strcasecmp(s, h->name)) { /* We force the upper bits of the mask on to make mf_parse_value() * happy (otherwise it will never think it's an exact match.) */ - *maskp = h->mask | ~FLOW_FRAG_MASK; + *maskp = h->mask | ~FLOW_NW_FRAG_MASK; *valuep = h->value; return NULL; } @@ -1793,7 +1793,7 @@ mf_format_frag_string(const uint8_t *valuep, const uint8_t *maskp, uint8_t mask = *maskp; value &= mask; - mask &= FLOW_FRAG_MASK; + mask &= FLOW_NW_FRAG_MASK; for (h = all_frags; h < &all_frags[ARRAY_SIZE(all_frags)]; h++) { if (value == h->value && mask == h->mask) { diff --git a/lib/nx-match.c b/lib/nx-match.c index 9919e1f1..b1551795 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -424,19 +424,20 @@ nxm_put_ipv6(struct ofpbuf *b, uint32_t header, static void nxm_put_frag(struct ofpbuf *b, const struct cls_rule *cr) { - uint8_t frag = cr->flow.frag; - uint8_t frag_mask = cr->wc.frag_mask; + uint8_t nw_frag = cr->flow.nw_frag; + uint8_t nw_frag_mask = cr->wc.nw_frag_mask; - switch (frag_mask) { + switch (nw_frag_mask) { case 0: break; - case FLOW_FRAG_MASK: - nxm_put_8(b, NXM_NX_IP_FRAG, frag); + case FLOW_NW_FRAG_MASK: + nxm_put_8(b, NXM_NX_IP_FRAG, nw_frag); break; default: - nxm_put_8m(b, NXM_NX_IP_FRAG, frag, frag_mask & FLOW_FRAG_MASK); + nxm_put_8m(b, NXM_NX_IP_FRAG, nw_frag, + nw_frag_mask & FLOW_NW_FRAG_MASK); break; } } @@ -488,12 +489,12 @@ nx_put_match(struct ofpbuf *b, const struct cls_rule *cr) nxm_put_32m(b, NXM_OF_IP_DST, flow->nw_dst, cr->wc.nw_dst_mask); nxm_put_frag(b, cr); - if (cr->wc.tos_mask & IP_DSCP_MASK) { - nxm_put_8(b, NXM_OF_IP_TOS, flow->tos & IP_DSCP_MASK); + if (cr->wc.nw_tos_mask & IP_DSCP_MASK) { + nxm_put_8(b, NXM_OF_IP_TOS, flow->nw_tos & IP_DSCP_MASK); } - if (cr->wc.tos_mask & IP_ECN_MASK) { - nxm_put_8(b, NXM_NX_IP_ECN, flow->tos & IP_ECN_MASK); + if (cr->wc.nw_tos_mask & IP_ECN_MASK) { + nxm_put_8(b, NXM_NX_IP_ECN, flow->nw_tos & IP_ECN_MASK); } if (!(wc & FWW_NW_TTL)) { @@ -546,12 +547,12 @@ nx_put_match(struct ofpbuf *b, const struct cls_rule *cr) nxm_put_32(b, NXM_NX_IPV6_LABEL, flow->ipv6_label); } - if (cr->wc.tos_mask & IP_DSCP_MASK) { - nxm_put_8(b, NXM_OF_IP_TOS, flow->tos & IP_DSCP_MASK); + if (cr->wc.nw_tos_mask & IP_DSCP_MASK) { + nxm_put_8(b, NXM_OF_IP_TOS, flow->nw_tos & IP_DSCP_MASK); } - if (cr->wc.tos_mask & IP_ECN_MASK) { - nxm_put_8(b, NXM_NX_IP_ECN, flow->tos & IP_ECN_MASK); + if (cr->wc.nw_tos_mask & IP_ECN_MASK) { + nxm_put_8(b, NXM_NX_IP_ECN, flow->nw_tos & IP_ECN_MASK); } if (!(wc & FWW_NW_TTL)) { @@ -1061,16 +1062,16 @@ nxm_read_field(const struct nxm_field *src, const struct flow *flow) return ntohs(flow->vlan_tci); case NFI_NXM_OF_IP_TOS: - return flow->tos & IP_DSCP_MASK; + return flow->nw_tos & IP_DSCP_MASK; case NFI_NXM_NX_IP_ECN: - return flow->tos & IP_ECN_MASK; + return flow->nw_tos & IP_ECN_MASK; case NFI_NXM_NX_IP_TTL: return flow->nw_ttl; case NFI_NXM_NX_IP_FRAG: - return flow->frag; + return flow->nw_frag; case NFI_NXM_OF_IP_PROTO: case NFI_NXM_OF_ARP_OP: @@ -1220,13 +1221,13 @@ nxm_write_field(const struct nxm_field *dst, struct flow *flow, #endif case NFI_NXM_OF_IP_TOS: - flow->tos &= ~IP_DSCP_MASK; - flow->tos |= new_value & IP_DSCP_MASK; + flow->nw_tos &= ~IP_DSCP_MASK; + flow->nw_tos |= new_value & IP_DSCP_MASK; break; case NFI_NXM_NX_IP_ECN: - flow->tos &= ~IP_ECN_MASK; - flow->tos |= new_value & IP_ECN_MASK; + flow->nw_tos &= ~IP_ECN_MASK; + flow->nw_tos |= new_value & IP_ECN_MASK; break; case NFI_NXM_NX_IP_TTL: @@ -1234,7 +1235,7 @@ nxm_write_field(const struct nxm_field *dst, struct flow *flow, break; case NFI_NXM_NX_IP_FRAG: - flow->frag = new_value; + flow->nw_frag = new_value; break; case NFI_NXM_OF_IP_SRC: diff --git a/lib/odp-util.c b/lib/odp-util.c index bda5861b..126be20a 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -827,8 +827,8 @@ odp_flow_key_from_string(const char *s, struct ofpbuf *key) static uint8_t ovs_to_odp_frag(uint8_t ovs_frag) { - return (ovs_frag & FLOW_FRAG_LATER ? OVS_FRAG_TYPE_LATER - : ovs_frag & FLOW_FRAG_ANY ? OVS_FRAG_TYPE_FIRST + return (ovs_frag & FLOW_NW_FRAG_LATER ? OVS_FRAG_TYPE_LATER + : ovs_frag & FLOW_NW_FRAG_ANY ? OVS_FRAG_TYPE_FIRST : OVS_FRAG_TYPE_NONE); } @@ -879,9 +879,9 @@ odp_flow_key_from_flow(struct ofpbuf *buf, const struct flow *flow) ipv4_key->ipv4_src = flow->nw_src; ipv4_key->ipv4_dst = flow->nw_dst; ipv4_key->ipv4_proto = flow->nw_proto; - ipv4_key->ipv4_tos = flow->tos; + ipv4_key->ipv4_tos = flow->nw_tos; ipv4_key->ipv4_ttl = flow->nw_ttl; - ipv4_key->ipv4_frag = ovs_to_odp_frag(flow->frag); + ipv4_key->ipv4_frag = ovs_to_odp_frag(flow->nw_frag); } else if (flow->dl_type == htons(ETH_TYPE_IPV6)) { struct ovs_key_ipv6 *ipv6_key; @@ -891,9 +891,9 @@ odp_flow_key_from_flow(struct ofpbuf *buf, const struct flow *flow) memcpy(ipv6_key->ipv6_dst, &flow->ipv6_dst, sizeof ipv6_key->ipv6_dst); ipv6_key->ipv6_label = flow->ipv6_label; ipv6_key->ipv6_proto = flow->nw_proto; - ipv6_key->ipv6_tclass = flow->tos; + ipv6_key->ipv6_tclass = flow->nw_tos; ipv6_key->ipv6_hlimit = flow->nw_ttl; - ipv6_key->ipv6_frag = ovs_to_odp_frag(flow->frag); + ipv6_key->ipv6_frag = ovs_to_odp_frag(flow->nw_frag); } else if (flow->dl_type == htons(ETH_TYPE_ARP)) { struct ovs_key_arp *arp_key; @@ -909,7 +909,7 @@ odp_flow_key_from_flow(struct ofpbuf *buf, const struct flow *flow) if ((flow->dl_type == htons(ETH_TYPE_IP) || flow->dl_type == htons(ETH_TYPE_IPV6)) - && !(flow->frag & FLOW_FRAG_LATER)) { + && !(flow->nw_frag & FLOW_NW_FRAG_LATER)) { if (flow->nw_proto == IPPROTO_TCP) { struct ovs_key_tcp *tcp_key; @@ -965,9 +965,9 @@ odp_to_ovs_frag(uint8_t odp_frag, struct flow *flow) } if (odp_frag != OVS_FRAG_TYPE_NONE) { - flow->frag |= FLOW_FRAG_ANY; + flow->nw_frag |= FLOW_NW_FRAG_ANY; if (odp_frag == OVS_FRAG_TYPE_LATER) { - flow->frag |= FLOW_FRAG_LATER; + flow->nw_frag |= FLOW_NW_FRAG_LATER; } } return true; @@ -1064,7 +1064,7 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len, flow->nw_src = ipv4_key->ipv4_src; flow->nw_dst = ipv4_key->ipv4_dst; flow->nw_proto = ipv4_key->ipv4_proto; - flow->tos = ipv4_key->ipv4_tos; + flow->nw_tos = ipv4_key->ipv4_tos; flow->nw_ttl = ipv4_key->ipv4_ttl; if (!odp_to_ovs_frag(ipv4_key->ipv4_frag, flow)) { return EINVAL; @@ -1080,7 +1080,7 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len, memcpy(&flow->ipv6_dst, ipv6_key->ipv6_dst, sizeof flow->ipv6_dst); flow->ipv6_label = ipv6_key->ipv6_label; flow->nw_proto = ipv6_key->ipv6_proto; - flow->tos = ipv6_key->ipv6_tclass; + flow->nw_tos = ipv6_key->ipv6_tclass; flow->nw_ttl = ipv6_key->ipv6_hlimit; if (!odp_to_ovs_frag(ipv6_key->ipv6_frag, flow)) { return EINVAL; @@ -1183,7 +1183,7 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len, return 0; case OVS_KEY_ATTR_IPV4: - if (flow->frag & FLOW_FRAG_LATER) { + if (flow->nw_frag & FLOW_NW_FRAG_LATER) { return 0; } if (flow->nw_proto == IPPROTO_TCP @@ -1194,7 +1194,7 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len, return 0; case OVS_KEY_ATTR_IPV6: - if (flow->frag & FLOW_FRAG_LATER) { + if (flow->nw_frag & FLOW_NW_FRAG_LATER) { return 0; } if (flow->nw_proto == IPPROTO_TCP @@ -1207,7 +1207,7 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len, case OVS_KEY_ATTR_ICMPV6: if (flow->tp_src == htons(ND_NEIGHBOR_SOLICIT) || flow->tp_src == htons(ND_NEIGHBOR_ADVERT) - || flow->frag & FLOW_FRAG_LATER) { + || flow->nw_frag & FLOW_NW_FRAG_LATER) { return EINVAL; } return 0; @@ -1216,7 +1216,7 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len, case OVS_KEY_ATTR_UDP: case OVS_KEY_ATTR_ICMP: case OVS_KEY_ATTR_ND: - if (flow->frag & FLOW_FRAG_LATER) { + if (flow->nw_frag & FLOW_NW_FRAG_LATER) { return EINVAL; } return 0; diff --git a/lib/ofp-util.c b/lib/ofp-util.c index fac21af7..923df057 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -112,7 +112,7 @@ ofputil_wildcard_from_openflow(uint32_t ofpfw, struct flow_wildcards *wc) | FWW_ND_TARGET | FWW_IPV6_LABEL); if (!(ofpfw & OFPFW_NW_TOS)) { - wc->tos_mask |= IP_DSCP_MASK; + wc->nw_tos_mask |= IP_DSCP_MASK; } wc->nw_src_mask = ofputil_wcbits_to_netmask(ofpfw >> OFPFW_NW_SRC_SHIFT); @@ -155,7 +155,7 @@ ofputil_cls_rule_from_match(const struct ofp_match *match, rule->flow.tp_dst = match->tp_dst; memcpy(rule->flow.dl_src, match->dl_src, ETH_ADDR_LEN); memcpy(rule->flow.dl_dst, match->dl_dst, ETH_ADDR_LEN); - rule->flow.tos = match->nw_tos & IP_DSCP_MASK; + rule->flow.nw_tos = match->nw_tos & IP_DSCP_MASK; rule->flow.nw_proto = match->nw_proto; /* Translate VLANs. */ @@ -194,7 +194,7 @@ ofputil_cls_rule_to_match(const struct cls_rule *rule, struct ofp_match *match) ofpfw = (OVS_FORCE uint32_t) (wc->wildcards & WC_INVARIANTS); ofpfw |= ofputil_netmask_to_wcbits(wc->nw_src_mask) << OFPFW_NW_SRC_SHIFT; ofpfw |= ofputil_netmask_to_wcbits(wc->nw_dst_mask) << OFPFW_NW_DST_SHIFT; - if (!(wc->tos_mask & IP_DSCP_MASK)) { + if (!(wc->nw_tos_mask & IP_DSCP_MASK)) { ofpfw |= OFPFW_NW_TOS; } @@ -228,7 +228,7 @@ ofputil_cls_rule_to_match(const struct cls_rule *rule, struct ofp_match *match) match->dl_type = ofputil_dl_type_to_openflow(rule->flow.dl_type); match->nw_src = rule->flow.nw_src; match->nw_dst = rule->flow.nw_dst; - match->nw_tos = rule->flow.tos & IP_DSCP_MASK; + match->nw_tos = rule->flow.nw_tos & IP_DSCP_MASK; match->nw_proto = rule->flow.nw_proto; match->tp_src = rule->flow.tp_src; match->tp_dst = rule->flow.tp_dst; @@ -888,7 +888,7 @@ ofputil_min_flow_format(const struct cls_rule *rule) } /* Only NXM supports matching fragments. */ - if (wc->frag_mask) { + if (wc->nw_frag_mask) { return NXFF_NXM; } @@ -898,7 +898,7 @@ ofputil_min_flow_format(const struct cls_rule *rule) } /* Only NXM supports matching IP ECN bits. */ - if (wc->tos_mask & IP_ECN_MASK) { + if (wc->nw_tos_mask & IP_ECN_MASK) { return NXFF_NXM; } @@ -2573,8 +2573,8 @@ ofputil_normalize_rule(struct cls_rule *rule, enum nx_flow_format flow_format) wc.wildcards |= FWW_NW_PROTO; } if (!(may_match & MAY_IPVx)) { - wc.tos_mask = 0; - wc.frag_mask = 0; + wc.nw_tos_mask = 0; + wc.nw_frag_mask = 0; wc.wildcards |= FWW_NW_TTL; } if (!(may_match & MAY_ARP_SHA)) { diff --git a/ofproto/netflow.c b/ofproto/netflow.c index 89ccb3b2..bf2e6287 100644 --- a/ofproto/netflow.c +++ b/ofproto/netflow.c @@ -160,7 +160,7 @@ gen_netflow_rec(struct netflow *nf, struct netflow_flow *nf_flow, } nf_rec->tcp_flags = nf_flow->tcp_flags; nf_rec->ip_proto = expired->flow.nw_proto; - nf_rec->ip_tos = expired->flow.tos & IP_DSCP_MASK; + nf_rec->ip_tos = expired->flow.nw_tos & IP_DSCP_MASK; /* NetFlow messages are limited to 30 records. */ if (ntohs(nf_hdr->count) >= 30) { diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index f6eee59a..b2961546 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -3248,7 +3248,7 @@ rule_dpif_lookup(struct ofproto_dpif *ofproto, const struct flow *flow, } cls = &ofproto->up.tables[table_id]; - if (flow->frag & FLOW_FRAG_ANY + if (flow->nw_frag & FLOW_NW_FRAG_ANY && ofproto->up.frag_handling == OFPC_FRAG_NORMAL) { /* For OFPC_NORMAL frag_handling, we must pretend that transport ports * are unavailable. */ @@ -3670,20 +3670,20 @@ commit_set_nw_action(const struct flow *flow, struct flow *base, if (base->nw_src == flow->nw_src && base->nw_dst == flow->nw_dst && - base->tos == flow->tos && + base->nw_tos == flow->nw_tos && base->nw_ttl == flow->nw_ttl && - base->frag == flow->frag) { + base->nw_frag == flow->nw_frag) { return; } ipv4_key.ipv4_src = base->nw_src = flow->nw_src; ipv4_key.ipv4_dst = base->nw_dst = flow->nw_dst; ipv4_key.ipv4_proto = base->nw_proto; - ipv4_key.ipv4_tos = flow->tos; + ipv4_key.ipv4_tos = flow->nw_tos; ipv4_key.ipv4_ttl = flow->nw_ttl; - ipv4_key.ipv4_frag = (base->frag == 0 ? OVS_FRAG_TYPE_NONE - : base->frag == FLOW_FRAG_ANY ? OVS_FRAG_TYPE_FIRST - : OVS_FRAG_TYPE_LATER); + ipv4_key.ipv4_frag = (base->nw_frag == 0 ? OVS_FRAG_TYPE_NONE + : base->nw_frag == FLOW_NW_FRAG_ANY + ? OVS_FRAG_TYPE_FIRST : OVS_FRAG_TYPE_LATER); commit_action__(odp_actions, OVS_ACTION_ATTR_SET, OVS_KEY_ATTR_IPV4, &ipv4_key, sizeof(ipv4_key)); @@ -4167,8 +4167,8 @@ do_xlate_actions(const union ofp_action *in, size_t n_in, break; case OFPUTIL_OFPAT_SET_NW_TOS: - ctx->flow.tos &= ~IP_DSCP_MASK; - ctx->flow.tos |= ia->nw_tos.nw_tos & IP_DSCP_MASK; + ctx->flow.nw_tos &= ~IP_DSCP_MASK; + ctx->flow.nw_tos |= ia->nw_tos.nw_tos & IP_DSCP_MASK; break; case OFPUTIL_OFPAT_SET_TP_SRC: @@ -4309,7 +4309,7 @@ xlate_actions(struct action_xlate_ctx *ctx, ctx->table_id = 0; ctx->exit = false; - if (ctx->flow.frag & FLOW_FRAG_ANY) { + if (ctx->flow.nw_frag & FLOW_NW_FRAG_ANY) { switch (ctx->ofproto->up.frag_handling) { case OFPC_FRAG_NORMAL: /* We must pretend that transport ports are unavailable. */ diff --git a/tests/test-classifier.c b/tests/test-classifier.c index d66654bc..d167574d 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -55,7 +55,7 @@ CLS_FIELD(FWW_DL_SRC, dl_src, DL_SRC) \ CLS_FIELD(FWW_DL_DST | FWW_ETH_MCAST, dl_dst, DL_DST) \ CLS_FIELD(FWW_NW_PROTO, nw_proto, NW_PROTO) \ - CLS_FIELD(0, tos, TOS) + CLS_FIELD(0, nw_tos, NW_TOS) /* Field indexes. * @@ -203,9 +203,9 @@ match(const struct cls_rule *wild, const struct flow *fixed) & wild->wc.vlan_tci_mask); } else if (f_idx == CLS_F_IDX_TUN_ID) { eq = !((fixed->tun_id ^ wild->flow.tun_id) & wild->wc.tun_id_mask); - } else if (f_idx == CLS_F_IDX_TOS) { - eq = !((fixed->tos ^ wild->flow.tos) - & wild->wc.tos_mask); + } else if (f_idx == CLS_F_IDX_NW_TOS) { + eq = !((fixed->nw_tos ^ wild->flow.nw_tos) + & wild->wc.nw_tos_mask); } else { NOT_REACHED(); } @@ -266,7 +266,7 @@ static uint8_t dl_src_values[][6] = { { 0x00, 0x02, 0xe3, 0x0f, 0x80, 0xa4 }, static uint8_t dl_dst_values[][6] = { { 0x4a, 0x27, 0x71, 0xae, 0x64, 0xc1 }, { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; static uint8_t nw_proto_values[] = { IPPROTO_TCP, IPPROTO_ICMP }; -static uint8_t tos_values[] = { 48, 0 }; +static uint8_t nw_tos_values[] = { 48, 0 }; static void *values[CLS_N_FIELDS][2]; @@ -300,8 +300,8 @@ init_values(void) values[CLS_F_IDX_NW_PROTO][0] = &nw_proto_values[0]; values[CLS_F_IDX_NW_PROTO][1] = &nw_proto_values[1]; - values[CLS_F_IDX_TOS][0] = &tos_values[0]; - values[CLS_F_IDX_TOS][1] = &tos_values[1]; + values[CLS_F_IDX_NW_TOS][0] = &nw_tos_values[0]; + values[CLS_F_IDX_NW_TOS][1] = &nw_tos_values[1]; values[CLS_F_IDX_TP_SRC][0] = &tp_src_values[0]; values[CLS_F_IDX_TP_SRC][1] = &tp_src_values[1]; @@ -321,7 +321,7 @@ init_values(void) #define N_DL_SRC_VALUES ARRAY_SIZE(dl_src_values) #define N_DL_DST_VALUES ARRAY_SIZE(dl_dst_values) #define N_NW_PROTO_VALUES ARRAY_SIZE(nw_proto_values) -#define N_TOS_VALUES ARRAY_SIZE(tos_values) +#define N_NW_TOS_VALUES ARRAY_SIZE(nw_tos_values) #define N_FLOW_VALUES (N_NW_SRC_VALUES * \ N_NW_DST_VALUES * \ @@ -334,7 +334,7 @@ init_values(void) N_DL_SRC_VALUES * \ N_DL_DST_VALUES * \ N_NW_PROTO_VALUES * \ - N_TOS_VALUES) + N_NW_TOS_VALUES) static unsigned int get_value(unsigned int *x, unsigned n_values) @@ -370,7 +370,7 @@ compare_classifiers(struct classifier *cls, struct tcls *tcls) memcpy(flow.dl_dst, dl_dst_values[get_value(&x, N_DL_DST_VALUES)], ETH_ADDR_LEN); flow.nw_proto = nw_proto_values[get_value(&x, N_NW_PROTO_VALUES)]; - flow.tos = tos_values[get_value(&x, N_TOS_VALUES)]; + flow.nw_tos = nw_tos_values[get_value(&x, N_NW_TOS_VALUES)]; cr0 = classifier_lookup(cls, &flow); cr1 = tcls_lookup(tcls, &flow); @@ -468,8 +468,8 @@ make_rule(int wc_fields, unsigned int priority, int value_pat) rule->cls_rule.wc.vlan_tci_mask = htons(UINT16_MAX); } else if (f_idx == CLS_F_IDX_TUN_ID) { rule->cls_rule.wc.tun_id_mask = htonll(UINT64_MAX); - } else if (f_idx == CLS_F_IDX_TOS) { - rule->cls_rule.wc.tos_mask = UINT8_MAX; + } else if (f_idx == CLS_F_IDX_NW_TOS) { + rule->cls_rule.wc.nw_tos_mask = UINT8_MAX; } else { NOT_REACHED(); }