From 397fbc056c1ae1478f0311feab3a8a44cc6a4685 Mon Sep 17 00:00:00 2001 From: Erik Kline Date: Fri, 5 Feb 2016 18:06:15 +0900 Subject: [PATCH] Switch to ifc_add_address() for setcfg This avoids the issue where, for example, 10.0.0.1/8 is added first, then 10.0.0.1/8 is deleted, and 10.0.0.1/24 is added. Netlink changes observed at the wrong time would make it seem as though IPv4 had been lost when in fact everthing was fine. Bug: 26991160 Change-Id: If0dad2993f818686ef8a99618e779813e9c7af90 --- server/CommandListener.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/CommandListener.cpp b/server/CommandListener.cpp index 7ecbffc..db6632d 100644 --- a/server/CommandListener.cpp +++ b/server/CommandListener.cpp @@ -357,18 +357,18 @@ int CommandListener::InterfaceCmd::runCommand(SocketClient *cli, // Handle flags only case index = 3; } else { - if (ifc_set_addr(argv[2], addr.s_addr)) { - cli->sendMsg(ResponseCode::OperationFailed, "Failed to set address", true); + if (ifc_set_addr(argv[2], 0)) { + cli->sendMsg(ResponseCode::OperationFailed, "Failed to clear address", true); ifc_close(); return 0; } - - // Set prefix length on a non zero address - if (addr.s_addr != 0 && ifc_set_prefixLength(argv[2], atoi(argv[4]))) { - cli->sendMsg(ResponseCode::OperationFailed, "Failed to set prefixLength", true); - ifc_close(); - return 0; - } + if (addr.s_addr != 0) { + if (ifc_add_address(argv[2], argv[3], atoi(argv[4]))) { + cli->sendMsg(ResponseCode::OperationFailed, "Failed to set address", true); + ifc_close(); + return 0; + } + } } /* Process flags */ -- 2.11.0