Skip to content

Commit eadef31

Browse files
author
Justin Pettit
committed
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.
1 parent 58828b0 commit eadef31

11 files changed

Lines changed: 163 additions & 160 deletions

File tree

lib/classifier.c

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,17 @@ cls_rule_set_nw_dst_masked(struct cls_rule *rule, ovs_be32 ip, ovs_be32 mask)
320320
void
321321
cls_rule_set_nw_dscp(struct cls_rule *rule, uint8_t nw_dscp)
322322
{
323-
rule->wc.tos_mask |= IP_DSCP_MASK;
324-
rule->flow.tos &= ~IP_DSCP_MASK;
325-
rule->flow.tos |= nw_dscp & IP_DSCP_MASK;
323+
rule->wc.nw_tos_mask |= IP_DSCP_MASK;
324+
rule->flow.nw_tos &= ~IP_DSCP_MASK;
325+
rule->flow.nw_tos |= nw_dscp & IP_DSCP_MASK;
326326
}
327327

328328
void
329329
cls_rule_set_nw_ecn(struct cls_rule *rule, uint8_t nw_ecn)
330330
{
331-
rule->wc.tos_mask |= IP_ECN_MASK;
332-
rule->flow.tos &= ~IP_ECN_MASK;
333-
rule->flow.tos |= nw_ecn & IP_ECN_MASK;
331+
rule->wc.nw_tos_mask |= IP_ECN_MASK;
332+
rule->flow.nw_tos &= ~IP_ECN_MASK;
333+
rule->flow.nw_tos |= nw_ecn & IP_ECN_MASK;
334334
}
335335

336336
void
@@ -341,17 +341,18 @@ cls_rule_set_nw_ttl(struct cls_rule *rule, uint8_t nw_ttl)
341341
}
342342

343343
void
344-
cls_rule_set_frag(struct cls_rule *rule, uint8_t frag)
344+
cls_rule_set_nw_frag(struct cls_rule *rule, uint8_t nw_frag)
345345
{
346-
rule->wc.frag_mask |= FLOW_FRAG_MASK;
347-
rule->flow.frag = frag;
346+
rule->wc.nw_frag_mask |= FLOW_NW_FRAG_MASK;
347+
rule->flow.nw_frag = nw_frag;
348348
}
349349

350350
void
351-
cls_rule_set_frag_masked(struct cls_rule *rule, uint8_t frag, uint8_t mask)
351+
cls_rule_set_nw_frag_masked(struct cls_rule *rule,
352+
uint8_t nw_frag, uint8_t mask)
352353
{
353-
rule->flow.frag = frag & mask;
354-
rule->wc.frag_mask = mask;
354+
rule->flow.nw_frag = nw_frag & mask;
355+
rule->wc.nw_frag_mask = mask;
355356
}
356357

