Parse set-field action in OF1.3 when creating flow rules from flow entries.
Closes ONOS-333 Change-Id: I7b032b3e6c874ded4c976de0afa3f4bbaa07df3c
Showing
1 changed file
with
104 additions
and
5 deletions
| ... | @@ -19,6 +19,10 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -19,6 +19,10 @@ import static org.slf4j.LoggerFactory.getLogger; |
| 19 | 19 | ||
| 20 | import java.util.List; | 20 | import java.util.List; |
| 21 | 21 | ||
| 22 | +import org.onlab.packet.Ip4Address; | ||
| 23 | +import org.onlab.packet.Ip4Prefix; | ||
| 24 | +import org.onlab.packet.MacAddress; | ||
| 25 | +import org.onlab.packet.VlanId; | ||
| 22 | import org.onosproject.net.DeviceId; | 26 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.PortNumber; | 27 | import org.onosproject.net.PortNumber; |
| 24 | import org.onosproject.net.flow.DefaultFlowEntry; | 28 | import org.onosproject.net.flow.DefaultFlowEntry; |
| ... | @@ -31,10 +35,6 @@ import org.onosproject.net.flow.FlowRule; | ... | @@ -31,10 +35,6 @@ import org.onosproject.net.flow.FlowRule; |
| 31 | import org.onosproject.net.flow.TrafficSelector; | 35 | import org.onosproject.net.flow.TrafficSelector; |
| 32 | import org.onosproject.net.flow.TrafficTreatment; | 36 | import org.onosproject.net.flow.TrafficTreatment; |
| 33 | import org.onosproject.openflow.controller.Dpid; | 37 | import org.onosproject.openflow.controller.Dpid; |
| 34 | -import org.onlab.packet.Ip4Address; | ||
| 35 | -import org.onlab.packet.Ip4Prefix; | ||
| 36 | -import org.onlab.packet.MacAddress; | ||
| 37 | -import org.onlab.packet.VlanId; | ||
| 38 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; | 38 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
| 39 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; | 39 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
| 40 | import org.projectfloodlight.openflow.protocol.OFInstructionType; | 40 | import org.projectfloodlight.openflow.protocol.OFInstructionType; |
| ... | @@ -44,6 +44,7 @@ import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter; | ... | @@ -44,6 +44,7 @@ import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter; |
| 44 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; | 44 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
| 45 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst; | 45 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst; |
| 46 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc; | 46 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc; |
| 47 | +import org.projectfloodlight.openflow.protocol.action.OFActionSetField; | ||
| 47 | import org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst; | 48 | import org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst; |
| 48 | import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc; | 49 | import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc; |
| 49 | import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp; | 50 | import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp; |
| ... | @@ -52,9 +53,12 @@ import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; | ... | @@ -52,9 +53,12 @@ import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
| 52 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; | 53 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; |
| 53 | import org.projectfloodlight.openflow.protocol.match.Match; | 54 | import org.projectfloodlight.openflow.protocol.match.Match; |
| 54 | import org.projectfloodlight.openflow.protocol.match.MatchField; | 55 | import org.projectfloodlight.openflow.protocol.match.MatchField; |
| 56 | +import org.projectfloodlight.openflow.protocol.oxm.OFOxm; | ||
| 55 | import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; | 57 | import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; |
| 56 | import org.projectfloodlight.openflow.types.IPv4Address; | 58 | import org.projectfloodlight.openflow.types.IPv4Address; |
| 57 | import org.projectfloodlight.openflow.types.Masked; | 59 | import org.projectfloodlight.openflow.types.Masked; |
| 60 | +import org.projectfloodlight.openflow.types.OFVlanVidMatch; | ||
| 61 | +import org.projectfloodlight.openflow.types.VlanPcp; | ||
| 58 | import org.slf4j.Logger; | 62 | import org.slf4j.Logger; |
| 59 | 63 | ||
| 60 | import com.google.common.collect.Lists; | 64 | import com.google.common.collect.Lists; |
| ... | @@ -152,7 +156,7 @@ public class FlowEntryBuilder { | ... | @@ -152,7 +156,7 @@ public class FlowEntryBuilder { |
| 152 | break; | 156 | break; |
| 153 | case SET_VLAN_PCP: | 157 | case SET_VLAN_PCP: |
| 154 | OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act; | 158 | OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act; |
| 155 | - builder.setVlanId(VlanId.vlanId(pcp.getVlanPcp().getValue())); | 159 | + builder.setVlanPcp(pcp.getVlanPcp().getValue()); |
| 156 | break; | 160 | break; |
| 157 | case SET_DL_DST: | 161 | case SET_DL_DST: |
| 158 | OFActionSetDlDst dldst = (OFActionSetDlDst) act; | 162 | OFActionSetDlDst dldst = (OFActionSetDlDst) act; |
| ... | @@ -186,6 +190,8 @@ public class FlowEntryBuilder { | ... | @@ -186,6 +190,8 @@ public class FlowEntryBuilder { |
| 186 | } | 190 | } |
| 187 | break; | 191 | break; |
| 188 | case SET_FIELD: | 192 | case SET_FIELD: |
| 193 | + OFActionSetField setField = (OFActionSetField) act; | ||
| 194 | + handleSetField(builder, setField.getField()); | ||
| 189 | break; | 195 | break; |
| 190 | case SET_TP_DST: | 196 | case SET_TP_DST: |
| 191 | case SET_TP_SRC: | 197 | case SET_TP_SRC: |
| ... | @@ -218,6 +224,99 @@ public class FlowEntryBuilder { | ... | @@ -218,6 +224,99 @@ public class FlowEntryBuilder { |
| 218 | return builder.build(); | 224 | return builder.build(); |
| 219 | } | 225 | } |
| 220 | 226 | ||
| 227 | + private void handleSetField(TrafficTreatment.Builder builder, OFOxm<?> oxm) { | ||
| 228 | + switch (oxm.getMatchField().id) { | ||
| 229 | + case VLAN_PCP: | ||
| 230 | + @SuppressWarnings("unchecked") | ||
| 231 | + OFOxm<VlanPcp> vlanpcp = (OFOxm<VlanPcp>) oxm; | ||
| 232 | + builder.setVlanPcp(vlanpcp.getValue().getValue()); | ||
| 233 | + break; | ||
| 234 | + case VLAN_VID: | ||
| 235 | + @SuppressWarnings("unchecked") | ||
| 236 | + OFOxm<OFVlanVidMatch> vlanvid = (OFOxm<OFVlanVidMatch>) oxm; | ||
| 237 | + builder.setVlanId(VlanId.vlanId(vlanvid.getValue().getVlan())); | ||
| 238 | + break; | ||
| 239 | + case ETH_DST: | ||
| 240 | + @SuppressWarnings("unchecked") | ||
| 241 | + OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethdst = | ||
| 242 | + (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm; | ||
| 243 | + builder.setEthDst(MacAddress.valueOf(ethdst.getValue().getLong())); | ||
| 244 | + break; | ||
| 245 | + case ETH_SRC: | ||
| 246 | + @SuppressWarnings("unchecked") | ||
| 247 | + OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethsrc = | ||
| 248 | + (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm; | ||
| 249 | + builder.setEthSrc(MacAddress.valueOf(ethsrc.getValue().getLong())); | ||
| 250 | + break; | ||
| 251 | + case IPV4_DST: | ||
| 252 | + @SuppressWarnings("unchecked") | ||
| 253 | + OFOxm<IPv4Address> ip4dst = (OFOxm<IPv4Address>) oxm; | ||
| 254 | + builder.setIpDst(Ip4Address.valueOf(ip4dst.getValue().getInt())); | ||
| 255 | + break; | ||
| 256 | + case IPV4_SRC: | ||
| 257 | + @SuppressWarnings("unchecked") | ||
| 258 | + OFOxm<IPv4Address> ip4src = (OFOxm<IPv4Address>) oxm; | ||
| 259 | + builder.setIpSrc(Ip4Address.valueOf(ip4src.getValue().getInt())); | ||
| 260 | + break; | ||
| 261 | + case ARP_OP: | ||
| 262 | + case ARP_SHA: | ||
| 263 | + case ARP_SPA: | ||
| 264 | + case ARP_THA: | ||
| 265 | + case ARP_TPA: | ||
| 266 | + case BSN_EGR_PORT_GROUP_ID: | ||
| 267 | + case BSN_GLOBAL_VRF_ALLOWED: | ||
| 268 | + case BSN_IN_PORTS_128: | ||
| 269 | + case BSN_L3_DST_CLASS_ID: | ||
| 270 | + case BSN_L3_INTERFACE_CLASS_ID: | ||
| 271 | + case BSN_L3_SRC_CLASS_ID: | ||
| 272 | + case BSN_LAG_ID: | ||
| 273 | + case BSN_TCP_FLAGS: | ||
| 274 | + case BSN_UDF0: | ||
| 275 | + case BSN_UDF1: | ||
| 276 | + case BSN_UDF2: | ||
| 277 | + case BSN_UDF3: | ||
| 278 | + case BSN_UDF4: | ||
| 279 | + case BSN_UDF5: | ||
| 280 | + case BSN_UDF6: | ||
| 281 | + case BSN_UDF7: | ||
| 282 | + case BSN_VLAN_XLATE_PORT_GROUP_ID: | ||
| 283 | + case BSN_VRF: | ||
| 284 | + case ETH_TYPE: | ||
| 285 | + case ICMPV4_CODE: | ||
| 286 | + case ICMPV4_TYPE: | ||
| 287 | + case ICMPV6_CODE: | ||
| 288 | + case ICMPV6_TYPE: | ||
| 289 | + case IN_PHY_PORT: | ||
| 290 | + case IN_PORT: | ||
| 291 | + case IPV6_DST: | ||
| 292 | + case IPV6_FLABEL: | ||
| 293 | + case IPV6_ND_SLL: | ||
| 294 | + case IPV6_ND_TARGET: | ||
| 295 | + case IPV6_ND_TLL: | ||
| 296 | + case IPV6_SRC: | ||
| 297 | + case IP_DSCP: | ||
| 298 | + case IP_ECN: | ||
| 299 | + case IP_PROTO: | ||
| 300 | + case METADATA: | ||
| 301 | + case MPLS_LABEL: | ||
| 302 | + case MPLS_TC: | ||
| 303 | + case OCH_SIGID: | ||
| 304 | + case OCH_SIGID_BASIC: | ||
| 305 | + case OCH_SIGTYPE: | ||
| 306 | + case OCH_SIGTYPE_BASIC: | ||
| 307 | + case SCTP_DST: | ||
| 308 | + case SCTP_SRC: | ||
| 309 | + case TCP_DST: | ||
| 310 | + case TCP_SRC: | ||
| 311 | + case TUNNEL_ID: | ||
| 312 | + case UDP_DST: | ||
| 313 | + case UDP_SRC: | ||
| 314 | + default: | ||
| 315 | + log.warn("Set field type {} not yet implemented.", oxm.getMatchField().id); | ||
| 316 | + break; | ||
| 317 | + } | ||
| 318 | + } | ||
| 319 | + | ||
| 221 | private TrafficSelector buildSelector() { | 320 | private TrafficSelector buildSelector() { |
| 222 | TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); | 321 | TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); |
| 223 | for (MatchField<?> field : match.getMatchFields()) { | 322 | for (MatchField<?> field : match.getMatchFields()) { | ... | ... |
-
Please register or login to post a comment