X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fofp-print.c;h=2d9e02657d7dd6f034bff7340a97930cb12649d2;hb=d2bb2799e1b7cf2177140cf4ca8a60312c87625a;hp=26d11489fae7c333fcced08eaf97df02e0394d4e;hpb=e41a91300789b03398007ebdb6025ca9d94fec26;p=openvswitch diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 26d11489..2d9e0265 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -184,6 +184,7 @@ static void ofp_print_port_name(struct ds *string, uint16_t port) ds_put_cstr(string, name); } + static void print_note(struct ds *string, const struct nx_action_note *nan) { @@ -200,15 +201,45 @@ print_note(struct ds *string, const struct nx_action_note *nan) } } +static int +nx_action_len(enum nx_action_subtype subtype) +{ + switch (subtype) { + case NXAST_SNAT__OBSOLETE: return -1; + case NXAST_RESUBMIT: return sizeof(struct nx_action_resubmit); + case NXAST_SET_TUNNEL: return sizeof(struct nx_action_set_tunnel); + case NXAST_DROP_SPOOFED_ARP: + return sizeof(struct nx_action_drop_spoofed_arp); + case NXAST_SET_QUEUE: return sizeof(struct nx_action_set_queue); + case NXAST_POP_QUEUE: return sizeof(struct nx_action_pop_queue); + case NXAST_REG_MOVE: return sizeof(struct nx_action_reg_move); + case NXAST_REG_LOAD: return sizeof(struct nx_action_reg_load); + case NXAST_NOTE: return -1; + case NXAST_SET_TUNNEL64: return sizeof(struct nx_action_set_tunnel64); + default: return -1; + } +} + static void ofp_print_nx_action(struct ds *string, const struct nx_action_header *nah) { uint16_t subtype = ntohs(nah->subtype); + int required_len = nx_action_len(subtype); + int len = ntohs(nah->len); + + if (required_len != -1 && required_len != len) { + ds_put_format(string, "***Nicira action %"PRIu16" wrong length: %d***", + subtype, len); + return; + } if (subtype <= TYPE_MAXIMUM(enum nx_action_subtype)) { + const struct nx_action_set_tunnel64 *nast64; const struct nx_action_set_tunnel *nast; const struct nx_action_set_queue *nasq; const struct nx_action_resubmit *nar; + const struct nx_action_reg_move *move; + const struct nx_action_reg_load *load; switch ((enum nx_action_subtype) subtype) { case NXAST_RESUBMIT: @@ -240,8 +271,19 @@ ofp_print_nx_action(struct ds *string, const struct nx_action_header *nah) return; case NXAST_REG_MOVE: + move = (const struct nx_action_reg_move *) nah; + nxm_format_reg_move(move, string); + return; + case NXAST_REG_LOAD: - /* XXX */ + load = (const struct nx_action_reg_load *) nah; + nxm_format_reg_load(load, string); + return; + + case NXAST_SET_TUNNEL64: + nast64 = (struct nx_action_set_tunnel64 *) nah; + ds_put_format(string, "set_tunnel64:%#"PRIx64, + ntohll(nast64->tun_id)); return; case NXAST_SNAT__OBSOLETE: @@ -1187,6 +1229,8 @@ ofp_print_nxst_flow_reply(struct ds *string, const struct ofp_header *oh) int match_len; int error; + ds_put_char(string, '\n'); + fs = ofpbuf_try_pull(&b, sizeof *fs); if (!fs) { ds_put_format(string, " ***%td leftover bytes at end***", b.size); @@ -1242,7 +1286,6 @@ ofp_print_nxst_flow_reply(struct ds *string, const struct ofp_header *oh) ds_put_char(string, ' '); ofp_print_actions(string, (const struct ofp_action_header *) actions, n_actions * sizeof *actions); - ds_put_char(string, '\n'); } }