Increase buffers for hotplug and cmdline for UML
[project/procd.git] / plug / hotplug.c
index ca1e823..075062b 100644 (file)
@@ -399,6 +399,18 @@ static struct json_script_ctx jctx = {
        .handle_file = rule_handle_file,
 };
 
+static void hotplug_handler_debug(struct blob_attr *data)
+{
+       char *str;
+
+       if (debug < 3)
+               return;
+
+       str = blobmsg_format_json(data, true);
+       DEBUG(3, "%s\n", str);
+       free(str);
+}
+
 static void hotplug_handler(struct uloop_fd *u, unsigned int ev)
 {
        int i = 0;
@@ -421,7 +433,7 @@ static void hotplug_handler(struct uloop_fd *u, unsigned int ev)
                i += l;
        }
        blobmsg_close_table(&b, index);
-       DEBUG(3, "%s\n", blobmsg_format_json(b.head, true));
+       hotplug_handler_debug(b.head);
        json_script_run(&jctx, rule_file, blob_data(b.head));
 }
 
@@ -441,6 +453,7 @@ void hotplug_last_event(uloop_timeout_handler handler)
 void hotplug(char *rules)
 {
        struct sockaddr_nl nls;
+       int nlbufsize = 512 * 1024;
 
        rule_file = strdup(rules);
        memset(&nls,0,sizeof(struct sockaddr_nl));
@@ -457,6 +470,11 @@ void hotplug(char *rules)
                exit(1);
        }
 
+       if (setsockopt(hotplug_fd.fd, SOL_SOCKET, SO_RCVBUFFORCE, &nlbufsize, sizeof(nlbufsize))) {
+               ERROR("Failed to resize receive buffer: %s\n", strerror(errno));
+               exit(1);
+       }
+
        json_script_init(&jctx);
        queue_proc.cb = queue_proc_cb;
        uloop_fd_add(&hotplug_fd, ULOOP_READ);