X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fofp-util.c;h=9210413a1417f15d78b9e07df12b0f3623f3d932;hb=6e11a6a15519561d932a018b2ca19dc3acee87c2;hp=f0e0c69eb9cb8e8df457accf786701be6e4e3296;hpb=5c47debbf0518135d75a3426eb136b1e01eb0845;p=openvswitch diff --git a/lib/ofp-util.c b/lib/ofp-util.c index f0e0c69e..9210413a 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -20,6 +20,7 @@ #include #include "byte-order.h" #include "classifier.h" +#include "multipath.h" #include "nx-match.h" #include "ofp-util.h" #include "ofpbuf.h" @@ -471,7 +472,7 @@ ofputil_decode_nxst_request(const struct ofp_header *oh, }; static const struct ofputil_msg_category nxst_request_category = { - "Nicira extension statistics", + "Nicira extension statistics request", nxst_requests, ARRAY_SIZE(nxst_requests), OFP_MKERR(OFPET_BAD_REQUEST, OFPBRC_BAD_SUBTYPE) }; @@ -505,7 +506,7 @@ ofputil_decode_nxst_reply(const struct ofp_header *oh, }; static const struct ofputil_msg_category nxst_reply_category = { - "Nicira extension statistics", + "Nicira extension statistics reply", nxst_replies, ARRAY_SIZE(nxst_replies), OFP_MKERR(OFPET_BAD_REQUEST, OFPBRC_BAD_SUBTYPE) }; @@ -1636,9 +1637,23 @@ check_action_exact_len(const union ofp_action *a, unsigned int len, unsigned int required_len) { if (len != required_len) { - VLOG_DBG_RL(&bad_ofmsg_rl, - "action %u has invalid length %"PRIu16" (must be %u)\n", - a->type, ntohs(a->header.len), required_len); + VLOG_WARN_RL(&bad_ofmsg_rl, "action %"PRIu16" has invalid length " + "%"PRIu16" (must be %u)\n", + ntohs(a->type), ntohs(a->header.len), required_len); + return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN); + } + return 0; +} + +static int +check_nx_action_exact_len(const struct nx_action_header *a, + unsigned int len, unsigned int required_len) +{ + if (len != required_len) { + VLOG_WARN_RL(&bad_ofmsg_rl, + "Nicira action %"PRIu16" has invalid length %"PRIu16" " + "(must be %u)\n", + ntohs(a->subtype), ntohs(a->len), required_len); return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN); } return 0; @@ -1703,8 +1718,8 @@ check_nicira_action(const union ofp_action *a, unsigned int len, int error; if (len < 16) { - VLOG_DBG_RL(&bad_ofmsg_rl, - "Nicira vendor action only %u bytes", len); + VLOG_WARN_RL(&bad_ofmsg_rl, + "Nicira vendor action only %u bytes", len); return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN); } nah = (const struct nx_action_header *) a; @@ -1722,19 +1737,19 @@ check_nicira_action(const union ofp_action *a, unsigned int len, case NXAST_DROP_SPOOFED_ARP: case NXAST_SET_QUEUE: case NXAST_POP_QUEUE: - return check_action_exact_len(a, len, 16); + return check_nx_action_exact_len(nah, len, 16); case NXAST_REG_MOVE: - error = check_action_exact_len(a, len, - sizeof(struct nx_action_reg_move)); + error = check_nx_action_exact_len(nah, len, + sizeof(struct nx_action_reg_move)); if (error) { return error; } return nxm_check_reg_move((const struct nx_action_reg_move *) a, flow); case NXAST_REG_LOAD: - error = check_action_exact_len(a, len, - sizeof(struct nx_action_reg_load)); + error = check_nx_action_exact_len(nah, len, + sizeof(struct nx_action_reg_load)); if (error) { return error; } @@ -1744,11 +1759,22 @@ check_nicira_action(const union ofp_action *a, unsigned int len, return 0; case NXAST_SET_TUNNEL64: - return check_action_exact_len(a, len, - sizeof(struct nx_action_set_tunnel64)); + return check_nx_action_exact_len( + nah, len, sizeof(struct nx_action_set_tunnel64)); + + case NXAST_MULTIPATH: + error = check_nx_action_exact_len( + nah, len, sizeof(struct nx_action_multipath)); + if (error) { + return error; + } + return multipath_check((const struct nx_action_multipath *) a); case NXAST_SNAT__OBSOLETE: default: + VLOG_WARN_RL(&bad_ofmsg_rl, + "unknown Nicira vendor action subtype %"PRIu16, + ntohs(nah->subtype)); return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_VENDOR_TYPE); } } @@ -1828,16 +1854,16 @@ validate_actions(const union ofp_action *actions, size_t n_actions, int error; if (n_slots > slots_left) { - VLOG_DBG_RL(&bad_ofmsg_rl, - "action requires %u slots but only %u remain", - n_slots, slots_left); + VLOG_WARN_RL(&bad_ofmsg_rl, + "action requires %u slots but only %u remain", + n_slots, slots_left); return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN); } else if (!len) { - VLOG_DBG_RL(&bad_ofmsg_rl, "action has invalid length 0"); + VLOG_WARN_RL(&bad_ofmsg_rl, "action has invalid length 0"); return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN); } else if (len % OFP_ACTION_ALIGN) { - VLOG_DBG_RL(&bad_ofmsg_rl, "action length %u is not a multiple " - "of %d", len, OFP_ACTION_ALIGN); + VLOG_WARN_RL(&bad_ofmsg_rl, "action length %u is not a multiple " + "of %d", len, OFP_ACTION_ALIGN); return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN); } @@ -2114,16 +2140,16 @@ ofputil_pull_actions(struct ofpbuf *b, unsigned int actions_len, union ofp_action **actionsp, size_t *n_actionsp) { if (actions_len % OFP_ACTION_ALIGN != 0) { - VLOG_DBG_RL(&bad_ofmsg_rl, "OpenFlow message actions length %u " - "is not a multiple of %d", actions_len, OFP_ACTION_ALIGN); + VLOG_WARN_RL(&bad_ofmsg_rl, "OpenFlow message actions length %u " + "is not a multiple of %d", actions_len, OFP_ACTION_ALIGN); goto error; } *actionsp = ofpbuf_try_pull(b, actions_len); if (*actionsp == NULL) { - VLOG_DBG_RL(&bad_ofmsg_rl, "OpenFlow message actions length %u " - "exceeds remaining message length (%zu)", - actions_len, b->size); + VLOG_WARN_RL(&bad_ofmsg_rl, "OpenFlow message actions length %u " + "exceeds remaining message length (%zu)", + actions_len, b->size); goto error; }