mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-31 06:15:55 +00:00
Rework DHCP lease state handling to be compatible with failover protocol.
This commit is contained in:
@@ -238,12 +238,10 @@ struct hardware {
|
||||
struct lease {
|
||||
OMAPI_OBJECT_PREAMBLE;
|
||||
struct lease *next;
|
||||
struct lease *prev;
|
||||
struct lease *n_uid, *n_hw;
|
||||
struct lease *waitq_next;
|
||||
|
||||
struct iaddr ip_addr;
|
||||
TIME starts, ends, timestamp;
|
||||
TIME starts, ends, timestamp, sort_time;
|
||||
unsigned char *uid;
|
||||
unsigned uid_len;
|
||||
unsigned uid_max;
|
||||
@@ -261,19 +259,17 @@ struct lease {
|
||||
struct executable_statement *on_commit;
|
||||
struct executable_statement *on_release;
|
||||
|
||||
int flags;
|
||||
u_int16_t flags;
|
||||
# define STATIC_LEASE 1
|
||||
# define BOOTP_LEASE 2
|
||||
# define PERSISTENT_FLAGS (0)
|
||||
# define MS_NULL_TERMINATION 8
|
||||
# define ABANDONED_LEASE 16
|
||||
# define PEER_IS_OWNER 32
|
||||
# define ON_UPDATE_QUEUE 64
|
||||
# define ON_ACK_QUEUE 128
|
||||
# define EPHEMERAL_FLAGS (BOOTP_LEASE | MS_NULL_TERMINATION | \
|
||||
ABANDONED_LEASE | PEER_IS_OWNER | \
|
||||
# define ON_UPDATE_QUEUE 16
|
||||
# define ON_ACK_QUEUE 32
|
||||
# define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
|
||||
ON_ACK_QUEUE | ON_UPDATE_QUEUE)
|
||||
|
||||
binding_state_t binding_state; /* See failover.h, FTS_*. */
|
||||
binding_state_t next_binding_state; /* See failover.h, FTS_*. */
|
||||
|
||||
struct lease_state *state;
|
||||
|
||||
TIME tstp; /* Time sent to partner. */
|
||||
@@ -500,14 +496,16 @@ struct pool {
|
||||
struct shared_network *shared_network;
|
||||
struct permit *permit_list;
|
||||
struct permit *prohibit_list;
|
||||
struct lease *leases;
|
||||
struct lease *insertion_point;
|
||||
struct lease *last_lease;
|
||||
struct lease *next_expiry;
|
||||
struct lease *active;
|
||||
struct lease *expired;
|
||||
struct lease *free;
|
||||
struct lease *backup;
|
||||
struct lease *abandoned;
|
||||
TIME next_event_time;
|
||||
#if defined (FAILOVER_PROTOCOL)
|
||||
int lease_count;
|
||||
int local_leases;
|
||||
int peer_leases;
|
||||
int free_leases;
|
||||
int backup_leases;
|
||||
dhcp_failover_state_t *failover_peer;
|
||||
#endif
|
||||
};
|
||||
@@ -1550,6 +1548,8 @@ extern u_int32_t fto_allowed [];
|
||||
extern int ft_sizes [];
|
||||
extern const char *dhcp_flink_state_names [];
|
||||
#endif
|
||||
extern const char *binding_state_names [];
|
||||
|
||||
extern struct universe agent_universe;
|
||||
extern struct option agent_options [256];
|
||||
extern struct universe server_universe;
|
||||
@@ -1617,8 +1617,8 @@ void make_release PROTO ((struct client_state *, struct client_lease *));
|
||||
|
||||
void destroy_client_lease PROTO ((struct client_lease *));
|
||||
void rewrite_client_leases PROTO ((void));
|
||||
void write_client_lease PROTO ((struct client_state *,
|
||||
struct client_lease *, int));
|
||||
int write_client_lease PROTO ((struct client_state *,
|
||||
struct client_lease *, int, int));
|
||||
char *dhcp_option_ev_name PROTO ((struct option *));
|
||||
|
||||
void script_init PROTO ((struct client_state *, const char *,
|
||||
@@ -2115,7 +2115,8 @@ void new_shared_network_interface PROTO ((struct parse *,
|
||||
int subnet_inner_than PROTO ((struct subnet *, struct subnet *, int));
|
||||
void enter_subnet PROTO ((struct subnet *));
|
||||
void enter_lease PROTO ((struct lease *));
|
||||
int supersede_lease PROTO ((struct lease *, struct lease *, int, int));
|
||||
int supersede_lease PROTO ((struct lease *, struct lease *, int, int, int));
|
||||
void process_state_transition (struct lease *);
|
||||
int lease_copy PROTO ((struct lease **, struct lease *, const char *, int));
|
||||
void release_lease PROTO ((struct lease *, struct packet *));
|
||||
void abandon_lease PROTO ((struct lease *, const char *));
|
||||
@@ -2205,7 +2206,7 @@ int dhcp_failover_pool_rebalance (dhcp_failover_state_t *);
|
||||
int dhcp_failover_pool_check (struct pool *);
|
||||
int dhcp_failover_state_pool_check (dhcp_failover_state_t *);
|
||||
isc_result_t dhcp_failover_send_updates (dhcp_failover_state_t *);
|
||||
int dhcp_failover_queue_update (struct lease *);
|
||||
int dhcp_failover_queue_update (struct lease *, int);
|
||||
void dhcp_failover_ack_queue_remove (dhcp_failover_state_t *, struct lease *);
|
||||
isc_result_t dhcp_failover_state_set_value PROTO ((omapi_object_t *,
|
||||
omapi_object_t *,
|
||||
@@ -2243,7 +2244,9 @@ failover_option_t *dhcp_failover_make_option PROTO ((unsigned, char *,
|
||||
isc_result_t dhcp_failover_put_message (dhcp_failover_link_t *,
|
||||
omapi_object_t *, int, ...);
|
||||
isc_result_t dhcp_failover_send_connect PROTO ((omapi_object_t *));
|
||||
isc_result_t dhcp_failover_send_connectack PROTO ((omapi_object_t *, int));
|
||||
isc_result_t dhcp_failover_send_connectack PROTO ((omapi_object_t *,
|
||||
dhcp_failover_state_t *,
|
||||
int, const char *));
|
||||
isc_result_t dhcp_failover_send_disconnect PROTO ((omapi_object_t *,
|
||||
int, const char *));
|
||||
isc_result_t dhcp_failover_send_bind_update (dhcp_failover_state_t *,
|
||||
@@ -2260,6 +2263,11 @@ isc_result_t dhcp_failover_process_bind_ack (dhcp_failover_state_t *,
|
||||
void failover_print PROTO ((char *, unsigned *, unsigned, const char *));
|
||||
void update_partner PROTO ((struct lease *));
|
||||
int load_balance_mine (struct packet *, dhcp_failover_state_t *);
|
||||
binding_state_t binding_state_transition_check (struct lease *,
|
||||
dhcp_failover_state_t *,
|
||||
binding_state_t);
|
||||
int lease_mine_to_extend (struct lease *);
|
||||
|
||||
OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_state, dhcp_failover_state_t,
|
||||
dhcp_type_failover_state)
|
||||
OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_listener, dhcp_failover_listener_t,
|
||||
|
@@ -114,7 +114,6 @@ enum dhcp_token {
|
||||
EXPIRE = 308,
|
||||
UNKNOWN_CLIENTS = 309,
|
||||
ALLOW = 310,
|
||||
BOOTP = 311,
|
||||
DENY = 312,
|
||||
BOOTING = 313,
|
||||
DEFAULT = 314,
|
||||
@@ -122,7 +121,7 @@ enum dhcp_token {
|
||||
MEDIUM = 316,
|
||||
ALIAS = 317,
|
||||
REBOOT = 318,
|
||||
ABANDONED = 319,
|
||||
TOKEN_ABANDONED = 319,
|
||||
BACKOFF_CUTOFF = 320,
|
||||
INITIAL_INTERVAL = 321,
|
||||
NAMESERVER = 322,
|
||||
@@ -216,7 +215,7 @@ enum dhcp_token {
|
||||
STATIC = 414,
|
||||
NEVER = 415,
|
||||
INFINITE = 416,
|
||||
DELETED = 417,
|
||||
TOKEN_DELETED = 417,
|
||||
UPDATED_DNS_RR = 418,
|
||||
DNS_DELETE = 419,
|
||||
DUPLICATES = 420,
|
||||
@@ -268,7 +267,17 @@ enum dhcp_token {
|
||||
STATE = 466,
|
||||
UNKNOWN_STATE = 567,
|
||||
CLTT = 568,
|
||||
INCLUDE = 569
|
||||
INCLUDE = 569,
|
||||
BINDING = 570,
|
||||
TOKEN_FREE = 571,
|
||||
TOKEN_ACTIVE = 572,
|
||||
TOKEN_EXPIRED = 573,
|
||||
TOKEN_RELEASED = 574,
|
||||
TOKEN_RESET = 575,
|
||||
TOKEN_BACKUP = 576,
|
||||
TOKEN_RESERVED = 577,
|
||||
TOKEN_BOOTP = 578,
|
||||
TOKEN_NEXT = 579,
|
||||
};
|
||||
|
||||
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
|
||||
|
@@ -157,13 +157,17 @@ typedef struct {
|
||||
#define FTR_UNKNOWN 254
|
||||
|
||||
/* Lease states: */
|
||||
#define FTS_FREE 1
|
||||
#define FTS_ACTIVE 2
|
||||
#define FTS_EXPIRED 3
|
||||
#define FTS_RELEASED 4
|
||||
#define FTS_ABANDONED 5
|
||||
#define FTS_RESET 6
|
||||
#define FTS_BACKUP 7
|
||||
typedef enum {
|
||||
FTS_FREE = 1,
|
||||
FTS_ACTIVE = 2,
|
||||
FTS_EXPIRED = 3,
|
||||
FTS_RELEASED = 4,
|
||||
FTS_ABANDONED = 5,
|
||||
FTS_RESET = 6,
|
||||
FTS_BACKUP = 7,
|
||||
FTS_RESERVED = 8,
|
||||
FTS_BOOTP = 9
|
||||
} binding_state_t;
|
||||
|
||||
#define DHCP_FAILOVER_MAX_MESSAGE_SIZE 2048
|
||||
|
||||
|
Reference in New Issue
Block a user