RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1939970 - [RFE] Sort network devices before matching by regex
Summary: [RFE] Sort network devices before matching by regex
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: tuned
Version: 8.3
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: rc
: ---
Assignee: Jaroslav Škarvada
QA Contact: Robin Hack
URL: https://github.com/redhat-performance...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-03-17 11:11 UTC by Yanir Quinn
Modified: 2021-11-10 10:04 UTC (History)
5 users (show)

Fixed In Version: tuned-2.16.0-0.1.rc1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-09 19:58:24 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4476 0 None None None 2021-11-09 19:58:50 UTC

Description Yanir Quinn 2021-03-17 11:11:23 UTC
Description of problem:

Since devices_udev_regex under [net] plugin depends on the way udev collects the device representations - it is not guaranteed that the regular expression will match due to the fact that the devices are not ordered.  

In order to guarantee a desired match the devices should be sorted alphabeticaly before the match procedure occurs.


Version-Release number of selected component (if applicable):


How reproducible:
Depends on the regex input

Steps to Reproduce:
Create a tuned.conf that contains the net plugin using a regex:

[net_test]
type=net 
devices_udev_regex=\bID_MODEL_ID=0x1000\b.*\bID_VENDOR_ID=0x1af4\b
<action on devices>


example use case: udev listed the devices in the following order :
ID_VENDOR_ID=0x1af4,ID_MODEL_ID=0x1000
(non v order)

Actual results:
<action on devices> was not applied


Expected results:
<action on devices> was applied  since we added the devices in an alphabetical order

Additional info:
alphabetical ordering should be done by the keys then the values.

Comment 2 Jaroslav Škarvada 2021-03-17 19:10:57 UTC
It seems the libudev API sorts it. After bit digging into the libudev implementation, it seems the udev_device_get_properties_list_entry sorts the properties alphabetically as a side effect of usage of udev_list_entry_add which is working over unique/hashed udev_list. The 'udevadm' tool doesn't use it, so its result is not sorted. But the libudev API documentation doesn't explicitly guarantee (I wasn't able to find such text) that the list is sorted. We could explicitly sort it in the TuneD, but I don't want to add redundant code and additional overhead.

@Lukas, can we rely on the fact that the following code outputs alphabetically (ASCII) sorted list of properties?

  struct udev_list_entry *list;
  struct udev_list_entry *node;

  list = udev_device_get_properties_list_entry (dev);

  udev_list_entry_foreach (node, list) {
    printf ("%s: %s\n", udev_list_entry_get_name(node), udev_list_entry_get_value(node));
  }

E.g. the following sorted output:

ID_ATA: 1
ID_BUS: ata
SCSI_TYPE: disk
SUBSYSTEM: block
TAGS: :systemd:

E.g. the ID_ATA is before TAGS. Is this behavior guaranteed in RHEL-7 and newer? Or could you point us to somebody who could answer this question?

Comment 3 Jaroslav Škarvada 2021-03-24 12:54:23 UTC
(In reply to Jaroslav Škarvada from comment #2)
> It seems the libudev API sorts it. After bit digging into the libudev
> implementation, it seems the udev_device_get_properties_list_entry sorts the
> properties alphabetically as a side effect of usage of udev_list_entry_add
> which is working over unique/hashed udev_list. The 'udevadm' tool doesn't
> use it, so its result is not sorted. But the libudev API documentation
> doesn't explicitly guarantee (I wasn't able to find such text) that the list
> is sorted. We could explicitly sort it in the TuneD, but I don't want to add
> redundant code and additional overhead.
> 
> @Lukas, can we rely on the fact that the following code outputs
> alphabetically (ASCII) sorted list of properties?
> 
>   struct udev_list_entry *list;
>   struct udev_list_entry *node;
> 
>   list = udev_device_get_properties_list_entry (dev);
> 
>   udev_list_entry_foreach (node, list) {
>     printf ("%s: %s\n", udev_list_entry_get_name(node),
> udev_list_entry_get_value(node));
>   }
> 
> E.g. the following sorted output:
> 
> ID_ATA: 1
> ID_BUS: ata
> SCSI_TYPE: disk
> SUBSYSTEM: block
> TAGS: :systemd:
> 
> E.g. the ID_ATA is before TAGS. Is this behavior guaranteed in RHEL-7 and
> newer? Or could you point us to somebody who could answer this question?

According to systemd upstream this behavior cannot be relied upon. Thanks Lukas for providing the answer (off channel).

Comment 4 Jaroslav Škarvada 2021-03-24 12:56:40 UTC
Upstream PR:
https://github.com/redhat-performance/tuned/pull/333

Comment 15 errata-xmlrpc 2021-11-09 19:58:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (tuned bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4476


Note You need to log in before you can comment on or make changes to this bug.