openSUSE / wicked

Framework for network configuration
https://en.opensuse.org/Portal:Wicked
GNU General Public License v2.0
101 stars 50 forks source link

compat-suse: fix infiniband type detection from ifname #1015

Closed cfconrad closed 4 months ago

cfconrad commented 4 months ago
mtomaschewski commented 4 months ago

I'd change the "foo or bar, I don't know" + checking pkey & device twice and use instead (pasted diff):

-   if ((pkey == NULL) != (device == NULL)) {

-       ni_error("ifcfg-%s: Missing one of IPOIB_DEVICE or IPOIB_PKEY variable",

-               dev->name);

-       ni_string_free(&device);

-       return -1;

-   }

-

-   if (pkey) {

+   if (pkey || device) {

        unsigned long tmp = ~0UL;

        if (ni_parse_ulong(pkey, &tmp, 16) < 0 || tmp > 0xffff) {

-           ni_error("ifcfg-%s: Cannot parse infiniband child key number",

-               dev->name);

+           ni_error("ifcfg-%s: %s %s partition key (IPOIB_PKEY)", dev->name,

+                   pkey ? "Cannot parse" : "Missing",

+                   ni_linktype_type_to_name(NI_IFTYPE_INFINIBAND_CHILD));

            ni_string_free(&device);

            return -1;

        }

        if (!ni_netdev_name_is_valid(device)) {

-           ni_error("ifcfg-%s: %s parent device name is not valid",

-                   dev->name, ni_linktype_type_to_name(NI_IFTYPE_INFINIBAND_CHILD));

+           ni_error("ifcfg-%s: %s %s parent device name (IPOIB_DEVICE)", dev->name,

+                   device ? "Invalid" : "Missing",

+                   ni_linktype_type_to_name(NI_IFTYPE_INFINIBAND_CHILD));

            ni_string_free(&device);

            return -1;

        }