mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-06 04:36:17 +02:00
Avoid division by zero
Nothing stops an OF agent to return zero for lambda values and ONOS probably ought to not crash then. One use case for this is when only one direction is supported on a port, for example tx. Unfortunately, the openflow specification does not separate the directions into different properties, so the agent implementation has to return some frequency value for rx in this case even if only the tx direction is supported. However, anything non-zero would probably be untruthful as it would indicate valid reading to the end user. Even zero will be problematic for unsupported power reading in a direction as 0 dBm is a valid value, but not sure how to deal with any better. Change-Id: I2597bd7d577d9c2e1a3b44421fe505b8b3b6cc92
This commit is contained in:
parent
b7e618d43d
commit
73f9aeaa11
@ -994,7 +994,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
|
||||
// f = c / λ
|
||||
// (m/s) * (nm/m) / (nm * 100) * 100
|
||||
// annotations is in Hz
|
||||
return Long.toString(c * 1_000_000_000 / lambda * 100);
|
||||
return Long.toString(lambda == 0 ? lambda : (c * 1_000_000_000 / lambda * 100));
|
||||
}
|
||||
|
||||
private PortDescription buildPortDescription14(OFPortDesc port) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user