implements ConfigInterface, GatewayMacResolver,PacketProcessingListener {
private static final Logger LOG = LoggerFactory.getLogger(GatewayMacResolverService.class);
- private static final short TABLE_FOR_ARP_FLOW = 0;
private static final String ARP_REPLY_TO_CONTROLLER_FLOW_NAME = "GatewayArpReplyRouter";
private static final int ARP_REPLY_TO_CONTROLLER_FLOW_PRIORITY = 10000;
private static final Instruction SEND_TO_CONTROLLER_INSTRUCTION;
for(final Entry<Ipv4Address, ArpResolverMetadata> gatewayToArpMetadataEntry : gatewayToArpMetadataMap.entrySet()){
final Ipv4Address gatewayIp = gatewayToArpMetadataEntry.getKey();
final ArpResolverMetadata gatewayMetaData =
- checkAndGetExternalBridgeDpid(gatewayToArpMetadataEntry.getValue());
+ checkAndGetExternalBridgeDpid(
+ resetFlowToRemove(gatewayIp, gatewayToArpMetadataEntry.getValue()));
gatewayMacRefresherPool.schedule(new Runnable(){
@Override
ArpResolverMetadata arpResolverMetadata = gatewayToArpMetadataMap.get(gatewayIp);
if(arpResolverMetadata != null && arpResolverMetadata.getGatewayMacAddress() != null){
if(!arpResolverMetadata.isPeriodicRefresh()){
+ resetFlowToRemove(gatewayIp, arpResolverMetadata);
return gatewayToArpMetadataMap.remove(gatewayIp).getGatewayMacAddress();
}
return arpResolverMetadata.getGatewayMacAddress();
private Flow createArpReplyToControllerFlow(final ArpMessageAddress senderAddress, final Ipv4Address ipForRequestedMac) {
checkNotNull(senderAddress);
checkNotNull(ipForRequestedMac);
- FlowBuilder arpFlow = new FlowBuilder().setTableId(TABLE_FOR_ARP_FLOW)
+ FlowBuilder arpFlow = new FlowBuilder().setTableId(Service.CLASSIFIER.getTable())
.setFlowName(ARP_REPLY_TO_CONTROLLER_FLOW_NAME)
.setPriority(ARP_REPLY_TO_CONTROLLER_FLOW_PRIORITY)
.setBufferId(OFConstants.OFP_NO_BUFFER)
if(candidateGatewayIp != null){
LOG.debug("Resolved MAC for Gateway Ip {} is {}",gatewayIpAddress.getValue(),gatewayMacAddress.getValue());
candidateGatewayIp.setGatewayMacAddress(gatewayMacAddress);
- flowService.removeFlow(candidateGatewayIp.getFlowToRemove());
+ resetFlowToRemove(gatewayIpAddress, candidateGatewayIp);
}
}
}
@Override
public void stopPeriodicRefresh(Ipv4Address gatewayIp) {
init();
+ resetFlowToRemove(gatewayIp, null);
gatewayToArpMetadataMap.remove(gatewayIp);
}
+ private ArpResolverMetadata resetFlowToRemove(
+ final Ipv4Address gatewayIp, ArpResolverMetadata gatewayArpMetadata) {
+ checkNotNull(gatewayIp);
+
+ // If gatewayArpMetadata was not provided, look it up
+ if (gatewayArpMetadata == null) {
+ gatewayArpMetadata = gatewayToArpMetadataMap.get(gatewayIp);
+ }
+ if (gatewayArpMetadata != null && gatewayArpMetadata.getFlowToRemove() != null) {
+ LOG.debug("Flow to route ARP Reply to Controller from {} being removed from node {}",
+ gatewayIp, gatewayArpMetadata.getFlowToRemove().getNode());
+ flowService.removeFlow(gatewayArpMetadata.getFlowToRemove());
+ gatewayArpMetadata.setFlowToRemove(null);
+ }
+ return gatewayArpMetadata;
+ }
+
}