Committed by
Gerrit Code Review
ONOS-367 FIxed a defect of missing links & ports
Change-Id: I4ac99fc06cf5711b0270d6e3043eb6dfb2063ec1
Showing
2 changed files
with
11 additions
and
5 deletions
| ... | @@ -33,6 +33,7 @@ import org.projectfloodlight.openflow.protocol.OFFeaturesReply; | ... | @@ -33,6 +33,7 @@ import org.projectfloodlight.openflow.protocol.OFFeaturesReply; |
| 33 | import org.projectfloodlight.openflow.protocol.OFMessage; | 33 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 34 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 34 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
| 35 | import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; | 35 | import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; |
| 36 | +import org.projectfloodlight.openflow.protocol.OFPortStatus; | ||
| 36 | import org.projectfloodlight.openflow.protocol.OFRoleReply; | 37 | import org.projectfloodlight.openflow.protocol.OFRoleReply; |
| 37 | import org.projectfloodlight.openflow.protocol.OFVersion; | 38 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 38 | import org.slf4j.Logger; | 39 | import org.slf4j.Logger; |
| ... | @@ -166,7 +167,7 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { | ... | @@ -166,7 +167,7 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { |
| 166 | */ | 167 | */ |
| 167 | @Override | 168 | @Override |
| 168 | public final void handleMessage(OFMessage m) { | 169 | public final void handleMessage(OFMessage m) { |
| 169 | - if (this.role == RoleState.MASTER) { | 170 | + if (this.role == RoleState.MASTER || m instanceof OFPortStatus) { |
| 170 | this.agent.processMessage(dpid, m); | 171 | this.agent.processMessage(dpid, m); |
| 171 | } | 172 | } |
| 172 | } | 173 | } | ... | ... |
| ... | @@ -265,7 +265,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -265,7 +265,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { |
| 265 | @Override | 265 | @Override |
| 266 | void processOFPortStatus(OFChannelHandler h, OFPortStatus m) | 266 | void processOFPortStatus(OFChannelHandler h, OFPortStatus m) |
| 267 | throws IOException { | 267 | throws IOException { |
| 268 | - unhandledMessageReceived(h, m); | 268 | + h.pendingPortStatusMsg.add(m); |
| 269 | } | 269 | } |
| 270 | }, | 270 | }, |
| 271 | 271 | ||
| ... | @@ -313,7 +313,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -313,7 +313,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { |
| 313 | @Override | 313 | @Override |
| 314 | void processOFPortStatus(OFChannelHandler h, OFPortStatus m) | 314 | void processOFPortStatus(OFChannelHandler h, OFPortStatus m) |
| 315 | throws IOException, SwitchStateException { | 315 | throws IOException, SwitchStateException { |
| 316 | - unhandledMessageReceived(h, m); | 316 | + h.pendingPortStatusMsg.add(m); |
| 317 | 317 | ||
| 318 | } | 318 | } |
| 319 | }, | 319 | }, |
| ... | @@ -438,6 +438,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -438,6 +438,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { |
| 438 | if (!h.sw.connectSwitch()) { | 438 | if (!h.sw.connectSwitch()) { |
| 439 | disconnectDuplicate(h); | 439 | disconnectDuplicate(h); |
| 440 | } | 440 | } |
| 441 | + handlePendingPortStatusMessages(h); | ||
| 441 | h.setState(ACTIVE); | 442 | h.setState(ACTIVE); |
| 442 | } else { | 443 | } else { |
| 443 | h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE); | 444 | h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE); |
| ... | @@ -528,6 +529,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -528,6 +529,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { |
| 528 | 529 | ||
| 529 | private void moveToActive(OFChannelHandler h) { | 530 | private void moveToActive(OFChannelHandler h) { |
| 530 | boolean success = h.sw.connectSwitch(); | 531 | boolean success = h.sw.connectSwitch(); |
| 532 | + handlePendingPortStatusMessages(h); | ||
| 531 | h.setState(ACTIVE); | 533 | h.setState(ACTIVE); |
| 532 | if (!success) { | 534 | if (!success) { |
| 533 | disconnectDuplicate(h); | 535 | disconnectDuplicate(h); |
| ... | @@ -602,7 +604,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -602,7 +604,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { |
| 602 | void processOFPortStatus(OFChannelHandler h, OFPortStatus m) | 604 | void processOFPortStatus(OFChannelHandler h, OFPortStatus m) |
| 603 | throws SwitchStateException { | 605 | throws SwitchStateException { |
| 604 | handlePortStatusMessage(h, m, true); | 606 | handlePortStatusMessage(h, m, true); |
| 605 | - h.dispatchMessage(m); | 607 | + //h.dispatchMessage(m); |
| 606 | } | 608 | } |
| 607 | 609 | ||
| 608 | @Override | 610 | @Override |
| ... | @@ -765,15 +767,18 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -765,15 +767,18 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { |
| 765 | "happen"; | 767 | "happen"; |
| 766 | throw new SwitchStateException(msg); | 768 | throw new SwitchStateException(msg); |
| 767 | } | 769 | } |
| 770 | + log.info("Processing {} pending port status messages for {}", | ||
| 771 | + h.pendingPortStatusMsg.size(), h.sw.getStringId()); | ||
| 772 | + | ||
| 768 | ArrayList<OFPortStatus> temp = new ArrayList<OFPortStatus>(); | 773 | ArrayList<OFPortStatus> temp = new ArrayList<OFPortStatus>(); |
| 769 | for (OFPortStatus ps: h.pendingPortStatusMsg) { | 774 | for (OFPortStatus ps: h.pendingPortStatusMsg) { |
| 770 | temp.add(ps); | 775 | temp.add(ps); |
| 771 | handlePortStatusMessage(h, ps, false); | 776 | handlePortStatusMessage(h, ps, false); |
| 772 | } | 777 | } |
| 773 | - temp.clear(); | ||
| 774 | // expensive but ok - we don't expect too many port-status messages | 778 | // expensive but ok - we don't expect too many port-status messages |
| 775 | // note that we cannot use clear(), because of the reasons below | 779 | // note that we cannot use clear(), because of the reasons below |
| 776 | h.pendingPortStatusMsg.removeAll(temp); | 780 | h.pendingPortStatusMsg.removeAll(temp); |
| 781 | + temp.clear(); | ||
| 777 | // the iterator above takes a snapshot of the list - so while we were | 782 | // the iterator above takes a snapshot of the list - so while we were |
| 778 | // dealing with the pending port-status messages, we could have received | 783 | // dealing with the pending port-status messages, we could have received |
| 779 | // newer ones. Handle them recursively, but break the recursion after | 784 | // newer ones. Handle them recursively, but break the recursion after | ... | ... |
-
Please register or login to post a comment