aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/mem_dlmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra/mem_dlmalloc.c')
-rw-r--r--src/vppinfra/mem_dlmalloc.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c
index e83e0e89d21..99f1c04f3eb 100644
--- a/src/vppinfra/mem_dlmalloc.c
+++ b/src/vppinfra/mem_dlmalloc.c
@@ -56,6 +56,10 @@ typedef struct
/* Hash table mapping mheap offset to trace index. */
uword *trace_index_by_offset;
+
+ /* So we can easily shut off current segment trace, if any */
+ void *current_traced_mheap;
+
} mheap_trace_main_t;
mheap_trace_main_t mheap_trace_main;
@@ -69,7 +73,7 @@ mheap_get_trace (uword offset, uword size)
mheap_trace_t trace;
uword save_enabled;
- if (tm->enabled == 0)
+ if (tm->enabled == 0 || (clib_mem_get_heap () != tm->current_traced_mheap))
return;
/* Spurious Coverity warnings be gone. */
@@ -80,11 +84,6 @@ mheap_get_trace (uword offset, uword size)
if (n_callers == 0)
return;
- /* $$$ This looks like dreck to remove... */
- if (0)
- for (i = n_callers; i < ARRAY_LEN (trace.callers); i++)
- trace.callers[i] = 0;
-
clib_spinlock_lock (&tm->lock);
/* Turn off tracing to avoid embarrassment... */
@@ -291,7 +290,8 @@ format_mheap_trace (u8 * s, va_list * va)
int i;
clib_spinlock_lock (&tm->lock);
- if (vec_len (tm->traces) > 0)
+ if (vec_len (tm->traces) > 0 &&
+ clib_mem_get_heap () == tm->current_traced_mheap)
{
have_traces = 1;
@@ -372,7 +372,8 @@ format_mheap (u8 * s, va_list * va)
format (s, "\n max total allocated %U", format_msize, mi.usmblks);
}
- s = format (s, "\n%U", format_mheap_trace, tm, verbose);
+ if (mspace_is_traced (heap))
+ s = format (s, "\n%U", format_mheap_trace, tm, verbose);
return s;
}
@@ -404,9 +405,21 @@ void
clib_mem_trace (int enable)
{
mheap_trace_main_t *tm = &mheap_trace_main;
+ void *current_heap = clib_mem_get_heap ();
tm->enabled = enable;
- mheap_trace (clib_mem_get_heap (), enable);
+ mheap_trace (current_heap, enable);
+
+ if (enable)
+ tm->current_traced_mheap = current_heap;
+ else
+ tm->current_traced_mheap = 0;
+}
+
+int
+clib_mem_is_traced (void)
+{
+ return mspace_is_traced (clib_mem_get_heap ());
}
uword
ght: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __ARP_H__
#define __ARP_H__

#include <vnet/ethernet/ethernet.h>
#include <vnet/ethernet/arp_packet.h>
#include <vnet/ip/ip.h>

extern int vnet_proxy_arp_add_del (ip4_address_t * lo_addr,
				   ip4_address_t * hi_addr,
				   u32 fib_index, int is_del);

extern int vnet_arp_set_ip4_over_ethernet (vnet_main_t * vnm,
					   u32 sw_if_index,
					   const
					   ethernet_arp_ip4_over_ethernet_address_t
					   * a, int is_static,
					   int is_no_fib_entry);

extern int vnet_arp_unset_ip4_over_ethernet (vnet_main_t * vnm,
					     u32 sw_if_index,
					     const
					     ethernet_arp_ip4_over_ethernet_address_t
					     * a);

extern int vnet_proxy_arp_fib_reset (u32 fib_id);

/**
 * call back function when walking the DB of proxy ARPs
 * @return 0 to stop the walk !0 to continue
 */
typedef walk_rc_t (proxy_arp_walk_t) (const ip4_address_t * lo_addr,
				      const ip4_address_t * hi_addr,
				      u32 fib_index, void *dat);

extern void proxy_arp_walk (proxy_arp_walk_t cb, void *data);

#endif

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */