Java Code Examples for org.onlab.packet.IpPrefix#isMulticast()
The following examples show how to use
org.onlab.packet.IpPrefix#isMulticast() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Ofdpa2GroupHandler.java From onos with Apache License 2.0 | 6 votes |
private void addBucketToBroadcastGroup(NextObjective nextObj, List<Deque<GroupKey>> allActiveKeys) { VlanId assignedVlan = readVlanFromSelector(nextObj.meta()); if (assignedVlan == null) { log.warn("VLAN ID required by broadcast next obj is missing. " + "Aborting add bucket to broadcast group for next:{} in dev:{}", nextObj.id(), deviceId); fail(nextObj, ObjectiveError.BADPARAMS); return; } List<GroupInfo> groupInfos = prepareL2InterfaceGroup(nextObj, assignedVlan); IpPrefix ipDst = readIpDstFromSelector(nextObj.meta()); if (ipDst != null) { if (ipDst.isMulticast()) { addBucketToL3MulticastGroup(nextObj, allActiveKeys, groupInfos, assignedVlan); } else { log.warn("Broadcast NextObj with non-multicast IP address {}", nextObj); fail(nextObj, ObjectiveError.BADPARAMS); } } else { addBucketToL2FloodGroup(nextObj, allActiveKeys, groupInfos, assignedVlan); } }
Example 2
Source File: Ofdpa2Pipeline.java From onos with Apache License 2.0 | 5 votes |
/** * Helper method to build Ipv6 selector using the selector provided by * a forwarding objective. * * @param builderToUpdate the builder to update * @param fwd the selector to read * @return 0 if the update ends correctly. -1 if the matches * are not yet supported */ int buildIpv6Selector(TrafficSelector.Builder builderToUpdate, ForwardingObjective fwd) { TrafficSelector selector = fwd.selector(); IpPrefix ipv6Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV6_DST)).ip(); if (ipv6Dst.isMulticast()) { if (ipv6Dst.prefixLength() != IpAddress.INET6_BIT_LENGTH) { log.warn("Multicast specific forwarding objective can only be /128"); fail(fwd, ObjectiveError.BADPARAMS); return -1; } VlanId assignedVlan = readVlanFromSelector(fwd.meta()); if (assignedVlan == null) { log.warn("VLAN ID required by multicast specific fwd obj is missing. Abort."); fail(fwd, ObjectiveError.BADPARAMS); return -1; } if (requireVlanExtensions()) { OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(assignedVlan); builderToUpdate.extension(ofdpaMatchVlanVid, deviceId); } else { builderToUpdate.matchVlanId(assignedVlan); } builderToUpdate.matchEthType(Ethernet.TYPE_IPV6).matchIPv6Dst(ipv6Dst); log.debug("processing IPv6 multicast specific forwarding objective {} -> next:{}" + " in dev:{}", fwd.id(), fwd.nextId(), deviceId); } else { if (ipv6Dst.prefixLength() != 0) { builderToUpdate.matchIPv6Dst(ipv6Dst); } builderToUpdate.matchEthType(Ethernet.TYPE_IPV6); log.debug("processing IPv6 unicast specific forwarding objective {} -> next:{}" + " in dev:{}", fwd.id(), fwd.nextId(), deviceId); } return 0; }
Example 3
Source File: OvsOfdpaPipeline.java From onos with Apache License 2.0 | 4 votes |
/** * Handles forwarding rules to the IP Unicast Routing. * * @param fwd the forwarding objective * @return A collection of flow rules, or an empty set */ protected Collection<FlowRule> processDoubleTaggedFwd(ForwardingObjective fwd) { // inner for UNICAST_ROUTING_TABLE_1, outer for UNICAST_ROUTING_TABLE TrafficSelector selector = fwd.selector(); TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); TrafficTreatment.Builder innerTtb = DefaultTrafficTreatment.builder(); TrafficTreatment.Builder outerTtb = DefaultTrafficTreatment.builder(); EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) { sBuilder.matchEthType(Ethernet.TYPE_IPV4); sBuilder.matchVlanId(VlanId.ANY); IpPrefix ipv4Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip(); if (!ipv4Dst.isMulticast() && ipv4Dst.prefixLength() == 32) { sBuilder.matchIPDst(ipv4Dst); if (fwd.nextId() != null) { NextGroup next = getGroupForNextObjective(fwd.nextId()); if (next != null) { List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data()); // we only need the top level group's key to point the flow to it Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst()); if (group == null) { log.warn("Group with key:{} for next-id:{} not found in dev:{}", gkeys.get(0).peekFirst(), fwd.nextId(), deviceId); fail(fwd, ObjectiveError.GROUPMISSING); return Collections.emptySet(); } outerTtb.immediate().setVlanId(extractDummyVlanIdFromGroupId(group.id().id())); //ACTSET_OUTPUT in OVS will match output action in write_action() set. outerTtb.deferred().setOutput(extractOutputPortFromGroupId(group.id().id())); outerTtb.transition(EGRESS_VLAN_FLOW_TABLE_IN_INGRESS); innerTtb.deferred().group(group.id()); innerTtb.transition(ACL_TABLE); FlowRule.Builder innerRuleBuilder = DefaultFlowRule.builder() .fromApp(fwd.appId()) .withPriority(fwd.priority()) .forDevice(deviceId) .withSelector(sBuilder.build()) .withTreatment(innerTtb.build()) .forTable(UNICAST_ROUTING_TABLE_1); if (fwd.permanent()) { innerRuleBuilder.makePermanent(); } else { innerRuleBuilder.makeTemporary(fwd.timeout()); } Collection<FlowRule> flowRuleCollection = new HashSet<>(); flowRuleCollection.add(innerRuleBuilder.build()); FlowRule.Builder outerRuleBuilder = DefaultFlowRule.builder() .fromApp(fwd.appId()) .withPriority(fwd.priority()) .forDevice(deviceId) .withSelector(sBuilder.build()) .withTreatment(outerTtb.build()) .forTable(UNICAST_ROUTING_TABLE); if (fwd.permanent()) { outerRuleBuilder.makePermanent(); } else { outerRuleBuilder.makeTemporary(fwd.timeout()); } flowRuleCollection.add(innerRuleBuilder.build()); flowRuleCollection.add(outerRuleBuilder.build()); return flowRuleCollection; } else { log.warn("Cannot find group for nextId:{} in dev:{}. Aborting fwd:{}", fwd.nextId(), deviceId, fwd.id()); fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED); return Collections.emptySet(); } } else { log.warn("NextId is not specified in fwd:{}", fwd.id()); fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED); return Collections.emptySet(); } } } return Collections.emptySet(); }
Example 4
Source File: Ofdpa2Pipeline.java From onos with Apache License 2.0 | 4 votes |
private int buildIpv4Selector(TrafficSelector.Builder builderToUpdate, TrafficSelector.Builder extBuilder, ForwardingObjective fwd, boolean allowDefaultRoute) { TrafficSelector selector = fwd.selector(); IpPrefix ipv4Dst = ((IPCriterion) selector.getCriterion(Criterion.Type.IPV4_DST)).ip(); if (ipv4Dst.isMulticast()) { if (ipv4Dst.prefixLength() != 32) { log.warn("Multicast specific forwarding objective can only be /32"); fail(fwd, ObjectiveError.BADPARAMS); return -1; } VlanId assignedVlan = readVlanFromSelector(fwd.meta()); if (assignedVlan == null) { log.warn("VLAN ID required by multicast specific fwd obj is missing. Abort."); fail(fwd, ObjectiveError.BADPARAMS); return -1; } if (requireVlanExtensions()) { OfdpaMatchVlanVid ofdpaMatchVlanVid = new OfdpaMatchVlanVid(assignedVlan); builderToUpdate.extension(ofdpaMatchVlanVid, deviceId); } else { builderToUpdate.matchVlanId(assignedVlan); } builderToUpdate.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(ipv4Dst); log.debug("processing IPv4 multicast specific forwarding objective {} -> next:{}" + " in dev:{}", fwd.id(), fwd.nextId(), deviceId); } else { if (ipv4Dst.prefixLength() == 0) { if (allowDefaultRoute) { // The entire IPV4_DST field is wildcarded intentionally builderToUpdate.matchEthType(Ethernet.TYPE_IPV4); } else { // NOTE: The switch does not support matching 0.0.0.0/0 // Split it into 0.0.0.0/1 and 128.0.0.0/1 builderToUpdate.matchEthType(Ethernet.TYPE_IPV4) .matchIPDst(IpPrefix.valueOf("0.0.0.0/1")); extBuilder.matchEthType(Ethernet.TYPE_IPV4) .matchIPDst(IpPrefix.valueOf("128.0.0.0/1")); } } else { builderToUpdate.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(ipv4Dst); } log.debug("processing IPv4 unicast specific forwarding objective {} -> next:{}" + " in dev:{}", fwd.id(), fwd.nextId(), deviceId); } return 0; }
Example 5
Source File: Ofdpa2GroupHandler.java From onos with Apache License 2.0 | 4 votes |
/** * As per the OFDPA 2.0 TTP, packets are sent out of ports by using * a chain of groups. The broadcast Next Objective passed in by the application * has to be broken up into a group chain comprising of an * L2 Flood group or L3 Multicast group, whose buckets point to L2 Interface groups. * * @param nextObj the nextObjective of type BROADCAST */ private void processBroadcastNextObjective(NextObjective nextObj) { VlanId assignedVlan = readVlanFromSelector(nextObj.meta()); if (assignedVlan == null) { log.warn("VLAN ID required by broadcast next obj is missing. Abort."); fail(nextObj, ObjectiveError.BADPARAMS); return; } // Handling L2 multicast cases. MacAddress dstMac = readEthDstFromSelector(nextObj.meta()); if (dstMac != null && dstMac.isMulticast()) { processL2MulticastNextObjective(nextObj); return; } // FIXME Improve the logic // If L2 load balancer is not involved, use L2IG. Otherwise, use L2UG. // The purpose is to make sure existing XConnect logic can still work on a configured port. List<GroupInfo> groupInfos; if (nextObj.nextTreatments().stream().allMatch(n -> n.type() == NextTreatment.Type.TREATMENT)) { groupInfos = prepareL2InterfaceGroup(nextObj, assignedVlan); log.debug("prepareL2InterfaceGroup"); } else { groupInfos = prepareL2UnfilteredGroup(nextObj); log.debug("prepareL2UnfilteredGroup"); } if (groupInfos == null || groupInfos.isEmpty()) { log.warn("No buckets for Broadcast NextObj {}", nextObj); fail(nextObj, ObjectiveError.GROUPMISSING); return; } IpPrefix ipDst = readIpDstFromSelector(nextObj.meta()); if (ipDst != null) { if (ipDst.isMulticast()) { createL3MulticastGroup(nextObj, assignedVlan, groupInfos); } else { log.warn("Broadcast NextObj with non-multicast IP address {}", nextObj); fail(nextObj, ObjectiveError.BADPARAMS); } } else { createL2FloodGroup(nextObj, assignedVlan, groupInfos); } }