X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fflow.c;h=d511fd81d7daacb0d208f15039329e338e991cf0;hb=07c8ec217b5641b74f20b216ad63fef230649f2c;hp=75087c943515de5747744db787b923ce7a297999;hpb=ddbfda846297ab9e89ed9c3f844a8eff86692275;p=sliver-openvswitch.git diff --git a/lib/flow.c b/lib/flow.c index 75087c943..d511fd81d 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -335,7 +335,7 @@ invalid: * present and has a correct length, and otherwise NULL. */ void -flow_extract(struct ofpbuf *packet, uint32_t skb_priority, +flow_extract(struct ofpbuf *packet, uint32_t skb_priority, uint32_t skb_mark, const struct flow_tnl *tnl, uint16_t ofp_in_port, struct flow *flow) { @@ -352,6 +352,7 @@ flow_extract(struct ofpbuf *packet, uint32_t skb_priority, } flow->in_port = ofp_in_port; flow->skb_priority = skb_priority; + flow->skb_mark = skb_mark; packet->l2 = b.data; packet->l3 = NULL; @@ -424,7 +425,8 @@ flow_extract(struct ofpbuf *packet, uint32_t skb_priority, packet->l7 = b.data; } } - } else if (flow->dl_type == htons(ETH_TYPE_ARP)) { + } else if (flow->dl_type == htons(ETH_TYPE_ARP) || + flow->dl_type == htons(ETH_TYPE_RARP)) { const struct arp_eth_header *arp = pull_arp(&b); if (arp && arp->ar_hrd == htons(1) && arp->ar_pro == htons(ETH_TYPE_IP) @@ -461,7 +463,7 @@ flow_zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards) void flow_get_metadata(const struct flow *flow, struct flow_metadata *fmd) { - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 18); fmd->tun_id = flow->tunnel.tun_id; fmd->metadata = flow->metadata; @@ -477,13 +479,57 @@ flow_to_string(const struct flow *flow) return ds_cstr(&ds); } +const char * +flow_tun_flag_to_string(uint32_t flags) +{ + switch (flags) { + case FLOW_TNL_F_DONT_FRAGMENT: + return "df"; + case FLOW_TNL_F_CSUM: + return "csum"; + case FLOW_TNL_F_KEY: + return "key"; + default: + return NULL; + } +} + +void +format_flags(struct ds *ds, const char *(*bit_to_string)(uint32_t), + uint32_t flags, char del) +{ + uint32_t bad = 0; + + if (!flags) { + return; + } + while (flags) { + uint32_t bit = rightmost_1bit(flags); + const char *s; + + s = bit_to_string(bit); + if (s) { + ds_put_format(ds, "%s%c", s, del); + } else { + bad |= bit; + } + + flags &= ~bit; + } + + if (bad) { + ds_put_format(ds, "0x%"PRIx32"%c", bad, del); + } + ds_chomp(ds, del); +} + void flow_format(struct ds *ds, const struct flow *flow) { struct match match; match_wc_init(&match, flow); - match_format(&match, ds, flow->skb_priority); + match_format(&match, ds, OFP_DEFAULT_PRIORITY); } void @@ -509,6 +555,7 @@ void flow_wildcards_init_exact(struct flow_wildcards *wc) { memset(&wc->masks, 0xff, sizeof wc->masks); + memset(wc->masks.zeros, 0, sizeof wc->masks.zeros); } /* Returns true if 'wc' matches every packet, false if 'wc' fixes any bits or @@ -808,7 +855,8 @@ flow_compose(struct ofpbuf *b, const struct flow *flow) ip->ip_csum = csum(ip, sizeof *ip); } else if (flow->dl_type == htons(ETH_TYPE_IPV6)) { /* XXX */ - } else if (flow->dl_type == htons(ETH_TYPE_ARP)) { + } else if (flow->dl_type == htons(ETH_TYPE_ARP) || + flow->dl_type == htons(ETH_TYPE_RARP)) { struct arp_eth_header *arp; b->l3 = arp = ofpbuf_put_zeros(b, sizeof *arp);