/** * Creates a new set nsh spi instruction. */ NiciraSetNshSpi() { nshSpi = NshServicePathId.of(0); }
@Override public void deserialize(byte[] data) { nshSpi = NshServicePathId.of(appKryo.deserialize(data)); }
@Override public void deserialize(byte[] data) { nshSpi = NshServicePathId.of(appKryo.deserialize(data)); }
@Override public NiciraMatchNshSpi decode(ObjectNode json, CodecContext context) { if (json == null || !json.isObject()) { return null; } // parse nsh path id int nshSpiInt = nullIsIllegal(json.get(NSH_PATH_ID), NSH_PATH_ID + MISSING_MEMBER_MESSAGE).asInt(); NshServicePathId nshSpi = NshServicePathId.of(nshSpiInt); return new NiciraMatchNshSpi(nshSpi); } }
@Override public NiciraSetNshSpi decode(ObjectNode json, CodecContext context) { if (json == null || !json.isObject()) { return null; } // parse service path id int servicePathIdInt = nullIsIllegal(json.get(NSH_PATH_ID), NSH_PATH_ID + MISSING_MEMBER_MESSAGE).asInt(); NshServicePathId pathId = NshServicePathId.of(servicePathIdInt); return new NiciraSetNshSpi(pathId); } }
@Override public void onPortChainCreated(PortChain portChain) { NshServicePathId nshSpi; log.info("On port chain created"); int spi = getNextNshSpi(); if (spi > MAX_NSH_SPI_ID) { log.error("Reached max limit of service path index." + "Failed to install SFC for port chain {}", portChain.portChainId().toString()); return; } nshSpi = NshServicePathId.of(spi); nshSpiPortChainMap.put(portChain.portChainId(), new Integer(spi)); if (!portChainFiveTupleMap.containsKey(portChain.portChainId())) { portChainFiveTupleMap.put(portChain.portChainId(), Lists.newArrayList()); } // Install classifier rule to send the packet to controller SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId); flowRuleInstaller.installFlowClassifier(portChain, nshSpi); // Install rules for already identified five tuples. List<FiveTuple> list = portChainFiveTupleMap.get(portChain.portChainId()); for (FiveTuple fiveTuple : list) { LoadBalanceId id = loadBalanceSfc(portChain.portChainId(), fiveTuple); // Get nsh service path index nshSpi = NshServicePathId.of(getNshServicePathId(id, spi)); // download the required flow rules for classifier and // forwarding flowRuleInstaller.installLoadBalancedFlowRules(portChain, fiveTuple, nshSpi); } }
@Override public ExtensionSelector mapOxm(OFOxm<?> oxm) { if (oxm.getMatchField() == MatchField.NSP) { OFOxmNsp oxmField = (OFOxmNsp) oxm; return new NiciraMatchNshSpi(NshServicePathId.of(oxmField.getValue().getRaw())); } if (oxm.getMatchField() == MatchField.NSI) { OFOxmNsi oxmField = (OFOxmNsi) oxm; return new NiciraMatchNshSi(NshServiceIndex.of(oxmField.getValue().getRaw())); } if (oxm.getMatchField() == MatchField.ENCAP_ETH_TYPE) { OFOxmEncapEthType oxmField = (OFOxmEncapEthType) oxm; return new NiciraMatchEncapEthType(oxmField.getValue().getRaw()); } return null; }
if (nshSpiPortChainMap.containsKey(portChain.portChainId())) { int nshSpiId = nshSpiPortChainMap.get(portChain.portChainId()); nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId)); } else { int nshSpiId = getNextNshSpi(); return; nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId)); nshSpiPortChainMap.put(portChain.portChainId(), new Integer(nshSpiId));
return new NiciraSetNshSpi(NshServicePathId.of((nsp.getValue().getRaw()))); case NSI: OFOxmNsi nsi = (OFOxmNsi) oxm;