Search in sources :

Example 11 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder in project netvirt by opendaylight.

the class AclMatchesTest method buildEthMatchTest.

@Test
public void buildEthMatchTest() {
    AceEthBuilder aceEthBuilder = new AceEthBuilder();
    aceEthBuilder.setDestinationMacAddress(new MacAddress(MAC_DST_STR));
    aceEthBuilder.setSourceMacAddress(new MacAddress(MAC_SRC_STR));
    MatchesBuilder matchesBuilder = new MatchesBuilder();
    matchesBuilder.setAceType(aceEthBuilder.build());
    // Create the aclMatches that is the object to be tested
    AclMatches aclMatches = new AclMatches(matchesBuilder.build());
    MatchBuilder matchBuilder = aclMatches.buildMatch();
    // The ethernet match should be there with src/dst values
    EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
    assertNotNull(ethMatch);
    assertEquals(ethMatch.getEthernetSource().getAddress().getValue(), MAC_SRC_STR);
    assertEquals(ethMatch.getEthernetDestination().getAddress().getValue(), MAC_DST_STR);
    // The rest should be null
    assertNull(matchBuilder.getIpMatch());
    assertNull(matchBuilder.getLayer3Match());
    assertNull(matchBuilder.getLayer4Match());
}
Also used : EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) AceEthBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEthBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchesBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.MatchesBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Test(org.junit.Test)

Example 12 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder in project netvirt by opendaylight.

the class Ipv6PktHandlerTest method testonPacketReceivedRouterSolicitationWithMultipleSubnets.

@Test
public void testonPacketReceivedRouterSolicitationWithMultipleSubnets() throws Exception {
    VirtualPort intf = Mockito.mock(VirtualPort.class);
    when(intf.getMacAddress()).thenReturn("50:7B:9D:78:54:F3");
    when(ifMgrInstance.obtainV6Interface(any())).thenReturn(intf);
    when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
    when(ifMgrInstance.getRouterV6InterfaceForNetwork(any())).thenReturn(intf);
    IpAddress gwIpAddress = Mockito.mock(IpAddress.class);
    when(gwIpAddress.getIpv4Address()).thenReturn(null);
    when(gwIpAddress.getIpv6Address()).thenReturn(new Ipv6Address("2001:db8:1111::1"));
    VirtualSubnet v6Subnet1 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8:1111::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_SLAAC).ipv6RAMode(Ipv6Constants.IPV6_SLAAC).build();
    VirtualRouter virtualRouter = VirtualRouter.builder().build();
    v6Subnet1.setRouter(virtualRouter);
    VirtualSubnet v6Subnet2 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8:2222::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_DHCPV6_STATELESS).ipv6RAMode(Ipv6Constants.IPV6_DHCPV6_STATELESS).build();
    v6Subnet2.setRouter(virtualRouter);
    VirtualSubnet v6Subnet3 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8:3333::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_DHCPV6_STATEFUL).ipv6RAMode(Ipv6Constants.IPV6_DHCPV6_STATEFUL).build();
    v6Subnet3.setRouter(virtualRouter);
    List<VirtualSubnet> subnetList = new ArrayList<>();
    subnetList.add(v6Subnet1);
    subnetList.add(v6Subnet2);
    subnetList.add(v6Subnet3);
    when(intf.getSubnets()).thenReturn(subnetList);
    InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
    NodeConnectorRef ncRef = new NodeConnectorRef(ncId);
    BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
    Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
    MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 00 00 00 02", // Source MAC
    "FA 16 3E 69 2C F3", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "60 00 00 00", // Payload length
    "00 10", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 02", // ICMPv6 router solicitation
    "85", // Code
    "00", // Checksum (valid)
    "B4 47", // ICMPv6 message body
    "00 00 00 00", // ICMPv6 Option: Source Link Layer Address
    "01", // Length
    "01", // Link Layer Address
    "FA 16 3E 69 2C F3")).setIngress(ncRef).setMatch(matchbuilder.build()).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
    byte[] expectedPayload = ipv6TestUtils.buildPacket(// Destination MAC
    "FA 16 3E 69 2C F3", // Source MAC
    "50 7B 9D 78 54 F3", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "60 00 00 00", // Payload length
    "00 78", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "FE 80 00 00 00 00 00 00 52 7B 9D FF FE 78 54 F3", // Destination IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // ICMPv6 router advertisement.
    "86", // Code
    "00", // Checksum (valid)
    "59 41", // Current Hop Limit
    "40", // ICMPv6 RA Flags
    "C0", // Router Lifetime
    "11 94", // Reachable time
    "00 01 D4 C0", // Retransmission time.
    "00 00 00 00", // Type: Source Link-Layer Option
    "01", // Option length
    "01", // Source Link layer address
    "50 7B 9D 78 54 F3", // Type: Prefix Information
    "03", // Option length
    "04", // Prefix length
    "40", // Prefix flags
    "C0", // Valid lifetime
    "00 27 8D 00", // Preferred lifetime
    "00 09 3A 80", // Reserved
    "00 00 00 00", // Prefix
    "20 01 0D B8 11 11 00 00 00 00 00 00 00 00 00 00", // Type: Prefix Information
    "03", // Option length
    "04", // Prefix length
    "40", // Prefix flags
    "C0", // Valid lifetime
    "00 27 8D 00", // Preferred lifetime
    "00 09 3A 80", // Reserved
    "00 00 00 00", // Prefix
    "20 01 0D B8 22 22 00 00 00 00 00 00 00 00 00 00", // Type: Prefix Information
    "03", // Option length
    "04", // Prefix length
    "40", // Prefix flags
    "80", // Valid lifetime
    "00 27 8D 00", // Preferred lifetime
    "00 09 3A 80", // Reserved
    "00 00 00 00", // Prefix
    "20 01 0D B8 33 33 00 00 00 00 00 00 00 00 00 00");
    verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload).setNode(new NodeRef(ncId)).setEgress(ncRef).build());
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) MetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Test(org.junit.Test)

Example 13 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder in project netvirt by opendaylight.

the class OpenFlow13Provider method createEgressClassifierNextHopNoC1C2Flow.

/*
     * Egress Classifier NextHop No C1/C2 flow:
     *     Set C1/C2 accordingly
     *     Match [C1, C2] == [0, 0], Move [TunIpv4Dst, TunVnid] to [C1, C2],
     *     Move Reg0 (SFF IP) to TunIpv4Dst, and goto Egress Classifier
     *     Transport Egress table on match
     */
public Flow createEgressClassifierNextHopNoC1C2Flow(NodeId nodeId) {
    MatchBuilder match = new MatchBuilder();
    OpenFlow13Utils.addMatchNshNsc1(match, DEFAULT_NSH_CONTEXT_VALUE);
    OpenFlow13Utils.addMatchNshNsc2(match, DEFAULT_NSH_CONTEXT_VALUE);
    List<Action> actionList = new ArrayList<>();
    actionList.add(OpenFlow13Utils.createActionNxMoveReg0ToNsc1Register(actionList.size()));
    actionList.add(OpenFlow13Utils.createActionNxMoveTunIdToNsc2Register(actionList.size()));
    actionList.add(OpenFlow13Utils.createActionNxMoveReg6ToNsc4Register(actionList.size()));
    actionList.add(OpenFlow13Utils.createActionNxLoadTunId(SFC_TUNNEL_ID, actionList.size()));
    InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
    OpenFlow13Utils.appendGotoTableInstruction(isb, NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE);
    String flowIdStr = EGRESS_CLASSIFIER_NEXTHOP_NOC1C2_FLOW_NAME + nodeId.getValue();
    return OpenFlow13Utils.createFlowBuilder(NwConstants.EGRESS_SFC_CLASSIFIER_NEXTHOP_TABLE, EGRESS_CLASSIFIER_NEXTHOP_NOC1C2_PRIORITY, EGRESS_CLASSIFIER_NEXTHOP_COOKIE, EGRESS_CLASSIFIER_NEXTHOP_NOC1C2_FLOW_NAME, flowIdStr, match, isb).build();
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ArrayList(java.util.ArrayList) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)

Example 14 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder in project netvirt by opendaylight.

the class OpenFlow13Provider method createIngressClassifierFilterChainEgressFlow.

/*
     * Classifier chain termination flow:
     *     Handle packets at the end of the chain
     *     Match C1 on local IP, NSP and ending NSI, restore metadata and
     *     resubmit to egress dispatcher
     */
public Flow createIngressClassifierFilterChainEgressFlow(NodeId nodeId, long nsp, short egressNsi) {
    MatchBuilder match = new MatchBuilder();
    OpenFlow13Utils.addMatchNsp(match, nsp);
    OpenFlow13Utils.addMatchNsi(match, egressNsi);
    List<Action> actionList = new ArrayList<>();
    actionList.add(OpenFlow13Utils.createActionNxMoveNsc4ToReg6Register(actionList.size()));
    actionList.add(OpenFlow13Utils.createActionNxPopNsh(actionList.size()));
    actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, actionList.size()));
    InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
    String flowIdStr = INGRESS_CLASSIFIER_FILTER_NSH_CHAIN_EGRESS_FLOW_NAME + nodeId.getValue() + "_" + nsp;
    return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE, INGRESS_CLASSIFIER_FILTER_CHAIN_EGRESS_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE, INGRESS_CLASSIFIER_FILTER_NSH_CHAIN_EGRESS_FLOW_NAME, flowIdStr, match, isb).build();
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ArrayList(java.util.ArrayList) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)

Example 15 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder in project netvirt by opendaylight.

the class OpenFlow13Provider method createEgressClassifierNextHopC1C2Flow.

/*
     * Egress Classifier NextHop with C1/C2 flow:
     *     Set C1/C2 accordingly
     *     MatchAny (C1, C2 already set) goto Egress Classifier
     *     Transport Egress table
     */
public Flow createEgressClassifierNextHopC1C2Flow(NodeId nodeId) {
    MatchBuilder match = new MatchBuilder();
    InstructionsBuilder isb = OpenFlow13Utils.appendGotoTableInstruction(new InstructionsBuilder(), NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE);
    String flowIdStr = EGRESS_CLASSIFIER_NEXTHOP_C1C2_FLOW_NAME + nodeId.getValue();
    return OpenFlow13Utils.createFlowBuilder(NwConstants.EGRESS_SFC_CLASSIFIER_NEXTHOP_TABLE, EGRESS_CLASSIFIER_NEXTHOP_C1C2_PRIORITY, EGRESS_CLASSIFIER_NEXTHOP_COOKIE, EGRESS_CLASSIFIER_NEXTHOP_C1C2_FLOW_NAME, flowIdStr, match, isb).build();
}
Also used : MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)

Aggregations

MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)220 Test (org.junit.Test)135 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)90 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)84 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)80 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)69 ArrayList (java.util.ArrayList)65 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)63 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)56 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)55 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)54 TcpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder)53 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)52 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)51 Icmpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder)51 UdpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder)51 BigInteger (java.math.BigInteger)46 SctpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder)44 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)42 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)40