From 6b93ad695e53a86dbe9eea13bd0ff651e1d8c9b7 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Fri, 24 Oct 2014 17:17:07 -0400 Subject: [PATCH] vldb_check: fix false mh block error message Fix a false error message about invalid mh blocks when the vldb has more than one mh block. To add insult to injury, vldb_check complains about the wrong address and block number. The flags field in the mh block header is in network byte order, in all of the blocks, not just the first one. Be sure to convert all of them to host byte order so the VLCONTBLOCK flag check works. Fix the error message on the secondary blocks to show the correct address and block number. Example bogus error messages: vldb_check ./vldb.DB0 address 132120 (offset 0x20458): Multihomed Block 0: Not a multihomed block address 132120 (offset 0x20458): Multihomed Block 0: Not a multihomed block address 132120 (offset 0x20458): Multihomed Block 0: Not a multihomed block Change-Id: I31d96ad43f01fbf2774815184942be45e2d7820b Reviewed-on: http://gerrit.openafs.org/11555 Tested-by: BuildBot Reviewed-by: D Brashear --- src/vlserver/vldb_check.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vlserver/vldb_check.c b/src/vlserver/vldb_check.c index 867f7fbce..1b5ee1899 100644 --- a/src/vlserver/vldb_check.c +++ b/src/vlserver/vldb_check.c @@ -353,9 +353,16 @@ readMH(afs_uint32 addr, int block, struct extentaddr *mhblockP) vldbread(addr, (char *)mhblockP, VL_ADDREXTBLK_SIZE); + /* Every mh block has the VLCONTBLOCK flag set in the header to + * indicate the entry is an 8192 byte extended block. The + * VLCONTBLOCK flag is always clear in regular vl entries. The + * vlserver depends on the VLCONTBLOCK flag to correctly traverse + * the vldb. The flags field is in network byte order. */ + mhblockP->ex_hdrflags = ntohl(mhblockP->ex_hdrflags); + if (block == 0) { + /* These header fields are only used in the first mh block. */ mhblockP->ex_count = ntohl(mhblockP->ex_count); - mhblockP->ex_hdrflags = ntohl(mhblockP->ex_hdrflags); for (i = 0; i < VL_MAX_ADDREXTBLKS; i++) { mhblockP->ex_contaddrs[i] = ntohl(mhblockP->ex_contaddrs[i]); } @@ -894,8 +901,8 @@ CheckIpAddrs(struct vlheader *header) readMH(mhinfo[i].addr, i, MHblock); if (MHblock->ex_hdrflags != VLCONTBLOCK) { log_error - (VLDB_CHECK_ERROR,"address %u (offset 0x%0x): Multihomed Block 0: Not a multihomed block\n", - header->SIT, OFFSET(header->SIT)); + (VLDB_CHECK_ERROR,"address %u (offset 0x%0x): Multihomed Block %d: Not a multihomed block\n", + mhinfo[i].addr, OFFSET(mhinfo[i].addr), i); } rindex = mhinfo[i].addr / sizeof(vlentry); -- 2.39.5