3 * Copyright 2009-2016, LabN Consulting, L.L.C.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "lib/zebra.h"
25 #include "lib/prefix.h"
26 #include "lib/table.h"
28 #include "lib/memory.h"
29 #include "lib/routemap.h"
31 #include "lib/log_int.h"
32 #include "lib/linklist.h"
33 #include "lib/command.h"
35 #include "bgpd/bgpd.h"
36 #include "bgpd/bgp_ecommunity.h"
37 #include "bgpd/bgp_attr.h"
38 #include "bgpd/bgp_route.h"
39 #include "bgpd/bgp_mplsvpn.h"
41 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
42 #include "bgpd/rfapi/rfapi.h"
43 #include "bgpd/rfapi/rfapi_backend.h"
45 #include "bgpd/bgp_route.h"
46 #include "bgpd/bgp_aspath.h"
47 #include "bgpd/bgp_community.h"
48 #include "bgpd/bgp_vnc_types.h"
50 #include "bgpd/rfapi/rfapi_import.h"
51 #include "bgpd/rfapi/rfapi_private.h"
52 #include "bgpd/rfapi/rfapi_monitor.h"
53 #include "bgpd/rfapi/rfapi_rib.h"
54 #include "bgpd/rfapi/rfapi_vty.h"
55 #include "bgpd/rfapi/rfapi_ap.h"
56 #include "bgpd/rfapi/rfapi_encap_tlv.h"
57 #include "bgpd/rfapi/vnc_debug.h"
59 #define DEBUG_L2_EXTRA 0
60 #define DEBUG_SHOW_EXTRA 0
62 #define VNC_SHOW_STR "VNC information\n"
64 /* format related utilies */
67 #define FMT_MIN 60 /* seconds */
68 #define FMT_HOUR (60 * FMT_MIN)
69 #define FMT_DAY (24 * FMT_HOUR)
70 #define FMT_YEAR (365 * FMT_DAY)
73 rfapiFormatSeconds (uint32_t seconds
, char *buf
, size_t len
)
75 int year
, day
, hour
, min
;
77 if (seconds
>= FMT_YEAR
)
79 year
= seconds
/ FMT_YEAR
;
80 seconds
-= year
* FMT_YEAR
;
85 if (seconds
>= FMT_DAY
)
87 day
= seconds
/ FMT_DAY
;
88 seconds
-= day
* FMT_DAY
;
93 if (seconds
>= FMT_HOUR
)
95 hour
= seconds
/ FMT_HOUR
;
96 seconds
-= hour
* FMT_HOUR
;
101 if (seconds
>= FMT_MIN
)
103 min
= seconds
/ FMT_MIN
;
104 seconds
-= min
* FMT_MIN
;
111 snprintf (buf
, len
, "%dy%dd%dh", year
, day
, hour
);
115 snprintf (buf
, len
, "%dd%dh%dm", day
, hour
, min
);
119 snprintf (buf
, len
, "%02d:%02d:%02d", hour
, min
, seconds
);
126 rfapiFormatAge (time_t age
, char *buf
, size_t len
)
128 time_t now
, age_adjusted
;
130 now
= rfapi_time (NULL
);
131 age_adjusted
= now
- age
;
133 return rfapiFormatSeconds (age_adjusted
, buf
, len
);
138 * Reimplementation of quagga/lib/prefix.c function, but
139 * for RFAPI-style prefixes
142 rfapiRprefixApplyMask (struct rfapi_ip_prefix
*rprefix
)
148 static uint8_t maskbit
[] =
149 { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
151 switch (rprefix
->prefix
.addr_family
)
154 index
= rprefix
->length
/ 8;
157 pnt
= (uint8_t *) & rprefix
->prefix
.addr
.v4
;
158 offset
= rprefix
->length
% 8;
159 pnt
[index
] &= maskbit
[offset
];
167 index
= rprefix
->length
/ 8;
170 pnt
= (uint8_t *) & rprefix
->prefix
.addr
.v6
;
171 offset
= rprefix
->length
% 8;
172 pnt
[index
] &= maskbit
[offset
];
185 * translate a quagga prefix into a rfapi IP address. The
186 * prefix is REQUIRED to be 32 bits for IPv4 and 128 bits for IPv6
194 rfapiQprefix2Raddr (struct prefix
*qprefix
, struct rfapi_ip_addr
*raddr
)
196 memset (raddr
, 0, sizeof (struct rfapi_ip_addr
));
197 raddr
->addr_family
= qprefix
->family
;
198 switch (qprefix
->family
)
201 if (qprefix
->prefixlen
!= 32)
203 raddr
->addr
.v4
= qprefix
->u
.prefix4
;
206 if (qprefix
->prefixlen
!= 128)
208 raddr
->addr
.v6
= qprefix
->u
.prefix6
;
217 * Translate Quagga prefix to RFAPI prefix
219 /* rprefix->cost set to 0 */
221 rfapiQprefix2Rprefix (struct prefix
*qprefix
, struct rfapi_ip_prefix
*rprefix
)
223 memset (rprefix
, 0, sizeof (struct rfapi_ip_prefix
));
224 rprefix
->length
= qprefix
->prefixlen
;
225 rprefix
->prefix
.addr_family
= qprefix
->family
;
226 switch (qprefix
->family
)
229 rprefix
->prefix
.addr
.v4
= qprefix
->u
.prefix4
;
232 rprefix
->prefix
.addr
.v6
= qprefix
->u
.prefix6
;
240 rfapiRprefix2Qprefix (struct rfapi_ip_prefix
*rprefix
, struct prefix
*qprefix
)
242 memset (qprefix
, 0, sizeof (struct prefix
));
243 qprefix
->prefixlen
= rprefix
->length
;
244 qprefix
->family
= rprefix
->prefix
.addr_family
;
246 switch (rprefix
->prefix
.addr_family
)
249 qprefix
->u
.prefix4
= rprefix
->prefix
.addr
.v4
;
252 qprefix
->u
.prefix6
= rprefix
->prefix
.addr
.v6
;
261 * returns 1 if prefixes have same addr family, prefix len, and address
262 * Note that host bits matter in this comparison!
264 * For paralellism with quagga/lib/prefix.c. if we need a comparison
265 * where host bits are ignored, call that function rfapiRprefixCmp.
268 rfapiRprefixSame (struct rfapi_ip_prefix
*hp1
, struct rfapi_ip_prefix
*hp2
)
270 if (hp1
->prefix
.addr_family
!= hp2
->prefix
.addr_family
)
272 if (hp1
->length
!= hp2
->length
)
274 if (hp1
->prefix
.addr_family
== AF_INET
)
275 if (IPV4_ADDR_SAME (&hp1
->prefix
.addr
.v4
, &hp2
->prefix
.addr
.v4
))
277 if (hp1
->prefix
.addr_family
== AF_INET6
)
278 if (IPV6_ADDR_SAME (&hp1
->prefix
.addr
.v6
, &hp2
->prefix
.addr
.v6
))
284 rfapiRaddr2Qprefix (struct rfapi_ip_addr
*hia
, struct prefix
*pfx
)
286 memset (pfx
, 0, sizeof (struct prefix
));
287 pfx
->family
= hia
->addr_family
;
289 switch (hia
->addr_family
)
293 pfx
->u
.prefix4
= hia
->addr
.v4
;
296 pfx
->prefixlen
= 128;
297 pfx
->u
.prefix6
= hia
->addr
.v6
;
306 rfapiL2o2Qprefix (struct rfapi_l2address_option
*l2o
, struct prefix
*pfx
)
308 memset (pfx
, 0, sizeof (struct prefix
));
309 pfx
->family
= AF_ETHERNET
;
311 pfx
->u
.prefix_eth
= l2o
->macaddr
;
315 rfapiEthAddr2Str (const struct ethaddr
*ea
, char *buf
, int bufsize
)
317 return prefix_mac2str (ea
, buf
, bufsize
);
321 rfapiStr2EthAddr (const char *str
, struct ethaddr
*ea
)
326 if (sscanf (str
, "%2x:%2x:%2x:%2x:%2x:%2x",
327 a
+ 0, a
+ 1, a
+ 2, a
+ 3, a
+ 4, a
+ 5) != 6)
333 for (i
= 0; i
< 6; ++i
)
334 ea
->octet
[i
] = a
[i
] & 0xff;
340 rfapi_ntop (int af
, const void *src
, char *buf
, socklen_t size
)
342 if (af
== AF_ETHERNET
)
344 return rfapiEthAddr2Str ((const struct ethaddr
*) src
, buf
, size
);
347 return inet_ntop (af
, src
, buf
, size
);
351 rfapiDebugPrintf (void *dummy
, const char *format
, ...)
354 va_start (args
, format
);
355 vzlog (LOG_DEBUG
, format
, args
);
361 rfapiStdioPrintf (void *stream
, const char *format
, ...)
366 va_start (args
, format
);
368 switch ((uintptr_t) stream
)
380 vfprintf (file
, format
, args
);
385 /* Fake out for debug logging */
386 static struct vty vty_dummy_zlog
;
387 static struct vty vty_dummy_stdio
;
388 #define HVTYNL ((vty == &vty_dummy_zlog)? "": VTYNL)
391 str_vty_newline (struct vty
*vty
)
393 if (vty
== &vty_dummy_zlog
)
400 void *stream
, /* input */
401 int (**fp
) (void *, const char *, ...), /* output */
402 struct vty
**vty
, /* output */
403 void **outstream
, /* output */
404 const char **vty_newline
) /* output */
409 vty_dummy_zlog
.type
= VTY_SHELL
; /* for VTYNL */
410 *vty
= &vty_dummy_zlog
;
411 *fp
= (int (*)(void *, const char *,...)) rfapiDebugPrintf
;
413 *vty_newline
= str_vty_newline (*vty
);
414 return (vzlog_test (LOG_DEBUG
));
417 if (((uintptr_t) stream
== (uintptr_t) 1) ||
418 ((uintptr_t) stream
== (uintptr_t) 2))
421 vty_dummy_stdio
.type
= VTY_SHELL
; /* for VTYNL */
422 *vty
= &vty_dummy_stdio
;
423 *fp
= (int (*)(void *, const char *,...)) rfapiStdioPrintf
;
425 *vty_newline
= str_vty_newline (*vty
);
431 *vty
= stream
; /* VTYNL requires vty to be legit */
432 *fp
= (int (*)(void *, const char *,...)) vty_out
;
434 *vty_newline
= str_vty_newline (*vty
);
441 /* called from bgpd/bgp_vty.c'route_vty_out() */
443 rfapi_vty_out_vncinfo (
453 * Print, on an indented line:
454 * UN address [if VPN route and VNC UN addr subtlv]
460 if (safi
== SAFI_MPLS_VPN
)
462 struct prefix pfx_un
;
464 if (!rfapiGetVncTunnelUnAddr (bi
->attr
, &pfx_un
))
467 vty_out (vty
, "UN=%s", inet_ntop (pfx_un
.family
,
468 pfx_un
.u
.val
, buf
, BUFSIZ
));
472 if (bi
->attr
&& bi
->attr
->extra
&& bi
->attr
->extra
->ecommunity
)
474 s
= ecommunity_ecom2str (bi
->attr
->extra
->ecommunity
,
475 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
476 vty_out (vty
, " EC{%s}", s
);
477 XFREE (MTYPE_ECOMMUNITY_STR
, s
);
480 if (bi
->extra
!= NULL
)
481 vty_out (vty
, " label=%u", decode_label (&bi
->extra
->label
));
483 if (!rfapiGetVncLifetime (bi
->attr
, &lifetime
))
485 vty_out (vty
, " life=%d", lifetime
);
488 vty_out (vty
, " type=%s, subtype=%d",
489 zebra_route_string (bi
->type
), bi
->sub_type
);
491 vty_out (vty
, "%s", HVTYNL
);
495 rfapiPrintAttrPtrs (void *stream
, struct attr
*attr
)
497 int (*fp
) (void *, const char *, ...);
500 const char *vty_newline
;
502 struct attr_extra
*ae
;
505 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
508 fp (out
, "Attr[%p]:%s", attr
, HVTYNL
);
513 inet_ntop (AF_INET
, &attr
->nexthop
, buf
, BUFSIZ
);
514 fp (out
, " nexthop=%s%s", buf
, HVTYNL
);
516 fp (out
, " aspath=%p, refcnt=%d%s", attr
->aspath
,
517 (attr
->aspath
? attr
->aspath
->refcnt
: 0), HVTYNL
);
518 fp (out
, " community=%p, refcnt=%d%s", attr
->community
,
519 (attr
->community
? attr
->community
->refcnt
: 0), HVTYNL
);
521 if ((ae
= attr
->extra
))
523 fp (out
, " ecommunity=%p, refcnt=%d%s", ae
->ecommunity
,
524 (ae
->ecommunity
? ae
->ecommunity
->refcnt
: 0), HVTYNL
);
525 fp (out
, " cluster=%p, refcnt=%d%s", ae
->cluster
,
526 (ae
->cluster
? ae
->cluster
->refcnt
: 0), HVTYNL
);
527 fp (out
, " transit=%p, refcnt=%d%s", ae
->transit
,
528 (ae
->transit
? ae
->transit
->refcnt
: 0), HVTYNL
);
533 * Print BI in an Import Table
536 rfapiPrintBi (void *stream
, struct bgp_info
*bi
)
541 int (*fp
) (void *, const char *, ...);
544 const char *vty_newline
;
550 struct ethaddr macaddr
;
551 struct rfapi_l2address_option l2o_buf
;
552 uint8_t l2hid
=0; /* valid if has_macaddr */
554 #define REMAIN (BUFSIZ - (p-line))
555 #define INCP {p += (r > REMAIN)? REMAIN: r;}
557 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
563 if (CHECK_FLAG (bi
->flags
, BGP_INFO_REMOVED
) && bi
->extra
564 && bi
->extra
->vnc
.import
.timer
)
566 struct thread
*t
= (struct thread
*) bi
->extra
->vnc
.import
.timer
;
567 r
= snprintf (p
, REMAIN
, " [%4lu] ", thread_timer_remain_second (t
));
573 r
= snprintf (p
, REMAIN
, " ");
579 /* TBD This valid only for SAFI_MPLS_VPN, but not for encap */
580 if (decode_rd_type(bi
->extra
->vnc
.import
.rd
.val
) == RD_TYPE_VNC_ETH
)
583 memcpy (macaddr
.octet
, bi
->extra
->vnc
.import
.rd
.val
+ 2, 6);
584 l2hid
= bi
->extra
->vnc
.import
.rd
.val
[1];
593 * RFP option sizes (they are opaque values)
594 * extended communities (RTs)
596 if (bi
->attr
&& bi
->attr
->extra
)
599 int printed_1st_gol
= 0;
600 struct bgp_attr_encap_subtlv
*pEncap
;
601 struct prefix pfx_un
;
602 int af
= BGP_MP_NEXTHOP_FAMILY (bi
->attr
->extra
->mp_nexthop_len
);
607 r
= snprintf (p
, REMAIN
, "%s", inet_ntop (AF_INET
,
608 &bi
->attr
->extra
->mp_nexthop_global_in
,
612 else if (af
== AF_INET6
)
614 r
= snprintf (p
, REMAIN
, "%s", inet_ntop (AF_INET6
,
615 &bi
->attr
->extra
->mp_nexthop_global
,
621 r
= snprintf (p
, REMAIN
, "?");
626 * VNC tunnel subtlv, if present, contains UN address
628 if (!rfapiGetVncTunnelUnAddr (bi
->attr
, &pfx_un
))
630 r
= snprintf (p
, REMAIN
, " un=%s", inet_ntop (pfx_un
.family
,
638 if (rfapiGetVncLifetime (bi
->attr
, &lifetime
))
640 r
= snprintf (p
, REMAIN
, " nolife");
645 if (lifetime
== 0xffffffff)
646 r
= snprintf (p
, REMAIN
, " %6s", "infini");
648 r
= snprintf (p
, REMAIN
, " %6u", lifetime
);
652 /* RFP option lengths */
653 for (pEncap
= bi
->attr
->extra
->vnc_subtlvs
; pEncap
;
654 pEncap
= pEncap
->next
)
657 if (pEncap
->type
== BGP_VNC_SUBTLV_TYPE_RFPOPTION
)
661 r
= snprintf (p
, REMAIN
, ",");
666 r
= snprintf (p
, REMAIN
, " "); /* leading space */
669 r
= snprintf (p
, REMAIN
, "%d", pEncap
->length
);
676 if (bi
->attr
->extra
->ecommunity
)
678 s
= ecommunity_ecom2str (bi
->attr
->extra
->ecommunity
,
679 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
680 r
= snprintf (p
, REMAIN
, " %s", s
);
682 XFREE (MTYPE_ECOMMUNITY_STR
, s
);
687 r
= snprintf (p
, REMAIN
, " bi@%p", bi
);
690 r
= snprintf (p
, REMAIN
, " p@%p", bi
->peer
);
693 if (CHECK_FLAG (bi
->flags
, BGP_INFO_REMOVED
))
695 r
= snprintf (p
, REMAIN
, " HD=yes");
700 r
= snprintf (p
, REMAIN
, " HD=no");
709 r
= snprintf (p
, REMAIN
, " W=%d", bi
->attr
->extra
->weight
);
713 if (bi
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
715 r
= snprintf (p
, REMAIN
, " LP=%d", bi
->attr
->local_pref
);
720 r
= snprintf (p
, REMAIN
, " LP=unset");
726 snprintf (p
, REMAIN
, " %c:%u", zebra_route_char (bi
->type
), bi
->sub_type
);
729 fp (out
, "%s%s", line
, HVTYNL
);
733 fp (out
, " RD HID=%d ETH=%02x:%02x:%02x:%02x:%02x:%02x%s",
738 macaddr
.octet
[3], macaddr
.octet
[4], macaddr
.octet
[5], HVTYNL
);
741 if (!rfapiGetL2o (bi
->attr
, &l2o_buf
))
744 " L2O ETH=%02x:%02x:%02x:%02x:%02x:%02x LBL=%d LNI=%d LHI=%hhu%s",
745 l2o_buf
.macaddr
.octet
[0], l2o_buf
.macaddr
.octet
[1],
746 l2o_buf
.macaddr
.octet
[2], l2o_buf
.macaddr
.octet
[3],
747 l2o_buf
.macaddr
.octet
[4], l2o_buf
.macaddr
.octet
[5], l2o_buf
.label
,
748 l2o_buf
.logical_net_id
, l2o_buf
.local_nve_id
, HVTYNL
);
750 if (bi
->extra
&& bi
->extra
->vnc
.import
.aux_prefix
.family
)
755 sp
= rfapi_ntop (bi
->extra
->vnc
.import
.aux_prefix
.family
,
756 &bi
->extra
->vnc
.import
.aux_prefix
.u
.prefix
,
761 fp (out
, " IP: %s%s", sp
, HVTYNL
);
765 struct rfapi_un_option
*uo
= rfapi_encap_tlv_to_un_option (bi
->attr
);
768 rfapi_print_tunneltype_option (stream
, 8, &uo
->v
.tunnel
);
769 rfapi_un_options_free (uo
);
775 rfapiMonitorVpn2Str (struct rfapi_monitor_vpn
*m
, char *buf
, int size
)
777 char buf_pfx
[BUFSIZ
];
782 rfapiRfapiIpAddr2Str (&m
->rfd
->un_addr
, buf_vn
, BUFSIZ
);
783 rfapiRfapiIpAddr2Str (&m
->rfd
->vn_addr
, buf_un
, BUFSIZ
);
785 rc
= snprintf (buf
, size
,
786 "m=%p, next=%p, rfd=%p(vn=%s un=%s), p=%s/%d, node=%p",
787 m
, m
->next
, m
->rfd
, buf_vn
, buf_un
,
788 inet_ntop (m
->p
.family
, &m
->p
.u
.prefix
, buf_pfx
, BUFSIZ
),
789 m
->p
.prefixlen
, m
->node
);
797 rfapiDebugPrintMonitorVpn (void *stream
, struct rfapi_monitor_vpn
*m
)
801 int (*fp
) (void *, const char *, ...);
804 const char *vty_newline
;
806 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
809 rfapiMonitorVpn2Str (m
, buf
, BUFSIZ
);
810 fp (out
, " Mon %s%s", buf
, HVTYNL
);
814 rfapiDebugPrintMonitorEncap (void *stream
, struct rfapi_monitor_encap
*m
)
816 int (*fp
) (void *, const char *, ...);
819 const char *vty_newline
;
821 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
824 fp (out
, " Mon m=%p, next=%p, node=%p, bi=%p%s",
825 m
, m
->next
, m
->node
, m
->bi
, HVTYNL
);
829 rfapiShowItNode (void *stream
, struct route_node
*rn
)
834 int (*fp
) (void *, const char *, ...);
837 const char *vty_newline
;
839 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
842 fp (out
, "%s/%d @%p #%d%s",
843 rfapi_ntop (rn
->p
.family
, &rn
->p
.u
.prefix
, buf
, BUFSIZ
),
844 rn
->p
.prefixlen
, rn
, rn
->lock
, HVTYNL
);
846 for (bi
= rn
->info
; bi
; bi
= bi
->next
)
848 rfapiPrintBi (stream
, bi
);
851 /* doesn't show montors */
855 rfapiShowImportTable (
858 struct route_table
*rt
,
861 struct route_node
*rn
;
864 int (*fp
) (void *, const char *, ...);
867 const char *vty_newline
;
869 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
872 fp (out
, "Import Table [%s]%s", label
, HVTYNL
);
874 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
878 if (rn
->p
.family
== AF_ETHERNET
)
880 rfapiEthAddr2Str (&rn
->p
.u
.prefix_eth
, buf
, BUFSIZ
);
884 inet_ntop (rn
->p
.family
, &rn
->p
.u
.prefix
, buf
, BUFSIZ
);
887 fp (out
, "%s/%d @%p #%d%s", buf
, rn
->p
.prefixlen
, rn
, rn
->lock
- 1, /* account for loop iterator locking */
890 for (bi
= rn
->info
; bi
; bi
= bi
->next
)
892 rfapiPrintBi (stream
, bi
);
897 struct rfapi_monitor_vpn
*m
;
898 for (m
= RFAPI_MONITOR_VPN (rn
); m
; m
= m
->next
)
900 rfapiDebugPrintMonitorVpn (stream
, m
);
905 struct rfapi_monitor_encap
*m
;
906 for (m
= RFAPI_MONITOR_ENCAP (rn
); m
; m
= m
->next
)
908 rfapiDebugPrintMonitorEncap (stream
, m
);
915 rfapiShowVncQueries (void *stream
, struct prefix
*pfx_match
)
919 struct listnode
*node
;
920 struct rfapi_descriptor
*rfd
;
922 int (*fp
) (void *, const char *, ...);
925 const char *vty_newline
;
927 int printedheader
= 0;
930 int nves_with_queries
= 0;
931 int nves_displayed
= 0;
933 int queries_total
= 0;
934 int queries_displayed
= 0;
936 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
939 bgp
= bgp_get_default (); /* assume 1 instance for now */
942 vty_outln (vty
, "No BGP instance");
949 vty_outln (vty
, "No RFAPI instance");
953 for (ALL_LIST_ELEMENTS_RO (&h
->descriptors
, node
, rfd
))
956 struct route_node
*rn
;
957 int printedquerier
= 0;
962 if (rfd
->mon
|| (rfd
->mon_eth
&& skiplist_count (rfd
->mon_eth
)))
976 for (rn
= route_top (rfd
->mon
); rn
; rn
= route_next (rn
))
978 struct rfapi_monitor_vpn
*m
;
979 char buf_remain
[BUFSIZ
];
980 char buf_pfx
[BUFSIZ
];
989 if (pfx_match
&& !prefix_match (pfx_match
, &rn
->p
) &&
990 !prefix_match (&rn
->p
, pfx_match
))
998 fp (out
, "%s", VTYNL
);
999 fp (out
, "%-15s %-15s %-15s %-10s%s",
1000 "VN Address", "UN Address",
1001 "Target", "Remaining", VTYNL
);
1004 if (!printedquerier
)
1006 char buf_vn
[BUFSIZ
];
1007 char buf_un
[BUFSIZ
];
1009 rfapiRfapiIpAddr2Str (&rfd
->un_addr
, buf_un
, BUFSIZ
);
1010 rfapiRfapiIpAddr2Str (&rfd
->vn_addr
, buf_vn
, BUFSIZ
);
1012 fp (out
, "%-15s %-15s", buf_vn
, buf_un
);
1018 fp (out
, "%-15s %-15s", "", "");
1022 rfapiFormatSeconds (thread_timer_remain_second (m
->timer
),
1023 buf_remain
, BUFSIZ
);
1025 fp (out
, " %-15s %-10s%s",
1026 inet_ntop (m
->p
.family
, &m
->p
.u
.prefix
, buf_pfx
, BUFSIZ
),
1034 if (rfd
->mon_eth
&& skiplist_count (rfd
->mon_eth
))
1039 struct rfapi_monitor_eth
*mon_eth
;
1043 skiplist_next (rfd
->mon_eth
, NULL
, (void **) &mon_eth
,
1046 skiplist_next (rfd
->mon_eth
, NULL
, (void **) &mon_eth
,
1050 char buf_remain
[BUFSIZ
];
1051 char buf_pfx
[BUFSIZ
];
1052 struct prefix pfx_mac
;
1056 vnc_zlog_debug_verbose ("%s: checking rfd=%p mon_eth=%p", __func__
, rfd
,
1059 memset ((void *) &pfx_mac
, 0, sizeof (struct prefix
));
1060 pfx_mac
.family
= AF_ETHERNET
;
1061 pfx_mac
.prefixlen
= 48;
1062 pfx_mac
.u
.prefix_eth
= mon_eth
->macaddr
;
1064 if (pfx_match
&& !prefix_match (pfx_match
, &pfx_mac
) &&
1065 !prefix_match (&pfx_mac
, pfx_match
))
1068 ++queries_displayed
;
1073 fp (out
, "%s", VTYNL
);
1074 fp (out
, "%-15s %-15s %-17s %10s %-10s%s",
1075 "VN Address", "UN Address",
1076 "Target", "LNI", "Remaining", VTYNL
);
1079 if (!printedquerier
)
1081 char buf_vn
[BUFSIZ
];
1082 char buf_un
[BUFSIZ
];
1084 rfapiRfapiIpAddr2Str (&rfd
->un_addr
, buf_un
, BUFSIZ
);
1085 rfapiRfapiIpAddr2Str (&rfd
->vn_addr
, buf_vn
, BUFSIZ
);
1087 fp (out
, "%-15s %-15s", buf_vn
, buf_un
);
1093 fp (out
, "%-15s %-15s", "", "");
1097 rfapiFormatSeconds (thread_timer_remain_second
1098 (mon_eth
->timer
), buf_remain
, BUFSIZ
);
1100 fp (out
, " %-17s %10d %-10s%s",
1101 rfapi_ntop (pfx_mac
.family
, &pfx_mac
.u
.prefix
, buf_pfx
,
1102 BUFSIZ
), mon_eth
->logical_net_id
, buf_remain
,
1110 fp (out
, "%s", VTYNL
);
1111 fp (out
, "Displayed %d out of %d total queries%s",
1112 queries_displayed
, queries_total
, VTYNL
);
1118 rfapiPrintRemoteRegBi (
1121 struct route_node
*rn
,
1122 struct bgp_info
*bi
)
1124 int (*fp
) (void *, const char *, ...);
1127 const char *vty_newline
;
1128 struct prefix pfx_un
;
1129 struct prefix pfx_vn
;
1132 bgp_encap_types tun_type
;
1134 char buf_pfx
[BUFSIZ
];
1135 char buf_ntop
[BUFSIZ
];
1136 char buf_un
[BUFSIZ
];
1137 char buf_vn
[BUFSIZ
];
1138 char buf_lifetime
[BUFSIZ
];
1142 return 0; /* for debug log, print into buf & call output once */
1144 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
1151 snprintf (buf_pfx
, BUFSIZ
, "%s/%d",
1152 rfapi_ntop (rn
->p
.family
, &rn
->p
.u
.prefix
, buf_ntop
, BUFSIZ
),
1154 buf_pfx
[BUFSIZ
- 1] = 0;
1161 if (!rfapiGetUnAddrOfVpnBi (bi
, &pfx_un
))
1163 snprintf (buf_un
, BUFSIZ
, "%s",
1164 inet_ntop (pfx_un
.family
, &pfx_un
.u
.prefix
, buf_ntop
,
1168 rfapiGetTunnelType(bi
->attr
,&tun_type
);
1173 rfapiNexthop2Prefix (bi
->attr
, &pfx_vn
);
1174 if (tun_type
== BGP_ENCAP_TYPE_MPLS
)
1176 /* MPLS carries un in nrli next hop (same as vn for IP tunnels) */
1177 snprintf (buf_un
, BUFSIZ
, "%s",
1178 inet_ntop (pfx_vn
.family
, &pfx_vn
.u
.prefix
, buf_ntop
, BUFSIZ
));
1181 u_int32_t l
= decode_label (&bi
->extra
->label
);
1182 snprintf (buf_vn
, BUFSIZ
, "Label: %d", l
);
1184 else /* should never happen */
1186 snprintf (buf_vn
, BUFSIZ
, "Label: N/A");
1191 snprintf (buf_vn
, BUFSIZ
, "%s",
1192 inet_ntop (pfx_vn
.family
, &pfx_vn
.u
.prefix
, buf_ntop
, BUFSIZ
));
1194 buf_vn
[BUFSIZ
- 1] = 0;
1195 buf_un
[BUFSIZ
- 1] = 0;
1198 * Cost is encoded in local_pref as (255-cost)
1199 * See rfapi_import.c'rfapiRouteInfo2NextHopEntry() for conversion
1204 uint32_t local_pref
;
1205 if (bi
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
1206 local_pref
= bi
->attr
->local_pref
;
1209 cost
= (local_pref
> 255) ? 0 : 255 - local_pref
;
1216 fp (out
, "%-20s ", buf_pfx
);
1217 fp (out
, "%-15s ", buf_vn
);
1218 fp (out
, "%-15s ", buf_un
);
1219 fp (out
, "%-4d ", cost
);
1222 /* NB rfapiGetVncLifetime sets infinite value when returning !0 */
1223 if (rfapiGetVncLifetime (bi
->attr
, &lifetime
) ||
1224 (lifetime
== RFAPI_INFINITE_LIFETIME
))
1227 fp (out
, "%-10s ", "infinite");
1231 time_t t_lifetime
= lifetime
;
1232 rfapiFormatSeconds (t_lifetime
, buf_lifetime
, BUFSIZ
);
1233 fp (out
, "%-10s ", buf_lifetime
);
1236 if (CHECK_FLAG (bi
->flags
, BGP_INFO_REMOVED
) &&
1237 bi
->extra
&& bi
->extra
->vnc
.import
.timer
)
1242 char buf_age
[BUFSIZ
];
1244 struct thread
*t
= (struct thread
*) bi
->extra
->vnc
.import
.timer
;
1245 remaining
= thread_timer_remain_second (t
);
1247 #if RFAPI_REGISTRATIONS_REPORT_AGE
1249 * Calculate when the timer started. Doing so here saves
1250 * us a timestamp field in "struct bgp_info".
1252 * See rfapi_import.c'rfapiBiStartWithdrawTimer() for the
1253 * original calculation.
1255 age
= rfapiGetHolddownFromLifetime (lifetime
, factor
) - remaining
;
1256 #else /* report remaining time */
1259 rfapiFormatSeconds (age
, buf_age
, BUFSIZ
);
1261 fp (out
, "%-10s ", buf_age
);
1264 else if (RFAPI_LOCAL_BI (bi
))
1267 char buf_age
[BUFSIZ
];
1269 if (bi
&& bi
->extra
&& bi
->extra
->vnc
.import
.create_time
)
1271 rfapiFormatAge (bi
->extra
->vnc
.import
.create_time
, buf_age
, BUFSIZ
);
1278 fp (out
, "%-10s ", buf_age
);
1280 fp (out
, "%s", HVTYNL
);
1282 if (rn
->p
.family
== AF_ETHERNET
)
1285 * If there is a corresponding IP address && != VN address,
1286 * print that on the next line
1289 if (bi
&& bi
->extra
&& bi
->extra
->vnc
.import
.aux_prefix
.family
)
1293 sp
= rfapi_ntop (bi
->extra
->vnc
.import
.aux_prefix
.family
,
1294 &bi
->extra
->vnc
.import
.aux_prefix
.u
.prefix
,
1296 buf_ntop
[BUFSIZ
- 1] = 0;
1298 if (sp
&& strcmp (buf_vn
, sp
) != 0)
1300 fp (out
, " IP: %s", sp
);
1306 if (tun_type
!= BGP_ENCAP_TYPE_MPLS
&& bi
->extra
)
1308 u_int32_t l
= decode_label (&bi
->extra
->label
);
1309 if (!MPLS_LABEL_IS_NULL (l
))
1311 fp (out
, " Label: %d", l
);
1317 fp (out
, "%s", HVTYNL
);
1323 rfapiShowRemoteRegistrationsIt (
1326 struct rfapi_import_table
*it
,
1327 struct prefix
*prefix_only
,
1328 int show_expiring
, /* either/or */
1331 int show_imported
, /* either/or */
1332 uint32_t *pLni
) /* AFI_L2VPN only */
1335 int printed_rtlist_hdr
= 0;
1337 int (*fp
) (void *, const char *, ...);
1340 const char *vty_newline
;
1344 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
1347 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
1350 struct route_node
*rn
;
1352 if (!it
->imported_vpn
[afi
])
1355 for (rn
= route_top (it
->imported_vpn
[afi
]); rn
; rn
= route_next (rn
))
1358 struct bgp_info
*bi
;
1361 /* allow for wider or more narrow mask from user */
1363 !prefix_match (prefix_only
, &rn
->p
) &&
1364 !prefix_match (&rn
->p
, prefix_only
))
1369 for (bi
= rn
->info
; bi
; bi
= bi
->next
)
1372 if (!show_local
&& RFAPI_LOCAL_BI (bi
))
1375 /* local route from RFP */
1379 if (!show_remote
&& !RFAPI_LOCAL_BI (bi
))
1386 if (show_expiring
&& !CHECK_FLAG (bi
->flags
, BGP_INFO_REMOVED
))
1389 if (!show_expiring
&& CHECK_FLAG (bi
->flags
, BGP_INFO_REMOVED
))
1392 if (bi
->type
== ZEBRA_ROUTE_BGP_DIRECT
||
1393 bi
->type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
)
1405 if (count_only
== 1)
1407 if (!printed_rtlist_hdr
)
1409 const char *agetype
= "";
1411 const char *type
= "";
1424 if (RFAPI_LOCAL_BI (bi
))
1435 s
= ecommunity_ecom2str (it
->rt_import_list
,
1436 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
1440 fp (out
, "%s[%s] L2VPN Network 0x%x (%u) RT={%s}",
1441 HVTYNL
, type
, *pLni
, (*pLni
& 0xfff), s
);
1445 fp (out
, "%s[%s] Prefix RT={%s}",
1448 XFREE (MTYPE_ECOMMUNITY_STR
, s
);
1450 if (it
->rfg
&& it
->rfg
->name
)
1452 fp (out
, " %s \"%s\"",
1453 (it
->rfg
->type
== RFAPI_GROUP_CFG_VRF
?
1454 "VRF" : "NVE group"),
1457 fp (out
, "%s", HVTYNL
);
1460 #if RFAPI_REGISTRATIONS_REPORT_AGE
1463 agetype
= "Remaining";
1466 else if (show_local
)
1471 printed_rtlist_hdr
= 1;
1473 fp (out
, "%-20s %-15s %-15s %4s %-10s %-10s%s",
1474 (pLni
? "L2 Address/IP" : "Prefix"),
1475 "VN Address", "UN Address", "Cost",
1476 "Lifetime", agetype
, HVTYNL
);
1478 printed
+= rfapiPrintRemoteRegBi (bgp
, stream
, rn
, bi
);
1486 const char *type
= "prefixes";
1490 type
= "imported prefixes";
1496 type
= "prefixes in holddown";
1500 if (show_local
&& !show_remote
)
1502 type
= "locally registered prefixes";
1504 else if (!show_local
&& show_remote
)
1506 type
= "remotely registered prefixes";
1511 fp (out
, "Displayed %d out of %d %s%s",
1512 printed
, total
, type
, HVTYNL
);
1513 #if DEBUG_SHOW_EXTRA
1514 fp(out
, "IT table above: it=%p%s", it
, HVTYNL
);
1523 * rfapiShowRemoteRegistrations
1525 * Similar to rfapiShowImportTable() above. This function
1526 * is mean to produce the "remote" portion of the output
1527 * of "show vnc registrations".
1530 rfapiShowRemoteRegistrations (
1532 struct prefix
*prefix_only
,
1540 struct rfapi_import_table
*it
;
1543 bgp
= bgp_get_default ();
1555 for (it
= h
->imports
; it
; it
= it
->next
)
1558 rfapiShowRemoteRegistrationsIt (bgp
, stream
, it
, prefix_only
,
1559 show_expiring
, show_local
,
1560 show_remote
, show_imported
, NULL
);
1565 void *cursor
= NULL
;
1567 uintptr_t lni_as_ptr
;
1572 skiplist_next (h
->import_mac
, (void **) &lni_as_ptr
, (void **) &it
,
1575 skiplist_next (h
->import_mac
, (void **) &lni_as_ptr
, (void **) &it
,
1579 if ((lni_as_ptr
& 0xffffffff) == lni_as_ptr
)
1581 lni
= (uint32_t) (lni_as_ptr
& 0xffffffff);
1586 rfapiShowRemoteRegistrationsIt (bgp
, stream
, it
, prefix_only
,
1587 show_expiring
, show_local
,
1588 show_remote
, show_imported
, pLni
);
1595 /*------------------------------------------
1596 * rfapiRfapiIpAddr2Str
1598 * UI helper: generate string from rfapi_ip_addr
1601 * a IP v4/v6 address
1604 * buf put string here
1605 * bufsize max space to write
1608 * NULL conversion failed
1609 * non-NULL pointer to buf
1610 --------------------------------------------*/
1612 rfapiRfapiIpAddr2Str (struct rfapi_ip_addr
*a
, char *buf
, int bufsize
)
1614 const char *rc
= NULL
;
1616 switch (a
->addr_family
)
1619 rc
= inet_ntop (a
->addr_family
, &a
->addr
.v4
, buf
, bufsize
);
1622 rc
= inet_ntop (a
->addr_family
, &a
->addr
.v6
, buf
, bufsize
);
1629 rfapiPrintRfapiIpAddr (void *stream
, struct rfapi_ip_addr
*a
)
1632 const char *rc
= NULL
;
1634 int (*fp
) (void *, const char *, ...);
1637 const char *vty_newline
;
1639 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
1642 rc
= rfapiRfapiIpAddr2Str (a
, buf
, BUFSIZ
);
1645 fp (out
, "%s", buf
);
1649 rfapiRfapiIpPrefix2Str (struct rfapi_ip_prefix
*p
, char *buf
, int bufsize
)
1651 struct rfapi_ip_addr
*a
= &p
->prefix
;
1652 const char *rc
= NULL
;
1654 switch (a
->addr_family
)
1657 rc
= inet_ntop (a
->addr_family
, &a
->addr
.v4
, buf
, bufsize
);
1660 rc
= inet_ntop (a
->addr_family
, &a
->addr
.v6
, buf
, bufsize
);
1666 int alen
= strlen (buf
);
1667 int remaining
= bufsize
- alen
- 1;
1672 slen
= snprintf (buf
+ alen
, remaining
, "/%u", p
->length
);
1673 if (slen
< remaining
) /* see man page for snprintf(3) */
1682 rfapiPrintRfapiIpPrefix (void *stream
, struct rfapi_ip_prefix
*p
)
1687 int (*fp
) (void *, const char *, ...);
1690 const char *vty_newline
;
1692 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
1695 rc
= rfapiRfapiIpPrefix2Str (p
, buf
, BUFSIZ
);
1698 fp (out
, "%s:%u", buf
, p
->cost
);
1704 rfapiPrintRd (struct vty
*vty
, struct prefix_rd
*prd
)
1709 prefix_rd2str (prd
, buf
, BUFSIZ
);
1710 buf
[BUFSIZ
- 1] = 0;
1711 vty_out (vty
, "%s", buf
);
1715 rfapiPrintAdvertisedInfo (
1717 struct rfapi_descriptor
*rfd
,
1721 afi_t afi
; /* of the VN address */
1722 struct bgp_node
*bn
;
1723 struct bgp_info
*bi
;
1724 uint8_t type
= ZEBRA_ROUTE_BGP
;
1727 struct prefix_rd prd0
;
1728 struct prefix_rd
*prd
;
1731 * Find the bgp_info in the RIB corresponding to this
1735 afi
= family2afi (p
->family
);
1736 assert (afi
== AFI_IP
|| afi
== AFI_IP6
);
1738 bgp
= bgp_get_default (); /* assume 1 instance for now */
1741 if (safi
== SAFI_ENCAP
)
1743 memset (&prd0
, 0, sizeof (prd0
));
1744 prd0
.family
= AF_UNSPEC
;
1745 prd0
.prefixlen
= 64;
1752 bn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1754 vty_out (vty
, " bn=%p%s", bn
, HVTYNL
);
1756 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
1758 if (bi
->peer
== rfd
->peer
&&
1760 bi
->sub_type
== BGP_ROUTE_RFP
&&
1761 bi
->extra
&& bi
->extra
->vnc
.export
.rfapi_handle
== (void *) rfd
)
1764 rfapiPrintBi (vty
, bi
);
1771 vty_out (vty
, " --?--%s", HVTYNL
);
1778 rfapiPrintDescriptor (struct vty
*vty
, struct rfapi_descriptor
*rfd
)
1780 /* pHD un-addr vn-addr pCB cookie rd lifetime */
1781 /* RT export list */
1782 /* RT import list */
1783 /* list of advertised prefixes */
1784 /* dump import table */
1790 struct rfapi_adb
*adb
;
1793 vty_out (vty
, "%-10p ", rfd
);
1794 rfapiPrintRfapiIpAddr (vty
, &rfd
->un_addr
);
1796 rfapiPrintRfapiIpAddr (vty
, &rfd
->vn_addr
);
1797 vty_out (vty
, " %p %p ", rfd
->response_cb
, rfd
->cookie
);
1798 rfapiPrintRd (vty
, &rfd
->rd
);
1799 vty_out (vty
, " %d", rfd
->response_lifetime
);
1800 vty_out (vty
, " %s", (rfd
->rfg
? rfd
->rfg
->name
: "<orphaned>"));
1801 vty_out (vty
, "%s", HVTYNL
);
1803 vty_out (vty
, " Peer %p #%d%s", rfd
->peer
, rfd
->peer
->lock
, HVTYNL
);
1805 /* export RT list */
1806 if (rfd
->rt_export_list
)
1809 ecommunity_ecom2str (rfd
->rt_export_list
,
1810 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
1811 vty_out (vty
, " Export %s%s", s
, HVTYNL
);
1812 XFREE (MTYPE_ECOMMUNITY_STR
, s
);
1816 vty_out (vty
, " Export (nil)%s", HVTYNL
);
1819 /* import RT list */
1820 if (rfd
->import_table
)
1822 s
= ecommunity_ecom2str (rfd
->import_table
->rt_import_list
,
1823 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
1824 vty_out (vty
, " Import %s%s", s
, HVTYNL
);
1825 XFREE (MTYPE_ECOMMUNITY_STR
, s
);
1829 vty_out (vty
, " Import (nil)%s", HVTYNL
);
1832 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
1836 family
= afi2family (afi
);
1842 skiplist_next (rfd
->advertised
.ipN_by_prefix
, NULL
, (void **) &adb
,
1845 skiplist_next (rfd
->advertised
.ipN_by_prefix
, NULL
, (void **) &adb
,
1849 /* group like family prefixes together in output */
1850 if (family
!= adb
->u
.s
.prefix_ip
.family
)
1853 prefix2str (&adb
->u
.s
.prefix_ip
, buf
, BUFSIZ
);
1854 buf
[BUFSIZ
- 1] = 0; /* guarantee NUL-terminated */
1856 vty_out (vty
, " Adv Pfx: %s%s", buf
, HVTYNL
);
1857 rfapiPrintAdvertisedInfo (vty
, rfd
, SAFI_MPLS_VPN
, &adb
->u
.s
.prefix_ip
);
1861 skiplist_next (rfd
->advertised
.ip0_by_ether
, NULL
, (void **) &adb
,
1864 skiplist_next (rfd
->advertised
.ip0_by_ether
, NULL
, (void **) &adb
,
1868 prefix2str (&adb
->u
.s
.prefix_eth
, buf
, BUFSIZ
);
1869 buf
[BUFSIZ
- 1] = 0; /* guarantee NUL-terminated */
1871 vty_out (vty
, " Adv Pfx: %s%s", buf
, HVTYNL
);
1873 /* TBD update the following function to print ethernet info */
1874 /* Also need to pass/use rd */
1875 rfapiPrintAdvertisedInfo (vty
, rfd
, SAFI_MPLS_VPN
, &adb
->u
.s
.prefix_ip
);
1877 vty_out (vty
, "%s", HVTYNL
);
1881 * test scripts rely on first line for each nve starting in 1st column,
1882 * leading whitespace for additional detail of that nve
1885 rfapiPrintMatchingDescriptors (struct vty
*vty
,
1886 struct prefix
*vn_prefix
,
1887 struct prefix
*un_prefix
)
1891 struct listnode
*ln
;
1892 struct rfapi_descriptor
*rfd
;
1895 bgp
= bgp_get_default (); /* assume 1 instance for now */
1902 for (ln
= listhead (&h
->descriptors
); ln
; ln
= listnextnode (ln
))
1904 rfd
= listgetdata (ln
);
1910 assert (!rfapiRaddr2Qprefix (&rfd
->vn_addr
, &pfx
));
1911 if (!prefix_match (vn_prefix
, &pfx
))
1917 assert (!rfapiRaddr2Qprefix (&rfd
->un_addr
, &pfx
));
1918 if (!prefix_match (un_prefix
, &pfx
))
1924 /* print column header */
1926 "%s %s %s %s %s %s %s %s%s",
1927 "descriptor", "un-addr", "vn-addr", "callback", "cookie",
1928 "RD", "lifetime", "group", HVTYNL
);
1930 rfapiPrintDescriptor (vty
, rfd
);
1937 * Parse an address and put into a struct prefix
1940 rfapiCliGetPrefixAddr (struct vty
*vty
, const char *str
, struct prefix
*p
)
1942 if (!str2prefix (str
, p
))
1944 vty_out (vty
, "Malformed address \"%s\"%s", str
, HVTYNL
);
1950 if (p
->prefixlen
!= 32)
1952 vty_out (vty
, "Not a host address: \"%s\"%s", str
, HVTYNL
);
1957 if (p
->prefixlen
!= 128)
1959 vty_out (vty
, "Not a host address: \"%s\"%s", str
, HVTYNL
);
1964 vty_out (vty
, "Invalid address \"%s\"%s", str
, HVTYNL
);
1971 rfapiCliGetRfapiIpAddr (
1974 struct rfapi_ip_addr
*hai
)
1979 rc
= rfapiCliGetPrefixAddr (vty
, str
, &pfx
);
1983 hai
->addr_family
= pfx
.family
;
1984 if (pfx
.family
== AF_INET
)
1985 hai
->addr
.v4
= pfx
.u
.prefix4
;
1987 hai
->addr
.v6
= pfx
.u
.prefix6
;
1993 * Note: this function does not flush vty output, so if it is called
1994 * with a stream pointing to a vty, the user will have to type something
1995 * before the callback output shows up
1998 rfapiPrintNhl (void *stream
, struct rfapi_next_hop_entry
*next_hops
)
2000 struct rfapi_next_hop_entry
*nh
;
2003 int (*fp
) (void *, const char *, ...);
2006 const char *vty_newline
;
2008 #define REMAIN (BUFSIZ - (p-line))
2009 #define INCP {p += (r > REMAIN)? REMAIN: r;}
2012 if (rfapiStream2Vty (stream
, &fp
, &vty
, &out
, &vty_newline
) == 0)
2015 for (nh
= next_hops
, count
= 1; nh
; nh
= nh
->next
, ++count
)
2022 r
= snprintf (p
, REMAIN
, "%3d pfx=", count
);
2025 if (rfapiRfapiIpPrefix2Str (&nh
->prefix
, p
, REMAIN
))
2027 /* it fit, so count length */
2037 r
= snprintf (p
, REMAIN
, ", un=");
2040 if (rfapiRfapiIpAddr2Str (&nh
->un_address
, p
, REMAIN
))
2042 /* it fit, so count length */
2052 r
= snprintf (p
, REMAIN
, ", vn=");
2055 if (rfapiRfapiIpAddr2Str (&nh
->vn_address
, p
, REMAIN
))
2057 /* it fit, so count length */
2068 line
[BUFSIZ
- 1] = 0;
2069 fp (out
, "%s%s", line
, HVTYNL
);
2076 struct rfapi_vn_option
*vo
;
2077 char offset
[] = " ";
2079 for (vo
= nh
->vn_options
; vo
; vo
= vo
->next
)
2085 case RFAPI_VN_OPTION_TYPE_L2ADDR
:
2086 rfapiEthAddr2Str (&vo
->v
.l2addr
.macaddr
, pbuf
,
2088 fp (out
, "%sL2 %s LBL=0x%06x NETID=0x%06x NVEID=%d%s",
2089 offset
, pbuf
, (vo
->v
.l2addr
.label
& 0x00ffffff),
2090 (vo
->v
.l2addr
.logical_net_id
& 0x00ffffff),
2091 vo
->v
.l2addr
.local_nve_id
, HVTYNL
);
2094 case RFAPI_VN_OPTION_TYPE_LOCAL_NEXTHOP
:
2095 prefix2str (&vo
->v
.local_nexthop
.addr
, pbuf
, sizeof (pbuf
));
2096 fp (out
, "%sLNH %s cost=%d%s",
2097 offset
, pbuf
, vo
->v
.local_nexthop
.cost
, HVTYNL
);
2101 fp (out
, "%svn option type %d (unknown)%s",
2102 offset
, vo
->type
, HVTYNL
);
2109 struct rfapi_un_option
*uo
;
2110 char offset
[] = " ";
2112 for (uo
= nh
->un_options
; uo
; uo
= uo
->next
)
2116 case RFAPI_UN_OPTION_TYPE_TUNNELTYPE
:
2117 rfapi_print_tunneltype_option (stream
, 8, &uo
->v
.tunnel
);
2120 fp (out
, "%sUN Option type %d%s",
2121 offset
, uo
->type
, vty_newline
);
2130 /***********************************************************************
2132 ***********************************************************************/
2135 * Add another nexthop to the NHL
2138 rfapiAddDeleteLocalRfpPrefix (
2139 struct rfapi_ip_addr
*un_addr
,
2140 struct rfapi_ip_addr
*vn_addr
,
2141 struct rfapi_ip_prefix
*rprefix
,
2143 uint32_t lifetime
, /* add only */
2144 struct rfapi_vn_option
*vn_options
,
2145 struct rfapi_next_hop_entry
**head
,
2146 struct rfapi_next_hop_entry
**tail
)
2148 struct rfapi_next_hop_entry
*new;
2154 new = XCALLOC (MTYPE_RFAPI_NEXTHOP
, sizeof (struct rfapi_next_hop_entry
));
2155 new->prefix
= *rprefix
;
2156 new->un_address
= *un_addr
;
2157 new->vn_address
= *vn_addr
;
2159 new->vn_options
= vn_options
;
2162 new->lifetime
= lifetime
;
2166 new->lifetime
= RFAPI_REMOVE_RESPONSE_LIFETIME
;
2170 (*tail
)->next
= new;
2182 struct cmd_token
*carg_prefix
,
2183 struct cmd_token
*carg_vn
,
2184 struct cmd_token
*carg_un
,
2185 struct cmd_token
*carg_cost
, /* optional */
2186 struct cmd_token
*carg_lifetime
, /* optional */
2187 struct cmd_token
*carg_macaddr
, /* optional */
2188 struct cmd_token
*carg_vni
, /* mac present=>mandatory Virtual Network ID */
2190 struct cmd_token
**argv
)
2192 const char *arg_prefix
= carg_prefix
? carg_prefix
->arg
: NULL
;
2193 const char *arg_vn
= carg_vn
? carg_vn
->arg
: NULL
;
2194 const char *arg_un
= carg_un
? carg_un
->arg
: NULL
;
2195 const char *arg_cost
= carg_cost
? carg_cost
->arg
: NULL
;
2196 const char *arg_lifetime
= carg_lifetime
? carg_lifetime
->arg
: NULL
;
2197 const char *arg_macaddr
= carg_macaddr
? carg_macaddr
->arg
: NULL
;
2198 const char *arg_vni
= carg_vni
? carg_vni
->arg
: NULL
;
2199 struct rfapi_ip_addr vn_address
;
2200 struct rfapi_ip_addr un_address
;
2202 struct rfapi_ip_prefix rpfx
;
2207 struct rfapi_vn_option optary
[10]; /* XXX must be big enough */
2208 struct rfapi_vn_option
*opt
= NULL
;
2211 int rc
= CMD_WARNING
;
2215 struct rfapi_cfg
*rfapi_cfg
;
2217 const char *arg_lnh
= NULL
;
2218 const char *arg_lnh_cost
= NULL
;
2220 bgp
= bgp_get_default (); /* assume 1 instance for now */
2224 vty_outln (vty
, "BGP not configured");
2229 rfapi_cfg
= bgp
->rfapi_cfg
;
2230 if (!h
|| !rfapi_cfg
)
2233 vty_outln (vty
, "RFAPI not configured");
2237 for (; argc
; --argc
, ++argv
)
2239 if (strmatch(argv
[0]->text
, "local-next-hop"))
2243 vty_outln (vty
,"local-next-hop specified more than once");
2248 vty_outln (vty
,"Missing parameter for local-next-hop");
2252 arg_lnh
= argv
[0]->arg
;
2254 if (strmatch(argv
[0]->text
, "local-cost"))
2258 vty_outln (vty
,"local-cost specified more than once");
2263 vty_outln (vty
,"Missing parameter for local-cost");
2267 arg_lnh_cost
= argv
[0]->arg
;
2271 if ((rc
= rfapiCliGetRfapiIpAddr (vty
, arg_vn
, &vn_address
)))
2273 if ((rc
= rfapiCliGetRfapiIpAddr (vty
, arg_un
, &un_address
)))
2276 /* arg_prefix is optional if mac address is given */
2277 if (arg_macaddr
&& !arg_prefix
)
2280 * fake up a 0/32 or 0/128 prefix
2282 switch (vn_address
.addr_family
)
2285 arg_prefix
= "0.0.0.0/32";
2288 arg_prefix
= "0::0/128";
2291 vty_outln (vty
,"Internal error, unknown VN address family");
2297 if (!str2prefix (arg_prefix
, &pfx
))
2299 vty_outln (vty
, "Malformed prefix \"%s\"",arg_prefix
);
2302 if (pfx
.family
!= AF_INET
2303 && pfx
.family
!= AF_INET6
)
2305 vty_outln (vty
, "prefix \"%s\" has invalid address family",
2311 memset (optary
, 0, sizeof (optary
));
2316 cost
= strtoul (arg_cost
, &endptr
, 10);
2317 if (*endptr
!= '\0' || cost
> 255)
2319 vty_outln (vty
, "%% Invalid %s value", "cost");
2330 if (!strcmp (arg_lifetime
, "infinite"))
2332 lifetime
= RFAPI_INFINITE_LIFETIME
;
2337 lifetime
= strtoul (arg_lifetime
, &endptr
, 10);
2338 if (*endptr
!= '\0')
2340 vty_outln (vty
, "%% Invalid %s value","lifetime");
2347 lifetime
= RFAPI_INFINITE_LIFETIME
; /* default infinite */
2355 "%% %s may only be specified with local-next-hop",
2360 lnh_cost
= strtoul (arg_lnh_cost
, &endptr
, 10);
2361 if (*endptr
!= '\0' || lnh_cost
> 255)
2363 vty_outln (vty
, "%% Invalid %s value","local-cost");
2376 vty_outln (vty
, "%% %s may only be specified with prefix",
2380 if ((rc
= rfapiCliGetPrefixAddr (vty
, arg_lnh
,
2381 &optary
[opt_next
].v
.
2382 local_nexthop
.addr
)))
2388 optary
[opt_next
].v
.local_nexthop
.cost
= lnh_cost
;
2389 optary
[opt_next
].type
= RFAPI_VN_OPTION_TYPE_LOCAL_NEXTHOP
;
2393 optary
[opt_next
- 1].next
= optary
+ opt_next
;
2402 if (arg_vni
&& !arg_macaddr
)
2404 vty_outln (vty
, "%% %s may only be specified with mac address",
2405 "virtual-network-identifier");
2414 "Missing \"vni\" parameter (mandatory with mac)");
2417 optary
[opt_next
].v
.l2addr
.logical_net_id
= strtoul(arg_vni
, NULL
,
2420 if ((rc
= rfapiStr2EthAddr (arg_macaddr
,
2421 &optary
[opt_next
].v
.l2addr
.macaddr
)))
2423 vty_outln (vty
, "Invalid %s value","mac address");
2426 /* TBD label, NVE ID */
2428 optary
[opt_next
].type
= RFAPI_VN_OPTION_TYPE_L2ADDR
;
2432 optary
[opt_next
- 1].next
= optary
+ opt_next
;
2441 vnc_zlog_debug_verbose
2442 ("%s: vn=%s, un=%s, prefix=%s, cost=%s, lifetime=%s, lnh=%s",
2443 __func__
, arg_vn
, arg_un
, arg_prefix
,
2444 (arg_cost
? arg_cost
: "NULL"),
2445 (arg_lifetime
? arg_lifetime
: "NULL"),
2446 (arg_lnh
? arg_lnh
: "NULL"));
2448 rfapiQprefix2Rprefix (&pfx
, &rpfx
);
2450 rpfx
.cost
= cost
& 255;
2452 /* look up rf descriptor, call open if it doesn't exist */
2454 rfapi_find_rfd (bgp
, &vn_address
, &un_address
,
2455 (struct rfapi_descriptor
**) &rfd
);
2460 struct rfapi_un_option uo
;
2463 * flag descriptor as provisionally opened for static route
2464 * registration so that we can fix up the other parameters
2465 * when the real open comes along
2467 memset (&uo
, 0, sizeof (uo
));
2468 uo
.type
= RFAPI_UN_OPTION_TYPE_PROVISIONAL
;
2470 rc
= rfapi_open (rfapi_get_rfp_start_val_by_bgp (bgp
), &vn_address
, &un_address
, &uo
, /* flags */
2471 NULL
, NULL
, /* no userdata */
2475 vty_outln (vty
, "Can't open session for this NVE: %s",
2476 rfapi_error_str(rc
));
2483 vty_outln (vty
, "Can't find session for this NVE: %s",
2484 rfapi_error_str(rc
));
2490 rfapi_register (rfd
, &rpfx
, lifetime
, NULL
, opt
, RFAPI_REGISTER_ADD
);
2493 struct rfapi_next_hop_entry
*head
= NULL
;
2494 struct rfapi_next_hop_entry
*tail
= NULL
;
2495 struct rfapi_vn_option
*vn_opt_new
;
2497 vnc_zlog_debug_verbose ("%s: rfapi_register succeeded, returning 0", __func__
);
2499 if (h
->rfp_methods
.local_cb
)
2501 struct rfapi_descriptor
*r
= (struct rfapi_descriptor
*) rfd
;
2502 vn_opt_new
= rfapi_vn_options_dup (opt
);
2504 rfapiAddDeleteLocalRfpPrefix (&r
->un_addr
, &r
->vn_addr
, &rpfx
,
2505 1, lifetime
, vn_opt_new
, &head
,
2509 h
->flags
|= RFAPI_INCALLBACK
;
2510 (*h
->rfp_methods
.local_cb
) (head
, r
->cookie
);
2511 h
->flags
&= ~RFAPI_INCALLBACK
;
2518 vnc_zlog_debug_verbose ("%s: rfapi_register failed", __func__
);
2519 vty_out (vty
, VTYNL
);
2520 vty_outln (vty
, "Registration failed.");
2522 "Confirm that either the VN or UN address matches a configured NVE group.");
2526 vnc_zlog_debug_verbose ("%s: fail, rc=%d", __func__
, rc
);
2530 /************************************************************************
2531 * Add prefix With LNH_OPTIONS...
2532 ************************************************************************/
2533 DEFUN (add_vnc_prefix_cost_life_lnh
,
2534 add_vnc_prefix_cost_life_lnh_cmd
,
2535 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) lifetime (1-4294967295) LNH_OPTIONS...",
2536 "Add registration\n"
2538 "Add/modify prefix related information\n"
2541 "VN address of NVE\n"
2542 "VN IPv4 interface address\n"
2543 "VN IPv6 interface address\n"
2544 "UN address of NVE\n"
2545 "UN IPv4 interface address\n"
2546 "UN IPv6 interface address\n"
2547 "Administrative cost [default: 255]\n"
2548 "Administrative cost\n"
2549 "Registration lifetime [default: infinite]\n"
2550 "Lifetime value in seconds\n"
2551 "[local-next-hop (A.B.C.D|X:X::X:X)] [local-cost <0-255>]\n")
2553 /* pfx vn un cost life */
2554 return register_add (vty
, argv
[3], argv
[5], argv
[7], argv
[9], argv
[11],
2556 NULL
, NULL
, argc
- 12, argv
+ 12);
2559 DEFUN (add_vnc_prefix_life_cost_lnh
,
2560 add_vnc_prefix_life_cost_lnh_cmd
,
2561 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295) cost (0-255) LNH_OPTIONS...",
2562 "Add registration\n"
2564 "Add/modify prefix related information\n"
2567 "VN address of NVE\n"
2568 "VN IPv4 interface address\n"
2569 "VN IPv6 interface address\n"
2570 "UN address of NVE\n"
2571 "UN IPv4 interface address\n"
2572 "UN IPv6 interface address\n"
2573 "Registration lifetime [default: infinite]\n"
2574 "Lifetime value in seconds\n"
2575 "Administrative cost [default: 255]\n"
2576 "Administrative cost\n"
2577 "[local-next-hop (A.B.C.D|X:X::X:X)] [local-cost <0-255>]\n")
2579 /* pfx vn un cost life */
2580 return register_add (vty
, argv
[3], argv
[5], argv
[7], argv
[11], argv
[9],
2582 NULL
, NULL
, argc
- 12, argv
+ 12);
2585 DEFUN (add_vnc_prefix_cost_lnh
,
2586 add_vnc_prefix_cost_lnh_cmd
,
2587 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) LNH_OPTIONS...",
2588 "Add registration\n"
2590 "Add/modify prefix related information\n"
2593 "VN address of NVE\n"
2594 "VN IPv4 interface address\n"
2595 "VN IPv6 interface address\n"
2596 "UN address of NVE\n"
2597 "UN IPv4 interface address\n"
2598 "UN IPv6 interface address\n"
2599 "Administrative cost [default: 255]\n"
2600 "Administrative cost\n"
2601 "[local-next-hop (A.B.C.D|X:X::X:X)] [local-cost <0-255>]\n")
2603 /* pfx vn un cost life */
2604 return register_add (vty
, argv
[3], argv
[5], argv
[7], argv
[9], NULL
,
2606 NULL
, NULL
, argc
- 10, argv
+ 10);
2609 DEFUN (add_vnc_prefix_life_lnh
,
2610 add_vnc_prefix_life_lnh_cmd
,
2611 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295) LNH_OPTIONS...",
2612 "Add registration\n"
2614 "Add/modify prefix related information\n"
2617 "VN address of NVE\n"
2618 "VN IPv4 interface address\n"
2619 "VN IPv6 interface address\n"
2620 "UN address of NVE\n"
2621 "UN IPv4 interface address\n"
2622 "UN IPv6 interface address\n"
2623 "Registration lifetime [default: infinite]\n"
2624 "Lifetime value in seconds\n"
2625 "[local-next-hop (A.B.C.D|X:X::X:X)] [local-cost <0-255>]\n")
2627 /* pfx vn un cost life */
2628 return register_add (vty
, argv
[3], argv
[5], argv
[7], NULL
, argv
[9],
2630 NULL
, NULL
, argc
- 10, argv
+ 10);
2633 DEFUN (add_vnc_prefix_lnh
,
2634 add_vnc_prefix_lnh_cmd
,
2635 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> LNH_OPTIONS...",
2636 "Add registration\n"
2638 "Add/modify prefix related information\n"
2641 "VN address of NVE\n"
2642 "VN IPv4 interface address\n"
2643 "VN IPv6 interface address\n"
2644 "UN address of NVE\n"
2645 "UN IPv4 interface address\n"
2646 "UN IPv6 interface address\n"
2647 "[local-next-hop (A.B.C.D|X:X::X:X)] [local-cost <0-255>]\n")
2649 /* pfx vn un cost life */
2650 return register_add (vty
, argv
[3], argv
[5], argv
[7], NULL
, NULL
,
2652 NULL
, NULL
, argc
- 8, argv
+ 8);
2655 /************************************************************************
2656 * Add prefix Without LNH_OPTIONS...
2657 ************************************************************************/
2658 DEFUN (add_vnc_prefix_cost_life
,
2659 add_vnc_prefix_cost_life_cmd
,
2660 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) lifetime (1-4294967295)",
2661 "Add registration\n"
2663 "Add/modify prefix related information\n"
2666 "VN address of NVE\n"
2667 "VN IPv4 interface address\n"
2668 "VN IPv6 interface address\n"
2669 "UN address of NVE\n"
2670 "UN IPv4 interface address\n"
2671 "UN IPv6 interface address\n"
2672 "Administrative cost [default: 255]\n"
2673 "Administrative cost\n"
2674 "Registration lifetime [default: infinite]\n"
2675 "Lifetime value in seconds\n")
2677 /* pfx vn un cost life */
2678 return register_add (vty
, argv
[3], argv
[5], argv
[7], argv
[9], argv
[11],
2680 NULL
, NULL
, 0, NULL
);
2683 DEFUN (add_vnc_prefix_life_cost
,
2684 add_vnc_prefix_life_cost_cmd
,
2685 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295) cost (0-255)",
2686 "Add registration\n"
2688 "Add/modify prefix related information\n"
2691 "VN address of NVE\n"
2692 "VN IPv4 interface address\n"
2693 "VN IPv6 interface address\n"
2694 "UN address of NVE\n"
2695 "UN IPv4 interface address\n"
2696 "UN IPv6 interface address\n"
2697 "Registration lifetime [default: infinite]\n"
2698 "Lifetime value in seconds\n"
2699 "Administrative cost [default: 255]\n"
2700 "Administrative cost\n")
2702 /* pfx vn un cost life */
2703 return register_add (vty
, argv
[3], argv
[5], argv
[7], argv
[11], argv
[9],
2705 NULL
, NULL
, 0, NULL
);
2708 DEFUN (add_vnc_prefix_cost
,
2709 add_vnc_prefix_cost_cmd
,
2710 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255)",
2711 "Add registration\n"
2713 "Add/modify prefix related information\n"
2716 "VN address of NVE\n"
2717 "VN IPv4 interface address\n"
2718 "VN IPv6 interface address\n"
2719 "UN address of NVE\n"
2720 "UN IPv4 interface address\n"
2721 "UN IPv6 interface address\n"
2722 "Administrative cost [default: 255]\n"
2723 "Administrative cost\n")
2725 /* pfx vn un cost life */
2726 return register_add (vty
, argv
[3], argv
[5], argv
[7], argv
[9], NULL
,
2728 NULL
, NULL
, 0, NULL
);
2731 DEFUN (add_vnc_prefix_life
,
2732 add_vnc_prefix_life_cmd
,
2733 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295)",
2734 "Add registration\n"
2736 "Add/modify prefix related information\n"
2739 "VN address of NVE\n"
2740 "VN IPv4 interface address\n"
2741 "VN IPv6 interface address\n"
2742 "UN address of NVE\n"
2743 "UN IPv4 interface address\n"
2744 "UN IPv6 interface address\n"
2745 "Registration lifetime [default: infinite]\n"
2746 "Lifetime value in seconds\n")
2748 /* pfx vn un cost life */
2749 return register_add (vty
, argv
[3], argv
[5], argv
[7], NULL
, argv
[9],
2751 NULL
, NULL
, 0, NULL
);
2754 DEFUN (add_vnc_prefix
,
2756 "add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X>",
2757 "Add registration\n"
2759 "Add/modify prefix related information\n"
2762 "VN address of NVE\n"
2763 "VN IPv4 interface address\n"
2764 "VN IPv6 interface address\n"
2765 "UN address of NVE\n"
2766 "UN IPv4 interface address\n"
2767 "UN IPv6 interface address\n")
2769 /* pfx vn un cost life */
2770 return register_add (vty
, argv
[3], argv
[5], argv
[7], NULL
, NULL
,
2772 NULL
, NULL
, 0, NULL
);
2775 /************************************************************************
2776 * Mac address registrations
2777 ************************************************************************/
2778 DEFUN (add_vnc_mac_vni_prefix_cost_life
,
2779 add_vnc_mac_vni_prefix_cost_life_cmd
,
2780 "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> cost (0-255) lifetime (1-4294967295)",
2781 "Add registration\n"
2783 "Add/modify mac address information\n"
2785 "Virtual Network Identifier follows\n"
2786 "Virtual Network Identifier\n"
2787 "VN address of NVE\n"
2788 "VN IPv4 interface address\n"
2789 "VN IPv6 interface address\n"
2790 "UN address of NVE\n"
2791 "UN IPv4 interface address\n"
2792 "UN IPv6 interface address\n"
2793 "Add/modify prefix related information\n"
2796 "Administrative cost [default: 255]\n"
2797 "Administrative cost\n"
2798 "Registration lifetime [default: infinite]\n"
2799 "Lifetime value in seconds\n")
2801 /* pfx vn un cost life */
2802 return register_add (vty
, argv
[11], argv
[7], argv
[9], argv
[13], argv
[15],
2804 argv
[3], argv
[5], 0, NULL
);
2808 DEFUN (add_vnc_mac_vni_prefix_life
,
2809 add_vnc_mac_vni_prefix_life_cmd
,
2810 "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> lifetime (1-4294967295)",
2811 "Add registration\n"
2813 "Add/modify mac address information\n"
2815 "Virtual Network Identifier follows\n"
2816 "Virtual Network Identifier\n"
2817 "VN address of NVE\n"
2818 "VN IPv4 interface address\n"
2819 "VN IPv6 interface address\n"
2820 "UN address of NVE\n"
2821 "UN IPv4 interface address\n"
2822 "UN IPv6 interface address\n"
2823 "Add/modify prefix related information\n"
2826 "Registration lifetime [default: infinite]\n"
2827 "Lifetime value in seconds\n")
2829 /* pfx vn un cost life */
2830 return register_add (vty
, argv
[11], argv
[7], argv
[9], NULL
, argv
[13],
2832 argv
[3], argv
[5], 0, NULL
);
2835 DEFUN (add_vnc_mac_vni_prefix_cost
,
2836 add_vnc_mac_vni_prefix_cost_cmd
,
2837 "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> cost (0-255)",
2838 "Add registration\n"
2840 "Add/modify mac address information\n"
2842 "Virtual Network Identifier follows\n"
2843 "Virtual Network Identifier\n"
2844 "VN address of NVE\n"
2845 "VN IPv4 interface address\n"
2846 "VN IPv6 interface address\n"
2847 "UN address of NVE\n"
2848 "UN IPv4 interface address\n"
2849 "UN IPv6 interface address\n"
2850 "Add/modify prefix related information\n"
2853 "Administrative cost [default: 255]\n" "Administrative cost\n")
2855 /* pfx vn un cost life */
2856 return register_add (vty
, argv
[11], argv
[7], argv
[9], argv
[13], NULL
,
2858 argv
[3], argv
[5], 0, NULL
);
2861 DEFUN (add_vnc_mac_vni_prefix
,
2862 add_vnc_mac_vni_prefix_cmd
,
2863 "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M>",
2864 "Add registration\n"
2866 "Add/modify mac address information\n"
2868 "Virtual Network Identifier follows\n"
2869 "Virtual Network Identifier\n"
2870 "VN address of NVE\n"
2871 "VN IPv4 interface address\n"
2872 "VN IPv6 interface address\n"
2873 "UN address of NVE\n"
2874 "UN IPv4 interface address\n"
2875 "UN IPv6 interface address\n"
2876 "Add/modify prefix related information\n"
2877 "IPv4 prefix\n" "IPv6 prefix\n")
2879 /* pfx vn un cost life */
2880 return register_add (vty
, argv
[11], argv
[7], argv
[9], NULL
, NULL
,
2882 argv
[3], argv
[5], 0, NULL
);
2885 DEFUN (add_vnc_mac_vni_cost_life
,
2886 add_vnc_mac_vni_cost_life_cmd
,
2887 "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) lifetime (1-4294967295)",
2888 "Add registration\n"
2890 "Add/modify mac address information\n"
2892 "Virtual Network Identifier follows\n"
2893 "Virtual Network Identifier\n"
2894 "VN address of NVE\n"
2895 "VN IPv4 interface address\n"
2896 "VN IPv6 interface address\n"
2897 "UN address of NVE\n"
2898 "UN IPv4 interface address\n"
2899 "UN IPv6 interface address\n"
2900 "Administrative cost [default: 255]\n"
2901 "Administrative cost\n"
2902 "Registration lifetime [default: infinite]\n"
2903 "Lifetime value in seconds\n")
2905 /* pfx vn un cost life */
2906 return register_add (vty
, NULL
, argv
[7], argv
[9], argv
[11], argv
[13],
2908 argv
[3], argv
[5], 0, NULL
);
2912 DEFUN (add_vnc_mac_vni_cost
,
2913 add_vnc_mac_vni_cost_cmd
,
2914 "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255)",
2915 "Add registration\n"
2917 "Add/modify mac address information\n"
2919 "Virtual Network Identifier follows\n"
2920 "Virtual Network Identifier\n"
2921 "VN address of NVE\n"
2922 "VN IPv4 interface address\n"
2923 "VN IPv6 interface address\n"
2924 "UN address of NVE\n"
2925 "UN IPv4 interface address\n"
2926 "UN IPv6 interface address\n"
2927 "Administrative cost [default: 255]\n" "Administrative cost\n")
2929 /* pfx vn un cost life */
2930 return register_add (vty
, NULL
, argv
[7], argv
[9], argv
[11], NULL
,
2932 argv
[3], argv
[5], 0, NULL
);
2936 DEFUN (add_vnc_mac_vni_life
,
2937 add_vnc_mac_vni_life_cmd
,
2938 "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295)",
2939 "Add registration\n"
2941 "Add/modify mac address information\n"
2943 "Virtual Network Identifier follows\n"
2944 "Virtual Network Identifier\n"
2945 "VN address of NVE\n"
2946 "VN IPv4 interface address\n"
2947 "VN IPv6 interface address\n"
2948 "UN address of NVE\n"
2949 "UN IPv4 interface address\n"
2950 "UN IPv6 interface address\n"
2951 "Registration lifetime [default: infinite]\n"
2952 "Lifetime value in seconds\n")
2954 /* pfx vn un cost life */
2955 return register_add (vty
, NULL
, argv
[7], argv
[9], NULL
, argv
[11],
2957 argv
[3], argv
[5], 0, NULL
);
2961 DEFUN (add_vnc_mac_vni
,
2962 add_vnc_mac_vni_cmd
,
2963 "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X>",
2964 "Add registration\n"
2966 "Add/modify mac address information\n"
2968 "Virtual Network Identifier follows\n"
2969 "Virtual Network Identifier\n"
2970 "VN address of NVE\n"
2971 "VN IPv4 interface address\n"
2972 "VN IPv6 interface address\n"
2973 "UN address of NVE\n"
2974 "UN IPv4 interface address\n" "UN IPv6 interface address\n")
2976 /* pfx vn un cost life */
2977 return register_add (vty
, NULL
, argv
[7], argv
[9], NULL
, NULL
,
2979 argv
[3], argv
[5], 0, NULL
);
2982 /************************************************************************
2984 ************************************************************************/
2986 struct rfapi_local_reg_delete_arg
2992 struct rfapi_ip_addr un_address
; /* AF==0: wildcard */
2993 struct rfapi_ip_addr vn_address
; /* AF==0: wildcard */
2994 struct prefix prefix
; /* AF==0: wildcard */
2995 struct prefix_rd rd
; /* plen!=64: wildcard */
2996 struct rfapi_nve_group_cfg
*rfg
; /* NULL: wildcard */
2998 struct rfapi_l2address_option_match l2o
;
3006 uint32_t query_count
;
3008 uint32_t failed_pfx_count
;
3011 struct skiplist
*nves
;
3013 uint32_t remote_active_nve_count
;
3014 uint32_t remote_active_pfx_count
;
3015 uint32_t remote_holddown_nve_count
;
3016 uint32_t remote_holddown_pfx_count
;
3021 struct rfapi_ip_addr vn
;
3022 struct rfapi_ip_addr un
;
3023 struct rfapi_descriptor
*rfd
;
3024 struct rfapi_local_reg_delete_arg
*cda
;
3028 nve_addr_free (void *hap
)
3030 ((struct nve_addr
*) hap
)->cda
->nve_count
+= 1;
3031 XFREE (MTYPE_RFAPI_NVE_ADDR
, hap
);
3035 nve_addr_cmp (void *k1
, void *k2
)
3037 struct nve_addr
*a
= (struct nve_addr
*) k1
;
3038 struct nve_addr
*b
= (struct nve_addr
*) k2
;
3045 if (a
->un
.addr_family
!= b
->un
.addr_family
)
3047 return (a
->un
.addr_family
- b
->un
.addr_family
);
3049 if (a
->vn
.addr_family
!= b
->vn
.addr_family
)
3051 return (a
->vn
.addr_family
- b
->vn
.addr_family
);
3053 if (a
->un
.addr_family
== AF_INET
)
3055 ret
= IPV4_ADDR_CMP (&a
->un
.addr
.v4
, &b
->un
.addr
.v4
);
3061 else if (a
->un
.addr_family
== AF_INET6
)
3063 ret
= IPV6_ADDR_CMP (&a
->un
.addr
.v6
, &b
->un
.addr
.v6
);
3073 if (a
->vn
.addr_family
== AF_INET
)
3075 ret
= IPV4_ADDR_CMP (&a
->vn
.addr
.v4
, &b
->vn
.addr
.v4
);
3079 else if (a
->vn
.addr_family
== AF_INET6
)
3081 ret
= IPV6_ADDR_CMP (&a
->vn
.addr
.v6
, &b
->vn
.addr
.v6
);
3095 parse_deleter_args (
3098 const char *arg_prefix
,
3101 const char *arg_l2addr
,
3102 const char *arg_vni
,
3104 struct rfapi_nve_group_cfg
*arg_rfg
,
3105 struct rfapi_local_reg_delete_arg
*rcdarg
)
3107 int rc
= CMD_WARNING
;
3109 memset (rcdarg
, 0, sizeof (struct rfapi_local_reg_delete_arg
));
3113 bgp
= bgp_get_default();
3115 rcdarg
->rfg
= arg_rfg
; /* may be NULL */
3117 if (arg_vn
&& strcmp (arg_vn
, "*"))
3119 if ((rc
= rfapiCliGetRfapiIpAddr (vty
, arg_vn
, &rcdarg
->vn_address
)))
3122 if (arg_un
&& strcmp (arg_un
, "*"))
3124 if ((rc
= rfapiCliGetRfapiIpAddr (vty
, arg_un
, &rcdarg
->un_address
)))
3127 if (arg_prefix
&& strcmp (arg_prefix
, "*"))
3130 if (!str2prefix (arg_prefix
, &rcdarg
->prefix
))
3132 vty_outln (vty
, "Malformed prefix \"%s\"", arg_prefix
);
3141 vty_outln (vty
, "Missing VNI");
3144 if (strcmp (arg_l2addr
, "*"))
3146 if ((rc
= rfapiStr2EthAddr (arg_l2addr
, &rcdarg
->l2o
.o
.macaddr
)))
3148 vty_outln (vty
, "Malformed L2 Address \"%s\"",
3152 rcdarg
->l2o
.flags
|= RFAPI_L2O_MACADDR
;
3154 if (strcmp (arg_vni
, "*"))
3156 rcdarg
->l2o
.o
.logical_net_id
= strtoul(arg_vni
, NULL
, 10);
3157 rcdarg
->l2o
.flags
|= RFAPI_L2O_LNI
;
3162 if (!str2prefix_rd (arg_rd
, &rcdarg
->rd
))
3164 vty_outln (vty
, "Malformed RD \"%s\"",
3174 parse_deleter_tokens (
3177 struct cmd_token
*carg_prefix
,
3178 struct cmd_token
*carg_vn
,
3179 struct cmd_token
*carg_un
,
3180 struct cmd_token
*carg_l2addr
,
3181 struct cmd_token
*carg_vni
,
3182 struct cmd_token
*carg_rd
,
3183 struct rfapi_nve_group_cfg
*arg_rfg
,
3184 struct rfapi_local_reg_delete_arg
*rcdarg
)
3186 const char *arg_prefix
= carg_prefix
? carg_prefix
->arg
: NULL
;
3187 const char *arg_vn
= carg_vn
? carg_vn
->arg
: NULL
;
3188 const char *arg_un
= carg_un
? carg_un
->arg
: NULL
;
3189 const char *arg_l2addr
= carg_l2addr
? carg_l2addr
->arg
: NULL
;
3190 const char *arg_vni
= carg_vni
? carg_vni
->arg
: NULL
;
3191 const char *arg_rd
= carg_rd
? carg_rd
->arg
: NULL
;
3192 return parse_deleter_args (vty
, bgp
,arg_prefix
, arg_vn
, arg_un
,
3193 arg_l2addr
, arg_vni
, arg_rd
,
3198 record_nve_in_cda_list (
3199 struct rfapi_local_reg_delete_arg
*cda
,
3200 struct rfapi_ip_addr
*un_address
,
3201 struct rfapi_ip_addr
*vn_address
,
3202 struct rfapi_descriptor
*rfd
)
3205 struct nve_addr
*hap
;
3207 memset (&ha
, 0, sizeof (ha
));
3208 ha
.un
= *un_address
;
3209 ha
.vn
= *vn_address
;
3213 cda
->nves
= skiplist_new (0, nve_addr_cmp
, nve_addr_free
);
3215 if (skiplist_search (cda
->nves
, &ha
, (void *) &hap
))
3217 hap
= XCALLOC (MTYPE_RFAPI_NVE_ADDR
, sizeof (struct nve_addr
));
3221 skiplist_insert (cda
->nves
, hap
, hap
);
3226 clear_vnc_responses (struct rfapi_local_reg_delete_arg
*cda
)
3229 struct rfapi_descriptor
*rfd
;
3230 int query_count
= 0;
3231 struct listnode
*node
;
3232 struct bgp
*bgp_default
= bgp_get_default ();
3234 if (cda
->vn_address
.addr_family
&& cda
->un_address
.addr_family
)
3240 (bgp_default
, &cda
->vn_address
, &cda
->un_address
, &rfd
))
3243 rfapiRibClear (rfd
);
3244 rfapi_query_done_all (rfd
, &query_count
);
3245 cda
->query_count
+= query_count
;
3248 * Track unique nves seen
3250 record_nve_in_cda_list (cda
, &rfd
->un_addr
, &rfd
->vn_addr
, rfd
);
3261 h
= bgp_default
->rfapi
;
3266 for (ALL_LIST_ELEMENTS_RO (&h
->descriptors
, node
, rfd
))
3269 * match un, vn addresses of NVEs
3271 if (cda
->un_address
.addr_family
&&
3272 rfapi_ip_addr_cmp (&cda
->un_address
, &rfd
->un_addr
))
3276 if (cda
->vn_address
.addr_family
&&
3277 rfapi_ip_addr_cmp (&cda
->vn_address
, &rfd
->vn_addr
))
3282 rfapiRibClear (rfd
);
3284 rfapi_query_done_all (rfd
, &query_count
);
3285 cda
->query_count
+= query_count
;
3288 * Track unique nves seen
3290 record_nve_in_cda_list (cda
, &rfd
->un_addr
, &rfd
->vn_addr
, rfd
);
3295 * TBD need to count deleted prefixes and nves?
3297 * ENXIO BGP or VNC not configured
3300 rfapiDeleteLocalPrefixesByRFD (struct rfapi_local_reg_delete_arg
*cda
,
3301 struct rfapi_descriptor
*rfd
)
3303 struct rfapi_ip_addr
*pUn
; /* NULL = wildcard */
3304 struct rfapi_ip_addr
*pVn
; /* NULL = wildcard */
3305 struct prefix
*pPrefix
; /* NULL = wildcard */
3306 struct prefix_rd
*pPrd
; /* NULL = wildcard */
3308 struct rfapi_ip_prefix rprefix
;
3309 struct rfapi_next_hop_entry
*head
= NULL
;
3310 struct rfapi_next_hop_entry
*tail
= NULL
;
3313 vnc_zlog_debug_verbose ("%s: entry", __func__
);
3316 pUn
= (cda
->un_address
.addr_family
? &cda
->un_address
: NULL
);
3317 pVn
= (cda
->vn_address
.addr_family
? &cda
->vn_address
: NULL
);
3318 pPrefix
= (cda
->prefix
.family
? &cda
->prefix
: NULL
);
3319 pPrd
= (cda
->rd
.prefixlen
== 64 ? &cda
->rd
: NULL
);
3323 rfapiQprefix2Rprefix (pPrefix
, &rprefix
);
3326 do /* to preserve old code structure */
3328 struct rfapi
*h
=cda
->bgp
->rfapi
;;
3329 struct rfapi_adb
*adb
;
3331 int deleted_from_this_nve
;
3333 struct nve_addr
*hap
;
3336 vnc_zlog_debug_verbose ("%s: rfd=%p", __func__
, rfd
);
3340 * match un, vn addresses of NVEs
3342 if (pUn
&& (rfapi_ip_addr_cmp (pUn
, &rfd
->un_addr
)))
3344 if (pVn
&& (rfapi_ip_addr_cmp (pVn
, &rfd
->vn_addr
)))
3348 vnc_zlog_debug_verbose ("%s: un, vn match", __func__
);
3355 deleted_from_this_nve
= 0;
3358 struct skiplist
*sl
;
3359 struct rfapi_ip_prefix rp
;
3361 struct list
*adb_delete_list
;
3364 * The advertisements are stored in a skiplist. Withdrawing
3365 * the registration deletes the advertisement from the
3366 * skiplist, which we can't do while iterating over that
3367 * same skiplist using the current skiplist API.
3369 * Strategy: iterate over the skiplist and build another
3370 * list containing only the matching ADBs. Then delete
3371 * _everything_ in that second list (which can be done
3372 * using either skiplists or quagga linklists).
3374 adb_delete_list
= list_new ();
3377 * Advertised IP prefixes (not 0/32 or 0/128)
3379 sl
= rfd
->advertised
.ipN_by_prefix
;
3382 rc
= skiplist_next (sl
, NULL
, (void **) &adb
, &cursor
);
3383 !rc
; rc
= skiplist_next (sl
, NULL
, (void **) &adb
, &cursor
))
3388 if (!prefix_same (pPrefix
, &adb
->u
.s
.prefix_ip
))
3391 vnc_zlog_debug_verbose ("%s: adb=%p, prefix doesn't match, skipping",
3399 if (memcmp(pPrd
->val
, adb
->u
.s
.prd
.val
, 8) != 0)
3402 vnc_zlog_debug_verbose ("%s: adb=%p, RD doesn't match, skipping",
3408 if (CHECK_FLAG (cda
->l2o
.flags
, RFAPI_L2O_MACADDR
))
3411 (cda
->l2o
.o
.macaddr
.octet
,
3412 adb
->u
.s
.prefix_eth
.u
.prefix_eth
.octet
, ETHER_ADDR_LEN
))
3415 vnc_zlog_debug_verbose ("%s: adb=%p, macaddr doesn't match, skipping",
3422 if (CHECK_FLAG (cda
->l2o
.flags
, RFAPI_L2O_LNI
))
3424 if (cda
->l2o
.o
.logical_net_id
!= adb
->l2o
.logical_net_id
)
3427 vnc_zlog_debug_verbose ("%s: adb=%p, LNI doesn't match, skipping",
3435 vnc_zlog_debug_verbose ("%s: ipN adding adb %p to delete list", __func__
,
3439 listnode_add (adb_delete_list
, adb
);
3442 struct listnode
*node
;
3444 for (ALL_LIST_ELEMENTS_RO (adb_delete_list
, node
, adb
))
3446 int this_advertisement_prefix_count
;
3447 struct rfapi_vn_option optary
[3];
3448 struct rfapi_vn_option
*opt
= NULL
;
3451 this_advertisement_prefix_count
= 1;
3453 rfapiQprefix2Rprefix (&adb
->u
.s
.prefix_ip
, &rp
);
3455 memset (optary
, 0, sizeof (optary
));
3457 /* if mac addr present in advert, make l2o vn option */
3458 if (adb
->u
.s
.prefix_eth
.family
== AF_ETHERNET
)
3461 opt
->next
= &optary
[cur_opt
];
3462 opt
= &optary
[cur_opt
++];
3463 opt
->type
= RFAPI_VN_OPTION_TYPE_L2ADDR
;
3464 opt
->v
.l2addr
.macaddr
= adb
->u
.s
.prefix_eth
.u
.prefix_eth
;
3465 ++this_advertisement_prefix_count
;
3468 * use saved RD value instead of trying to invert
3469 * complex RD computation in rfapi_register()
3472 opt
->next
= &optary
[cur_opt
];
3473 opt
= &optary
[cur_opt
++];
3474 opt
->type
= RFAPI_VN_OPTION_TYPE_INTERNAL_RD
;
3475 opt
->v
.internal_rd
= adb
->u
.s
.prd
;
3478 vnc_zlog_debug_verbose ("%s: ipN killing reg from adb %p ", __func__
, adb
);
3481 rc
= rfapi_register (rfd
, &rp
, 0, NULL
,
3482 (cur_opt
? optary
: NULL
), RFAPI_REGISTER_KILL
);
3485 cda
->pfx_count
+= this_advertisement_prefix_count
;
3486 cda
->reg_count
+= 1;
3487 deleted_from_this_nve
= 1;
3489 if (h
->rfp_methods
.local_cb
)
3491 rfapiAddDeleteLocalRfpPrefix (&rfd
->un_addr
, &rfd
->vn_addr
,
3492 &rp
, 0, 0, NULL
, &head
, &tail
);
3495 list_delete_all_node (adb_delete_list
);
3497 if (!(pPrefix
&& !RFAPI_0_PREFIX (pPrefix
)))
3502 * Caller didn't specify a prefix, or specified (0/32 or 0/128)
3506 * Advertised 0/32 and 0/128 (indexed by ethernet address)
3508 sl
= rfd
->advertised
.ip0_by_ether
;
3511 rc
= skiplist_next (sl
, NULL
, (void **) &adb
, &cursor
);
3512 !rc
; rc
= skiplist_next (sl
, NULL
, (void **) &adb
, &cursor
))
3515 if (CHECK_FLAG (cda
->l2o
.flags
, RFAPI_L2O_MACADDR
))
3517 if (memcmp (cda
->l2o
.o
.macaddr
.octet
,
3518 adb
->u
.s
.prefix_eth
.u
.prefix_eth
.octet
,
3525 if (CHECK_FLAG (cda
->l2o
.flags
, RFAPI_L2O_LNI
))
3527 if (cda
->l2o
.o
.logical_net_id
!= adb
->l2o
.logical_net_id
)
3533 vnc_zlog_debug_verbose ("%s: ip0 adding adb %p to delete list",
3536 listnode_add (adb_delete_list
, adb
);
3540 for (ALL_LIST_ELEMENTS_RO (adb_delete_list
, node
, adb
))
3543 struct rfapi_vn_option vn
;
3545 rfapiQprefix2Rprefix (&adb
->u
.s
.prefix_ip
, &rp
);
3547 memset (&vn
, 0, sizeof (vn
));
3548 vn
.type
= RFAPI_VN_OPTION_TYPE_L2ADDR
;
3549 vn
.v
.l2addr
= adb
->l2o
;
3552 vnc_zlog_debug_verbose ("%s: ip0 killing reg from adb %p ",
3556 rc
= rfapi_register (rfd
, &rp
, 0, NULL
, &vn
,
3557 RFAPI_REGISTER_KILL
);
3560 cda
->pfx_count
+= 1;
3561 cda
->reg_count
+= 1;
3562 deleted_from_this_nve
= 1;
3564 if (h
->rfp_methods
.local_cb
)
3566 struct rfapi_vn_option
*vn_opt_new
;
3568 vn_opt_new
= rfapi_vn_options_dup (&vn
);
3569 rfapiAddDeleteLocalRfpPrefix (&rfd
->un_addr
,
3570 &rfd
->vn_addr
, &rp
, 0, 0,
3571 vn_opt_new
, &head
, &tail
);
3574 list_delete_all_node (adb_delete_list
);
3576 list_delete (adb_delete_list
);
3581 { /* should not be set if (NULL == rfapi_cfg->local_cb) */
3582 h
->flags
|= RFAPI_INCALLBACK
;
3583 (*h
->rfp_methods
.local_cb
) (head
, rfd
->cookie
);
3584 h
->flags
&= ~RFAPI_INCALLBACK
;
3588 if (deleted_from_this_nve
)
3591 * track unique NVEs seen
3593 memset (&ha
, 0, sizeof (ha
));
3594 ha
.un
= rfd
->un_addr
;
3595 ha
.vn
= rfd
->vn_addr
;
3598 cda
->nves
= skiplist_new (0, nve_addr_cmp
, nve_addr_free
);
3599 if (skiplist_search (cda
->nves
, &ha
, (void **) &hap
))
3601 hap
= XCALLOC (MTYPE_RFAPI_NVE_ADDR
, sizeof (struct nve_addr
));
3605 skiplist_insert (cda
->nves
, hap
, hap
);
3608 } while (0); /* to preserve old code structure */
3614 rfapiDeleteLocalPrefixes (struct rfapi_local_reg_delete_arg
*cda
)
3620 if (cda
->rfg
->rfd
) /* if not open, nothing to delete */
3621 rc
= rfapiDeleteLocalPrefixesByRFD (cda
, cda
->rfg
->rfd
);
3625 struct bgp
*bgp
= cda
->bgp
;
3627 struct rfapi_cfg
*rfapi_cfg
;
3629 struct listnode
*node
;
3630 struct rfapi_descriptor
*rfd
;
3634 rfapi_cfg
= bgp
->rfapi_cfg
;
3635 if (!h
|| !rfapi_cfg
)
3637 vnc_zlog_debug_verbose ("%s: starting descriptor loop", __func__
);
3638 for (ALL_LIST_ELEMENTS_RO (&h
->descriptors
, node
, rfd
))
3640 rc
= rfapiDeleteLocalPrefixesByRFD (cda
, rfd
);
3649 * Deletes local and remote prefixes that match
3652 clear_vnc_prefix (struct rfapi_local_reg_delete_arg
*cda
)
3654 struct prefix pfx_un
;
3655 struct prefix pfx_vn
;
3657 struct prefix
*pUN
= NULL
;
3658 struct prefix
*pVN
= NULL
;
3659 struct prefix
*pPrefix
= NULL
;
3661 struct rfapi_import_table
*it
= NULL
;
3664 * Delete matching remote prefixes in holddown
3666 if (cda
->vn_address
.addr_family
)
3668 if (!rfapiRaddr2Qprefix (&cda
->vn_address
, &pfx_vn
))
3671 if (cda
->un_address
.addr_family
)
3673 if (!rfapiRaddr2Qprefix (&cda
->un_address
, &pfx_un
))
3676 if (cda
->prefix
.family
)
3678 pPrefix
= &cda
->prefix
;
3682 it
= cda
->rfg
->rfapi_import_table
;
3684 rfapiDeleteRemotePrefixes (pUN
, pVN
, pPrefix
, it
,
3685 0, 1, &cda
->remote_active_pfx_count
,
3686 &cda
->remote_active_nve_count
,
3687 &cda
->remote_holddown_pfx_count
,
3688 &cda
->remote_holddown_nve_count
);
3691 * Now do local prefixes
3693 rfapiDeleteLocalPrefixes (cda
);
3697 print_cleared_stats (struct rfapi_local_reg_delete_arg
*cda
)
3699 struct vty
*vty
= cda
->vty
; /* for benefit of VTYNL */
3701 /* Our special element-deleting function counts nves */
3704 skiplist_free (cda
->nves
);
3707 if (cda
->failed_pfx_count
)
3708 vty_outln (vty
, "Failed to delete %d prefixes",
3709 cda
->failed_pfx_count
);
3711 /* left as "prefixes" even in single case for ease of machine parsing */
3713 "[Local] Cleared %u registrations, %u prefixes, %u responses from %d NVEs",
3714 cda
->reg_count
, cda
->pfx_count
, cda
->query_count
,cda
->nve_count
);
3717 * We don't currently allow deletion of active remote prefixes from
3721 vty_outln (vty
, "[Holddown] Cleared %u prefixes from %u NVEs",
3722 cda
->remote_holddown_pfx_count
,cda
->remote_holddown_nve_count
);
3726 * Caller has already deleted registrations and queries for this/these
3727 * NVEs. Now we just have to close their descriptors.
3730 clear_vnc_nve_closer (struct rfapi_local_reg_delete_arg
*cda
)
3732 struct skiplist
*sl
= cda
->nves
; /* contains affected NVEs */
3733 struct nve_addr
*pKey
;
3734 struct nve_addr
*pValue
;
3735 void *cursor
= NULL
;
3741 for (rc
= skiplist_next (sl
, (void **) &pKey
, (void **) &pValue
, &cursor
);
3743 rc
= skiplist_next (sl
, (void **) &pKey
, (void **) &pValue
, &cursor
))
3748 ((struct rfapi_descriptor
*) pValue
->rfd
)->flags
|=
3749 RFAPI_HD_FLAG_CLOSING_ADMINISTRATIVELY
;
3750 rfapi_close (pValue
->rfd
);
3755 DEFUN (clear_vnc_nve_all
,
3756 clear_vnc_nve_all_cmd
,
3760 "Clear per NVE information\n"
3764 struct rfapi_local_reg_delete_arg cda
;
3767 if ((rc
= parse_deleter_args (vty
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &cda
)))
3772 clear_vnc_responses (&cda
);
3773 clear_vnc_prefix (&cda
);
3774 clear_vnc_nve_closer (&cda
);
3776 print_cleared_stats (&cda
);
3781 DEFUN (clear_vnc_nve_vn_un
,
3782 clear_vnc_nve_vn_un_cmd
,
3783 "clear vnc nve vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X>",
3786 "Clear prefix registration information\n"
3787 "VN address of NVE\n"
3789 "VN IPv4 interface address\n"
3790 "VN IPv6 interface address\n"
3791 "UN address of NVE\n"
3792 "For all UN addresses\n"
3793 "UN IPv4 interface address\n"
3794 "UN IPv6 interface address\n")
3796 struct rfapi_local_reg_delete_arg cda
;
3800 parse_deleter_tokens (vty
, NULL
, NULL
, argv
[4], argv
[6], NULL
, NULL
, NULL
, NULL
, &cda
)))
3805 clear_vnc_responses (&cda
);
3806 clear_vnc_prefix (&cda
);
3807 clear_vnc_nve_closer (&cda
);
3809 print_cleared_stats (&cda
);
3814 DEFUN (clear_vnc_nve_un_vn
,
3815 clear_vnc_nve_un_vn_cmd
,
3816 "clear vnc nve un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X>",
3819 "Clear prefix registration information\n"
3820 "UN address of NVE\n"
3822 "UN IPv4 interface address\n"
3823 "UN IPv6 interface address\n"
3824 "VN address of NVE\n"
3826 "VN IPv4 interface address\n"
3827 "VN IPv6 interface address\n")
3829 struct rfapi_local_reg_delete_arg cda
;
3833 parse_deleter_tokens (vty
, NULL
, NULL
, argv
[6], argv
[4], NULL
, NULL
, NULL
, NULL
, &cda
)))
3838 clear_vnc_responses (&cda
);
3839 clear_vnc_prefix (&cda
);
3840 clear_vnc_nve_closer (&cda
);
3842 print_cleared_stats (&cda
);
3847 DEFUN (clear_vnc_nve_vn
,
3848 clear_vnc_nve_vn_cmd
,
3849 "clear vnc nve vn <*|A.B.C.D|X:X::X:X>",
3852 "Clear prefix registration information\n"
3853 "VN address of NVE\n"
3855 "VN IPv4 interface address\n"
3856 "VN IPv6 interface address\n")
3858 struct rfapi_local_reg_delete_arg cda
;
3861 if ((rc
= parse_deleter_tokens (vty
, NULL
, NULL
, argv
[4], NULL
, NULL
, NULL
, NULL
, NULL
, &cda
)))
3866 clear_vnc_responses (&cda
);
3867 clear_vnc_prefix (&cda
);
3868 clear_vnc_nve_closer (&cda
);
3870 print_cleared_stats (&cda
);
3874 DEFUN (clear_vnc_nve_un
,
3875 clear_vnc_nve_un_cmd
,
3876 "clear vnc nve un <*|A.B.C.D|X:X::X:X>",
3879 "Clear prefix registration information\n"
3880 "UN address of NVE\n"
3882 "UN IPv4 interface address\n"
3883 "UN IPv6 interface address\n")
3885 struct rfapi_local_reg_delete_arg cda
;
3888 if ((rc
= parse_deleter_tokens (vty
, NULL
, NULL
, NULL
, argv
[4], NULL
, NULL
, NULL
, NULL
, &cda
)))
3893 clear_vnc_responses (&cda
);
3894 clear_vnc_prefix (&cda
);
3895 clear_vnc_nve_closer (&cda
);
3897 print_cleared_stats (&cda
);
3901 /*-------------------------------------------------
3903 *-------------------------------------------------*/
3906 * This function is defined in this file (rather than in rfp_registration.c)
3907 * because here we have access to all the task handles.
3909 DEFUN (clear_vnc_prefix_vn_un
,
3910 clear_vnc_prefix_vn_un_cmd
,
3911 "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X>",
3914 "Clear prefix registration information\n"
3918 "VN address of NVE\n"
3919 "All VN addresses\n"
3920 "VN IPv4 interface address\n"
3921 "VN IPv6 interface address\n"
3922 "UN address of NVE\n"
3923 "All UN addresses\n"
3924 "UN IPv4 interface address\n"
3925 "UN IPv6 interface address\n")
3927 struct rfapi_local_reg_delete_arg cda
;
3931 parse_deleter_tokens (vty
, NULL
, argv
[3], argv
[5], argv
[7], NULL
, NULL
, NULL
, NULL
, &cda
)))
3934 clear_vnc_prefix (&cda
);
3935 print_cleared_stats (&cda
);
3939 DEFUN (clear_vnc_prefix_un_vn
,
3940 clear_vnc_prefix_un_vn_cmd
,
3941 "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X>",
3944 "Clear prefix registration information\n"
3948 "UN address of NVE\n"
3949 "All UN addresses\n"
3950 "UN IPv4 interface address\n"
3951 "UN IPv6 interface address\n"
3952 "VN address of NVE\n"
3953 "All VN addresses\n"
3954 "VN IPv4 interface address\n"
3955 "VN IPv6 interface address\n")
3957 struct rfapi_local_reg_delete_arg cda
;
3961 parse_deleter_tokens (vty
, NULL
, argv
[3], argv
[7], argv
[5], NULL
, NULL
, NULL
, NULL
, &cda
)))
3964 clear_vnc_prefix (&cda
);
3965 print_cleared_stats (&cda
);
3969 DEFUN (clear_vnc_prefix_un
,
3970 clear_vnc_prefix_un_cmd
,
3971 "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> un <*|A.B.C.D|X:X::X:X>",
3974 "Clear prefix registration information\n"
3978 "UN address of NVE\n"
3979 "All UN addresses\n"
3980 "UN IPv4 interface address\n"
3981 "UN IPv6 interface address\n")
3983 struct rfapi_local_reg_delete_arg cda
;
3987 parse_deleter_tokens (vty
, NULL
, argv
[3], NULL
, argv
[5], NULL
, NULL
, NULL
, NULL
, &cda
)))
3990 clear_vnc_prefix (&cda
);
3991 print_cleared_stats (&cda
);
3995 DEFUN (clear_vnc_prefix_vn
,
3996 clear_vnc_prefix_vn_cmd
,
3997 "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> vn <*|A.B.C.D|X:X::X:X>",
4000 "Clear prefix registration information\n"
4004 "UN address of NVE\n"
4005 "All VN addresses\n"
4006 "VN IPv4 interface address\n"
4007 "VN IPv6 interface address\n")
4009 struct rfapi_local_reg_delete_arg cda
;
4013 parse_deleter_tokens (vty
, NULL
, argv
[3], argv
[5], NULL
, NULL
, NULL
, NULL
, NULL
, &cda
)))
4016 clear_vnc_prefix (&cda
);
4017 print_cleared_stats (&cda
);
4021 DEFUN (clear_vnc_prefix_all
,
4022 clear_vnc_prefix_all_cmd
,
4023 "clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> *",
4026 "Clear prefix registration information\n"
4032 struct rfapi_local_reg_delete_arg cda
;
4035 if ((rc
= parse_deleter_tokens (vty
, NULL
, argv
[3], NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &cda
)))
4038 clear_vnc_prefix (&cda
);
4039 print_cleared_stats (&cda
);
4043 /*-------------------------------------------------
4045 *-------------------------------------------------*/
4048 * This function is defined in this file (rather than in rfp_registration.c)
4049 * because here we have access to all the task handles.
4051 DEFUN (clear_vnc_mac_vn_un
,
4052 clear_vnc_mac_vn_un_cmd
,
4053 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X>",
4056 "Clear mac registration information\n"
4060 "Any virtual network identifier\n"
4061 "Virtual network identifier\n"
4062 "VN address of NVE\n"
4063 "All VN addresses\n"
4064 "VN IPv4 interface address\n"
4065 "VN IPv6 interface address\n"
4066 "UN address of NVE\n"
4067 "All UN addresses\n"
4068 "UN IPv4 interface address\n"
4069 "UN IPv6 interface address\n")
4071 struct rfapi_local_reg_delete_arg cda
;
4074 /* pfx vn un L2 VNI */
4076 parse_deleter_tokens (vty
, NULL
, NULL
, argv
[7], argv
[9], argv
[3], argv
[5],
4080 clear_vnc_prefix (&cda
);
4081 print_cleared_stats (&cda
);
4085 DEFUN (clear_vnc_mac_un_vn
,
4086 clear_vnc_mac_un_vn_cmd
,
4087 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X>",
4090 "Clear mac registration information\n"
4094 "Any virtual network identifier\n"
4095 "Virtual network identifier\n"
4096 "UN address of NVE\n"
4097 "All UN addresses\n"
4098 "UN IPv4 interface address\n"
4099 "UN IPv6 interface address\n"
4100 "VN address of NVE\n"
4101 "All VN addresses\n"
4102 "VN IPv4 interface address\n"
4103 "VN IPv6 interface address\n")
4105 struct rfapi_local_reg_delete_arg cda
;
4108 /* pfx vn un L2 VNI */
4110 parse_deleter_tokens (vty
, NULL
, NULL
, argv
[9], argv
[7], argv
[3], argv
[5],
4114 clear_vnc_prefix (&cda
);
4115 print_cleared_stats (&cda
);
4119 DEFUN (clear_vnc_mac_un
,
4120 clear_vnc_mac_un_cmd
,
4121 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X>",
4124 "Clear mac registration information\n"
4128 "Any virtual network identifier\n"
4129 "Virtual network identifier\n"
4130 "UN address of NVE\n"
4131 "All UN addresses\n"
4132 "UN IPv4 interface address\n"
4133 "UN IPv6 interface address\n")
4135 struct rfapi_local_reg_delete_arg cda
;
4138 /* pfx vn un L2 VNI */
4140 parse_deleter_tokens (vty
, NULL
, NULL
, NULL
, argv
[7], argv
[3], argv
[5], NULL
, NULL
, &cda
)))
4143 clear_vnc_prefix (&cda
);
4144 print_cleared_stats (&cda
);
4148 DEFUN (clear_vnc_mac_vn
,
4149 clear_vnc_mac_vn_cmd
,
4150 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X>",
4153 "Clear mac registration information\n"
4157 "Any virtual network identifier\n"
4158 "Virtual network identifier\n"
4159 "UN address of NVE\n"
4160 "All VN addresses\n"
4161 "VN IPv4 interface address\n"
4162 "VN IPv6 interface address\n")
4164 struct rfapi_local_reg_delete_arg cda
;
4167 /* pfx vn un L2 VNI */
4169 parse_deleter_tokens (vty
, NULL
, NULL
, argv
[7], NULL
, argv
[3], argv
[5], NULL
, NULL
, &cda
)))
4172 clear_vnc_prefix (&cda
);
4173 print_cleared_stats (&cda
);
4177 DEFUN (clear_vnc_mac_all
,
4178 clear_vnc_mac_all_cmd
,
4179 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> *",
4182 "Clear mac registration information\n"
4186 "Any virtual network identifier\n"
4187 "Virtual network identifier\n"
4190 struct rfapi_local_reg_delete_arg cda
;
4193 /* pfx vn un L2 VNI */
4195 parse_deleter_tokens (vty
, NULL
, NULL
, NULL
, NULL
, argv
[3], argv
[5], NULL
, NULL
, &cda
)))
4198 clear_vnc_prefix (&cda
);
4199 print_cleared_stats (&cda
);
4203 /*-------------------------------------------------
4204 * Clear VNC MAC PREFIX
4205 *-------------------------------------------------*/
4207 DEFUN (clear_vnc_mac_vn_un_prefix
,
4208 clear_vnc_mac_vn_un_prefix_cmd
,
4209 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M>",
4212 "Clear mac registration information\n"
4216 "Any virtual network identifier\n"
4217 "Virtual network identifier\n"
4218 "VN address of NVE\n"
4219 "All VN addresses\n"
4220 "VN IPv4 interface address\n"
4221 "VN IPv6 interface address\n"
4222 "UN address of NVE\n"
4223 "All UN addresses\n"
4224 "UN IPv4 interface address\n"
4225 "UN IPv6 interface address\n"
4226 "Clear prefix registration information\n"
4231 struct rfapi_local_reg_delete_arg cda
;
4234 /* pfx vn un L2 VNI */
4236 parse_deleter_tokens (vty
, NULL
, argv
[11], argv
[7], argv
[9], argv
[3], argv
[5],
4240 clear_vnc_prefix (&cda
);
4241 print_cleared_stats (&cda
);
4245 DEFUN (clear_vnc_mac_un_vn_prefix
,
4246 clear_vnc_mac_un_vn_prefix_cmd
,
4247 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M> prefix <*|A.B.C.D/M|X:X::X:X/M>",
4250 "Clear mac registration information\n"
4254 "Any virtual network identifier\n"
4255 "Virtual network identifier\n"
4256 "UN address of NVE\n"
4257 "All UN addresses\n"
4258 "UN IPv4 interface address\n"
4259 "UN IPv6 interface address\n"
4260 "VN address of NVE\n"
4261 "All VN addresses\n"
4262 "VN IPv4 interface address\n"
4263 "VN IPv6 interface address\n"
4264 "Clear prefix registration information\n"
4268 "Clear prefix registration information\n"
4273 struct rfapi_local_reg_delete_arg cda
;
4276 /* pfx vn un L2 VNI */
4278 parse_deleter_tokens (vty
, NULL
, argv
[11], argv
[9], argv
[7], argv
[3], argv
[5],
4282 clear_vnc_prefix (&cda
);
4283 print_cleared_stats (&cda
);
4287 DEFUN (clear_vnc_mac_un_prefix
,
4288 clear_vnc_mac_un_prefix_cmd
,
4289 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M>",
4292 "Clear mac registration information\n"
4296 "Any virtual network identifier\n"
4297 "Virtual network identifier\n"
4298 "UN address of NVE\n"
4299 "All UN addresses\n"
4300 "UN IPv4 interface address\n"
4301 "UN IPv6 interface address\n"
4302 "Clear prefix registration information\n"
4307 struct rfapi_local_reg_delete_arg cda
;
4310 /* pfx vn un L2 VNI */
4312 parse_deleter_tokens (vty
, NULL
, argv
[9], NULL
, argv
[7], argv
[3], argv
[5],
4316 clear_vnc_prefix (&cda
);
4317 print_cleared_stats (&cda
);
4321 DEFUN (clear_vnc_mac_vn_prefix
,
4322 clear_vnc_mac_vn_prefix_cmd
,
4323 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M>",
4326 "Clear mac registration information\n"
4330 "Any virtual network identifier\n"
4331 "Virtual network identifier\n"
4332 "UN address of NVE\n"
4333 "All VN addresses\n"
4334 "VN IPv4 interface address\n"
4335 "VN IPv6 interface address\n"
4336 "Clear prefix registration information\n"
4341 struct rfapi_local_reg_delete_arg cda
;
4344 /* pfx vn un L2 VNI */
4346 parse_deleter_tokens (vty
, NULL
, argv
[9], argv
[7], NULL
, argv
[3], argv
[5],
4350 clear_vnc_prefix (&cda
);
4351 print_cleared_stats (&cda
);
4355 DEFUN (clear_vnc_mac_all_prefix
,
4356 clear_vnc_mac_all_prefix_cmd
,
4357 "clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> prefix <*|A.B.C.D/M|X:X::X:X/M>",
4360 "Clear mac registration information\n"
4364 "Any virtual network identifier\n"
4365 "Virtual network identifier\n"
4366 "UN address of NVE\n"
4367 "All VN addresses\n"
4368 "VN IPv4 interface address\n"
4369 "VN IPv6 interface address\n")
4371 struct rfapi_local_reg_delete_arg cda
;
4374 /* pfx vn un L2 VNI */
4376 parse_deleter_tokens (vty
, NULL
, argv
[7], NULL
, NULL
, argv
[3], argv
[5], NULL
, NULL
, &cda
)))
4379 clear_vnc_prefix (&cda
);
4380 print_cleared_stats (&cda
);
4384 /************************************************************************
4386 ************************************************************************/
4389 /* copied from rfp_vty.c */
4391 check_and_display_is_vnc_running (struct vty
*vty
)
4393 if (!bgp_rfapi_is_vnc_configured (NULL
))
4394 return 1; /* is running */
4399 "VNC is not configured. (There are no configured BGP VPN SAFI peers.)");
4401 return 0; /* not running */
4405 rfapi_vty_show_nve_summary (struct vty
*vty
, show_nve_summary_t show_type
)
4407 struct bgp
*bgp_default
= bgp_get_default ();
4409 int is_vnc_running
= !bgp_rfapi_is_vnc_configured (bgp_default
);
4411 int active_local_routes
;
4412 int active_remote_routes
;
4413 int holddown_remote_routes
;
4414 int imported_remote_routes
;
4419 h
= bgp_default
->rfapi
;
4424 /* don't show local info if not running RFP */
4425 if (is_vnc_running
|| show_type
== SHOW_NVE_SUMMARY_REGISTERED
)
4431 case SHOW_NVE_SUMMARY_ACTIVE_NVES
:
4432 vty_out (vty
, "%-24s ", "NVEs:");
4433 vty_out (vty
, "%-8s %-8u ", "Active:", h
->descriptors
.count
);
4434 vty_out (vty
, "%-8s %-8u ", "Maximum:", h
->stat
.max_descriptors
);
4435 vty_out (vty
, "%-8s %-8u", "Unknown:", h
->stat
.count_unknown_nves
);
4438 case SHOW_NVE_SUMMARY_REGISTERED
:
4440 * NB: With the introduction of L2 route support, we no
4441 * longer have a one-to-one correspondence between
4442 * locally-originated route advertisements and routes in
4443 * the import tables that have local origin. This
4444 * discrepancy arises because a single advertisement
4445 * may contain both an IP prefix and a MAC address.
4446 * Such an advertisement results in two import table
4447 * entries: one indexed by IP prefix, the other indexed
4450 * TBD: update computation and display of registration
4451 * statistics to reflect the underlying semantics.
4455 vty_out (vty
, "%-24s ", "Registrations:");
4456 vty_out (vty
, "%-8s %-8u ", "Active:",
4457 rfapiApCountAll (bgp_default
));
4458 vty_out (vty
, "%-8s %-8u ", "Failed:",
4459 h
->stat
.count_registrations_failed
);
4460 vty_out (vty
, "%-8s %-8u", "Total:",
4461 h
->stat
.count_registrations
);
4462 vty_out (vty
, VTYNL
);
4464 vty_out (vty
, "%-24s ", "Prefixes registered:");
4465 vty_out (vty
, VTYNL
);
4467 rfapiCountAllItRoutes (&active_local_routes
,
4468 &active_remote_routes
,
4469 &holddown_remote_routes
,
4470 &imported_remote_routes
);
4475 vty_out (vty
, " %-20s ", "Locally:");
4476 vty_out (vty
, "%-8s %-8u ", "Active:", active_local_routes
);
4477 vty_out (vty
, VTYNL
);
4481 vty_out (vty
, " %-20s ", "Remotely:");
4482 vty_out (vty
, "%-8s %-8u", "Active:", active_remote_routes
);
4483 vty_out (vty
, VTYNL
);
4484 vty_out (vty
, " %-20s ", "In Holddown:");
4485 vty_out (vty
, "%-8s %-8u", "Active:", holddown_remote_routes
);
4486 vty_out (vty
, VTYNL
);
4487 vty_out (vty
, " %-20s ", "Imported:");
4488 vty_out (vty
, "%-8s %-8u", "Active:", imported_remote_routes
);
4491 case SHOW_NVE_SUMMARY_QUERIES
:
4492 vty_out (vty
, "%-24s ", "Queries:");
4493 vty_out (vty
, "%-8s %-8u ", "Active:", rfapi_monitor_count (NULL
));
4494 vty_out (vty
, "%-8s %-8u ", "Failed:",
4495 h
->stat
.count_queries_failed
);
4496 vty_out (vty
, "%-8s %-8u", "Total:", h
->stat
.count_queries
);
4499 case SHOW_NVE_SUMMARY_RESPONSES
:
4500 rfapiRibShowResponsesSummary (vty
);
4505 vty_out (vty
, VTYNL
);
4510 vty_outln (vty
, "VNC is not configured.");
4517 struct prefix
*vn_prefix
,
4518 struct prefix
*un_prefix
)
4520 //struct hash *rfds;
4521 //struct rfp_rfapi_descriptor_param param;
4523 struct bgp
*bgp_default
= bgp_get_default ();
4525 struct listnode
*node
;
4526 struct rfapi_descriptor
*rfd
;
4535 h
= bgp_default
->rfapi
;
4540 rc
= rfapi_vty_show_nve_summary (vty
, SHOW_NVE_SUMMARY_ACTIVE_NVES
);
4544 for (ALL_LIST_ELEMENTS_RO (&h
->descriptors
, node
, rfd
))
4547 char vn_addr_buf
[INET6_ADDRSTRLEN
] =
4550 char un_addr_buf
[INET6_ADDRSTRLEN
] =
4559 assert (!rfapiRaddr2Qprefix (&rfd
->vn_addr
, &pfx
));
4560 if (!prefix_match (vn_prefix
, &pfx
))
4566 assert (!rfapiRaddr2Qprefix (&rfd
->un_addr
, &pfx
));
4567 if (!prefix_match (un_prefix
, &pfx
))
4571 rfapiRfapiIpAddr2Str (&rfd
->vn_addr
, vn_addr_buf
, INET6_ADDRSTRLEN
);
4572 rfapiRfapiIpAddr2Str (&rfd
->un_addr
, un_addr_buf
, INET6_ADDRSTRLEN
);
4576 /* print out a header */
4578 " " "Active Next Hops");
4579 vty_outln (vty
, "%-15s %-15s %-5s %-5s %-6s %-6s %s",
4582 "Regis", "Resps", "Reach", "Remove", "Age");
4587 vty_outln (vty
, "%-15s %-15s %-5u %-5u %-6u %-6u %s",
4591 rfapi_monitor_count (rfd
),
4592 rfd
->stat_count_nh_reachable
,
4593 rfd
->stat_count_nh_removal
,
4594 rfapiFormatAge(rfd
->open_time
, age
, 10));
4597 if (printed
> 0 || vn_prefix
|| un_prefix
)
4598 vty_outln (vty
, "Displayed %d out of %d active NVEs",
4604 vty_outln (vty
, "VNC is not configured.");
4609 DEFUN (vnc_show_summary
,
4610 vnc_show_summary_cmd
,
4614 "Display VNC status summary\n")
4616 if (!check_and_display_is_vnc_running (vty
))
4618 bgp_rfapi_show_summary (bgp_get_default (), vty
);
4619 vty_out (vty
, VTYNL
);
4620 rfapi_vty_show_nve_summary (vty
, SHOW_NVE_SUMMARY_ACTIVE_NVES
);
4621 rfapi_vty_show_nve_summary (vty
, SHOW_NVE_SUMMARY_QUERIES
);
4622 rfapi_vty_show_nve_summary (vty
, SHOW_NVE_SUMMARY_RESPONSES
);
4623 rfapi_vty_show_nve_summary (vty
, SHOW_NVE_SUMMARY_REGISTERED
);
4627 DEFUN (vnc_show_nves
,
4632 "List known NVEs\n")
4634 rfapi_show_nves (vty
, NULL
, NULL
);
4638 DEFUN (vnc_show_nves_ptct
,
4639 vnc_show_nves_ptct_cmd
,
4640 "show vnc nves <vn|un> <A.B.C.D|X:X::X:X>",
4644 "VN address of NVE\n"
4645 "UN address of NVE\n"
4646 "IPv4 interface address\n"
4647 "IPv6 interface address\n")
4651 if (!check_and_display_is_vnc_running (vty
))
4654 if (!str2prefix (argv
[4]->arg
, &pfx
))
4656 vty_outln (vty
, "Malformed address \"%s\"", argv
[4]->arg
);
4659 if (pfx
.family
!= AF_INET
&& pfx
.family
!= AF_INET6
)
4661 vty_outln (vty
, "Invalid address \"%s\"", argv
[4]->arg
);
4665 if (argv
[3]->arg
[0] == 'u')
4667 rfapi_show_nves (vty
, NULL
, &pfx
);
4671 rfapi_show_nves (vty
, &pfx
, NULL
);
4677 /* adapted from rfp_registration_cache_log() */
4679 rfapi_show_registrations (
4681 struct prefix
*restrict_to
,
4692 rfapi_vty_show_nve_summary (vty
, SHOW_NVE_SUMMARY_REGISTERED
);
4696 /* non-expiring, local */
4697 printed
+= rfapiShowRemoteRegistrations (vty
, restrict_to
, 0, 1, 0, 0);
4701 /* non-expiring, non-local */
4702 printed
+= rfapiShowRemoteRegistrations (vty
, restrict_to
, 0, 0, 1, 0);
4706 /* expiring, including local */
4707 printed
+= rfapiShowRemoteRegistrations (vty
, restrict_to
, 1, 1, 1, 0);
4711 /* non-expiring, non-local */
4712 printed
+= rfapiShowRemoteRegistrations (vty
, restrict_to
, 0, 0, 1, 1);
4716 vty_out (vty
, VTYNL
);
4720 DEFUN (vnc_show_registrations_pfx
,
4721 vnc_show_registrations_pfx_cmd
,
4722 "show vnc registrations [<A.B.C.D/M|X:X::X:X/M|YY:YY:YY:YY:YY:YY>]",
4725 "List active prefix registrations\n"
4726 "Limit output to a particular IPv4 prefix\n"
4727 "Limit output to a particular IPv6 prefix\n"
4728 "Limit output to a particular IPv6 address\n")
4731 struct prefix
*p_addr
= NULL
;
4735 if (!str2prefix (argv
[3]->arg
, &p
))
4737 vty_outln (vty
, "Invalid prefix: %s", argv
[3]->arg
);
4746 rfapi_show_registrations (vty
, p_addr
, 1, 1, 1, 1);
4750 DEFUN (vnc_show_registrations_some_pfx
,
4751 vnc_show_registrations_some_pfx_cmd
,
4752 "show vnc registrations <all|holddown|imported|local|remote> [<A.B.C.D/M|X:X::X:X/M|YY:YY:YY:YY:YY:YY>]",
4755 "List active prefix registrations\n"
4756 "show all registrations\n"
4757 "show only registrations in holddown\n"
4758 "show only imported prefixes\n"
4759 "show only local registrations\n"
4760 "show only remote registrations\n"
4761 "Limit output to a particular prefix or address\n"
4762 "Limit output to a particular prefix or address\n"
4763 "Limit output to a particular prefix or address\n")
4766 struct prefix
*p_addr
= NULL
;
4769 int show_remote
= 0;
4770 int show_holddown
= 0;
4771 int show_imported
= 0;
4775 if (!str2prefix (argv
[4]->arg
, &p
))
4777 vty_outln (vty
, "Invalid prefix: %s", argv
[4]->arg
);
4785 switch (argv
[3]->arg
[0])
4811 rfapi_show_registrations (vty
, p_addr
,
4812 show_local
, show_remote
, show_holddown
,
4817 DEFUN (vnc_show_responses_pfx
,
4818 vnc_show_responses_pfx_cmd
,
4819 "show vnc responses [<A.B.C.D/M|X:X::X:X/M|YY:YY:YY:YY:YY:YY>]",
4822 "List recent query responses\n"
4823 "Limit output to a particular IPv4 prefix\n"
4824 "Limit output to a particular IPv6 prefix\n"
4825 "Limit output to a particular IPv6 address\n" )
4828 struct prefix
*p_addr
= NULL
;
4832 if (!str2prefix (argv
[3]->arg
, &p
))
4834 vty_outln (vty
, "Invalid prefix: %s", argv
[3]->arg
);
4842 rfapi_vty_show_nve_summary (vty
, SHOW_NVE_SUMMARY_QUERIES
);
4844 rfapiRibShowResponsesSummary (vty
);
4846 rfapiRibShowResponses (vty
, p_addr
, 0);
4847 rfapiRibShowResponses (vty
, p_addr
, 1);
4852 DEFUN (vnc_show_responses_some_pfx
,
4853 vnc_show_responses_some_pfx_cmd
,
4854 "show vnc responses <active|removed> [<A.B.C.D/M|X:X::X:X/M|YY:YY:YY:YY:YY:YY>]",
4857 "List recent query responses\n"
4858 "show only active query responses\n"
4859 "show only removed query responses\n"
4860 "Limit output to a particular IPv4 prefix\n"
4861 "Limit output to a particular IPv6 prefix\n"
4862 "Limit output to a particular IPV6 address\n")
4865 struct prefix
*p_addr
= NULL
;
4867 int show_active
= 0;
4868 int show_removed
= 0;
4870 if (!check_and_display_is_vnc_running (vty
))
4875 if (!str2prefix (argv
[4]->arg
, &p
))
4877 vty_outln (vty
, "Invalid prefix: %s", argv
[4]->arg
);
4886 switch (argv
[3]->arg
[0])
4897 rfapi_vty_show_nve_summary (vty
, SHOW_NVE_SUMMARY_QUERIES
);
4899 rfapiRibShowResponsesSummary (vty
);
4902 rfapiRibShowResponses (vty
, p_addr
, 0);
4904 rfapiRibShowResponses (vty
, p_addr
, 1);
4909 DEFUN (show_vnc_queries_pfx
,
4910 show_vnc_queries_pfx_cmd
,
4911 "show vnc queries [<A.B.C.D/M|X:X::X:X/M|YY:YY:YY:YY:YY:YY>]",
4914 "List active queries\n"
4915 "Limit output to a particular IPv4 prefix or address\n"
4916 "Limit output to a particular IPv6 prefix\n"
4917 "Limit output to a particualr IPV6 address\n")
4920 struct prefix
*p
= NULL
;
4924 if (!str2prefix (argv
[3]->arg
, &pfx
))
4926 vty_outln (vty
, "Invalid prefix: %s", argv
[3]->arg
);
4932 rfapi_vty_show_nve_summary (vty
, SHOW_NVE_SUMMARY_QUERIES
);
4934 return rfapiShowVncQueries (vty
, p
);
4937 DEFUN (vnc_clear_counters
,
4938 vnc_clear_counters_cmd
,
4939 "clear vnc counters",
4942 "Reset VNC counters\n")
4944 struct bgp
*bgp_default
= bgp_get_default ();
4946 struct listnode
*node
;
4947 struct rfapi_descriptor
*rfd
;
4952 h
= bgp_default
->rfapi
;
4958 for (ALL_LIST_ELEMENTS_RO (&h
->descriptors
, node
, rfd
))
4960 rfd
->stat_count_nh_reachable
= 0;
4961 rfd
->stat_count_nh_removal
= 0;
4965 memset (&h
->stat
, 0, sizeof (h
->stat
));
4968 * 151122 per bug 103, set count_registrations = number active.
4969 * Do same for queries
4971 h
->stat
.count_registrations
= rfapiApCountAll (bgp_default
);
4972 h
->stat
.count_queries
= rfapi_monitor_count (NULL
);
4974 rfapiRibShowResponsesSummaryClear ();
4979 vty_outln (vty
, "VNC is not configured.");
4983 /************************************************************************
4984 * Add prefix with vrf
4986 * add [vrf <vrf-name>] prefix <prefix>
4987 * [rd <value>] [label <value>] [local-preference <0-4294967295>]
4988 ************************************************************************/
4990 vnc_add_vrf_prefix (struct vty
*vty
,
4991 const char *arg_vrf
,
4992 const char *arg_prefix
,
4993 const char *arg_rd
, /* optional */
4994 const char *arg_label
, /* optional */
4995 const char *arg_pref
) /* optional */
4998 struct rfapi_nve_group_cfg
*rfg
;
5000 struct rfapi_ip_prefix rpfx
;
5002 struct rfapi_vn_option optary
[3];
5003 struct rfapi_vn_option
*opt
= NULL
;
5006 bgp
= bgp_get_default (); /* assume main instance for now */
5009 vty_outln (vty
, "No BGP process is configured");
5012 if (!bgp
->rfapi
|| !bgp
->rfapi_cfg
)
5014 vty_outln (vty
, "VRF support not configured");
5018 rfg
= bgp_rfapi_cfg_match_byname (bgp
, arg_vrf
, RFAPI_GROUP_CFG_VRF
);
5022 vty_outln (vty
, "VRF \"%s\" appears not to be configured.",
5026 if (!rfg
->rt_export_list
|| !rfg
->rfapi_import_table
)
5028 vty_outln (vty
, "VRF \"%s\" is missing RT import/export RT configuration.",
5032 if (!rfg
->rd
.family
&& !arg_rd
)
5034 vty_outln (vty
, "VRF \"%s\" isn't configured with an RD, so RD must be provided.",
5038 if (rfg
->label
> MPLS_LABEL_MAX
&& !arg_label
)
5040 vty_outln (vty
, "VRF \"%s\" isn't configured with a default labels, so a label must be provided.",
5044 if (!str2prefix (arg_prefix
, &pfx
))
5046 vty_outln (vty
, "Malformed prefix \"%s\"",
5050 rfapiQprefix2Rprefix (&pfx
, &rpfx
);
5051 memset (optary
, 0, sizeof (optary
));
5055 opt
->next
= &optary
[cur_opt
];
5056 opt
= &optary
[cur_opt
++];
5057 opt
->type
= RFAPI_VN_OPTION_TYPE_INTERNAL_RD
;
5058 if (!str2prefix_rd (arg_rd
, &opt
->v
.internal_rd
))
5060 vty_outln (vty
, "Malformed RD \"%s\"",
5065 if (rfg
->label
<= MPLS_LABEL_MAX
|| arg_label
)
5067 struct rfapi_l2address_option
*l2o
;
5069 opt
->next
= &optary
[cur_opt
];
5070 opt
= &optary
[cur_opt
++];
5071 opt
->type
= RFAPI_VN_OPTION_TYPE_L2ADDR
;
5072 l2o
= &opt
->v
.l2addr
;
5076 label
= strtoul(arg_label
, NULL
, 10);
5080 l2o
->label
= rfg
->label
;
5084 char *endptr
= NULL
;
5085 pref
= strtoul (arg_pref
, &endptr
, 10);
5086 if (*endptr
!= '\0')
5088 vty_outln (vty
, "%% Invalid local-preference value \"%s\"",
5093 rpfx
.cost
= 255 - (pref
& 255) ;
5094 if (rfg
->rfd
== NULL
) /* need new rfapi_handle */
5096 /* based on rfapi_open */
5097 struct rfapi_descriptor
*rfd
;
5098 rfd
= XCALLOC (MTYPE_RFAPI_DESC
, sizeof (struct rfapi_descriptor
));
5101 /* leave most fields empty as will get from (dynamic) config when needed */
5102 rfd
->default_tunneltype_option
.type
= BGP_ENCAP_TYPE_MPLS
;
5104 if (rfg
->vn_prefix
.family
&&
5105 !CHECK_FLAG(rfg
->flags
, RFAPI_RFG_VPN_NH_SELF
))
5107 rfapiQprefix2Raddr(&rfg
->vn_prefix
, &rfd
->vn_addr
);
5111 memset(&rfd
->vn_addr
, 0, sizeof(struct rfapi_ip_addr
));
5112 rfd
->vn_addr
.addr_family
= AF_INET
;
5113 rfd
->vn_addr
.addr
.v4
= bgp
->router_id
;
5115 rfd
->un_addr
= rfd
->vn_addr
; /* sigh, need something in UN for lookups */
5116 vnc_zlog_debug_verbose ("%s: Opening RFD for VRF %s",
5117 __func__
, rfg
->name
);
5118 rfapi_init_and_open(bgp
, rfd
, rfg
);
5121 if (!rfapi_register (rfg
->rfd
, &rpfx
, RFAPI_INFINITE_LIFETIME
, NULL
,
5122 (cur_opt
? optary
: NULL
), RFAPI_REGISTER_ADD
))
5124 struct rfapi_next_hop_entry
*head
= NULL
;
5125 struct rfapi_next_hop_entry
*tail
= NULL
;
5126 struct rfapi_vn_option
*vn_opt_new
;
5128 vnc_zlog_debug_verbose ("%s: rfapi_register succeeded", __func__
);
5130 if (bgp
->rfapi
->rfp_methods
.local_cb
)
5132 struct rfapi_descriptor
*r
= (struct rfapi_descriptor
*) rfg
->rfd
;
5133 vn_opt_new
= rfapi_vn_options_dup (opt
);
5135 rfapiAddDeleteLocalRfpPrefix (&r
->un_addr
, &r
->vn_addr
, &rpfx
,
5136 1, RFAPI_INFINITE_LIFETIME
,
5137 vn_opt_new
, &head
, &tail
);
5140 bgp
->rfapi
->flags
|= RFAPI_INCALLBACK
;
5141 (*bgp
->rfapi
->rfp_methods
.local_cb
) (head
, r
->cookie
);
5142 bgp
->rfapi
->flags
&= ~RFAPI_INCALLBACK
;
5146 vnc_zlog_debug_verbose ("%s completed, count=%d/%d", __func__
,
5147 rfg
->rfapi_import_table
->local_count
[AFI_IP
],
5148 rfg
->rfapi_import_table
->local_count
[AFI_IP6
]);
5152 vnc_zlog_debug_verbose ("%s: rfapi_register failed", __func__
);
5153 vty_outln (vty
, "Add failed.");
5157 DEFUN (add_vrf_prefix_rd_label_pref
,
5158 add_vrf_prefix_rd_label_pref_cmd
,
5159 "add vrf NAME prefix <A.B.C.D/M|X:X::X:X/M> [{rd ASN:nn_or_IP-address|label (0-1048575)|preference (0-4294967295)}]",
5163 "Add/modify prefix related information\n"
5166 "Override configured VRF Route Distinguisher\n"
5167 "<as-number>:<number> or <ip-address>:<number>\n"
5168 "Override configured VRF label\n"
5169 "Label Value <0-1048575>\n"
5170 "Set advertised local preference\n"
5171 "local preference (higher=more preferred)\n")
5173 char *arg_vrf
= argv
[2]->arg
;
5174 char *arg_prefix
= argv
[4]->arg
;
5175 char *arg_rd
= NULL
; /* optional */
5176 char *arg_label
= NULL
; /* optional */
5177 char *arg_pref
= NULL
; /* optional */
5179 argc
--; /* don't parse argument */
5180 while (pargc
< argc
)
5182 switch (argv
[pargc
++]->arg
[0])
5185 arg_rd
= argv
[pargc
]->arg
;
5188 arg_label
= argv
[pargc
]->arg
;
5191 arg_pref
= argv
[pargc
]->arg
;
5199 return vnc_add_vrf_prefix (vty
, arg_vrf
, arg_prefix
, arg_rd
, arg_label
, arg_pref
);
5202 /************************************************************************
5203 * del prefix with vrf
5205 * clear [vrf <vrf-name>] prefix <prefix> [rd <value>]
5206 ************************************************************************/
5208 rfapi_cfg_group_it_count(struct rfapi_nve_group_cfg
*rfg
)
5211 afi_t afi
= AFI_MAX
;
5214 count
+= rfg
->rfapi_import_table
->local_count
[afi
];
5220 clear_vnc_vrf_closer (struct rfapi_nve_group_cfg
*rfg
)
5222 struct rfapi_descriptor
*rfd
= rfg
->rfd
;
5227 /* check if IT is empty */
5229 afi
< AFI_MAX
&& rfg
->rfapi_import_table
->local_count
[afi
] == 0;
5234 vnc_zlog_debug_verbose ("%s: closing RFD for VRF %s",
5235 __func__
, rfg
->name
);
5241 vnc_zlog_debug_verbose ("%s: VRF %s afi=%d count=%d",
5242 __func__
, rfg
->name
, afi
,
5243 rfg
->rfapi_import_table
->local_count
[afi
]);
5248 vnc_clear_vrf (struct vty
*vty
,
5250 const char *arg_vrf
,
5251 const char *arg_prefix
, /* NULL = all */
5252 const char *arg_rd
) /* optional */
5254 struct rfapi_nve_group_cfg
*rfg
;
5255 struct rfapi_local_reg_delete_arg cda
;
5260 bgp
= bgp_get_default (); /* assume main instance for now */
5263 vty_outln (vty
, "No BGP process is configured");
5266 if (!bgp
->rfapi
|| !bgp
->rfapi_cfg
)
5268 vty_outln (vty
, "VRF support not configured");
5271 rfg
= bgp_rfapi_cfg_match_byname (bgp
, arg_vrf
, RFAPI_GROUP_CFG_VRF
);
5275 vty_outln (vty
, "VRF \"%s\" appears not to be configured.",
5279 rc
= parse_deleter_args (vty
, bgp
, arg_prefix
, NULL
, NULL
, NULL
, NULL
,
5281 if (rc
!= CMD_SUCCESS
) /* parse error */
5284 start_count
= rfapi_cfg_group_it_count(rfg
);
5285 clear_vnc_prefix (&cda
);
5286 clear_vnc_vrf_closer (rfg
);
5287 vty_outln (vty
, "Cleared %u out of %d prefixes.",
5288 cda
.pfx_count
, start_count
);
5292 DEFUN (clear_vrf_prefix_rd
,
5293 clear_vrf_prefix_rd_cmd
,
5294 "clear vrf NAME [prefix <A.B.C.D/M|X:X::X:X/M>] [rd ASN:nn_or_IP-address]",
5295 "Clear stored data\n"
5298 "Prefix related information\n"
5301 "Specific VRF Route Distinguisher\n"
5302 "<as-number>:<number> or <ip-address>:<number>\n")
5304 char *arg_vrf
= argv
[2]->arg
;
5305 char *arg_prefix
= NULL
; /* optional */
5306 char *arg_rd
= NULL
; /* optional */
5308 argc
--; /* don't check parameter */
5309 while (pargc
< argc
)
5311 switch (argv
[pargc
++]->arg
[0])
5314 arg_rd
= argv
[pargc
]->arg
;
5317 arg_prefix
= argv
[pargc
]->arg
;
5324 return vnc_clear_vrf (vty
, NULL
, arg_vrf
, arg_prefix
, arg_rd
);
5327 DEFUN (clear_vrf_all
,
5329 "clear vrf NAME all",
5330 "Clear stored data\n"
5335 char *arg_vrf
= argv
[2]->arg
;
5336 return vnc_clear_vrf (vty
, NULL
, arg_vrf
, NULL
, NULL
);
5339 void rfapi_vty_init ()
5341 install_element (ENABLE_NODE
, &add_vnc_prefix_cost_life_lnh_cmd
);
5342 install_element (ENABLE_NODE
, &add_vnc_prefix_life_cost_lnh_cmd
);
5343 install_element (ENABLE_NODE
, &add_vnc_prefix_cost_lnh_cmd
);
5344 install_element (ENABLE_NODE
, &add_vnc_prefix_life_lnh_cmd
);
5345 install_element (ENABLE_NODE
, &add_vnc_prefix_lnh_cmd
);
5347 install_element (ENABLE_NODE
, &add_vnc_prefix_cost_life_cmd
);
5348 install_element (ENABLE_NODE
, &add_vnc_prefix_life_cost_cmd
);
5349 install_element (ENABLE_NODE
, &add_vnc_prefix_cost_cmd
);
5350 install_element (ENABLE_NODE
, &add_vnc_prefix_life_cmd
);
5351 install_element (ENABLE_NODE
, &add_vnc_prefix_cmd
);
5353 install_element (ENABLE_NODE
, &add_vnc_mac_vni_prefix_cost_life_cmd
);
5354 install_element (ENABLE_NODE
, &add_vnc_mac_vni_prefix_life_cmd
);
5355 install_element (ENABLE_NODE
, &add_vnc_mac_vni_prefix_cost_cmd
);
5356 install_element (ENABLE_NODE
, &add_vnc_mac_vni_prefix_cmd
);
5357 install_element (ENABLE_NODE
, &add_vnc_mac_vni_cost_life_cmd
);
5358 install_element (ENABLE_NODE
, &add_vnc_mac_vni_cost_cmd
);
5359 install_element (ENABLE_NODE
, &add_vnc_mac_vni_life_cmd
);
5360 install_element (ENABLE_NODE
, &add_vnc_mac_vni_cmd
);
5362 install_element (ENABLE_NODE
, &add_vrf_prefix_rd_label_pref_cmd
);
5364 install_element (ENABLE_NODE
, &clear_vnc_nve_all_cmd
);
5365 install_element (ENABLE_NODE
, &clear_vnc_nve_vn_un_cmd
);
5366 install_element (ENABLE_NODE
, &clear_vnc_nve_un_vn_cmd
);
5367 install_element (ENABLE_NODE
, &clear_vnc_nve_vn_cmd
);
5368 install_element (ENABLE_NODE
, &clear_vnc_nve_un_cmd
);
5370 install_element (ENABLE_NODE
, &clear_vnc_prefix_vn_un_cmd
);
5371 install_element (ENABLE_NODE
, &clear_vnc_prefix_un_vn_cmd
);
5372 install_element (ENABLE_NODE
, &clear_vnc_prefix_un_cmd
);
5373 install_element (ENABLE_NODE
, &clear_vnc_prefix_vn_cmd
);
5374 install_element (ENABLE_NODE
, &clear_vnc_prefix_all_cmd
);
5376 install_element (ENABLE_NODE
, &clear_vnc_mac_vn_un_cmd
);
5377 install_element (ENABLE_NODE
, &clear_vnc_mac_un_vn_cmd
);
5378 install_element (ENABLE_NODE
, &clear_vnc_mac_un_cmd
);
5379 install_element (ENABLE_NODE
, &clear_vnc_mac_vn_cmd
);
5380 install_element (ENABLE_NODE
, &clear_vnc_mac_all_cmd
);
5382 install_element (ENABLE_NODE
, &clear_vnc_mac_vn_un_prefix_cmd
);
5383 install_element (ENABLE_NODE
, &clear_vnc_mac_un_vn_prefix_cmd
);
5384 install_element (ENABLE_NODE
, &clear_vnc_mac_un_prefix_cmd
);
5385 install_element (ENABLE_NODE
, &clear_vnc_mac_vn_prefix_cmd
);
5386 install_element (ENABLE_NODE
, &clear_vnc_mac_all_prefix_cmd
);
5388 install_element (ENABLE_NODE
, &clear_vrf_prefix_rd_cmd
);
5389 install_element (ENABLE_NODE
, &clear_vrf_all_cmd
);
5391 install_element (ENABLE_NODE
, &vnc_clear_counters_cmd
);
5393 install_element (VIEW_NODE
, &vnc_show_summary_cmd
);
5394 install_element (VIEW_NODE
, &vnc_show_nves_cmd
);
5395 install_element (VIEW_NODE
, &vnc_show_nves_ptct_cmd
);
5397 install_element (VIEW_NODE
, &vnc_show_registrations_pfx_cmd
);
5398 install_element (VIEW_NODE
, &vnc_show_registrations_some_pfx_cmd
);
5399 install_element (VIEW_NODE
, &vnc_show_responses_pfx_cmd
);
5400 install_element (VIEW_NODE
, &vnc_show_responses_some_pfx_cmd
);
5401 install_element (VIEW_NODE
, &show_vnc_queries_pfx_cmd
);