Search in sources :

Example 6 with MatchEthernetSource

use of org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource in project netvirt by opendaylight.

the class EgressAclServiceImpl method egressAclDhcpv6AllowClientTraffic.

/**
 * Add rule to ensure only DHCPv6 server traffic from the specified mac is
 * allowed.
 *
 * @param dpId the dpid
 * @param allowedAddresses the allowed addresses
 * @param lportTag the lport tag
 * @param addOrRemove whether to add or remove the flow
 */
private void egressAclDhcpv6AllowClientTraffic(BigInteger dpId, List<AllowedAddressPairs> allowedAddresses, int lportTag, int addOrRemove) {
    List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions();
    for (AllowedAddressPairs aap : allowedAddresses) {
        if (AclServiceUtils.isIPv4Address(aap)) {
            continue;
        }
        List<MatchInfoBase> matches = new ArrayList<>();
        matches.addAll(AclServiceUtils.buildDhcpV6Matches(AclConstants.DHCP_CLIENT_PORT_IPV6, AclConstants.DHCP_SERVER_PORT_IPV6, lportTag, serviceMode));
        matches.add(new MatchEthernetSource(aap.getMacAddress()));
        String flowName = "Egress_DHCP_Client_v6" + "_" + dpId + "_" + lportTag + "_" + aap.getMacAddress().getValue() + "_Permit_";
        syncFlow(dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
    }
}
Also used : InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) MatchEthernetSource(org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource) ArrayList(java.util.ArrayList) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 7 with MatchEthernetSource

use of org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource in project netvirt by opendaylight.

the class EgressAclServiceImpl method programArpRule.

/**
 * Adds the rule to allow arp packets.
 *
 * @param dpId the dpId
 * @param allowedAddresses the allowed addresses
 * @param lportTag the lport tag
 * @param addOrRemove whether to add or remove the flow
 */
protected void programArpRule(BigInteger dpId, List<AllowedAddressPairs> allowedAddresses, int lportTag, int addOrRemove) {
    for (AllowedAddressPairs allowedAddress : allowedAddresses) {
        if (!AclServiceUtils.isIPv4Address(allowedAddress)) {
            // For IPv6 allowed addresses
            continue;
        }
        IpPrefixOrAddress allowedAddressIp = allowedAddress.getIpAddress();
        MacAddress allowedAddressMac = allowedAddress.getMacAddress();
        List<MatchInfoBase> arpIpMatches = AclServiceUtils.buildArpIpMatches(allowedAddressIp);
        List<MatchInfoBase> matches = new ArrayList<>();
        matches.add(MatchEthernetType.ARP);
        matches.add(new MatchArpSha(allowedAddressMac));
        matches.add(new MatchEthernetSource(allowedAddressMac));
        matches.addAll(arpIpMatches);
        matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
        List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions();
        LOG.debug("{} ARP Rule on DPID {}, lportTag {}", addOrRemove == NwConstants.DEL_FLOW ? "Deleting" : "Adding", dpId, lportTag);
        String flowName = "Egress_ARP_" + dpId + "_" + lportTag + "_" + allowedAddress.getMacAddress().getValue() + String.valueOf(allowedAddressIp.getValue());
        syncFlow(dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_ARP_TRAFFIC_MATCH_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
    }
}
Also used : MatchArpSha(org.opendaylight.genius.mdsalutil.matches.MatchArpSha) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) MatchEthernetSource(org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource) ArrayList(java.util.ArrayList) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 8 with MatchEthernetSource

use of org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource in project netvirt by opendaylight.

the class EgressAclServiceImpl method programGotoClassifierTableRules.

@Override
protected void programGotoClassifierTableRules(BigInteger dpId, List<AllowedAddressPairs> aaps, int lportTag, int addOrRemove) {
    List<AllowedAddressPairs> filteredAAPs = AclServiceUtils.excludeMulticastAAPs(aaps);
    for (AllowedAddressPairs aap : filteredAAPs) {
        IpPrefixOrAddress attachIp = aap.getIpAddress();
        MacAddress mac = aap.getMacAddress();
        List<MatchInfoBase> matches = new ArrayList<>();
        matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
        matches.add(new MatchEthernetSource(mac));
        matches.addAll(AclServiceUtils.buildIpMatches(attachIp, MatchCriteria.MATCH_SOURCE));
        List<InstructionInfo> gotoInstructions = new ArrayList<>();
        gotoInstructions.add(new InstructionGotoTable(getAclConntrackClassifierTable()));
        String flowName = "Egress_Fixed_Goto_Classifier_" + dpId + "_" + lportTag + "_" + mac.getValue() + "_" + String.valueOf(attachIp.getValue());
        syncFlow(dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_MATCH_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, gotoInstructions, addOrRemove);
    }
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) MatchEthernetSource(org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource) ArrayList(java.util.ArrayList) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Aggregations

MatchEthernetSource (org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource)8 ArrayList (java.util.ArrayList)7 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)6 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)5 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)5 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)3 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)3 IpPrefixOrAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress)3 BigInteger (java.math.BigInteger)2 MatchArpSha (org.opendaylight.genius.mdsalutil.matches.MatchArpSha)2 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)2 Collections (java.util.Collections)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 FlowEntityBuilder (org.opendaylight.genius.mdsalutil.FlowEntityBuilder)1