use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project netvirt by opendaylight.
the class DhcpPktHandler method onPacketReceived.
// TODO: Handle this in a separate thread
@Override
public void onPacketReceived(PacketReceived packet) {
if (!config.isControllerDhcpEnabled()) {
return;
}
Class<? extends PacketInReason> pktInReason = packet.getPacketInReason();
short tableId = packet.getTableId().getValue();
if ((tableId == NwConstants.DHCP_TABLE || tableId == NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL) && isPktInReasonSendtoCtrl(pktInReason)) {
byte[] inPayload = packet.getPayload();
Ethernet ethPkt = new Ethernet();
try {
ethPkt.deserialize(inPayload, 0, inPayload.length * NetUtils.NUM_BITS_IN_A_BYTE);
} catch (PacketException e) {
LOG.warn("Failed to decode DHCP Packet.", e);
LOG.trace("Received packet {}", packet);
return;
}
DHCP pktIn;
pktIn = getDhcpPktIn(ethPkt);
if (pktIn != null) {
LOG.trace("DHCPPkt received: {}", pktIn);
LOG.trace("Received Packet: {}", packet);
BigInteger metadata = packet.getMatch().getMetadata().getMetadata();
long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
String macAddress = DHCPUtils.byteArrayToString(ethPkt.getSourceMACAddress());
BigInteger tunnelId = packet.getMatch().getTunnel() == null ? null : packet.getMatch().getTunnel().getTunnelId();
String interfaceName = getInterfaceNameFromTag(portTag);
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(interfaceName);
if (interfaceInfo == null) {
LOG.error("Failed to get interface info for interface name {}", interfaceName);
return;
}
Port port;
if (tunnelId != null) {
port = dhcpExternalTunnelManager.readVniMacToPortCache(tunnelId, macAddress);
} else {
port = getNeutronPort(interfaceName);
}
Subnet subnet = getNeutronSubnet(port);
String serverMacAddress = interfaceInfo.getMacAddress();
String serverIp = null;
if (subnet != null) {
java.util.Optional<SubnetToDhcpPort> dhcpPortData = DhcpServiceUtils.getSubnetDhcpPortData(broker, subnet.getUuid().getValue());
/* If enable_dhcp_service flag was enabled and an ODL network DHCP Port data was made available use
* the ports Fixed IP as server IP for DHCP communication.
*/
if (dhcpPortData.isPresent()) {
serverIp = dhcpPortData.get().getPortFixedip();
serverMacAddress = dhcpPortData.get().getPortMacaddress();
} else {
// DHCP Neutron Port not found for this network
LOG.error("Neutron DHCP port is not available for the Subnet {} and port {}.", subnet.getUuid(), port.getUuid());
return;
}
}
DHCP replyPkt = handleDhcpPacket(pktIn, interfaceName, macAddress, port, subnet, serverIp);
if (replyPkt == null) {
LOG.warn("Unable to construct reply packet for interface name {}", interfaceName);
return;
}
byte[] pktOut = getDhcpPacketOut(replyPkt, ethPkt, serverMacAddress);
sendPacketOut(pktOut, interfaceInfo.getDpId(), interfaceName, tunnelId);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project netvirt by opendaylight.
the class IngressAclServiceImpl method dropTrafficToDhcpServer.
/**
* Add rule to drop BUM traffic to DHCP Server.
*
* @param flowEntries the flow entries
* @param dpId the dpid
* @param lportTag the lport tag
* @param addOrRemove is write or delete
*/
protected void dropTrafficToDhcpServer(List<FlowEntity> flowEntries, Uint64 dpId, int lportTag, int addOrRemove) {
InstructionInfo writeMetatdata = AclServiceUtils.getWriteMetadataForDropFlag();
List<InstructionInfo> instructions = Lists.newArrayList(writeMetatdata);
instructions.addAll(AclServiceOFFlowBuilder.getGotoInstructionInfo(getAclCommitterTable()));
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(new NxMatchRegister(NxmNxReg6.class, MetaDataUtil.getLportTagForReg6(lportTag).longValue(), MetaDataUtil.getLportTagMaskForReg6()));
String flowName = "Ingress_DHCP_Service_" + dpId + "_" + lportTag + "_Drop";
addFlowEntryToList(flowEntries, dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_DHCP_SERVER_DROP_PRIORITY, 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server 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 flowEntries the flow entries
* @param port the Acl Interface port
* @param allowedAddresses the allowed addresses
* @param lportTag the lport tag
* @param addOrRemove whether to add or remove the flow
*/
private void egressAclDhcpv6AllowClientTraffic(List<FlowEntity> flowEntries, AclInterface port, List<AllowedAddressPairs> allowedAddresses, int lportTag, int addOrRemove) {
Uint64 dpId = Uint64.valueOf(port.getDpId());
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_";
addFlowEntryToList(flowEntries, dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY, 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnServerSessionManagerUnstarted.
/**
* Verify the PCEP session should not be up when server session manager is down,
* otherwise it would be a problem when the session is up while it's not registered with session manager.
*/
@Test
public void testOnServerSessionManagerUnstarted() throws InterruptedException, ExecutionException, TransactionCommitFailedException, ReadFailedException {
stopSessionManager();
assertFalse(this.session.isClosed());
this.listener.onSessionUp(this.session);
// verify the session was NOT added to topology
checkNotPresentOperational(getDataBroker(), TOPO_IID);
// verify the session is closed due to server session manager is closed
assertTrue(this.session.isClosed());
// send request
final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
final AddLspOutput output = futureOutput.get().getResult();
// deal with unsent request after session down
assertEquals(FailureType.Unsent, output.getFailure());
}
Aggregations