<div dir="ltr">It seems that strongswan version 5.0.4 (as well as 5.1.0 rc) writes a malformed scope ids to the kernel when installing policies and secure associations (using pfkey). The same setup on 4.5.3 does not add the scope ids in the kernel.<div>
<div><br></div><div><div>Kernel Policies (setkey -DP)</div><div>100:200:300:400::2[any] 100:200:300:400::1[any] any</div><div><span class="" style="white-space:pre">   </span>in ipsec</div><div><span class="" style="white-space:pre">   </span>esp/tunnel/100:200:300:400::2%672264932-100:200:300:400::1%672264932/unique:1</div>
<div><span class="" style="white-space:pre">    </span>created: Jul 30 14:09:03 2013  lastused: Jul 30 14:09:03 2013</div><div><span class="" style="white-space:pre">      </span>lifetime: 2147483647(s) validtime: 0(s)</div><div>
<span class="" style="white-space:pre">       </span>spid=76 seq=1 pid=37272</div><div><span class="" style="white-space:pre">    </span>refcnt=1</div><div>100:200:300:400::1[any] 100:200:300:400::2[any] any</div><div><span class="" style="white-space:pre"> </span>out ipsec</div>
<div><span class="" style="white-space:pre">    </span>esp/tunnel/100:200:300:400::1%672264932-100:200:300:400::2%672264932/unique:1</div><div><span class="" style="white-space:pre">      </span>created: Jul 30 14:09:03 2013  lastused: Jul 30 14:09:03 2013</div>
<div><span class="" style="white-space:pre">    </span>lifetime: 2147483647(s) validtime: 0(s)</div><div><span class="" style="white-space:pre">    </span>spid=75 seq=0 pid=37272</div><div><span class="" style="white-space:pre">    </span>refcnt=1</div>
<div><br></div><div>Note the traffic selectors: esp/tunnel/100:200:300:400::1%672264932-100:200:300:400::2%672264932/unique:1<br></div><div>A "strange" %6722... appended to the ip6 addresses</div><div><br></div>
<div>Part of the pfkey messages sent from strongswan to the kernel (setkey -x) is as follows:<br></div><div>sadb_msg{ version=2 type=14 errno=0 satype=0</div><div>  len=26 reserved=0 seq=3 pid=35371</div><div>sadb_ext{ len=10 type=18 }</div>
<div>sadb_x_policy{ type=2 dir=2 id=37 }</div><div> { len=64 proto=50 mode=2 level=3 reqid=1</div><div>sockaddr{ len=28 family=28 port=0</div><div>  flowinfo=0x00000001, scope_id=0x2811f2e4</div><div> 01000200 03000400 00000000 00000001  }</div>
<div>sockaddr{ len=28 family=28 port=0</div><div>  flowinfo=0x00000001, scope_id=0x2811f2e4</div><div> 01000200 03000400 00000000 00000002  }</div><div> }</div><div><br></div><div>Note the line: flowinfo=0x00000001, scope_id=0x2811f2e4</div>
<div>It looks like the "strange" number seen in the SPD traffic selector is passed as a scope_id attribute with setkey.</div><div><br></div><div><br></div><div>The pfkey plugin gets these scope id values to write into the SAD and policies. I inserted a debug statement in libhydra/plugins/kernel_pfkey/kernel_pfkey_ipsec.c (+- line 865) to print out the scope_id of the host address passed in, and it contains the scope_ids seen in the SPD (kernel policies)</div>
<div><br></div><div><br></div><div><br></div><div>My ipsec connection setup:</div><div>conn six</div><div>        also=certificate</div><div>        auto=route</div><div>        left=100:200:300:400::1</div><div>        right=100:200:300:400::2</div>
<div>        rightid="XXXXXXXXXXXXX"</div><div><br></div><div>My inteface config</div><div>em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500</div><div><span class="" style="white-space:pre">    </span>options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM></div>
<div><span class="" style="white-space:pre">    </span>ether 00:0c:29:79:f8:d6</div><div><span class="" style="white-space:pre">    </span>inet6 fe80::20c:29ff:fe79:f8d6%em1 prefixlen 64 scopeid 0x4 </div><div><span class="" style="white-space:pre">       </span>inet 10.37.1.10 netmask 0xffffff00 broadcast 10.37.1.255</div>
<div><span class="" style="white-space:pre">    </span>inet6 100:200:300:400::1 prefixlen 64 </div><div><span class="" style="white-space:pre">     </span>nd6 options=3<PERFORMNUD,ACCEPT_RTADV></div><div><span class="" style="white-space:pre">       </span>media: Ethernet autoselect (1000baseT <full-duplex>)</div>
<div><span class="" style="white-space:pre">    </span>status: active</div></div><div><br></div><div>Regards</div><div>Riaan Kruger</div></div></div>