import re


def _parse_head(line):
    """
    Parse the line of `ip addr show` that contains the interface name, MTU, and
    flags.
    """
    retval = {}
    m = re.match(
        '[0-9]+: (?P<if>\w+\d{1,3}): <(?P<flags>[^>]+)> mtu (?P<mtu>[0-9]+)',
        line
    )
    if m:
        retval['ifname'] = m.group('if')
        retval['mtu'] = int(m.group('mtu'))
        retval['flags'] = m.group('flags').split(',')
    return retval