Run clang-format on all files.
This commit is contained in:
		
							
								
								
									
										12
									
								
								lcpng.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								lcpng.c
									
									
									
									
									
								
							| @@ -23,7 +23,9 @@ | |||||||
|  |  | ||||||
| lcp_main_t lcp_main; | lcp_main_t lcp_main; | ||||||
|  |  | ||||||
| u8 *lcp_get_default_ns(void) { | u8 * | ||||||
|  | lcp_get_default_ns (void) | ||||||
|  | { | ||||||
|   lcp_main_t *lcpm = &lcp_main; |   lcp_main_t *lcpm = &lcp_main; | ||||||
|  |  | ||||||
|   if (!lcpm->default_namespace || lcpm->default_namespace[0] == 0) |   if (!lcpm->default_namespace || lcpm->default_namespace[0] == 0) | ||||||
| @@ -31,7 +33,9 @@ u8 *lcp_get_default_ns(void) { | |||||||
|   return lcpm->default_namespace; |   return lcpm->default_namespace; | ||||||
| } | } | ||||||
|  |  | ||||||
| int lcp_get_default_ns_fd(void) { | int | ||||||
|  | lcp_get_default_ns_fd (void) | ||||||
|  | { | ||||||
|   lcp_main_t *lcpm = &lcp_main; |   lcp_main_t *lcpm = &lcp_main; | ||||||
|  |  | ||||||
|   return lcpm->default_ns_fd; |   return lcpm->default_ns_fd; | ||||||
| @@ -40,7 +44,9 @@ int lcp_get_default_ns_fd(void) { | |||||||
| /* | /* | ||||||
|  * ns is expected to be or look like a NUL-terminated C string. |  * ns is expected to be or look like a NUL-terminated C string. | ||||||
|  */ |  */ | ||||||
| int lcp_set_default_ns(u8 *ns) { | int | ||||||
|  | lcp_set_default_ns (u8 *ns) | ||||||
|  | { | ||||||
|   lcp_main_t *lcpm = &lcp_main; |   lcp_main_t *lcpm = &lcp_main; | ||||||
|   char *p; |   char *p; | ||||||
|   int len; |   int len; | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								lcpng.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								lcpng.h
									
									
									
									
									
								
							| @@ -35,9 +35,9 @@ extern lcp_main_t lcp_main; | |||||||
| /** | /** | ||||||
|  * Get/Set the default namespace for LCP host taps. |  * Get/Set the default namespace for LCP host taps. | ||||||
|  */ |  */ | ||||||
| int lcp_set_default_ns(u8 *ns); | int lcp_set_default_ns (u8 *ns); | ||||||
| u8 *lcp_get_default_ns(void); /* Returns NULL or shared string */ | u8 *lcp_get_default_ns (void); /* Returns NULL or shared string */ | ||||||
| int lcp_get_default_ns_fd(void); | int lcp_get_default_ns_fd (void); | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Sync state from VPP into all LCP devices |  * Sync state from VPP into all LCP devices | ||||||
|   | |||||||
| @@ -185,13 +185,13 @@ lcp_adj_show_cmd (vlib_main_t *vm, unformat_input_t *input, | |||||||
|   if (unformat (input, "verbose")) |   if (unformat (input, "verbose")) | ||||||
|     verbose = 1; |     verbose = 1; | ||||||
|  |  | ||||||
|   vlib_cli_output(vm, "lcp Adjs:\n%U", BV(format_bihash), &lcp_adj_tbl, |   vlib_cli_output (vm, "lcp Adjs:\n%U", BV (format_bihash), &lcp_adj_tbl, | ||||||
| 		   verbose); | 		   verbose); | ||||||
|  |  | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| VLIB_CLI_COMMAND(lcp_itf_pair_show_cmd_node, static) = { | VLIB_CLI_COMMAND (lcp_itf_pair_show_cmd_node, static) = { | ||||||
|   .path = "show lcp adj", |   .path = "show lcp adj", | ||||||
|   .function = lcp_adj_show_cmd, |   .function = lcp_adj_show_cmd, | ||||||
|   .short_help = "show lcp adj", |   .short_help = "show lcp adj", | ||||||
| @@ -210,7 +210,7 @@ lcp_adj_init (vlib_main_t *vm) | |||||||
| { | { | ||||||
|   adj_type = adj_delegate_register_new_type (&lcp_adj_vft); |   adj_type = adj_delegate_register_new_type (&lcp_adj_vft); | ||||||
|  |  | ||||||
|   BV(clib_bihash_init)(&lcp_adj_tbl, "lcp ADJ table", 1024, 1 << 24); |   BV (clib_bihash_init) (&lcp_adj_tbl, "lcp ADJ table", 1024, 1 << 24); | ||||||
|   BV (clib_bihash_set_kvp_format_fn) (&lcp_adj_tbl, format_lcp_adj_kvp); |   BV (clib_bihash_set_kvp_format_fn) (&lcp_adj_tbl, format_lcp_adj_kvp); | ||||||
|  |  | ||||||
|   return (NULL); |   return (NULL); | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								lcpng_if.api
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								lcpng_if.api
									
									
									
									
									
								
							| @@ -134,9 +134,10 @@ autoendian define lcp_itf_pair_details | |||||||
|   string netns[32]; /* LCP_NS_LEN */ |   string netns[32]; /* LCP_NS_LEN */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| service { | service | ||||||
|   rpc lcp_itf_pair_get returns lcp_itf_pair_get_reply | { | ||||||
|     stream lcp_itf_pair_details; |   rpc lcp_itf_pair_get returns lcp_itf_pair_get_reply stream | ||||||
|  |     lcp_itf_pair_details; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /** \brief Replace end/begin | /** \brief Replace end/begin | ||||||
| @@ -155,14 +156,17 @@ autoreply define lcp_itf_pair_replace_end | |||||||
| /* | /* | ||||||
|  * Linux-CP Error counters/messages |  * Linux-CP Error counters/messages | ||||||
|  */ |  */ | ||||||
| counters linuxcp { | counters linuxcp | ||||||
|   packets { | { | ||||||
|  |   packets | ||||||
|  |   { | ||||||
|     severity info; |     severity info; | ||||||
|     type counter64; |     type counter64; | ||||||
|     units "packets"; |     units "packets"; | ||||||
|     description "ARP packets processed"; |     description "ARP packets processed"; | ||||||
|   }; |   }; | ||||||
|   copies { |   copies | ||||||
|  |   { | ||||||
|     severity info; |     severity info; | ||||||
|     type counter64; |     type counter64; | ||||||
|     units "packets"; |     units "packets"; | ||||||
| @@ -170,9 +174,12 @@ counters linuxcp { | |||||||
|   }; |   }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| paths { | paths | ||||||
|   "/err/linux-cp-arp-phy" "linuxcp"; | { | ||||||
|   "/err/linux-cp-arp-host" "linuxcp"; |   "/err/linux-cp-arp-phy" | ||||||
|  |   "linuxcp"; | ||||||
|  |   "/err/linux-cp-arp-host" | ||||||
|  |   "linuxcp"; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
|   | |||||||
| @@ -162,18 +162,20 @@ vl_api_lcp_itf_pair_get_t_handler (vl_api_lcp_itf_pair_get_t *mp) | |||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| vl_api_lcp_default_ns_set_t_handler(vl_api_lcp_default_ns_set_t *mp) { | vl_api_lcp_default_ns_set_t_handler (vl_api_lcp_default_ns_set_t *mp) | ||||||
|  | { | ||||||
|   vl_api_lcp_default_ns_set_reply_t *rmp; |   vl_api_lcp_default_ns_set_reply_t *rmp; | ||||||
|   int rv; |   int rv; | ||||||
|  |  | ||||||
|   mp->netns[LCP_NS_LEN - 1] = 0; |   mp->netns[LCP_NS_LEN - 1] = 0; | ||||||
|   rv = lcp_set_default_ns (mp->netns); |   rv = lcp_set_default_ns (mp->netns); | ||||||
|  |  | ||||||
|   REPLY_MACRO(VL_API_LCP_DEFAULT_NS_SET_REPLY); |   REPLY_MACRO (VL_API_LCP_DEFAULT_NS_SET_REPLY); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| vl_api_lcp_default_ns_get_t_handler(vl_api_lcp_default_ns_get_t *mp) { | vl_api_lcp_default_ns_get_t_handler (vl_api_lcp_default_ns_get_t *mp) | ||||||
|  | { | ||||||
|   vl_api_lcp_default_ns_get_reply_t *rmp; |   vl_api_lcp_default_ns_get_reply_t *rmp; | ||||||
|   vl_api_registration_t *reg; |   vl_api_registration_t *reg; | ||||||
|   char *ns; |   char *ns; | ||||||
|   | |||||||
| @@ -99,12 +99,12 @@ lcp_itf_pair_create_command_fn (vlib_main_t *vm, unformat_input_t *input, | |||||||
|   vec_free (ns); |   vec_free (ns); | ||||||
|  |  | ||||||
|   if (r) |   if (r) | ||||||
|     return clib_error_return(0, "lcp pair creation failed (%d)", r); |     return clib_error_return (0, "lcp pair creation failed (%d)", r); | ||||||
|  |  | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| VLIB_CLI_COMMAND(lcp_itf_pair_create_command, static) = { | VLIB_CLI_COMMAND (lcp_itf_pair_create_command, static) = { | ||||||
|   .path = "lcp create", |   .path = "lcp create", | ||||||
|   .short_help = "lcp create <sw_if_index>|<if-name> host-if <host-if-name> " |   .short_help = "lcp create <sw_if_index>|<if-name> host-if <host-if-name> " | ||||||
| 		"netns <namespace> [tun]", | 		"netns <namespace> [tun]", | ||||||
| @@ -173,23 +173,25 @@ VLIB_CLI_COMMAND (lcp_auto_subint_command, static) = { | |||||||
|   .function = lcp_auto_subint_command_fn, |   .function = lcp_auto_subint_command_fn, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| static clib_error_t *lcp_default_netns_command_fn(vlib_main_t *vm, | static clib_error_t * | ||||||
|                                                   unformat_input_t *input, | lcp_default_netns_command_fn (vlib_main_t *vm, unformat_input_t *input, | ||||||
|                                                   vlib_cli_command_t *cmd) { | 			      vlib_cli_command_t *cmd) | ||||||
|  | { | ||||||
|   unformat_input_t _line_input, *line_input = &_line_input; |   unformat_input_t _line_input, *line_input = &_line_input; | ||||||
|   u8 *ns; |   u8 *ns; | ||||||
|   int r; |   int r; | ||||||
|   clib_error_t *error = NULL; |   clib_error_t *error = NULL; | ||||||
|  |  | ||||||
|   if (!unformat_user(input, unformat_line_input, line_input)) |   if (!unformat_user (input, unformat_line_input, line_input)) | ||||||
|     return 0; |     return 0; | ||||||
|  |  | ||||||
|   ns = 0; |   ns = 0; | ||||||
|  |  | ||||||
|   while (unformat_check_input(line_input) != UNFORMAT_END_OF_INPUT) { |   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) | ||||||
|     if (unformat(line_input, "netns %s", &ns)) |     { | ||||||
|  |       if (unformat (line_input, "netns %s", &ns)) | ||||||
| 	; | 	; | ||||||
|     else if (unformat(line_input, "clear netns")) |       else if (unformat (line_input, "clear netns")) | ||||||
| 	; | 	; | ||||||
|       else |       else | ||||||
| 	{ | 	{ | ||||||
| @@ -200,12 +202,12 @@ static clib_error_t *lcp_default_netns_command_fn(vlib_main_t *vm, | |||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   vlib_cli_output(vm, "lcp set default netns %v\n", ns); |   vlib_cli_output (vm, "lcp set default netns %v\n", ns); | ||||||
|  |  | ||||||
|   r = lcp_set_default_ns(ns); |   r = lcp_set_default_ns (ns); | ||||||
|  |  | ||||||
|   if (r) |   if (r) | ||||||
|     return clib_error_return(0, "linux-cp set default netns failed (%d)", r); |     return clib_error_return (0, "linux-cp set default netns failed (%d)", r); | ||||||
|  |  | ||||||
| done: | done: | ||||||
|   unformat_free (line_input); |   unformat_free (line_input); | ||||||
| @@ -213,7 +215,7 @@ done: | |||||||
|   return error; |   return error; | ||||||
| } | } | ||||||
|  |  | ||||||
| VLIB_CLI_COMMAND(lcp_default_netns_command, static) = { | VLIB_CLI_COMMAND (lcp_default_netns_command, static) = { | ||||||
|   .path = "lcp default", |   .path = "lcp default", | ||||||
|   .short_help = "lcp default netns [<namespace>]", |   .short_help = "lcp default netns [<namespace>]", | ||||||
|   .function = lcp_default_netns_command_fn, |   .function = lcp_default_netns_command_fn, | ||||||
| @@ -253,11 +255,11 @@ lcp_itf_pair_delete_command_fn (vlib_main_t *vm, unformat_input_t *input, | |||||||
|   r = lcp_itf_pair_delete (sw_if_index); |   r = lcp_itf_pair_delete (sw_if_index); | ||||||
|  |  | ||||||
|   if (r) |   if (r) | ||||||
|     return clib_error_return(0, "lcp pair deletion failed (%d)", r); |     return clib_error_return (0, "lcp pair deletion failed (%d)", r); | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| VLIB_CLI_COMMAND(lcp_itf_pair_delete_command, static) = { | VLIB_CLI_COMMAND (lcp_itf_pair_delete_command, static) = { | ||||||
|   .path = "lcp delete", |   .path = "lcp delete", | ||||||
|   .short_help = "lcp delete <sw_if_index>|<if-name>", |   .short_help = "lcp delete <sw_if_index>|<if-name>", | ||||||
|   .function = lcp_itf_pair_delete_command_fn, |   .function = lcp_itf_pair_delete_command_fn, | ||||||
| @@ -287,7 +289,7 @@ lcp_itf_pair_show_cmd (vlib_main_t *vm, unformat_input_t *input, | |||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| VLIB_CLI_COMMAND(lcp_itf_pair_show_cmd_node, static) = { | VLIB_CLI_COMMAND (lcp_itf_pair_show_cmd_node, static) = { | ||||||
|   .path = "show lcp", |   .path = "show lcp", | ||||||
|   .function = lcp_itf_pair_show_cmd, |   .function = lcp_itf_pair_show_cmd, | ||||||
|   .short_help = "show lcp [phy <interface>]", |   .short_help = "show lcp [phy <interface>]", | ||||||
|   | |||||||
| @@ -181,7 +181,7 @@ format_lcp_punt_l3_trace (u8 *s, va_list *args) | |||||||
|   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); | ||||||
|   lcp_punt_l3_trace_t *t = va_arg (*args, lcp_punt_l3_trace_t *); |   lcp_punt_l3_trace_t *t = va_arg (*args, lcp_punt_l3_trace_t *); | ||||||
|  |  | ||||||
|   s = format(s, "linux-cp-punt-l3: %u", t->phy_sw_if_index); |   s = format (s, "linux-cp-punt-l3: %u", t->phy_sw_if_index); | ||||||
|  |  | ||||||
|   return s; |   return s; | ||||||
| } | } | ||||||
| @@ -261,16 +261,16 @@ VLIB_REGISTER_NODE(lcp_punt_l3_node) = { | |||||||
|         }, |         }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lcp_punt_l3_ip4, static) = { | VNET_FEATURE_INIT (lcp_punt_l3_ip4, static) = { | ||||||
|   .arc_name = "ip4-punt", |   .arc_name = "ip4-punt", | ||||||
|   .node_name = "linux-cp-punt-l3", |   .node_name = "linux-cp-punt-l3", | ||||||
|     .runs_before = VNET_FEATURES("ip4-punt-redirect"), |   .runs_before = VNET_FEATURES ("ip4-punt-redirect"), | ||||||
| }; | }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lip_punt_l3_ip6, static) = { | VNET_FEATURE_INIT (lip_punt_l3_ip6, static) = { | ||||||
|   .arc_name = "ip6-punt", |   .arc_name = "ip6-punt", | ||||||
|   .node_name = "linux-cp-punt-l3", |   .node_name = "linux-cp-punt-l3", | ||||||
|     .runs_before = VNET_FEATURES("ip6-punt-redirect"), |   .runs_before = VNET_FEATURES ("ip6-punt-redirect"), | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #define foreach_lcp_xc                                                        \ | #define foreach_lcp_xc                                                        \ | ||||||
| @@ -408,32 +408,32 @@ VLIB_NODE_FN (lcp_xc_ip6) | |||||||
|   return (lcp_xc_inline (vm, node, frame, AF_IP6)); |   return (lcp_xc_inline (vm, node, frame, AF_IP6)); | ||||||
| } | } | ||||||
|  |  | ||||||
| VLIB_REGISTER_NODE(lcp_xc_ip4) = {.name = "linux-cp-xc-ip4", | VLIB_REGISTER_NODE (lcp_xc_ip4) = { .name = "linux-cp-xc-ip4", | ||||||
|                                   .vector_size = sizeof(u32), | 				    .vector_size = sizeof (u32), | ||||||
| 				    .format_trace = format_lcp_xc_trace, | 				    .format_trace = format_lcp_xc_trace, | ||||||
| 				    .type = VLIB_NODE_TYPE_INTERNAL, | 				    .type = VLIB_NODE_TYPE_INTERNAL, | ||||||
|                                   .sibling_of = "ip4-rewrite"}; | 				    .sibling_of = "ip4-rewrite" }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lcp_xc_ip4_ucast_node, static) = { | VNET_FEATURE_INIT (lcp_xc_ip4_ucast_node, static) = { | ||||||
|   .arc_name = "ip4-unicast", |   .arc_name = "ip4-unicast", | ||||||
|   .node_name = "linux-cp-xc-ip4", |   .node_name = "linux-cp-xc-ip4", | ||||||
| }; | }; | ||||||
| VNET_FEATURE_INIT(lcp_xc_ip4_mcast_node, static) = { | VNET_FEATURE_INIT (lcp_xc_ip4_mcast_node, static) = { | ||||||
|   .arc_name = "ip4-multicast", |   .arc_name = "ip4-multicast", | ||||||
|   .node_name = "linux-cp-xc-ip4", |   .node_name = "linux-cp-xc-ip4", | ||||||
| }; | }; | ||||||
|  |  | ||||||
| VLIB_REGISTER_NODE(lcp_xc_ip6) = {.name = "linux-cp-xc-ip6", | VLIB_REGISTER_NODE (lcp_xc_ip6) = { .name = "linux-cp-xc-ip6", | ||||||
|                                   .vector_size = sizeof(u32), | 				    .vector_size = sizeof (u32), | ||||||
| 				    .format_trace = format_lcp_xc_trace, | 				    .format_trace = format_lcp_xc_trace, | ||||||
| 				    .type = VLIB_NODE_TYPE_INTERNAL, | 				    .type = VLIB_NODE_TYPE_INTERNAL, | ||||||
|                                   .sibling_of = "ip6-rewrite"}; | 				    .sibling_of = "ip6-rewrite" }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lcp_xc_ip6_ucast_node, static) = { | VNET_FEATURE_INIT (lcp_xc_ip6_ucast_node, static) = { | ||||||
|   .arc_name = "ip6-unicast", |   .arc_name = "ip6-unicast", | ||||||
|   .node_name = "linux-cp-xc-ip6", |   .node_name = "linux-cp-xc-ip6", | ||||||
| }; | }; | ||||||
| VNET_FEATURE_INIT(lcp_xc_ip6_mcast_node, static) = { | VNET_FEATURE_INIT (lcp_xc_ip6_mcast_node, static) = { | ||||||
|   .arc_name = "ip6-multicast", |   .arc_name = "ip6-multicast", | ||||||
|   .node_name = "linux-cp-xc-ip6", |   .node_name = "linux-cp-xc-ip6", | ||||||
| }; | }; | ||||||
| @@ -557,12 +557,12 @@ VLIB_REGISTER_NODE(lcp_xc_l3_ip4_node) = { | |||||||
|         }, |         }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lcp_xc_node_l3_ip4_unicast, static) = { | VNET_FEATURE_INIT (lcp_xc_node_l3_ip4_unicast, static) = { | ||||||
|   .arc_name = "ip4-unicast", |   .arc_name = "ip4-unicast", | ||||||
|   .node_name = "linux-cp-xc-l3-ip4", |   .node_name = "linux-cp-xc-l3-ip4", | ||||||
| }; | }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lcp_xc_node_l3_ip4_multicaast, static) = { | VNET_FEATURE_INIT (lcp_xc_node_l3_ip4_multicaast, static) = { | ||||||
|   .arc_name = "ip4-multicast", |   .arc_name = "ip4-multicast", | ||||||
|   .node_name = "linux-cp-xc-l3-ip4", |   .node_name = "linux-cp-xc-l3-ip4", | ||||||
| }; | }; | ||||||
| @@ -581,12 +581,12 @@ VLIB_REGISTER_NODE(lcp_xc_l3_ip6_node) = { | |||||||
|         }, |         }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lcp_xc_node_l3_ip6_unicast, static) = { | VNET_FEATURE_INIT (lcp_xc_node_l3_ip6_unicast, static) = { | ||||||
|   .arc_name = "ip6-unicast", |   .arc_name = "ip6-unicast", | ||||||
|   .node_name = "linux-cp-xc-l3-ip6", |   .node_name = "linux-cp-xc-l3-ip6", | ||||||
| }; | }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lcp_xc_node_l3_ip6_multicast, static) = { | VNET_FEATURE_INIT (lcp_xc_node_l3_ip6_multicast, static) = { | ||||||
|   .arc_name = "ip6-multicast", |   .arc_name = "ip6-multicast", | ||||||
|   .node_name = "linux-cp-xc-l3-ip6", |   .node_name = "linux-cp-xc-l3-ip6", | ||||||
| }; | }; | ||||||
| @@ -850,10 +850,10 @@ VLIB_REGISTER_NODE(lcp_arp_phy_node) = { | |||||||
|         }, |         }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lcp_arp_phy_arp_feat, static) = { | VNET_FEATURE_INIT (lcp_arp_phy_arp_feat, static) = { | ||||||
|   .arc_name = "arp", |   .arc_name = "arp", | ||||||
|   .node_name = "linux-cp-arp-phy", |   .node_name = "linux-cp-arp-phy", | ||||||
|     .runs_before = VNET_FEATURES("arp-reply"), |   .runs_before = VNET_FEATURES ("arp-reply"), | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -935,10 +935,10 @@ VLIB_REGISTER_NODE(lcp_arp_host_node) = { | |||||||
|         }, |         }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| VNET_FEATURE_INIT(lcp_arp_host_arp_feat, static) = { | VNET_FEATURE_INIT (lcp_arp_host_arp_feat, static) = { | ||||||
|   .arc_name = "arp", |   .arc_name = "arp", | ||||||
|   .node_name = "linux-cp-arp-host", |   .node_name = "linux-cp-arp-host", | ||||||
|     .runs_before = VNET_FEATURES("arp-reply"), |   .runs_before = VNET_FEATURES ("arp-reply"), | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
|   | |||||||
| @@ -170,7 +170,7 @@ lcp_itf_pair_sync_state_hw (vnet_hw_interface_t *hi) | |||||||
| } | } | ||||||
|  |  | ||||||
| static clib_error_t * | static clib_error_t * | ||||||
| lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags) | lcp_itf_admin_state_change (vnet_main_t *vnm, u32 sw_if_index, u32 flags) | ||||||
| { | { | ||||||
|   lcp_itf_pair_t *lip; |   lcp_itf_pair_t *lip; | ||||||
|   vnet_hw_interface_t *hi; |   vnet_hw_interface_t *hi; | ||||||
| @@ -184,7 +184,8 @@ lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags) | |||||||
|  |  | ||||||
|   // Sync interface state changes into host |   // Sync interface state changes into host | ||||||
|   lip = lcp_itf_pair_get (lcp_itf_pair_find_by_phy (sw_if_index)); |   lip = lcp_itf_pair_get (lcp_itf_pair_find_by_phy (sw_if_index)); | ||||||
|   if (!lip) return NULL; |   if (!lip) | ||||||
|  |     return NULL; | ||||||
|   LCP_IF_INFO ("admin_state_change: %U flags %u", format_lcp_itf_pair, lip, |   LCP_IF_INFO ("admin_state_change: %U flags %u", format_lcp_itf_pair, lip, | ||||||
| 	       flags); | 	       flags); | ||||||
|  |  | ||||||
| @@ -215,7 +216,7 @@ lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags) | |||||||
|   return NULL; |   return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(lcp_itf_admin_state_change); | VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (lcp_itf_admin_state_change); | ||||||
|  |  | ||||||
| static clib_error_t * | static clib_error_t * | ||||||
| lcp_itf_mtu_change (vnet_main_t *vnm, u32 sw_if_index, u32 flags) | lcp_itf_mtu_change (vnet_main_t *vnm, u32 sw_if_index, u32 flags) | ||||||
|   | |||||||
| @@ -128,7 +128,7 @@ lcp_itf_pair_show (u32 phy_sw_if_index) | |||||||
|   index_t api; |   index_t api; | ||||||
|  |  | ||||||
|   vm = vlib_get_main (); |   vm = vlib_get_main (); | ||||||
|   ns = lcp_get_default_ns(); |   ns = lcp_get_default_ns (); | ||||||
|   vlib_cli_output (vm, "lcp default netns %v\n", ns); |   vlib_cli_output (vm, "lcp default netns %v\n", ns); | ||||||
|   vlib_cli_output (vm, "lcp lcp-auto-subint %s\n", |   vlib_cli_output (vm, "lcp lcp-auto-subint %s\n", | ||||||
| 		   lcp_auto_subint () ? "on" : "off"); | 		   lcp_auto_subint () ? "on" : "off"); | ||||||
| @@ -149,8 +149,10 @@ lcp_itf_pair_show (u32 phy_sw_if_index) | |||||||
| lcp_itf_pair_t * | lcp_itf_pair_t * | ||||||
| lcp_itf_pair_get (u32 index) | lcp_itf_pair_get (u32 index) | ||||||
| { | { | ||||||
|   if (!lcp_itf_pair_pool) return NULL; |   if (!lcp_itf_pair_pool) | ||||||
|   if (index == INDEX_INVALID) return NULL; |     return NULL; | ||||||
|  |   if (index == INDEX_INVALID) | ||||||
|  |     return NULL; | ||||||
|  |  | ||||||
|   return pool_elt_at_index (lcp_itf_pair_pool, index); |   return pool_elt_at_index (lcp_itf_pair_pool, index); | ||||||
| } | } | ||||||
| @@ -230,12 +232,14 @@ lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name, | |||||||
|   if (lipi != INDEX_INVALID) |   if (lipi != INDEX_INVALID) | ||||||
|     return VNET_API_ERROR_VALUE_EXIST; |     return VNET_API_ERROR_VALUE_EXIST; | ||||||
|  |  | ||||||
|   if (host_sw_if_index == ~0) { |   if (host_sw_if_index == ~0) | ||||||
|  |     { | ||||||
|       LCP_IF_ERROR ("pair_add: Cannot add LIP - invalid host"); |       LCP_IF_ERROR ("pair_add: Cannot add LIP - invalid host"); | ||||||
|       return VNET_API_ERROR_INVALID_SW_IF_INDEX; |       return VNET_API_ERROR_INVALID_SW_IF_INDEX; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   if (phy_sw_if_index == ~0) { |   if (phy_sw_if_index == ~0) | ||||||
|  |     { | ||||||
|       LCP_IF_ERROR ("pair_add: Cannot add LIP - invalid phy"); |       LCP_IF_ERROR ("pair_add: Cannot add LIP - invalid phy"); | ||||||
|       return VNET_API_ERROR_INVALID_SW_IF_INDEX; |       return VNET_API_ERROR_INVALID_SW_IF_INDEX; | ||||||
|     } |     } | ||||||
| @@ -304,9 +308,9 @@ lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name, | |||||||
|   /* enable ARP feature node for broadcast interfaces */ |   /* enable ARP feature node for broadcast interfaces */ | ||||||
|   if (lip->lip_host_type != LCP_ITF_HOST_TUN) |   if (lip->lip_host_type != LCP_ITF_HOST_TUN) | ||||||
|     { |     { | ||||||
|     vnet_feature_enable_disable("arp", "linux-cp-arp-phy", |       vnet_feature_enable_disable ("arp", "linux-cp-arp-phy", | ||||||
| 				   lip->lip_phy_sw_if_index, 1, NULL, 0); | 				   lip->lip_phy_sw_if_index, 1, NULL, 0); | ||||||
|     vnet_feature_enable_disable("arp", "linux-cp-arp-host", |       vnet_feature_enable_disable ("arp", "linux-cp-arp-host", | ||||||
| 				   lip->lip_host_sw_if_index, 1, NULL, 0); | 				   lip->lip_host_sw_if_index, 1, NULL, 0); | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
| @@ -343,7 +347,8 @@ lcp_netlink_add_link_vlan (int parent, u32 vlan, u16 proto, const char *name) | |||||||
|   int err; |   int err; | ||||||
|  |  | ||||||
|   sk = nl_socket_alloc (); |   sk = nl_socket_alloc (); | ||||||
|   if ((err = nl_connect (sk, NETLINK_ROUTE)) < 0) { |   if ((err = nl_connect (sk, NETLINK_ROUTE)) < 0) | ||||||
|  |     { | ||||||
|       LCP_IF_ERROR ("netlink_add_link_vlan: Netlink connect error: %s", |       LCP_IF_ERROR ("netlink_add_link_vlan: Netlink connect error: %s", | ||||||
| 		    nl_geterror (err)); | 		    nl_geterror (err)); | ||||||
|       return clib_error_return (NULL, "Unable to connect socket: %d", err); |       return clib_error_return (NULL, "Unable to connect socket: %d", err); | ||||||
| @@ -356,7 +361,8 @@ lcp_netlink_add_link_vlan (int parent, u32 vlan, u16 proto, const char *name) | |||||||
|   rtnl_link_vlan_set_id (link, vlan); |   rtnl_link_vlan_set_id (link, vlan); | ||||||
|   rtnl_link_vlan_set_protocol (link, htons (proto)); |   rtnl_link_vlan_set_protocol (link, htons (proto)); | ||||||
|  |  | ||||||
|   if ((err = rtnl_link_add (sk, link, NLM_F_CREATE)) < 0) { |   if ((err = rtnl_link_add (sk, link, NLM_F_CREATE)) < 0) | ||||||
|  |     { | ||||||
|       LCP_IF_ERROR ("netlink_add_link_vlan: Netlink link add error: %s", |       LCP_IF_ERROR ("netlink_add_link_vlan: Netlink link add error: %s", | ||||||
| 		    nl_geterror (err)); | 		    nl_geterror (err)); | ||||||
|       return clib_error_return (NULL, "Unable to add link %s: %d", name, err); |       return clib_error_return (NULL, "Unable to add link %s: %d", name, err); | ||||||
| @@ -432,9 +438,9 @@ lcp_itf_pair_del (u32 phy_sw_if_index) | |||||||
|   /* disable ARP feature node for broadcast interfaces */ |   /* disable ARP feature node for broadcast interfaces */ | ||||||
|   if (lip->lip_host_type != LCP_ITF_HOST_TUN) |   if (lip->lip_host_type != LCP_ITF_HOST_TUN) | ||||||
|     { |     { | ||||||
|     vnet_feature_enable_disable("arp", "linux-cp-arp-phy", |       vnet_feature_enable_disable ("arp", "linux-cp-arp-phy", | ||||||
| 				   lip->lip_phy_sw_if_index, 0, NULL, 0); | 				   lip->lip_phy_sw_if_index, 0, NULL, 0); | ||||||
|     vnet_feature_enable_disable("arp", "linux-cp-arp-host", |       vnet_feature_enable_disable ("arp", "linux-cp-arp-host", | ||||||
| 				   lip->lip_host_sw_if_index, 0, NULL, 0); | 				   lip->lip_host_sw_if_index, 0, NULL, 0); | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
| @@ -611,7 +617,8 @@ lcp_itf_set_link_state (const lcp_itf_pair_t *lip, u8 state) | |||||||
|   vnet_main_t *vnm = vnet_get_main (); |   vnet_main_t *vnm = vnet_get_main (); | ||||||
|   int curr_ns_fd, vif_ns_fd; |   int curr_ns_fd, vif_ns_fd; | ||||||
|  |  | ||||||
|   if (!lip) return; |   if (!lip) | ||||||
|  |     return; | ||||||
|  |  | ||||||
|   curr_ns_fd = vif_ns_fd = -1; |   curr_ns_fd = vif_ns_fd = -1; | ||||||
|  |  | ||||||
| @@ -769,12 +776,14 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, | |||||||
|   const vnet_hw_interface_t *hw; |   const vnet_hw_interface_t *hw; | ||||||
|   lcp_itf_pair_t *lip; |   lcp_itf_pair_t *lip; | ||||||
|  |  | ||||||
|   if (!vnet_sw_if_index_is_api_valid (phy_sw_if_index)) { |   if (!vnet_sw_if_index_is_api_valid (phy_sw_if_index)) | ||||||
|  |     { | ||||||
|       LCP_IF_ERROR ("pair_create: Invalid phy index %u", phy_sw_if_index); |       LCP_IF_ERROR ("pair_create: Invalid phy index %u", phy_sw_if_index); | ||||||
|       return VNET_API_ERROR_INVALID_SW_IF_INDEX; |       return VNET_API_ERROR_INVALID_SW_IF_INDEX; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   if (!lcp_validate_if_name (host_if_name)) { |   if (!lcp_validate_if_name (host_if_name)) | ||||||
|  |     { | ||||||
|       LCP_IF_ERROR ("pair_create: Invalid host-if-name '%s'", host_if_name); |       LCP_IF_ERROR ("pair_create: Invalid host-if-name '%s'", host_if_name); | ||||||
|       return VNET_API_ERROR_INVALID_ARGUMENT; |       return VNET_API_ERROR_INVALID_ARGUMENT; | ||||||
|     } |     } | ||||||
| @@ -782,13 +791,15 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, | |||||||
|   vnm = vnet_get_main (); |   vnm = vnet_get_main (); | ||||||
|   sw = vnet_get_sw_interface (vnm, phy_sw_if_index); |   sw = vnet_get_sw_interface (vnm, phy_sw_if_index); | ||||||
|   hw = vnet_get_sup_hw_interface (vnm, phy_sw_if_index); |   hw = vnet_get_sup_hw_interface (vnm, phy_sw_if_index); | ||||||
|   if (!sw && !hw) { |   if (!sw && !hw) | ||||||
|  |     { | ||||||
|       LCP_IF_ERROR ("pair_create: Invalid interface"); |       LCP_IF_ERROR ("pair_create: Invalid interface"); | ||||||
|       return VNET_API_ERROR_INVALID_SW_IF_INDEX; |       return VNET_API_ERROR_INVALID_SW_IF_INDEX; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   if (hw->hw_class_index != ethernet_hw_interface_class.index && |   if (hw->hw_class_index != ethernet_hw_interface_class.index && | ||||||
|       host_if_type == LCP_ITF_HOST_TAP) { |       host_if_type == LCP_ITF_HOST_TAP) | ||||||
|  |     { | ||||||
|       LCP_IF_ERROR ( |       LCP_IF_ERROR ( | ||||||
| 	"pair_create: don't create TAP for non-eth interface; use tun"); | 	"pair_create: don't create TAP for non-eth interface; use tun"); | ||||||
|       return VNET_API_ERROR_INVALID_ARGUMENT; |       return VNET_API_ERROR_INVALID_ARGUMENT; | ||||||
| @@ -799,7 +810,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, | |||||||
|    * Otherwise, use netns if defined, otherwise use the OS default. |    * Otherwise, use netns if defined, otherwise use the OS default. | ||||||
|    */ |    */ | ||||||
|   if (ns == 0 || ns[0] == 0) |   if (ns == 0 || ns[0] == 0) | ||||||
|     ns = lcp_get_default_ns(); |     ns = lcp_get_default_ns (); | ||||||
|  |  | ||||||
|   /* sub interfaces do not need a tap created */ |   /* sub interfaces do not need a tap created */ | ||||||
|   if (vnet_sw_interface_is_sub (vnm, phy_sw_if_index)) |   if (vnet_sw_interface_is_sub (vnm, phy_sw_if_index)) | ||||||
| @@ -812,7 +823,9 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, | |||||||
|       u16 vlan, proto; |       u16 vlan, proto; | ||||||
|       u32 parent_vif_index; |       u32 parent_vif_index; | ||||||
|  |  | ||||||
|       if (sw->type == VNET_SW_INTERFACE_TYPE_SUB && sw->sub.eth.flags.exact_match == 0) { |       if (sw->type == VNET_SW_INTERFACE_TYPE_SUB && | ||||||
|  | 	  sw->sub.eth.flags.exact_match == 0) | ||||||
|  | 	{ | ||||||
| 	  LCP_IF_ERROR ("pair_create: Cannot create LIP for a " | 	  LCP_IF_ERROR ("pair_create: Cannot create LIP for a " | ||||||
| 			"sub-interface without exact-match set"); | 			"sub-interface without exact-match set"); | ||||||
| 	  return VNET_API_ERROR_INVALID_ARGUMENT; | 	  return VNET_API_ERROR_INVALID_ARGUMENT; | ||||||
| @@ -821,7 +834,8 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, | |||||||
|       outer_vlan = sw->sub.eth.outer_vlan_id; |       outer_vlan = sw->sub.eth.outer_vlan_id; | ||||||
|       inner_vlan = sw->sub.eth.inner_vlan_id; |       inner_vlan = sw->sub.eth.inner_vlan_id; | ||||||
|       outer_proto = inner_proto = ETH_P_8021Q; |       outer_proto = inner_proto = ETH_P_8021Q; | ||||||
|       if (1 == sw->sub.eth.flags.dot1ad) outer_proto = ETH_P_8021AD; |       if (1 == sw->sub.eth.flags.dot1ad) | ||||||
|  | 	outer_proto = ETH_P_8021AD; | ||||||
|  |  | ||||||
|       LCP_IF_INFO ("pair_create: creating dot1%s %d inner-dot1q %d on %U", |       LCP_IF_INFO ("pair_create: creating dot1%s %d inner-dot1q %d on %U", | ||||||
| 		   sw->sub.eth.flags.dot1ad ? "ad" : "q", outer_vlan, | 		   sw->sub.eth.flags.dot1ad ? "ad" : "q", outer_vlan, | ||||||
| @@ -916,7 +930,8 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, | |||||||
|  |  | ||||||
| 	  err = lcp_netlink_add_link_vlan (parent_vif_index, vlan, proto, | 	  err = lcp_netlink_add_link_vlan (parent_vif_index, vlan, proto, | ||||||
| 					   (const char *) host_if_name); | 					   (const char *) host_if_name); | ||||||
| 	  if (err != 0) { | 	  if (err != 0) | ||||||
|  | 	    { | ||||||
| 	      LCP_IF_ERROR ("pair_create: Cannot create link " | 	      LCP_IF_ERROR ("pair_create: Cannot create link " | ||||||
| 			    "outer(proto:0x%04x,vlan:%u).inner(proto:0x%" | 			    "outer(proto:0x%04x,vlan:%u).inner(proto:0x%" | ||||||
| 			    "04x,vlan:%u) name:'%s'", | 			    "04x,vlan:%u) name:'%s'", | ||||||
| @@ -1190,11 +1205,11 @@ VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (lcp_itf_pair_link_up_down); | |||||||
| static clib_error_t * | static clib_error_t * | ||||||
| lcp_itf_pair_init (vlib_main_t *vm) | lcp_itf_pair_init (vlib_main_t *vm) | ||||||
| { | { | ||||||
|   vlib_punt_hdl_t punt_hdl = vlib_punt_client_register("linux-cp"); |   vlib_punt_hdl_t punt_hdl = vlib_punt_client_register ("linux-cp"); | ||||||
|   lcp_itf_pair_logger = vlib_log_register_class ("linux-cp", "if"); |   lcp_itf_pair_logger = vlib_log_register_class ("linux-cp", "if"); | ||||||
|  |  | ||||||
|   /* punt IKE */ |   /* punt IKE */ | ||||||
|   vlib_punt_register(punt_hdl, ipsec_punt_reason[IPSEC_PUNT_IP4_SPI_UDP_0], |   vlib_punt_register (punt_hdl, ipsec_punt_reason[IPSEC_PUNT_IP4_SPI_UDP_0], | ||||||
| 		      "linux-cp-punt"); | 		      "linux-cp-punt"); | ||||||
|  |  | ||||||
|   /* punt all unknown ports */ |   /* punt all unknown ports */ | ||||||
|   | |||||||
| @@ -408,7 +408,7 @@ lcp_nl_pair_add_cb (lcp_itf_pair_t *lip) | |||||||
| 	      nm->nl_ns.clib_file_lcp_refcnt); | 	      nm->nl_ns.clib_file_lcp_refcnt); | ||||||
|  |  | ||||||
|   if ((nm->nl_ns.clib_file_lcp_refcnt > 0) && |   if ((nm->nl_ns.clib_file_lcp_refcnt > 0) && | ||||||
|       vec_cmp(nm->nl_ns.netns_name, lip->lip_namespace)) |       vec_cmp (nm->nl_ns.netns_name, lip->lip_namespace)) | ||||||
|     { |     { | ||||||
|       LCP_NL_WARN ( |       LCP_NL_WARN ( | ||||||
| 	"pair_add_cb: Existing netlink listener for netns %v -- this " | 	"pair_add_cb: Existing netlink listener for netns %v -- this " | ||||||
|   | |||||||
| @@ -461,7 +461,7 @@ lcp_nl_route_add (struct rtnl_route *rr, int is_replace) | |||||||
|   uint8_t rtype, rproto; |   uint8_t rtype, rproto; | ||||||
|  |  | ||||||
|   LCP_NL_DBG ("route_add: netlink %U %s", format_nl_object, rr, |   LCP_NL_DBG ("route_add: netlink %U %s", format_nl_object, rr, | ||||||
| 	      is_replace?"replace":""); | 	      is_replace ? "replace" : ""); | ||||||
|  |  | ||||||
|   rtype = rtnl_route_get_type (rr); |   rtype = rtnl_route_get_type (rr); | ||||||
|   table_id = rtnl_route_get_table (rr); |   table_id = rtnl_route_get_table (rr); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user