package org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.services;
-
import com.google.common.collect.Lists;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.ovsdb.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import java.net.UnknownHostException;
import java.util.List;
-
-
public class IngressAclService extends AbstractServiceInstance implements IngressAclProvider, ConfigInterface {
-
private static final Logger LOG = LoggerFactory.getLogger(IngressAclService.class);
private volatile SecurityServicesManager securityServicesManager;
private volatile SecurityGroupCacheManger securityGroupCacheManger;
matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,
new Ipv4Prefix(portSecurityRule.getSecurityRuleRemoteIpPrefix()),null);
}
- String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
flowId = flowId + "_Permit";
syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
}
*/
private void ingressAclIPv4(Long dpidLong, String segmentationId, String dstMac,
boolean write, Integer protoPortMatchPriority ) {
- String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
MatchBuilder matchBuilder = new MatchBuilder();
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
String flowId = "Ingress_IP" + segmentationId + "_" + dstMac + "_Permit_";
matchBuilder = MatchUtils.createEtherMatchWithType(matchBuilder,null,dstMac);
syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
Integer protoPortMatchPriority ) {
MatchBuilder matchBuilder = new MatchBuilder();
- FlowBuilder flowBuilder = new FlowBuilder();
String flowId = "Ingress_TCP_" + segmentationId + "_" + dstMac + "_";
matchBuilder = MatchUtils.createEtherMatchWithType(matchBuilder,null,dstMac);
matchBuilder = MatchUtils.addLayer4Match(matchBuilder, MatchUtils.TCP_SHORT, 0, 0);
}
/*TODO TCP PortRange Match*/
-
}
if (null != srcAddress) {
new Ipv4Prefix(portSecurityRule
.getSecurityRuleRemoteIpPrefix()),null);
}
- String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
flowId = flowId + "_Permit";
syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
-
}
/**
new Ipv4Prefix(portSecurityRule
.getSecurityRuleRemoteIpPrefix()),null);
}
- String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
flowId = flowId + "_Permit";
syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
-
}
/**
new Ipv4Prefix(portSecurityRule
.getSecurityRuleRemoteIpPrefix()),null);
}
- String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
flowId = flowId + "_Permit";
syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
}
private void ingressAclDhcpAllowServerTraffic(Long dpidLong, String segmentationId, String dhcpMacAddress,
boolean write, Integer protoPortMatchPriority) {
- String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
+ NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
MatchBuilder matchBuilder = new MatchBuilder();
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
MatchUtils.createDhcpServerMatch(matchBuilder, dhcpMacAddress, 67, 68).build();
- LOG.debug("ingressAclDHCPAllowServerTraffic: MatchBuilder contains: {}", matchBuilder);
String flowId = "Ingress_DHCP_Server" + segmentationId + "_" + dhcpMacAddress + "_Permit_";
syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
}
/**
* Add or remove flow to the node.
*
- * @param flowId the the flow id
+ * @param flowName the the flow id
* @param nodeBuilder the node builder
* @param matchBuilder the matchbuilder
- * @param protoPortMatchPriority the protocol priority
+ * @param priority the protocol priority
* @param write whether it is a write
* @param drop whether it is a drop or forward
*/
- private void syncFlow(String flowId, NodeBuilder nodeBuilder,
- MatchBuilder matchBuilder,Integer protoPortMatchPriority,
- boolean write,boolean drop) {
+ private void syncFlow(String flowName, NodeBuilder nodeBuilder,
+ MatchBuilder matchBuilder, Integer priority,
+ boolean write, boolean drop) {
FlowBuilder flowBuilder = new FlowBuilder();
flowBuilder.setMatch(matchBuilder.build());
- flowBuilder.setId(new FlowId(flowId));
- FlowKey key = new FlowKey(new FlowId(flowId));
- flowBuilder.setStrict(false);
- flowBuilder.setPriority(protoPortMatchPriority);
- flowBuilder.setBarrier(true);
- flowBuilder.setTableId(this.getTable());
- flowBuilder.setKey(key);
- flowBuilder.setFlowName(flowId);
- flowBuilder.setHardTimeout(0);
- flowBuilder.setIdleTimeout(0);
+ FlowUtils.initFlowBuilder(flowBuilder, flowName, getTable()).setPriority(priority);
if (write) {
- // Instantiate the Builders for the OF Actions and Instructions
InstructionBuilder ib = this.getMutablePipelineInstructionBuilder();
if (drop) {
InstructionUtils.createDropInstructions(ib);
} else {
removeFlow(flowBuilder, nodeBuilder);
}
-
}
@Override