On Thu, 2013-10-03 at 22:56 +0200, Thomas Glanzmann wrote: > Add a new TPG attribute hide_from_unauthorized which is disabled by default. > > Signed-off-by: Thomas Glanzmann <thomas@xxxxxxxxxxxx> > --- > drivers/target/iscsi/iscsi_target_configfs.c | 16 ++++++++++++++++ > drivers/target/iscsi/iscsi_target_core.h | 2 ++ > drivers/target/iscsi/iscsi_target_tpg.c | 20 ++++++++++++++++++++ > drivers/target/iscsi/iscsi_target_tpg.h | 1 + > include/target/target_core_fabric.h | 1 + > 5 files changed, 40 insertions(+) > > diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c > index fd14525..c622ad5 100644 > --- a/drivers/target/iscsi/iscsi_target_configfs.c > +++ b/drivers/target/iscsi/iscsi_target_configfs.c > @@ -1041,6 +1041,11 @@ TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR); > */ > DEF_TPG_ATTRIB(prod_mode_write_protect); > TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR); > +/* > + * Define iscsi_tpg_attrib_s_hide_from_unauthorized > + */ > +DEF_TPG_ATTRIB(hide_from_unauthorized); > +TPG_ATTR(hide_from_unauthorized, S_IRUGO | S_IWUSR); > So as mentioned in the previous email, let's change this to demo_mode_discovery as it's slightly more descriptive about what the attribute is actually used for.. > static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { > &iscsi_tpg_attrib_authentication.attr, > @@ -1051,6 +1056,7 @@ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { > &iscsi_tpg_attrib_cache_dynamic_acls.attr, > &iscsi_tpg_attrib_demo_mode_write_protect.attr, > &iscsi_tpg_attrib_prod_mode_write_protect.attr, > + &iscsi_tpg_attrib_hide_from_unauthorized.attr, > NULL, > }; > Extra whitespace here.. > @@ -1848,6 +1854,14 @@ static int lio_tpg_check_prod_mode_write_protect( > return ISCSI_TPG_ATTRIB(tpg)->prod_mode_write_protect; > } > > +static int lio_tpg_check_hide_from_unauthorized( > + struct se_portal_group *se_tpg) > +{ > + struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; > + > + return ISCSI_TPG_ATTRIB(tpg)->hide_from_unauthorized; > +} > + > static void lio_tpg_release_fabric_acl( > struct se_portal_group *se_tpg, > struct se_node_acl *se_acl) > @@ -1960,6 +1974,8 @@ int iscsi_target_register_configfs(void) > &lio_tpg_check_demo_mode_write_protect; > fabric->tf_ops.tpg_check_prod_mode_write_protect = > &lio_tpg_check_prod_mode_write_protect; > + fabric->tf_ops.tpg_check_hide_from_unauthorized= > + &lio_tpg_check_hide_from_unauthorized; Give that only iscsi_target_mod needs to know about this attribute, there is no reason why it needs to be part of target_core_fabric_ops. So that said, it's fine to drop this part. > fabric->tf_ops.tpg_alloc_fabric_acl = &lio_tpg_alloc_fabric_acl; > fabric->tf_ops.tpg_release_fabric_acl = &lio_tpg_release_fabric_acl; > fabric->tf_ops.tpg_get_inst_index = &lio_tpg_get_inst_index; > diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h > index 9a5721b..94e6bb5 100644 > --- a/drivers/target/iscsi/iscsi_target_core.h > +++ b/drivers/target/iscsi/iscsi_target_core.h > @@ -58,6 +58,7 @@ > #define TA_DEMO_MODE_WRITE_PROTECT 1 > /* Disabled by default in production mode w/ explict ACLs */ > #define TA_PROD_MODE_WRITE_PROTECT 0 > +#define TA_HIDE_FROM_UNAUTHORIZED 0 > #define TA_CACHE_CORE_NPS 0 > > > @@ -769,6 +770,7 @@ struct iscsi_tpg_attrib { > u32 default_cmdsn_depth; > u32 demo_mode_write_protect; > u32 prod_mode_write_protect; > + u32 hide_from_unauthorized; > struct iscsi_portal_group *tpg; > }; > > diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c > index 4faeb47..2a09a93 100644 > --- a/drivers/target/iscsi/iscsi_target_tpg.c > +++ b/drivers/target/iscsi/iscsi_target_tpg.c > @@ -223,6 +223,7 @@ static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *tpg) > a->cache_dynamic_acls = TA_CACHE_DYNAMIC_ACLS; > a->demo_mode_write_protect = TA_DEMO_MODE_WRITE_PROTECT; > a->prod_mode_write_protect = TA_PROD_MODE_WRITE_PROTECT; > + a->hide_from_unauthorized = TA_HIDE_FROM_UNAUTHORIZED; > } > > int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg) > @@ -820,3 +821,22 @@ int iscsit_ta_prod_mode_write_protect( > > return 0; > } > + > +int iscsit_ta_hide_from_unauthorized( > + struct iscsi_portal_group *tpg, > + u32 flag) > +{ > + struct iscsi_tpg_attrib *a = &tpg->tpg_attrib; > + > + if ((flag != 0) && (flag != 1)) { > + pr_err("Illegal value %d\n", flag); > + return -EINVAL; > + } > + > + a->hide_from_unauthorized = flag; > + pr_debug("iSCSI_TPG[%hu] - Hide From Unauthorized bit:" > + " %s\n", tpg->tpgt, (a->hide_from_unauthorized) ? > + "ON" : "OFF"); > + > + return 0; > +} > diff --git a/drivers/target/iscsi/iscsi_target_tpg.h b/drivers/target/iscsi/iscsi_target_tpg.h > index b77693e..bfdd2ad 100644 > --- a/drivers/target/iscsi/iscsi_target_tpg.h > +++ b/drivers/target/iscsi/iscsi_target_tpg.h > @@ -37,5 +37,6 @@ extern int iscsit_ta_default_cmdsn_depth(struct iscsi_portal_group *, u32); > extern int iscsit_ta_cache_dynamic_acls(struct iscsi_portal_group *, u32); > extern int iscsit_ta_demo_mode_write_protect(struct iscsi_portal_group *, u32); > extern int iscsit_ta_prod_mode_write_protect(struct iscsi_portal_group *, u32); > +extern int iscsit_ta_hide_from_unauthorized(struct iscsi_portal_group *, u32); > > #endif /* ISCSI_TARGET_TPG_H */ > diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h > index 882b650e..5eb977e 100644 > --- a/include/target/target_core_fabric.h > +++ b/include/target/target_core_fabric.h > @@ -21,6 +21,7 @@ struct target_core_fabric_ops { > int (*tpg_check_demo_mode_cache)(struct se_portal_group *); > int (*tpg_check_demo_mode_write_protect)(struct se_portal_group *); > int (*tpg_check_prod_mode_write_protect)(struct se_portal_group *); > + int (*tpg_check_hide_from_unauthorized)(struct se_portal_group *); Ditto here.. --nab -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html