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… #47

Open dingjs1421 opened 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.

cvubrugier commented 6 years ago

Hi @dingjs1421 and thank you for your patch!

I have added some review comments.

I saw that you opened and closed another pull request (#46). I think it is not necessary to create a new pull request when you modify your patch: just git push --force your changes and it should update the existing pull request.

I will be off for a few days so please be patient.

dingjs1421 commented 6 years ago

Hi @cvubrugier : thank you so much for quick reply. While I didn't see your review comments.

heroin-moose commented 3 years ago

This patch works for me as intended if a target has a single TPG. If I add more TPGs only the portals from the first TPG are seen on the Windows iSNS server.