1*dbed73cbSSangeeta Misra /* 2*dbed73cbSSangeeta Misra * CDDL HEADER START 3*dbed73cbSSangeeta Misra * 4*dbed73cbSSangeeta Misra * The contents of this file are subject to the terms of the 5*dbed73cbSSangeeta Misra * Common Development and Distribution License (the "License"). 6*dbed73cbSSangeeta Misra * You may not use this file except in compliance with the License. 7*dbed73cbSSangeeta Misra * 8*dbed73cbSSangeeta Misra * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*dbed73cbSSangeeta Misra * or http://www.opensolaris.org/os/licensing. 10*dbed73cbSSangeeta Misra * See the License for the specific language governing permissions 11*dbed73cbSSangeeta Misra * and limitations under the License. 12*dbed73cbSSangeeta Misra * 13*dbed73cbSSangeeta Misra * When distributing Covered Code, include this CDDL HEADER in each 14*dbed73cbSSangeeta Misra * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*dbed73cbSSangeeta Misra * If applicable, add the following below this CDDL HEADER, with the 16*dbed73cbSSangeeta Misra * fields enclosed by brackets "[]" replaced with your own identifying 17*dbed73cbSSangeeta Misra * information: Portions Copyright [yyyy] [name of copyright owner] 18*dbed73cbSSangeeta Misra * 19*dbed73cbSSangeeta Misra * CDDL HEADER END 20*dbed73cbSSangeeta Misra */ 21*dbed73cbSSangeeta Misra 22*dbed73cbSSangeeta Misra /* 23*dbed73cbSSangeeta Misra * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24*dbed73cbSSangeeta Misra * Use is subject to license terms. 25*dbed73cbSSangeeta Misra */ 26*dbed73cbSSangeeta Misra #ifndef _INET_ILB_H 27*dbed73cbSSangeeta Misra #define _INET_ILB_H 28*dbed73cbSSangeeta Misra 29*dbed73cbSSangeeta Misra #ifdef __cplusplus 30*dbed73cbSSangeeta Misra extern "C" { 31*dbed73cbSSangeeta Misra #endif 32*dbed73cbSSangeeta Misra 33*dbed73cbSSangeeta Misra /* 34*dbed73cbSSangeeta Misra * This file contains the private interface to IP to configure ILB in 35*dbed73cbSSangeeta Misra * the system. Note that this is not a supported interface, and is 36*dbed73cbSSangeeta Misra * subject to be changed without notice. User level apps should instead 37*dbed73cbSSangeeta Misra * use the libilb library to interface with ILB. 38*dbed73cbSSangeeta Misra */ 39*dbed73cbSSangeeta Misra 40*dbed73cbSSangeeta Misra /* ioctl cmds to IP to configure ILB */ 41*dbed73cbSSangeeta Misra typedef enum { 42*dbed73cbSSangeeta Misra ILB_CREATE_RULE, 43*dbed73cbSSangeeta Misra ILB_DESTROY_RULE, 44*dbed73cbSSangeeta Misra ILB_ENABLE_RULE, 45*dbed73cbSSangeeta Misra ILB_DISABLE_RULE, 46*dbed73cbSSangeeta Misra ILB_NUM_RULES, 47*dbed73cbSSangeeta Misra ILB_NUM_SERVERS, 48*dbed73cbSSangeeta Misra ILB_RULE_NAMES, 49*dbed73cbSSangeeta Misra ILB_LIST_RULE, 50*dbed73cbSSangeeta Misra ILB_LIST_SERVERS, 51*dbed73cbSSangeeta Misra ILB_ADD_SERVERS, 52*dbed73cbSSangeeta Misra ILB_DEL_SERVERS, 53*dbed73cbSSangeeta Misra ILB_ENABLE_SERVERS, 54*dbed73cbSSangeeta Misra ILB_DISABLE_SERVERS, 55*dbed73cbSSangeeta Misra ILB_LIST_NAT_TABLE, 56*dbed73cbSSangeeta Misra ILB_LIST_STICKY_TABLE 57*dbed73cbSSangeeta Misra } ilb_cmd_t; 58*dbed73cbSSangeeta Misra 59*dbed73cbSSangeeta Misra /* Supported load balancing algorithm type */ 60*dbed73cbSSangeeta Misra typedef enum { 61*dbed73cbSSangeeta Misra ILB_ALG_IMPL_ROUNDROBIN = 1, 62*dbed73cbSSangeeta Misra ILB_ALG_IMPL_HASH_IP, 63*dbed73cbSSangeeta Misra ILB_ALG_IMPL_HASH_IP_SPORT, 64*dbed73cbSSangeeta Misra ILB_ALG_IMPL_HASH_IP_VIP 65*dbed73cbSSangeeta Misra } ilb_algo_impl_t; 66*dbed73cbSSangeeta Misra 67*dbed73cbSSangeeta Misra /* Supported load balancing method */ 68*dbed73cbSSangeeta Misra typedef enum { 69*dbed73cbSSangeeta Misra ILB_TOPO_IMPL_DSR = 1, 70*dbed73cbSSangeeta Misra ILB_TOPO_IMPL_NAT, 71*dbed73cbSSangeeta Misra ILB_TOPO_IMPL_HALF_NAT 72*dbed73cbSSangeeta Misra } ilb_topo_impl_t; 73*dbed73cbSSangeeta Misra 74*dbed73cbSSangeeta Misra /* Max ILB rule name length */ 75*dbed73cbSSangeeta Misra #define ILB_RULE_NAMESZ 20 76*dbed73cbSSangeeta Misra 77*dbed73cbSSangeeta Misra /* Max kstat server name length */ 78*dbed73cbSSangeeta Misra #define ILB_SERVER_NAMESZ 20 79*dbed73cbSSangeeta Misra 80*dbed73cbSSangeeta Misra /* Rule destroy/enable/disable command struct */ 81*dbed73cbSSangeeta Misra typedef struct { 82*dbed73cbSSangeeta Misra ilb_cmd_t cmd; 83*dbed73cbSSangeeta Misra char name[ILB_RULE_NAMESZ]; 84*dbed73cbSSangeeta Misra uint32_t flags; 85*dbed73cbSSangeeta Misra } ilb_name_cmd_t; 86*dbed73cbSSangeeta Misra 87*dbed73cbSSangeeta Misra /* Flags for rule creation command */ 88*dbed73cbSSangeeta Misra /* these are echoed in lib/libilb/common/libilb.h - please keep in sync */ 89*dbed73cbSSangeeta Misra #define ILB_RULE_ENABLED 0x1 90*dbed73cbSSangeeta Misra #define ILB_RULE_STICKY 0x2 91*dbed73cbSSangeeta Misra #define ILB_RULE_ALLRULES 0x4 92*dbed73cbSSangeeta Misra #define ILB_RULE_BUSY 0x8 93*dbed73cbSSangeeta Misra 94*dbed73cbSSangeeta Misra /* Rule creation/retrieval command struct */ 95*dbed73cbSSangeeta Misra typedef struct { 96*dbed73cbSSangeeta Misra ilb_cmd_t cmd; 97*dbed73cbSSangeeta Misra char name[ILB_RULE_NAMESZ]; 98*dbed73cbSSangeeta Misra uint32_t ip_ver; 99*dbed73cbSSangeeta Misra in6_addr_t vip; 100*dbed73cbSSangeeta Misra char vip_itf[LIFNAMSIZ]; 101*dbed73cbSSangeeta Misra uint32_t proto; 102*dbed73cbSSangeeta Misra in_port_t min_port; /* In network byte order */ 103*dbed73cbSSangeeta Misra in_port_t max_port; 104*dbed73cbSSangeeta Misra ilb_algo_impl_t algo; 105*dbed73cbSSangeeta Misra ilb_topo_impl_t topo; 106*dbed73cbSSangeeta Misra char servers_itf[LIFNAMSIZ]; 107*dbed73cbSSangeeta Misra in6_addr_t nat_src_start; 108*dbed73cbSSangeeta Misra in6_addr_t nat_src_end; 109*dbed73cbSSangeeta Misra uint32_t flags; 110*dbed73cbSSangeeta Misra in6_addr_t sticky_mask; 111*dbed73cbSSangeeta Misra uint32_t conn_drain_timeout; /* Time value is in seconds */ 112*dbed73cbSSangeeta Misra uint32_t nat_expiry; 113*dbed73cbSSangeeta Misra uint32_t sticky_expiry; 114*dbed73cbSSangeeta Misra } ilb_rule_cmd_t; 115*dbed73cbSSangeeta Misra 116*dbed73cbSSangeeta Misra /* Get number of servers command struct */ 117*dbed73cbSSangeeta Misra typedef struct { 118*dbed73cbSSangeeta Misra ilb_cmd_t cmd; 119*dbed73cbSSangeeta Misra char name[ILB_RULE_NAMESZ]; 120*dbed73cbSSangeeta Misra uint32_t num; 121*dbed73cbSSangeeta Misra } ilb_num_servers_cmd_t; 122*dbed73cbSSangeeta Misra 123*dbed73cbSSangeeta Misra /* Get number of rules command struct */ 124*dbed73cbSSangeeta Misra typedef struct { 125*dbed73cbSSangeeta Misra ilb_cmd_t cmd; 126*dbed73cbSSangeeta Misra uint32_t num; 127*dbed73cbSSangeeta Misra } ilb_num_rules_cmd_t; 128*dbed73cbSSangeeta Misra 129*dbed73cbSSangeeta Misra /* Get all rule names command struct */ 130*dbed73cbSSangeeta Misra typedef struct { 131*dbed73cbSSangeeta Misra ilb_cmd_t cmd; 132*dbed73cbSSangeeta Misra uint32_t num_names; 133*dbed73cbSSangeeta Misra /* buf size is (num_names * ILB_RULE_NAMESZ) */ 134*dbed73cbSSangeeta Misra char buf[ILB_RULE_NAMESZ]; 135*dbed73cbSSangeeta Misra } ilb_rule_names_cmd_t; 136*dbed73cbSSangeeta Misra 137*dbed73cbSSangeeta Misra /* Flags for ilb_server_info_t */ 138*dbed73cbSSangeeta Misra #define ILB_SERVER_ENABLED 0x1 139*dbed73cbSSangeeta Misra 140*dbed73cbSSangeeta Misra /* Struct to represent a backend server for add/list command */ 141*dbed73cbSSangeeta Misra typedef struct { 142*dbed73cbSSangeeta Misra char name[ILB_SERVER_NAMESZ]; 143*dbed73cbSSangeeta Misra in6_addr_t addr; 144*dbed73cbSSangeeta Misra in_port_t min_port; /* In network byte order */ 145*dbed73cbSSangeeta Misra in_port_t max_port; 146*dbed73cbSSangeeta Misra uint32_t flags; 147*dbed73cbSSangeeta Misra int err; /* In return, non zero value indicates error */ 148*dbed73cbSSangeeta Misra } ilb_server_info_t; 149*dbed73cbSSangeeta Misra 150*dbed73cbSSangeeta Misra /* Add/list servers command struct */ 151*dbed73cbSSangeeta Misra typedef struct { 152*dbed73cbSSangeeta Misra ilb_cmd_t cmd; 153*dbed73cbSSangeeta Misra char name[ILB_RULE_NAMESZ]; 154*dbed73cbSSangeeta Misra uint32_t num_servers; 155*dbed73cbSSangeeta Misra ilb_server_info_t servers[1]; 156*dbed73cbSSangeeta Misra } ilb_servers_info_cmd_t; 157*dbed73cbSSangeeta Misra 158*dbed73cbSSangeeta Misra /* 159*dbed73cbSSangeeta Misra * Struct to represent a backend server for delete/enable/disable 160*dbed73cbSSangeeta Misra * command 161*dbed73cbSSangeeta Misra */ 162*dbed73cbSSangeeta Misra typedef struct { 163*dbed73cbSSangeeta Misra in6_addr_t addr; 164*dbed73cbSSangeeta Misra int err; /* In return, non zero value indicates error */ 165*dbed73cbSSangeeta Misra } ilb_server_arg_t; 166*dbed73cbSSangeeta Misra 167*dbed73cbSSangeeta Misra /* Delete/enable/disable a server command struct */ 168*dbed73cbSSangeeta Misra typedef struct { 169*dbed73cbSSangeeta Misra ilb_cmd_t cmd; 170*dbed73cbSSangeeta Misra char name[ILB_RULE_NAMESZ]; 171*dbed73cbSSangeeta Misra uint32_t num_servers; 172*dbed73cbSSangeeta Misra ilb_server_arg_t servers[1]; 173*dbed73cbSSangeeta Misra } ilb_servers_cmd_t; 174*dbed73cbSSangeeta Misra 175*dbed73cbSSangeeta Misra /* 176*dbed73cbSSangeeta Misra * Flags for listing NAT/persistence table entries 177*dbed73cbSSangeeta Misra * 178*dbed73cbSSangeeta Misra * ILB_LIST_BEGIN: start from the beginning of the table 179*dbed73cbSSangeeta Misra * ILB_LIST_CONT: start from the last reply 180*dbed73cbSSangeeta Misra * ILB_LIST_END: on return, this flag indicates the end of the table 181*dbed73cbSSangeeta Misra */ 182*dbed73cbSSangeeta Misra #define ILB_LIST_BEGIN 0x1 183*dbed73cbSSangeeta Misra #define ILB_LIST_CONT 0x2 184*dbed73cbSSangeeta Misra #define ILB_LIST_END 0x4 185*dbed73cbSSangeeta Misra 186*dbed73cbSSangeeta Misra #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 187*dbed73cbSSangeeta Misra #pragma pack(4) 188*dbed73cbSSangeeta Misra #endif 189*dbed73cbSSangeeta Misra 190*dbed73cbSSangeeta Misra typedef struct { 191*dbed73cbSSangeeta Misra uint32_t proto; 192*dbed73cbSSangeeta Misra 193*dbed73cbSSangeeta Misra in6_addr_t in_local; 194*dbed73cbSSangeeta Misra in6_addr_t in_global; 195*dbed73cbSSangeeta Misra in6_addr_t out_local; 196*dbed73cbSSangeeta Misra in6_addr_t out_global; 197*dbed73cbSSangeeta Misra 198*dbed73cbSSangeeta Misra in_port_t in_local_port; 199*dbed73cbSSangeeta Misra in_port_t in_global_port; 200*dbed73cbSSangeeta Misra in_port_t out_local_port; 201*dbed73cbSSangeeta Misra in_port_t out_global_port; 202*dbed73cbSSangeeta Misra 203*dbed73cbSSangeeta Misra int64_t create_time; 204*dbed73cbSSangeeta Misra int64_t last_access_time; 205*dbed73cbSSangeeta Misra uint64_t pkt_cnt; 206*dbed73cbSSangeeta Misra } ilb_nat_entry_t; 207*dbed73cbSSangeeta Misra 208*dbed73cbSSangeeta Misra /* List NAT table entries command struct */ 209*dbed73cbSSangeeta Misra typedef struct { 210*dbed73cbSSangeeta Misra ilb_cmd_t cmd; 211*dbed73cbSSangeeta Misra uint32_t flags; 212*dbed73cbSSangeeta Misra uint32_t num_nat; 213*dbed73cbSSangeeta Misra ilb_nat_entry_t entries[1]; 214*dbed73cbSSangeeta Misra } ilb_list_nat_cmd_t; 215*dbed73cbSSangeeta Misra 216*dbed73cbSSangeeta Misra typedef struct { 217*dbed73cbSSangeeta Misra char rule_name[ILB_RULE_NAMESZ]; 218*dbed73cbSSangeeta Misra in6_addr_t req_addr; 219*dbed73cbSSangeeta Misra in6_addr_t srv_addr; 220*dbed73cbSSangeeta Misra int64_t expiry_time; 221*dbed73cbSSangeeta Misra } ilb_sticky_entry_t; 222*dbed73cbSSangeeta Misra 223*dbed73cbSSangeeta Misra /* List sticky table entries command struct */ 224*dbed73cbSSangeeta Misra typedef struct { 225*dbed73cbSSangeeta Misra ilb_cmd_t cmd; 226*dbed73cbSSangeeta Misra uint32_t flags; 227*dbed73cbSSangeeta Misra uint32_t num_sticky; 228*dbed73cbSSangeeta Misra ilb_sticky_entry_t entries[1]; 229*dbed73cbSSangeeta Misra } ilb_list_sticky_cmd_t; 230*dbed73cbSSangeeta Misra 231*dbed73cbSSangeeta Misra #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 232*dbed73cbSSangeeta Misra #pragma pack() 233*dbed73cbSSangeeta Misra #endif 234*dbed73cbSSangeeta Misra 235*dbed73cbSSangeeta Misra #ifdef __cplusplus 236*dbed73cbSSangeeta Misra } 237*dbed73cbSSangeeta Misra #endif 238*dbed73cbSSangeeta Misra 239*dbed73cbSSangeeta Misra #endif /* _INET_ILB_H */ 240