FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
dns.c File Reference
+ Include dependency graph for dns.c:

Go to the source code of this file.

Macros

#define vl_typedefs
 
#define vl_endianfun
 
#define vl_print(handle, ...)   vlib_cli_output (handle, __VA_ARGS__)
 
#define vl_printfun
 
#define vl_api_version(n, v)   static u32 api_version=(v);
 
#define REPLY_MSG_ID_BASE   dm->msg_id_base
 
#define FINISH
 
#define foreach_notification_to_move   _(pending_requests)
 
#define vl_msg_name_crc_list
 
#define foreach_dns_plugin_api_msg
 
#define DNS_FORMAT_TEST   1
 

Functions

static int dns_cache_clear (dns_main_t *dm)
 
static int dns_enable_disable (dns_main_t *dm, int is_enable)
 
static void vl_api_dns_enable_disable_t_handler (vl_api_dns_enable_disable_t *mp)
 
static int dns6_name_server_add_del (dns_main_t *dm, u8 *server_address_as_u8, int is_add)
 
static int dns4_name_server_add_del (dns_main_t *dm, u8 *server_address_as_u8, int is_add)
 
static void vl_api_dns_name_server_add_del_t_handler (vl_api_dns_name_server_add_del_t *mp)
 
void vnet_dns_send_dns4_request (dns_main_t *dm, dns_cache_entry_t *ep, ip4_address_t *server)
 
void vnet_dns_send_dns6_request (dns_main_t *dm, dns_cache_entry_t *ep, ip6_address_t *server)
 
u8name_to_labels (u8 *name)
 Translate "foo.com" into "0x3 f o o 0x3 c o m 0x0" A historical / hysterical micro-TLV scheme. More...
 
u8vnet_dns_labels_to_name (u8 *label, u8 *full_text, u8 **parse_from_here)
 arc-function for the above. More...
 
void vnet_send_dns_request (dns_main_t *dm, dns_cache_entry_t *ep)
 
int vnet_dns_delete_entry_by_index_nolock (dns_main_t *dm, u32 index)
 
static int dns_delete_by_name (dns_main_t *dm, u8 *name)
 
static int delete_random_entry (dns_main_t *dm)
 
static int dns_add_static_entry (dns_main_t *dm, u8 *name, u8 *dns_reply_data)
 
int vnet_dns_resolve_name (dns_main_t *dm, u8 *name, dns_pending_request_t *t, dns_cache_entry_t **retp)
 
int vnet_dns_cname_indirection_nolock (dns_main_t *dm, u32 ep_index, u8 *reply)
 Handle cname indirection. More...
 
int vnet_dns_response_to_reply (u8 *response, vl_api_dns_resolve_name_reply_t *rmp, u32 *min_ttlp)
 
int vnet_dns_response_to_name (u8 *response, vl_api_dns_resolve_ip_reply_t *rmp, u32 *min_ttlp)
 
static void vl_api_dns_resolve_name_t_handler (vl_api_dns_resolve_name_t *mp)
 
static void vl_api_dns_resolve_ip_t_handler (vl_api_dns_resolve_ip_t *mp)
 
static void setup_message_id_table (dns_main_t *dm)
 
static clib_error_tdns_config_fn (vlib_main_t *vm, unformat_input_t *input)
 
uword unformat_dns_reply (unformat_input_t *input, va_list *args)
 
u8format_dns_query (u8 *s, va_list *args)
 
u8format_dns_reply_data (u8 *s, va_list *args)
 format dns reply data verbose > 1, dump everything verbose == 1, dump all A and AAAA records verbose == 0, dump one A record, and one AAAA record More...
 
u8format_dns_reply (u8 *s, va_list *args)
 
u8format_dns_cache (u8 *s, va_list *args)
 
