use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.
the class LldpPostIngressOneSwitchFlowGenerator method getLldpFlowMod.
@Override
OFFlowMod getLldpFlowMod(IOFSwitch sw, OFInstructionMeter meter, List<OFAction> actionList) {
OFFactory ofFactory = sw.getOFFactory();
RoutingMetadata metadata = makeMetadataMatch(sw);
Match match = ofFactory.buildMatch().setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build();
actionList.add(actionSendToController(sw.getOFFactory()));
OFInstructionApplyActions actions = ofFactory.instructions().applyActions(actionList).createBuilder().build();
return prepareFlowModBuilder(ofFactory, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY, POST_INGRESS_TABLE_ID).setMatch(match).setInstructions(meter != null ? ImmutableList.of(meter, actions) : ImmutableList.of(actions)).build();
}
use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.
the class LldpTransitFlowGenerator method getLldpFlowMod.
@Override
OFFlowMod getLldpFlowMod(IOFSwitch sw, OFInstructionMeter meter, List<OFAction> actionList) {
OFFactory ofFactory = sw.getOFFactory();
Match match = ofFactory.buildMatch().setExact(MatchField.ETH_TYPE, EthType.LLDP).build();
actionList.add(actionSendToController(sw.getOFFactory()));
OFInstructionApplyActions actions = ofFactory.instructions().applyActions(actionList).createBuilder().build();
return prepareFlowModBuilder(ofFactory, Cookie.LLDP_TRANSIT_COOKIE, LLDP_TRANSIT_ISL_PRIORITY, TRANSIT_TABLE_ID).setMatch(match).setInstructions(meter != null ? ImmutableList.of(meter, actions) : ImmutableList.of(actions)).build();
}
use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.
the class SwitchManager method matchFlow.
/**
* Creates a Match based on an inputPort and VlanID.
* NB1: that this match only matches on the outer most tag which must be of ether-type 0x8100.
* NB2: vlanId of 0 means match on port, not vlan
*
* @param ofFactory OF factory for the switch
* @param inputPort input port for the match
* @param tunnelId tunnel id to match on; 0 means match on port
* @return {@link Match}
*/
private Match matchFlow(OFFactory ofFactory, int inputPort, int tunnelId, FlowEncapsulationType encapsulationType) {
Match.Builder mb = ofFactory.buildMatch();
addMatchFlowToBuilder(mb, ofFactory, inputPort, tunnelId, encapsulationType);
return mb.build();
}
use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.
the class SwitchManager method buildFlowDeleteByCriteria.
private OFFlowDelete buildFlowDeleteByCriteria(OFFactory ofFactory, DeleteRulesCriteria criteria, boolean multiTable, RuleType ruleType) {
OFFlowDelete.Builder builder = ofFactory.buildFlowDelete();
if (criteria.getCookie() != null) {
builder.setCookie(U64.of(criteria.getCookie()));
builder.setCookieMask(U64.NO_MASK);
}
Match.Builder matchBuilder = ofFactory.buildMatch();
if (criteria.getMetadataValue() != null && criteria.getMetadataMask() != null) {
matchBuilder.setMasked(MatchField.METADATA, OFMetadata.of(U64.of(criteria.getMetadataValue())), OFMetadata.of(U64.of(criteria.getMetadataMask())));
}
if (criteria.getInPort() != null) {
// Match either In Port or both Port & Vlan criteria.
addMatchFlowToBuilder(matchBuilder, ofFactory, criteria.getInPort(), Optional.ofNullable(criteria.getEncapsulationId()).orElse(0), criteria.getEncapsulationType());
} else if (criteria.getEncapsulationId() != null) {
// Match In Vlan criterion if In Port is not specified
switch(criteria.getEncapsulationType()) {
case TRANSIT_VLAN:
matchVlan(ofFactory, matchBuilder, criteria.getEncapsulationId());
break;
case VXLAN:
matchVxlan(ofFactory, matchBuilder, criteria.getEncapsulationId());
break;
default:
throw new UnsupportedOperationException(String.format("Unknown encapsulation type: %s", criteria.getEncapsulationType()));
}
}
Match match = matchBuilder.build();
if (!match.equals(ofFactory.buildMatch().build())) {
// we should not set empty match
builder.setMatch(matchBuilder.build());
}
if (criteria.getPriority() != null) {
// Match Priority criterion.
builder.setPriority(criteria.getPriority());
}
if (criteria.getOutPort() != null) {
// Match only Out Vlan criterion.
builder.setOutPort(OFPort.of(criteria.getOutPort()));
}
if (multiTable) {
switch(ruleType) {
case TRANSIT:
builder.setTableId(TableId.of(TRANSIT_TABLE_ID));
break;
case EGRESS:
builder.setTableId(TableId.of(EGRESS_TABLE_ID));
break;
case INGRESS:
builder.setTableId(TableId.of(INGRESS_TABLE_ID));
break;
default:
builder.setTableId(TableId.of(INPUT_TABLE_ID));
break;
}
} else {
if (POST_INGRESS.equals(ruleType)) {
builder.setTableId(TableId.of(TABLE_1));
} else {
builder.setTableId(TableId.ALL);
}
}
return builder.setTableId(TableId.ALL).build();
}
use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.
the class SwitchManager method removeEgressIslVlanRule.
@Override
public long removeEgressIslVlanRule(DatapathId dpid, int port) throws SwitchOperationException {
IOFSwitch sw = lookupSwitch(dpid);
OFFactory ofFactory = sw.getOFFactory();
OFFlowDelete.Builder builder = ofFactory.buildFlowDelete();
long cookie = Cookie.encodeIslVlanEgress(port);
builder.setCookie(U64.of(cookie));
builder.setCookieMask(U64.NO_MASK);
Match match = buildInPortMatch(port, ofFactory);
builder.setMatch(match);
builder.setPriority(ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE);
removeFlowByOfFlowDelete(dpid, EGRESS_TABLE_ID, builder.build());
return cookie;
}
Aggregations