357358
void
@@ -632,31 +633,31 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
632633
ETH_ADDR_ARGS(f->arp_tha));
633634
}
634635
}
635-
if (wc->tos_mask & IP_DSCP_MASK) {
636-
ds_put_format(s, "nw_tos=%"PRIu8",", f->tos & IP_DSCP_MASK);
636+
if (wc->nw_tos_mask & IP_DSCP_MASK) {
637+
ds_put_format(s, "nw_tos=%"PRIu8",", f->nw_tos & IP_DSCP_MASK);
637638
}
638-
if (wc->tos_mask & IP_ECN_MASK) {
639-
ds_put_format(s, "nw_ecn=%"PRIu8",", f->tos & IP_ECN_MASK);
639+
if (wc->nw_tos_mask & IP_ECN_MASK) {
640+
ds_put_format(s, "nw_ecn=%"PRIu8",", f->nw_tos & IP_ECN_MASK);
640641
}
641642
if (!(w & FWW_NW_TTL)) {
642643
ds_put_format(s, "nw_ttl=%"PRIu8",", f->nw_ttl);
643644
}
644-
switch (wc->frag_mask) {
645-
case FLOW_FRAG_ANY | FLOW_FRAG_LATER:
646-
ds_put_format(s, "frag=%s,",
647-
f->frag & FLOW_FRAG_ANY
648-
? (f->frag & FLOW_FRAG_LATER ? "later" : "first")
649-
: (f->frag & FLOW_FRAG_LATER ? "<error>" : "no"));
645+
switch (wc->nw_frag_mask) {
646+
case FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER:
647+
ds_put_format(s, "nw_frag=%s,",
648+
f->nw_frag & FLOW_NW_FRAG_ANY
649+
? (f->nw_frag & FLOW_NW_FRAG_LATER ? "later" : "first")
650+
: (f->nw_frag & FLOW_NW_FRAG_LATER ? "<error>" : "no"));
650651
break;
651652

652-
case FLOW_FRAG_ANY:
653-
ds_put_format(s, "frag=%s,",
654-
f->frag & FLOW_FRAG_ANY ? "yes" : "no");
653+
case FLOW_NW_FRAG_ANY:
654+
ds_put_format(s, "nw_frag=%s,",
655+
f->nw_frag & FLOW_NW_FRAG_ANY ? "yes" : "no");
655656
break;
656657

657-
case FLOW_FRAG_LATER:
658-
ds_put_format(s, "frag=%s,",
659-
f->frag & FLOW_FRAG_LATER ? "later" : "not_later");
658+
case FLOW_NW_FRAG_LATER:
659+
ds_put_format(s, "nw_frag=%s,",
660+
f->nw_frag & FLOW_NW_FRAG_LATER ? "later" : "not_later");
660661
break;
661662
}
662663
if (f->nw_proto == IPPROTO_ICMP) {
@@ -1215,8 +1216,8 @@ flow_equal_except(const struct flow *a, const struct flow *b,
12151216
|| !((a->dl_dst[0] ^ b->dl_dst[0]) & 0x01))
12161217
&& (wc & FWW_NW_PROTO || a->nw_proto == b->nw_proto)
12171218
&& (wc & FWW_NW_TTL || a->nw_ttl == b->nw_ttl)
1218-
&& !((a->tos ^ b->tos) & wildcards->tos_mask)
1219-
&& !((a->frag ^ b->frag) & wildcards->frag_mask)
1219+
&& !((a->nw_tos ^ b->nw_tos) & wildcards->nw_tos_mask)
1220+
&& !((a->nw_frag ^ b->nw_frag) & wildcards->nw_frag_mask)
12201221
&& (wc & FWW_ARP_SHA || eth_addr_equals(a->arp_sha, b->arp_sha))
12211222
&& (wc & FWW_ARP_THA || eth_addr_equals(a->arp_tha, b->arp_tha))
12221223
&& (wc & FWW_IPV6_LABEL || a->ipv6_label == b->ipv6_label)

lib/classifier.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ bool cls_rule_set_nw_dst_masked(struct cls_rule *, ovs_be32 ip, ovs_be32 mask);
119119
void cls_rule_set_nw_dscp(struct cls_rule *, uint8_t);
120120
void cls_rule_set_nw_ecn(struct cls_rule *, uint8_t);
121121
void cls_rule_set_nw_ttl(struct cls_rule *, uint8_t);
122-
void cls_rule_set_frag(struct cls_rule *, uint8_t frag);
123-
void cls_rule_set_frag_masked(struct cls_rule *, uint8_t frag, uint8_t mask);
122+
void cls_rule_set_nw_frag(struct cls_rule *, uint8_t nw_frag);
123+
void cls_rule_set_nw_frag_masked(struct cls_rule *,
124+
uint8_t nw_frag, uint8_t mask);
124125
void cls_rule_set_icmp_type(struct cls_rule *, uint8_t);
125126
void cls_rule_set_icmp_code(struct cls_rule *, uint8_t);
126127
void cls_rule_set_arp_sha(struct cls_rule *, const uint8_t[6]);

lib/flow.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow)
148148
flow->ipv6_dst = nh->ip6_dst;
149149

150150
tc_flow = get_unaligned_be32(&nh->ip6_flow);
151-
flow->tos = ntohl(tc_flow) >> 4;
151+
flow->nw_tos = ntohl(tc_flow) >> 4;
152152
flow->ipv6_label = tc_flow & htonl(IPV6_LABEL_MASK);
153153
flow->nw_ttl = nh->ip6_hlim;
154154
flow->nw_proto = IPPROTO_NONE;
@@ -203,9 +203,9 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow)
203203
}
204204

205205
/* We only process the first fragment. */
206-
flow->frag = FLOW_FRAG_ANY;
206+
flow->nw_frag = FLOW_NW_FRAG_ANY;
207207
if ((frag_hdr->ip6f_offlg & IP6F_OFF_MASK) != htons(0)) {
208-
flow->frag |= FLOW_FRAG_LATER;
208+
flow->nw_frag |= FLOW_NW_FRAG_LATER;
209209
nexthdr = IPPROTO_FRAGMENT;
210210
break;
211211
}
@@ -370,11 +370,11 @@ flow_extract(struct ofpbuf *packet, uint32_t priority, ovs_be64 tun_id,
370370
flow->nw_dst = get_unaligned_be32(&nh->ip_dst);
371371
flow->nw_proto = nh->ip_proto;
372372

373-
flow->tos = nh->ip_tos;
373+
flow->nw_tos = nh->ip_tos;
374374
if (IP_IS_FRAGMENT(nh->ip_frag_off)) {
375-
flow->frag = FLOW_FRAG_ANY;
375+
flow->nw_frag = FLOW_NW_FRAG_ANY;
376376
if (nh->ip_frag_off & htons(IP_FRAG_OFF_MASK)) {
377-
flow->frag |= FLOW_FRAG_LATER;
377+
flow->nw_frag |= FLOW_NW_FRAG_LATER;
378378
}
379379
}
380380
flow->nw_ttl = nh->ip_ttl;
@@ -476,11 +476,11 @@ flow_zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards)
476476
if (wc & FWW_IPV6_LABEL) {
477477
flow->ipv6_label = htonl(0);
478478
}
479-
flow->tos &= wildcards->tos_mask;
479+
flow->nw_tos &= wildcards->nw_tos_mask;
480480
if (wc & FWW_NW_TTL) {
481481
flow->nw_ttl = 0;
482482
}
483-
flow->frag &= wildcards->frag_mask;
483+
flow->nw_frag &= wildcards->nw_frag_mask;
484484
if (wc & FWW_ARP_SHA) {
485485
memset(flow->arp_sha, 0, sizeof flow->arp_sha);
486486
}
@@ -533,21 +533,21 @@ flow_format(struct ds *ds, const struct flow *flow)
533533
ds_put_format(ds, " label%#"PRIx32" proto%"PRIu8" tos%#"PRIx8
534534
" ttl%"PRIu8" ipv6",
535535
ntohl(flow->ipv6_label), flow->nw_proto,
536-
flow->tos, flow->nw_ttl);
536+
flow->nw_tos, flow->nw_ttl);
537537
print_ipv6_addr(ds, &flow->ipv6_src);
538538
ds_put_cstr(ds, "->");
539539
print_ipv6_addr(ds, &flow->ipv6_dst);
540540