static clib_error_tshow_dns_cache_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tshow_dns_servers_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tdns_cache_add_del_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_ttest_dns_fmt_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_ttest_dns_unfmt_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_ttest_dns_expire_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
void vnet_send_dns6_reply (dns_main_t *dm, dns_pending_request_t *pr, dns_cache_entry_t *ep, vlib_buffer_t *b0)
 
void vnet_send_dns4_reply (dns_main_t *dm, dns_pending_request_t *pr, dns_cache_entry_t *ep, vlib_buffer_t *b0)
 
static void * vl_api_dns_enable_disable_t_print (vl_api_dns_enable_disable_t *mp, void *handle)
 
static void * vl_api_dns_name_server_add_del_t_print (vl_api_dns_name_server_add_del_t *mp, void *handle)
 
static void * vl_api_dns_resolve_name_t_print (vl_api_dns_resolve_name_t *mp, void *handle)
 
static void * vl_api_dns_resolve_ip_t_print (vl_api_dns_resolve_ip_t *mp, void *handle)
 
static void dns_custom_dump_configure (dns_main_t *dm)
 
static clib_error_tdns_plugin_api_hookup (vlib_main_t *vm)
 
static clib_error_tdns_init (vlib_main_t *vm)
 
 VLIB_PLUGIN_REGISTER ()
 

Variables

dns_main_t dns_main
 
vlib_cli_command_t show_dns_cache_command
 (constructor) VLIB_CLI_COMMAND (show_dns_cache_command) More...
 
vlib_cli_command_t show_dns_server_command
 (constructor) VLIB_CLI_COMMAND (show_dns_server_command) More...
 
vlib_cli_command_t dns_cache_add_del_command
 (constructor) VLIB_CLI_COMMAND (dns_cache_add_del_command) More...
 
static u8 dns_reply_data_initializer []
 
vlib_cli_command_t test_dns_fmt_command
 (constructor) VLIB_CLI_COMMAND (test_dns_fmt_command) More...
 
vlib_cli_command_t test_dns_unfmt_command
 (constructor) VLIB_CLI_COMMAND (test_dns_unfmt_command) More...
 
vlib_cli_command_t test_dns_expire_command
 (constructor) VLIB_CLI_COMMAND (test_dns_expire_command) More...
 

Macro Definition Documentation

◆ DNS_FORMAT_TEST

#define DNS_FORMAT_TEST   1

Definition at line 2429 of file dns.c.

◆ FINISH

#define FINISH
Value:
vec_add1 (s, 0); \
vl_print (handle, (char *)s); \
vec_free (s); \
return handle;
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522

Definition at line 55 of file dns.c.

◆ foreach_dns_plugin_api_msg

#define foreach_dns_plugin_api_msg
Value:
_(DNS_ENABLE_DISABLE, dns_enable_disable) \
_(DNS_NAME_SERVER_ADD_DEL, dns_name_server_add_del) \
_(DNS_RESOLVE_NAME, dns_resolve_name) \
_(DNS_RESOLVE_IP, dns_resolve_ip)
static int dns_enable_disable(dns_main_t *dm, int is_enable)
Definition: dns.c:90

Definition at line 1594 of file dns.c.

◆ foreach_notification_to_move

#define foreach_notification_to_move   _(pending_requests)

Definition at line 977 of file dns.c.

◆ REPLY_MSG_ID_BASE

#define REPLY_MSG_ID_BASE   dm->msg_id_base

Definition at line 51 of file dns.c.

◆ vl_api_version

#define vl_api_version (   n,
 
)    static u32 api_version=(v);

Definition at line 47 of file dns.c.

◆ vl_endianfun

#define vl_endianfun

Definition at line 36 of file dns.c.

◆ vl_msg_name_crc_list

#define vl_msg_name_crc_list

Definition at line 1581 of file dns.c.

◆ vl_print

#define vl_print (   handle,
  ... 
)    vlib_cli_output (handle, __VA_ARGS__)

Definition at line 41 of file dns.c.

◆ vl_printfun

#define vl_printfun

Definition at line 42 of file dns.c.

◆ vl_typedefs

#define vl_typedefs

Definition at line 31 of file dns.c.

Function Documentation

◆ delete_random_entry()

static int delete_random_entry ( dns_main_t dm)
static

Definition at line 739 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dns4_name_server_add_del()

static int dns4_name_server_add_del ( dns_main_t dm,
u8 server_address_as_u8,
int  is_add 
)
static

Definition at line 189 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dns6_name_server_add_del()

static int dns6_name_server_add_del ( dns_main_t dm,
u8 server_address_as_u8,
int  is_add 
)
static

Definition at line 153 of file dns.c.

+ Here is the caller graph for this function:

◆ dns_add_static_entry()

static int dns_add_static_entry ( dns_main_t dm,
u8 name,
u8 dns_reply_data 
)
static

Definition at line 786 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dns_cache_add_del_command_fn()

static clib_error_t* dns_cache_add_del_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2329 of file dns.c.

+ Here is the call graph for this function:

◆ dns_cache_clear()

static int dns_cache_clear ( dns_main_t dm)
static

Definition at line 64 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dns_config_fn()

static clib_error_t* dns_config_fn ( vlib_main_t vm,
unformat_input_t input 
)
static

Definition at line 1601 of file dns.c.

+ Here is the call graph for this function:

◆ dns_custom_dump_configure()

static void dns_custom_dump_configure ( dns_main_t dm)
static

Definition at line 3087 of file dns.c.

+ Here is the caller graph for this function:

◆ dns_delete_by_name()

static int dns_delete_by_name ( dns_main_t dm,
u8 name 
)
static

Definition at line 716 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dns_enable_disable()

static int dns_enable_disable ( dns_main_t dm,
int  is_enable 
)
static

Definition at line 90 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dns_init()

static clib_error_t* dns_init ( vlib_main_t vm)
static

Definition at line 3116 of file dns.c.

+ Here is the call graph for this function:

◆ dns_plugin_api_hookup()

static clib_error_t* dns_plugin_api_hookup ( vlib_main_t vm)
static

Definition at line 3098 of file dns.c.

+ Here is the caller graph for this function:

◆ format_dns_cache()

u8* format_dns_cache ( u8 s,
va_list *  args 
)

Definition at line 2115 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_dns_query()

u8* format_dns_query ( u8 s,
va_list *  args 
)

Definition at line 1725 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_dns_reply()

u8* format_dns_reply ( u8 s,
va_list *  args 
)

Definition at line 2055 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_dns_reply_data()

u8* format_dns_reply_data ( u8 s,
va_list *  args 
)

format dns reply data verbose > 1, dump everything verbose == 1, dump all A and AAAA records verbose == 0, dump one A record, and one AAAA record

Definition at line 1789 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ name_to_labels()

u8* name_to_labels ( u8 name)

Translate "foo.com" into "0x3 f o o 0x3 c o m 0x0" A historical / hysterical micro-TLV scheme.

DGMS.

Definition at line 473 of file dns.c.

+ Here is the caller graph for this function:

◆ setup_message_id_table()

static void setup_message_id_table ( dns_main_t dm)
static

Definition at line 1586 of file dns.c.

+ Here is the caller graph for this function:

◆ show_dns_cache_command_fn()

static clib_error_t* show_dns_cache_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2255 of file dns.c.

+ Here is the call graph for this function:

◆ show_dns_servers_command_fn()

static clib_error_t* show_dns_servers_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2291 of file dns.c.

+ Here is the call graph for this function:

◆ test_dns_expire_command_fn()

static clib_error_t* test_dns_expire_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2722 of file dns.c.

+ Here is the call graph for this function:

◆ test_dns_fmt_command_fn()

static clib_error_t* test_dns_fmt_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2616 of file dns.c.

+ Here is the call graph for this function:

◆ test_dns_unfmt_command_fn()

static clib_error_t* test_dns_unfmt_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 2682 of file dns.c.

