use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.
the class OfdpaExtensionSelectorInterpreter method mapSelector.
@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
ExtensionSelectorType type = extensionSelector.type();
if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_VLAN_VID.type())) {
VlanId vlanId = ((OfdpaMatchVlanVid) extensionSelector).vlanId();
// Special VLAN 0x0000/0x1FFF required by OFDPA
if (vlanId.equals(VlanId.NONE)) {
OFVlanVidMatch vid = OFVlanVidMatch.ofRawVid((short) 0x0000);
OFVlanVidMatch mask = OFVlanVidMatch.ofRawVid((short) 0x1FFF);
return factory.oxms().vlanVidMasked(vid, mask);
// Normal case
} else if (vlanId.equals(VlanId.ANY)) {
return factory.oxms().vlanVidMasked(OFVlanVidMatch.PRESENT, OFVlanVidMatch.PRESENT);
} else {
return factory.oxms().vlanVid(OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vlanId.toShort())));
}
} else if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_ACTSET_OUTPUT.type())) {
PortNumber port = ((OfdpaMatchActsetOutput) extensionSelector).port();
return factory.oxms().ofdpaActsetOutput(U32.of(port.toLong()));
} else if (type.equals(ExtensionSelectorTypes.OFDPA_MATCH_ALLOW_VLAN_TRANSLATION.type())) {
Short allowVlanTranslation = ((OfdpaMatchAllowVlanTranslation) extensionSelector).allowVlanTranslation();
return factory.oxms().ofdpaAllowVlanTranslation(U8.of(allowVlanTranslation));
}
throw new UnsupportedOperationException("Unexpected ExtensionSelector: " + extensionSelector.toString());
}
use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.
the class OvsOfdpaExtensionSelectorInterpreter method mapOxm.
@Override
public ExtensionSelector mapOxm(OFOxm<?> oxm) {
if (oxm.getMatchField().equals(MatchField.OFDPA_ACTSET_OUTPUT)) {
U32 portNumberU32 = ((OFOxmOfdpaActsetOutput) oxm).getValue();
PortNumber portNumber = PortNumber.portNumber(portNumberU32.getValue());
return new OfdpaMatchActsetOutput(portNumber);
}
throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
}
use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.
the class KubevirtFloatingIpHandler method setFloatingIpDownstreamRulesToGatewayTunBridge.
private void setFloatingIpDownstreamRulesToGatewayTunBridge(KubevirtFloatingIp floatingIp, KubevirtNode electedGw, KubevirtNetwork network, KubevirtPort port, boolean install) {
KubevirtNode workerNode = kubevirtNodeService.node(port.deviceId());
if (workerNode == null) {
log.warn("Failed to install floating Ip rules for floating ip {} " + "because fail to fine the worker node that the associated port is running on", floatingIp.floatingIp());
return;
}
PortNumber tunnelPortNumber = tunnelPort(electedGw, network);
if (tunnelPortNumber == null) {
return;
}
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IpPrefix.valueOf(port.ipAddress(), 32)).matchEthDst(port.macAddress());
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setTunnelId(Long.parseLong(network.segmentId())).extension(buildExtension(deviceService, electedGw.tunBridge(), workerNode.dataIp().getIp4Address()), electedGw.tunBridge()).setOutput(tunnelPortNumber);
flowService.setRule(appId, electedGw.tunBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_FLOATING_GATEWAY_TUN_BRIDGE_RULE, TUNNEL_DEFAULT_TABLE, install);
}
use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.
the class KubevirtLbHandler method setLbDownStreamRulesForTunBridge.
private void setLbDownStreamRulesForTunBridge(KubevirtLoadBalancer loadBalancer, KubevirtNode gateway, boolean install) {
Set<KubevirtPort> ports = portService.ports(loadBalancer.networkId());
KubevirtNetwork network = networkService.network(loadBalancer.networkId());
PortNumber tunnelPortNumber = tunnelPort(gateway, network);
if (tunnelPortNumber == null) {
return;
}
loadBalancer.members().forEach(ip -> {
ports.stream().filter(port -> port.ipAddress().equals(ip) && port.macAddress() != null).findAny().ifPresent(port -> {
KubevirtNode workerNode = nodeService.node(port.deviceId());
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IpPrefix.valueOf(port.ipAddress(), 32)).matchEthDst(port.macAddress());
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setTunnelId(Long.parseLong(network.segmentId())).extension(buildExtension(deviceService, gateway.tunBridge(), workerNode.dataIp().getIp4Address()), gateway.tunBridge()).setOutput(tunnelPortNumber);
flowRuleService.setRule(appId, gateway.tunBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_LB_GATEWAY_TUN_BRIDGE_RULE, TUNNEL_DEFAULT_TABLE, install);
});
});
}
use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.
the class KubevirtNetworkHandler method setDefaultEgressRuleToGatewayNode.
private void setDefaultEgressRuleToGatewayNode(KubevirtRouter router, KubevirtNetwork network, DeviceId gwDeviceId, boolean install) {
MacAddress routerMacAddress = getRouterMacAddress(router);
if (routerMacAddress == null) {
log.warn("Setting gateway default eggress rule to gateway for tenant internal network because " + "there's no br-int port for device {}", gwDeviceId);
return;
}
KubevirtNode gwNode = kubevirtNodeService.node(gwDeviceId);
if (gwNode == null) {
log.warn("Setting gateway default eggress rule to gateway for tenant internal network because " + "there's no gateway node for device {}", gwDeviceId);
return;
}
PortNumber tunToIntPortNum = portNumber(deviceService, gwNode.tunBridge(), TUNNEL_TO_INTEGRATION);
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchTunnelId(Long.parseLong(network.segmentId()));
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setOutput(tunToIntPortNum);
flowService.setRule(appId, gwNode.tunBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_TUNNEL_RULE, TUNNEL_DEFAULT_TABLE, install);
}
Aggregations