541541
} else {
542542
ds_put_format(ds, " proto%"PRIu8" tos%#"PRIx8" ttl%"PRIu8
543543
" ip"IP_FMT"->"IP_FMT,
544-
flow->nw_proto, flow->tos, flow->nw_ttl,
544+
flow->nw_proto, flow->nw_tos, flow->nw_ttl,
545545
IP_ARGS(&flow->nw_src), IP_ARGS(&flow->nw_dst));
546546
}
547-
if (flow->frag) {
547+
if (flow->nw_frag) {
548548
ds_put_format(ds, " frag(%s)",
549-
flow->frag == FLOW_FRAG_ANY ? "first"
550-
: flow->frag == (FLOW_FRAG_ANY | FLOW_FRAG_LATER)
549+
flow->nw_frag == FLOW_NW_FRAG_ANY ? "first"
550+
: flow->nw_frag == (FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER)
551551
? "later" : "<error>");
552552
}
553553
if (flow->tp_src || flow->tp_dst) {
@@ -585,8 +585,8 @@ flow_wildcards_init_catchall(struct flow_wildcards *wc)
585585
wc->ipv6_dst_mask = in6addr_any;
586586
memset(wc->reg_masks, 0, sizeof wc->reg_masks);
587587
wc->vlan_tci_mask = htons(0);
588-
wc->tos_mask = 0;
589-
wc->frag_mask = 0;
588+
wc->nw_tos_mask = 0;
589+
wc->nw_frag_mask = 0;
590590
memset(wc->zeros, 0, sizeof wc->zeros);
591591
}
592592

@@ -605,8 +605,8 @@ flow_wildcards_init_exact(struct flow_wildcards *wc)
605605
wc->ipv6_dst_mask = in6addr_exact;
606606
memset(wc->reg_masks, 0xff, sizeof wc->reg_masks);
607607
wc->vlan_tci_mask = htons(UINT16_MAX);
608-
wc->tos_mask = UINT8_MAX;
609-
wc->frag_mask = UINT8_MAX;
608+
wc->nw_tos_mask = UINT8_MAX;
609+
wc->nw_frag_mask = UINT8_MAX;
610610
memset(wc->zeros, 0, sizeof wc->zeros);
611611
}
612612

