Loop Detection

Hi,

I'm a newbie in OpenWrt and am trying to find out the existing package/configuration that support to detect network loop for following case:
image
(Directly connect 2 ports of a router together)

Would someone help?
Thanks.

Loop detection is often done with STP, which is a feature of the Linux networking stack and many non-SOHO switches and routers. It can be enabled through LuCI for a switch/bridge, or through UCI directly.

See, for example, https://en.wikipedia.org/wiki/Spanning_Tree_Protocol

Some (many? most?) inexpensive SOHO switches and routers don't implement STP. This might be because loop topologies usually happen with multiple devices involved, where the loop isn't obvious by inspection.

Thanks @jeff ,

As I understand about the STP, it will detect the loop and prevent router from the broadcast storm.
And we can enable STP by adding option stp '1' to the bridge interface (/etc/config/network).
But when the loop occurs, how do I aware of this? It seems STP doesn't provide API e.g. alert looping status. Is my understanding correct?

I would like to create an app that able to detect this network looping then can do actions accordingly e.g. do reset the router when it occurs and record to the event log .

Personally, I wouldn't spend time to develop a custom monitoring solution to fix a problem that shouldn't exist. Unless you've got people constantly plugging in cables to other switches/hubs, it should be a once-only thing, at most.

If STP is in a situation where the topology isn't wildly broken, it will just work. If not, you'll generally lose network connectivity.

If you are in some situation where things aren't well controlled, SNMP is often used to report to a central location. On Linux, you could monitor events. How that would be done will depend on the type of bridge (software, hardware, DSA, ...). I don't have further information on that.