aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Documentation/ABI
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2017-05-09 15:22:30 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-25 18:30:51 +0200
commitf36776fafbaa0094390dd4e7e3e29805e0b82730 (patch)
treecc7d6eac4fc119b41179288c55ed8c04d12e1d0c /Documentation/ABI
parentdriver core: platform: fix race condition with driver_override (diff)
downloadwireguard-linux-f36776fafbaa0094390dd4e7e3e29805e0b82730.tar.xz
wireguard-linux-f36776fafbaa0094390dd4e7e3e29805e0b82730.zip
kobject: support passing in variables for synthetic uevents
This patch makes it possible to pass additional arguments in addition to uevent action name when writing /sys/.../uevent attribute. These additional arguments are then inserted into generated synthetic uevent as additional environment variables. Before, we were not able to pass any additional uevent environment variables for synthetic uevents. This made it hard to identify such uevents properly in userspace to make proper distinction between genuine uevents originating from kernel and synthetic uevents triggered from userspace. Also, it was not possible to pass any additional information which would make it possible to optimize and change the way the synthetic uevents are processed back in userspace based on the originating environment of the triggering action in userspace. With the extra additional variables, we are able to pass through this extra information needed and also it makes it possible to synchronize with such synthetic uevents as they can be clearly identified back in userspace. The format for writing the uevent attribute is following: ACTION [UUID [KEY=VALUE ...] There's no change in how "ACTION" is recognized - it stays the same ("add", "change", "remove"). The "ACTION" is the only argument required to generate synthetic uevent, the rest of arguments, that this patch adds support for, are optional. The "UUID" is considered as transaction identifier so it's possible to use the same UUID value for one or more synthetic uevents in which case we logically group these uevents together for any userspace listeners. The "UUID" is expected to be in "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" format where "x" is a hex digit. The value appears in uevent as "SYNTH_UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" environment variable. The "KEY=VALUE" pairs can contain alphanumeric characters only. It's possible to define zero or more more pairs - each pair is then delimited by a space character " ". Each pair appears in synthetic uevents as "SYNTH_ARG_KEY=VALUE" environment variable. That means the KEY name gains "SYNTH_ARG_" prefix to avoid possible collisions with existing variables. To pass the "KEY=VALUE" pairs, it's also required to pass in the "UUID" part for the synthetic uevent first. If "UUID" is not passed in, the generated synthetic uevent gains "SYNTH_UUID=0" environment variable automatically so it's possible to identify this situation in userspace when reading generated uevent and so we can still make a difference between genuine and synthetic uevents. Signed-off-by: Peter Rajnoha <prajnoha@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'Documentation/ABI')
-rw-r--r--Documentation/ABI/testing/sysfs-uevent47
1 files changed, 47 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-uevent b/Documentation/ABI/testing/sysfs-uevent
new file mode 100644
index 000000000000..d7ac99072a16
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-uevent
@@ -0,0 +1,47 @@
+What: /sys/.../uevent
+Date: May 2017
+KernelVersion: 4.12
+Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
+Description:
+ Enable passing additional variables for synthetic uevents that
+ are generated by writing /sys/.../uevent file.
+
+ Recognized extended format is ACTION [UUID [KEY=VALUE ...].
+
+ The ACTION is compulsory - it is the name of the uevent action
+ ("add", "change", "remove"). There is no change compared to
+ previous functionality here. The rest of the extended format
+ is optional.
+
+ You need to pass UUID first before any KEY=VALUE pairs.
+ The UUID must be in "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ format where 'x' is a hex digit. The UUID is considered to be
+ a transaction identifier so it's possible to use the same UUID
+ value for one or more synthetic uevents in which case we
+ logically group these uevents together for any userspace
+ listeners. The UUID value appears in uevent as
+ "SYNTH_UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" environment
+ variable.
+
+ If UUID is not passed in, the generated synthetic uevent gains
+ "SYNTH_UUID=0" environment variable automatically.
+
+ The KEY=VALUE pairs can contain alphanumeric characters only.
+ It's possible to define zero or more pairs - each pair is then
+ delimited by a space character ' '. Each pair appears in
+ synthetic uevent as "SYNTH_ARG_KEY=VALUE". That means the KEY
+ name gains "SYNTH_ARG_" prefix to avoid possible collisions
+ with existing variables.
+
+ Example of valid sequence written to the uevent file:
+
+ add fe4d7c9d-b8c6-4a70-9ef1-3d8a58d18eed A=1 B=abc
+
+ This generates synthetic uevent including these variables:
+
+ ACTION=add
+ SYNTH_ARG_A=1
+ SYNTH_ARG_B=abc
+ SYNTH_UUID=fe4d7c9d-b8c6-4a70-9ef1-3d8a58d18eed
+Users:
+ udev, userspace tools generating synthetic uevents