X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fofproto.c;h=aae85680ce72c34724586b69f29917575042cd98;hb=2e9d1b61b32867cf1343b3f1865610606d83adf5;hp=df5850f19d94473927311495b445f8d7ea2b9d25;hpb=dc4762edd02693770d392b8f6495deb7e52635bf;p=openvswitch diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index df5850f1..aae85680 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1354,6 +1354,60 @@ ofproto_is_alive(const struct ofproto *p) return !hmap_is_empty(&p->controllers); } +void +ofproto_get_ofproto_controller_info(const struct ofproto * ofproto, + struct shash *info) +{ + const struct ofconn *ofconn; + + shash_init(info); + + HMAP_FOR_EACH (ofconn, hmap_node, &ofproto->controllers) { + const struct rconn *rconn = ofconn->rconn; + const int last_error = rconn_get_last_error(rconn); + struct ofproto_controller_info *cinfo = xmalloc(sizeof *cinfo); + + shash_add(info, rconn_get_target(rconn), cinfo); + + cinfo->is_connected = rconn_is_connected(rconn); + cinfo->role = ofconn->role; + + cinfo->pairs.n = 0; + + if (last_error == EOF) { + cinfo->pairs.keys[cinfo->pairs.n] = "last_error"; + cinfo->pairs.values[cinfo->pairs.n++] = xstrdup("End of file"); + } else if (last_error > 0) { + cinfo->pairs.keys[cinfo->pairs.n] = "last_error"; + cinfo->pairs.values[cinfo->pairs.n++] = + xstrdup(strerror(last_error)); + } + + cinfo->pairs.keys[cinfo->pairs.n] = "state"; + cinfo->pairs.values[cinfo->pairs.n++] = + xstrdup(rconn_get_state(rconn)); + + cinfo->pairs.keys[cinfo->pairs.n] = "time_in_state"; + cinfo->pairs.values[cinfo->pairs.n++] = + xasprintf("%u", rconn_get_state_elapsed(rconn)); + } +} + +void +ofproto_free_ofproto_controller_info(struct shash *info) +{ + struct shash_node *node; + + SHASH_FOR_EACH (node, info) { + struct ofproto_controller_info *cinfo = node->data; + while (cinfo->pairs.n) { + free((char *) cinfo->pairs.values[--cinfo->pairs.n]); + } + free(cinfo); + } + shash_destroy(info); +} + /* Deletes port number 'odp_port' from the datapath for 'ofproto'. * * This is almost the same as calling dpif_port_del() directly on the @@ -2858,17 +2912,29 @@ xlate_set_dl_tci(struct action_xlate_ctx *ctx) } } +struct xlate_reg_state { + ovs_be16 vlan_tci; + ovs_be64 tun_id; +}; + static void -xlate_reg_move_action(struct action_xlate_ctx *ctx, - const struct nx_action_reg_move *narm) +save_reg_state(const struct action_xlate_ctx *ctx, + struct xlate_reg_state *state) { - ovs_be16 old_tci = ctx->flow.vlan_tci; - - nxm_execute_reg_move(narm, &ctx->flow); + state->vlan_tci = ctx->flow.vlan_tci; + state->tun_id = ctx->flow.tun_id; +} - if (ctx->flow.vlan_tci != old_tci) { +static void +update_reg_state(struct action_xlate_ctx *ctx, + const struct xlate_reg_state *state) +{ + if (ctx->flow.vlan_tci != state->vlan_tci) { xlate_set_dl_tci(ctx); } + if (ctx->flow.tun_id != state->tun_id) { + nl_msg_put_be64(ctx->odp_actions, ODPAT_SET_TUNNEL, ctx->flow.tun_id); + } } static void @@ -2880,6 +2946,7 @@ xlate_nicira_action(struct action_xlate_ctx *ctx, const struct nx_action_set_queue *nasq; const struct nx_action_multipath *nam; enum nx_action_subtype subtype = ntohs(nah->subtype); + struct xlate_reg_state state; ovs_be64 tun_id; assert(nah->vendor == htonl(NX_VENDOR_ID)); @@ -2912,12 +2979,18 @@ xlate_nicira_action(struct action_xlate_ctx *ctx, break; case NXAST_REG_MOVE: - xlate_reg_move_action(ctx, (const struct nx_action_reg_move *) nah); + save_reg_state(ctx, &state); + nxm_execute_reg_move((const struct nx_action_reg_move *) nah, + &ctx->flow); + update_reg_state(ctx, &state); break; case NXAST_REG_LOAD: + save_reg_state(ctx, &state); nxm_execute_reg_load((const struct nx_action_reg_load *) nah, &ctx->flow); + update_reg_state(ctx, &state); + break; case NXAST_NOTE: /* Nothing to do. */ @@ -3530,8 +3603,8 @@ put_nx_flow_stats(struct ofconn *ofconn, struct rule *rule, act_len = sizeof *rule->actions * rule->n_actions; - start_len = (*replyp)->size; append_nxstats_reply(sizeof *nfs + NXM_MAX_LEN + act_len, ofconn, replyp); + start_len = (*replyp)->size; reply = *replyp; nfs = ofpbuf_put_uninit(reply, sizeof *nfs); @@ -5007,7 +5080,7 @@ ofproto_unixctl_trace(struct unixctl_conn *conn, const char *args_, struct ds result; struct flow flow; uint16_t in_port; - ovs_be32 tun_id; + ovs_be64 tun_id; char *s; ofpbuf_init(&packet, strlen(args) / 2); @@ -5029,7 +5102,7 @@ ofproto_unixctl_trace(struct unixctl_conn *conn, const char *args_, goto exit; } - tun_id = ntohl(strtoul(tun_id_s, NULL, 10)); + tun_id = htonll(strtoull(tun_id_s, NULL, 10)); in_port = ofp_port_to_odp_port(atoi(in_port_s)); packet_s = ofpbuf_put_hex(&packet, packet_s, NULL);