+ Here is the call graph for this function:

◆ unformat_dns_reply()

uword unformat_dns_reply ( unformat_input_t input,
va_list *  args 
)

Definition at line 1621 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vl_api_dns_enable_disable_t_handler()

static void vl_api_dns_enable_disable_t_handler ( vl_api_dns_enable_disable_t mp)
static

Definition at line 141 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vl_api_dns_enable_disable_t_print()

static void* vl_api_dns_enable_disable_t_print ( vl_api_dns_enable_disable_t mp,
void *  handle 
)
static

Definition at line 3034 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vl_api_dns_name_server_add_del_t_handler()

static void vl_api_dns_name_server_add_del_t_handler ( vl_api_dns_name_server_add_del_t mp)
static

Definition at line 225 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vl_api_dns_name_server_add_del_t_print()

static void* vl_api_dns_name_server_add_del_t_print ( vl_api_dns_name_server_add_del_t mp,
void *  handle 
)
static

Definition at line 3045 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vl_api_dns_resolve_ip_t_handler()

static void vl_api_dns_resolve_ip_t_handler ( vl_api_dns_resolve_ip_t mp)
static

Definition at line 1502 of file dns.c.

+ Here is the call graph for this function:

◆ vl_api_dns_resolve_ip_t_print()

static void* vl_api_dns_resolve_ip_t_print ( vl_api_dns_resolve_ip_t mp,
void *  handle 
)
static

Definition at line 3074 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vl_api_dns_resolve_name_t_handler()

static void vl_api_dns_resolve_name_t_handler ( vl_api_dns_resolve_name_t mp)
static

Definition at line 1458 of file dns.c.

+ Here is the call graph for this function:

◆ vl_api_dns_resolve_name_t_print()

static void* vl_api_dns_resolve_name_t_print ( vl_api_dns_resolve_name_t mp,
void *  handle 
)
static

Definition at line 3064 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VLIB_PLUGIN_REGISTER()

VLIB_PLUGIN_REGISTER ( )

◆ vnet_dns_cname_indirection_nolock()

int vnet_dns_cname_indirection_nolock ( dns_main_t dm,
u32  ep_index,
u8 reply 
)

Handle cname indirection.

JFC. Called with the cache locked. returns 0 if the reply is not a CNAME.

Definition at line 986 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vnet_dns_delete_entry_by_index_nolock()

int vnet_dns_delete_entry_by_index_nolock ( dns_main_t dm,
u32  index 
)

Definition at line 682 of file dns.c.

+ Here is the caller graph for this function:

◆ vnet_dns_labels_to_name()

u8* vnet_dns_labels_to_name ( u8 label,
u8 full_text,
u8 **  parse_from_here 
)

arc-function for the above.

Translate "0x3 f o o 0x3 c o m 0x0" into "foo.com" Produces a non-NULL-terminated u8 *vector. v format is your friend.

Definition at line 516 of file dns.c.

+ Here is the caller graph for this function:

◆ vnet_dns_resolve_name()

int vnet_dns_resolve_name ( dns_main_t dm,
u8 name,
dns_pending_request_t t,
dns_cache_entry_t **  retp 
)

Definition at line 830 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vnet_dns_response_to_name()

int vnet_dns_response_to_name ( u8 response,
vl_api_dns_resolve_ip_reply_t rmp,
u32 min_ttlp 
)

Definition at line 1322 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vnet_dns_response_to_reply()

int vnet_dns_response_to_reply ( u8 response,
vl_api_dns_resolve_name_reply_t rmp,
u32 min_ttlp 
)

Definition at line 1181 of file dns.c.

+ Here is the caller graph for this function:

◆ vnet_dns_send_dns4_request()

void vnet_dns_send_dns4_request ( dns_main_t dm,
dns_cache_entry_t ep,
ip4_address_t server 
)

Definition at line 240 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vnet_dns_send_dns6_request()

