<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def modify_ip_prefixes( config, config_file, variable_name, dummy_ip_prefix, reconfigure_cmd, keep_changes, changes_counter, ip_version):
 """Modify IP prefixes in Bird configuration. Depending on the configuration either removes or reports IP prefixes found in Bird configuration for which we don't have a service check associated with them. Moreover, it adds the dummy IP prefix if it isn't present and ensures that the correct variable name is set. Arguments: config (obg):
 A configparser object which holds our configuration. config_file (str):
 The file name of bird configuration variable_name (str):
 The name of the variable set in bird configuration dummy_ip_prefix (str):
 The dummy IP prefix, which must be always reconfigure_cmd (str):
 The command to run to trigger a reconfiguration on Bird daemon upon successful configuration update keep_changes (boolean):
 To enable keeping a history of changes applied to bird configuration changes_counter (int):
 The number of configuration changes to keep ip_version (int):
 IP protocol version of Bird configuration """

    log = logging.getLogger(PROGRAM_NAME)
    services = config.sections()
    services.remove('daemon')  # not needed during sanity check for IP-Prefixes
    update_bird_conf = False
    try:
        ip_prefixes_in_bird = get_ip_prefixes_from_bird(config_file)
    except OSError as error:
        log.error("failed to open Bird configuration %s, this is a FATAL "
                  "error, thus exiting main program", error)
        sys.exit(1)

    _name = get_variable_name_from_bird(config_file)
    if _name is None:
        log.warning("failed to find variable name in %s, going to add it",
                    config_file)
        update_bird_conf = True
    elif _name != variable_name:
        log.warning("found incorrect variable name in %s, going to add the "
                    "correct one %s", _name, variable_name)
        update_bird_conf = True

    if dummy_ip_prefix not in ip_prefixes_in_bird:
        log.warning("dummy IP prefix %s is missing from bird configuration "
                    "%s, adding it", dummy_ip_prefix, config_file)
        ip_prefixes_in_bird.insert(0, dummy_ip_prefix)
        update_bird_conf = True

    # Find IP prefixes in Bird configuration without a check.
    ip_prefixes_with_check = get_ip_prefixes_from_config(
        config,
        services,
        ip_version)
    # dummy_ip_prefix doesn't have a config by design
    ip_prefixes_with_check.add(dummy_ip_prefix)

    ip_prefixes_without_check = set(ip_prefixes_in_bird).difference(
        ip_prefixes_with_check)

    if ip_prefixes_without_check:
        if config.getboolean('daemon', 'purge_ip_prefixes'):
            log.warning("removing IP prefix(es) %s from %s because they don't "
                        "have a service check configured",
                        ','.join(ip_prefixes_without_check),
                        config_file)
            ip_prefixes_in_bird[:] = (ip for ip in ip_prefixes_in_bird
                                      if ip not in ip_prefixes_without_check)
            update_bird_conf = True
        else:
            log.warning("found IP prefixes %s in %s without a service "
                        "check configured",
                        ','.join(ip_prefixes_without_check),
                        config_file)

    if update_bird_conf:
        if keep_changes:
            archive_bird_conf(config_file, changes_counter)
        tempname = write_temp_bird_conf(
            dummy_ip_prefix,
            config_file,
            variable_name,
            ip_prefixes_in_bird
        )
        try:
            os.rename(tempname, config_file)
        except OSError as error:
            msg = ("CRITICAL: failed to create Bird configuration {e}, "
                   "this is FATAL error, thus exiting main program"
                   .format(e=error))
            sys.exit("{m}".format(m=msg))
        else:
            log.info("Bird configuration for IPv%s is updated", ip_version)
            reconfigure_bird(reconfigure_cmd)