]>
git.proxmox.com Git - mirror_frr.git/blob - sharpd/sharp_nht.c
2 * SHARP - code to track nexthops
3 * Copyright (C) Cumulus Networks, Inc.
6 * This file is part of FRR.
8 * FRR is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
13 * FRR is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "nexthop_group.h"
29 #include "sharp_nht.h"
30 #include "sharp_globals.h"
32 DEFINE_MTYPE_STATIC(SHARPD
, NH_TRACKER
, "Nexthop Tracker")
34 struct sharp_nh_tracker
*sharp_nh_tracker_get(struct prefix
*p
)
36 struct listnode
*node
;
37 struct sharp_nh_tracker
*nht
;
39 for (ALL_LIST_ELEMENTS_RO(sg
.nhs
, node
, nht
)) {
40 if (prefix_same(&nht
->p
, p
))
47 nht
= XCALLOC(MTYPE_NH_TRACKER
, sizeof(*nht
));
48 prefix_copy(&nht
->p
, p
);
50 listnode_add(sg
.nhs
, nht
);
54 void sharp_nh_tracker_dump(struct vty
*vty
)
56 struct listnode
*node
;
57 struct sharp_nh_tracker
*nht
;
59 for (ALL_LIST_ELEMENTS_RO(sg
.nhs
, node
, nht
)) {
60 char buf
[PREFIX_STRLEN
];
62 vty_out(vty
, "%s: Nexthops: %u Updates: %u\n",
63 prefix2str(&nht
->p
, buf
, sizeof(buf
)),