summaryrefslogtreecommitdiffstats
path: root/src/plugins/lb/lb.api
blob: a9f05f253c53f6d9cf977cc50d4e94ce1fc5619b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
option version = "1.0.0";

/** \brief Configure Load-Balancer global parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param ip4_src_address - IPv4 address to be used as source for IPv4 traffic(applicable in GRE4/GRE6/NAT4/NAT6 mode only).
    @param ip6_src_address - IPv6 address to be used as source for IPv6 traffic(applicable in GRE4/GRE6/NAT4/NAT6 mode only).
    @param sticky_buckets_per_core - Number of buckets *per worker thread* in the
           established flow table (must be power of 2).
    @param flow_timeout - Time in seconds after which, if no packet is received
           for a given flow, the flow is removed from the established flow table.
*/
autoreply define lb_conf
{
  u32 client_index;
  u32 context;
  u32 ip4_src_address;
  u8 ip6_src_address[16];
  u32 sticky_buckets_per_core;
  u32 flow_timeout;
};

/** \brief Add a virtual address (or prefix)
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param ip_prefix - IP address (IPv4 in lower order 32 bits).
    @param prefix_length - IP prefix length (96 + 'IPv4 prefix length' for IPv4).
    @param encap - Encap is ip4 GRE(0) or ip6 GRE(1) or L3DSR(2) or NAT4(3) or NAT6(4).
    @param dscp - DSCP bit corresponding to VIP(applicable in L3DSR mode only).
    @param type - service type(applicable in NAT4/NAT6 mode only).
    @param port - service port(applicable in NAT4/NAT6 mode only).
    @param target_port - Pod's port corresponding to specific service(applicable in NAT4/NAT6 mode only).
    @param node_port - Node's port(applicable in NAT4/NAT6 mode only).
    @param new_flows_table_length - Size of the new connections flow table used
           for this VIP (must be power of 2).
    @param is_del - The VIP should be removed.
*/
autoreply define lb_add_del_vip {
  u32 client_index;
  u32 context;
  u8 ip_prefix[16];
  u8 prefix_length;
  u8 encap;
  u8 dscp;
  u8 type;
  u16 port;
  u16 target_port;
  u16 node_port;
  u32 new_flows_table_length;
  u8 is_del;
};

/** \brief Add an application server for a given VIP
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param vip_ip_prefix - VIP IP address (IPv4 in lower order 32 bits).
    @param vip_ip_prefix - VIP IP prefix length (96 + 'IPv4 prefix length' for IPv4).
    @param as_address - The application server address (IPv4 in lower order 32 bits).
    @param is_del - The AS should be removed.
*/
autoreply define lb_add_del_as {
  u32 client_index;
  u32 context;
  u8 vip_ip_prefix[16];
  u8 vip_prefix_length;
  u8 as_address[16];
  u8 is_del;
};
oid * parse_last_match_value (vlib_parse_main_t * pm) { vlib_parse_item_t *i; i = pool_elt_at_index (pm->parse_items, vec_elt (pm->match_items, vec_len (pm->match_items) - 1)); return i->value.as_pointer; } vlib_parse_match_t eof_match (vlib_parse_main_t * pm, vlib_parse_type_t * type, vlib_lex_token_t * t, vlib_parse_value_t * valuep) { return t->token == VLIB_LEX_eof ? VLIB_PARSE_MATCH_DONE : VLIB_PARSE_MATCH_FAIL; } PARSE_TYPE_INIT (eof, eof_match, 0 /* cleanup value */ , 0 /* format value */ ); vlib_parse_match_t rule_eof_match (vlib_parse_main_t * pm, vlib_parse_type_t * type, vlib_lex_token_t * t, vlib_parse_value_t * valuep) { vlib_parse_match_function_t *fp = parse_last_match_value (pm); pm->current_token_index--; return fp ? fp (pm, type, t, valuep) : VLIB_PARSE_MATCH_RULE; } PARSE_TYPE_INIT (rule_eof, rule_eof_match, 0, 0); vlib_parse_match_t word_match (vlib_parse_main_t * pm, vlib_parse_type_t * type, vlib_lex_token_t * t, vlib_parse_value_t * valuep) { u8 *tv, *iv; int i; if (t->token != VLIB_LEX_word) return VLIB_PARSE_MATCH_FAIL; tv = t->value.as_pointer; iv = parse_last_match_value (pm); for (i = 0; tv[i]; i++) { if (tv[i] != iv[i]) return VLIB_PARSE_MATCH_FAIL; } return iv[i] == 0 ? VLIB_PARSE_MATCH_FULL : VLIB_PARSE_MATCH_PARTIAL; } PARSE_TYPE_INIT (word, word_match, 0 /* clnup value */ , 0 /* format value */ ); vlib_parse_match_t number_match (vlib_parse_main_t * pm, vlib_parse_type_t * type, vlib_lex_token_t * t, vlib_parse_value_t * valuep) { if (t->token == VLIB_LEX_number) { valuep->value.as_uword = t->value.as_uword; return VLIB_PARSE_MATCH_VALUE; } return VLIB_PARSE_MATCH_FAIL; } static u8 * format_value_number (u8 * s, va_list * args) { vlib_parse_value_t *v = va_arg (*args, vlib_parse_value_t *); uword a = v->value.as_uword; if (BITS (uword) == 64) s = format (s, "%lld(0x%llx)", a, a); else s = format (s, "%ld(0x%lx)", a, a); return s; } PARSE_TYPE_INIT (number, number_match, 0 /* cln value */ , format_value_number /* fmt value */ ); #define foreach_vanilla_lex_match_function \ _(plus) \ _(minus) \ _(star) \ _(slash) \ _(lpar) \ _(rpar) #define LEX_MATCH_DEBUG 0 #define _(name) \ vlib_parse_match_t name##_match (vlib_parse_main_t *pm, \ vlib_parse_type_t *type, \ vlib_lex_token_t *t, \ vlib_parse_value_t *valuep) \ { \ if (LEX_MATCH_DEBUG > 0) \ clib_warning ("against %U returns %s", \ format_vlib_lex_token, pm->lex_main, t, \ (t->token == VLIB_LEX_##name) \ ? "VLIB_PARSE_MATCH_FULL" : \ "VLIB_PARSE_MATCH_FAIL"); \ if (t->token == VLIB_LEX_##name) \ return VLIB_PARSE_MATCH_FULL; \ return VLIB_PARSE_MATCH_FAIL; \ } \ \ PARSE_TYPE_INIT (name, name##_match, 0 /* cln value */, \ 0 /* fmt val */); foreach_vanilla_lex_match_function #undef _ /* So we're linked in. */ static clib_error_t * parse_builtin_init (vlib_main_t * vm) { return 0; } VLIB_INIT_FUNCTION (parse_builtin_init); /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */