Search in sources :

Example 1 with Ipv6

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.

the class AclMatchesTest method buildIpv6MatchTest.

@Test
public void buildIpv6MatchTest() {
    AceIpv6Builder aceIpv6 = new AceIpv6Builder();
    aceIpv6.setDestinationIpv6Network(new Ipv6Prefix(IPV6_DST_STR));
    aceIpv6.setSourceIpv6Network(new Ipv6Prefix(IPV6_SRC_STR));
    AceIpBuilder aceIpBuilder = new AceIpBuilder();
    aceIpBuilder.setAceIpVersion(aceIpv6.build());
    MatchesBuilder matchesBuilder = new MatchesBuilder();
    matchesBuilder.setAceType(aceIpBuilder.build());
    // Create the aclMatches that is the object to be tested
    AclMatches aclMatches = new AclMatches(matchesBuilder.build());
    MatchBuilder matchBuilder = aclMatches.buildMatch();
    // The layer3 match should be there with src/dst values
    Ipv6Match l3 = (Ipv6Match) matchBuilder.getLayer3Match();
    assertNotNull(l3);
    assertEquals(l3.getIpv6Destination().getValue().toString(), IPV6_DST_STR);
    assertEquals(l3.getIpv6Source().getValue().toString(), IPV6_SRC_STR);
    // There should be an IPv6 etherType set
    EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
    assertNotNull(ethMatch);
    assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV6));
    // The rest should be null
    assertNull(matchBuilder.getIpMatch());
    assertNull(matchBuilder.getLayer4Match());
}
Also used : AceIpv6Builder(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.ace.ip.ace.ip.version.AceIpv6Builder) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) AceIpBuilder(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.AceIpBuilder) Ipv6Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match) 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) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Test(org.junit.Test)

Example 2 with Ipv6

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.

the class AclServiceOFFlowBuilder method programIcmpFlow.

/**
 *Converts icmp matches to flows.
 * @param acl the access control list
 * @return the map containing the flows and the respective flow id
 */
