dns: cherry-pick 21444, 21468 from master
Type: refactor Ticket: VPP-1752 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Ieaec721056531ba0c70538c9bf97769a0e80aefd
This commit is contained in:
10
MAINTAINERS
10
MAINTAINERS
@ -245,11 +245,6 @@ M: Dave Barach <dave@barachs.net>
|
||||
M: Neale Ranns <nranns@cisco.com>
|
||||
F: src/vnet/dhcp/
|
||||
|
||||
VNET DNS
|
||||
I: dns
|
||||
M: Dave Barach <dave@barachs.net>
|
||||
F: src/vnet/dns/
|
||||
|
||||
VNET TLS and TLS engine plugins
|
||||
I: tls
|
||||
M: Florin Coras <fcoras@cisco.com>
|
||||
@ -399,6 +394,11 @@ I: nsim
|
||||
M: Dave Barach <dave@barachs.net>
|
||||
F: src/plugins/nsim/
|
||||
|
||||
Plugin - Simple DNS name resolver
|
||||
I: dns
|
||||
M: Dave Barach <dave@barachs.net>
|
||||
F: src/plugins/dns/
|
||||
|
||||
Test Infrastructure
|
||||
I: tests
|
||||
M: Klement Sekera <ksekera@cisco.com>
|
||||
|
33
src/plugins/dns/CMakeLists.txt
Normal file
33
src/plugins/dns/CMakeLists.txt
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
# Copyright (c) <current-year> <your-organization>
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at:
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
add_vpp_plugin(dns
|
||||
SOURCES
|
||||
dns.c
|
||||
dns.h
|
||||
request_node.c
|
||||
reply_node.c
|
||||
resolver_process.c
|
||||
|
||||
API_FILES
|
||||
dns.api
|
||||
|
||||
INSTALL_HEADERS
|
||||
dns_all_api_h.h
|
||||
dns_msg_enum.h
|
||||
dns_packet.h
|
||||
|
||||
API_TEST_SOURCES
|
||||
dns_test.c
|
||||
)
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
option version = "1.0.0";
|
||||
|
||||
/** \brief enable/disable name resolution
|
||||
@ -21,7 +21,7 @@ option version = "1.0.0";
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param is_enable - 1 = enable, 0 = disable
|
||||
*/
|
||||
autoreply define dns_enable_disable {
|
||||
autoreply manual_print define dns_enable_disable {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 enable;
|
||||
@ -35,7 +35,7 @@ autoreply define dns_enable_disable {
|
||||
@param is_add - add = 1, delete = 0
|
||||
@param server_address - server ip address
|
||||
*/
|
||||
autoreply define dns_name_server_add_del {
|
||||
autoreply manual_print define dns_name_server_add_del {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 is_ip6;
|
||||
@ -49,7 +49,7 @@ autoreply define dns_name_server_add_del {
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param name - the name to resolve
|
||||
*/
|
||||
define dns_resolve_name {
|
||||
manual_print define dns_resolve_name {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 name[256];
|
||||
@ -81,7 +81,7 @@ define dns_resolve_name_reply {
|
||||
@param is_ip6 - set if the reverse-DNS request is an ip6 address
|
||||
@param address - the address to map to a name
|
||||
*/
|
||||
define dns_resolve_ip {
|
||||
manual_print define dns_resolve_ip {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 is_ip6;
|
||||
@ -100,4 +100,3 @@ define dns_resolve_ip_reply {
|
||||
i32 retval;
|
||||
u8 name[256];
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,9 +21,10 @@
|
||||
#include <vppinfra/error.h>
|
||||
|
||||
#include <vppinfra/hash.h>
|
||||
#include <vnet/dns/dns_packet.h>
|
||||
#include <dns/dns_packet.h>
|
||||
#include <vnet/ip/ip.h>
|
||||
#include <vppinfra/lock.h>
|
||||
#include <vlibapi/api_common.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -98,6 +99,7 @@ typedef struct
|
||||
/** Find cached record by name */
|
||||
uword *cache_entry_by_name;
|
||||
clib_spinlock_t cache_lock;
|
||||
int cache_lock_tag;
|
||||
|
||||
/** enable / disable flag */
|
||||
int is_enabled;
|
||||
@ -117,9 +119,13 @@ typedef struct
|
||||
u32 max_ttl_in_seconds;
|
||||
u32 random_seed;
|
||||
|
||||
/** message-ID base */
|
||||
u16 msg_id_base;
|
||||
|
||||
/* convenience */
|
||||
vlib_main_t *vlib_main;
|
||||
vnet_main_t *vnet_main;
|
||||
api_main_t *api_main;
|
||||
} dns_main_t;
|
||||
|
||||
extern dns_main_t dns_main;
|
||||
@ -193,11 +199,14 @@ void vnet_dns_create_resolver_process (dns_main_t * dm);
|
||||
format_function_t format_dns_reply;
|
||||
|
||||
static inline void
|
||||
dns_cache_lock (dns_main_t * dm)
|
||||
dns_cache_lock (dns_main_t * dm, int tag)
|
||||
{
|
||||
if (dm->cache_lock)
|
||||
{
|
||||
ASSERT (tag);
|
||||
ASSERT (dm->cache_lock_tag == 0);
|
||||
clib_spinlock_lock (&dm->cache_lock);
|
||||
dm->cache_lock_tag = tag;
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,6 +215,8 @@ dns_cache_unlock (dns_main_t * dm)
|
||||
{
|
||||
if (dm->cache_lock)
|
||||
{
|
||||
ASSERT (dm->cache_lock_tag);
|
||||
dm->cache_lock_tag = 0;
|
||||
clib_spinlock_unlock (&dm->cache_lock);
|
||||
}
|
||||
}
|
19
src/plugins/dns/dns_all_api_h.h
Normal file
19
src/plugins/dns/dns_all_api_h.h
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
/*
|
||||
* dns_all_api_h.h - skeleton vpp engine plug-in api #include file
|
||||
*
|
||||
* Copyright (c) <current-year> <your-organization>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
|
||||
#include <dns/dns.api.h>
|
31
src/plugins/dns/dns_msg_enum.h
Normal file
31
src/plugins/dns/dns_msg_enum.h
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
/*
|
||||
* dns_msg_enum.h - skeleton vpp engine plug-in message enumeration
|
||||
*
|
||||
* Copyright (c) <current-year> <your-organization>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef included_dns_msg_enum_h
|
||||
#define included_dns_msg_enum_h
|
||||
|
||||
#include <vppinfra/byte_order.h>
|
||||
|
||||
#define vl_msg_id(n,h) n,
|
||||
typedef enum {
|
||||
#include <dns/dns_all_api_h.h>
|
||||
/* We'll want to know how many messages IDs we need... */
|
||||
VL_MSG_FIRST_AVAILABLE,
|
||||
} vl_msg_id_t;
|
||||
#undef vl_msg_id
|
||||
|
||||
#endif /* included_dns_msg_enum_h */
|
346
src/plugins/dns/dns_test.c
Normal file
346
src/plugins/dns/dns_test.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vnet/dns/dns.h>
|
||||
#include <dns/dns.h>
|
||||
|
||||
#include <vlib/vlib.h>
|
||||
#include <vnet/vnet.h>
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vnet/dns/dns.h>
|
||||
#include <dns/dns.h>
|
||||
|
||||
#include <vlib/vlib.h>
|
||||
#include <vnet/vnet.h>
|
@ -13,36 +13,37 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vnet/dns/dns.h>
|
||||
#include <dns/dns.h>
|
||||
#include <vlibapi/api.h>
|
||||
#include <vlibmemory/api.h>
|
||||
|
||||
#include <vlib/vlib.h>
|
||||
#include <vnet/vnet.h>
|
||||
|
||||
#include <vnet/vnet_msg_enum.h>
|
||||
/* define message IDs */
|
||||
#include <dns/dns_msg_enum.h>
|
||||
|
||||
#define vl_typedefs /* define message structures */
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#include <dns/dns_all_api_h.h>
|
||||
#undef vl_typedefs
|
||||
|
||||
#define vl_endianfun /* define message structures */
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#include <dns/dns_all_api_h.h>
|
||||
#undef vl_endianfun
|
||||
|
||||
/* instantiate all the print functions we know about */
|
||||
#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
|
||||
#define vl_printfun
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#include <dns/dns_all_api_h.h>
|
||||
#undef vl_printfun
|
||||
|
||||
#include <vlibapi/api_helper_macros.h>
|
||||
|
||||
extern int
|
||||
int
|
||||
vnet_dns_response_to_reply (u8 * response,
|
||||
vl_api_dns_resolve_name_reply_t * rmp,
|
||||
u32 * min_ttlp);
|
||||
extern int
|
||||
int
|
||||
vnet_dns_response_to_name (u8 * response,
|
||||
vl_api_dns_resolve_ip_reply_t * rmp,
|
||||
u32 * min_ttlp);
|
||||
@ -69,7 +70,7 @@ resolve_event (dns_main_t * dm, f64 now, u8 * reply)
|
||||
|
||||
/* $$$ u16 limits cache to 65K entries, fix later multiple dst ports */
|
||||
pool_index = clib_net_to_host_u16 (d->id);
|
||||
dns_cache_lock (dm);
|
||||
dns_cache_lock (dm, 10);
|
||||
|
||||
if (pool_is_free_index (dm->entries, pool_index))
|
||||
{
|
||||
@ -197,7 +198,8 @@ reply:
|
||||
|
||||
rmp = vl_msg_api_alloc (sizeof (*rmp));
|
||||
rmp->_vl_msg_id =
|
||||
clib_host_to_net_u16 (VL_API_DNS_RESOLVE_NAME_REPLY);
|
||||
clib_host_to_net_u16 (VL_API_DNS_RESOLVE_NAME_REPLY
|
||||
+ dm->msg_id_base);
|
||||
rmp->context = pr->client_context;
|
||||
min_ttl = ~0;
|
||||
rv = vnet_dns_response_to_reply (ep->dns_response, rmp, &min_ttl);
|
||||
@ -218,7 +220,8 @@ reply:
|
||||
|
||||
rmp = vl_msg_api_alloc (sizeof (*rmp));
|
||||
rmp->_vl_msg_id =
|
||||
clib_host_to_net_u16 (VL_API_DNS_RESOLVE_IP_REPLY);
|
||||
clib_host_to_net_u16 (VL_API_DNS_RESOLVE_IP_REPLY
|
||||
+ dm->msg_id_base);
|
||||
rmp->context = pr->client_context;
|
||||
min_ttl = ~0;
|
||||
rv = vnet_dns_response_to_name (ep->dns_response, rmp, &min_ttl);
|
||||
@ -303,7 +306,7 @@ retry_scan (dns_main_t * dm, f64 now)
|
||||
|
||||
for (i = 0; i < vec_len (dm->unresolved_entries); i++)
|
||||
{
|
||||
dns_cache_lock (dm);
|
||||
dns_cache_lock (dm, 11);
|
||||
ep = pool_elt_at_index (dm->entries, dm->unresolved_entries[i]);
|
||||
|
||||
ASSERT ((ep->flags & DNS_CACHE_ENTRY_FLAG_VALID) == 0);
|
111
src/plugins/dns/test/test_dns.py
Normal file
111
src/plugins/dns/test/test_dns.py
Normal file
@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import unittest
|
||||
import socket
|
||||
|
||||
from framework import VppTestCase, VppTestRunner
|
||||
from ipaddress import *
|
||||
|
||||
import scapy.compat
|
||||
from scapy.contrib.mpls import MPLS
|
||||
from scapy.layers.inet import IP, UDP, TCP, ICMP, icmptypes, icmpcodes
|
||||
from scapy.layers.l2 import Ether
|
||||
from scapy.packet import Raw
|
||||
from scapy.layers.dns import DNSRR, DNS, DNSQR
|
||||
|
||||
|
||||
class TestDns(VppTestCase):
|
||||
""" Dns Test Cases """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestDns, cls).setUpClass()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(TestDns, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(TestDns, self).setUp()
|
||||
|
||||
self.create_pg_interfaces(range(1))
|
||||
|
||||
for i in self.pg_interfaces:
|
||||
i.admin_up()
|
||||
i.config_ip4()
|
||||
i.resolve_arp()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestDns, self).tearDown()
|
||||
|
||||
def create_stream(self, src_if):
|
||||
"""Create input packet stream for defined interface.
|
||||
|
||||
:param VppInterface src_if: Interface to create packet stream for.
|
||||
"""
|
||||
good_request = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
|
||||
IP(src=src_if.remote_ip4) /
|
||||
UDP(sport=1234, dport=53) /
|
||||
DNS(rd=1, qd=DNSQR(qname="bozo.clown.org")))
|
||||
|
||||
bad_request = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
|
||||
IP(src=src_if.remote_ip4) /
|
||||
UDP(sport=1234, dport=53) /
|
||||
DNS(rd=1, qd=DNSQR(qname="no.clown.org")))
|
||||
pkts = [good_request, bad_request]
|
||||
return pkts
|
||||
|
||||
def verify_capture(self, dst_if, capture):
|
||||
"""Verify captured input packet stream for defined interface.
|
||||
|
||||
:param VppInterface dst_if: Interface to verify captured packet stream
|
||||
for.
|
||||
:param list capture: Captured packet stream.
|
||||
"""
|
||||
self.logger.info("Verifying capture on interface %s" % dst_if.name)
|
||||
for packet in capture:
|
||||
dns = packet[DNS]
|
||||
self.assertEqual(dns.an[0].rdata, '1.2.3.4')
|
||||
|
||||
def test_dns_unittest(self):
|
||||
""" DNS Name Resolver Basic Functional Test """
|
||||
|
||||
# Set up an upstream name resolver. We won't actually go there
|
||||
self.vapi.dns_name_server_add_del(
|
||||
is_ip6=0, is_add=1, server_address=IPv4Address(u'8.8.8.8').packed)
|
||||
|
||||
# Enable name resolution
|
||||
self.vapi.dns_enable_disable(enable=1)
|
||||
|
||||
# Manually add a static dns cache entry
|
||||
self.logger.info(self.vapi.cli("dns cache add bozo.clown.org 1.2.3.4"))
|
||||
|
||||
# Test the binary API
|
||||
rv = self.vapi.dns_resolve_name(name='bozo.clown.org')
|
||||
self.assertEqual(rv.ip4_address, IPv4Address(u'1.2.3.4').packed)
|
||||
|
||||
# Configure 127.0.0.1/8 on the pg interface
|
||||
ip_addr_n = socket.inet_pton(socket.AF_INET, "127.0.0.1")
|
||||
|
||||
self.vapi.sw_interface_add_del_address(
|
||||
sw_if_index=self.pg0.sw_if_index,
|
||||
address=ip_addr_n, address_length=8)
|
||||
|
||||
# Send a couple of DNS request packets, one for bozo.clown.org
|
||||
# and one for no.clown.org which won't resolve
|
||||
|
||||
pkts = self.create_stream(self.pg0)
|
||||
self.pg0.add_stream(pkts)
|
||||
self.pg_enable_capture(self.pg_interfaces)
|
||||
|
||||
self.pg_start()
|
||||
pkts = self.pg0.get_capture(1)
|
||||
self.verify_capture(self.pg0, pkts)
|
||||
|
||||
# Make sure that the cache contents are correct
|
||||
str = self.vapi.cli("show dns cache verbose")
|
||||
self.assertIn('1.2.3.4', str)
|
||||
self.assertIn('[P] no.clown.org:', str)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(testRunner=VppTestRunner)
|
@ -2574,70 +2574,6 @@ static void vl_api_create_vhost_user_if_reply_t_handler_json
|
||||
vam->result_ready = 1;
|
||||
}
|
||||
|
||||
static void vl_api_dns_resolve_name_reply_t_handler
|
||||
(vl_api_dns_resolve_name_reply_t * mp)
|
||||
{
|
||||
vat_main_t *vam = &vat_main;
|
||||
i32 retval = ntohl (mp->retval);
|
||||
if (vam->async_mode)
|
||||
{
|
||||
vam->async_errors += (retval < 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
vam->retval = retval;
|
||||
vam->result_ready = 1;
|
||||
|
||||
if (retval == 0)
|
||||
{
|
||||
if (mp->ip4_set)
|
||||
clib_warning ("ip4 address %U", format_ip4_address,
|
||||
(ip4_address_t *) mp->ip4_address);
|
||||
if (mp->ip6_set)
|
||||
clib_warning ("ip6 address %U", format_ip6_address,
|
||||
(ip6_address_t *) mp->ip6_address);
|
||||
}
|
||||
else
|
||||
clib_warning ("retval %d", retval);
|
||||
}
|
||||
}
|
||||
|
||||
static void vl_api_dns_resolve_name_reply_t_handler_json
|
||||
(vl_api_dns_resolve_name_reply_t * mp)
|
||||
{
|
||||
clib_warning ("not implemented");
|
||||
}
|
||||
|
||||
static void vl_api_dns_resolve_ip_reply_t_handler
|
||||
(vl_api_dns_resolve_ip_reply_t * mp)
|
||||
{
|
||||
vat_main_t *vam = &vat_main;
|
||||
i32 retval = ntohl (mp->retval);
|
||||
if (vam->async_mode)
|
||||
{
|
||||
vam->async_errors += (retval < 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
vam->retval = retval;
|
||||
vam->result_ready = 1;
|
||||
|
||||
if (retval == 0)
|
||||
{
|
||||
clib_warning ("canonical name %s", mp->name);
|
||||
}
|
||||
else
|
||||
clib_warning ("retval %d", retval);
|
||||
}
|
||||
}
|
||||
|
||||
static void vl_api_dns_resolve_ip_reply_t_handler_json
|
||||
(vl_api_dns_resolve_ip_reply_t * mp)
|
||||
{
|
||||
clib_warning ("not implemented");
|
||||
}
|
||||
|
||||
|
||||
static void vl_api_ip_address_details_t_handler
|
||||
(vl_api_ip_address_details_t * mp)
|
||||
{
|
||||
@ -5265,8 +5201,6 @@ _(p2p_ethernet_del_reply) \
|
||||
_(lldp_config_reply) \
|
||||
_(sw_interface_set_lldp_reply) \
|
||||
_(tcp_configure_src_addresses_reply) \
|
||||
_(dns_enable_disable_reply) \
|
||||
_(dns_name_server_add_del_reply) \
|
||||
_(session_rule_add_del_reply) \
|
||||
_(ip_container_proxy_add_del_reply) \
|
||||
_(output_acl_set_interface_reply) \
|
||||
@ -5583,10 +5517,6 @@ _(LLDP_CONFIG_REPLY, lldp_config_reply) \
|
||||
_(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
|
||||
_(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
|
||||
_(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
|
||||
_(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
|
||||
_(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
|
||||
_(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
|
||||
_(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
|
||||
_(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
|
||||
_(SESSION_RULES_DETAILS, session_rules_details) \
|
||||
_(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
|
||||
@ -20952,172 +20882,6 @@ api_sock_init_shm (vat_main_t * vam)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
api_dns_enable_disable (vat_main_t * vam)
|
||||
{
|
||||
unformat_input_t *line_input = vam->input;
|
||||
vl_api_dns_enable_disable_t *mp;
|
||||
u8 enable_disable = 1;
|
||||
int ret;
|
||||
|
||||
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (line_input, "disable"))
|
||||
enable_disable = 0;
|
||||
if (unformat (line_input, "enable"))
|
||||
enable_disable = 1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/* Construct the API message */
|
||||
M (DNS_ENABLE_DISABLE, mp);
|
||||
mp->enable = enable_disable;
|
||||
|
||||
/* send it... */
|
||||
S (mp);
|
||||
/* Wait for the reply */
|
||||
W (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
api_dns_resolve_name (vat_main_t * vam)
|
||||
{
|
||||
unformat_input_t *line_input = vam->input;
|
||||
vl_api_dns_resolve_name_t *mp;
|
||||
u8 *name = 0;
|
||||
int ret;
|
||||
|
||||
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (line_input, "%s", &name))
|
||||
;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (vec_len (name) > 127)
|
||||
{
|
||||
errmsg ("name too long");
|
||||
return -99;
|
||||
}
|
||||
|
||||
/* Construct the API message */
|
||||
M (DNS_RESOLVE_NAME, mp);
|
||||
memcpy (mp->name, name, vec_len (name));
|
||||
vec_free (name);
|
||||
|
||||
/* send it... */
|
||||
S (mp);
|
||||
/* Wait for the reply */
|
||||
W (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
api_dns_resolve_ip (vat_main_t * vam)
|
||||
{
|
||||
unformat_input_t *line_input = vam->input;
|
||||
vl_api_dns_resolve_ip_t *mp;
|
||||
int is_ip6 = -1;
|
||||
ip4_address_t addr4;
|
||||
ip6_address_t addr6;
|
||||
int ret;
|
||||
|
||||
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
|
||||
is_ip6 = 1;
|
||||
else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
|
||||
is_ip6 = 0;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_ip6 == -1)
|
||||
{
|
||||
errmsg ("missing address");
|
||||
return -99;
|
||||
}
|
||||
|
||||
/* Construct the API message */
|
||||
M (DNS_RESOLVE_IP, mp);
|
||||
mp->is_ip6 = is_ip6;
|
||||
if (is_ip6)
|
||||
memcpy (mp->address, &addr6, sizeof (addr6));
|
||||
else
|
||||
memcpy (mp->address, &addr4, sizeof (addr4));
|
||||
|
||||
/* send it... */
|
||||
S (mp);
|
||||
/* Wait for the reply */
|
||||
W (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
api_dns_name_server_add_del (vat_main_t * vam)
|
||||
{
|
||||
unformat_input_t *i = vam->input;
|
||||
vl_api_dns_name_server_add_del_t *mp;
|
||||
u8 is_add = 1;
|
||||
ip6_address_t ip6_server;
|
||||
ip4_address_t ip4_server;
|
||||
int ip6_set = 0;
|
||||
int ip4_set = 0;
|
||||
int ret = 0;
|
||||
|
||||
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
|
||||
ip6_set = 1;
|
||||
else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
|
||||
ip4_set = 1;
|
||||
else if (unformat (i, "del"))
|
||||
is_add = 0;
|
||||
else
|
||||
{
|
||||
clib_warning ("parse error '%U'", format_unformat_error, i);
|
||||
return -99;
|
||||
}
|
||||
}
|
||||
|
||||
if (ip4_set && ip6_set)
|
||||
{
|
||||
errmsg ("Only one server address allowed per message");
|
||||
return -99;
|
||||
}
|
||||
if ((ip4_set + ip6_set) == 0)
|
||||
{
|
||||
errmsg ("Server address required");
|
||||
return -99;
|
||||
}
|
||||
|
||||
/* Construct the API message */
|
||||
M (DNS_NAME_SERVER_ADD_DEL, mp);
|
||||
|
||||
if (ip6_set)
|
||||
{
|
||||
memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
|
||||
mp->is_ip6 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
|
||||
mp->is_ip6 = 0;
|
||||
}
|
||||
|
||||
mp->is_add = is_add;
|
||||
|
||||
/* send it... */
|
||||
S (mp);
|
||||
|
||||
/* Wait for a reply, return good/bad news */
|
||||
W (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
|
||||
{
|
||||
@ -22382,12 +22146,6 @@ _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n
|
||||
_(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
|
||||
_(sock_init_shm, "size <nnn>") \
|
||||
_(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
|
||||
_(dns_enable_disable, "[enable][disable]") \
|
||||
_(dns_name_server_add_del, "<ip-address> [del]") \
|
||||
_(dns_resolve_name, "<hostname>") \
|
||||
_(dns_resolve_ip, "<ip4|ip6>") \
|
||||
_(dns_name_server_add_del, "<ip-address> [del]") \
|
||||
_(dns_resolve_name, "<hostname>") \
|
||||
_(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
|
||||
"<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
|
||||
_(session_rules_dump, "") \
|
||||
|
@ -1029,24 +1029,6 @@ list(APPEND VNET_HEADERS
|
||||
|
||||
list(APPEND VNET_API_FILES span/span.api)
|
||||
|
||||
##############################################################################
|
||||
# DNS proxy, API
|
||||
##############################################################################
|
||||
list(APPEND VNET_SOURCES
|
||||
dns/dns.c
|
||||
dns/dns.h
|
||||
dns/dns_packet.h
|
||||
dns/reply_node.c
|
||||
dns/request_node.c
|
||||
dns/resolver_process.c
|
||||
)
|
||||
|
||||
list(APPEND VNET_HEADERS
|
||||
dns/dns.h
|
||||
)
|
||||
|
||||
list(APPEND VNET_API_FILES dns/dns.api)
|
||||
|
||||
##############################################################################
|
||||
# Packet generator
|
||||
##############################################################################
|
||||
|
@ -62,7 +62,6 @@
|
||||
#include <vnet/policer/policer.api.h>
|
||||
#include <vnet/ethernet/p2p_ethernet.api.h>
|
||||
#include <vnet/tcp/tcp.api.h>
|
||||
#include <vnet/dns/dns.api.h>
|
||||
#include <vnet/udp/udp.api.h>
|
||||
#include <vnet/bier/bier.api.h>
|
||||
#include <vnet/ip/punt.api.h>
|
||||
|
@ -3637,29 +3637,6 @@ static void *vl_api_app_namespace_add_del_t_print
|
||||
FINISH;
|
||||
}
|
||||
|
||||
static void *vl_api_lldp_config_t_print
|
||||
(vl_api_lldp_config_t * mp, void *handle)
|
||||
{
|
||||
u8 *s;
|
||||
|
||||
s = format (0, "SCRIPT: lldp_config ");
|
||||
s = format (s, "system_name %s ", mp->system_name);
|
||||
s = format (s, "tx_hold %d ", ntohl (mp->tx_hold));
|
||||
s = format (s, "tx_interval %d ", ntohl (mp->tx_interval));
|
||||
FINISH;
|
||||
}
|
||||
|
||||
static void *vl_api_dns_enable_disable_t_print
|
||||
(vl_api_dns_enable_disable_t * mp, void *handle)
|
||||
{
|
||||
u8 *s;
|
||||
|
||||
s = format (0, "SCRIPT: dns_enable_disable ");
|
||||
s = format (s, "%s ", mp->enable ? "enable" : "disable");
|
||||
|
||||
FINISH;
|
||||
}
|
||||
|
||||
static void *vl_api_sw_interface_set_lldp_t_print
|
||||
(vl_api_sw_interface_set_lldp_t * mp, void *handle)
|
||||
{
|
||||
@ -3689,45 +3666,15 @@ static void *vl_api_sw_interface_set_lldp_t_print
|
||||
FINISH;
|
||||
}
|
||||
|
||||
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_lldp_config_t_print
|
||||
(vl_api_lldp_config_t * mp, void *handle)
|
||||
{
|
||||
u8 *s;
|
||||
|
||||
s = format (0, "SCRIPT: dns_name_server_add_del ");
|
||||
if (mp->is_ip6)
|
||||
s = format (s, "%U ", format_ip6_address,
|
||||
(ip6_address_t *) mp->server_address);
|
||||
else
|
||||
s = format (s, "%U ", format_ip4_address,
|
||||
(ip4_address_t *) mp->server_address);
|
||||
|
||||
if (mp->is_add == 0)
|
||||
s = format (s, "del ");
|
||||
|
||||
FINISH;
|
||||
}
|
||||
|
||||
static void *vl_api_dns_resolve_name_t_print
|
||||
(vl_api_dns_resolve_name_t * mp, void *handle)
|
||||
{
|
||||
u8 *s;
|
||||
|
||||
s = format (0, "SCRIPT: dns_resolve_name ");
|
||||
s = format (s, "%s ", mp->name);
|
||||
FINISH;
|
||||
}
|
||||
|
||||
static void *vl_api_dns_resolve_ip_t_print
|
||||
(vl_api_dns_resolve_ip_t * mp, void *handle)
|
||||
{
|
||||
u8 *s;
|
||||
|
||||
s = format (0, "SCRIPT: dns_resolve_ip ");
|
||||
if (mp->is_ip6)
|
||||
s = format (s, "%U ", format_ip6_address, mp->address);
|
||||
else
|
||||
s = format (s, "%U ", format_ip4_address, mp->address);
|
||||
s = format (0, "SCRIPT: lldp_config ");
|
||||
s = format (s, "system_name %s ", mp->system_name);
|
||||
s = format (s, "tx_hold %d ", ntohl (mp->tx_hold));
|
||||
s = format (s, "tx_interval %d ", ntohl (mp->tx_interval));
|
||||
FINISH;
|
||||
}
|
||||
|
||||
@ -4005,10 +3952,6 @@ _(TCP_CONFIGURE_SRC_ADDRESSES, tcp_configure_src_addresses) \
|
||||
_(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \
|
||||
_(LLDP_CONFIG, lldp_config) \
|
||||
_(SW_INTERFACE_SET_LLDP, sw_interface_set_lldp) \
|
||||
_(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) \
|
||||
_(SESSION_RULE_ADD_DEL, session_rule_add_del) \
|
||||
_(OUTPUT_ACL_SET_INTERFACE, output_acl_set_interface) \
|
||||
_(QOS_RECORD_ENABLE_DISABLE, qos_record_enable_disable) \
|
||||
|
Reference in New Issue
Block a user