Beispiel #1
0
/* ------------------------------------------------------------ */
int ipvsfuncs_del_dest_entry(ipvs_service_t *svc, struct ip_vs_dest_entry *de) {
    int ret;
    ipvs_dest_t dest;

    memset(&dest, 0, sizeof(ipvs_dest_t));
    dest.addr.ip = de->addr.ip;
    dest.port = de->port;
    dest.conn_flags = de->conn_flags;
    dest.weight = de->weight;
    dest.u_threshold = de->u_threshold;
    dest.l_threshold = de->l_threshold;
    ret = ipvsfuncs_del_dest(svc, &dest);

    return ret;
}
Beispiel #2
0
static void diffs_apply_change_real(Config *conf, GHashTable *ht, gchar *line, gboolean sync_to_ipvs) {
    ConfVirtual    *cv;
    ConfReal       *cr;
    gint            cvindex;
    gint            crindex;
    ipvs_service_t  svc;
    ipvs_dest_t     dest;
    gchar          *cmd;
    gint            ret;
    gboolean        addflag = FALSE;

    LOGDEBUG("*** diffs apply change real ***");

    /* Fill svc and dst */
    ret = ipvsfuncs_set_svc_from_ht(&svc, ht);
    if (!ret) {
        LOGERROR("Can't parse svc in change real line [%s]", line);
        return;
    }

    cv = config_find_virtual(conf, &svc, &cvindex);
    if (!cv) {
        LOGWARN("Can't find virtual [%s]", line);
        return;
    }

    ret = ipvsfuncs_set_dest_from_ht(&dest, ht, cv->conn_flags);
    if (!ret) {
        LOGERROR("Can't parse dest in change real line [%s]", line);
        return;
    }

    /* need to known cmd - because after delreal it will not be in ConfVirtual */
    cmd = g_hash_table_lookup(ht, "cmd");
    if (!cmd) {
        LOGERROR("cmd lookup error");
        return;
    }
    if (!strcmp(cmd, "addreal"))
        addflag = TRUE;

    cr = config_find_real(cv, &dest, &crindex);
    if (!cr && !addflag) {
        LOGWARN("Can't find real [%s]", line);
        return;
    }

    /* Ok, here we have 'svc' and 'dest' which points to real or addflag is set */
    if (!strcmp(cmd, "chgreal")) {
        LOGINFO("* CHGREAL [%s]", line);
        if (sync_to_ipvs) //at ipvssync starts apply diffs only to configuration
            ipvsfuncs_update_dest(&svc, &dest);
        cr->dest = dest;
    }
    else if (!strcmp(cmd, "delreal")) {
        LOGINFO("* DELREAL [%s]", line);
        if (sync_to_ipvs)
            ipvsfuncs_del_dest(&svc, &dest);
        config_remove_real_by_index(cv, crindex);
    }
    else if (!strcmp(cmd, "addreal")) {
        LOGINFO("* ADDREAL [%s]", line);
        if (cr)
            LOGINFO("** real already exists, skipping adding to ipvs");
        else {
            if (sync_to_ipvs)
                ipvsfuncs_add_dest(&svc, &dest);
            config_add_real(conf, cv, ht);
        }
    }
}