2 * ethernet/arp.c: IP v4 ARP node
4 * Copyright (c) 2010 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <vnet/arp/arp.h>
19 #include <vnet/arp/arp_packet.h>
21 #include <vnet/fib/ip4_fib.h>
22 #include <vnet/fib/fib_entry_src.h>
23 #include <vnet/adj/adj_nbr.h>
24 #include <vnet/adj/adj_mcast.h>
26 #include <vnet/ip-neighbor/ip_neighbor.h>
27 #include <vnet/ip-neighbor/ip_neighbor_dp.h>
29 #include <vlibmemory/api.h>
35 * This file contains code to manage the IPv4 ARP tables (IP Address
36 * to MAC Address lookup).
40 * @brief Per-interface ARP configuration and state
42 typedef struct ethernet_arp_interface_t_
45 * Is ARP enabled on this interface
48 } ethernet_arp_interface_t;
52 /* Hash tables mapping name to opcode. */
53 uword *opcode_by_name;
55 /** Per interface state */
56 ethernet_arp_interface_t *ethernet_arp_by_sw_if_index;
58 /* ARP feature arc index */
60 } ethernet_arp_main_t;
62 static ethernet_arp_main_t ethernet_arp_main;
64 static const u8 vrrp_prefix[] = { 0x00, 0x00, 0x5E, 0x00, 0x01 };
67 unformat_ethernet_arp_opcode_host_byte_order (unformat_input_t * input,
70 int *result = va_arg (*args, int *);
71 ethernet_arp_main_t *am = ðernet_arp_main;
75 if (unformat (input, "0x%x", &x) || unformat (input, "%d", &x))
84 if (unformat_user (input, unformat_vlib_number_by_name,
85 am->opcode_by_name, &i))
95 unformat_ethernet_arp_opcode_net_byte_order (unformat_input_t * input,
98 int *result = va_arg (*args, int *);
100 (input, unformat_ethernet_arp_opcode_host_byte_order, result))
103 *result = clib_host_to_net_u16 ((u16) * result);
110 } ethernet_arp_input_trace_t;
113 format_ethernet_arp_input_trace (u8 * s, va_list * va)
115 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
116 CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
117 ethernet_arp_input_trace_t *t = va_arg (*va, ethernet_arp_input_trace_t *);
120 format_ethernet_arp_header,
121 t->packet_data, sizeof (t->packet_data));
127 arp_is_enabled (ethernet_arp_main_t * am, u32 sw_if_index)
129 if (vec_len (am->ethernet_arp_by_sw_if_index) <= sw_if_index)
132 return (am->ethernet_arp_by_sw_if_index[sw_if_index].enabled);
136 arp_enable (ethernet_arp_main_t * am, u32 sw_if_index)
138 if (arp_is_enabled (am, sw_if_index))
141 vec_validate (am->ethernet_arp_by_sw_if_index, sw_if_index);
143 am->ethernet_arp_by_sw_if_index[sw_if_index].enabled = 1;
145 vnet_feature_enable_disable ("arp", "arp-reply", sw_if_index, 1, NULL, 0);
146 vnet_feature_enable_disable ("arp", "arp-disabled", sw_if_index, 0, NULL,
151 arp_disable (ethernet_arp_main_t * am, u32 sw_if_index)
153 if (!arp_is_enabled (am, sw_if_index))
156 vnet_feature_enable_disable ("arp", "arp-disabled", sw_if_index, 1, NULL,
158 vnet_feature_enable_disable ("arp", "arp-reply", sw_if_index, 0, NULL, 0);
160 am->ethernet_arp_by_sw_if_index[sw_if_index].enabled = 0;
164 arp_unnumbered (vlib_buffer_t * p0,
165 u32 input_sw_if_index, u32 conn_sw_if_index)
167 vnet_main_t *vnm = vnet_get_main ();
168 vnet_interface_main_t *vim = &vnm->interface_main;
169 vnet_sw_interface_t *si;
171 /* verify that the input interface is unnumbered to the connected.
172 * the connected interface is the interface on which the subnet is
174 si = &vim->sw_interfaces[input_sw_if_index];
176 if (!(si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED &&
177 (si->unnumbered_sw_if_index == conn_sw_if_index)))
179 /* the input interface is not unnumbered to the interface on which
180 * the sub-net is configured that covers the ARP request.
181 * So this is not the case for unnumbered.. */
189 arp_learn (u32 sw_if_index,
190 const ethernet_arp_ip4_over_ethernet_address_t * addr)
193 ip_neighbor_learn_t l = {
199 .sw_if_index = sw_if_index,
203 ip_neighbor_learn_dp (&l);
205 return (ETHERNET_ARP_ERROR_l3_src_address_learned);
208 typedef enum arp_input_next_t_
211 ARP_INPUT_NEXT_DISABLED,
216 arp_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
218 u32 n_left_from, next_index, *from, *to_next, n_left_to_next;
219 ethernet_arp_main_t *am = ðernet_arp_main;
221 from = vlib_frame_vector_args (frame);
222 n_left_from = frame->n_vectors;
223 next_index = node->cached_next_index;
225 if (node->flags & VLIB_NODE_FLAG_TRACE)
226 vlib_trace_frame_buffers_only (vm, node, from, frame->n_vectors,
228 sizeof (ethernet_arp_input_trace_t));
230 while (n_left_from > 0)
232 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
234 while (n_left_from > 0 && n_left_to_next > 0)
236 const ethernet_arp_header_t *arp0;
237 arp_input_next_t next0;
241 pi0 = to_next[0] = from[0];
247 p0 = vlib_get_buffer (vm, pi0);
248 arp0 = vlib_buffer_get_current (p0);
250 error0 = ETHERNET_ARP_ERROR_replies_sent;
251 next0 = ARP_INPUT_NEXT_DROP;
255 clib_net_to_host_u16 (ETHERNET_ARP_HARDWARE_TYPE_ethernet) ?
256 ETHERNET_ARP_ERROR_l2_type_not_ethernet : error0);
259 clib_net_to_host_u16 (ETHERNET_TYPE_IP4) ?
260 ETHERNET_ARP_ERROR_l3_type_not_ip4 : error0);
262 (0 == arp0->ip4_over_ethernet[0].ip4.as_u32 ?
263 ETHERNET_ARP_ERROR_l3_dst_address_unset : error0);
265 if (ETHERNET_ARP_ERROR_replies_sent == error0)
267 next0 = ARP_INPUT_NEXT_DISABLED;
268 vnet_feature_arc_start (am->feature_arc_index,
269 vnet_buffer (p0)->sw_if_index[VLIB_RX],
273 p0->error = node->errors[error0];
275 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
276 n_left_to_next, pi0, next0);
279 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
282 return frame->n_vectors;
285 typedef enum arp_disabled_next_t_
287 ARP_DISABLED_NEXT_DROP,
289 } arp_disabled_next_t;
291 #define foreach_arp_disabled_error \
292 _ (DISABLED, "ARP Disabled on this interface") \
296 #define _(sym,string) ARP_DISABLED_ERROR_##sym,
297 foreach_arp_disabled_error
299 ARP_DISABLED_N_ERROR,
300 } arp_disabled_error_t;
302 static char *arp_disabled_error_strings[] = {
303 #define _(sym,string) string,
304 foreach_arp_disabled_error
309 arp_disabled (vlib_main_t * vm,
310 vlib_node_runtime_t * node, vlib_frame_t * frame)
312 u32 n_left_from, next_index, *from, *to_next, n_left_to_next;
314 from = vlib_frame_vector_args (frame);
315 n_left_from = frame->n_vectors;
316 next_index = node->cached_next_index;
318 if (node->flags & VLIB_NODE_FLAG_TRACE)
319 vlib_trace_frame_buffers_only (vm, node, from, frame->n_vectors,
321 sizeof (ethernet_arp_input_trace_t));
323 while (n_left_from > 0)
325 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
327 while (n_left_from > 0 && n_left_to_next > 0)
329 arp_disabled_next_t next0 = ARP_DISABLED_NEXT_DROP;
333 next0 = ARP_DISABLED_NEXT_DROP;
334 error0 = ARP_DISABLED_ERROR_DISABLED;
336 pi0 = to_next[0] = from[0];
342 p0 = vlib_get_buffer (vm, pi0);
343 p0->error = node->errors[error0];
345 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
346 n_left_to_next, pi0, next0);
349 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
352 return frame->n_vectors;
355 enum arp_dst_fib_type
363 * we're looking for FIB sources that indicate the destination
364 * is attached. There may be interposed DPO prior to the one
367 static enum arp_dst_fib_type
368 arp_dst_fib_check (const fib_node_index_t fei, fib_entry_flag_t * flags)
370 const fib_entry_t *entry = fib_entry_get (fei);
371 const fib_entry_src_t *entry_src;
374 FOR_EACH_SRC_ADDED(entry, entry_src, src,
376 *flags = fib_entry_get_flags_for_source (fei, src);
377 if (fib_entry_is_sourced (fei, FIB_SOURCE_ADJ))
378 return ARP_DST_FIB_ADJ;
379 else if (FIB_ENTRY_FLAG_CONNECTED & *flags)
380 return ARP_DST_FIB_CONN;
384 return ARP_DST_FIB_NONE;
388 arp_reply (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
390 vnet_main_t *vnm = vnet_get_main ();
391 u32 n_left_from, next_index, *from, *to_next;
392 u32 n_replies_sent = 0;
394 from = vlib_frame_vector_args (frame);
395 n_left_from = frame->n_vectors;
396 next_index = node->cached_next_index;
398 if (node->flags & VLIB_NODE_FLAG_TRACE)
399 vlib_trace_frame_buffers_only (vm, node, from, frame->n_vectors,
401 sizeof (ethernet_arp_input_trace_t));
403 while (n_left_from > 0)
407 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
409 while (n_left_from > 0 && n_left_to_next > 0)
412 ethernet_arp_header_t *arp0;
413 ethernet_header_t *eth_rx;
414 const ip4_address_t *if_addr0;
415 u32 pi0, error0, next0, sw_if_index0, conn_sw_if_index0, fib_index0;
416 u8 dst_is_local0, is_vrrp_reply0;
417 fib_node_index_t dst_fei, src_fei;
418 const fib_prefix_t *pfx0;
419 fib_entry_flag_t src_flags, dst_flags;
428 p0 = vlib_get_buffer (vm, pi0);
429 arp0 = vlib_buffer_get_current (p0);
430 /* Fill in ethernet header. */
431 eth_rx = ethernet_buffer_get_header (p0);
433 next0 = ARP_REPLY_NEXT_DROP;
434 error0 = ETHERNET_ARP_ERROR_replies_sent;
435 sw_if_index0 = vnet_buffer (p0)->sw_if_index[VLIB_RX];
437 /* Check that IP address is local and matches incoming interface. */
438 fib_index0 = ip4_fib_table_get_index_for_sw_if_index (sw_if_index0);
439 if (~0 == fib_index0)
441 error0 = ETHERNET_ARP_ERROR_interface_no_table;
448 * we're looking for FIB entries that indicate the source
449 * is attached. There may be more specific non-attached
450 * routes that match the source, but these do not influence
451 * whether we respond to an ARP request, i.e. they do not
452 * influence whether we are the correct way for the sender
453 * to reach us, they only affect how we reach the sender.
455 fib_entry_t *src_fib_entry;
456 const fib_prefix_t *pfx;
457 fib_entry_src_t *src;
467 src_fei = ip4_fib_table_lookup (ip4_fib_get (fib_index0),
469 ip4_over_ethernet[0].ip4,
471 src_fib_entry = fib_entry_get (src_fei);
474 * It's possible that the source that provides the
475 * flags we need, or the flags we must not have,
476 * is not the best source, so check then all.
479 FOR_EACH_SRC_ADDED(src_fib_entry, src, source,
481 src_flags = fib_entry_get_flags_for_source (src_fei, source);
483 /* Reject requests/replies with our local interface
485 if (FIB_ENTRY_FLAG_LOCAL & src_flags)
487 error0 = ETHERNET_ARP_ERROR_l3_src_address_is_local;
489 * When VPP has an interface whose address is also
490 * applied to a TAP interface on the host, then VPP's
491 * TAP interface will be unnumbered to the 'real'
492 * interface and do proxy ARP from the host.
493 * The curious aspect of this setup is that ARP requests
494 * from the host will come from the VPP's own address.
495 * So don't drop immediately here, instead go see if this
496 * is a proxy ARP case.
500 /* A Source must also be local to subnet of matching
501 * interface address. */
502 if ((FIB_ENTRY_FLAG_ATTACHED & src_flags) ||
503 (FIB_ENTRY_FLAG_CONNECTED & src_flags))
510 * The packet was sent from an address that is not
511 * connected nor attached i.e. it is not from an
512 * address that is covered by a link's sub-net,
513 * nor is it a already learned host resp.
519 * shorter mask lookup for the next iteration.
521 pfx = fib_entry_get_prefix (src_fei);
522 mask = pfx->fp_len - 1;
525 * continue until we hit the default route or we find
526 * the attached we are looking for. The most likely
527 * outcome is we find the attached with the first source
528 * on the first lookup.
532 !fib_entry_is_sourced (src_fei, FIB_SOURCE_DEFAULT_ROUTE));
537 * the matching route is a not attached, i.e. it was
538 * added as a result of routing, rather than interface/ARP
539 * configuration. If the matching route is not a host route
542 error0 = ETHERNET_ARP_ERROR_l3_src_address_not_local;
547 dst_fei = ip4_fib_table_lookup (ip4_fib_get (fib_index0),
548 &arp0->ip4_over_ethernet[1].ip4,
550 conn_sw_if_index0 = fib_entry_get_any_resolving_interface (dst_fei);
552 switch (arp_dst_fib_check (dst_fei, &dst_flags))
554 case ARP_DST_FIB_ADJ:
556 * We matched an adj-fib on ths source subnet (a /32 previously
557 * added as a result of ARP). If this request is a gratuitous
558 * ARP, then learn from it.
559 * The check for matching an adj-fib, is to prevent hosts
560 * from spamming us with gratuitous ARPS that might otherwise
563 if (conn_sw_if_index0 != sw_if_index0)
564 error0 = ETHERNET_ARP_ERROR_l3_dst_address_not_local;
565 else if (arp0->ip4_over_ethernet[0].ip4.as_u32 ==
566 arp0->ip4_over_ethernet[1].ip4.as_u32)
567 error0 = arp_learn (sw_if_index0,
568 &arp0->ip4_over_ethernet[0]);
570 case ARP_DST_FIB_CONN:
571 /* destination is connected, continue to process */
573 case ARP_DST_FIB_NONE:
574 /* destination is not connected, stop here */
575 error0 = ETHERNET_ARP_ERROR_l3_dst_address_not_local;
579 dst_is_local0 = (FIB_ENTRY_FLAG_LOCAL & dst_flags);
580 pfx0 = fib_entry_get_prefix (dst_fei);
581 if_addr0 = &pfx0->fp_addr.ip4;
585 clib_host_to_net_u16 (ETHERNET_ARP_OPCODE_reply))
588 (arp0->ip4_over_ethernet[0].mac.bytes, vrrp_prefix,
589 sizeof (vrrp_prefix))));
591 /* Trash ARP packets whose ARP-level source addresses do not
592 match their L2-frame-level source addresses, unless it's
593 a reply from a VRRP virtual router */
594 if (!ethernet_mac_address_equal
595 (eth_rx->src_address,
596 arp0->ip4_over_ethernet[0].mac.bytes) && !is_vrrp_reply0)
598 error0 = ETHERNET_ARP_ERROR_l2_address_mismatch;
602 /* Learn or update sender's mapping only for replies to addresses
603 * that are local to the subnet */
605 clib_host_to_net_u16 (ETHERNET_ARP_OPCODE_reply))
609 arp_learn (sw_if_index0, &arp0->ip4_over_ethernet[0]);
611 /* a reply for a non-local destination could be a GARP.
612 * GARPs for hosts we know were handled above, so this one
614 error0 = ETHERNET_ARP_ERROR_l3_dst_address_not_local;
618 else if (arp0->opcode ==
619 clib_host_to_net_u16 (ETHERNET_ARP_OPCODE_request) &&
620 (dst_is_local0 == 0))
625 /* Honor unnumbered interface, if any */
626 if (sw_if_index0 != conn_sw_if_index0 ||
627 sw_if_index0 != fib_entry_get_resolving_interface (src_fei))
630 * The interface the ARP is sent to or was received on is not the
631 * interface on which the covering prefix is configured.
632 * Maybe this is a case for unnumbered.
634 if (!arp_unnumbered (p0, sw_if_index0, conn_sw_if_index0))
636 error0 = ETHERNET_ARP_ERROR_unnumbered_mismatch;
640 if (arp0->ip4_over_ethernet[0].ip4.as_u32 ==
641 arp0->ip4_over_ethernet[1].ip4.as_u32)
643 error0 = ETHERNET_ARP_ERROR_gratuitous_arp;
647 next0 = arp_mk_reply (vnm, p0, sw_if_index0,
648 if_addr0, arp0, eth_rx);
650 /* We are going to reply to this request, so, in the absence of
651 errors, learn the sender */
653 error0 = arp_learn (sw_if_index0, &arp0->ip4_over_ethernet[1]);
659 vnet_feature_next (&next0, p0);
663 p0->error = node->errors[error0];
666 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
667 n_left_to_next, pi0, next0);
670 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
673 vlib_error_count (vm, node->node_index,
674 ETHERNET_ARP_ERROR_replies_sent, n_replies_sent);
676 return frame->n_vectors;
680 static char *ethernet_arp_error_strings[] = {
681 #define _(sym,string) string,
682 foreach_ethernet_arp_error
688 VLIB_REGISTER_NODE (arp_input_node, static) =
690 .function = arp_input,
692 .vector_size = sizeof (u32),
693 .n_errors = ETHERNET_ARP_N_ERROR,
694 .error_strings = ethernet_arp_error_strings,
695 .n_next_nodes = ARP_INPUT_N_NEXT,
697 [ARP_INPUT_NEXT_DROP] = "error-drop",
698 [ARP_INPUT_NEXT_DISABLED] = "arp-disabled",
700 .format_buffer = format_ethernet_arp_header,
701 .format_trace = format_ethernet_arp_input_trace,
704 VLIB_REGISTER_NODE (arp_disabled_node, static) =
706 .function = arp_disabled,
707 .name = "arp-disabled",
708 .vector_size = sizeof (u32),
709 .n_errors = ARP_DISABLED_N_ERROR,
710 .error_strings = arp_disabled_error_strings,
711 .n_next_nodes = ARP_DISABLED_N_NEXT,
713 [ARP_INPUT_NEXT_DROP] = "error-drop",
715 .format_buffer = format_ethernet_arp_header,
716 .format_trace = format_ethernet_arp_input_trace,
719 VLIB_REGISTER_NODE (arp_reply_node, static) =
721 .function = arp_reply,
723 .vector_size = sizeof (u32),
724 .n_errors = ETHERNET_ARP_N_ERROR,
725 .error_strings = ethernet_arp_error_strings,
726 .n_next_nodes = ARP_REPLY_N_NEXT,
728 [ARP_REPLY_NEXT_DROP] = "error-drop",
729 [ARP_REPLY_NEXT_REPLY_TX] = "interface-output",
731 .format_buffer = format_ethernet_arp_header,
732 .format_trace = format_ethernet_arp_input_trace,
735 /* Built-in ARP rx feature path definition */
736 VNET_FEATURE_ARC_INIT (arp_feat, static) =
739 .start_nodes = VNET_FEATURES ("arp-input"),
740 .last_in_arc = "error-drop",
741 .arc_index_ptr = ðernet_arp_main.feature_arc_index,
744 VNET_FEATURE_INIT (arp_reply_feat_node, static) =
747 .node_name = "arp-reply",
748 .runs_before = VNET_FEATURES ("arp-disabled"),
751 VNET_FEATURE_INIT (arp_proxy_feat_node, static) =
754 .node_name = "arp-proxy",
755 .runs_after = VNET_FEATURES ("arp-reply"),
756 .runs_before = VNET_FEATURES ("arp-disabled"),
759 VNET_FEATURE_INIT (arp_disabled_feat_node, static) =
762 .node_name = "arp-disabled",
763 .runs_before = VNET_FEATURES ("error-drop"),
766 VNET_FEATURE_INIT (arp_drop_feat_node, static) =
769 .node_name = "error-drop",
770 .runs_before = 0, /* last feature */
777 pg_edit_t l2_type, l3_type;
778 pg_edit_t n_l2_address_bytes, n_l3_address_bytes;
784 } ip4_over_ethernet[2];
785 } pg_ethernet_arp_header_t;
788 pg_ethernet_arp_header_init (pg_ethernet_arp_header_t * p)
790 /* Initialize fields that are not bit fields in the IP header. */
791 #define _(f) pg_edit_init (&p->f, ethernet_arp_header_t, f);
794 _(n_l2_address_bytes);
795 _(n_l3_address_bytes);
797 _(ip4_over_ethernet[0].mac);
798 _(ip4_over_ethernet[0].ip4);
799 _(ip4_over_ethernet[1].mac);
800 _(ip4_over_ethernet[1].ip4);
805 unformat_pg_arp_header (unformat_input_t * input, va_list * args)
807 pg_stream_t *s = va_arg (*args, pg_stream_t *);
808 pg_ethernet_arp_header_t *p;
811 p = pg_create_edit_group (s, sizeof (p[0]), sizeof (ethernet_arp_header_t),
813 pg_ethernet_arp_header_init (p);
816 pg_edit_set_fixed (&p->l2_type, ETHERNET_ARP_HARDWARE_TYPE_ethernet);
817 pg_edit_set_fixed (&p->l3_type, ETHERNET_TYPE_IP4);
818 pg_edit_set_fixed (&p->n_l2_address_bytes, 6);
819 pg_edit_set_fixed (&p->n_l3_address_bytes, 4);
821 if (!unformat (input, "%U: %U/%U -> %U/%U",
823 unformat_ethernet_arp_opcode_net_byte_order, &p->opcode,
825 unformat_mac_address_t, &p->ip4_over_ethernet[0].mac,
827 unformat_ip4_address, &p->ip4_over_ethernet[0].ip4,
829 unformat_mac_address_t, &p->ip4_over_ethernet[1].mac,
831 unformat_ip4_address, &p->ip4_over_ethernet[1].ip4))
833 /* Free up any edits we may have added. */
834 pg_free_edit_group (s);
841 * callback when an interface address is added or deleted
844 arp_enable_disable_interface (ip4_main_t * im,
845 uword opaque, u32 sw_if_index, u32 is_enable)
847 ethernet_arp_main_t *am = ðernet_arp_main;
850 arp_enable (am, sw_if_index);
852 arp_disable (am, sw_if_index);
856 * Remove any arp entries associated with the specified interface
858 static clib_error_t *
859 vnet_arp_add_del_sw_interface (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
861 ethernet_arp_main_t *am = ðernet_arp_main;
863 arp_disable (am, sw_if_index);
867 VNET_SW_INTERFACE_ADD_DEL_FUNCTION (vnet_arp_add_del_sw_interface);
869 const static ip_neighbor_vft_t arp_vft = {
870 .inv_proxy4_add = arp_proxy_add,
871 .inv_proxy4_del = arp_proxy_del,
872 .inv_proxy4_enable = arp_proxy_disable,
873 .inv_proxy4_disable = arp_proxy_disable,
876 static clib_error_t *
877 ethernet_arp_init (vlib_main_t * vm)
879 ethernet_arp_main_t *am = ðernet_arp_main;
880 ip4_main_t *im = &ip4_main;
883 ethernet_register_input_type (vm, ETHERNET_TYPE_ARP, arp_input_node.index);
885 pn = pg_get_node (arp_input_node.index);
886 pn->unformat_edit = unformat_pg_arp_header;
888 am->opcode_by_name = hash_create_string (0, sizeof (uword));
889 #define _(o) hash_set_mem (am->opcode_by_name, #o, ETHERNET_ARP_OPCODE_##o);
890 foreach_ethernet_arp_opcode;
893 /* don't trace ARP error packets */
895 vlib_node_runtime_t *rt =
896 vlib_node_get_runtime (vm, arp_input_node.index);
899 vnet_pcap_drop_trace_filter_add_del \
900 (rt->errors[ETHERNET_ARP_ERROR_##a], \
902 foreach_ethernet_arp_error
907 ip4_enable_disable_interface_callback_t cb = {
908 .function = arp_enable_disable_interface,
910 vec_add1 (im->enable_disable_interface_callbacks, cb);
913 ip_neighbor_register (AF_IP4, &arp_vft);
919 VLIB_INIT_FUNCTION (ethernet_arp_init) =
921 .runs_after = VLIB_INITS("ethernet_init",
927 * fd.io coding-style-patch-verification: ON
930 * eval: (c-set-style "gnu")