VPNServiceChainHandler implements AutoCloseable { public void bindScfOnVpnInterface(String ifName, int scfTag) { LOG.debug("bind SCF tag {} on iface {}", scfTag, ifName); if (isServiceBoundOnInterface(NwConstants.SCF_SERVICE_INDEX, ifName)) { LOG.info("SCF is already bound on Interface {} for Ingress. Binding aborted", ifName); return; } Action loadReg2Action = new ActionRegLoad(1, NxmNxReg2.class, 0, 31, scfTag).buildAction(); List<Instruction> instructions = Arrays.asList(MDSALUtil.buildApplyActionsInstruction(Collections.singletonList(loadReg2Action)), MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.SCF_DOWN_SUB_FILTER_TCP_BASED_TABLE, 1 )); BoundServices boundServices = InterfaceServiceUtil.getBoundServices(ifName, NwConstants.SCF_SERVICE_INDEX, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, CloudServiceChainConstants.COOKIE_SCF_BASE, instructions); interfaceManager.bindService(ifName, ServiceModeIngress.class, boundServices); } @Inject  VPNServiceChainHandler(final DataBroker db, final IMdsalApiManager mdsalManager,
                                  final IVpnFootprintService vpnFootprintService, final IInterfaceManager ifaceMgr,
                                  final JobCoordinator jobCoordinator); @PostConstruct void init(); @Override @PreDestroy void close(); void programVpnToScfPipeline(String vpnName, short tableId, long scfTag, int lportTag, int addOrRemove); void programVpnToScfPipelineOnDpn(BigInteger dpnId, List<VrfEntry> vpnVrfEntries, short tableIdToGoTo,
                                             int scfTag, int lportTag, int addOrRemove); void programScfToVpnPipeline(String vpnName, long scfTag, int servChainTag, long dpnId,
                                        int vpnPseudoLportTag, boolean isLastServiceChain, int addOrRemove); void removeVpnPseudoPortFlows(String vpnInstanceName, int vpnPseudoLportTag); void bindScfOnVpnInterface(String ifName, int scfTag); void unbindScfOnVpnInterface(String ifName); Optional<VpnToPseudoPortData> getScfInfoForVpn(String vpnName);  }
@Test public void testBindScfOnVpnInterfaceWithScfAlreadyBound() throws Exception { String ifName = "eth4"; int scfTag = 30; stubScfIsBoundOnIface(scfTag, ifName); vpnsch.bindScfOnVpnInterface(ifName, scfTag); verify(ifaceMgr, never()).bindService(anyObject(), anyObject(), anyObject()); }
@Test public void testBindScfOnVpnInterfaceWithScfNotBound() throws Exception { String ifName = "eth4"; int scfTag = 30; stubScfIsNotBoundOnIface(scfTag, ifName); vpnsch.bindScfOnVpnInterface(ifName, scfTag); verify(ifaceMgr).bindService(eq(ifName), eq(ServiceModeIngress.class), anyObject()); }