X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsrv6%2Fsr_steering.c;h=cb1d81742eb0e7c9c6c51a8702b77c51149df8e4;hb=78b4f4e19bb60b89c5ed00a2d81b1bbfee27c3e2;hp=a7903751dda8376ec781e43a219dc9cecdc83685;hpb=5d73eecd63018db69b10bf56adeec9cc5cf92790;p=vpp.git diff --git a/src/vnet/srv6/sr_steering.c b/src/vnet/srv6/sr_steering.c old mode 100755 new mode 100644 index a7903751dda..cb1d81742eb --- a/src/vnet/srv6/sr_steering.c +++ b/src/vnet/srv6/sr_steering.c @@ -69,7 +69,7 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, ip6_sr_policy_t *sr_policy = 0; uword *p = 0; - memset (&key, 0, sizeof (sr_steering_key_t)); + clib_memset (&key, 0, sizeof (sr_steering_key_t)); /* Compute the steer policy key */ if (traffic_type == SR_STEER_IPV4 || traffic_type == SR_STEER_IPV6) @@ -135,21 +135,22 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, else if (steer_pl->classify.traffic_type == SR_STEER_L2) { /* Remove HW redirection */ - vnet_feature_enable_disable ("device-input", - "sr-policy-rewrite-encaps-l2", - sw_if_index, 0, 0, 0); + int ret = vnet_feature_enable_disable ("device-input", + "sr-pl-rewrite-encaps-l2", + sw_if_index, 0, 0, 0); + + if (ret != 0) + return -1; + sm->sw_iface_sr_policies[sw_if_index] = ~(u32) 0; /* Remove promiscous mode from interface */ vnet_main_t *vnm = vnet_get_main (); - ethernet_main_t *em = ðernet_main; - ethernet_interface_t *eif = - ethernet_get_interface (em, sw_if_index); - - if (!eif) - goto cleanup_error_redirection; - - ethernet_set_flags (vnm, sw_if_index, 0); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, sw_if_index); + /* Make sure it is main interface */ + if (hi->sw_if_index == sw_if_index) + ethernet_set_flags (vnm, hi->hw_if_index, 0); } /* Delete SR steering policy entry */ @@ -159,13 +160,15 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, /* If no more SR policies or steering policies */ if (!pool_elts (sm->sr_policies) && !pool_elts (sm->steer_policies)) { - fib_table_unlock (sm->fib_table_ip6, FIB_PROTOCOL_IP6); - fib_table_unlock (sm->fib_table_ip4, FIB_PROTOCOL_IP6); + fib_table_unlock (sm->fib_table_ip6, + FIB_PROTOCOL_IP6, FIB_SOURCE_SR); + fib_table_unlock (sm->fib_table_ip4, + FIB_PROTOCOL_IP6, FIB_SOURCE_SR); sm->fib_table_ip6 = (u32) ~ 0; sm->fib_table_ip4 = (u32) ~ 0; } - return 1; + return 0; } else /* It means user requested to update an existing SR steering policy */ { @@ -243,12 +246,12 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, /* Create a new steering policy */ pool_get (sm->steer_policies, steer_pl); - memset (steer_pl, 0, sizeof (*steer_pl)); + clib_memset (steer_pl, 0, sizeof (*steer_pl)); if (traffic_type == SR_STEER_IPV4 || traffic_type == SR_STEER_IPV6) { - clib_memcpy (&steer_pl->classify.l3.prefix, prefix, - sizeof (ip46_address_t)); + clib_memcpy_fast (&steer_pl->classify.l3.prefix, prefix, + sizeof (ip46_address_t)); steer_pl->classify.l3.mask_width = mask_width; steer_pl->classify.l3.fib_table = (table_id != (u32) ~ 0 ? table_id : 0); @@ -283,14 +286,11 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, /* Set promiscous mode on interface */ vnet_main_t *vnm = vnet_get_main (); - ethernet_main_t *em = ðernet_main; - ethernet_interface_t *eif = ethernet_get_interface (em, sw_if_index); - - if (!eif) - goto cleanup_error_redirection; - - ethernet_set_flags (vnm, sw_if_index, - ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); + vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index); + /* Make sure it is main interface */ + if (hi->sw_if_index == sw_if_index) + ethernet_set_flags (vnm, hi->hw_if_index, + ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); } else if (traffic_type == SR_STEER_IPV4) if (!sr_policy->is_encap) @@ -310,7 +310,7 @@ update_fib: table_id : 0)), &pfx, FIB_SOURCE_SR, FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, - FIB_PROTOCOL_IP6, + DPO_PROTO_IP6, (ip46_address_t *) & sr_policy->bsid, ~0, sm->fib_table_ip6, 1, NULL, FIB_ROUTE_PATH_FLAG_NONE); @@ -327,7 +327,7 @@ update_fib: table_id : 0)), &pfx, FIB_SOURCE_SR, FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, - FIB_PROTOCOL_IP6, + DPO_PROTO_IP6, (ip46_address_t *) & sr_policy->bsid, ~0, sm->fib_table_ip4, 1, NULL, FIB_ROUTE_PATH_FLAG_NONE); @@ -377,7 +377,7 @@ sr_steer_policy_command_fn (vlib_main_t * vm, unformat_input_t * input, u8 sr_policy_set = 0; - memset (&prefix, 0, sizeof (ip46_address_t)); + clib_memset (&prefix, 0, sizeof (ip46_address_t)); int rv; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -397,11 +397,10 @@ sr_steer_policy_command_fn (vlib_main_t * vm, unformat_input_t * input, &sw_if_index)) traffic_type = SR_STEER_L2; else if (!sr_policy_set - && unformat (input, "via sr policy index %d", - &sr_policy_index)) + && unformat (input, "via index %d", &sr_policy_index)) sr_policy_set = 1; else if (!sr_policy_set - && unformat (input, "via sr policy bsid %U", + && unformat (input, "via bsid %U", unformat_ip6_address, &bsid)) sr_policy_set = 1; else if (fib_table == (u32) ~ 0 @@ -412,7 +411,7 @@ sr_steer_policy_command_fn (vlib_main_t * vm, unformat_input_t * input, if (!traffic_type) return clib_error_return (0, "No L2/L3 traffic specified"); - if (!sr_policy_set) + if (!is_del && !sr_policy_set) return clib_error_return (0, "No SR policy specified"); /* Make sure that the prefixes are clean */ @@ -463,8 +462,8 @@ sr_steer_policy_command_fn (vlib_main_t * vm, unformat_input_t * input, /* *INDENT-OFF* */ VLIB_CLI_COMMAND (sr_steer_policy_command, static) = { .path = "sr steer", - .short_help = "sr steer (del) [l3 |l2 ]" - "via sr policy [index |bsid ]" + .short_help = "sr steer (del) [l3 |l2 ] " + "via [index |bsid ] " "(fib-table )", .long_help = "\tSteer a L2 or L3 traffic through an existing SR policy.\n" @@ -493,7 +492,7 @@ show_sr_steering_policies_command_fn (vlib_main_t * vm, vlib_cli_output (vm, "SR steering policies:"); /* *INDENT-OFF* */ - pool_foreach (steer_pl, sm->steer_policies, ({vec_add1(steer_policies, steer_pl);})); + pool_foreach (steer_pl, sm->steer_policies) {vec_add1(steer_policies, steer_pl);} /* *INDENT-ON* */ vlib_cli_output (vm, "Traffic\t\tSR policy BSID"); for (i = 0; i < vec_len (steer_policies); i++) @@ -529,8 +528,8 @@ show_sr_steering_policies_command_fn (vlib_main_t * vm, /* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_sr_steering_policies_command, static) = { - .path = "show sr steering policies", - .short_help = "show sr steering policies", + .path = "show sr steering-policies", + .short_help = "show sr steering-policies", .function = show_sr_steering_policies_command_fn, }; /* *INDENT-ON* */