use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.
the class KubevirtFloatingIpHandler method setFloatingIpArpResponseRules.
private void setFloatingIpArpResponseRules(KubevirtRouter router, KubevirtFloatingIp floatingIp, KubevirtPort port, KubevirtNode electedGw, boolean install) {
TrafficSelector selector = DefaultTrafficSelector.builder().matchInPort(externalPatchPortNum(deviceService, electedGw)).matchEthType(EthType.EtherType.ARP.ethType().toShort()).matchArpOp(ARP.OP_REQUEST).matchArpTpa(floatingIp.floatingIp().getIp4Address()).build();
Device device = deviceService.getDevice(electedGw.intgBridge());
TrafficTreatment treatment = DefaultTrafficTreatment.builder().extension(RulePopulatorUtil.buildMoveEthSrcToDstExtension(device), device.id()).extension(RulePopulatorUtil.buildMoveArpShaToThaExtension(device), device.id()).extension(RulePopulatorUtil.buildMoveArpSpaToTpaExtension(device), device.id()).setArpOp(ARP.OP_REPLY).setEthSrc(port.macAddress()).setArpSha(port.macAddress()).setArpSpa(floatingIp.floatingIp().getIp4Address()).setOutput(PortNumber.IN_PORT).build();
flowService.setRule(appId, electedGw.intgBridge(), selector, treatment, PRIORITY_ARP_GATEWAY_RULE, GW_ENTRY_TABLE, install);
}
use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.
the class KubevirtFloatingIpHandler method processGarpPacketForFloatingIp.
private void processGarpPacketForFloatingIp(KubevirtFloatingIp floatingIp, KubevirtNode electedGw) {
if (floatingIp == null) {
return;
}
KubevirtPort kubevirtPort = getKubevirtPortByFloatingIp(floatingIp);
if (kubevirtPort == null) {
return;
}
Ethernet ethernet = buildGarpPacket(kubevirtPort.macAddress(), floatingIp.floatingIp());
if (ethernet == null) {
return;
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(externalPatchPortNum(deviceService, electedGw)).build();
packetService.emit(new DefaultOutboundPacket(electedGw.intgBridge(), treatment, ByteBuffer.wrap(ethernet.serialize())));
}
use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.
the class KubevirtLbHandler method setLbDownstreamRules.
private void setLbDownstreamRules(KubevirtLoadBalancer loadBalancer, KubevirtRouter router, KubevirtNode gateway, boolean install) {
int groupId = loadBalancer.hashCode();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthSrc(router.mac()).group(GroupId.valueOf(groupId)).build();
loadBalancer.rules().forEach(rule -> {
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
switch(rule.protocol().toUpperCase()) {
case PROTOCOL_TCP:
sBuilder.matchIPDst(loadBalancer.vip().toIpPrefix()).matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_TCP).matchTcpDst(TpPort.tpPort(rule.portRangeMin().intValue()));
break;
case PROTOCOL_UDP:
sBuilder.matchIPDst(loadBalancer.vip().toIpPrefix()).matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_UDP).matchUdpDst(TpPort.tpPort(rule.portRangeMin().intValue()));
break;
case PROTOCOL_ICMP:
sBuilder.matchIPDst(loadBalancer.vip().toIpPrefix()).matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_ICMP);
break;
default:
break;
}
flowRuleService.setRule(appId, gateway.intgBridge(), sBuilder.build(), treatment, PRIORITY_LB_RULE, GW_DROP_TABLE, install);
});
}
use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.
the class KubevirtNetworkHandler method setForwardingRule.
private void setForwardingRule(DeviceId deviceId, boolean install) {
TrafficSelector selector = DefaultTrafficSelector.builder().build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.NORMAL).build();
flowService.setRule(appId, deviceId, selector, treatment, PRIORITY_FORWARDING_RULE, TENANT_FORWARDING_TABLE, install);
}
use of org.onosproject.net.flow.TrafficTreatment in project onos by opennetworkinglab.
the class KubevirtNetworkHandler method setDhcpRuleForTenantNetwork.
private void setDhcpRuleForTenantNetwork(DeviceId deviceId, boolean install) {
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_UDP).matchUdpDst(TpPort.tpPort(UDP.DHCP_SERVER_PORT)).matchUdpSrc(TpPort.tpPort(UDP.DHCP_CLIENT_PORT)).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().punt().build();
flowService.setRule(appId, deviceId, selector, treatment, PRIORITY_DHCP_RULE, TENANT_DHCP_TABLE, install);
}
Aggregations