diff options
author | rzalamena <rzalamena@openbsd.org> | 2016-11-18 19:07:44 +0000 |
---|---|---|
committer | rzalamena <rzalamena@openbsd.org> | 2016-11-18 19:07:44 +0000 |
commit | 7f8cd71137bc523064561f549808600d94d605a3 (patch) | |
tree | f1bb18d68f031fc4ab0cea4bff6a87234a29af1b /usr.sbin/switchd | |
parent | import from OpenSSL; (diff) | |
download | wireguard-openbsd-7f8cd71137bc523064561f549808600d94d605a3.tar.xz wireguard-openbsd-7f8cd71137bc523064561f549808600d94d605a3.zip |
Make switchd(8) use more strings just like tcpdump(8). While here remove
action field display from features request.
Diffstat (limited to 'usr.sbin/switchd')
-rw-r--r-- | usr.sbin/switchd/ofp13.c | 140 |
1 files changed, 67 insertions, 73 deletions
diff --git a/usr.sbin/switchd/ofp13.c b/usr.sbin/switchd/ofp13.c index 11fc46cbd5a..534563c3844 100644 --- a/usr.sbin/switchd/ofp13.c +++ b/usr.sbin/switchd/ofp13.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofp13.c,v 1.32 2016/11/18 16:56:09 reyk Exp $ */ +/* $OpenBSD: ofp13.c,v 1.33 2016/11/18 19:07:44 rzalamena Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -412,11 +412,11 @@ ofp13_validate_packet_in(struct switchd *sc, off = 0; if ((pin = ibuf_seek(ibuf, off, sizeof(*pin))) == NULL) return (-1); - log_debug("\tbuffer %d length %u reason %s table %u cookie 0x%016llx", - ntohl(pin->pin_buffer_id), + log_debug("\tbuffer %s length %u reason %s table %s cookie 0x%#016llx", + print_map(ntohl(pin->pin_buffer_id), ofp_pktout_map), ntohs(pin->pin_total_len), print_map(ntohs(pin->pin_reason), ofp_pktin_map), - pin->pin_table_id, + print_map(pin->pin_table_id, ofp_table_id_map), be64toh(pin->pin_cookie)); off += offsetof(struct ofp_packet_in, pin_match); @@ -485,9 +485,8 @@ ofp13_validate_packet_out(struct switchd *sc, return (-1); } - log_debug("\tbuffer %d port %s " - "actions length %u", - ntohl(pout->pout_buffer_id), + log_debug("\tbuffer %s port %s actions length %u", + print_map(ntohl(pout->pout_buffer_id), ofp_pktout_map), print_map(ntohl(pout->pout_in_port), ofp_port_map), ntohs(pout->pout_actions_len)); len = ntohl(pout->pout_actions_len); @@ -499,11 +498,12 @@ ofp13_validate_packet_out(struct switchd *sc, case OFP_ACTION_OUTPUT: ao = (struct ofp_action_output *)ah; log_debug("\t\taction type %s length %d " - "port %s max length %d", + "port %s max length %s", print_map(ntohs(ao->ao_type), ofp_action_map), ntohs(ao->ao_len), print_map(ntohs(ao->ao_port), ofp_port_map), - ntohs(ao->ao_max_len)); + print_map(ntohs(ao->ao_max_len), + ofp_controller_maxlen_map)); break; default: log_debug("\t\taction type %s length %d", @@ -630,11 +630,10 @@ ofp13_validate_features_reply(struct switchd *sc, if ((swf = ibuf_seek(ibuf, 0, sizeof(*swf))) == NULL) return (-1); - log_debug("\tdatapath_id %#llx nbuffers %u ntables %d aux_id %d " - "capabilities %#08x actions %#08x", + log_debug("\tdatapath_id %#016llx nbuffers %u ntables %d aux_id %d " + "capabilities %#08x", be64toh(swf->swf_datapath_id), ntohl(swf->swf_nbuffers), - swf->swf_ntables, swf->swf_aux_id, ntohl(swf->swf_capabilities), - ntohl(swf->swf_actions)); + swf->swf_ntables, swf->swf_aux_id, ntohl(swf->swf_capabilities)); return (0); } @@ -686,10 +685,11 @@ ofp13_validate_action(struct switchd *sc, struct ofp_header *oh, return (-1); *off += len; - log_debug("\t\taction %s len %lu port %s max_len %d", + log_debug("\t\taction %s len %lu port %s max_len %s", print_map(type, ofp_action_map), len, print_map(ntohl(ao->ao_port), ofp_port_map), - ntohs(ao->ao_max_len)); + print_map(ntohs(ao->ao_max_len), + ofp_controller_maxlen_map)); break; case OFP_ACTION_SET_MPLS_TTL: if (len != sizeof(*amt)) @@ -743,9 +743,9 @@ ofp13_validate_action(struct switchd *sc, struct ofp_header *oh, return (-1); *off += len; - log_debug("\t\taction %s len %lu group_id %u", + log_debug("\t\taction %s len %lu group_id %s", print_map(type, ofp_action_map), len, - ntohl(ag->ag_group_id)); + print_map(ntohl(ag->ag_group_id), ofp_group_id_map)); break; case OFP_ACTION_SET_NW_TTL: if (len != sizeof(*ant)) @@ -819,9 +819,9 @@ ofp13_validate_instruction(struct switchd *sc, struct ofp_header *oh, return (-1); *off += len; - log_debug("\tinstruction %s length %lu table_id %d", + log_debug("\tinstruction %s length %lu table_id %s", print_map(type, ofp_instruction_t_map), len, - igt->igt_table_id); + print_map(igt->igt_table_id, ofp_table_id_map)); break; case OFP_INSTRUCTION_T_WRITE_META: if (len != sizeof(*iwm)) @@ -831,7 +831,7 @@ ofp13_validate_instruction(struct switchd *sc, struct ofp_header *oh, *off += len; log_debug("\tinstruction %s length %lu " - "metadata %llu mask %llu", + "metadata %#016llx mask %#016llx", print_map(type, ofp_instruction_t_map), len, be64toh(iwm->iwm_metadata), be64toh(iwm->iwm_metadata_mask)); @@ -903,15 +903,18 @@ ofp13_validate_flow_mod(struct switchd *sc, if ((fm = ibuf_seek(ibuf, off, sizeof(*fm))) == NULL) return (-1); - log_debug("\tcommand %s table %d timeout (idle %d hard %d) " - "priority %d buffer_id %u out_port %u out_group %u " - "flags %#04x cookie %llu mask %llu", + log_debug("\tcommand %s table %s timeout (idle %d hard %d) " + "priority %d buffer_id %s out_port %s out_group %s " + "flags %#04x cookie %#016llx mask %#016llx", print_map(fm->fm_command, ofp_flowcmd_map), - fm->fm_table_id, ntohs(fm->fm_idle_timeout), - ntohs(fm->fm_hard_timeout), ntohs(fm->fm_priority), - ntohl(fm->fm_buffer_id), ntohl(fm->fm_out_port), - ntohl(fm->fm_out_group), ntohs(fm->fm_flags), - be64toh(fm->fm_cookie), be64toh(fm->fm_cookie_mask)); + print_map(fm->fm_table_id, ofp_table_id_map), + ntohs(fm->fm_idle_timeout), ntohs(fm->fm_hard_timeout), + ntohs(fm->fm_priority), + print_map(ntohl(fm->fm_buffer_id), ofp_pktout_map), + print_map(ntohl(fm->fm_out_port), ofp_port_map), + print_map(ntohl(fm->fm_out_group), ofp_group_id_map), + ntohs(fm->fm_flags), be64toh(fm->fm_cookie), + be64toh(fm->fm_cookie_mask)); off += offsetof(struct ofp_flow_mod, fm_match); @@ -1152,32 +1155,16 @@ ofp13_flow_removed(struct switchd *sc, struct switch_connection *con, if ((fr = ibuf_getdata(ibuf, sizeof(*fr))) == NULL) return (-1); - log_debug("%s: cookie:%llu priority:%d reason:%d tableid:%d " - "duration(%u sec, %u nsec) idleto:%d hard:%d packet:%llu byte:%llu", - __func__, be64toh(fr->fr_cookie), ntohs(fr->fr_priority), - fr->fr_reason, fr->fr_table_id, ntohl(fr->fr_duration_sec), - ntohl(fr->fr_duration_nsec), ntohs(fr->fr_idle_timeout), - ntohs(fr->fr_hard_timeout), + log_debug("cookie %#016llx priority %d reason %s table_id %s " + "duration(%u sec, %u nsec) timeout idle %d hard %d " + "packet %llu byte %llu", + be64toh(fr->fr_cookie), ntohs(fr->fr_priority), + print_map(fr->fr_reason, ofp_flowrem_reason_map), + print_map(fr->fr_table_id, ofp_table_id_map), + ntohl(fr->fr_duration_sec), ntohl(fr->fr_duration_nsec), + ntohs(fr->fr_idle_timeout), ntohs(fr->fr_hard_timeout), be64toh(fr->fr_packet_count), be64toh(fr->fr_byte_count)); - switch (fr->fr_reason) { - case OFP_FLOWREM_REASON_IDLE_TIMEOUT: - log_debug("\tReason: IDLE TIMEOUT"); - break; - case OFP_FLOWREM_REASON_HARD_TIMEOUT: - log_debug("\tReason: HARD TIMEOUT"); - break; - case OFP_FLOWREM_REASON_DELETE: - log_debug("\tReason: DELETE"); - break; - case OFP_FLOWREM_REASON_GROUP_DELETE: - log_debug("\tReason: GROUP DELETE"); - break; - default: - log_debug("\tReason: UNKNOWN"); - break; - } - return (0); } @@ -1248,9 +1235,11 @@ ofp13_parse_tableproperties(struct ibuf *ibuf, struct ofp_table_features *tf) int remaining, type, length; int totallen, padsize, rv; - log_debug("Table %s (%d): max_entries %u config %u", + log_debug("Table %s (%d) max_entries %u config %u " + "metadata match %#016llx write %#016llx", tf->tf_name, tf->tf_tableid, ntohl(tf->tf_max_entries), - ntohl(tf->tf_config)); + ntohl(tf->tf_config), be64toh(tf->tf_metadata_match), + be64toh(tf->tf_metadata_write)); totallen = htons(tf->tf_length); remaining = totallen - sizeof(*tf); @@ -1453,14 +1442,15 @@ ofp13_multipart_reply_validate(struct switchd *sc, moff = off + sizeof(*fs); off += hlen; - log_debug("\tflow length %d table_id %d duration sec %u " + log_debug("\tflow length %d table_id %s duration sec %u " "nsec %u prio %d timeout idle %d hard %d flags %#04x " - "cookie %llu packet count %llu byte count %llu", - hlen, fs->fs_table_id, ntohl(fs->fs_duration_sec), - ntohl(fs->fs_duration_nsec), ntohs(fs->fs_priority), - ntohs(fs->fs_idle_timeout), ntohs(fs->fs_hard_timeout), - ntohs(fs->fs_flags), be64toh(fs->fs_cookie), - be64toh(fs->fs_packet_count), be64toh(fs->fs_byte_count)); + "cookie %#016llx packet count %llu byte count %llu", + hlen, print_map(fs->fs_table_id, ofp_table_id_map), + ntohl(fs->fs_duration_sec), ntohl(fs->fs_duration_nsec), + ntohs(fs->fs_priority), ntohs(fs->fs_idle_timeout), + ntohs(fs->fs_hard_timeout), ntohs(fs->fs_flags), + be64toh(fs->fs_cookie), be64toh(fs->fs_packet_count), + be64toh(fs->fs_byte_count)); om = &fs->fs_match; matchtype = ntohs(om->om_type); @@ -1500,12 +1490,14 @@ ofp13_multipart_reply_validate(struct switchd *sc, return (-1); hlen = ntohs(tf->tf_length); - log_debug("\ttable features length %d tableid %d name \"%s\" " - "metadata match %llu write %llu config %u max_entries %u", - hlen, tf->tf_tableid, tf->tf_name, + log_debug("\ttable features length %d tableid %s name \"%s\" " + "config %u max_entries %u " + "metadata match %#016llx write %#016llx", + hlen, print_map(tf->tf_tableid, ofp_table_id_map), + tf->tf_name,ntohl(tf->tf_config), + ntohl(tf->tf_max_entries), be64toh(tf->tf_metadata_match), - be64toh(tf->tf_metadata_write), ntohl(tf->tf_config), - ntohl(tf->tf_max_entries)); + be64toh(tf->tf_metadata_write)); remaining -= hlen; off += hlen; if (remaining) @@ -1582,12 +1574,13 @@ ofp13_multipart_request_validate(struct switchd *sc, om = &fsr->fsr_match; matchtype = ntohs(om->om_type); matchlen = ntohs(om->om_length); - log_debug("\ttable_id %d out_port %u out_group %u " - "cookie %llu mask %llu match type %s length %d " + log_debug("\ttable_id %s out_port %s out_group %s " + "cookie %#016llx mask %#016llx match type %s length %d " "(padded to %d)", - fsr->fsr_table_id, ntohl(fsr->fsr_out_port), - ntohl(fsr->fsr_out_group), be64toh(fsr->fsr_cookie), - be64toh(fsr->fsr_cookie_mask), + print_map(fsr->fsr_table_id, ofp_table_id_map), + print_map(ntohl(fsr->fsr_out_port), ofp_port_map), + print_map(ntohl(fsr->fsr_out_group), ofp_group_id_map), + be64toh(fsr->fsr_cookie), be64toh(fsr->fsr_cookie_mask), print_map(matchtype, ofp_match_map), matchlen, OFP_ALIGN(matchlen)); @@ -1831,8 +1824,9 @@ ofp13_setconfig_validate(struct switchd *sc, if ((cfg = ibuf_seek(ibuf, 0, sizeof(*cfg))) == NULL) return (-1); - log_debug("\tflags %#04x miss_send_len %d", - ntohs(cfg->cfg_flags), ntohs(cfg->cfg_miss_send_len)); + log_debug("\tflags %#04x miss_send_len %s", + ntohs(cfg->cfg_flags), print_map(ntohs(cfg->cfg_miss_send_len), + ofp_controller_maxlen_map)); return (0); } |