vos: changeaddr refuse to change mh entries without -force

Add a client side check to vos changeaddr -oldaddr -newaddr
to refuse to change multihomed server entries, unless -force
is given.

Reviewed-on: http://gerrit.openafs.org/11638
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 656aaacd01a90f658a5126111af9988fa1854dec)

Change-Id: I4eb7e2b3a2e027b5e1368298a274b0328c8b1343
Reviewed-on: http://gerrit.openafs.org/12087
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Michael Meffie 2014-12-16 19:25:06 -05:00 committed by Stephan Wiesand
parent 38a14a9d37
commit efb10d6fac
2 changed files with 55 additions and 2 deletions

View File

@ -8,12 +8,12 @@ vos_changeaddr - Changes or removes a file server machine's entry in the VLDB
<div class="synopsis">
B<vos changeaddr> S<<< B<-oldaddr> <I<original IP address>> >>>
S<<< [B<-newaddr> <I<new IP address>>] >>> [B<-remove>]
S<<< [B<-newaddr> <I<new IP address>>] >>> [B<-remove>] [B<-force>]
S<<< [B<-cell> <I<cell name>>] >>> [B<-noauth>] [B<-localauth>]
[B<-verbose>] [B<-encrypt>] [B<-noresolve>] [B<-help>]
B<vos changea> S<<< B<-o> <I<original IP address>> >>>
S<<< [B<-ne> <I<new IP address>>] >>> [B<-r>]
S<<< [B<-ne> <I<new IP address>>] >>> [B<-r>] [B<-f>]
S<<< [B<-c> <I<cell name>>] >>>
[B<-noa>] [B<-l>] [B<-v>] [B<-e>] [B<-nor>] [B<-h>]
@ -74,11 +74,21 @@ multihomed machine, use any of them to identify the server entry.
Specifies the new IP address that replaces all currently registered
addresses.
Unless the B<-force> option is given, B<vos changeaddr> will refuse to change
addresses when the address given in B<-oldaddr> is registered with a multihomed
server entry in the VLDB. See L</CAUTIONS>.
=item B<-remove>
Removes from the VLDB the server entry that includes the address specified
by the B<-oldaddr> argument.
=item B<-force>
Overrides the multihomed server entry check when the B<-oldaddr> and
B<-newaddr> options are combined. The B<-force> flag is provided for historical
compatibility and is not recommended.
=item B<-cell> <I<cell name>>
Names the cell in which to run the command. Do not combine this argument

View File

@ -5208,6 +5208,7 @@ ChangeAddr(struct cmd_syndesc *as, void *arock)
{
afs_int32 ip1, ip2, vcode;
int remove = 0;
int force = 0;
if (noresolve)
ip1 = GetServerNoresolve(as->parms[0].items->data);
@ -5225,6 +5226,10 @@ ChangeAddr(struct cmd_syndesc *as, void *arock)
return (EINVAL);
}
if (as->parms[3].items) {
force = 1;
}
if (as->parms[1].items) {
if (noresolve)
ip2 = GetServerNoresolve(as->parms[1].items->data);
@ -5244,6 +5249,42 @@ ChangeAddr(struct cmd_syndesc *as, void *arock)
ip1 = 0xffffffff;
}
if (!remove && !force) {
afs_int32 m_nentries;
bulkaddrs m_addrs;
afs_int32 m_uniq = 0;
afsUUID m_uuid;
ListAddrByAttributes m_attrs;
char buffer[128];
memset(&m_attrs, 0, sizeof(m_attrs));
memset(&m_uuid, 0, sizeof(m_uuid));
memset(&m_addrs, 0, sizeof(m_addrs));
memset(buffer, 0, sizeof(buffer));
m_attrs.Mask = VLADDR_IPADDR;
m_attrs.ipaddr = ntohl(ip1); /* -oldaddr */
vcode =
ubik_VL_GetAddrsU(cstruct, UBIK_CALL_NEW, &m_attrs, &m_uuid,
&m_uniq, &m_nentries, &m_addrs);
xdr_free((xdrproc_t) xdr_bulkaddrs, &m_addrs);
switch (vcode) {
case 0: /* mh entry detected */
afsUUID_to_string(&m_uuid, buffer, sizeof(buffer) - 1);
fprintf(STDERR, "vos: Refusing to change address in multi-homed server entry.\n");
fprintf(STDERR, " -oldaddr address is registered to file server UUID %s\n", buffer);
fprintf(STDERR, " Please restart the file server or use vos setaddrs.\n");
return EINVAL;
case VL_NOENT:
break;
default:
fprintf(STDERR, "vos: could not list the server addresses\n");
PrintError("", vcode);
return vcode;
}
}
vcode = ubik_VL_ChangeAddr(cstruct, UBIK_CALL_NEW, ntohl(ip1), ntohl(ip2));
if (vcode) {
char hoststr1[16], hoststr2[16];
@ -6288,6 +6329,8 @@ main(int argc, char **argv)
cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
"remove the IP address from the VLDB");
cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
"allow multi-homed server entry change (not recommended)");
COMMONPARMS;
ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,