public static Map<String, List<MatchInfoBase>> programIcmpFlow(AceIp acl) {
    List<MatchInfoBase> flowMatches = new ArrayList<>();
    flowMatches.addAll(addSrcIpMatches(acl));
    flowMatches.addAll(addDstIpMatches(acl));
    // For ICMP port range indicates type and code
    SourcePortRange sourcePortRange = acl.getSourcePortRange();
    String flowId = "ICMP_";
    if (sourcePortRange != null) {
        if (acl.getAceIpVersion() instanceof AceIpv4) {
            flowMatches.add(new MatchIcmpv4(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
            flowId = flowId + "V4_SOURCE_" + sourcePortRange.getLowerPort().getValue() + sourcePortRange.getUpperPort().getValue();
        } else if (acl.getAceIpVersion() instanceof AceIpv6) {
            flowMatches.add(new MatchIcmpv6(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
            flowId = flowId + "V6_SOURCE_" + sourcePortRange.getLowerPort().getValue() + "_" + sourcePortRange.getUpperPort().getValue() + "_";
        }
    }
    DestinationPortRange destinationPortRange = acl.getDestinationPortRange();
    if (destinationPortRange != null) {
        if (acl.getAceIpVersion() instanceof AceIpv4) {
            flowMatches.add(new MatchIcmpv4(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
            flowId = flowId + "V4_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
        } else if (acl.getAceIpVersion() instanceof AceIpv6) {
            flowMatches.add(new MatchIcmpv6(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
            flowId = flowId + "V6_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
        }
    }
    if (acl.getAceIpVersion() instanceof AceIpv6 && acl.getProtocol() == NwConstants.IP_PROT_ICMP) {
        // We are aligning our implementation similar to Neutron Firewall driver where a Security
        // Group rule with "Ethertype as IPv6 and Protocol as icmp" is treated as ICMPV6 SG Rule.
        flowMatches.add(new MatchIpProtocol(AclConstants.IP_PROT_ICMPV6));
    } else {
        flowMatches.add(new MatchIpProtocol(acl.getProtocol()));
    }
    Map<String, List<MatchInfoBase>> flowMatchesMap = new HashMap<>();
    flowMatchesMap.put(flowId, flowMatches);
    return flowMatchesMap;
}
Also used : SourcePortRange(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.SourcePortRange) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MatchIpProtocol(org.opendaylight.genius.mdsalutil.matches.MatchIpProtocol) DestinationPortRange(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.DestinationPortRange) MatchIcmpv4(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv4) MatchIcmpv6(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv6) ArrayList(java.util.ArrayList) List(java.util.List) AceIpv6(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.ace.ip.ace.ip.version.AceIpv6) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) AceIpv4(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.ace.ip.ace.ip.version.AceIpv4)

Example 3 with Ipv6

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.

the class AclServiceUtils method doesIpv6AddressExists.

/**
 * Does IPv6 address exists in the list of allowed address pair.
 *
 * @param aaps the allowed address pairs
 * @return true, if successful
 */
public static boolean doesIpv6AddressExists(List<AllowedAddressPairs> aaps) {
    if (aaps == null) {
        return false;
    }
    for (AllowedAddressPairs aap : aaps) {
        IpPrefixOrAddress ipPrefixOrAddress = aap.getIpAddress();
        IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
        if (ipPrefix != null) {
            if (ipPrefix.getIpv6Prefix() != null) {
                return true;
            }
        } else {
            IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
            if (ipAddress != null && ipAddress.getIpv6Address() != null) {
                return true;
            }
        }
    }
    return false;
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 4 with Ipv6

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.

the class SubnetGwMacChangeListener method handleSubnetGwIpChange.

private void handleSubnetGwIpChange(LearntVpnVipToPort learntVpnVipToPort) {
    String macAddress = learntVpnVipToPort.getMacAddress();
    if (macAddress == null) {
        LOG.error("handleSubnetGwIpChange : Mac address is null for LearntVpnVipToPort for vpn {} prefix {}", learntVpnVipToPort.getVpnName(), learntVpnVipToPort.getPortFixedip());
        return;
    }
    String fixedIp = learntVpnVipToPort.getPortFixedip();
    if (fixedIp == null) {
        LOG.error("handleSubnetGwIpChange : Fixed ip is null for LearntVpnVipToPort for vpn {}", learntVpnVipToPort.getVpnName());
        return;
    }
    try {
        InetAddress address = InetAddress.getByName(fixedIp);
        if (address instanceof Inet6Address) {
            // TODO: Revisit when IPv6 North-South communication support is added.
            LOG.debug("handleSubnetGwIpChange : Skipping ipv6 address {}.", address);
            return;
        }
    } catch (UnknownHostException e) {
        LOG.warn("handleSubnetGwIpChange : Invalid ip address {}", fixedIp, e);
        return;
    }
    for (Uuid subnetId : nvpnManager.getSubnetIdsForGatewayIp(new IpAddress(new Ipv4Address(fixedIp)))) {
        LOG.trace("handleSubnetGwIpChange : Updating MAC resolution on vpn {} for GW ip {} to {}", learntVpnVipToPort.getVpnName(), fixedIp, macAddress);
        extNetworkInstaller.installExtNetGroupEntries(subnetId, macAddress);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) UnknownHostException(java.net.UnknownHostException) Inet6Address(java.net.Inet6Address) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) InetAddress(java.net.InetAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 5 with Ipv6

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.

the class Ipv6PktHandlerTest method testonPacketReceivedNeighborSolicitationWithInvalidPayload.

@Test
public void testonPacketReceivedNeighborSolicitationWithInvalidPayload() throws Exception {
    // incorrect checksum
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 FF F5 00 00", // Source MAC
    "00 01 02 03 04 05", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "6E 00 00 00", // Payload length
    "00 18", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 neighbor solicitation
    "87", // Code
    "00", // Checksum (invalid, should be 67 3C)
    "67 3E", // ICMPv6 message body
    "00 00 00 00", // Target
    "FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
    // unavailable ip
    when(ifMgrInstance.obtainV6Interface(any())).thenReturn(null);
    counter = pktHandler.getPacketProcessedCounter();
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 FF F5 00 00", // Source MAC
    "00 01 02 03 04 05", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "6E 00 00 00", // Payload length
    "00 18", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 neighbor solicitation
    "87", // Code
    "00", // Checksum (valid)
    "67 3C", // ICMPv6 message body
    "00 00 00 00", // Target
    "FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
}
Also used : TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)64 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)36 ArrayList (java.util.ArrayList)30 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)21 ByteBuf (io.netty.buffer.ByteBuf)20 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)16 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)16 BigInteger (java.math.BigInteger)15 InetAddress (java.net.InetAddress)13 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)13 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)13 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)13 List (java.util.List)10 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)10 Inet6Address (java.net.Inet6Address)9 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)9 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)9 Ipv6 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6)9 Ipv6SrcCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder)9 Ipv6SrcBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder)9