use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class EgressAclServiceImpl method egressAclDhcpAllowClientTraffic.
/**
* Add rule to ensure only DHCP 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 egressAclDhcpAllowClientTraffic(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.buildDhcpMatches(AclConstants.DHCP_CLIENT_PORT_IPV4, AclConstants.DHCP_SERVER_PORT_IPV4, lportTag, serviceMode));
matches.add(new MatchEthernetSource(aap.getMacAddress()));
String flowName = "Egress_DHCP_Client_v4" + 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);
}
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class EgressAclServiceImpl method programL2BroadcastAllowRule.
/**
* Programs Non-IP broadcast rules.
*
* @param port the Acl Interface port
* @param addOrRemove whether to delete or add flow
*/
private void programL2BroadcastAllowRule(AclInterface port, int addOrRemove) {
BigInteger dpId = port.getDpId();
int lportTag = port.getLPortTag();
List<AllowedAddressPairs> allowedAddresses = port.getAllowedAddressPairs();
Set<MacAddress> macs = allowedAddresses.stream().map(aap -> aap.getMacAddress()).collect(Collectors.toSet());
for (MacAddress mac : macs) {
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(new MatchEthernetSource(mac));
matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions();
String flowName = "Egress_L2Broadcast_" + dpId + "_" + lportTag + "_" + mac.getValue();
syncFlow(dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_L2BROADCAST_TRAFFIC_MATCH_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
}
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class EgressAclServiceImpl method egressAclIcmpv6AllowedList.
/**
* Add rule to allow certain ICMPv6 traffic from VM ports.
*
* @param dpId the dpId
* @param lportTag the lport tag
* @param addOrRemove add/remove the flow.
*/
private void egressAclIcmpv6AllowedList(BigInteger dpId, int lportTag, int addOrRemove) {
List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions();
for (Integer icmpv6Type : AclConstants.allowedIcmpv6NdList()) {
List<MatchInfoBase> matches = AclServiceUtils.buildIcmpV6Matches(icmpv6Type, 0, lportTag, serviceMode);
String flowName = "Egress_ICMPv6" + "_" + dpId + "_" + lportTag + "_" + icmpv6Type + "_Permit_";
syncFlow(dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_IPV6_ALLOWED_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
}
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class IngressAclServiceImpl method programIpv4BroadcastRule.
/**
* Programs IPv4 broadcast rules.
*
* @param port the Acl Interface port
* @param addOrRemove whether to delete or add flow
*/
private void programIpv4BroadcastRule(AclInterface port, int addOrRemove) {
BigInteger dpId = port.getDpId();
int lportTag = port.getLPortTag();
MatchInfoBase lportMatchInfo = AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode);
List<IpPrefixOrAddress> cidrs = port.getSubnetIpPrefixes();
if (cidrs != null) {
List<String> broadcastAddresses = AclServiceUtils.getIpBroadcastAddresses(cidrs);
for (String broadcastAddress : broadcastAddresses) {
List<MatchInfoBase> matches = AclServiceUtils.buildBroadcastIpV4Matches(broadcastAddress);
matches.add(lportMatchInfo);
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionGotoTable(getAclConntrackClassifierTable()));
String flowName = "Ingress_v4_Broadcast_" + dpId + "_" + lportTag + "_" + broadcastAddress + "_Permit";
syncFlow(dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_MATCH_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
}
} else {
LOG.warn("IP Broadcast CIDRs are missing for port {}", port.getInterfaceId());
}
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class AclNodeDefaultFlowsTxBuilder method addEgressConntrackDummyLookup.
private void addEgressConntrackDummyLookup() {
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new NxMatchCtState(AclConstants.TRACKED_CT_STATE, AclConstants.TRACKED_CT_STATE_MASK));
int elanTag = dummyTag;
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
actionsInfos.add(new ActionNxConntrack(2, 0, 0, elanTag, NwConstants.EGRESS_ACL_ANTI_SPOOFING_TABLE));
instructions.add(new InstructionApplyActions(actionsInfos));
String flowName = "Egress_Fixed_Dummy_Table_Ipv4_" + this.dpId;
addFlowToTx(NwConstants.EGRESS_ACL_DUMMY_TABLE, flowName, AclConstants.ACL_DEFAULT_PRIORITY, matches, instructions);
matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV6);
matches.add(new NxMatchCtState(AclConstants.TRACKED_CT_STATE, AclConstants.TRACKED_CT_STATE_MASK));
flowName = "Egress_Fixed_Dummy_Table_Ipv6_" + this.dpId;
addFlowToTx(NwConstants.EGRESS_ACL_DUMMY_TABLE, flowName, AclConstants.ACL_DEFAULT_PRIORITY, matches, instructions);
}
Aggregations