Am Donnerstag, den 07.07.2016, 15:46 +0200 schrieb Guus Sliepen:
> The patch looks fine except for one thing:
> 
> > 
> > -        ip link set up dev %link%; \
> > -        ip link add link %link% name %iface0% type vlan id
> > %vlan_id%; \
> > +        if test -d /sys/class/net/%link%/device/infiniband; then \
> > +            echo 0x%vlan_id% > /sys/class/net/%link%/create_child;
> > \
> ifupdown converts the VLAN ID to a decimal number before passing it
> in
> %vlan_id%. So I believe the "0x" prefix is in error here. Can you
> check
> this? I don't have any InfiniBand devices myself, unfortunately.

Checked again. We want to use %vlan_id1% there. An updated patch is
attached. It would be nice to have it included in stretch.

My previous patch worked, because the conversion to integer failed, as
some debug output revealed:

$ sudo ifup ib0.dddd
link: ib0, vlan_id0: dddd, iface0: ib0.dddd,
vlan_id1: dddd, vlan_id: dddd

-- 
Benjamin Drung
System Developer
Debian & Ubuntu Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Email: benjamin.dr...@profitbricks.com
URL:  http://www.profitbricks.com

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506B.
Geschäftsführer: Andreas Gauger, Achim Weiss.

From dbf88e8b4f1535a6b83a666630f52539d756e51b Mon Sep 17 00:00:00 2001
From: Benjamin Drung <benjamin.dr...@profitbricks.com>
Date: Wed, 6 Jul 2016 16:26:16 +0200
Subject: [PATCH] Add Infiniband partition key support

InfiniBand supports partitions for network isolation using a 16-bit
partition key. This is similar to VLANs. You can use IPoIB to run IP
traffic over a InfiniBand partition. The IP devices is called
$interface.$partition where $partition is the hex value of the
partition. Example: ib0.beef ib0.d00d are two partitions of the
InfiniBand device ib0.

ifupdown assumes that the InfiniBand partitions are VLANs and tries to
run "ip link add link" (ifup) and "ip link del" (ifdown) on them, which
will cause error messages.

Instead ifupdown should create the InfiniBand partitions if they are not
present on ifup by running
"echo 0x%partition% > /sys/class/net/%device%/create_child"
and delete it on ifdown by running
"echo 0x%partition% > /sys/class/net/%device%/delete_child".

diff --git a/debian/changelog b/debian/changelog
diff --git a/link.defn b/link.defn
index 5e296a6..456c710 100644
--- a/link.defn
+++ b/link.defn
@@ -13,13 +13,21 @@ method none
     if test -d /sys/class/net/%link% -a \
             ! -d /sys/class/net/%iface0% ; \
     then \
-        ip link set up dev %link%; \
-        ip link add link %link% name %iface0% type vlan id %vlan_id%; \
+        if test -d /sys/class/net/%link%/device/infiniband; then \
+            echo 0x%vlan_id1% > /sys/class/net/%link%/create_child; \
+        else \
+            ip link set up dev %link%; \
+            ip link add link %link% name %iface0% type vlan id %vlan_id%; \
+        fi; \
     fi if (iface_has(".") && (!var_set_anywhere("bridge_ports", ifd)))
     -ip link set up dev %iface% 2>/dev/null \
 	if (iface_is_lo())
   down
-    ip link del %iface% if (iface_has(".") && (!iface_has(":")) && (!var_set_anywhere("bridge_ports", ifd)))
+    if test -d /sys/class/net/%link%/device/infiniband; then \
+        echo 0x%vlan_id1% > /sys/class/net/%link%/delete_child; \
+    else \
+        ip link del %iface%; \
+    fi if (iface_has(".") && (!iface_has(":")) && (!var_set_anywhere("bridge_ports", ifd)))
     -ip link set down dev %iface% 2>/dev/null \
 	if (iface_is_lo())
 
-- 
2.7.4

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to