X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fofp-print.c;h=37e1f4f88a448c5e77a1a7a159030fe571943845;hb=bcb8bde4ca385b85154d3905ed7779473249e6fe;hp=b280a3738b833948e8e48dfd674334bad04ee17f;hpb=db09e4308a18f12d93191d057dc9e2b938ff4649;p=sliver-openvswitch.git diff --git a/lib/ofp-print.c b/lib/ofp-print.c index b280a3738..37e1f4f88 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -105,11 +105,11 @@ ofp_print_packet_in(struct ds *string, const struct ofp_header *oh, ds_put_format(string, " table_id=%"PRIu8, pin.table_id); } - if (pin.cookie) { + if (pin.cookie != OVS_BE64_MAX) { ds_put_format(string, " cookie=0x%"PRIx64, ntohll(pin.cookie)); } - ds_put_format(string, " total_len=%"PRIu16" in_port=", pin.total_len); + ds_put_format(string, " total_len=%zu in_port=", pin.total_len); ofputil_format_port(pin.fmd.in_port, string); if (pin.fmd.tun_id != htonll(0)) { @@ -185,7 +185,7 @@ ofp_print_packet_out(struct ds *string, const struct ofp_header *oh, ds_put_cstr(string, " in_port="); ofputil_format_port(po.in_port, string); - ds_put_char(string, ' '); + ds_put_cstr(string, " actions="); ofpacts_format(po.ofpacts, po.ofpacts_len, string); if (po.buffer_id == UINT32_MAX) { @@ -757,7 +757,8 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh, int verbosity) protocol = ofputil_protocol_set_tid(protocol, true); ofpbuf_init(&ofpacts, 64); - error = ofputil_decode_flow_mod(&fm, oh, protocol, &ofpacts); + error = ofputil_decode_flow_mod(&fm, oh, protocol, &ofpacts, + OFPP_MAX, 255); if (error) { ofpbuf_uninit(&ofpacts); ofp_print_error(s, error); @@ -817,7 +818,7 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh, int verbosity) if (ds_last(s) != ' ') { ds_put_char(s, ' '); } - if (fm.new_cookie != htonll(0) && fm.new_cookie != htonll(UINT64_MAX)) { + if (fm.new_cookie != htonll(0) && fm.new_cookie != OVS_BE64_MAX) { ds_put_format(s, "cookie:0x%"PRIx64" ", ntohll(fm.new_cookie)); } if (fm.cookie_mask != htonll(0)) { @@ -850,6 +851,7 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh, int verbosity) } ofp_print_flow_flags(s, fm.flags); + ds_put_cstr(s, "actions="); ofpacts_format(fm.ofpacts, fm.ofpacts_len, s); ofpbuf_uninit(&ofpacts); } @@ -964,6 +966,114 @@ ofp_print_port_mod(struct ds *string, const struct ofp_header *oh) } } +static void +ofp_print_table_miss_config(struct ds *string, const uint32_t config) +{ + uint32_t table_miss_config = config & OFPTC11_TABLE_MISS_MASK; + + switch (table_miss_config) { + case OFPTC11_TABLE_MISS_CONTROLLER: + ds_put_cstr(string, "controller\n"); + break; + case OFPTC11_TABLE_MISS_CONTINUE: + ds_put_cstr(string, "continue\n"); + break; + case OFPTC11_TABLE_MISS_DROP: + ds_put_cstr(string, "drop\n"); + break; + default: + ds_put_cstr(string, "Unknown\n"); + break; + } +} + +static void +ofp_print_table_mod(struct ds *string, const struct ofp_header *oh) +{ + struct ofputil_table_mod pm; + enum ofperr error; + + error = ofputil_decode_table_mod(oh, &pm); + if (error) { + ofp_print_error(string, error); + return; + } + + if (pm.table_id == 0xff) { + ds_put_cstr(string, " table_id: ALL_TABLES"); + } else { + ds_put_format(string, " table_id=%"PRIu8, pm.table_id); + } + + ds_put_cstr(string, ", flow_miss_config="); + ofp_print_table_miss_config(string, pm.config); +} + +static void +ofp_print_queue_get_config_request(struct ds *string, + const struct ofp_header *oh) +{ + enum ofperr error; + ofp_port_t port; + + error = ofputil_decode_queue_get_config_request(oh, &port); + if (error) { + ofp_print_error(string, error); + return; + } + + ds_put_cstr(string, " port="); + ofputil_format_port(port, string); +} + +static void +print_queue_rate(struct ds *string, const char *name, unsigned int rate) +{ + if (rate <= 1000) { + ds_put_format(string, " %s:%u.%u%%", name, rate / 10, rate % 10); + } else if (rate < UINT16_MAX) { + ds_put_format(string, " %s:(disabled)", name); + } +} + +static void +ofp_print_queue_get_config_reply(struct ds *string, + const struct ofp_header *oh) +{ + enum ofperr error; + struct ofpbuf b; + ofp_port_t port; + + ofpbuf_use_const(&b, oh, ntohs(oh->length)); + error = ofputil_decode_queue_get_config_reply(&b, &port); + if (error) { + ofp_print_error(string, error); + return; + } + + ds_put_cstr(string, " port="); + ofputil_format_port(port, string); + ds_put_char(string, '\n'); + + for (;;) { + struct ofputil_queue_config queue; + int retval; + + retval = ofputil_pull_queue_get_config_reply(&b, &queue); + if (retval) { + if (retval != EOF) { + ofp_print_error(string, retval); + } + break; + } + + ds_put_format(string, "queue %"PRIu32":", queue.queue_id); + print_queue_rate(string, "min_rate", queue.min_rate); + print_queue_rate(string, "max_rate", queue.max_rate); + ds_put_char(string, '\n'); + } +} + static void ofp_print_meter_flags(struct ds *s, uint16_t flags) { @@ -1339,6 +1449,7 @@ ofp_print_flow_stats(struct ds *string, struct ofputil_flow_stats *fs) ds_put_char(string, ' '); } + ds_put_cstr(string, "actions="); ofpacts_format(fs->ofpacts, fs->ofpacts_len, string); } @@ -1807,20 +1918,12 @@ ofp_print_echo(struct ds *string, const struct ofp_header *oh, int verbosity) } static void -ofp_print_role_message(struct ds *string, const struct ofp_header *oh) +ofp_print_role_generic(struct ds *string, enum ofp12_controller_role role, + uint64_t generation_id) { - struct ofputil_role_request rr; - enum ofperr error; - - error = ofputil_decode_role_message(oh, &rr); - if (error) { - ofp_print_error(string, error); - return; - } - ds_put_cstr(string, " role="); - switch (rr.role) { + switch (role) { case OFPCR12_ROLE_NOCHANGE: ds_put_cstr(string, "nochange"); break; @@ -1837,8 +1940,54 @@ ofp_print_role_message(struct ds *string, const struct ofp_header *oh) NOT_REACHED(); } - if (rr.have_generation_id) { - ds_put_format(string, " generation_id=%"PRIu64, rr.generation_id); + if (generation_id != UINT64_MAX) { + ds_put_format(string, " generation_id=%"PRIu64, generation_id); + } +} + +static void +ofp_print_role_message(struct ds *string, const struct ofp_header *oh) +{ + struct ofputil_role_request rr; + enum ofperr error; + + error = ofputil_decode_role_message(oh, &rr); + if (error) { + ofp_print_error(string, error); + return; + } + + ofp_print_role_generic(string, rr.role, rr.have_generation_id ? rr.generation_id : UINT64_MAX); +} + +static void +ofp_print_role_status_message(struct ds *string, const struct ofp_header *oh) +{ + struct ofputil_role_status rs; + enum ofperr error; + + error = ofputil_decode_role_status(oh, &rs); + if (error) { + ofp_print_error(string, error); + return; + } + + ofp_print_role_generic(string, rs.role, rs.generation_id); + + ds_put_cstr(string, " reason="); + + switch (rs.reason) { + case OFPCRR_MASTER_REQUEST: + ds_put_cstr(string, "master_request"); + break; + case OFPCRR_CONFIG: + ds_put_cstr(string, "configuration_changed"); + break; + case OFPCRR_EXPERIMENTER: + ds_put_cstr(string, "experimenter_data_changed"); + break; + default: + NOT_REACHED(); } } @@ -2098,6 +2247,7 @@ ofp_print_nxst_flow_monitor_reply(struct ds *string, if (string->string[string->length - 1] != ' ') { ds_put_char(string, ' '); } + ds_put_cstr(string, "actions="); ofpacts_format(update.ofpacts, update.ofpacts_len, string); } } @@ -2167,6 +2317,7 @@ ofp_print_group(struct ds *s, uint32_t group_id, uint8_t type, ds_put_format(s, "watch_group:%"PRIu32",", bucket->watch_group); } + ds_put_cstr(s, "actions="); ofpacts_format(bucket->ofpacts, bucket->ofpacts_len, s); } } @@ -2181,7 +2332,7 @@ ofp_print_group_desc(struct ds *s, const struct ofp_header *oh) struct ofputil_group_desc gd; int retval; - retval = ofputil_decode_group_desc_reply(&gd, &b); + retval = ofputil_decode_group_desc_reply(&gd, &b, oh->version); if (retval) { if (retval != EOF) { ds_put_cstr(s, " ***parse error***"); @@ -2372,8 +2523,6 @@ ofp_to_string__(const struct ofp_header *oh, enum ofpraw raw, ofp_print_group_mod(string, oh); break; - case OFPTYPE_QUEUE_GET_CONFIG_REQUEST: - case OFPTYPE_QUEUE_GET_CONFIG_REPLY: case OFPTYPE_TABLE_FEATURES_STATS_REQUEST: case OFPTYPE_TABLE_FEATURES_STATS_REPLY: ofp_print_not_implemented(string); @@ -2431,6 +2580,10 @@ ofp_to_string__(const struct ofp_header *oh, enum ofpraw raw, ofp_print_port_mod(string, oh); break; + case OFPTYPE_TABLE_MOD: + ofp_print_table_mod(string, oh); + break; + case OFPTYPE_METER_MOD: ofp_print_meter_mod(string, oh); break; @@ -2439,10 +2592,21 @@ ofp_to_string__(const struct ofp_header *oh, enum ofpraw raw, case OFPTYPE_BARRIER_REPLY: break; + case OFPTYPE_QUEUE_GET_CONFIG_REQUEST: + ofp_print_queue_get_config_request(string, oh); + break; + + case OFPTYPE_QUEUE_GET_CONFIG_REPLY: + ofp_print_queue_get_config_reply(string, oh); + break; + case OFPTYPE_ROLE_REQUEST: case OFPTYPE_ROLE_REPLY: ofp_print_role_message(string, oh); break; + case OFPTYPE_ROLE_STATUS: + ofp_print_role_status_message(string, oh); + break; case OFPTYPE_METER_STATS_REQUEST: case OFPTYPE_METER_CONFIG_STATS_REQUEST: