From af90c193ecd7e41a738892f8e70accd0086dbb85 Mon Sep 17 00:00:00 2001 From: Jason Ye Date: Sun, 12 May 2013 12:09:52 -0700 Subject: [PATCH 1/1] - Discard discovery packet if the ingress port is down - SwitchManager osgi cmds are useful tools for debugging. But the input node id currently has to be in long format. Change it to take node id string. Example: pncs "OF|00:01:44:03:a7:7a:54:e0" Signed-off-by: Jason Ye --- .../openflow/internal/DiscoveryService.java | 10 +++-- .../internal/SwitchManagerImpl.java | 40 +++++++++++++------ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java index afc5b8c825..0cbaf67d9e 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java @@ -294,11 +294,13 @@ public class DiscoveryService implements IInventoryShimExternalListener, } if (ethPkt.getPayload() instanceof LLDP) { NodeConnector dst = inPkt.getIncomingNodeConnector(); - if (!processDiscoveryPacket(dst, ethPkt)) { - /* Snoop the discovery pkt if not generated from us */ - snoopDiscoveryPacket(dst, ethPkt); + if (isEnabled(dst)) { + if (!processDiscoveryPacket(dst, ethPkt)) { + /* Snoop the discovery pkt if not generated from us */ + snoopDiscoveryPacket(dst, ethPkt); + } + return PacketResult.CONSUME; } - return PacketResult.CONSUME; } return PacketResult.IGNORED; } diff --git a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java index 79159e5ff1..4ef8416436 100644 --- a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java +++ b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java @@ -1479,9 +1479,13 @@ public class SwitchManagerImpl implements ISwitchManager, ci.println("Please enter node id"); return; } - Long id = Long.decode(st); - Node node = NodeCreator.createOFNode(id); + Node node = Node.fromString(st); + if (node == null) { + ci.println("Please enter node id"); + return; + } + Set nodeConnectorSet = getUpNodeConnectors(node); if (nodeConnectorSet == null) { return; @@ -1501,10 +1505,14 @@ public class SwitchManagerImpl implements ISwitchManager, ci.println("Please enter node id"); return; } - Long id = Long.decode(st); + + Node node = Node.fromString(st); + if (node == null) { + ci.println("Please enter node id"); + return; + } ci.println(" NodeConnector BandWidth(Gbps) Admin State"); - Node node = NodeCreator.createOFNode(id); Set nodeConnectorSet = getNodeConnectors(node); if (nodeConnectorSet == null) { return; @@ -1534,8 +1542,14 @@ public class SwitchManagerImpl implements ISwitchManager, ci.println("Please enter node id"); return; } - Object id = Long.decode(st); - Switch sw = getSwitchByNode(NodeCreator.createOFNode((Long) id)); + + Node node = Node.fromString(st); + if (node == null) { + ci.println("Please enter node id"); + return; + } + + Switch sw = getSwitchByNode(node); ci.println(" NodeConnector Name"); if (sw == null) { @@ -1549,10 +1563,9 @@ public class SwitchManagerImpl implements ISwitchManager, nodeConnectorName = (propMap == null) ? null : ((Name) propMap .get(Name.NamePropName)).getValue(); if (nodeConnectorName != null) { - Node node = nodeConnector.getNode(); - if (!node.equals(getNode((Long) id))) { - log.debug("node not match {} {}", node, - getNode((Long) id)); + Node nd = nodeConnector.getNode(); + if (!nd.equals(node)) { + log.debug("node not match {} {}", nd, node); } Map map = nodeConnectorNames .get(node); @@ -1584,9 +1597,12 @@ public class SwitchManagerImpl implements ISwitchManager, ci.println("Please enter node id"); return; } - Long id = Long.decode(st); - Node node = NodeCreator.createOFNode(id); + Node node = Node.fromString(st); + if (node == null) { + ci.println("Please enter node id"); + return; + } st = ci.nextArgument(); if (st == null) { -- 2.36.6