def mask_to_cidr(mask):
    """
    Determine the CIDR suffix for a given dotted decimal IPv4 netmask.
    """
    # convert netmask to 32 binary digits
    tmp = "".join([format(int(x), "08b") for x in mask.split(".")])
    # count leading ones
    return len(tmp) - len(tmp.lstrip("1"))