@@ -626,8 +626,8 @@ flow_wildcards_is_exact(const struct flow_wildcards *wc)
626626
|| wc->vlan_tci_mask != htons(UINT16_MAX)
627627
|| !ipv6_mask_is_exact(&wc->ipv6_src_mask)
628628
|| !ipv6_mask_is_exact(&wc->ipv6_dst_mask)
629-
|| wc->tos_mask != UINT8_MAX
630-
|| wc->frag_mask != UINT8_MAX) {
629+
|| wc->nw_tos_mask != UINT8_MAX
630+
|| wc->nw_frag_mask != UINT8_MAX) {
631631
return false;
632632
}
633633

@@ -656,8 +656,8 @@ flow_wildcards_is_catchall(const struct flow_wildcards *wc)
656656
|| wc->vlan_tci_mask != htons(0)
657657
|| !ipv6_mask_is_any(&wc->ipv6_src_mask)
658658
|| !ipv6_mask_is_any(&wc->ipv6_dst_mask)
659-
|| wc->tos_mask != 0
660-
|| wc->frag_mask != 0) {
659+
|| wc->nw_tos_mask != 0
660+
|| wc->nw_frag_mask != 0) {
661661
return false;
662662
}
663663

@@ -1019,19 +1019,19 @@ flow_compose(struct ofpbuf *b, const struct flow *flow)
10191019

10201020
b->l3 = ip = ofpbuf_put_zeros(b, sizeof *ip);
10211021
ip->ip_ihl_ver = IP_IHL_VER(5, 4);
1022-
ip->ip_tos = flow->tos;
1022+
ip->ip_tos = flow->nw_tos;
10231023
ip->ip_proto = flow->nw_proto;
10241024
ip->ip_src = flow->nw_src;
10251025
ip->ip_dst = flow->nw_dst;
10261026

