open-iscsi / target-isns

Target-isns is an iSNS client for the Linux LIO iSCSI target
GNU General Public License v2.0
16 stars 19 forks source link

Attach PGT for each PG Portal, set PGT as NULL explicily for not-allo… #46

Closed dingjs1421 closed 6 years ago

dingjs1421 commented 6 years ago

…wed portals.

According to RFC4171, an entity may have multiple Portals, each Portal consists of its IP address and port. Besides each PG (portal group) follows by its own PG IP addresses and TCP/UDP ports. In order for a Portal to provide access to an iSCSI Node, the PGT of the PG object MUST be non-NULL. If the PGT value registered for a specified Portal and iSCSI Node is NULL, or if no PGT value is registered, then the Portal does not provide access to that iSCSI Node in the Entity.

So PGT is a selector, that controls from which portal iSCSI Node is allowed to access. The current implementation attachs a default PGT with value of 0x00000001 at the end of each iSCSI target, means each iSCSI target is allowed to access from all portals ignoring np config in iSCSI target.

For example: a host has two interfaces : eth0:192.168.1.10/255.255.255.0 eth1:10.40.1.20/255.255.255.0 Also has two iSCSI targets: target 1: iqn.1994-11.com.netgear:nas-e7-5b-4c:0e261f2a:group1, np is set as 192.168.1.10:3260. target 2: iqn.1994-11.com.netgear:nas-e7-5b-4c:0e261f2a:group1, np is set as 10.40.1.20:3260.

Obviously target 1 is allowed to access from eth0 and target 2 is only from eth1. While currebt target-isns notifies iSNS server target1 and target 2 can be accessed from both two interfaces, may cause connection failure.

This change is to attach PGT for each PG Portal, set PGT as NULL explicily for not-allowed portals.

dingjs1421 commented 6 years ago

will re-submit another pull request.