void vnet_dns_send_dns6_request ( dns_main_t dm,
dns_cache_entry_t ep,
ip6_address_t server 
)

Definition at line 359 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vnet_send_dns4_reply()

void vnet_send_dns4_reply ( dns_main_t dm,
dns_pending_request_t pr,
dns_cache_entry_t ep,
vlib_buffer_t b0 
)

Definition at line 2777 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vnet_send_dns6_reply()

void vnet_send_dns6_reply ( dns_main_t dm,
dns_pending_request_t pr,
dns_cache_entry_t ep,
vlib_buffer_t b0 
)

Definition at line 2769 of file dns.c.

+ Here is the caller graph for this function:

◆ vnet_send_dns_request()

void vnet_send_dns_request ( dns_main_t dm,
dns_cache_entry_t ep 
)

Definition at line 558 of file dns.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ dns_cache_add_del_command

vlib_cli_command_t dns_cache_add_del_command
Initial value:
=
{
.path = "dns cache",
.short_help = "dns cache [add|del|clear] <name> [ip4][ip6]",
}
static clib_error_t * dns_cache_add_del_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dns.c:2329

(constructor) VLIB_CLI_COMMAND (dns_cache_add_del_command)

Definition at line 2421 of file dns.c.

◆ dns_main

dns_main_t dns_main

Definition at line 61 of file dns.c.

◆ dns_reply_data_initializer

u8 dns_reply_data_initializer[]
static
Initial value:
= {
0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x0b,
0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x6c, 0x69,
0x6e, 0x6b, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0xff,
0x00, 0x01, 0xc0, 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00,
0x00, 0x0c, 0x9e, 0x00, 0x1f, 0x0e, 0x64, 0x33, 0x6b,
0x72, 0x30, 0x67, 0x75, 0x62, 0x61, 0x31, 0x64, 0x76,
0x77, 0x66, 0x0a, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x66,
0x72, 0x6f, 0x6e, 0x74, 0x03, 0x6e, 0x65, 0x74, 0x00,
}

Definition at line 2601 of file dns.c.

◆ show_dns_cache_command

vlib_cli_command_t show_dns_cache_command
Initial value:
=
{
.path = "show dns cache",
.short_help = "show dns cache [verbose [nn]]",
}
static clib_error_t * show_dns_cache_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dns.c:2255

(constructor) VLIB_CLI_COMMAND (show_dns_cache_command)

Definition at line 2282 of file dns.c.

◆ show_dns_server_command

vlib_cli_command_t show_dns_server_command
Initial value:
=
{
.path = "show dns servers",
.short_help = "show dns servers",
}
static clib_error_t * show_dns_servers_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dns.c:2291

(constructor) VLIB_CLI_COMMAND (show_dns_server_command)

Definition at line 2319 of file dns.c.

◆ test_dns_expire_command

vlib_cli_command_t test_dns_expire_command
Initial value:
=
{
.path = "test dns expire",
.short_help = "test dns expire <name>",
}
static clib_error_t * test_dns_expire_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dns.c:2722

(constructor) VLIB_CLI_COMMAND (test_dns_expire_command)

Definition at line 2759 of file dns.c.

◆ test_dns_fmt_command

vlib_cli_command_t test_dns_fmt_command
Initial value:
=
{
.path = "test dns format",
.short_help = "test dns format",
}
static clib_error_t * test_dns_fmt_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dns.c:2616

(constructor) VLIB_CLI_COMMAND (test_dns_fmt_command)

Definition at line 2673 of file dns.c.

◆ test_dns_unfmt_command

vlib_cli_command_t test_dns_unfmt_command
Initial value:
=
{
.path = "test dns unformat",
.short_help = "test dns unformat <name> [ip4][ip6]",
}
static clib_error_t * test_dns_unfmt_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dns.c:2682

(constructor) VLIB_CLI_COMMAND (test_dns_unfmt_command)

Definition at line 2713 of file dns.c.