X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utilities%2Fovs-ofctl.c;h=54e4b0c329c216bae9f8546f33d6af3081a1b31d;hb=d12513f7075373d07565f66ab4c781b73b00867d;hp=4deb82b1edfd3319c09ff5ea0c9b1c296500e24d;hpb=0df0e81da2351902c93e8a1ae1933523a91a8262;p=openvswitch diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 4deb82b1..54e4b0c3 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -337,6 +337,24 @@ dump_trivial_stats_transaction(const char *vconn_name, uint8_t stats_type) dump_stats_transaction(vconn_name, request); } +/* Sends 'request', which should be a request that only has a reply if an error + * occurs, and waits for it to succeed or fail. If an error does occur, prints + * it and exits with an error. */ +static void +dump_noreply_transaction(struct vconn *vconn, struct ofpbuf *request) +{ + struct ofpbuf *reply; + + update_openflow_length(request); + run(vconn_transact_noreply(vconn, request, &reply), + "talking to %s", vconn_get_name(vconn)); + if (reply) { + ofp_print(stderr, reply->data, reply->size, 2); + exit(1); + } + ofpbuf_delete(reply); +} + static void do_show(int argc OVS_UNUSED, char *argv[]) { @@ -509,12 +527,12 @@ static void do_add_flow(int argc OVS_UNUSED, char *argv[]) { struct vconn *vconn; - struct ofpbuf *buffer; + struct ofpbuf *request; - buffer = parse_ofp_flow_mod_str(argv[2], OFPFC_ADD); + request = parse_ofp_flow_mod_str(argv[2], OFPFC_ADD); open_vconn(argv[1], &vconn); - send_openflow_buffer(vconn, buffer); + dump_noreply_transaction(vconn, request); vconn_close(vconn); } @@ -532,7 +550,7 @@ do_add_flows(int argc OVS_UNUSED, char *argv[]) open_vconn(argv[1], &vconn); while ((b = parse_ofp_add_flow_file(file)) != NULL) { - send_openflow_buffer(vconn, b); + dump_noreply_transaction(vconn, b); } vconn_close(vconn); fclose(file); @@ -548,7 +566,7 @@ do_mod_flows(int argc OVS_UNUSED, char *argv[]) command = strict ? OFPFC_MODIFY_STRICT : OFPFC_MODIFY; buffer = parse_ofp_flow_mod_str(argv[2], command); open_vconn(argv[1], &vconn); - send_openflow_buffer(vconn, buffer); + dump_noreply_transaction(vconn, buffer); vconn_close(vconn); } @@ -562,23 +580,7 @@ static void do_del_flows(int argc, char *argv[]) buffer = parse_ofp_flow_mod_str(argc > 2 ? argv[2] : "", command); open_vconn(argv[1], &vconn); - send_openflow_buffer(vconn, buffer); - vconn_close(vconn); -} - -static void -do_tun_cookie(int argc OVS_UNUSED, char *argv[]) -{ - struct nxt_tun_id_cookie *tun_id_cookie; - struct ofpbuf *buffer; - struct vconn *vconn; - - tun_id_cookie = make_nxmsg(sizeof *tun_id_cookie, NXT_TUN_ID_FROM_COOKIE, - &buffer); - tun_id_cookie->set = !strcmp(argv[2], "true"); - - open_vconn(argv[1], &vconn); - send_openflow_buffer(vconn, buffer); + dump_noreply_transaction(vconn, buffer); vconn_close(vconn); } @@ -606,7 +608,7 @@ do_monitor(int argc, char *argv[]) osc = make_openflow(sizeof *osc, OFPT_SET_CONFIG, &buf); osc->miss_send_len = htons(miss_send_len); - send_openflow_buffer(vconn, buf); + dump_noreply_transaction(vconn, buf); } monitor_vconn(vconn); } @@ -682,7 +684,7 @@ do_mod_port(int argc OVS_UNUSED, char *argv[]) } open_vconn(argv[1], &vconn); - send_openflow_buffer(vconn, request); + dump_noreply_transaction(vconn, request); vconn_close(vconn); } @@ -870,7 +872,6 @@ static const struct command all_commands[] = { { "add-flows", 2, 2, do_add_flows }, { "mod-flows", 2, 2, do_mod_flows }, { "del-flows", 1, 2, do_del_flows }, - { "tun-cookie", 2, 2, do_tun_cookie }, { "dump-ports", 1, 2, do_dump_ports }, { "mod-port", 3, 3, do_mod_port }, { "probe", 1, 1, do_probe },