Modification_of_the_weak-modules_Script_for_OS_Compatibility

why涛2023-12-27openGauss

Symptom

Although the umdk-urma-kmod and umdk-urma-compat-ib-kmod dependencies are successfully installed, the system displays a message indicating that the ubcore.ko module in kernel 4.19.90-2012.5.0.0054.oe1.x86_64 is incompatible with the symbols of kernel 4.19.90-2109.1.0.0108.oe1.x86_64. When the modinfo and modprobe commands are used to view and load the .ko files, the .ko file cannot be found.

  • Install the umdk-urma-kmod dependency.

    [root@localhost dlock]# rpm -ivh umdk-urma-kmod-1.3.0-206.3.0.B130.x86_64.rpm 
    Verifying...                          ################################# [100%]
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:umdk-urma-kmod-1.3.0-206.3.0.B130################################# [100%]
    /var/tmp/rpm-tmp.wSpThz: line 2: fg: no job control
    Module ubcore.ko from kernel 4.19.90-2012.5.0.0054.oe1.x86_64 is not compatible   with kernel 4.19.90-2109.1.0.0108.oe1.x86_64 in symbols: memcpy_s memset_s
    Module uburma.ko from kernel 4.19.90-2012.5.0.0054.oe1.x86_64 is not compatible   with kernel 4.19.90-2109.1.0.0108.oe1.x86_64 in symbols: snprintf_s
  • Install the umdk-urma-compat-ib-kmod dependency.

    [root@localhost dlock]# rpm -ivh umdk-urma-compat-ib-kmod-1.3.0-206.3.0.B130.x86_64.rpm 
    Verifying...                          ################################# [100%]
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:umdk-urma-compat-ib-kmod-1.3.0-20################################# [100%]
    Module uboib.ko from kernel 4.19.90-2012.5.0.0054.oe1.x86_64 is not compatible   with kernel 4.19.90-2109.1.0.0108.oe1.x86_64 in symbols: ib_destroy_cq_user ib_register_client ib_set_client_data ib_destroy_qp_user rdma_query_gid ib_query_port ib_unregister_client memcpy_s __ib_create_cq ib_dealloc_pd_user backport_dependency_symbol ib_query_qp strcpy_s __ib_alloc_pd memset_s ib_create_qp
    Created symlink /etc/systemd/system/multi-user.target.wants/uboib-module.service → /usr/lib/systemd/system/uboib-module.service.

Possible Cause

The uboib module depends on OFED which is installed separately after the OS is installed. The OFED symbols are in /lib/modules/current_kernel_version/extra. When RPM dependencies are installed, the OFED symbols cannot be found when the weak-modules script is running, and the default symbols of the OS are used to correspond to the ubcore module. As a result, a compatibility error occurs.

OS Compatibility

Table 1 OS compatibility information

OS

Compatibility Issue Detected

openEuler 20.03 SP1 x86

Yes

openEuler 20.03 SP1 Arm

Yes

openEuler 20.03 SP3 x86

No

openEuler 20.03 SP3 Arm

No

openEuler 20.03 LTS x86

No

openEuler 20.03 LTS Arm

No

openEuler 22.03 LTS x86

No

openEuler 22.03 LTS Arm

No

Root Cause

The urma kernel version does not match the system version.

  • Run the rpm -ql umdk-urma-kmod command to check the minor kernel version used for urma compilation.

    /etc/modules-load.d/ubcore.conf
    /etc/modules-load.d/uburma.conf
    /lib/modules/4.19.90-2012.5.0.0054.oe1.x86_64/extra/urma
    /lib/modules/4.19.90-2012.5.0.0054.oe1.x86_64/extra/urma/ubcore.ko
    /lib/modules/4.19.90-2012.5.0.0054.oe1.x86_64/extra/urma/uburma.ko
    /usr/include/umdk
    /usr/src/ubcore/Module.symvers
  • Run the uname -r command to query the minor version of the OS.

    4.19.90-2109.1.0.0108.oe1.x86_64

According to the query result, the minor version of the kernel used for urma compilation does not match the minor version of the OS.

Direct Cause

The .ko file in use is not correctly obtained for compatibility check. As a result, the OS incorrectly determines that the .ko file is incompatible.

The weak-modules script checks OS compatibility as follows:

  1. Obtain the symbol table when the current OS kernel is compiled, which is recorded as S-kernel.
  2. Obtain the symbol tables of extra .ko files in /lib/modules/$module_krel/extra, which is recorded as S-extra.
  3. Combine the symbol tables in the first two steps into S-all.
  4. Obtain the symbol table of the .ko file to be checked, which is recorded as S-target.
  5. Check whether all symbols in S-target can be matched in S-all.
  • If all symbols in S-target can be found in S-all, the .ko file is determined as compatible. In this case, the symbolic link of the .ko file is created in /lib/modules/$(uname -r)/weak-updates/.
  • If any symbol in S-target cannot be found in S-all, the .ko file is considered incompatible and an error is reported. For details about error handling, see Solution.

Precautions and Recommendations

Before installing the RPM packages, check whether the minor kernel version used for urma compilation matches the minor version of the OS. If they match, install the RPM packages.

If not, refer to Solution.

Solution

Add the .ko files that have been installed using RPM to S-all to determine symbol dependency.

  1. Log in to the server and open the weak-modules script.

    vi /sbin/weak-modules
  2. Add the corresponding script to the white-background area shown in the following figure.

    The script is as follows:

    if type "nm" > /dev/null; then
        find -L /lib/modules/$krel -name '*.ko' \
        | xargs nm \
        | sed -nre 's:^[0]*([0-9a-f]{8}) A __crc_(.*):0x\1 \2:p'
    else
        for ko in `find -L /lib/modules/$krel -name '*.ko'`
        do
                modprobe --show-exports $ko 2>/dev/null
        done
    fi >> $tmpdir/symvers-$krel
  3. Save the content and perform the installation again.