static final BigInteger COOKIE_TUNNEL = new BigInteger("9000000", 16);
static final String FLOWID_PREFIX = "NAT.";
- static final BigInteger COOKIE_VM_LFIB_TABLE = new BigInteger("8000002", 16);
public VpnFloatingIpHandler(VpnRpcService vpnService, IBgpManager bgpManager, FibRpcService fibService) {
this.vpnService = vpnService;
this.fibManager = fibManager;
}
+ void setBgpManager(IBgpManager bgpManager) {
+ this.bgpManager = bgpManager;
+ }
+
@Override
public void onAddFloatingIp(final BigInteger dpnId, final String routerId,
Uuid networkId, final String interfaceName, final String externalIp, final String internalIp) {
- final String vpnName = NatUtil.getAssociatedVPN(dataBroker, networkId, LOG);
+ final String vpnName = getAssociatedVPN(networkId, routerId);
if(vpnName == null) {
LOG.info("No VPN associated with ext nw {} to handle add floating ip configuration {} in router {}",
networkId, externalIp, routerId);
List<Instruction> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
- actionsInfos.add(new ActionInfo(ActionType.nx_resubmit, new String[] { Integer.toString(NatConstants.PDNAT_TABLE) }));
+ actionsInfos.add(new ActionInfo(ActionType.nx_resubmit, new String[] { Integer.toString(NwConstants.PDNAT_TABLE) }));
instructions.add(new InstructionInfo(InstructionType.apply_actions, actionsInfos).buildInstruction(0));
makeTunnelTableEntry(dpnId, label, instructions);
//Install custom FIB routes
List<Instruction> customInstructions = new ArrayList<>();
- customInstructions.add(new InstructionInfo(InstructionType.goto_table, new long[] { NatConstants.PDNAT_TABLE }).buildInstruction(0));
- makeLFibTableEntry(dpnId, label, NatConstants.PDNAT_TABLE);
+ customInstructions.add(new InstructionInfo(InstructionType.goto_table, new long[] { NwConstants.PDNAT_TABLE }).buildInstruction(0));
+ makeLFibTableEntry(dpnId, label, NwConstants.PDNAT_TABLE);
CreateFibEntryInput input = new CreateFibEntryInputBuilder().setVpnName(vpnName).setSourceDpid(dpnId).setInstruction(customInstructions)
.setIpAddress(externalIp + "/32").setServiceId(label).setInstruction(customInstructions).build();
//Future<RpcResult<java.lang.Void>> createFibEntry(CreateFibEntryInput input);
@Override
public void onRemoveFloatingIp(final BigInteger dpnId, String routerId, Uuid networkId, final String externalIp,
String internalIp, final long label) {
- final String vpnName = NatUtil.getAssociatedVPN(dataBroker, networkId, LOG);
+ final String vpnName = getAssociatedVPN(networkId, routerId);
if(vpnName == null) {
LOG.info("No VPN associated with ext nw {} to handle remove floating ip configuration {} in router {}",
networkId, externalIp, routerId);
RemoveFibEntryInput input = new RemoveFibEntryInputBuilder().setVpnName(vpnName).setSourceDpid(dpnId).setIpAddress(externalIp + "/32").setServiceId(label).build();
Future<RpcResult<Void>> future = fibService.removeFibEntry(input);
- ListenableFuture<RpcResult<Void>> labelFuture = Futures.transform(JdkFutureAdapters.listenInPoolThread(future),
+ ListenableFuture<RpcResult<Void>> labelFuture = Futures.transform(JdkFutureAdapters.listenInPoolThread(future),
new AsyncFunction<RpcResult<Void>, RpcResult<Void>>() {
@Override
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef,
10, flowRef, 0, 0,
- COOKIE_VM_LFIB_TABLE, matches, instructions);
+ NwConstants.COOKIE_VM_LFIB_TABLE, matches, instructions);
mdsalManager.installFlow(dpId, flowEntity);
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef,
10, flowRef, 0, 0,
- COOKIE_VM_LFIB_TABLE, matches, null);
+ NwConstants.COOKIE_VM_LFIB_TABLE, matches, null);
mdsalManager.removeFlow(dpnId, flowEntity);
LOG.debug("LFIB Entry for dpID : {} label : {} removed successfully {}",dpnId, serviceId);
}
-}
\ No newline at end of file
+ private String getAssociatedVPN(Uuid networkId, String routerId) {
+ String vpnName = NatUtil.getAssociatedVPN(dataBroker, networkId, LOG);
+ return vpnName != null ? vpnName : routerId;
+ }
+}