At layer 2 of the OSI model, we have very little to work with when it comes to forwarding data—essentially just the MAC address. And yet in layer 2 switching, functions including address learning, forwarding vs. filtering decision making, and loop avoidance can be taken. Obviously there are some clever things going on.
Forwarding and filtering is, of course, managed using the bridging (switching) table, constructed by reading source MAC addresses as frames are passed through the switch. This is very similar to legacy bridging, apart from the fact that multi-port switches support micro- segmentation, and have several ways of forwarding frames, including store-and-forward, cut- through, and FragmentFree switching.
Additional links can be implemented to provide redundancy in a network; however, these redundant links can introduce problems such as broadcast storms, multiple frame copies, and multiple loops. The Spanning Tree Protocol can be used to break network loops by forcing some switches to place some of their ports into a blocking mode. This is effected by having one bridge assume a sort of control—the root—and other switches calculating the shortest distance to the root, thus allowing the loop to be seen and broken.