aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/interface_funcs.h
AgeCommit message (Expand)AuthorFilesLines
2020-04-15pg: set vnet buffer flags in pg streamsDave Barach1-0/+1
2019-12-04gre: Multi-point interfacesNeale Ranns1-0/+1
2019-11-12interface: Allow VLAN tag-rewrite on non-sub-interfaces too.Jon Loeliger1-0/+3
2019-10-09interface: callback to manage extra MAC addressesMatthew Smith1-0/+6
2019-07-23api: binary api cleanupDave Barach1-2/+18
2019-06-18ipsec: ipsec-tun protectNeale Ranns1-0/+3
2019-03-22ADJ: more thorough link up checkNeale Ranns1-2/+17
2019-02-19tap gso: experimental supportAndrew Yourtchenko1-0/+2
2019-02-02Deprecate old mutliarch code, phase 1Damjan Marion1-2/+0
2018-11-08vnet: store hw interface speed in kbps instead of using flagsDamjan Marion1-0/+8
2018-11-07GBP Endpoint LearningNeale Ranns1-0/+7
2018-10-30change mac address functions take const macNeale Ranns1-1/+1
2018-10-27Enumify interface flagsNeale Ranns1-2/+2
2018-08-24rx-placement: Add API call for interface rx-placementMohsin Kazmi1-0/+4
2018-07-20IP directed broadcastNeale Ranns1-1/+3
2018-07-15VPP-1341: fix loopback interface graph arcsDave Barach1-0/+1
2018-07-07PipesNeale Ranns1-1/+17
2018-06-11MTU: Software interface / Per-protocol MTU supportOle Troan1-9/+16
2018-05-25ARP proxy dumpsNeale Ranns1-2/+25
2018-05-10vnet: device flow offload infraDamjan Marion1-0/+22
2018-04-13Revert "MTU: Setting of MTU on software interface (instead of hardware interf...Damjan Marion1-13/+12
2018-04-13MTU: Setting of MTU on software interface (instead of hardware interface)Ole Troan1-12/+13
2018-04-04Detailed stats collection featureNeale Ranns1-0/+3
2018-03-18Remove unnumbered configuration on interface deleteNeale Ranns1-0/+4
2018-02-27vnet/interface: vnet_(put|get)frame_to_sw_interface is not worker thread awareSteven1-2/+2
2018-02-12Improve MTU handlingNeale Ranns1-0/+3
2018-01-24Improve tunnel interface creation performanceJohn Lo1-0/+8
2017-10-31Fix set interface mac address API to be endian neutralJohn Lo1-1/+1
2017-10-29devices: Add binary API for set interface <interface> rx-modeSteven1-0/+8
2017-08-01P2P EthernetPavel Kotucek1-1/+2
2017-07-12Deprecate support for flattened output nodesDamjan Marion1-2/+1
2017-05-02Add interface rx mode commands, unify rx mode and placement CLIDamjan Marion1-0/+1
2017-03-07CLI: hide deleted interfacesEyal Bari1-0/+20
2017-01-10IPv6 NS RS tests and fixesNeale Ranns1-0/+8
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion1-0/+318
class="n">cnat_vip_ip4_node; vlib_node_registration_t cnat_vip_ip6_node; static u8 * format_cnat_translation_trace (u8 * s, va_list * args) { CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); cnat_translation_trace_t *t = va_arg (*args, cnat_translation_trace_t *); if (t->found_session) s = format (s, "found: %U", format_cnat_session, &t->session, 1); else if (t->created_session) s = format (s, "created: %U\n tr: %U", format_cnat_session, &t->session, 1, format_cnat_translation, &t->tr, 0); else if (t->has_tr) s = format (s, "tr pass: %U", format_cnat_translation, &t->tr, 0); else s = format (s, "not found"); return s; } /* CNat sub for NAT behind a fib entry (VIP or interposed real IP) */ static uword cnat_vip_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t * b, cnat_node_ctx_t * ctx, int rv, cnat_session_t * session) { vlib_combined_counter_main_t *cntm = &cnat_translation_counters; const cnat_translation_t *ct = NULL; ip4_header_t *ip4 = NULL; ip_protocol_t iproto; ip6_header_t *ip6 = NULL; udp_header_t *udp0; cnat_client_t *cc; u16 next0; index_t cti; int created_session = 0; cnat_src_policy_main_t *cspm = &cnat_src_policy_main; if (AF_IP4 == ctx->af) { ip4 = vlib_buffer_get_current (b); iproto = ip4->protocol; udp0 = (udp_header_t *) (ip4 + 1); } else { ip6 = vlib_buffer_get_current (b); iproto = ip6->protocol; udp0 = (udp_header_t *) (ip6 + 1); } 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) { /* Dont translate & follow the fib programming */ next0 = cc->cc_parent.dpoi_next_node; vnet_buffer (b)->ip.adj_index[VLIB_TX] = cc->cc_parent.dpoi_index; goto trace; } if (!rv) { /* session table hit */ cnat_timestamp_update (session->value.cs_ts_index, ctx->now); if (INDEX_INVALID != session->value.cs_lbi) { /* Translate & follow the translation given LB */ ct = cnat_translation_get (session->value.ct_index); next0 = ct->ct_lb.dpoi_next_node; vnet_buffer (b)->ip.adj_index[VLIB_TX] = session->value.cs_lbi; } else if (session->value.flags & CNAT_SESSION_FLAG_HAS_SNAT) { /* The return needs DNAT, so we need an additionnal * lookup after translation */ next0 = CNAT_TRANSLATION_NEXT_LOOKUP; } else { /* Translate & follow the fib programming */ next0 = cc->cc_parent.dpoi_next_node; vnet_buffer (b)->ip.adj_index[VLIB_TX] = cc->cc_parent.dpoi_index; } } else { ct = cnat_find_translation (cc->parent_cci, clib_host_to_net_u16 (udp0->dst_port), iproto); if (NULL == ct) { /* Dont translate & Follow the fib programming */ vnet_buffer (b)->ip.adj_index[VLIB_TX] = cc->cc_parent.dpoi_index; next0 = cc->cc_parent.dpoi_next_node; goto trace; } /* 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; lb0 = load_balance_get (ct->ct_lb.dpoi_index); if (!lb0->lb_n_buckets) { /* Dont translate & Follow the fib programming */ vnet_buffer (b)->ip.adj_index[VLIB_TX] = cc->cc_parent.dpoi_index; next0 = cc->cc_parent.dpoi_next_node; 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)) { if (AF_IP4 == ctx->af) ip46_address_set_ip4 (&session->value.cs_ip[VLIB_RX], &ip4->src_address); else ip46_address_set_ip6 (&session->value.cs_ip[VLIB_RX], &ip6->src_address); } else { /* We source NAT with the translation */ rsession_flags |= CNAT_SESSION_FLAG_HAS_SNAT; ip46_address_copy (&session->value.cs_ip[VLIB_RX], &trk0->ct_ep[VLIB_RX].ce_ip.ip); } session->value.cs_port[VLIB_TX] = clib_host_to_net_u16 (trk0->ct_ep[VLIB_TX].ce_port); session->value.cs_port[VLIB_RX] = clib_host_to_net_u16 (trk0->ct_ep[VLIB_RX].ce_port); session->value.ct_index = ct - cnat_translation_pool; session->value.cs_lbi = dpo0->dpoi_index; rv = cspm->vip_policy (vm, b, session, &rsession_flags, ct, ctx); if (CNAT_SOURCE_ERROR_USE_DEFAULT == rv) rv = cspm->default_policy (vm, b, session, &rsession_flags, ct, ctx); if (rv) { if (CNAT_SOURCE_ERROR_EXHAUSTED_PORTS == rv) vlib_node_increment_counter (vm, cnat_vip_ip4_node.index, CNAT_ERROR_EXHAUSTED_PORTS, 1); next0 = CNAT_TRANSLATION_NEXT_DROP; goto trace; } /* refcnt session in current client */ cnat_client_cnt_session (cc); cnat_session_create (session, ctx, rsession_flags); created_session = 1; next0 = ct->ct_lb.dpoi_next_node; vnet_buffer (b)->ip.adj_index[VLIB_TX] = session->value.cs_lbi; } if (AF_IP4 == ctx->af) cnat_translation_ip4 (session, ip4, udp0); else cnat_translation_ip6 (session, ip6, udp0); if (NULL != ct) { cti = ct - cnat_translation_pool; vlib_increment_combined_counter (cntm, ctx->thread_index, cti, 1, vlib_buffer_length_in_chain (vm, b)); } trace: if (PREDICT_FALSE (ctx->do_trace)) { cnat_translation_trace_t *t; t = vlib_add_trace (vm, node, b, sizeof (*t)); t->found_session = !rv; t->created_session = created_session; if (t->found_session || t->created_session) clib_memcpy (&t->session, session, sizeof (t->session)); t->has_tr = (NULL != ct); if (t->has_tr) clib_memcpy (&t->tr, ct, sizeof (cnat_translation_t)); } return next0; } VLIB_NODE_FN (cnat_vip_ip4_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) return cnat_node_inline (vm, node, frame, cnat_vip_node_fn, AF_IP4, 1 /* do_trace */ ); return cnat_node_inline (vm, node, frame, cnat_vip_node_fn, AF_IP4, 0 /* do_trace */ ); } VLIB_NODE_FN (cnat_vip_ip6_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) return cnat_node_inline (vm, node, frame, cnat_vip_node_fn, AF_IP6, 1 /* do_trace */ ); return cnat_node_inline (vm, node, frame, cnat_vip_node_fn, AF_IP6, 0 /* do_trace */ ); } /* *INDENT-OFF* */ VLIB_REGISTER_NODE (cnat_vip_ip4_node) = { .name = "ip4-cnat-tx", .vector_size = sizeof (u32), .format_trace = format_cnat_translation_trace, .type = VLIB_NODE_TYPE_INTERNAL, .n_errors = 0, .n_next_nodes = CNAT_TRANSLATION_N_NEXT, .next_nodes = { [CNAT_TRANSLATION_NEXT_DROP] = "ip4-drop", [CNAT_TRANSLATION_NEXT_LOOKUP] = "ip4-lookup", } }; VLIB_REGISTER_NODE (cnat_vip_ip6_node) = { .name = "ip6-cnat-tx", .vector_size = sizeof (u32), .format_trace = format_cnat_translation_trace, .type = VLIB_NODE_TYPE_INTERNAL, .n_errors = 0, .n_next_nodes = CNAT_TRANSLATION_N_NEXT, .next_nodes = { [CNAT_TRANSLATION_NEXT_DROP] = "ip6-drop", [CNAT_TRANSLATION_NEXT_LOOKUP] = "ip6-lookup", } }; /* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */