use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class RecordHandler method processInstallDefaultFlowByCookie.
private Long processInstallDefaultFlowByCookie(SwitchId switchId, long cookie) throws SwitchOperationException {
ISwitchManager switchManager = context.getSwitchManager();
DatapathId dpid = DatapathId.of(switchId.toLong());
Cookie encodedCookie = new Cookie(cookie);
PortColourCookie portColourCookie = new PortColourCookie(cookie);
CookieType cookieType = encodedCookie.getType();
if (cookie == DROP_RULE_COOKIE) {
return switchManager.installDropFlow(dpid);
} else if (cookie == VERIFICATION_BROADCAST_RULE_COOKIE) {
return switchManager.installVerificationRule(dpid, true);
} else if (cookie == VERIFICATION_UNICAST_RULE_COOKIE) {
return switchManager.installVerificationRule(dpid, false);
} else if (cookie == DROP_VERIFICATION_LOOP_RULE_COOKIE) {
return switchManager.installDropLoopRule(dpid);
} else if (cookie == CATCH_BFD_RULE_COOKIE) {
return switchManager.installBfdCatchFlow(dpid);
} else if (cookie == ROUND_TRIP_LATENCY_RULE_COOKIE) {
return switchManager.installRoundTripLatencyFlow(dpid);
} else if (cookie == VERIFICATION_UNICAST_VXLAN_RULE_COOKIE) {
return switchManager.installUnicastVerificationRuleVxlan(dpid);
} else if (cookie == MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE) {
return switchManager.installPreIngressTablePassThroughDefaultRule(dpid);
} else if (cookie == MULTITABLE_INGRESS_DROP_COOKIE) {
return switchManager.installDropFlowForTable(dpid, INGRESS_TABLE_ID, MULTITABLE_INGRESS_DROP_COOKIE);
} else if (cookie == MULTITABLE_POST_INGRESS_DROP_COOKIE) {
return switchManager.installDropFlowForTable(dpid, POST_INGRESS_TABLE_ID, MULTITABLE_POST_INGRESS_DROP_COOKIE);
} else if (cookie == MULTITABLE_EGRESS_PASS_THROUGH_COOKIE) {
return switchManager.installEgressTablePassThroughDefaultRule(dpid);
} else if (cookie == MULTITABLE_TRANSIT_DROP_COOKIE) {
return switchManager.installDropFlowForTable(dpid, TRANSIT_TABLE_ID, MULTITABLE_TRANSIT_DROP_COOKIE);
} else if (cookie == LLDP_INPUT_PRE_DROP_COOKIE) {
return switchManager.installLldpInputPreDropFlow(dpid);
} else if (cookie == LLDP_INGRESS_COOKIE) {
return switchManager.installLldpIngressFlow(dpid);
} else if (cookie == LLDP_POST_INGRESS_COOKIE) {
return switchManager.installLldpPostIngressFlow(dpid);
} else if (cookie == LLDP_POST_INGRESS_VXLAN_COOKIE) {
return switchManager.installLldpPostIngressVxlanFlow(dpid);
} else if (cookie == LLDP_POST_INGRESS_ONE_SWITCH_COOKIE) {
return switchManager.installLldpPostIngressOneSwitchFlow(dpid);
} else if (cookie == LLDP_TRANSIT_COOKIE) {
return switchManager.installLldpTransitFlow(dpid);
} else if (cookie == ARP_INPUT_PRE_DROP_COOKIE) {
return switchManager.installArpInputPreDropFlow(dpid);
} else if (cookie == ARP_INGRESS_COOKIE) {
return switchManager.installArpIngressFlow(dpid);
} else if (cookie == ARP_POST_INGRESS_COOKIE) {
return switchManager.installArpPostIngressFlow(dpid);
} else if (cookie == ARP_POST_INGRESS_VXLAN_COOKIE) {
return switchManager.installArpPostIngressVxlanFlow(dpid);
} else if (cookie == ARP_POST_INGRESS_ONE_SWITCH_COOKIE) {
return switchManager.installArpPostIngressOneSwitchFlow(dpid);
} else if (cookie == ARP_TRANSIT_COOKIE) {
return switchManager.installArpTransitFlow(dpid);
} else if (cookie == SERVER_42_FLOW_RTT_TURNING_COOKIE) {
return switchManager.installServer42FlowRttTurningFlow(dpid);
} else if (cookie == SERVER_42_ISL_RTT_TURNING_COOKIE) {
return switchManager.installServer42IslRttTurningFlow(dpid);
} else if (cookie == SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE) {
return switchManager.installServer42FlowRttVxlanTurningFlow(dpid);
} else if (cookieType == CookieType.MULTI_TABLE_INGRESS_RULES) {
return switchManager.installIntermediateIngressRule(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.MULTI_TABLE_ISL_VLAN_EGRESS_RULES) {
return switchManager.installEgressIslVlanRule(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.MULTI_TABLE_ISL_VXLAN_TRANSIT_RULES) {
return switchManager.installTransitIslVxlanRule(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.MULTI_TABLE_ISL_VXLAN_EGRESS_RULES) {
return switchManager.installEgressIslVxlanRule(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.LLDP_INPUT_CUSTOMER_TYPE) {
return switchManager.installLldpInputCustomerFlow(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.ARP_INPUT_CUSTOMER_TYPE) {
return switchManager.installArpInputCustomerFlow(dpid, portColourCookie.getPortNumber());
} else if (cookie == SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE) {
return switchManager.installServer42FlowRttVxlanTurningFlow(dpid);
} else {
logger.warn("Skipping the installation of unexpected default switch rule {} for switch {}", encodedCookie, switchId);
}
return null;
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class RecordHandler method processInstallServer42Rule.
private Long processInstallServer42Rule(ReinstallServer42FlowForSwitchManagerRequest command) throws SwitchOperationException {
ISwitchManager switchManager = context.getSwitchManager();
DatapathId dpid = DatapathId.of(command.getSwitchId().toLong());
long cookie = command.getCookie();
if (cookie == SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE) {
return switchManager.installServer42FlowRttOutputVlanFlow(dpid, command.getServer42Port(), command.getServer42Vlan(), command.getServer42MacAddress());
} else if (cookie == SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE) {
return switchManager.installServer42FlowRttOutputVxlanFlow(dpid, command.getServer42Port(), command.getServer42Vlan(), command.getServer42MacAddress());
} else if (new Cookie(cookie).getType() == CookieType.SERVER_42_FLOW_RTT_INPUT) {
PortColourCookie portColourCookie = new PortColourCookie(cookie);
int customerPort = portColourCookie.getPortNumber();
return switchManager.installServer42FlowRttInputFlow(dpid, command.getServer42Port(), customerPort, command.getServer42MacAddress());
} else if (cookie == SERVER_42_ISL_RTT_OUTPUT_COOKIE || new Cookie(cookie).getType() == CookieType.SERVER_42_ISL_RTT_INPUT) {
return processInstallServer42IslRttRule(command.getSwitchId(), command.getCookie(), command.getServer42Port(), command.getServer42Vlan(), command.getServer42MacAddress());
} else {
logger.warn("Skipping the installation of unexpected server 42 switch rule {} for switch {}", Long.toHexString(cookie), command.getSwitchId());
return null;
}
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class EnableBfdResource method makeSessionConfigPayload.
private IPacket makeSessionConfigPayload(IOFSwitch sw, ISwitchManager switchManager, NoviBfdSession bfdSession) {
final TransportPort udpPort = TransportPort.of(bfdSession.getUdpPortNumber());
UDP l4 = new UDP().setSourcePort(udpPort).setDestinationPort(udpPort);
InetAddress sourceIpAddress = switchManager.getSwitchIpAddress(sw);
InetAddress destIpAddress = bfdSession.getRemote().getInetAddress();
IPacket l3 = new IPv4().setSourceAddress(IPv4Address.of(sourceIpAddress.getAddress())).setDestinationAddress(IPv4Address.of(destIpAddress.getAddress())).setProtocol(IpProtocol.UDP).setPayload(l4);
DatapathId remoteDatapath = DatapathId.of(bfdSession.getRemote().getDatapath().toLong());
return new Ethernet().setEtherType(EthType.IPv4).setSourceMACAddress(convertDpIdToMac(sw.getId())).setDestinationMACAddress(convertDpIdToMac(remoteDatapath)).setPayload(l3);
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class EnableBfdResource method enableBfd.
/**
* Setting up BFD session.
*
* @param json the json from request.
* @return json response.
* @throws JsonProcessingException if response can't be wrote to string.
*/
@Post("json")
@Put("json")
public String enableBfd(String json) {
ISwitchManager switchManager = (ISwitchManager) getContext().getAttributes().get(ISwitchManager.class.getCanonicalName());
NoviBfdSession request;
try {
request = MAPPER.readValue(json, NoviBfdSession.class);
if (request.getIntervalMs() < CONSTRAINT_INTERVAL_MIN) {
throw new IllegalArgumentException(String.format("Invalid bfd session interval value: %d < %d", request.getIntervalMs(), CONSTRAINT_INTERVAL_MIN));
}
DatapathId datapathIdtarget = DatapathId.of(request.getTarget().getDatapath().toLong());
IOFSwitch iofSwitch = switchManager.lookupSwitch(datapathIdtarget);
OFPacketOut outPacket = makeSessionConfigMessage(request, iofSwitch, switchManager);
if (!iofSwitch.write(outPacket)) {
throw new IllegalStateException("Failed to set up BFD session");
}
} catch (IOException e) {
logger.error("Message received is not valid BFD Request: {}", json);
MessageError responseMessage = new MessageError(DEFAULT_CORRELATION_ID, now(), ErrorType.DATA_INVALID.toString(), "Message received is not valid BFD Request", e.getMessage());
return generateJson(responseMessage);
} catch (SwitchNotFoundException e) {
MessageError responseMessage = new MessageError(DEFAULT_CORRELATION_ID, now(), ErrorType.DATA_INVALID.toString(), "Switch not found", e.getMessage());
return generateJson(responseMessage);
}
return generateJson("ok");
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class RecordHandler method doDeleteFlow.
/**
* Removes flow.
*
* @param message command message for flow installation
*/
private void doDeleteFlow(final CommandMessage message, String replyToTopic, Destination replyDestination) throws FlowCommandException {
RemoveFlow command = (RemoveFlow) message.getData();
logger.debug("deleting a flow: {}", command);
DatapathId dpid = DatapathId.of(command.getSwitchId());
ISwitchManager switchManager = context.getSwitchManager();
try {
switchManager.deleteFlow(dpid, command.getId(), command.getCookie());
Integer meterId = meterPool.deallocate(command.getSwitchId(), command.getId());
if (meterId != null) {
switchManager.deleteMeter(dpid, meterId);
}
message.setDestination(replyDestination);
context.getKafkaProducer().postMessage(replyToTopic, message);
} catch (SwitchOperationException e) {
throw new FlowCommandException(command.getId(), ErrorType.DELETION_FAILURE, e);
}
}
Aggregations