Skip to content

Commit 4f4d0a6

Browse files
kcp-gitvijay-suman
authored andcommitted
{IB/{core,ipoib},net/rds}: IPv6 support for ACL
The IB ACL components are extended to support IPv6 address. Some of the ACL ioctls use a 32 bit integer to represent an IP address. To support IPv6, struct in6_addr needs to be used. To ensure backward compatibility, a new ioctl will be introduced for each of those ioctls that take a 32 bit integer as address. The original ioctls are kept and can still be used. The new ioctls can take IPv4 mapped IPv6 address so new apps only need to use the new ioctls. The IPOIBACLNGET and IPOIBACLNADD commands re-use the same ipoib_ioctl_req_data, except that the ips field should actually be a pointer to a list of struct in6_addr. Here we assume that the pointer size to an u32 and in6_addr are the same. Orabug: 25410192 Signed-off-by: Ka-Cheong Poon <[email protected]> Reviewed-by: Yuval Shaia <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Orabug: 27487515 (cherry picked from commit e95a33b) cherry-pick-repo=linux-uek.git Signed-off-by: Gerd Rausch <[email protected]> Reviewed-by: Sudhakar Didnukurti <[email protected]> Signed-off-by: Aron Silverton <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]> Merge-Monkey-Notes: Not changing any files outside net/rds Merge-Monkey: Gerd Rausch <[email protected]> Orabug: 33590097 UEK6 => UEK7 (cherry picked from commit 6321891) cherry-pick-repo=UEK/production/linux-uek.git Signed-off-by: Gerd Rausch <[email protected]> Reviewed-by: William Kucharski <[email protected]> Orabug: 33590087 UEK7 => LUCI (cherry picked from commit 9b6387a) cherry-pick-repo=UEK/production/linux-uek.git Signed-off-by: Gerd Rausch <[email protected]> Reviewed-by: William Kucharski <[email protected]>
1 parent 950fb87 commit 4f4d0a6

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

net/rds/ib_cm.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ static inline void rds_ib_init_ic_frag(struct rds_ib_connection *ic)
206206
* 1 - acl is not enabled
207207
* -1 - acl match failed
208208
*/
209-
static int rds_ib_match_acl(struct rdma_cm_id *cm_id, __be32 saddr)
209+
static int rds_ib_match_acl(struct rdma_cm_id *cm_id,
210+
const struct in6_addr *saddr)
210211
{
211212
struct ib_cm_acl *acl = 0;
212213
struct ib_cm_acl_elem *acl_elem = 0;
213214
__be64 fguid = cm_id->route.path_rec->dgid.global.interface_id;
214215
__be64 fsubnet = cm_id->route.path_rec->dgid.global.subnet_prefix;
215216
struct ib_cm_dpp dpp;
216-
u32 addr;
217217

218218
ib_cm_dpp_init(&dpp, cm_id->device, cm_id->port_num,
219219
ntohs(cm_id->route.path_rec->pkey));
@@ -231,14 +231,10 @@ static int rds_ib_match_acl(struct rdma_cm_id *cm_id, __be32 saddr)
231231
goto out;
232232
}
233233

234-
addr = be32_to_cpu(saddr);
235-
if (!addr)
236-
goto out;
237-
238-
acl_elem = ib_cm_acl_lookup_uuid_ip(acl, acl_elem->uuid, addr);
234+
acl_elem = ib_cm_acl_lookup_uuid_ip(acl, acl_elem->uuid, saddr);
239235
if (!acl_elem) {
240-
pr_err_ratelimited("RDS/IB: IP %pI4 ib_cm_acl_lookup_uuid_ip() failed\n",
241-
&saddr);
236+
pr_err_ratelimited("RDS/IB: IP %pI6c ib_cm_acl_lookup_uuid_ip() failed\n",
237+
saddr);
242238
goto out;
243239
}
244240

@@ -1043,16 +1039,11 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
10431039

10441040
#ifdef CONFIG_RDS_ACL
10451041

1046-
/* IPoIB ACL only supports IPv4. Let all IPv6 traffic pass. */
1047-
if (ipv6_addr_v4mapped(saddr6)) {
1048-
acl_ret = rds_ib_match_acl(cm_id, saddr6->s6_addr32[3]);
1049-
if (acl_ret < 0) {
1050-
err = RDS_ACL_FAILURE;
1051-
rdsdebug("RDS: IB: passive: rds_ib_match_acl failed\n");
1052-
goto out;
1053-
}
1054-
} else {
1055-
acl_ret = 0;
1042+
acl_ret = rds_ib_match_acl(cm_id, saddr6);
1043+
if (acl_ret < 0) {
1044+
err = RDS_ACL_FAILURE;
1045+
rdsdebug("RDS: IB: passive: rds_ib_match_acl failed\n");
1046+
goto out;
10561047
}
10571048

10581049
#else /* !CONFIG_RDS_ACL */
@@ -1226,11 +1217,7 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id, bool isv6)
12261217

12271218
#ifdef CONFIG_RDS_ACL
12281219

1229-
/* IPoIB ACL only supports IPv4. Let all IPv6 traffic pass. */
1230-
if (ipv6_addr_v4mapped(&conn->c_faddr))
1231-
ret = rds_ib_match_acl(ic->i_cm_id, conn->c_faddr.s6_addr32[3]);
1232-
else
1233-
ret = 0;
1220+
ret = rds_ib_match_acl(ic->i_cm_id, &conn->c_faddr);
12341221
if (ret < 0) {
12351222
pr_err("RDS: IB: active conn=%p, <%pI6c,%pI6c,%d> destroyed due ACL violation\n",
12361223
conn, &conn->c_laddr, &conn->c_faddr,

0 commit comments

Comments
 (0)