+ case NSCTL_REQ_CONTROL:
+ {
+ struct param_control param = {
+ config->cluster_iam_master,
+ request.argc,
+ request.argv,
+ 0,
+ NULL,
+ };
+
+ int r = run_plugins(PLUGIN_CONTROL, ¶m);
+
+ if (r == PLUGIN_RET_ERROR)
+ {
+ response.type = NSCTL_RES_ERR;
+ response.argc = 1;
+ response.argv[0] = param.additional
+ ? param.additional
+ : "error returned by plugin";
+ }
+ else if (r == PLUGIN_RET_NOTMASTER)
+ {
+ static char msg[] = "must be run on master: 000.000.000.000";
+
+ response.type = NSCTL_RES_ERR;
+ response.argc = 1;
+ if (config->cluster_master_address)
+ {
+ strcpy(msg + 23, inet_toa(config->cluster_master_address));
+ response.argv[0] = msg;
+ }
+ else
+ {
+ response.argv[0] = "must be run on master: none elected";
+ }
+ }
+ else if (!(param.response & NSCTL_RESPONSE))
+ {
+ response.type = NSCTL_RES_ERR;
+ response.argc = 1;
+ response.argv[0] = param.response
+ ? "unrecognised response value from plugin"
+ : "unhandled action";
+ }
+ else
+ {
+ response.type = param.response;
+ response.argc = 0;
+ if (param.additional)
+ {
+ response.argc = 1;
+ response.argv[0] = param.additional;
+ }
+ }
+ }
+
+ break;
+
+ default:
+ response.type = NSCTL_RES_ERR;
+ response.argc = 1;
+ response.argv[0] = "error unpacking control packet";
+ }
+
+ buf = calloc(NSCTL_MAX_PKT_SZ, 1);
+ if (!buf)
+ {
+ LOG(2, ntohl(addr->sin_addr.s_addr), 0, 0, "Failed to allocate nsctl response\n");
+ return;
+ }
+
+ r = pack_control(buf, NSCTL_MAX_PKT_SZ, response.type, response.argc, response.argv);
+ if (r > 0)