That's a certainly a generic function that is needed.
Can we leave the vlan/lagg implementation logic inside appropriate modules and avoid polluting if.c?
For example, can we hide the appropriate chunks into function like vlan_get_parent(ifp) and lagg_is_parent_of(ifp) with these functions residing in if_vlan.c and if_lagg.c?