Coverage Report

Created: 2025-08-28 06:29

/src/frr/lib/xref.h
Line
Count
Source (jump to first uncovered line)
1
// SPDX-License-Identifier: ISC
2
/*
3
 * Copyright (c) 2017-20  David Lamparter, for NetDEF, Inc.
4
 */
5
6
#ifndef _FRR_XREF_H
7
#define _FRR_XREF_H
8
9
#include <stdint.h>
10
#include <stdlib.h>
11
#include <limits.h>
12
#include <errno.h>
13
#include "compiler.h"
14
#include "typesafe.h"
15
16
#ifdef __cplusplus
17
extern "C" {
18
#endif
19
20
enum xref_type {
21
  XREFT_NONE = 0,
22
23
  XREFT_EVENTSCHED = 0x100,
24
25
  XREFT_LOGMSG = 0x200,
26
  XREFT_ASSERT = 0x280,
27
28
  XREFT_DEFUN = 0x300,
29
  XREFT_INSTALL_ELEMENT = 0x301,
30
};
31
32
/* struct xref is the "const" part;  struct xrefdata is the writable part. */
33
struct xref;
34
struct xrefdata;
35
36
struct xref {
37
  /* this may be NULL, depending on the type of the xref.
38
   * if it is NULL, the xref has no unique ID and cannot be accessed
39
   * through that mechanism.
40
   */
41
  struct xrefdata *xrefdata;
42
43
  /* type isn't generally needed at runtime */
44
  enum xref_type type;
45
46
  /* code location */
47
  int line;
48
  const char *file;
49
  const char *func;
50
51
  /* -- 32 bytes (on 64bit) -- */
52
53
  /* type-specific bits appended by embedding this struct */
54
};
55
56
PREDECL_RBTREE_UNIQ(xrefdata_uid);
57
58
struct xrefdata {
59
  /* pointer back to the const part;  this will be initialized at
60
   * program startup by xref_block_add().  (Creating structs with
61
   * cyclic pointers to each other is not easily possible for
62
   * function-scoped static variables.)
63
   *
64
   * There is no xrefdata w/o xref, but there are xref w/o xrefdata.
65
   */
66
  const struct xref *xref;
67
68
  /* base32(crockford) of unique ID.  not all bytes are used, but
69
   * let's pad to 16 for simplicity
70
   */
71
  char uid[16];
72
73
  /* hash/uid input
74
   * if hashstr is NULL, no UID is assigned/calculated.  Use macro
75
   * string concatenation if multiple values need to be fed in.
76
   * (This is here to not make the UID calculation independent of
77
   * xref type.)
78
   */
79
  const char *hashstr;
80
  uint32_t hashu32[2];
81
82
  /* -- 32 bytes (on 64bit) -- */
83
  struct xrefdata_uid_item xui;
84
};
85
86
static inline int xrefdata_uid_cmp(const struct xrefdata *a,
87
           const struct xrefdata *b)
88
0
{
89
0
  return strcmp(a->uid, b->uid);
90
0
}
Unexecuted instantiation: ospf_main.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-ospf-route-map.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_bfd.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_dump.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_dump_api.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_errors.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_interface.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_lsa.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_lsdb.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_neighbor.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_network.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_nsm.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_opaque.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_packet.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_ri.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_routemap.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_routemap_nb.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_routemap_nb_config.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_spf.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_ti_lfa.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_sr.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_te.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_zebra.c:xrefdata_uid_cmp
Unexecuted instantiation: ospfd.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_gr_helper.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_abr.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_apiserver.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_asbr.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_ase.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_ext.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_flood.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_gr.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_ia.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_ism.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_ldp_sync.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_route.c:xrefdata_uid_cmp
Unexecuted instantiation: ospf_api.c:xrefdata_uid_cmp
Unexecuted instantiation: admin_group.c:xrefdata_uid_cmp
Unexecuted instantiation: affinitymap.c:xrefdata_uid_cmp
Unexecuted instantiation: affinitymap_cli.c:xrefdata_uid_cmp
Unexecuted instantiation: affinitymap_northbound.c:xrefdata_uid_cmp
Unexecuted instantiation: agg_table.c:xrefdata_uid_cmp
Unexecuted instantiation: atomlist.c:xrefdata_uid_cmp
Unexecuted instantiation: asn.c:xrefdata_uid_cmp
Unexecuted instantiation: bfd.c:xrefdata_uid_cmp
Unexecuted instantiation: buffer.c:xrefdata_uid_cmp
Unexecuted instantiation: checksum.c:xrefdata_uid_cmp
Unexecuted instantiation: command.c:xrefdata_uid_cmp
Unexecuted instantiation: command_graph.c:xrefdata_uid_cmp
Unexecuted instantiation: command_lex.c:xrefdata_uid_cmp
Unexecuted instantiation: command_match.c:xrefdata_uid_cmp
Unexecuted instantiation: command_parse.c:xrefdata_uid_cmp
Unexecuted instantiation: cspf.c:xrefdata_uid_cmp
Unexecuted instantiation: csv.c:xrefdata_uid_cmp
Unexecuted instantiation: darr.c:xrefdata_uid_cmp
Unexecuted instantiation: debug.c:xrefdata_uid_cmp
Unexecuted instantiation: defaults.c:xrefdata_uid_cmp
Unexecuted instantiation: distribute.c:xrefdata_uid_cmp
Unexecuted instantiation: ferr.c:xrefdata_uid_cmp
Unexecuted instantiation: filter.c:xrefdata_uid_cmp
Unexecuted instantiation: filter_cli.c:xrefdata_uid_cmp
Unexecuted instantiation: filter_nb.c:xrefdata_uid_cmp
Unexecuted instantiation: flex_algo.c:xrefdata_uid_cmp
Unexecuted instantiation: frrcu.c:xrefdata_uid_cmp
Unexecuted instantiation: frrlua.c:xrefdata_uid_cmp
Unexecuted instantiation: frrscript.c:xrefdata_uid_cmp
Unexecuted instantiation: frr_pthread.c:xrefdata_uid_cmp
Unexecuted instantiation: frrstr.c:xrefdata_uid_cmp
Unexecuted instantiation: grammar_sandbox.c:xrefdata_uid_cmp
Unexecuted instantiation: graph.c:xrefdata_uid_cmp
Unexecuted instantiation: hash.c:xrefdata_uid_cmp
Unexecuted instantiation: hook.c:xrefdata_uid_cmp
Unexecuted instantiation: id_alloc.c:xrefdata_uid_cmp
Unexecuted instantiation: if.c:xrefdata_uid_cmp
Unexecuted instantiation: if_rmap.c:xrefdata_uid_cmp
Unexecuted instantiation: imsg-buffer.c:xrefdata_uid_cmp
Unexecuted instantiation: imsg.c:xrefdata_uid_cmp
Unexecuted instantiation: jhash.c:xrefdata_uid_cmp
Unexecuted instantiation: json.c:xrefdata_uid_cmp
Unexecuted instantiation: keychain.c:xrefdata_uid_cmp
Unexecuted instantiation: ldp_sync.c:xrefdata_uid_cmp
Unexecuted instantiation: lib_errors.c:xrefdata_uid_cmp
Unexecuted instantiation: lib_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: libfrr.c:xrefdata_uid_cmp
Unexecuted instantiation: libfrr_trace.c:xrefdata_uid_cmp
Unexecuted instantiation: linklist.c:xrefdata_uid_cmp
Unexecuted instantiation: link_state.c:xrefdata_uid_cmp
Unexecuted instantiation: log.c:xrefdata_uid_cmp
Unexecuted instantiation: log_filter.c:xrefdata_uid_cmp
Unexecuted instantiation: log_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: md5.c:xrefdata_uid_cmp
Unexecuted instantiation: memory.c:xrefdata_uid_cmp
Unexecuted instantiation: mgmt_be_client.c:xrefdata_uid_cmp
Unexecuted instantiation: mgmt_fe_client.c:xrefdata_uid_cmp
Unexecuted instantiation: mgmt_msg.c:xrefdata_uid_cmp
Unexecuted instantiation: mlag.c:xrefdata_uid_cmp
Unexecuted instantiation: module.c:xrefdata_uid_cmp
Unexecuted instantiation: mpls.c:xrefdata_uid_cmp
Unexecuted instantiation: srv6.c:xrefdata_uid_cmp
Unexecuted instantiation: network.c:xrefdata_uid_cmp
Unexecuted instantiation: nexthop.c:xrefdata_uid_cmp
Unexecuted instantiation: netns_linux.c:xrefdata_uid_cmp
Unexecuted instantiation: nexthop_group.c:xrefdata_uid_cmp
Unexecuted instantiation: northbound.c:xrefdata_uid_cmp
Unexecuted instantiation: northbound_cli.c:xrefdata_uid_cmp
Unexecuted instantiation: northbound_db.c:xrefdata_uid_cmp
Unexecuted instantiation: pid_output.c:xrefdata_uid_cmp
Unexecuted instantiation: plist.c:xrefdata_uid_cmp
Unexecuted instantiation: prefix.c:xrefdata_uid_cmp
Unexecuted instantiation: privs.c:xrefdata_uid_cmp
Unexecuted instantiation: pullwr.c:xrefdata_uid_cmp
Unexecuted instantiation: qobj.c:xrefdata_uid_cmp
Unexecuted instantiation: ringbuf.c:xrefdata_uid_cmp
Unexecuted instantiation: routemap.c:xrefdata_uid_cmp
Unexecuted instantiation: routemap_cli.c:xrefdata_uid_cmp
Unexecuted instantiation: routemap_northbound.c:xrefdata_uid_cmp
Unexecuted instantiation: sbuf.c:xrefdata_uid_cmp
Unexecuted instantiation: seqlock.c:xrefdata_uid_cmp
Unexecuted instantiation: sha256.c:xrefdata_uid_cmp
Unexecuted instantiation: sigevent.c:xrefdata_uid_cmp
Unexecuted instantiation: skiplist.c:xrefdata_uid_cmp
Unexecuted instantiation: sockopt.c:xrefdata_uid_cmp
Unexecuted instantiation: sockunion.c:xrefdata_uid_cmp
Unexecuted instantiation: spf_backoff.c:xrefdata_uid_cmp
Unexecuted instantiation: segment_routing.c:xrefdata_uid_cmp
Unexecuted instantiation: srcdest_table.c:xrefdata_uid_cmp
Unexecuted instantiation: stream.c:xrefdata_uid_cmp
Unexecuted instantiation: systemd.c:xrefdata_uid_cmp
Unexecuted instantiation: table.c:xrefdata_uid_cmp
Unexecuted instantiation: termtable.c:xrefdata_uid_cmp
Unexecuted instantiation: event.c:xrefdata_uid_cmp
Unexecuted instantiation: typesafe.c:xrefdata_uid_cmp
Unexecuted instantiation: vector.c:xrefdata_uid_cmp
Unexecuted instantiation: vrf.c:xrefdata_uid_cmp
Unexecuted instantiation: vty.c:xrefdata_uid_cmp
Unexecuted instantiation: wheel.c:xrefdata_uid_cmp
Unexecuted instantiation: workqueue.c:xrefdata_uid_cmp
Unexecuted instantiation: xref.c:xrefdata_uid_cmp
Unexecuted instantiation: yang.c:xrefdata_uid_cmp
Unexecuted instantiation: yang_translator.c:xrefdata_uid_cmp
Unexecuted instantiation: yang_wrappers.c:xrefdata_uid_cmp
Unexecuted instantiation: zclient.c:xrefdata_uid_cmp
Unexecuted instantiation: zlog.c:xrefdata_uid_cmp
Unexecuted instantiation: zlog_5424.c:xrefdata_uid_cmp
Unexecuted instantiation: zlog_5424_cli.c:xrefdata_uid_cmp
Unexecuted instantiation: zlog_live.c:xrefdata_uid_cmp
Unexecuted instantiation: zlog_targets.c:xrefdata_uid_cmp
Unexecuted instantiation: routing_nb.c:xrefdata_uid_cmp
Unexecuted instantiation: routing_nb_config.c:xrefdata_uid_cmp
Unexecuted instantiation: tc.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-affinity-map.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-filter.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-if-rmap.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-interface.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-route-map.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-route-types.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-vrf.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-routing.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-nexthop.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: ietf-routing-types.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: ietf-interfaces.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: ietf-bgp-types.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-module-translator.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: connected.c:xrefdata_uid_cmp
Unexecuted instantiation: if_ioctl.c:xrefdata_uid_cmp
Unexecuted instantiation: if_netlink.c:xrefdata_uid_cmp
Unexecuted instantiation: if_socket.c:xrefdata_uid_cmp
Unexecuted instantiation: if_sysctl.c:xrefdata_uid_cmp
Unexecuted instantiation: interface.c:xrefdata_uid_cmp
Unexecuted instantiation: ioctl.c:xrefdata_uid_cmp
Unexecuted instantiation: ipforward_proc.c:xrefdata_uid_cmp
Unexecuted instantiation: ipforward_sysctl.c:xrefdata_uid_cmp
Unexecuted instantiation: kernel_netlink.c:xrefdata_uid_cmp
Unexecuted instantiation: kernel_socket.c:xrefdata_uid_cmp
Unexecuted instantiation: label_manager.c:xrefdata_uid_cmp
Unexecuted instantiation: main.c:xrefdata_uid_cmp
Unexecuted instantiation: netconf_netlink.c:xrefdata_uid_cmp
Unexecuted instantiation: redistribute.c:xrefdata_uid_cmp
Unexecuted instantiation: router-id.c:xrefdata_uid_cmp
Unexecuted instantiation: rt_netlink.c:xrefdata_uid_cmp
Unexecuted instantiation: rt_socket.c:xrefdata_uid_cmp
Unexecuted instantiation: rtadv.c:xrefdata_uid_cmp
Unexecuted instantiation: rtread_netlink.c:xrefdata_uid_cmp
Unexecuted instantiation: rtread_sysctl.c:xrefdata_uid_cmp
Unexecuted instantiation: rule_netlink.c:xrefdata_uid_cmp
Unexecuted instantiation: rule_socket.c:xrefdata_uid_cmp
Unexecuted instantiation: table_manager.c:xrefdata_uid_cmp
Unexecuted instantiation: tc_netlink.c:xrefdata_uid_cmp
Unexecuted instantiation: tc_socket.c:xrefdata_uid_cmp
Unexecuted instantiation: zapi_msg.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_affinitymap.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_dplane.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_errors.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_gr.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_l2.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_l2_bridge_if.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_evpn.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_evpn_mac.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_evpn_neigh.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_mlag.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_mlag_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_mpls.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_mpls_netlink.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_mpls_openbsd.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_mpls_null.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_mpls_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_srv6.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_srv6_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_mroute.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_nb.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_nb_config.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_nb_rpcs.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_nb_state.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_netns_id.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_netns_notify.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_nhg.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_ns.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_opaque.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_pbr.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_ptm.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_ptm_redistribute.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_pw.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_rib.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_router.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_rnh.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_routemap.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_routemap_nb.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_routemap_nb_config.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_script.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_srte.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_tc.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_trace.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_vrf.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_vxlan.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_vxlan_if.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_evpn_mh.c:xrefdata_uid_cmp
Unexecuted instantiation: zebra_neigh.c:xrefdata_uid_cmp
Unexecuted instantiation: zserv.c:xrefdata_uid_cmp
Unexecuted instantiation: debug_nl.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-zebra.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-zebra-route-map.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_main.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-types.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-common-structure.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-common.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-common-multiprotocol.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-neighbor.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-peer-group.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-bmp.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-rpki.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-deviations-bgp-datacenter.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-filter.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-bgp-route-map.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_attr.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_attr_evpn.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_clist.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_community.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_community_alias.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_debug.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_dump.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_ecommunity.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_errors.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_evpn.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_evpn_mh.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_evpn_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_filter.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_flowspec_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_fsm.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_io.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_keepalives.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_labelpool.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_lcommunity.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_mac.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_mpath.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_mplsvpn.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_network.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_nexthop.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_nht.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_packet.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_pbr.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_rd.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_regex.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_route.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_routemap.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_routemap_nb.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_routemap_nb_config.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_table.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_updgrp.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_updgrp_adv.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_updgrp_packet.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_vpn.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_zebra.c:xrefdata_uid_cmp
Unexecuted instantiation: bgpd.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_rfapi_cfg.c:xrefdata_uid_cmp
Unexecuted instantiation: rfapi_import.c:xrefdata_uid_cmp
Unexecuted instantiation: rfapi.c:xrefdata_uid_cmp
Unexecuted instantiation: rfapi_ap.c:xrefdata_uid_cmp
Unexecuted instantiation: rfapi_encap_tlv.c:xrefdata_uid_cmp
Unexecuted instantiation: rfapi_nve_addr.c:xrefdata_uid_cmp
Unexecuted instantiation: rfapi_monitor.c:xrefdata_uid_cmp
Unexecuted instantiation: rfapi_rib.c:xrefdata_uid_cmp
Unexecuted instantiation: rfapi_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: vnc_debug.c:xrefdata_uid_cmp
Unexecuted instantiation: vnc_export_bgp.c:xrefdata_uid_cmp
Unexecuted instantiation: vnc_export_table.c:xrefdata_uid_cmp
Unexecuted instantiation: vnc_import_bgp.c:xrefdata_uid_cmp
Unexecuted instantiation: vnc_zebra.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_addpath.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_advertise.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_aspath.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_bfd.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_conditional_adv.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_damp.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_encap_tlv.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_flowspec.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_flowspec_util.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_label.c:xrefdata_uid_cmp
Unexecuted instantiation: bgp_open.c:xrefdata_uid_cmp
Unexecuted instantiation: rfp_example.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_addr.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_assert.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_bfd.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_bsm.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_cmd_common.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_errors.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_hello.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_iface.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_ifchannel.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_instance.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_int.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_join.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_jp_agg.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_macro.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_mroute.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_msg.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_nb.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_nb_config.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_neighbor.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_nht.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_oil.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_pim.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_routemap.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_rp.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_rpf.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_sock.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_ssm.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_ssmpingd.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_static.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_str.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_tib.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_time.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_tlv.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_upstream.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_util.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_vty.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_zebra.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_zlookup.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_vxlan.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_register.c:xrefdata_uid_cmp
Unexecuted instantiation: pimd.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_cmd.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_igmp.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_igmp_mtrace.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_igmp_stats.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_igmpv2.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_igmpv3.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_main.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_mlag.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_msdp.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_msdp_packet.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_msdp_socket.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_signals.c:xrefdata_uid_cmp
Unexecuted instantiation: pim_zpthread.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-pim.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-pim-rp.yang.c:xrefdata_uid_cmp
Unexecuted instantiation: frr-gmp.yang.c:xrefdata_uid_cmp
91
92
DECLARE_RBTREE_UNIQ(xrefdata_uid, struct xrefdata, xui, xrefdata_uid_cmp);
93
extern struct xrefdata_uid_head xrefdata_uid;
94
95
/* linker "magic" is used to create an array of pointers to struct xref.
96
 * the result is a contiguous block of pointers, each pointing to an xref
97
 * somewhere in the code.  The linker gives us start and end pointers, we
98
 * stuff those into the struct below and hook up a constructor to run at
99
 * program startup with the struct passed.
100
 *
101
 * Placing the xrefs themselves into an array doesn't work because they'd
102
 * need to be constant size, but we're embedding struct xref into other
103
 * container structs with extra data.  Also this means that external code
104
 * (like the python xref dumper) can safely ignore extra data at the end of
105
 * xrefs without needing to account for size in iterating the array.
106
 *
107
 * If you're curious, this is also how __attribute__((constructor)) (and
108
 * destructor) are implemented - there are 2 arrays, ".init_array" and
109
 * ".fini_array", containing function pointers.  The magic turns out to be
110
 * quite mundane, actually ;)
111
 *
112
 * The slightly tricky bit is that this is a per-object (i.e. per shared
113
 * library & daemon) thing and we need a bit of help (in XREF_SETUP) to
114
 * initialize correctly.
115
 */
116
117
struct xref_block {
118
  struct xref_block *next;
119
  const struct xref * const *start;
120
  const struct xref * const *stop;
121
};
122
123
extern struct xref_block *xref_blocks;
124
extern void xref_block_add(struct xref_block *block);
125
extern void xref_gcc_workaround(const struct xref *xref);
126
127
#ifndef HAVE_SECTION_SYMS
128
/* we have a build system patch to use GNU ld on Solaris;  if that doesn't
129
 * work we end up on Solaris ld which doesn't support the section start/end
130
 * symbols.
131
 */
132
#define XREF_SETUP() \
133
  CPP_NOTICE("Missing linker support for section arrays.  Solaris ld?")
134
#else
135
/* the actual symbols that the linker provides for us.  Note these are
136
 * _symbols_ referring to the actual section start/end, i.e. they are very
137
 * much NOT _pointers_, rather the symbol *value* is the pointer.  Declaring
138
 * them as size-1 arrays is the "best" / "right" thing.
139
 */
140
extern const struct xref * const __start_xref_array[1] DSO_LOCAL;
141
extern const struct xref * const __stop_xref_array[1] DSO_LOCAL;
142
143
#if defined(__has_feature)
144
#if __has_feature(address_sanitizer)
145
/* no redzone around each of the xref_p please, we're building an array out
146
 * of variables here.  kinda breaks things if there's redzones between each
147
 * array item.
148
 */
149
#define xref_array_attr used, section("xref_array"), no_sanitize("address")
150
#endif
151
#endif
152
#ifndef xref_array_attr
153
#define xref_array_attr used, section("xref_array")
154
#endif
155
156
/* this macro is invoked once for each standalone DSO through
157
 *   FRR_MODULE_SETUP  \
158
 *                      }-> FRR_COREMOD_SETUP -> XREF_SETUP
159
 *   FRR_DAEMON_INFO   /
160
 */
161
#define XREF_SETUP()                                                           \
162
  static const struct xref _dummy_xref = {                               \
163
      /* .xrefdata = */ NULL,                                \
164
      /* .type = */ XREFT_NONE,                              \
165
      /* .line = */ __LINE__,                                \
166
      /* .file = */ __FILE__,                                \
167
      /* .func = */ "dummy",                                 \
168
  };                                                                     \
169
  static const struct xref * const _dummy_xref_p                         \
170
      __attribute__((xref_array_attr)) = &_dummy_xref;       \
171
  static void __attribute__((used, _CONSTRUCTOR(1100)))                  \
172
12
      _xref_init(void) {                                     \
173
12
    static struct xref_block _xref_block = {                       \
174
12
      .next = NULL,                                          \
175
12
      .start = __start_xref_array,                           \
176
12
      .stop = __stop_xref_array,                             \
177
12
    };                                                             \
178
12
    xref_block_add(&_xref_block);                                  \
179
12
  }                                                                      \
ospf_main.c:_xref_init
Line
Count
Source
172
2
      _xref_init(void) {                                     \
173
2
    static struct xref_block _xref_block = {                       \
174
2
      .next = NULL,                                          \
175
2
      .start = __start_xref_array,                           \
176
2
      .stop = __stop_xref_array,                             \
177
2
    };                                                             \
178
2
    xref_block_add(&_xref_block);                                  \
179
2
  }                                                                      \
module.c:_xref_init
Line
Count
Source
172
6
      _xref_init(void) {                                     \
173
6
    static struct xref_block _xref_block = {                       \
174
6
      .next = NULL,                                          \
175
6
      .start = __start_xref_array,                           \
176
6
      .stop = __stop_xref_array,                             \
177
6
    };                                                             \
178
6
    xref_block_add(&_xref_block);                                  \
179
6
  }                                                                      \
main.c:_xref_init
Line
Count
Source
172
1
      _xref_init(void) {                                     \
173
1
    static struct xref_block _xref_block = {                       \
174
1
      .next = NULL,                                          \
175
1
      .start = __start_xref_array,                           \
176
1
      .stop = __stop_xref_array,                             \
177
1
    };                                                             \
178
1
    xref_block_add(&_xref_block);                                  \
179
1
  }                                                                      \
bgp_main.c:_xref_init
Line
Count
Source
172
1
      _xref_init(void) {                                     \
173
1
    static struct xref_block _xref_block = {                       \
174
1
      .next = NULL,                                          \
175
1
      .start = __start_xref_array,                           \
176
1
      .stop = __stop_xref_array,                             \
177
1
    };                                                             \
178
1
    xref_block_add(&_xref_block);                                  \
179
1
  }                                                                      \
pim_main.c:_xref_init
Line
Count
Source
172
2
      _xref_init(void) {                                     \
173
2
    static struct xref_block _xref_block = {                       \
174
2
      .next = NULL,                                          \
175
2
      .start = __start_xref_array,                           \
176
2
      .stop = __stop_xref_array,                             \
177
2
    };                                                             \
178
2
    xref_block_add(&_xref_block);                                  \
179
2
  }                                                                      \
180
  asm(XREF_NOTE);                                                        \
181
  MACRO_REQUIRE_SEMICOLON() /* end */
182
183
/* the following blurb emits an ELF note indicating start and end of the xref
184
 * array in the binary.  This is technically the "correct" entry point for
185
 * external tools reading xrefs out of an ELF shared library or executable.
186
 *
187
 * right now, the extraction tools use the section header for "xref_array"
188
 * instead; however, section headers are technically not necessarily preserved
189
 * for fully linked libraries or executables.  (In practice they are only
190
 * stripped by obfuscation tools.)
191
 *
192
 * conversely, for reading xrefs out of a single relocatable object file (e.g.
193
 * bar.o), section headers are the right thing to look at since the note is
194
 * only emitted for the final binary once.
195
 *
196
 * FRR itself does not need this note to operate correctly, so if you have
197
 * some build issue with it just add -DFRR_XREF_NO_NOTE to your build flags
198
 * to disable it.
199
 */
200
#if defined(FRR_XREF_NO_NOTE) || defined(__mips64)
201
#define XREF_NOTE ""
202
203
/* mips64 note:  MIPS64 (regardless of endianness, both mips64 & mips64el)
204
 * does not have a 64-bit PC-relative relocation type.  Unfortunately, a
205
 * 64-bit PC-relative relocation is exactly what the below asm magic emits.
206
 * Therefore, the xref ELF note is permanently disabled on MIPS64.
207
 *
208
 * For some context, refer to https://reviews.llvm.org/D80390
209
 *
210
 * As noted above, xref extraction still works through the section header
211
 * path, so no functionality is lost.
212
 */
213
#else
214
215
#if __SIZEOF_POINTER__ == 4
216
#define _NOTE_2PTRSIZE  "8"
217
#define _NOTE_PTR ".long"
218
#elif __SIZEOF_POINTER__ == 8
219
#define _NOTE_2PTRSIZE  "16"
220
#define _NOTE_PTR ".quad"
221
#else
222
#error unsupported pointer size
223
#endif
224
225
#ifdef __arm__
226
# define asmspecial "%"
227
#else
228
# define asmspecial "@"
229
#endif
230
231
#define XREF_NOTE                                                              \
232
  ""                                                                 "\n"\
233
  " .type _frr_xref_note," asmspecial "object"                 "\n"\
234
  " .pushsection .note.FRR,\"a\"," asmspecial "note"           "\n"\
235
  " .p2align 2"                                                "\n"\
236
  "_frr_xref_note:"                                                  "\n"\
237
  " .long 9"                                                 "\n"\
238
  " .long " _NOTE_2PTRSIZE                                   "\n"\
239
  " .ascii  \"XREF\""                                          "\n"\
240
  " .ascii  \"FRRouting\\0\\0\\0\""                            "\n"\
241
  " " _NOTE_PTR " __start_xref_array-."                      "\n"\
242
  " " _NOTE_PTR " __stop_xref_array-."                       "\n"\
243
  " .size _frr_xref_note, .-_frr_xref_note"                    "\n"\
244
  " .popsection"                                               "\n"\
245
  ""                                                                 "\n"\
246
  /* end */
247
#endif
248
249
#endif /* HAVE_SECTION_SYMS */
250
251
/* emit the array entry / pointer to xref */
252
#if defined(__clang__) || !defined(__cplusplus)
253
#define XREF_LINK(dst)                                                         \
254
49.5M
  static const struct xref * const NAMECTR(xref_p_)                      \
255
49.5M
      __attribute__((xref_array_attr))                       \
256
49.5M
    = &(dst)                                                       \
257
  /* end */
258
259
#else /* GCC && C++ */
260
/* workaround for GCC bug 41091 (dated 2009), added in 2021...
261
 *
262
 * this breaks extraction of xrefs with xrelfo.py (because the xref_array
263
 * entry will be missing), but provides full runtime functionality.  To get
264
 * the proper list of xrefs from C++ code, build with clang...
265
 */
266
struct _xref_p {
267
  const struct xref * const ptr;
268
269
  _xref_p(const struct xref *_ptr) : ptr(_ptr)
270
  {
271
    xref_gcc_workaround(_ptr);
272
  }
273
};
274
275
#define XREF_LINK(dst)                                                         \
276
  static const struct _xref_p __attribute__((used))                      \
277
      NAMECTR(xref_p_)(&(dst))                               \
278
  /* end */
279
#endif
280
281
/* initializer for a "struct xref" */
282
#define XREF_INIT(type_, xrefdata_, func_)                                     \
283
49.5M
  {                                                                      \
284
49.5M
    /* .xrefdata = */ (xrefdata_),                                 \
285
49.5M
    /* .type = */ (type_),                                         \
286
49.5M
    /* .line = */ __LINE__,                                        \
287
49.5M
    /* .file = */ __FILE__,                                        \
288
49.5M
    /* .func = */ func_,                                           \
289
49.5M
  }                                                                      \
290
  /* end */
291
292
/* use with XREF_INIT when outside of a function, i.e. no __func__ */
293
#define XREF_NO_FUNC  "<global>"
294
295
#ifdef __cplusplus
296
}
297
#endif
298
299
#endif /* _FRR_XREF_H */