Search in sources :

Example 1 with MatchArpSha

use of org.opendaylight.genius.mdsalutil.matches.MatchArpSha 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)

Aggregations

ArrayList (java.util.ArrayList)1 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)1 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)1 MatchArpSha (org.opendaylight.genius.mdsalutil.matches.MatchArpSha)1 MatchEthernetSource (org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 IpPrefixOrAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress)1 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)1