iscsi: Rename access control functions of target
Naming rule of access control of iSCSI target does not reveal its intention. Hence change it before refactoring to avoid unnecessary repeated procedure. Change-Id: I4064ec0a5a2b52244b6de3958ee2ab41342d1a57 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/381248 Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
eee268fea8
commit
1674f37ac9
@ -53,7 +53,7 @@
|
||||
#define MAX_MASKBUF 128
|
||||
|
||||
static bool
|
||||
spdk_iscsi_tgt_node_allow_ipv6(const char *netmask, const char *addr)
|
||||
spdk_iscsi_ipv6_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
{
|
||||
struct in6_addr in6_mask;
|
||||
struct in6_addr in6_addr;
|
||||
@ -111,7 +111,7 @@ spdk_iscsi_tgt_node_allow_ipv6(const char *netmask, const char *addr)
|
||||
}
|
||||
|
||||
static bool
|
||||
spdk_iscsi_tgt_node_allow_ipv4(const char *netmask, const char *addr)
|
||||
spdk_iscsi_ipv4_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
{
|
||||
struct in_addr in4_mask;
|
||||
struct in_addr in4_addr;
|
||||
@ -156,7 +156,7 @@ spdk_iscsi_tgt_node_allow_ipv4(const char *netmask, const char *addr)
|
||||
}
|
||||
|
||||
static bool
|
||||
spdk_iscsi_tgt_node_allow_netmask(const char *netmask, const char *addr)
|
||||
spdk_iscsi_netmask_allow_addr(const char *netmask, const char *addr)
|
||||
{
|
||||
if (netmask == NULL || addr == NULL)
|
||||
return false;
|
||||
@ -164,11 +164,11 @@ spdk_iscsi_tgt_node_allow_netmask(const char *netmask, const char *addr)
|
||||
return true;
|
||||
if (netmask[0] == '[') {
|
||||
/* IPv6 */
|
||||
if (spdk_iscsi_tgt_node_allow_ipv6(netmask, addr))
|
||||
if (spdk_iscsi_ipv6_netmask_allow_addr(netmask, addr))
|
||||
return true;
|
||||
} else {
|
||||
/* IPv4 */
|
||||
if (spdk_iscsi_tgt_node_allow_ipv4(netmask, addr))
|
||||
if (spdk_iscsi_ipv4_netmask_allow_addr(netmask, addr))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -210,7 +210,7 @@ spdk_iscsi_tgt_node_access(struct spdk_iscsi_conn *conn,
|
||||
SPDK_DEBUGLOG(SPDK_TRACE_ISCSI,
|
||||
"netmask=%s, addr=%s\n",
|
||||
imask->mask, addr);
|
||||
if (spdk_iscsi_tgt_node_allow_netmask(imask->mask, addr)) {
|
||||
if (spdk_iscsi_netmask_allow_addr(imask->mask, addr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -227,7 +227,7 @@ denied:
|
||||
}
|
||||
|
||||
static bool
|
||||
spdk_iscsi_tgt_node_visible(struct spdk_iscsi_tgt_node *target, const char *iqn)
|
||||
spdk_iscsi_tgt_node_allow_iscsi_name(struct spdk_iscsi_tgt_node *target, const char *iqn)
|
||||
{
|
||||
struct spdk_iscsi_init_grp *igp;
|
||||
struct spdk_iscsi_initiator_name *iname;
|
||||
@ -297,7 +297,7 @@ spdk_iscsi_send_tgts(struct spdk_iscsi_conn *conn, const char *iiqn,
|
||||
&& strcasecmp(tiqn, target->name) != 0) {
|
||||
continue;
|
||||
}
|
||||
rc = spdk_iscsi_tgt_node_visible(target, iiqn);
|
||||
rc = spdk_iscsi_tgt_node_allow_iscsi_name(target, iiqn);
|
||||
if (rc == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -118,10 +118,10 @@ allow_ipv6_allowed(void)
|
||||
netmask = "[2001:ad6:1234::]/48";
|
||||
addr = "2001:ad6:1234:5678:9abc::";
|
||||
|
||||
result = spdk_iscsi_tgt_node_allow_ipv6(netmask, addr);
|
||||
result = spdk_iscsi_ipv6_netmask_allow_addr(netmask, addr);
|
||||
CU_ASSERT(result == true);
|
||||
|
||||
result = spdk_iscsi_tgt_node_allow_netmask(netmask, addr);
|
||||
result = spdk_iscsi_netmask_allow_addr(netmask, addr);
|
||||
CU_ASSERT(result == true);
|
||||
}
|
||||
|
||||
@ -135,10 +135,10 @@ allow_ipv6_denied(void)
|
||||
netmask = "[2001:ad6:1234::]/56";
|
||||
addr = "2001:ad6:1234:5678:9abc::";
|
||||
|
||||
result = spdk_iscsi_tgt_node_allow_ipv6(netmask, addr);
|
||||
result = spdk_iscsi_ipv6_netmask_allow_addr(netmask, addr);
|
||||
CU_ASSERT(result == false);
|
||||
|
||||
result = spdk_iscsi_tgt_node_allow_netmask(netmask, addr);
|
||||
result = spdk_iscsi_netmask_allow_addr(netmask, addr);
|
||||
CU_ASSERT(result == false);
|
||||
}
|
||||
|
||||
@ -152,10 +152,10 @@ allow_ipv4_allowed(void)
|
||||
netmask = "192.168.2.0/24";
|
||||
addr = "192.168.2.1";
|
||||
|
||||
result = spdk_iscsi_tgt_node_allow_ipv4(netmask, addr);
|
||||
result = spdk_iscsi_ipv4_netmask_allow_addr(netmask, addr);
|
||||
CU_ASSERT(result == true);
|
||||
|
||||
result = spdk_iscsi_tgt_node_allow_netmask(netmask, addr);
|
||||
result = spdk_iscsi_netmask_allow_addr(netmask, addr);
|
||||
CU_ASSERT(result == true);
|
||||
}
|
||||
|
||||
@ -169,10 +169,10 @@ allow_ipv4_denied(void)
|
||||
netmask = "192.168.2.0";
|
||||
addr = "192.168.2.1";
|
||||
|
||||
result = spdk_iscsi_tgt_node_allow_ipv4(netmask, addr);
|
||||
result = spdk_iscsi_ipv4_netmask_allow_addr(netmask, addr);
|
||||
CU_ASSERT(result == false);
|
||||
|
||||
result = spdk_iscsi_tgt_node_allow_netmask(netmask, addr);
|
||||
result = spdk_iscsi_netmask_allow_addr(netmask, addr);
|
||||
CU_ASSERT(result == false);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user