OpensyncGateway changes to only treat clients which appear in

Wifi_Associated_Clients table as clients which can be added to the
cloud's client and client session lists. Other changes through either
stats changes or via other tables in ovsdb can only alter existing
clients and sessions. Else they are ignored.
SSIDs and InetConfig for SSIDs are not automatically deleted if an
existing configuration for this AP containing profiles for the ssids exists on the cloud.
This commit is contained in:
Mike Hansen
2020-11-02 16:04:41 -05:00
parent 6c784367ed
commit 1d7f822ed4
5 changed files with 416 additions and 484 deletions

View File

@@ -336,9 +336,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ce.getCustomerId(), ce.getId()); ce.getCustomerId(), ce.getId());
updateApStatus(ce, connectNodeInfo); updateApStatus(ce, connectNodeInfo);
removeNonWifiClients(ce,connectNodeInfo); removeNonWifiClients(ce, connectNodeInfo);
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId); OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
ovsdbSession.setRoutingId(equipmentRoutingRecord.getId()); ovsdbSession.setRoutingId(equipmentRoutingRecord.getId());
ovsdbSession.setEquipmentId(ce.getId()); ovsdbSession.setEquipmentId(ce.getId());
@@ -1228,10 +1228,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus); activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus);
if (LOG.isTraceEnabled()) { LOG.info("Processing Wifi_VIF_State table update for AP {}, updated ACTIVE_BSSID Status {}", apId,
LOG.trace("Processing Wifi_VIF_State table update for AP {}, updated ACTIVE_BSSID Status {}", apId, activeBssidsStatus);
activeBssidsStatus.toPrettyString());
}
} }
@Override @Override
@@ -1415,9 +1414,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
isReassociation = false; isReassociation = false;
} }
ClientInfoDetails clientDetails = (ClientInfoDetails) clientInstance.getDetails();
clientInstance.setDetails(clientDetails);
clientInstance = clientServiceInterface.update(clientInstance); clientInstance = clientServiceInterface.update(clientInstance);
@@ -1432,16 +1428,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
clientSession.setLocationId(ce.getLocationId()); clientSession.setLocationId(ce.getLocationId());
ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
clientSessionDetails.setIsReassociation(isReassociation); clientSessionDetails.setIsReassociation(isReassociation);
clientSessionDetails.setSessionId(clientInstance.getMacAddress().getAddressAsLong());
clientSession.setDetails(clientSessionDetails); clientSession.setDetails(clientSessionDetails);
clientSession = clientServiceInterface.updateSession(clientSession); clientSession = clientServiceInterface.updateSession(clientSession);
} }
ClientSessionDetails clientSessionDetails = clientSession.getDetails(); ClientSessionDetails clientSessionDetails = clientSession.getDetails();
clientSessionDetails.setAssociationState(AssociationState._802_11_Associated); clientSessionDetails.setAssociationState(AssociationState._802_11_Associated);
clientSessionDetails.setAssocTimestamp(System.currentTimeMillis()); clientSessionDetails.setAssocTimestamp(System.currentTimeMillis());
clientSessionDetails.setSessionId(clientInstance.getMacAddress().getAddressAsLong());
clientSession.getDetails().mergeSession(clientSessionDetails); clientSession.getDetails().mergeSession(clientSessionDetails);
clientSession = clientServiceInterface.updateSession(clientSession); clientSession = clientServiceInterface.updateSession(clientSession);
@@ -1772,30 +1765,30 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return; return;
} }
Set<MacAddress> macAddressSet = new HashSet<>(); com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
macAddressSet.add(new MacAddress(deletedClientMac)); new MacAddress(deletedClientMac));
List<ClientSession> clientSessionList = clientServiceInterface.getSessions(customerId, macAddressSet); ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
new MacAddress(deletedClientMac));
for (ClientSession session : clientSessionList) { if (client != null) {
if (clientSession != null) {
ClientSessionDetails clientSessionDetails = session.getDetails(); if (!clientSession.getDetails().getAssociationState().equals(AssociationState.Disconnected)) {
clientSession.getDetails().setAssociationState(AssociationState.Disconnected);
if ((clientSessionDetails.getAssociationState() != null) clientSession = clientServiceInterface.updateSession(clientSession);
&& !clientSessionDetails.getAssociationState().equals(AssociationState.Disconnected)) { LOG.info("Session {} for client {} is now disconnected.", clientSession, client.getMacAddress());
clientSessionDetails.setDisconnectByClientTimestamp(System.currentTimeMillis());
clientSessionDetails.setAssociationState(AssociationState.Disconnected);
session.setDetails(clientSessionDetails);
session = clientServiceInterface.updateSession(session);
if (LOG.isTraceEnabled()) {
LOG.trace("wifiAssociatedClientsDbTableDelete Updated client session, set to disconnected {}",
session.toPrettyString());
} }
} }
} else {
if (clientSession != null) {
clientSession = clientServiceInterface.deleteSession(customerId, equipmentId,
new MacAddress(deletedClientMac));
LOG.info("No client {} found, delete session {}", new MacAddress(deletedClientMac), clientSession);
}
} }
} }
@Override @Override
@@ -1839,34 +1832,34 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
continue; continue;
} }
MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr")); MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr"));
if (clientMacAddress.equals(equipmentServiceInterface.get(equipmentId).getBaseMacAddress())) {
LOG.info("Not a client device {} ", dhcpLeasedIps);
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface
.getOrNull(customerId, clientMacAddress);
if (client != null) {
// In case somehow this equipment has accidentally been
// tagged as a client, remove
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
clientMacAddress);
if (clientSession != null) {
LOG.info("Deleting invalid client session {}",
clientServiceInterface.deleteSession(customerId, equipmentId, clientMacAddress));
}
LOG.info("Deleting invalid client {}",
clientServiceInterface.delete(customerId, clientMacAddress));
}
continue;
}
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
clientMacAddress); clientMacAddress);
if (client != null) {
if (client == null) {
LOG.info("Cannot find client instance for {}", clientMacAddress);
continue;
} else if (clientMacAddress.equals(equipmentServiceInterface.get(equipmentId).getBaseMacAddress())) {
LOG.info("Not a client device {} ", dhcpLeasedIps);
// In case somehow this equipment has accidentally been
// tagged as a client, remove
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
clientMacAddress);
if (clientSession != null) {
LOG.info("Deleting invalid client session {}",
clientServiceInterface.deleteSession(customerId, equipmentId, clientMacAddress));
}
LOG.info("Deleting invalid client {}", clientServiceInterface.delete(customerId, clientMacAddress));
continue;
} else {
LOG.info("Client {} already exists on the cloud, update client values", dhcpLeasedIps); LOG.info("Client {} already exists on the cloud, update client values", dhcpLeasedIps);
ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails(); ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails();
@@ -1902,6 +1895,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// In this case, we might have a session, as the client // In this case, we might have a session, as the client
// already exists on the cloud, update if required // already exists on the cloud, update if required
ClientSession session = updateClientSession(customerId, equipmentId, locationId, dhcpLeasedIps, ClientSession session = updateClientSession(customerId, equipmentId, locationId, dhcpLeasedIps,
clientMacAddress); clientMacAddress);
if (session != null) { if (session != null) {
@@ -1909,15 +1903,61 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} }
}
}
if (!clientSessionList.isEmpty()) {
LOG.info("Updating client sessions {}", clientSessionList);
clientSessionList = clientServiceInterface.updateSessions(clientSessionList);
LOG.info("Updated client sessions {}", clientSessionList);
}
} else if (rowUpdateOperation.equals(RowUpdateOperation.MODIFY)
|| rowUpdateOperation.equals(RowUpdateOperation.INIT)) {
List<ClientSession> clientSessionList = new ArrayList<>();
for (Map<String, String> dhcpLeasedIps : dhcpAttributes) {
if (!dhcpLeasedIps.containsKey("hwaddr")) {
LOG.info("Cannot update a client {} that has no hwaddr.", dhcpLeasedIps);
continue;
}
MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr"));
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
clientMacAddress);
if (client == null) {
LOG.info("Cannot find client instance for {}", clientMacAddress);
continue;
} else if (clientMacAddress.equals(equipmentServiceInterface.get(equipmentId).getBaseMacAddress())) {
LOG.info("Not a client device {} ", dhcpLeasedIps);
// In case somehow this equipment has accidentally been
// tagged as a client, remove
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
clientMacAddress);
if (clientSession != null) {
LOG.info("Deleting invalid client session {}",
clientServiceInterface.deleteSession(customerId, equipmentId, clientMacAddress));
}
LOG.info("Deleting invalid client {}", clientServiceInterface.delete(customerId, clientMacAddress));
continue;
} else { } else {
client = new com.telecominfraproject.wlan.client.models.Client();
client.setCustomerId(customerId);
client.setMacAddress(clientMacAddress);
ClientInfoDetails clientDetails = new ClientInfoDetails();
ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails();
if (dhcpLeasedIps.containsKey("hostname")) { if (dhcpLeasedIps.containsKey("hostname")) {
clientDetails.setHostName(dhcpLeasedIps.get("hostname")); clientDetails.setHostName(dhcpLeasedIps.get("hostname"));
@@ -1944,120 +1984,18 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
client.setDetails(clientDetails); client.setDetails(clientDetails);
client = clientServiceInterface.create(client); client = clientServiceInterface.update(client);
LOG.info("Created Client {}.", client); LOG.info("Updated Client {}.", client);
}
// we might have a session, update if required // check if there is a session for this client
ClientSession session = updateClientSession(customerId, equipmentId, locationId, dhcpLeasedIps,
clientMacAddress);
if (session != null) {
clientSessionList.add(session);
}
} ClientSession session = updateClientSession(customerId, equipmentId, locationId, dhcpLeasedIps,
clientMacAddress);
if (!clientSessionList.isEmpty()) { if (session != null) {
LOG.info("Updating client sessions {}", clientSessionList); clientSessionList.add(session);
clientSessionList = clientServiceInterface.updateSessions(clientSessionList);
LOG.info("Updated client sessions {}", clientSessionList);
}
} else if (rowUpdateOperation.equals(RowUpdateOperation.MODIFY)
|| rowUpdateOperation.equals(RowUpdateOperation.INIT)) {
List<ClientSession> clientSessionList = new ArrayList<>();
for (Map<String, String> dhcpLeasedIps : dhcpAttributes) {
if (!dhcpLeasedIps.containsKey("hwaddr")) {
LOG.info("Cannot update a client {} that has no hwaddr.", dhcpLeasedIps);
continue;
}
MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr"));
if (clientMacAddress.equals(equipmentServiceInterface.get(equipmentId).getBaseMacAddress())) {
LOG.info("Not a client device {} ", dhcpLeasedIps);
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface
.getOrNull(customerId, clientMacAddress);
if (client != null) {
// In case somehow this equipment has accidentally been
// tagged as a client, remove
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
clientMacAddress);
if (clientSession != null) {
LOG.info("Deleting invalid client session {}",
clientServiceInterface.deleteSession(customerId, equipmentId, clientMacAddress));
}
LOG.info("Deleting invalid client {}",
clientServiceInterface.delete(customerId, clientMacAddress));
} }
continue;
}
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
clientMacAddress);
if (client == null) {
LOG.info("Client {} does not exist on the cloud. Creating...", dhcpLeasedIps);
client = new com.telecominfraproject.wlan.client.models.Client();
client.setCustomerId(customerId);
client.setMacAddress(clientMacAddress);
ClientInfoDetails clientDetails = new ClientInfoDetails();
client.setDetails(clientDetails);
client = clientServiceInterface.create(client);
}
ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails();
if (dhcpLeasedIps.containsKey("hostname")) {
clientDetails.setHostName(dhcpLeasedIps.get("hostname"));
}
if (dhcpLeasedIps.containsKey("fingerprint")) {
clientDetails.setApFingerprint(dhcpLeasedIps.get("fingerprint"));
}
if (dhcpLeasedIps.containsKey("device_type")) {
DhcpFpDeviceType dhcpFpDeviceType = DhcpFpDeviceType.getByName(dhcpLeasedIps.get("device_type"));
ClientType clientType = OvsdbToWlanCloudTypeMappingUtility
.getClientTypeForDhcpFpDeviceType(dhcpFpDeviceType);
LOG.debug("Translate from ovsdb {} to cloud {}", dhcpFpDeviceType, clientType);
clientDetails.setClientType(clientType.getId());
}
client.setDetails(clientDetails);
client = clientServiceInterface.update(client);
LOG.info("Updated Client {}.", client);
// check if there is a session for this client
ClientSession session = updateClientSession(customerId, equipmentId, locationId, dhcpLeasedIps,
clientMacAddress);
if (session != null) {
clientSessionList.add(session);
} }
} }
@@ -2096,7 +2034,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
//         "manuf_id": //         "manuf_id":
if (session == null) { if (session == null) {
session = new ClientSession(); return null;
} }
session.setCustomerId(customerId); session.setCustomerId(customerId);
session.setEquipmentId(equipmentId); session.setEquipmentId(equipmentId);

