use of org.onosproject.net.flow.criteria.PiCriterion in project onos by opennetworkinglab.
the class FabricIntProgrammable method setSinkPort.
@Override
public boolean setSinkPort(PortNumber port) {
if (!setupBehaviour()) {
return false;
}
PiCriterion egressCriterion = PiCriterion.builder().matchExact(FabricConstants.HDR_EG_PORT, port.toLong()).build();
TrafficSelector sinkSelector = DefaultTrafficSelector.builder().matchPi(egressCriterion).build();
PiAction setSinkAct = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_PROCESS_SET_SOURCE_SINK_INT_SET_SINK).build();
TrafficTreatment sinkTreatment = DefaultTrafficTreatment.builder().piTableAction(setSinkAct).build();
FlowRule sinkFlowRule = DefaultFlowRule.builder().withSelector(sinkSelector).withTreatment(sinkTreatment).fromApp(appId).withPriority(DEFAULT_PRIORITY).makePermanent().forDevice(deviceId).forTable(FabricConstants.FABRIC_INGRESS_PROCESS_SET_SOURCE_SINK_TB_SET_SINK).build();
flowRuleService.applyFlowRules(sinkFlowRule);
return true;
}
use of org.onosproject.net.flow.criteria.PiCriterion in project onos by opennetworkinglab.
the class FabricBngProgrammable method buildTPppoeTermV4FlowRule.
/**
* Build the Flow Rule for the table t_pppoe_term_v4 of the ingress
* upstream.
*/
private FlowRule buildTPppoeTermV4FlowRule(Attachment attachment) throws BngProgrammableException {
PiCriterion criterion = PiCriterion.builder().matchExact(FabricConstants.HDR_LINE_ID, lineId(attachment)).matchExact(FabricConstants.HDR_IPV4_SRC, attachment.ipAddress().toOctets()).matchExact(FabricConstants.HDR_PPPOE_SESSION_ID, attachment.pppoeSessionId()).build();
TrafficSelector trafficSelector = DefaultTrafficSelector.builder().matchPi(criterion).build();
PiAction action = PiAction.builder().withId(attachment.lineActive() ? FabricConstants.FABRIC_INGRESS_BNG_INGRESS_UPSTREAM_TERM_ENABLED_V4 : FabricConstants.FABRIC_INGRESS_BNG_INGRESS_UPSTREAM_TERM_DISABLED).build();
TrafficTreatment instTreatment = DefaultTrafficTreatment.builder().piTableAction(action).build();
return buildFlowRule(trafficSelector, instTreatment, FabricConstants.FABRIC_INGRESS_BNG_INGRESS_UPSTREAM_T_PPPOE_TERM_V4, attachment.appId());
}
use of org.onosproject.net.flow.criteria.PiCriterion in project onos by opennetworkinglab.
the class FabricBngProgrammable method buildTLineMapFlowRule.
/**
* Build the flow rule for the table t_line_map of the BNG-U (common to both
* upstream and downstream).
*/
private FlowRule buildTLineMapFlowRule(Attachment attachment) throws BngProgrammableException {
PiCriterion criterion = PiCriterion.builder().matchExact(FabricConstants.HDR_S_TAG, attachment.sTag().toShort()).matchExact(FabricConstants.HDR_C_TAG, attachment.cTag().toShort()).build();
TrafficSelector trafficSelector = DefaultTrafficSelector.builder().matchPi(criterion).build();
PiAction action = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_BNG_INGRESS_SET_LINE).withParameter(new PiActionParam(FabricConstants.LINE_ID, lineId(attachment))).build();
TrafficTreatment instTreatment = DefaultTrafficTreatment.builder().piTableAction(action).build();
return buildFlowRule(trafficSelector, instTreatment, FabricConstants.FABRIC_INGRESS_BNG_INGRESS_T_LINE_MAP, attachment.appId());
}
use of org.onosproject.net.flow.criteria.PiCriterion in project onos by opennetworkinglab.
the class FabricBngProgrammable method buildTLineSessionMapFlowRule.
/**
* Build the Flow Rule for the table t_line_session_map of the ingress
* downstream.
*/
private FlowRule buildTLineSessionMapFlowRule(Attachment attachment) throws BngProgrammableException {
PiCriterion criterion = PiCriterion.builder().matchExact(FabricConstants.HDR_LINE_ID, lineId(attachment)).build();
TrafficSelector trafficSelector = DefaultTrafficSelector.builder().matchPi(criterion).build();
PiAction action;
if (attachment.lineActive()) {
action = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_BNG_INGRESS_DOWNSTREAM_SET_SESSION).withParameter(new PiActionParam(FabricConstants.PPPOE_SESSION_ID, attachment.pppoeSessionId())).build();
} else {
action = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_BNG_INGRESS_DOWNSTREAM_DROP).build();
}
TrafficTreatment instTreatment = DefaultTrafficTreatment.builder().piTableAction(action).build();
return buildFlowRule(trafficSelector, instTreatment, FabricConstants.FABRIC_INGRESS_BNG_INGRESS_DOWNSTREAM_T_LINE_SESSION_MAP, attachment.appId());
}
use of org.onosproject.net.flow.criteria.PiCriterion in project onos by opennetworkinglab.
the class NextObjectiveTranslatorTest method testBroadcastOutput.
/**
* Test program output group for Broadcast table.
*/
@Test
public void testBroadcastOutput() throws FabricPipelinerException {
TrafficTreatment treatment1 = DefaultTrafficTreatment.builder().setOutput(PORT_1).build();
TrafficTreatment treatment2 = DefaultTrafficTreatment.builder().popVlan().setOutput(PORT_2).build();
NextObjective nextObjective = DefaultNextObjective.builder().withId(NEXT_ID_1).withPriority(PRIORITY).addTreatment(treatment1).addTreatment(treatment2).withMeta(VLAN_META).withType(NextObjective.Type.BROADCAST).makePermanent().fromApp(APP_ID).add();
ObjectiveTranslation actualTranslation = translatorHashed.doTranslate(nextObjective);
// Should generate 3 flows:
// - Multicast table flow that matches on next-id and set multicast group (1)
// - Egress VLAN pop handling for treatment2 (0)
// - Next VLAN flow (2)
// And 2 groups:
// - Multicast group
// Expected multicast table flow rule.
PiCriterion nextIdCriterion = PiCriterion.builder().matchExact(FabricConstants.HDR_NEXT_ID, NEXT_ID_1).build();
TrafficSelector nextIdSelector = DefaultTrafficSelector.builder().matchPi(nextIdCriterion).build();
PiAction setMcGroupAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_NEXT_SET_MCAST_GROUP_ID).withParameter(new PiActionParam(FabricConstants.GROUP_ID, NEXT_ID_1)).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(setMcGroupAction).build();
FlowRule expectedHashedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent().withPriority(nextObjective.priority()).forTable(FabricConstants.FABRIC_INGRESS_NEXT_MULTICAST).withSelector(nextIdSelector).withTreatment(treatment).build();
// Expected egress VLAN_PUSH flow rule.
PiCriterion egressVlanTableMatch = PiCriterion.builder().matchExact(FabricConstants.HDR_EG_PORT, PORT_1.toLong()).build();
TrafficSelector selectorForEgressVlan = DefaultTrafficSelector.builder().matchPi(egressVlanTableMatch).matchVlanId(VLAN_100).build();
PiAction piActionForEgressVlan = PiAction.builder().withId(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_PUSH_VLAN).build();
TrafficTreatment treatmentForEgressVlan = DefaultTrafficTreatment.builder().piTableAction(piActionForEgressVlan).build();
FlowRule expectedEgressVlanPushRule = DefaultFlowRule.builder().withSelector(selectorForEgressVlan).withTreatment(treatmentForEgressVlan).forTable(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN).makePermanent().withPriority(nextObjective.priority()).forDevice(DEVICE_ID).fromApp(APP_ID).build();
// Expected egress VLAN POP flow rule.
egressVlanTableMatch = PiCriterion.builder().matchExact(FabricConstants.HDR_EG_PORT, PORT_2.toLong()).build();
selectorForEgressVlan = DefaultTrafficSelector.builder().matchPi(egressVlanTableMatch).matchVlanId(VLAN_100).build();
piActionForEgressVlan = PiAction.builder().withId(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_POP_VLAN).build();
treatmentForEgressVlan = DefaultTrafficTreatment.builder().piTableAction(piActionForEgressVlan).build();
FlowRule expectedEgressVlanPopRule = DefaultFlowRule.builder().withSelector(selectorForEgressVlan).withTreatment(treatmentForEgressVlan).forTable(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN).makePermanent().withPriority(nextObjective.priority()).forDevice(DEVICE_ID).fromApp(APP_ID).build();
// Expected ALL group.
TrafficTreatment allGroupTreatment1 = DefaultTrafficTreatment.builder().setOutput(PORT_1).build();
TrafficTreatment allGroupTreatment2 = DefaultTrafficTreatment.builder().setOutput(PORT_2).build();
List<TrafficTreatment> allTreatments = ImmutableList.of(allGroupTreatment1, allGroupTreatment2);
List<GroupBucket> allBuckets = allTreatments.stream().map(DefaultGroupBucket::createAllGroupBucket).collect(Collectors.toList());
GroupBuckets allGroupBuckets = new GroupBuckets(allBuckets);
GroupKey allGroupKey = new DefaultGroupKey(FabricPipeliner.KRYO.serialize(NEXT_ID_1));
GroupDescription expectedAllGroup = new DefaultGroupDescription(DEVICE_ID, GroupDescription.Type.ALL, allGroupBuckets, allGroupKey, NEXT_ID_1, APP_ID);
ObjectiveTranslation expectedTranslation = ObjectiveTranslation.builder().addFlowRule(expectedHashedFlowRule).addFlowRule(vlanMetaFlowRule).addFlowRule(expectedEgressVlanPushRule).addFlowRule(expectedEgressVlanPopRule).addGroup(expectedAllGroup).build();
assertEquals(expectedTranslation, actualTranslation);
}
Aggregations