X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fflow.c;h=d511fd81d7daacb0d208f15039329e338e991cf0;hb=476ff5a0ad285b12de1cbe16453b8f12ff79afc6;hp=3085848dc37686396f3e964985ab3e494c1156bd;hpb=72e8bf28bb38e8816435c64859fb350215b6a9e6;p=sliver-openvswitch.git diff --git a/lib/flow.c b/lib/flow.c index 3085848dc..d511fd81d 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -479,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 @@ -511,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