Update reported IpV4 address for wan interface based on the value in the

Wifi_Inet_Table when the table state changes. Handles situation where
the AP connects before it's services are up and the table is not
populated with the IPs of the wan/lan interfaces.

Ensure dhcp_sniff is set on all interfaces.
This commit is contained in:
Mike Hansen
2020-10-29 15:01:05 -04:00
parent 7ef59937f2
commit 4df03431ed
3 changed files with 1998 additions and 1963 deletions

View File

@@ -104,7 +104,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
// successfully connected - register it in our
// connectedClients table
String key = alterClientCnIfRequired(clientCn, connectNodeInfo);
ovsdbSessionMapInterface.newSession(key, ovsdbClient);
@@ -132,7 +132,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
}
@Override
public void disconnected(OvsdbClient ovsdbClient) {
String remoteHost = ovsdbClient.getConnectionInfo().getRemoteAddress().getHostAddress();
@@ -192,22 +191,16 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
// connectedClients table
String apId = alterClientCnIfRequired(clientCn, connectNodeInfo);
LOG.debug("Client connect for AP {}", apId);
LOG.debug("Client {} connect for AP {}", clientCn, apId);
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
// try {
// ovsdbDao.provisionBridgePortInterface(ovsdbClient);
// } catch (Exception e) {
// LOG.warn("Could not provision Bridge->Port->Interface mapping.", e);
// }
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
ovsdbDao.removeAllSsids(ovsdbClient); // always
ovsdbDao.removeWifiRrm(ovsdbClient);
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
if (opensyncAPConfig != null) {
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureInterfaces(ovsdbClient);
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
if (opensyncAPConfig.getHotspotConfig() != null) {
@@ -218,11 +211,14 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
ovsdbDao.enableNetworkProbeForSyntheticClient(ovsdbClient);
}
}
ovsdbDao.configureInterfaces(ovsdbClient);
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
}
LOG.debug("Client connect Done");
return connectNodeInfo;
}
@@ -271,12 +267,13 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureInterfaces(ovsdbClient);
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
if (opensyncAPConfig.getHotspotConfig() != null) {
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
}
ovsdbDao.configureInterfaces(ovsdbClient);
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
@@ -360,7 +357,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
OvsdbDao.dhcpLeasedIpDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.dhcpLeasedIpDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))),
new MonitorRequests(ImmutableMap.of(OvsdbDao.dhcpLeasedIpDbTable,
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
new MonitorCallback() {
@Override
@@ -425,15 +423,12 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
}
});
awCf.join();
}
private void monitorCommandStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> csCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
@@ -450,7 +445,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
List<Map<String, String>> delete = new ArrayList<>();
List<Map<String, String>> update = new ArrayList<>();
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
@@ -504,12 +498,10 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
}
});
csCf.join();
}
private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
@@ -564,7 +556,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
}
// now address the update/add
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(associatedClients, key);
@@ -574,50 +565,48 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
acCf.join();
}
private void monitorWifiInetStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> isCf = ovsdbClient
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiInetStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiInetStateDbTable,
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
new MonitorCallback() {
CompletableFuture<TableUpdates> isCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
OvsdbDao.wifiInetStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiInetStateDbTable,
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
new MonitorCallback() {
@Override
public void update(TableUpdates tableUpdates) {
LOG.info(OvsdbDao.ovsdbName,
OvsdbDao.wifiInetStateDbTable + "_" + key + " monitor callback received {}",
tableUpdates);
@Override
public void update(TableUpdates tableUpdates) {
LOG.info(OvsdbDao.ovsdbName,
OvsdbDao.wifiInetStateDbTable + "_" + key + " monitor callback received {}",
tableUpdates);
List<OpensyncAPInetState> inetStateInsertOrUpdate = new ArrayList<>();
List<OpensyncAPInetState> inetStateDelete = new ArrayList<>();
List<OpensyncAPInetState> inetStateInsertOrUpdate = new ArrayList<>();
List<OpensyncAPInetState> inetStateDelete = new ArrayList<>();
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
if (rowUpdate.getNew() == null) {
inetStateDelete.addAll(ovsdbDao
.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
} else {
inetStateInsertOrUpdate.addAll(ovsdbDao
.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
}
}
if (rowUpdate.getNew() == null) {
inetStateDelete.addAll(
ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
} else {
inetStateInsertOrUpdate.addAll(
ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
}
// delete first
extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateDelete, key);
// now process updates and mutations
extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateInsertOrUpdate, key);
}
}
});
// delete first
extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateDelete, key);
// now process updates and mutations
extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateInsertOrUpdate, key);
}
});
isCf.join();
}
@@ -686,7 +675,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
}
}
});
@@ -732,7 +720,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
try {
ovsdbDao.configureFirmwareFlash(session.getOvsdbClient(), apId, firmwareVersion, username);
} catch (Exception e) {
LOG.error("Failed to flash firmware for " + apId + " " + e.getLocalizedMessage());
LOG.error("Failed to flash firmware for " + apId + " " + e.getLocalizedMessage());
return "Failed to flash firmware for " + apId + " " + e.getLocalizedMessage();
}
@@ -841,7 +829,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
return "failed to trigger a factory reset of AP " + apId;
}
}
public String alterClientCnIfRequired(String clientCn, ConnectNodeInfo connectNodeInfo) {

View File

@@ -2049,41 +2049,44 @@ public class OvsdbDao {
public void configureInterfaces(OvsdbClient ovsdbClient) {
configureWanInterfaces(ovsdbClient);
configureLanInterfaces(ovsdbClient);
configureWanInterfacesForDhcpSniffing(ovsdbClient);
configureLanInterfacesforDhcpSniffing(ovsdbClient);
}
private void configureLanInterfaces(OvsdbClient ovsdbClient) {
private void configureLanInterfacesforDhcpSniffing(OvsdbClient ovsdbClient) {
List<Operation> operations = new ArrayList<>();
Map<String, Value> updateColumns = new HashMap<>();
List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("if_name", Function.NOT_EQUALS, new Atom<>(defaultWanInterfaceName)));
conditions.add(new Condition("parent_ifname", Function.NOT_EQUALS, new Atom<>(defaultWanInterfaceName)));
updateColumns.put("dhcp_sniff", new Atom<>(true));
Row row = new Row(updateColumns);
operations.add(new Update(wifiInetConfigDbTable, conditions, row));
try {
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
for (OperationResult res : result) {
LOG.debug("Op Result {}", res);
}
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
LOG.error("OvsdbDao::configureLanInterfaces failed.", e);
throw new RuntimeException(e);
}
}
private void configureWanInterfacesForDhcpSniffing(OvsdbClient ovsdbClient) {
List<Operation> operations = new ArrayList<>();
Map<String, Value> updateColumns = new HashMap<>();
List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(defaultLanInterfaceName)));
updateColumns.put("dhcp_sniff", new Atom<>(true));
conditions.add(new Condition("if_name", Function.NOT_EQUALS, new Atom<>(defaultLanInterfaceName)));
conditions.add(new Condition("parent_ifname", Function.NOT_EQUALS, new Atom<>(defaultLanInterfaceName)));
Row row = new Row(updateColumns);
operations.add(new Update(wifiInetConfigDbTable, conditions, row));
try {
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
for (OperationResult res : result) {
LOG.debug("Op Result {}", res);
}
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
LOG.error("OvsdbDao::configureLanInterfaces failed.", e);
throw new RuntimeException(e);
}
}
private void configureWanInterfaces(OvsdbClient ovsdbClient) {
List<Operation> operations = new ArrayList<>();
Map<String, Value> updateColumns = new HashMap<>();
List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(defaultWanInterfaceName)));
updateColumns.put("dhcp_sniff", new Atom<>(true));
Row row = new Row(updateColumns);
@@ -3359,6 +3362,7 @@ public class OvsdbDao {
tableColumns.put("network", new Atom<>(true));
tableColumns.put("if_name", new Atom<>(ifName));
tableColumns.put("NAT", new Atom<>(isNat));
tableColumns.put("dhcp_sniff", new Atom<>(true));
Row row = new Row(tableColumns);
if (isUpdate) {