Ejemplo n.º 1
0
/* ------------------------------------------------------------ */
int ipvsfuncs_fprintf_ipvs(FILE *f) {
	int i, j;

	struct ip_vs_service_entry *se;
	struct ip_vs_dest_entry *de;
	struct ip_vs_get_services *vs = ipvs_get_services();
	
	for (i = 0; i < vs->num_services; i++) {
		se = &vs->entrytable[i];
		struct ip_vs_get_dests *vd = ipvs_get_dests(se);
        if (!vd)
            continue;
		fprintf(f, " svc dest [%d], ip=%x, port=%d, fwmark=%d, proto=%d\n", 
				i, ntohl(se->addr.ip), ntohs(se->port), se->fwmark, se->protocol);
		for (j = 0; j < se->num_dests; j++) {
			de = &vd->entrytable[j];
			fprintf(f, "  dest [%d], ip=%x, port=%d, weight=%d\n", 
					j, ntohl(de->addr.ip), ntohs(de->port), de->weight);
		}
		free(vd);		
	}
	free(vs);

	return 0;
}
Ejemplo n.º 2
0
static void cipvs_submit_service (struct ip_vs_service_entry *se)
{
	struct ip_vs_stats_user  stats = se->stats;
	struct ip_vs_get_dests  *dests = ipvs_get_dests (se);

	char pi[DATA_MAX_NAME_LEN];

	size_t i;

	if (0 != get_pi (se, pi, sizeof (pi)))
	{
		free (dests);
		return;
	}

	cipvs_submit_connections (pi, NULL, stats.conns);
	cipvs_submit_if (pi, "if_packets", NULL, stats.inpkts, stats.outpkts);
	cipvs_submit_if (pi, "if_octets", NULL, stats.inbytes, stats.outbytes);

	for (i = 0; i < dests->num_dests; ++i)
		cipvs_submit_dest (pi, &dests->entrytable[i]);

	free (dests);
	return;
} /* cipvs_submit_service */
Ejemplo n.º 3
0
/* args:
   - svc          - service 
   - managed_dest - pointer to dest table
   - is_in_ipvs   - function stores status is a real defined in ipvs 
                    (status is saved here only if (is_in_ipvs != NULL)
*/
int ipvsfuncs_del_unmanaged_dests(ipvs_service_t *svc,
								  ipvs_dest_t **managed_dest, gint *is_in_ipvs) {
	int i, idx, found;
	ipvs_dest_t **m;

	ipvs_service_entry_t *se = ipvs_get_service(svc->fwmark, AF_INET, 
												svc->protocol, 
												svc->addr, 
												svc->port);

	if (!se) 
		return 0;

	struct ip_vs_dest_entry *de;
	struct ip_vs_get_dests *vd = ipvs_get_dests(se);

	if (!vd)
		return 0;
	
	for (i = 0; i < vd->num_dests; i++) {
		de = &vd->entrytable[i];
		m = managed_dest;
		found = 0;
		idx = 0;
		while (*m) {
			if ((*m)->addr.ip == de->addr.ip && 
				(*m)->port == de->port) {
				found = 1;
				if (is_in_ipvs)
					is_in_ipvs[idx] = 1;
				break;
			}
			m++;
			idx++;
		}

		if (!found){
                       LOGDEBUG("Delete unmanaged dest: ip=%s, port=%d", 
                           INETTXTADDR(de->addr.ip), ntohs(de->port));
		       ipvsfuncs_del_dest_entry(svc, (struct ip_vs_dest_entry *) de);
                }
	}
	free(vd);
	free(se);

	return 0;
}