From 24d2d3ea83bdadee3d8a8b477be10e9ced178b6d Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Thu, 21 Jun 2012 23:44:31 -0400 Subject: [PATCH] vlserver: always use the hostaddress table in GetAddrsU Use the hostaddress (IpMappedAddr) table when looking up hosts by IP address and when listing addresses by index, instead of accessing the multi-homed extensions directly. The existing vos client calls the old GetAddrs rpc to first retrieve a count of the number of addresses expected. This count is the number of addresses in the hostaddress table. If there are unreferenced entries in the mh extension blocks, then vos can return an incorrect or incomplete list of addresses. To be consistent with the rest of the host address processing, use the hostaddress table in GetAddrsU to lookup hosts by index or by IP address. The hostaddress table is already used when looking up addresses by UUID. Change-Id: I01aa29ae7d24d48bcd245f0320e329435f61548e Reviewed-on: http://gerrit.openafs.org/7878 Tested-by: BuildBot Reviewed-by: Alistair Ferguson Reviewed-by: Derrick Brashear --- src/vlserver/vlprocs.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/vlserver/vlprocs.c b/src/vlserver/vlprocs.c index 8156e293a..0fba51c89 100644 --- a/src/vlserver/vlprocs.c +++ b/src/vlserver/vlprocs.c @@ -2511,7 +2511,7 @@ SVL_GetAddrsU(struct rx_call *rxcall, bulkaddrs *addrsp) { int this_op = VLGETADDRSU; - afs_int32 code, index = -1, offset; + afs_int32 code, index; struct vl_ctx ctx; int nservers, i, j, base = 0; struct extentaddr *exp = 0; @@ -2531,15 +2531,13 @@ SVL_GetAddrsU(struct rx_call *rxcall, code = VL_BADMASK; goto abort; } - for (base = 0; base < VL_MAX_ADDREXTBLKS; base++) { - if (!ctx.ex_addr[base]) - break; - for (i = 1; i < VL_MHSRV_PERBLK; i++) { - exp = &ctx.ex_addr[base][i]; - tuuid = exp->ex_hostuuid; - afs_ntohuuid(&tuuid); - if (afs_uuid_is_nil(&tuuid)) - continue; + /* Search for a server registered with the VLDB with this ip address. */ + for (index = 0; index <= MAXSERVERID; index++) { + code = multiHomedExtent(&ctx, index, &exp); + if (code) + continue; + + if (exp) { for (j = 0; j < VL_MAXIPADDRS_PERMH; j++) { if (exp->ex_addrs[j] && (ntohl(exp->ex_addrs[j]) == attributes->ipaddr)) { @@ -2549,10 +2547,8 @@ SVL_GetAddrsU(struct rx_call *rxcall, if (j < VL_MAXIPADDRS_PERMH) break; } - if (i < VL_MHSRV_PERBLK) - break; } - if (base >= VL_MAX_ADDREXTBLKS) { + if (index > MAXSERVERID) { code = VL_NOENT; goto abort; } @@ -2561,22 +2557,17 @@ SVL_GetAddrsU(struct rx_call *rxcall, code = VL_BADMASK; goto abort; } - index = attributes->index; - if (index < 1 || index >= (VL_MAX_ADDREXTBLKS * VL_MHSRV_PERBLK)) { + /* VLADDR_INDEX index is one based */ + if (attributes->index < 1 || attributes->index > MAXSERVERID) { code = VL_INDEXERANGE; goto abort; } - base = index / VL_MHSRV_PERBLK; - offset = index % VL_MHSRV_PERBLK; - if (offset == 0) { + index = attributes->index - 1; + code = multiHomedExtent(&ctx, index, &exp); + if (code) { code = VL_NOENT; goto abort; } - if (!ctx.ex_addr[base]) { - code = VL_INDEXERANGE; - goto abort; - } - exp = &ctx.ex_addr[base][offset]; } else if (attributes->Mask & VLADDR_UUID) { if (attributes->Mask & (VLADDR_IPADDR | VLADDR_INDEX)) { code = VL_BADMASK; -- 2.39.5