View File

@@ -1891,8 +1891,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
} }
} }
void handleClientSessionMetricsUpdate(int customerId, long equipmentId, long locationId, RadioType radioType, ClientSession handleClientSessionMetricsUpdate(int customerId, long equipmentId, long locationId,
long timestamp, sts.OpensyncStats.Client client) { RadioType radioType, long timestamp, sts.OpensyncStats.Client client) {
try try
{ {
@@ -1904,13 +1904,10 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
boolean isReassociation = true; boolean isReassociation = true;
if (clientInstance == null) { if (clientInstance == null) {
clientInstance = new com.telecominfraproject.wlan.client.models.Client();
clientInstance.setCustomerId(customerId);
clientInstance.setMacAddress(new MacAddress(client.getMacAddress()));
clientInstance.setDetails(new ClientInfoDetails());
clientInstance = clientServiceInterface.create(clientInstance);
isReassociation = false; LOG.info("Cannot get client instance for {}", client.getMacAddress());
return null;
} }
LOG.info("Client {}", clientInstance); LOG.info("Client {}", clientInstance);
@@ -1919,18 +1916,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
clientInstance.getMacAddress()); clientInstance.getMacAddress());
if (clientSession == null) { if (clientSession == null) {
LOG.info("Cannot get client session for {}", clientInstance.getMacAddress());
clientSession = new ClientSession(); return null;
clientSession.setCustomerId(customerId);
clientSession.setEquipmentId(equipmentId);
clientSession.setLocationId(locationId);
clientSession.setMacAddress(clientInstance.getMacAddress());
ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
clientSessionDetails.setSsid(client.getSsid());
clientSessionDetails.setRadioType(radioType);
clientSessionDetails.setSessionId(clientInstance.getMacAddress().getAddressAsLong());
clientSession.setDetails(new ClientSessionDetails());
clientSession = clientServiceInterface.updateSession(clientSession);
} }
ClientSessionDetails latestClientSessionDetails = clientSession.getDetails(); ClientSessionDetails latestClientSessionDetails = clientSession.getDetails();
@@ -1961,7 +1948,6 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (!ssidConfigList.isEmpty()) { if (!ssidConfigList.isEmpty()) {
Profile ssidProfile = ssidConfigList.iterator().next(); Profile ssidProfile = ssidConfigList.iterator().next();
SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails(); SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails();
if (ssidConfig.getSecureMode().equals(SecureMode.open)) { if (ssidConfig.getSecureMode().equals(SecureMode.open)) {
@@ -1979,7 +1965,6 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
|| ssidConfig.getSecureMode().equals(SecureMode.wpa2EAP) || ssidConfig.getSecureMode().equals(SecureMode.wpa2EAP)
|| ssidConfig.getSecureMode().equals(SecureMode.wpa2OnlyEAP)) { || ssidConfig.getSecureMode().equals(SecureMode.wpa2OnlyEAP)) {
latestClientSessionDetails.setSecurityType(SecurityType.RADIUS); latestClientSessionDetails.setSecurityType(SecurityType.RADIUS);
latestClientSessionDetails.setEapDetails(new ClientEapDetails()); latestClientSessionDetails.setEapDetails(new ClientEapDetails());
} else { } else {
latestClientSessionDetails.setSecurityType(SecurityType.UNSUPPORTED); latestClientSessionDetails.setSecurityType(SecurityType.UNSUPPORTED);
@@ -2009,9 +1994,11 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
LOG.debug("Updated client session {}", clientSession); LOG.debug("Updated client session {}", clientSession);
return clientSession;
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error while attempting to create ClientSession and Info", e); LOG.error("Error while attempting to create ClientSession and Info", e);
} }
return null;
} }
ClientSessionMetricDetails calculateClientSessionMetricDetails(sts.OpensyncStats.Client client, long timestamp) { ClientSessionMetricDetails calculateClientSessionMetricDetails(sts.OpensyncStats.Client client, long timestamp) {
@@ -2134,9 +2121,11 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
if (client.hasConnected() && client.getConnected() && client.hasMacAddress()) { if (client.hasConnected() && client.getConnected() && client.hasMacAddress()) {
// update metrics for connected client // update metrics for connected client
numConnectedClients += 1; ClientSession session = handleClientSessionMetricsUpdate(customerId, equipmentId, locationId, radioType,
handleClientSessionMetricsUpdate(customerId, equipmentId, locationId, radioType,
clientReport.getTimestampMs(), client); clientReport.getTimestampMs(), client);
if (session != null) {
numConnectedClients += 1;
}
} else { } else {
// Make sure, if we have a session for this client, // Make sure, if we have a session for this client,
// it // it
@@ -2258,7 +2247,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
ProfileContainer profileContainer = new ProfileContainer( ProfileContainer profileContainer = new ProfileContainer(
profileServiceInterface.getProfileWithChildren(profileId)); profileServiceInterface.getProfileWithChildren(profileId));
RfConfiguration rfConfig = (RfConfiguration) profileContainer.getChildOfTypeOrNull(profileId, ProfileType.rf) RfConfiguration rfConfig = (RfConfiguration) profileContainer.getChildOfTypeOrNull(profileId, ProfileType.rf)
.getDetails(); .getDetails();
for (Survey survey : report.getSurveyList()) { for (Survey survey : report.getSurveyList()) {

View File

@@ -193,14 +193,15 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
LOG.debug("Client {} connect for AP {}", clientCn, apId); LOG.debug("Client {} connect for AP {}", clientCn, apId);
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
ovsdbDao.removeAllSsids(ovsdbClient); // always
ovsdbDao.removeWifiRrm(ovsdbClient);
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId); OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
if (opensyncAPConfig != null) { if (opensyncAPConfig != null) {
ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
ovsdbDao.removeAllSsids(ovsdbClient, opensyncAPConfig); // always
ovsdbDao.removeWifiRrm(ovsdbClient);
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) {
@@ -210,10 +211,13 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
if (((ApNetworkConfiguration) opensyncAPConfig.getApProfile().getDetails()).getSyntheticClientEnabled()) { if (((ApNetworkConfiguration) opensyncAPConfig.getApProfile().getDetails()).getSyntheticClientEnabled()) {
ovsdbDao.enableNetworkProbeForSyntheticClient(ovsdbClient); ovsdbDao.enableNetworkProbeForSyntheticClient(ovsdbClient);
} }
} else {
ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
ovsdbDao.removeAllSsids(ovsdbClient); // always
ovsdbDao.removeWifiRrm(ovsdbClient);
} }
ovsdbDao.configureInterfaces(ovsdbClient);
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) { if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats); ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
} }
@@ -262,18 +266,18 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
return; return;
} }
ovsdbDao.removeAllSsids(ovsdbClient); // always ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
ovsdbDao.removeAllSsids(ovsdbClient, opensyncAPConfig); // always
ovsdbDao.removeWifiRrm(ovsdbClient); ovsdbDao.removeWifiRrm(ovsdbClient);
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);
@@ -507,7 +511,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
OvsdbDao.awlanNodeDbTable + "_" + key, OvsdbDao.awlanNodeDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest())), new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest(new MonitorSelect(true, false, false, true)))),
new MonitorCallback() { new MonitorCallback() {
@Override @Override
@@ -615,7 +619,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
CompletableFuture<TableUpdates> rsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, CompletableFuture<TableUpdates> rsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
OvsdbDao.wifiRadioStateDbTable + "_" + key, OvsdbDao.wifiRadioStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, new MonitorRequest())), new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, new MonitorRequest(new MonitorSelect(true, false, false, true)))),
new MonitorCallback() { new MonitorCallback() {
@Override @Override
@@ -636,7 +640,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
CompletableFuture<TableUpdates> vsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, CompletableFuture<TableUpdates> vsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
OvsdbDao.wifiVifStateDbTable + "_" + key, OvsdbDao.wifiVifStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest())), new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))),
new MonitorCallback() { new MonitorCallback() {
@Override @Override

View File

@@ -297,8 +297,10 @@ public class OvsdbDao {
if ((ret.ipV4Address == null) || (ret.macAddress == null)) { if ((ret.ipV4Address == null) || (ret.macAddress == null)) {
// when not found - look them up for if_name = br-lan // when not found - look them up for if_name = br-lan
fillInWanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType, defaultLanInterfaceName); fillInWanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType, defaultLanInterfaceName);
if (ret.ipV4Address == null) throw new RuntimeException("Could not get inet address for Lan and Wan network interfaces. Node is not ready to connect."); if (ret.ipV4Address == null)
throw new RuntimeException(
"Could not get inet address for Lan and Wan network interfaces. Node is not ready to connect.");
} }
fillInLanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType); fillInLanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType);
@@ -379,20 +381,20 @@ public class OvsdbDao {
String radioFrequencyBand = getSingleValueFromSet(row, "freq_band"); String radioFrequencyBand = getSingleValueFromSet(row, "freq_band");
switch (radioFrequencyBand) { switch (radioFrequencyBand) {
case "2.4G": case "2.4G":
radios.add(RadioType.is2dot4GHz); radios.add(RadioType.is2dot4GHz);
break; break;
case "5G": case "5G":
radios.add(RadioType.is5GHz); radios.add(RadioType.is5GHz);
break; break;
case "5GL": case "5GL":
radios.add(RadioType.is5GHzL); radios.add(RadioType.is5GHzL);
break; break;
case "5GU": case "5GU":
radios.add(RadioType.is5GHzU); radios.add(RadioType.is5GHzU);
break; break;
default: default:
LOG.debug("Unsupported or unrecognized radio band type {}", radioFrequencyBand); LOG.debug("Unsupported or unrecognized radio band type {}", radioFrequencyBand);
} }
@@ -973,88 +975,6 @@ public class OvsdbDao {
return ret; return ret;
} }
public Map<String, PortInfo> getProvisionedPorts(OvsdbClient ovsdbClient) {
Map<String, PortInfo> ret = new HashMap<>();
List<Operation> operations = new ArrayList<>();
List<Condition> conditions = new ArrayList<>();
List<String> columns = new ArrayList<>();
columns.add("name");
columns.add("_uuid");
columns.add("interfaces");
try {
LOG.debug("Retrieving Ports:");
operations.add(new Select(portDbTable, conditions, columns));
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
for (OperationResult res : result) {
LOG.debug("Op Result {}", res);
}
for (Row row : ((SelectResult) result[0]).getRows()) {
PortInfo portInfo = new PortInfo();
portInfo.name = row.getStringColumn("name");
portInfo.uuid = row.getUuidColumn("_uuid");
portInfo.interfaceUuids = row.getSetColumn("interfaces");
ret.put(portInfo.name, portInfo);
}
LOG.debug("Retrieved Ports: {}", ret);
} catch (ExecutionException | InterruptedException | OvsdbClientException | TimeoutException e) {
LOG.error("Error in getProvisionedPorts", e);
throw new RuntimeException(e);
}
return ret;
}
public Map<String, BridgeInfo> getProvisionedBridges(OvsdbClient ovsdbClient) {
Map<String, BridgeInfo> ret = new HashMap<>();
List<Operation> operations = new ArrayList<>();
List<Condition> conditions = new ArrayList<>();
List<String> columns = new ArrayList<>();
columns.add("name");
columns.add("_uuid");
columns.add("ports");
try {
LOG.debug("Retrieving Bridges:");
operations.add(new Select(bridgeDbTable, conditions, columns));
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
for (OperationResult res : result) {
LOG.debug("Op Result {}", res);
}
for (Row row : ((SelectResult) result[0]).getRows()) {
BridgeInfo bridgeInfo = new BridgeInfo();
bridgeInfo.name = row.getStringColumn("name");
bridgeInfo.uuid = row.getUuidColumn("_uuid");
bridgeInfo.portUuids = row.getSetColumn("ports");
ret.put(bridgeInfo.name, bridgeInfo);
}
LOG.debug("Retrieved Bridges: {}", ret);
} catch (ExecutionException | InterruptedException | OvsdbClientException | TimeoutException e) {
LOG.error("Error in getProvisionedBridges", e);
throw new RuntimeException(e);
}
return ret;
}
public Map<String, CommandConfigInfo> getProvisionedCommandConfigs(OvsdbClient ovsdbClient) { public Map<String, CommandConfigInfo> getProvisionedCommandConfigs(OvsdbClient ovsdbClient) {
Map<String, CommandConfigInfo> ret = new HashMap<>(); Map<String, CommandConfigInfo> ret = new HashMap<>();
@@ -1779,62 +1699,106 @@ public class OvsdbDao {
} }
} }
public void provisionBridgePortInterface(OvsdbClient ovsdbClient) { public void removeAllSsids(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
Map<String, WifiVifConfigInfo> currentWifiVifConfigInfo = getProvisionedWifiVifConfigs(ovsdbClient);
Map<String, WifiRadioConfigInfo> currentWifiRadioConfigInfo = getProvisionedWifiRadioConfigs(ovsdbClient);
List<WifiVifConfigInfo> vifConfigsToDelete = new ArrayList<>();
for (Entry<String, WifiVifConfigInfo> vifConfigInfo : currentWifiVifConfigInfo.entrySet()) {
LOG.debug("Checking {}", vifConfigInfo.getKey());
WifiRadioConfigInfo radioConfigInfo = null;
if (vifConfigInfo.getValue().ifName.startsWith(defaultRadio0)) {
radioConfigInfo = currentWifiRadioConfigInfo.get(radio0);
} else if (vifConfigInfo.getValue().ifName.startsWith(defaultRadio1)) {
radioConfigInfo = currentWifiRadioConfigInfo.get(radio1);
} else if (vifConfigInfo.getValue().ifName.startsWith(defaultRadio2)) {
radioConfigInfo = currentWifiRadioConfigInfo.get(radio2);
}
boolean delete = true;
if (radioConfigInfo != null) {
final String freqBand = radioConfigInfo.freqBand;
if (radioConfigInfo.vifConfigUuids.contains(vifConfigInfo.getValue().uuid)) {
if (opensyncAPConfig.getSsidProfile().stream().anyMatch(new Predicate<Profile>() {
@Override
public boolean test(Profile t) {
SsidConfiguration ssidConfig = (SsidConfiguration) t.getDetails();
return (ssidConfig.getSsid().equals(vifConfigInfo.getValue().ssid))
&& (ssidConfig.getAppliedRadios().contains(OvsdbToWlanCloudTypeMappingUtility
.getRadioTypeForOvsdbRadioFreqBand(freqBand)));
}
})) {
delete = false;
LOG.debug("Do not delete vif {}", vifConfigInfo.getValue());
}
}
}
if (delete) {
vifConfigsToDelete.add(vifConfigInfo.getValue());
}
}
LOG.debug("The following VIFs should be deleted {}", vifConfigsToDelete);
List<Operation> operations = new ArrayList<>();
for (WifiVifConfigInfo vifConfigInfo : vifConfigsToDelete) {
List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("_uuid", Function.EQUALS, new Atom<>(vifConfigInfo.uuid)));
operations.add(new Delete(wifiVifConfigDbTable, conditions));
}
try { try {
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
String patchW2h = "patch-w2h"; if (LOG.isDebugEnabled()) {
String patchH2w = "patch-h2w"; LOG.debug("Removed existing SSIDs from {}:", wifiVifConfigDbTable);
Map<String, InterfaceInfo> provisionedInterfaces = getProvisionedInterfaces(ovsdbClient);
if (provisionedInterfaces.isEmpty()) { for (OperationResult res : result) {
LOG.debug("No Interfaces defined in Ovsdb. Cannot perform Bridge/Port/Interface mapping."); LOG.debug("Op Result {}", res);
return; }
} }
LOG.debug("Existing Interfaces: {}", provisionedInterfaces.keySet());
Map<String, PortInfo> provisionedPorts = getProvisionedPorts(ovsdbClient); operations = new ArrayList<>();
if (provisionedInterfaces.isEmpty()) { // Add vifs to delete
LOG.debug("No Ports defined in Ovsdb. Cannot perform Bridge/Port/Interface mapping."); for (WifiVifConfigInfo vifConfigInfo : vifConfigsToDelete) {
return; List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(vifConfigInfo.ifName)));
operations.add(new Delete(wifiInetConfigDbTable, conditions));
} }
LOG.debug("Existing Ports: {}", provisionedPorts.keySet());
Map<String, BridgeInfo> provisionedBridges = getProvisionedBridges(ovsdbClient); fResult = ovsdbClient.transact(ovsdbName, operations);
if (provisionedInterfaces.isEmpty()) { result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
LOG.debug("No Bridges defined in Ovsdb. Cannot perform Bridge/Port/Interface mapping.");
return; if (LOG.isDebugEnabled()) {
LOG.debug("Removed existing InetConfigs from {}:", wifiVifConfigDbTable);
for (OperationResult res : result) {
LOG.debug("Op Result {}", res);
}
} }
LOG.debug("Existing Bridges: {}", provisionedBridges.keySet());
Map<String, String> patchH2wOptions = new HashMap<>(); } catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
patchH2wOptions.put("peer", "patch-w2h"); LOG.error("Error in removeAllSsids", e);
Map<String, String> patchW2hOptions = new HashMap<>();
patchH2wOptions.put("peer", "patch-h2w");
provisionSingleBridgePortInterface(ovsdbClient, patchH2w, bridgeNameVifInterfaces, "patch", patchH2wOptions,
provisionedInterfaces, provisionedPorts, provisionedBridges);
provisionSingleBridgePortInterface(ovsdbClient, patchW2h, defaultWanInterfaceType, "patch", patchW2hOptions,
provisionedInterfaces, provisionedPorts, provisionedBridges);
provisionSingleBridgePortInterface(ovsdbClient, defaultRadio0, bridgeNameVifInterfaces, "vif", null,
provisionedInterfaces, provisionedPorts, provisionedBridges);
provisionSingleBridgePortInterface(ovsdbClient, defaultRadio1, bridgeNameVifInterfaces, "vif", null,
provisionedInterfaces, provisionedPorts, provisionedBridges);
provisionSingleBridgePortInterface(ovsdbClient, defaultRadio2, bridgeNameVifInterfaces, "vif", null,
provisionedInterfaces, provisionedPorts, provisionedBridges);
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
LOG.error("Error in provisionBridgePortInterface", e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public void removeAllSsids(OvsdbClient ovsdbClient) { public void removeAllSsids(OvsdbClient ovsdbClient) {
try { try {
removeAllHotspot20Config(ovsdbClient); removeAllPasspointConfigs(ovsdbClient);
removeAllHotspot20OsuProviders(ovsdbClient);
removeAllHotspot20IconConfig(ovsdbClient);
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
@@ -1893,6 +1857,12 @@ public class OvsdbDao {
} }
public void removeAllPasspointConfigs(OvsdbClient ovsdbClient) {
removeAllHotspot20Config(ovsdbClient);
removeAllHotspot20OsuProviders(ovsdbClient);
removeAllHotspot20IconConfig(ovsdbClient);
}
public void configureWifiRadios(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) { public void configureWifiRadios(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
String country = opensyncAPConfig.getCountryCode(); // should be the String country = opensyncAPConfig.getCountryCode(); // should be the
@@ -1913,23 +1883,23 @@ public class OvsdbDao {
ChannelBandwidth bandwidth = rfElementConfig.getChannelBandwidth(); ChannelBandwidth bandwidth = rfElementConfig.getChannelBandwidth();
String ht_mode = null; String ht_mode = null;
switch (bandwidth) { switch (bandwidth) {
case is20MHz: case is20MHz:
ht_mode = "HT20"; ht_mode = "HT20";
break; break;
case is40MHz: case is40MHz:
ht_mode = "HT40"; ht_mode = "HT40";
break; break;
case is80MHz: case is80MHz:
ht_mode = "HT80"; ht_mode = "HT80";
break; break;
case is160MHz: case is160MHz:
ht_mode = "HT160"; ht_mode = "HT160";
break; break;
case auto: case auto:
ht_mode = "0"; ht_mode = "0";
break; break;
default: default:
ht_mode = null; ht_mode = null;
} }
rfElementConfig.getAutoChannelSelection(); rfElementConfig.getAutoChannelSelection();
@@ -1946,75 +1916,75 @@ public class OvsdbDao {
String hwMode = null; String hwMode = null;
switch (rfElementConfig.getRadioMode()) { switch (rfElementConfig.getRadioMode()) {
case modeA: case modeA:
hwMode = "11a"; hwMode = "11a";
break; break;
case modeAB: case modeAB:
hwMode = "11ab"; hwMode = "11ab";
break; break;
case modeAC: case modeAC:
hwMode = "11ac"; hwMode = "11ac";
break; break;
case modeB: case modeB:
hwMode = "11b"; hwMode = "11b";
break; break;
case modeG: case modeG:
hwMode = "11g"; hwMode = "11g";
break; break;
case modeX: case modeX:
hwMode = "11ax"; hwMode = "11ax";
break; break;
case modeN: case modeN:
hwMode = "11n"; hwMode = "11n";
break; break;
default: default:
} }
String freqBand = null; String freqBand = null;
switch (radioType) { switch (radioType) {
case is2dot4GHz: case is2dot4GHz:
freqBand = "2.4G"; freqBand = "2.4G";
break; break;
case is5GHz: case is5GHz:
// 802.11h dfs (Dynamic Frequency Selection) aka military // 802.11h dfs (Dynamic Frequency Selection) aka military
// and // and
// weather radar // weather radar
// avoidance protocol // avoidance protocol
// Must not be disabled (by law) // Must not be disabled (by law)
// NA for 2.4GHz // NA for 2.4GHz
hwConfig.put("dfs_enable", "1"); hwConfig.put("dfs_enable", "1");
hwConfig.put("dfs_ignorecac", "0"); hwConfig.put("dfs_ignorecac", "0");
hwConfig.put("dfs_usenol", "1"); hwConfig.put("dfs_usenol", "1");
freqBand = "5G"; freqBand = "5G";
break; break;
case is5GHzL: case is5GHzL:
// 802.11h dfs (Dynamic Frequency Selection) aka military // 802.11h dfs (Dynamic Frequency Selection) aka military
// and // and
// weather radar // weather radar
// avoidance protocol // avoidance protocol
// Must not be disabled (by law) // Must not be disabled (by law)
// NA for 2.4GHz // NA for 2.4GHz
hwConfig.put("dfs_enable", "1"); hwConfig.put("dfs_enable", "1");
hwConfig.put("dfs_ignorecac", "0"); hwConfig.put("dfs_ignorecac", "0");
hwConfig.put("dfs_usenol", "1"); hwConfig.put("dfs_usenol", "1");
freqBand = "5GL"; freqBand = "5GL";
break; break;
case is5GHzU: case is5GHzU:
// 802.11h dfs (Dynamic Frequency Selection) aka military // 802.11h dfs (Dynamic Frequency Selection) aka military
// and // and
// weather radar // weather radar
// avoidance protocol // avoidance protocol
// Must not be disabled (by law) // Must not be disabled (by law)
// NA for 2.4GHz // NA for 2.4GHz
hwConfig.put("dfs_enable", "1"); hwConfig.put("dfs_enable", "1");
hwConfig.put("dfs_ignorecac", "0"); hwConfig.put("dfs_ignorecac", "0");
hwConfig.put("dfs_usenol", "1"); hwConfig.put("dfs_usenol", "1");
freqBand = "5GU"; freqBand = "5GU";
break; break;
default: // don't know this interface default: // don't know this interface
continue; continue;
} }
@@ -2137,20 +2107,20 @@ public class OvsdbDao {
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
String frequencyBand = row.getStringColumn("freq_band"); String frequencyBand = row.getStringColumn("freq_band");
switch (frequencyBand) { switch (frequencyBand) {
case "2.4G": case "2.4G":
tableState.setFreqBand(RadioType.is2dot4GHz); tableState.setFreqBand(RadioType.is2dot4GHz);
break; break;
case "5G": case "5G":
tableState.setFreqBand(RadioType.is5GHz); tableState.setFreqBand(RadioType.is5GHz);
break; break;
case "5GL": case "5GL":
tableState.setFreqBand(RadioType.is5GHzL); tableState.setFreqBand(RadioType.is5GHzL);
break; break;
case "5GU": case "5GU":
tableState.setFreqBand(RadioType.is5GHzU); tableState.setFreqBand(RadioType.is5GHzU);
break; break;
default: default:
tableState.setFreqBand(RadioType.UNSUPPORTED); tableState.setFreqBand(RadioType.UNSUPPORTED);
} }
} }
if ((map.get("if_name") != null) && map.get("if_name").getClass() if ((map.get("if_name") != null) && map.get("if_name").getClass()
@@ -2615,7 +2585,7 @@ public class OvsdbDao {
String ipAssignScheme, List<MacAddress> macBlockList, boolean rateLimitEnable, int ssidDlLimit, String ipAssignScheme, List<MacAddress> macBlockList, boolean rateLimitEnable, int ssidDlLimit,
int ssidUlLimit, int clientDlLimit, int clientUlLimit, int rtsCtsThreshold, int fragThresholdBytes, int ssidUlLimit, int clientDlLimit, int clientUlLimit, int rtsCtsThreshold, int fragThresholdBytes,
int dtimPeriod, Map<String, String> captiveMap, List<String> walledGardenAllowlist, int dtimPeriod, Map<String, String> captiveMap, List<String> walledGardenAllowlist,
Map<Short, Set<String>> bonjourServiceMap) { Map<Short, Set<String>> bonjourServiceMap, boolean isUpdate) {
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
Map<String, Value> updateColumns = new HashMap<>(); Map<String, Value> updateColumns = new HashMap<>();
@@ -2718,29 +2688,46 @@ public class OvsdbDao {
updateBlockList(updateColumns, macBlockList); updateBlockList(updateColumns, macBlockList);
Row row = new Row(updateColumns); Row row = new Row(updateColumns);
operations.add(new Insert(wifiVifConfigDbTable, row));
//////
if (isUpdate) {
List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(vifInterfaceName)));
operations.add(new Update(wifiVifConfigDbTable, conditions, row));
} else {
operations.add(new Insert(wifiVifConfigDbTable, row));
}
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations); CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
LOG.debug("Provisioned SSID {} on {}", ssid, vifInterfaceName);
Uuid vifConfigUuid = null; if (isUpdate) {
for (OperationResult res : result) { for (OperationResult res : result) {
LOG.debug("Op Result {}", res); LOG.debug("Op Result {}", res);
if (res instanceof InsertResult) {
vifConfigUuid = ((InsertResult) res).getUuid();
} }
LOG.info("Updated existing SSID {} on interface {} / {}", ssid, vifInterfaceName, radioFreqBand);
} else {
Uuid vifConfigUuid = null;
for (OperationResult res : result) {
LOG.debug("Op Result {}", res);
if (res instanceof InsertResult) {
vifConfigUuid = ((InsertResult) res).getUuid();
}
}
if (vifConfigUuid == null) {
throw new IllegalStateException("Wifi_VIF_Config entry was not created successfully");
}
updateColumns.clear();
operations.clear();
updateVifConfigsSetForRadio(ovsdbClient, ssid, radioFreqBand, operations, updateColumns, vifConfigUuid);
LOG.info("Provisioned SSID {} on interface {} / {}", ssid, vifInterfaceName, radioFreqBand);
} }
if (vifConfigUuid == null) {
throw new IllegalStateException("Wifi_VIF_Config entry was not created successfully");
}
updateColumns.clear();
operations.clear();
updateVifConfigsSetForRadio(ovsdbClient, ssid, radioFreqBand, operations, updateColumns, vifConfigUuid);
Map<String, WifiInetConfigInfo> inetConfigs = getProvisionedWifiInetConfigs(ovsdbClient); Map<String, WifiInetConfigInfo> inetConfigs = getProvisionedWifiInetConfigs(ovsdbClient);
if (inetConfigs.containsKey(vifInterfaceName)) { if (inetConfigs.containsKey(vifInterfaceName)) {
@@ -2751,12 +2738,11 @@ public class OvsdbDao {
(networkForwardMode == NetworkForwardMode.NAT)); (networkForwardMode == NetworkForwardMode.NAT));
} }
LOG.info("Provisioned SSID {} on interface {} / {}", ssid, vifInterfaceName, radioFreqBand);
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
LOG.error("Error in configureSingleSsid", e); LOG.error("Error in configureSingleSsid", e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
private void updateBlockList(Map<String, Value> updateColumns, List<MacAddress> macBlockList) { private void updateBlockList(Map<String, Value> updateColumns, List<MacAddress> macBlockList) {
@@ -3093,25 +3079,39 @@ public class OvsdbDao {
boolean enabled = ssidConfig.getSsidAdminState().equals(StateSetting.enabled); boolean enabled = ssidConfig.getSsidAdminState().equals(StateSetting.enabled);
int numberOfInterfaces = 0;
for (String key : getProvisionedWifiVifConfigs(ovsdbClient).keySet()) {
if (key.startsWith(ifName)) {
numberOfInterfaces++;
}
}
try { try {
if (numberOfInterfaces >= maxInterfacesPerRadio) { boolean isUpdate = false;
// this cannot occur, log error, do not try to provision Map<String, WifiVifConfigInfo> provisionedVifs = getProvisionedWifiVifConfigs(ovsdbClient);
throw new IllegalStateException( for (String key : provisionedVifs.keySet()) {
"Cannot provision more than " + maxInterfacesPerRadio + " interfaces per Wifi Radio"); if (key.contains(ifName) && key.contains(ssidConfig.getSsid())) {
isUpdate = true;
ifName = provisionedVifs.get(key).ifName;
break;
}
} }
if (numberOfInterfaces > 0) { if (!isUpdate) {
// 1st interface has no number, 2nd has '_1', 3rd has int numberOfInterfaces = 0;
// '_2' etc. for (String key : getProvisionedWifiVifConfigs(ovsdbClient).keySet()) {
ifName = ifName + "_" + numberOfInterfaces; if (key.startsWith(ifName)) {
numberOfInterfaces++;
}
}
if (numberOfInterfaces >= maxInterfacesPerRadio) {
// this cannot occur, log error, do not try to
// provision
throw new IllegalStateException("Cannot provision more than " + maxInterfacesPerRadio
+ " interfaces per Wifi Radio");
}
if (numberOfInterfaces > 0) {
// 1st interface has no number, 2nd has '_1', 3rd
// has
// '_2' etc.
ifName = ifName + "_" + numberOfInterfaces;
}
} }
configureSingleSsid(ovsdbClient, ifName, ssidConfig.getSsid(), ssidBroadcast, security, freqBand, configureSingleSsid(ovsdbClient, ifName, ssidConfig.getSsid(), ssidBroadcast, security, freqBand,
@@ -3119,7 +3119,8 @@ public class OvsdbDao {
enable80211k, minHwMode, enabled, keyRefresh, uapsdEnabled, apBridge, enable80211k, minHwMode, enabled, keyRefresh, uapsdEnabled, apBridge,
ssidConfig.getForwardMode(), gateway, inet, dns, ipAssignScheme, macBlockList, ssidConfig.getForwardMode(), gateway, inet, dns, ipAssignScheme, macBlockList,
rateLimitEnable, ssidDlLimit, ssidUlLimit, clientDlLimit, clientUlLimit, rtsCtsThreshold, rateLimitEnable, ssidDlLimit, ssidUlLimit, clientDlLimit, clientUlLimit, rtsCtsThreshold,
fragThresholdBytes, dtimPeriod, captiveMap, walledGardenAllowlist, bonjourServiceMap); fragThresholdBytes, dtimPeriod, captiveMap, walledGardenAllowlist, bonjourServiceMap,
isUpdate);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// could not provision this SSID, but still can go on // could not provision this SSID, but still can go on
@@ -3317,15 +3318,15 @@ public class OvsdbDao {
private String getCaptiveAuthentication(CaptivePortalAuthenticationType authentication) { private String getCaptiveAuthentication(CaptivePortalAuthenticationType authentication) {
switch (authentication) { switch (authentication) {
case guest: case guest:
return "None"; return "None";
case username: case username:
return "Captive Portal User List"; return "Captive Portal User List";
case radius: case radius:
return "RADIUS"; return "RADIUS";
default: default:
LOG.error("Unsupported captive portal authentication {}", authentication); LOG.error("Unsupported captive portal authentication {}", authentication);
return "None"; return "None";
} }
} }

View File

@@ -126,7 +126,7 @@ public class OpensyncGatewayTipWlanOvsdbClientTest {
Mockito.verify(ovsdbSessionMapInterface).getSession("Test_Client_21P10C68818122"); Mockito.verify(ovsdbSessionMapInterface).getSession("Test_Client_21P10C68818122");
Mockito.verify(ovsdbSession).getOvsdbClient(); Mockito.verify(ovsdbSession).getOvsdbClient();
Mockito.verify(opensyncExternalIntegrationInterface).getApConfig("Test_Client_21P10C68818122"); Mockito.verify(opensyncExternalIntegrationInterface).getApConfig("Test_Client_21P10C68818122");
Mockito.verify(ovsdbDao).removeAllSsids(ovsdbClient); Mockito.verify(ovsdbDao).removeAllSsids(ovsdbClient, apConfig);
Mockito.verify(ovsdbDao).removeAllStatsConfigs(ovsdbClient); Mockito.verify(ovsdbDao).removeAllStatsConfigs(ovsdbClient);
Mockito.verify(ovsdbDao).configureWifiRadios(ovsdbClient, apConfig); Mockito.verify(ovsdbDao).configureWifiRadios(ovsdbClient, apConfig);
Mockito.verify(ovsdbDao).configureSsids(ovsdbClient, apConfig); Mockito.verify(ovsdbDao).configureSsids(ovsdbClient, apConfig);