ilbd.h revision dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ILBD_H
#define _ILBD_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <ucred.h>
#include <pwd.h>
#include <priv.h>
#include <stdarg.h>
#include <syslog.h>
#include <libscf.h>
#include <libintl.h>
#include <locale.h>
#include <libinetutil.h>
#include <auth_list.h>
#include <bsm/adt_event.h>
#define SGNAME_SZ 80
#define ILB_FMRI "svc:/network/loadbalancer/ilb:default"
#define HC_ACTION ILB_SRV_DISABLED_HC
#define ADMIN_ACTION ILB_SRV_DISABLED_ADMIN
/* Max name and value length for scf properties */
/* Different events ILBD is interested in. */
typedef enum {
ILBD_EVENT_NEW_REQ, /* New client request */
ILBD_EVENT_REQ, /* Client request comes in */
ILBD_EVENT_REP_OK, /* Reply channel to client is writeable */
ILBD_EVENT_PROBE, /* A HC returns some result */
ILBD_EVENT_TIMER /* ilbd_timer_q fired */
} ilbd_event_t;
typedef enum {
ILBD_SCF_RULE, /* prop group for rules */
ILBD_SCF_SG, /* prop group for servergroups */
ILBD_SCF_HC /* prop group for healthchecks */
typedef enum {
typedef enum {
ILBD_STRING, /* string */
ILBD_INT, /* int */
ILBD_ADDR_V4, /* ipv4 addr */
ILBD_ADDR_V6 /* ipv6 addr */
typedef enum {
/*
* All user struct pointer passed to port_associate() should have the first
* field as ilbd_event_t. The following struct can be used to find the
* event.
*/
typedef struct {
typedef struct {
typedef struct ilbd_srv {
} ilbd_srv_t;
#define MAX_SRVCOUNT 1000
#define BAD_SRVID (-1)
typedef struct ilbd_sg {
char isg_name[ILB_SGNAME_SZ];
} ilbd_sg_t;
typedef struct ilbd_rule {
} ilbd_rule_t;
/*
* Health check related definitions
*/
/* Default health check probe program provided */
/* Command name (argv[0]) passed to ilb_probe to indicate a ping test */
#define ILB_PROBE_PING "ilb_ping"
/* Use the first character of the rule's hcname to decide if rule has HC. */
/* Type of probe test */
typedef enum {
ILBD_HC_TCP, /* TCP connect probe */
ILBD_HC_UDP, /* UDP packet probe */
ILBD_HC_USER /* User supplied probe */
/* Struct representing a hc object in ilbd */
typedef struct {
/* Short hand for the fields inside ilb_hc_info_t */
int ihc_rule_cnt; /* Num of rules associated with hc */
} ilbd_hc_t;
struct ilbd_hc_srv_s;
/*
* Struct representing a hc rule object
*
* hcr_link: list linkage
* hcr_rule: pointer to the ilbd rule object
* hcr_servers: list of servers of this rule
*/
typedef struct {
ilbd_rule_t const *hcr_rule;
struct ilbd_hc_srv_s;
/*
* Struct representing a event of the probe process
*
* ihp_ev: the event type, which is ILBD_EVENT_PROBE
* ihp_srv: pointer to the hc server object
* ihp_pid: pid of the probe process
* ihp_done: is ilbd done reading the output of the probe process
*/
typedef struct {
struct ilbd_hc_srv_s *ihp_srv;
/*
* ilbd_hc_srv_t state
*
* ihd_hc_def_pinging: the default ping should be run
* ihd-hc_probing: the probe process should be started
*/
enum ilbd_hc_state {
};
/*
* Struct representing a server associated with a hc object
*
* shc_srv_link: list linkage
* shc_hc: pointer to the hc object
* shc_hc_rule: pointer to the hc rule object
* shc_sg_srv: pointer to the server group object
* shc_tid: timeout ID
* shc_cur_cnt: number of times the hc probe has been run
* shc_fail_cnt: number of consecutive probe failure
* shc_status: health status
* shc_rtt: rtt (in micro sec) to the backend server
* shc_lasttimer: last time a probe sequence is executed
* shc_nexttime: next time a probe sequence is executed
* shc_state: hc probe state
* shc_child_pid: pid of the probe process
* shc_child_fd: fd to the output of the probe process
* shc_ev: event object of the probe process
* shc_ev_port: event port of the event object
*/
typedef struct ilbd_hc_srv_s {
ilb_sg_srv_t const *shc_sg_srv;
enum ilbd_hc_state shc_state;
int shc_child_fd;
int shc_ev_port;
/*
* Structure for holding audit server and servergroup event
* data. Not all events use all members of the structure.
*/
typedef struct audit_sg_event_data {
char *ed_server_address; /* server's IP address */
char *ed_serverid; /* serverid. */
char *ed_sgroup; /* servergroup */
/* Struct to store client info */
typedef struct {
int cli_sd;
char *cli_pw_buf;
void i_setup_sg_hlist(void);
void i_setup_rule_hlist(void);
void logperror(const char *);
ucred_t *);
ucred_t *);
ucred_t *);
int ilbd_get_num_krules(void);
ilbd_sg_t *i_find_sg_byname(const char *);
ucred_t *);
ucred_t *);
ucred_t *);
boolean_t is_debugging_on(void);
void ilbd_enable_debug(void);
/* Logging routine and macros */
void ilbd_log(int, const char *, ...);
/* Health check manipulation routines */
void i_ilbd_setup_hc_list(void);
ilbd_hc_t *ilbd_get_hc(const char *);
int);
const ilb_sg_srv_t *);
const ilb_sg_srv_t *);
/* Health check timer routines */
void ilbd_hc_probe_return(int, int, int, ilbd_hc_probe_event_t *);
void ilbd_hc_timer_init(int, ilbd_timer_event_obj_t *);
void ilbd_hc_timeout(void);
/* Show NAT info routines */
size_t *);
void ilbd_show_nat_cleanup(void);
/* Show sticky info routines */
size_t *);
void ilbd_show_sticky_cleanup(void);
const char *, void *);
void ilbd_scf_str_to_ip(int, char *, struct in6_addr *);
char *);
int ilbd_scf_limit(int);
void ilbd_algo_to_str(ilb_algo_t, char *);
void ilbd_topo_to_str(ilb_topo_t, char *);
#ifdef __cplusplus
}
#endif
#endif /* _ILBD_H */