Simplify and improve device detection (support subinterfaces)

The current logic does not properly handle sub-interfaces like those used for VLAN tagging, due to the way ip displays these by default. This patch seems to to both simplify the logic here and fix this problem.