|
The C Source, Patches and (shudder!) Bugs
-
tjjh89017
- Posts: 4
- Joined: 31 Jul 2022, 15:26
Post
by tjjh89017 » 31 Jul 2022, 15:49
I tested Huawei ME909s-821 LTE module and found a bug in usb-modeswitch-data's udev rules.
I attached the patch in this thread.
Root cause:
Huawei ME909s only needs to change configuration.
If I override Configuration in /etc/usb_modeswitch.d/12d1:15c1 with Configuration=3
usb-modeswitch will not change ID/product.
and udev's rules is incorrect.
It will be triggered again, and kill/stop the first systemctl restart usb_modeswitch@<DEV>.service
Configuration will not be applied correctly and leave it as Configuration=0 (unconfigurated).
I used echo 3 >/sys.../bConfigurationValue.
It will be rollback because the above reason. (udev will be triggered again and again)
I executed usb_modeswitch maually it will complain this device is unconfigurated.
Fix:
Udev "match" is AND operatation.
Code: Select all SUBSYSTEM!="usb", ACTION!="add",, GOTO="modeswitch_rules_end"
It will match device is usb and return FALSE in this match.
It will never check the ACTION.
Fix it with
Code: Select all SUBSYSTEM!="usb", GOTO="modeswitch_rules_end"
ACTION!="add", GOTO="modeswitch_rules_end"
It works fine and properly again.
Thanks a lot
Date Huang
-
Attachments
-
- 0001-Avoid-udev-rule-being-triggered-again-in-change-even.patch
- (1.15 KiB) Downloaded 314 times
-
dominicburton
- Posts: 1
- Joined: 11 Nov 2022, 17:55
Post
by dominicburton » 11 Nov 2022, 18:40
I found that the Huawei ME909s-821 LTE module does not work on Ubuntu 18.04. I believe it is because of the usb-modeswitch-data's udev rules.
-
mikhailnov
- Posts: 1
- Joined: 03 Feb 2023, 11:52
Post
by mikhailnov » 03 Feb 2023, 11:57
Thanks for your patch. It helps to make this modem Huawei ME906s LTE M.2 Module work. I have made an a bit different version of it:
From 98b596d73f789b6a787e89c7dd908fa1c5954042 Mon Sep 17 00:00:00 2001
From: Mikhail Novosyolov < m.novosyolov@rosalinux.ru>
Date: Mon, 30 Jan 2023 15:43:47 +0300
Subject: [PATCH] Call usb_modeswitch only on "add" event
Modern Linux kernel have the following events:
Code: Select all static const char *kobject_actions[] = {
[KOBJ_ADD] = "add",
[KOBJ_REMOVE] = "remove",
[KOBJ_CHANGE] = "change",
[KOBJ_MOVE] = "move",
[KOBJ_ONLINE] = "online",
[KOBJ_OFFLINE] = "offline",
[KOBJ_BIND] = "bind",
[KOBJ_UNBIND] = "unbind",
};
(from Linux 6.1, lib/kobject_uevent.c)
Changelog of systemd (udev) 247 says that new events appeared and changes were made in udev:
https://github.com/systemd/systemd/blob/v247/NEWS#L5
Calling usm_modeswitch makes sense only on "add" event and makes no sense on "bind" (which means that a kernel module supporting this device has been assiciated with it), "unbind", "change" (which means quite a lot of situations) etc.
It was called multiple times for Huawei ME906s LTE M.2 modem which prevented it from working properly. It works now.
Based on solution from Date Huang < tjjh89017@hotmail.com> at viewtopic.php?f=2&t=3034&p=19976
Co-authored-by: Date Huang < tjjh89017@hotmail.com>
Co-authored-by: SgAkErRu < sulmpx60@yandex.ru>
Code: Select all
---
40-usb_modeswitch.rules | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/40-usb_modeswitch.rules b/40-usb_modeswitch.rules
index dae3e3a..16f404b 100644
--- a/40-usb_modeswitch.rules
+++ b/40-usb_modeswitch.rules
@@ -3,13 +3,13 @@
# Works with usb_modeswitch versions >= 2.4.0. Slash before %k parameter
# is for compatibility only. Versions >= 2.5.0 don't need it.
#
-ACTION!="add|change", GOTO="modeswitch_rules_end"
+ACTION!="add", GOTO="modeswitch_rules_end"
# Adds a symlink "gsmmodem[n]" to the lowest ttyUSB port with interrupt
# transfer; checked against a list of known modems, or else no action
KERNEL=="ttyUSB*", ATTRS{bNumConfigurations}=="*", PROGRAM="usb_modeswitch --symlink-name %p %s{idVendor} %s{idProduct} %E{PRODUCT}", SYMLINK+="%c"
-SUBSYSTEM!="usb", ACTION!="add",, GOTO="modeswitch_rules_end"
+SUBSYSTEM!="usb", GOTO="modeswitch_rules_end"
# Generic entry for most Huawei devices, excluding Android phones
ATTRS{idVendor}=="12d1", ATTRS{manufacturer}!="Android", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"
--
2.35.2
-
Attachments
-
- 0001-Call-usb_modeswitch-only-on-add-event.patch
- (2.37 KiB) Downloaded 131 times
-
x260
- Posts: 1
- Joined: 19 Mar 2023, 19:56
Post
by x260 » 19 Mar 2023, 20:07
mikhailnov wrote: ↑03 Feb 2023, 11:57
Thanks for your patch. It helps to make this modem Huawei ME906s LTE M.2 Module work. I have made an a bit different version of it:
From 98b596d73f789b6a787e89c7dd908fa1c5954042 Mon Sep 17 00:00:00 2001
From: Mikhail Novosyolov < m.novosyolov@rosalinux.ru>
Date: Mon, 30 Jan 2023 15:43:47 +0300
Subject: [PATCH] Call usb_modeswitch only on "add" event
Modern Linux kernel have the following events:
Code: Select all static const char *kobject_actions[] = {
[KOBJ_ADD] = "add",
[KOBJ_REMOVE] = "remove",
[KOBJ_CHANGE] = "change",
[KOBJ_MOVE] = "move",
[KOBJ_ONLINE] = "online",
[KOBJ_OFFLINE] = "offline",
[KOBJ_BIND] = "bind",
[KOBJ_UNBIND] = "unbind",
};
(from Linux 6.1, lib/kobject_uevent.c)
Changelog of systemd (udev) 247 says that new events appeared and changes were made in udev:
https://github.com/systemd/systemd/blob/v247/NEWS#L5
Calling usm_modeswitch makes sense only on "add" event and makes no sense on "bind" (which means that a kernel module supporting this device has been assiciated with it), "unbind", "change" (which means quite a lot of situations) etc.
It was called multiple times for Huawei ME906s LTE M.2 modem which prevented it from working properly. It works now.
Based on solution from Date Huang < tjjh89017@hotmail.com> at viewtopic.php?f=2&t=3034&p=19976
Co-authored-by: Date Huang < tjjh89017@hotmail.com>
Co-authored-by: SgAkErRu < sulmpx60@yandex.ru>
Code: Select all
---
40-usb_modeswitch.rules | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/40-usb_modeswitch.rules b/40-usb_modeswitch.rules
index dae3e3a..16f404b 100644
--- a/40-usb_modeswitch.rules
+++ b/40-usb_modeswitch.rules
@@ -3,13 +3,13 @@
# Works with usb_modeswitch versions >= 2.4.0. Slash before %k parameter
# is for compatibility only. Versions >= 2.5.0 don't need it.
#
-ACTION!="add|change", GOTO="modeswitch_rules_end"
+ACTION!="add", GOTO="modeswitch_rules_end"
# Adds a symlink "gsmmodem[n]" to the lowest ttyUSB port with interrupt
# transfer; checked against a list of known modems, or else no action
KERNEL=="ttyUSB*", ATTRS{bNumConfigurations}=="*", PROGRAM="usb_modeswitch --symlink-name %p %s{idVendor} %s{idProduct} %E{PRODUCT}", SYMLINK+="%c"
-SUBSYSTEM!="usb", ACTION!="add",, GOTO="modeswitch_rules_end"
+SUBSYSTEM!="usb", GOTO="modeswitch_rules_end"
# Generic entry for most Huawei devices, excluding Android phones
ATTRS{idVendor}=="12d1", ATTRS{manufacturer}!="Android", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"
--
2.35.2
I have Lenovo Thinkpad X260 laptop and Huawei Technologies Co., Ltd. ME906s LTE M.2 Module (12d1:15c1).
I could not use the modem with Fedora 37's Linux 6.1.18 kernel.
After applied your patch to my /lib/udev/rules.d/40-usb_modeswitch.rules file, it worked!
I think this patch should applied to usb_modeswitch itself.
-
tjjh89017
- Posts: 4
- Joined: 31 Jul 2022, 15:26
Post
by tjjh89017 » 10 Apr 2023, 19:23
mikhailnov wrote: ↑03 Feb 2023, 11:57
Thanks for your patch. It helps to make this modem Huawei ME906s LTE M.2 Module work. I have made an a bit different version of it:
From 98b596d73f789b6a787e89c7dd908fa1c5954042 Mon Sep 17 00:00:00 2001
From: Mikhail Novosyolov < m.novosyolov@rosalinux.ru>
Date: Mon, 30 Jan 2023 15:43:47 +0300
Subject: [PATCH] Call usb_modeswitch only on "add" event
Modern Linux kernel have the following events:
Code: Select all static const char *kobject_actions[] = {
[KOBJ_ADD] = "add",
[KOBJ_REMOVE] = "remove",
[KOBJ_CHANGE] = "change",
[KOBJ_MOVE] = "move",
[KOBJ_ONLINE] = "online",
[KOBJ_OFFLINE] = "offline",
[KOBJ_BIND] = "bind",
[KOBJ_UNBIND] = "unbind",
};
(from Linux 6.1, lib/kobject_uevent.c)
Changelog of systemd (udev) 247 says that new events appeared and changes were made in udev:
https://github.com/systemd/systemd/blob/v247/NEWS#L5
Calling usm_modeswitch makes sense only on "add" event and makes no sense on "bind" (which means that a kernel module supporting this device has been assiciated with it), "unbind", "change" (which means quite a lot of situations) etc.
It was called multiple times for Huawei ME906s LTE M.2 modem which prevented it from working properly. It works now.
Based on solution from Date Huang < tjjh89017@hotmail.com> at viewtopic.php?f=2&t=3034&p=19976
Co-authored-by: Date Huang < tjjh89017@hotmail.com>
Co-authored-by: SgAkErRu < sulmpx60@yandex.ru>
Code: Select all
---
40-usb_modeswitch.rules | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/40-usb_modeswitch.rules b/40-usb_modeswitch.rules
index dae3e3a..16f404b 100644
--- a/40-usb_modeswitch.rules
+++ b/40-usb_modeswitch.rules
@@ -3,13 +3,13 @@
# Works with usb_modeswitch versions >= 2.4.0. Slash before %k parameter
# is for compatibility only. Versions >= 2.5.0 don't need it.
#
-ACTION!="add|change", GOTO="modeswitch_rules_end"
+ACTION!="add", GOTO="modeswitch_rules_end"
# Adds a symlink "gsmmodem[n]" to the lowest ttyUSB port with interrupt
# transfer; checked against a list of known modems, or else no action
KERNEL=="ttyUSB*", ATTRS{bNumConfigurations}=="*", PROGRAM="usb_modeswitch --symlink-name %p %s{idVendor} %s{idProduct} %E{PRODUCT}", SYMLINK+="%c"
-SUBSYSTEM!="usb", ACTION!="add",, GOTO="modeswitch_rules_end"
+SUBSYSTEM!="usb", GOTO="modeswitch_rules_end"
# Generic entry for most Huawei devices, excluding Android phones
ATTRS{idVendor}=="12d1", ATTRS{manufacturer}!="Android", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"
--
2.35.2
Hi @mikhailnov
Please note some devices will switch mode and change the device id and need to trigger udev rule again.
and change event might need this command to be executed Code: Select all KERNEL=="ttyUSB*", ATTRS{bNumConfigurations}=="*", PROGRAM="usb_modeswitch --symlink-name %p %s{idVendor} %s{idProduct} %E{PRODUCT}", SYMLINK+="%c"
I looked back to previous version and only modified one line to make sure the behavior is as same as the previous.
So could you help to check this line should be patched or not?
I don't have confidence about that.
Code: Select all ACTION!="add|change", GOTO="modeswitch_rules_end"
Thanks your patch!
By the way, I think we should ask distro package maintainer to help us to contact the author.
I used email, contact me link below, but no luck.
We don't get any reply from the author.
-
saferot
- Posts: 2
- Joined: 31 Aug 2023, 02:16
-
Contact:
Post
by saferot » 31 Aug 2023, 02:24
tjjh89017 wrote: ↑31 Jul 2022, 15:49
I tested Huawei ME909s-821 Jumping Shell LTE module and found a bug in usb-modeswitch-data's udev rules.
I attached the patch in this thread.
Root cause:
Huawei ME909s only needs to change configuration.
If I override Configuration in /etc/usb_modeswitch.d/12d1:15c1 monkey mart with Configuration=3
usb-modeswitch will not change ID/product.
and udev's rules is incorrect.
It will be triggered again, and kill/stop the first systemctl restart usb_modeswitch@<DEV>.service
Configuration will not be applied correctly and leave it as Configuration=0 (unconfigurated).
I used echo 3 >/sys.../bConfigurationValue.
It will be rollback because the above reason. dreadhead parkour (udev will be triggered again and again)
I executed usb_modeswitch maually it will complain this device is unconfigurated.
Fix:
Udev "match" is AND operatation.
Code: Select all SUBSYSTEM!="usb", ACTION!="add",, GOTO="modeswitch_rules_end"
It will match device is usb and return FALSE in this match.
It will never check the ACTION.
Fix it with
Code: Select all SUBSYSTEM!="usb", GOTO="modeswitch_rules_end"
ACTION!="add", GOTO="modeswitch_rules_end"
It works fine and properly again.
Thanks a lot
Date Huang
It's impressive how you've dug into the intricacies of udev rules and usb_modeswitch behavior. Your fix makes sense, ensuring proper execution and preventing unintended triggers. Collaborative problem-solving like this keeps the tech community thriving. Kudos!
-
jesse99
- Posts: 2
- Joined: 17 Oct 2023, 05:46
Post
by jesse99 » 17 Oct 2023, 05:50
An alternative method to address this issue is by modifying the udev rule conditions to explicitly include both SUBSYSTEM and ACTION without changing the original conditions. crossover grid
Code: Select all SUBSYSTEM=="usb", ACTION=="add", GOTO="modeswitch_rules_continue"
GOTO="modeswitch_rules_end"
LABEL="modeswitch_rules_continue"
# Add your udev rule actions here
-
carolynquin
- Posts: 2
- Joined: 09 Nov 2023, 06:52
Post
by carolynquin » 09 Nov 2023, 06:57
In my yocto-base Linux distribution if I modify a rule about USB storage plug in (sorry not about network changes like in your question) and execute udevadm control --reload-rules the rule change doesn't need a reboot drift hunters
-
timothyferriss
- Posts: 5
- Joined: 11 Oct 2023, 09:48
Post
by timothyferriss » 16 Nov 2023, 04:49
This is a valuable contribution to the community. I have reviewed your patch and it appears to be correct. I will apply it to the next release of usb-modeswitch-data.
retro bowl
-
superedan
- Posts: 2
- Joined: 25 Nov 2023, 03:43
Post
by superedan » 25 Nov 2023, 03:45
You can create specific rules for your device that match based on properties like the device's vendor, product ID, Watermelon Game or other attributes. Ensure that the rules for your device are configured correctly.
-
y2mate1
- Posts: 1
- Joined: 06 Dec 2023, 17:21
-
Contact:
Post
by y2mate1 » 06 Dec 2023, 17:22
Y2 Mate was thoroughly tested on dozens of browsers to ensure that it works. It works on all browsers and all platforms.
Source: https://y2mate.net.pk/
-
mariahcarey
- Posts: 4
- Joined: 29 Dec 2023, 11:57
Post
by mariahcarey » 29 Dec 2023, 12:01
The suggested fix separates these conditions into two lines to ensure that both conditions are checked independently, wordle game thank
-
mariarivera
- Posts: 1
- Joined: 05 Feb 2024, 04:39
Post
by mariarivera » 04 Mar 2024, 11:52
it seems like the user is discussing a technical issue related to udev rules and a patch for fixing it. In a short response mentioning the "rice purity test," one could say: "While troubleshooting udev rules, it's important to ensure they trigger correctly to avoid issues. By the way, have you ever taken the rice purity test?
|
|