  We present Contra, a system for performance-aware routing that can adapt to
traffic changes at hardware speeds. While existing work has developed point
solutions for performance-aware routing on a fixed topology (e.g., a Fattree)
with a fixed routing policy (e.g., use least utilized paths), Contra can be
configured to operate seamlessly over any network topology and a wide variety
of sophisticated routing policies. Users of Contra write network-wide policies
that rank network paths given their current performance. A compiler then
analyzes such policies in conjunction with the network topology and decomposes
them into switch-local P4 programs, which collectively implement a new,
specialized distance-vector protocol. This protocol generates compact probes
that traverse the network, gathering path metrics to optimize for the user
policy dynamically. Switches respond to changing network conditions at hardware
speeds by routing flowlets along the best policy-compliant paths. Our
experiments show that Contra scales to large networks, and that in terms of
flow completion times, it is competitive with hand-crafted systems that have
been customized for specific topologies and policies.
