The C Source, Patches and (shudder!) Bugs
Post Reply
lkundrak
Posts: 24
Joined: 22 Jun 2016, 14:17

usb_modeswitch: don't pass busname to the dispatcher

Post by lkundrak » 09 Nov 2016, 13:49

In the better case it's empty and useless, in worst case it's something very irrelevant (a bus name of a random parent of a device that happens to have one, such as the usb controller) and harmful -- when passed to the dispatcher it appends it to the sysfs path, making it invalid.

To add insult to injury, the / is escaped as _ for systemd (as opposed to the correct "\x2d"), so the dispatcher gets even more confused.

Both of these issues exhibit on Odriod C2, with DWC2 platform USB controlers, that happen to have device-tree names of "dwc2_a" and "dwc2_b". Udev uses that for %b of the modem device:

When the actual device path is /sys/devices/platform/dwc2_b/usb1/1-1/1-1.4/1-1.4:1.0 (and a link in /sys/bus/usb/devices/1-1.4:1.0), udev helper starts the service with dwc2_b_1-1.4:1.0 argument, which the dispatcher translates to /sys/bus/usb/devices/dwc2/b. /sys/bus/usb/devices/dwc2_b/1-1.4:1.0 would still be incorrect.

Let's just lay it to rest.
Attachments
0001-usb_modeswitch-don-t-pass-busname-to-the-dispatcher.patch
Proposed patch
(4.75 KiB) Downloaded 680 times

lkundrak
Posts: 24
Joined: 22 Jun 2016, 14:17

Re: usb_modeswitch: don't pass busname to the dispatcher

Post by lkundrak » 09 Nov 2016, 15:53

Whoops, the patch was wrong, since it's the usb_modeswitch-data that passes the %b argument.
Updated the patch to keep the compatibility.

This is not too nice though.

Ideally, the data package should tag the device for the modeswitch with

Code: Select all

TAG+="usb_modeswitch"
rule and then the usb_modeswitch package should ship a rule that does

Code: Select all

TAG=="usb_modeswitch", SYSTEMD_WANTS+="usb_modeswitch@%k"
without the shell script and involved overhead (including the format of command line parameters).
Attachments
0001-usb_modeswitch-don-t-pass-busname-to-the-dispatcher.patch
Updated patch.
(4.94 KiB) Downloaded 659 times

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: usb_modeswitch: don't pass busname to the dispatcher

Post by Josh » 10 Nov 2016, 23:39

I was actually thinking along the same lines myself regarding the busname. There is some redundancy involved from a time when udev was not very consistent yet between versions.

Regarding the 'ideal' solution, I'm not sure about dropping 'upstart' and old systems support though. Also, the shell script provides a facility to symlink the serial modem ports to use for the actual PPP connection (again, a provision from a time when systems didn't know what to do with all those serial USB ports of a 3G modem).

I know that Network and modem manager nowadays handle practically all classic USB modems correctly. The question is: are there any important long-running distributions that may be disrupted by changes like these?

Post Reply