Committed by
Gerrit Code Review
Fix possible concurrency flaws in ArpHandler
Change-Id: I7e869453aefa580246af593c211aa98fb417f5cc
Showing
1 changed file
with
5 additions
and
4 deletions
| ... | @@ -88,7 +88,6 @@ public class ArpHandler { | ... | @@ -88,7 +88,6 @@ public class ArpHandler { |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | private void handleArpRequest(DeviceId deviceId, ConnectPoint inPort, Ethernet payload) { | 90 | private void handleArpRequest(DeviceId deviceId, ConnectPoint inPort, Ethernet payload) { |
| 91 | - | ||
| 92 | ARP arpRequest = (ARP) payload.getPayload(); | 91 | ARP arpRequest = (ARP) payload.getPayload(); |
| 93 | HostId targetHostId = HostId.hostId(MacAddress.valueOf( | 92 | HostId targetHostId = HostId.hostId(MacAddress.valueOf( |
| 94 | arpRequest.getTargetHardwareAddress())); | 93 | arpRequest.getTargetHardwareAddress())); |
| ... | @@ -98,16 +97,18 @@ public class ArpHandler { | ... | @@ -98,16 +97,18 @@ public class ArpHandler { |
| 98 | Ip4Address targetAddress = Ip4Address.valueOf(arpRequest.getTargetProtocolAddress()); | 97 | Ip4Address targetAddress = Ip4Address.valueOf(arpRequest.getTargetProtocolAddress()); |
| 99 | 98 | ||
| 100 | sendArpResponse(arpRequest, config.getRouterMacForAGatewayIp(targetAddress)); | 99 | sendArpResponse(arpRequest, config.getRouterMacForAGatewayIp(targetAddress)); |
| 100 | + } else { | ||
| 101 | + Host targetHost = srManager.hostService.getHost(targetHostId); | ||
| 101 | // ARP request for known hosts | 102 | // ARP request for known hosts |
| 102 | - } else if (srManager.hostService.getHost(targetHostId) != null) { | 103 | + if (targetHost != null) { |
| 103 | - MacAddress targetMac = srManager.hostService.getHost(targetHostId).mac(); | 104 | + sendArpResponse(arpRequest, targetHost.mac()); |
| 104 | - sendArpResponse(arpRequest, targetMac); | ||
| 105 | 105 | ||
| 106 | // ARP request for unknown host in the subnet | 106 | // ARP request for unknown host in the subnet |
| 107 | } else if (isArpReqForSubnet(deviceId, arpRequest)) { | 107 | } else if (isArpReqForSubnet(deviceId, arpRequest)) { |
| 108 | flood(payload, inPort); | 108 | flood(payload, inPort); |
| 109 | } | 109 | } |
| 110 | } | 110 | } |
| 111 | + } | ||
| 111 | 112 | ||
| 112 | 113 | ||
| 113 | private boolean isArpReqForRouter(DeviceId deviceId, ARP arpRequest) { | 114 | private boolean isArpReqForRouter(DeviceId deviceId, ARP arpRequest) { | ... | ... |
-
Please register or login to post a comment