*/
#include <vlib/vlib.h>
-#include <vnet/pg/pg.h>
#include <dhcp/dhcp_proxy.h>
#include <dhcp/dhcp6_packet.h>
#include <vnet/mfib/mfib_table.h>
ip_interface_address_t *ia = 0;
ip6_address_t *result = 0;
- /* *INDENT-OFF* */
foreach_ip_interface_address (lm, ia, sw_if_index,
1 /* honor unnumbered */,
({
break;
}
}));
- /* *INDENT-ON* */
return result;
}
dhcp_proxy_main_t *dpm = &dhcp_proxy_main;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
- u32 pkts_to_server = 0, pkts_to_client = 0, pkts_no_server = 0;
- u32 pkts_no_interface_address = 0, pkts_no_exceeding_max_hop = 0;
+ u32 pkts_to_server = 0, pkts_to_client = 0;
+ u32 pkts_no_interface_address = 0;
u32 pkts_no_src_address = 0;
u32 pkts_wrong_msg_type = 0;
u32 pkts_too_big = 0;
{
error0 = DHCPV6_PROXY_ERROR_NO_SERVER;
next0 = DHCPV6_PROXY_TO_SERVER_INPUT_NEXT_DROP;
- pkts_no_server++;
goto do_trace;
}
{
error0 = DHCPV6_RELAY_PKT_DROP_MAX_HOPS;
next0 = DHCPV6_PROXY_TO_SERVER_INPUT_NEXT_DROP;
- pkts_no_exceeding_max_hop++;
goto do_trace;
}
DHCPV6_PROXY_ERROR_ALLOC_FAIL, 1);
continue;
}
- VLIB_BUFFER_TRACE_TRAJECTORY_INIT (c0);
ci0 = vlib_get_buffer_index (vm, c0);
server = &proxy->dhcp_servers[ii];
return from_frame->n_vectors;
}
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE (dhcpv6_proxy_to_server_node, static) = {
.function = dhcpv6_proxy_to_server_input,
.name = "dhcpv6-proxy-to-server",
.unformat_buffer = unformat_dhcpv6_proxy_header,
#endif
};
-/* *INDENT-ON* */
static uword
dhcpv6_proxy_to_client_input (vlib_main_t * vm,
udp_header_t *u0, *u1 = 0;
dhcpv6_relay_hdr_t *h0;
ip6_header_t *ip1 = 0, *ip0;
- ip6_address_t _ia0, *ia0 = &_ia0;
+ ip6_address_t *ia0 = 0;
ip6_address_t client_address;
ethernet_interface_t *ei0;
ethernet_header_t *mac0;
u32 sw_if_index = ~0;
u32 original_sw_if_index = ~0;
vnet_sw_interface_t *si0;
+ u32 inner_vlan = (u32) ~ 0;
+ u32 outer_vlan = (u32) ~ 0;
u32 error0 = (u32) ~ 0;
vnet_sw_interface_t *swif;
dhcpv6_option_t *r0 = 0, *o;
vlib_buffer_advance (b0, -(sizeof (ethernet_header_t)));
si0 = vnet_get_sw_interface (vnm, original_sw_if_index);
if (si0->type == VNET_SW_INTERFACE_TYPE_SUB)
- vlib_buffer_advance (b0, -4 /* space for VLAN tag */ );
+ {
+ if (si0->sub.eth.flags.one_tag == 1)
+ {
+ vlib_buffer_advance (b0, -4 /* space for 1 VLAN tag */ );
+ outer_vlan = (si0->sub.eth.outer_vlan_id << 16) | 0x86dd;
+ }
+ else if (si0->sub.eth.flags.two_tags == 1)
+ {
+ vlib_buffer_advance (b0, -8 /* space for 2 VLAN tag */ );
+ outer_vlan = (si0->sub.eth.outer_vlan_id << 16) | 0x8100;
+ inner_vlan = (si0->sub.eth.inner_vlan_id << 16) | 0x86dd;
+ }
+ }
mac0 = vlib_buffer_get_current (b0);
hi0 = vnet_get_sup_hw_interface (vnm, original_sw_if_index);
ei0 = pool_elt_at_index (em->interfaces, hi0->hw_instance);
- clib_memcpy (mac0->src_address, ei0->address, sizeof (ei0->address));
+ clib_memcpy (mac0->src_address, &ei0->address,
+ sizeof (mac0->src_address));
clib_memset (&mac0->dst_address, 0xff, sizeof (mac0->dst_address));
- mac0->type = (si0->type == VNET_SW_INTERFACE_TYPE_SUB) ?
- clib_net_to_host_u16 (0x8100) : clib_net_to_host_u16 (0x86dd);
- if (si0->type == VNET_SW_INTERFACE_TYPE_SUB)
+ if (si0->type == VNET_SW_INTERFACE_TYPE_SUB && outer_vlan != (u32) ~ 0)
{
+ mac0->type = (si0->sub.eth.flags.dot1ad == 1) ?
+ clib_net_to_host_u16 (0x88a8) : clib_net_to_host_u16 (0x8100);
u32 *vlan_tag = (u32 *) (mac0 + 1);
- u32 tmp;
- tmp = (si0->sub.id << 16) | 0x0800;
- *vlan_tag = clib_host_to_net_u32 (tmp);
+ *vlan_tag = clib_host_to_net_u32 (outer_vlan);
+ if (inner_vlan != (u32) ~ 0)
+ {
+ u32 *inner_vlan_tag = (u32 *) (vlan_tag + 1);
+ *inner_vlan_tag = clib_host_to_net_u32 (inner_vlan);
+ }
+ }
+ else
+ {
+ mac0->type = clib_net_to_host_u16 (0x86dd);
}
/* $$$ consider adding a dynamic next to the graph node, for performance */
}
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE (dhcpv6_proxy_to_client_node, static) = {
.function = dhcpv6_proxy_to_client_input,
.name = "dhcpv6-proxy-to-client",
.unformat_buffer = unformat_dhcpv6_proxy_header,
#endif
};
-/* *INDENT-ON* */
static clib_error_t *
dhcp6_proxy_init (vlib_main_t * vm)
if (dhcp_proxy_server_add (FIB_PROTOCOL_IP6, addr, src_addr,
rx_fib_index, server_table_id))
{
- mfib_table_entry_path_update (rx_fib_index,
- &all_dhcp_servers,
- MFIB_SOURCE_DHCP, &path_for_us);
+ mfib_table_entry_path_update (rx_fib_index, &all_dhcp_servers,
+ MFIB_SOURCE_DHCP, MFIB_ENTRY_FLAG_NONE,
+ &path_for_us);
/*
* Each interface that is enabled in this table, needs to be added
* as an accepting interface, but this is not easily doable in VPP.
format_unformat_error, input);
}
-/* *INDENT-OFF* */
VLIB_CLI_COMMAND (dhcpv6_proxy_set_command, static) = {
.path = "set dhcpv6 proxy",
.short_help = "set dhcpv6 proxy [del] server <ipv6-addr> src-address <ipv6-addr> "
"[server-fib-id <fib-id>] [rx-fib-id <fib-id>] ",
.function = dhcpv6_proxy_set_command_fn,
};
-/* *INDENT-ON* */
static u8 *
format_dhcp6_proxy_server (u8 * s, va_list * args)
return (NULL);
}
-/* *INDENT-OFF* */
VLIB_CLI_COMMAND (dhcpv6_proxy_show_command, static) = {
.path = "show dhcpv6 proxy",
.short_help = "Display dhcpv6 proxy info",
.function = dhcpv6_proxy_show_command_fn,
};
-/* *INDENT-ON* */
static clib_error_t *
dhcpv6_vss_command_fn (vlib_main_t * vm,
}
}
-/* *INDENT-OFF* */
VLIB_CLI_COMMAND (dhcpv6_proxy_vss_command, static) = {
.path = "set dhcpv6 vss",
.short_help = "set dhcpv6 vss table <table-id> [oui <n> vpn-id <n> | vpn-ascii-id <text>]",
.function = dhcpv6_vss_command_fn,
};
-/* *INDENT-ON* */
static clib_error_t *
dhcpv6_vss_show_command_fn (vlib_main_t * vm,
return (NULL);
}
-/* *INDENT-OFF* */
VLIB_CLI_COMMAND (dhcpv6_proxy_vss_show_command, static) = {
.path = "show dhcpv6 vss",
.short_help = "show dhcpv6 VSS",
.function = dhcpv6_vss_show_command_fn,
};
-/* *INDENT-ON* */
static clib_error_t *
dhcpv6_link_address_show_command_fn (vlib_main_t * vm,
return 0;
}
-/* *INDENT-OFF* */
VLIB_CLI_COMMAND (dhcpv6_proxy_address_show_command, static) = {
.path = "show dhcpv6 link-address interface",
.short_help = "show dhcpv6 link-address interface <interface>",
.function = dhcpv6_link_address_show_command_fn,
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON