alshabib
Committed by Gerrit Code Review

fix corsa pipeline divergence : need to differentiate between write and apply instructions.

Change-Id: I477d27d6e52a8e09744614e5f5aa843dd26331e0
......@@ -415,28 +415,6 @@ public class BgpRouter {
FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
FlowRule rule;
selector.matchEthType(Ethernet.TYPE_IPV4);
treatment.transition(FlowRule.Type.VLAN);
rule = new DefaultFlowRule(deviceId, selector.build(), treatment.build(), CONTROLLER_PRIORITY,
appId, 0, true, FlowRule.Type.VLAN_MPLS);
ops = install ? ops.add(rule) : ops.remove(rule);
selector = DefaultTrafficSelector.builder();
treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_ARP);
treatment.transition(FlowRule.Type.VLAN);
rule = new DefaultFlowRule(deviceId, selector.build(),
treatment.build(), CONTROLLER_PRIORITY,
appId, 0, true, FlowRule.Type.VLAN_MPLS);
ops = install ? ops.add(rule) : ops.remove(rule);
selector = DefaultTrafficSelector.builder();
treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_VLAN);
treatment.transition(FlowRule.Type.VLAN);
......@@ -447,18 +425,6 @@ public class BgpRouter {
ops = install ? ops.add(rule) : ops.remove(rule);
//Drop rule
selector = DefaultTrafficSelector.builder();
treatment = DefaultTrafficTreatment.builder();
treatment.drop();
rule = new DefaultFlowRule(deviceId, selector.build(),
treatment.build(), DROP_PRIORITY, appId,
0, true, FlowRule.Type.VLAN_MPLS);
ops = install ? ops.add(rule) : ops.remove(rule);
flowService.apply(ops.build(new FlowRuleOperationsContext() {
@Override
public void onSuccess(FlowRuleOperations ops) {
......@@ -487,7 +453,7 @@ public class BgpRouter {
treatment = DefaultTrafficTreatment.builder();
selector.matchVlanId(vid);
treatment.popVlan();
treatment.stripVlan();
treatment.transition(Type.ETHER);
rule = new DefaultFlowRule(deviceId, selector.build(),
......
......@@ -21,15 +21,11 @@ import org.onlab.packet.IpAddress;
import org.onlab.packet.TCP;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.OutboundPacket;
import org.onosproject.net.packet.PacketContext;
import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.packet.PacketProcessor;
import org.onosproject.net.packet.PacketService;
import org.onosproject.routing.config.BgpPeer;
......@@ -65,26 +61,6 @@ public class TunnellingConnectivityManager {
public void start() {
packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 3);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
// Request packets with BGP port as their TCP source port
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPProtocol(IPv4.PROTOCOL_TCP);
selector.matchTcpSrc(BGP_PORT);
packetService.requestPackets(selector.build(), PacketPriority.CONTROL,
appId, FlowRule.Type.DEFAULT);
selector = DefaultTrafficSelector.builder();
// Request packets with BGP port as their TCP destination port
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPProtocol(IPv4.PROTOCOL_TCP);
selector.matchTcpDst(BGP_PORT);
packetService.requestPackets(selector.build(), PacketPriority.CONTROL,
appId, FlowRule.Type.DEFAULT);
}
public void stop() {
......
......@@ -189,6 +189,10 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
return add(Instructions.modVlanPcp(pcp));
}
public Builder stripVlan() {
return add(Instructions.stripVlanId());
}
@Override
public Builder setIpSrc(IpAddress addr) {
return add(Instructions.modL3Src(addr));
......
......@@ -106,6 +106,12 @@ public interface TrafficTreatment {
public Builder setVlanPcp(Byte pcp);
/**
* Strips the vlan tag if there is one.
* @return a treatment builder
*/
public Builder stripVlan();
/**
* Sets the src l3 address.
*
* @param addr an ip
......
......@@ -130,6 +130,14 @@ public final class Instructions {
}
/**
* Strips the VLAN tag if one is present.
* @return a L2 modification
*/
public static L2ModificationInstruction stripVlanId() {
return new StripVlanInstruction();
}
/**
* Creates a MPLS label modification.
* @param mplsLabel to set.
* @return a L2 Modification
......
......@@ -53,6 +53,11 @@ public abstract class L2ModificationInstruction implements Instruction {
VLAN_PCP,
/**
* Strips the vlan.
*/
STRIP_VLAN,
/**
* MPLS Label modification.
*/
MPLS_LABEL,
......@@ -273,6 +278,33 @@ public abstract class L2ModificationInstruction implements Instruction {
}
}
public static final class StripVlanInstruction extends L2ModificationInstruction {
@Override
public L2SubType subtype() {
return L2SubType.STRIP_VLAN;
}
@Override
public String toString() {
return subtype().toString();
}
@Override
public int hashCode() {
return Objects.hash(type(), subtype());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
return false;
}
}
/**
* Represents a VLAN POP modification instruction.
*/
......
......@@ -268,6 +268,9 @@ public class FlowEntryBuilder {
case POP_VLAN:
builder.popVlan();
break;
case STRIP_VLAN:
builder.stripVlan();
break;
case SET_TP_DST:
case SET_TP_SRC:
case POP_PBB:
......@@ -280,7 +283,7 @@ public class FlowEntryBuilder {
case SET_NW_TOS:
case SET_NW_TTL:
case SET_QUEUE:
case STRIP_VLAN:
case ENQUEUE:
default:
log.warn("Action type {} not yet implemented.", act.getType());
......
......@@ -207,6 +207,8 @@ public class FlowModBuilderVer10 extends FlowModBuilder {
case VLAN_PCP:
ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m;
return factory().actions().setVlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
case STRIP_VLAN:
return factory().actions().stripVlan();
default:
log.warn("Unimplemented action type {}.", l2m.subtype());
break;
......
......@@ -319,6 +319,8 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
(PushHeaderInstructions) l2m;
return factory().actions().popMpls(EthType.of(popHeaderInstructions
.ethernetType()));
case STRIP_VLAN:
return factory().actions().stripVlan();
case MPLS_LABEL:
ModMplsLabelInstruction mplsLabel =
(ModMplsLabelInstruction) l2m;
......