[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lxc-devel
Subject:    [lxc-devel] [lxd/master] unix-hotplug: fix uevent injection
From:       brauner on Github <lxc-bot () linuxcontainers ! org>
Date:       2020-05-27 14:48:21
Message-ID: 5ece7db5.1c69fb81.7159b.2ff9SMTPIN_ADDED_MISSING () mx ! google ! com
[Download RAW message or body]

[Attachment #2 (text/x-mailbox)]

The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7452

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

[Attachment #3 (text/plain)]

From 5b5d38b5481f5b6dcfa95ef7e1834c86b6e30640 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner@ubuntu.com>
Date: Wed, 27 May 2020 16:44:53 +0200
Subject: [PATCH] unix-hotplug: fix uevent injection

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
 lxd/devices.go | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lxd/devices.go b/lxd/devices.go
index 5060c1788c..3442765652 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -112,12 +112,15 @@ func deviceNetlinkListener() (chan []string, chan []string, chan device.USBEvent
 			}
 			ueventLen := 0
 			ueventParts := strings.Split(string(ueventBuf), "\x00")
-			props := map[string]string{}
-			for _, part := range ueventParts {
+			for i, part := range ueventParts {
 				if strings.HasPrefix(part, "SEQNUM=") {
-					continue
+					ueventParts = append(ueventParts[:i], ueventParts[i+1:]...)
+					break
 				}
+			}
 
+			props := map[string]string{}
+			for _, part := range ueventParts {
 				// libudev string prefix distinguishes udev events from kernel uevents
 				if strings.HasPrefix(part, "libudev") {
 					udevEvent = true
@@ -136,6 +139,13 @@ func deviceNetlinkListener() (chan []string, chan []string, chan device.USBEvent
 
 			ueventLen--
 
+			if udevEvent {
+				// The kernel always prepends this and udev expects it.
+				kernelPrefix := fmt.Sprintf("%s@%s", props["ACTION"], props["DEVPATH"])
+				ueventParts = append([]string{kernelPrefix}, ueventParts...)
+				ueventLen += len(kernelPrefix)
+			}
+
 			if props["SUBSYSTEM"] == "cpu" && !udevEvent {
 				if props["DRIVER"] != "processor" {
 					continue

[Attachment #4 (text/plain)]

_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic