X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fcnat%2Fcnat_node_vip.c;h=d320746c5fa248c25bda863921fa5519243e20b8;hb=663103279;hp=f653aa1e430a60bacb0cb67be0a4db9712c4338c;hpb=27647a27c7b1e800547e3a3ea97b099b25618177;p=vpp.git diff --git a/src/plugins/cnat/cnat_node_vip.c b/src/plugins/cnat/cnat_node_vip.c index f653aa1e430..d320746c5fa 100644 --- a/src/plugins/cnat/cnat_node_vip.c +++ b/src/plugins/cnat/cnat_node_vip.c @@ -62,8 +62,8 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, cc = cnat_client_get (vnet_buffer (b)->ip.adj_index[VLIB_TX]); - if (iproto != IP_PROTOCOL_UDP && iproto != IP_PROTOCOL_TCP - && iproto != IP_PROTOCOL_ICMP && iproto != IP_PROTOCOL_ICMP6) + /* Wrong session key */ + if (session->key.cs_proto == 0) { /* Dont translate & follow the fib programming */ next0 = cc->cc_parent.dpoi_next_node; @@ -109,14 +109,12 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, } /* New flow, create the sessions */ - const load_balance_t *lb0; cnat_ep_trk_t *trk0; - u32 hash_c0, bucket0; u32 rsession_flags = 0; - const dpo_id_t *dpo0; + u32 dpoi_index = -1; - lb0 = load_balance_get (ct->ct_lb.dpoi_index); - if (!lb0->lb_n_buckets) + trk0 = cnat_load_balance (ct, ctx->af, ip4, ip6, &dpoi_index); + if (PREDICT_FALSE (NULL == trk0)) { /* Dont translate & Follow the fib programming */ vnet_buffer (b)->ip.adj_index[VLIB_TX] = cc->cc_parent.dpoi_index; @@ -124,16 +122,7 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, goto trace; } - /* session table miss */ - hash_c0 = (AF_IP4 == ctx->af ? - ip4_compute_flow_hash (ip4, lb0->lb_hash_config) : - ip6_compute_flow_hash (ip6, lb0->lb_hash_config)); - bucket0 = hash_c0 % lb0->lb_n_buckets; - dpo0 = load_balance_get_fwd_bucket (lb0, bucket0); - /* add the session */ - trk0 = &ct->ct_paths[bucket0]; - ip46_address_copy (&session->value.cs_ip[VLIB_TX], &trk0->ct_ep[VLIB_TX].ce_ip.ip); if (ip_address_is_zero (&trk0->ct_ep[VLIB_RX].ce_ip)) @@ -158,7 +147,8 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, clib_host_to_net_u16 (trk0->ct_ep[VLIB_RX].ce_port); session->value.dpoi_next_node = ct->ct_lb.dpoi_next_node; - session->value.cs_lbi = dpo0->dpoi_index; + session->value.cs_lbi = dpoi_index; + session->value.flags = 0; rv = cspm->vip_policy (vm, b, session, &rsession_flags, ct, ctx); if (CNAT_SOURCE_ERROR_USE_DEFAULT == rv) @@ -178,7 +168,9 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, /* refcnt session in current client */ cnat_client_cnt_session (cc); - cnat_session_create (session, ctx, CNAT_LOCATION_FIB, rsession_flags); + cnat_session_create (session, ctx); + if (!(ct->flags & CNAT_TR_FLAG_NO_RETURN_SESSION)) + cnat_rsession_create (session, ctx, CNAT_LOCATION_FIB, rsession_flags); trace_flags |= CNAT_TRACE_SESSION_CREATED; next0 = ct->ct_lb.dpoi_next_node; @@ -186,9 +178,9 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, } if (AF_IP4 == ctx->af) - cnat_translation_ip4 (session, ip4, udp0); + cnat_translation_ip4 (session, ip4, udp0, vnet_buffer (b)->oflags); else - cnat_translation_ip6 (session, ip6, udp0); + cnat_translation_ip6 (session, ip6, udp0, vnet_buffer (b)->oflags); if (NULL != ct) {