1027-
if (flow->frag & FLOW_FRAG_ANY) {
1027+
if (flow->nw_frag & FLOW_NW_FRAG_ANY) {
10281028
ip->ip_frag_off |= htons(IP_MORE_FRAGMENTS);
1029-
if (flow->frag & FLOW_FRAG_LATER) {
1029+
if (flow->nw_frag & FLOW_NW_FRAG_LATER) {
10301030
ip->ip_frag_off |= htons(100);
10311031
}
10321032
}
1033-
if (!(flow->frag & FLOW_FRAG_ANY)
1034-
|| !(flow->frag & FLOW_FRAG_LATER)) {
1033+
if (!(flow->nw_frag & FLOW_NW_FRAG_ANY)
1034+
|| !(flow->nw_frag & FLOW_NW_FRAG_LATER)) {
10351035
if (flow->nw_proto == IPPROTO_TCP) {
10361036
struct tcp_header *tcp;
10371037

lib/flow.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ BUILD_ASSERT_DECL(FLOW_N_REGS <= NXM_NX_MAX_REGS);
4545
#define FLOW_DL_TYPE_NONE 0x5ff
4646

4747
/* Fragment bits, used for IPv4 and IPv6, always zero for non-IP flows. */
48-
#define FLOW_FRAG_ANY (1 << 0) /* Set for any IP fragment. */
49-
#define FLOW_FRAG_LATER (1 << 1) /* Set for IP fragment with nonzero offset. */
50-
#define FLOW_FRAG_MASK (FLOW_FRAG_ANY | FLOW_FRAG_LATER)
48+
#define FLOW_NW_FRAG_ANY (1 << 0) /* Set for any IP frag. */
49+
#define FLOW_NW_FRAG_LATER (1 << 1) /* Set for IP frag with nonzero offset. */
50+
#define FLOW_NW_FRAG_MASK (FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER)
5151

52-
BUILD_ASSERT_DECL(FLOW_FRAG_ANY == NX_IP_FRAG_ANY);
53-
BUILD_ASSERT_DECL(FLOW_FRAG_LATER == NX_IP_FRAG_LATER);
52+
BUILD_ASSERT_DECL(FLOW_NW_FRAG_ANY == NX_IP_FRAG_ANY);
53+
BUILD_ASSERT_DECL(FLOW_NW_FRAG_LATER == NX_IP_FRAG_LATER);
5454

5555
struct flow {
5656
ovs_be64 tun_id; /* Encapsulating tunnel ID. */
@@ -70,20 +70,20 @@ struct flow {
7070
uint8_t dl_src[6]; /* Ethernet source address. */
7171
uint8_t dl_dst[6]; /* Ethernet destination address. */
7272
uint8_t nw_proto; /* IP protocol or low 8 bits of ARP opcode. */
73-
uint8_t tos; /* IP ToS. */
73+
uint8_t nw_tos; /* IP ToS (including DSCP and ECN). */
7474
uint8_t arp_sha[6]; /* ARP/ND source hardware address. */
7575
uint8_t arp_tha[6]; /* ARP/ND target hardware address. */
7676
uint8_t nw_ttl; /* IP TTL/Hop Limit. */
77-
uint8_t frag; /* FLOW_FRAG_* flags. */
77+
uint8_t nw_frag; /* FLOW_FRAG_* flags. */
7878
uint8_t reserved[6]; /* Reserved for 64-bit packing. */
7979
};
8080

8181
/* Assert that there are FLOW_SIG_SIZE bytes of significant data in "struct
8282
* flow", followed by FLOW_PAD_SIZE bytes of padding. */
8383
#define FLOW_SIG_SIZE (110 + FLOW_N_REGS * 4)
8484
#define FLOW_PAD_SIZE 6
85-
BUILD_ASSERT_DECL(offsetof(struct flow, frag) == FLOW_SIG_SIZE - 1);
86-
BUILD_ASSERT_DECL(sizeof(((struct flow *)0)->frag) == 1);
85+
BUILD_ASSERT_DECL(offsetof(struct flow, nw_frag) == FLOW_SIG_SIZE - 1);
86+
BUILD_ASSERT_DECL(sizeof(((struct flow *)0)->nw_frag) == 1);
8787
BUILD_ASSERT_DECL(sizeof(struct flow) == FLOW_SIG_SIZE + FLOW_PAD_SIZE);
8888

8989
/* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */
@@ -163,8 +163,8 @@ struct flow_wildcards {
163163
struct in6_addr ipv6_src_mask; /* 1-bit in each signficant ipv6_src bit. */
164164
struct in6_addr ipv6_dst_mask; /* 1-bit in each signficant ipv6_dst bit. */
165165
ovs_be16 vlan_tci_mask; /* 1-bit in each significant vlan_tci bit. */
166-
uint8_t tos_mask; /* 1-bit in each significant tos bit. */
167-
uint8_t frag_mask; /* 1-bit in each significant frag bit. */
166+
uint8_t nw_tos_mask; /* 1-bit in each significant nw_tos bit. */
167+
uint8_t nw_frag_mask; /* 1-bit in each significant nw_frag bit. */
168168
uint8_t zeros[4]; /* Padding field set to zero. */
169169
};
170170

0 commit comments

Comments
 (0)