DEFINE_MTYPE_STATIC(NHRPD, NHRP_REGISTRATION, "NHRP registration entries")
static int nhrp_nhs_resolve(struct thread *t);
-
-struct nhrp_registration {
- struct list_head reglist_entry;
- struct thread *t_register;
- struct nhrp_nhs *nhs;
- struct nhrp_reqid reqid;
- unsigned int timeout;
- unsigned mark : 1;
- union sockunion proto_addr;
- struct nhrp_peer *peer;
- struct notifier_block peer_notifier;
-};
-
static int nhrp_reg_send_req(struct thread *t);
static void nhrp_reg_reply(struct nhrp_reqid *reqid, void *arg)
}
}
}
+
+void nhrp_nhs_foreach(struct interface *ifp, afi_t afi, void (*cb)(struct nhrp_nhs *, struct nhrp_registration *, void *), void *ctx)
+{
+ struct nhrp_interface *nifp = ifp->info;
+ struct nhrp_nhs *nhs;
+ struct nhrp_registration *reg;
+
+ list_for_each_entry(nhs, &nifp->afi[afi].nhslist_head, nhslist_entry) {
+ if (!list_empty(&nhs->reglist_head)) {
+ list_for_each_entry(reg, &nhs->reglist_head, reglist_entry)
+ cb(nhs, reg, ctx);
+ } else
+ cb(nhs, 0, ctx);
+ }
+}
VTY_NEWLINE);
}
+static void show_ip_nhrp_nhs(struct nhrp_nhs *n, struct nhrp_registration *reg, void *pctx)
+{
+ struct info_ctx *ctx = pctx;
+ struct vty *vty = ctx->vty;
+ char buf[2][SU_ADDRSTRLEN];
+
+ if (!ctx->count) {
+ vty_out(vty, "%-8s %-24s %-16s %-16s%s",
+ "Iface",
+ "FQDN",
+ "NBMA",
+ "Protocol",
+ VTY_NEWLINE);
+ }
+ ctx->count++;
+
+ vty_out(vty, "%-8s %-24s %-16s %-16s%s",
+ n->ifp->name,
+ n->nbma_fqdn,
+ (reg && reg->peer) ? sockunion2str(®->peer->vc->remote.nbma, buf[0], sizeof buf[0]) : "-",
+ sockunion2str(reg ? ®->proto_addr : &n->proto_addr, buf[1], sizeof buf[1]),
+ VTY_NEWLINE);
+}
+
+static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)
+{
+ struct info_ctx *ctx = pctx;
+ struct nhrp_cache *c;
+ struct vty *vty = ctx->vty;
+ char buf1[PREFIX_STRLEN], buf2[SU_ADDRSTRLEN];
+
+ if (!ctx->count) {
+ vty_out(vty, "%-8s %-24s %-24s %s%s",
+ "Type",
+ "Prefix",
+ "Via",
+ "Identity",
+ VTY_NEWLINE);
+ }
+ ctx->count++;
+
+ c = s->cache;
+ vty_out(ctx->vty, "%-8s %-24s %-24s %s%s",
+ nhrp_cache_type_str[s->type],
+ prefix2str(s->p, buf1, sizeof buf1),
+ c ? sockunion2str(&c->remote_addr, buf2, sizeof buf2) : "",
+ (c && c->cur.peer) ? c->cur.peer->vc->remote.id : "",
+ VTY_NEWLINE);
+}
+
static void show_ip_opennhrp_cache(struct nhrp_cache *c, void *pctx)
{
struct info_ctx *ctx = pctx;
vty_out(ctx->vty, "%s", VTY_NEWLINE);
}
-static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)
-{
- struct info_ctx *ctx = pctx;
- struct nhrp_cache *c;
- struct vty *vty = ctx->vty;
- char buf1[PREFIX_STRLEN], buf2[SU_ADDRSTRLEN];
-
- if (!ctx->count) {
- vty_out(vty, "%-8s %-24s %-24s %s%s",
- "Type",
- "Prefix",
- "Via",
- "Identity",
- VTY_NEWLINE);
- }
- ctx->count++;
-
- c = s->cache;
- vty_out(ctx->vty, "%-8s %-24s %-24s %s%s",
- nhrp_cache_type_str[s->type],
- prefix2str(s->p, buf1, sizeof buf1),
- c ? sockunion2str(&c->remote_addr, buf2, sizeof buf2) : "",
- (c && c->cur.peer) ? c->cur.peer->vc->remote.id : "",
- VTY_NEWLINE);
-}
-
DEFUN(show_ip_nhrp, show_ip_nhrp_cmd,
- "show " AFI_CMD " nhrp [cache|shortcut|opennhrp]",
+ "show " AFI_CMD " nhrp [cache|nhs|shortcut|opennhrp]",
SHOW_STR
AFI_STR
"NHRP information\n"
"Forwarding cache information\n"
+ "Next hop server information\n"
"Shortcut information\n"
"opennhrpctl style cache dump\n")
{
if (argc <= 3 || argv[3]->text[0] == 'c') {
for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
nhrp_cache_foreach(ifp, show_ip_nhrp_cache, &ctx);
- } else if (argv[3]->text[0] == 'o') {
+ } else if (argv[3]->text[0] == 'n') {
+ for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ nhrp_nhs_foreach(ifp, ctx.afi, show_ip_nhrp_nhs, &ctx);
+ } else if (argv[3]->text[0] == 's') {
+ nhrp_shortcut_foreach(ctx.afi, show_ip_nhrp_shortcut, &ctx);
+ } else {
vty_out(vty, "Status: ok%s%s", VTY_NEWLINE, VTY_NEWLINE);
ctx.count++;
for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
nhrp_cache_foreach(ifp, show_ip_opennhrp_cache, &ctx);
- } else {
- nhrp_shortcut_foreach(ctx.afi, show_ip_nhrp_shortcut, &ctx);
}
if (!ctx.count) {
struct list_head reglist_head;
};
+struct nhrp_registration {
+ struct list_head reglist_entry;
+ struct thread *t_register;
+ struct nhrp_nhs *nhs;
+ struct nhrp_reqid reqid;
+ unsigned int timeout;
+ unsigned mark : 1;
+ union sockunion proto_addr;
+ struct nhrp_peer *peer;
+ struct notifier_block peer_notifier;
+};
+
#define NHRP_IFF_SHORTCUT 0x0001
#define NHRP_IFF_REDIRECT 0x0002
#define NHRP_IFF_REG_NO_UNIQUE 0x0100
int nhrp_nhs_del(struct interface *ifp, afi_t afi, union sockunion *proto_addr, const char *nbma_fqdn);
int nhrp_nhs_free(struct nhrp_nhs *nhs);
void nhrp_nhs_terminate(void);
+void nhrp_nhs_foreach(struct interface *ifp, afi_t afi, void (*cb)(struct nhrp_nhs *, struct nhrp_registration *, void *), void *ctx);
void nhrp_route_update_nhrp(const struct prefix *p, struct interface *ifp);
void nhrp_route_announce(int add, enum nhrp_cache_type type, const struct prefix *p, struct interface *ifp, const union sockunion *nexthop, uint32_t mtu);