Search in sources :

Example 11 with Server

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 testOnServerSessionManagerRestartAndSessionRecovery.

@Test
public void testOnServerSessionManagerRestartAndSessionRecovery() throws Exception {
    // close server session manager first
    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());
    // PCC client is not there
    checkNotPresentOperational(getDataBroker(), this.pathComputationClientIId);
    // reset received message queue
    this.receivedMsgs.clear();
    // now we restart the session manager
    startSessionManager();
    // try to start the session again
    // notice since the session was terminated before, it is not usable anymore.
    // we need to get a new session instance. the new session will have the same local / remote preference
    this.session = getPCEPSession(getLocalPref(), getRemotePref());
    assertFalse(this.session.isClosed());
    this.listener.onSessionUp(this.session);
    assertFalse(this.session.isClosed());
    // create node
    this.topologyRpcs.addLsp(createAddLspInput());
    final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
    final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
    final long srpId = req.getSrp().getOperationId().getValue();
    final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
    this.listener.onMessage(this.session, pcRpt);
    readDataOperational(getDataBroker(), TOPO_IID, topology -> {
        assertEquals(1, topology.getNode().size());
        return topology;
    });
}
Also used : AddLspOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests) Pcinitiate(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate) Test(org.junit.Test)

Example 12 with Server

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 testOnServerSessionManagerDown.

/**
 * All the pcep session registration should be closed when the session manager is closed.
 */
@Test
public void testOnServerSessionManagerDown() throws InterruptedException, ExecutionException, TransactionCommitFailedException {
    this.listener.onSessionUp(this.session);
    // the session should not be closed when session manager is up
    assertFalse(this.session.isClosed());
    // send request
    final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
    stopSessionManager();
    final AddLspOutput output = futureOutput.get().getResult();
    // deal with unsent request after session down
    assertEquals(FailureType.Unsent, output.getFailure());
    // verify the session is closed after server session manager is closed
    assertTrue(this.session.isClosed());
}
Also used : AddLspOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 13 with Server

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 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 14 with Server

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.server.config.Server in project openflowplugin by opendaylight.

the class SwitchConnectionProviderImpl method createAndConfigureServer.

private ServerFacade createAndConfigureServer() {
    LOG.debug("Configuring ..");
    ServerFacade server = null;
    final ChannelInitializerFactory factory = new ChannelInitializerFactory();
    factory.setSwitchConnectionHandler(switchConnectionHandler);
    factory.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout());
    factory.setTlsConfig(connConfig.getTlsConfiguration());
    factory.setSerializationFactory(serializationFactory);
    factory.setDeserializationFactory(deserializationFactory);
    factory.setUseBarrier(connConfig.useBarrier());
    factory.setChannelOutboundQueueSize(connConfig.getChannelOutboundQueueSize());
    final TransportProtocol transportProtocol = (TransportProtocol) connConfig.getTransferProtocol();
    // Check if Epoll native transport is available.
    // TODO : Add option to disable Epoll.
    boolean isEpollEnabled = Epoll.isAvailable();
    if (TransportProtocol.TCP.equals(transportProtocol) || TransportProtocol.TLS.equals(transportProtocol)) {
        server = new TcpHandler(connConfig.getAddress(), connConfig.getPort());
        final TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer();
        ((TcpHandler) server).setChannelInitializer(channelInitializer);
        ((TcpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
        final EventLoopGroup workerGroupFromTcpHandler = ((TcpHandler) server).getWorkerGroup();
        connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler, isEpollEnabled);
        connectionInitializer.setChannelInitializer(channelInitializer);
        connectionInitializer.run();
    } else if (TransportProtocol.UDP.equals(transportProtocol)) {
        server = new UdpHandler(connConfig.getAddress(), connConfig.getPort());
        ((UdpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
        ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer());
    } else {
        throw new IllegalStateException("Unknown transport protocol received: " + transportProtocol);
    }
    server.setThreadConfig(connConfig.getThreadConfiguration());
    return server;
}
Also used : EventLoopGroup(io.netty.channel.EventLoopGroup) TransportProtocol(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol)

Example 15 with Server

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 allowIcmpTrafficToDhcpServer.

/**
 * Add rules to allow ICMP traffic for DHCP server.
 * @param flowEntries the flow entries
 * @param port the Acl Interface port
 * @param allowedAddresses the allowed addresses
 * @param addOrRemove the lport tag
 */
protected void allowIcmpTrafficToDhcpServer(List<FlowEntity> flowEntries, AclInterface port, List<AllowedAddressPairs> allowedAddresses, int addOrRemove) {
    Uint64 dpId = Uint64.valueOf(port.getDpId());
    int lportTag = port.getLPortTag();
    for (AllowedAddressPairs allowedAddress : allowedAddresses) {
        if (AclServiceUtils.isIPv4Address(allowedAddress)) {
            MatchInfo reqMatchInfo = new MatchIcmpv4((short) AclConstants.ICMPV4_TYPE_ECHO_REQUEST, (short) 0);
            programIcmpFlow(flowEntries, dpId, lportTag, allowedAddress, MatchIpProtocol.ICMP, reqMatchInfo, AclConstants.ICMPV4_TYPE_ECHO_REQUEST, addOrRemove);
            MatchInfo replyMatchInfo = new MatchIcmpv4((short) AclConstants.ICMPV4_TYPE_ECHO_REPLY, (short) 0);
            programIcmpFlow(flowEntries, dpId, lportTag, allowedAddress, MatchIpProtocol.ICMP, replyMatchInfo, AclConstants.ICMPV4_TYPE_ECHO_REPLY, addOrRemove);
        } else {
            MatchInfo reqMatchInfo = new MatchIcmpv6((short) AclConstants.ICMPV6_TYPE_ECHO_REQUEST, (short) 0);
            programIcmpFlow(flowEntries, dpId, lportTag, allowedAddress, MatchIpProtocol.ICMPV6, reqMatchInfo, AclConstants.ICMPV6_TYPE_ECHO_REQUEST, addOrRemove);
            MatchInfo replyMatchInfo = new MatchIcmpv6((short) AclConstants.ICMPV6_TYPE_ECHO_REPLY, (short) 0);
            programIcmpFlow(flowEntries, dpId, lportTag, allowedAddress, MatchIpProtocol.ICMPV6, replyMatchInfo, AclConstants.ICMPV6_TYPE_ECHO_REPLY, addOrRemove);
        }
    }
}
Also used : MatchIcmpv4(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv4) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchIcmpv6(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv6) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)5 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)5 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)5 MatchEthernetSource (org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource)4 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)4 AddLspOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput)3 AddLspOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.AddLspOutput)3 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)2 AsId (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.AsId)2 GracefulRestart (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.GracefulRestart)2 Logging (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Logging)2 Multipath (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.multipathcontainer.Multipath)2 MultipathKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.multipathcontainer.MultipathKey)2 Neighbors (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.Neighbors)2 NeighborsKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.NeighborsKey)2 Networks (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.Networks)2 NetworksKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey)2