mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-28 16:23:32 +00:00
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:
File diff suppressed because it is too large
Load Diff
@@ -104,7 +104,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
// successfully connected - register it in our
|
// successfully connected - register it in our
|
||||||
// connectedClients table
|
// connectedClients table
|
||||||
|
|
||||||
String key = alterClientCnIfRequired(clientCn, connectNodeInfo);
|
String key = alterClientCnIfRequired(clientCn, connectNodeInfo);
|
||||||
ovsdbSessionMapInterface.newSession(key, ovsdbClient);
|
ovsdbSessionMapInterface.newSession(key, ovsdbClient);
|
||||||
|
|
||||||
@@ -132,7 +132,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(OvsdbClient ovsdbClient) {
|
public void disconnected(OvsdbClient ovsdbClient) {
|
||||||
String remoteHost = ovsdbClient.getConnectionInfo().getRemoteAddress().getHostAddress();
|
String remoteHost = ovsdbClient.getConnectionInfo().getRemoteAddress().getHostAddress();
|
||||||
@@ -192,22 +191,16 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
// connectedClients table
|
// connectedClients table
|
||||||
String apId = alterClientCnIfRequired(clientCn, connectNodeInfo);
|
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.removeAllStatsConfigs(ovsdbClient); // always
|
||||||
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
||||||
ovsdbDao.removeWifiRrm(ovsdbClient);
|
ovsdbDao.removeWifiRrm(ovsdbClient);
|
||||||
|
|
||||||
|
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
||||||
|
|
||||||
if (opensyncAPConfig != null) {
|
if (opensyncAPConfig != null) {
|
||||||
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureInterfaces(ovsdbClient);
|
|
||||||
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
||||||
if (opensyncAPConfig.getHotspotConfig() != null) {
|
if (opensyncAPConfig.getHotspotConfig() != null) {
|
||||||
@@ -218,11 +211,14 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
ovsdbDao.enableNetworkProbeForSyntheticClient(ovsdbClient);
|
ovsdbDao.enableNetworkProbeForSyntheticClient(ovsdbClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ovsdbDao.configureInterfaces(ovsdbClient);
|
||||||
|
|
||||||
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
||||||
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LOG.debug("Client connect Done");
|
LOG.debug("Client connect Done");
|
||||||
return connectNodeInfo;
|
return connectNodeInfo;
|
||||||
}
|
}
|
||||||
@@ -271,12 +267,13 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
||||||
|
|
||||||
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureInterfaces(ovsdbClient);
|
|
||||||
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
||||||
if (opensyncAPConfig.getHotspotConfig() != null) {
|
if (opensyncAPConfig.getHotspotConfig() != null) {
|
||||||
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
|
||||||
}
|
}
|
||||||
|
ovsdbDao.configureInterfaces(ovsdbClient);
|
||||||
|
|
||||||
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
|
||||||
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
||||||
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
||||||
@@ -360,7 +357,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
||||||
OvsdbDao.dhcpLeasedIpDbTable + "_" + key,
|
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() {
|
new MonitorCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -425,15 +423,12 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
awCf.join();
|
awCf.join();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void monitorCommandStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
|
private void monitorCommandStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
|
||||||
|
|
||||||
CompletableFuture<TableUpdates> csCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
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>> delete = new ArrayList<>();
|
||||||
List<Map<String, String>> update = new ArrayList<>();
|
List<Map<String, String>> update = 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()) {
|
||||||
|
|
||||||
@@ -504,12 +498,10 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
csCf.join();
|
csCf.join();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
|
private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
|
||||||
@@ -564,7 +556,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// now address the update/add
|
// now address the update/add
|
||||||
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(associatedClients, key);
|
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(associatedClients, key);
|
||||||
|
|
||||||
@@ -574,50 +565,48 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
acCf.join();
|
acCf.join();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void monitorWifiInetStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
|
private void monitorWifiInetStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
|
||||||
CompletableFuture<TableUpdates> isCf = ovsdbClient
|
CompletableFuture<TableUpdates> isCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
||||||
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiInetStateDbTable + "_" + key,
|
OvsdbDao.wifiInetStateDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiInetStateDbTable,
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiInetStateDbTable,
|
||||||
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
||||||
new MonitorCallback() {
|
new MonitorCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(TableUpdates tableUpdates) {
|
public void update(TableUpdates tableUpdates) {
|
||||||
LOG.info(OvsdbDao.ovsdbName,
|
LOG.info(OvsdbDao.ovsdbName,
|
||||||
OvsdbDao.wifiInetStateDbTable + "_" + key + " monitor callback received {}",
|
OvsdbDao.wifiInetStateDbTable + "_" + key + " monitor callback received {}",
|
||||||
tableUpdates);
|
tableUpdates);
|
||||||
|
|
||||||
List<OpensyncAPInetState> inetStateInsertOrUpdate = new ArrayList<>();
|
List<OpensyncAPInetState> inetStateInsertOrUpdate = new ArrayList<>();
|
||||||
List<OpensyncAPInetState> inetStateDelete = 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) {
|
if (rowUpdate.getNew() == null) {
|
||||||
inetStateDelete.addAll(ovsdbDao
|
inetStateDelete.addAll(
|
||||||
.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
|
ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
|
||||||
} else {
|
} else {
|
||||||
inetStateInsertOrUpdate.addAll(ovsdbDao
|
inetStateInsertOrUpdate.addAll(
|
||||||
.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
|
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();
|
isCf.join();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -686,7 +675,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -732,7 +720,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
try {
|
try {
|
||||||
ovsdbDao.configureFirmwareFlash(session.getOvsdbClient(), apId, firmwareVersion, username);
|
ovsdbDao.configureFirmwareFlash(session.getOvsdbClient(), apId, firmwareVersion, username);
|
||||||
} catch (Exception e) {
|
} 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();
|
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;
|
return "failed to trigger a factory reset of AP " + apId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String alterClientCnIfRequired(String clientCn, ConnectNodeInfo connectNodeInfo) {
|
public String alterClientCnIfRequired(String clientCn, ConnectNodeInfo connectNodeInfo) {
|
||||||
|
|||||||
@@ -2049,41 +2049,44 @@ public class OvsdbDao {
|
|||||||
|
|
||||||
public void configureInterfaces(OvsdbClient ovsdbClient) {
|
public void configureInterfaces(OvsdbClient ovsdbClient) {
|
||||||
|
|
||||||
configureWanInterfaces(ovsdbClient);
|
configureWanInterfacesForDhcpSniffing(ovsdbClient);
|
||||||
configureLanInterfaces(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<>();
|
List<Operation> operations = new ArrayList<>();
|
||||||
Map<String, Value> updateColumns = new HashMap<>();
|
Map<String, Value> updateColumns = new HashMap<>();
|
||||||
List<Condition> conditions = new ArrayList<>();
|
List<Condition> conditions = new ArrayList<>();
|
||||||
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(defaultLanInterfaceName)));
|
conditions.add(new Condition("if_name", Function.NOT_EQUALS, new Atom<>(defaultLanInterfaceName)));
|
||||||
updateColumns.put("dhcp_sniff", new Atom<>(true));
|
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));
|
updateColumns.put("dhcp_sniff", new Atom<>(true));
|
||||||
|
|
||||||
Row row = new Row(updateColumns);
|
Row row = new Row(updateColumns);
|
||||||
@@ -3359,6 +3362,7 @@ public class OvsdbDao {
|
|||||||
tableColumns.put("network", new Atom<>(true));
|
tableColumns.put("network", new Atom<>(true));
|
||||||
tableColumns.put("if_name", new Atom<>(ifName));
|
tableColumns.put("if_name", new Atom<>(ifName));
|
||||||
tableColumns.put("NAT", new Atom<>(isNat));
|
tableColumns.put("NAT", new Atom<>(isNat));
|
||||||
|
tableColumns.put("dhcp_sniff", new Atom<>(true));
|
||||||
|
|
||||||
Row row = new Row(tableColumns);
|
Row row = new Row(tableColumns);
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
|
|||||||
Reference in New Issue
Block a user