2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

Don't overload IP TOS with the frag matching bits.

This will be useful later when we add support for matching the ECN bits
within the TOS field.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
This commit is contained in:
Justin Pettit
2011-11-02 18:17:36 -07:00
parent fa8223b7fd
commit 9e44d71563
14 changed files with 192 additions and 201 deletions

View File

@@ -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_frag = (ntohl(tc_flow) >> 4) & IP_DSCP_MASK;
flow->tos = (ntohl(tc_flow) >> 4) & IP_DSCP_MASK;
flow->ipv6_label = tc_flow & htonl(IPV6_LABEL_MASK);
flow->nw_proto = IPPROTO_NONE;
@@ -202,10 +202,9 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow)
}
/* We only process the first fragment. */
flow->tos_frag &= ~FLOW_FRAG_MASK;
flow->tos_frag |= FLOW_FRAG_ANY;
flow->frag = FLOW_FRAG_ANY;
if ((frag_hdr->ip6f_offlg & IP6F_OFF_MASK) != htons(0)) {
flow->tos_frag |= FLOW_FRAG_LATER;
flow->frag |= FLOW_FRAG_LATER;
nexthdr = IPPROTO_FRAGMENT;
break;
}
@@ -370,11 +369,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_frag = nh->ip_tos & IP_DSCP_MASK;
flow->tos = nh->ip_tos & IP_DSCP_MASK;
if (IP_IS_FRAGMENT(nh->ip_frag_off)) {
flow->tos_frag |= FLOW_FRAG_ANY;
flow->frag = FLOW_FRAG_ANY;
if (nh->ip_frag_off & htons(IP_FRAG_OFF_MASK)) {
flow->tos_frag |= FLOW_FRAG_LATER;
flow->frag |= FLOW_FRAG_LATER;
}
}
@@ -438,7 +437,7 @@ flow_zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards)
const flow_wildcards_t wc = wildcards->wildcards;
int i;
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 4);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 5);
for (i = 0; i < FLOW_N_REGS; i++) {
flow->regs[i] &= wildcards->reg_masks[i];
@@ -475,7 +474,8 @@ flow_zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards)
if (wc & FWW_IPV6_LABEL) {
flow->ipv6_label = htonl(0);
}
flow->tos_frag &= wildcards->tos_frag_mask;
flow->tos &= wildcards->tos_mask;
flow->frag &= wildcards->frag_mask;
if (wc & FWW_ARP_SHA) {
memset(flow->arp_sha, 0, sizeof flow->arp_sha);
}
@@ -503,8 +503,6 @@ flow_to_string(const struct flow *flow)
void
flow_format(struct ds *ds, const struct flow *flow)
{
int frag;
ds_put_format(ds, "priority%"PRIu32
":tunnel%#"PRIx64
":in_port%04"PRIx16,
@@ -529,7 +527,7 @@ flow_format(struct ds *ds, const struct flow *flow)
if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
ds_put_format(ds, " label%#"PRIx32" proto%"PRIu8" tos%"PRIu8" ipv6",
ntohl(flow->ipv6_label), flow->nw_proto,
flow->tos_frag & IP_DSCP_MASK);
flow->tos & IP_DSCP_MASK);
print_ipv6_addr(ds, &flow->ipv6_src);
ds_put_cstr(ds, "->");
print_ipv6_addr(ds, &flow->ipv6_dst);
@@ -539,16 +537,15 @@ flow_format(struct ds *ds, const struct flow *flow)
" tos%"PRIu8
" ip"IP_FMT"->"IP_FMT,
flow->nw_proto,
flow->tos_frag & IP_DSCP_MASK,
flow->tos & IP_DSCP_MASK,
IP_ARGS(&flow->nw_src),
IP_ARGS(&flow->nw_dst));
}
frag = flow->tos_frag & FLOW_FRAG_MASK;
if (frag) {
if (flow->frag) {
ds_put_format(ds, " frag(%s)",
frag == FLOW_FRAG_ANY ? "first"
: frag == (FLOW_FRAG_ANY | FLOW_FRAG_LATER) ? "later"
: "<error>");
flow->frag == FLOW_FRAG_ANY ? "first"
: flow->frag == (FLOW_FRAG_ANY | FLOW_FRAG_LATER)
? "later" : "<error>");
}
if (flow->tp_src || flow->tp_dst) {
ds_put_format(ds, " port%"PRIu16"->%"PRIu16,
@@ -575,7 +572,7 @@ flow_print(FILE *stream, const struct flow *flow)
void
flow_wildcards_init_catchall(struct flow_wildcards *wc)
{
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 4);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 5);
wc->wildcards = FWW_ALL;
wc->tun_id_mask = htonll(0);
@@ -585,7 +582,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_frag_mask = 0;
wc->tos_mask = 0;
wc->frag_mask = 0;
memset(wc->zeros, 0, sizeof wc->zeros);
}
@@ -594,7 +592,7 @@ flow_wildcards_init_catchall(struct flow_wildcards *wc)
void
flow_wildcards_init_exact(struct flow_wildcards *wc)
{
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 4);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 5);
wc->wildcards = 0;
wc->tun_id_mask = htonll(UINT64_MAX);
@@ -604,7 +602,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_frag_mask = UINT8_MAX;
wc->tos_mask = UINT8_MAX;
wc->frag_mask = UINT8_MAX;
memset(wc->zeros, 0, sizeof wc->zeros);
}
@@ -615,7 +614,7 @@ flow_wildcards_is_exact(const struct flow_wildcards *wc)
{
int i;
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 4);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 5);
if (wc->wildcards
|| wc->tun_id_mask != htonll(UINT64_MAX)
@@ -624,7 +623,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_frag_mask != UINT8_MAX) {
|| wc->tos_mask != UINT8_MAX
|| wc->frag_mask != UINT8_MAX) {
return false;
}
@@ -644,7 +644,7 @@ flow_wildcards_is_catchall(const struct flow_wildcards *wc)
{
int i;
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 4);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 5);
if (wc->wildcards != FWW_ALL
|| wc->tun_id_mask != htonll(0)
@@ -653,7 +653,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_frag_mask != 0) {
|| wc->tos_mask != 0
|| wc->frag_mask != 0) {
return false;
}
@@ -1015,19 +1016,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_frag & IP_DSCP_MASK;
ip->ip_tos = flow->tos & IP_DSCP_MASK;
ip->ip_proto = flow->nw_proto;
ip->ip_src = flow->nw_src;
ip->ip_dst = flow->nw_dst;
if (flow->tos_frag & FLOW_FRAG_ANY) {
if (flow->frag & FLOW_FRAG_ANY) {
ip->ip_frag_off |= htons(IP_MORE_FRAGMENTS);
if (flow->tos_frag & FLOW_FRAG_LATER) {
if (flow->frag & FLOW_FRAG_LATER) {
ip->ip_frag_off |= htons(100);
}
}
if (!(flow->tos_frag & FLOW_FRAG_ANY)
|| !(flow->tos_frag & FLOW_FRAG_LATER)) {
if (!(flow->frag & FLOW_FRAG_ANY)
|| !(flow->frag & FLOW_FRAG_LATER)) {
if (flow->nw_proto == IPPROTO_TCP) {
struct tcp_header *tcp;