Ask is moving to Stack Overflow and Serverfault.com! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode

0

Flow not installed in switch.

asked 2017-09-14 11:45:12 -0800

Hello,

I use the following code snippet to install a flow in a switch:

  FlowEntityBuilder flowEntityBuilder = new FlowEntityBuilder();
flowEntityBuilder.setTableId(tableId)
    .setDpnId(dpnId)
    .setFlowId(FlowUtils.createFlowId().toString())
    .setFlowName("gotoTable1");

MatchInfo matchInfo = new MatchEthernetSource(macAddress);


InstructionInfo instructionInfo = new InstructionGotoTable(tableId);
FlowEntity flowEntity = flowEntityBuilder.addInstructionInfoList(instructionInfo).addMatchInfoList(matchInfo).build();
mdsalApiManager.installFlow(dpnId,flowEntity);

I connect with mininet but when I go to look at the flow, I do not see anything. No execptions thrown. How can I debug such problems? Any pointers appreciated. Thanks

edit retag flag offensive close merge delete

Comments

Can you check your config datastore for the flow entry?

sunilkumarms ( 2017-09-14 22:14:13 -0800 )edit

I'm not used to these plugins. I use SalFlowService (examples exist on l2switch). Is MdsalApiManager quite different?

VincentJahjah ( 2017-09-15 05:11:38 -0800 )edit

@sunilkumarms How can I check the config datastore ? I am just getting into this so any pointers appreciated. Thank you.

mranga ( 2017-09-16 15:33:39 -0800 )edit

use the REST URL http://<controller_ip_address>:<controller_port>/restconf/config/opendaylight-inventory:nodes from any of the rest client to get the output and also capture packets between controller and mininet using wireshark

sunilkumarms ( 2017-09-20 00:29:11 -0800 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-09-16 17:13:20 -0800

After some hacking, I finally got it to work. Here's what I had to do:

In my provider I have :

    public SdnmudProvider(final DataBroker dataBroker, SalFlowService flowService,
        PacketProcessingService packetProcessingService, NotificationService notificationService,
        IMdsalApiManager mdsalApiManager) {
    this.dataBroker = dataBroker;
    this.flowService = flowService;
    this.packetProcessingService = packetProcessingService;
    this.notificationService = notificationService;
    this.mdsalApiManager = mdsalApiManager;

}

 private static InstanceIdentifier<?> getWildcardPath() {
      return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
  }



         /**
         * Method called when the blueprint container is created.
         */
public void init() {
    LOG.info("SdnmudProvider Session Initiated");
    FlowCommitWrapper flowCommitWrapper = new FlowCommitWrapper(dataBroker, mdsalApiManager, flowService);
    SdnMudHandler sdnMudHandler = new SdnMudHandler(flowCommitWrapper);
    WakeupOnFlowCapableNode wakeupListener = new WakeupOnFlowCapableNode(sdnMudHandler);

    final InstanceIdentifier<Table> instanceIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class)
            .augmentation(FlowCapableNode.class).child(Table.class).build();

    final DataTreeIdentifier<FlowCapableNode> dataTreeIdentifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, getWildcardPath());


    this.dataTreeChangeListenerRegistration = this.dataBroker.registerDataTreeChangeListener(dataTreeIdentifier,
            wakeupListener);


    this.notificationService.registerNotificationListener(
            new PacketInDispatcherImpl(sdnMudHandler, mdsalApiManager, flowCommitWrapper));

    LOG.info("start() <--");

}

The key seems to be to generate the right DataTreeIdentifier.

Then I install the flow using the following when the switch appears.

      public void writeFlow(FlowBuilder flow, InstanceIdentifier<FlowCapableNode> flowNodeIdent) {

    ReadWriteTransaction modification = dataBrokerService.newReadWriteTransaction();
    final InstanceIdentifier<Flow> path1 = flowNodeIdent.child(Table.class, new TableKey(flow.getTableId()))
            .child(Flow.class, flow.getKey());
    modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
    CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
    Futures.addCallback(commitFuture, new FutureCallback<Void>() {
        @Override
        public void onSuccess(Void aVoid) {
            LOG.debug("Write of flow on device succeeded.");
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.error("Write of flow on device failed.", throwable);
        }
    });

}

Later when a packet arrives, I use this method to install other flows.

A bit verbose but it works (for now).

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2017-09-14 11:45:12 -0800

Seen: 33 times

Last updated: Sep 16