Returns True if the value passed is a valid netmask, otherwise return False

def netmask(mask):
    '''
    Returns True if the value passed is a valid netmask, otherwise return False
    '''
    if not isinstance(mask, string_types):
        return False

    octets = mask.split('.')
    if not len(octets) == 4:
        return False

    return ipv4_addr(mask) and octets == sorted(octets, reverse=True)