diff options
238 files changed, 19878 insertions, 8664 deletions
diff --git a/.gitignore b/.gitignore index 62aa48e22..3ad6b1de1 100644 --- a/.gitignore +++ b/.gitignore @@ -48,18 +48,18 @@ m4/*.m4 debian/autoreconf.after debian/autoreconf.before debian/files -debian/quagga-dbg.debhelper.log -debian/quagga-dbg.substvars -debian/quagga-dbg/ -debian/quagga-doc.debhelper.log -debian/quagga-doc.substvars -debian/quagga-doc/ -debian/quagga.debhelper.log -debian/quagga.postinst.debhelper -debian/quagga.postrm.debhelper -debian/quagga.prerm.debhelper -debian/quagga.substvars -debian/quagga/ +debian/frr-dbg.debhelper.log +debian/frr-dbg.substvars +debian/frr-dbg/ +debian/frr-doc.debhelper.log +debian/frr-doc.substvars +debian/frr-doc/ +debian/frr.debhelper.log +debian/frr.postinst.debhelper +debian/frr.postrm.debhelper +debian/frr.prerm.debhelper +debian/frr.substvars +debian/frr/ debian/tmp/ *.pyc *.swp diff --git a/COMMUNITY.md b/COMMUNITY.md index a441929b3..8ab6a624e 100644 --- a/COMMUNITY.md +++ b/COMMUNITY.md @@ -380,3 +380,36 @@ CLI's are a complicated ugly beast. Additions or changes to the CLI should use a DEFUN to encapsulate one setting as much as is possible. Additionally as new DEFUN's are added to the system, documentation should be provided for the new commands. + +### Backwards Compatibility + +As a general principle, changes to CLI and code in the lib/ directory +should be made in a backwards compatible fashion. This means that +changes that are purely stylistic in nature should be avoided, e.g., +renaming an existing macro or library function name without any +functional change. When adding new parameters to common functions, it is +also good to consider if this too should be done in a backward +compatible fashion, e.g., by preserving the old form in addition to +adding the new form. + +This is not to say that minor or even major functional changes to CLI +and common code should be avoided, but rather that the benefit gained +from a change should be weighed against the added cost/complexity to +existing code. Also, that when making such changes, it is good to +preserve compatibility when possible to do so without introducing +maintenance overhead/cost. It is also important to keep in mind, +existing code includes code that may reside in private repositories (and +is yet to be submitted) or code that has yet to be migrated from Quagga +to FRR. + +That said, compatibility measures can (and should) be removed when either: + +* they become a significant burden, e.g. when data structures change and + the compatibility measure would need a complex adaptation layer or becomes + flat-out impossible +* some measure of time (dependent on the specific case) has passed, so that + the compatibility grace period is considered expired. + +In all cases, compatibility pieces should be marked with compiler/preprocessor +annotations to print warnings at compile time, pointing to the appropriate +update path. A `-Werror` build should fail if compatibility bits are used. diff --git a/Makefile.am b/Makefile.am index d18837c08..0092ba8c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,9 +8,8 @@ SUBDIRS = lib qpb fpm @ZEBRA@ @LIBRFP@ @RFPTEST@ \ DIST_SUBDIRS = lib qpb fpm zebra bgpd ripd ripngd ospfd ospf6d ldpd \ isisd watchfrr vtysh ospfclient doc m4 pkgsrc redhat tests \ - solaris pimd nhrpd eigrpd @LIBRFP@ @RFPTEST@ tools snapcraft \ - babeld \ - python \ + solaris pimd nhrpd eigrpd bgpd/rfp-example/librfp \ + bgpd/rfp-example/rfptest tools snapcraft babeld python \ # end EXTRA_DIST = aclocal.m4 SERVICES REPORTING-BUGS \ diff --git a/README.NetBSD b/README.NetBSD index 6e454533e..c97e3bcb3 100755 --- a/README.NetBSD +++ b/README.NetBSD @@ -1,18 +1,18 @@ #!/bin/sh -# This file is helpful for building quagga from cvs on NetBSD, and +# This file is helpful for building FRR from cvs on NetBSD, and # probably on any system using pkgsrc. # One should have readline installed already (pkgsrc/devel/readline). MAKE=make -# Quagga is currently documented not to require GNU make, but sometimes +# FRR is currently documented not to require GNU make, but sometimes # BSD make fails. Enable this if statement as a workaround. if false; then MAKE=gmake echo "WARNING: using gmake to work around nonportable makefiles" fi -# Use /usr/quagga to be independent, and /usr/pkg to overwrite pkgsrc. +# Use /usr/frr to be independent, and /usr/pkg to overwrite pkgsrc. PREFIX=/usr/pkg case $1 in diff --git a/REPORTING-BUGS b/REPORTING-BUGS index 01f25a205..339ebc24d 100644 --- a/REPORTING-BUGS +++ b/REPORTING-BUGS @@ -16,7 +16,7 @@ Please supply the following information: 1. Your FRRouting version or if it is from git then the commit reference. Please try to report bugs against git master or the latest release. 2. FRR daemons you run e.g. bgpd or ripd and full name of your OS. Any - specific options you compiled Quagga with. + specific options you compiled FRR with. 3. Problem description. Copy and paste relative commands and their output to describe your network setup e.g. "zebra>show ip route". Please, also give your simple network layout and output of relative OS diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index fe8fde92e..1ae33b3a2 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -290,9 +290,9 @@ DEFUN (babel_network, ret = babel_enable_if_add (argv[1]->arg); if (ret < 0) { - vty_outln (vty, "There is same network configuration %s", + vty_out (vty, "There is same network configuration %s\n", argv[1]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -318,8 +318,8 @@ DEFUN (no_babel_network, ret = babel_enable_if_delete (argv[2]->arg); if (ret < 0) { - vty_outln (vty, "can't find network %s",argv[2]->arg); - return CMD_WARNING; + vty_out (vty, "can't find network %s\n",argv[2]->arg); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -861,31 +861,31 @@ show_babel_interface_sub (struct vty *vty, struct interface *ifp) int is_up; babel_interface_nfo *babel_ifp; - vty_outln (vty, "%s is %s", ifp->name, + vty_out (vty, "%s is %s\n", ifp->name, ((is_up = if_is_operative(ifp)) ? "up" : "down")); - vty_outln (vty, " ifindex %u, MTU %u bytes %s", + vty_out (vty, " ifindex %u, MTU %u bytes %s\n", ifp->ifindex, MIN(ifp->mtu, ifp->mtu6), if_flag_dump(ifp->flags)); if (!IS_ENABLE(ifp)) { - vty_outln (vty, " Babel protocol is not enabled on this interface"); + vty_out (vty, " Babel protocol is not enabled on this interface\n"); return; } if (!is_up) { - vty_outln (vty, - " Babel protocol is enabled, but not running on this interface"); + vty_out (vty, + " Babel protocol is enabled, but not running on this interface\n"); return; } babel_ifp = babel_get_if_nfo (ifp); - vty_outln (vty, " Babel protocol is running on this interface"); - vty_outln (vty, " Operating mode is \"%s\"", + vty_out (vty, " Babel protocol is running on this interface\n"); + vty_out (vty, " Operating mode is \"%s\"\n", CHECK_FLAG(babel_ifp->flags, BABEL_IF_WIRED) ? "wired" : "wireless"); - vty_outln (vty, " Split horizon mode is %s", + vty_out (vty, " Split horizon mode is %s\n", CHECK_FLAG(babel_ifp->flags, BABEL_IF_SPLIT_HORIZON) ? "On" : "Off"); - vty_outln (vty, " Hello interval is %u ms", babel_ifp->hello_interval); - vty_outln (vty, " Update interval is %u ms", babel_ifp->update_interval); - vty_outln (vty, " Rxcost multiplier is %u", babel_ifp->cost); + vty_out (vty, " Hello interval is %u ms\n", babel_ifp->hello_interval); + vty_out (vty, " Update interval is %u ms\n", babel_ifp->update_interval); + vty_out (vty, " Rxcost multiplier is %u\n", babel_ifp->cost); } DEFUN (show_babel_interface, @@ -907,7 +907,7 @@ DEFUN (show_babel_interface, } if ((ifp = if_lookup_by_name (argv[3]->arg, VRF_DEFAULT)) == NULL) { - vty_outln (vty, "No such interface name"); + vty_out (vty, "No such interface name\n"); return CMD_WARNING; } show_babel_interface_sub (vty, ifp); @@ -917,9 +917,9 @@ DEFUN (show_babel_interface, static void show_babel_neighbour_sub (struct vty *vty, struct neighbour *neigh) { - vty_outln (vty, + vty_out (vty, "Neighbour %s dev %s reach %04x rxcost %d txcost %d " - "rtt %s rttcost %d%s.", + "rtt %s rttcost %d%s.\n", format_address(neigh->address), neigh->ifp->name, neigh->reach, @@ -949,7 +949,7 @@ DEFUN (show_babel_neighbour, } if ((ifp = if_lookup_by_name (argv[3]->arg, VRF_DEFAULT)) == NULL) { - vty_outln (vty, "No such interface name"); + vty_out (vty, "No such interface name\n"); return CMD_WARNING; } FOR_ALL_NEIGHBOURS(neigh) { @@ -1009,9 +1009,9 @@ show_babel_routes_sub(struct babel_route *route, struct vty *vty, channels[0] = '\0'; } - vty_outln (vty, + vty_out (vty, "%s metric %d refmetric %d id %s seqno %d%s age %d " - "via %s neigh %s%s%s%s", + "via %s neigh %s%s%s%s\n", format_prefix(route->src->prefix, route->src->plen), route_metric(route), route->refmetric, format_eui64(route->src->id), @@ -1032,7 +1032,7 @@ show_babel_xroutes_sub (struct xroute *xroute, struct vty *vty, if(prefix && !babel_prefix_eq(prefix, xroute->prefix, xroute->plen)) return; - vty_outln (vty, "%s metric %d (exported)", + vty_out (vty, "%s metric %d (exported)\n", format_prefix(xroute->prefix, xroute->plen), xroute->metric); } @@ -1089,7 +1089,7 @@ DEFUN (show_babel_route_prefix, ret = str2prefix(argv[3]->arg, &prefix); if(ret == 0) { - vty_outln (vty, "%% Malformed address"); + vty_out (vty, "%% Malformed address\n"); return CMD_WARNING; } @@ -1138,7 +1138,7 @@ DEFUN (show_babel_route_addr, ret = inet_aton (argv[3]->arg, &addr); if (ret <= 0) { - vty_outln (vty, "%% Malformed address"); + vty_out (vty, "%% Malformed address\n"); return CMD_WARNING; } @@ -1147,7 +1147,7 @@ DEFUN (show_babel_route_addr, ret = str2prefix(buf, &prefix); if (ret == 0) { - vty_outln (vty, "%% Parse error -- this shouldn't happen"); + vty_out (vty, "%% Parse error -- this shouldn't happen\n"); return CMD_WARNING; } @@ -1196,7 +1196,7 @@ DEFUN (show_babel_route_addr6, ret = inet_pton (AF_INET6, argv[3]->arg, &addr); if (ret <= 0) { - vty_outln (vty, "%% Malformed address"); + vty_out (vty, "%% Malformed address\n"); return CMD_WARNING; } @@ -1206,7 +1206,7 @@ DEFUN (show_babel_route_addr6, ret = str2prefix(buf, &prefix); if (ret == 0) { - vty_outln (vty, "%% Parse error -- this shouldn't happen"); + vty_out (vty, "%% Parse error -- this shouldn't happen\n"); return CMD_WARNING; } @@ -1244,9 +1244,9 @@ DEFUN (show_babel_parameters, "Babel information\n" "Configuration information\n") { - vty_outln (vty, " -- Babel running configuration --"); + vty_out (vty, " -- Babel running configuration --\n"); show_babel_main_configuration(vty); - vty_outln (vty, " -- distribution lists --"); + vty_out (vty, " -- distribution lists --\n"); config_show_distribute(vty); return CMD_SUCCESS; @@ -1321,63 +1321,63 @@ interface_config_write (struct vty *vty) int write = 0; for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp)) { - vty_outln (vty, "interface %s",ifp->name); + vty_out (vty, "interface %s\n",ifp->name); if (ifp->desc) - vty_outln (vty, " description %s",ifp->desc); + vty_out (vty, " description %s\n",ifp->desc); babel_interface_nfo *babel_ifp = babel_get_if_nfo (ifp); /* wireless is the default*/ if (CHECK_FLAG (babel_ifp->flags, BABEL_IF_WIRED)) { - vty_outln (vty, " babel wired"); + vty_out (vty, " babel wired\n"); write++; } if (babel_ifp->hello_interval != BABEL_DEFAULT_HELLO_INTERVAL) { - vty_outln (vty, " babel hello-interval %u", + vty_out (vty, " babel hello-interval %u\n", babel_ifp->hello_interval); write++; } if (babel_ifp->update_interval != BABEL_DEFAULT_UPDATE_INTERVAL) { - vty_outln (vty, " babel update-interval %u", + vty_out (vty, " babel update-interval %u\n", babel_ifp->update_interval); write++; } /* Some parameters have different defaults for wired/wireless. */ if (CHECK_FLAG (babel_ifp->flags, BABEL_IF_WIRED)) { if (!CHECK_FLAG (babel_ifp->flags, BABEL_IF_SPLIT_HORIZON)) { - vty_outln (vty, " no babel split-horizon"); + vty_out (vty, " no babel split-horizon\n"); write++; } if (babel_ifp->cost != BABEL_DEFAULT_RXCOST_WIRED) { - vty_outln (vty, " babel rxcost %u", babel_ifp->cost); + vty_out (vty, " babel rxcost %u\n", babel_ifp->cost); write++; } if (babel_ifp->channel == BABEL_IF_CHANNEL_INTERFERING) { - vty_outln (vty, " babel channel interfering"); + vty_out (vty, " babel channel interfering\n"); write++; } else if(babel_ifp->channel != BABEL_IF_CHANNEL_NONINTERFERING) { - vty_outln (vty, " babel channel %d",babel_ifp->channel); + vty_out (vty, " babel channel %d\n",babel_ifp->channel); write++; } } else { if (CHECK_FLAG (babel_ifp->flags, BABEL_IF_SPLIT_HORIZON)) { - vty_outln (vty, " babel split-horizon"); + vty_out (vty, " babel split-horizon\n"); write++; } if (babel_ifp->cost != BABEL_DEFAULT_RXCOST_WIRELESS) { - vty_outln (vty, " babel rxcost %u", babel_ifp->cost); + vty_out (vty, " babel rxcost %u\n", babel_ifp->cost); write++; } if (babel_ifp->channel == BABEL_IF_CHANNEL_NONINTERFERING) { - vty_outln (vty, " babel channel noninterfering"); + vty_out (vty, " babel channel noninterfering\n"); write++; } else if(babel_ifp->channel != BABEL_IF_CHANNEL_INTERFERING) { - vty_outln (vty, " babel channel %d",babel_ifp->channel); + vty_out (vty, " babel channel %d\n",babel_ifp->channel); write++; } } - vty_outln (vty, "!"); + vty_out (vty, "!\n"); write++; } return write; @@ -1393,7 +1393,7 @@ babel_enable_if_config_write (struct vty * vty) for (i = 0; i < vector_active (babel_enable_if); i++) if ((str = vector_slot (babel_enable_if, i)) != NULL) { - vty_outln (vty, " network %s", str); + vty_out (vty, " network %s\n", str); lines++; } return lines; diff --git a/babeld/babel_main.c b/babeld/babel_main.c index eb2909b40..517489f15 100644 --- a/babeld/babel_main.c +++ b/babeld/babel_main.c @@ -377,25 +377,22 @@ babel_save_state_file(void) void show_babel_main_configuration (struct vty *vty) { - vty_outln (vty, - "state file = %s%s" - "configuration file = %s%s" - "protocol informations:%s" - " multicast address = %s%s" - " port = %d%s" - "vty address = %s%s" - "vty port = %d%s" - "id = %s%s" - "kernel_metric = %d", - state_file, VTYNL, + vty_out (vty, + "state file = %s\n" + "configuration file = %s\n" + "protocol informations:\n" + " multicast address = %s\n" + " port = %d\n" + "vty address = %s\n" + "vty port = %d\n" + "id = %s\n" + "kernel_metric = %d\n", + state_file, babel_config_file ? babel_config_file : babel_config_default, - VTYNL, - VTYNL, - format_address(protocol_group), VTYNL, - protocol_port, VTYNL, + format_address(protocol_group), + protocol_port, babel_vty_addr ? babel_vty_addr : "None", - VTYNL, - babel_vty_port, VTYNL, - format_eui64(myid), VTYNL, + babel_vty_port, + format_eui64(myid), kernel_metric); } diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c index 3a7a52ccc..52d7eaee8 100644 --- a/babeld/babel_zebra.c +++ b/babeld/babel_zebra.c @@ -222,11 +222,12 @@ DEFUN (babel_redistribute_type, type = babel_proto_redistnum(argv[1]->arg); if (type < 0) { - vty_outln (vty, "Invalid type %s", argv[1]->arg); - return CMD_WARNING; + vty_out (vty, "Invalid type %s\n", argv[1]->arg); + return CMD_WARNING_CONFIG_FAILED; } zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, VRF_DEFAULT); + zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT); return CMD_SUCCESS; } @@ -243,11 +244,12 @@ DEFUN (no_babel_redistribute_type, type = babel_proto_redistnum(argv[2]->arg); if (type < 0) { - vty_outln (vty, "Invalid type %s", argv[2]->arg); - return CMD_WARNING; + vty_out (vty, "Invalid type %s\n", argv[2]->arg); + return CMD_WARNING_CONFIG_FAILED; } zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT); + zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0, VRF_DEFAULT); /* perhaps should we remove xroutes having the same type... */ return CMD_SUCCESS; } @@ -277,9 +279,9 @@ DEFUN (debug_babel, } } - vty_outln (vty, "Invalid type %s", argv[2]->arg); + vty_out (vty, "Invalid type %s\n", argv[2]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* [Babel Command] */ @@ -307,9 +309,9 @@ DEFUN (no_debug_babel, } } - vty_outln (vty, "Invalid type %s", argv[3]->arg); + vty_out (vty, "Invalid type %s\n", argv[3]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } #endif /* NO_DEBUG */ @@ -324,7 +326,7 @@ debug_babel_config_write (struct vty * vty) if (debug == BABEL_DEBUG_ALL) { - vty_outln (vty, "debug babel all"); + vty_out (vty, "debug babel all\n"); lines++; } else @@ -335,12 +337,12 @@ debug_babel_config_write (struct vty * vty) && CHECK_FLAG (debug, debug_type[i].type) ) { - vty_outln (vty, "debug babel %s", debug_type[i].str); + vty_out (vty, "debug babel %s\n", debug_type[i].str); lines++; } if (lines) { - vty_outln (vty, "!"); + vty_out (vty, "!\n"); lines++; } return lines; @@ -384,13 +386,13 @@ zebra_config_write (struct vty *vty) { if (! zclient->enable) { - vty_outln (vty, "no router zebra"); + vty_out (vty, "no router zebra\n"); return 1; } else if (! vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_BABEL], VRF_DEFAULT)) { - vty_outln (vty, "router zebra"); - vty_outln (vty, " no redistribute babel"); + vty_out (vty, "router zebra\n"); + vty_out (vty, " no redistribute babel\n"); return 1; } return 0; diff --git a/babeld/babeld.c b/babeld/babeld.c index e17e00ca5..b2f8176aa 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -83,25 +83,25 @@ babel_config_write (struct vty *vty) if (!babel_routing_process) return lines; - vty_outln (vty, "router babel"); + vty_out (vty, "router babel\n"); if (diversity_kind != DIVERSITY_NONE) { - vty_outln (vty, " babel diversity"); + vty_out (vty, " babel diversity\n"); lines++; } if (diversity_factor != BABEL_DEFAULT_DIVERSITY_FACTOR) { - vty_outln (vty, " babel diversity-factor %d",diversity_factor); + vty_out (vty, " babel diversity-factor %d\n",diversity_factor); lines++; } if (resend_delay != BABEL_DEFAULT_RESEND_DELAY) { - vty_outln (vty, " babel resend-delay %u", resend_delay); + vty_out (vty, " babel resend-delay %u\n", resend_delay); lines++; } if (smoothing_half_life != BABEL_DEFAULT_SMOOTHING_HALF_LIFE) { - vty_outln (vty, " babel smoothing-half-life %u", + vty_out (vty, " babel smoothing-half-life %u\n", smoothing_half_life); lines++; } @@ -112,7 +112,7 @@ babel_config_write (struct vty *vty) if (i != zclient->redist_default && vrf_bitmap_check (zclient->redist[AFI_IP][i], VRF_DEFAULT)) { - vty_outln (vty, " redistribute %s", zebra_route_string(i)); + vty_out (vty, " redistribute %s\n", zebra_route_string(i)); lines++; } diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am index f096f0ff1..0ec5a778b 100644 --- a/bgpd/Makefile.am +++ b/bgpd/Makefile.am @@ -83,7 +83,7 @@ libbgp_a_SOURCES = \ bgp_damp.c bgp_table.c bgp_advertise.c bgp_vty.c bgp_mpath.c \ bgp_nht.c bgp_updgrp.c bgp_updgrp_packet.c bgp_updgrp_adv.c bgp_bfd.c \ bgp_encap_tlv.c $(BGP_VNC_RFAPI_SRC) bgp_attr_evpn.c \ - bgp_evpn.c bgp_evpn_vty.c bgp_vpn.c bgp_label.c + bgp_evpn.c bgp_evpn_vty.c bgp_vpn.c bgp_label.c bgp_rd.c noinst_HEADERS = \ bgp_memory.h \ @@ -95,7 +95,7 @@ noinst_HEADERS = \ bgp_advertise.h bgp_vty.h bgp_mpath.h bgp_nht.h \ bgp_updgrp.h bgp_bfd.h bgp_encap_tlv.h bgp_encap_types.h \ $(BGP_VNC_RFAPI_HD) bgp_attr_evpn.h bgp_evpn.h bgp_evpn_vty.h \ - bgp_vpn.h bgp_label.h + bgp_vpn.h bgp_label.h bgp_rd.h bgp_evpn_private.h bgpd_SOURCES = bgp_main.c bgpd_LDADD = libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ @LIBM@ diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index f304b3a1b..95257493b 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -2176,7 +2176,7 @@ aspath_show_all_iterator (struct hash_backet *backet, struct vty *vty) as = (struct aspath *) backet->data; vty_out (vty, "[%p:%u] (%ld) ", (void *)backet, backet->key, as->refcnt); - vty_outln (vty, "%s", as->str); + vty_out (vty, "%s\n", as->str); } /* Print all aspath and hash information. This function is used from diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 439469d61..a22a7a5b4 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -270,17 +270,17 @@ encap_free(struct bgp_attr_encap_subtlv *p) void bgp_attr_flush_encap(struct attr *attr) { - if (!attr || !attr->extra) + if (!attr) return; - if (attr->extra->encap_subtlvs) { - encap_free(attr->extra->encap_subtlvs); - attr->extra->encap_subtlvs = NULL; + if (attr->encap_subtlvs) { + encap_free(attr->encap_subtlvs); + attr->encap_subtlvs = NULL; } #if ENABLE_BGP_VNC - if (attr->extra->vnc_subtlvs) { - encap_free(attr->extra->vnc_subtlvs); - attr->extra->vnc_subtlvs = NULL; + if (attr->vnc_subtlvs) { + encap_free(attr->vnc_subtlvs); + attr->vnc_subtlvs = NULL; } #endif } @@ -424,15 +424,15 @@ encap_finish (void) } static bool -overlay_index_same(const struct attr_extra *ae1, const struct attr_extra *ae2) +overlay_index_same(const struct attr *a1, const struct attr *a2) { - if(!ae1 && ae2) + if(!a1 && a2) return false; - if(!ae2 && ae1) + if(!a2 && a1) return false; - if(!ae1 && !ae2) + if(!a1 && !a2) return true; - return !memcmp(&(ae1->evpn_overlay), &(ae2->evpn_overlay), sizeof(struct overlay_index)); + return !memcmp(&(a1->evpn_overlay), &(a2->evpn_overlay), sizeof(struct overlay_index)); } /* Unknown transit attribute. */ @@ -532,34 +532,6 @@ transit_finish (void) /* Attribute hash routines. */ static struct hash *attrhash; -static struct attr_extra * -bgp_attr_extra_new (void) -{ - struct attr_extra *extra; - extra = XCALLOC (MTYPE_ATTR_EXTRA, sizeof (struct attr_extra)); - extra->label_index = BGP_INVALID_LABEL_INDEX; - extra->label = MPLS_INVALID_LABEL; - return extra; -} - -void -bgp_attr_extra_free (struct attr *attr) -{ - if (attr->extra) - { - XFREE (MTYPE_ATTR_EXTRA, attr->extra); - attr->extra = NULL; - } -} - -struct attr_extra * -bgp_attr_extra_get (struct attr *attr) -{ - if (!attr->extra) - attr->extra = bgp_attr_extra_new(); - return attr->extra; -} - /* Shallow copy of an attribute * Though, not so shallow that it doesn't copy the contents * of the attr_extra pointed to by 'extra' @@ -567,33 +539,7 @@ bgp_attr_extra_get (struct attr *attr) void bgp_attr_dup (struct attr *new, struct attr *orig) { - struct attr_extra *extra = new->extra; - *new = *orig; - /* if caller provided attr_extra space, use it in any case. - * - * This is neccesary even if orig->extra equals NULL, because otherwise - * memory may be later allocated on the heap by bgp_attr_extra_get. - * - * That memory would eventually be leaked, because the caller must not - * call bgp_attr_extra_free if he provided attr_extra on the stack. - */ - if (extra) - { - new->extra = extra; - memset(new->extra, 0, sizeof(struct attr_extra)); - new->extra->label_index = BGP_INVALID_LABEL_INDEX; - new->extra->label = MPLS_INVALID_LABEL; - - if (orig->extra) { - *new->extra = *orig->extra; - } - } - else if (orig->extra) - { - new->extra = bgp_attr_extra_new(); - *new->extra = *orig->extra; - } } void @@ -605,21 +551,18 @@ bgp_attr_deep_dup (struct attr *new, struct attr *orig) if (orig->community) new->community = community_dup(orig->community); - if (orig->extra) - { - if (orig->extra->ecommunity) - new->extra->ecommunity = ecommunity_dup(orig->extra->ecommunity); - if (orig->extra->cluster) - new->extra->cluster = cluster_dup(orig->extra->cluster); - if (orig->extra->transit) - new->extra->transit = transit_dup(orig->extra->transit); - if (orig->extra->encap_subtlvs) - new->extra->encap_subtlvs = encap_tlv_dup(orig->extra->encap_subtlvs); + if (orig->ecommunity) + new->ecommunity = ecommunity_dup(orig->ecommunity); + if (orig->cluster) + new->cluster = cluster_dup(orig->cluster); + if (orig->transit) + new->transit = transit_dup(orig->transit); + if (orig->encap_subtlvs) + new->encap_subtlvs = encap_tlv_dup(orig->encap_subtlvs); #if ENABLE_BGP_VNC - if (orig->extra->vnc_subtlvs) - new->extra->vnc_subtlvs = encap_tlv_dup(orig->extra->vnc_subtlvs); + if (orig->vnc_subtlvs) + new->vnc_subtlvs = encap_tlv_dup(orig->vnc_subtlvs); #endif - } } void @@ -631,21 +574,18 @@ bgp_attr_deep_free (struct attr *attr) if (attr->community) community_free(attr->community); - if (attr->extra) - { - if (attr->extra->ecommunity) - ecommunity_free(&attr->extra->ecommunity); - if (attr->extra->cluster) - cluster_free(attr->extra->cluster); - if (attr->extra->transit) - transit_free(attr->extra->transit); - if (attr->extra->encap_subtlvs) - encap_free(attr->extra->encap_subtlvs); + if (attr->ecommunity) + ecommunity_free(&attr->ecommunity); + if (attr->cluster) + cluster_free(attr->cluster); + if (attr->transit) + transit_free(attr->transit); + if (attr->encap_subtlvs) + encap_free(attr->encap_subtlvs); #if ENABLE_BGP_VNC - if (attr->extra->vnc_subtlvs) - encap_free(attr->extra->vnc_subtlvs); + if (attr->vnc_subtlvs) + encap_free(attr->vnc_subtlvs); #endif - } } unsigned long int @@ -664,7 +604,6 @@ unsigned int attrhash_key_make (void *p) { const struct attr *attr = (struct attr *) p; - const struct attr_extra *extra = attr->extra; uint32_t key = 0; #define MIX(val) key = jhash_1word(val, key) @@ -678,43 +617,37 @@ attrhash_key_make (void *p) key += attr->med; key += attr->local_pref; - if (extra) - { - MIX(extra->aggregator_as); - MIX(extra->aggregator_addr.s_addr); - MIX(extra->weight); - MIX(extra->mp_nexthop_global_in.s_addr); - MIX(extra->originator_id.s_addr); - MIX(extra->tag); - MIX(extra->label); - MIX(extra->label_index); - } - + MIX(attr->aggregator_as); + MIX(attr->aggregator_addr.s_addr); + MIX(attr->weight); + MIX(attr->mp_nexthop_global_in.s_addr); + MIX(attr->originator_id.s_addr); + MIX(attr->tag); + MIX(attr->label); + MIX(attr->label_index); + if (attr->aspath) MIX(aspath_key_make (attr->aspath)); if (attr->community) MIX(community_hash_make (attr->community)); - - if (extra) - { - if (extra->lcommunity) - MIX(lcommunity_hash_make (extra->lcommunity)); - if (extra->ecommunity) - MIX(ecommunity_hash_make (extra->ecommunity)); - if (extra->cluster) - MIX(cluster_hash_key_make (extra->cluster)); - if (extra->transit) - MIX(transit_hash_key_make (extra->transit)); - if (extra->encap_subtlvs) - MIX(encap_hash_key_make (extra->encap_subtlvs)); + + if (attr->lcommunity) + MIX(lcommunity_hash_make (attr->lcommunity)); + if (attr->ecommunity) + MIX(ecommunity_hash_make (attr->ecommunity)); + if (attr->cluster) + MIX(cluster_hash_key_make (attr->cluster)); + if (attr->transit) + MIX(transit_hash_key_make (attr->transit)); + if (attr->encap_subtlvs) + MIX(encap_hash_key_make (attr->encap_subtlvs)); #if ENABLE_BGP_VNC - if (extra->vnc_subtlvs) - MIX(encap_hash_key_make (extra->vnc_subtlvs)); + if (attr->vnc_subtlvs) + MIX(encap_hash_key_make (attr->vnc_subtlvs)); #endif - MIX(extra->mp_nexthop_len); - key = jhash(extra->mp_nexthop_global.s6_addr, IPV6_MAX_BYTELEN, key); - key = jhash(extra->mp_nexthop_local.s6_addr, IPV6_MAX_BYTELEN, key); - } + MIX(attr->mp_nexthop_len); + key = jhash(attr->mp_nexthop_global.s6_addr, IPV6_MAX_BYTELEN, key); + key = jhash(attr->mp_nexthop_local.s6_addr, IPV6_MAX_BYTELEN, key); return key; } @@ -734,38 +667,30 @@ attrhash_cmp (const void *p1, const void *p2) && attr1->local_pref == attr2->local_pref && attr1->rmap_change_flags == attr2->rmap_change_flags) { - const struct attr_extra *ae1 = attr1->extra; - const struct attr_extra *ae2 = attr2->extra; - - if (ae1 && ae2 - && ae1->aggregator_as == ae2->aggregator_as - && ae1->aggregator_addr.s_addr == ae2->aggregator_addr.s_addr - && ae1->weight == ae2->weight - && ae1->tag == ae2->tag - && ae1->label_index == ae2->label_index - && ae1->mp_nexthop_len == ae2->mp_nexthop_len - && IPV6_ADDR_SAME (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global) - && IPV6_ADDR_SAME (&ae1->mp_nexthop_local, &ae2->mp_nexthop_local) - && IPV4_ADDR_SAME (&ae1->mp_nexthop_global_in, &ae2->mp_nexthop_global_in) - && ae1->ecommunity == ae2->ecommunity - && ae1->lcommunity == ae2->lcommunity - && ae1->cluster == ae2->cluster - && ae1->transit == ae2->transit - && (ae1->encap_tunneltype == ae2->encap_tunneltype) - && encap_same(ae1->encap_subtlvs, ae2->encap_subtlvs) + if (attr1->aggregator_as == attr2->aggregator_as + && attr1->aggregator_addr.s_addr == attr2->aggregator_addr.s_addr + && attr1->weight == attr2->weight + && attr1->tag == attr2->tag + && attr1->label_index == attr2->label_index + && attr1->mp_nexthop_len == attr2->mp_nexthop_len + && IPV6_ADDR_SAME (&attr1->mp_nexthop_global, &attr2->mp_nexthop_global) + && IPV6_ADDR_SAME (&attr1->mp_nexthop_local, &attr2->mp_nexthop_local) + && IPV4_ADDR_SAME (&attr1->mp_nexthop_global_in, &attr2->mp_nexthop_global_in) + && attr1->ecommunity == attr2->ecommunity + && attr1->lcommunity == attr2->lcommunity + && attr1->cluster == attr2->cluster + && attr1->transit == attr2->transit + && (attr1->encap_tunneltype == attr2->encap_tunneltype) + && encap_same(attr1->encap_subtlvs, attr2->encap_subtlvs) #if ENABLE_BGP_VNC - && encap_same(ae1->vnc_subtlvs, ae2->vnc_subtlvs) + && encap_same(attr1->vnc_subtlvs, attr2->vnc_subtlvs) #endif - && IPV4_ADDR_SAME (&ae1->originator_id, &ae2->originator_id) - && overlay_index_same(ae1, ae2)) + && IPV4_ADDR_SAME (&attr1->originator_id, &attr2->originator_id) + && overlay_index_same(attr1, attr2)) return 1; - else if (ae1 || ae2) - return 0; - /* neither attribute has extra attributes, so they're same */ - return 1; } - else - return 0; + + return 0; } static void @@ -780,7 +705,6 @@ attrhash_init (void) static void attr_vfree (void *attr) { - bgp_attr_extra_free ((struct attr *)attr); XFREE (MTYPE_ATTR, attr); } @@ -797,7 +721,7 @@ attr_show_all_iterator (struct hash_backet *backet, struct vty *vty) { struct attr *attr = backet->data; - vty_outln (vty, "attr[%ld] nexthop %s", attr->refcnt, + vty_out (vty, "attr[%ld] nexthop %s\n", attr->refcnt, inet_ntoa(attr->nexthop)); } @@ -813,24 +737,19 @@ attr_show_all (struct vty *vty) static void * bgp_attr_hash_alloc (void *p) { - const struct attr * val = (const struct attr *) p; + struct attr * val = (struct attr *) p; struct attr *attr; attr = XMALLOC (MTYPE_ATTR, sizeof (struct attr)); *attr = *val; - if (val->extra) - { - attr->extra = bgp_attr_extra_new (); - *attr->extra = *val->extra; - if (val->extra->encap_subtlvs) { - val->extra->encap_subtlvs = NULL; - } + if (val->encap_subtlvs) { + val->encap_subtlvs = NULL; + } #if ENABLE_BGP_VNC - if (val->extra->vnc_subtlvs) { - val->extra->vnc_subtlvs = NULL; - } + if (val->vnc_subtlvs) { + val->vnc_subtlvs = NULL; + } #endif - } attr->refcnt = 0; return attr; } @@ -856,56 +775,51 @@ bgp_attr_intern (struct attr *attr) else attr->community->refcnt++; } - if (attr->extra) + + if (attr->ecommunity) { - struct attr_extra *attre = attr->extra; - - if (attre->ecommunity) - { - if (! attre->ecommunity->refcnt) - attre->ecommunity = ecommunity_intern (attre->ecommunity); - else - attre->ecommunity->refcnt++; - - } - if (attre->lcommunity) - { - if (! attre->lcommunity->refcnt) - attre->lcommunity = lcommunity_intern (attre->lcommunity); - else - attre->lcommunity->refcnt++; - } - if (attre->cluster) - { - if (! attre->cluster->refcnt) - attre->cluster = cluster_intern (attre->cluster); - else - attre->cluster->refcnt++; - } - if (attre->transit) - { - if (! attre->transit->refcnt) - attre->transit = transit_intern (attre->transit); - else - attre->transit->refcnt++; - } - if (attre->encap_subtlvs) - { - if (! attre->encap_subtlvs->refcnt) - attre->encap_subtlvs = encap_intern (attre->encap_subtlvs, ENCAP_SUBTLV_TYPE); - else - attre->encap_subtlvs->refcnt++; - } + if (! attr->ecommunity->refcnt) + attr->ecommunity = ecommunity_intern (attr->ecommunity); + else + attr->ecommunity->refcnt++; + } + if (attr->lcommunity) + { + if (! attr->lcommunity->refcnt) + attr->lcommunity = lcommunity_intern (attr->lcommunity); + else + attr->lcommunity->refcnt++; + } + if (attr->cluster) + { + if (! attr->cluster->refcnt) + attr->cluster = cluster_intern (attr->cluster); + else + attr->cluster->refcnt++; + } + if (attr->transit) + { + if (! attr->transit->refcnt) + attr->transit = transit_intern (attr->transit); + else + attr->transit->refcnt++; + } + if (attr->encap_subtlvs) + { + if (! attr->encap_subtlvs->refcnt) + attr->encap_subtlvs = encap_intern (attr->encap_subtlvs, ENCAP_SUBTLV_TYPE); + else + attr->encap_subtlvs->refcnt++; + } #if ENABLE_BGP_VNC - if (attre->vnc_subtlvs) - { - if (! attre->vnc_subtlvs->refcnt) - attre->vnc_subtlvs = encap_intern (attre->vnc_subtlvs, VNC_SUBTLV_TYPE); - else - attre->vnc_subtlvs->refcnt++; - } -#endif + if (attr->vnc_subtlvs) + { + if (! attr->vnc_subtlvs->refcnt) + attr->vnc_subtlvs = encap_intern (attr->vnc_subtlvs, VNC_SUBTLV_TYPE); + else + attr->vnc_subtlvs->refcnt++; } +#endif find = (struct attr *) hash_get (attrhash, attr, bgp_attr_hash_alloc); find->refcnt++; @@ -932,26 +846,23 @@ bgp_attr_refcount (struct attr *attr) if (attr->community) attr->community->refcnt++; - if (attr->extra) - { - struct attr_extra *attre = attr->extra; - if (attre->ecommunity) - attre->ecommunity->refcnt++; + if (attr->ecommunity) + attr->ecommunity->refcnt++; - if (attre->cluster) - attre->cluster->refcnt++; + if (attr->cluster) + attr->cluster->refcnt++; - if (attre->transit) - attre->transit->refcnt++; + if (attr->transit) + attr->transit->refcnt++; - if (attre->encap_subtlvs) - attre->encap_subtlvs->refcnt++; + if (attr->encap_subtlvs) + attr->encap_subtlvs->refcnt++; #if ENABLE_BGP_VNC - if (attre->vnc_subtlvs) - attre->vnc_subtlvs->refcnt++; + if (attr->vnc_subtlvs) + attr->vnc_subtlvs->refcnt++; #endif - } + attr->refcnt++; return attr; } @@ -961,18 +872,17 @@ struct attr * bgp_attr_default_set (struct attr *attr, u_char origin) { memset (attr, 0, sizeof (struct attr)); - bgp_attr_extra_get (attr); attr->origin = origin; attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN); attr->aspath = aspath_empty (); attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH); - attr->extra->weight = BGP_ATTR_DEFAULT_WEIGHT; - attr->extra->tag = 0; - attr->extra->label_index = BGP_INVALID_LABEL_INDEX; - attr->extra->label = MPLS_INVALID_LABEL; + attr->weight = BGP_ATTR_DEFAULT_WEIGHT; + attr->tag = 0; + attr->label_index = BGP_INVALID_LABEL_INDEX; + attr->label = MPLS_INVALID_LABEL; attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); - attr->extra->mp_nexthop_len = IPV6_MAX_BYTELEN; + attr->mp_nexthop_len = IPV6_MAX_BYTELEN; return attr; } @@ -986,11 +896,8 @@ bgp_attr_aggregate_intern (struct bgp *bgp, u_char origin, { struct attr attr; struct attr *new; - struct attr_extra attre; memset (&attr, 0, sizeof (struct attr)); - memset (&attre, 0, sizeof (struct attr_extra)); - attr.extra = &attre; /* Origin attribute. */ attr.origin = origin; @@ -1012,18 +919,20 @@ bgp_attr_aggregate_intern (struct bgp *bgp, u_char origin, attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES); } - attre.label_index = BGP_INVALID_LABEL_INDEX; - attre.label = MPLS_INVALID_LABEL; - attre.weight = BGP_ATTR_DEFAULT_WEIGHT; - attre.mp_nexthop_len = IPV6_MAX_BYTELEN; + attr.label_index = BGP_INVALID_LABEL_INDEX; + attr.label = MPLS_INVALID_LABEL; + attr.weight = BGP_ATTR_DEFAULT_WEIGHT; + attr.mp_nexthop_len = IPV6_MAX_BYTELEN; if (! as_set || atomic_aggregate) attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR); if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)) - attre.aggregator_as = bgp->confed_id; + attr.aggregator_as = bgp->confed_id; else - attre.aggregator_as = bgp->as; - attre.aggregator_addr = bgp->router_id; + attr.aggregator_as = bgp->as; + attr.aggregator_addr = bgp->router_id; + attr.label_index = BGP_INVALID_LABEL_INDEX; + attr.label = MPLS_INVALID_LABEL; new = bgp_attr_intern (&attr); @@ -1044,31 +953,28 @@ bgp_attr_unintern_sub (struct attr *attr) community_unintern (&attr->community); UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)); - if (attr->extra) - { - if (attr->extra->ecommunity) - ecommunity_unintern (&attr->extra->ecommunity); - UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES)); + if (attr->ecommunity) + ecommunity_unintern (&attr->ecommunity); + UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES)); - if (attr->extra->lcommunity) - lcommunity_unintern (&attr->extra->lcommunity); - UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES)); + if (attr->lcommunity) + lcommunity_unintern (&attr->lcommunity); + UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES)); - if (attr->extra->cluster) - cluster_unintern (attr->extra->cluster); - UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)); - - if (attr->extra->transit) - transit_unintern (attr->extra->transit); + if (attr->cluster) + cluster_unintern (attr->cluster); + UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)); - if (attr->extra->encap_subtlvs) - encap_unintern (&attr->extra->encap_subtlvs, ENCAP_SUBTLV_TYPE); + if (attr->transit) + transit_unintern (attr->transit); + + if (attr->encap_subtlvs) + encap_unintern (&attr->encap_subtlvs, ENCAP_SUBTLV_TYPE); #if ENABLE_BGP_VNC - if (attr->extra->vnc_subtlvs) - encap_unintern (&attr->extra->vnc_subtlvs, VNC_SUBTLV_TYPE); + if (attr->vnc_subtlvs) + encap_unintern (&attr->vnc_subtlvs, VNC_SUBTLV_TYPE); #endif - } } /* Free bgp attribute and aspath. */ @@ -1078,25 +984,17 @@ bgp_attr_unintern (struct attr **pattr) struct attr *attr = *pattr; struct attr *ret; struct attr tmp; - struct attr_extra tmp_extra; - + /* Decrement attribute reference. */ attr->refcnt--; - + tmp = *attr; - if (attr->extra) - { - tmp.extra = &tmp_extra; - memcpy (tmp.extra, attr->extra, sizeof (struct attr_extra)); - } - /* If reference becomes zero then free attribute object. */ if (attr->refcnt == 0) { ret = hash_release (attrhash, attr); assert (ret != NULL); - bgp_attr_extra_free (attr); XFREE (MTYPE_ATTR, attr); *pattr = NULL; } @@ -1117,37 +1015,33 @@ bgp_attr_flush (struct attr *attr) community_free (attr->community); attr->community = NULL; } - if (attr->extra) - { - struct attr_extra *attre = attr->extra; - if (attre->ecommunity && ! attre->ecommunity->refcnt) - ecommunity_free (&attre->ecommunity); - if (attre->lcommunity && ! attre->lcommunity->refcnt) - lcommunity_free (&attre->lcommunity); - if (attre->cluster && ! attre->cluster->refcnt) - { - cluster_free (attre->cluster); - attre->cluster = NULL; - } - if (attre->transit && ! attre->transit->refcnt) - { - transit_free (attre->transit); - attre->transit = NULL; - } - if (attre->encap_subtlvs && ! attre->encap_subtlvs->refcnt) - { - encap_free(attre->encap_subtlvs); - attre->encap_subtlvs = NULL; - } + if (attr->ecommunity && ! attr->ecommunity->refcnt) + ecommunity_free (&attr->ecommunity); + if (attr->lcommunity && ! attr->lcommunity->refcnt) + lcommunity_free (&attr->lcommunity); + if (attr->cluster && ! attr->cluster->refcnt) + { + cluster_free (attr->cluster); + attr->cluster = NULL; + } + if (attr->transit && ! attr->transit->refcnt) + { + transit_free (attr->transit); + attr->transit = NULL; + } + if (attr->encap_subtlvs && ! attr->encap_subtlvs->refcnt) + { + encap_free(attr->encap_subtlvs); + attr->encap_subtlvs = NULL; + } #if ENABLE_BGP_VNC - if (attre->vnc_subtlvs && ! attre->vnc_subtlvs->refcnt) - { - encap_free(attre->vnc_subtlvs); - attre->vnc_subtlvs = NULL; - } -#endif + if (attr->vnc_subtlvs && ! attr->vnc_subtlvs->refcnt) + { + encap_free(attr->vnc_subtlvs); + attr->vnc_subtlvs = NULL; } +#endif } /* Implement draft-scudder-idr-optional-transitive behaviour and @@ -1630,7 +1524,6 @@ bgp_attr_aggregator (struct bgp_attr_parser_args *args) const bgp_size_t length = args->length; int wantedlen = 6; - struct attr_extra *attre = bgp_attr_extra_get (attr); /* peer with AS4 will send 4 Byte AS, peer without will send 2 Byte */ if (CHECK_FLAG (peer->cap, PEER_CAP_AS4_RCV)) @@ -1645,10 +1538,10 @@ bgp_attr_aggregator (struct bgp_attr_parser_args *args) } if ( CHECK_FLAG (peer->cap, PEER_CAP_AS4_RCV ) ) - attre->aggregator_as = stream_getl (peer->ibuf); + attr->aggregator_as = stream_getl (peer->ibuf); else - attre->aggregator_as = stream_getw (peer->ibuf); - attre->aggregator_addr.s_addr = stream_get_ipv4 (peer->ibuf); + attr->aggregator_as = stream_getw (peer->ibuf); + attr->aggregator_addr.s_addr = stream_get_ipv4 (peer->ibuf); /* Set atomic aggregate flag. */ attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR); @@ -1692,7 +1585,6 @@ bgp_attr_munge_as4_attrs (struct peer *const peer, { int ignore_as4_path = 0; struct aspath *newpath; - struct attr_extra *attre = attr->extra; if (!attr->aspath) { @@ -1732,8 +1624,6 @@ bgp_attr_munge_as4_attrs (struct peer *const peer, { if (attr->flag & (ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR) ) ) { - assert (attre); - /* received both. * if the as_number in aggregator is not AS_TRANS, * then AS4_AGGREGATOR and AS4_PATH shall be ignored @@ -1746,7 +1636,7 @@ bgp_attr_munge_as4_attrs (struct peer *const peer, * Aggregating node and the AS_PATH is to be * constructed "as in all other cases" */ - if (attre->aggregator_as != BGP_AS_TRANS) + if (attr->aggregator_as != BGP_AS_TRANS) { /* ignore */ if ( BGP_DEBUG(as4, AS4)) @@ -1759,8 +1649,8 @@ bgp_attr_munge_as4_attrs (struct peer *const peer, else { /* "New_aggregator shall be taken as aggregator" */ - attre->aggregator_as = as4_aggregator; - attre->aggregator_addr.s_addr = as4_aggregator_addr->s_addr; + attr->aggregator_as = as4_aggregator; + attr->aggregator_addr.s_addr = as4_aggregator_addr->s_addr; } } else @@ -1774,7 +1664,7 @@ bgp_attr_munge_as4_attrs (struct peer *const peer, zlog_debug ("[AS4] %s BGP not AS4 capable peer send" " AS4_AGGREGATOR but no AGGREGATOR, will take" " it as if AGGREGATOR with AS_TRANS had been there", peer->host); - (attre = bgp_attr_extra_get (attr))->aggregator_as = as4_aggregator; + attr->aggregator_as = as4_aggregator; /* sweep it under the carpet and simulate a "good" AGGREGATOR */ attr->flag |= (ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)); } @@ -1838,8 +1728,7 @@ bgp_attr_originator_id (struct bgp_attr_parser_args *args) args->total); } - (bgp_attr_extra_get (attr))->originator_id.s_addr - = stream_get_ipv4 (peer->ibuf); + attr->originator_id.s_addr = stream_get_ipv4 (peer->ibuf); attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID); @@ -1863,8 +1752,7 @@ bgp_attr_cluster_list (struct bgp_attr_parser_args *args) args->total); } - (bgp_attr_extra_get (attr))->cluster - = cluster_parse ((struct in_addr *)stream_pnt (peer->ibuf), length); + attr->cluster = cluster_parse ((struct in_addr *)stream_pnt (peer->ibuf), length); /* XXX: Fix cluster_parse to use stream API and then remove this */ stream_forward_getp (peer->ibuf, length); @@ -1888,7 +1776,6 @@ bgp_mp_reach_parse (struct bgp_attr_parser_args *args, struct peer *const peer = args->peer; struct attr *const attr = args->attr; const bgp_size_t length = args->length; - struct attr_extra *attre = bgp_attr_extra_get(attr); /* Set end of packet. */ s = BGP_INPUT(peer); @@ -1921,53 +1808,53 @@ bgp_mp_reach_parse (struct bgp_attr_parser_args *args, } /* Get nexthop length. */ - attre->mp_nexthop_len = stream_getc (s); + attr->mp_nexthop_len = stream_getc (s); - if (LEN_LEFT < attre->mp_nexthop_len) + if (LEN_LEFT < attr->mp_nexthop_len) { zlog_info ("%s: %s, MP nexthop length, %u, goes past end of attribute", - __func__, peer->host, attre->mp_nexthop_len); + __func__, peer->host, attr->mp_nexthop_len); return BGP_ATTR_PARSE_ERROR_NOTIFYPLS; } /* Nexthop length check. */ - switch (attre->mp_nexthop_len) + switch (attr->mp_nexthop_len) { case BGP_ATTR_NHLEN_IPV4: - stream_get (&attre->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN); + stream_get (&attr->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN); /* Probably needed for RFC 2283 */ if (attr->nexthop.s_addr == 0) - memcpy(&attr->nexthop.s_addr, &attre->mp_nexthop_global_in, IPV4_MAX_BYTELEN); + memcpy(&attr->nexthop.s_addr, &attr->mp_nexthop_global_in, IPV4_MAX_BYTELEN); break; case BGP_ATTR_NHLEN_VPNV4: stream_getl (s); /* RD high */ stream_getl (s); /* RD low */ - stream_get (&attre->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN); + stream_get (&attr->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN); break; case BGP_ATTR_NHLEN_IPV6_GLOBAL: case BGP_ATTR_NHLEN_VPNV6_GLOBAL: - if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL) + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL) { stream_getl (s); /* RD high */ stream_getl (s); /* RD low */ } - stream_get (&attre->mp_nexthop_global, s, IPV6_MAX_BYTELEN); + stream_get (&attr->mp_nexthop_global, s, IPV6_MAX_BYTELEN); break; case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: case BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL: - if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) { stream_getl (s); /* RD high */ stream_getl (s); /* RD low */ } - stream_get (&attre->mp_nexthop_global, s, IPV6_MAX_BYTELEN); - if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) + stream_get (&attr->mp_nexthop_global, s, IPV6_MAX_BYTELEN); + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) { stream_getl (s); /* RD high */ stream_getl (s); /* RD low */ } - stream_get (&attre->mp_nexthop_local, s, IPV6_MAX_BYTELEN); - if (! IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local)) + stream_get (&attr->mp_nexthop_local, s, IPV6_MAX_BYTELEN); + if (! IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local)) { char buf1[INET6_ADDRSTRLEN]; char buf2[INET6_ADDRSTRLEN]; @@ -1975,17 +1862,17 @@ bgp_mp_reach_parse (struct bgp_attr_parser_args *args, if (bgp_debug_update(peer, NULL, NULL, 1)) zlog_debug ("%s rcvd nexthops %s, %s -- ignoring non-LL value", peer->host, - inet_ntop (AF_INET6, &attre->mp_nexthop_global, + inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf1, INET6_ADDRSTRLEN), - inet_ntop (AF_INET6, &attre->mp_nexthop_local, + inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf2, INET6_ADDRSTRLEN)); - attre->mp_nexthop_len = IPV6_MAX_BYTELEN; + attr->mp_nexthop_len = IPV6_MAX_BYTELEN; } break; default: zlog_info ("%s: (%s) Wrong multiprotocol next hop length: %d", - __func__, peer->host, attre->mp_nexthop_len); + __func__, peer->host, attr->mp_nexthop_len); return BGP_ATTR_PARSE_ERROR_NOTIFYPLS; } @@ -2087,18 +1974,16 @@ bgp_attr_large_community (struct bgp_attr_parser_args *args) */ if (length == 0) { - if (attr->extra) - attr->extra->lcommunity = NULL; + attr->lcommunity = NULL; /* Empty extcomm doesn't seem to be invalid per se */ return BGP_ATTR_PARSE_PROCEED; } - (bgp_attr_extra_get (attr))->lcommunity = - lcommunity_parse ((u_int8_t *)stream_pnt (peer->ibuf), length); + attr->lcommunity = lcommunity_parse ((u_int8_t *)stream_pnt (peer->ibuf), length); /* XXX: fix ecommunity_parse to use stream API */ stream_forward_getp (peer->ibuf, length); - if (attr->extra && !attr->extra->lcommunity) + if (!attr->lcommunity) return bgp_attr_malformed (args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, args->total); @@ -2115,27 +2000,30 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) struct peer *const peer = args->peer; struct attr *const attr = args->attr; const bgp_size_t length = args->length; + u_char sticky = 0; if (length == 0) { - if (attr->extra) - attr->extra->ecommunity = NULL; + attr->ecommunity = NULL; /* Empty extcomm doesn't seem to be invalid per se */ return BGP_ATTR_PARSE_PROCEED; } - (bgp_attr_extra_get (attr))->ecommunity = - ecommunity_parse ((u_int8_t *)stream_pnt (peer->ibuf), length); + attr->ecommunity = ecommunity_parse ((u_int8_t *)stream_pnt (peer->ibuf), length); /* XXX: fix ecommunity_parse to use stream API */ stream_forward_getp (peer->ibuf, length); - if (attr->extra && !attr->extra->ecommunity) + if (!attr->ecommunity) return bgp_attr_malformed (args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, args->total); attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES); + /* Extract MAC mobility sequence number, if any. */ + attr->mm_seqnum = bgp_attr_mac_mobility_seqnum (attr, &sticky); + attr->sticky = sticky; + return BGP_ATTR_PARSE_PROCEED; } @@ -2150,7 +2038,6 @@ bgp_attr_encap( u_char *startp) { bgp_size_t total; - struct attr_extra *attre = NULL; struct bgp_attr_encap_subtlv *stlv_last = NULL; uint16_t tunneltype = 0; @@ -2225,37 +2112,30 @@ bgp_attr_encap( length -= sublength; /* attach tlv to encap chain */ - if (!attre) { - attre = bgp_attr_extra_get(attr); - if (BGP_ATTR_ENCAP == type) { - for (stlv_last = attre->encap_subtlvs; stlv_last && stlv_last->next; - stlv_last = stlv_last->next); - if (stlv_last) { - stlv_last->next = tlv; - } else { - attre->encap_subtlvs = tlv; - } + if (BGP_ATTR_ENCAP == type) { + for (stlv_last = attr->encap_subtlvs; stlv_last && stlv_last->next; + stlv_last = stlv_last->next); + if (stlv_last) { + stlv_last->next = tlv; + } else { + attr->encap_subtlvs = tlv; + } #if ENABLE_BGP_VNC - } else { - for (stlv_last = attre->vnc_subtlvs; stlv_last && stlv_last->next; - stlv_last = stlv_last->next); - if (stlv_last) { - stlv_last->next = tlv; - } else { - attre->vnc_subtlvs = tlv; - } -#endif - } } else { - stlv_last->next = tlv; + for (stlv_last = attr->vnc_subtlvs; stlv_last && stlv_last->next; + stlv_last = stlv_last->next); + if (stlv_last) { + stlv_last->next = tlv; + } else { + attr->vnc_subtlvs = tlv; + } +#endif } - stlv_last = tlv; + stlv_last->next = tlv; } if (BGP_ATTR_ENCAP == type) { - if (!attre) - attre = bgp_attr_extra_get(attr); - attre->encap_tunneltype = tunneltype; + attr->encap_tunneltype = tunneltype; } if (length) { @@ -2314,14 +2194,14 @@ bgp_attr_prefix_sid (struct bgp_attr_parser_args *args, struct bgp_nlri *mp_upda args->total); /* Store label index; subsequently, we'll check on address-family */ - (bgp_attr_extra_get (attr))->label_index = label_index; + attr->label_index = label_index; /* * Ignore the Label index attribute unless received for labeled-unicast * SAFI. */ if (!mp_update->length || mp_update->safi != SAFI_LABELED_UNICAST) - attr->extra->label_index = BGP_INVALID_LABEL_INDEX; + attr->label_index = BGP_INVALID_LABEL_INDEX; } /* Placeholder code for the IPv6 SID type */ @@ -2377,7 +2257,6 @@ bgp_attr_unknown (struct bgp_attr_parser_args *args) { bgp_size_t total = args->total; struct transit *transit; - struct attr_extra *attre; struct peer *const peer = args->peer; struct attr *const attr = args->attr; u_char *const startp = args->startp; @@ -2415,10 +2294,10 @@ bgp_attr_unknown (struct bgp_attr_parser_args *args) SET_FLAG (*startp, BGP_ATTR_FLAG_PARTIAL); /* Store transitive attribute to the end of attr->transit. */ - if (! ((attre = bgp_attr_extra_get(attr))->transit) ) - attre->transit = XCALLOC (MTYPE_TRANSIT, sizeof (struct transit)); + if (!attr->transit) + attr->transit = XCALLOC (MTYPE_TRANSIT, sizeof (struct transit)); - transit = attre->transit; + transit = attr->transit; if (transit->val) transit->val = XREALLOC (MTYPE_TRANSIT_VAL, transit->val, @@ -2800,18 +2679,15 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size, if (ret != BGP_ATTR_PARSE_PROCEED) return ret; } - if (attr->extra) - { - /* Finally intern unknown attribute. */ - if (attr->extra->transit) - attr->extra->transit = transit_intern (attr->extra->transit); - if (attr->extra->encap_subtlvs) - attr->extra->encap_subtlvs = encap_intern (attr->extra->encap_subtlvs, ENCAP_SUBTLV_TYPE); + /* Finally intern unknown attribute. */ + if (attr->transit) + attr->transit = transit_intern (attr->transit); + if (attr->encap_subtlvs) + attr->encap_subtlvs = encap_intern (attr->encap_subtlvs, ENCAP_SUBTLV_TYPE); #if ENABLE_BGP_VNC - if (attr->extra->vnc_subtlvs) - attr->extra->vnc_subtlvs = encap_intern (attr->extra->vnc_subtlvs, VNC_SUBTLV_TYPE); + if (attr->vnc_subtlvs) + attr->vnc_subtlvs = encap_intern (attr->vnc_subtlvs, VNC_SUBTLV_TYPE); #endif - } return BGP_ATTR_PARSE_PROCEED; } @@ -2841,16 +2717,14 @@ bgp_packet_mpattr_start (struct stream *s, struct peer *peer, stream_putc (s, pkt_safi); /* SAFI */ /* Nexthop AFI */ - if (peer_cap_enhe(peer, afi, safi)) { - nh_afi = AFI_IP6; - } else { - if (afi == AFI_L2VPN) - nh_afi = AFI_L2VPN; - else if (safi == SAFI_LABELED_UNICAST) - nh_afi = afi; - else - nh_afi = BGP_NEXTHOP_AFI_FROM_NHLEN(attr->extra->mp_nexthop_len); - } + if (afi == AFI_IP && safi == SAFI_UNICAST) + { + nh_afi = peer_cap_enhe (peer, afi, safi) ? AFI_IP6 : AFI_IP; + } + else if (safi == SAFI_LABELED_UNICAST) + nh_afi = afi; + else + nh_afi = BGP_NEXTHOP_AFI_FROM_NHLEN(attr->mp_nexthop_len); /* Nexthop */ bpacket_attr_vec_arr_set_vec (vecarr, BGP_ATTR_VEC_NH, s, attr); @@ -2869,11 +2743,12 @@ bgp_packet_mpattr_start (struct stream *s, struct peer *peer, stream_putc (s, 12); stream_putl (s, 0); /* RD = 0, per RFC */ stream_putl (s, 0); - stream_put (s, &attr->extra->mp_nexthop_global_in, 4); + stream_put (s, &attr->mp_nexthop_global_in, 4); break; case SAFI_ENCAP: + case SAFI_EVPN: stream_putc (s, 4); - stream_put (s, &attr->extra->mp_nexthop_global_in, 4); + stream_put (s, &attr->mp_nexthop_global_in, 4); break; default: break; @@ -2885,85 +2760,47 @@ bgp_packet_mpattr_start (struct stream *s, struct peer *peer, case SAFI_UNICAST: case SAFI_MULTICAST: case SAFI_LABELED_UNICAST: + case SAFI_EVPN: { - struct attr_extra *attre = attr->extra; - - assert (attr->extra); - - if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { stream_putc (s, BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL); - stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN); - stream_put (s, &attre->mp_nexthop_local, IPV6_MAX_BYTELEN); + stream_put (s, &attr->mp_nexthop_global, IPV6_MAX_BYTELEN); + stream_put (s, &attr->mp_nexthop_local, IPV6_MAX_BYTELEN); } else { stream_putc (s, IPV6_MAX_BYTELEN); - stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN); + stream_put (s, &attr->mp_nexthop_global, IPV6_MAX_BYTELEN); } } break; case SAFI_MPLS_VPN: { - struct attr_extra *attre = attr->extra; - - assert (attr->extra); - if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) { + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) { stream_putc (s, 24); stream_putl (s, 0); /* RD = 0, per RFC */ stream_putl (s, 0); - stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN); - } else if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { + stream_put (s, &attr->mp_nexthop_global, IPV6_MAX_BYTELEN); + } else if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { stream_putc (s, 48); stream_putl (s, 0); /* RD = 0, per RFC */ stream_putl (s, 0); - stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN); + stream_put (s, &attr->mp_nexthop_global, IPV6_MAX_BYTELEN); stream_putl (s, 0); /* RD = 0, per RFC */ stream_putl (s, 0); - stream_put (s, &attre->mp_nexthop_local, IPV6_MAX_BYTELEN); + stream_put (s, &attr->mp_nexthop_local, IPV6_MAX_BYTELEN); } } break; case SAFI_ENCAP: - assert (attr->extra); stream_putc (s, IPV6_MAX_BYTELEN); - stream_put (s, &attr->extra->mp_nexthop_global, IPV6_MAX_BYTELEN); + stream_put (s, &attr->mp_nexthop_global, IPV6_MAX_BYTELEN); break; default: break; } break; - case AFI_L2VPN: - switch (safi) - { - case SAFI_EVPN: - if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV4) - { - stream_putc (s, 12); - stream_putl (s, 0); /* RD = 0, per RFC */ - stream_putl (s, 0); - stream_put (s, &attr->extra->mp_nexthop_global_in, 4); - } - else if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) - { - stream_putc (s, 24); - stream_putl (s, 0); /* RD = 0, per RFC */ - stream_putl (s, 0); - stream_put (s, &attr->extra->mp_nexthop_global, IPV6_MAX_BYTELEN); - } - else if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) - { - stream_putc (s, 48); - stream_putl (s, 0); /* RD = 0, per RFC */ - stream_putl (s, 0); - stream_put (s, &attr->extra->mp_nexthop_global, IPV6_MAX_BYTELEN); - stream_putl (s, 0); /* RD = 0, per RFC */ - stream_putl (s, 0); - stream_put (s, &attr->extra->mp_nexthop_local, IPV6_MAX_BYTELEN); - } - break; - break; - default: - break; - } default: + zlog_err ("Bad nexthop when sening to %s, AFI %u SAFI %u nhlen %d", + peer->host, afi, safi, attr->mp_nexthop_len); break; } @@ -2988,9 +2825,11 @@ bgp_packet_mpattr_prefix (struct stream *s, afi_t afi, safi_t safi, stream_put (s, prd->val, 8); stream_put (s, &p->u.prefix, PSIZE (p->prefixlen)); } - else if (safi == SAFI_EVPN) + else if (afi == AFI_L2VPN && safi == SAFI_EVPN) { - bgp_packet_mpattr_route_type_5(s, p, prd, label, attr); + /* EVPN prefix - contents depend on type */ + bgp_evpn_encode_prefix (s, p, prd, label, attr, + addpath_encode, addpath_tx_id); } else if (safi == SAFI_LABELED_UNICAST) { @@ -3007,6 +2846,8 @@ bgp_packet_mpattr_prefix_size (afi_t afi, safi_t safi, struct prefix *p) int size = PSIZE (p->prefixlen); if (safi == SAFI_MPLS_VPN) size += 88; + else if (afi == AFI_L2VPN && safi == SAFI_EVPN) + size += 232; // TODO: Maximum possible for type-2, type-3 and type-5 return size; } @@ -3029,16 +2870,16 @@ bgp_packet_mpattr_tea( struct bgp_attr_encap_subtlv *st; const char *attrname; - if (!attr || !attr->extra || + if (!attr || (attrtype == BGP_ATTR_ENCAP && - (!attr->extra->encap_tunneltype || - attr->extra->encap_tunneltype == BGP_ENCAP_TYPE_MPLS))) + (!attr->encap_tunneltype || + attr->encap_tunneltype == BGP_ENCAP_TYPE_MPLS))) return; switch (attrtype) { case BGP_ATTR_ENCAP: attrname = "Tunnel Encap"; - subtlvs = attr->extra->encap_subtlvs; + subtlvs = attr->encap_subtlvs; if (subtlvs == NULL) /* nothing to do */ return; /* @@ -3054,7 +2895,7 @@ bgp_packet_mpattr_tea( #if ENABLE_BGP_VNC case BGP_ATTR_VNC: attrname = "VNC"; - subtlvs = attr->extra->vnc_subtlvs; + subtlvs = attr->vnc_subtlvs; if (subtlvs == NULL) /* nothing to do */ return; attrlenfield = 0; /* no outer T + L */ @@ -3093,7 +2934,7 @@ bgp_packet_mpattr_tea( if (attrtype == BGP_ATTR_ENCAP) { /* write outer T+L */ - stream_putw(s, attr->extra->encap_tunneltype); + stream_putw(s, attr->encap_tunneltype); stream_putw(s, attrlenfield - 4); } @@ -3282,8 +3123,6 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, /* Aggregator. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)) { - assert (attr->extra); - /* Common to BGP_ATTR_AGGREGATOR, regardless of ASN size */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_AGGREGATOR); @@ -3292,7 +3131,7 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, { /* AS4 capable peer */ stream_putc (s, 8); - stream_putl (s, attr->extra->aggregator_as); + stream_putl (s, attr->aggregator_as); } else { @@ -3300,7 +3139,7 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, stream_putc (s, 6); /* Is ASN representable in 2-bytes? Or must AS_TRANS be used? */ - if ( attr->extra->aggregator_as > 65535 ) + if ( attr->aggregator_as > 65535 ) { stream_putw (s, BGP_AS_TRANS); @@ -3311,9 +3150,9 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, send_as4_aggregator = 1; } else - stream_putw (s, (u_int16_t) attr->extra->aggregator_as); + stream_putw (s, (u_int16_t) attr->aggregator_as); } - stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr); + stream_put_ipv4 (s, attr->aggregator_addr.s_addr); } /* Community attribute. */ @@ -3338,23 +3177,22 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, /* * Large Community attribute. */ - if (attr->extra && - CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY) + if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY) && (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES))) { - if (attr->extra->lcommunity->size * 12 > 255) + if (attr->lcommunity->size * 12 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES); - stream_putw (s, attr->extra->lcommunity->size * 12); + stream_putw (s, attr->lcommunity->size * 12); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES); - stream_putc (s, attr->extra->lcommunity->size * 12); + stream_putc (s, attr->lcommunity->size * 12); } - stream_put (s, attr->extra->lcommunity->val, attr->extra->lcommunity->size * 12); + stream_put (s, attr->lcommunity->val, attr->lcommunity->size * 12); } /* Route Reflector. */ @@ -3368,7 +3206,7 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, stream_putc (s, 4); if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) - stream_put_in_addr (s, &attr->extra->originator_id); + stream_put_in_addr (s, &attr->originator_id); else stream_put_in_addr (s, &from->remote_id); @@ -3376,16 +3214,16 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_CLUSTER_LIST); - if (attr->extra && attr->extra->cluster) + if (attr->cluster) { - stream_putc (s, attr->extra->cluster->length + 4); + stream_putc (s, attr->cluster->length + 4); /* If this peer configuration's parent BGP has cluster_id. */ if (bgp->config & BGP_CONFIG_CLUSTER_ID) stream_put_in_addr (s, &bgp->cluster_id); else stream_put_in_addr (s, &bgp->router_id); - stream_put (s, attr->extra->cluster->list, - attr->extra->cluster->length); + stream_put (s, attr->cluster->list, + attr->cluster->length); } else { @@ -3402,26 +3240,22 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) && (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES))) { - struct attr_extra *attre = attr->extra; - - assert (attre); - if (peer->sort == BGP_PEER_IBGP || peer->sort == BGP_PEER_CONFED) { - if (attre->ecommunity->size * 8 > 255) + if (attr->ecommunity->size * 8 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); - stream_putw (s, attre->ecommunity->size * 8); + stream_putw (s, attr->ecommunity->size * 8); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); - stream_putc (s, attre->ecommunity->size * 8); + stream_putc (s, attr->ecommunity->size * 8); } - stream_put (s, attre->ecommunity->val, attre->ecommunity->size * 8); + stream_put (s, attr->ecommunity->val, attr->ecommunity->size * 8); } else { @@ -3430,9 +3264,9 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, int ecom_tr_size = 0; int i; - for (i = 0; i < attre->ecommunity->size; i++) + for (i = 0; i < attr->ecommunity->size; i++) { - pnt = attre->ecommunity->val + (i * 8); + pnt = attr->ecommunity->val + (i * 8); tbit = *pnt; if (CHECK_FLAG (tbit, ECOMMUNITY_FLAG_NON_TRANSITIVE)) @@ -3456,9 +3290,9 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, stream_putc (s, ecom_tr_size * 8); } - for (i = 0; i < attre->ecommunity->size; i++) + for (i = 0; i < attr->ecommunity->size; i++) { - pnt = attre->ecommunity->val + (i * 8); + pnt = attr->ecommunity->val + (i * 8); tbit = *pnt; if (CHECK_FLAG (tbit, ECOMMUNITY_FLAG_NON_TRANSITIVE)) @@ -3477,8 +3311,7 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, { u_int32_t label_index; - assert (attr->extra); - label_index = attr->extra->label_index; + label_index = attr->label_index; if (label_index != BGP_INVALID_LABEL_INDEX) { @@ -3522,8 +3355,6 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, if ( send_as4_aggregator ) { - assert (attr->extra); - /* send AS4_AGGREGATOR, at this place */ /* this section of code moved here in order to ensure the correct * *ascending* order of attributes @@ -3531,8 +3362,8 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_AS4_AGGREGATOR); stream_putc (s, 8); - stream_putl (s, attr->extra->aggregator_as); - stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr); + stream_putl (s, attr->aggregator_as); + stream_put_ipv4 (s, attr->aggregator_addr.s_addr); } if (((afi == AFI_IP || afi == AFI_IP6) && @@ -3549,8 +3380,8 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer, } /* Unknown transit attribute. */ - if (attr->extra && attr->extra->transit) - stream_put (s, attr->extra->transit->val, attr->extra->transit->length); + if (attr->transit) + stream_put (s, attr->transit->val, attr->transit->length); /* Return total size of attribute. */ return stream_get_endp (s) - cp; @@ -3700,12 +3531,11 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, /* Aggregator. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)) { - assert (attr->extra); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_AGGREGATOR); stream_putc (s, 8); - stream_putl (s, attr->extra->aggregator_as); - stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr); + stream_putl (s, attr->aggregator_as); + stream_put_ipv4 (s, attr->aggregator_addr.s_addr); } /* Community attribute. */ @@ -3727,32 +3557,31 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, } /* Large Community attribute. */ - if (attr->extra && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES)) + if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES)) { - if (attr->extra->lcommunity->size * 12 > 255) + if (attr->lcommunity->size * 12 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES); - stream_putw (s, attr->extra->lcommunity->size * 12); + stream_putw (s, attr->lcommunity->size * 12); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES); - stream_putc (s, attr->extra->lcommunity->size * 12); + stream_putc (s, attr->lcommunity->size * 12); } - stream_put (s, attr->extra->lcommunity->val, attr->extra->lcommunity->size * 12); + stream_put (s, attr->lcommunity->val, attr->lcommunity->size * 12); } /* Add a MP_NLRI attribute to dump the IPv6 next hop */ - if (prefix != NULL && prefix->family == AF_INET6 && attr->extra && - (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL || - attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) ) + if (prefix != NULL && prefix->family == AF_INET6 && + (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL || + attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) ) { int sizep; - struct attr_extra *attre = attr->extra; - + stream_putc(s, BGP_ATTR_FLAG_OPTIONAL); stream_putc(s, BGP_ATTR_MP_REACH_NLRI); sizep = stream_get_endp (s); @@ -3763,10 +3592,10 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, stream_putc(s, SAFI_UNICAST); /* SAFI */ /* Next hop */ - stream_putc(s, attre->mp_nexthop_len); - stream_put(s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN); - if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) - stream_put(s, &attre->mp_nexthop_local, IPV6_MAX_BYTELEN); + stream_putc(s, attr->mp_nexthop_len); + stream_put(s, &attr->mp_nexthop_global, IPV6_MAX_BYTELEN); + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + stream_put(s, &attr->mp_nexthop_local, IPV6_MAX_BYTELEN); /* SNPA */ stream_putc(s, 0); @@ -3781,9 +3610,7 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, /* Prefix SID */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID)) { - assert (attr->extra); - - if (attr->extra->label_index != BGP_INVALID_LABEL_INDEX) + if (attr->label_index != BGP_INVALID_LABEL_INDEX) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_PREFIX_SID); @@ -3792,7 +3619,7 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, stream_putc (s, BGP_PREFIX_SID_LABEL_INDEX_LENGTH); stream_putc (s, 0); // reserved stream_putw (s, 0); // flags - stream_putl (s, attr->extra->label_index); + stream_putl (s, attr->label_index); } } diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index f3c1b5e3c..99c6a6b79 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -98,13 +98,35 @@ struct overlay_index union gw_addr gw_ip; }; -/* Additional/uncommon BGP attributes. - * lazily allocated as and when a struct attr - * requires it. - */ -struct attr_extra +/* BGP core attribute structure. */ +struct attr { - /* Multi-Protocol Nexthop, AFI IPv6 */ + /* AS Path structure */ + struct aspath *aspath; + + /* Community structure */ + struct community *community; + + /* Reference count of this attribute. */ + unsigned long refcnt; + + /* Flag of attribute is set or not. */ + uint64_t flag; + + /* Apart from in6_addr, the remaining static attributes */ + struct in_addr nexthop; + u_int32_t med; + u_int32_t local_pref; + ifindex_t nh_ifindex; + + /* Path origin attribute */ + u_char origin; + + /* has the route-map changed any attribute? + Used on the peer outbound side. */ + u_int32_t rmap_change_flags; + + /* Multi-Protocol Nexthop, AFI IPv6 */ struct in6_addr mp_nexthop_global; struct in6_addr mp_nexthop_local; @@ -140,6 +162,9 @@ struct attr_extra /* MP Nexthop preference */ u_char mp_nexthop_prefer_global; + /* Static MAC for EVPN */ + u_char sticky; + /* route tag */ route_tag_t tag; @@ -157,38 +182,9 @@ struct attr_extra #endif /* EVPN */ struct overlay_index evpn_overlay; -}; -/* BGP core attribute structure. */ -struct attr -{ - /* AS Path structure */ - struct aspath *aspath; - - /* Community structure */ - struct community *community; - - /* Lazily allocated pointer to extra attributes */ - struct attr_extra *extra; - - /* Reference count of this attribute. */ - unsigned long refcnt; - - /* Flag of attribute is set or not. */ - uint64_t flag; - - /* Apart from in6_addr, the remaining static attributes */ - struct in_addr nexthop; - u_int32_t med; - u_int32_t local_pref; - ifindex_t nh_ifindex; - - /* Path origin attribute */ - u_char origin; - - /* has the route-map changed any attribute? - Used on the peer outbound side. */ - u_int32_t rmap_change_flags; + /* EVPN MAC Mobility sequence number, if any. */ + u_int32_t mm_seqnum; }; /* rmap_change_flags definition */ @@ -220,7 +216,7 @@ struct transit #define BGP_CLUSTER_LIST_LENGTH(attr) \ (((attr)->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) ? \ - (attr)->extra->cluster->length : 0) + (attr)->cluster->length : 0) typedef enum { BGP_ATTR_PARSE_PROCEED = 0, @@ -239,8 +235,6 @@ extern void bgp_attr_finish (void); extern bgp_attr_parse_ret_t bgp_attr_parse (struct peer *, struct attr *, bgp_size_t, struct bgp_nlri *, struct bgp_nlri *); -extern struct attr_extra *bgp_attr_extra_get (struct attr *); -extern void bgp_attr_extra_free (struct attr *); extern void bgp_attr_dup (struct attr *, struct attr *); extern void bgp_attr_deep_dup (struct attr *, struct attr *); extern void bgp_attr_deep_free (struct attr *); @@ -333,4 +327,10 @@ bgp_rmap_nhop_changed(u_int32_t out_rmap_flags, u_int32_t in_rmap_flags) CHECK_FLAG(in_rmap_flags, BATTR_RMAP_NEXTHOP_UNCHANGED)) ? 1 : 0); } +static inline u_int32_t +mac_mobility_seqnum (struct attr *attr) +{ + return (attr) ? attr->mm_seqnum : 0; +} + #endif /* _QUAGGA_BGP_ATTR_H */ diff --git a/bgpd/bgp_attr_evpn.c b/bgpd/bgp_attr_evpn.c index 6970d5a67..aa175bcf5 100644 --- a/bgpd/bgp_attr_evpn.c +++ b/bgpd/bgp_attr_evpn.c @@ -33,21 +33,20 @@ #include "bgpd/bgp_attr_evpn.h" #include "bgpd/bgp_ecommunity.h" #include "bgpd/bgp_evpn.h" +#include "bgpd/bgp_evpn_private.h" void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac) { - struct ecommunity_val routermac_ecom; - - if (attr->extra) { - memset(&routermac_ecom, 0, sizeof(struct ecommunity_val)); - routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN; - routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC; - memcpy(&routermac_ecom.val[2], routermac->octet, ETHER_ADDR_LEN); - if (!attr->extra->ecommunity) - attr->extra->ecommunity = ecommunity_new(); - ecommunity_add_val(attr->extra->ecommunity, &routermac_ecom); - ecommunity_str (attr->extra->ecommunity); - } + struct ecommunity_val routermac_ecom; + + memset(&routermac_ecom, 0, sizeof(struct ecommunity_val)); + routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN; + routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC; + memcpy(&routermac_ecom.val[2], routermac->octet, ETHER_ADDR_LEN); + if (!attr->ecommunity) + attr->ecommunity = ecommunity_new(); + ecommunity_add_val(attr->ecommunity, &routermac_ecom); + ecommunity_str (attr->ecommunity); } /* converts to an esi @@ -57,85 +56,138 @@ void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac) */ int str2esi(const char *str, struct eth_segment_id *id) { - unsigned int a[ESI_LEN]; - int i; - - if (!str) - return 0; - if (sscanf (str, "%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x", - a + 0, a + 1, a + 2, a + 3, a + 4, a + 5, - a + 6, a + 7, a + 8, a + 9) != ESI_LEN) - { - /* error in incoming str length */ - return 0; - } - /* valid mac address */ - if (!id) - return 1; - for (i = 0; i < ESI_LEN; ++i) - id->val[i] = a[i] & 0xff; - return 1; + unsigned int a[ESI_LEN]; + int i; + + if (!str) + return 0; + if (sscanf (str, "%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x", + a + 0, a + 1, a + 2, a + 3, a + 4, a + 5, + a + 6, a + 7, a + 8, a + 9) != ESI_LEN) + { + /* error in incoming str length */ + return 0; + } + /* valid mac address */ + if (!id) + return 1; + for (i = 0; i < ESI_LEN; ++i) + id->val[i] = a[i] & 0xff; + return 1; } char *esi2str(struct eth_segment_id *id) { - char *ptr; - u_char *val; + char *ptr; + u_char *val; - if (!id) - return NULL; + if (!id) + return NULL; - val = id->val; - ptr = (char *)XMALLOC(MTYPE_TMP, (ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char)); + val = id->val; + ptr = (char *)XMALLOC(MTYPE_TMP, (ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char)); - snprintf(ptr, (ESI_LEN * 2 + ESI_LEN - 1 + 1), - "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", - val[0], val[1], val[2], val[3], val[4], - val[5], val[6], val[7], val[8], val[9]); + snprintf(ptr, (ESI_LEN * 2 + ESI_LEN - 1 + 1), + "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + val[0], val[1], val[2], val[3], val[4], + val[5], val[6], val[7], val[8], val[9]); - return ptr; + return ptr; } char *ecom_mac2str(char *ecom_mac) { - char *en; + char *en; - en = ecom_mac; - en += 2; - return prefix_mac2str((struct ethaddr *)en, NULL, 0); + en = ecom_mac; + en += 2; + + return prefix_mac2str((struct ethaddr *)en, NULL, 0); +} + +/* + * Fetch and return the sequence number from MAC Mobility extended + * community, if present, else 0. + */ +u_int32_t +bgp_attr_mac_mobility_seqnum (struct attr *attr, u_char *sticky) +{ + struct ecommunity *ecom; + int i; + u_char flags = 0; + + ecom = attr->ecommunity; + if (!ecom || !ecom->size) + return 0; + + /* If there is a MAC Mobility extended community, return its + * sequence number. + * TODO: RFC is silent on handling of multiple MAC mobility extended + * communities for the same route. We will bail out upon the first + * one. + */ + for (i = 0; i < ecom->size; i++) + { + u_char *pnt; + u_char type, sub_type; + u_int32_t seq_num; + + pnt = (ecom->val + (i * ECOMMUNITY_SIZE)); + type = *pnt++; + sub_type = *pnt++; + if (!(type == ECOMMUNITY_ENCODE_EVPN && + sub_type == ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY)) + continue; + flags = *pnt++; + + if (flags & ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY_FLAG_STICKY) + *sticky = 1; + else + *sticky = 0; + + pnt++; + seq_num = (*pnt++ << 24); + seq_num |= (*pnt++ << 16); + seq_num |= (*pnt++ << 8); + seq_num |= (*pnt++); + + return seq_num; + } + + return 0; } /* dst prefix must be AF_INET or AF_INET6 prefix, to forge EVPN prefix */ extern int bgp_build_evpn_prefix(int evpn_type, uint32_t eth_tag, struct prefix *dst) { - struct evpn_addr *p_evpn_p; - struct prefix p2; - struct prefix *src = &p2; - - if (!dst || dst->family == 0) - return -1; - /* store initial prefix in src */ - prefix_copy(src, dst); - memset(dst, 0, sizeof(struct prefix)); - p_evpn_p = &(dst->u.prefix_evpn); - dst->family = AF_ETHERNET; - p_evpn_p->route_type = evpn_type; - if (evpn_type == EVPN_IP_PREFIX) { - p_evpn_p->eth_tag = eth_tag; - p_evpn_p->ip_prefix_length = p2.prefixlen; - if (src->family == AF_INET) { + struct evpn_addr *p_evpn_p; + struct prefix p2; + struct prefix *src = &p2; + + if (!dst || dst->family == 0) + return -1; + /* store initial prefix in src */ + prefix_copy(src, dst); + memset(dst, 0, sizeof(struct prefix)); + p_evpn_p = &(dst->u.prefix_evpn); + dst->family = AF_ETHERNET; + p_evpn_p->route_type = evpn_type; + if (evpn_type == BGP_EVPN_IP_PREFIX_ROUTE) { + p_evpn_p->eth_tag = eth_tag; + p_evpn_p->ip_prefix_length = p2.prefixlen; + if (src->family == AF_INET) { SET_IPADDR_V4 (&p_evpn_p->ip); - memcpy(&p_evpn_p->ip.ipaddr_v4, &src->u.prefix4, - sizeof(struct in_addr)); - dst->prefixlen = (u_char) PREFIX_LEN_ROUTE_TYPE_5_IPV4; - } else { + memcpy(&p_evpn_p->ip.ipaddr_v4, &src->u.prefix4, + sizeof(struct in_addr)); + dst->prefixlen = (u_char) PREFIX_LEN_ROUTE_TYPE_5_IPV4; + } else { SET_IPADDR_V6 (&p_evpn_p->ip); - memcpy(&p_evpn_p->ip.ipaddr_v6, &src->u.prefix6, - sizeof(struct in6_addr)); - dst->prefixlen = (u_char) PREFIX_LEN_ROUTE_TYPE_5_IPV6; - } - } else - return -1; - return 0; + memcpy(&p_evpn_p->ip.ipaddr_v6, &src->u.prefix6, + sizeof(struct in6_addr)); + dst->prefixlen = (u_char) PREFIX_LEN_ROUTE_TYPE_5_IPV6; + } + } else + return -1; + return 0; } diff --git a/bgpd/bgp_attr_evpn.h b/bgpd/bgp_attr_evpn.h index 3a93f6ae6..26650ef8b 100644 --- a/bgpd/bgp_attr_evpn.h +++ b/bgpd/bgp_attr_evpn.h @@ -22,31 +22,37 @@ #define _QUAGGA_BGP_ATTR_EVPN_H /* value of first byte of ESI */ -#define ESI_TYPE_ARBITRARY 0 /* */ -#define ESI_TYPE_LACP 1 /* <> */ -#define ESI_TYPE_BRIDGE 2 /* <Root bridge Mac-6B>:<Root Br Priority-2B>:00 */ -#define ESI_TYPE_MAC 3 /* <Syst Mac Add-6B>:<Local Discriminator Value-3B> */ -#define ESI_TYPE_ROUTER 4 /* <RouterId-4B>:<Local Discriminator Value-4B> */ -#define ESI_TYPE_AS 5 /* <AS-4B>:<Local Discriminator Value-4B> */ +#define ESI_TYPE_ARBITRARY 0 /* */ +#define ESI_TYPE_LACP 1 /* <> */ +#define ESI_TYPE_BRIDGE 2 /* <Root bridge Mac-6B>:<Root Br Priority-2B>:00 */ +#define ESI_TYPE_MAC 3 /* <Syst Mac Add-6B>:<Local Discriminator Value-3B> */ +#define ESI_TYPE_ROUTER 4 /* <RouterId-4B>:<Local Discriminator Value-4B> */ +#define ESI_TYPE_AS 5 /* <AS-4B>:<Local Discriminator Value-4B> */ + + #define MAX_ESI {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff} #define ESI_LEN 10 #define MAX_ET 0xffffffff + u_long eth_tag_id; struct attr; -struct eth_segment_id { - u_char val[ESI_LEN]; +struct eth_segment_id +{ + u_char val[ESI_LEN]; }; -union gw_addr { - struct in_addr ipv4; - struct in6_addr ipv6; +union gw_addr +{ + struct in_addr ipv4; + struct in6_addr ipv6; }; -struct bgp_route_evpn { - struct eth_segment_id eth_s_id; - union gw_addr gw_ip; +struct bgp_route_evpn +{ + struct eth_segment_id eth_s_id; + union gw_addr gw_ip; }; extern int str2esi(const char *str, struct eth_segment_id *id); @@ -55,5 +61,9 @@ extern char *ecom_mac2str(char *ecom_mac); extern void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac); extern int bgp_build_evpn_prefix(int type, uint32_t eth_tag, - struct prefix *dst); -#endif /* _QUAGGA_BGP_ATTR_EVPN_H */ + struct prefix *dst); + +extern u_int32_t +bgp_attr_mac_mobility_seqnum (struct attr *attr, u_char *sticky); + +#endif /* _QUAGGA_BGP_ATTR_EVPN_H */ diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index 890acb3a4..bb0a0fc63 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -526,17 +526,17 @@ bgp_bfd_peer_config_write(struct vty *vty, struct peer *peer, char *addr) bfd_info = (struct bfd_info *)peer->bfd_info; if (CHECK_FLAG (bfd_info->flags, BFD_FLAG_PARAM_CFG)) - vty_outln (vty, " neighbor %s bfd %d %d %d", addr, + vty_out (vty, " neighbor %s bfd %d %d %d\n", addr, bfd_info->detect_mult, bfd_info->required_min_rx, bfd_info->desired_min_tx); if (bfd_info->type != BFD_TYPE_NOT_CONFIGURED) - vty_outln (vty, " neighbor %s bfd %s", addr, + vty_out (vty, " neighbor %s bfd %s\n", addr, (bfd_info->type == BFD_TYPE_MULTIHOP) ? "multihop" : "singlehop"); if (!CHECK_FLAG (bfd_info->flags, BFD_FLAG_PARAM_CFG) && (bfd_info->type == BFD_TYPE_NOT_CONFIGURED)) - vty_outln (vty, " neighbor %s bfd", addr); + vty_out (vty, " neighbor %s bfd\n", addr); } /* @@ -562,7 +562,7 @@ DEFUN (neighbor_bfd, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = bgp_bfd_peer_param_set (peer, BFD_DEF_MIN_RX, BFD_DEF_MIN_TX, BFD_DEF_DETECT_MULT, 1); @@ -595,7 +595,7 @@ DEFUN (neighbor_bfd_param, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (!peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if ((ret = bfd_validate_param (vty, argv[idx_number_1]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val, &rx_val, &tx_val)) != CMD_SUCCESS) @@ -626,14 +626,14 @@ DEFUN_HIDDEN (neighbor_bfd_type, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (!peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (strmatch(argv[idx_hop]->text, "singlehop")) type = BFD_TYPE_SINGLEHOP; else if (strmatch(argv[idx_hop]->text, "multihop")) type = BFD_TYPE_MULTIHOP; else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = bgp_bfd_peer_param_type_set (peer, type); if (ret != 0) @@ -659,7 +659,7 @@ DEFUN (no_neighbor_bfd, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = bgp_bfd_peer_param_unset(peer); if (ret != 0) @@ -685,7 +685,7 @@ DEFUN_HIDDEN (no_neighbor_bfd_type, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (!peer->bfd_info) return 0; diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index d5a89c1ff..d276de6eb 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -525,15 +525,15 @@ bgp_config_write_damp (struct vty *vty) && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) - vty_outln (vty, " bgp dampening"); + vty_out (vty, " bgp dampening\n"); else if (bgp_damp_cfg.half_life != DEFAULT_HALF_LIFE*60 && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) - vty_outln (vty, " bgp dampening %lld", + vty_out (vty, " bgp dampening %lld\n", bgp_damp_cfg.half_life / 60LL); else - vty_outln (vty, " bgp dampening %lld %d %d %lld", + vty_out (vty, " bgp dampening %lld %d %d %lld\n", bgp_damp_cfg.half_life/60LL, bgp_damp_cfg.reuse_limit, bgp_damp_cfg.suppress_value, @@ -652,7 +652,7 @@ bgp_damp_info_vty (struct vty *vty, struct bgp_info *binfo, vty_out (vty, ", reuse in %s", bgp_get_reuse_time (penalty, timebuf, BGP_UPTIME_LEN, 0, json_path)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } @@ -691,26 +691,26 @@ bgp_show_dampening_parameters (struct vty *vty, afi_t afi, safi_t safi) if (bgp == NULL) { - vty_outln (vty, "No BGP process is configured"); + vty_out (vty, "No BGP process is configured\n"); return CMD_WARNING; } if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) { - vty_outln (vty, "Half-life time: %lld min", + vty_out (vty, "Half-life time: %lld min\n", (long long)damp->half_life / 60); - vty_outln (vty, "Reuse penalty: %d", + vty_out (vty, "Reuse penalty: %d\n", damp->reuse_limit); - vty_outln (vty, "Suppress penalty: %d", + vty_out (vty, "Suppress penalty: %d\n", damp->suppress_value); - vty_outln (vty, "Max suppress time: %lld min", + vty_out (vty, "Max suppress time: %lld min\n", (long long)damp->max_suppress_time / 60); - vty_outln (vty, "Max supress penalty: %u", + vty_out (vty, "Max supress penalty: %u\n", damp->ceiling); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } else - vty_outln (vty, "dampening not enabled for %s", + vty_out (vty, "dampening not enabled for %s\n", afi == AFI_IP ? "IPv4" : "IPv6"); return CMD_SUCCESS; diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 553840207..f9e67d96c 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -39,6 +39,9 @@ #include "bgpd/bgp_community.h" #include "bgpd/bgp_updgrp.h" #include "bgpd/bgp_mplsvpn.h" +#include "bgpd/bgp_ecommunity.h" +#include "bgpd/bgp_label.h" +#include "bgpd/bgp_evpn.h" unsigned long conf_bgp_debug_as4; unsigned long conf_bgp_debug_neighbor_events; @@ -254,7 +257,7 @@ bgp_debug_list_print (struct vty *vty, const char *desc, struct list *list) } } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* Print the command to enable the debug for each peer/prefix this debug is @@ -274,14 +277,14 @@ bgp_debug_list_conf_print (struct vty *vty, const char *desc, struct list *list) { if (filter->host) { - vty_outln (vty, "%s %s", desc, filter->host); + vty_out (vty, "%s %s\n", desc, filter->host); write++; } if (filter->p) { - vty_outln (vty, "%s %s/%d", desc, + vty_out (vty, "%s %s/%d\n", desc, inet_ntop (filter->p->family, &filter->p->u.prefix, buf, INET6_ADDRSTRLEN), filter->p->prefixlen); write++; @@ -291,7 +294,7 @@ bgp_debug_list_conf_print (struct vty *vty, const char *desc, struct list *list) if (!write) { - vty_outln (vty, "%s", desc); + vty_out (vty, "%s\n", desc); write++; } @@ -384,6 +387,8 @@ bgp_debug_peer_updout_enabled(char *host) int bgp_dump_attr (struct attr *attr, char *buf, size_t size) { + char addrbuf[BUFSIZ]; + if (! attr) return 0; @@ -394,66 +399,68 @@ bgp_dump_attr (struct attr *attr, char *buf, size_t size) snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s", bgp_origin_str[attr->origin]); - if (attr->extra) - { - char addrbuf[BUFSIZ]; + /* Add MP case. */ + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL + || attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s", + inet_ntop (AF_INET6, &attr->mp_nexthop_global, + addrbuf, BUFSIZ)); - /* Add MP case. */ - if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL - || attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) - snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, - addrbuf, BUFSIZ)); + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + snprintf (buf + strlen (buf), size - strlen (buf), "(%s)", + inet_ntop (AF_INET6, &attr->mp_nexthop_local, + addrbuf, BUFSIZ)); - if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) - snprintf (buf + strlen (buf), size - strlen (buf), "(%s)", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, - addrbuf, BUFSIZ)); - } + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) + snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop)); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))) snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %u", attr->local_pref); - if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))) + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))) snprintf (buf + strlen (buf), size - strlen (buf), ", metric %u", attr->med); - if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) snprintf (buf + strlen (buf), size - strlen (buf), ", community %s", community_str (attr->community)); + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES))) + snprintf (buf + strlen (buf), size - strlen (buf), ", extcommunity %s", + ecommunity_str (attr->ecommunity)); + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))) snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate"); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %u %s", - attr->extra->aggregator_as, - inet_ntoa (attr->extra->aggregator_addr)); + attr->aggregator_as, + inet_ntoa (attr->aggregator_addr)); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))) snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s", - inet_ntoa (attr->extra->originator_id)); + inet_ntoa (attr->originator_id)); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST))) { int i; snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist"); - for (i = 0; i < attr->extra->cluster->length / 4; i++) + for (i = 0; i < attr->cluster->length / 4; i++) snprintf (buf + strlen (buf), size - strlen (buf), " %s", - inet_ntoa (attr->extra->cluster->list[i])); + inet_ntoa (attr->cluster->list[i])); } - if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH))) + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH))) snprintf (buf + strlen (buf), size - strlen (buf), ", path %s", aspath_print (attr->aspath)); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID))) { - if (attr->extra->label_index != BGP_INVALID_LABEL_INDEX) + if (attr->label_index != BGP_INVALID_LABEL_INDEX) snprintf (buf + strlen (buf), size - strlen (buf), ", label-index %u", - attr->extra->label_index); + attr->label_index); } if (strlen (buf) > 1) @@ -583,7 +590,7 @@ DEFUN (debug_bgp_as4, else { TERM_DEBUG_ON (as4, AS4); - vty_outln (vty, "BGP as4 debugging is on"); + vty_out (vty, "BGP as4 debugging is on\n"); } return CMD_SUCCESS; } @@ -601,7 +608,7 @@ DEFUN (no_debug_bgp_as4, else { TERM_DEBUG_OFF (as4, AS4); - vty_outln (vty, "BGP as4 debugging is off"); + vty_out (vty, "BGP as4 debugging is off\n"); } return CMD_SUCCESS; } @@ -619,7 +626,7 @@ DEFUN (debug_bgp_as4_segment, else { TERM_DEBUG_ON (as4, AS4_SEGMENT); - vty_outln (vty, "BGP as4 segment debugging is on"); + vty_out (vty, "BGP as4 segment debugging is on\n"); } return CMD_SUCCESS; } @@ -638,7 +645,7 @@ DEFUN (no_debug_bgp_as4_segment, else { TERM_DEBUG_OFF (as4, AS4_SEGMENT); - vty_outln (vty, "BGP as4 segment debugging is off"); + vty_out (vty, "BGP as4 segment debugging is off\n"); } return CMD_SUCCESS; } @@ -658,7 +665,7 @@ DEFUN (debug_bgp_neighbor_events, else { TERM_DEBUG_ON (neighbor_events, NEIGHBOR_EVENTS); - vty_outln (vty, "BGP neighbor-events debugging is on"); + vty_out (vty, "BGP neighbor-events debugging is on\n"); } return CMD_SUCCESS; } @@ -681,7 +688,7 @@ DEFUN (debug_bgp_neighbor_events_peer, if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers, host, NULL)) { - vty_outln (vty, "BGP neighbor-events debugging is already enabled for %s", + vty_out (vty, "BGP neighbor-events debugging is already enabled for %s\n", host); return CMD_SUCCESS; } @@ -693,7 +700,7 @@ DEFUN (debug_bgp_neighbor_events_peer, else { TERM_DEBUG_ON (neighbor_events, NEIGHBOR_EVENTS); - vty_outln (vty, "BGP neighbor-events debugging is on for %s", host); + vty_out (vty, "BGP neighbor-events debugging is on for %s\n", host); } return CMD_SUCCESS; } @@ -713,7 +720,7 @@ DEFUN (no_debug_bgp_neighbor_events, else { TERM_DEBUG_OFF (neighbor_events, NEIGHBOR_EVENTS); - vty_outln (vty, "BGP neighbor-events debugging is off"); + vty_out (vty, "BGP neighbor-events debugging is off\n"); } return CMD_SUCCESS; } @@ -747,9 +754,9 @@ DEFUN (no_debug_bgp_neighbor_events_peer, } if (found_peer) - vty_outln (vty, "BGP neighbor-events debugging is off for %s", host); + vty_out (vty, "BGP neighbor-events debugging is off for %s\n", host); else - vty_outln (vty, "BGP neighbor-events debugging was not enabled for %s", + vty_out (vty, "BGP neighbor-events debugging was not enabled for %s\n", host); return CMD_SUCCESS; @@ -768,7 +775,7 @@ DEFUN (debug_bgp_nht, else { TERM_DEBUG_ON (nht, NHT); - vty_outln (vty, "BGP nexthop tracking debugging is on"); + vty_out (vty, "BGP nexthop tracking debugging is on\n"); } return CMD_SUCCESS; } @@ -786,7 +793,7 @@ DEFUN (no_debug_bgp_nht, else { TERM_DEBUG_OFF (nht, NHT); - vty_outln (vty, "BGP nexthop tracking debugging is off"); + vty_out (vty, "BGP nexthop tracking debugging is off\n"); } return CMD_SUCCESS; } @@ -806,7 +813,7 @@ DEFUN (debug_bgp_keepalive, else { TERM_DEBUG_ON (keepalive, KEEPALIVE); - vty_outln (vty, "BGP keepalives debugging is on"); + vty_out (vty, "BGP keepalives debugging is on\n"); } return CMD_SUCCESS; } @@ -829,7 +836,7 @@ DEFUN (debug_bgp_keepalive_peer, if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers, host, NULL)) { - vty_outln (vty, "BGP keepalive debugging is already enabled for %s", + vty_out (vty, "BGP keepalive debugging is already enabled for %s\n", host); return CMD_SUCCESS; } @@ -841,7 +848,7 @@ DEFUN (debug_bgp_keepalive_peer, else { TERM_DEBUG_ON (keepalive, KEEPALIVE); - vty_outln (vty, "BGP keepalives debugging is on for %s", host); + vty_out (vty, "BGP keepalives debugging is on for %s\n", host); } return CMD_SUCCESS; } @@ -861,7 +868,7 @@ DEFUN (no_debug_bgp_keepalive, else { TERM_DEBUG_OFF (keepalive, KEEPALIVE); - vty_outln (vty, "BGP keepalives debugging is off"); + vty_out (vty, "BGP keepalives debugging is off\n"); } return CMD_SUCCESS; } @@ -895,9 +902,9 @@ DEFUN (no_debug_bgp_keepalive_peer, } if (found_peer) - vty_outln (vty, "BGP keepalives debugging is off for %s", host); + vty_out (vty, "BGP keepalives debugging is off for %s\n", host); else - vty_outln (vty, "BGP keepalives debugging was not enabled for %s", host); + vty_out (vty, "BGP keepalives debugging was not enabled for %s\n", host); return CMD_SUCCESS; } @@ -922,7 +929,7 @@ DEFPY (debug_bgp_bestpath_prefix, if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL, bestpath)) { - vty_outln (vty, "BGP bestpath debugging is already enabled for %s", bestpath_str); + vty_out (vty, "BGP bestpath debugging is already enabled for %s\n", bestpath_str); return CMD_SUCCESS; } @@ -935,7 +942,7 @@ DEFPY (debug_bgp_bestpath_prefix, else { TERM_DEBUG_ON (bestpath, BESTPATH); - vty_outln (vty, "BGP bestpath debugging is on for %s", bestpath_str); + vty_out (vty, "BGP bestpath debugging is on for %s\n", bestpath_str); } return CMD_SUCCESS; @@ -962,8 +969,8 @@ DEFUN (no_debug_bgp_bestpath_prefix, if (!ret) { prefix_free(argv_p); - vty_outln (vty, "%% Malformed Prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed Prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } if (bgp_debug_bestpath_prefixes && !list_isempty(bgp_debug_bestpath_prefixes)) @@ -979,16 +986,16 @@ DEFUN (no_debug_bgp_bestpath_prefix, else { TERM_DEBUG_OFF (bestpath, BESTPATH); - vty_outln (vty, "BGP bestpath debugging (per prefix) is off"); + vty_out (vty, "BGP bestpath debugging (per prefix) is off\n"); } } } if (found_prefix) - vty_outln (vty, "BGP bestpath debugging is off for %s", + vty_out (vty, "BGP bestpath debugging is off for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); else - vty_outln (vty, "BGP bestpath debugging was not enabled for %s", + vty_out (vty, "BGP bestpath debugging was not enabled for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); return CMD_SUCCESS; @@ -1009,7 +1016,7 @@ DEFUN (no_debug_bgp_bestpath, else { TERM_DEBUG_OFF (bestpath, BESTPATH); - vty_outln (vty, "BGP bestpath debugging is off"); + vty_out (vty, "BGP bestpath debugging is off\n"); } return CMD_SUCCESS; } @@ -1035,7 +1042,7 @@ DEFUN (debug_bgp_update, { TERM_DEBUG_ON (update, UPDATE_IN); TERM_DEBUG_ON (update, UPDATE_OUT); - vty_outln (vty, "BGP updates debugging is on"); + vty_out (vty, "BGP updates debugging is on\n"); } return CMD_SUCCESS; } @@ -1068,12 +1075,12 @@ DEFUN (debug_bgp_update_direct, if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) { TERM_DEBUG_ON (update, UPDATE_IN); - vty_outln (vty, "BGP updates debugging is on (inbound)"); + vty_out (vty, "BGP updates debugging is on (inbound)\n"); } else { TERM_DEBUG_ON (update, UPDATE_OUT); - vty_outln (vty, "BGP updates debugging is on (outbound)"); + vty_out (vty, "BGP updates debugging is on (outbound)\n"); } } return CMD_SUCCESS; @@ -1111,7 +1118,7 @@ DEFUN (debug_bgp_update_direct_peer, { if (bgp_debug_list_has_entry(bgp_debug_update_in_peers, host, NULL)) { - vty_outln (vty, "BGP inbound update debugging is already enabled for %s", + vty_out (vty, "BGP inbound update debugging is already enabled for %s\n", host); return CMD_SUCCESS; } @@ -1121,7 +1128,7 @@ DEFUN (debug_bgp_update_direct_peer, { if (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host, NULL)) { - vty_outln (vty, "BGP outbound update debugging is already enabled for %s", + vty_out (vty, "BGP outbound update debugging is already enabled for %s\n", host); return CMD_SUCCESS; } @@ -1166,13 +1173,13 @@ DEFUN (debug_bgp_update_direct_peer, if (inbound) { TERM_DEBUG_ON (update, UPDATE_IN); - vty_outln (vty, "BGP updates debugging is on (inbound) for %s", + vty_out (vty, "BGP updates debugging is on (inbound) for %s\n", argv[idx_peer]->arg); } else { TERM_DEBUG_ON (update, UPDATE_OUT); - vty_outln (vty, "BGP updates debugging is on (outbound) for %s", + vty_out (vty, "BGP updates debugging is on (outbound) for %s\n", argv[idx_peer]->arg); } } @@ -1201,7 +1208,7 @@ DEFUN (no_debug_bgp_update_direct, else { TERM_DEBUG_OFF (update, UPDATE_IN); - vty_outln (vty, "BGP updates debugging is off (inbound)"); + vty_out (vty, "BGP updates debugging is off (inbound)\n"); } } else @@ -1215,7 +1222,7 @@ DEFUN (no_debug_bgp_update_direct, else { TERM_DEBUG_OFF (update, UPDATE_OUT); - vty_outln (vty, "BGP updates debugging is off (outbound)"); + vty_out (vty, "BGP updates debugging is off (outbound)\n"); } } @@ -1258,7 +1265,7 @@ DEFUN (no_debug_bgp_update_direct_peer, else { TERM_DEBUG_OFF (update, UPDATE_IN); - vty_outln (vty, "BGP updates debugging (inbound) is off"); + vty_out (vty, "BGP updates debugging (inbound) is off\n"); } } } @@ -1275,7 +1282,7 @@ DEFUN (no_debug_bgp_update_direct_peer, else { TERM_DEBUG_OFF (update, UPDATE_OUT); - vty_outln (vty, "BGP updates debugging (outbound) is off"); + vty_out (vty, "BGP updates debugging (outbound) is off\n"); } } @@ -1302,16 +1309,16 @@ DEFUN (no_debug_bgp_update_direct_peer, if (found_peer) if (inbound) - vty_outln (vty, "BGP updates debugging (inbound) is off for %s", host); + vty_out (vty, "BGP updates debugging (inbound) is off for %s\n", host); else - vty_outln (vty, "BGP updates debugging (outbound) is off for %s", + vty_out (vty, "BGP updates debugging (outbound) is off for %s\n", host); else if (inbound) - vty_outln (vty, "BGP updates debugging (inbound) was not enabled for %s", + vty_out (vty, "BGP updates debugging (inbound) was not enabled for %s\n", host); else - vty_outln (vty, "BGP updates debugging (outbound) was not enabled for %s", + vty_out (vty, "BGP updates debugging (outbound) was not enabled for %s\n", host); return CMD_SUCCESS; @@ -1337,8 +1344,8 @@ DEFUN (debug_bgp_update_prefix, if (!ret) { prefix_free(argv_p); - vty_outln (vty, "%% Malformed Prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed Prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } @@ -1347,7 +1354,7 @@ DEFUN (debug_bgp_update_prefix, if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p)) { - vty_outln (vty, "BGP updates debugging is already enabled for %s", + vty_out (vty, "BGP updates debugging is already enabled for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); return CMD_SUCCESS; } @@ -1361,7 +1368,7 @@ DEFUN (debug_bgp_update_prefix, else { TERM_DEBUG_ON (update, UPDATE_PREFIX); - vty_outln (vty, "BGP updates debugging is on for %s", + vty_out (vty, "BGP updates debugging is on for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); } @@ -1390,8 +1397,8 @@ DEFUN (no_debug_bgp_update_prefix, if (!ret) { prefix_free(argv_p); - vty_outln (vty, "%% Malformed Prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed Prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } if (bgp_debug_update_prefixes && !list_isempty(bgp_debug_update_prefixes)) @@ -1407,16 +1414,16 @@ DEFUN (no_debug_bgp_update_prefix, else { TERM_DEBUG_OFF (update, UPDATE_PREFIX); - vty_outln (vty, "BGP updates debugging (per prefix) is off"); + vty_out (vty, "BGP updates debugging (per prefix) is off\n"); } } } if (found_prefix) - vty_outln (vty, "BGP updates debugging is off for %s", + vty_out (vty, "BGP updates debugging is off for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); else - vty_outln (vty, "BGP updates debugging was not enabled for %s", + vty_out (vty, "BGP updates debugging was not enabled for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); return CMD_SUCCESS; @@ -1448,7 +1455,7 @@ DEFUN (no_debug_bgp_update, TERM_DEBUG_OFF (update, UPDATE_IN); TERM_DEBUG_OFF (update, UPDATE_OUT); TERM_DEBUG_OFF (update, UPDATE_PREFIX); - vty_outln (vty, "BGP updates debugging is off"); + vty_out (vty, "BGP updates debugging is off\n"); } return CMD_SUCCESS; } @@ -1466,7 +1473,7 @@ DEFUN (debug_bgp_zebra, else { TERM_DEBUG_ON (zebra, ZEBRA); - vty_outln (vty, "BGP zebra debugging is on"); + vty_out (vty, "BGP zebra debugging is on\n"); } return CMD_SUCCESS; } @@ -1491,8 +1498,8 @@ DEFUN (debug_bgp_zebra_prefix, if (!ret) { prefix_free(argv_p); - vty_outln (vty, "%% Malformed Prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed Prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!bgp_debug_zebra_prefixes) @@ -1500,7 +1507,7 @@ DEFUN (debug_bgp_zebra_prefix, if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, argv_p)) { - vty_outln (vty, "BGP zebra debugging is already enabled for %s", + vty_out (vty, "BGP zebra debugging is already enabled for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); return CMD_SUCCESS; } @@ -1512,7 +1519,7 @@ DEFUN (debug_bgp_zebra_prefix, else { TERM_DEBUG_ON (zebra, ZEBRA); - vty_outln (vty, "BGP zebra debugging is on for %s", + vty_out (vty, "BGP zebra debugging is on for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); } @@ -1534,7 +1541,7 @@ DEFUN (no_debug_bgp_zebra, else { TERM_DEBUG_OFF (zebra, ZEBRA); - vty_outln (vty, "BGP zebra debugging is off"); + vty_out (vty, "BGP zebra debugging is off\n"); } return CMD_SUCCESS; } @@ -1561,8 +1568,8 @@ DEFUN (no_debug_bgp_zebra_prefix, if (!ret) { prefix_free(argv_p); - vty_outln (vty, "%% Malformed Prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed Prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } if (bgp_debug_zebra_prefixes && !list_isempty(bgp_debug_zebra_prefixes)) @@ -1576,16 +1583,16 @@ DEFUN (no_debug_bgp_zebra_prefix, else { TERM_DEBUG_OFF (zebra, ZEBRA); - vty_outln (vty, "BGP zebra debugging is off"); + vty_out (vty, "BGP zebra debugging is off\n"); } } } if (found_prefix) - vty_outln (vty, "BGP zebra debugging is off for %s", + vty_out (vty, "BGP zebra debugging is off for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); else - vty_outln (vty, "BGP zebra debugging was not enabled for %s", + vty_out (vty, "BGP zebra debugging was not enabled for %s\n", argv[idx_ipv4_ipv6_prefixlen]->arg); return CMD_SUCCESS; @@ -1603,7 +1610,7 @@ DEFUN (debug_bgp_allow_martians, else { TERM_DEBUG_ON (allow_martians, ALLOW_MARTIANS); - vty_outln (vty, "BGP allow_martian next hop debugging is on"); + vty_out (vty, "BGP allow_martian next hop debugging is on\n"); } return CMD_SUCCESS; } @@ -1621,7 +1628,7 @@ DEFUN (no_debug_bgp_allow_martians, else { TERM_DEBUG_OFF (allow_martians, ALLOW_MARTIANS); - vty_outln (vty, "BGP allow martian next hop debugging is off"); + vty_out (vty, "BGP allow martian next hop debugging is off\n"); } return CMD_SUCCESS; } @@ -1640,7 +1647,7 @@ DEFUN (debug_bgp_update_groups, else { TERM_DEBUG_ON (update_groups, UPDATE_GROUPS); - vty_outln (vty, "BGP update-groups debugging is on"); + vty_out (vty, "BGP update-groups debugging is on\n"); } return CMD_SUCCESS; } @@ -1658,7 +1665,7 @@ DEFUN (no_debug_bgp_update_groups, else { TERM_DEBUG_OFF (update_groups, UPDATE_GROUPS); - vty_outln (vty, "BGP update-groups debugging is off"); + vty_out (vty, "BGP update-groups debugging is off\n"); } return CMD_SUCCESS; } @@ -1691,7 +1698,7 @@ DEFUN (no_debug_bgp, TERM_DEBUG_OFF (neighbor_events, NEIGHBOR_EVENTS); TERM_DEBUG_OFF (zebra, ZEBRA); TERM_DEBUG_OFF (allow_martians, ALLOW_MARTIANS); - vty_outln (vty, "All possible debugging has been turned off"); + vty_out (vty, "All possible debugging has been turned off\n"); return CMD_SUCCESS; } @@ -1703,13 +1710,13 @@ DEFUN (show_debugging_bgp, DEBUG_STR BGP_STR) { - vty_outln (vty, "BGP debugging status:"); + vty_out (vty, "BGP debugging status:\n"); if (BGP_DEBUG (as4, AS4)) - vty_outln (vty, " BGP as4 debugging is on"); + vty_out (vty, " BGP as4 debugging is on\n"); if (BGP_DEBUG (as4, AS4_SEGMENT)) - vty_outln (vty, " BGP as4 aspath segment debugging is on"); + vty_out (vty, " BGP as4 aspath segment debugging is on\n"); if (BGP_DEBUG (bestpath, BESTPATH)) bgp_debug_list_print (vty, " BGP bestpath debugging is on", @@ -1724,10 +1731,10 @@ DEFUN (show_debugging_bgp, bgp_debug_neighbor_events_peers); if (BGP_DEBUG (nht, NHT)) - vty_outln (vty, " BGP next-hop tracking debugging is on"); + vty_out (vty, " BGP next-hop tracking debugging is on\n"); if (BGP_DEBUG (update_groups, UPDATE_GROUPS)) - vty_outln (vty, " BGP update-groups debugging is on"); + vty_out (vty, " BGP update-groups debugging is on\n"); if (BGP_DEBUG (update, UPDATE_PREFIX)) bgp_debug_list_print (vty, " BGP updates debugging is on", @@ -1746,8 +1753,8 @@ DEFUN (show_debugging_bgp, bgp_debug_zebra_prefixes); if (BGP_DEBUG (allow_martians, ALLOW_MARTIANS)) - vty_outln (vty, " BGP allow martian next hop debugging is on"); - vty_out (vty, VTYNL); + vty_out (vty, " BGP allow martian next hop debugging is on\n"); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -1802,13 +1809,13 @@ bgp_config_write_debug (struct vty *vty) if (CONF_BGP_DEBUG (as4, AS4)) { - vty_outln (vty, "debug bgp as4"); + vty_out (vty, "debug bgp as4\n"); write++; } if (CONF_BGP_DEBUG (as4, AS4_SEGMENT)) { - vty_outln (vty, "debug bgp as4 segment"); + vty_out (vty, "debug bgp as4 segment\n"); write++; } @@ -1832,13 +1839,13 @@ bgp_config_write_debug (struct vty *vty) if (CONF_BGP_DEBUG (nht, NHT)) { - vty_outln (vty, "debug bgp nht"); + vty_out (vty, "debug bgp nht\n"); write++; } if (CONF_BGP_DEBUG (update_groups, UPDATE_GROUPS)) { - vty_outln (vty, "debug bgp update-groups"); + vty_out (vty, "debug bgp update-groups\n"); write++; } @@ -1864,7 +1871,7 @@ bgp_config_write_debug (struct vty *vty) { if (!bgp_debug_zebra_prefixes || list_isempty(bgp_debug_zebra_prefixes)) { - vty_outln (vty, "debug bgp zebra"); + vty_out (vty, "debug bgp zebra\n"); write++; } else @@ -1876,7 +1883,7 @@ bgp_config_write_debug (struct vty *vty) if (CONF_BGP_DEBUG (allow_martians, ALLOW_MARTIANS)) { - vty_outln (vty, "debug bgp allow-martians"); + vty_out (vty, "debug bgp allow-martians\n"); write++; } @@ -2142,12 +2149,14 @@ bgp_debug_zebra (struct prefix *p) } const char * -bgp_debug_rdpfxpath2str (struct prefix_rd *prd, union prefixconstptr pu, - int addpath_valid, u_int32_t addpath_id, - char *str, int size) +bgp_debug_rdpfxpath2str (afi_t afi, safi_t safi, + struct prefix_rd *prd, union prefixconstptr pu, + mpls_label_t *label, int addpath_valid, + u_int32_t addpath_id, char *str, int size) { char rd_buf[RD_ADDRSTRLEN]; char pfx_buf[PREFIX_STRLEN]; + char tag_buf[30]; /* ' with addpath ID ' 17 * max strlen of uint32 + 10 * +/- (just in case) + 1 @@ -2163,13 +2172,24 @@ bgp_debug_rdpfxpath2str (struct prefix_rd *prd, union prefixconstptr pu, if (addpath_valid) snprintf(pathid_buf, sizeof(pathid_buf), " with addpath ID %u", addpath_id); + tag_buf[0] = '\0'; + if (bgp_labeled_safi (safi) && label) + { + u_int32_t label_value; + + label_value = decode_label (label); + sprintf (tag_buf, " label %u", label_value); + } + if (prd) - snprintf (str, size, "RD %s %s%s", + snprintf (str, size, "RD %s %s%s%s", prefix_rd2str(prd, rd_buf, sizeof (rd_buf)), - prefix2str (pu, pfx_buf, sizeof (pfx_buf)), pathid_buf); + prefix2str (pu, pfx_buf, sizeof (pfx_buf)), + tag_buf, pathid_buf); else - snprintf (str, size, "%s%s", - prefix2str (pu, pfx_buf, sizeof (pfx_buf)), pathid_buf); + snprintf (str, size, "%s%s%s", + prefix2str (pu, pfx_buf, sizeof (pfx_buf)), + tag_buf, pathid_buf); return str; } diff --git a/bgpd/bgp_debug.h b/bgpd/bgp_debug.h index 5ec2eaa7c..11ab4dbd6 100644 --- a/bgpd/bgp_debug.h +++ b/bgpd/bgp_debug.h @@ -153,7 +153,8 @@ extern int bgp_debug_bestpath(struct prefix *p); extern int bgp_debug_zebra(struct prefix *p); extern int bgp_debug_count(void); -extern const char *bgp_debug_rdpfxpath2str (struct prefix_rd *, union prefixconstptr, +extern const char *bgp_debug_rdpfxpath2str (afi_t, safi_t, struct prefix_rd *, + union prefixconstptr, mpls_label_t *, int, u_int32_t, char *, int); const char *bgp_notify_admin_message(char *buf, size_t bufsz, u_char *data, size_t datalen); diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index eca29a351..5b6b8e137 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -667,8 +667,8 @@ bgp_dump_set (struct vty *vty, struct bgp_dump *bgp_dump, interval = bgp_dump_parse_time (interval_str); if (interval == 0) { - vty_outln (vty, "Malformed interval string"); - return CMD_WARNING; + vty_out (vty, "Malformed interval string\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Setting interval string */ @@ -866,10 +866,10 @@ config_write_bgp_dump (struct vty *vty) type_str = "all-et"; if (bgp_dump_all.interval_str) - vty_outln (vty, "dump bgp %s %s %s", type_str, + vty_out (vty, "dump bgp %s %s %s\n", type_str, bgp_dump_all.filename,bgp_dump_all.interval_str); else - vty_outln (vty, "dump bgp %s %s", type_str, + vty_out (vty, "dump bgp %s %s\n", type_str, bgp_dump_all.filename); } if (bgp_dump_updates.filename) @@ -879,19 +879,19 @@ config_write_bgp_dump (struct vty *vty) type_str = "updates-et"; if (bgp_dump_updates.interval_str) - vty_outln (vty, "dump bgp %s %s %s", type_str, + vty_out (vty, "dump bgp %s %s %s\n", type_str, bgp_dump_updates.filename,bgp_dump_updates.interval_str); else - vty_outln (vty, "dump bgp %s %s", type_str, + vty_out (vty, "dump bgp %s %s\n", type_str, bgp_dump_updates.filename); } if (bgp_dump_routes.filename) { if (bgp_dump_routes.interval_str) - vty_outln (vty, "dump bgp routes-mrt %s %s", + vty_out (vty, "dump bgp routes-mrt %s %s\n", bgp_dump_routes.filename,bgp_dump_routes.interval_str); else - vty_outln (vty, "dump bgp routes-mrt %s", + vty_out (vty, "dump bgp routes-mrt %s\n", bgp_dump_routes.filename); } diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 0555d1bbe..934921434 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -304,6 +304,61 @@ enum ecommunity_token ecommunity_token_val, }; +/* + * Encode BGP extended community from passed values. Supports types + * defined in RFC 4360 and well-known sub-types. + */ +static int +ecommunity_encode (u_char type, u_char sub_type, int trans, + as_t as, struct in_addr ip, u_int32_t val, + struct ecommunity_val *eval) +{ + assert (eval); + if (type == ECOMMUNITY_ENCODE_AS) + { + if (as > BGP_AS_MAX) + return -1; + } + else if (type == ECOMMUNITY_ENCODE_IP + || type == ECOMMUNITY_ENCODE_AS4) + { + if (val > UINT16_MAX) + return -1; + } + + /* Fill in the values. */ + eval->val[0] = type; + if (!trans) + eval->val[0] |= ECOMMUNITY_FLAG_NON_TRANSITIVE; + eval->val[1] = sub_type; + if (type == ECOMMUNITY_ENCODE_AS) + { + eval->val[2] = (as >> 8) & 0xff; + eval->val[3] = as & 0xff; + eval->val[4] = (val >> 24) & 0xff; + eval->val[5] = (val >> 16) & 0xff; + eval->val[6] = (val >> 8) & 0xff; + eval->val[7] = val & 0xff; + } + else if (type == ECOMMUNITY_ENCODE_IP) + { + memcpy (&eval->val[2], &ip, sizeof (struct in_addr)); + eval->val[6] = (val >> 8) & 0xff; + eval->val[7] = val & 0xff; + } + else + { + eval->val[2] = (as >> 24) & 0xff; + eval->val[3] = (as >> 16) & 0xff; + eval->val[4] = (as >> 8) & 0xff; + eval->val[5] = as & 0xff; + eval->val[6] = (val >> 8) & 0xff; + eval->val[7] = val & 0xff; + } + + return 0; +} + /* Get next Extended Communities token from the string. */ static const char * ecommunity_gettoken (const char *str, struct ecommunity_val *eval, @@ -318,6 +373,7 @@ ecommunity_gettoken (const char *str, struct ecommunity_val *eval, struct in_addr ip; as_t as = 0; u_int32_t val = 0; + u_char ecomm_type; char buf[INET_ADDRSTRLEN + 1]; /* Skip white space. */ @@ -452,44 +508,15 @@ ecommunity_gettoken (const char *str, struct ecommunity_val *eval, if (!digit || !separator) goto error; - /* Encode result into routing distinguisher. */ + /* Encode result into extended community. */ if (dot) - { - if (val > UINT16_MAX) - goto error; - - eval->val[0] = ECOMMUNITY_ENCODE_IP; - eval->val[1] = 0; - memcpy (&eval->val[2], &ip, sizeof (struct in_addr)); - eval->val[6] = (val >> 8) & 0xff; - eval->val[7] = val & 0xff; - } + ecomm_type = ECOMMUNITY_ENCODE_IP; else if (as > BGP_AS_MAX) - { - if (val > UINT16_MAX) - goto error; - - eval->val[0] = ECOMMUNITY_ENCODE_AS4; - eval->val[1] = 0; - eval->val[2] = (as >>24) & 0xff; - eval->val[3] = (as >>16) & 0xff; - eval->val[4] = (as >>8) & 0xff; - eval->val[5] = as & 0xff; - eval->val[6] = (val >> 8) & 0xff; - eval->val[7] = val & 0xff; - } + ecomm_type = ECOMMUNITY_ENCODE_AS4; else - { - eval->val[0] = ECOMMUNITY_ENCODE_AS; - eval->val[1] = 0; - - eval->val[2] = (as >>8) & 0xff; - eval->val[3] = as & 0xff; - eval->val[4] = (val >>24) & 0xff; - eval->val[5] = (val >>16) & 0xff; - eval->val[6] = (val >>8) & 0xff; - eval->val[7] = val & 0xff; - } + ecomm_type = ECOMMUNITY_ENCODE_AS; + if (ecommunity_encode (ecomm_type, 0, 1, as, ip, val, eval)) + goto error; *token = ecommunity_token_val; return p; @@ -581,6 +608,81 @@ ecommunity_str2com (const char *str, int type, int keyword_included) return ecom; } +static int +ecommunity_rt_soo_str (char *buf, u_int8_t *pnt, int type, + int sub_type, int format) +{ + int len = 0; + const char *prefix; + + /* For parse Extended Community attribute tupple. */ + struct ecommunity_as + { + as_t as; + u_int32_t val; + } eas; + + struct ecommunity_ip + { + struct in_addr ip; + u_int16_t val; + } eip; + + + /* Determine prefix for string, if any. */ + switch (format) + { + case ECOMMUNITY_FORMAT_COMMUNITY_LIST: + prefix = (sub_type == ECOMMUNITY_ROUTE_TARGET ? "rt " : "soo "); + break; + case ECOMMUNITY_FORMAT_DISPLAY: + prefix = (sub_type == ECOMMUNITY_ROUTE_TARGET ? "RT:" : "SoO:"); + break; + case ECOMMUNITY_FORMAT_ROUTE_MAP: + prefix = ""; + break; + default: + prefix = ""; + break; + } + + /* Put string into buffer. */ + if (type == ECOMMUNITY_ENCODE_AS4) + { + eas.as = (*pnt++ << 24); + eas.as |= (*pnt++ << 16); + eas.as |= (*pnt++ << 8); + eas.as |= (*pnt++); + eas.val = (*pnt++ << 8); + eas.val |= (*pnt++); + + len = sprintf (buf, "%s%u:%u", prefix, eas.as, eas.val); + } + else if (type == ECOMMUNITY_ENCODE_AS) + { + eas.as = (*pnt++ << 8); + eas.as |= (*pnt++); + + eas.val = (*pnt++ << 24); + eas.val |= (*pnt++ << 16); + eas.val |= (*pnt++ << 8); + eas.val |= (*pnt++); + + len = sprintf (buf, "%s%u:%u", prefix, eas.as, eas.val); + } + else if (type == ECOMMUNITY_ENCODE_IP) + { + memcpy (&eip.ip, pnt, 4); + pnt += 4; + eip.val = (*pnt++ << 8); + eip.val |= (*pnt++); + + len = sprintf (buf, "%s%s:%u", prefix, inet_ntoa (eip.ip), eip.val); + } + + return len; +} + /* Convert extended community attribute to string. Due to historical reason of industry standard implementation, there @@ -610,29 +712,15 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format, int filter) { int i; u_int8_t *pnt; - int encode = 0; int type = 0; + int sub_type = 0; #define ECOMMUNITY_STR_DEFAULT_LEN 27 int str_size; int str_pnt; char *str_buf; - const char *prefix; int len = 0; int first = 1; - /* For parse Extended Community attribute tupple. */ - struct ecommunity_as - { - as_t as; - u_int32_t val; - } eas; - - struct ecommunity_ip - { - struct in_addr ip; - u_int16_t val; - } eip; - if (ecom->size == 0) { str_buf = XMALLOC (MTYPE_ECOMMUNITY_STR, 1); @@ -648,6 +736,8 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format, int filter) for (i = 0; i < ecom->size; i++) { + int unk_ecom = 0; + /* Make it sure size is enough. */ while (str_pnt + ECOMMUNITY_STR_DEFAULT_LEN >= str_size) { @@ -662,39 +752,39 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format, int filter) pnt = ecom->val + (i * 8); /* High-order octet of type. */ - encode = *pnt++; + type = *pnt++; - switch (encode) + if (type == ECOMMUNITY_ENCODE_AS || + type == ECOMMUNITY_ENCODE_IP || + type == ECOMMUNITY_ENCODE_AS4) { - case ECOMMUNITY_ENCODE_AS: - case ECOMMUNITY_ENCODE_IP: - case ECOMMUNITY_ENCODE_AS4: - break; - - case ECOMMUNITY_ENCODE_OPAQUE: - if(filter == ECOMMUNITY_ROUTE_TARGET) - { - continue; - } + /* Low-order octet of type. */ + sub_type = *pnt++; + if (sub_type != ECOMMUNITY_ROUTE_TARGET && + sub_type != ECOMMUNITY_SITE_ORIGIN) + unk_ecom = 1; + else + len = ecommunity_rt_soo_str (str_buf + str_pnt, pnt, type, + sub_type, format); + } + else if (type == ECOMMUNITY_ENCODE_OPAQUE) + { + if (filter == ECOMMUNITY_ROUTE_TARGET) + continue; if (*pnt == ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP) { uint16_t tunneltype; memcpy (&tunneltype, pnt + 5, 2); tunneltype = ntohs(tunneltype); len = sprintf (str_buf + str_pnt, "ET:%d", tunneltype); - str_pnt += len; - first = 0; - continue; - } - len = sprintf (str_buf + str_pnt, "?"); - str_pnt += len; - first = 0; - continue; - case ECOMMUNITY_ENCODE_EVPN: - if(filter == ECOMMUNITY_ROUTE_TARGET) - { - continue; } + else + unk_ecom = 1; + } + else if (type == ECOMMUNITY_ENCODE_EVPN) + { + if (filter == ECOMMUNITY_ROUTE_TARGET) + continue; if (*pnt == ECOMMUNITY_SITE_ORIGIN) { char macaddr[6]; @@ -703,91 +793,32 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format, int filter) len = sprintf(str_buf + str_pnt, "EVPN:%02x:%02x:%02x:%02x:%02x:%02x", macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]); - str_pnt += len; - first = 0; - continue; } - len = sprintf (str_buf + str_pnt, "?"); - str_pnt += len; - first = 0; - continue; - default: - len = sprintf (str_buf + str_pnt, "?"); - str_pnt += len; - first = 0; - continue; + else if (*pnt == ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY) + { + u_int32_t seqnum; + u_char flags = *++pnt; + + memcpy (&seqnum, pnt + 2, 4); + seqnum = ntohl(seqnum); + if (flags & ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY_FLAG_STICKY) + len = sprintf (str_buf + str_pnt, "MM:%u, sticky MAC", seqnum); + else + len = sprintf (str_buf + str_pnt, "MM:%u", seqnum); + } + else + unk_ecom = 1; } + else + unk_ecom = 1; - /* Low-order octet of type. */ - type = *pnt++; - if (type != ECOMMUNITY_ROUTE_TARGET && type != ECOMMUNITY_SITE_ORIGIN) - { - len = sprintf (str_buf + str_pnt, "?"); - str_pnt += len; - first = 0; - continue; - } - - switch (format) - { - case ECOMMUNITY_FORMAT_COMMUNITY_LIST: - prefix = (type == ECOMMUNITY_ROUTE_TARGET ? "rt " : "soo "); - break; - case ECOMMUNITY_FORMAT_DISPLAY: - prefix = (type == ECOMMUNITY_ROUTE_TARGET ? "RT:" : "SoO:"); - break; - case ECOMMUNITY_FORMAT_ROUTE_MAP: - prefix = ""; - break; - default: - prefix = ""; - break; - } + if (unk_ecom) + len = sprintf (str_buf + str_pnt, "?"); - /* Put string into buffer. */ - if (encode == ECOMMUNITY_ENCODE_AS4) - { - eas.as = (*pnt++ << 24); - eas.as |= (*pnt++ << 16); - eas.as |= (*pnt++ << 8); - eas.as |= (*pnt++); - - eas.val = (*pnt++ << 8); - eas.val |= (*pnt++); - - len = sprintf( str_buf + str_pnt, "%s%u:%u", prefix, - eas.as, eas.val ); - str_pnt += len; - first = 0; - } - if (encode == ECOMMUNITY_ENCODE_AS) - { - eas.as = (*pnt++ << 8); - eas.as |= (*pnt++); - - eas.val = (*pnt++ << 24); - eas.val |= (*pnt++ << 16); - eas.val |= (*pnt++ << 8); - eas.val |= (*pnt++); - - len = sprintf (str_buf + str_pnt, "%s%u:%u", prefix, - eas.as, eas.val); - str_pnt += len; - first = 0; - } - else if (encode == ECOMMUNITY_ENCODE_IP) - { - memcpy (&eip.ip, pnt, 4); - pnt += 4; - eip.val = (*pnt++ << 8); - eip.val |= (*pnt++); - - len = sprintf (str_buf + str_pnt, "%s%s:%u", prefix, - inet_ntoa (eip.ip), eip.val); - str_pnt += len; - first = 0; - } + str_pnt += len; + first = 0; } + return str_buf; } diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h index d6006e81d..9281c0d99 100644 --- a/bgpd/bgp_ecommunity.h +++ b/bgpd/bgp_ecommunity.h @@ -32,12 +32,15 @@ #define ECOMMUNITY_ROUTE_TARGET 0x02 #define ECOMMUNITY_SITE_ORIGIN 0x03 +/* Low-order octet of the Extended Communities type field for EVPN types */ #define ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY 0x00 #define ECOMMUNITY_EVPN_SUBTYPE_ESI_LABEL 0x01 #define ECOMMUNITY_EVPN_SUBTYPE_ES_IMPORT_RT 0x02 #define ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC 0x03 #define ECOMMUNITY_EVPN_SUBTYPE_DEF_GW 0x0d +#define ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY_FLAG_STICKY 0x01 + /* Low-order octet of the Extended Communities type field for OPAQUE types */ #define ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP 0x0c @@ -76,6 +79,54 @@ struct ecommunity_val #define ecom_length(X) ((X)->size * ECOMMUNITY_SIZE) +/* + * Encode BGP Route Target AS:nn. + */ +static inline void +encode_route_target_as (as_t as, u_int32_t val, + struct ecommunity_val *eval) +{ + eval->val[0] = ECOMMUNITY_ENCODE_AS; + eval->val[1] = ECOMMUNITY_ROUTE_TARGET; + eval->val[2] = (as >> 8) & 0xff; + eval->val[3] = as & 0xff; + eval->val[4] = (val >> 24) & 0xff; + eval->val[5] = (val >> 16) & 0xff; + eval->val[6] = (val >> 8) & 0xff; + eval->val[7] = val & 0xff; +} + +/* + * Encode BGP Route Target IP:nn. + */ +static inline void +encode_route_target_ip (struct in_addr ip, u_int16_t val, + struct ecommunity_val *eval) +{ + eval->val[0] = ECOMMUNITY_ENCODE_IP; + eval->val[1] = ECOMMUNITY_ROUTE_TARGET; + memcpy (&eval->val[2], &ip, sizeof (struct in_addr)); + eval->val[6] = (val >> 8) & 0xff; + eval->val[7] = val & 0xff; +} + +/* + * Encode BGP Route Target AS4:nn. + */ +static inline void +encode_route_target_as4 (as_t as, u_int16_t val, + struct ecommunity_val *eval) +{ + eval->val[0] = ECOMMUNITY_ENCODE_AS4; + eval->val[1] = ECOMMUNITY_ROUTE_TARGET; + eval->val[2] = (as >> 24) & 0xff; + eval->val[3] = (as >> 16) & 0xff; + eval->val[4] = (as >> 8) & 0xff; + eval->val[5] = as & 0xff; + eval->val[6] = (val >> 8) & 0xff; + eval->val[7] = val & 0xff; +} + extern void ecommunity_init (void); extern void ecommunity_finish (void); extern void ecommunity_free (struct ecommunity **); diff --git a/bgpd/bgp_encap_tlv.c b/bgpd/bgp_encap_tlv.c index eee2cb72c..89194980d 100644 --- a/bgpd/bgp_encap_tlv.c +++ b/bgpd/bgp_encap_tlv.c @@ -238,7 +238,7 @@ subtlv_encode_remote_endpoint( if (last) {\ last->next = new;\ } else {\ - extra->encap_subtlvs = new;\ + attr->encap_subtlvs = new;\ }\ last = new;\ }\ @@ -249,13 +249,12 @@ bgp_encap_type_l2tpv3overip_to_tlv( struct bgp_encap_type_l2tpv3_over_ip *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); struct bgp_attr_encap_subtlv *last; /* advance to last subtlv */ - for (last = extra->encap_subtlvs; last && last->next; last = last->next); + for (last = attr->encap_subtlvs; last && last->next; last = last->next); - extra->encap_tunneltype = BGP_ENCAP_TYPE_L2TPV3_OVER_IP; + attr->encap_tunneltype = BGP_ENCAP_TYPE_L2TPV3_OVER_IP; assert(CHECK_FLAG(bet->valid_subtlvs, BGP_TEA_SUBTLV_ENCAP)); @@ -270,13 +269,12 @@ bgp_encap_type_gre_to_tlv( struct bgp_encap_type_gre *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); struct bgp_attr_encap_subtlv *last; /* advance to last subtlv */ - for (last = extra->encap_subtlvs; last && last->next; last = last->next); + for (last = attr->encap_subtlvs; last && last->next; last = last->next); - extra->encap_tunneltype = BGP_ENCAP_TYPE_GRE; + attr->encap_tunneltype = BGP_ENCAP_TYPE_GRE; ENC_SUBTLV(BGP_TEA_SUBTLV_ENCAP, subtlv_encode_encap_gre, st_encap); ENC_SUBTLV(BGP_TEA_SUBTLV_PROTO_TYPE, subtlv_encode_proto_type, st_proto); @@ -289,13 +287,12 @@ bgp_encap_type_ip_in_ip_to_tlv( struct bgp_encap_type_ip_in_ip *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); struct bgp_attr_encap_subtlv *last; /* advance to last subtlv */ - for (last = extra->encap_subtlvs; last && last->next; last = last->next); + for (last = attr->encap_subtlvs; last && last->next; last = last->next); - extra->encap_tunneltype = BGP_ENCAP_TYPE_IP_IN_IP; + attr->encap_tunneltype = BGP_ENCAP_TYPE_IP_IN_IP; ENC_SUBTLV(BGP_TEA_SUBTLV_PROTO_TYPE, subtlv_encode_proto_type, st_proto); ENC_SUBTLV(BGP_TEA_SUBTLV_COLOR, subtlv_encode_color, st_color); @@ -307,13 +304,12 @@ bgp_encap_type_transmit_tunnel_endpoint( struct bgp_encap_type_transmit_tunnel_endpoint *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); struct bgp_attr_encap_subtlv *last; /* advance to last subtlv */ - for (last = extra->encap_subtlvs; last && last->next; last = last->next); + for (last = attr->encap_subtlvs; last && last->next; last = last->next); - extra->encap_tunneltype = BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT; + attr->encap_tunneltype = BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT; /* no subtlvs for this type */ } @@ -323,13 +319,12 @@ bgp_encap_type_ipsec_in_tunnel_mode_to_tlv( struct bgp_encap_type_ipsec_in_tunnel_mode *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); struct bgp_attr_encap_subtlv *last; /* advance to last subtlv */ - for (last = extra->encap_subtlvs; last && last->next; last = last->next); + for (last = attr->encap_subtlvs; last && last->next; last = last->next); - extra->encap_tunneltype = BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE; + attr->encap_tunneltype = BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE; ENC_SUBTLV(BGP_TEA_SUBTLV_IPSEC_TA, subtlv_encode_ipsec_ta, st_ipsec_ta); } @@ -339,13 +334,12 @@ bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode_to_tlv( struct bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); struct bgp_attr_encap_subtlv *last; /* advance to last subtlv */ - for (last = extra->encap_subtlvs; last && last->next; last = last->next); + for (last = attr->encap_subtlvs; last && last->next; last = last->next); - extra->encap_tunneltype = BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE; + attr->encap_tunneltype = BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE; ENC_SUBTLV(BGP_TEA_SUBTLV_IPSEC_TA, subtlv_encode_ipsec_ta, st_ipsec_ta); } @@ -355,13 +349,12 @@ bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode_to_tlv( struct bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); struct bgp_attr_encap_subtlv *last; /* advance to last subtlv */ - for (last = extra->encap_subtlvs; last && last->next; last = last->next); + for (last = attr->encap_subtlvs; last && last->next; last = last->next); - extra->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE; + attr->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE; ENC_SUBTLV(BGP_TEA_SUBTLV_IPSEC_TA, subtlv_encode_ipsec_ta, st_ipsec_ta); } @@ -371,13 +364,12 @@ bgp_encap_type_pbb_to_tlv( struct bgp_encap_type_pbb *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); struct bgp_attr_encap_subtlv *last; /* advance to last subtlv */ - for (last = extra->encap_subtlvs; last && last->next; last = last->next); + for (last = attr->encap_subtlvs; last && last->next; last = last->next); - extra->encap_tunneltype = BGP_ENCAP_TYPE_PBB; + attr->encap_tunneltype = BGP_ENCAP_TYPE_PBB; assert(CHECK_FLAG(bet->valid_subtlvs, BGP_TEA_SUBTLV_ENCAP)); ENC_SUBTLV(BGP_TEA_SUBTLV_ENCAP, subtlv_encode_encap_pbb, st_encap); @@ -388,16 +380,15 @@ bgp_encap_type_vxlan_to_tlv( struct bgp_encap_type_vxlan *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); struct bgp_attr_encap_subtlv *tlv; uint32_t vnid; - extra->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN; + attr->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN; if(bet == NULL ||!bet->vnid) return; - if(extra->encap_subtlvs) - XFREE(MTYPE_ENCAP_TLV, extra->encap_subtlvs); + if(attr->encap_subtlvs) + XFREE(MTYPE_ENCAP_TLV, attr->encap_subtlvs); tlv = XCALLOC (MTYPE_ENCAP_TLV, sizeof(struct bgp_attr_encap_subtlv)-1+12); tlv->type = 1; /* encapsulation type */ tlv->length = 12; @@ -411,7 +402,7 @@ bgp_encap_type_vxlan_to_tlv( char *ptr = (char *)&tlv->value + 4; memcpy( ptr, bet->mac_address, 6); } - extra->encap_subtlvs = tlv; + attr->encap_subtlvs = tlv; return; } @@ -420,9 +411,7 @@ bgp_encap_type_nvgre_to_tlv( struct bgp_encap_type_nvgre *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); - - extra->encap_tunneltype = BGP_ENCAP_TYPE_NVGRE; + attr->encap_tunneltype = BGP_ENCAP_TYPE_NVGRE; } void @@ -438,9 +427,7 @@ bgp_encap_type_mpls_in_gre_to_tlv( struct bgp_encap_type_mpls_in_gre *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); - - extra->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_GRE; + attr->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_GRE; } void @@ -448,9 +435,8 @@ bgp_encap_type_vxlan_gpe_to_tlv( struct bgp_encap_type_vxlan_gpe *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); - extra->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN_GPE; + attr->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN_GPE; } void @@ -458,9 +444,8 @@ bgp_encap_type_mpls_in_udp_to_tlv( struct bgp_encap_type_mpls_in_udp *bet, /* input structure */ struct attr *attr) { - struct attr_extra *extra = bgp_attr_extra_get(attr); - extra->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_UDP; + attr->encap_tunneltype = BGP_ENCAP_TYPE_MPLS_IN_UDP; } diff --git a/bgpd/bgp_encap_types.h b/bgpd/bgp_encap_types.h index ffeb2f61e..03664fe7a 100644 --- a/bgpd/bgp_encap_types.h +++ b/bgpd/bgp_encap_types.h @@ -19,6 +19,8 @@ #ifndef _QUAGGA_BGP_ENCAP_TYPES_H #define _QUAGGA_BGP_ENCAP_TYPES_H +#include "bgpd/bgp_ecommunity.h" + /* from http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#tunnel-types */ typedef enum { BGP_ENCAP_TYPE_RESERVED=0, @@ -213,4 +215,15 @@ struct bgp_encap_type_pbb { struct bgp_tea_subtlv_encap_pbb st_encap; }; +static inline void +encode_encap_extcomm (bgp_encap_types tnl_type, + struct ecommunity_val *eval) +{ + memset (eval, 0, sizeof (*eval)); + eval->val[0] = ECOMMUNITY_ENCODE_OPAQUE; + eval->val[1] = ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP; + eval->val[6] = ((tnl_type) >> 8) & 0xff; + eval->val[7] = (tnl_type) & 0xff; +} + #endif /* _QUAGGA_BGP_ENCAP_TYPES_H */ diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 34a3315c0..46e97cc50 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -1,7 +1,8 @@ /* Ethernet-VPN Packet and vty Processing File * Copyright (C) 2016 6WIND + * Copyright (C) 2017 Cumulus Networks, Inc. * - * This file is part of FRRouting. + * This file is part of FRR. * * FRRouting is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -26,6 +27,10 @@ #include "log.h" #include "memory.h" #include "stream.h" +#include "hash.h" +#include "jhash.h" +#include "bitfield.h" +#include "zclient.h" #include "bgpd/bgp_attr_evpn.h" #include "bgpd/bgpd.h" @@ -35,193 +40,2817 @@ #include "bgpd/bgp_mplsvpn.h" #include "bgpd/bgp_label.h" #include "bgpd/bgp_evpn.h" +#include "bgpd/bgp_evpn_private.h" +#include "bgpd/bgp_ecommunity.h" +#include "bgpd/bgp_encap_types.h" +#include "bgpd/bgp_debug.h" +#include "bgpd/bgp_aspath.h" + +/* + * Definitions and external declarations. + */ +extern struct zclient *zclient; + +DEFINE_QOBJ_TYPE(bgpevpn) + + +/* + * Static function declarations + */ +static void +delete_evpn_route_entry (struct bgp *bgp, struct bgpevpn *vpn, + afi_t afi, safi_t safi, struct bgp_node *rn, + struct bgp_info **ri); +static int +delete_all_vni_routes (struct bgp *bgp, struct bgpevpn *vpn); + +/* + * Private functions. + */ + +/* + * Make vni hash key. + */ +static unsigned int +vni_hash_key_make(void *p) +{ + struct bgpevpn *vpn = p; + return (jhash_1word(vpn->vni, 0)); +} + +/* + * Comparison function for vni hash + */ +static int +vni_hash_cmp (const void *p1, const void *p2) +{ + const struct bgpevpn *vpn1 = p1; + const struct bgpevpn *vpn2 = p2; + + if (!vpn1 && !vpn2) + return 1; + if (!vpn1 || !vpn2) + return 0; + return(vpn1->vni == vpn2->vni); +} + +/* + * Make import route target hash key. + */ +static unsigned int +import_rt_hash_key_make (void *p) +{ + struct irt_node *irt = p; + char *pnt = irt->rt.val; + unsigned int key = 0; + int c=0; + + key += pnt[c]; + key += pnt[c + 1]; + key += pnt[c + 2]; + key += pnt[c + 3]; + key += pnt[c + 4]; + key += pnt[c + 5]; + key += pnt[c + 6]; + key += pnt[c + 7]; + + return (key); +} + +/* + * Comparison function for import rt hash + */ +static int +import_rt_hash_cmp (const void *p1, const void *p2) +{ + const struct irt_node *irt1 = p1; + const struct irt_node *irt2 = p2; + + if (irt1 == NULL && irt2 == NULL) + return 1; + + if (irt1 == NULL || irt2 == NULL) + return 0; + + return(memcmp(irt1->rt.val, irt2->rt.val, ECOMMUNITY_SIZE) == 0); +} + +/* + * Create a new import_rt + */ +static struct irt_node * +import_rt_new (struct bgp *bgp, struct ecommunity_val *rt) +{ + struct irt_node *irt; + + if (!bgp) + return NULL; + + irt = XCALLOC (MTYPE_BGP_EVPN_IMPORT_RT, sizeof (struct irt_node)); + if (!irt) + return NULL; + + irt->rt = *rt; + irt->vnis = list_new (); + + /* Add to hash */ + if (!hash_get(bgp->import_rt_hash, irt, hash_alloc_intern)) + { + XFREE(MTYPE_BGP_EVPN_IMPORT_RT, irt); + return NULL; + } + + return irt; +} + +/* + * Free the import rt node + */ +static void +import_rt_free (struct bgp *bgp, struct irt_node *irt) +{ + hash_release(bgp->import_rt_hash, irt); + XFREE(MTYPE_BGP_EVPN_IMPORT_RT, irt); +} + +/* + * Function to lookup Import RT node - used to map a RT to set of + * VNIs importing routes with that RT. + */ +static struct irt_node * +lookup_import_rt (struct bgp *bgp, struct ecommunity_val *rt) +{ + struct irt_node *irt; + struct irt_node tmp; + + memset(&tmp, 0, sizeof(struct irt_node)); + memcpy(&tmp.rt, rt, ECOMMUNITY_SIZE); + irt = hash_lookup(bgp->import_rt_hash, &tmp); + return irt; +} + +/* + * Is specified VNI present on the RT's list of "importing" VNIs? + */ +static int +is_vni_present_in_irt_vnis (struct list *vnis, struct bgpevpn *vpn) +{ + struct listnode *node, *nnode; + struct bgpevpn *tmp_vpn; + + for (ALL_LIST_ELEMENTS (vnis, node, nnode, tmp_vpn)) + { + if (tmp_vpn == vpn) + return 1; + } + + return 0; +} + +/* + * Compare Route Targets. + */ +static int +evpn_route_target_cmp (struct ecommunity *ecom1, struct ecommunity *ecom2) +{ + if (ecom1 && !ecom2) + return -1; + + if (!ecom1 && ecom2) + return 1; + + if (!ecom1 && !ecom2) + return 0; + + if (ecom1->str && !ecom2->str) + return -1; + + if (!ecom1->str && ecom2->str) + return 1; + + if (!ecom1->str && !ecom2->str) + return 0; + + return strcmp(ecom1->str, ecom2->str); +} + +/* + * Mask off global-admin field of specified extended community (RT), + * just retain the local-admin field. + */ +static inline void +mask_ecom_global_admin (struct ecommunity_val *dst, + struct ecommunity_val *src) +{ + u_char type; + + type = src->val[0]; + dst->val[0] = 0; + if (type == ECOMMUNITY_ENCODE_AS) + { + dst->val[2] = dst->val[3] = 0; + } + else if (type == ECOMMUNITY_ENCODE_AS4 || + type == ECOMMUNITY_ENCODE_IP) + { + dst->val[2] = dst->val[3] = 0; + dst->val[4] = dst->val[5] = 0; + } +} + +/* + * Map one RT to specified VNI. + */ +static void +map_vni_to_rt (struct bgp *bgp, struct bgpevpn *vpn, + struct ecommunity_val *eval) +{ + struct irt_node *irt; + struct ecommunity_val eval_tmp; + + /* If using "automatic" RT, we only care about the local-admin sub-field. + * This is to facilitate using VNI as the RT for EBGP peering too. + */ + memcpy (&eval_tmp, eval, ECOMMUNITY_SIZE); + if (!is_import_rt_configured (vpn)) + mask_ecom_global_admin (&eval_tmp, eval); + + irt = lookup_import_rt (bgp, &eval_tmp); + if (irt && irt->vnis) + if (is_vni_present_in_irt_vnis (irt->vnis, vpn)) + /* Already mapped. */ + return; + + if (!irt) + { + irt = import_rt_new (bgp, &eval_tmp); + assert (irt); + } + + /* Add VNI to the hash list for this RT. */ + listnode_add (irt->vnis, vpn); +} + +/* + * Unmap specified VNI from specified RT. If there are no other + * VNIs for this RT, then the RT hash is deleted. + */ +static void +unmap_vni_from_rt (struct bgp *bgp, struct bgpevpn *vpn, + struct irt_node *irt) +{ + /* Delete VNI from hash list for this RT. */ + listnode_delete (irt->vnis, vpn); + if (!listnode_head (irt->vnis)) + { + list_free (irt->vnis); + import_rt_free (bgp, irt); + } +} + +/* + * Create RT extended community automatically from passed information: + * of the form AS:VNI. + * NOTE: We use only the lower 16 bits of the AS. This is sufficient as + * the need is to get a RT value that will be unique across different + * VNIs but the same across routers (in the same AS) for a particular + * VNI. + */ +static void +form_auto_rt (struct bgp *bgp, struct bgpevpn *vpn, + struct list *rtl) +{ + struct ecommunity_val eval; + struct ecommunity *ecomadd; + + encode_route_target_as ((bgp->as & 0xFFFF), vpn->vni, &eval); + + ecomadd = ecommunity_new (); + ecommunity_add_val (ecomadd, &eval); + listnode_add_sort (rtl, ecomadd); +} + +/* + * Derive RD and RT for a VNI automatically. Invoked at the time of + * creation of a VNI. + */ +static void +derive_rd_rt_for_vni (struct bgp *bgp, struct bgpevpn *vpn) +{ + bgp_evpn_derive_auto_rd (bgp, vpn); + bgp_evpn_derive_auto_rt_import (bgp, vpn); + bgp_evpn_derive_auto_rt_export (bgp, vpn); +} + +/* + * Add (update) or delete MACIP from zebra. + */ +static int +bgp_zebra_send_remote_macip (struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_evpn *p, + struct in_addr remote_vtep_ip, + int add, u_char sticky) +{ + struct stream *s; + int ipa_len; + char buf1[ETHER_ADDR_STRLEN]; + char buf2[INET6_ADDRSTRLEN]; + char buf3[INET6_ADDRSTRLEN]; + + /* Check socket. */ + if (!zclient || zclient->sock < 0) + return 0; + + /* Don't try to register if Zebra doesn't know of this instance. */ + if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) + return 0; + + s = zclient->obuf; + stream_reset (s); + + zclient_create_header (s, add ? ZEBRA_REMOTE_MACIP_ADD : ZEBRA_REMOTE_MACIP_DEL, + bgp->vrf_id); + stream_putl(s, vpn->vni); + stream_put (s, &p->prefix.mac.octet, ETHER_ADDR_LEN); /* Mac Addr */ + /* IP address length and IP address, if any. */ + if (IS_EVPN_PREFIX_IPADDR_NONE(p)) + stream_putl(s, 0); + else + { + ipa_len = IS_EVPN_PREFIX_IPADDR_V4(p) ? + IPV4_MAX_BYTELEN : IPV6_MAX_BYTELEN; + stream_putl(s, ipa_len); + stream_put (s, &p->prefix.ip.ip.addr, ipa_len); + } + stream_put_in_addr(s, &remote_vtep_ip); + + /* TX MAC sticky status */ + if (add) + stream_putc (s, sticky); + + stream_putw_at (s, 0, stream_get_endp (s)); + + if (bgp_debug_zebra (NULL)) + zlog_debug("Tx %s MACIP, VNI %u %sMAC %s IP %s remote VTEP %s", + add ? "ADD" : "DEL", vpn->vni, + sticky ? "sticky " : "", + prefix_mac2str (&p->prefix.mac, buf1, sizeof(buf1)), + ipaddr2str (&p->prefix.ip, buf3, sizeof(buf3)), + inet_ntop(AF_INET, &remote_vtep_ip, buf2, sizeof(buf2))); + + return zclient_send_message(zclient); +} + +/* + * Add (update) or delete remote VTEP from zebra. + */ +static int +bgp_zebra_send_remote_vtep (struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_evpn *p, int add) +{ + struct stream *s; + + /* Check socket. */ + if (!zclient || zclient->sock < 0) + return 0; + + /* Don't try to register if Zebra doesn't know of this instance. */ + if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) + return 0; + + s = zclient->obuf; + stream_reset (s); + + zclient_create_header (s, add ? ZEBRA_REMOTE_VTEP_ADD : ZEBRA_REMOTE_VTEP_DEL, + bgp->vrf_id); + stream_putl(s, vpn->vni); + if (IS_EVPN_PREFIX_IPADDR_V4(p)) + stream_put_in_addr(s, &p->prefix.ip.ipaddr_v4); + else if (IS_EVPN_PREFIX_IPADDR_V6(p)) + { + zlog_err ("Bad remote IP when trying to %s remote VTEP for VNI %u", + add ? "ADD" : "DEL", vpn->vni); + return -1; + } + + stream_putw_at (s, 0, stream_get_endp (s)); + + if (bgp_debug_zebra (NULL)) + zlog_debug("Tx %s Remote VTEP, VNI %u remote VTEP %s", + add ? "ADD" : "DEL", vpn->vni, + inet_ntoa (p->prefix.ip.ipaddr_v4)); + + return zclient_send_message(zclient); +} + +/* + * Build extended communities for EVPN route. RT and ENCAP are + * applicable to all routes. + */ +static void +build_evpn_route_extcomm (struct bgpevpn *vpn, struct attr *attr) +{ + struct ecommunity ecom_encap; + struct ecommunity ecom_sticky; + struct ecommunity_val eval; + struct ecommunity_val eval_sticky; + bgp_encap_types tnl_type; + struct listnode *node, *nnode; + struct ecommunity *ecom; + u_int32_t seqnum; + + /* Encap */ + tnl_type = BGP_ENCAP_TYPE_VXLAN; + memset (&ecom_encap, 0, sizeof (ecom_encap)); + encode_encap_extcomm (tnl_type, &eval); + ecom_encap.size = 1; + ecom_encap.val = (u_int8_t *)eval.val; + + /* Add Encap */ + attr->ecommunity = ecommunity_dup (&ecom_encap); + + /* Add the export RTs */ + for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) + attr->ecommunity = ecommunity_merge (attr->ecommunity, ecom); + + if (attr->sticky) + { + seqnum = 0; + memset (&ecom_sticky, 0, sizeof (ecom_sticky)); + encode_mac_mobility_extcomm(1, seqnum, &eval_sticky); + ecom_sticky.size = 1; + ecom_sticky.val = (u_int8_t *)eval_sticky.val; + attr->ecommunity = ecommunity_merge (attr->ecommunity, &ecom_sticky); + } + + attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES); +} + +/* + * Add MAC mobility extended community to attribute. + */ +static void +add_mac_mobility_to_attr (u_int32_t seq_num, struct attr *attr) +{ + struct ecommunity ecom_tmp; + struct ecommunity_val eval; + struct ecommunity *ecom_mm; + int i; + u_int8_t *pnt; + int type = 0; + int sub_type = 0; + + /* Build MM */ + encode_mac_mobility_extcomm (0, seq_num, &eval); + + /* Find current MM ecommunity */ + ecom_mm = NULL; + + if (attr->ecommunity) + { + for (i = 0; i < attr->ecommunity->size; i++) + { + pnt = attr->ecommunity->val + (i * 8); + type = *pnt++; + sub_type = *pnt++; + + if (type == ECOMMUNITY_ENCODE_EVPN && sub_type == ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY) + { + ecom_mm = (struct ecommunity*) attr->ecommunity->val + (i * 8); + break; + } + } + } + + /* Update the existing MM ecommunity */ + if (ecom_mm) + { + memcpy(ecom_mm->val, eval.val, sizeof(char) * ECOMMUNITY_SIZE); + } + /* Add MM to existing */ + else + { + memset (&ecom_tmp, 0, sizeof (ecom_tmp)); + ecom_tmp.size = 1; + ecom_tmp.val = (u_int8_t *)eval.val; + + attr->ecommunity = ecommunity_merge (attr->ecommunity, &ecom_tmp); + } +} + +/* Install EVPN route into zebra. */ +static int +evpn_zebra_install (struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_evpn *p, struct in_addr remote_vtep_ip, + u_char sticky) +{ + int ret; + + if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) + ret = bgp_zebra_send_remote_macip (bgp, vpn, p, remote_vtep_ip, 1, sticky); + else + ret = bgp_zebra_send_remote_vtep (bgp, vpn, p, 1); + + return ret; +} + +/* Uninstall EVPN route from zebra. */ +static int +evpn_zebra_uninstall (struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_evpn *p, struct in_addr remote_vtep_ip) +{ + int ret; + + if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) + ret = bgp_zebra_send_remote_macip (bgp, vpn, p, remote_vtep_ip, 0, 0); + else + ret = bgp_zebra_send_remote_vtep (bgp, vpn, p, 0); + + return ret; +} + +/* + * Due to MAC mobility, the prior "local" best route has been supplanted + * by a "remote" best route. The prior route has to be deleted and withdrawn + * from peers. + */ +static void +evpn_delete_old_local_route (struct bgp *bgp, struct bgpevpn *vpn, + struct bgp_node *rn, struct bgp_info *old_local) +{ + struct bgp_node *global_rn; + struct bgp_info *ri; + afi_t afi = AFI_L2VPN; + safi_t safi = SAFI_EVPN; + + /* Locate route node in the global EVPN routing table. Note that + * this table is a 2-level tree (RD-level + Prefix-level) similar to + * L3VPN routes. + */ + global_rn = bgp_afi_node_lookup (bgp->rib[afi][safi], afi, safi, + (struct prefix *)&rn->p, &vpn->prd); + if (global_rn) + { + /* Delete route entry in the global EVPN table. */ + delete_evpn_route_entry (bgp, vpn, afi, safi, global_rn, &ri); + + /* Schedule for processing - withdraws to peers happen from + * this table. + */ + if (ri) + bgp_process (bgp, global_rn, afi, safi); + bgp_unlock_node (global_rn); + } + + /* Delete route entry in the VNI route table, caller to remove. */ + bgp_info_delete (rn, old_local); +} + +/* + * Calculate the best path for an EVPN route. Install/update best path in zebra, + * if appropriate. + */ +static int +evpn_route_select_install (struct bgp *bgp, struct bgpevpn *vpn, + struct bgp_node *rn) +{ + struct bgp_info *old_select, *new_select; + struct bgp_info_pair old_and_new; + afi_t afi = AFI_L2VPN; + safi_t safi = SAFI_EVPN; + int ret = 0; + + /* Compute the best path. */ + bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], + &old_and_new, afi, safi); + old_select = old_and_new.old; + new_select = old_and_new.new; + + /* If the best path hasn't changed - see if there is still something to update + * to zebra RIB. + */ + if (old_select && old_select == new_select && + old_select->type == ZEBRA_ROUTE_BGP && + old_select->sub_type == BGP_ROUTE_NORMAL && + !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR) && + !CHECK_FLAG(old_select->flags, BGP_INFO_ATTR_CHANGED) && + !bgp->addpath_tx_used[afi][safi]) + { + if (bgp_zebra_has_route_changed (rn, old_select)) + ret = evpn_zebra_install (bgp, vpn, (struct prefix_evpn *)&rn->p, + old_select->attr->nexthop, + old_select->attr->sticky); + UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); + bgp_zebra_clear_route_change_flags (rn); + return ret; + } + + /* If the user did a "clear" this flag will be set */ + UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); + + /* bestpath has changed; update relevant fields and install or uninstall + * into the zebra RIB. + */ + if (old_select || new_select) + bgp_bump_version(rn); + + if (old_select) + bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); + if (new_select) + { + bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); + bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); + UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); + } + + if (new_select + && new_select->type == ZEBRA_ROUTE_BGP + && new_select->sub_type == BGP_ROUTE_NORMAL) + { + ret = evpn_zebra_install (bgp, vpn, (struct prefix_evpn *) &rn->p, + new_select->attr->nexthop, + new_select->attr->sticky); + /* If an old best existed and it was a "local" route, the only reason + * it would be supplanted is due to MAC mobility procedures. So, we + * need to do an implicit delete and withdraw that route from peers. + */ + if (old_select + && old_select->peer == bgp->peer_self + && old_select->type == ZEBRA_ROUTE_BGP + && old_select->sub_type == BGP_ROUTE_STATIC) + evpn_delete_old_local_route (bgp, vpn, rn, old_select); + } + else + { + if (old_select + && old_select->type == ZEBRA_ROUTE_BGP + && old_select->sub_type == BGP_ROUTE_NORMAL) + ret = evpn_zebra_uninstall (bgp, vpn, (struct prefix_evpn *) &rn->p, + old_select->attr->nexthop); + } + + /* Clear any route change flags. */ + bgp_zebra_clear_route_change_flags (rn); + + /* Reap old select bgp_info, if it has been removed */ + if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) + bgp_info_reap (rn, old_select); + + return ret; +} + + +/* + * Return true if the local ri for this rn has sticky set + */ +static int +evpn_route_is_sticky (struct bgp *bgp, struct bgp_node *rn) +{ + struct bgp_info *tmp_ri; + struct bgp_info *local_ri; + + local_ri = NULL; + for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) + { + if (tmp_ri->peer == bgp->peer_self + && tmp_ri->type == ZEBRA_ROUTE_BGP + && tmp_ri->sub_type == BGP_ROUTE_STATIC) + local_ri = tmp_ri; + } + + if (!local_ri) + return 0; + + return local_ri->attr->sticky; +} + +/* + * Create or update EVPN route entry. This could be in the VNI route table + * or the global route table. + */ +static int +update_evpn_route_entry (struct bgp *bgp, struct bgpevpn *vpn, afi_t afi, + safi_t safi, struct bgp_node *rn, struct attr *attr, + int add, int vni_table, struct bgp_info **ri) +{ + struct bgp_info *tmp_ri; + struct bgp_info *local_ri, *remote_ri; + struct attr *attr_new; + mpls_label_t label = MPLS_INVALID_LABEL; + int route_change = 1; + u_char sticky = 0; + + *ri = NULL; + + /* See if this is an update of an existing route, or a new add. Also, + * identify if already known from remote, and if so, the one with the + * highest sequence number; this is only when adding to the VNI routing + * table. + */ + local_ri = remote_ri = NULL; + for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) + { + if (tmp_ri->peer == bgp->peer_self + && tmp_ri->type == ZEBRA_ROUTE_BGP + && tmp_ri->sub_type == BGP_ROUTE_STATIC) + local_ri = tmp_ri; + if (vni_table) + { + if (tmp_ri->type == ZEBRA_ROUTE_BGP + && tmp_ri->sub_type == BGP_ROUTE_NORMAL + && CHECK_FLAG (tmp_ri->flags, BGP_INFO_VALID)) + { + if (!remote_ri) + remote_ri = tmp_ri; + else if (mac_mobility_seqnum (tmp_ri->attr) > + mac_mobility_seqnum (remote_ri->attr)) + remote_ri = tmp_ri; + } + } + } + + /* If route doesn't exist already, create a new one, if told to. + * Otherwise act based on whether the attributes of the route have + * changed or not. + */ + if (!local_ri && !add) + return 0; + + if (!local_ri) + { + /* When learnt locally for the first time but already known from + * remote, we have to initiate appropriate MAC mobility steps. This + * is applicable when updating the VNI routing table. + */ + if (remote_ri) + { + u_int32_t cur_seqnum; + + /* Add MM extended community to route. */ + cur_seqnum = mac_mobility_seqnum (remote_ri->attr); + add_mac_mobility_to_attr (cur_seqnum + 1, attr); + } + + /* Add (or update) attribute to hash. */ + attr_new = bgp_attr_intern (attr); + + /* Extract MAC mobility sequence number, if any. */ + attr_new->mm_seqnum = bgp_attr_mac_mobility_seqnum (attr_new, &sticky); + attr_new->sticky = sticky; + + /* Create new route with its attribute. */ + tmp_ri = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, + bgp->peer_self, attr_new, rn); + SET_FLAG (tmp_ri->flags, BGP_INFO_VALID); + bgp_info_extra_get(tmp_ri); + + /* The VNI goes into the 'label' field of the route */ + vni2label (vpn->vni, &label); + + memcpy (&tmp_ri->extra->label, &label, BGP_LABEL_BYTES); + bgp_info_add (rn, tmp_ri); + } + else + { + tmp_ri = local_ri; + if (attrhash_cmp (tmp_ri->attr, attr) && + !CHECK_FLAG(tmp_ri->flags, BGP_INFO_REMOVED)) + route_change = 0; + else + { + /* The attribute has changed. */ + /* Add (or update) attribute to hash. */ + attr_new = bgp_attr_intern (attr); + bgp_info_set_flag (rn, tmp_ri, BGP_INFO_ATTR_CHANGED); + + /* Restore route, if needed. */ + if (CHECK_FLAG(tmp_ri->flags, BGP_INFO_REMOVED)) + bgp_info_restore(rn, tmp_ri); + + /* Unintern existing, set to new. */ + bgp_attr_unintern (&tmp_ri->attr); + tmp_ri->attr = attr_new; + tmp_ri->uptime = bgp_clock (); + } + } + + /* Return back the route entry. */ + *ri = tmp_ri; + return route_change; +} + +/* + * Create or update EVPN route (of type based on prefix) for specified VNI + * and schedule for processing. + */ +static int +update_evpn_route (struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_evpn *p, u_char sticky) +{ + struct bgp_node *rn; + struct attr attr; + struct attr *attr_new; + struct bgp_info *ri; + afi_t afi = AFI_L2VPN; + safi_t safi = SAFI_EVPN; + int route_change; + + memset (&attr, 0, sizeof (struct attr)); + + /* Build path-attribute for this route. */ + bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); + attr.nexthop = vpn->originator_ip; + attr.mp_nexthop_global_in = vpn->originator_ip; + attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4; + attr.sticky = sticky; + + /* Set up RT and ENCAP extended community. */ + build_evpn_route_extcomm (vpn, &attr); + + /* First, create (or fetch) route node within the VNI. */ + /* NOTE: There is no RD here. */ + rn = bgp_node_get (vpn->route_table, (struct prefix *)p); + + /* Create or update route entry. */ + route_change = update_evpn_route_entry (bgp, vpn, afi, safi, + rn, &attr, 1, 1, &ri); + assert (ri); + attr_new = ri->attr; + + /* Perform route selection; this is just to set the flags correctly + * as local route in the VNI always wins. + */ + evpn_route_select_install (bgp, vpn, rn); + bgp_unlock_node (rn); + + /* If this is a new route or some attribute has changed, export the + * route to the global table. The route will be advertised to peers + * from there. Note that this table is a 2-level tree (RD-level + + * Prefix-level) similar to L3VPN routes. + */ + if (route_change) + { + struct bgp_info *global_ri; + + rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, + (struct prefix *)p, &vpn->prd); + update_evpn_route_entry (bgp, vpn, afi, safi, rn, + attr_new, 1, 0, &global_ri); + + /* Schedule for processing and unlock node. */ + bgp_process (bgp, rn, afi, safi); + bgp_unlock_node (rn); + } + + /* Unintern temporary. */ + aspath_unintern (&attr.aspath); + + return 0; +} + +/* + * Delete EVPN route entry. This could be in the VNI route table + * or the global route table. + */ +static void +delete_evpn_route_entry (struct bgp *bgp, struct bgpevpn *vpn, + afi_t afi, safi_t safi, struct bgp_node *rn, + struct bgp_info **ri) +{ + struct bgp_info *tmp_ri; + + *ri = NULL; + + /* Now, find matching route. */ + for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) + if (tmp_ri->peer == bgp->peer_self + && tmp_ri->type == ZEBRA_ROUTE_BGP + && tmp_ri->sub_type == BGP_ROUTE_STATIC) + break; + + *ri = tmp_ri; + + /* Mark route for delete. */ + if (tmp_ri) + bgp_info_delete (rn, tmp_ri); +} + +/* + * Delete EVPN route (of type based on prefix) for specified VNI and + * schedule for processing. + */ +static int +delete_evpn_route (struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_evpn *p) +{ + struct bgp_node *rn, *global_rn; + struct bgp_info *ri; + afi_t afi = AFI_L2VPN; + safi_t safi = SAFI_EVPN; + + /* First, locate the route node within the VNI. If it doesn't exist, there + * is nothing further to do. + */ + /* NOTE: There is no RD here. */ + rn = bgp_node_lookup (vpn->route_table, (struct prefix *)p); + if (!rn) + return 0; + + /* Next, locate route node in the global EVPN routing table. Note that + * this table is a 2-level tree (RD-level + Prefix-level) similar to + * L3VPN routes. + */ + global_rn = bgp_afi_node_lookup (bgp->rib[afi][safi], afi, safi, + (struct prefix *)p, &vpn->prd); + if (global_rn) + { + /* Delete route entry in the global EVPN table. */ + delete_evpn_route_entry (bgp, vpn, afi, safi, global_rn, &ri); + + /* Schedule for processing - withdraws to peers happen from + * this table. + */ + if (ri) + bgp_process (bgp, global_rn, afi, safi); + bgp_unlock_node (global_rn); + } + + /* Delete route entry in the VNI route table. This can just be removed. */ + delete_evpn_route_entry (bgp, vpn, afi, safi, rn, &ri); + if (ri) + bgp_info_reap (rn, ri); + bgp_unlock_node (rn); + + return 0; +} + +/* + * Update all type-2 (MACIP) local routes for this VNI - these should also + * be scheduled for advertise to peers. + */ +static int +update_all_type2_routes (struct bgp *bgp, struct bgpevpn *vpn) +{ + afi_t afi; + safi_t safi; + struct bgp_node *rn; + struct bgp_info *ri; + struct attr attr; + struct attr attr_sticky; + struct attr *attr_new; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + memset (&attr, 0, sizeof (struct attr)); + memset (&attr_sticky, 0, sizeof (struct attr)); + + /* Build path-attribute - all type-2 routes for this VNI will share the + * same path attribute. + */ + bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); + bgp_attr_default_set (&attr_sticky, BGP_ORIGIN_IGP); + attr.nexthop = vpn->originator_ip; + attr.mp_nexthop_global_in = vpn->originator_ip; + attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4; + attr_sticky.nexthop = vpn->originator_ip; + attr_sticky.mp_nexthop_global_in = vpn->originator_ip; + attr_sticky.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4; + attr_sticky.sticky = 1; + + /* Set up RT, ENCAP and sticky MAC extended community. */ + build_evpn_route_extcomm (vpn, &attr); + build_evpn_route_extcomm (vpn, &attr_sticky); + + /* Walk this VNI's route table and update local type-2 routes. For any + * routes updated, update corresponding entry in the global table too. + */ + for (rn = bgp_table_top (vpn->route_table); rn; rn = bgp_route_next (rn)) + { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + struct bgp_node *rd_rn; + struct bgp_info *global_ri; + + if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE) + continue; + + if (evpn_route_is_sticky (bgp, rn)) + update_evpn_route_entry (bgp, vpn, afi, safi, rn, &attr_sticky, 0, 1, &ri); + else + update_evpn_route_entry (bgp, vpn, afi, safi, rn, &attr, 0, 1, &ri); + + /* If a local route exists for this prefix, we need to update + * the global routing table too. + */ + if (!ri) + continue; + + /* Perform route selection; this is just to set the flags correctly + * as local route in the VNI always wins. + */ + evpn_route_select_install (bgp, vpn, rn); + + attr_new = ri->attr; + + /* Update route in global routing table. */ + rd_rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, + (struct prefix *)evp, &vpn->prd); + assert (rd_rn); + update_evpn_route_entry (bgp, vpn, afi, safi, rd_rn, + attr_new, 0, 0, &global_ri); + + /* Schedule for processing and unlock node. */ + bgp_process (bgp, rd_rn, afi, safi); + bgp_unlock_node (rd_rn); + } + + /* Unintern temporary. */ + aspath_unintern (&attr.aspath); + aspath_unintern (&attr_sticky.aspath); + + return 0; +} + +/* + * Delete all type-2 (MACIP) local routes for this VNI - only from the + * global routing table. These are also scheduled for withdraw from peers. + */ +static int +delete_global_type2_routes (struct bgp *bgp, struct bgpevpn *vpn) +{ + afi_t afi; + safi_t safi; + struct bgp_node *rdrn, *rn; + struct bgp_table *table; + struct bgp_info *ri; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + + rdrn = bgp_node_lookup (bgp->rib[afi][safi], (struct prefix *) &vpn->prd); + if (rdrn && rdrn->info) + { + table = (struct bgp_table *)rdrn->info; + for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) + { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE) + continue; + + delete_evpn_route_entry (bgp, vpn, afi, safi, rn, &ri); + if (ri) + bgp_process (bgp, rn, afi, safi); + } + } + + /* Unlock RD node. */ + if (rdrn) + bgp_unlock_node (rdrn); + + return 0; +} + +/* + * Delete all type-2 (MACIP) local routes for this VNI - from the global + * table as well as the per-VNI route table. + */ +static int +delete_all_type2_routes (struct bgp *bgp, struct bgpevpn *vpn) +{ + afi_t afi; + safi_t safi; + struct bgp_node *rn; + struct bgp_info *ri; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + + /* First, walk the global route table for this VNI's type-2 local routes. + * EVPN routes are a 2-level table, first get the RD table. + */ + delete_global_type2_routes (bgp, vpn); + + /* Next, walk this VNI's route table and delete local type-2 routes. */ + for (rn = bgp_table_top (vpn->route_table); rn; rn = bgp_route_next (rn)) + { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE) + continue; + + delete_evpn_route_entry (bgp, vpn, afi, safi, rn, &ri); + + /* Route entry in local table gets deleted immediately. */ + if (ri) + bgp_info_reap (rn, ri); + } + + return 0; +} + +/* + * Delete all routes in the per-VNI route table. + */ +static int +delete_all_vni_routes (struct bgp *bgp, struct bgpevpn *vpn) +{ + struct bgp_node *rn; + struct bgp_info *ri, *nextri; + + /* Walk this VNI's route table and delete all routes. */ + for (rn = bgp_table_top (vpn->route_table); rn; rn = bgp_route_next (rn)) + { + for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) + { + bgp_info_delete (rn, ri); + bgp_info_reap (rn, ri); + } + } + + return 0; +} + +/* + * Update (and advertise) local routes for a VNI. Invoked upon the VNI + * export RT getting modified or change to tunnel IP. Note that these + * situations need the route in the per-VNI table as well as the global + * table to be updated (as attributes change). + */ +static int +update_routes_for_vni (struct bgp *bgp, struct bgpevpn *vpn) +{ + int ret; + struct prefix_evpn p; + + /* Update and advertise the type-3 route (only one) followed by the + * locally learnt type-2 routes (MACIP) - for this VNI. + */ + build_evpn_type3_prefix (&p, vpn->originator_ip); + ret = update_evpn_route (bgp, vpn, &p, 0); + if (ret) + return ret; + + return update_all_type2_routes (bgp, vpn); +} + +/* + * Delete (and withdraw) local routes for specified VNI from the global + * table and per-VNI table. After this, remove all other routes from + * the per-VNI table. Invoked upon the VNI being deleted or EVPN + * (advertise-all-vni) being disabled. + */ +static int +delete_routes_for_vni (struct bgp *bgp, struct bgpevpn *vpn) +{ + int ret; + struct prefix_evpn p; + + /* Delete and withdraw locally learnt type-2 routes (MACIP) + * followed by type-3 routes (only one) - for this VNI. + */ + ret = delete_all_type2_routes (bgp, vpn); + if (ret) + return ret; + + build_evpn_type3_prefix (&p, vpn->originator_ip); + ret = delete_evpn_route (bgp, vpn, &p); + if (ret) + return ret; + + /* Delete all routes from the per-VNI table. */ + return delete_all_vni_routes (bgp, vpn); +} + +/* + * There is a tunnel endpoint IP address change for this VNI, + * need to re-advertise routes with the new nexthop. + */ +static int +handle_tunnel_ip_change (struct bgp *bgp, struct bgpevpn *vpn, + struct in_addr originator_ip) +{ + struct prefix_evpn p; + + /* Need to withdraw type-3 route as the originator IP is part + * of the key. + */ + build_evpn_type3_prefix (&p, vpn->originator_ip); + delete_evpn_route (bgp, vpn, &p); + + /* Update the tunnel IP and re-advertise all routes for this VNI. */ + vpn->originator_ip = originator_ip; + return update_routes_for_vni (bgp, vpn); +} + +/* + * Install route entry into the VNI routing table and invoke route selection. + */ +static int +install_evpn_route_entry (struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_evpn *p, struct bgp_info *parent_ri) +{ + struct bgp_node *rn; + struct bgp_info *ri; + struct attr *attr_new; + int ret; + + /* Create (or fetch) route within the VNI. */ + /* NOTE: There is no RD here. */ + rn = bgp_node_get (vpn->route_table, (struct prefix *)p); + + /* Check if route entry is already present. */ + for (ri = rn->info; ri; ri = ri->next) + if (ri->extra && + (struct bgp_info *)ri->extra->parent == parent_ri) + break; + + if (!ri) + { + /* Add (or update) attribute to hash. */ + attr_new = bgp_attr_intern (parent_ri->attr); + + /* Create new route with its attribute. */ + ri = info_make (parent_ri->type, parent_ri->sub_type, 0, + parent_ri->peer, attr_new, rn); + SET_FLAG (ri->flags, BGP_INFO_VALID); + bgp_info_extra_get(ri); + ri->extra->parent = parent_ri; + if (parent_ri->extra) + memcpy (&ri->extra->label, &parent_ri->extra->label, BGP_LABEL_BYTES); + bgp_info_add (rn, ri); + } + else + { + if (attrhash_cmp (ri->attr, parent_ri->attr) && + !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) + { + bgp_unlock_node (rn); + return 0; + } + /* The attribute has changed. */ + /* Add (or update) attribute to hash. */ + attr_new = bgp_attr_intern (parent_ri->attr); + + /* Restore route, if needed. */ + if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) + bgp_info_restore(rn, ri); + + /* Mark if nexthop has changed. */ + if (!IPV4_ADDR_SAME (&ri->attr->nexthop, &attr_new->nexthop)) + SET_FLAG(ri->flags, BGP_INFO_IGP_CHANGED); + + /* Unintern existing, set to new. */ + bgp_attr_unintern (&ri->attr); + ri->attr = attr_new; + ri->uptime = bgp_clock (); + } + + /* Perform route selection and update zebra, if required. */ + ret = evpn_route_select_install (bgp, vpn, rn); + + return ret; +} + +/* + * Uninstall route entry from the VNI routing table and send message + * to zebra, if appropriate. + */ +static int +uninstall_evpn_route_entry (struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_evpn *p, struct bgp_info *parent_ri) +{ + struct bgp_node *rn; + struct bgp_info *ri; + int ret; + + /* Locate route within the VNI. */ + /* NOTE: There is no RD here. */ + rn = bgp_node_lookup (vpn->route_table, (struct prefix *)p); + if (!rn) + return 0; + + /* Find matching route entry. */ + for (ri = rn->info; ri; ri = ri->next) + if (ri->extra && + (struct bgp_info *)ri->extra->parent == parent_ri) + break; + + if (!ri) + return 0; + + /* Mark entry for deletion */ + bgp_info_delete (rn, ri); + + /* Perform route selection and update zebra, if required. */ + ret = evpn_route_select_install (bgp, vpn, rn); + + /* Unlock route node. */ + bgp_unlock_node (rn); + + return ret; +} + +/* + * Given a route entry and a VNI, see if this route entry should be + * imported into the VNI i.e., RTs match. + */ +static int +is_route_matching_for_vni (struct bgp *bgp, struct bgpevpn *vpn, + struct bgp_info *ri) +{ + struct attr *attr = ri->attr; + struct ecommunity *ecom; + int i; + + assert (attr); + /* Route should have valid RT to be even considered. */ + if (!(attr->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES))) + return 0; + + ecom = attr->ecommunity; + if (!ecom || !ecom->size) + return 0; + + /* For each extended community RT, see if it matches this VNI. If any RT + * matches, we're done. + */ + for (i = 0; i < ecom->size; i++) + { + u_char *pnt; + u_char type, sub_type; + struct ecommunity_val *eval; + struct ecommunity_val eval_tmp; + struct irt_node *irt; + + /* Only deal with RTs */ + pnt = (ecom->val + (i * ECOMMUNITY_SIZE)); + eval = (struct ecommunity_val *) (ecom->val + (i * ECOMMUNITY_SIZE)); + type = *pnt++; + sub_type = *pnt++; + if (sub_type != ECOMMUNITY_ROUTE_TARGET) + continue; + + /* See if this RT matches specified VNIs import RTs */ + irt = lookup_import_rt (bgp, eval); + if (irt && irt->vnis) + if (is_vni_present_in_irt_vnis (irt->vnis, vpn)) + return 1; + + /* Also check for non-exact match. In this, we mask out the AS and + * only check on the local-admin sub-field. This is to facilitate using + * VNI as the RT for EBGP peering too. + */ + irt = NULL; + if (type == ECOMMUNITY_ENCODE_AS || + type == ECOMMUNITY_ENCODE_AS4 || + type == ECOMMUNITY_ENCODE_IP) + { + memcpy (&eval_tmp, eval, ECOMMUNITY_SIZE); + mask_ecom_global_admin (&eval_tmp, eval); + irt = lookup_import_rt (bgp, &eval_tmp); + } + if (irt && irt->vnis) + if (is_vni_present_in_irt_vnis (irt->vnis, vpn)) + return 1; + } + + return 0; +} + +/* + * Install or uninstall routes of specified type that are appropriate for this + * particular VNI. + */ +static int +install_uninstall_routes_for_vni (struct bgp *bgp, struct bgpevpn *vpn, + bgp_evpn_route_type rtype, int install) +{ + afi_t afi; + safi_t safi; + struct bgp_node *rd_rn, *rn; + struct bgp_table *table; + struct bgp_info *ri; + int ret; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + + /* Walk entire global routing table and evaluate routes which could be + * imported into this VPN. Note that we cannot just look at the routes for + * the VNI's RD - remote routes applicable for this VNI could have any RD. + */ + /* EVPN routes are a 2-level table. */ + for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn; rd_rn = bgp_route_next (rd_rn)) + { + table = (struct bgp_table *)(rd_rn->info); + if (!table) + continue; + + for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) + { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + if (evp->prefix.route_type != rtype) + continue; + + for (ri = rn->info; ri; ri = ri->next) + { + /* Consider "valid" remote routes applicable for this VNI. */ + if (!(CHECK_FLAG (ri->flags, BGP_INFO_VALID) + && ri->type == ZEBRA_ROUTE_BGP + && ri->sub_type == BGP_ROUTE_NORMAL)) + continue; + + if (is_route_matching_for_vni (bgp, vpn, ri)) + { + if (install) + ret = install_evpn_route_entry (bgp, vpn, evp, ri); + else + ret = uninstall_evpn_route_entry (bgp, vpn, evp, ri); + + if (ret) + { + zlog_err ("%u: Failed to %s EVPN %s route in VNI %u", + bgp->vrf_id, install ? "install" : "uninstall", + rtype == BGP_EVPN_MAC_IP_ROUTE ? \ + "MACIP" : "IMET", vpn->vni); + return ret; + } + } + } + } + } + + return 0; +} + +/* + * Install any existing remote routes applicable for this VNI into its + * routing table. This is invoked when a VNI becomes "live" or its Import + * RT is changed. + */ +static int +install_routes_for_vni (struct bgp *bgp, struct bgpevpn *vpn) +{ + int ret; + + /* Install type-3 routes followed by type-2 routes - the ones applicable + * for this VNI. + */ + ret = install_uninstall_routes_for_vni (bgp, vpn, BGP_EVPN_IMET_ROUTE, 1); + if (ret) + return ret; + + return install_uninstall_routes_for_vni (bgp, vpn, BGP_EVPN_MAC_IP_ROUTE, 1); +} + +/* + * Uninstall any existing remote routes for this VNI. One scenario in which + * this is invoked is upon an import RT change. + */ +static int +uninstall_routes_for_vni (struct bgp *bgp, struct bgpevpn *vpn) +{ + int ret; + + /* Uninstall type-2 routes followed by type-3 routes - the ones applicable + * for this VNI. + */ + ret = install_uninstall_routes_for_vni (bgp, vpn, BGP_EVPN_MAC_IP_ROUTE, 0); + if (ret) + return ret; + + return install_uninstall_routes_for_vni (bgp, vpn, BGP_EVPN_IMET_ROUTE, 0); +} + +/* + * Install or uninstall route in matching VNIs (list). + */ +static int +install_uninstall_route_in_vnis (struct bgp *bgp, afi_t afi, safi_t safi, + struct prefix_evpn *evp, struct bgp_info *ri, + struct list *vnis, int install) +{ + struct bgpevpn *vpn; + struct listnode *node, *nnode; + + for (ALL_LIST_ELEMENTS (vnis, node, nnode, vpn)) + { + int ret; + + if (!is_vni_live (vpn)) + continue; + + if (install) + ret = install_evpn_route_entry (bgp, vpn, evp, ri); + else + ret = uninstall_evpn_route_entry (bgp, vpn, evp, ri); + + if (ret) + { + zlog_err ("%u: Failed to %s EVPN %s route in VNI %u", + bgp->vrf_id, install ? "install" : "uninstall", + evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE ? \ + "MACIP" : "IMET", vpn->vni); + return ret; + } + } + + return 0; +} + +/* + * Install or uninstall route for appropriate VNIs. + */ +static int +install_uninstall_evpn_route (struct bgp *bgp, afi_t afi, safi_t safi, + struct prefix *p, struct bgp_info *ri, + int import) +{ + struct prefix_evpn *evp = (struct prefix_evpn *)p; + struct attr *attr = ri->attr; + struct ecommunity *ecom; + int i; + + assert (attr); + + /* Only type-2 and type-3 routes go into a L2 VNI. */ + if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE || + evp->prefix.route_type == BGP_EVPN_IMET_ROUTE)) + return 0; + + /* If we don't have Route Target, nothing much to do. */ + if (!(attr->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES))) + return 0; + + ecom = attr->ecommunity; + if (!ecom || !ecom->size) + return -1; + + /* For each extended community RT, see which VNIs match and import + * the route into matching VNIs. + */ + for (i = 0; i < ecom->size; i++) + { + u_char *pnt; + u_char type, sub_type; + struct ecommunity_val *eval; + struct ecommunity_val eval_tmp; + struct irt_node *irt; + + /* Only deal with RTs */ + pnt = (ecom->val + (i * ECOMMUNITY_SIZE)); + eval = (struct ecommunity_val *) (ecom->val + (i * ECOMMUNITY_SIZE)); + type = *pnt++; + sub_type = *pnt++; + if (sub_type != ECOMMUNITY_ROUTE_TARGET) + continue; + + /* Are we interested in this RT? */ + irt = lookup_import_rt (bgp, eval); + if (irt && irt->vnis) + install_uninstall_route_in_vnis (bgp, afi, safi, evp, + ri, irt->vnis, import); + + /* Also check for non-exact match. In this, we mask out the AS and + * only check on the local-admin sub-field. This is to facilitate using + * VNI as the RT for EBGP peering too. + */ + irt = NULL; + if (type == ECOMMUNITY_ENCODE_AS || + type == ECOMMUNITY_ENCODE_AS4 || + type == ECOMMUNITY_ENCODE_IP) + { + memcpy (&eval_tmp, eval, ECOMMUNITY_SIZE); + mask_ecom_global_admin (&eval_tmp, eval); + irt = lookup_import_rt (bgp, &eval_tmp); + } + if (irt && irt->vnis) + install_uninstall_route_in_vnis (bgp, afi, safi, evp, + ri, irt->vnis, import); + } + + return 0; +} + +/* + * Update and advertise local routes for a VNI. Invoked upon router-id + * change. Note that the processing is done only on the global route table + * using routes that already exist in the per-VNI table. + */ +static int +update_advertise_vni_routes (struct bgp *bgp, struct bgpevpn *vpn) +{ + struct prefix_evpn p; + struct bgp_node *rn, *global_rn; + struct bgp_info *ri, *global_ri; + struct attr *attr; + afi_t afi = AFI_L2VPN; + safi_t safi = SAFI_EVPN; + + /* Locate type-3 route for VNI in the per-VNI table and use its + * attributes to create and advertise the type-3 route for this VNI + * in the global table. + */ + build_evpn_type3_prefix (&p, vpn->originator_ip); + rn = bgp_node_lookup (vpn->route_table, (struct prefix *)&p); + if (!rn) /* unexpected */ + return 0; + for (ri = rn->info; ri; ri = ri->next) + if (ri->peer == bgp->peer_self + && ri->type == ZEBRA_ROUTE_BGP + && ri->sub_type == BGP_ROUTE_STATIC) + break; + if (!ri) /* unexpected */ + return 0; + attr = ri->attr; + + global_rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, + (struct prefix *)&p, &vpn->prd); + update_evpn_route_entry (bgp, vpn, afi, safi, global_rn, + attr, 1, 0, &ri); + + /* Schedule for processing and unlock node. */ + bgp_process (bgp, global_rn, afi, safi); + bgp_unlock_node (global_rn); + + /* Now, walk this VNI's route table and use the route and its attribute + * to create and schedule route in global table. + */ + for (rn = bgp_table_top (vpn->route_table); rn; rn = bgp_route_next (rn)) + { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + /* Identify MAC-IP local routes. */ + if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE) + continue; + + for (ri = rn->info; ri; ri = ri->next) + if (ri->peer == bgp->peer_self + && ri->type == ZEBRA_ROUTE_BGP + && ri->sub_type == BGP_ROUTE_STATIC) + break; + if (!ri) + continue; + + /* Create route in global routing table using this route entry's + * attribute. + */ + attr = ri->attr; + global_rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, + (struct prefix *)evp, &vpn->prd); + assert (global_rn); + update_evpn_route_entry (bgp, vpn, afi, safi, global_rn, + attr, 1, 0, &global_ri); + + /* Schedule for processing and unlock node. */ + bgp_process (bgp, global_rn, afi, safi); + bgp_unlock_node (global_rn); + } + + return 0; +} + +/* + * Delete (and withdraw) local routes for a VNI - only from the global + * table. Invoked upon router-id change. + */ +static int +delete_withdraw_vni_routes (struct bgp *bgp, struct bgpevpn *vpn) +{ + int ret; + struct prefix_evpn p; + struct bgp_node *global_rn; + struct bgp_info *ri; + afi_t afi = AFI_L2VPN; + safi_t safi = SAFI_EVPN; + + /* Delete and withdraw locally learnt type-2 routes (MACIP) + * for this VNI - from the global table. + */ + ret = delete_global_type2_routes (bgp, vpn); + if (ret) + return ret; + + /* Remove type-3 route for this VNI from global table. */ + build_evpn_type3_prefix (&p, vpn->originator_ip); + global_rn = bgp_afi_node_lookup (bgp->rib[afi][safi], afi, safi, + (struct prefix *)&p, &vpn->prd); + if (global_rn) + { + /* Delete route entry in the global EVPN table. */ + delete_evpn_route_entry (bgp, vpn, afi, safi, global_rn, &ri); + + /* Schedule for processing - withdraws to peers happen from + * this table. + */ + if (ri) + bgp_process (bgp, global_rn, afi, safi); + bgp_unlock_node (global_rn); + } + + return 0; +} + +/* + * Handle router-id change. Update and advertise local routes corresponding + * to this VNI from peers. Note that this is invoked after updating the + * router-id. The routes in the per-VNI table are used to create routes in + * the global table and schedule them. + */ +static void +update_router_id_vni (struct hash_backet *backet, struct bgp *bgp) +{ + struct bgpevpn *vpn; + + vpn = (struct bgpevpn *) backet->data; + + if (!vpn) + { + zlog_warn ("%s: VNI hash entry for VNI not found", + __FUNCTION__); + return; + } + + /* Skip VNIs with configured RD. */ + if (is_rd_configured (vpn)) + return; + + bgp_evpn_derive_auto_rd (bgp, vpn); + update_advertise_vni_routes (bgp, vpn); +} + +/* + * Handle router-id change. Delete and withdraw local routes corresponding + * to this VNI from peers. Note that this is invoked prior to updating + * the router-id and is done only on the global route table, the routes + * are needed in the per-VNI table to re-advertise with new router id. + */ +static void +withdraw_router_id_vni (struct hash_backet *backet, struct bgp *bgp) +{ + struct bgpevpn *vpn; + + vpn = (struct bgpevpn *) backet->data; + + if (!vpn) + { + zlog_warn ("%s: VNI hash entry for VNI not found", + __FUNCTION__); + return; + } + + /* Skip VNIs with configured RD. */ + if (is_rd_configured (vpn)) + return; + + delete_withdraw_vni_routes (bgp, vpn); +} + +/* + * Process received EVPN type-2 route (advertise or withdraw). + */ +static int +process_type2_route (struct peer *peer, afi_t afi, safi_t safi, + struct attr *attr, u_char *pfx, int psize, + u_int32_t addpath_id) +{ + struct prefix_rd prd; + struct prefix_evpn p; + u_char ipaddr_len; + u_char macaddr_len; + mpls_label_t *label_pnt; + int ret; + + /* Type-2 route should be either 33, 37 or 49 bytes or an + * additional 3 bytes if there is a second label (VNI): + * RD (8), ESI (10), Eth Tag (4), MAC Addr Len (1), + * MAC Addr (6), IP len (1), IP (0, 4 or 16), + * MPLS Lbl1 (3), MPLS Lbl2 (0 or 3) + */ + if (psize != 33 && psize != 37 && psize != 49 && + psize != 36 && psize != 40 && psize != 52) + { + zlog_err ("%u:%s - Rx EVPN Type-2 NLRI with invalid length %d", + peer->bgp->vrf_id, peer->host, psize); + return -1; + } + + /* Make prefix_rd */ + prd.family = AF_UNSPEC; + prd.prefixlen = 64; + memcpy (&prd.val, pfx, 8); + pfx += 8; + + /* Make EVPN prefix. */ + memset (&p, 0, sizeof (struct prefix_evpn)); + p.family = AF_ETHERNET; + p.prefixlen = EVPN_TYPE_2_ROUTE_PREFIXLEN; + p.prefix.route_type = BGP_EVPN_MAC_IP_ROUTE; + + /* Skip over Ethernet Seg Identifier for now. */ + pfx += 10; + + /* Skip over Ethernet Tag for now. */ + pfx += 4; + + /* Get the MAC Addr len */ + macaddr_len = *pfx++; + + /* Get the MAC Addr */ + if (macaddr_len == (ETHER_ADDR_LEN * 8)) + { + memcpy (&p.prefix.mac.octet, pfx, ETHER_ADDR_LEN); + pfx += ETHER_ADDR_LEN; + } + else + { + zlog_err ("%u:%s - Rx EVPN Type-2 NLRI with unsupported MAC address length %d", + peer->bgp->vrf_id, peer->host, macaddr_len); + return -1; + } + + + /* Get the IP. */ + ipaddr_len = *pfx++; + if (ipaddr_len != 0 && + ipaddr_len != IPV4_MAX_BITLEN && + ipaddr_len != IPV6_MAX_BITLEN) + { + zlog_err ("%u:%s - Rx EVPN Type-2 NLRI with unsupported IP address length %d", + peer->bgp->vrf_id, peer->host, ipaddr_len); + return -1; + } + + if (ipaddr_len) + { + ipaddr_len /= 8; /* Convert to bytes. */ + p.prefix.ip.ipa_type = (ipaddr_len == IPV4_MAX_BYTELEN) ? + IPADDR_V4 : IPADDR_V6; + memcpy (&p.prefix.ip.ip.addr, pfx, ipaddr_len); + } + pfx += ipaddr_len; + + /* Get the VNI (in MPLS label field). */ + /* Note: We ignore the second VNI, if any. */ + label_pnt = (mpls_label_t *) pfx; + + /* Process the route. */ + if (attr) + ret = bgp_update (peer, (struct prefix *)&p, addpath_id, attr, afi, safi, + ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, label_pnt, 0, NULL); + else + ret = bgp_withdraw (peer, (struct prefix *)&p, addpath_id, attr, afi, safi, + ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, label_pnt, NULL); + return ret; +} + +/* + * Process received EVPN type-3 route (advertise or withdraw). + */ +static int +process_type3_route (struct peer *peer, afi_t afi, safi_t safi, + struct attr *attr, u_char *pfx, int psize, + u_int32_t addpath_id) +{ + struct prefix_rd prd; + struct prefix_evpn p; + u_char ipaddr_len; + int ret; + + /* Type-3 route should be either 17 or 29 bytes: RD (8), Eth Tag (4), + * IP len (1) and IP (4 or 16). + */ + if (psize != 17 && psize != 29) + { + zlog_err ("%u:%s - Rx EVPN Type-3 NLRI with invalid length %d", + peer->bgp->vrf_id, peer->host, psize); + return -1; + } + + /* Make prefix_rd */ + prd.family = AF_UNSPEC; + prd.prefixlen = 64; + memcpy (&prd.val, pfx, 8); + pfx += 8; + + /* Make EVPN prefix. */ + memset (&p, 0, sizeof (struct prefix_evpn)); + p.family = AF_ETHERNET; + p.prefixlen = EVPN_TYPE_3_ROUTE_PREFIXLEN; + p.prefix.route_type = BGP_EVPN_IMET_ROUTE; + + /* Skip over Ethernet Tag for now. */ + pfx += 4; + + /* Get the IP. */ + ipaddr_len = *pfx++; + if (ipaddr_len == IPV4_MAX_BITLEN) + { + p.prefix.ip.ipa_type = IPADDR_V4; + memcpy (&p.prefix.ip.ip.addr, pfx, IPV4_MAX_BYTELEN); + } + else + { + zlog_err ("%u:%s - Rx EVPN Type-3 NLRI with unsupported IP address length %d", + peer->bgp->vrf_id, peer->host, ipaddr_len); + return -1; + } + + /* Process the route. */ + if (attr) + ret = bgp_update (peer, (struct prefix *)&p, addpath_id, attr, afi, safi, + ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0, NULL); + else + ret = bgp_withdraw (peer, (struct prefix *)&p, addpath_id, attr, afi, safi, + ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, NULL); + return ret; +} + +/* + * Process received EVPN type-5 route (advertise or withdraw). + */ +static int +process_type5_route (struct peer *peer, afi_t afi, safi_t safi, + struct attr *attr, u_char *pfx, int psize, + u_int32_t addpath_id, int withdraw) +{ + struct prefix_rd prd; + struct prefix_evpn p; + struct bgp_route_evpn evpn; + u_char ippfx_len; + u_int32_t eth_tag; + mpls_label_t *label_pnt; + int ret; + + /* Type-5 route should be 34 or 58 bytes: + * RD (8), ESI (10), Eth Tag (4), IP len (1), IP (4 or 16), + * GW (4 or 16) and VNI (3). + * Note that the IP and GW should both be IPv4 or both IPv6. + */ + if (psize != 34 && psize != 58) + { + zlog_err ("%u:%s - Rx EVPN Type-5 NLRI with invalid length %d", + peer->bgp->vrf_id, peer->host, psize); + return -1; + } + + /* Make prefix_rd */ + prd.family = AF_UNSPEC; + prd.prefixlen = 64; + memcpy (&prd.val, pfx, 8); + pfx += 8; + + /* Make EVPN prefix. */ + memset (&p, 0, sizeof (struct prefix_evpn)); + p.family = AF_ETHERNET; + p.prefix.route_type = BGP_EVPN_IP_PREFIX_ROUTE; + + /* Additional information outside of prefix - ESI and GW IP */ + memset(&evpn, 0, sizeof(evpn)); + + /* Fetch ESI */ + memcpy (&evpn.eth_s_id.val, pfx, 10); + pfx += 10; + + /* Fetch Ethernet Tag. */ + memcpy (ð_tag, pfx, 4); + p.prefix.eth_tag = ntohl (eth_tag); + pfx += 4; + + /* Fetch IP prefix length. */ + ippfx_len = *pfx++; + if (ippfx_len > IPV6_MAX_BITLEN) + { + zlog_err ("%u:%s - Rx EVPN Type-5 NLRI with invalid IP Prefix length %d", + peer->bgp->vrf_id, peer->host, ippfx_len); + return -1; + } + p.prefix.ip_prefix_length = ippfx_len; + + /* Determine IPv4 or IPv6 prefix */ + /* Since the address and GW are from the same family, this just becomes + * a simple check on the total size. + */ + if (psize == 34) + { + SET_IPADDR_V4 (&p.prefix.ip); + memcpy (&p.prefix.ip.ipaddr_v4, pfx, 4); + pfx += 4; + memcpy (&evpn.gw_ip.ipv4, pfx, 4); + pfx += 4; + p.prefixlen = PREFIX_LEN_ROUTE_TYPE_5_IPV4; + } + else + { + SET_IPADDR_V6 (&p.prefix.ip); + memcpy (&p.prefix.ip.ipaddr_v6, pfx, 16); + pfx += 16; + memcpy (&evpn.gw_ip.ipv6, pfx, 16); + pfx += 16; + p.prefixlen = PREFIX_LEN_ROUTE_TYPE_5_IPV6; + } + + label_pnt = (mpls_label_t *) pfx; + + /* Process the route. */ + if (!withdraw) + ret = bgp_update (peer, (struct prefix *)&p, addpath_id, attr, afi, safi, + ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, label_pnt, 0, &evpn); + else + ret = bgp_withdraw (peer, (struct prefix *)&p, addpath_id, attr, afi, safi, + ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, label_pnt, &evpn); + + return ret; +} + +static void +evpn_mpattr_encode_type5 (struct stream *s, struct prefix *p, + struct prefix_rd *prd, mpls_label_t * label, + struct attr *attr) +{ + int len; + char temp[16]; + struct evpn_addr *p_evpn_p; + + memset(&temp, 0, 16); + if (p->family != AF_ETHERNET) + return; + p_evpn_p = &(p->u.prefix_evpn); + + if (IS_IPADDR_V4(&p_evpn_p->ip)) + len = 8; /* ipv4 */ + else + len = 32; /* ipv6 */ + stream_putc(s, BGP_EVPN_IP_PREFIX_ROUTE); + /* Prefix contains RD, ESI, EthTag, IP length, IP, GWIP and VNI */ + stream_putc(s, 8 + 10 + 4 + 1 + len + 3); + stream_put(s, prd->val, 8); + if (attr && attr) + stream_put(s, &(attr->evpn_overlay.eth_s_id), 10); + else + stream_put(s, &temp, 10); + stream_putl(s, p_evpn_p->eth_tag); + stream_putc(s, p_evpn_p->ip_prefix_length); + if (IS_IPADDR_V4(&p_evpn_p->ip)) + stream_put_ipv4(s, p_evpn_p->ip.ipaddr_v4.s_addr); + else + stream_put(s, &p_evpn_p->ip.ipaddr_v6, 16); + if (attr && attr) + { + if (IS_IPADDR_V4(&p_evpn_p->ip)) + stream_put_ipv4(s, attr->evpn_overlay.gw_ip.ipv4. s_addr); + else + stream_put(s, &(attr->evpn_overlay.gw_ip.ipv6), 16); + } + else + { + if (IS_IPADDR_V4(&p_evpn_p->ip)) + stream_put_ipv4(s, 0); + else + stream_put(s, &temp, 16); + } + + if (label) + stream_put(s, label, 3); + else + stream_put3(s, 0); +} + +/* + * Cleanup specific VNI upon EVPN (advertise-all-vni) being disabled. + */ +static void +cleanup_vni_on_disable (struct hash_backet *backet, struct bgp *bgp) +{ + struct bgpevpn *vpn = (struct bgpevpn *) backet->data; + + /* Remove EVPN routes and schedule for processing. */ + delete_routes_for_vni (bgp, vpn); + + /* Clear "live" flag and see if hash needs to be freed. */ + UNSET_FLAG (vpn->flags, VNI_FLAG_LIVE); + if (!is_vni_configured (vpn)) + bgp_evpn_free (bgp, vpn); +} + +/* + * Free a VNI entry; iterator function called during cleanup. + */ +static void +free_vni_entry (struct hash_backet *backet, struct bgp *bgp) +{ + struct bgpevpn *vpn; + + vpn = (struct bgpevpn *) backet->data; + delete_all_vni_routes (bgp, vpn); + bgp_evpn_free(bgp, vpn); +} + + +/* + * Public functions. + */ + +/* + * Handle change to BGP router id. This is invoked twice by the change + * handler, first before the router id has been changed and then after + * the router id has been changed. The first invocation will result in + * local routes for all VNIs being deleted and withdrawn and the next + * will result in the routes being re-advertised. + */ +void +bgp_evpn_handle_router_id_update (struct bgp *bgp, int withdraw) +{ + if (withdraw) + hash_iterate (bgp->vnihash, + (void (*) (struct hash_backet *, void *)) + withdraw_router_id_vni, bgp); + else + hash_iterate (bgp->vnihash, + (void (*) (struct hash_backet *, void *)) + update_router_id_vni, bgp); +} + +/* + * Handle change to export RT - update and advertise local routes. + */ +int +bgp_evpn_handle_export_rt_change (struct bgp *bgp, struct bgpevpn *vpn) +{ + return update_routes_for_vni (bgp, vpn); +} + +/* + * Handle change to RD. This is invoked twice by the change handler, + * first before the RD has been changed and then after the RD has + * been changed. The first invocation will result in local routes + * of this VNI being deleted and withdrawn and the next will result + * in the routes being re-advertised. + */ +void +bgp_evpn_handle_rd_change (struct bgp *bgp, struct bgpevpn *vpn, + int withdraw) +{ + if (withdraw) + delete_withdraw_vni_routes (bgp, vpn); + else + update_advertise_vni_routes (bgp, vpn); +} + +/* + * Install routes for this VNI. Invoked upon change to Import RT. + */ +int +bgp_evpn_install_routes (struct bgp *bgp, struct bgpevpn *vpn) +{ + return install_routes_for_vni (bgp, vpn); +} + +/* + * Uninstall all routes installed for this VNI. Invoked upon change + * to Import RT. + */ +int +bgp_evpn_uninstall_routes (struct bgp *bgp, struct bgpevpn *vpn) +{ + return uninstall_routes_for_vni (bgp, vpn); +} + +/* + * Function to display "tag" in route as a VNI. + */ +char * +bgp_evpn_label2str (mpls_label_t *label, char *buf, int len) +{ + vni_t vni; + + vni = label2vni (label); + snprintf (buf, len, "%u", vni); + return buf; +} + +/* + * Function to convert evpn route to string. + * NOTE: We don't use prefix2str as the output here is a bit different. + */ +char * +bgp_evpn_route2str (struct prefix_evpn *p, char *buf, int len) +{ + char buf1[ETHER_ADDR_STRLEN]; + char buf2[PREFIX2STR_BUFFER]; + + if (p->prefix.route_type == BGP_EVPN_IMET_ROUTE) + { + snprintf (buf, len, "[%d]:[0]:[%d]:[%s]", + p->prefix.route_type, IS_EVPN_PREFIX_IPADDR_V4(p) ? \ + IPV4_MAX_BITLEN : IPV6_MAX_BITLEN, + inet_ntoa(p->prefix.ip.ipaddr_v4)); + } + else if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) + { + if (IS_EVPN_PREFIX_IPADDR_NONE(p)) + snprintf (buf, len, "[%d]:[0]:[0]:[%d]:[%s]", + p->prefix.route_type, 8*ETHER_ADDR_LEN, + prefix_mac2str (&p->prefix.mac, buf1, sizeof(buf1))); + else + { + u_char family; + + family = IS_EVPN_PREFIX_IPADDR_V4(p) ? \ + AF_INET : AF_INET6; + snprintf (buf, len, "[%d]:[0]:[0]:[%d]:[%s]:[%d]:[%s]", + p->prefix.route_type, 8*ETHER_ADDR_LEN, + prefix_mac2str (&p->prefix.mac, buf1, sizeof(buf1)), + family == AF_INET ? IPV4_MAX_BITLEN : IPV6_MAX_BITLEN, + inet_ntop (family, &p->prefix.ip.ip.addr, + buf2, PREFIX2STR_BUFFER)); + } + } + else + { + /* Currently, this is to cater to other AF_ETHERNET code. */ + } + + return(buf); +} + +/* + * Encode EVPN prefix in Update (MP_REACH) + */ +void +bgp_evpn_encode_prefix (struct stream *s, struct prefix *p, + struct prefix_rd *prd, mpls_label_t *label, + struct attr *attr, int addpath_encode, + u_int32_t addpath_tx_id) +{ + struct prefix_evpn *evp = (struct prefix_evpn *)p; + int ipa_len = 0; + + if (addpath_encode) + stream_putl (s, addpath_tx_id); + + /* Route type */ + stream_putc (s, evp->prefix.route_type); + + switch (evp->prefix.route_type) + { + case BGP_EVPN_MAC_IP_ROUTE: + if (IS_EVPN_PREFIX_IPADDR_V4(evp)) + ipa_len = IPV4_MAX_BYTELEN; + else if (IS_EVPN_PREFIX_IPADDR_V6(evp)) + ipa_len = IPV6_MAX_BYTELEN; + stream_putc (s, 33 + ipa_len); // 1 VNI + stream_put (s, prd->val, 8); /* RD */ + stream_put (s, 0, 10); /* ESI */ + stream_putl (s, 0); /* Ethernet Tag ID */ + stream_putc (s, 8*ETHER_ADDR_LEN); /* Mac Addr Len - bits */ + stream_put (s, evp->prefix.mac.octet, 6); /* Mac Addr */ + stream_putc (s, 8*ipa_len); /* IP address Length */ + if (ipa_len) + stream_put (s, &evp->prefix.ip.ip.addr, ipa_len); /* IP */ + stream_put (s, label, BGP_LABEL_BYTES); /* VNI is contained in 'tag' */ + break; + + case BGP_EVPN_IMET_ROUTE: + stream_putc (s, 17); // TODO: length - assumes IPv4 address + stream_put (s, prd->val, 8); /* RD */ + stream_putl (s, 0); /* Ethernet Tag ID */ + stream_putc (s, IPV4_MAX_BITLEN); /* IP address Length - bits */ + /* Originating Router's IP Addr */ + stream_put_in_addr (s, &evp->prefix.ip.ipaddr_v4); + break; + + case BGP_EVPN_IP_PREFIX_ROUTE: + /* TODO: AddPath support. */ + evpn_mpattr_encode_type5 (s, p, prd, label, attr); + break; + + default: + break; + } +} int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, - struct bgp_nlri *packet, int withdraw) -{ - u_char *pnt; - u_char *lim; - struct prefix p; - struct prefix_rd prd; - struct evpn_addr *p_evpn_p; - struct bgp_route_evpn evpn; - uint8_t route_type, route_length; - mpls_label_t label; - u_int32_t addpath_id = 0; - - /* Check peer status. */ - if (peer->status != Established) - return 0; - - /* Make prefix_rd */ - prd.family = AF_UNSPEC; - prd.prefixlen = 64; - - p_evpn_p = &p.u.prefix_evpn; - pnt = packet->nlri; - lim = pnt + packet->length; - while (pnt < lim) { - /* clear evpn structure */ - memset(&evpn, 0, sizeof(evpn)); - - /* Clear prefix structure. */ - memset(&p, 0, sizeof(struct prefix)); - memset(&evpn.gw_ip, 0, sizeof(union gw_addr)); - memset(&evpn.eth_s_id, 0, sizeof(struct eth_segment_id)); - - /* Fetch Route Type */ - route_type = *pnt++; - route_length = *pnt++; - /* simply ignore. goto next route type if any */ - if (route_type != EVPN_IP_PREFIX) { - if (pnt + route_length > lim) { - zlog_err - ("not enough bytes for New Route Type left in NLRI?"); - return -1; - } - pnt += route_length; - continue; - } - - /* Fetch RD */ - if (pnt + 8 > lim) { - zlog_err("not enough bytes for RD left in NLRI?"); - return -1; - } - - /* Copy routing distinguisher to rd. */ - memcpy(&prd.val, pnt, 8); - pnt += 8; - - /* Fetch ESI */ - if (pnt + 10 > lim) { - zlog_err("not enough bytes for ESI left in NLRI?"); - return -1; - } - memcpy(&evpn.eth_s_id.val, pnt, 10); - pnt += 10; - - /* Fetch Ethernet Tag */ - if (pnt + 4 > lim) { - zlog_err("not enough bytes for Eth Tag left in NLRI?"); - return -1; - } - - if (route_type == EVPN_IP_PREFIX) { - p_evpn_p->route_type = route_type; - memcpy(&(p_evpn_p->eth_tag), pnt, 4); - p_evpn_p->eth_tag = ntohl(p_evpn_p->eth_tag); - pnt += 4; - - /* Fetch IP prefix length. */ - p_evpn_p->ip_prefix_length = *pnt++; - - if (p_evpn_p->ip_prefix_length > 128) { - zlog_err("invalid prefixlen %d in EVPN NLRI?", - p.prefixlen); - return -1; - } - /* determine IPv4 or IPv6 prefix */ - if (route_length - 4 - 10 - 8 - - 3 /* label to be read */ >= 32) { - SET_IPADDR_V6 (&p_evpn_p->ip); - memcpy(&(p_evpn_p->ip.ipaddr_v6), pnt, 16); - pnt += 16; - memcpy(&evpn.gw_ip.ipv6, pnt, 16); - pnt += 16; - } else { - SET_IPADDR_V4 (&p_evpn_p->ip); - memcpy(&(p_evpn_p->ip.ipaddr_v4), pnt, 4); - pnt += 4; - memcpy(&evpn.gw_ip.ipv4, pnt, 4); - pnt += 4; - } - p.family = AFI_L2VPN; - if (IS_IPADDR_V4(&p_evpn_p->ip)) - p.prefixlen = - (u_char) PREFIX_LEN_ROUTE_TYPE_5_IPV4; - else - p.prefixlen = PREFIX_LEN_ROUTE_TYPE_5_IPV6; - p.family = AF_ETHERNET; - } - - /* Fetch Label */ - if (pnt + BGP_LABEL_BYTES > lim) { - zlog_err("not enough bytes for Label left in NLRI?"); - return -1; - } - - memcpy(&label, pnt, BGP_LABEL_BYTES); - bgp_set_valid_label(&label); - pnt += BGP_LABEL_BYTES; - - if (!withdraw) { - bgp_update(peer, &p, addpath_id, attr, AFI_L2VPN, - SAFI_EVPN, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, - &prd, &label, 0, &evpn); - } else { - bgp_withdraw(peer, &p, addpath_id, attr, AFI_L2VPN, - SAFI_EVPN, ZEBRA_ROUTE_BGP, - BGP_ROUTE_NORMAL, &prd, &label, &evpn); - } - } - - /* Packet length consistency check. */ - if (pnt != lim) - return -1; - return 0; + struct bgp_nlri *packet, int withdraw) +{ + u_char *pnt; + u_char *lim; + afi_t afi; + safi_t safi; + u_int32_t addpath_id; + int addpath_encoded; + int psize = 0; + u_char rtype; + u_char rlen; + struct prefix p; + + /* Check peer status. */ + if (peer->status != Established) + { + zlog_err ("%u:%s - EVPN update received in state %d", + peer->bgp->vrf_id, peer->host, peer->status); + return -1; + } + + /* Start processing the NLRI - there may be multiple in the MP_REACH */ + pnt = packet->nlri; + lim = pnt + packet->length; + afi = packet->afi; + safi = packet->safi; + addpath_id = 0; + + addpath_encoded = (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) && + CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)); + + for (; pnt < lim; pnt += psize) + { + /* Clear prefix structure. */ + memset (&p, 0, sizeof (struct prefix)); + + /* Deal with path-id if AddPath is supported. */ + if (addpath_encoded) + { + /* When packet overflow occurs return immediately. */ + if (pnt + BGP_ADDPATH_ID_LEN > lim) + return -1; + + addpath_id = ntohl(*((uint32_t*) pnt)); + pnt += BGP_ADDPATH_ID_LEN; + } + + /* All EVPN NLRI types start with type and length. */ + if (pnt + 2 > lim) + return -1; + + rtype = *pnt++; + psize = rlen = *pnt++; + + /* When packet overflow occur return immediately. */ + if (pnt + psize > lim) + return -1; + + switch (rtype) + { + case BGP_EVPN_MAC_IP_ROUTE: + if (process_type2_route (peer, afi, safi, + withdraw ? NULL : attr, + pnt, psize, addpath_id)) + { + zlog_err ("%u:%s - Error in processing EVPN type-2 NLRI size %d", + peer->bgp->vrf_id, peer->host, psize); + return -1; + } + break; + + case BGP_EVPN_IMET_ROUTE: + if (process_type3_route (peer, afi, safi, + withdraw ? NULL : attr, + pnt, psize, addpath_id)) + { + zlog_err ("%u:%s - Error in processing EVPN type-3 NLRI size %d", + peer->bgp->vrf_id, peer->host, psize); + return -1; + } + break; + + case BGP_EVPN_IP_PREFIX_ROUTE: + if (process_type5_route (peer, afi, safi, attr, + pnt, psize, addpath_id, withdraw)) + { + zlog_err ("%u:%s - Error in processing EVPN type-5 NLRI size %d", + peer->bgp->vrf_id, peer->host, psize); + return -1; + } + break; + + default: + break; + } + + } + + /* Packet length consistency check. */ + if (pnt != lim) + return -1; + + return 0; +} + + +/* + * Map the RTs (configured or automatically derived) of a VNI to the VNI. + * The mapping will be used during route processing. + */ +void +bgp_evpn_map_vni_to_its_rts (struct bgp *bgp, struct bgpevpn *vpn) +{ + int i; + struct ecommunity_val *eval; + struct listnode *node, *nnode; + struct ecommunity *ecom; + + for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) + { + for (i = 0; i < ecom->size; i++) + { + eval = (struct ecommunity_val *) (ecom->val + (i * ECOMMUNITY_SIZE)); + map_vni_to_rt (bgp, vpn, eval); + } + } +} + +/* + * Unmap the RTs (configured or automatically derived) of a VNI from the VNI. + */ +void +bgp_evpn_unmap_vni_from_its_rts (struct bgp *bgp, struct bgpevpn *vpn) +{ + int i; + struct ecommunity_val *eval; + struct listnode *node, *nnode; + struct ecommunity *ecom; + + for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) + { + for (i = 0; i < ecom->size; i++) + { + struct irt_node *irt; + struct ecommunity_val eval_tmp; + + eval = (struct ecommunity_val *) (ecom->val + (i * ECOMMUNITY_SIZE)); + /* If using "automatic" RT, we only care about the local-admin sub-field. + * This is to facilitate using VNI as the RT for EBGP peering too. + */ + memcpy (&eval_tmp, eval, ECOMMUNITY_SIZE); + if (!is_import_rt_configured (vpn)) + mask_ecom_global_admin (&eval_tmp, eval); + + irt = lookup_import_rt (bgp, &eval_tmp); + if (irt) + unmap_vni_from_rt (bgp, vpn, irt); + } + } +} + +/* + * Derive Import RT automatically for VNI and map VNI to RT. + * The mapping will be used during route processing. + */ +void +bgp_evpn_derive_auto_rt_import (struct bgp *bgp, struct bgpevpn *vpn) +{ + form_auto_rt (bgp, vpn, vpn->import_rtl); + UNSET_FLAG (vpn->flags, VNI_FLAG_IMPRT_CFGD); + + /* Map RT to VNI */ + bgp_evpn_map_vni_to_its_rts (bgp, vpn); +} + +/* + * Derive Export RT automatically for VNI. + */ +void +bgp_evpn_derive_auto_rt_export (struct bgp *bgp, struct bgpevpn *vpn) +{ + form_auto_rt (bgp, vpn, vpn->export_rtl); + UNSET_FLAG (vpn->flags, VNI_FLAG_EXPRT_CFGD); +} + +/* + * Derive RD automatically for VNI using passed information - it + * is of the form RouterId:unique-id-for-vni. + */ +void +bgp_evpn_derive_auto_rd (struct bgp *bgp, struct bgpevpn *vpn) +{ + char buf[100]; + + vpn->prd.family = AF_UNSPEC; + vpn->prd.prefixlen = 64; + sprintf (buf, "%s:%hu", inet_ntoa (bgp->router_id), vpn->rd_id); + str2prefix_rd (buf, &vpn->prd); + UNSET_FLAG (vpn->flags, VNI_FLAG_RD_CFGD); +} + +/* + * Lookup VNI. + */ +struct bgpevpn * +bgp_evpn_lookup_vni (struct bgp *bgp, vni_t vni) +{ + struct bgpevpn *vpn; + struct bgpevpn tmp; + + memset(&tmp, 0, sizeof(struct bgpevpn)); + tmp.vni = vni; + vpn = hash_lookup (bgp->vnihash, &tmp); + return vpn; +} + +/* + * Create a new vpn - invoked upon configuration or zebra notification. + */ +struct bgpevpn * +bgp_evpn_new (struct bgp *bgp, vni_t vni, struct in_addr originator_ip) +{ + struct bgpevpn *vpn; + + if (!bgp) + return NULL; + + vpn = XCALLOC (MTYPE_BGP_EVPN, sizeof (struct bgpevpn)); + if (!vpn) + return NULL; + + /* Set values - RD and RT set to defaults. */ + vpn->vni = vni; + vpn->originator_ip = originator_ip; + + /* Initialize route-target import and export lists */ + vpn->import_rtl = list_new (); + vpn->import_rtl->cmp = (int (*)(void *, void *)) evpn_route_target_cmp; + vpn->export_rtl = list_new (); + vpn->export_rtl->cmp = (int (*)(void *, void *)) evpn_route_target_cmp; + bf_assign_index(bgp->rd_idspace, vpn->rd_id); + derive_rd_rt_for_vni (bgp, vpn); + + /* Initialize EVPN route table. */ + vpn->route_table = bgp_table_init (AFI_L2VPN, SAFI_EVPN); + + /* Add to hash */ + if (!hash_get(bgp->vnihash, vpn, hash_alloc_intern)) + { + XFREE(MTYPE_BGP_EVPN, vpn); + return NULL; + } + QOBJ_REG (vpn, bgpevpn); + return vpn; +} + +/* + * Free a given VPN - called in multiple scenarios such as zebra + * notification, configuration being deleted, advertise-all-vni disabled etc. + * This just frees appropriate memory, caller should have taken other + * needed actions. + */ +void +bgp_evpn_free (struct bgp *bgp, struct bgpevpn *vpn) +{ + bgp_table_unlock (vpn->route_table); + bgp_evpn_unmap_vni_from_its_rts (bgp, vpn); + list_delete (vpn->import_rtl); + list_delete (vpn->export_rtl); + vpn->import_rtl = NULL; + vpn->export_rtl = NULL; + bf_release_index(bgp->rd_idspace, vpn->rd_id); + hash_release (bgp->vnihash, vpn); + QOBJ_UNREG (vpn); + XFREE(MTYPE_BGP_EVPN, vpn); +} + +/* + * Import route into matching VNI(s). + */ +int +bgp_evpn_import_route (struct bgp *bgp, afi_t afi, safi_t safi, + struct prefix *p, struct bgp_info *ri) +{ + return install_uninstall_evpn_route (bgp, afi, safi, p, ri, 1); +} + +/* + * Unimport route from matching VNI(s). + */ +int +bgp_evpn_unimport_route (struct bgp *bgp, afi_t afi, safi_t safi, + struct prefix *p, struct bgp_info *ri) +{ + return install_uninstall_evpn_route (bgp, afi, safi, p, ri, 0); +} + +/* + * Handle del of a local MACIP. + */ +int +bgp_evpn_local_macip_del (struct bgp *bgp, vni_t vni, + struct ethaddr *mac, struct ipaddr *ip) +{ + struct bgpevpn *vpn; + struct prefix_evpn p; + + if (!bgp->vnihash) + { + zlog_err ("%u: VNI hash not created", bgp->vrf_id); + return -1; + } + + /* Lookup VNI hash - should exist. */ + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (!vpn || !is_vni_live (vpn)) + { + zlog_warn ("%u: VNI hash entry for VNI %u %s at MACIP DEL", + bgp->vrf_id, vni, vpn ? "not live" : "not found"); + return -1; + } + + /* Remove EVPN type-2 route and schedule for processing. */ + build_evpn_type2_prefix (&p, mac, ip); + delete_evpn_route (bgp, vpn, &p); + + return 0; +} + +/* + * Handle add of a local MACIP. + */ +int +bgp_evpn_local_macip_add (struct bgp *bgp, vni_t vni, + struct ethaddr *mac, struct ipaddr *ip, + u_char sticky) +{ + struct bgpevpn *vpn; + struct prefix_evpn p; + + if (!bgp->vnihash) + { + zlog_err ("%u: VNI hash not created", bgp->vrf_id); + return -1; + } + + /* Lookup VNI hash - should exist. */ + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (!vpn || !is_vni_live (vpn)) + { + zlog_warn ("%u: VNI hash entry for VNI %u %s at MACIP ADD", + bgp->vrf_id, vni, vpn ? "not live" : "not found"); + return -1; + } + + /* Create EVPN type-2 route and schedule for processing. */ + build_evpn_type2_prefix (&p, mac, ip); + if (update_evpn_route (bgp, vpn, &p, sticky)) + { + char buf[ETHER_ADDR_STRLEN]; + char buf2[INET6_ADDRSTRLEN]; + + zlog_err ("%u:Failed to create Type-2 route, VNI %u %sMAC %s IP %s", + bgp->vrf_id, vpn->vni, + sticky ? "sticky" : "", + prefix_mac2str (mac, buf, sizeof (buf)), + ipaddr2str (ip, buf2, sizeof(buf2))); + return -1; + } + + return 0; +} + +/* + * Handle del of a local VNI. + */ +int +bgp_evpn_local_vni_del (struct bgp *bgp, vni_t vni) +{ + struct bgpevpn *vpn; + + if (!bgp->vnihash) + { + zlog_err ("%u: VNI hash not created", bgp->vrf_id); + return -1; + } + + /* Locate VNI hash */ + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (!vpn) + { + zlog_warn ("%u: VNI hash entry for VNI %u not found at DEL", + bgp->vrf_id, vni); + return 0; + } + + /* Remove all local EVPN routes and schedule for processing (to + * withdraw from peers). + */ + delete_routes_for_vni (bgp, vpn); + + /* Clear "live" flag and see if hash needs to be freed. */ + UNSET_FLAG (vpn->flags, VNI_FLAG_LIVE); + if (!is_vni_configured (vpn)) + bgp_evpn_free (bgp, vpn); + + return 0; +} + +/* + * Handle add (or update) of a local VNI. The only VNI change we care + * about is change to local-tunnel-ip. + */ +int +bgp_evpn_local_vni_add (struct bgp *bgp, vni_t vni, struct in_addr originator_ip) +{ + struct bgpevpn *vpn; + struct prefix_evpn p; + + if (!bgp->vnihash) + { + zlog_err ("%u: VNI hash not created", bgp->vrf_id); + return -1; + } + + /* Lookup VNI. If present and no change, exit. */ + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (vpn && is_vni_live (vpn)) + { + if (IPV4_ADDR_SAME (&vpn->originator_ip, &originator_ip)) + /* Probably some other param has changed that we don't care about. */ + return 0; + + /* Local tunnel endpoint IP address has changed */ + return handle_tunnel_ip_change (bgp, vpn, originator_ip); + } + + /* Create or update as appropriate. */ + if (!vpn) + { + vpn = bgp_evpn_new (bgp, vni, originator_ip); + if (!vpn) + { + zlog_err ("%u: Failed to allocate VNI entry for VNI %u - at Add", + bgp->vrf_id, vni); + return -1; + } + } + + /* Mark as "live" */ + SET_FLAG (vpn->flags, VNI_FLAG_LIVE); + + /* Create EVPN type-3 route and schedule for processing. */ + build_evpn_type3_prefix (&p, vpn->originator_ip); + if (update_evpn_route (bgp, vpn, &p, 0)) + { + zlog_err ("%u: Type3 route creation failure for VNI %u", + bgp->vrf_id, vni); + return -1; + } + + /* If we have learnt and retained remote routes (VTEPs, MACs) for this VNI, + * install them. + */ + install_routes_for_vni (bgp, vpn); + + return 0; +} + +/* + * Cleanup EVPN information on disable - Need to delete and withdraw + * EVPN routes from peers. + */ +void +bgp_evpn_cleanup_on_disable (struct bgp *bgp) +{ + hash_iterate (bgp->vnihash, + (void (*) (struct hash_backet *, void *)) + cleanup_vni_on_disable, bgp); +} + +/* + * Cleanup EVPN information - invoked at the time of bgpd exit or when the + * BGP instance (default) is being freed. + */ +void +bgp_evpn_cleanup (struct bgp *bgp) +{ + if (bgp->vnihash) + hash_iterate (bgp->vnihash, + (void (*) (struct hash_backet *, void *)) + free_vni_entry, bgp); + if (bgp->import_rt_hash) + hash_free (bgp->import_rt_hash); + bgp->import_rt_hash = NULL; + if (bgp->vnihash) + hash_free (bgp->vnihash); + bgp->vnihash = NULL; + bf_free (bgp->rd_idspace); } +/* + * Initialization for EVPN + * Create + * VNI hash table + * hash for RT to VNI + * unique rd id space for auto derivation of RD for VNIs + */ void -bgp_packet_mpattr_route_type_5(struct stream *s, - struct prefix *p, struct prefix_rd *prd, - mpls_label_t *label, struct attr *attr) -{ - int len; - char temp[16]; - struct evpn_addr *p_evpn_p; - - memset(&temp, 0, 16); - if (p->family != AF_ETHERNET) - return; - p_evpn_p = &(p->u.prefix_evpn); - if (IS_IPADDR_V4(&p_evpn_p->ip)) - len = 8; /* ipv4 */ - else - len = 32; /* ipv6 */ - stream_putc(s, EVPN_IP_PREFIX); - stream_putc(s, - 8 /* RD */ + 10 /* ESI */ + 4 /* EthTag */ + 1 + len + - 3 /* label */ ); - stream_put(s, prd->val, 8); - if (attr && attr->extra) - stream_put(s, &(attr->extra->evpn_overlay.eth_s_id), 10); - else - stream_put(s, &temp, 10); - stream_putl(s, p_evpn_p->eth_tag); - stream_putc(s, p_evpn_p->ip_prefix_length); - if (IS_IPADDR_V4(&p_evpn_p->ip)) - stream_put_ipv4(s, p_evpn_p->ip.ipaddr_v4.s_addr); - else - stream_put(s, &p_evpn_p->ip.ipaddr_v6, 16); - if (attr && attr->extra) { - if (IS_IPADDR_V4(&p_evpn_p->ip)) - stream_put_ipv4(s, - attr->extra->evpn_overlay.gw_ip.ipv4. - s_addr); - else - stream_put(s, &(attr->extra->evpn_overlay.gw_ip.ipv6), - 16); - } else { - if (IS_IPADDR_V4(&p_evpn_p->ip)) - stream_put_ipv4(s, 0); - else - stream_put(s, &temp, 16); - } - if (label) - stream_put(s, label, 3); - else - stream_put3(s, 0); - return; +bgp_evpn_init (struct bgp *bgp) +{ + bgp->vnihash = hash_create (vni_hash_key_make, + vni_hash_cmp, + "BGP VNI Hash"); + bgp->import_rt_hash = hash_create (import_rt_hash_key_make, + import_rt_hash_cmp, + "BGP Import RT Hash"); + bf_init (bgp->rd_idspace, UINT16_MAX); + /*assign 0th index in the bitfield, so that we start with id 1*/ + bf_assign_zero_index (bgp->rd_idspace); } diff --git a/bgpd/bgp_evpn.h b/bgpd/bgp_evpn.h index feabc9cd2..610710d84 100644 --- a/bgpd/bgp_evpn.h +++ b/bgpd/bgp_evpn.h @@ -21,20 +21,45 @@ #ifndef _QUAGGA_BGP_EVPN_H #define _QUAGGA_BGP_EVPN_H +#include "vxlan.h" + +#define EVPN_ROUTE_STRLEN 200 /* Must be >> MAC + IPv6 strings. */ + +extern void +bgp_evpn_handle_router_id_update (struct bgp *bgp, int withdraw); +extern char * +bgp_evpn_label2str (mpls_label_t *label, char *buf, int len); +extern char * +bgp_evpn_route2str (struct prefix_evpn *p, char *buf, int len); +extern void +bgp_evpn_encode_prefix (struct stream *s, struct prefix *p, + struct prefix_rd *prd, mpls_label_t *label, + struct attr *attr, int addpath_encode, + u_int32_t addpath_tx_id); extern int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, struct bgp_nlri *packet, int withdraw); - +extern int +bgp_evpn_import_route (struct bgp *bgp, afi_t afi, safi_t safi, + struct prefix *p, struct bgp_info *ri); +extern int +bgp_evpn_unimport_route (struct bgp *bgp, afi_t afi, safi_t safi, + struct prefix *p, struct bgp_info *ri); +extern int +bgp_evpn_local_macip_del (struct bgp *bgp, vni_t vni, + struct ethaddr *mac, struct ipaddr *ip); +extern int +bgp_evpn_local_macip_add (struct bgp *bgp, vni_t vni, + struct ethaddr *mac, struct ipaddr *ip, + u_char sticky); +extern int +bgp_evpn_local_vni_del (struct bgp *bgp, vni_t vni); +extern int +bgp_evpn_local_vni_add (struct bgp *bgp, vni_t vni, struct in_addr originator_ip); extern void -bgp_packet_mpattr_route_type_5(struct stream *s, - struct prefix *p, struct prefix_rd *prd, - mpls_label_t *label, struct attr *attr); -/* EVPN route types as per RFC7432 and - * as per draft-ietf-bess-evpn-prefix-advertisement-02 - */ -#define EVPN_ETHERNET_AUTO_DISCOVERY 1 -#define EVPN_MACIP_ADVERTISEMENT 2 -#define EVPN_INCLUSIVE_MULTICAST_ETHERNET_TAG 3 -#define EVPN_ETHERNET_SEGMENT 4 -#define EVPN_IP_PREFIX 5 +bgp_evpn_cleanup_on_disable (struct bgp *bgp); +extern void +bgp_evpn_cleanup (struct bgp *bgp); +extern void +bgp_evpn_init (struct bgp *bgp); -#endif /* _QUAGGA_BGP_EVPN_H */ +#endif /* _QUAGGA_BGP_EVPN_H */ diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h new file mode 100644 index 000000000..cd40fa9f0 --- /dev/null +++ b/bgpd/bgp_evpn_private.h @@ -0,0 +1,232 @@ +/* BGP EVPN internal definitions + * Copyright (C) 2017 Cumulus Networks, Inc. + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _BGP_EVPN_PRIVATE_H +#define _BGP_EVPN_PRIVATE_H + +#include "vxlan.h" +#include "zebra.h" + +#include "bgpd/bgpd.h" +#include "bgpd/bgp_ecommunity.h" + +/* EVPN prefix lengths. */ +#define EVPN_TYPE_2_ROUTE_PREFIXLEN 224 +#define EVPN_TYPE_3_ROUTE_PREFIXLEN 224 + +/* EVPN route types. */ +typedef enum +{ + BGP_EVPN_AD_ROUTE = 1, /* Ethernet Auto-Discovery (A-D) route */ + BGP_EVPN_MAC_IP_ROUTE, /* MAC/IP Advertisement route */ + BGP_EVPN_IMET_ROUTE, /* Inclusive Multicast Ethernet Tag route */ + BGP_EVPN_ES_ROUTE, /* Ethernet Segment route */ + BGP_EVPN_IP_PREFIX_ROUTE, /* IP Prefix route */ +} bgp_evpn_route_type; + +/* + * Hash table of EVIs. Right now, the only type of EVI supported is with + * VxLAN encapsulation, hence each EVI corresponds to a L2 VNI. + * The VNIs are not "created" through BGP but through some other interface + * on the system. This table stores VNIs that BGP comes to know as present + * on the system (through interaction with zebra) as well as pre-configured + * VNIs (which need to be defined in the system to become "live"). + */ +struct bgpevpn +{ + vni_t vni; + u_int32_t flags; +#define VNI_FLAG_CFGD 0x1 /* VNI is user configured */ +#define VNI_FLAG_LIVE 0x2 /* VNI is "live" */ +#define VNI_FLAG_RD_CFGD 0x4 /* RD is user configured. */ +#define VNI_FLAG_IMPRT_CFGD 0x8 /* Import RT is user configured */ +#define VNI_FLAG_EXPRT_CFGD 0x10 /* Export RT is user configured */ + + /* Id for deriving the RD automatically for this VNI */ + u_int16_t rd_id; + + /* RD for this VNI. */ + struct prefix_rd prd; + + /* Route type 3 field */ + struct in_addr originator_ip; + + /* Import and Export RTs. */ + struct list *import_rtl; + struct list *export_rtl; + + /* Route table for EVPN routes for this VNI. */ + struct bgp_table *route_table; + + QOBJ_FIELDS +}; + +DECLARE_QOBJ_TYPE(bgpevpn) + +/* Mapping of Import RT to VNIs. + * The Import RTs of all VNIs are maintained in a hash table with each + * RT linking to all VNIs that will import routes matching this RT. + */ +struct irt_node +{ + /* RT */ + struct ecommunity_val rt; + + /* List of VNIs importing routes matching this RT. */ + struct list *vnis; +}; + +#define RT_TYPE_IMPORT 1 +#define RT_TYPE_EXPORT 2 +#define RT_TYPE_BOTH 3 + +static inline int +is_vni_configured (struct bgpevpn *vpn) +{ + return (CHECK_FLAG (vpn->flags, VNI_FLAG_CFGD)); +} + +static inline int +is_vni_live (struct bgpevpn *vpn) +{ + return (CHECK_FLAG (vpn->flags, VNI_FLAG_LIVE)); +} + +static inline int +is_rd_configured (struct bgpevpn *vpn) +{ + return (CHECK_FLAG (vpn->flags, VNI_FLAG_RD_CFGD)); +} + +static inline int +bgp_evpn_rd_matches_existing (struct bgpevpn *vpn, struct prefix_rd *prd) +{ + return(memcmp (&vpn->prd.val, prd->val, ECOMMUNITY_SIZE) == 0); +} + +static inline int +is_import_rt_configured (struct bgpevpn *vpn) +{ + return (CHECK_FLAG (vpn->flags, VNI_FLAG_IMPRT_CFGD)); +} + +static inline int +is_export_rt_configured (struct bgpevpn *vpn) +{ + return (CHECK_FLAG (vpn->flags, VNI_FLAG_EXPRT_CFGD)); +} + +static inline int +is_vni_param_configured (struct bgpevpn *vpn) +{ + return (is_rd_configured (vpn) || + is_import_rt_configured (vpn) || + is_export_rt_configured (vpn)); +} + +static inline void +vni2label (vni_t vni, mpls_label_t *label) +{ + u_char *tag = (u_char *) label; + tag[0] = (vni >> 16) & 0xFF; + tag[1] = (vni >> 8) & 0xFF; + tag[2] = vni & 0xFF; +} + +static inline vni_t +label2vni (mpls_label_t *label) +{ + u_char *tag = (u_char *) label; + vni_t vni; + + vni = ((u_int32_t) *tag++ << 16); + vni |= (u_int32_t) *tag++ << 8; + vni |= (u_int32_t) (*tag & 0xFF); + + return vni; +} + +static inline void +encode_mac_mobility_extcomm (int static_mac, u_int32_t seq, + struct ecommunity_val *eval) +{ + memset (eval, 0, sizeof (*eval)); + eval->val[0] = ECOMMUNITY_ENCODE_EVPN; + eval->val[1] = ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY; + if (static_mac) + eval->val[2] = ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY_FLAG_STICKY; + eval->val[4] = (seq >> 24) & 0xff; + eval->val[5] = (seq >> 16) & 0xff; + eval->val[6] = (seq >> 8) & 0xff; + eval->val[7] = seq & 0xff; +} + +static inline void +build_evpn_type2_prefix (struct prefix_evpn *p, struct ethaddr *mac, + struct ipaddr *ip) +{ + memset (p, 0, sizeof (struct prefix_evpn)); + p->family = AF_ETHERNET; + p->prefixlen = EVPN_TYPE_2_ROUTE_PREFIXLEN; + p->prefix.route_type = BGP_EVPN_MAC_IP_ROUTE; + memcpy(&p->prefix.mac.octet, mac->octet, ETHER_ADDR_LEN); + p->prefix.ip.ipa_type = IPADDR_NONE; + if (ip) + memcpy(&p->prefix.ip, ip, sizeof (*ip)); +} + +static inline void +build_evpn_type3_prefix (struct prefix_evpn *p, struct in_addr originator_ip) +{ + memset (p, 0, sizeof (struct prefix_evpn)); + p->family = AF_ETHERNET; + p->prefixlen = EVPN_TYPE_3_ROUTE_PREFIXLEN; + p->prefix.route_type = BGP_EVPN_IMET_ROUTE; + p->prefix.ip.ipa_type = IPADDR_V4; + p->prefix.ip.ipaddr_v4 = originator_ip; +} + + +extern int +bgp_evpn_handle_export_rt_change (struct bgp *bgp, struct bgpevpn *vpn); +extern void +bgp_evpn_handle_rd_change (struct bgp *bgp, struct bgpevpn *vpn, int withdraw); +extern int +bgp_evpn_install_routes (struct bgp *bgp, struct bgpevpn *vpn); +extern int +bgp_evpn_uninstall_routes (struct bgp *bgp, struct bgpevpn *vpn); +extern void +bgp_evpn_map_vni_to_its_rts (struct bgp *bgp, struct bgpevpn *vpn); +extern void +bgp_evpn_unmap_vni_from_its_rts (struct bgp *bgp, struct bgpevpn *vpn); +extern void +bgp_evpn_derive_auto_rt_import (struct bgp *bgp, struct bgpevpn *vpn); +extern void +bgp_evpn_derive_auto_rt_export (struct bgp *bgp, struct bgpevpn *vpn); +extern void +bgp_evpn_derive_auto_rd (struct bgp *bgp, struct bgpevpn *vpn); +extern struct bgpevpn * +bgp_evpn_lookup_vni (struct bgp *bgp, vni_t vni); +extern struct bgpevpn * +bgp_evpn_new (struct bgp *bgp, vni_t vni, struct in_addr originator_ip); +extern void +bgp_evpn_free (struct bgp *bgp, struct bgpevpn *vpn); +#endif /* _BGP_EVPN_PRIVATE_H */ diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index d22a07ed3..b5a58f014 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -31,11 +31,312 @@ #include "bgpd/bgp_vpn.h" #include "bgpd/bgp_evpn_vty.h" #include "bgpd/bgp_evpn.h" +#include "bgpd/bgp_evpn_private.h" +#include "bgpd/bgp_zebra.h" +#include "bgpd/bgp_vty.h" #define SHOW_DISPLAY_STANDARD 0 #define SHOW_DISPLAY_TAGS 1 #define SHOW_DISPLAY_OVERLAY 2 +/* + * Context for VNI hash walk - used by callbacks. + */ +struct vni_walk_ctx +{ + struct bgp *bgp; + struct vty *vty; + struct in_addr vtep_ip; +}; + +struct evpn_config_write +{ + int write; + struct vty *vty; +}; + +#if defined (HAVE_CUMULUS) +static void +display_import_rt (struct vty *vty, struct irt_node *irt) +{ + u_char *pnt; + u_char type, sub_type; + struct ecommunity_as + { + as_t as; + u_int32_t val; + } eas; + struct ecommunity_ip + { + struct in_addr ip; + u_int16_t val; + } eip; + struct listnode *node, *nnode; + struct bgpevpn *tmp_vpn; + + + /* TODO: This needs to go into a function */ + + pnt = (u_char *)&irt->rt.val; + type = *pnt++; + sub_type = *pnt++; + if (sub_type != ECOMMUNITY_ROUTE_TARGET) + return; + + switch (type) + { + case ECOMMUNITY_ENCODE_AS: + eas.as = (*pnt++ << 8); + eas.as |= (*pnt++); + + eas.val = (*pnt++ << 24); + eas.val |= (*pnt++ << 16); + eas.val |= (*pnt++ << 8); + eas.val |= (*pnt++); + + vty_out (vty, "Route-target: %u:%u", eas.as, eas.val); + break; + + case ECOMMUNITY_ENCODE_IP: + memcpy (&eip.ip, pnt, 4); + pnt += 4; + eip.val = (*pnt++ << 8); + eip.val |= (*pnt++); + + vty_out (vty, "Route-target: %s:%u", + inet_ntoa (eip.ip), eip.val); + break; + + case ECOMMUNITY_ENCODE_AS4: + eas.as = (*pnt++ << 24); + eas.as |= (*pnt++ << 16); + eas.as |= (*pnt++ << 8); + eas.as |= (*pnt++); + + eas.val = (*pnt++ << 8); + eas.val |= (*pnt++); + + vty_out (vty, "Route-target: %u:%u", eas.as, eas.val); + break; + + default: + return; + } + + vty_out (vty, "\n"); + vty_out (vty, "List of VNIs importing routes with this route-target:\n"); + + for (ALL_LIST_ELEMENTS (irt->vnis, node, nnode, tmp_vpn)) + vty_out (vty, " %u\n", tmp_vpn->vni); +} + +static void +show_import_rt_entry (struct hash_backet *backet, struct vty *vty) +{ + struct irt_node *irt = (struct irt_node *) backet->data; + display_import_rt (vty, irt); +} + +static void +bgp_evpn_show_route_rd_header (struct vty *vty, struct bgp_node *rd_rn) +{ + u_int16_t type; + struct rd_as rd_as; + struct rd_ip rd_ip; + u_char *pnt; + + pnt = rd_rn->p.u.val; + + /* Decode RD type. */ + type = decode_rd_type (pnt); + + vty_out (vty, "Route Distinguisher: "); + + switch (type) + { + case RD_TYPE_AS: + decode_rd_as (pnt + 2, &rd_as); + vty_out (vty, "%u:%d", rd_as.as, rd_as.val); + break; + + case RD_TYPE_IP: + decode_rd_ip (pnt + 2, &rd_ip); + vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val); + break; + + default: + vty_out (vty, "Unknown RD type"); + break; + } + + vty_out (vty, "\n"); +} + +static void +bgp_evpn_show_route_header (struct vty *vty, struct bgp *bgp) +{ + char ri_header[] = " Network Next Hop Metric LocPrf Weight Path\n"; + + vty_out (vty, "BGP table version is 0, local router ID is %s\n", + inet_ntoa (bgp->router_id)); + vty_out (vty, "Status codes: s suppressed, d damped, h history, " + "* valid, > best, i - internal\n"); + vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete\n"); + vty_out (vty, "EVPN type-2 prefix: [2]:[ESI]:[EthTag]:[MAClen]:[MAC]:[IPlen]:[IP]\n"); + vty_out (vty, "EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:[OrigIP]\n\n"); + vty_out (vty, "%s", ri_header); +} + +static void +display_vni (struct vty *vty, struct bgpevpn *vpn) +{ + char buf1[INET6_ADDRSTRLEN]; + char *ecom_str; + struct listnode *node, *nnode; + struct ecommunity *ecom; + + vty_out (vty, "VNI: %d", vpn->vni); + if (is_vni_live (vpn)) + vty_out (vty, " (known to the kernel)"); + vty_out (vty, "\n"); + + vty_out (vty, " RD: %s\n", + prefix_rd2str (&vpn->prd, buf1, RD_ADDRSTRLEN)); + vty_out (vty, " Originator IP: %s\n", + inet_ntoa(vpn->originator_ip)); + + vty_out (vty, " Import Route Target:\n"); + for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) + { + ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + vty_out (vty, " %s\n", ecom_str); + XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); + } + + vty_out (vty, " Export Route Target:\n"); + for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) + { + ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + vty_out (vty, " %s\n", ecom_str); + XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); + } +} + +static void +show_vni_routes (struct bgp *bgp, struct bgpevpn *vpn, int type, + struct vty *vty, struct in_addr vtep_ip) +{ + struct bgp_node *rn; + struct bgp_info *ri; + int header = 1; + u_int32_t prefix_cnt, path_cnt; + + prefix_cnt = path_cnt = 0; + + for (rn = bgp_table_top (vpn->route_table); rn; rn = bgp_route_next (rn)) + { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + if (type && + evp->prefix.route_type != type) + continue; + + if (rn->info) + { + /* Overall header/legend displayed once. */ + if (header) + { + bgp_evpn_show_route_header (vty, bgp); + header = 0; + } + + prefix_cnt++; + } + + /* For EVPN, the prefix is displayed for each path (to fit in + * with code that already exists). + */ + for (ri = rn->info; ri; ri = ri->next) + { + if (vtep_ip.s_addr && + !IPV4_ADDR_SAME(&(vtep_ip), &(ri->attr->nexthop))) + continue; + + path_cnt++; + route_vty_out (vty, &rn->p, ri, 0, SAFI_EVPN, NULL); + } + } + + if (prefix_cnt == 0) + vty_out (vty, "No EVPN prefixes %sexist for this VNI\n", + type ? "(of requested type) " : ""); + else + vty_out (vty, "\nDisplayed %u prefixes (%u paths)%s\n", + prefix_cnt, path_cnt, + type ? " (of requested type)" : ""); +} + +static void +show_vni_routes_hash (struct hash_backet *backet, void *arg) +{ + struct bgpevpn *vpn = (struct bgpevpn *) backet->data; + struct vni_walk_ctx *wctx = arg; + struct vty *vty = wctx->vty; + + vty_out (vty, "\nVNI: %d\n\n", vpn->vni); + show_vni_routes (wctx->bgp, vpn, 0, wctx->vty, wctx->vtep_ip); +} + +static void +show_vni_entry (struct hash_backet *backet, struct vty *vty) +{ + struct bgpevpn *vpn = (struct bgpevpn *) backet->data; + char buf1[10]; + char buf2[INET6_ADDRSTRLEN]; + char rt_buf[25]; + char *ecom_str; + struct listnode *node, *nnode; + struct ecommunity *ecom; + + buf1[0] = '\0'; + if (is_vni_live (vpn)) + sprintf (buf1, "*"); + + vty_out(vty, "%-1s %-10u %-15s %-21s", + buf1, vpn->vni, inet_ntoa(vpn->originator_ip), + prefix_rd2str (&vpn->prd, buf2, RD_ADDRSTRLEN)); + + for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) + { + ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + + if (listcount(vpn->import_rtl) > 1) + sprintf (rt_buf, "%s, ...", ecom_str); + else + sprintf (rt_buf, "%s", ecom_str); + vty_out (vty, " %-25s", rt_buf); + + XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); + break; + } + + for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) + { + ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + + if (listcount(vpn->export_rtl) > 1) + sprintf (rt_buf, "%s, ...", ecom_str); + else + sprintf (rt_buf, "%s", ecom_str); + vty_out (vty, " %-25s", rt_buf); + + XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); + break; + } + vty_out (vty, "\n"); +} +#endif /* HAVE_CUMULUS */ + static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, int option, @@ -61,7 +362,7 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, bgp = bgp_get_default(); if (bgp == NULL) { if (!use_json) - vty_outln (vty,"No BGP process is configured"); + vty_out (vty,"No BGP process is configured\n"); return CMD_WARNING; } @@ -135,20 +436,19 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, } else { if (option == SHOW_DISPLAY_TAGS) - vty_outln(vty, V4_HEADER_TAG); + vty_out(vty, V4_HEADER_TAG); else if (option == SHOW_DISPLAY_OVERLAY) - vty_outln(vty, V4_HEADER_OVERLAY); + vty_out(vty, V4_HEADER_OVERLAY); else { - vty_outln (vty, - "BGP table version is 0, local router ID is %s", + vty_out (vty, + "BGP table version is 0, local router ID is %s\n", inet_ntoa(bgp->router_id)); - vty_outln (vty, - "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal"); - vty_outln (vty, - "Origin codes: i - IGP, e - EGP, ? - incomplete%s", - VTYNL); - vty_outln(vty, V4_HEADER); + vty_out (vty, + "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n"); + vty_out (vty, + "Origin codes: i - IGP, e - EGP, ? - incomplete\n\n"); + vty_out(vty, V4_HEADER); } } header = 0; @@ -224,7 +524,7 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, ip), rd_ip. val); - vty_outln (vty, VTYNL); + vty_out (vty, "\n\n"); } rd_header = 0; } @@ -253,11 +553,10 @@ bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, } } if (output_count == 0) - vty_outln (vty, "No prefixes displayed, %ld exist", + vty_out (vty, "No prefixes displayed, %ld exist\n", total_count); else - vty_outln (vty, "%sDisplayed %ld out of %ld total prefixes", - VTYNL, output_count, total_count); + vty_out (vty, "\nDisplayed %ld out of %ld total prefixes\n", output_count, total_count); return CMD_SUCCESS; } @@ -289,7 +588,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd, ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { - vty_outln (vty, "%% Malformed Route Distinguisher"); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 0, @@ -330,7 +629,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_tags, ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { - vty_outln (vty, "%% Malformed Route Distinguisher"); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 1, @@ -365,11 +664,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "Malformed address: %s", + vty_out (vty, "Malformed address: %s\n", argv[idx_ipv4]->arg); return CMD_WARNING; } @@ -381,12 +680,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, - "%% No such neighbor or address family"); + vty_out (vty, + "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -426,11 +725,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty,"%% Malformed Route Distinguisher"); + vty_out (vty,"%% Malformed Route Distinguisher\n"); return CMD_WARNING; } @@ -441,11 +740,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "Malformed address: %s", + vty_out (vty, "Malformed address: %s\n", argv[idx_ext_community]->arg); return CMD_WARNING; } @@ -457,12 +756,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, - "%% No such neighbor or address family"); + vty_out (vty, + "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -498,11 +797,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "Malformed address: %s", + vty_out (vty, "Malformed address: %s\n", argv[idx_ipv4]->arg); return CMD_WARNING; } @@ -513,12 +812,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, - "%% No such neighbor or address family"); + vty_out (vty, + "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -557,11 +856,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "Malformed address: %s", + vty_out (vty, "Malformed address: %s\n", argv[idx_ext_community]->arg); return CMD_WARNING; } @@ -572,12 +871,12 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, - "%% No such neighbor or address family"); + vty_out (vty, + "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -588,11 +887,11 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty,"%% Malformed Route Distinguisher"); + vty_out (vty,"%% Malformed Route Distinguisher\n"); return CMD_WARNING; } @@ -635,7 +934,7 @@ DEFUN(show_ip_bgp_evpn_rd_overlay, ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd); if (!ret) { - vty_outln (vty, "%% Malformed Route Distinguisher"); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, @@ -679,7 +978,7 @@ DEFUN(evpnrt5_network, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_rmap] ? argv[idx_gwip]->arg : NULL, - EVPN_IP_PREFIX, argv[idx_esi]->arg, + BGP_EVPN_IP_PREFIX_ROUTE, argv[idx_esi]->arg, argv[idx_gwip]->arg, argv[idx_ethtag]->arg, argv[idx_routermac]->arg); } @@ -711,27 +1010,1657 @@ DEFUN(no_evpnrt5_network, return bgp_static_unset_safi(AFI_L2VPN, SAFI_EVPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, - argv[idx_label]->arg, EVPN_IP_PREFIX, + argv[idx_label]->arg, BGP_EVPN_IP_PREFIX_ROUTE, argv[idx_esi]->arg, argv[idx_gwip]->arg, argv[idx_ethtag]->arg); } +#if defined(HAVE_CUMULUS) +static void +evpn_rt_delete_auto (struct bgp *bgp, struct bgpevpn *vpn, struct list *rtl) +{ + struct listnode *node, *nnode, *node_to_del; + struct ecommunity *ecom, *ecom_auto; + struct ecommunity_val eval; + + encode_route_target_as ((bgp->as & 0xFFFF), vpn->vni, &eval); + + ecom_auto = ecommunity_new (); + ecommunity_add_val (ecom_auto, &eval); + node_to_del = NULL; + + for (ALL_LIST_ELEMENTS (rtl, node, nnode, ecom)) + { + if (ecommunity_match (ecom, ecom_auto)) + { + ecommunity_free (&ecom); + node_to_del = node; + } + } + + if (node_to_del) + list_delete_node(rtl, node_to_del); + + ecommunity_free(&ecom_auto); +} + +static void +evpn_import_rt_delete_auto (struct bgp *bgp, struct bgpevpn *vpn) +{ + evpn_rt_delete_auto (bgp, vpn, vpn->import_rtl); +} + +static void +evpn_export_rt_delete_auto (struct bgp *bgp, struct bgpevpn *vpn) +{ + evpn_rt_delete_auto (bgp, vpn, vpn->export_rtl); +} + +/* + * Configure the Import RTs for a VNI (vty handler). Caller expected to + * check that this is a change. + */ +static void +evpn_configure_import_rt (struct bgp *bgp, struct bgpevpn *vpn, + struct ecommunity *ecomadd) +{ + /* If the VNI is "live", we need to uninstall routes using the current + * import RT(s) first before we update the import RT, and subsequently + * install routes. + */ + if (is_vni_live (vpn)) + bgp_evpn_uninstall_routes (bgp, vpn); + + /* Cleanup the RT to VNI mapping and get rid of existing import RT. */ + bgp_evpn_unmap_vni_from_its_rts (bgp, vpn); + + /* If the auto route-target is in use we must remove it */ + evpn_import_rt_delete_auto(bgp, vpn); + + /* Add new RT and rebuild the RT to VNI mapping */ + listnode_add_sort (vpn->import_rtl, ecomadd); + + SET_FLAG (vpn->flags, VNI_FLAG_IMPRT_CFGD); + bgp_evpn_map_vni_to_its_rts (bgp, vpn); + + /* Install routes that match new import RT */ + if (is_vni_live (vpn)) + bgp_evpn_install_routes (bgp, vpn); +} + +/* + * Unconfigure Import RT(s) for a VNI (vty handler). + */ +static void +evpn_unconfigure_import_rt (struct bgp *bgp, struct bgpevpn *vpn, + struct ecommunity *ecomdel) +{ + struct listnode *node, *nnode, *node_to_del; + struct ecommunity *ecom; + + /* Along the lines of "configure" except we have to reset to the + * automatic value. + */ + if (is_vni_live (vpn)) + bgp_evpn_uninstall_routes (bgp, vpn); + + /* Cleanup the RT to VNI mapping and get rid of existing import RT. */ + bgp_evpn_unmap_vni_from_its_rts (bgp, vpn); + + /* Delete all import RTs */ + if (ecomdel == NULL) + { + for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) + ecommunity_free (&ecom); + + list_delete_all_node(vpn->import_rtl); + } + + /* Delete a specific import RT */ + else + { + node_to_del = NULL; + + for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) + { + if (ecommunity_match (ecom, ecomdel)) + { + ecommunity_free (&ecom); + node_to_del = node; + break; + } + } + + if (node_to_del) + list_delete_node(vpn->import_rtl, node_to_del); + } + + /* Reset to auto RT - this also rebuilds the RT to VNI mapping */ + if (list_isempty(vpn->import_rtl)) + { + UNSET_FLAG (vpn->flags, VNI_FLAG_IMPRT_CFGD); + bgp_evpn_derive_auto_rt_import (bgp, vpn); + } + /* Rebuild the RT to VNI mapping */ + else + bgp_evpn_map_vni_to_its_rts (bgp, vpn); + + /* Install routes that match new import RT */ + if (is_vni_live (vpn)) + bgp_evpn_install_routes (bgp, vpn); +} + +/* + * Configure the Export RT for a VNI (vty handler). Caller expected to + * check that this is a change. Note that only a single export RT is + * allowed for a VNI and any change to configuration is implemented as + * a "replace" (similar to other configuration). + */ +static void +evpn_configure_export_rt (struct bgp *bgp, struct bgpevpn *vpn, + struct ecommunity *ecomadd) +{ + /* If the auto route-target is in use we must remove it */ + evpn_export_rt_delete_auto (bgp, vpn); + + listnode_add_sort (vpn->export_rtl, ecomadd); + SET_FLAG (vpn->flags, VNI_FLAG_EXPRT_CFGD); + + if (is_vni_live (vpn)) + bgp_evpn_handle_export_rt_change (bgp, vpn); +} + +/* + * Unconfigure the Export RT for a VNI (vty handler) + */ +static void +evpn_unconfigure_export_rt (struct bgp *bgp, struct bgpevpn *vpn, + struct ecommunity *ecomdel) +{ + struct listnode *node, *nnode, *node_to_del; + struct ecommunity *ecom; + + /* Delete all export RTs */ + if (ecomdel == NULL) + { + /* Reset to default and process all routes. */ + for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) + ecommunity_free (&ecom); + + list_delete_all_node(vpn->export_rtl); + } + + /* Delete a specific export RT */ + else + { + node_to_del = NULL; + + for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) + { + if (ecommunity_match (ecom, ecomdel)) + { + ecommunity_free (&ecom); + node_to_del = node; + break; + } + } + + if (node_to_del) + list_delete_node(vpn->export_rtl, node_to_del); + } + + if (list_isempty(vpn->export_rtl)) + { + UNSET_FLAG (vpn->flags, VNI_FLAG_EXPRT_CFGD); + bgp_evpn_derive_auto_rt_export (bgp, vpn); + } + + if (is_vni_live (vpn)) + bgp_evpn_handle_export_rt_change (bgp, vpn); +} + +/* + * Configure RD for a VNI (vty handler) + */ +static void +evpn_configure_rd (struct bgp *bgp, struct bgpevpn *vpn, + struct prefix_rd *rd) +{ + /* If the VNI is "live", we need to delete and withdraw this VNI's + * local routes with the prior RD first. Then, after updating RD, + * need to re-advertise. + */ + if (is_vni_live (vpn)) + bgp_evpn_handle_rd_change (bgp, vpn, 1); + + /* update RD */ + memcpy(&vpn->prd, rd, sizeof (struct prefix_rd)); + SET_FLAG (vpn->flags, VNI_FLAG_RD_CFGD); + + if (is_vni_live (vpn)) + bgp_evpn_handle_rd_change (bgp, vpn, 0); +} + +/* + * Unconfigure RD for a VNI (vty handler) + */ +static void +evpn_unconfigure_rd (struct bgp *bgp, struct bgpevpn *vpn) +{ + /* If the VNI is "live", we need to delete and withdraw this VNI's + * local routes with the prior RD first. Then, after resetting RD + * to automatic value, need to re-advertise. + */ + if (is_vni_live (vpn)) + bgp_evpn_handle_rd_change (bgp, vpn, 1); + + /* reset RD to default */ + bgp_evpn_derive_auto_rd (bgp, vpn); + + if (is_vni_live (vpn)) + bgp_evpn_handle_rd_change (bgp, vpn, 0); +} + +/* + * Create VNI, if not already present (VTY handler). Mark as configured. + */ +static struct bgpevpn * +evpn_create_update_vni (struct bgp *bgp, vni_t vni) +{ + struct bgpevpn *vpn; + + if (!bgp->vnihash) + return NULL; + + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (!vpn) + { + vpn = bgp_evpn_new (bgp, vni, bgp->router_id); + if (!vpn) + { + zlog_err ("%u: Failed to allocate VNI entry for VNI %u - at Config", + bgp->vrf_id, vni); + return NULL; + } + } + + /* Mark as configured. */ + SET_FLAG (vpn->flags, VNI_FLAG_CFGD); + return vpn; +} + +/* + * Delete VNI. If VNI does not exist in the system (i.e., just + * configuration), all that is needed is to free it. Otherwise, + * any parameters configured for the VNI need to be reset (with + * appropriate action) and the VNI marked as unconfigured; the + * VNI will continue to exist, purely as a "learnt" entity. + */ +static int +evpn_delete_vni (struct bgp *bgp, struct bgpevpn *vpn) +{ + assert (bgp->vnihash); + + if (!is_vni_live (vpn)) + { + bgp_evpn_free (bgp, vpn); + return 0; + } + + /* We need to take the unconfigure action for each parameter of this VNI + * that is configured. Some optimization is possible, but not worth the + * additional code for an operation that should be pretty rare. + */ + UNSET_FLAG (vpn->flags, VNI_FLAG_CFGD); + + /* First, deal with the export side - RD and export RT changes. */ + if (is_rd_configured (vpn)) + evpn_unconfigure_rd (bgp, vpn); + if (is_export_rt_configured (vpn)) + evpn_unconfigure_export_rt (bgp, vpn, NULL); + + /* Next, deal with the import side. */ + if (is_import_rt_configured (vpn)) + evpn_unconfigure_import_rt (bgp, vpn, NULL); + + return 0; +} + +/* + * Display import RT mapping to VNIs (vty handler) + */ +static void +evpn_show_import_rts (struct vty *vty, struct bgp *bgp) +{ + hash_iterate (bgp->import_rt_hash, + (void (*) (struct hash_backet *, void *)) + show_import_rt_entry, vty); +} + +/* + * Display EVPN routes for all VNIs - vty handler. + */ +static void +evpn_show_routes_vni_all (struct vty *vty, struct bgp *bgp, struct in_addr vtep_ip) +{ + u_int32_t num_vnis; + struct vni_walk_ctx wctx; + + num_vnis = hashcount(bgp->vnihash); + if (!num_vnis) + return; + memset (&wctx, 0, sizeof (struct vni_walk_ctx)); + wctx.bgp = bgp; + wctx.vty = vty; + wctx.vtep_ip = vtep_ip; + hash_iterate (bgp->vnihash, + (void (*) (struct hash_backet *, void *)) + show_vni_routes_hash, &wctx); +} + +/* + * Display EVPN routes for a VNI -- for specific type-3 route (vty handler). + */ +static void +evpn_show_route_vni_multicast (struct vty *vty, struct bgp *bgp, + vni_t vni, struct in_addr orig_ip) +{ + struct bgpevpn *vpn; + struct prefix_evpn p; + struct bgp_node *rn; + struct bgp_info *ri; + u_int32_t path_cnt = 0; + afi_t afi; + safi_t safi; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + + /* Locate VNI. */ + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (!vpn) + { + vty_out (vty, "VNI not found\n"); + return; + } + + /* See if route exists. */ + build_evpn_type3_prefix (&p, orig_ip); + rn = bgp_node_lookup (vpn->route_table, (struct prefix *)&p); + if (!rn || !rn->info) + { + vty_out (vty, "%% Network not in table\n"); + return; + } + + /* Prefix and num paths displayed once per prefix. */ + route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi, NULL); + + /* Display each path for this prefix. */ + for (ri = rn->info; ri; ri = ri->next) + { + route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, NULL); + path_cnt++; + } + + vty_out (vty, "\nDisplayed %u paths for requested prefix\n", + path_cnt); +} + +/* + * Display EVPN routes for a VNI -- for specific MAC and/or IP (vty handler). + * By definition, only matching type-2 route will be displayed. + */ +static void +evpn_show_route_vni_macip (struct vty *vty, struct bgp *bgp, + vni_t vni, struct ethaddr *mac, + struct ipaddr *ip) +{ + struct bgpevpn *vpn; + struct prefix_evpn p; + struct bgp_node *rn; + struct bgp_info *ri; + u_int32_t path_cnt = 0; + afi_t afi; + safi_t safi; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + + /* Locate VNI. */ + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (!vpn) + { + vty_out (vty, "VNI not found\n"); + return; + } + + /* See if route exists. Look for both non-sticky and sticky. */ + build_evpn_type2_prefix (&p, mac, ip); + rn = bgp_node_lookup (vpn->route_table, (struct prefix *)&p); + if (!rn || !rn->info) + { + vty_out (vty, "%% Network not in table\n"); + return; + } + + /* Prefix and num paths displayed once per prefix. */ + route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi, NULL); + + /* Display each path for this prefix. */ + for (ri = rn->info; ri; ri = ri->next) + { + route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, NULL); + path_cnt++; + } + + vty_out (vty, "\nDisplayed %u paths for requested prefix\n", + path_cnt); +} + +/* + * Display EVPN routes for a VNI - vty handler. + * If 'type' is non-zero, only routes matching that type are shown. + * If the vtep_ip is non zero, only routes behind that vtep are shown + */ +static void +evpn_show_routes_vni (struct vty *vty, struct bgp *bgp, + vni_t vni, int type, struct in_addr vtep_ip) +{ + struct bgpevpn *vpn; + + /* Locate VNI. */ + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (!vpn) + { + vty_out (vty, "VNI not found\n"); + return; + } + + /* Walk this VNI's route table and display appropriate routes. */ + show_vni_routes (bgp, vpn, type, vty, vtep_ip); +} + +/* + * Display BGP EVPN routing table -- for specific RD and MAC and/or + * IP (vty handler). By definition, only matching type-2 route will be + * displayed. + */ +static void +evpn_show_route_rd_macip (struct vty *vty, struct bgp *bgp, + struct prefix_rd *prd, struct ethaddr *mac, + struct ipaddr *ip) +{ + struct prefix_evpn p; + struct bgp_node *rn; + struct bgp_info *ri; + afi_t afi; + safi_t safi; + u_int32_t path_cnt = 0; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + + /* See if route exists. Look for both non-sticky and sticky. */ + build_evpn_type2_prefix (&p, mac, ip); + rn = bgp_afi_node_lookup (bgp->rib[afi][safi], afi, safi, + (struct prefix *)&p, prd); + if (!rn || !rn->info) + { + vty_out (vty, "%% Network not in table\n"); + return; + } + + /* Prefix and num paths displayed once per prefix. */ + route_vty_out_detail_header (vty, bgp, rn, prd, afi, safi, NULL); + + /* Display each path for this prefix. */ + for (ri = rn->info; ri; ri = ri->next) + { + route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, NULL); + path_cnt++; + } + + vty_out (vty, "\nDisplayed %u paths for requested prefix\n", + path_cnt); +} + +/* + * Display BGP EVPN routing table -- for specific RD (vty handler) + * If 'type' is non-zero, only routes matching that type are shown. + */ +static void +evpn_show_route_rd (struct vty *vty, struct bgp *bgp, + struct prefix_rd *prd, int type) +{ + struct bgp_node *rd_rn; + struct bgp_table *table; + struct bgp_node *rn; + struct bgp_info *ri; + int rd_header = 1; + afi_t afi; + safi_t safi; + u_int32_t prefix_cnt, path_cnt; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + prefix_cnt = path_cnt = 0; + + rd_rn = bgp_node_lookup (bgp->rib[afi][safi], (struct prefix *) prd); + if (!rd_rn) + return; + table = (struct bgp_table *)rd_rn->info; + if (table == NULL) + return; + + /* Display all prefixes with this RD. */ + for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) + { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + if (type && + evp->prefix.route_type != type) + continue; + + if (rn->info) + { + /* RD header and legend - once overall. */ + if (rd_header) + { + vty_out (vty, "EVPN type-2 prefix: [2]:[ESI]:[EthTag]:[MAClen]:" + "[MAC]\n"); + vty_out (vty, "EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:" + "[OrigIP]\n\n"); + rd_header = 0; + } + + /* Prefix and num paths displayed once per prefix. */ + route_vty_out_detail_header (vty, bgp, rn, prd, afi, safi, NULL); + + prefix_cnt++; + } + + /* Display each path for this prefix. */ + for (ri = rn->info; ri; ri = ri->next) + { + route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi, NULL); + path_cnt++; + } + } + + if (prefix_cnt == 0) + vty_out (vty, "No prefixes exist with this RD%s\n", + type ? " (of requested type)" : ""); + else + vty_out (vty, "\nDisplayed %u prefixes (%u paths) with this RD%s\n", + prefix_cnt, path_cnt, + type ? " (of requested type)" : ""); +} + +/* + * Display BGP EVPN routing table - all routes (vty handler). + * If 'type' is non-zero, only routes matching that type are shown. + */ +static void +evpn_show_all_routes (struct vty *vty, struct bgp *bgp, int type) +{ + struct bgp_node *rd_rn; + struct bgp_table *table; + struct bgp_node *rn; + struct bgp_info *ri; + int header = 1; + int rd_header; + afi_t afi; + safi_t safi; + u_int32_t prefix_cnt, path_cnt; + + afi = AFI_L2VPN; + safi = SAFI_EVPN; + prefix_cnt = path_cnt = 0; + + /* EVPN routing table is a 2-level table with the first level being + * the RD. + */ + for (rd_rn = bgp_table_top (bgp->rib[afi][safi]); rd_rn; + rd_rn = bgp_route_next (rd_rn)) + { + table = (struct bgp_table *)rd_rn->info; + if (table == NULL) + continue; + + rd_header = 1; + + /* Display all prefixes for an RD */ + for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) + { + struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p; + + if (type && + evp->prefix.route_type != type) + continue; + + if (rn->info) + { + /* Overall header/legend displayed once. */ + if (header) + { + bgp_evpn_show_route_header (vty, bgp); + header = 0; + } + + /* RD header - per RD. */ + if (rd_header) + { + bgp_evpn_show_route_rd_header (vty, rd_rn); + rd_header = 0; + } + + prefix_cnt++; + } + + /* For EVPN, the prefix is displayed for each path (to fit in + * with code that already exists). + */ + for (ri = rn->info; ri; ri = ri->next) + { + path_cnt++; + route_vty_out (vty, &rn->p, ri, 0, SAFI_EVPN, NULL); + } + } + } + + if (prefix_cnt == 0) + vty_out (vty, "No EVPN prefixes %sexist\n", + type ? "(of requested type) " : ""); + else + vty_out (vty, "\nDisplayed %u prefixes (%u paths)%s\n", + prefix_cnt, path_cnt, + type ? " (of requested type)" : ""); +} + +/* + * Display specified VNI (vty handler) + */ +static void +evpn_show_vni (struct vty *vty, struct bgp *bgp, vni_t vni) +{ + struct bgpevpn *vpn; + + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (!vpn) + { + vty_out (vty, "VNI not found\n"); + return; + } + + display_vni (vty, vpn); +} + +/* + * Display a VNI (upon user query). + */ +static void +evpn_show_all_vnis (struct vty *vty, struct bgp *bgp) +{ + u_int32_t num_vnis; + + num_vnis = hashcount(bgp->vnihash); + if (!num_vnis) + return; + vty_out(vty, "Number of VNIs: %u\n", num_vnis); + vty_out(vty, "Flags: * - Kernel \n"); + vty_out(vty, " %-10s %-15s %-21s %-25s %-25s\n", + "VNI", "Orig IP", "RD", "Import RT", "Export RT"); + hash_iterate (bgp->vnihash, + (void (*) (struct hash_backet *, void *)) + show_vni_entry, vty); +} + +/* + * EVPN (VNI advertisement) enabled. Register with zebra. + */ +static void +evpn_set_advertise_all_vni (struct bgp *bgp) +{ + bgp->advertise_all_vni = 1; + bgp_zebra_advertise_all_vni (bgp, bgp->advertise_all_vni); +} + +/* + * EVPN (VNI advertisement) disabled. De-register with zebra. Cleanup VNI + * cache, EVPN routes (delete and withdraw from peers). + */ +static void +evpn_unset_advertise_all_vni (struct bgp *bgp) +{ + bgp->advertise_all_vni = 0; + bgp_zebra_advertise_all_vni (bgp, bgp->advertise_all_vni); + bgp_evpn_cleanup_on_disable (bgp); +} +#endif /* HAVE_CUMULUS */ + +static void +write_vni_config (struct vty *vty, struct bgpevpn *vpn, int *write) +{ + char buf1[INET6_ADDRSTRLEN]; + afi_t afi = AFI_L2VPN; + safi_t safi = SAFI_EVPN; + char *ecom_str; + struct listnode *node, *nnode; + struct ecommunity *ecom; + + if (is_vni_configured (vpn)) + { + bgp_config_write_family_header (vty, afi, safi, write); + vty_out (vty, " vni %d\n", vpn->vni); + if (is_rd_configured (vpn)) + vty_out (vty, " rd %s\n", + prefix_rd2str (&vpn->prd, buf1, RD_ADDRSTRLEN)); + + if (is_import_rt_configured (vpn)) + { + for (ALL_LIST_ELEMENTS (vpn->import_rtl, node, nnode, ecom)) + { + ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + vty_out (vty, " route-target import %s\n", ecom_str); + XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); + } + } + + if (is_export_rt_configured (vpn)) + { + for (ALL_LIST_ELEMENTS (vpn->export_rtl, node, nnode, ecom)) + { + ecom_str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); + vty_out (vty, " route-target export %s\n", ecom_str); + XFREE (MTYPE_ECOMMUNITY_STR, ecom_str); + } + } + + vty_out (vty, " exit-vni\n"); + } +} + +static void +write_vni_config_for_entry (struct hash_backet *backet, + struct evpn_config_write *cfg) +{ + struct bgpevpn *vpn = (struct bgpevpn *) backet->data; + write_vni_config (cfg->vty, vpn, &cfg->write); +} + +#if defined (HAVE_CUMULUS) +DEFUN (bgp_evpn_advertise_all_vni, + bgp_evpn_advertise_all_vni_cmd, + "advertise-all-vni", + "Advertise All local VNIs\n") +{ + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + + if (!bgp) + return CMD_WARNING; + evpn_set_advertise_all_vni (bgp); + return CMD_SUCCESS; +} + +DEFUN (no_bgp_evpn_advertise_all_vni, + no_bgp_evpn_advertise_all_vni_cmd, + "no advertise-all-vni", + NO_STR + "Advertise All local VNIs\n") +{ + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + + if (!bgp) + return CMD_WARNING; + evpn_unset_advertise_all_vni (bgp); + return CMD_SUCCESS; +} + +DEFUN (show_bgp_evpn_vni, + show_bgp_evpn_vni_cmd, + "show bgp evpn vni", + SHOW_STR + BGP_STR + EVPN_HELP_STR + "Show VNI\n") +{ + struct bgp *bgp; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + vty_out (vty, "Advertise All VNI flag: %s\n", + bgp->advertise_all_vni? "Enabled" : "Disabled"); + + evpn_show_all_vnis (vty, bgp); + return CMD_SUCCESS; +} + +DEFUN (show_bgp_evpn_vni_num, + show_bgp_evpn_vni_num_cmd, + "show bgp evpn vni (1-16777215)", + SHOW_STR + BGP_STR + "Address family modifier\n" + "Show VNI\n" + "VNI number\n") +{ + vni_t vni; + struct bgp *bgp; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + vni = strtoul(argv[4]->arg, NULL, 10); + + evpn_show_vni (vty, bgp, vni); + return CMD_SUCCESS; +} + +/* `show bgp evpn summary' commands. */ +DEFUN (show_bgp_evpn_summary, + show_bgp_evpn_summary_cmd, + "show bgp evpn summary [json]", + SHOW_STR + BGP_STR + "EVPN\n" + "Summary of BGP neighbor status\n" + "JavaScript Object Notation\n") +{ + u_char uj = use_json(argc, argv); + return bgp_show_summary_vty (vty, NULL, AFI_L2VPN, SAFI_EVPN, uj); +} + +/* Show bgp evpn route */ +DEFUN (show_bgp_evpn_route, + show_bgp_evpn_route_cmd, + "show bgp evpn route [type <macip|multicast>]", + SHOW_STR + BGP_STR + "Address Family Modifier\n" + "Display EVPN route information\n" + "Specify Route type\n" + "MAC-IP (Type-2) route\n" + "Multicast (Type-3) route\n") +{ + struct bgp *bgp; + int type = 0; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + if (argc == 6) + { + if (strncmp (argv[5]->arg, "ma", 2) == 0) + type = BGP_EVPN_MAC_IP_ROUTE; + else if (strncmp (argv[5]->arg, "mu", 2) == 0) + type = BGP_EVPN_IMET_ROUTE; + else + return CMD_WARNING; + } + + evpn_show_all_routes (vty, bgp, type); + return CMD_SUCCESS; +} + +DEFUN (show_bgp_evpn_route_rd, + show_bgp_evpn_route_rd_cmd, + "show bgp evpn route rd ASN:nn_or_IP-address:nn [type <macip|multicast>]", + SHOW_STR + BGP_STR + "Address Family Modifier\n" + "Display EVPN route information\n" + "Route Distinguisher\n" + "ASN:XX or A.B.C.D:XX\n" + "Specify Route type\n" + "MAC-IP (Type-2) route\n" + "Multicast (Type-3) route\n") +{ + struct bgp *bgp; + int ret; + struct prefix_rd prd; + int type = 0; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + ret = str2prefix_rd (argv[5]->arg, &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher\n"); + return CMD_WARNING; + } + + if (argc == 8) + { + if (strncmp (argv[7]->arg, "ma", 2) == 0) + type = BGP_EVPN_MAC_IP_ROUTE; + else if (strncmp (argv[7]->arg, "mu", 2) == 0) + type = BGP_EVPN_IMET_ROUTE; + else + return CMD_WARNING; + } + + evpn_show_route_rd (vty, bgp, &prd, type); + return CMD_SUCCESS; +} + +DEFUN (show_bgp_evpn_route_rd_macip, + show_bgp_evpn_route_rd_macip_cmd, + "show bgp evpn route rd ASN:nn_or_IP-address:nn mac WORD [ip WORD]", + SHOW_STR + BGP_STR + "Address Family Modifier\n" + "Display EVPN route information\n" + "Route Distinguisher\n" + "ASN:XX or A.B.C.D:XX\n" + "MAC\n" + "MAC address (e.g., 00:e0:ec:20:12:62)\n" + "IP\n" + "IP address (IPv4 or IPv6)\n") +{ + struct bgp *bgp; + int ret; + struct prefix_rd prd; + struct ethaddr mac; + struct ipaddr ip; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + ret = str2prefix_rd (argv[5]->arg, &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher\n"); + return CMD_WARNING; + } + if (!prefix_str2mac (argv[7]->arg, &mac)) + { + vty_out (vty, "%% Malformed MAC address\n"); + return CMD_WARNING; + } + memset (&ip, 0, sizeof (ip)); + if (argc == 10 && argv[9]->arg != NULL) + { + if (str2ipaddr (argv[9]->arg, &ip) != 0) + { + vty_out (vty, "%% Malformed IP address\n"); + return CMD_WARNING; + } + } + + evpn_show_route_rd_macip (vty, bgp, &prd, &mac, &ip); + return CMD_SUCCESS; +} + +DEFUN (show_bgp_evpn_route_vni, + show_bgp_evpn_route_vni_cmd, + "show bgp evpn route vni (1-16777215) [<type <macip|multicast> | vtep A.B.C.D>]", + SHOW_STR + BGP_STR + "Address Family Modifier\n" + "Display EVPN route information\n" + "VXLAN Network Identifier\n" + "VNI number\n" + "Specify Route type\n" + "MAC-IP (Type-2) route\n" + "Multicast (Type-3) route\n" + "Remote VTEP\n" + "Remote VTEP IP address\n") +{ + vni_t vni; + struct bgp *bgp; + struct in_addr vtep_ip; + int type = 0; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + vtep_ip.s_addr = 0; + + vni = strtoul(argv[5]->arg, NULL, 10); + + if (argc == 8 && argv[6]->arg) + { + if (strncmp (argv[6]->arg, "type", 4) == 0) + { + if (strncmp (argv[7]->arg, "ma", 2) == 0) + type = BGP_EVPN_MAC_IP_ROUTE; + else if (strncmp (argv[7]->arg, "mu", 2) == 0) + type = BGP_EVPN_IMET_ROUTE; + else + return CMD_WARNING; + } + else if (strncmp (argv[6]->arg, "vtep", 4) == 0) + { + if (!inet_aton (argv[7]->arg, &vtep_ip)) + { + vty_out (vty, "%% Malformed VTEP IP address\n"); + return CMD_WARNING; + } + } + else + return CMD_WARNING; + } + + evpn_show_routes_vni (vty, bgp, vni, type, vtep_ip); + return CMD_SUCCESS; +} + +DEFUN (show_bgp_evpn_route_vni_macip, + show_bgp_evpn_route_vni_macip_cmd, + "show bgp evpn route vni (1-16777215) mac WORD [ip WORD]", + SHOW_STR + BGP_STR + "Address Family Modifier\n" + "Display EVPN route information\n" + "VXLAN Network Identifier\n" + "VNI number\n" + "MAC\n" + "MAC address (e.g., 00:e0:ec:20:12:62)\n" + "IP\n" + "IP address (IPv4 or IPv6)\n") +{ + vni_t vni; + struct bgp *bgp; + struct ethaddr mac; + struct ipaddr ip; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + vni = strtoul(argv[5]->arg, NULL, 10); + if (!prefix_str2mac (argv[7]->arg, &mac)) + { + vty_out (vty, "%% Malformed MAC address\n"); + return CMD_WARNING; + } + memset (&ip, 0, sizeof (ip)); + if (argc == 10 && argv[9]->arg != NULL) + { + if (str2ipaddr (argv[9]->arg, &ip) != 0) + { + vty_out (vty, "%% Malformed IP address\n"); + return CMD_WARNING; + } + } + + evpn_show_route_vni_macip (vty, bgp, vni, &mac, &ip); + return CMD_SUCCESS; +} + +DEFUN (show_bgp_evpn_route_vni_multicast, + show_bgp_evpn_route_vni_multicast_cmd, + "show bgp evpn route vni (1-16777215) multicast A.B.C.D", + SHOW_STR + BGP_STR + "Address Family Modifier\n" + "Display EVPN route information\n" + "VXLAN Network Identifier\n" + "VNI number\n" + "Multicast (Type-3) route\n" + "Originating Router IP address\n") +{ + vni_t vni; + struct bgp *bgp; + int ret; + struct in_addr orig_ip; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + vni = strtoul(argv[5]->arg, NULL, 10); + ret = inet_aton (argv[7]->arg, &orig_ip); + if (!ret) + { + vty_out (vty, "%% Malformed Originating Router IP address\n"); + return CMD_WARNING; + } + + evpn_show_route_vni_multicast (vty, bgp, vni, orig_ip); + return CMD_SUCCESS; +} + +DEFUN (show_bgp_evpn_route_vni_all, + show_bgp_evpn_route_vni_all_cmd, + "show bgp evpn route vni all [vtep A.B.C.D]", + SHOW_STR + BGP_STR + "Address Family Modifier\n" + "Display EVPN route information\n" + "VXLAN Network Identifier\n" + "All VNIs\n" + "Remote VTEP\n" + "Remote VTEP IP address\n") +{ + struct bgp *bgp; + struct in_addr vtep_ip; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + vtep_ip.s_addr = 0; + if (argc == 8 && argv[7]->arg) + { + if (!inet_aton (argv[7]->arg, &vtep_ip)) + { + vty_out (vty, "%% Malformed VTEP IP address\n"); + return CMD_WARNING; + } + } + + evpn_show_routes_vni_all (vty, bgp, vtep_ip); + return CMD_SUCCESS; +} + +DEFUN (show_bgp_evpn_import_rt, + show_bgp_evpn_import_rt_cmd, + "show bgp evpn import-rt", + SHOW_STR + BGP_STR + "Address family modifier\n" + "Show import route target\n") +{ + struct bgp *bgp; + + bgp = bgp_get_default(); + if (!bgp) + return CMD_WARNING; + + evpn_show_import_rts (vty, bgp); + return CMD_SUCCESS; +} + +DEFUN_NOSH (bgp_evpn_vni, + bgp_evpn_vni_cmd, + "vni (1-16777215)", + "VXLAN Network Identifier\n" + "VNI number\n") +{ + vni_t vni; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + struct bgpevpn *vpn; + + if (!bgp) + return CMD_WARNING; + + vni = strtoul(argv[1]->arg, NULL, 10); + + /* Create VNI, or mark as configured. */ + vpn = evpn_create_update_vni (bgp, vni); + if (!vpn) + { + vty_out (vty, "%% Failed to create VNI \n"); + return CMD_WARNING; + } + + VTY_PUSH_CONTEXT_SUB (BGP_EVPN_VNI_NODE, vpn); + return CMD_SUCCESS; +} + +DEFUN (no_bgp_evpn_vni, + no_bgp_evpn_vni_cmd, + "no vni (1-16777215)", + NO_STR + "VXLAN Network Identifier\n" + "VNI number\n") +{ + vni_t vni; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + struct bgpevpn *vpn; + + if (!bgp) + return CMD_WARNING; + + vni = strtoul(argv[2]->arg, NULL, 10); + + /* Check if we should disallow. */ + vpn = bgp_evpn_lookup_vni (bgp, vni); + if (!vpn) + { + vty_out (vty, "%% Specified VNI does not exist\n"); + return CMD_WARNING; + } + if (!is_vni_configured (vpn)) + { + vty_out (vty, "%% Specified VNI is not configured\n"); + return CMD_WARNING; + } + + evpn_delete_vni (bgp, vpn); + return CMD_SUCCESS; +} + +DEFUN_NOSH (exit_vni, + exit_vni_cmd, + "exit-vni", + "Exit from VNI mode\n") +{ + if (vty->node == BGP_EVPN_VNI_NODE) + vty->node = BGP_EVPN_NODE; + return CMD_SUCCESS; +} + +DEFUN (bgp_evpn_vni_rd, + bgp_evpn_vni_rd_cmd, + "rd ASN:nn_or_IP-address:nn", + "Route Distinguisher\n" + "ASN:XX or A.B.C.D:XX\n") +{ + struct prefix_rd prd; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int ret; + + if (!bgp || !vpn) + return CMD_WARNING; + + ret = str2prefix_rd (argv[1]->arg, &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher\n"); + return CMD_WARNING; + } + + /* If same as existing value, there is nothing more to do. */ + if (bgp_evpn_rd_matches_existing (vpn, &prd)) + return CMD_SUCCESS; + + /* Configure or update the RD. */ + evpn_configure_rd (bgp, vpn, &prd); + return CMD_SUCCESS; +} + +DEFUN (no_bgp_evpn_vni_rd, + no_bgp_evpn_vni_rd_cmd, + "no rd ASN:nn_or_IP-address:nn", + NO_STR + "Route Distinguisher\n" + "ASN:XX or A.B.C.D:XX\n") +{ + struct prefix_rd prd; + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int ret; + + if (!bgp || !vpn) + return CMD_WARNING; + + ret = str2prefix_rd (argv[2]->arg, &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher\n"); + return CMD_WARNING; + } + + /* Check if we should disallow. */ + if (!is_rd_configured (vpn)) + { + vty_out (vty, "%% RD is not configured for this VNI\n"); + return CMD_WARNING; + } + + if (!bgp_evpn_rd_matches_existing(vpn, &prd)) + { + vty_out (vty, "%% RD specified does not match configuration for this VNI\n"); + return CMD_WARNING; + } + + evpn_unconfigure_rd (bgp, vpn); + return CMD_SUCCESS; +} + +DEFUN (no_bgp_evpn_vni_rd_without_val, + no_bgp_evpn_vni_rd_without_val_cmd, + "no rd", + NO_STR + "Route Distinguisher\n") +{ + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + + if (!bgp || !vpn) + return CMD_WARNING; + + /* Check if we should disallow. */ + if (!is_rd_configured (vpn)) + { + vty_out (vty, "%% RD is not configured for this VNI\n"); + return CMD_WARNING; + } + + evpn_unconfigure_rd (bgp, vpn); + return CMD_SUCCESS; +} + +/* + * Loop over all extended-communities in the route-target list rtl and + * return 1 if we find ecomtarget + */ +static int +bgp_evpn_rt_matches_existing (struct list *rtl, + struct ecommunity *ecomtarget) +{ + struct listnode *node, *nnode; + struct ecommunity *ecom; + + for (ALL_LIST_ELEMENTS (rtl, node, nnode, ecom)) + { + if (ecommunity_match (ecom, ecomtarget)) + return 1; + } + + return 0; +} + + +DEFUN (bgp_evpn_vni_rt, + bgp_evpn_vni_rt_cmd, + "route-target <both|import|export> RT", + "Route Target\n" + "import and export\n" + "import\n" + "export\n" + "Route target (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") +{ + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int rt_type; + struct ecommunity *ecomadd = NULL; + + if (!bgp || !vpn) + return CMD_WARNING; + + if (!strcmp (argv[1]->arg, "import")) + rt_type = RT_TYPE_IMPORT; + else if (!strcmp (argv[1]->arg, "export")) + rt_type = RT_TYPE_EXPORT; + else if (!strcmp (argv[1]->arg, "both")) + rt_type = RT_TYPE_BOTH; + else + { + vty_out (vty, "%% Invalid Route Target type\n"); + return CMD_WARNING; + } + + /* Add/update the import route-target */ + if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_IMPORT) + { + ecomadd = ecommunity_str2com (argv[2]->arg, + ECOMMUNITY_ROUTE_TARGET, 0); + ecommunity_str(ecomadd); + if (!ecomadd) + { + vty_out (vty, "%% Malformed Route Target list\n"); + return CMD_WARNING; + } + + /* Do nothing if we already have this import route-target */ + if (! bgp_evpn_rt_matches_existing (vpn->import_rtl, ecomadd)) + evpn_configure_import_rt (bgp, vpn, ecomadd); + } + + /* Add/update the export route-target */ + if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_EXPORT) + { + ecomadd = ecommunity_str2com (argv[2]->arg, + ECOMMUNITY_ROUTE_TARGET, 0); + ecommunity_str(ecomadd); + if (!ecomadd) + { + vty_out (vty, "%% Malformed Route Target list\n"); + return CMD_WARNING; + } + + /* Do nothing if we already have this export route-target */ + if (! bgp_evpn_rt_matches_existing (vpn->export_rtl, ecomadd)) + evpn_configure_export_rt (bgp, vpn, ecomadd); + } + + return CMD_SUCCESS; +} + +DEFUN (no_bgp_evpn_vni_rt, + no_bgp_evpn_vni_rt_cmd, + "no route-target <both|import|export> RT", + NO_STR + "Route Target\n" + "import and export\n" + "import\n" + "export\n" + "ASN:XX or A.B.C.D:XX\n") +{ + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int rt_type, found_ecomdel; + struct ecommunity *ecomdel = NULL; + + if (!bgp || !vpn) + return CMD_WARNING; + + if (!strcmp (argv[2]->arg, "import")) + rt_type = RT_TYPE_IMPORT; + else if (!strcmp (argv[2]->arg, "export")) + rt_type = RT_TYPE_EXPORT; + else if (!strcmp (argv[2]->arg, "both")) + rt_type = RT_TYPE_BOTH; + else + { + vty_out (vty, "%% Invalid Route Target type\n"); + return CMD_WARNING; + } + + /* The user did "no route-target import", check to see if there are any + * import route-targets configured. */ + if (rt_type == RT_TYPE_IMPORT) + { + if (!is_import_rt_configured (vpn)) + { + vty_out (vty, "%% Import RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } + else if (rt_type == RT_TYPE_EXPORT) + { + if (!is_export_rt_configured (vpn)) + { + vty_out (vty, "%% Export RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } + else if (rt_type == RT_TYPE_BOTH) + { + if (!is_import_rt_configured (vpn) && !is_export_rt_configured (vpn)) + { + vty_out (vty, "%% Import/Export RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } + + ecomdel = ecommunity_str2com (argv[3]->arg, ECOMMUNITY_ROUTE_TARGET, 0); + ecommunity_str(ecomdel); + if (!ecomdel) + { + vty_out (vty, "%% Malformed Route Target list\n"); + return CMD_WARNING; + } + + if (rt_type == RT_TYPE_IMPORT) + { + if (!bgp_evpn_rt_matches_existing (vpn->import_rtl, ecomdel)) + { + vty_out (vty, "%% RT specified does not match configuration for this VNI\n"); + return CMD_WARNING; + } + evpn_unconfigure_import_rt (bgp, vpn, ecomdel); + } + else if (rt_type == RT_TYPE_EXPORT) + { + if (!bgp_evpn_rt_matches_existing (vpn->export_rtl, ecomdel)) + { + vty_out (vty, "%% RT specified does not match configuration for this VNI\n"); + return CMD_WARNING; + } + evpn_unconfigure_export_rt (bgp, vpn, ecomdel); + } + else if (rt_type == RT_TYPE_BOTH) + { + found_ecomdel = 0; + + if (bgp_evpn_rt_matches_existing (vpn->import_rtl, ecomdel)) + { + evpn_unconfigure_import_rt (bgp, vpn, ecomdel); + found_ecomdel = 1; + } + + if (bgp_evpn_rt_matches_existing (vpn->export_rtl, ecomdel)) + { + evpn_unconfigure_export_rt (bgp, vpn, ecomdel); + found_ecomdel = 1; + } + + if (! found_ecomdel) + { + vty_out (vty, "%% RT specified does not match configuration for this VNI\n"); + return CMD_WARNING; + } + } + + return CMD_SUCCESS; +} + +DEFUN (no_bgp_evpn_vni_rt_without_val, + no_bgp_evpn_vni_rt_without_val_cmd, + "no route-target <import|export>", + NO_STR + "Route Target\n" + "import\n" + "export\n") +{ + struct bgp *bgp = VTY_GET_CONTEXT(bgp); + VTY_DECLVAR_CONTEXT_SUB(bgpevpn, vpn); + int rt_type; + + if (!bgp || !vpn) + return CMD_WARNING; + + if (!strcmp (argv[2]->arg, "import")) + { + rt_type = RT_TYPE_IMPORT; + } + else if (!strcmp (argv[2]->arg, "export")) + { + rt_type = RT_TYPE_EXPORT; + } + else + { + vty_out (vty, "%% Invalid Route Target type\n"); + return CMD_WARNING; + } + + /* Check if we should disallow. */ + if (rt_type == RT_TYPE_IMPORT) + { + if (!is_import_rt_configured (vpn)) + { + vty_out (vty, "%% Import RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } + else + { + if (!is_export_rt_configured (vpn)) + { + vty_out (vty, "%% Export RT is not configured for this VNI\n"); + return CMD_WARNING; + } + } + + /* Unconfigure the RT. */ + if (rt_type == RT_TYPE_IMPORT) + evpn_unconfigure_import_rt (bgp, vpn, NULL); + else + evpn_unconfigure_export_rt (bgp, vpn, NULL); + return CMD_SUCCESS; +} +#endif +/* + * Output EVPN configuration information. + */ +void +bgp_config_write_evpn_info (struct vty *vty, struct bgp *bgp, afi_t afi, + safi_t safi, int *write) +{ + struct evpn_config_write cfg; + + if (bgp->vnihash) + { + cfg.write = *write; + cfg.vty = vty; + hash_iterate (bgp->vnihash, + (void (*) (struct hash_backet *, void *)) + write_vni_config_for_entry, &cfg); + *write = cfg.write; + } + + if (bgp->advertise_all_vni) + { + bgp_config_write_family_header (vty, afi, safi, write); + vty_out (vty, " advertise-all-vni\n"); + } +} + void bgp_ethernetvpn_init(void) { - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_tags_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_tags_cmd); - install_element(VIEW_NODE, - &show_ip_bgp_l2vpn_evpn_all_neighbor_routes_cmd); - install_element(VIEW_NODE, - &show_ip_bgp_l2vpn_evpn_rd_neighbor_routes_cmd); - install_element(VIEW_NODE, - &show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes_cmd); - install_element(VIEW_NODE, - &show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes_cmd); - install_element(VIEW_NODE, &show_ip_bgp_evpn_rd_overlay_cmd); - install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_overlay_cmd); - install_element(BGP_EVPN_NODE, &no_evpnrt5_network_cmd); - install_element(BGP_EVPN_NODE, &evpnrt5_network_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_tags_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_tags_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_neighbor_routes_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_neighbor_routes_cmd); + install_element(VIEW_NODE, + &show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes_cmd); + install_element(VIEW_NODE, + &show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes_cmd); + install_element(VIEW_NODE, &show_ip_bgp_evpn_rd_overlay_cmd); + install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_overlay_cmd); + install_element(BGP_EVPN_NODE, &no_evpnrt5_network_cmd); + install_element(BGP_EVPN_NODE, &evpnrt5_network_cmd); +#if defined(HAVE_CUMULUS) + install_element (BGP_EVPN_NODE, &bgp_evpn_advertise_all_vni_cmd); + install_element (BGP_EVPN_NODE, &no_bgp_evpn_advertise_all_vni_cmd); + + /* "show bgp evpn" commands. */ + install_element (VIEW_NODE, &show_bgp_evpn_vni_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_vni_num_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_summary_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_route_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_route_rd_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_route_rd_macip_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_route_vni_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_route_vni_multicast_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_route_vni_macip_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_route_vni_all_cmd); + install_element (VIEW_NODE, &show_bgp_evpn_import_rt_cmd); + + install_element (BGP_EVPN_NODE, &bgp_evpn_vni_cmd); + install_element (BGP_EVPN_NODE, &no_bgp_evpn_vni_cmd); + install_element (BGP_EVPN_VNI_NODE, &exit_vni_cmd); + install_element (BGP_EVPN_VNI_NODE, &bgp_evpn_vni_rd_cmd); + install_element (BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rd_cmd); + install_element (BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rd_without_val_cmd); + install_element (BGP_EVPN_VNI_NODE, &bgp_evpn_vni_rt_cmd); + install_element (BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rt_cmd); + install_element (BGP_EVPN_VNI_NODE, &no_bgp_evpn_vni_rt_without_val_cmd); +#endif } diff --git a/bgpd/bgp_evpn_vty.h b/bgpd/bgp_evpn_vty.h index fe01e84e2..4c8f63c2f 100644 --- a/bgpd/bgp_evpn_vty.h +++ b/bgpd/bgp_evpn_vty.h @@ -21,6 +21,9 @@ #ifndef _FRR_BGP_EVPN_VTY_H #define _FRR_BGP_EVPN_VTY_H +extern void +bgp_config_write_evpn_info (struct vty *vty, struct bgp *bgp, afi_t afi, + safi_t safi, int *write); extern void bgp_ethernetvpn_init(void); #define L2VPN_HELP_STR "Layer 2 Virtual Private Network\n" diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index b2f0c3ee2..a61321b0e 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -457,9 +457,9 @@ DEFUN (ip_as_path, regex = bgp_regcomp (regstr); if (!regex) { - vty_outln (vty, "can't compile regexp %s", regstr); + vty_out (vty, "can't compile regexp %s\n", regstr); XFREE (MTYPE_TMP, regstr); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } asfilter = as_filter_make (regex, regstr, type); @@ -503,8 +503,8 @@ DEFUN (no_ip_as_path, aslist = as_list_lookup (aslistname); if (aslist == NULL) { - vty_outln (vty, "ip as-path access-list %s doesn't exist",aslistname); - return CMD_WARNING; + vty_out (vty, "ip as-path access-list %s doesn't exist\n",aslistname); + return CMD_WARNING_CONFIG_FAILED; } /* Check the filter type. */ @@ -514,8 +514,8 @@ DEFUN (no_ip_as_path, type = AS_FILTER_DENY; else { - vty_outln (vty, "filter type must be [permit|deny]"); - return CMD_WARNING; + vty_out (vty, "filter type must be [permit|deny]\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Compile AS path. */ @@ -525,9 +525,9 @@ DEFUN (no_ip_as_path, regex = bgp_regcomp (regstr); if (!regex) { - vty_outln (vty, "can't compile regexp %s", regstr); + vty_out (vty, "can't compile regexp %s\n", regstr); XFREE (MTYPE_TMP, regstr); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Lookup asfilter. */ @@ -538,8 +538,8 @@ DEFUN (no_ip_as_path, if (asfilter == NULL) { - vty_out (vty, VTYNL); - return CMD_WARNING; + vty_out (vty, "\n"); + return CMD_WARNING_CONFIG_FAILED; } as_list_filter_delete (aslist, asfilter); @@ -562,9 +562,9 @@ DEFUN (no_ip_as_path_all, aslist = as_list_lookup (argv[idx_word]->arg); if (aslist == NULL) { - vty_outln (vty, "ip as-path access-list %s doesn't exist", + vty_out (vty, "ip as-path access-list %s doesn't exist\n", argv[idx_word]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } as_list_delete (aslist); @@ -581,11 +581,11 @@ as_list_show (struct vty *vty, struct as_list *aslist) { struct as_filter *asfilter; - vty_outln (vty, "AS path access list %s", aslist->name); + vty_out (vty, "AS path access list %s\n", aslist->name); for (asfilter = aslist->head; asfilter; asfilter = asfilter->next) { - vty_outln (vty, " %s %s", filter_type_str (asfilter->type), + vty_out (vty, " %s %s\n", filter_type_str (asfilter->type), asfilter->reg_str); } } @@ -598,22 +598,22 @@ as_list_show_all (struct vty *vty) for (aslist = as_list_master.num.head; aslist; aslist = aslist->next) { - vty_outln (vty, "AS path access list %s", aslist->name); + vty_out (vty, "AS path access list %s\n", aslist->name); for (asfilter = aslist->head; asfilter; asfilter = asfilter->next) { - vty_outln (vty, " %s %s", filter_type_str (asfilter->type), + vty_out (vty, " %s %s\n", filter_type_str (asfilter->type), asfilter->reg_str); } } for (aslist = as_list_master.str.head; aslist; aslist = aslist->next) { - vty_outln (vty, "AS path access list %s", aslist->name); + vty_out (vty, "AS path access list %s\n", aslist->name); for (asfilter = aslist->head; asfilter; asfilter = asfilter->next) { - vty_outln (vty, " %s %s", filter_type_str (asfilter->type), + vty_out (vty, " %s %s\n", filter_type_str (asfilter->type), asfilter->reg_str); } } @@ -658,7 +658,7 @@ config_write_as_list (struct vty *vty) for (aslist = as_list_master.num.head; aslist; aslist = aslist->next) for (asfilter = aslist->head; asfilter; asfilter = asfilter->next) { - vty_outln (vty, "ip as-path access-list %s %s %s", + vty_out (vty, "ip as-path access-list %s %s %s\n", aslist->name, filter_type_str (asfilter->type), asfilter->reg_str); write++; @@ -667,7 +667,7 @@ config_write_as_list (struct vty *vty) for (aslist = as_list_master.str.head; aslist; aslist = aslist->next) for (asfilter = aslist->head; asfilter; asfilter = asfilter->next) { - vty_outln (vty, "ip as-path access-list %s %s %s", + vty_out (vty, "ip as-path access-list %s %s %s\n", aslist->name, filter_type_str (asfilter->type), asfilter->reg_str); write++; diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index fc0654f18..27533a581 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -151,12 +151,10 @@ bgp_reg_dereg_for_label (struct bgp_node *rn, struct bgp_info *ri, assert (ri); if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID)) { - assert (ri->attr->extra); - - if (ri->attr->extra->label_index != BGP_INVALID_LABEL_INDEX) + if (ri->attr->label_index != BGP_INVALID_LABEL_INDEX) { flags |= ZEBRA_FEC_REGISTER_LABEL_INDEX; - stream_putl (s, ri->attr->extra->label_index); + stream_putl (s, ri->attr->label_index); } } SET_FLAG (rn->flags, BGP_NODE_REGISTERED_FOR_LABEL); diff --git a/bgpd/bgp_label.h b/bgpd/bgp_label.h index c98f4531f..a0994d68a 100644 --- a/bgpd/bgp_label.h +++ b/bgpd/bgp_label.h @@ -41,6 +41,9 @@ extern int bgp_nlri_parse_label (struct peer *peer, struct attr *attr, static inline int bgp_labeled_safi (safi_t safi) { + /* NOTE: This API really says a label (tag) MAY be present. Not all EVPN + * routes will have a label. + */ if ((safi == SAFI_LABELED_UNICAST) || (safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) return 1; diff --git a/bgpd/bgp_memory.c b/bgpd/bgp_memory.c index c457f4b3e..6da9ff868 100644 --- a/bgpd/bgp_memory.c +++ b/bgpd/bgp_memory.c @@ -43,7 +43,6 @@ DEFINE_MTYPE(BGPD, BGP_UPDGRP, "BGP update group") DEFINE_MTYPE(BGPD, BGP_UPD_SUBGRP, "BGP update subgroup") DEFINE_MTYPE(BGPD, BGP_PACKET, "BGP packet") DEFINE_MTYPE(BGPD, ATTR, "BGP attribute") -DEFINE_MTYPE(BGPD, ATTR_EXTRA, "BGP extra attributes") DEFINE_MTYPE(BGPD, AS_PATH, "BGP aspath") DEFINE_MTYPE(BGPD, AS_SEG, "BGP aspath seg") DEFINE_MTYPE(BGPD, AS_SEG_DATA, "BGP aspath segment data") @@ -114,3 +113,7 @@ DEFINE_MTYPE(BGPD, BGP_TEA_OPTIONS_VALUE, "BGP TEA Options Value") DEFINE_MTYPE(BGPD, LCOMMUNITY, "Large Community") DEFINE_MTYPE(BGPD, LCOMMUNITY_STR, "Large Community display string") DEFINE_MTYPE(BGPD, LCOMMUNITY_VAL, "Large Community value") + +DEFINE_MTYPE(BGPD, BGP_EVPN, "BGP EVPN Information") +DEFINE_MTYPE(BGPD, BGP_EVPN_IMPORT_RT, "BGP EVPN Import RT") +DEFINE_MTYPE(BGPD, BGP_EVPN_MACIP, "BGP EVPN MAC IP") diff --git a/bgpd/bgp_memory.h b/bgpd/bgp_memory.h index 454092cef..152cfaeaf 100644 --- a/bgpd/bgp_memory.h +++ b/bgpd/bgp_memory.h @@ -39,7 +39,6 @@ DECLARE_MTYPE(BGP_UPDGRP) DECLARE_MTYPE(BGP_UPD_SUBGRP) DECLARE_MTYPE(BGP_PACKET) DECLARE_MTYPE(ATTR) -DECLARE_MTYPE(ATTR_EXTRA) DECLARE_MTYPE(AS_PATH) DECLARE_MTYPE(AS_SEG) DECLARE_MTYPE(AS_SEG_DATA) @@ -110,4 +109,8 @@ DECLARE_MTYPE(BGP_TEA_OPTIONS_VALUE) DECLARE_MTYPE(LCOMMUNITY) DECLARE_MTYPE(LCOMMUNITY_STR) DECLARE_MTYPE(LCOMMUNITY_VAL) + +DECLARE_MTYPE(BGP_EVPN) +DECLARE_MTYPE(BGP_EVPN_IMPORT_RT) +DECLARE_MTYPE(BGP_EVPN_MACIP) #endif /* _QUAGGA_BGP_MEMORY_H */ diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index 34690ac77..7ea5c9e77 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -106,35 +106,31 @@ bgp_maximum_paths_unset (struct bgp *bgp, afi_t afi, safi_t safi, int bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) { - struct attr_extra *ae1, *ae2; int compare; - ae1 = bi1->attr->extra; - ae2 = bi2->attr->extra; - compare = IPV4_ADDR_CMP (&bi1->attr->nexthop, &bi2->attr->nexthop); - if (!compare && ae1 && ae2) + if (!compare) { - if (ae1->mp_nexthop_len == ae2->mp_nexthop_len) + if (bi1->attr->mp_nexthop_len == bi2->attr->mp_nexthop_len) { - switch (ae1->mp_nexthop_len) + switch (bi1->attr->mp_nexthop_len) { case BGP_ATTR_NHLEN_IPV4: case BGP_ATTR_NHLEN_VPNV4: - compare = IPV4_ADDR_CMP (&ae1->mp_nexthop_global_in, - &ae2->mp_nexthop_global_in); + compare = IPV4_ADDR_CMP (&bi1->attr->mp_nexthop_global_in, + &bi2->attr->mp_nexthop_global_in); break; case BGP_ATTR_NHLEN_IPV6_GLOBAL: case BGP_ATTR_NHLEN_VPNV6_GLOBAL: - compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, - &ae2->mp_nexthop_global); + compare = IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_global, + &bi2->attr->mp_nexthop_global); break; case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: - compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, - &ae2->mp_nexthop_global); + compare = IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_global, + &bi2->attr->mp_nexthop_global); if (!compare) - compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_local, - &ae2->mp_nexthop_local); + compare = IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_local, + &bi2->attr->mp_nexthop_local); break; } } @@ -142,14 +138,14 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) /* This can happen if one IPv6 peer sends you global and link-local * nexthops but another IPv6 peer only sends you global */ - else if (ae1->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL || - ae1->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + else if (bi1->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL || + bi1->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { - compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, - &ae2->mp_nexthop_global); + compare = IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_global, + &bi2->attr->mp_nexthop_global); if (!compare) { - if (ae1->mp_nexthop_len < ae2->mp_nexthop_len) + if (bi1->attr->mp_nexthop_len < bi2->attr->mp_nexthop_len) compare = -1; else compare = 1; @@ -663,7 +659,6 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best, struct community *community, *commerge; struct ecommunity *ecomm, *ecommerge; struct lcommunity *lcomm, *lcommerge; - struct attr_extra *ae; struct attr attr = { 0 }; if (old_best && (old_best != new_best) && @@ -697,9 +692,8 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best, aspath = aspath_dup (attr.aspath); origin = attr.origin; community = attr.community ? community_dup (attr.community) : NULL; - ae = attr.extra; - ecomm = (ae && ae->ecommunity) ? ecommunity_dup (ae->ecommunity) : NULL; - lcomm = (ae && ae->lcommunity) ? lcommunity_dup (ae->lcommunity) : NULL; + ecomm = (attr.ecommunity) ? ecommunity_dup (attr.ecommunity) : NULL; + lcomm = (attr.lcommunity) ? lcommunity_dup (attr.lcommunity) : NULL; for (mpinfo = bgp_info_mpath_first (new_best); mpinfo; mpinfo = bgp_info_mpath_next (mpinfo)) @@ -723,28 +717,27 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best, community = community_dup (mpinfo->attr->community); } - ae = mpinfo->attr->extra; - if (ae && ae->ecommunity) + if (mpinfo->attr->ecommunity) { if (ecomm) { - ecommerge = ecommunity_merge (ecomm, ae->ecommunity); + ecommerge = ecommunity_merge (ecomm, mpinfo->attr->ecommunity); ecomm = ecommunity_uniq_sort (ecommerge); ecommunity_free (&ecommerge); } else - ecomm = ecommunity_dup (ae->ecommunity); + ecomm = ecommunity_dup (mpinfo->attr->ecommunity); } - if (ae && ae->lcommunity) + if (mpinfo->attr->lcommunity) { if (lcomm) { - lcommerge = lcommunity_merge (lcomm, ae->lcommunity); + lcommerge = lcommunity_merge (lcomm, mpinfo->attr->lcommunity); lcomm = lcommunity_uniq_sort (lcommerge); lcommunity_free (&lcommerge); } else - lcomm = lcommunity_dup (ae->lcommunity); + lcomm = lcommunity_dup (mpinfo->attr->lcommunity); } } @@ -757,21 +750,18 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best, } if (ecomm) { - ae = bgp_attr_extra_get (&attr); - ae->ecommunity = ecomm; + attr.ecommunity = ecomm; attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES); } /* Zap multipath attr nexthop so we set nexthop to self */ attr.nexthop.s_addr = 0; - if (attr.extra) - memset (&attr.extra->mp_nexthop_global, 0, sizeof (struct in6_addr)); + memset (&attr.mp_nexthop_global, 0, sizeof (struct in6_addr)); /* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */ } new_attr = bgp_attr_intern (&attr); - bgp_attr_extra_free (&attr); if (new_attr != bgp_info_mpath_attr (new_best)) { diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index b5fbfd8bb..3a8398d8a 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -62,31 +62,6 @@ argv_find_and_parse_vpnvx(struct cmd_token **argv, int argc, int *index, afi_t * return ret; } -u_int16_t -decode_rd_type (u_char *pnt) -{ - u_int16_t v; - - v = ((u_int16_t) *pnt++ << 8); -#if ENABLE_BGP_VNC - /* - * VNC L2 stores LHI in lower byte, so omit it - */ - if (v != RD_TYPE_VNC_ETH) - v |= (u_int16_t) *pnt; -#else /* duplicate code for clarity */ - v |= (u_int16_t) *pnt; -#endif - - return v; -} - -void -encode_rd_type (u_int16_t v, u_char *pnt) -{ - *((u_int16_t *)pnt) = htons(v); -} - u_int32_t decode_label (mpls_label_t *label_pnt) { @@ -111,54 +86,6 @@ encode_label(mpls_label_t label, *pnt++ = ((label<<4)+1) & 0xff; /* S=1 */ } -/* type == RD_TYPE_AS */ -void -decode_rd_as (u_char *pnt, struct rd_as *rd_as) -{ - rd_as->as = (u_int16_t) *pnt++ << 8; - rd_as->as |= (u_int16_t) *pnt++; - - rd_as->val = ((u_int32_t) *pnt++ << 24); - rd_as->val |= ((u_int32_t) *pnt++ << 16); - rd_as->val |= ((u_int32_t) *pnt++ << 8); - rd_as->val |= (u_int32_t) *pnt; -} - -/* type == RD_TYPE_AS4 */ -void -decode_rd_as4 (u_char *pnt, struct rd_as *rd_as) -{ - rd_as->as = (u_int32_t) *pnt++ << 24; - rd_as->as |= (u_int32_t) *pnt++ << 16; - rd_as->as |= (u_int32_t) *pnt++ << 8; - rd_as->as |= (u_int32_t) *pnt++; - - rd_as->val = ((u_int16_t) *pnt++ << 8); - rd_as->val |= (u_int16_t) *pnt; -} - -/* type == RD_TYPE_IP */ -void -decode_rd_ip (u_char *pnt, struct rd_ip *rd_ip) -{ - memcpy (&rd_ip->ip, pnt, 4); - pnt += 4; - - rd_ip->val = ((u_int16_t) *pnt++ << 8); - rd_ip->val |= (u_int16_t) *pnt; -} - -#if ENABLE_BGP_VNC -/* type == RD_TYPE_VNC_ETH */ -void -decode_rd_vnc_eth (u_char *pnt, struct rd_vnc_eth *rd_vnc_eth) -{ - rd_vnc_eth->type = RD_TYPE_VNC_ETH; - rd_vnc_eth->local_nve_id = pnt[1]; - memcpy (rd_vnc_eth->macaddr.octet, pnt + 2, ETHER_ADDR_LEN); -} -#endif - int bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) @@ -313,129 +240,6 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, #undef VPN_PREFIXLEN_MIN_BYTES } -int -str2prefix_rd (const char *str, struct prefix_rd *prd) -{ - int ret; /* ret of called functions */ - int lret; /* local ret, of this func */ - char *p; - char *p2; - struct stream *s = NULL; - char *half = NULL; - struct in_addr addr; - - s = stream_new (8); - - prd->family = AF_UNSPEC; - prd->prefixlen = 64; - - lret = 0; - p = strchr (str, ':'); - if (! p) - goto out; - - if (! all_digit (p + 1)) - goto out; - - half = XMALLOC (MTYPE_TMP, (p - str) + 1); - memcpy (half, str, (p - str)); - half[p - str] = '\0'; - - p2 = strchr (str, '.'); - - if (! p2) - { - unsigned long as_val; - - if (! all_digit (half)) - goto out; - - as_val = atol(half); - if (as_val > 0xffff) - { - stream_putw (s, RD_TYPE_AS4); - stream_putl (s, as_val); - stream_putw (s, atol (p + 1)); - } - else - { - stream_putw (s, RD_TYPE_AS); - stream_putw (s, as_val); - stream_putl (s, atol (p + 1)); - } - } - else - { - ret = inet_aton (half, &addr); - if (! ret) - goto out; - - stream_putw (s, RD_TYPE_IP); - stream_put_in_addr (s, &addr); - stream_putw (s, atol (p + 1)); - } - memcpy (prd->val, s->data, 8); - lret = 1; - -out: - if (s) - stream_free (s); - if (half) - XFREE(MTYPE_TMP, half); - return lret; -} - -char * -prefix_rd2str (struct prefix_rd *prd, char *buf, size_t size) -{ - u_char *pnt; - u_int16_t type; - struct rd_as rd_as; - struct rd_ip rd_ip; - - if (size < RD_ADDRSTRLEN) - return NULL; - - pnt = prd->val; - - type = decode_rd_type (pnt); - - if (type == RD_TYPE_AS) - { - decode_rd_as (pnt + 2, &rd_as); - snprintf (buf, size, "%u:%d", rd_as.as, rd_as.val); - return buf; - } - else if (type == RD_TYPE_AS4) - { - decode_rd_as4 (pnt + 2, &rd_as); - snprintf (buf, size, "%u:%d", rd_as.as, rd_as.val); - return buf; - } - else if (type == RD_TYPE_IP) - { - decode_rd_ip (pnt + 2, &rd_ip); - snprintf (buf, size, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val); - return buf; - } -#if ENABLE_BGP_VNC - else if (type == RD_TYPE_VNC_ETH) - { - snprintf(buf, size, "LHI:%d, %02x:%02x:%02x:%02x:%02x:%02x", - *(pnt+1), /* LHI */ - *(pnt+2), /* MAC[0] */ - *(pnt+3), - *(pnt+4), - *(pnt+5), - *(pnt+6), - *(pnt+7)); - - return buf; - } -#endif - return NULL; -} - /* For testing purpose, static route of MPLS-VPN. */ DEFUN (vpnv4_network, vpnv4_network_cmd, @@ -563,7 +367,7 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, if (bgp == NULL) { if (!use_json) - vty_outln (vty, "No BGP process is configured"); + vty_out (vty, "No BGP process is configured\n"); return CMD_WARNING; } @@ -589,7 +393,7 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, if ((afi != AFI_IP) && (afi != AFI_IP6)) { - vty_outln (vty, "Afi %d not supported", afi); + vty_out (vty, "Afi %d not supported\n", afi); return CMD_WARNING; } @@ -634,16 +438,15 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, else { if (tags) - vty_outln (vty, V4_HEADER_TAG); + vty_out (vty, V4_HEADER_TAG); else { - vty_outln (vty, "BGP table version is 0, local router ID is %s", + vty_out (vty, "BGP table version is 0, local router ID is %s\n", inet_ntoa(bgp->router_id)); - vty_outln (vty, - "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal"); - vty_outln (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s", - VTYNL); - vty_outln (vty, V4_HEADER); + vty_out (vty, + "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n"); + vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete\n\n"); + vty_out (vty, V4_HEADER); } } header = 0; @@ -703,7 +506,7 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, rd_vnc_eth.macaddr.octet[4], rd_vnc_eth.macaddr.octet[5]); #endif - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } rd_header = 0; } @@ -740,17 +543,16 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, if (use_json) { json_object_object_add(json, "routes", json_nroute); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { if (output_count == 0) - vty_outln (vty, "No prefixes displayed, %ld exist", total_count); + vty_out (vty, "No prefixes displayed, %ld exist\n", total_count); else - vty_outln (vty, "%sDisplayed %ld routes and %ld total paths", - VTYNL, output_count, total_count); + vty_out (vty, "\nDisplayed %ld routes and %ld total paths\n", output_count, total_count); } return CMD_SUCCESS; @@ -781,7 +583,7 @@ DEFUN (show_bgp_ip_vpn_all_rd, ret = str2prefix_rd (argv[idx_rd]->arg, &prd); if (! ret) { - vty_outln (vty, "%% Malformed Route Distinguisher"); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); @@ -816,7 +618,7 @@ DEFUN (show_ip_bgp_vpn_rd, ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { - vty_outln (vty, "%% Malformed Route Distinguisher"); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_normal, NULL, 0, 0); @@ -881,7 +683,7 @@ DEFUN (show_ip_bgp_vpn_rd_tags, ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { - vty_outln (vty, "%% Malformed Route Distinguisher"); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_normal, NULL, 1, 0); @@ -920,11 +722,11 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "Malformed address: %s", argv[idx_ipv4]->arg); + vty_out (vty, "Malformed address: %s\n", argv[idx_ipv4]->arg); return CMD_WARNING; } @@ -936,11 +738,11 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "%% No such neighbor or address family"); + vty_out (vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -983,11 +785,11 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "%% Malformed Route Distinguisher"); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } @@ -999,11 +801,11 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "Malformed address: %s", + vty_out (vty, "Malformed address: %s\n", argv[idx_ext_community]->arg); return CMD_WARNING; } @@ -1016,11 +818,11 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "%% No such neighbor or address family"); + vty_out (vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -1060,11 +862,11 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_advertised_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "Malformed address: %s", argv[idx_ipv4]->arg); + vty_out (vty, "Malformed address: %s\n", argv[idx_ipv4]->arg); return CMD_WARNING; } peer = peer_lookup (NULL, &su); @@ -1075,11 +877,11 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_advertised_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "%% No such neighbor or address family"); + vty_out (vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } return show_adj_route_vpn (vty, peer, NULL, AFI_IP, SAFI_MPLS_VPN, uj); @@ -1121,11 +923,11 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_advertised_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "Malformed address: %s", + vty_out (vty, "Malformed address: %s\n", argv[idx_ext_community]->arg); return CMD_WARNING; } @@ -1137,11 +939,11 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_advertised_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "%% No such neighbor or address family"); + vty_out (vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -1153,11 +955,11 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_advertised_routes, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "%% Malformed Route Distinguisher"); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h index 4ba4597d0..8d4f5f806 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -1,7 +1,7 @@ /* MPLS-VPN * Copyright (C) 2000 Kunihiro Ishiguro <kunihiro@zebra.org> * - * This file is part of GNU Zebra. + * This file is part of GxNU Zebra. * * GNU Zebra is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -22,15 +22,7 @@ #define _QUAGGA_BGP_MPLSVPN_H #include "bgpd/bgp_route.h" - -#define RD_TYPE_AS 0 -#define RD_TYPE_IP 1 -#define RD_TYPE_AS4 2 -#if ENABLE_BGP_VNC -#define RD_TYPE_VNC_ETH 0xff00 /* VNC L2VPN */ -#endif - -#define RD_ADDRSTRLEN 28 +#include "bgpd/bgp_rd.h" #ifdef MPLS_LABEL_MAX # undef MPLS_LABEL_MAX @@ -68,50 +60,16 @@ typedef enum { "Address Family\n" #define V4_HEADER \ - " Network Next Hop Metric LocPrf Weight Path" + " Network Next Hop Metric LocPrf Weight Path\n" #define V4_HEADER_TAG \ - " Network Next Hop In tag/Out tag" + " Network Next Hop In tag/Out tag\n" #define V4_HEADER_OVERLAY \ - " Network Next Hop EthTag Overlay Index RouterMac" - -struct rd_as -{ - u_int16_t type; - as_t as; - u_int32_t val; -}; + " Network Next Hop EthTag Overlay Index RouterMac\n" -struct rd_ip -{ - u_int16_t type; - struct in_addr ip; - u_int16_t val; -}; - -#if ENABLE_BGP_VNC -struct rd_vnc_eth -{ - u_int16_t type; - uint8_t local_nve_id; - struct ethaddr macaddr; -}; -#endif - -extern u_int16_t decode_rd_type (u_char *); -extern void encode_rd_type (u_int16_t, u_char *); extern void bgp_mplsvpn_init (void); extern int bgp_nlri_parse_vpn (struct peer *, struct attr *, struct bgp_nlri *); extern u_int32_t decode_label (mpls_label_t *); extern void encode_label(mpls_label_t, mpls_label_t *); -extern void decode_rd_as (u_char *, struct rd_as *); -extern void decode_rd_as4 (u_char *, struct rd_as *); -extern void decode_rd_ip (u_char *, struct rd_ip *); -#if ENABLE_BGP_VNC -extern void -decode_rd_vnc_eth (u_char *pnt, struct rd_vnc_eth *rd_vnc_eth); -#endif -extern int str2prefix_rd (const char *, struct prefix_rd *); -extern char *prefix_rd2str (struct prefix_rd *, char *, size_t); extern int argv_find_and_parse_vpnvx(struct cmd_token **argv, int argc, int *index, afi_t *afi); diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index d0c4d2c94..148fba2d4 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -329,11 +329,11 @@ bgp_connected_delete (struct bgp *bgp, struct connected *ifc) } int -bgp_nexthop_self (struct bgp *bgp, struct attr *attr) +bgp_nexthop_self (struct bgp *bgp, struct in_addr nh_addr) { struct bgp_addr tmp, *addr; - tmp.addr = attr->nexthop; + tmp.addr = nh_addr; addr = hash_lookup (bgp->address_hash, &tmp); if (addr) @@ -387,7 +387,7 @@ bgp_show_nexthops (struct vty *vty, struct bgp *bgp, int detail) time_t tbuf; afi_t afi; - vty_outln (vty, "Current BGP nexthop cache:"); + vty_out (vty, "Current BGP nexthop cache:\n"); for (afi = AFI_IP ; afi < AFI_MAX ; afi++) { if (!bgp->nexthop_cache_table[afi]) @@ -399,7 +399,7 @@ bgp_show_nexthops (struct vty *vty, struct bgp *bgp, int detail) { if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID)) { - vty_outln (vty, " %s valid [IGP metric %d], #paths %d", + vty_out (vty, " %s valid [IGP metric %d], #paths %d\n", inet_ntop (rn->p.family, &rn->p.u.prefix, buf, sizeof (buf)), bnc->metric, bnc->path_count); if (detail) @@ -407,44 +407,44 @@ bgp_show_nexthops (struct vty *vty, struct bgp *bgp, int detail) switch (nexthop->type) { case NEXTHOP_TYPE_IPV6: - vty_outln (vty, " gate %s", + vty_out (vty, " gate %s\n", inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf))); break; case NEXTHOP_TYPE_IPV6_IFINDEX: - vty_outln (vty, " gate %s, if %s", + vty_out (vty, " gate %s, if %s\n", inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, sizeof (buf)), ifindex2ifname(nexthop->ifindex, bgp->vrf_id)); break; case NEXTHOP_TYPE_IPV4: - vty_outln (vty, " gate %s", + vty_out (vty, " gate %s\n", inet_ntop(AF_INET, &nexthop->gate.ipv4, buf, sizeof(buf))); break; case NEXTHOP_TYPE_IFINDEX: - vty_outln (vty, " if %s", + vty_out (vty, " if %s\n", ifindex2ifname(nexthop->ifindex, bgp->vrf_id)); break; case NEXTHOP_TYPE_IPV4_IFINDEX: - vty_outln (vty, " gate %s, if %s", + vty_out (vty, " gate %s, if %s\n", inet_ntop(AF_INET, &nexthop->gate.ipv4, buf, sizeof (buf)), ifindex2ifname(nexthop->ifindex, bgp->vrf_id)); break; default: - vty_outln (vty, " invalid nexthop type %u", + vty_out (vty, " invalid nexthop type %u\n", nexthop->type); } } else { - vty_outln (vty, " %s invalid", + vty_out (vty, " %s invalid\n", inet_ntop(rn->p.family, &rn->p.u.prefix, buf, sizeof(buf))); if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)) - vty_outln (vty, " Must be Connected"); + vty_out (vty, " Must be Connected\n"); } tbuf = time(NULL) - (bgp_clock() - bnc->last_update); vty_out (vty, " Last update: %s", ctime(&tbuf)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } } @@ -461,7 +461,7 @@ show_ip_bgp_nexthop_table (struct vty *vty, const char *name, int detail) bgp = bgp_get_default (); if (!bgp) { - vty_outln (vty, "%% No such BGP instance exist"); + vty_out (vty, "%% No such BGP instance exist\n"); return CMD_WARNING; } @@ -478,8 +478,7 @@ bgp_show_all_instances_nexthops_vty (struct vty *vty) for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) { - vty_outln (vty, "%sInstance %s:", - VTYNL, + vty_out (vty, "\nInstance %s:\n", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name); bgp_show_nexthops (vty, bgp, 0); } diff --git a/bgpd/bgp_nexthop.h b/bgpd/bgp_nexthop.h index c5d9232e3..3aa20a9d5 100644 --- a/bgpd/bgp_nexthop.h +++ b/bgpd/bgp_nexthop.h @@ -74,7 +74,7 @@ extern void bgp_connected_add (struct bgp *bgp, struct connected *c); extern void bgp_connected_delete (struct bgp *bgp, struct connected *c); extern int bgp_multiaccess_check_v4 (struct in_addr, struct peer *); extern int bgp_config_write_scan_time (struct vty *); -extern int bgp_nexthop_self (struct bgp *, struct attr *); +extern int bgp_nexthop_self (struct bgp *, struct in_addr); extern struct bgp_nexthop_cache *bnc_new(void); extern void bnc_free(struct bgp_nexthop_cache *bnc); extern void bnc_nexthop_free(struct bgp_nexthop_cache *bnc); diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 341bb0abb..3feb42246 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -532,8 +532,8 @@ make_prefix (int afi, struct bgp_info *ri, struct prefix *p) break; case AFI_IP6: /* We don't register link local NH */ - if (ri->attr->extra->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL - || IN6_IS_ADDR_LINKLOCAL (&ri->attr->extra->mp_nexthop_global)) + if (ri->attr->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL + || IN6_IS_ADDR_LINKLOCAL (&ri->attr->mp_nexthop_global)) return -1; p->family = AF_INET6; @@ -545,7 +545,7 @@ make_prefix (int afi, struct bgp_info *ri, struct prefix *p) } else { - p->u.prefix6 = ri->attr->extra->mp_nexthop_global; + p->u.prefix6 = ri->attr->mp_nexthop_global; p->prefixlen = IPV6_MAX_BITLEN; } break; diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 86befd3e8..d6ed441df 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -167,7 +167,7 @@ bgp_capability_vty_out (struct vty *vty, struct peer *peer, u_char use_json, jso vty_out (vty, "SAFI Unknown %d ", mpc.safi); break; } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } else if (hdr->code >= 128) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 0c31d6e9f..2b48b34e1 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1364,7 +1364,6 @@ bgp_update_receive (struct peer *peer, bgp_size_t size) u_char *end; struct stream *s; struct attr attr; - struct attr_extra extra; bgp_size_t attribute_len; bgp_size_t update_len; bgp_size_t withdraw_len; @@ -1389,11 +1388,9 @@ bgp_update_receive (struct peer *peer, bgp_size_t size) /* Set initial values. */ memset (&attr, 0, sizeof (struct attr)); - memset (&extra, 0, sizeof (struct attr_extra)); - extra.label_index = BGP_INVALID_LABEL_INDEX; - extra.label = MPLS_INVALID_LABEL; + attr.label_index = BGP_INVALID_LABEL_INDEX; + attr.label = MPLS_INVALID_LABEL; memset (&nlris, 0, sizeof (nlris)); - attr.extra = &extra; memset (peer->rcvd_attr_str, 0, BUFSIZ); peer->rcvd_attr_printed = 0; diff --git a/bgpd/bgp_rd.c b/bgpd/bgp_rd.c new file mode 100644 index 000000000..03257a292 --- /dev/null +++ b/bgpd/bgp_rd.c @@ -0,0 +1,232 @@ +/* BGP RD definitions for BGP-based VPNs (IP/EVPN) + * -- brought over from bgpd/bgp_mplsvpn.c + * Copyright (C) 2000 Kunihiro Ishiguro <kunihiro@zebra.org> + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <zebra.h> +#include "command.h" +#include "log.h" +#include "prefix.h" +#include "memory.h" +#include "stream.h" +#include "filter.h" + +#include "bgpd/bgpd.h" +#include "bgpd/bgp_rd.h" +#include "bgpd/bgp_attr.h" + +#if ENABLE_BGP_VNC +#include "bgpd/rfapi/rfapi_backend.h" +#endif + +u_int16_t +decode_rd_type (u_char *pnt) +{ + u_int16_t v; + + v = ((u_int16_t) *pnt++ << 8); +#if ENABLE_BGP_VNC + /* + * VNC L2 stores LHI in lower byte, so omit it + */ + if (v != RD_TYPE_VNC_ETH) + v |= (u_int16_t) *pnt; +#else /* duplicate code for clarity */ + v |= (u_int16_t) *pnt; +#endif + return v; +} + +void +encode_rd_type (u_int16_t v, u_char *pnt) +{ + *((u_int16_t *)pnt) = htons(v); +} + +/* type == RD_TYPE_AS */ +void +decode_rd_as (u_char *pnt, struct rd_as *rd_as) +{ + rd_as->as = (u_int16_t) *pnt++ << 8; + rd_as->as |= (u_int16_t) *pnt++; + + rd_as->val = ((u_int32_t) *pnt++ << 24); + rd_as->val |= ((u_int32_t) *pnt++ << 16); + rd_as->val |= ((u_int32_t) *pnt++ << 8); + rd_as->val |= (u_int32_t) *pnt; +} + +/* type == RD_TYPE_AS4 */ +void +decode_rd_as4 (u_char *pnt, struct rd_as *rd_as) +{ + rd_as->as = (u_int32_t) *pnt++ << 24; + rd_as->as |= (u_int32_t) *pnt++ << 16; + rd_as->as |= (u_int32_t) *pnt++ << 8; + rd_as->as |= (u_int32_t) *pnt++; + + rd_as->val = ((u_int16_t) *pnt++ << 8); + rd_as->val |= (u_int16_t) *pnt; +} + +/* type == RD_TYPE_IP */ +void +decode_rd_ip (u_char *pnt, struct rd_ip *rd_ip) +{ + memcpy (&rd_ip->ip, pnt, 4); + pnt += 4; + + rd_ip->val = ((u_int16_t) *pnt++ << 8); + rd_ip->val |= (u_int16_t) *pnt; +} + +#if ENABLE_BGP_VNC +/* type == RD_TYPE_VNC_ETH */ +void +decode_rd_vnc_eth (u_char *pnt, struct rd_vnc_eth *rd_vnc_eth) +{ + rd_vnc_eth->type = RD_TYPE_VNC_ETH; + rd_vnc_eth->local_nve_id = pnt[1]; + memcpy (rd_vnc_eth->macaddr.octet, pnt + 2, ETHER_ADDR_LEN); +} +#endif + +int +str2prefix_rd (const char *str, struct prefix_rd *prd) +{ + int ret; /* ret of called functions */ + int lret; /* local ret, of this func */ + char *p; + char *p2; + struct stream *s = NULL; + char *half = NULL; + struct in_addr addr; + + s = stream_new (8); + + prd->family = AF_UNSPEC; + prd->prefixlen = 64; + + lret = 0; + p = strchr (str, ':'); + if (! p) + goto out; + + if (! all_digit (p + 1)) + goto out; + + half = XMALLOC (MTYPE_TMP, (p - str) + 1); + memcpy (half, str, (p - str)); + half[p - str] = '\0'; + + p2 = strchr (str, '.'); + + if (! p2) + { + unsigned long as_val; + + if (! all_digit (half)) + goto out; + + as_val = atol(half); + if (as_val > 0xffff) + { + stream_putw (s, RD_TYPE_AS4); + stream_putl (s, as_val); + stream_putw (s, atol (p + 1)); + } + else + { + stream_putw (s, RD_TYPE_AS); + stream_putw (s, as_val); + stream_putl (s, atol (p + 1)); + } + } + else + { + ret = inet_aton (half, &addr); + if (! ret) + goto out; + + stream_putw (s, RD_TYPE_IP); + stream_put_in_addr (s, &addr); + stream_putw (s, atol (p + 1)); + } + memcpy (prd->val, s->data, 8); + lret = 1; + +out: + if (s) + stream_free (s); + if (half) + XFREE(MTYPE_TMP, half); + return lret; +} + +char * +prefix_rd2str (struct prefix_rd *prd, char *buf, size_t size) +{ + u_char *pnt; + u_int16_t type; + struct rd_as rd_as; + struct rd_ip rd_ip; + + if (size < RD_ADDRSTRLEN) + return NULL; + + pnt = prd->val; + + type = decode_rd_type (pnt); + + if (type == RD_TYPE_AS) + { + decode_rd_as (pnt + 2, &rd_as); + snprintf (buf, size, "%u:%d", rd_as.as, rd_as.val); + return buf; + } + else if (type == RD_TYPE_AS4) + { + decode_rd_as4 (pnt + 2, &rd_as); + snprintf (buf, size, "%u:%d", rd_as.as, rd_as.val); + return buf; + } + else if (type == RD_TYPE_IP) + { + decode_rd_ip (pnt + 2, &rd_ip); + snprintf (buf, size, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val); + return buf; + } +#if ENABLE_BGP_VNC + else if (type == RD_TYPE_VNC_ETH) + { + snprintf(buf, size, "LHI:%d, %02x:%02x:%02x:%02x:%02x:%02x", + *(pnt+1), /* LHI */ + *(pnt+2), /* MAC[0] */ + *(pnt+3), + *(pnt+4), + *(pnt+5), + *(pnt+6), + *(pnt+7)); + + return buf; + } +#endif + return NULL; +} diff --git a/bgpd/bgp_rd.h b/bgpd/bgp_rd.h new file mode 100644 index 000000000..2c7df9d74 --- /dev/null +++ b/bgpd/bgp_rd.h @@ -0,0 +1,74 @@ +/* BGP RD definitions for BGP-based VPNs (IP/EVPN) + * -- brought over from bgpd/bgp_mplsvpn.h + * Copyright (C) 2000 Kunihiro Ishiguro <kunihiro@zebra.org> + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _QUAGGA_BGP_RD_H +#define _QUAGGA_BGP_RD_H + +/* RD types */ +#define RD_TYPE_AS 0 +#define RD_TYPE_IP 1 +#define RD_TYPE_AS4 2 + +#if ENABLE_BGP_VNC +#define RD_TYPE_VNC_ETH 0xff00 /* VNC L2VPN */ +#endif + +#define RD_ADDRSTRLEN 28 + +struct rd_as +{ + u_int16_t type; + as_t as; + u_int32_t val; +}; + +struct rd_ip +{ + u_int16_t type; + struct in_addr ip; + u_int16_t val; +}; + +#if ENABLE_BGP_VNC +struct rd_vnc_eth +{ + u_int16_t type; + uint8_t local_nve_id; + struct ethaddr macaddr; +}; +#endif + +extern u_int16_t decode_rd_type (u_char *pnt); +extern void encode_rd_type (u_int16_t, u_char *); + +extern void decode_rd_as (u_char *pnt, struct rd_as *rd_as); +extern void decode_rd_as4 (u_char *pnt, struct rd_as *rd_as); +extern void decode_rd_ip (u_char *pnt, struct rd_ip *rd_ip); +#if ENABLE_BGP_VNC +extern void +decode_rd_vnc_eth (u_char *pnt, struct rd_vnc_eth *rd_vnc_eth); +#endif + +extern int str2prefix_rd (const char *, struct prefix_rd *); +extern char *prefix_rd2str (struct prefix_rd *, char *, size_t); + +#endif /* _QUAGGA_BGP_RD_H */ diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 12ad65883..88b63107e 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -110,6 +110,36 @@ bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix return rn; } +struct bgp_node * +bgp_afi_node_lookup (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, + struct prefix_rd *prd) +{ + struct bgp_node *rn; + struct bgp_node *prn = NULL; + + if (!table) + return NULL; + + if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP) || (safi == SAFI_EVPN)) + { + prn = bgp_node_lookup (table, (struct prefix *) prd); + if (!prn) + return NULL; + + if (prn->info == NULL) + { + bgp_unlock_node (prn); + return NULL; + } + + table = prn->info; + } + + rn = bgp_node_lookup (table, p); + + return rn; +} + /* Allocate bgp_info_extra */ static struct bgp_info_extra * bgp_info_extra_new (void) @@ -224,7 +254,7 @@ bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) /* Do the actual removal of info from RIB, for use by bgp_process completion callback *only* */ -static void +void bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) { if (ri->next) @@ -300,7 +330,7 @@ bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) static int bgp_label_index_differs (struct bgp_info *ri1, struct bgp_info *ri2) { - return (!(ri1->attr->extra->label_index == ri2->attr->extra->label_index)); + return (!(ri1->attr->label_index == ri2->attr->label_index)); } /* Set/unset bgp_info flags, adjusting any other state as needed. @@ -359,10 +389,9 @@ bgp_info_path_with_addpath_rx_str (struct bgp_info *ri, char *buf) static int bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, int *paths_eq, struct bgp_maxpaths_cfg *mpath_cfg, int debug, - const char *pfx_buf) + char *pfx_buf, afi_t afi, safi_t safi) { struct attr *newattr, *existattr; - struct attr_extra *newattre, *existattre; bgp_peer_sort_t new_sort; bgp_peer_sort_t exist_sort; u_int32_t new_pref; @@ -381,6 +410,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, int ret; char new_buf[PATH_ADDPATH_STR_BUFFER]; char exist_buf[PATH_ADDPATH_STR_BUFFER]; + u_int32_t new_mm_seq; + u_int32_t exist_mm_seq; *paths_eq = 0; @@ -411,16 +442,67 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, newattr = new->attr; existattr = exist->attr; - newattre = newattr->extra; - existattre = existattr->extra; + + /* For EVPN routes, we cannot just go by local vs remote, we have to + * look at the MAC mobility sequence number, if present. + */ + if (safi == SAFI_EVPN) + { + /* This is an error condition described in RFC 7432 Section 15.2. The RFC + * states that in this scenario "the PE MUST alert the operator" but it + * does not state what other action to take. In order to provide some + * consistency in this scenario we are going to prefer the path with the + * sticky flag. + */ + if (newattr->sticky != existattr->sticky) + { + if (!debug) + { + prefix2str (&new->net->p, pfx_buf, sizeof (*pfx_buf) * PREFIX2STR_BUFFER); + bgp_info_path_with_addpath_rx_str (new, new_buf); + bgp_info_path_with_addpath_rx_str (exist, exist_buf); + } + + if (newattr->sticky && !existattr->sticky) + { + zlog_warn("%s: %s wins over %s due to sticky MAC flag", + pfx_buf, new_buf, exist_buf); + return 1; + } + + if (!newattr->sticky && existattr->sticky) + { + zlog_warn("%s: %s loses to %s due to sticky MAC flag", + pfx_buf, new_buf, exist_buf); + return 0; + } + } + + new_mm_seq = mac_mobility_seqnum (newattr); + exist_mm_seq = mac_mobility_seqnum (existattr); + + if (new_mm_seq > exist_mm_seq) + { + if (debug) + zlog_debug("%s: %s wins over %s due to MM seq %u > %u", + pfx_buf, new_buf, exist_buf, new_mm_seq, exist_mm_seq); + return 1; + } + + if (new_mm_seq < exist_mm_seq) + { + if (debug) + zlog_debug("%s: %s loses to %s due to MM seq %u < %u", + pfx_buf, new_buf, exist_buf, new_mm_seq, exist_mm_seq); + return 0; + } + } /* 1. Weight check. */ new_weight = exist_weight = 0; - if (newattre) - new_weight = newattre->weight; - if (existattre) - exist_weight = existattre->weight; + new_weight = newattr->weight; + exist_weight = existattr->weight; if (new_weight > exist_weight) { @@ -790,11 +872,11 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, * used for the comparision, it will decide which path is better. */ if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) - new_id.s_addr = newattre->originator_id.s_addr; + new_id.s_addr = newattr->originator_id.s_addr; else new_id.s_addr = new->peer->remote_id.s_addr; if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) - exist_id.s_addr = existattre->originator_id.s_addr; + exist_id.s_addr = existattr->originator_id.s_addr; else exist_id.s_addr = exist->peer->remote_id.s_addr; @@ -891,11 +973,12 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, * This version is compatible with */ int bgp_info_cmp_compatible (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, - afi_t afi, safi_t safi) + char *pfx_buf, afi_t afi, safi_t safi) { int paths_eq; int ret; - ret = bgp_info_cmp (bgp, new, exist, &paths_eq, NULL, 0, __func__); + ret = bgp_info_cmp (bgp, new, exist, &paths_eq, NULL, 0, + pfx_buf, afi, safi); if (paths_eq) ret = 0; @@ -1017,14 +1100,14 @@ bgp_cluster_filter (struct peer *peer, struct attr *attr) { struct in_addr cluster_id; - if (attr->extra && attr->extra->cluster) + if (attr->cluster) { if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) cluster_id = peer->bgp->cluster_id; else cluster_id = peer->bgp->router_id; - if (cluster_loop_check (attr->extra->cluster, cluster_id)) + if (cluster_loop_check (attr->cluster, cluster_id)) return 1; } return 0; @@ -1043,7 +1126,7 @@ bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, /* Apply default weight value. */ if (peer->weight[afi][safi]) - (bgp_attr_extra_get (attr))->weight = peer->weight[afi][safi]; + attr->weight = peer->weight[afi][safi]; if (rmap_name) { @@ -1100,7 +1183,7 @@ bgp_output_modifier (struct peer *peer, struct prefix *p, struct attr *attr, /* Apply default weight value. */ if (peer->weight[afi][safi]) - (bgp_attr_extra_get (attr))->weight = peer->weight[afi][safi]; + attr->weight = peer->weight[afi][safi]; if (rmap_name) { @@ -1199,7 +1282,7 @@ subgroup_announce_reset_nhop (u_char family, struct attr *attr) if (family == AF_INET) attr->nexthop.s_addr = 0; if (family == AF_INET6) - memset (&attr->extra->mp_nexthop_global, 0, IPV6_MAX_BYTELEN); + memset (&attr->mp_nexthop_global, 0, IPV6_MAX_BYTELEN); } int @@ -1328,7 +1411,7 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, peer's id. */ if (onlypeer && riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) && - (IPV4_ADDR_SAME (&onlypeer->remote_id, &riattr->extra->originator_id))) + (IPV4_ADDR_SAME (&onlypeer->remote_id, &riattr->originator_id))) { if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) zlog_debug ("%s [Update:SEND] %s originator-id is same as " @@ -1435,8 +1518,7 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, set the originator id */ if (reflect && (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) { - attr->extra = bgp_attr_extra_get(attr); - IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); + IPV4_ADDR_COPY(&(attr->originator_id), &(from->remote_id)); SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); } @@ -1467,7 +1549,7 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, (safi != SAFI_ENCAP && safi != SAFI_MPLS_VPN &&\ (p->family == AF_INET6 || peer_cap_enhe(peer, afi, safi))) || \ ((safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN) &&\ - attr->extra->mp_nexthop_len >= IPV6_MAX_BYTELEN)) + attr->mp_nexthop_len >= IPV6_MAX_BYTELEN)) /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if * the peer (group) is configured to receive link-local nexthop unchanged @@ -1477,14 +1559,14 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, */ if (NEXTHOP_IS_V6) { - attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; + attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; if ((CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) && - IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local)) || + IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local)) || (!reflect && peer->shared_network && (from == bgp->peer_self || peer->sort == BGP_PEER_EBGP))) { - attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; + attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; } /* Clear off link-local nexthop in source, whenever it is not needed to @@ -1492,7 +1574,7 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, */ if (!(CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED))) - memset (&attr->extra->mp_nexthop_local, 0, IPV6_MAX_BYTELEN); + memset (&attr->mp_nexthop_local, 0, IPV6_MAX_BYTELEN); } bgp_peer_remove_private_as(bgp, afi, safi, peer, attr); @@ -1504,9 +1586,6 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, { struct bgp_info info; struct attr dummy_attr; - struct attr_extra dummy_extra; - - dummy_attr.extra = &dummy_extra; info.peer = peer; info.attr = attr; @@ -1591,7 +1670,7 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, */ if (p->family == AF_INET6 || peer_cap_enhe(peer, afi, safi)) { - if (IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_global)) + if (IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_global)) subgroup_announce_reset_nhop (AF_INET6, attr); } } @@ -1599,16 +1678,11 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, return 1; } -struct bgp_info_pair -{ - struct bgp_info *old; - struct bgp_info *new; -}; - -static void +void bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_maxpaths_cfg *mpath_cfg, - struct bgp_info_pair *result) + struct bgp_info_pair *result, + afi_t afi, safi_t safi) { struct bgp_info *new_select; struct bgp_info *old_select; @@ -1668,7 +1742,7 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, ri2->attr->aspath)) { if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq, - mpath_cfg, debug, pfx_buf)) + mpath_cfg, debug, pfx_buf, afi, safi)) { bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); new_select = ri2; @@ -1725,7 +1799,8 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); - if (bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, debug, pfx_buf)) + if (bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, + debug, pfx_buf, afi, safi)) { new_select = ri; } @@ -1779,7 +1854,8 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, continue; } - bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, debug, pfx_buf); + bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, + debug, pfx_buf, afi, safi); if (paths_eq) { @@ -1814,7 +1890,6 @@ subgroup_process_announce_selected (struct update_subgroup *subgrp, struct prefix *p; struct peer *onlypeer; struct attr attr; - struct attr_extra extra; afi_t afi; safi_t safi; @@ -1829,9 +1904,8 @@ subgroup_process_announce_selected (struct update_subgroup *subgrp, PEER_STATUS_ORF_WAIT_REFRESH)) return 0; - memset(&extra, 0, sizeof(struct attr_extra)); + memset(&attr, 0, sizeof(struct attr)); /* It's initialized in bgp_announce_check() */ - attr.extra = &extra; /* Announcement to the subgroup. If the route is filtered withdraw it. */ if (selected) @@ -1855,7 +1929,7 @@ subgroup_process_announce_selected (struct update_subgroup *subgrp, * Clear IGP changed flag and attribute changed flag for a route (all paths). * This is called at the end of route processing. */ -static void +void bgp_zebra_clear_route_change_flags (struct bgp_node *rn) { struct bgp_info *ri; @@ -1874,7 +1948,7 @@ bgp_zebra_clear_route_change_flags (struct bgp_node *rn) * if the route selection returns the same best route as earlier - to * determine if we need to update zebra or not. */ -static int +int bgp_zebra_has_route_changed (struct bgp_node *rn, struct bgp_info *selected) { struct bgp_info *mpinfo; @@ -1933,7 +2007,8 @@ bgp_process_main (struct work_queue *wq, void *data) for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { - bgp_zebra_announce_table(bgp, afi, safi); + if (bgp_fibupd_safi(safi)) + bgp_zebra_announce_table(bgp, afi, safi); } bgp->main_peers_update_hold = 0; @@ -1942,7 +2017,8 @@ bgp_process_main (struct work_queue *wq, void *data) } /* Best path selection. */ - bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); + bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], + &old_and_new, afi, safi); old_select = old_and_new.old; new_select = old_and_new.new; @@ -1960,7 +2036,7 @@ bgp_process_main (struct work_queue *wq, void *data) { if (new_select->sub_type == BGP_ROUTE_STATIC && new_select->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID) && - new_select->attr->extra->label_index != BGP_INVALID_LABEL_INDEX) + new_select->attr->label_index != BGP_INVALID_LABEL_INDEX) { if (CHECK_FLAG (rn->flags, BGP_NODE_REGISTERED_FOR_LABEL)) bgp_unregister_for_label (rn); @@ -2342,12 +2418,17 @@ bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, } } #endif + + /* If this is an EVPN route, process for un-import. */ + if (safi == SAFI_EVPN) + bgp_evpn_unimport_route (peer->bgp, afi, safi, &rn->p, ri); + bgp_rib_remove (rn, ri, peer, afi, safi); } -static struct bgp_info * -info_make (int type, int sub_type, u_short instance, struct peer *peer, struct attr *attr, - struct bgp_node *rn) +struct bgp_info * +info_make (int type, int sub_type, u_short instance, struct peer *peer, + struct attr *attr, struct bgp_node *rn) { struct bgp_info *new; @@ -2367,27 +2448,24 @@ info_make (int type, int sub_type, u_short instance, struct peer *peer, struct a static void overlay_index_update(struct attr *attr, struct eth_segment_id *eth_s_id, union gw_addr *gw_ip) { - struct attr_extra *extra; - if(!attr) return; - extra = bgp_attr_extra_get(attr); if(eth_s_id == NULL) { - memset(&(extra->evpn_overlay.eth_s_id),0, sizeof(struct eth_segment_id)); + memset(&(attr->evpn_overlay.eth_s_id),0, sizeof(struct eth_segment_id)); } else { - memcpy(&(extra->evpn_overlay.eth_s_id), eth_s_id, sizeof(struct eth_segment_id)); + memcpy(&(attr->evpn_overlay.eth_s_id), eth_s_id, sizeof(struct eth_segment_id)); } if(gw_ip == NULL) { - memset(&(extra->evpn_overlay.gw_ip), 0, sizeof(union gw_addr)); + memset(&(attr->evpn_overlay.gw_ip), 0, sizeof(union gw_addr)); } else { - memcpy(&(extra->evpn_overlay.gw_ip),gw_ip, sizeof(union gw_addr)); + memcpy(&(attr->evpn_overlay.gw_ip),gw_ip, sizeof(union gw_addr)); } } @@ -2400,7 +2478,7 @@ overlay_index_equal(afi_t afi, struct bgp_info *info, struct eth_segment_id *eth if(afi != AFI_L2VPN) return true; - if (!info->attr || !info->attr->extra) + if (!info->attr) { memset(&temp, 0, 16); info_eth_s_id = (struct eth_segment_id *)&temp; @@ -2410,8 +2488,8 @@ overlay_index_equal(afi_t afi, struct bgp_info *info, struct eth_segment_id *eth } else { - info_eth_s_id = &(info->attr->extra->evpn_overlay.eth_s_id); - info_gw_ip = &(info->attr->extra->evpn_overlay.gw_ip); + info_eth_s_id = &(info->attr->evpn_overlay.eth_s_id); + info_gw_ip = &(info->attr->evpn_overlay.gw_ip); } if(gw_ip == NULL) info_gw_ip_remote = (union gw_addr *)&temp; @@ -2430,11 +2508,11 @@ overlay_index_equal(afi_t afi, struct bgp_info *info, struct eth_segment_id *eth static int bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr *attr) { - struct attr_extra *attre = attr->extra; int ret = 0; /* Only validated for unicast and multicast currently. */ - if (safi != SAFI_UNICAST && safi != SAFI_MULTICAST) + /* Also valid for EVPN where the nexthop is an IP address. */ + if (safi != SAFI_UNICAST && safi != SAFI_MULTICAST && safi != SAFI_EVPN) return 0; /* If NEXT_HOP is present, validate it. */ @@ -2442,8 +2520,8 @@ bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr { if (attr->nexthop.s_addr == 0 || IPV4_CLASS_DE (ntohl (attr->nexthop.s_addr)) || - bgp_nexthop_self (bgp, attr)) - ret = 1; + bgp_nexthop_self (bgp, attr->nexthop)) + return 1; } /* If MP_NEXTHOP is present, validate it. */ @@ -2451,22 +2529,23 @@ bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if * it is not an IPv6 link-local address. */ - if (attre && attre->mp_nexthop_len) + if (attr->mp_nexthop_len) { - switch (attre->mp_nexthop_len) + switch (attr->mp_nexthop_len) { case BGP_ATTR_NHLEN_IPV4: case BGP_ATTR_NHLEN_VPNV4: - ret = (attre->mp_nexthop_global_in.s_addr == 0 || - IPV4_CLASS_DE (ntohl (attre->mp_nexthop_global_in.s_addr))); + ret = (attr->mp_nexthop_global_in.s_addr == 0 || + IPV4_CLASS_DE (ntohl (attr->mp_nexthop_global_in.s_addr)) || + bgp_nexthop_self (bgp, attr->mp_nexthop_global_in)); break; case BGP_ATTR_NHLEN_IPV6_GLOBAL: case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: case BGP_ATTR_NHLEN_VPNV6_GLOBAL: - ret = (IN6_IS_ADDR_UNSPECIFIED(&attre->mp_nexthop_global) || - IN6_IS_ADDR_LOOPBACK(&attre->mp_nexthop_global) || - IN6_IS_ADDR_MULTICAST(&attre->mp_nexthop_global)); + ret = (IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global) || + IN6_IS_ADDR_LOOPBACK(&attr->mp_nexthop_global) || + IN6_IS_ADDR_MULTICAST(&attr->mp_nexthop_global)); break; default: @@ -2489,7 +2568,6 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, struct bgp_node *rn; struct bgp *bgp; struct attr new_attr; - struct attr_extra new_extra; struct attr *attr_new; struct bgp_info *ri; struct bgp_info *new; @@ -2502,16 +2580,14 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, #if ENABLE_BGP_VNC int vnc_implicit_withdraw = 0; #endif + int same_attr=0; memset (&new_attr, 0, sizeof(struct attr)); - memset (&new_extra, 0, sizeof(struct attr_extra)); - new_extra.label_index = BGP_INVALID_LABEL_INDEX; - new_extra.label = MPLS_INVALID_LABEL; + new_attr.label_index = BGP_INVALID_LABEL_INDEX; + new_attr.label = MPLS_INVALID_LABEL; bgp = peer->bgp; rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); - label_buf[0] = '\0'; - has_valid_label = bgp_is_valid_label(label); if (has_valid_label) @@ -2563,7 +2639,7 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, /* Route reflector originator ID check. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) - && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) + && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id)) { reason = "originator is us;"; goto filtered; @@ -2583,7 +2659,6 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, goto filtered; } - new_attr.extra = &new_extra; bgp_attr_dup (&new_attr, attr); /* Apply incoming route-map. @@ -2611,6 +2686,7 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, if (ri) { ri->uptime = bgp_clock (); + same_attr = attrhash_cmp (ri->attr, attr_new); /* Same attribute comes in. */ if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) @@ -2625,9 +2701,12 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) { if (bgp_debug_update(peer, p, NULL, 1)) - zlog_debug ("%s rcvd %s %s", peer->host, - bgp_debug_rdpfxpath2str (prd, p, addpath_id ? 1 : 0, - addpath_id, pfx_buf, sizeof (pfx_buf)), label_buf); + { + bgp_debug_rdpfxpath2str (afi, safi, prd, p, label, + addpath_id ? 1 : 0, addpath_id, + pfx_buf, sizeof (pfx_buf)); + zlog_debug ("%s rcvd %s", peer->host, pfx_buf); + } if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) { @@ -2645,10 +2724,11 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, peer->rcvd_attr_printed = 1; } - zlog_debug ("%s rcvd %s %s...duplicate ignored", - peer->host, - bgp_debug_rdpfxpath2str (prd, p, addpath_id ? - 1 : 0, addpath_id, pfx_buf, sizeof (pfx_buf)), label_buf); + bgp_debug_rdpfxpath2str (afi, safi, prd, p, label, + addpath_id ? 1 : 0, addpath_id, + pfx_buf, sizeof (pfx_buf)); + zlog_debug ("%s rcvd %s...duplicate ignored", + peer->host, pfx_buf); } /* graceful restart STALE flag unset. */ @@ -2669,18 +2749,25 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) { if (bgp_debug_update(peer, p, NULL, 1)) - zlog_debug ("%s rcvd %s %s, flapped quicker than processing", - peer->host, - bgp_debug_rdpfxpath2str (prd, p, addpath_id ? 1 : 0, - addpath_id, pfx_buf, sizeof (pfx_buf)), label_buf); + { + bgp_debug_rdpfxpath2str (afi, safi, prd, p, label, + addpath_id ? 1 : 0, addpath_id, + pfx_buf, sizeof (pfx_buf)); + zlog_debug ("%s rcvd %s, flapped quicker than processing", + peer->host, pfx_buf); + } + bgp_info_restore (rn, ri); } /* Received Logging. */ if (bgp_debug_update(peer, p, NULL, 1)) - zlog_debug ("%s rcvd %s %s", peer->host, - bgp_debug_rdpfxpath2str (prd, p, addpath_id ? 1 : 0, - addpath_id, pfx_buf, sizeof (pfx_buf)), label_buf); + { + bgp_debug_rdpfxpath2str (afi, safi, prd, p, label, + addpath_id ? 1 : 0, addpath_id, + pfx_buf, sizeof (pfx_buf)); + zlog_debug ("%s rcvd %s", peer->host, pfx_buf); + } /* graceful restart STALE flag unset. */ if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) @@ -2732,7 +2819,32 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, } } #endif - + + /* Special handling for EVPN update of an existing route. If the + * extended community attribute has changed, we need to un-import + * the route using its existing extended community. It will be + * subsequently processed for import with the new extended community. + */ + if (safi == SAFI_EVPN && !same_attr) + { + if ((ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES)) && + (attr_new->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES))) + { + int cmp; + + cmp = ecommunity_cmp (ri->attr->ecommunity, + attr_new->ecommunity); + if (!cmp) + { + if (bgp_debug_update(peer, p, NULL, 1)) + zlog_debug ("Change in EXT-COMM, existing %s new %s", + ecommunity_str (ri->attr->ecommunity), + ecommunity_str (attr_new->ecommunity)); + bgp_evpn_unimport_route (bgp, afi, safi, p, ri); + } + } + } + /* Update to new attribute. */ bgp_attr_unintern (&ri->attr); ri->attr = attr_new; @@ -2831,6 +2943,16 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, } #endif + /* If this is an EVPN route and some attribute has changed, process + * route for import. If the extended community has changed, we would + * have done the un-import earlier and the import would result in the + * route getting injected into appropriate L2 VNIs. If it is just + * some other attribute change, the import will result in updating + * the attributes for the route in the VNI(s). + */ + if (safi == SAFI_EVPN && !same_attr) + bgp_evpn_import_route (bgp, afi, safi, p, ri); + /* Process change. */ bgp_aggregate_increment (bgp, p, ri, afi, safi); @@ -2864,9 +2986,10 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, peer->rcvd_attr_printed = 1; } - zlog_debug ("%s rcvd %s %s ", peer->host, - bgp_debug_rdpfxpath2str (prd, p, addpath_id ? 1 : 0, - addpath_id, pfx_buf, sizeof (pfx_buf)), label_buf); + bgp_debug_rdpfxpath2str (afi, safi, prd, p, label, + addpath_id ? 1 : 0, addpath_id, + pfx_buf, sizeof (pfx_buf)); + zlog_debug ("%s rcvd %s", peer->host, pfx_buf); } /* Make new BGP info. */ @@ -2951,6 +3074,10 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) return -1; + /* If this is an EVPN route, process for import. */ + if (safi == SAFI_EVPN) + bgp_evpn_import_route (bgp, afi, safi, p, new); + /* Process change. */ bgp_process (bgp, rn, afi, safi); @@ -2982,14 +3109,21 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id, peer->rcvd_attr_printed = 1; } - zlog_debug ("%s rcvd UPDATE about %s %s -- DENIED due to: %s", - peer->host, - bgp_debug_rdpfxpath2str (prd, p, addpath_id ? 1 : 0, - addpath_id, pfx_buf, sizeof (pfx_buf)), label_buf, reason); + bgp_debug_rdpfxpath2str (afi, safi, prd, p, label, + addpath_id ? 1 : 0, addpath_id, + pfx_buf, sizeof (pfx_buf)); + zlog_debug ("%s rcvd UPDATE about %s -- DENIED due to: %s", + peer->host, pfx_buf, reason); } if (ri) - bgp_rib_remove (rn, ri, peer, afi, safi); + { + /* If this is an EVPN route, un-import it as it is now filtered. */ + if (safi == SAFI_EVPN) + bgp_evpn_unimport_route (bgp, afi, safi, p, ri); + + bgp_rib_remove (rn, ri, peer, afi, safi); + } bgp_unlock_node (rn); @@ -3043,10 +3177,13 @@ bgp_withdraw (struct peer *peer, struct prefix *p, u_int32_t addpath_id, if (!bgp_adj_in_unset (rn, peer, addpath_id)) { if (bgp_debug_update (peer, p, NULL, 1)) - zlog_debug ("%s withdrawing route %s not in adj-in", - peer->host, - bgp_debug_rdpfxpath2str (prd, p, addpath_id ? 1 : 0, - addpath_id, pfx_buf, sizeof (pfx_buf))); + { + bgp_debug_rdpfxpath2str (afi, safi, prd, p, label, + addpath_id ? 1 : 0, addpath_id, + pfx_buf, sizeof (pfx_buf)); + zlog_debug ("%s withdrawing route %s not in adj-in", + peer->host, pfx_buf); + } bgp_unlock_node (rn); return 0; } @@ -3060,20 +3197,24 @@ bgp_withdraw (struct peer *peer, struct prefix *p, u_int32_t addpath_id, /* Logging. */ if (bgp_debug_update(peer, p, NULL, 1)) { + bgp_debug_rdpfxpath2str (afi, safi, prd, p, label, + addpath_id ? 1 : 0, addpath_id, + pfx_buf, sizeof (pfx_buf)); zlog_debug ("%s rcvd UPDATE about %s -- withdrawn", - peer->host, - bgp_debug_rdpfxpath2str (prd, p, addpath_id ? 1 : 0, - addpath_id, pfx_buf, sizeof (pfx_buf))); + peer->host, pfx_buf); } /* Withdraw specified route from routing table. */ if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); else if (bgp_debug_update(peer, p, NULL, 1)) - zlog_debug ("%s Can't find the route %s", - peer->host, - bgp_debug_rdpfxpath2str (prd, p, addpath_id ? 1 : 0, - addpath_id, pfx_buf, sizeof (pfx_buf))); + { + bgp_debug_rdpfxpath2str (afi, safi, prd, p, label, + addpath_id ? 1 : 0, addpath_id, + pfx_buf, sizeof (pfx_buf)); + zlog_debug ("%s Can't find the route %s", + peer->host, pfx_buf); + } /* Unlock bgp_node_get() lock. */ bgp_unlock_node (rn); @@ -3269,7 +3410,12 @@ bgp_clear_route_node (struct work_queue *wq, void *data) && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) bgp_info_set_flag (rn, ri, BGP_INFO_STALE); else - bgp_rib_remove (rn, ri, peer, afi, safi); + { + /* If this is an EVPN route, process for un-import. */ + if (safi == SAFI_EVPN) + bgp_evpn_unimport_route (peer->bgp, afi, safi, &rn->p, ri); + bgp_rib_remove (rn, ri, peer, afi, safi); + } } return WQ_SUCCESS; } @@ -3561,7 +3707,8 @@ bgp_cleanup_table(struct bgp_table *table, safi_t safi) && (ri->sub_type == BGP_ROUTE_NORMAL || ri->sub_type == BGP_ROUTE_AGGREGATE)) { - bgp_zebra_withdraw (&rn->p, ri, safi); + if (bgp_fibupd_safi(safi)) + bgp_zebra_withdraw (&rn->p, ri, safi); bgp_info_reap (rn, ri); } } @@ -3835,7 +3982,7 @@ bgp_static_update (struct bgp *bgp, struct prefix *p, /* Store label index, if required. */ if (bgp_static->label_index != BGP_INVALID_LABEL_INDEX) { - (bgp_attr_extra_get (&attr))->label_index = bgp_static->label_index; + attr.label_index = bgp_static->label_index; attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID); } @@ -3859,7 +4006,6 @@ bgp_static_update (struct bgp *bgp, struct prefix *p, /* Unintern original. */ aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); bgp_static_withdraw (bgp, p, afi, safi); return; } @@ -3882,7 +4028,6 @@ bgp_static_update (struct bgp *bgp, struct prefix *p, bgp_unlock_node (rn); bgp_attr_unintern (&attr_new); aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); return; } else @@ -3957,7 +4102,6 @@ bgp_static_update (struct bgp *bgp, struct prefix *p, bgp_process (bgp, rn, afi, safi); bgp_unlock_node (rn); aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); return; } } @@ -4009,7 +4153,6 @@ bgp_static_update (struct bgp *bgp, struct prefix *p, /* Unintern original. */ aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); } void @@ -4112,8 +4255,8 @@ bgp_static_update_safi (struct bgp *bgp, struct prefix *p, { if (afi == AFI_IP) { - bgp_attr_extra_get (&attr)->mp_nexthop_global_in = bgp_static->igpnexthop; - bgp_attr_extra_get (&attr)->mp_nexthop_len = IPV4_MAX_BYTELEN; + attr.mp_nexthop_global_in = bgp_static->igpnexthop; + attr.mp_nexthop_len = IPV4_MAX_BYTELEN; } } if(afi == AFI_L2VPN) @@ -4158,7 +4301,6 @@ bgp_static_update_safi (struct bgp *bgp, struct prefix *p, /* Unintern original. */ aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd); return; } @@ -4186,7 +4328,6 @@ bgp_static_update_safi (struct bgp *bgp, struct prefix *p, bgp_unlock_node (rn); bgp_attr_unintern (&attr_new); aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); return; } else @@ -4217,7 +4358,6 @@ bgp_static_update_safi (struct bgp *bgp, struct prefix *p, #endif bgp_unlock_node (rn); aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); return; } } @@ -4252,7 +4392,6 @@ bgp_static_update_safi (struct bgp *bgp, struct prefix *p, /* Unintern original. */ aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); } /* Configure static BGP network. When user don't run zebra, static @@ -4273,13 +4412,13 @@ bgp_static_set (struct vty *vty, const char *ip_str, ret = str2prefix (ip_str, &p); if (! ret) { - vty_outln (vty, "%% Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) { - vty_outln (vty,"%% Malformed prefix (link-local address)"); - return CMD_WARNING; + vty_out (vty,"%% Malformed prefix (link-local address)\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask (&p); @@ -4295,8 +4434,8 @@ bgp_static_set (struct vty *vty, const char *ip_str, /* Label index cannot be changed. */ if (bgp_static->label_index != label_index) { - vty_outln (vty, "%% Label index cannot be changed"); - return CMD_WARNING; + vty_out (vty, "%% Label index cannot be changed\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Check previous routes are installed into BGP. */ @@ -4367,13 +4506,13 @@ bgp_static_unset (struct vty *vty, const char *ip_str, ret = str2prefix (ip_str, &p); if (! ret) { - vty_outln (vty, "%% Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) { - vty_outln (vty,"%% Malformed prefix (link-local address)"); - return CMD_WARNING; + vty_out (vty,"%% Malformed prefix (link-local address)\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask (&p); @@ -4381,8 +4520,8 @@ bgp_static_unset (struct vty *vty, const char *ip_str, rn = bgp_node_lookup (bgp->route[afi][safi], &p); if (! rn) { - vty_outln (vty,"%% Can't find specified static route configuration."); - return CMD_WARNING; + vty_out (vty,"%% Can't find specified static route configuration.\n"); + return CMD_WARNING_CONFIG_FAILED; } bgp_static = rn->info; @@ -4579,22 +4718,22 @@ bgp_static_set_safi (afi_t afi, safi_t safi, struct vty *vty, const char *ip_str ret = str2prefix (ip_str, &p); if (! ret) { - vty_outln (vty, "%% Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask (&p); if ( (afi == AFI_L2VPN) && (bgp_build_evpn_prefix ( evpn_type, ethtag!=NULL?atol(ethtag):0, &p))) { - vty_outln (vty, "%% L2VPN prefix could not be forged"); - return CMD_WARNING; + vty_out (vty, "%% L2VPN prefix could not be forged\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = str2prefix_rd (rd_str, &prd); if (! ret) { - vty_outln (vty, "%% Malformed rd"); - return CMD_WARNING; + vty_out (vty, "%% Malformed rd\n"); + return CMD_WARNING_CONFIG_FAILED; } if (label_str) @@ -4608,13 +4747,13 @@ bgp_static_set_safi (afi_t afi, safi_t safi, struct vty *vty, const char *ip_str { if( esi && str2esi (esi, NULL) == 0) { - vty_outln (vty, "%% Malformed ESI"); - return CMD_WARNING; + vty_out (vty, "%% Malformed ESI\n"); + return CMD_WARNING_CONFIG_FAILED; } if( routermac && prefix_str2mac (routermac, NULL) == 0) { - vty_outln (vty, "%% Malformed Router MAC"); - return CMD_WARNING; + vty_out (vty, "%% Malformed Router MAC\n"); + return CMD_WARNING_CONFIG_FAILED; } if (gwip) { @@ -4622,16 +4761,16 @@ bgp_static_set_safi (afi_t afi, safi_t safi, struct vty *vty, const char *ip_str ret = str2prefix (gwip, &gw_ip); if (! ret) { - vty_outln (vty, "%% Malformed GatewayIp"); - return CMD_WARNING; + vty_out (vty, "%% Malformed GatewayIp\n"); + return CMD_WARNING_CONFIG_FAILED; } if((gw_ip.family == AF_INET && IS_EVPN_PREFIX_IPADDR_V6((struct prefix_evpn *)&p)) || (gw_ip.family == AF_INET6 && IS_EVPN_PREFIX_IPADDR_V4((struct prefix_evpn *)&p))) { - vty_outln (vty, "%% GatewayIp family differs with IP prefix"); - return CMD_WARNING; + vty_out (vty, "%% GatewayIp family differs with IP prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } } } @@ -4647,7 +4786,7 @@ bgp_static_set_safi (afi_t afi, safi_t safi, struct vty *vty, const char *ip_str if (rn->info) { - vty_outln (vty, "%% Same network configuration exists"); + vty_out (vty, "%% Same network configuration exists\n"); bgp_unlock_node (rn); } else @@ -4713,21 +4852,21 @@ bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *vty, const char *ip_st ret = str2prefix (ip_str, &p); if (! ret) { - vty_outln (vty, "%% Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask (&p); if ( (afi == AFI_L2VPN) && (bgp_build_evpn_prefix ( evpn_type, ethtag!=NULL?atol(ethtag):0, &p))) { - vty_outln (vty, "%% L2VPN prefix could not be forged"); - return CMD_WARNING; + vty_out (vty, "%% L2VPN prefix could not be forged\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = str2prefix_rd (rd_str, &prd); if (! ret) { - vty_outln (vty, "%% Malformed rd"); - return CMD_WARNING; + vty_out (vty, "%% Malformed rd\n"); + return CMD_WARNING_CONFIG_FAILED; } if (label_str) @@ -4758,7 +4897,7 @@ bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *vty, const char *ip_st bgp_unlock_node (rn); } else - vty_outln (vty, "%% Can't find the route"); + vty_out (vty, "%% Can't find the route\n"); return CMD_SUCCESS; } @@ -4786,7 +4925,8 @@ bgp_table_map_set (struct vty *vty, afi_t afi, safi_t safi, rmap->map = NULL; } - bgp_zebra_announce_table(bgp, afi, safi); + if (bgp_fibupd_safi(safi)) + bgp_zebra_announce_table(bgp, afi, safi); return CMD_SUCCESS; } @@ -4804,7 +4944,8 @@ bgp_table_map_unset (struct vty *vty, afi_t afi, safi_t safi, rmap->name = NULL; rmap->map = NULL; - bgp_zebra_announce_table(bgp, afi, safi); + if (bgp_fibupd_safi(safi)) + bgp_zebra_announce_table(bgp, afi, safi); return CMD_SUCCESS; } @@ -4816,7 +4957,7 @@ bgp_config_write_table_map (struct vty *vty, struct bgp *bgp, afi_t afi, if (bgp->table_map[afi][safi].name) { bgp_config_write_family_header (vty, afi, safi, write); - vty_outln (vty, " table-map %s", + vty_out (vty, " table-map %s\n", bgp->table_map[afi][safi].name); } @@ -4900,8 +5041,8 @@ DEFUN (bgp_network_mask, ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_static_set (vty, prefix_str, @@ -4927,8 +5068,8 @@ DEFUN (bgp_network_mask_route_map, ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_static_set (vty, prefix_str, @@ -4952,8 +5093,8 @@ DEFUN (bgp_network_mask_backdoor, ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_static_set (vty, prefix_str, AFI_IP, SAFI_UNICAST, @@ -4974,8 +5115,8 @@ DEFUN (bgp_network_mask_natural, ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_static_set (vty, prefix_str, @@ -4999,8 +5140,8 @@ DEFUN (bgp_network_mask_natural_route_map, ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_static_set (vty, prefix_str, @@ -5022,8 +5163,8 @@ DEFUN (bgp_network_mask_natural_backdoor, ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_static_set (vty, prefix_str, AFI_IP, SAFI_UNICAST, @@ -5097,8 +5238,8 @@ DEFUN (no_bgp_network_mask, ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_static_unset (vty, prefix_str, AFI_IP, @@ -5122,8 +5263,8 @@ DEFUN (no_bgp_network_mask_natural, ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_static_unset (vty, prefix_str, AFI_IP, @@ -5756,8 +5897,8 @@ bgp_aggregate_unset (struct vty *vty, const char *prefix_str, ret = str2prefix (prefix_str, &p); if (!ret) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask (&p); @@ -5765,8 +5906,8 @@ bgp_aggregate_unset (struct vty *vty, const char *prefix_str, rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); if (! rn) { - vty_outln (vty,"%% There is no aggregate-address configuration."); - return CMD_WARNING; + vty_out (vty,"%% There is no aggregate-address configuration.\n"); + return CMD_WARNING_CONFIG_FAILED; } aggregate = rn->info; @@ -5801,8 +5942,8 @@ bgp_aggregate_set (struct vty *vty, const char *prefix_str, ret = str2prefix (prefix_str, &p); if (!ret) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask (&p); @@ -5811,14 +5952,14 @@ bgp_aggregate_set (struct vty *vty, const char *prefix_str, if (rn->info) { - vty_outln (vty, "There is already same aggregate network."); + vty_out (vty, "There is already same aggregate network.\n"); /* try to remove the old entry */ ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); if (ret) { - vty_outln (vty, "Error deleting aggregate."); + vty_out (vty, "Error deleting aggregate.\n"); bgp_unlock_node (rn); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } @@ -5884,8 +6025,8 @@ DEFUN (aggregate_address_mask, if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), summary_only, as_set); @@ -5930,8 +6071,8 @@ DEFUN (no_aggregate_address_mask, if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty, "%% Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); @@ -5989,14 +6130,13 @@ bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *n if (nexthop6) { - struct attr_extra *extra = bgp_attr_extra_get(&attr); - extra->mp_nexthop_global = *nexthop6; - extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; + attr.mp_nexthop_global = *nexthop6; + attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } attr.med = metric; attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); - attr.extra->tag = tag; + attr.tag = tag; afi = family2afi (p->family); @@ -6004,10 +6144,8 @@ bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *n if (red) { struct attr attr_new; - struct attr_extra extra_new; /* Copy attribute for modification. */ - attr_new.extra = &extra_new; bgp_attr_dup (&attr_new, &attr); if (red->redist_metric_flag) @@ -6032,7 +6170,6 @@ bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *n /* Unintern original. */ aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); bgp_redistribute_delete (bgp, p, type, instance); return; } @@ -6057,7 +6194,6 @@ bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *n { bgp_attr_unintern (&new_attr); aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); bgp_unlock_node (bn); return; } @@ -6080,7 +6216,6 @@ bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *n bgp_process (bgp, bn, afi, SAFI_UNICAST); bgp_unlock_node (bn); aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); return; } } @@ -6097,7 +6232,6 @@ bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *n /* Unintern original. */ aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); } void @@ -6182,8 +6316,13 @@ route_vty_out_route (struct prefix *p, struct vty *vty) } else if (p->family == AF_ETHERNET) { +#if defined (HAVE_CUMULUS) + len = vty_out (vty, "%s", + bgp_evpn_route2str((struct prefix_evpn *)p, buf, BUFSIZ)); +#else prefix2str(p, buf, PREFIX_STRLEN); len = vty_out (vty, "%s", buf); +#endif } else len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), @@ -6191,7 +6330,7 @@ route_vty_out_route (struct prefix *p, struct vty *vty) len = 17 - len; if (len < 1) - vty_out (vty, "%s%*s", VTYNL, 20, " "); + vty_out (vty, "\n%*s", 20, " "); else vty_out (vty, "%*s", len, " "); } @@ -6307,37 +6446,46 @@ route_vty_out (struct vty *vty, struct prefix *p, /* Print attribute */ attr = binfo->attr; - if (attr) + if (attr) { /* - * For ENCAP routes, nexthop address family is not + * For ENCAP and EVPN routes, nexthop address family is not * neccessarily the same as the prefix address family. * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field + * EVPN routes are also exchanged with a MP nexthop. Currently, this + * is only IPv4, the value will be present in either attr->nexthop or + * attr->mp_nexthop_global_in */ - if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) + if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) { - if (attr->extra) + char buf[BUFSIZ]; + int af = NEXTHOP_FAMILY(attr->mp_nexthop_len); + + switch (af) { - char buf[BUFSIZ]; - int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); + case AF_INET: + vty_out (vty, "%s", inet_ntop(af, &attr->mp_nexthop_global_in, buf, BUFSIZ)); + break; + case AF_INET6: + vty_out (vty, "%s", inet_ntop(af, &attr->mp_nexthop_global, buf, BUFSIZ)); + break; + default: + vty_out(vty, "?"); + break; + } + } + else if (safi == SAFI_EVPN) + { + if (json_paths) + { + json_nexthop_global = json_object_new_object(); - switch (af) - { - case AF_INET: - vty_out (vty, "%s", inet_ntop(af, - &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); - break; - case AF_INET6: - vty_out (vty, "%s", inet_ntop(af, - &attr->extra->mp_nexthop_global, buf, BUFSIZ)); - break; - default: - vty_out(vty, "?"); - break; - } + json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->nexthop)); + json_object_string_add(json_nexthop_global, "afi", "ipv4"); + json_object_boolean_true_add(json_nexthop_global, "used"); } else - vty_out(vty, "?"); + vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); } /* IPv4 Next Hop */ else if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) @@ -6347,7 +6495,7 @@ route_vty_out (struct vty *vty, struct prefix *p, json_nexthop_global = json_object_new_object(); if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) - json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->extra->mp_nexthop_global_in)); + json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->mp_nexthop_global_in)); else json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->nexthop)); @@ -6358,7 +6506,7 @@ route_vty_out (struct vty *vty, struct prefix *p, { if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) vty_out (vty, "%-16s", - inet_ntoa (attr->extra->mp_nexthop_global_in)); + inet_ntoa (attr->mp_nexthop_global_in)); else vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); } @@ -6375,25 +6523,25 @@ route_vty_out (struct vty *vty, struct prefix *p, json_nexthop_global = json_object_new_object(); json_object_string_add(json_nexthop_global, "ip", inet_ntop (AF_INET6, - &attr->extra->mp_nexthop_global, + &attr->mp_nexthop_global, buf, BUFSIZ)); json_object_string_add(json_nexthop_global, "afi", "ipv6"); json_object_string_add(json_nexthop_global, "scope", "global"); /* We display both LL & GL if both have been received */ - if ((attr->extra->mp_nexthop_len == 32) || (binfo->peer->conf_if)) + if ((attr->mp_nexthop_len == 32) || (binfo->peer->conf_if)) { json_nexthop_ll = json_object_new_object(); json_object_string_add(json_nexthop_ll, "ip", inet_ntop (AF_INET6, - &attr->extra->mp_nexthop_local, + &attr->mp_nexthop_local, buf, BUFSIZ)); json_object_string_add(json_nexthop_ll, "afi", "ipv6"); json_object_string_add(json_nexthop_ll, "scope", "link-local"); - if ((IPV6_ADDR_CMP (&attr->extra->mp_nexthop_global, - &attr->extra->mp_nexthop_local) != 0) && - !attr->extra->mp_nexthop_prefer_global) + if ((IPV6_ADDR_CMP (&attr->mp_nexthop_global, + &attr->mp_nexthop_local) != 0) && + !attr->mp_nexthop_prefer_global) json_object_boolean_true_add(json_nexthop_ll, "used"); else json_object_boolean_true_add(json_nexthop_global, "used"); @@ -6404,8 +6552,8 @@ route_vty_out (struct vty *vty, struct prefix *p, else { /* Display LL if LL/Global both in table unless prefer-global is set */ - if (((attr->extra->mp_nexthop_len == 32) && - !attr->extra->mp_nexthop_prefer_global) || + if (((attr->mp_nexthop_len == 32) && + !attr->mp_nexthop_prefer_global) || (binfo->peer->conf_if)) { if (binfo->peer->conf_if) @@ -6415,7 +6563,7 @@ route_vty_out (struct vty *vty, struct prefix *p, len = 7 - len; /* len of IPv6 addr + max len of def ifname */ if (len < 1) - vty_out (vty, "%s%*s", VTYNL, 45, " "); + vty_out (vty, "\n%*s", 45, " "); else vty_out (vty, "%*s", len, " "); } @@ -6423,12 +6571,12 @@ route_vty_out (struct vty *vty, struct prefix *p, { len = vty_out (vty, "%s", inet_ntop (AF_INET6, - &attr->extra->mp_nexthop_local, + &attr->mp_nexthop_local, buf, BUFSIZ)); len = 16 - len; if (len < 1) - vty_out (vty, "%s%*s", VTYNL, 36, " "); + vty_out (vty, "\n%*s", 36, " "); else vty_out (vty, "%*s", len, " "); } @@ -6437,12 +6585,12 @@ route_vty_out (struct vty *vty, struct prefix *p, { len = vty_out (vty, "%s", inet_ntop (AF_INET6, - &attr->extra->mp_nexthop_global, + &attr->mp_nexthop_global, buf, BUFSIZ)); len = 16 - len; if (len < 1) - vty_out (vty, "%s%*s", VTYNL, 36, " "); + vty_out (vty, "\n%*s", 36, " "); else vty_out (vty, "%*s", len, " "); } @@ -6470,14 +6618,9 @@ route_vty_out (struct vty *vty, struct prefix *p, vty_out (vty, " "); if (json_paths) - { - if (attr->extra) - json_object_int_add(json_path, "weight", attr->extra->weight); - else - json_object_int_add(json_path, "weight", 0); - } + json_object_int_add(json_path, "weight", attr->weight); else - vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); + vty_out (vty, "%7u ", attr->weight); if (json_paths) { char buf[BUFSIZ]; @@ -6504,7 +6647,7 @@ route_vty_out (struct vty *vty, struct prefix *p, if (json_paths) json_object_string_add(json_path, "alert", "No attributes"); else - vty_outln (vty, "No attributes to print"); + vty_out (vty, "No attributes to print\n"); } if (json_paths) @@ -6526,7 +6669,7 @@ route_vty_out (struct vty *vty, struct prefix *p, } else { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); #if ENABLE_BGP_VNC /* prints an additional line, indented, with VNC info, if present */ if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) @@ -6574,7 +6717,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN) - json_object_string_add(json_net, "nextHop", inet_ntoa (attr->extra->mp_nexthop_global_in)); + json_object_string_add(json_net, "nextHop", inet_ntoa (attr->mp_nexthop_global_in)); else json_object_string_add(json_net, "nextHop", inet_ntoa (attr->nexthop)); } @@ -6582,7 +6725,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t { char buf[BUFSIZ]; - json_object_string_add(json_net, "netHopGloabal", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, + json_object_string_add(json_net, "netHopGloabal", inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); } @@ -6592,10 +6735,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) json_object_int_add(json_net, "localPref", attr->local_pref); - if (attr->extra) - json_object_int_add(json_net, "weight", attr->extra->weight); - else - json_object_int_add(json_net, "weight", 0); + json_object_int_add(json_net, "weight", attr->weight); /* Print aspath */ if (attr->aspath) @@ -6614,7 +6754,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t { if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN) vty_out (vty, "%-16s", - inet_ntoa (attr->extra->mp_nexthop_global_in)); + inet_ntoa (attr->mp_nexthop_global_in)); else vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); } @@ -6623,14 +6763,12 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t int len; char buf[BUFSIZ]; - assert (attr->extra); - len = vty_out (vty, "%s", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, + inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); len = 16 - len; if (len < 1) - vty_out (vty, "%s%*s", VTYNL, 36, " "); + vty_out (vty, "\n%*s", 36, " "); else vty_out (vty, "%*s", len, " "); } @@ -6644,7 +6782,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t else vty_out (vty, " "); - vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); + vty_out (vty, "%7u ", attr->weight); /* Print aspath */ if (attr->aspath) @@ -6663,7 +6801,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t json_object_object_add(json_ar, inet_ntop (p->family, &p->u.prefix, buf_cut, BUFSIZ), json_net); } else - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } void @@ -6703,9 +6841,9 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN) { if (json) - json_object_string_add(json_out, "mpNexthopGlobalIn", inet_ntoa (attr->extra->mp_nexthop_global_in)); + json_object_string_add(json_out, "mpNexthopGlobalIn", inet_ntoa (attr->mp_nexthop_global_in)); else - vty_out (vty, "%-16s", inet_ntoa (attr->extra->mp_nexthop_global_in)); + vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); } else { @@ -6719,36 +6857,35 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, || (safi == SAFI_EVPN && p->family == AF_ETHERNET && BGP_ATTR_NEXTHOP_AFI_IP6(attr)) || (BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { - assert (attr->extra); char buf_a[BUFSIZ]; char buf_b[BUFSIZ]; char buf_c[BUFSIZ]; - if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) { if (json) json_object_string_add(json_out, "mpNexthopGlobalIn", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, buf_a, BUFSIZ)); + inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf_a, BUFSIZ)); else vty_out (vty, "%s", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, + inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf_a, BUFSIZ)); } - else if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + else if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { if (json) { - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, + inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf_a, BUFSIZ); - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, + inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf_b, BUFSIZ); sprintf(buf_c, "%s(%s)", buf_a, buf_b); json_object_string_add(json_out, "mpNexthopGlobalLocal", buf_c); } else vty_out (vty, "%s(%s)", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, + inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf_a, BUFSIZ), - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, + inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf_b, BUFSIZ)); } @@ -6767,7 +6904,7 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, else { vty_out (vty, "notag/%d", label); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } } @@ -6799,63 +6936,55 @@ route_vty_out_overlay (struct vty *vty, struct prefix *p, attr = binfo->attr; if (attr) { - if (attr->extra) - { - char buf1[BUFSIZ]; - int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); + char buf1[BUFSIZ]; + int af = NEXTHOP_FAMILY(attr->mp_nexthop_len); - switch (af) { - case AF_INET: - vty_out (vty, "%-16s", inet_ntop(af, - &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); - break; - case AF_INET6: - vty_out (vty, "%s(%s)", - inet_ntop (af, - &attr->extra->mp_nexthop_global, buf, BUFSIZ), - inet_ntop (af, - &attr->extra->mp_nexthop_local, buf1, BUFSIZ)); - break; - default: - vty_out(vty, "?"); - } - } else { + switch (af) { + case AF_INET: + vty_out (vty, "%-16s", inet_ntop(af, + &attr->mp_nexthop_global_in, buf, BUFSIZ)); + break; + case AF_INET6: + vty_out (vty, "%s(%s)", + inet_ntop (af, + &attr->mp_nexthop_global, buf, BUFSIZ), + inet_ntop (af, + &attr->mp_nexthop_local, buf1, BUFSIZ)); + break; + default: vty_out(vty, "?"); } } - if(attr->extra) + struct eth_segment_id *id = &(attr->evpn_overlay.eth_s_id); + char *str = esi2str(id); + vty_out (vty, "%s", str); + XFREE (MTYPE_TMP, str); + if (IS_EVPN_PREFIX_IPADDR_V4((struct prefix_evpn *)p)) { - struct eth_segment_id *id = &(attr->extra->evpn_overlay.eth_s_id); - char *str = esi2str(id); - vty_out (vty, "%s", str); - XFREE (MTYPE_TMP, str); - if (IS_EVPN_PREFIX_IPADDR_V4((struct prefix_evpn *)p)) - { - vty_out (vty, "/%s", inet_ntoa (attr->extra->evpn_overlay.gw_ip.ipv4)); - } - else if (IS_EVPN_PREFIX_IPADDR_V6((struct prefix_evpn *)p)) - { - vty_out (vty, "/%s", - inet_ntop (AF_INET6, &(attr->extra->evpn_overlay.gw_ip.ipv6), - buf, BUFSIZ)); - } - if(attr->extra->ecommunity) - { - char *mac = NULL; - struct ecommunity_val *routermac = ecommunity_lookup (attr->extra->ecommunity, - ECOMMUNITY_ENCODE_EVPN, - ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC); - if(routermac) - mac = ecom_mac2str((char *)routermac->val); - if(mac) - { - vty_out (vty, "/%s",(char *)mac); - XFREE(MTYPE_TMP, mac); - } + vty_out (vty, "/%s", inet_ntoa (attr->evpn_overlay.gw_ip.ipv4)); + } + else if (IS_EVPN_PREFIX_IPADDR_V6((struct prefix_evpn *)p)) + { + vty_out (vty, "/%s", + inet_ntop (AF_INET6, &(attr->evpn_overlay.gw_ip.ipv6), + buf, BUFSIZ)); + } + if(attr->ecommunity) + { + char *mac = NULL; + struct ecommunity_val *routermac = ecommunity_lookup (attr->ecommunity, + ECOMMUNITY_ENCODE_EVPN, + ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC); + if(routermac) + mac = ecom_mac2str((char *)routermac->val); + if(mac) + { + vty_out (vty, "/%s",(char *)mac); + XFREE(MTYPE_TMP, mac); } } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* dampening route */ @@ -6884,7 +7013,7 @@ damp_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, if (len < 1) { if (!use_json) - vty_out (vty, "%s%*s", VTYNL, 34, " "); + vty_out (vty, "\n%*s", 34, " "); } else { @@ -6919,7 +7048,7 @@ damp_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, vty_out (vty, "%s", bgp_origin_str[attr->origin]); } if (!use_json) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* flap route */ @@ -6954,7 +7083,7 @@ flap_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, if (len < 1) { if (!use_json) - vty_out (vty, "%s%*s", VTYNL, 33, " "); + vty_out (vty, "\n%*s", 33, " "); } else { @@ -7019,7 +7148,7 @@ flap_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, vty_out (vty, "%s", bgp_origin_str[attr->origin]); } if (!use_json) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } static void @@ -7073,13 +7202,16 @@ route_vty_out_advertised_to (struct vty *vty, struct peer *peer, int *first, } } -static void +void route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, struct bgp_info *binfo, afi_t afi, safi_t safi, json_object *json_paths) { char buf[INET6_ADDRSTRLEN]; char buf1[BUFSIZ]; +#if defined(HAVE_CUMULUS) + char buf2[EVPN_ROUTE_STRLEN]; +#endif struct attr *attr; int sockunion_vty_out (struct vty *, union sockunion *); time_t tbuf; @@ -7109,6 +7241,39 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, json_nexthop_global = json_object_new_object(); } +#if defined (HAVE_CUMULUS) + if (!json_paths && safi == SAFI_EVPN) + { + char tag_buf[20]; + + bgp_evpn_route2str ((struct prefix_evpn *)p, buf2, sizeof (buf2)); + vty_out (vty, " Route %s", buf2); + tag_buf[0] = '\0'; + if (binfo->extra) + { + bgp_evpn_label2str (&binfo->extra->label, tag_buf, sizeof (tag_buf)); + vty_out (vty, " VNI %s", tag_buf); + } + vty_out (vty, "\n"); + if (binfo->extra && binfo->extra->parent) + { + struct bgp_info *parent_ri; + struct bgp_node *rn, *prn; + + parent_ri = (struct bgp_info *)binfo->extra->parent; + rn = parent_ri->net; + if (rn && rn->prn) + { + prn = rn->prn; + vty_out (vty, " Imported from %s:%s\n", + prefix_rd2str ((struct prefix_rd *)&prn->p, + buf1, RD_ADDRSTRLEN), + buf2); + } + } + } +#endif + attr = binfo->attr; if (attr) @@ -7150,14 +7315,14 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, { if (json_paths) { - json_object_int_add(json_path, "aggregatorAs", attr->extra->aggregator_as); - json_object_string_add(json_path, "aggregatorId", inet_ntoa (attr->extra->aggregator_addr)); + json_object_int_add(json_path, "aggregatorAs", attr->aggregator_as); + json_object_string_add(json_path, "aggregatorId", inet_ntoa (attr->aggregator_addr)); } else { vty_out (vty, ", (aggregated by %u %s)", - attr->extra->aggregator_as, - inet_ntoa (attr->extra->aggregator_addr)); + attr->aggregator_as, + inet_ntoa (attr->aggregator_addr)); } } @@ -7193,7 +7358,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, } if (!json_paths) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); /* Line2 display Next-hop, Neighbor, Router-id */ /* Display the nexthop */ @@ -7207,9 +7372,9 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN) { if (json_paths) - json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->extra->mp_nexthop_global_in)); + json_object_string_add(json_nexthop_global, "ip", inet_ntoa (attr->mp_nexthop_global_in)); else - vty_out (vty, " %s", inet_ntoa (attr->extra->mp_nexthop_global_in)); + vty_out (vty, " %s", inet_ntoa (attr->mp_nexthop_global_in)); } else { @@ -7224,11 +7389,10 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, } else { - assert (attr->extra); if (json_paths) { json_object_string_add(json_nexthop_global, "ip", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, + inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, INET6_ADDRSTRLEN)); json_object_string_add(json_nexthop_global, "afi", "ipv6"); json_object_string_add(json_nexthop_global, "scope", "global"); @@ -7236,7 +7400,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, else { vty_out (vty, " %s", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, + inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, INET6_ADDRSTRLEN)); } } @@ -7275,7 +7439,8 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, if (binfo->peer == bgp->peer_self) { - if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) + if (safi == SAFI_EVPN || + (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { if (json_paths) json_object_string_add(json_peer, "peerId", "0.0.0.0"); @@ -7336,40 +7501,40 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, } if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) - vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); + vty_out (vty, " (%s)", inet_ntoa (attr->originator_id)); else vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); } } if (!json_paths) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); /* display the link-local nexthop */ - if (attr->extra && attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { if (json_paths) { json_nexthop_ll = json_object_new_object(); json_object_string_add(json_nexthop_ll, "ip", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, + inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf, INET6_ADDRSTRLEN)); json_object_string_add(json_nexthop_ll, "afi", "ipv6"); json_object_string_add(json_nexthop_ll, "scope", "link-local"); json_object_boolean_true_add(json_nexthop_ll, "accessible"); - if (!attr->extra->mp_nexthop_prefer_global) + if (!attr->mp_nexthop_prefer_global) json_object_boolean_true_add(json_nexthop_ll, "used"); else json_object_boolean_true_add(json_nexthop_global, "used"); } else { - vty_outln (vty, " (%s) %s", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, + vty_out (vty, " (%s) %s\n", + inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf, INET6_ADDRSTRLEN), - attr->extra->mp_nexthop_prefer_global ? "(prefer-global)" : "(used)"); + attr->mp_nexthop_prefer_global ? "(prefer-global)" : "(used)"); } } /* If we do not have a link-local nexthop then we must flag the global as "used" */ @@ -7408,20 +7573,20 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, vty_out (vty, ", localpref %u", bgp->default_local_pref); } - if (attr->extra && attr->extra->weight != 0) + if (attr->weight != 0) { if (json_paths) - json_object_int_add(json_path, "weight", attr->extra->weight); + json_object_int_add(json_path, "weight", attr->weight); else - vty_out (vty, ", weight %u", attr->extra->weight); + vty_out (vty, ", weight %u", attr->weight); } - if (attr->extra && attr->extra->tag != 0) + if (attr->tag != 0) { if (json_paths) - json_object_int_add(json_path, "tag", attr->extra->tag); + json_object_int_add(json_path, "tag", attr->tag); else - vty_out (vty, ", tag %"ROUTE_TAG_PRI, attr->extra->tag); + vty_out (vty, ", tag %"ROUTE_TAG_PRI, attr->tag); } if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) @@ -7562,7 +7727,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, json_object_object_add(json_path, "bestpath", json_bestpath); if (!json_paths) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); /* Line 4 display Community */ if (attr->community) @@ -7574,7 +7739,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, } else { - vty_outln (vty, " Community: %s",attr->community->str); + vty_out (vty, " Community: %s\n",attr->community->str); } } @@ -7584,33 +7749,32 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, if (json_paths) { json_ext_community = json_object_new_object(); - json_object_string_add(json_ext_community, "string", attr->extra->ecommunity->str); + json_object_string_add(json_ext_community, "string", attr->ecommunity->str); json_object_object_add(json_path, "extendedCommunity", json_ext_community); } else { - vty_outln (vty, " Extended Community: %s", - attr->extra->ecommunity->str); + vty_out (vty, " Extended Community: %s\n", + attr->ecommunity->str); } } /* Line 6 display Large community */ if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) - vty_outln (vty, " Large Community: %s", - attr->extra->lcommunity->str); + vty_out (vty, " Large Community: %s\n", + attr->lcommunity->str); /* Line 7 display Originator, Cluster-id */ if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) { - assert (attr->extra); if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) { if (json_paths) - json_object_string_add(json_path, "originatorId", inet_ntoa (attr->extra->originator_id)); + json_object_string_add(json_path, "originatorId", inet_ntoa (attr->originator_id)); else vty_out (vty, " Originator: %s", - inet_ntoa (attr->extra->originator_id)); + inet_ntoa (attr->originator_id)); } if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) @@ -7622,16 +7786,16 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, json_cluster_list = json_object_new_object(); json_cluster_list_list = json_object_new_array(); - for (i = 0; i < attr->extra->cluster->length / 4; i++) + for (i = 0; i < attr->cluster->length / 4; i++) { - json_string = json_object_new_string(inet_ntoa (attr->extra->cluster->list[i])); + json_string = json_object_new_string(inet_ntoa (attr->cluster->list[i])); json_object_array_add(json_cluster_list_list, json_string); } /* struct cluster_list does not have "str" variable like * aspath and community do. Add this someday if someone * asks for it. - json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str); + json_object_string_add(json_cluster_list, "string", attr->cluster->str); */ json_object_object_add(json_cluster_list, "list", json_cluster_list_list); json_object_object_add(json_path, "clusterList", json_cluster_list); @@ -7640,39 +7804,43 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, { vty_out (vty, ", Cluster list: "); - for (i = 0; i < attr->extra->cluster->length / 4; i++) + for (i = 0; i < attr->cluster->length / 4; i++) { vty_out (vty, "%s ", - inet_ntoa (attr->extra->cluster->list[i])); + inet_ntoa (attr->cluster->list[i])); } } } if (!json_paths) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (binfo->extra && binfo->extra->damp_info) bgp_damp_info_vty (vty, binfo, json_path); /* Remote Label */ +#if defined (HAVE_CUMULUS) + if (binfo->extra && bgp_is_valid_label(&binfo->extra->label) && safi != SAFI_EVPN) +#else if (binfo->extra && bgp_is_valid_label(&binfo->extra->label)) +#endif { mpls_label_t label = label_pton(&binfo->extra->label); if (json_paths) json_object_int_add(json_path, "remoteLabel", label); else - vty_outln (vty, " Remote label: %d", label); + vty_out (vty, " Remote label: %d\n", label); } /* Label Index */ - if (attr->extra->label_index != BGP_INVALID_LABEL_INDEX) + if (attr->label_index != BGP_INVALID_LABEL_INDEX) { if (json_paths) - json_object_int_add(json_path, "labelIndex", attr->extra->label_index); + json_object_int_add(json_path, "labelIndex", attr->label_index); else - vty_outln (vty, " Label Index: %d", - attr->extra->label_index); + vty_out (vty, " Label Index: %d\n", + attr->label_index); } /* Line 8 display Addpath IDs */ @@ -7685,7 +7853,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, } else { - vty_outln (vty, " AddPath ID: RX %u, TX %u", + vty_out (vty, " AddPath ID: RX %u, TX %u\n", binfo->addpath_rx_id,binfo->addpath_tx_id); } } @@ -7724,7 +7892,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, { if (!first) { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } } @@ -7764,12 +7932,12 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, json_object_array_add(json_paths, json_path); } else - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path" -#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path" -#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path" +#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path\n" +#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path\n" static int bgp_show_prefix_list (struct vty *vty, struct bgp *bgp, @@ -7878,10 +8046,8 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, struct route_map *rmap = output_arg; struct bgp_info binfo; struct attr dummy_attr; - struct attr_extra dummy_extra; int ret; - dummy_attr.extra = &dummy_extra; bgp_attr_dup (&dummy_attr, ri->attr); binfo.peer = ri->peer; @@ -7959,21 +8125,20 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, { struct lcommunity *lcom = output_arg; - if (! ri->attr->extra || ! ri->attr->extra->lcommunity || - ! lcommunity_match (ri->attr->extra->lcommunity, lcom)) + if (! ri->attr->lcommunity || + ! lcommunity_match (ri->attr->lcommunity, lcom)) continue; } if (type == bgp_show_type_lcommunity_list) { struct community_list *list = output_arg; - if (! ri->attr->extra || - ! lcommunity_list_match (ri->attr->extra->lcommunity, list)) + if (! lcommunity_list_match (ri->attr->lcommunity, list)) continue; } if (type == bgp_show_type_lcommunity_all) { - if (! ri->attr->extra || ! ri->attr->extra->lcommunity) + if (! ri->attr->lcommunity) continue; } if (type == bgp_show_type_dampend_paths @@ -7986,18 +8151,18 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, if (!use_json && header) { - vty_outln (vty, "BGP table version is %" PRIu64 ", local router ID is %s", table->version, + vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s\n", table->version, inet_ntoa(bgp->router_id)); - vty_outln (vty, BGP_SHOW_SCODE_HEADER, VTYNL); - vty_outln (vty, BGP_SHOW_OCODE_HEADER, VTYNL); + vty_out (vty, BGP_SHOW_SCODE_HEADER); + vty_out (vty, BGP_SHOW_OCODE_HEADER); if (type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) - vty_outln (vty, BGP_SHOW_DAMP_HEADER); + vty_out (vty, BGP_SHOW_DAMP_HEADER); else if (type == bgp_show_type_flap_statistics || type == bgp_show_type_flap_neighbor) - vty_outln (vty, BGP_SHOW_FLAP_HEADER); + vty_out (vty, BGP_SHOW_FLAP_HEADER); else - vty_outln (vty, BGP_SHOW_HEADER); + vty_out (vty, BGP_SHOW_HEADER); header = 0; } @@ -8031,7 +8196,7 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, if (use_json) { json_object_free (json_paths); - vty_outln (vty, " } }"); + vty_out (vty, " } }\n"); } else { @@ -8039,12 +8204,11 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, if (output_count == 0) { if (type == bgp_show_type_normal) - vty_outln (vty, "No BGP prefixes displayed, %ld exist", + vty_out (vty, "No BGP prefixes displayed, %ld exist\n", total_count); } else - vty_outln (vty, "%sDisplayed %ld routes and %ld total paths", - VTYNL, output_count, total_count); + vty_out (vty, "\nDisplayed %ld routes and %ld total paths\n", output_count, total_count); } return CMD_SUCCESS; @@ -8064,15 +8228,19 @@ bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, if (bgp == NULL) { if (!use_json) - vty_outln (vty, "No BGP process is configured"); + vty_out (vty, "No BGP process is configured\n"); return CMD_WARNING; } + /* use MPLS and ENCAP specific shows until they are merged */ if (safi == SAFI_MPLS_VPN) { return bgp_show_mpls_vpn(vty, afi, NULL, type, output_arg, 0, use_json); } + /* labeled-unicast routes live in the unicast table */ + else if (safi == SAFI_LABELED_UNICAST) + safi = SAFI_UNICAST; table = bgp->rib[afi][safi]; @@ -8089,14 +8257,14 @@ bgp_show_all_instances_routes_vty (struct vty *vty, afi_t afi, safi_t safi, int is_first = 1; if (use_json) - vty_outln (vty, "{"); + vty_out (vty, "{\n"); for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) { if (use_json) { if (! is_first) - vty_outln (vty, ","); + vty_out (vty, ",\n"); else is_first = 0; @@ -8105,8 +8273,7 @@ bgp_show_all_instances_routes_vty (struct vty *vty, afi_t afi, safi_t safi, } else { - vty_outln (vty, "%sInstance %s:", - VTYNL, + vty_out (vty, "\nInstance %s:\n", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name); } bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL, use_json); @@ -8114,11 +8281,11 @@ bgp_show_all_instances_routes_vty (struct vty *vty, afi_t afi, safi_t safi, } if (use_json) - vty_outln (vty, "}"); + vty_out (vty, "}\n"); } /* Header of detailed BGP route information */ -static void +void route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, struct bgp_node *rn, struct prefix_rd *prd, afi_t afi, safi_t safi, @@ -8130,6 +8297,9 @@ route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, struct listnode *node, *nnode; char buf1[INET6_ADDRSTRLEN]; char buf2[INET6_ADDRSTRLEN]; +#if defined(HAVE_CUMULUS) + char buf3[EVPN_ROUTE_STRLEN]; +#endif int count = 0; int best = 0; int suppress = 0; @@ -8157,21 +8327,41 @@ route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, } else { +#if defined (HAVE_CUMULUS) + if (safi == SAFI_EVPN) + vty_out (vty, "BGP routing table entry for %s%s%s\n", + prd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : "", + prd ? ":" : "", + bgp_evpn_route2str ((struct prefix_evpn *)p, + buf3, sizeof (buf3))); + else + vty_out (vty, "BGP routing table entry for %s%s%s/%d\n", + ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) ? + prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), + safi == SAFI_MPLS_VPN ? ":" : "", + inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), + p->prefixlen); +#else if (p->family == AF_ETHERNET) prefix2str (p, buf2, INET6_ADDRSTRLEN); else inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN); - vty_outln (vty, "BGP routing table entry for %s%s%s/%d", + vty_out (vty, "BGP routing table entry for %s%s%s/%d\n", ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN) ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), ((safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) ? ":" : "", buf2, p->prefixlen); +#endif if (has_valid_label) - vty_outln (vty, "Local label: %d", label); - else if (bgp_labeled_safi(safi)) - vty_outln (vty, "Local label: not allocated"); + vty_out (vty, "Local label: %d\n", label); +#if defined (HAVE_CUMULUS) + if (bgp_labeled_safi(safi) && safi != SAFI_EVPN) +#else + if (bgp_labeled_safi(safi)) +#endif + vty_out(vty, "not allocated\n"); } for (ri = rn->info; ri; ri = ri->next) @@ -8217,7 +8407,7 @@ route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, if (suppress) vty_out (vty, ", Advertisements suppressed by an aggregate."); - vty_outln (vty, ")"); + vty_out (vty, ")\n"); } /* If we are not using addpath then we can display Advertised to and that will @@ -8249,7 +8439,7 @@ route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, { if (first) vty_out (vty, " Not advertised to any peer"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } } @@ -8277,7 +8467,7 @@ bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, ret = str2prefix (ip_str, &match); if (! ret) { - vty_outln (vty, "address is malformed"); + vty_out (vty, "address is malformed\n"); return CMD_WARNING; } @@ -8364,7 +8554,7 @@ bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, if (display) json_object_object_add(json, "paths", json_paths); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -8372,7 +8562,7 @@ bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, { if (!display) { - vty_outln (vty, "%% Network not in table"); + vty_out (vty, "%% Network not in table\n"); return CMD_WARNING; } } @@ -8390,6 +8580,10 @@ bgp_show_route (struct vty *vty, struct bgp *bgp, const char *ip_str, if (!bgp) bgp = bgp_get_default (); + /* labeled-unicast routes live in the unicast table */ + if (safi == SAFI_LABELED_UNICAST) + safi = SAFI_UNICAST; + return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, afi, safi, prd, prefix_check, pathtype, use_json); @@ -8428,7 +8622,7 @@ bgp_show_lcommunity (struct vty *vty, struct bgp *bgp, int argc, XFREE (MTYPE_TMP, str); if (! lcom) { - vty_outln (vty, "%% Large-community malformed"); + vty_out (vty, "%% Large-community malformed\n"); return CMD_WARNING; } @@ -8444,7 +8638,7 @@ bgp_show_lcommunity_list (struct vty *vty, struct bgp *bgp, const char *lcom, list = community_list_lookup (bgp_clist, lcom, LARGE_COMMUNITY_LIST_MASTER); if (list == NULL) { - vty_outln (vty, "%% %s is not a valid large-community-list name",lcom); + vty_out (vty, "%% %s is not a valid large-community-list name\n",lcom); return CMD_WARNING; } @@ -8453,13 +8647,13 @@ bgp_show_lcommunity_list (struct vty *vty, struct bgp *bgp, const char *lcom, DEFUN (show_ip_bgp_large_community_list, show_ip_bgp_large_community_list_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] large-community-list <(1-500)|WORD> [json]", + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] large-community-list <(1-500)|WORD> [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR - BGP_SAFI_HELP_STR + BGP_SAFI_WITH_LABEL_HELP_STR "Display routes matching the large-community-list\n" "large-community-list number\n" "large-community-list name\n" @@ -8486,7 +8680,7 @@ DEFUN (show_ip_bgp_large_community_list, struct bgp *bgp = bgp_lookup_by_name (vrf); if (bgp == NULL) { - vty_outln (vty, "Can't find BGP instance %s", vrf); + vty_out (vty, "Can't find BGP instance %s\n", vrf); return CMD_WARNING; } @@ -8495,13 +8689,13 @@ DEFUN (show_ip_bgp_large_community_list, } DEFUN (show_ip_bgp_large_community, show_ip_bgp_large_community_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] large-community [AA:BB:CC] [json]", + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] large-community [AA:BB:CC] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR - BGP_SAFI_HELP_STR + BGP_SAFI_WITH_LABEL_HELP_STR "Display routes matching the large-communities\n" "List of large-community numbers\n" JSON_STR) @@ -8527,7 +8721,7 @@ DEFUN (show_ip_bgp_large_community, struct bgp *bgp = bgp_lookup_by_name (vrf); if (bgp == NULL) { - vty_outln (vty, "Can't find BGP instance %s", vrf); + vty_out (vty, "Can't find BGP instance %s\n", vrf); return CMD_WARNING; } @@ -8542,7 +8736,7 @@ static int bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t /* BGP route print out function. */ DEFUN (show_ip_bgp, show_ip_bgp_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]]\ + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\ [<\ cidr-only\ |dampening <flap-statistics|dampened-paths|parameters>\ @@ -8560,7 +8754,7 @@ DEFUN (show_ip_bgp, BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR - BGP_SAFI_HELP_STR + BGP_SAFI_WITH_LABEL_HELP_STR "Display only routes with non-natural netmasks\n" "Display detailed information about dampening\n" "Display flap statistics of routes\n" @@ -8663,14 +8857,14 @@ DEFUN (show_ip_bgp, DEFUN (show_ip_bgp_route, show_ip_bgp_route_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]]" + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]" "<A.B.C.D|A.B.C.D/M|X:X::X:X|X:X::X:X/M> [<bestpath|multipath>] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR - BGP_SAFI_HELP_STR + BGP_SAFI_WITH_LABEL_HELP_STR "Network in the BGP routing table to display\n" "IPv4 prefix\n" "Network in the BGP routing table to display\n" @@ -8696,8 +8890,8 @@ DEFUN (show_ip_bgp_route, if (!bgp) { - vty_outln (vty, - "Specified 'all' vrf's but this command currently only works per view/vrf"); + vty_out (vty, + "Specified 'all' vrf's but this command currently only works per view/vrf\n"); return CMD_WARNING; } @@ -8709,14 +8903,14 @@ DEFUN (show_ip_bgp_route, if ((argv[idx]->type == IPV6_TKN || argv[idx]->type == IPV6_PREFIX_TKN) && afi != AFI_IP6) { - vty_outln (vty, - "%% Cannot specify IPv6 address or prefix with IPv4 AFI"); + vty_out (vty, + "%% Cannot specify IPv6 address or prefix with IPv4 AFI\n"); return CMD_WARNING; } if ((argv[idx]->type == IPV4_TKN || argv[idx]->type == IPV4_PREFIX_TKN) && afi != AFI_IP) { - vty_outln (vty, - "%% Cannot specify IPv4 address or prefix with IPv6 AFI"); + vty_out (vty, + "%% Cannot specify IPv4 address or prefix with IPv6 AFI\n"); return CMD_WARNING; } @@ -8735,13 +8929,13 @@ DEFUN (show_ip_bgp_route, DEFUN (show_ip_bgp_regexp, show_ip_bgp_regexp_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] regexp REGEX...", + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] regexp REGEX...", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR - BGP_SAFI_HELP_STR + BGP_SAFI_WITH_LABEL_HELP_STR "Display routes matching the AS path regular expression\n" "A regular-expression to match the BGP AS paths\n") { @@ -8766,13 +8960,13 @@ DEFUN (show_ip_bgp_regexp, DEFUN (show_ip_bgp_instance_all, show_ip_bgp_instance_all_cmd, - "show [ip] bgp <view|vrf> all ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] [json]", + "show [ip] bgp <view|vrf> all ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_ALL_HELP_STR BGP_AFI_HELP_STR - BGP_SAFI_HELP_STR + BGP_SAFI_WITH_LABEL_HELP_STR JSON_STR) { afi_t afi = AFI_IP; @@ -8801,7 +8995,7 @@ bgp_show_regexp (struct vty *vty, const char *regstr, afi_t afi, regex = bgp_regcomp (regstr); if (! regex) { - vty_outln (vty, "Can't compile regexp %s", regstr); + vty_out (vty, "Can't compile regexp %s\n", regstr); return CMD_WARNING; } @@ -8820,7 +9014,7 @@ bgp_show_prefix_list (struct vty *vty, struct bgp *bgp, plist = prefix_list_lookup (afi, prefix_list_str); if (plist == NULL) { - vty_outln (vty, "%% %s is not a valid prefix-list name", + vty_out (vty, "%% %s is not a valid prefix-list name\n", prefix_list_str); return CMD_WARNING; } @@ -8838,7 +9032,7 @@ bgp_show_filter_list (struct vty *vty, struct bgp *bgp, as_list = as_list_lookup (filter); if (as_list == NULL) { - vty_outln (vty, "%% %s is not a valid AS-path access-list name", + vty_out (vty, "%% %s is not a valid AS-path access-list name\n", filter); return CMD_WARNING; } @@ -8856,7 +9050,7 @@ bgp_show_route_map (struct vty *vty, struct bgp *bgp, rmap = route_map_lookup_by_name (rmap_str); if (! rmap) { - vty_outln (vty, "%% %s is not a valid route-map name", + vty_out (vty, "%% %s is not a valid route-map name\n", rmap_str); return CMD_WARNING; } @@ -8898,7 +9092,7 @@ bgp_show_community (struct vty *vty, struct bgp *bgp, int argc, XFREE (MTYPE_TMP, str); if (! com) { - vty_outln (vty, "%% Community malformed: "); + vty_out (vty, "%% Community malformed: \n"); return CMD_WARNING; } @@ -8920,7 +9114,7 @@ bgp_show_community_list (struct vty *vty, struct bgp *bgp, list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); if (list == NULL) { - vty_outln (vty, "%% %s is not a valid community-list name",com); + vty_out (vty, "%% %s is not a valid community-list name\n",com); return CMD_WARNING; } @@ -8942,7 +9136,7 @@ bgp_show_prefix_longer (struct vty *vty, struct bgp *bgp, ret = str2prefix (prefix, p); if (! ret) { - vty_outln (vty, "%% Malformed Prefix"); + vty_out (vty, "%% Malformed Prefix\n"); return CMD_WARNING; } @@ -8975,11 +9169,11 @@ peer_lookup_in_view (struct vty *vty, struct bgp *bgp, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "malformedAddressOrName", ip_str); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "%% Malformed address or name: %s", ip_str); + vty_out (vty, "%% Malformed address or name: %s\n", ip_str); return NULL; } } @@ -8995,11 +9189,11 @@ peer_lookup_in_view (struct vty *vty, struct bgp *bgp, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning","No such neighbor"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "No such neighbor"); + vty_out (vty, "No such neighbor\n"); return NULL; } @@ -9174,21 +9368,25 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) { struct bgp_table_stats ts; unsigned int i; - + if (!bgp->rib[afi][safi]) { - vty_outln (vty, "%% No RIB exist's for the AFI(%d)/SAFI(%d)", + vty_out (vty, "%% No RIB exist's for the AFI(%d)/SAFI(%d)\n", afi, safi); return CMD_WARNING; } - + + vty_out (vty, "BGP %s RIB statistics\n", + afi_safi_print (afi, safi)); + + /* labeled-unicast routes live in the unicast table */ + if (safi == SAFI_LABELED_UNICAST) + safi = SAFI_UNICAST; + memset (&ts, 0, sizeof (ts)); ts.table = bgp->rib[afi][safi]; thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); - vty_outln (vty, "BGP %s RIB statistics%s", - afi_safi_print (afi, safi), VTYNL); - for (i = 0; i < BGP_STATS_MAX; i++) { if (!table_stats_strs[i]) @@ -9224,14 +9422,14 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) break; case BGP_STATS_SPACE: vty_out (vty, "%-30s: ", table_stats_strs[i]); - vty_outln (vty, "%12llu", ts.counts[i]); + vty_out (vty, "%12llu\n", ts.counts[i]); if (ts.counts[BGP_STATS_MAXBITLEN] < 9) break; vty_out (vty, "%30s: ", "%% announced "); - vty_outln (vty, "%12.2f", + vty_out (vty, "%12.2f\n", 100 * (float)ts.counts[BGP_STATS_SPACE] / (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN])); vty_out (vty, "%30s: ", "/8 equivalent "); - vty_outln (vty, "%12.2f", + vty_out (vty, "%12.2f\n", (float)ts.counts[BGP_STATS_SPACE] / (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8))); if (ts.counts[BGP_STATS_MAXBITLEN] < 25) break; @@ -9245,7 +9443,7 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) vty_out (vty, "%12llu", ts.counts[i]); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return CMD_SUCCESS; } @@ -9369,11 +9567,11 @@ bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_c if (use_json) { json_object_string_add(json, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", json_object_to_json_string(json)); + vty_out (vty, "%s\n", json_object_to_json_string(json)); json_object_free(json); } else - vty_outln (vty, "%% No such neighbor or address family"); + vty_out (vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -9404,7 +9602,7 @@ bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_c json_object_string_add(json, "pfxctDriftFor", peer->host); json_object_string_add(json, "recommended", "Please report this bug, with the above command output"); } - vty_outln (vty, "%s", json_object_to_json_string(json)); + vty_out (vty, "%s\n", json_object_to_json_string(json)); json_object_free(json); } else @@ -9412,28 +9610,27 @@ bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_c if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) { - vty_outln (vty, "Prefix counts for %s/%s, %s", + vty_out (vty, "Prefix counts for %s/%s, %s\n", peer->hostname, peer->host,afi_safi_print(afi, safi)); } else { - vty_outln (vty, "Prefix counts for %s, %s", + vty_out (vty, "Prefix counts for %s, %s\n", peer->host, afi_safi_print(afi, safi)); } - vty_outln (vty, "PfxCt: %ld", peer->pcount[afi][safi]); - vty_outln (vty, "%sCounts from RIB table walk:%s", - VTYNL, VTYNL); + vty_out (vty, "PfxCt: %ld\n", peer->pcount[afi][safi]); + vty_out (vty, "\nCounts from RIB table walk:\n\n"); for (i = 0; i < PCOUNT_MAX; i++) - vty_outln (vty, "%20s: %-10d", pcount_strs[i], pcounts.count[i]); + vty_out (vty, "%20s: %-10d\n", pcount_strs[i], pcounts.count[i]); if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) { - vty_outln (vty, "%s [pcount] PfxCt drift!", + vty_out (vty, "%s [pcount] PfxCt drift!\n", peer->host); - vty_outln (vty, - "Please report this bug, with the above command output"); + vty_out (vty, + "Please report this bug, with the above command output\n"); } } @@ -9522,7 +9719,7 @@ DEFUN (show_ip_bgp_vpn_all_route_prefix, struct bgp *bgp = bgp_get_default(); if (!bgp) { - vty_outln (vty, "Can't find default instance"); + vty_out (vty, "Can't find default instance\n"); return CMD_WARNING; } @@ -9532,7 +9729,7 @@ DEFUN (show_ip_bgp_vpn_all_route_prefix, network = argv[idx]->arg; else { - vty_outln (vty, "Unable to figure out Network"); + vty_out (vty, "Unable to figure out Network\n"); return CMD_WARNING; } @@ -9562,7 +9759,7 @@ DEFUN (show_ip_bgp_l2vpn_evpn_all_route_prefix, network = argv[idx]->arg; else { - vty_outln (vty, "Unable to figure out Network"); + vty_out (vty, "Unable to figure out Network\n"); return CMD_WARNING; } return bgp_show_route (vty, NULL, network, AFI_L2VPN, SAFI_EVPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); @@ -9582,7 +9779,6 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, struct bgp *bgp; int header2 = 1; struct attr attr; - struct attr_extra extra; int ret; struct update_subgroup *subgrp; json_object *json_scode = NULL; @@ -9619,11 +9815,11 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, if (use_json) { json_object_string_add(json, "alert", "no BGP"); - vty_outln (vty, "%s", json_object_to_json_string(json)); + vty_out (vty, "%s\n", json_object_to_json_string(json)); json_object_free(json); } else - vty_outln (vty, "%% No bgp"); + vty_out (vty, "%% No bgp\n"); return; } @@ -9644,18 +9840,16 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, } else { - vty_outln (vty, "BGP table version is %" PRIu64 ", local router ID is %s", table->version, + vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s\n", table->version, inet_ntoa(bgp->router_id)); - vty_outln (vty, BGP_SHOW_SCODE_HEADER, VTYNL); - vty_outln (vty, BGP_SHOW_OCODE_HEADER, VTYNL); + vty_out (vty, BGP_SHOW_SCODE_HEADER); + vty_out (vty, BGP_SHOW_OCODE_HEADER); - vty_outln (vty, "Originating default network 0.0.0.0%s", - VTYNL); + vty_out (vty, "Originating default network 0.0.0.0\n\n"); } header1 = 0; } - attr.extra = &extra; for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) { if (in) @@ -9675,17 +9869,17 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, } else { - vty_outln (vty, "BGP table version is 0, local router ID is %s", + vty_out (vty, "BGP table version is 0, local router ID is %s\n", inet_ntoa(bgp->router_id)); - vty_outln (vty, BGP_SHOW_SCODE_HEADER, VTYNL); - vty_outln (vty, BGP_SHOW_OCODE_HEADER, VTYNL); + vty_out (vty, BGP_SHOW_SCODE_HEADER); + vty_out (vty, BGP_SHOW_OCODE_HEADER); } header1 = 0; } if (header2) { if (!use_json) - vty_outln (vty, BGP_SHOW_HEADER); + vty_out (vty, BGP_SHOW_HEADER); header2 = 0; } if (ain->attr) @@ -9719,10 +9913,10 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, } else { - vty_outln (vty, "BGP table version is %" PRIu64 ", local router ID is %s", table->version, + vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s\n", table->version, inet_ntoa(bgp->router_id)); - vty_outln (vty, BGP_SHOW_SCODE_HEADER, VTYNL); - vty_outln (vty, BGP_SHOW_OCODE_HEADER, VTYNL); + vty_out (vty, BGP_SHOW_SCODE_HEADER); + vty_out (vty, BGP_SHOW_OCODE_HEADER); } header1 = 0; } @@ -9730,7 +9924,7 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, if (header2) { if (!use_json) - vty_outln (vty, BGP_SHOW_HEADER); + vty_out (vty, BGP_SHOW_HEADER); header2 = 0; } @@ -9757,12 +9951,11 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, if (use_json) json_object_int_add(json, "totalPrefixCounter", output_count); else - vty_outln (vty, "%sTotal number of prefixes %ld", - VTYNL, output_count); + vty_out (vty, "\nTotal number of prefixes %ld\n", output_count); } if (use_json) { - vty_outln (vty, "%s", json_object_to_json_string(json)); + vty_out (vty, "%s\n", json_object_to_json_string(json)); json_object_free(json); } @@ -9777,16 +9970,20 @@ peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, if (use_json) json = json_object_new_object(); + /* labeled-unicast routes live in the unicast table */ + if (safi == SAFI_LABELED_UNICAST) + safi = SAFI_UNICAST; + if (!peer || !peer->afc[afi][safi]) { if (use_json) { json_object_string_add(json, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", json_object_to_json_string(json)); + vty_out (vty, "%s\n", json_object_to_json_string(json)); json_object_free(json); } else - vty_outln (vty, "%% No such neighbor or address family"); + vty_out (vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } @@ -9796,11 +9993,11 @@ peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, if (use_json) { json_object_string_add(json, "warning", "Inbound soft reconfiguration not enabled"); - vty_outln (vty, "%s", json_object_to_json_string(json)); + vty_out (vty, "%s\n", json_object_to_json_string(json)); json_object_free(json); } else - vty_outln (vty, "%% Inbound soft reconfiguration not enabled"); + vty_out (vty, "%% Inbound soft reconfiguration not enabled\n"); return CMD_WARNING; } @@ -9812,14 +10009,14 @@ peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, DEFUN (show_ip_bgp_instance_neighbor_advertised_route, show_ip_bgp_instance_neighbor_advertised_route_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] " + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] " "neighbors <A.B.C.D|X:X::X:X|WORD> <received-routes|advertised-routes> [route-map WORD] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR - BGP_SAFI_HELP_STR + BGP_SAFI_WITH_LABEL_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -9914,9 +10111,9 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, if (! peer) { if (uj) - vty_outln (vty, "{}"); + vty_out (vty, "{}\n"); else - vty_outln (vty, "%% Malformed address or name: %s", peerstr); + vty_out (vty, "%% Malformed address or name: %s\n", peerstr); return CMD_WARNING; } } @@ -9926,9 +10123,9 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, if (! peer) { if (uj) - vty_outln (vty, "{}"); + vty_out (vty, "{}\n"); else - vty_outln (vty, "No peer"); + vty_out (vty, "No peer\n"); return CMD_WARNING; } } @@ -9938,15 +10135,15 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, if (count) { if (!uj) - vty_outln (vty, "Address Family: %s", afi_safi_print(afi, safi)); + vty_out (vty, "Address Family: %s\n", afi_safi_print(afi, safi)); prefix_bgp_show_prefix_list (vty, afi, name, uj); } else { if (uj) - vty_outln (vty, "{}"); + vty_out (vty, "{}\n"); else - vty_outln (vty, "No functional output"); + vty_out (vty, "No functional output\n"); } return CMD_SUCCESS; @@ -9963,27 +10160,31 @@ bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_outln (vty, "%s", json_object_to_json_string(json_no)); + vty_out (vty, "%s\n", json_object_to_json_string(json_no)); json_object_free(json_no); } else - vty_outln (vty, "%% No such neighbor or address family"); + vty_out (vty, "%% No such neighbor or address family\n"); return CMD_WARNING; } + /* labeled-unicast routes live in the unicast table */ + if (safi == SAFI_LABELED_UNICAST) + safi = SAFI_UNICAST; + return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su, use_json); } DEFUN (show_ip_bgp_neighbor_routes, show_ip_bgp_neighbor_routes_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] " + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] " "neighbors <A.B.C.D|X:X::X:X|WORD> <flap-statistics|dampened-routes|routes> [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR - BGP_SAFI_HELP_STR + BGP_SAFI_WITH_LABEL_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -10016,7 +10217,7 @@ DEFUN (show_ip_bgp_neighbor_routes, peer = peer_lookup_in_view (vty, bgp, peerstr, uj); if (! peer) { - vty_outln (vty, "No such neighbor"); + vty_out (vty, "No such neighbor\n"); return CMD_WARNING; } @@ -10063,7 +10264,7 @@ DEFUN (show_bgp_afi_vpn_rd_route, ret = str2prefix_rd (argv[5]->arg, &prd); if (! ret) { - vty_outln (vty, "%% Malformed Route Distinguisher"); + vty_out (vty, "%% Malformed Route Distinguisher\n"); return CMD_WARNING; } return bgp_show_route (vty, NULL, argv[6]->arg, afi, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); @@ -10099,8 +10300,8 @@ bgp_distance_set (struct vty *vty, const char *distance_str, ret = str2prefix (ip_str, &p); if (ret == 0) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } distance = atoi (distance_str); @@ -10151,15 +10352,15 @@ bgp_distance_unset (struct vty *vty, const char *distance_str, ret = str2prefix (ip_str, &p); if (ret == 0) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } rn = bgp_node_lookup (bgp_distance_table[afi][safi], (struct prefix *)&p); if (! rn) { - vty_outln (vty, "Can't find specified prefix"); - return CMD_WARNING; + vty_out (vty, "Can't find specified prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } bdistance = rn->info; @@ -10167,8 +10368,8 @@ bgp_distance_unset (struct vty *vty, const char *distance_str, if (bdistance->distance != distance) { - vty_outln (vty, "Distance does not match configured"); - return CMD_WARNING; + vty_out (vty, "Distance does not match configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (bdistance->access_list) @@ -10437,7 +10638,7 @@ DEFUN (bgp_damp_set, if (suppress < reuse) { - vty_outln (vty,"Suppress value cannot be less than reuse value "); + vty_out (vty,"Suppress value cannot be less than reuse value \n"); return 0; } @@ -10481,7 +10682,7 @@ bgp_clear_damp_route (struct vty *vty, const char *view_name, bgp = bgp_lookup_by_name (view_name); if (bgp == NULL) { - vty_outln (vty, "%% Can't find BGP instance %s", view_name); + vty_out (vty, "%% Can't find BGP instance %s\n", view_name); return CMD_WARNING; } } @@ -10490,7 +10691,7 @@ bgp_clear_damp_route (struct vty *vty, const char *view_name, bgp = bgp_get_default (); if (bgp == NULL) { - vty_outln (vty, "%% No BGP process is configured"); + vty_out (vty, "%% No BGP process is configured\n"); return CMD_WARNING; } } @@ -10499,7 +10700,7 @@ bgp_clear_damp_route (struct vty *vty, const char *view_name, ret = str2prefix (ip_str, &match); if (! ret) { - vty_outln (vty, "%% address is malformed"); + vty_out (vty, "%% address is malformed\n"); return CMD_WARNING; } @@ -10620,7 +10821,7 @@ DEFUN (clear_ip_bgp_dampening_address_mask, ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { - vty_outln (vty, "%% Inconsistent address and mask"); + vty_out (vty, "%% Inconsistent address and mask\n"); return CMD_WARNING; } @@ -10672,7 +10873,7 @@ bgp_config_write_network_vpn (struct vty *vty, struct bgp *bgp, if (bgp_static->backdoor) vty_out (vty, " backdoor"); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return 0; } @@ -10719,7 +10920,7 @@ bgp_config_write_network_evpn (struct vty *vty, struct bgp *bgp, vty_out (vty, " network %s rd %s ethtag %u tag %u esi %s gwip %s routermac %s", buf, rdbuf, p->u.prefix_evpn.eth_tag, decode_label (&bgp_static->label), esi, buf2 , macrouter); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); if (macrouter) XFREE (MTYPE_TMP, macrouter); if (esi) @@ -10794,7 +10995,7 @@ bgp_config_write_network (struct vty *vty, struct bgp *bgp, vty_out (vty, " backdoor"); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* Aggregate-address configuration. */ @@ -10828,7 +11029,7 @@ bgp_config_write_network (struct vty *vty, struct bgp *bgp, if (bgp_aggregate->summary_only) vty_out (vty, " summary-only"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return 0; @@ -10850,7 +11051,7 @@ bgp_config_write_distance (struct vty *vty, struct bgp *bgp, afi_t afi, || bgp->distance_local[afi][safi] != ZEBRA_IBGP_DISTANCE_DEFAULT)) { bgp_config_write_family_header (vty, afi, safi, write); - vty_outln (vty, " distance bgp %d %d %d", + vty_out (vty, " distance bgp %d %d %d\n", bgp->distance_ebgp[afi][safi], bgp->distance_ibgp[afi][safi], bgp->distance_local[afi][safi]); } @@ -10862,7 +11063,7 @@ bgp_config_write_distance (struct vty *vty, struct bgp *bgp, afi_t afi, char buf[PREFIX_STRLEN]; bgp_config_write_family_header (vty, afi, safi, write); - vty_outln (vty, " distance %d %s %s", bdistance->distance, + vty_out (vty, " distance %d %s %s\n", bdistance->distance, prefix2str (&rn->p, buf, sizeof (buf)), bdistance->access_list ? bdistance->access_list : ""); } diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 0c77cc1ee..907690381 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -53,10 +53,10 @@ enum bgp_show_type #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ - "h history, * valid, > best, = multipath,%s"\ - " i internal, r RIB-failure, S Stale, R Removed" -#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s" -#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path" + "h history, * valid, > best, = multipath,\n"\ + " i internal, r RIB-failure, S Stale, R Removed\n" +#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete\n\n" +#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path\n" /* Ancillary information to struct bgp_info, * used for uncommonly used data (aggregation, MPLS, etc.) @@ -99,6 +99,9 @@ struct bgp_info_extra } vnc; #endif + + /* For imported routes into a VNI (or VRF), this points to the parent. */ + void *parent; }; struct bgp_info @@ -174,6 +177,13 @@ struct bgp_info }; +/* Structure used in BGP path selection */ +struct bgp_info_pair +{ + struct bgp_info *old; + struct bgp_info *new; +}; + /* BGP static route configuration. */ struct bgp_static { @@ -222,8 +232,8 @@ struct bgp_static #define BGP_ATTR_NEXTHOP_AFI_IP6(attr) \ (! CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)) && \ - (attr)->extra && ((attr)->extra->mp_nexthop_len == 16 || \ - (attr)->extra->mp_nexthop_len == 32)) + ((attr)->mp_nexthop_len == 16 || \ + (attr)->mp_nexthop_len == 32)) #define BGP_INFO_COUNTABLE(BI) \ (! CHECK_FLAG ((BI)->flags, BGP_INFO_HISTORY) \ && ! CHECK_FLAG ((BI)->flags, BGP_INFO_REMOVED)) @@ -309,6 +319,7 @@ extern struct bgp_node *bgp_afi_node_get (struct bgp_table *table, afi_t afi, extern struct bgp_info *bgp_info_lock (struct bgp_info *); extern struct bgp_info *bgp_info_unlock (struct bgp_info *); extern void bgp_info_add (struct bgp_node *rn, struct bgp_info *ri); +extern void bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri); extern void bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri); extern struct bgp_info_extra *bgp_info_extra_get (struct bgp_info *); extern void bgp_info_set_flag (struct bgp_node *, struct bgp_info *, u_int32_t); @@ -372,6 +383,10 @@ extern u_char bgp_distance_apply (struct prefix *, struct bgp_info *, afi_t, saf extern afi_t bgp_node_afi (struct vty *); extern safi_t bgp_node_safi (struct vty *); +extern struct bgp_info * +info_make (int type, int sub_type, u_short instance, struct peer *peer, + struct attr *attr, struct bgp_node *rn); + extern void route_vty_out (struct vty *, struct prefix *, struct bgp_info *, int, safi_t, json_object *); extern void route_vty_out_tag (struct vty *, struct prefix *, struct bgp_info *, int, safi_t, json_object *); extern void route_vty_out_tmp (struct vty *, struct prefix *, struct attr *, safi_t, u_char, json_object *); @@ -396,10 +411,32 @@ extern void bgp_process_queues_drain_immediate (void); extern struct bgp_node * bgp_afi_node_get (struct bgp_table *, afi_t , safi_t , struct prefix *, struct prefix_rd *); +extern struct bgp_node * +bgp_afi_node_lookup (struct bgp_table *table, afi_t afi, safi_t safi, + struct prefix *p, struct prefix_rd *prd); extern struct bgp_info *bgp_info_new (void); extern void bgp_info_restore (struct bgp_node *, struct bgp_info *); -extern int bgp_info_cmp_compatible (struct bgp *, struct bgp_info *, - struct bgp_info *, afi_t, safi_t ); +extern int +bgp_info_cmp_compatible (struct bgp *, struct bgp_info *, struct bgp_info *, + char *pfx_buf, afi_t afi, safi_t safi); + +extern void +bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, + struct bgp_maxpaths_cfg *mpath_cfg, + struct bgp_info_pair *result, + afi_t afi, safi_t safi); +extern void bgp_zebra_clear_route_change_flags (struct bgp_node *rn); +extern int +bgp_zebra_has_route_changed (struct bgp_node *rn, struct bgp_info *selected); +extern void +route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, + struct bgp_node *rn, + struct prefix_rd *prd, afi_t afi, safi_t safi, + json_object *json); +extern void +route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, + struct bgp_info *binfo, afi_t afi, safi_t safi, + json_object *json_paths); #endif /* _QUAGGA_BGP_ROUTE_H */ diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index f2c94371a..b53c112d9 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -868,8 +868,7 @@ route_match_lcommunity (void *rule, struct prefix *prefix, if (! list) return RMAP_NOMATCH; - if (bgp_info->attr->extra && - lcommunity_list_match (bgp_info->attr->extra->lcommunity, list)) + if (lcommunity_list_match (bgp_info->attr->lcommunity, list)) return RMAP_MATCH; } @@ -933,15 +932,12 @@ route_match_ecommunity (void *rule, struct prefix *prefix, { bgp_info = object; - if (!bgp_info->attr->extra) - return RMAP_NOMATCH; - list = community_list_lookup (bgp_clist, (char *) rule, EXTCOMMUNITY_LIST_MASTER); if (! list) return RMAP_NOMATCH; - if (ecommunity_list_match (bgp_info->attr->extra->ecommunity, list)) + if (ecommunity_list_match (bgp_info->attr->ecommunity, list)) return RMAP_MATCH; } return RMAP_NOMATCH; @@ -1149,10 +1145,7 @@ route_match_tag (void *rule, struct prefix *prefix, tag = rule; bgp_info = object; - if (!bgp_info->attr->extra) - return RMAP_NOMATCH; - - return ((bgp_info->attr->extra->tag == *tag)? RMAP_MATCH : RMAP_NOMATCH); + return ((bgp_info->attr->tag == *tag)? RMAP_MATCH : RMAP_NOMATCH); } return RMAP_NOMATCH; @@ -1332,7 +1325,6 @@ route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type, { struct rmap_value *rv; struct bgp_info *bgp_info; - u_int32_t weight; if (type == RMAP_BGP) { @@ -1341,11 +1333,7 @@ route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type, bgp_info = object; /* Set weight value. */ - weight = route_value_adjust(rv, 0, bgp_info->peer); - if (weight) - (bgp_attr_extra_get (bgp_info->attr))->weight = weight; - else if (bgp_info->attr->extra) - bgp_info->attr->extra->weight = 0; + bgp_info->attr->weight = route_value_adjust(rv, 0, bgp_info->peer); } return RMAP_OKAY; @@ -1644,14 +1632,13 @@ route_set_lcommunity (void *rule, struct prefix *prefix, rcs = rule; binfo = object; attr = binfo->attr; - old = (attr->extra) ? attr->extra->lcommunity : NULL; + old = attr->lcommunity; /* "none" case. */ if (rcs->none) { attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES)); - if (attr->extra) - attr->extra->lcommunity = NULL; + attr->lcommunity = NULL; /* See the longer comment down below. */ if (old && old->refcnt == 0) @@ -1676,7 +1663,7 @@ route_set_lcommunity (void *rule, struct prefix *prefix, new = lcommunity_dup (rcs->lcom); /* will be intern()'d or attr_flush()'d by bgp_update_main() */ - (bgp_attr_extra_get (attr))->lcommunity = new; + attr->lcommunity = new; attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES); } @@ -1766,7 +1753,7 @@ route_set_lcommunity_delete (void *rule, struct prefix *prefix, binfo = object; list = community_list_lookup (bgp_clist, rule, LARGE_COMMUNITY_LIST_MASTER); - old = ((binfo->attr->extra) ? binfo->attr->extra->lcommunity : NULL); + old = binfo->attr->lcommunity; if (list && old) { @@ -1783,13 +1770,13 @@ route_set_lcommunity_delete (void *rule, struct prefix *prefix, if (new->size == 0) { - binfo->attr->extra->lcommunity = NULL; + binfo->attr->lcommunity = NULL; binfo->attr->flag &= ~ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES); lcommunity_free (&new); } else { - binfo->attr->extra->lcommunity = new; + binfo->attr->lcommunity = new; binfo->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES); } } @@ -1946,7 +1933,7 @@ route_set_ecommunity (void *rule, struct prefix *prefix, return RMAP_OKAY; /* We assume additive for Extended Community. */ - old_ecom = (bgp_attr_extra_get (bgp_info->attr))->ecommunity; + old_ecom = bgp_info->attr->ecommunity; if (old_ecom) { @@ -1961,7 +1948,7 @@ route_set_ecommunity (void *rule, struct prefix *prefix, new_ecom = ecommunity_dup (ecom); /* will be intern()'d or attr_flush()'d by bgp_update_main() */ - bgp_info->attr->extra->ecommunity = new_ecom; + bgp_info->attr->ecommunity = new_ecom; bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES); } @@ -2129,16 +2116,14 @@ route_set_aggregator_as (void *rule, struct prefix *prefix, { struct bgp_info *bgp_info; struct aggregator *aggregator; - struct attr_extra *ae; if (type == RMAP_BGP) { bgp_info = object; aggregator = rule; - ae = bgp_attr_extra_get (bgp_info->attr); - ae->aggregator_as = aggregator->as; - ae->aggregator_addr = aggregator->address; + bgp_info->attr->aggregator_as = aggregator->as; + bgp_info->attr->aggregator_addr = aggregator->address; bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR); } @@ -2187,16 +2172,14 @@ route_set_tag (void *rule, struct prefix *prefix, { route_tag_t *tag; struct bgp_info *bgp_info; - struct attr_extra *ae; if (type == RMAP_BGP) { tag = rule; bgp_info = object; - ae = bgp_attr_extra_get (bgp_info->attr); /* Set tag value */ - ae->tag=*tag; + bgp_info->attr->tag=*tag; } @@ -2231,7 +2214,7 @@ route_set_label_index (void *rule, struct prefix *prefix, label_index = rv->value; if (label_index) { - (bgp_attr_extra_get (bgp_info->attr))->label_index = label_index; + bgp_info->attr->label_index = label_index; bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID); } } @@ -2302,14 +2285,11 @@ route_match_ipv6_next_hop (void *rule, struct prefix *prefix, { bgp_info = object; - if (!bgp_info->attr->extra) - return RMAP_NOMATCH; - - if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, addr)) + if (IPV6_ADDR_SAME (&bgp_info->attr->mp_nexthop_global, addr)) return RMAP_MATCH; - if (bgp_info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL && - IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_local, rule)) + if (bgp_info->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL && + IPV6_ADDR_SAME (&bgp_info->attr->mp_nexthop_local, rule)) return RMAP_MATCH; return RMAP_NOMATCH; @@ -2407,11 +2387,11 @@ route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix, bgp_info = object; /* Set next hop value. */ - (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = *address; + bgp_info->attr->mp_nexthop_global = *address; /* Set nexthop length. */ - if (bgp_info->attr->extra->mp_nexthop_len == 0) - bgp_info->attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; + if (bgp_info->attr->mp_nexthop_len == 0) + bgp_info->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; SET_FLAG(bgp_info->attr->rmap_change_flags, BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED); @@ -2477,13 +2457,13 @@ route_set_ipv6_nexthop_prefer_global (void *rule, struct prefix *prefix, && sockunion_family (peer->su_remote) == AF_INET6) { /* Set next hop preference to global */ - bgp_info->attr->extra->mp_nexthop_prefer_global = TRUE; + bgp_info->attr->mp_nexthop_prefer_global = TRUE; SET_FLAG(bgp_info->attr->rmap_change_flags, BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED); } else { - bgp_info->attr->extra->mp_nexthop_prefer_global = FALSE; + bgp_info->attr->mp_nexthop_prefer_global = FALSE; SET_FLAG(bgp_info->attr->rmap_change_flags, BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED); } @@ -2535,11 +2515,11 @@ route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, bgp_info = object; /* Set next hop value. */ - (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = *address; + bgp_info->attr->mp_nexthop_local = *address; /* Set nexthop length. */ - if (bgp_info->attr->extra->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) - bgp_info->attr->extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; + if (bgp_info->attr->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + bgp_info->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; SET_FLAG(bgp_info->attr->rmap_change_flags, BATTR_RMAP_IPV6_LL_NHOP_CHANGED); @@ -2611,15 +2591,15 @@ route_set_ipv6_nexthop_peer (void *rule, struct prefix *prefix, /* Set next hop value and length in attribute. */ if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) { - (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = peer_address; - if (bgp_info->attr->extra->mp_nexthop_len != 32) - bgp_info->attr->extra->mp_nexthop_len = 32; + bgp_info->attr->mp_nexthop_local = peer_address; + if (bgp_info->attr->mp_nexthop_len != 32) + bgp_info->attr->mp_nexthop_len = 32; } else { - (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = peer_address; - if (bgp_info->attr->extra->mp_nexthop_len == 0) - bgp_info->attr->extra->mp_nexthop_len = 16; + bgp_info->attr->mp_nexthop_global = peer_address; + if (bgp_info->attr->mp_nexthop_len == 0) + bgp_info->attr->mp_nexthop_len = 16; } } @@ -2633,9 +2613,9 @@ route_set_ipv6_nexthop_peer (void *rule, struct prefix *prefix, SET_FLAG(bgp_info->attr->rmap_change_flags, BATTR_RMAP_NEXTHOP_PEER_ADDRESS); /* clear next hop value. */ - memset (&((bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global), + memset (&(bgp_info->attr->mp_nexthop_global), 0, sizeof (struct in6_addr)); - memset (&((bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local), + memset (&(bgp_info->attr->mp_nexthop_local), 0, sizeof (struct in6_addr)); } } @@ -2688,8 +2668,8 @@ route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, bgp_info = object; /* Set next hop value. */ - (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global_in = *address; - (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_len = 4; + bgp_info->attr->mp_nexthop_global_in = *address; + bgp_info->attr->mp_nexthop_len = 4; } return RMAP_OKAY; @@ -2730,8 +2710,8 @@ route_set_vpnv6_nexthop (void *rule, struct prefix *prefix, bgp_info = object; /* Set next hop value. */ - memcpy (&(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global, address, sizeof(struct in6_addr)); - (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL; + memcpy (&bgp_info->attr->mp_nexthop_global, address, sizeof(struct in6_addr)); + bgp_info->attr->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL; } return RMAP_OKAY; @@ -2794,7 +2774,7 @@ route_set_originator_id (void *rule, struct prefix *prefix, route_map_object_t t bgp_info = object; bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID); - (bgp_attr_extra_get (bgp_info->attr))->originator_id = *address; + bgp_info->attr->originator_id = *address; } return RMAP_OKAY; @@ -2851,11 +2831,11 @@ bgp_route_match_add (struct vty *vty, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% BGP Can't find rule."); - return CMD_WARNING; + vty_out (vty, "%% BGP Can't find rule.\n"); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% BGP Argument is malformed."); - return CMD_WARNING; + vty_out (vty, "%% BGP Argument is malformed.\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -2900,17 +2880,17 @@ bgp_route_match_delete (struct vty *vty, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% BGP Can't find rule."); + vty_out (vty, "%% BGP Can't find rule.\n"); break; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% BGP Argument is malformed."); + vty_out (vty, "%% BGP Argument is malformed.\n"); break; } if (dep_name) XFREE(MTYPE_ROUTE_MAP_RULE, dep_name); if (rmap_name) XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (type != RMAP_EVENT_MATCH_DELETED && dep_name) @@ -3112,6 +3092,9 @@ bgp_route_map_process_update (struct bgp *bgp, const char *rmap_name, int route_ for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { /* For table route-map updates. */ + if (!bgp_fibupd_safi(safi)) + continue; + if (bgp->table_map[afi][safi].name && (strcmp(rmap_name, bgp->table_map[afi][safi].name) == 0)) { @@ -3592,7 +3575,8 @@ DEFUN (match_origin, return bgp_route_match_add (vty, "origin", "incomplete", RMAP_EVENT_MATCH_ADDED); - return CMD_WARNING; + vty_out (vty, "%% Invalid match origin type\n"); + return CMD_WARNING_CONFIG_FAILED; } @@ -3886,8 +3870,8 @@ DEFUN (set_community, /* Can't compile user input into communities attribute. */ if (! com) { - vty_outln (vty, "%% Malformed communities attribute"); - return CMD_WARNING; + vty_out (vty, "%% Malformed communities attribute\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Set communites attribute string. */ @@ -4152,7 +4136,8 @@ DEFUN (set_origin, return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), "origin", "incomplete"); - return CMD_WARNING; + vty_out (vty, "%% Invalid set origin type\n"); + return CMD_WARNING_CONFIG_FAILED; } @@ -4210,8 +4195,8 @@ DEFUN (set_aggregator_as, ret = inet_aton (argv[idx_ipv4]->arg, &address); if (ret == 0) { - vty_outln (vty, "Aggregator IP address is invalid"); - return CMD_WARNING; + vty_out (vty, "Aggregator IP address is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, @@ -4251,8 +4236,8 @@ DEFUN (no_set_aggregator_as, ret = inet_aton (argv[idx_ip]->arg, &address); if (ret == 0) { - vty_outln (vty, "Aggregator IP address is invalid"); - return CMD_WARNING; + vty_out (vty, "Aggregator IP address is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, @@ -4362,16 +4347,16 @@ DEFUN (set_ipv6_nexthop_global, ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr); if (!ret) { - vty_outln (vty, "%% Malformed nexthop address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed nexthop address\n"); + return CMD_WARNING_CONFIG_FAILED; } if (IN6_IS_ADDR_UNSPECIFIED(&addr) || IN6_IS_ADDR_LOOPBACK(&addr) || IN6_IS_ADDR_MULTICAST(&addr) || IN6_IS_ADDR_LINKLOCAL(&addr)) { - vty_outln (vty, "%% Invalid global nexthop address"); - return CMD_WARNING; + vty_out (vty, "%% Invalid global nexthop address\n"); + return CMD_WARNING_CONFIG_FAILED; } return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), @@ -4400,12 +4385,13 @@ DEFUN (no_set_ipv6_nexthop_global, #ifdef KEEP_OLD_VPN_COMMANDS DEFUN (set_vpn_nexthop, set_vpn_nexthop_cmd, - "set <vpnv4|vpnv6> next-hop <A.B.C.D|X:X::X:X>", + "set <vpnv4 next-hop A.B.C.D|vpnv6 next-hop X:X::X:X>", SET_STR "VPNv4 information\n" - "VPNv6 information\n" "VPN next-hop address\n" "IP address of next hop\n" + "VPNv6 information\n" + "VPN next-hop address\n" "IPv6 address of next hop\n") { int idx_ip = 3; @@ -4426,12 +4412,14 @@ DEFUN (set_vpn_nexthop, DEFUN (no_set_vpn_nexthop, no_set_vpn_nexthop_cmd, - "no set vpn next-hop <A.B.C.D|X:X::X:X>", + "no set <vpnv4 next-hop A.B.C.D|vpnv6 next-hop X:X::X:X>", NO_STR SET_STR - "VPN information\n" + "VPNv4 information\n" "VPN next-hop address\n" "IP address of next hop\n" + "VPNv6 information\n" + "VPN next-hop address\n" "IPv6 address of next hop\n") { int idx_ip = 4; diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index db69400a6..c1a6ad589 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -802,16 +802,10 @@ bgp4PathAttrTable (struct variable *v, oid name[], size_t *length, return SNMP_INTEGER (1); break; case BGP4PATHATTRAGGREGATORAS: /* 10 */ - if (binfo->attr->extra) - return SNMP_INTEGER (binfo->attr->extra->aggregator_as); - else - return SNMP_INTEGER (0); + return SNMP_INTEGER (binfo->attr->aggregator_as); break; case BGP4PATHATTRAGGREGATORADDR: /* 11 */ - if (binfo->attr->extra) - return SNMP_IPADDRESS (binfo->attr->extra->aggregator_addr); - else - return SNMP_INTEGER (0); + return SNMP_IPADDRESS (binfo->attr->aggregator_addr); break; case BGP4PATHATTRCALCLOCALPREF: /* 12 */ return SNMP_INTEGER (-1); diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 722eed91c..b8971dcd6 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -564,17 +564,17 @@ update_group_show_walkcb (struct update_group *updgrp, void *arg) vty = ctx->vty; - vty_outln (vty, "Update-group %" PRIu64 ":", updgrp->id); + vty_out (vty, "Update-group %" PRIu64 ":\n", updgrp->id); vty_out (vty, " Created: %s", timestamp_string (updgrp->uptime)); filter = &updgrp->conf->filter[updgrp->afi][updgrp->safi]; if (filter->map[RMAP_OUT].name) - vty_outln (vty, " Outgoing route map: %s%s", + vty_out (vty, " Outgoing route map: %s%s\n", filter->map[RMAP_OUT].map ? "X" : "", filter->map[RMAP_OUT].name); - vty_outln (vty, " MRAI value (seconds): %d", + vty_out (vty, " MRAI value (seconds): %d\n", updgrp->conf->v_routeadv); if (updgrp->conf->change_local_as) - vty_outln (vty, " Local AS %u%s%s", + vty_out (vty, " Local AS %u%s%s\n", updgrp->conf->change_local_as, CHECK_FLAG (updgrp->conf->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? " no-prepend" : "", @@ -584,49 +584,49 @@ update_group_show_walkcb (struct update_group *updgrp, void *arg) { if (ctx->subgrp_id && (ctx->subgrp_id != subgrp->id)) continue; - vty_out (vty, VTYNL); - vty_outln (vty, " Update-subgroup %" PRIu64 ":", subgrp->id); + vty_out (vty, "\n"); + vty_out (vty, " Update-subgroup %" PRIu64 ":\n", subgrp->id); vty_out (vty, " Created: %s", timestamp_string (subgrp->uptime)); if (subgrp->split_from.update_group_id || subgrp->split_from.subgroup_id) { - vty_outln (vty, " Split from group id: %" PRIu64 "", + vty_out (vty, " Split from group id: %" PRIu64 "\n", subgrp->split_from.update_group_id); - vty_outln (vty, " Split from subgroup id: %" PRIu64 "", + vty_out (vty, " Split from subgroup id: %" PRIu64 "\n", subgrp->split_from.subgroup_id); } - vty_outln (vty, " Join events: %u", subgrp->join_events); - vty_outln (vty, " Prune events: %u", + vty_out (vty, " Join events: %u\n", subgrp->join_events); + vty_out (vty, " Prune events: %u\n", subgrp->prune_events); - vty_outln (vty, " Merge events: %u", + vty_out (vty, " Merge events: %u\n", subgrp->merge_events); - vty_outln (vty, " Split events: %u", + vty_out (vty, " Split events: %u\n", subgrp->split_events); - vty_outln (vty, " Update group switch events: %u", + vty_out (vty, " Update group switch events: %u\n", subgrp->updgrp_switch_events); - vty_outln (vty, " Peer refreshes combined: %u", + vty_out (vty, " Peer refreshes combined: %u\n", subgrp->peer_refreshes_combined); - vty_outln (vty, " Merge checks triggered: %u", + vty_out (vty, " Merge checks triggered: %u\n", subgrp->merge_checks_triggered); - vty_outln (vty, " Version: %" PRIu64 "", subgrp->version); - vty_outln (vty, " Packet queue length: %d", + vty_out (vty, " Version: %" PRIu64 "\n", subgrp->version); + vty_out (vty, " Packet queue length: %d\n", bpacket_queue_length(SUBGRP_PKTQ(subgrp))); - vty_outln (vty, " Total packets enqueued: %u", + vty_out (vty, " Total packets enqueued: %u\n", subgroup_total_packets_enqueued(subgrp)); - vty_outln (vty, " Packet queue high watermark: %d", + vty_out (vty, " Packet queue high watermark: %d\n", bpacket_queue_hwm_length(SUBGRP_PKTQ(subgrp))); - vty_outln (vty, " Adj-out list count: %u", + vty_out (vty, " Adj-out list count: %u\n", subgrp->adj_count); - vty_outln (vty, " Advertise list: %s", + vty_out (vty, " Advertise list: %s\n", advertise_list_is_empty(subgrp) ? "empty" : "not empty"); - vty_outln (vty, " Flags: %s", + vty_out (vty, " Flags: %s\n", CHECK_FLAG(subgrp->flags, SUBGRP_FLAG_NEEDS_REFRESH) ? "R" : ""); if (subgrp->peer_count > 0) { - vty_outln (vty, " Peers:"); + vty_out (vty, " Peers:\n"); SUBGRP_FOREACH_PEER (subgrp, paf) - vty_outln (vty, " - %s", paf->peer->host); + vty_out (vty, " - %s\n", paf->peer->host); } } return UPDWALK_CONTINUE; @@ -648,7 +648,7 @@ updgrp_show_packet_queue_walkcb (struct update_group *updgrp, void *arg) { if (ctx->subgrp_id && (ctx->subgrp_id != subgrp->id)) continue; - vty_outln (vty, "update group %" PRIu64 ", subgroup %" PRIu64 "", updgrp->id, + vty_out (vty, "update group %" PRIu64 ", subgroup %" PRIu64 "\n", updgrp->id, subgrp->id); bpacket_queue_show_vty (SUBGRP_PKTQ (subgrp), vty); } @@ -1597,27 +1597,27 @@ update_group_show (struct bgp *bgp, afi_t afi, safi_t safi, struct vty *vty, void update_group_show_stats (struct bgp *bgp, struct vty *vty) { - vty_outln (vty, "Update groups created: %u", + vty_out (vty, "Update groups created: %u\n", bgp->update_group_stats.updgrps_created); - vty_outln (vty, "Update groups deleted: %u", + vty_out (vty, "Update groups deleted: %u\n", bgp->update_group_stats.updgrps_deleted); - vty_outln (vty, "Update subgroups created: %u", + vty_out (vty, "Update subgroups created: %u\n", bgp->update_group_stats.subgrps_created); - vty_outln (vty, "Update subgroups deleted: %u", + vty_out (vty, "Update subgroups deleted: %u\n", bgp->update_group_stats.subgrps_deleted); - vty_outln (vty, "Join events: %u", + vty_out (vty, "Join events: %u\n", bgp->update_group_stats.join_events); - vty_outln (vty, "Prune events: %u", + vty_out (vty, "Prune events: %u\n", bgp->update_group_stats.prune_events); - vty_outln (vty, "Merge events: %u", + vty_out (vty, "Merge events: %u\n", bgp->update_group_stats.merge_events); - vty_outln (vty, "Split events: %u", + vty_out (vty, "Split events: %u\n", bgp->update_group_stats.split_events); - vty_outln (vty, "Update group switch events: %u", + vty_out (vty, "Update group switch events: %u\n", bgp->update_group_stats.updgrp_switch_events); - vty_outln (vty, "Peer route refreshes combined: %u", + vty_out (vty, "Peer route refreshes combined: %u\n", bgp->update_group_stats.peer_refreshes_combined); - vty_outln (vty, "Merge checks triggered: %u", + vty_out (vty, "Merge checks triggered: %u\n", bgp->update_group_stats.merge_checks_triggered); } diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index c4cb8ae1b..5019830c0 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -226,16 +226,16 @@ subgrp_show_adjq_vty (struct update_subgroup *subgrp, struct vty *vty, { if (header1) { - vty_outln (vty, - "BGP table version is %" PRIu64 ", local router ID is %s", + vty_out (vty, + "BGP table version is %" PRIu64 ", local router ID is %s\n", table->version,inet_ntoa(bgp->router_id)); - vty_outln (vty, BGP_SHOW_SCODE_HEADER, VTYNL); - vty_outln (vty, BGP_SHOW_OCODE_HEADER, VTYNL); + vty_out (vty, BGP_SHOW_SCODE_HEADER); + vty_out (vty, BGP_SHOW_OCODE_HEADER); header1 = 0; } if (header2) { - vty_outln (vty, BGP_SHOW_HEADER); + vty_out (vty, BGP_SHOW_HEADER); header2 = 0; } if ((flags & UPDWALK_FLAGS_ADVQUEUE) && adj->adv && adj->adv->baa) @@ -250,8 +250,7 @@ subgrp_show_adjq_vty (struct update_subgroup *subgrp, struct vty *vty, } } if (output_count != 0) - vty_outln (vty, "%sTotal number of prefixes %ld", - VTYNL, output_count); + vty_out (vty, "\nTotal number of prefixes %ld\n", output_count); } static int @@ -266,7 +265,7 @@ updgrp_show_adj_walkcb (struct update_group *updgrp, void *arg) { if (ctx->subgrp_id && (ctx->subgrp_id != subgrp->id)) continue; - vty_outln (vty, "update group %" PRIu64 ", subgroup %" PRIu64 "", updgrp->id, + vty_out (vty, "update group %" PRIu64 ", subgroup %" PRIu64 "\n", updgrp->id, subgrp->id); subgrp_show_adjq_vty (subgrp, vty, ctx->flags); } @@ -587,7 +586,6 @@ subgroup_announce_table (struct update_subgroup *subgrp, struct bgp_node *rn; struct bgp_info *ri; struct attr attr; - struct attr_extra extra; struct peer *peer; afi_t afi; safi_t safi; @@ -610,9 +608,6 @@ subgroup_announce_table (struct update_subgroup *subgrp, && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) subgroup_default_originate (subgrp, 0); - /* It's initialized in bgp_announce_check() */ - attr.extra = &extra; - for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) for (ri = rn->info; ri; ri = ri->next) @@ -716,18 +711,16 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw) str2prefix ("0.0.0.0/0", &p); else if (afi == AFI_IP6) { - struct attr_extra *ae = attr.extra; - str2prefix ("::/0", &p); /* IPv6 global nexthop must be included. */ - ae->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; + attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; /* If the peer is on shared nextwork and we have link-local nexthop set it. */ if (peer->shared_network && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) - ae->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; + attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; } if (peer->default_rmap[afi][safi].name) @@ -739,11 +732,9 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw) for (ri = rn->info; ri; ri = ri->next) { struct attr dummy_attr; - struct attr_extra dummy_extra; struct bgp_info info; /* Provide dummy so the route-map can't modify the attributes */ - dummy_attr.extra = &dummy_extra; bgp_attr_dup (&dummy_attr, ri->attr); info.peer = ri->peer; info.attr = &dummy_attr; @@ -794,7 +785,6 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw) } } - bgp_attr_extra_free (&attr); aspath_unintern (&aspath); } diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index dff46a946..0ef4d4c0c 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -392,12 +392,12 @@ bpacket_queue_show_vty (struct bpacket_queue *q, struct vty *vty) pkt = bpacket_queue_first (q); while (pkt) { - vty_outln (vty, " Packet %p ver %u buffer %p", pkt, pkt->ver, + vty_out (vty, " Packet %p ver %u buffer %p\n", pkt, pkt->ver, pkt->buffer); LIST_FOREACH (paf, &(pkt->peers), pkt_train) { - vty_outln (vty, " - %s", paf->peer->host); + vty_out (vty, " - %s\n", paf->peer->host); } pkt = bpacket_next (pkt); } @@ -423,12 +423,10 @@ bpacket_reformat_for_peer (struct bpacket *pkt, struct peer_af *paf) afi_t nhafi = AFI_MAX; /* NH AFI is based on nhlen! */ int route_map_sets_nh; nhlen = stream_getc_from (s, vec->offset); - if (paf->afi == AFI_IP || paf->afi == AFI_IP6) - { - nhafi = BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen); - if (peer_cap_enhe(peer, paf->afi, paf->safi)) - nhafi = AFI_IP6; - } + if (peer_cap_enhe(peer, paf->afi, paf->safi)) + nhafi = AFI_IP6; + else + nhafi = BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen); if (nhafi == AFI_IP) { @@ -484,6 +482,7 @@ bpacket_reformat_for_peer (struct bpacket *pkt, struct peer_af *paf) nh_modified = 1; } else if (peer->sort == BGP_PEER_EBGP && + paf->safi != SAFI_EVPN && (bgp_multiaccess_check_v4 (v4nh, peer) == 0) && !CHECK_FLAG(vec->flags, BPKT_ATTRVEC_FLAGS_RMAP_NH_UNCHANGED) && @@ -609,6 +608,30 @@ bpacket_reformat_for_peer (struct bpacket *pkt, struct peer_af *paf) (nhlen == 24 ? " and RD" : "")); } } + else if (paf->afi == AFI_L2VPN) + { + struct in_addr v4nh, *mod_v4nh; + int nh_modified = 0; + + stream_get_from (&v4nh, s, vec->offset + 1, 4); + mod_v4nh = &v4nh; + + /* No route-map changes allowed for EVPN nexthops. */ + if (!v4nh.s_addr) + { + mod_v4nh = &peer->nexthop.v4; + nh_modified = 1; + } + + if (nh_modified) + stream_put_in_addr_at (s, vec->offset + 1, mod_v4nh); + + if (bgp_debug_update(peer, NULL, NULL, 0)) + zlog_debug ("u%" PRIu64 ":s%" PRIu64 " %s send UPDATE w/ nexthop %s", + PAF_SUBGRP(paf)->update_group->id, PAF_SUBGRP(paf)->id, + peer->host, inet_ntoa (*mod_v4nh)); + + } } bgp_packet_add (peer, s); @@ -681,7 +704,7 @@ subgroup_update_packet (struct update_subgroup *subgrp) int addpath_encode = 0; u_int32_t addpath_tx_id = 0; struct prefix_rd *prd = NULL; - char label_buf[20]; + mpls_label_t label = MPLS_INVALID_LABEL; if (!subgrp) return NULL; @@ -696,7 +719,6 @@ subgroup_update_packet (struct update_subgroup *subgrp) stream_reset (s); snlri = subgrp->scratch; stream_reset (snlri); - label_buf[0] = '\0'; bpacket_attr_vec_arr_reset (&vecarr); @@ -785,8 +807,6 @@ subgroup_update_packet (struct update_subgroup *subgrp) else { /* Encode the prefix in MP_REACH_NLRI attribute */ - mpls_label_t label = MPLS_INVALID_LABEL; - if (rn->prn) prd = (struct prefix_rd *) &rn->prn->p; @@ -796,9 +816,6 @@ subgroup_update_packet (struct update_subgroup *subgrp) if (binfo && binfo->extra) label = binfo->extra->label; - if (bgp_labeled_safi(safi)) - sprintf (label_buf, "label %u", label_pton(&label)); - if (stream_empty (snlri)) mpattrlen_pos = bgp_packet_mpattr_start (snlri, peer, afi, safi, &vecarr, adv->baa->attr); @@ -831,12 +848,11 @@ subgroup_update_packet (struct update_subgroup *subgrp) send_attr_printed = 1; } - zlog_debug ("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s %s", - subgrp->update_group->id, subgrp->id, - bgp_debug_rdpfxpath2str (prd, &rn->p, addpath_encode, - addpath_tx_id, - pfx_buf, sizeof (pfx_buf)), - label_buf); + bgp_debug_rdpfxpath2str (afi, safi, prd, &rn->p, &label, + addpath_encode, addpath_tx_id, + pfx_buf, sizeof (pfx_buf)); + zlog_debug ("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s", + subgrp->update_group->id, subgrp->id, pfx_buf); } /* Synchnorize attribute. */ @@ -989,11 +1005,11 @@ subgroup_withdraw_packet (struct update_subgroup *subgrp) { char pfx_buf[BGP_PRD_PATH_STRLEN]; + bgp_debug_rdpfxpath2str (afi, safi, prd, &rn->p, NULL, + addpath_encode, addpath_tx_id, + pfx_buf, sizeof (pfx_buf)); zlog_debug ("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s -- unreachable", - subgrp->update_group->id, subgrp->id, - bgp_debug_rdpfxpath2str (prd, &rn->p, - addpath_encode, addpath_tx_id, - pfx_buf, sizeof (pfx_buf))); + subgrp->update_group->id, subgrp->id, pfx_buf); } subgrp->scount--; diff --git a/bgpd/bgp_vpn.c b/bgpd/bgp_vpn.c index 3e6224395..c7f8ae3c0 100644 --- a/bgpd/bgp_vpn.c +++ b/bgpd/bgp_vpn.c @@ -51,7 +51,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, if (bgp == NULL) { if (!use_json) - vty_outln (vty, "No BGP process is configured"); + vty_out (vty, "No BGP process is configured\n"); return CMD_WARNING; } @@ -104,13 +104,12 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, } else { - vty_outln (vty, "BGP table version is 0, local router ID is %s", + vty_out (vty, "BGP table version is 0, local router ID is %s\n", inet_ntoa(bgp->router_id)); - vty_outln (vty, - "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal"); - vty_outln (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s", - VTYNL); - vty_outln (vty, V4_HEADER); + vty_out (vty, + "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n"); + vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete\n\n"); + vty_out (vty, V4_HEADER); } header = 0; } @@ -170,7 +169,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, rd_vnc_eth.macaddr.octet[5]); #endif - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } rd_header = 0; } @@ -191,7 +190,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, if (use_json) { json_object_object_add(json, "routes", json_routes); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 710aa926a..9d0f6b44d 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -308,7 +308,7 @@ bgp_vty_find_and_parse_afi_safi_bgp (struct vty *vty, struct cmd_token **argv, i *bgp = bgp_lookup_by_name (vrf_name); if (!*bgp) { - vty_out (vty, "View/Vrf specified is unknown: %s%s", vrf_name, VTYNL); + vty_out (vty, "View/Vrf specified is unknown: %s\n", vrf_name); *idx = 0; return 0; } @@ -319,7 +319,7 @@ bgp_vty_find_and_parse_afi_safi_bgp (struct vty *vty, struct cmd_token **argv, i *bgp = bgp_get_default (); if (!*bgp) { - vty_out (vty, "Unable to find default BGP instance%s", VTYNL); + vty_out (vty, "Unable to find default BGP instance\n"); *idx = 0; return 0; } @@ -373,7 +373,7 @@ peer_lookup_vty (struct vty *vty, const char *ip_str) { if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) { - vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTYNL); + vty_out (vty, "%% Malformed address or name: %s\n", ip_str); return NULL; } } @@ -383,14 +383,12 @@ peer_lookup_vty (struct vty *vty, const char *ip_str) peer = peer_lookup (bgp, &su); if (! peer) { - vty_out (vty, "%% Specify remote-as or peer-group commands first%s", - VTYNL); + vty_out (vty, "%% Specify remote-as or peer-group commands first\n"); return NULL; } if (peer_dynamic_neighbor (peer)) { - vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", - VTYNL); + vty_out (vty, "%% Operation not allowed on a dynamic neighbor\n"); return NULL; } @@ -433,8 +431,7 @@ peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) { if (peer_dynamic_neighbor (peer)) { - vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", - VTYNL); + vty_out (vty, "%% Operation not allowed on a dynamic neighbor\n"); return NULL; } @@ -444,8 +441,7 @@ peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) if (group) return group->conf; - vty_out (vty, "%% Specify remote-as or peer-group commands first%s", - VTYNL); + vty_out (vty, "%% Specify remote-as or peer-group commands first\n"); return NULL; } @@ -523,8 +519,8 @@ bgp_vty_return (struct vty *vty, int ret) } if (str) { - vty_out (vty, "%% %s%s", str, VTYNL); - return CMD_WARNING; + vty_out (vty, "%% %s\n", str); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -547,11 +543,11 @@ bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, { case BGP_ERR_AF_UNCONFIGURED: vty_out (vty, - "%%BGP: Enable %s address family for the neighbor %s%s", - afi_safi_print(afi, safi), peer->host, VTYNL); + "%%BGP: Enable %s address family for the neighbor %s\n", + afi_safi_print(afi, safi), peer->host); break; case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: - vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer->host, VTYNL, VTYNL); + vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", peer->host); break; default: break; @@ -610,7 +606,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, peer = peer_lookup_by_hostname(bgp, arg); if (!peer) { - vty_out (vty, "Malformed address or name: %s%s", arg, VTYNL); + vty_out (vty, "Malformed address or name: %s\n", arg); return CMD_WARNING; } } @@ -620,7 +616,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, peer = peer_lookup (bgp, &su); if (! peer) { - vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTYNL); + vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"\n", arg); return CMD_WARNING; } } @@ -644,7 +640,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, group = peer_group_lookup (bgp, arg); if (! group) { - vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTYNL); + vty_out (vty, "%%BGP: No such peer-group %s\n", arg); return CMD_WARNING; } @@ -707,8 +703,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, bgp_clear_vty_error (vty, peer, afi, safi, ret); } if (! find) - vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, - VTYNL); + vty_out (vty, "%%BGP: No peer is configured with AS %s\n", arg); return CMD_SUCCESS; } @@ -728,7 +723,7 @@ bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, bgp = bgp_lookup_by_name (name); if (bgp == NULL) { - vty_out (vty, "Can't find BGP instance %s%s", name, VTYNL); + vty_out (vty, "Can't find BGP instance %s\n", name); return CMD_WARNING; } } @@ -737,7 +732,7 @@ bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, bgp = bgp_get_default (); if (bgp == NULL) { - vty_out (vty, "No BGP process is configured%s", VTYNL); + vty_out (vty, "No BGP process is configured\n"); return CMD_WARNING; } } @@ -794,8 +789,8 @@ DEFUN (no_bgp_multiple_instance, ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); if (ret < 0) { - vty_out (vty, "%% There are more than two BGP instances%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% There are more than two BGP instances\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -875,14 +870,14 @@ DEFUN_NOSH (router_bgp, if (bgp == NULL) { - vty_out (vty, "%% No BGP process is configured%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (listcount(bm->bgp) > 1) { - vty_out (vty, "%% Multiple BGP processes are configured%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Multiple BGP processes are configured\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -906,17 +901,16 @@ DEFUN_NOSH (router_bgp, switch (ret) { case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: - vty_out (vty, "Please specify 'bgp multiple-instance' first%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify 'bgp multiple-instance' first\n"); + return CMD_WARNING_CONFIG_FAILED; case BGP_ERR_AS_MISMATCH: - vty_out (vty, "BGP is already running; AS is %u%s", as, VTYNL); - return CMD_WARNING; + vty_out (vty, "BGP is already running; AS is %u\n", as); + return CMD_WARNING_CONFIG_FAILED; case BGP_ERR_INSTANCE_MISMATCH: - vty_out (vty, "BGP instance name and AS number mismatch%s", VTYNL); - vty_out (vty, "BGP instance is already running; AS is %u%s", - as, VTYNL); - return CMD_WARNING; + vty_out (vty, "BGP instance name and AS number mismatch\n"); + vty_out (vty, "BGP instance is already running; AS is %u\n", + as); + return CMD_WARNING_CONFIG_FAILED; } /* Pending: handle when user tries to change a view to vrf n vv. */ @@ -951,14 +945,14 @@ DEFUN (no_router_bgp, if (bgp == NULL) { - vty_out (vty, "%% No BGP process is configured%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (listcount(bm->bgp) > 1) { - vty_out (vty, "%% Multiple BGP processes are configured%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Multiple BGP processes are configured\n"); + return CMD_WARNING_CONFIG_FAILED; } } else @@ -972,8 +966,8 @@ DEFUN (no_router_bgp, bgp = bgp_lookup (as, name); if (! bgp) { - vty_out (vty, "%% Can't find BGP instance%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Can't find BGP instance\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -1012,8 +1006,8 @@ DEFPY (no_bgp_router_id, { if (! IPV4_ADDR_SAME (&bgp->router_id_static, &router_id)) { - vty_outln (vty, "%% BGP router-id doesn't match"); - return CMD_WARNING; + vty_out (vty, "%% BGP router-id doesn't match\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -1041,8 +1035,8 @@ DEFUN (bgp_cluster_id, ret = inet_aton (argv[idx_ipv4]->arg, &cluster); if (! ret) { - vty_out (vty, "%% Malformed bgp cluster identifier%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Malformed bgp cluster identifier\n"); + return CMD_WARNING_CONFIG_FAILED; } bgp_cluster_id_set (bgp, &cluster); @@ -1120,8 +1114,7 @@ DEFUN (bgp_confederation_peers, if (bgp->as == as) { - vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", - VTYNL); + vty_out (vty, "%% Local member-AS not allowed in confed peer list\n"); continue; } @@ -1179,7 +1172,7 @@ bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, vty_out (vty, "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", maxpaths, multipath_num); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); } @@ -1189,11 +1182,11 @@ bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, if (ret < 0) { vty_out (vty, - "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", + "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", (set == 1) ? "" : "un", (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", - maxpaths, afi, safi, VTYNL); - return CMD_WARNING; + maxpaths, afi, safi); + return CMD_WARNING_CONFIG_FAILED; } bgp_recalculate_all_bestpaths (bgp); @@ -1326,9 +1319,8 @@ bgp_update_delay_config_vty (struct vty *vty, const char *delay, establish_wait = atoi (wait); if (update_delay < establish_wait) { - vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%%Failed: update-delay less than the establish-wait!\n"); + return CMD_WARNING_CONFIG_FAILED; } bgp->v_update_delay = update_delay; @@ -1356,7 +1348,7 @@ bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) vty_out (vty, " update-delay %d", bgp->v_update_delay); if (bgp->v_update_delay != bgp->v_establish_wait) vty_out (vty, " %d", bgp->v_establish_wait); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } return 0; @@ -1416,8 +1408,8 @@ int bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) { if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) - vty_out (vty, " write-quanta %d%s", - bgp->wpkt_quanta, VTYNL); + vty_out (vty, " write-quanta %d\n", + bgp->wpkt_quanta); return 0; } @@ -1450,8 +1442,8 @@ int bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) { if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) - vty_out (vty, " coalesce-time %u%s", - bgp->coalesce_time, VTYNL); + vty_out (vty, " coalesce-time %u\n", + bgp->coalesce_time); return 0; } @@ -1487,7 +1479,7 @@ DEFUN (no_bgp_coalesce_time, /* Maximum-paths configuration */ DEFUN (bgp_maxpaths, bgp_maxpaths_cmd, - "maximum-paths (1-255)", + "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), "Forward packets over multiple paths\n" "Number of paths\n") { @@ -1497,13 +1489,13 @@ DEFUN (bgp_maxpaths, ALIAS_HIDDEN (bgp_maxpaths, bgp_maxpaths_hidden_cmd, - "maximum-paths (1-255)", + "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), "Forward packets over multiple paths\n" "Number of paths\n") DEFUN (bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_cmd, - "maximum-paths ibgp (1-255)", + "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), "Forward packets over multiple paths\n" "iBGP-multipath\n" "Number of paths\n") @@ -1514,14 +1506,14 @@ DEFUN (bgp_maxpaths_ibgp, ALIAS_HIDDEN (bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, - "maximum-paths ibgp (1-255)", + "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), "Forward packets over multiple paths\n" "iBGP-multipath\n" "Number of paths\n") DEFUN (bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_cmd, - "maximum-paths ibgp (1-255) equal-cluster-length", + "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", "Forward packets over multiple paths\n" "iBGP-multipath\n" "Number of paths\n" @@ -1534,7 +1526,7 @@ DEFUN (bgp_maxpaths_ibgp_cluster, ALIAS_HIDDEN (bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, - "maximum-paths ibgp (1-255) equal-cluster-length", + "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", "Forward packets over multiple paths\n" "iBGP-multipath\n" "Number of paths\n" @@ -1542,7 +1534,7 @@ ALIAS_HIDDEN (bgp_maxpaths_ibgp_cluster, DEFUN (no_bgp_maxpaths, no_bgp_maxpaths_cmd, - "no maximum-paths [(1-255)]", + "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR "Forward packets over multiple paths\n" "Number of paths\n") @@ -1552,14 +1544,14 @@ DEFUN (no_bgp_maxpaths, ALIAS_HIDDEN (no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, - "no maximum-paths [(1-255)]", + "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR "Forward packets over multiple paths\n" "Number of paths\n") DEFUN (no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_cmd, - "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", + "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", NO_STR "Forward packets over multiple paths\n" "iBGP-multipath\n" @@ -1571,7 +1563,7 @@ DEFUN (no_bgp_maxpaths_ibgp, ALIAS_HIDDEN (no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, - "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", + "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", NO_STR "Forward packets over multiple paths\n" "iBGP-multipath\n" @@ -1585,8 +1577,8 @@ bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { bgp_config_write_family_header (vty, afi, safi, write); - vty_out (vty, " maximum-paths %d%s", - bgp->maxpaths[afi][safi].maxpaths_ebgp, VTYNL); + vty_out (vty, " maximum-paths %d\n", + bgp->maxpaths[afi][safi].maxpaths_ebgp); } if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) @@ -1597,7 +1589,7 @@ bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) vty_out (vty, " equal-cluster-length"); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } return 0; @@ -1625,9 +1617,8 @@ DEFUN (bgp_timers, /* Holdtime value check. */ if (holdtime < 3 && holdtime != 0) { - vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% hold time value must be either 0 or greater than 3\n"); + return CMD_WARNING_CONFIG_FAILED; } bgp_timers_set (bgp, keepalive, holdtime); @@ -1760,9 +1751,8 @@ DEFUN (no_bgp_deterministic_med, if (bestpath_per_as_used) { - vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); + return CMD_WARNING_CONFIG_FAILED; } else { @@ -2454,17 +2444,16 @@ DEFUN (bgp_listen_range, ret = str2prefix (prefix, &range); if (! ret) { - vty_out (vty, "%% Malformed listen range%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Malformed listen range\n"); + return CMD_WARNING_CONFIG_FAILED; } afi = family2afi(range.family); if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) { - vty_out (vty, "%% Malformed listen range (link-local address)%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Malformed listen range (link-local address)\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask (&range); @@ -2477,25 +2466,24 @@ DEFUN (bgp_listen_range, return CMD_SUCCESS; else { - vty_out (vty, "%% Same listen range is attached to peer-group %s%s", - existing_group->name, VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Same listen range is attached to peer-group %s\n", + existing_group->name); + return CMD_WARNING_CONFIG_FAILED; } } /* Check if an overlapping listen range exists. */ if (listen_range_exists (bgp, &range, 0)) { - vty_out (vty, "%% Listen range overlaps with existing listen range%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Listen range overlaps with existing listen range\n"); + return CMD_WARNING_CONFIG_FAILED; } group = peer_group_lookup (bgp, peergroup); if (! group) { - vty_out (vty, "%% Configure the peer-group first%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Configure the peer-group first\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = peer_group_listen_range_add(group, &range); @@ -2530,17 +2518,16 @@ DEFUN (no_bgp_listen_range, ret = str2prefix (prefix, &range); if (! ret) { - vty_out (vty, "%% Malformed listen range%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Malformed listen range\n"); + return CMD_WARNING_CONFIG_FAILED; } afi = family2afi(range.family); if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) { - vty_out (vty, "%% Malformed listen range (link-local address)%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Malformed listen range (link-local address)\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask (&range); @@ -2548,8 +2535,8 @@ DEFUN (no_bgp_listen_range, group = peer_group_lookup (bgp, peergroup); if (! group) { - vty_out (vty, "%% Peer-group does not exist%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Peer-group does not exist\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = peer_group_listen_range_del(group, &range); @@ -2566,8 +2553,8 @@ bgp_config_write_listen (struct vty *vty, struct bgp *bgp) char buf[PREFIX2STR_BUFFER]; if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) - vty_out (vty, " bgp listen limit %d%s", - bgp->dynamic_neighbors_limit, VTYNL); + vty_out (vty, " bgp listen limit %d\n", + bgp->dynamic_neighbors_limit); for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) { @@ -2576,8 +2563,8 @@ bgp_config_write_listen (struct vty *vty, struct bgp *bgp) for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) { prefix2str(range, buf, sizeof(buf)); - vty_out(vty, " bgp listen range %s peer-group %s%s", - buf, group->name, VTYNL); + vty_out(vty, " bgp listen range %s peer-group %s\n", + buf, group->name); } } } @@ -2651,9 +2638,8 @@ peer_remote_as_vty (struct vty *vty, const char *peer_str, ret = peer_group_remote_as (bgp, peer_str, &as, as_type); if (ret < 0) { - vty_out (vty, "%% Create the peer-group or interface first%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Create the peer-group or interface first\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -2662,9 +2648,8 @@ peer_remote_as_vty (struct vty *vty, const char *peer_str, { if (peer_address_self_check (bgp, &su)) { - vty_out (vty, "%% Can not configure the local system as neighbor%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Can not configure the local system as neighbor\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); } @@ -2673,11 +2658,11 @@ peer_remote_as_vty (struct vty *vty, const char *peer_str, switch (ret) { case BGP_ERR_PEER_GROUP_MEMBER: - vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member\n", as); + return CMD_WARNING_CONFIG_FAILED; case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: - vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", as, as_str, VTYNL); - return CMD_WARNING; + vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", as, as_str); + return CMD_WARNING_CONFIG_FAILED; } return bgp_vty_return (vty, ret); } @@ -2714,8 +2699,8 @@ peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, if (group) { - vty_out (vty, "%% Name conflict with peer-group %s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Name conflict with peer-group \n"); + return CMD_WARNING_CONFIG_FAILED; } if (as_str) @@ -2753,7 +2738,10 @@ peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, NULL); if (!peer) - return CMD_WARNING; + { + vty_out (vty, "%% BGP failed to create peer\n"); + return CMD_WARNING_CONFIG_FAILED; + } if (v6only) SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); @@ -2794,8 +2782,8 @@ peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, group = peer_group_lookup (bgp, peer_group_name); if (! group) { - vty_out (vty, "%% Configure the peer-group first%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Configure the peer-group first\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = peer_group_bind (bgp, &su, peer, group, &as); @@ -2896,13 +2884,16 @@ DEFUN (neighbor_peer_group, peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); if (peer) { - vty_out (vty, "%% Name conflict with interface: %s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Name conflict with interface: \n"); + return CMD_WARNING_CONFIG_FAILED; } group = peer_group_get (bgp, argv[idx_word]->arg); if (! group) - return CMD_WARNING; + { + vty_out (vty, "%% BGP failed to find or create peer-group\n"); + return CMD_WARNING_CONFIG_FAILED; + } return CMD_SUCCESS; } @@ -2945,8 +2936,8 @@ DEFUN (no_neighbor, peer_group_delete (group); else { - vty_out (vty, "%% Create the peer-group first%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Create the peer-group first\n"); + return CMD_WARNING_CONFIG_FAILED; } } else @@ -2956,9 +2947,8 @@ DEFUN (no_neighbor, { if (peer_dynamic_neighbor (peer)) { - vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Operation not allowed on a dynamic neighbor\n"); + return CMD_WARNING_CONFIG_FAILED; } other = peer->doppelganger; @@ -3001,8 +2991,8 @@ DEFUN (no_neighbor_interface_config, } else { - vty_out (vty, "%% Create the bgp interface first%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Create the bgp interface first\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -3024,8 +3014,8 @@ DEFUN (no_neighbor_peer_group, peer_group_delete (group); else { - vty_out (vty, "%% Create the peer-group first%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Create the peer-group first\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -3059,8 +3049,8 @@ DEFUN (no_neighbor_interface_peer_group_remote_as, peer_group_remote_as_delete (group); else { - vty_out (vty, "%% Create the peer-group or interface first%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Create the peer-group or interface first\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -3081,7 +3071,7 @@ DEFUN (neighbor_local_as, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; as = strtoul(argv[idx_number]->arg, NULL, 10); ret = peer_local_as_set (peer, as, 0, 0); @@ -3105,7 +3095,7 @@ DEFUN (neighbor_local_as_no_prepend, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; as = strtoul(argv[idx_number]->arg, NULL, 10); ret = peer_local_as_set (peer, as, 1, 0); @@ -3130,7 +3120,7 @@ DEFUN (neighbor_local_as_no_prepend_replace_as, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; as = strtoul(argv[idx_number]->arg, NULL, 10); ret = peer_local_as_set (peer, as, 1, 1); @@ -3154,7 +3144,7 @@ DEFUN (no_neighbor_local_as, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_local_as_unset (peer); return bgp_vty_return (vty, ret); @@ -3176,7 +3166,7 @@ DEFUN (neighbor_solo, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = update_group_adjust_soloness(peer, 1); return bgp_vty_return (vty, ret); @@ -3196,7 +3186,7 @@ DEFUN (no_neighbor_solo, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = update_group_adjust_soloness(peer, 0); return bgp_vty_return (vty, ret); @@ -3217,7 +3207,7 @@ DEFUN (neighbor_password, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_password_set (peer, argv[idx_line]->arg); return bgp_vty_return (vty, ret); @@ -3238,7 +3228,7 @@ DEFUN (no_neighbor_password, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_password_unset (peer); return bgp_vty_return (vty, ret); @@ -3258,7 +3248,7 @@ DEFUN (neighbor_activate, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); return bgp_vty_return (vty, ret); @@ -3286,7 +3276,7 @@ DEFUN (no_neighbor_activate, /* Lookup peer. */ peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); return bgp_vty_return (vty, ret); @@ -3325,42 +3315,40 @@ DEFUN (neighbor_set_peer_group, peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); if (!peer) { - vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Malformed address or name: %s\n", argv[idx_peer]->arg); + return CMD_WARNING_CONFIG_FAILED; } } else { if (peer_address_self_check (bgp, &su)) { - vty_out (vty, "%% Can not configure the local system as neighbor%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Can not configure the local system as neighbor\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Disallow for dynamic neighbor. */ peer = peer_lookup (bgp, &su); if (peer && peer_dynamic_neighbor (peer)) { - vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Operation not allowed on a dynamic neighbor\n"); + return CMD_WARNING_CONFIG_FAILED; } } group = peer_group_lookup (bgp, argv[idx_word]->arg); if (! group) { - vty_out (vty, "%% Configure the peer-group first%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Configure the peer-group first\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = peer_group_bind (bgp, &su, peer, group, &as); if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { - vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", as, VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", as); + return CMD_WARNING_CONFIG_FAILED; } return bgp_vty_return (vty, ret); @@ -3392,13 +3380,13 @@ DEFUN (no_neighbor_set_peer_group, peer = peer_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; group = peer_group_lookup (bgp, argv[idx_word]->arg); if (! group) { - vty_out (vty, "%% Configure the peer-group first%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Configure the peer-group first\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = peer_group_unbind (bgp, peer, group); @@ -3424,7 +3412,7 @@ peer_flag_modify_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* * If 'neighbor <interface>', then this is for directly connected peers, @@ -3432,8 +3420,8 @@ peer_flag_modify_vty (struct vty *vty, const char *ip_str, */ if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { vty_out (vty, "%s is directly connected peer, cannot accept disable-" - "connected-check%s", ip_str, VTYNL); - return CMD_WARNING; + "connected-check\n", ip_str); + return CMD_WARNING_CONFIG_FAILED; } if (!set && flag == PEER_FLAG_SHUTDOWN) @@ -3501,7 +3489,7 @@ DEFUN (neighbor_shutdown_msg, char *message; if (!peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; message = argv_concat (argv, argc, 4); peer_tx_shutdown_message_set (peer, message); XFREE (MTYPE_TMP, message); @@ -3625,7 +3613,7 @@ peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, peer = peer_and_group_lookup_vty (vty, peer_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (set) ret = peer_af_flag_set (peer, afi, safi, flag); @@ -3673,7 +3661,10 @@ DEFUN (neighbor_capability_orf_prefix, else if (strmatch (argv[idx_send_recv]->text, "both")) flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; else - return CMD_WARNING; + { + vty_out (vty, "%% BGP invalid orf prefix-list option\n"); + return CMD_WARNING_CONFIG_FAILED; + } return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flag); @@ -3715,7 +3706,10 @@ DEFUN (no_neighbor_capability_orf_prefix, else if (strmatch (argv[idx_send_recv]->text, "both")) flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; else - return CMD_WARNING; + { + vty_out (vty, "%% BGP invalid orf prefix-list option\n"); + return CMD_WARNING_CONFIG_FAILED; + } return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flag); @@ -4262,7 +4256,7 @@ DEFUN (neighbor_route_reflector_client, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), @@ -4311,7 +4305,7 @@ DEFUN (neighbor_route_server_client, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_RSERVER_CLIENT); @@ -4473,7 +4467,7 @@ peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (peer->conf_if) return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); @@ -4493,7 +4487,7 @@ peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); } @@ -4578,7 +4572,7 @@ DEFUN (neighbor_description, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; str = argv_concat(argv, argc, idx_line); @@ -4603,7 +4597,7 @@ DEFUN (no_neighbor_description, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; peer_description_unset (peer); @@ -4621,7 +4615,7 @@ peer_update_source_vty (struct vty *vty, const char *peer_str, peer = peer_and_group_lookup_vty (vty, peer_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (peer->conf_if) return CMD_WARNING; @@ -4637,9 +4631,8 @@ peer_update_source_vty (struct vty *vty, const char *peer_str, { if (str2prefix (source_str, &p)) { - vty_out (vty, "%% Invalid update-source, remove prefix length %s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid update-source, remove prefix length \n"); + return CMD_WARNING_CONFIG_FAILED; } else peer_update_source_if_set (peer, source_str); @@ -4692,7 +4685,7 @@ peer_default_originate_set_vty (struct vty *vty, const char *peer_str, peer = peer_and_group_lookup_vty (vty, peer_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (set) ret = peer_default_originate_set (peer, afi, safi, rmap); @@ -4783,7 +4776,7 @@ peer_port_vty (struct vty *vty, const char *ip_str, int afi, peer = peer_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (! port_str) { @@ -4840,7 +4833,7 @@ peer_weight_set_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; weight = strtoul(weight_str, NULL, 10); @@ -4857,7 +4850,7 @@ peer_weight_unset_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_weight_unset (peer, afi, safi); return bgp_vty_return (vty, ret); @@ -4969,7 +4962,7 @@ peer_timers_set_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; keepalive = strtoul(keep_str, NULL, 10); holdtime = strtoul(hold_str, NULL, 10); @@ -4987,7 +4980,7 @@ peer_timers_unset_vty (struct vty *vty, const char *ip_str) peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_timers_unset (peer); @@ -5034,7 +5027,7 @@ peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; connect = strtoul(time_str, NULL, 10); @@ -5051,7 +5044,7 @@ peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_timers_connect_unset (peer); @@ -5097,7 +5090,7 @@ peer_advertise_interval_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (time_str) routeadv = strtoul(time_str, NULL, 10); @@ -5165,7 +5158,10 @@ DEFUN (bgp_set_route_map_delay_timer, return CMD_SUCCESS; } else - return CMD_WARNING; + { + vty_out (vty, "%% BGP invalid route-map delay-timer\n"); + return CMD_WARNING_CONFIG_FAILED; + } } DEFUN (no_bgp_set_route_map_delay_timer, @@ -5192,7 +5188,10 @@ peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) peer = peer_lookup_vty (vty, ip_str); if (! peer || peer->conf_if) - return CMD_WARNING; + { + vty_out (vty, "%% BGP invalid peer %s\n", ip_str); + return CMD_WARNING_CONFIG_FAILED; + } if (str) peer_interface_set (peer, str); @@ -5251,7 +5250,7 @@ DEFUN (neighbor_distribute_list, peer = peer_and_group_lookup_vty (vty, pstr); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Check filter direction. */ direct = strmatch (inout, "in") ? FILTER_IN : FILTER_OUT; @@ -5294,7 +5293,7 @@ DEFUN (no_neighbor_distribute_list, peer = peer_and_group_lookup_vty (vty, pstr); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Check filter direction. */ direct = strmatch (inout, "in") ? FILTER_IN : FILTER_OUT; @@ -5328,7 +5327,7 @@ peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Check filter direction. */ if (strncmp (direct_str, "i", 1) == 0) @@ -5351,7 +5350,7 @@ peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Check filter direction. */ if (strncmp (direct_str, "i", 1) == 0) @@ -5430,7 +5429,7 @@ peer_aslist_set_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Check filter direction. */ if (strncmp (direct_str, "i", 1) == 0) @@ -5454,7 +5453,7 @@ peer_aslist_unset_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Check filter direction. */ if (strncmp (direct_str, "i", 1) == 0) @@ -5534,7 +5533,7 @@ peer_route_map_set_vty (struct vty *vty, const char *ip_str, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Check filter direction. */ if (strncmp (direct_str, "in", 2) == 0) @@ -5557,7 +5556,7 @@ peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Check filter direction. */ if (strncmp (direct_str, "in", 2) == 0) @@ -5635,7 +5634,7 @@ peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_unsuppress_map_set (peer, afi, safi, name_str); @@ -5652,7 +5651,7 @@ peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_unsuppress_map_unset (peer, afi, safi); @@ -5718,7 +5717,7 @@ peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; max = strtoul(num_str, NULL, 10); if (threshold_str) @@ -5745,7 +5744,7 @@ peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_maximum_prefix_unset (peer, afi, safi); @@ -5964,7 +5963,7 @@ DEFUN (neighbor_allowas_in, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (argc <= idx_number_origin) allow_num = 3; @@ -6007,7 +6006,7 @@ DEFUN (no_neighbor_allowas_in, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); @@ -6040,7 +6039,7 @@ DEFUN (neighbor_ttl_security, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); @@ -6049,9 +6048,9 @@ DEFUN (neighbor_ttl_security, * we should not accept a ttl-security hops value greater than 1. */ if (peer->conf_if && (gtsm_hops > 1)) { - vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", - argv[idx_peer]->arg, VTYNL); - return CMD_WARNING; + vty_out (vty, "%s is directly connected peer, hops cannot exceed 1\n", + argv[idx_peer]->arg); + return CMD_WARNING_CONFIG_FAILED; } return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); @@ -6072,7 +6071,7 @@ DEFUN (no_neighbor_ttl_security, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); } @@ -6089,7 +6088,7 @@ DEFUN (neighbor_addpath_tx_all_paths, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), @@ -6137,7 +6136,7 @@ DEFUN (neighbor_addpath_tx_bestpath_per_as, peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), @@ -6282,7 +6281,7 @@ bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, bgp = bgp_lookup_by_name (view_name); if (bgp == NULL) { - vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTYNL); + vty_out (vty, "%% Can't find BGP instance %s\n", view_name); return CMD_WARNING; } } @@ -6291,7 +6290,7 @@ bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, bgp = bgp_get_default (); if (bgp == NULL) { - vty_out (vty, "%% No BGP process is configured%s", VTYNL); + vty_out (vty, "%% No BGP process is configured\n"); return CMD_WARNING; } } @@ -6300,7 +6299,7 @@ bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, ret = str2prefix (ip_str, &match); if (! ret) { - vty_out (vty, "%% address is malformed%s", VTYNL); + vty_out (vty, "%% address is malformed\n"); return CMD_WARNING; } @@ -6526,19 +6525,19 @@ DEFUN (show_bgp_views, if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) { - vty_out (vty, "BGP Multiple Instance is not enabled%s", VTYNL); + vty_out (vty, "BGP Multiple Instance is not enabled\n"); return CMD_WARNING; } - vty_out (vty, "Defined BGP views:%s", VTYNL); + vty_out (vty, "Defined BGP views:\n"); for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { /* Skip VRFs. */ if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) continue; - vty_out (vty, "\t%s (AS%u)%s", + vty_out (vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", - bgp->as, VTYNL); + bgp->as); } return CMD_SUCCESS; @@ -6564,7 +6563,7 @@ DEFUN (show_bgp_vrfs, if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) { - vty_out (vty, "BGP Multiple Instance is not enabled%s", VTYNL); + vty_out (vty, "BGP Multiple Instance is not enabled\n"); return CMD_WARNING; } @@ -6589,7 +6588,7 @@ DEFUN (show_bgp_vrfs, count++; if (!uj && count == 1) - vty_out (vty, "%s%s", header, VTYNL); + vty_out (vty, "%s\n", header); peers_cfg = peers_estb = 0; if (uj) @@ -6628,10 +6627,9 @@ DEFUN (show_bgp_vrfs, json_object_object_add(json_vrfs, name, json_vrf); } else - vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", + vty_out (vty, "%4s %-5d %-16s %9u %10u %s\n", type, vrf_id_ui, inet_ntoa (bgp->router_id), - peers_cfg, peers_estb, name, - VTYNL); + peers_cfg, peers_estb, name); } if (uj) @@ -6640,14 +6638,13 @@ DEFUN (show_bgp_vrfs, json_object_int_add(json, "totalVrfs", count); - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { if (count) - vty_out (vty, "%sTotal number of VRFs (including default): %d%s", - VTYNL, count, VTYNL); + vty_out (vty, "\nTotal number of VRFs (including default): %d\n", count); } return CMD_SUCCESS; @@ -6666,139 +6663,113 @@ DEFUN (show_bgp_memory, /* RIB related usage stats */ count = mtype_stats_alloc (MTYPE_BGP_NODE); - vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, + vty_out (vty, "%ld RIB nodes, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct bgp_node)), - VTYNL); + count * sizeof (struct bgp_node))); count = mtype_stats_alloc (MTYPE_BGP_ROUTE); - vty_out (vty, "%ld BGP routes, using %s of memory%s", count, + vty_out (vty, "%ld BGP routes, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct bgp_info)), - VTYNL); + count * sizeof (struct bgp_info))); if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) - vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, + vty_out (vty, "%ld BGP route ancillaries, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct bgp_info_extra)), - VTYNL); + count * sizeof (struct bgp_info_extra))); if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) - vty_out (vty, "%ld Static routes, using %s of memory%s", count, + vty_out (vty, "%ld Static routes, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct bgp_static)), - VTYNL); + count * sizeof (struct bgp_static))); if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) - vty_out (vty, "%ld Packets, using %s of memory%s", count, + vty_out (vty, "%ld Packets, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct bpacket)), - VTYNL); + count * sizeof (struct bpacket))); /* Adj-In/Out */ if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) - vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, + vty_out (vty, "%ld Adj-In entries, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct bgp_adj_in)), - VTYNL); + count * sizeof (struct bgp_adj_in))); if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) - vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, + vty_out (vty, "%ld Adj-Out entries, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct bgp_adj_out)), - VTYNL); + count * sizeof (struct bgp_adj_out))); if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) - vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, + vty_out (vty, "%ld Nexthop cache entries, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct bgp_nexthop_cache)), - VTYNL); + count * sizeof (struct bgp_nexthop_cache))); if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) - vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, + vty_out (vty, "%ld Dampening entries, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct bgp_damp_info)), - VTYNL); + count * sizeof (struct bgp_damp_info))); /* Attributes */ count = attr_count(); - vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, + vty_out (vty, "%ld BGP attributes, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof(struct attr)), - VTYNL); - if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) - vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, - mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof(struct attr_extra)), - VTYNL); + count * sizeof(struct attr))); if ((count = attr_unknown_count())) - vty_out (vty, "%ld unknown attributes%s", count, VTYNL); + vty_out (vty, "%ld unknown attributes\n", count); /* AS_PATH attributes */ count = aspath_count (); - vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, + vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct aspath)), - VTYNL); + count * sizeof (struct aspath))); count = mtype_stats_alloc (MTYPE_AS_SEG); - vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, + vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct assegment)), - VTYNL); + count * sizeof (struct assegment))); /* Other attributes */ if ((count = community_count ())) - vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, + vty_out (vty, "%ld BGP community entries, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct community)), - VTYNL); + count * sizeof (struct community))); if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) - vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, + vty_out (vty, "%ld BGP community entries, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct ecommunity)), - VTYNL); + count * sizeof (struct ecommunity))); if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY))) - vty_out (vty, "%ld BGP large-community entries, using %s of memory%s", + vty_out (vty, "%ld BGP large-community entries, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct lcommunity)), - VTYNL); + count * sizeof (struct lcommunity))); if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) - vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, + vty_out (vty, "%ld Cluster lists, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct cluster_list)), - VTYNL); + count * sizeof (struct cluster_list))); /* Peer related usage */ count = mtype_stats_alloc (MTYPE_BGP_PEER); - vty_out (vty, "%ld peers, using %s of memory%s", count, + vty_out (vty, "%ld peers, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct peer)), - VTYNL); + count * sizeof (struct peer))); if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) - vty_out (vty, "%ld peer groups, using %s of memory%s", count, + vty_out (vty, "%ld peer groups, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct peer_group)), - VTYNL); + count * sizeof (struct peer_group))); /* Other */ if ((count = mtype_stats_alloc (MTYPE_HASH))) - vty_out (vty, "%ld hash tables, using %s of memory%s", count, + vty_out (vty, "%ld hash tables, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct hash)), - VTYNL); + count * sizeof (struct hash))); if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) - vty_out (vty, "%ld hash buckets, using %s of memory%s", count, + vty_out (vty, "%ld hash buckets, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (struct hash_backet)), - VTYNL); + count * sizeof (struct hash_backet))); if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) - vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, + vty_out (vty, "%ld compiled regexes, using %s of memory\n", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), - count * sizeof (regex_t)), - VTYNL); + count * sizeof (regex_t))); return CMD_SUCCESS; } @@ -6815,9 +6786,18 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, int neighbor_col_default_width = 16; int len; int max_neighbor_width = 0; + int pfx_rcd_safi; json_object *json_peer = NULL; json_object *json_peers = NULL; + /* labeled-unicast routes are installed in the unicast table so in order to + * display the correct PfxRcd value we must look at SAFI_UNICAST + */ + if (safi == SAFI_LABELED_UNICAST) + pfx_rcd_safi = SAFI_UNICAST; + else + pfx_rcd_safi = safi; + if (use_json) { if (json == NULL) @@ -6890,7 +6870,7 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, vty_out (vty, "BGP router identifier %s, local AS number %u vrf-id %d", inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } if (bgp_update_delay_configured(bgp)) @@ -6924,30 +6904,30 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, } else { - vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", - bgp->v_update_delay, VTYNL); + vty_out (vty, "Read-only mode update-delay limit: %d seconds\n", + bgp->v_update_delay); if (bgp->v_update_delay != bgp->v_establish_wait) - vty_out (vty, " Establish wait: %d seconds%s", - bgp->v_establish_wait, VTYNL); + vty_out (vty, " Establish wait: %d seconds\n", + bgp->v_establish_wait); if (bgp_update_delay_active(bgp)) { - vty_out (vty, " First neighbor established: %s%s", - bgp->update_delay_begin_time, VTYNL); - vty_out (vty, " Delay in progress%s", VTYNL); + vty_out (vty, " First neighbor established: %s\n", + bgp->update_delay_begin_time); + vty_out (vty, " Delay in progress\n"); } else { if (bgp->update_delay_over) { - vty_out (vty, " First neighbor established: %s%s", - bgp->update_delay_begin_time, VTYNL); - vty_out (vty, " Best-paths resumed: %s%s", - bgp->update_delay_end_time, VTYNL); - vty_out (vty, " zebra update resumed: %s%s", - bgp->update_delay_zebra_resume_time, VTYNL); - vty_out (vty, " peers update resumed: %s%s", - bgp->update_delay_peers_resume_time, VTYNL); + vty_out (vty, " First neighbor established: %s\n", + bgp->update_delay_begin_time); + vty_out (vty, " Best-paths resumed: %s\n", + bgp->update_delay_end_time); + vty_out (vty, " zebra update resumed: %s\n", + bgp->update_delay_zebra_resume_time); + vty_out (vty, " peers update resumed: %s\n", + bgp->update_delay_peers_resume_time); } } } @@ -6982,41 +6962,38 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, else { if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) - vty_out (vty, "Max-med on-startup active%s", VTYNL); + vty_out (vty, "Max-med on-startup active\n"); if (bgp->v_maxmed_admin) - vty_out (vty, "Max-med administrative active%s", VTYNL); + vty_out (vty, "Max-med administrative active\n"); - vty_out(vty, "BGP table version %" PRIu64 "%s", - bgp_table_version(bgp->rib[afi][safi]), VTYNL); + vty_out(vty, "BGP table version %" PRIu64 "\n", + bgp_table_version(bgp->rib[afi][safi])); ents = bgp_table_count (bgp->rib[afi][safi]); - vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, + vty_out (vty, "RIB entries %ld, using %s of memory\n", ents, mtype_memstr (memstrbuf, sizeof (memstrbuf), - ents * sizeof (struct bgp_node)), - VTYNL); + ents * sizeof (struct bgp_node))); /* Peer related usage */ ents = listcount (bgp->peer); - vty_out (vty, "Peers %ld, using %s of memory%s", + vty_out (vty, "Peers %ld, using %s of memory\n", ents, mtype_memstr (memstrbuf, sizeof (memstrbuf), - ents * sizeof (struct peer)), - VTYNL); + ents * sizeof (struct peer))); if ((ents = listcount (bgp->group))) - vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, + vty_out (vty, "Peer groups %ld, using %s of memory\n", ents, mtype_memstr (memstrbuf, sizeof (memstrbuf), - ents * sizeof (struct peer_group)), - VTYNL); + ents * sizeof (struct peer_group))); if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) - vty_out (vty, "Dampening enabled.%s", VTYNL); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "Dampening enabled.\n"); + vty_out (vty, "\n"); /* Subtract 8 here because 'Neighbor' is 8 characters */ vty_out (vty, "Neighbor"); vty_out (vty, "%*s", max_neighbor_width - 8, " "); - vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTYNL); + vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); } } @@ -7050,7 +7027,7 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, json_object_int_add(json_peer, "outq", peer->obuf->count); json_object_int_add(json_peer, "inq", 0); peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); - json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); + json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][pfx_rcd_safi]); if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) json_object_string_add(json_peer, "state", "Idle (Admin)"); @@ -7101,7 +7078,7 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); if (peer->status == Established) - vty_out (vty, " %12ld", peer->pcount[afi][safi]); + vty_out (vty, " %12ld", peer->pcount[afi][pfx_rcd_safi]); else { if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) @@ -7111,7 +7088,7 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, else vty_out (vty, " %12s", lookup_msg(bgp_status_msg, peer->status, NULL)); } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } } @@ -7123,30 +7100,30 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, json_object_int_add(json, "totalPeers", count); json_object_int_add(json, "dynamicPeers", dn_count); - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { if (count) - vty_out (vty, "%sTotal number of neighbors %d%s", VTYNL, - count, VTYNL); + vty_out (vty, "\nTotal number of neighbors %d\n", + count); else { if (use_json) - vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", - afi_safi_print(afi, safi), VTYNL); + vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n", + afi_safi_print(afi, safi)); else - vty_out (vty, "No %s neighbor is configured%s", - afi_safi_print(afi, safi), VTYNL); + vty_out (vty, "No %s neighbor is configured\n", + afi_safi_print(afi, safi)); } if (dn_count && ! use_json) { - vty_out(vty, "* - dynamic neighbor%s", VTYNL); + vty_out(vty, "* - dynamic neighbor\n"); vty_out(vty, - "%d dynamic neighbor(s), limit %d%s", - dn_count, bgp->dynamic_neighbors_limit, VTYNL); + "%d dynamic neighbor(s), limit %d\n", + dn_count, bgp->dynamic_neighbors_limit); } } @@ -7185,7 +7162,7 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, bool json_output = false; if (use_json && is_wildcard) - vty_out (vty, "{%s", VTYNL); + vty_out (vty, "{\n"); if (afi_wildcard) afi = 1; /* AFI_IP */ while (afi < AFI_MAX) @@ -7208,7 +7185,7 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, json = json_object_new_object(); if (! is_first) - vty_out (vty, ",%s", VTYNL); + vty_out (vty, ",\n"); else is_first = 0; @@ -7216,8 +7193,7 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, } else { - vty_out (vty, "%s%s Summary:%s", - VTYNL, afi_safi_print(afi, safi), VTYNL); + vty_out (vty, "\n%s Summary:\n", afi_safi_print(afi, safi)); } } bgp_show_summary (vty, bgp, afi, safi, use_json, json); @@ -7236,9 +7212,9 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, } if (use_json && is_wildcard) - vty_out (vty, "}%s", VTYNL); + vty_out (vty, "}\n"); else if (use_json && !json_output) - vty_out (vty, "{}%s", VTYNL); + vty_out (vty, "{}\n"); } static void @@ -7251,7 +7227,7 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, int is_first = 1; if (use_json) - vty_out (vty, "{%s", VTYNL); + vty_out (vty, "{\n"); for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) { @@ -7260,7 +7236,7 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, json = json_object_new_object(); if (! is_first) - vty_out (vty, ",%s", VTYNL); + vty_out (vty, ",\n"); else is_first = 0; @@ -7269,20 +7245,19 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, } else { - vty_out (vty, "%sInstance %s:%s", - VTYNL, + vty_out (vty, "\nInstance %s:\n", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) - ? "Default" : bgp->name, VTYNL); + ? "Default" : bgp->name); } bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); } if (use_json) - vty_out (vty, "}%s", VTYNL); + vty_out (vty, "}\n"); } -static int +int bgp_show_summary_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, u_char use_json) { @@ -7302,9 +7277,9 @@ bgp_show_summary_vty (struct vty *vty, const char *name, if (! bgp) { if (use_json) - vty_out (vty, "{}%s", VTYNL); + vty_out (vty, "{}\n"); else - vty_out (vty, "%% No such BGP instance exist%s", VTYNL); + vty_out (vty, "%% No such BGP instance exist\n"); return CMD_WARNING; } @@ -7365,7 +7340,7 @@ afi_safi_print (afi_t afi, safi_t safi) else if (afi == AFI_IP && safi == SAFI_MULTICAST) return "IPv4 Multicast"; else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) - return "IPv4 labeled-unicast"; + return "IPv4 Labeled Unicast"; else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) return "IPv4 VPN"; else if (afi == AFI_IP && safi == SAFI_ENCAP) @@ -7375,7 +7350,7 @@ afi_safi_print (afi_t afi, safi_t safi) else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) return "IPv6 Multicast"; else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) - return "IPv6 labeled-unicast"; + return "IPv6 Labeled Unicast"; else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) return "IPv6 VPN"; else if (afi == AFI_IP6 && safi == SAFI_ENCAP) @@ -7455,7 +7430,7 @@ bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t sa vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? ", " : ""); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } @@ -7481,7 +7456,7 @@ bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t sa vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? ", " : ""); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } } @@ -7686,23 +7661,22 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, { filter = &p->filter[afi][safi]; - vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), - VTYNL); + vty_out (vty, " For address family: %s\n", afi_safi_print (afi, safi)); if (peer_group_active(p)) - vty_out (vty, " %s peer-group member%s", p->group->name, VTYNL); + vty_out (vty, " %s peer-group member\n", p->group->name); paf = peer_af_find(p, afi, safi); if (paf && PAF_SUBGRP(paf)) { - vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", - PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTYNL); - vty_out (vty, " Packet Queue length %d%s", - bpacket_queue_virtual_length(paf), VTYNL); + vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "\n", + PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); + vty_out (vty, " Packet Queue length %d\n", + bpacket_queue_virtual_length(paf)); } else { - vty_out(vty, " Not part of any update group%s", VTYNL); + vty_out(vty, " Not part of any update group\n"); } if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) @@ -7710,15 +7684,15 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) - vty_out (vty, " AF-dependant capabilities:%s", VTYNL); + vty_out (vty, " AF-dependant capabilities:\n"); if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) { - vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", - ORF_TYPE_PREFIX, VTYNL); + vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", + ORF_TYPE_PREFIX); bgp_show_peer_afi_orf_cap (vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, PEER_CAP_ORF_PREFIX_RM_ADV, @@ -7730,8 +7704,8 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { - vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", - ORF_TYPE_PREFIX_OLD, VTYNL); + vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", + ORF_TYPE_PREFIX_OLD); bgp_show_peer_afi_orf_cap (vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, PEER_CAP_ORF_PREFIX_RM_ADV, @@ -7750,45 +7724,45 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, vty_out (vty, " sent;"); if (orf_pfx_count) vty_out (vty, " received (%d entries)", orf_pfx_count); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) - vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTYNL); + vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) - vty_out (vty, " Route-Reflector Client%s", VTYNL); + vty_out (vty, " Route-Reflector Client\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) - vty_out (vty, " Route-Server Client%s", VTYNL); + vty_out (vty, " Route-Server Client\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) - vty_out (vty, " Inbound soft reconfiguration allowed%s", VTYNL); + vty_out (vty, " Inbound soft reconfiguration allowed\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) - vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTYNL); + vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor\n"); else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) - vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTYNL); + vty_out (vty, " Private AS numbers replaced in updates to this neighbor\n"); else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) - vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTYNL); + vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor\n"); else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) - vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTYNL); + vty_out (vty, " Private AS numbers removed in updates to this neighbor\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) - vty_out (vty, " Advertise all paths via addpath%s", VTYNL); + vty_out (vty, " Advertise all paths via addpath\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) - vty_out (vty, " Advertise bestpath per AS via addpath%s", VTYNL); + vty_out (vty, " Advertise bestpath per AS via addpath\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) - vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTYNL); + vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) - vty_out (vty, " NEXT_HOP is always this router%s", VTYNL); + vty_out (vty, " NEXT_HOP is always this router\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) - vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTYNL); + vty_out (vty, " AS_PATH is propagated unchanged to this neighbor\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) - vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTYNL); + vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) - vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTYNL); + vty_out (vty, " MED is propagated unchanged to this neighbor\n"); if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) @@ -7797,13 +7771,13 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) - vty_out (vty, "(all)%s", VTYNL); + vty_out (vty, "(all)\n"); else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) - vty_out (vty, "(large)%s", VTYNL); + vty_out (vty, "(large)\n"); else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) - vty_out (vty, "(extended)%s", VTYNL); + vty_out (vty, "(extended)\n"); else - vty_out (vty, "(standard)%s", VTYNL); + vty_out (vty, "(standard)\n"); } if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) { @@ -7814,94 +7788,86 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, p->default_rmap[afi][safi].map ? "*" : "", p->default_rmap[afi][safi].name); if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) - vty_out (vty, " default sent%s", VTYNL); + vty_out (vty, " default sent\n"); else - vty_out (vty, " default not sent%s", VTYNL); + vty_out (vty, " default not sent\n"); } if (filter->plist[FILTER_IN].name || filter->dlist[FILTER_IN].name || filter->aslist[FILTER_IN].name || filter->map[RMAP_IN].name) - vty_out (vty, " Inbound path policy configured%s", VTYNL); + vty_out (vty, " Inbound path policy configured\n"); if (filter->plist[FILTER_OUT].name || filter->dlist[FILTER_OUT].name || filter->aslist[FILTER_OUT].name || filter->map[RMAP_OUT].name || filter->usmap.name) - vty_out (vty, " Outbound path policy configured%s", VTYNL); + vty_out (vty, " Outbound path policy configured\n"); /* prefix-list */ if (filter->plist[FILTER_IN].name) - vty_out (vty, " Incoming update prefix filter list is %s%s%s", + vty_out (vty, " Incoming update prefix filter list is %s%s\n", filter->plist[FILTER_IN].plist ? "*" : "", - filter->plist[FILTER_IN].name, - VTYNL); + filter->plist[FILTER_IN].name); if (filter->plist[FILTER_OUT].name) - vty_out (vty, " Outgoing update prefix filter list is %s%s%s", + vty_out (vty, " Outgoing update prefix filter list is %s%s\n", filter->plist[FILTER_OUT].plist ? "*" : "", - filter->plist[FILTER_OUT].name, - VTYNL); + filter->plist[FILTER_OUT].name); /* distribute-list */ if (filter->dlist[FILTER_IN].name) - vty_out (vty, " Incoming update network filter list is %s%s%s", + vty_out (vty, " Incoming update network filter list is %s%s\n", filter->dlist[FILTER_IN].alist ? "*" : "", - filter->dlist[FILTER_IN].name, - VTYNL); + filter->dlist[FILTER_IN].name); if (filter->dlist[FILTER_OUT].name) - vty_out (vty, " Outgoing update network filter list is %s%s%s", + vty_out (vty, " Outgoing update network filter list is %s%s\n", filter->dlist[FILTER_OUT].alist ? "*" : "", - filter->dlist[FILTER_OUT].name, - VTYNL); + filter->dlist[FILTER_OUT].name); /* filter-list. */ if (filter->aslist[FILTER_IN].name) - vty_out (vty, " Incoming update AS path filter list is %s%s%s", + vty_out (vty, " Incoming update AS path filter list is %s%s\n", filter->aslist[FILTER_IN].aslist ? "*" : "", - filter->aslist[FILTER_IN].name, - VTYNL); + filter->aslist[FILTER_IN].name); if (filter->aslist[FILTER_OUT].name) - vty_out (vty, " Outgoing update AS path filter list is %s%s%s", + vty_out (vty, " Outgoing update AS path filter list is %s%s\n", filter->aslist[FILTER_OUT].aslist ? "*" : "", - filter->aslist[FILTER_OUT].name, - VTYNL); + filter->aslist[FILTER_OUT].name); /* route-map. */ if (filter->map[RMAP_IN].name) - vty_out (vty, " Route map for incoming advertisements is %s%s%s", + vty_out (vty, " Route map for incoming advertisements is %s%s\n", filter->map[RMAP_IN].map ? "*" : "", - filter->map[RMAP_IN].name, - VTYNL); + filter->map[RMAP_IN].name); if (filter->map[RMAP_OUT].name) - vty_out (vty, " Route map for outgoing advertisements is %s%s%s", + vty_out (vty, " Route map for outgoing advertisements is %s%s\n", filter->map[RMAP_OUT].map ? "*" : "", - filter->map[RMAP_OUT].name, - VTYNL); + filter->map[RMAP_OUT].name); /* unsuppress-map */ if (filter->usmap.name) - vty_out (vty, " Route map for selective unsuppress is %s%s%s", + vty_out (vty, " Route map for selective unsuppress is %s%s\n", filter->usmap.map ? "*" : "", - filter->usmap.name, VTYNL); + filter->usmap.name); /* Receive prefix count */ - vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTYNL); + vty_out (vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); /* Maximum prefix */ if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { - vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], + vty_out (vty, " Maximum prefixes allowed %ld%s\n", p->pmax[afi][safi], CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) - ? " (warning-only)" : "", VTYNL); + ? " (warning-only)" : ""); vty_out (vty, " Threshold for warning message %d%%", p->pmax_threshold[afi][safi]); if (p->pmax_restart[afi][safi]) vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } @@ -7988,9 +7954,9 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js else { if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) - vty_out (vty, "confed-internal link%s", VTYNL); + vty_out (vty, "confed-internal link\n"); else - vty_out (vty, "internal link%s", VTYNL); + vty_out (vty, "internal link\n"); } } else @@ -8005,9 +7971,9 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js else { if (bgp_confederation_peers_check(bgp, p->as)) - vty_out (vty, "confed-external link%s", VTYNL); + vty_out (vty, "confed-external link\n"); else - vty_out (vty, "external link%s", VTYNL); + vty_out (vty, "external link\n"); } } @@ -8017,7 +7983,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (use_json) json_object_string_add(json_neigh, "nbrDesc", p->desc); else - vty_out (vty, " Description: %s%s", p->desc, VTYNL); + vty_out (vty, " Description: %s\n", p->desc); } if (p->hostname) @@ -8033,10 +7999,9 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js else { if (p->domainname && (p->domainname[0] != '\0')) - vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, - VTYNL); + vty_out(vty, "Hostname: %s.%s\n", p->hostname, p->domainname); else - vty_out(vty, "Hostname: %s%s", p->hostname, VTYNL); + vty_out(vty, "Hostname: %s\n", p->hostname); } } @@ -8064,8 +8029,8 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } else { - vty_out (vty, " Member of peer-group %s for session parameters%s", - p->group->name, VTYNL); + vty_out (vty, " Member of peer-group %s for session parameters\n", + p->group->name); if (dn_flag[0]) { @@ -8077,7 +8042,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (range) { prefix2str(range, buf1, sizeof(buf1)); - vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTYNL); + vty_out (vty, " Belongs to the subnet range group: %s\n", buf1); } } } @@ -8158,18 +8123,17 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js { /* Administrative shutdown. */ if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) - vty_out (vty, " Administratively shut down%s", VTYNL); + vty_out (vty, " Administratively shut down\n"); /* BGP Version. */ vty_out (vty, " BGP version 4"); - vty_out (vty, ", remote router ID %s%s", - inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)), - VTYNL); + vty_out (vty, ", remote router ID %s\n", + inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1))); /* Confederation */ if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) - vty_out (vty, " Neighbor under common administration%s", VTYNL); + vty_out (vty, " Neighbor under common administration\n"); /* Status. */ vty_out (vty, " BGP state = %s", lookup_msg(bgp_status_msg, p->status, NULL)); @@ -8184,21 +8148,21 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) vty_out (vty, " (NSF passive)"); } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); /* read timer */ vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); - vty_out (vty, ", Last write %s%s", - peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTYNL); + vty_out (vty, ", Last write %s\n", + peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL)); /* Configured timer values. */ - vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", - p->v_holdtime, p->v_keepalive, VTYNL); + vty_out (vty, " Hold time is %d, keepalive interval is %d seconds\n", + p->v_holdtime, p->v_keepalive); if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) { vty_out (vty, " Configured hold time is %d", p->holdtime); - vty_out (vty, ", keepalive interval is %d seconds%s", - p->keepalive, VTYNL); + vty_out (vty, ", keepalive interval is %d seconds\n", + p->keepalive); } } /* Capability. */ @@ -8430,7 +8394,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } else { - vty_out (vty, " Neighbor capabilities:%s", VTYNL); + vty_out (vty, " Neighbor capabilities:\n"); /* AS4 */ if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) @@ -8442,14 +8406,14 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) vty_out (vty, " %sreceived", CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* AddPath */ if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) { - vty_out (vty, " AddPath:%s", VTYNL); + vty_out (vty, " AddPath:\n"); for (afi = AFI_IP ; afi < AFI_MAX ; afi++) for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) @@ -8465,7 +8429,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || @@ -8479,7 +8443,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } } @@ -8494,7 +8458,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) vty_out (vty, " %sreceived", CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Extended nexthop */ @@ -8507,15 +8471,15 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) vty_out (vty, " %sreceived", CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) { - vty_out (vty, " Address families by peer:%s ", VTYNL); + vty_out (vty, " Address families by peer:\n "); for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) - vty_out (vty, " %s%s", - afi_safi_print (AFI_IP, safi), VTYNL); + vty_out (vty, " %s\n", + afi_safi_print (AFI_IP, safi)); } } @@ -8535,7 +8499,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Multiprotocol Extensions */ @@ -8548,7 +8512,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js vty_out (vty, " advertised"); if (p->afc_recv[afi][safi]) vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Hostname capability */ @@ -8561,7 +8525,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) vty_out (vty, " %sreceived", CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Gracefull Restart */ @@ -8574,15 +8538,15 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) vty_out (vty, " %sreceived", CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) { int restart_af_count = 0; - vty_out (vty, " Remote Restart timer is %d seconds%s", - p->v_gr_restart, VTYNL); - vty_out (vty, " Address families by peer:%s ", VTYNL); + vty_out (vty, " Remote Restart timer is %d seconds\n", + p->v_gr_restart); + vty_out (vty, " Address families by peer:\n "); for (afi = AFI_IP ; afi < AFI_MAX ; afi++) for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) @@ -8596,7 +8560,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } if (! restart_af_count) vty_out (vty, "none"); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } } @@ -8659,7 +8623,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } else { - vty_out (vty, " Graceful restart informations:%s", VTYNL); + vty_out (vty, " Graceful restart informations:\n"); if (p->status == Established) { vty_out (vty, " End-of-RIB send: "); @@ -8675,7 +8639,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } } } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); vty_out (vty, " End-of-RIB received: "); for (afi = AFI_IP ; afi < AFI_MAX ; afi++) { @@ -8689,16 +8653,16 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } } } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } if (p->t_gr_restart) - vty_out (vty, " The remaining time of restart timer is %ld%s", - thread_timer_remain_second (p->t_gr_restart), VTYNL); + vty_out (vty, " The remaining time of restart timer is %ld\n", + thread_timer_remain_second (p->t_gr_restart)); if (p->t_gr_stale) - vty_out (vty, " The remaining time of stalepath timer is %ld%s", - thread_timer_remain_second (p->t_gr_stale), VTYNL); + vty_out (vty, " The remaining time of stalepath timer is %ld\n", + thread_timer_remain_second (p->t_gr_stale)); } } if (use_json) @@ -8727,20 +8691,20 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js else { /* Packet counts. */ - vty_out (vty, " Message statistics:%s", VTYNL); - vty_out (vty, " Inq depth is 0%s", VTYNL); - vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTYNL); - vty_out (vty, " Sent Rcvd%s", VTYNL); - vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTYNL); - vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTYNL); - vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTYNL); - vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTYNL); - vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTYNL); - vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTYNL); - vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + + vty_out (vty, " Message statistics:\n"); + vty_out (vty, " Inq depth is 0\n"); + vty_out (vty, " Outq depth is %lu\n", (unsigned long) p->obuf->count); + vty_out (vty, " Sent Rcvd\n"); + vty_out (vty, " Opens: %10d %10d\n", p->open_out, p->open_in); + vty_out (vty, " Notifications: %10d %10d\n", p->notify_out, p->notify_in); + vty_out (vty, " Updates: %10d %10d\n", p->update_out, p->update_in); + vty_out (vty, " Keepalives: %10d %10d\n", p->keepalive_out, p->keepalive_in); + vty_out (vty, " Route Refresh: %10d %10d\n", p->refresh_out, p->refresh_in); + vty_out (vty, " Capability: %10d %10d\n", p->dynamic_cap_out, p->dynamic_cap_in); + vty_out (vty, " Total: %10d %10d\n", p->open_out + p->notify_out + p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + - p->dynamic_cap_in, VTYNL); + p->dynamic_cap_in); } if (use_json) @@ -8760,8 +8724,8 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js else { /* advertisement-interval */ - vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", - p->v_routeadv, VTYNL); + vty_out (vty, " Minimum time between advertisement runs is %d seconds\n", + p->v_routeadv); /* Update-source. */ if (p->update_if || p->update_source) @@ -8771,10 +8735,10 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js vty_out (vty, "%s", p->update_if); else if (p->update_source) vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Address Family Information */ @@ -8795,15 +8759,14 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js json_object_int_add(json_neigh, "connectionsDropped", p->dropped); } else - vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, - VTYNL); + vty_out (vty, " Connections established %d; dropped %d\n", p->established, p->dropped); if (! p->last_reset) { if (use_json) json_object_string_add(json_neigh, "lastReset", "never"); else - vty_out (vty, " Last reset never%s", VTYNL); + vty_out (vty, " Last reset never\n"); } else { @@ -8856,9 +8819,9 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js { code_str = bgp_notify_code_str(p->notify.code); subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); - vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", + vty_out (vty, "due to NOTIFICATION %s (%s%s)\n", p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", - code_str, subcode_str, VTYNL); + code_str, subcode_str); if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED && p->notify.code == BGP_NOTIFY_CEASE && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN @@ -8871,19 +8834,19 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf), (u_char*)p->notify.data, p->notify.length); if (msg_str) - vty_out (vty, " Message: \"%s\"%s", msg_str, VTYNL); + vty_out (vty, " Message: \"%s\"\n", msg_str); } } else { - vty_out (vty, "due to %s%s", - peer_down_str[(int) p->last_reset], VTYNL); + vty_out (vty, "due to %s\n", + peer_down_str[(int) p->last_reset]); } if (p->last_reset_cause_size) { msg = p->last_reset_cause; - vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTYNL); + vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:\n "); for (i = 1; i <= p->last_reset_cause_size; i++) { vty_out(vty, "%02X", *msg++); @@ -8892,7 +8855,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js { if (i % 16 == 0) { - vty_out(vty, "%s ", VTYNL); + vty_out(vty, "\n "); } else if (i % 4 == 0) { @@ -8900,7 +8863,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } } } - vty_out(vty, "%s", VTYNL); + vty_out(vty, "\n"); } } } @@ -8910,7 +8873,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (use_json) json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); else - vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTYNL); + vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.\n"); if (p->t_pmax_restart) { @@ -8920,17 +8883,16 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); } else - vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", - p->host, thread_timer_remain_second (p->t_pmax_restart), - VTYNL); + vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds\n", + p->host, thread_timer_remain_second (p->t_pmax_restart)); } else { if (use_json) json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); else - vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", - p->host, VTYNL); + vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", + p->host); } } @@ -8947,11 +8909,11 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js else { if (p->gtsm_hops > 0) - vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", - p->gtsm_hops, VTYNL); + vty_out (vty, " External BGP neighbor may be up to %d hops away.\n", + p->gtsm_hops); else if (p->ttl > 1) - vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", - p->ttl, VTYNL); + vty_out (vty, " External BGP neighbor may be up to %d hops away.\n", + p->ttl); } } else @@ -8961,8 +8923,8 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (use_json) json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); else - vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", - p->gtsm_hops, VTYNL); + vty_out (vty, " Internal BGP neighbor may be up to %d hops away.\n", + p->gtsm_hops); } } @@ -8975,10 +8937,9 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); } else - vty_out (vty, "Local host: %s, Local port: %d%s", + vty_out (vty, "Local host: %s, Local port: %d\n", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), - ntohs (p->su_local->sin.sin_port), - VTYNL); + ntohs (p->su_local->sin.sin_port)); } /* Remote address. */ @@ -8990,10 +8951,9 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); } else - vty_out (vty, "Foreign host: %s, Foreign port: %d%s", + vty_out (vty, "Foreign host: %s, Foreign port: %d\n", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), - ntohs (p->su_remote->sin.sin_port), - VTYNL); + ntohs (p->su_remote->sin.sin_port)); } /* Nexthop display. */ @@ -9014,18 +8974,14 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } else { - vty_out (vty, "Nexthop: %s%s", - inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)), - VTYNL); - vty_out (vty, "Nexthop global: %s%s", - inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)), - VTYNL); - vty_out (vty, "Nexthop local: %s%s", - inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)), - VTYNL); - vty_out (vty, "BGP connection: %s%s", - p->shared_network ? "shared network" : "non shared network", - VTYNL); + vty_out (vty, "Nexthop: %s\n", + inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1))); + vty_out (vty, "Nexthop global: %s\n", + inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1))); + vty_out (vty, "Nexthop local: %s\n", + inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1))); + vty_out (vty, "BGP connection: %s\n", + p->shared_network ? "shared network" : "non shared network"); } } @@ -9058,28 +9014,26 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } else { - vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", - p->v_connect, VTYNL); + vty_out (vty, "BGP Connect Retry Timer in Seconds: %d\n", + p->v_connect); if (p->status == Established && p->rtt) - vty_out (vty, "Estimated round trip time: %d ms%s", - p->rtt, VTYNL); + vty_out (vty, "Estimated round trip time: %d ms\n", + p->rtt); if (p->t_start) - vty_out (vty, "Next start timer due in %ld seconds%s", - thread_timer_remain_second (p->t_start), VTYNL); + vty_out (vty, "Next start timer due in %ld seconds\n", + thread_timer_remain_second (p->t_start)); if (p->t_connect) - vty_out (vty, "Next connect timer due in %ld seconds%s", - thread_timer_remain_second (p->t_connect), VTYNL); + vty_out (vty, "Next connect timer due in %ld seconds\n", + thread_timer_remain_second (p->t_connect)); if (p->t_routeadv) - vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", - p->v_routeadv, thread_timer_remain_second (p->t_routeadv), - VTYNL); + vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds\n", + p->v_routeadv, thread_timer_remain_second (p->t_routeadv)); if (p->password) - vty_out (vty, "Peer Authentication Enabled%s", VTYNL); + vty_out (vty, "Peer Authentication Enabled\n"); - vty_out (vty, "Read thread: %s Write thread: %s%s", + vty_out (vty, "Read thread: %s Write thread: %s\n", p->t_read ? "on" : "off", - p->t_write ? "on" : "off", - VTYNL); + p->t_write ? "on" : "off"); } if (p->notify.code == BGP_NOTIFY_OPEN_ERR @@ -9087,7 +9041,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js bgp_capability_vty_out (vty, p, use_json, json_neigh); if (!use_json) - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); /* BFD information. */ bgp_bfd_show_info(vty, p, use_json, json_neigh); @@ -9146,17 +9100,17 @@ bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, if (use_json) json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); else - vty_out (vty, "%% No such neighbor%s", VTYNL); + vty_out (vty, "%% No such neighbor\n"); } if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } return CMD_SUCCESS; @@ -9171,7 +9125,7 @@ bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) int is_first = 1; if (use_json) - vty_out (vty, "{%s", VTYNL); + vty_out (vty, "{\n"); for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) { @@ -9181,8 +9135,7 @@ bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) { zlog_err("Unable to allocate memory for JSON object"); vty_out (vty, - "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", - VTYNL); + "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); return; } @@ -9194,7 +9147,7 @@ bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) ? "Default" : bgp->name); if (! is_first) - vty_out (vty, ",%s", VTYNL); + vty_out (vty, ",\n"); else is_first = 0; @@ -9203,17 +9156,15 @@ bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) } else { - vty_out (vty, "%sInstance %s:%s", - VTYNL, + vty_out (vty, "\nInstance %s:\n", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) - ? "Default" : bgp->name, - VTYNL); + ? "Default" : bgp->name); } bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); } if (use_json) - vty_out (vty, "}%s", VTYNL); + vty_out (vty, "}\n"); } static int @@ -9241,11 +9192,11 @@ bgp_show_neighbor_vty (struct vty *vty, const char *name, { json = json_object_new_object(); json_object_boolean_true_add(json, "bgpNoSuchInstance"); - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_out (vty, "%% No such BGP instance exist%s", VTYNL); + vty_out (vty, "%% No such BGP instance exist\n"); return CMD_WARNING; } @@ -9335,7 +9286,7 @@ DEFUN (show_ip_bgp_paths, BGP_SAFI_HELP_STR "Path information\n") { - vty_out (vty, "Address Refcnt Path%s", VTYNL); + vty_out (vty, "Address Refcnt Path\n"); aspath_print_all_vty (vty); return CMD_SUCCESS; } @@ -9348,8 +9299,8 @@ community_show_all_iterator (struct hash_backet *backet, struct vty *vty) struct community *com; com = (struct community *) backet->data; - vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, - community_str (com), VTYNL); + vty_out (vty, "[%p] (%ld) %s\n", (void *)backet, com->refcnt, + community_str (com)); } /* Show BGP's community internal data. */ @@ -9361,7 +9312,7 @@ DEFUN (show_ip_bgp_community_info, BGP_STR "List all bgp community information\n") { - vty_out (vty, "Address Refcnt Community%s", VTYNL); + vty_out (vty, "Address Refcnt Community\n"); hash_iterate (community_hash (), (void (*) (struct hash_backet *, void *)) @@ -9377,8 +9328,8 @@ lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty) struct lcommunity *lcom; lcom = (struct lcommunity *) backet->data; - vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt, - lcommunity_str (lcom), VTYNL); + vty_out (vty, "[%p] (%ld) %s\n", (void *)backet, lcom->refcnt, + lcommunity_str (lcom)); } /* Show BGP's community internal data. */ @@ -9390,7 +9341,7 @@ DEFUN (show_ip_bgp_lcommunity_info, BGP_STR "List all bgp large-community information\n") { - vty_out (vty, "Address Refcnt Large-community%s", VTYNL); + vty_out (vty, "Address Refcnt Large-community\n"); hash_iterate (lcommunity_hash (), (void (*) (struct hash_backet *, void *)) @@ -9421,10 +9372,8 @@ bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) { - vty_out (vty, "%sInstance %s:%s", - VTYNL, - (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, - VTYNL); + vty_out (vty, "\nInstance %s:\n", + (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name); update_group_show(bgp, afi, safi, vty, 0); } } @@ -9807,20 +9756,17 @@ bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { - vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", - VTYNL, group->name, conf->as, VTYNL); + vty_out (vty, "\nBGP peer-group %s, remote AS %d\n", group->name, conf->as); } else if (conf->as_type == AS_INTERNAL) { - vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", - VTYNL, group->name, group->bgp->as, VTYNL); + vty_out (vty, "\nBGP peer-group %s, remote AS %d\n", group->name, group->bgp->as); } else { - vty_out (vty, "%sBGP peer-group %s%s", - VTYNL, group->name, VTYNL); + vty_out (vty, "\nBGP peer-group %s\n", group->name); } if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) - vty_out (vty, " Peer-group type is internal%s", VTYNL); + vty_out (vty, " Peer-group type is internal\n"); else - vty_out (vty, " Peer-group type is external%s", VTYNL); + vty_out (vty, " Peer-group type is external\n"); /* Display AFs configured. */ vty_out (vty, " Configured address-families:"); @@ -9834,9 +9780,9 @@ bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) } } if (!af_cfgd) - vty_out (vty, " none%s", VTYNL); + vty_out (vty, " none\n"); else - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); /* Display listen ranges (for dynamic neighbors), if any */ for (afi = AFI_IP; afi < AFI_MAX; afi++) @@ -9851,15 +9797,15 @@ bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) if (lr_count) { vty_out(vty, - " %d %s listen range(s)%s", - lr_count, af_str, VTYNL); + " %d %s listen range(s)\n", + lr_count, af_str); for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, nnode, range)) { prefix2str(range, buf, sizeof(buf)); - vty_out(vty, " %s%s", buf, VTYNL); + vty_out(vty, " %s\n", buf); } } } @@ -9867,7 +9813,7 @@ bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) /* Display group members and their status */ if (listcount(group->peer)) { - vty_out (vty, " Peer-group members:%s", VTYNL); + vty_out (vty, " Peer-group members:\n"); for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) @@ -9878,9 +9824,9 @@ bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) peer_status = lookup_msg(bgp_status_msg, peer->status, NULL); dynamic = peer_dynamic_neighbor(peer); - vty_out (vty, " %s %s %s %s", + vty_out (vty, " %s %s %s \n", peer->host, dynamic ? "(dynamic)" : "", - peer_status, VTYNL); + peer_status); } } @@ -9920,7 +9866,7 @@ bgp_show_peer_group (struct vty *vty, struct bgp *bgp, } if (type == show_peer_group && ! find) - vty_out (vty, "%% No such peer-group%s", VTYNL); + vty_out (vty, "%% No such peer-group\n"); return CMD_SUCCESS; } @@ -9939,7 +9885,7 @@ bgp_show_peer_group_vty (struct vty *vty, const char *name, if (! bgp) { - vty_out (vty, "%% No such BGP instance exist%s", VTYNL); + vty_out (vty, "%% No such BGP instance exist\n"); return CMD_WARNING; } @@ -9984,8 +9930,8 @@ DEFUN (bgp_redistribute_ipv4, type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } bgp_redist_add(bgp, AFI_IP, type, 0); return bgp_redistribute_set (bgp, AFI_IP, type, 0); @@ -10014,8 +9960,8 @@ DEFUN (bgp_redistribute_ipv4_rmap, type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } red = bgp_redist_add(bgp, AFI_IP, type, 0); @@ -10049,8 +9995,8 @@ DEFUN (bgp_redistribute_ipv4_metric, type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } metric = strtoul(argv[idx_number]->arg, NULL, 10); @@ -10088,8 +10034,8 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric, type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } metric = strtoul(argv[idx_number]->arg, NULL, 10); @@ -10130,8 +10076,8 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap, type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } metric = strtoul(argv[idx_number]->arg, NULL, 10); @@ -10420,8 +10366,8 @@ DEFUN (no_bgp_redistribute_ipv4, type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_redistribute_unset (bgp, AFI_IP, type, 0); } @@ -10450,8 +10396,8 @@ DEFUN (bgp_redistribute_ipv6, type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } bgp_redist_add(bgp, AFI_IP6, type, 0); @@ -10475,8 +10421,8 @@ DEFUN (bgp_redistribute_ipv6_rmap, type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } red = bgp_redist_add(bgp, AFI_IP6, type, 0); @@ -10502,8 +10448,8 @@ DEFUN (bgp_redistribute_ipv6_metric, type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } metric = strtoul(argv[idx_number]->arg, NULL, 10); @@ -10533,8 +10479,8 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric, type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } metric = strtoul(argv[idx_number]->arg, NULL, 10); @@ -10565,8 +10511,8 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap, type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } metric = strtoul(argv[idx_number]->arg, NULL, 10); @@ -10594,8 +10540,8 @@ DEFUN (no_bgp_redistribute_ipv6, type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); if (type < 0) { - vty_out (vty, "%% Invalid route type%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); @@ -10637,7 +10583,7 @@ bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, vty_out (vty, " metric %u", red->redist_metric); if (red->rmap.name) vty_out (vty, " route-map %s", red->rmap.name); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } } @@ -10715,6 +10661,13 @@ static struct cmd_node bgp_evpn_node = 1 }; +static struct cmd_node bgp_evpn_vni_node = +{ + BGP_EVPN_VNI_NODE, + "%s(config-router-af-vni)# ", + 1 +}; + static void community_list_vty (void); static void @@ -10784,6 +10737,7 @@ bgp_vty_init (void) install_node (&bgp_vpnv4_node, NULL); install_node (&bgp_vpnv6_node, NULL); install_node (&bgp_evpn_node, NULL); + install_node (&bgp_evpn_vni_node, NULL); /* Install default VTY commands to new nodes. */ install_default (BGP_NODE); @@ -10796,6 +10750,7 @@ bgp_vty_init (void) install_default (BGP_VPNV4_NODE); install_default (BGP_VPNV6_NODE); install_default (BGP_EVPN_NODE); + install_default (BGP_EVPN_VNI_NODE); /* "bgp multiple-instance" commands. */ install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); @@ -11286,6 +11241,8 @@ bgp_vty_init (void) install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); + install_element (BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); + install_element (BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); /* "neighbor route-server" commands.*/ install_element (BGP_NODE, &neighbor_route_server_client_hidden_cmd); @@ -11659,6 +11616,8 @@ bgp_vty_init (void) install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); + install_element (BGP_EVPN_NODE, &neighbor_allowas_in_cmd); + install_element (BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); /* address-family commands. */ install_element (BGP_NODE, &address_family_ipv4_safi_cmd); @@ -11801,16 +11760,16 @@ community_list_perror (struct vty *vty, int ret) switch (ret) { case COMMUNITY_LIST_ERR_CANT_FIND_LIST: - vty_out (vty, "%% Can't find community-list%s", VTYNL); + vty_out (vty, "%% Can't find community-list\n"); break; case COMMUNITY_LIST_ERR_MALFORMED_VAL: - vty_out (vty, "%% Malformed community-list value%s", VTYNL); + vty_out (vty, "%% Malformed community-list value\n"); break; case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: - vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTYNL); + vty_out (vty, "%% Community name conflict, previously defined as standard community\n"); break; case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: - vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTYNL); + vty_out (vty, "%% Community name conflict, previously defined as expanded community\n"); break; } } @@ -11852,7 +11811,7 @@ DEFUN (ip_community_list_standard, { /* Display error string. */ community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -11892,7 +11851,7 @@ DEFUN (no_ip_community_list_standard_all, if (ret < 0) { community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -11931,7 +11890,7 @@ DEFUN (ip_community_list_expanded_all, { /* Display error string. */ community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -11971,7 +11930,7 @@ DEFUN (no_ip_community_list_expanded_all, if (ret < 0) { community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -11987,25 +11946,24 @@ community_list_show (struct vty *vty, struct community_list *list) if (entry == list->head) { if (all_digit (list->name)) - vty_out (vty, "Community %s list %s%s", + vty_out (vty, "Community %s list %s\n", entry->style == COMMUNITY_LIST_STANDARD ? "standard" : "(expanded) access", - list->name, VTYNL); + list->name); else - vty_out (vty, "Named Community %s list %s%s", + vty_out (vty, "Named Community %s list %s\n", entry->style == COMMUNITY_LIST_STANDARD ? "standard" : "expanded", - list->name, VTYNL); + list->name); } if (entry->any) - vty_out (vty, " %s%s", - community_direct_str (entry->direct), VTYNL); + vty_out (vty, " %s\n", + community_direct_str (entry->direct)); else - vty_out (vty, " %s %s%s", + vty_out (vty, " %s %s\n", community_direct_str (entry->direct), entry->style == COMMUNITY_LIST_STANDARD - ? community_str (entry->u.com) : entry->config, - VTYNL); + ? community_str (entry->u.com) : entry->config); } } @@ -12047,7 +12005,7 @@ DEFUN (show_ip_community_list_arg, list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); if (! list) { - vty_out (vty, "%% Can't find community-list%s", VTYNL); + vty_out (vty, "%% Can't find community-list\n"); return CMD_WARNING; } @@ -12079,8 +12037,8 @@ lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, cl_name = argv[idx]->arg; if (reject_all_digit_name && all_digit (cl_name)) { - vty_out (vty, "%% Community name cannot have all digits%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Community name cannot have all digits\n"); + return CMD_WARNING_CONFIG_FAILED; } idx = 0; @@ -12102,7 +12060,7 @@ lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, if (ret < 0) { community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -12150,7 +12108,7 @@ lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, if (ret < 0) { community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -12332,25 +12290,24 @@ lcommunity_list_show (struct vty *vty, struct community_list *list) if (entry == list->head) { if (all_digit (list->name)) - vty_out (vty, "Large community %s list %s%s", + vty_out (vty, "Large community %s list %s\n", entry->style == EXTCOMMUNITY_LIST_STANDARD ? "standard" : "(expanded) access", - list->name, VTYNL); + list->name); else - vty_out (vty, "Named large community %s list %s%s", + vty_out (vty, "Named large community %s list %s\n", entry->style == EXTCOMMUNITY_LIST_STANDARD ? "standard" : "expanded", - list->name, VTYNL); + list->name); } if (entry->any) - vty_out (vty, " %s%s", - community_direct_str (entry->direct), VTYNL); + vty_out (vty, " %s\n", + community_direct_str (entry->direct)); else - vty_out (vty, " %s %s%s", + vty_out (vty, " %s %s\n", community_direct_str (entry->direct), entry->style == EXTCOMMUNITY_LIST_STANDARD ? - entry->u.ecom->str : entry->config, - VTYNL); + entry->u.ecom->str : entry->config); } } @@ -12391,7 +12348,7 @@ DEFUN (show_ip_lcommunity_list_arg, list = community_list_lookup (bgp_clist, argv[3]->arg, LARGE_COMMUNITY_LIST_MASTER); if (! list) { - vty_out (vty, "%% Can't find extcommunity-list%s", VTYNL); + vty_out (vty, "%% Can't find extcommunity-list\n"); return CMD_WARNING; } @@ -12435,7 +12392,7 @@ DEFUN (ip_extcommunity_list_standard, if (ret < 0) { community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -12472,7 +12429,7 @@ DEFUN (ip_extcommunity_list_name_expanded, if (ret < 0) { community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -12512,7 +12469,7 @@ DEFUN (no_ip_extcommunity_list_standard_all, if (ret < 0) { community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -12552,7 +12509,7 @@ DEFUN (no_ip_extcommunity_list_expanded_all, if (ret < 0) { community_list_perror (vty, ret); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -12568,25 +12525,24 @@ extcommunity_list_show (struct vty *vty, struct community_list *list) if (entry == list->head) { if (all_digit (list->name)) - vty_out (vty, "Extended community %s list %s%s", + vty_out (vty, "Extended community %s list %s\n", entry->style == EXTCOMMUNITY_LIST_STANDARD ? "standard" : "(expanded) access", - list->name, VTYNL); + list->name); else - vty_out (vty, "Named extended community %s list %s%s", + vty_out (vty, "Named extended community %s list %s\n", entry->style == EXTCOMMUNITY_LIST_STANDARD ? "standard" : "expanded", - list->name, VTYNL); + list->name); } if (entry->any) - vty_out (vty, " %s%s", - community_direct_str (entry->direct), VTYNL); + vty_out (vty, " %s\n", + community_direct_str (entry->direct)); else - vty_out (vty, " %s %s%s", + vty_out (vty, " %s %s\n", community_direct_str (entry->direct), entry->style == EXTCOMMUNITY_LIST_STANDARD ? - entry->u.ecom->str : entry->config, - VTYNL); + entry->u.ecom->str : entry->config); } } @@ -12628,7 +12584,7 @@ DEFUN (show_ip_extcommunity_list_arg, list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); if (! list) { - vty_out (vty, "%% Can't find extcommunity-list%s", VTYNL); + vty_out (vty, "%% Can't find extcommunity-list\n"); return CMD_WARNING; } @@ -12670,21 +12626,19 @@ community_list_config_write (struct vty *vty) for (list = cm->num.head; list; list = list->next) for (entry = list->head; entry; entry = entry->next) { - vty_out (vty, "ip community-list %s %s %s%s", + vty_out (vty, "ip community-list %s %s %s\n", list->name, community_direct_str (entry->direct), - community_list_config_str (entry), - VTYNL); + community_list_config_str (entry)); write++; } for (list = cm->str.head; list; list = list->next) for (entry = list->head; entry; entry = entry->next) { - vty_out (vty, "ip community-list %s %s %s %s%s", + vty_out (vty, "ip community-list %s %s %s %s\n", entry->style == COMMUNITY_LIST_STANDARD ? "standard" : "expanded", list->name, community_direct_str (entry->direct), - community_list_config_str (entry), - VTYNL); + community_list_config_str (entry)); write++; } @@ -12694,19 +12648,19 @@ community_list_config_write (struct vty *vty) for (list = cm->num.head; list; list = list->next) for (entry = list->head; entry; entry = entry->next) { - vty_out (vty, "ip extcommunity-list %s %s %s%s", + vty_out (vty, "ip extcommunity-list %s %s %s\n", list->name, community_direct_str (entry->direct), - community_list_config_str (entry), VTYNL); + community_list_config_str (entry)); write++; } for (list = cm->str.head; list; list = list->next) for (entry = list->head; entry; entry = entry->next) { - vty_out (vty, "ip extcommunity-list %s %s %s %s%s", + vty_out (vty, "ip extcommunity-list %s %s %s %s\n", entry->style == EXTCOMMUNITY_LIST_STANDARD ? "standard" : "expanded", list->name, community_direct_str (entry->direct), - community_list_config_str (entry), VTYNL); + community_list_config_str (entry)); write++; } @@ -12717,19 +12671,19 @@ community_list_config_write (struct vty *vty) for (list = cm->num.head; list; list = list->next) for (entry = list->head; entry; entry = entry->next) { - vty_out (vty, "ip large-community-list %s %s %s%s", + vty_out (vty, "ip large-community-list %s %s %s\n", list->name, community_direct_str (entry->direct), - community_list_config_str (entry), VTYNL); + community_list_config_str (entry)); write++; } for (list = cm->str.head; list; list = list->next) for (entry = list->head; entry; entry = entry->next) { - vty_out (vty, "ip large-community-list %s %s %s %s%s", + vty_out (vty, "ip large-community-list %s %s %s %s\n", entry->style == LARGE_COMMUNITY_LIST_STANDARD ? "standard" : "expanded", list->name, community_direct_str (entry->direct), - community_list_config_str (entry), VTYNL); + community_list_config_str (entry)); write++; } diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index edc994a57..62228c64e 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -69,4 +69,7 @@ argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, safi_t * extern int bgp_vty_find_and_parse_afi_safi_bgp (struct vty *vty, struct cmd_token **argv, int argc, int *idx, afi_t *afi, safi_t *safi, struct bgp **bgp); +extern int +bgp_show_summary_vty (struct vty *vty, const char *name, + afi_t afi, safi_t safi, u_char use_json); #endif /* _QUAGGA_BGP_VTY_H */ diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 71a4d4317..f267e7a07 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -35,6 +35,7 @@ #include "lib/bfd.h" #include "filter.h" #include "mpls.h" +#include "vxlan.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_route.h" @@ -52,6 +53,7 @@ # include "bgpd/rfapi/rfapi_backend.h" # include "bgpd/rfapi/vnc_export_bgp.h" #endif +#include "bgpd/bgp_evpn.h" /* All information about zebra. */ struct zclient *zclient = NULL; @@ -71,14 +73,12 @@ struct stream *bgp_label_buf = NULL; 2. use an array to avoid number of mallocs. Number of supported next-hops are finite, use of arrays should be ok. */ struct attr attr_cp[MULTIPATH_NUM]; -struct attr_extra attr_extra_cp[MULTIPATH_NUM]; unsigned int attr_index = 0; /* Once per address-family initialization of the attribute array */ #define BGP_INFO_ATTR_BUF_INIT()\ do {\ memset(attr_cp, 0, MULTIPATH_NUM * sizeof(struct attr));\ - memset(attr_extra_cp, 0, MULTIPATH_NUM * sizeof(struct attr_extra));\ attr_index = 0;\ } while (0) @@ -86,7 +86,6 @@ do {\ do { \ *info_dst = *info_src; \ assert(attr_index != multipath_num);\ - attr_cp[attr_index].extra = &attr_extra_cp[attr_index]; \ bgp_attr_dup (&attr_cp[attr_index], info_src->attr); \ bgp_attr_deep_dup (&attr_cp[attr_index], info_src->attr); \ info_dst->attr = &attr_cp[attr_index]; \ @@ -1160,23 +1159,23 @@ bgp_info_to_ipv6_nexthop (struct bgp_info *info) struct in6_addr *nexthop = NULL; /* Only global address nexthop exists. */ - if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) - nexthop = &info->attr->extra->mp_nexthop_global; + if (info->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) + nexthop = &info->attr->mp_nexthop_global; /* If both global and link-local address present. */ - if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + if (info->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) { /* Check if route-map is set to prefer global over link-local */ - if (info->attr->extra->mp_nexthop_prefer_global) - nexthop = &info->attr->extra->mp_nexthop_global; + if (info->attr->mp_nexthop_prefer_global) + nexthop = &info->attr->mp_nexthop_global; else { /* Workaround for Cisco's nexthop bug. */ - if (IN6_IS_ADDR_UNSPECIFIED (&info->attr->extra->mp_nexthop_global) + if (IN6_IS_ADDR_UNSPECIFIED (&info->attr->mp_nexthop_global) && info->peer->su_remote->sa.sa_family == AF_INET6) nexthop = &info->peer->su_remote->sin6.sin6_addr; else - nexthop = &info->attr->extra->mp_nexthop_local; + nexthop = &info->attr->mp_nexthop_local; } } @@ -1246,10 +1245,7 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info flags = 0; peer = info->peer; - if ((info->attr->extra) && (info->attr->extra->tag != 0)) - tag = info->attr->extra->tag; - else - tag = 0; + tag = info->attr->tag; /* When we create an aggregate route we must also install a Null0 route in * the RIB */ @@ -1303,7 +1299,7 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info { /* Metric is currently based on the best-path only */ metric = info_cp->attr->med; - tag = info_cp->attr->extra->tag; + tag = info_cp->attr->tag; } nexthop = &info_cp->attr->nexthop; } @@ -1418,8 +1414,6 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info ifindex = 0; nexthop = NULL; - assert (info->attr->extra); - if (bgp->table_map[afi][safi].name) BGP_INFO_ATTR_BUF_INIT(); @@ -1439,7 +1433,7 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info if (mpinfo == info) { metric = info_cp->attr->med; - tag = info_cp->attr->extra->tag; + tag = info_cp->attr->tag; } nexthop = bgp_info_to_ipv6_nexthop(info_cp); } @@ -1452,7 +1446,7 @@ bgp_zebra_announce (struct bgp_node *rn, struct prefix *p, struct bgp_info *info continue; if ((mpinfo == info) && - mpinfo->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + mpinfo->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) if (mpinfo->peer->nexthop.ifp) ifindex = mpinfo->peer->nexthop.ifp->ifindex; @@ -1672,10 +1666,10 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi) api.metric = info->attr->med; api.tag = 0; - if ((info->attr->extra) && (info->attr->extra->tag != 0)) + if (info->attr->tag != 0) { SET_FLAG(api.message, ZAPI_MESSAGE_TAG); - api.tag = info->attr->extra->tag; + api.tag = info->attr->tag; } if (bgp_debug_zebra(p)) @@ -1694,8 +1688,6 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi) if (p->family == AF_INET6) { struct zapi_ipv6 api; - - assert (info->attr->extra); api.vrf_id = peer->bgp->vrf_id; api.flags = flags; @@ -1712,10 +1704,10 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi) api.metric = info->attr->med; api.tag = 0; - if ((info->attr->extra) && (info->attr->extra->tag != 0)) + if (info->attr->tag != 0) { SET_FLAG(api.message, ZAPI_MESSAGE_TAG); - api.tag = info->attr->extra->tag; + api.tag = info->attr->tag; } if (bgp_debug_zebra(p)) @@ -1823,7 +1815,7 @@ bgp_redistribute_set (struct bgp *bgp, afi_t afi, int type, u_short instance) * know of this instance. */ if (!bgp_install_info_to_zebra (bgp)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (BGP_DEBUG (zebra, ZEBRA)) zlog_debug("Tx redistribute add VRF %u afi %d %s %d", @@ -1901,9 +1893,7 @@ bgp_redistribute_metric_set (struct bgp *bgp, struct bgp_redist *red, afi_t afi, { struct attr *old_attr; struct attr new_attr; - struct attr_extra new_extra; - new_attr.extra = &new_extra; bgp_attr_dup (&new_attr, ri->attr); new_attr.med = red->redist_metric; old_attr = ri->attr; @@ -2033,6 +2023,11 @@ bgp_zebra_instance_register (struct bgp *bgp) /* Register for router-id, interfaces, redistributed routes. */ zclient_send_reg_requests (zclient, bgp->vrf_id); + + /* For default instance, register to learn about VNIs, if appropriate. */ + if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT + && bgp->advertise_all_vni) + bgp_zebra_advertise_all_vni (bgp, 1); } /* Deregister this instance with Zebra. Invoked upon the instance @@ -2048,6 +2043,11 @@ bgp_zebra_instance_deregister (struct bgp *bgp) if (BGP_DEBUG (zebra, ZEBRA)) zlog_debug("Deregistering VRF %u", bgp->vrf_id); + /* For default instance, unregister learning about VNIs, if appropriate. */ + if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT + && bgp->advertise_all_vni) + bgp_zebra_advertise_all_vni (bgp, 0); + /* Deregister for router-id, interfaces, redistributed routes. */ zclient_send_dereg_requests (zclient, bgp->vrf_id); } @@ -2080,6 +2080,29 @@ bgp_zebra_terminate_radv (struct bgp *bgp, struct peer *peer) zclient_send_interface_radv_req (zclient, bgp->vrf_id, peer->ifp, 0, 0); } +int +bgp_zebra_advertise_all_vni (struct bgp *bgp, int advertise) +{ + struct stream *s; + + /* Check socket. */ + if (!zclient || zclient->sock < 0) + return 0; + + /* Don't try to register if Zebra doesn't know of this instance. */ + if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) + return 0; + + s = zclient->obuf; + stream_reset (s); + + zclient_create_header (s, ZEBRA_ADVERTISE_ALL_VNI, bgp->vrf_id); + stream_putc(s, advertise); + stream_putw_at (s, 0, stream_get_endp (s)); + + return zclient_send_message(zclient); +} + /* BGP has established connection with Zebra. */ static void bgp_zebra_connected (struct zclient *zclient) @@ -2106,6 +2129,85 @@ bgp_zebra_connected (struct zclient *zclient) */ } +static int +bgp_zebra_process_local_vni (int command, struct zclient *zclient, + zebra_size_t length, vrf_id_t vrf_id) +{ + struct stream *s; + vni_t vni; + struct bgp *bgp; + struct in_addr vtep_ip; + + s = zclient->ibuf; + vni = stream_getl (s); + if (command == ZEBRA_VNI_ADD) + vtep_ip.s_addr = stream_get_ipv4 (s); + bgp = bgp_lookup_by_vrf_id (vrf_id); + if (!bgp) + return 0; + + if (BGP_DEBUG (zebra, ZEBRA)) + zlog_debug("Rx VNI %s VRF %u VNI %u", + (command == ZEBRA_VNI_ADD) ? "add" : "del", vrf_id, vni); + + if (command == ZEBRA_VNI_ADD) + return bgp_evpn_local_vni_add (bgp, vni, vtep_ip.s_addr? vtep_ip : bgp->router_id); + else + return bgp_evpn_local_vni_del (bgp, vni); +} + +static int +bgp_zebra_process_local_macip (int command, struct zclient *zclient, + zebra_size_t length, vrf_id_t vrf_id) +{ + struct stream *s; + vni_t vni; + struct bgp *bgp; + struct ethaddr mac; + struct ipaddr ip; + int ipa_len; + char buf[ETHER_ADDR_STRLEN]; + char buf1[INET6_ADDRSTRLEN]; + u_char sticky; + + memset (&ip, 0, sizeof (ip)); + s = zclient->ibuf; + vni = stream_getl (s); + stream_get (&mac.octet, s, ETHER_ADDR_LEN); + ipa_len = stream_getl (s); + if (ipa_len != 0 && + ipa_len != IPV4_MAX_BYTELEN && + ipa_len != IPV6_MAX_BYTELEN) + { + zlog_err ("%u:Recv MACIP %s with invalid IP addr length %d", + vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del", + ipa_len); + return -1; + } + + if (ipa_len) + { + ip.ipa_type = (ipa_len == IPV4_MAX_BYTELEN) ? IPADDR_V4: IPADDR_V6; + stream_get (&ip.ip.addr, s, ipa_len); + } + sticky = stream_getc (s); + + bgp = bgp_lookup_by_vrf_id (vrf_id); + if (!bgp) + return 0; + + if (BGP_DEBUG (zebra, ZEBRA)) + zlog_debug ("%u:Recv MACIP %s %sMAC %s IP %s VNI %u", + vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del", + sticky ? "sticky " : "", + prefix_mac2str (&mac, buf, sizeof (buf)), + ipaddr2str (&ip, buf1, sizeof(buf1)), vni); + + if (command == ZEBRA_MACIP_ADD) + return bgp_evpn_local_macip_add (bgp, vni, &mac, &ip, sticky); + else + return bgp_evpn_local_macip_del (bgp, vni, &mac, &ip); +} void bgp_zebra_init (struct thread_master *master) @@ -2133,6 +2235,10 @@ bgp_zebra_init (struct thread_master *master) zclient->nexthop_update = bgp_read_nexthop_update; zclient->import_check_update = bgp_read_import_check_update; zclient->fec_update = bgp_read_fec_update; + zclient->local_vni_add = bgp_zebra_process_local_vni; + zclient->local_vni_del = bgp_zebra_process_local_vni; + zclient->local_macip_add = bgp_zebra_process_local_macip; + zclient->local_macip_del = bgp_zebra_process_local_macip; bgp_nexthop_buf = stream_new(multipath_num * sizeof (struct in6_addr)); bgp_ifindices_buf = stream_new(multipath_num * sizeof (unsigned int)); diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h index 3d634ed69..7ad1f706d 100644 --- a/bgpd/bgp_zebra.h +++ b/bgpd/bgp_zebra.h @@ -54,6 +54,8 @@ extern struct interface *if_lookup_by_ipv4_exact (struct in_addr *, vrf_id_t); extern struct interface *if_lookup_by_ipv6 (struct in6_addr *, ifindex_t, vrf_id_t); extern struct interface *if_lookup_by_ipv6_exact (struct in6_addr *, ifindex_t, vrf_id_t); +extern int bgp_zebra_advertise_all_vni (struct bgp *, int); + extern int bgp_zebra_num_connects(void); #endif /* _QUAGGA_BGP_ZEBRA_H */ diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index d7ddd5db8..1b0d78ff9 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -227,6 +227,10 @@ bgp_router_id_set (struct bgp *bgp, const struct in_addr *id) if (IPV4_ADDR_SAME (&bgp->router_id, id)) return 0; + /* EVPN uses router id in RD, withdraw them */ + if (bgp->advertise_all_vni) + bgp_evpn_handle_router_id_update (bgp, TRUE); + IPV4_ADDR_COPY (&bgp->router_id, id); /* Set all peer's local identifier with this value. */ @@ -241,6 +245,11 @@ bgp_router_id_set (struct bgp *bgp, const struct in_addr *id) BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } + + /* EVPN uses router id in RD, update them */ + if (bgp->advertise_all_vni) + bgp_evpn_handle_router_id_update (bgp, FALSE); + return 0; } @@ -2251,7 +2260,7 @@ peer_group_get (struct bgp *bgp, const char *name) SET_FLAG (group->conf->sflags, PEER_STATUS_GROUP); listnode_add_sort (bgp->group, group); - return 0; + return group; } static void @@ -3004,6 +3013,7 @@ bgp_create (as_t *as, const char *name, enum bgp_instance_type inst_type) QOBJ_REG (bgp, bgp); update_bgp_group_init(bgp); + bgp_evpn_init(bgp); return bgp; } @@ -3355,6 +3365,8 @@ bgp_free (struct bgp *bgp) bgp_scan_finish (bgp); bgp_address_destroy (bgp); + bgp_evpn_cleanup (bgp); + if (bgp->name) XFREE(MTYPE_BGP, bgp->name); @@ -6502,15 +6514,15 @@ bgp_config_write_filter (struct vty *vty, struct peer *peer, || strcmp (filter->dlist[in].name, gfilter->dlist[in].name) != 0) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s distribute-list %s in%s", - addr, filter->dlist[in].name, VTYNL); + " neighbor %s distribute-list %s in\n", + addr, filter->dlist[in].name); } if (filter->dlist[out].name && ! gfilter) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s distribute-list %s out%s", - addr, filter->dlist[out].name, VTYNL); + " neighbor %s distribute-list %s out\n", + addr, filter->dlist[out].name); } /* prefix-list. */ @@ -6519,15 +6531,15 @@ bgp_config_write_filter (struct vty *vty, struct peer *peer, || strcmp (filter->plist[in].name, gfilter->plist[in].name) != 0) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s prefix-list %s in%s", - addr, filter->plist[in].name, VTYNL); + " neighbor %s prefix-list %s in\n", + addr, filter->plist[in].name); } if (filter->plist[out].name && ! gfilter) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s prefix-list %s out%s", - addr, filter->plist[out].name, VTYNL); + " neighbor %s prefix-list %s out\n", + addr, filter->plist[out].name); } /* route-map. */ @@ -6536,8 +6548,8 @@ bgp_config_write_filter (struct vty *vty, struct peer *peer, || strcmp (filter->map[RMAP_IN].name, gfilter->map[RMAP_IN].name) != 0) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s route-map %s in%s", - addr, filter->map[RMAP_IN].name, VTYNL); + " neighbor %s route-map %s in\n", + addr, filter->map[RMAP_IN].name); } if (filter->map[RMAP_OUT].name) @@ -6545,16 +6557,16 @@ bgp_config_write_filter (struct vty *vty, struct peer *peer, || strcmp (filter->map[RMAP_OUT].name, gfilter->map[RMAP_OUT].name) != 0) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s route-map %s out%s", - addr, filter->map[RMAP_OUT].name, VTYNL); + " neighbor %s route-map %s out\n", + addr, filter->map[RMAP_OUT].name); } /* unsuppress-map */ if (filter->usmap.name && ! gfilter) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s unsuppress-map %s%s", - addr, filter->usmap.name, VTYNL); + " neighbor %s unsuppress-map %s\n", + addr, filter->usmap.name); } /* filter-list. */ @@ -6563,15 +6575,15 @@ bgp_config_write_filter (struct vty *vty, struct peer *peer, || strcmp (filter->aslist[in].name, gfilter->aslist[in].name) != 0) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s filter-list %s in%s", - addr, filter->aslist[in].name, VTYNL); + " neighbor %s filter-list %s in\n", + addr, filter->aslist[in].name); } if (filter->aslist[out].name && ! gfilter) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s filter-list %s out%s", - addr, filter->aslist[out].name, VTYNL); + " neighbor %s filter-list %s out\n", + addr, filter->aslist[out].name); } } @@ -6626,7 +6638,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if_ras_printed = TRUE; } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* remote-as and peer-group */ @@ -6639,22 +6651,22 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, { if (peer->as_type == AS_SPECIFIED) { - vty_outln (vty, " neighbor %s remote-as %u", addr,peer->as); + vty_out (vty, " neighbor %s remote-as %u\n", addr,peer->as); } else if (peer->as_type == AS_INTERNAL) { - vty_outln (vty, " neighbor %s remote-as internal", addr); + vty_out (vty, " neighbor %s remote-as internal\n", addr); } else if (peer->as_type == AS_EXTERNAL) { - vty_outln (vty, " neighbor %s remote-as external", addr); + vty_out (vty, " neighbor %s remote-as external\n", addr); } } /* For swpX peers we displayed the peer-group * via 'neighbor swpX interface peer-group WORD' */ if (!if_pg_printed) - vty_outln (vty, " neighbor %s peer-group %s", addr, + vty_out (vty, " neighbor %s peer-group %s\n", addr, peer->group->name); } @@ -6664,22 +6676,22 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, /* peer is a peer-group, declare the peer-group */ if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { - vty_outln (vty, " neighbor %s peer-group",addr); + vty_out (vty, " neighbor %s peer-group\n",addr); } if (!if_ras_printed) { if (peer->as_type == AS_SPECIFIED) { - vty_outln (vty, " neighbor %s remote-as %u", addr,peer->as); + vty_out (vty, " neighbor %s remote-as %u\n", addr,peer->as); } else if (peer->as_type == AS_INTERNAL) { - vty_outln (vty, " neighbor %s remote-as internal", addr); + vty_out (vty, " neighbor %s remote-as internal\n", addr); } else if (peer->as_type == AS_EXTERNAL) { - vty_outln (vty, " neighbor %s remote-as external", addr); + vty_out (vty, " neighbor %s remote-as external\n", addr); } } } @@ -6694,7 +6706,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, || (CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) != CHECK_FLAG (g_peer->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS))) { - vty_outln (vty, " neighbor %s local-as %u%s%s", addr, + vty_out (vty, " neighbor %s local-as %u%s%s\n", addr, peer->change_local_as, CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? " no-prepend" : "", @@ -6705,7 +6717,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, /* description */ if (peer->desc) { - vty_outln (vty, " neighbor %s description %s", addr,peer->desc); + vty_out (vty, " neighbor %s description %s\n", addr,peer->desc); } /* shutdown */ @@ -6716,10 +6728,10 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, peer->tx_shutdown_message) { if (peer->tx_shutdown_message) - vty_outln (vty, " neighbor %s shutdown message %s", addr, + vty_out (vty, " neighbor %s shutdown message %s\n", addr, peer->tx_shutdown_message); else - vty_outln (vty, " neighbor %s shutdown", addr); + vty_out (vty, " neighbor %s shutdown\n", addr); } } @@ -6739,7 +6751,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, || ! g_peer->password || strcmp (peer->password, g_peer->password) != 0) { - vty_outln (vty, " neighbor %s password %s", addr,peer->password); + vty_out (vty, " neighbor %s password %s\n", addr,peer->password); } } @@ -6748,20 +6760,20 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, { if (!peer_group_active (peer)) { - vty_outln (vty, " neighbor %s solo", addr); + vty_out (vty, " neighbor %s solo\n", addr); } } /* BGP port */ if (peer->port != BGP_PORT_DEFAULT) { - vty_outln (vty, " neighbor %s port %d", addr,peer->port); + vty_out (vty, " neighbor %s port %d\n", addr,peer->port); } /* Local interface name */ if (peer->ifname) { - vty_outln (vty, " neighbor %s interface %s", addr,peer->ifname); + vty_out (vty, " neighbor %s interface %s\n", addr,peer->ifname); } /* passive */ @@ -6770,7 +6782,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_PASSIVE)) { - vty_outln (vty, " neighbor %s passive", addr); + vty_out (vty, " neighbor %s passive\n", addr); } } @@ -6780,7 +6792,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, { if (! peer_group_active (peer) || g_peer->ttl != peer->ttl) { - vty_outln (vty, " neighbor %s ebgp-multihop %d", addr,peer->ttl); + vty_out (vty, " neighbor %s ebgp-multihop %d\n", addr,peer->ttl); } } @@ -6789,7 +6801,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, { if (! peer_group_active (peer) || g_peer->gtsm_hops != peer->gtsm_hops) { - vty_outln (vty, " neighbor %s ttl-security hops %d", addr, + vty_out (vty, " neighbor %s ttl-security hops %d\n", addr, peer->gtsm_hops); } } @@ -6800,7 +6812,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) { - vty_outln (vty, " neighbor %s disable-connected-check", addr); + vty_out (vty, " neighbor %s disable-connected-check\n", addr); } } @@ -6810,7 +6822,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if (! peer_group_active (peer) || ! g_peer->update_if || strcmp (g_peer->update_if, peer->update_if) != 0) { - vty_outln (vty, " neighbor %s update-source %s", addr, + vty_out (vty, " neighbor %s update-source %s\n", addr, peer->update_if); } } @@ -6820,7 +6832,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, || sockunion_cmp (g_peer->update_source, peer->update_source) != 0) { - vty_outln (vty, " neighbor %s update-source %s", addr, + vty_out (vty, " neighbor %s update-source %s\n", addr, sockunion2str(peer->update_source, buf, SU_ADDRSTRLEN)); } } @@ -6830,7 +6842,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, ((! peer_group_active (peer) && peer->v_routeadv != BGP_DEFAULT_EBGP_ROUTEADV) || (peer_group_active (peer) && peer->v_routeadv != g_peer->v_routeadv))) { - vty_outln (vty, " neighbor %s advertisement-interval %u", + vty_out (vty, " neighbor %s advertisement-interval %u\n", addr, peer->v_routeadv); } @@ -6839,7 +6851,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, ((! peer_group_active (peer) && (peer->keepalive != BGP_DEFAULT_KEEPALIVE || peer->holdtime != BGP_DEFAULT_HOLDTIME)) || (peer_group_active (peer) && (peer->keepalive != g_peer->keepalive || peer->holdtime != g_peer->holdtime)))) { - vty_outln (vty, " neighbor %s timers %u %u", addr, + vty_out (vty, " neighbor %s timers %u %u\n", addr, peer->keepalive, peer->holdtime); } @@ -6848,7 +6860,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, (peer_group_active (peer) && peer->connect != g_peer->connect))) { - vty_outln (vty, " neighbor %s timers connect %u", addr, + vty_out (vty, " neighbor %s timers connect %u\n", addr, peer->connect); } @@ -6858,7 +6870,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY)) { - vty_outln (vty, " neighbor %s capability dynamic",addr); + vty_out (vty, " neighbor %s capability dynamic\n",addr); } } @@ -6868,7 +6880,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_CAPABILITY_ENHE)) { - vty_outln (vty, " no neighbor %s capability extended-nexthop", + vty_out (vty, " no neighbor %s capability extended-nexthop\n", addr); } } @@ -6878,7 +6890,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_CAPABILITY_ENHE)) { - vty_outln (vty, " neighbor %s capability extended-nexthop",addr); + vty_out (vty, " neighbor %s capability extended-nexthop\n",addr); } } @@ -6888,7 +6900,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_DONT_CAPABILITY)) { - vty_outln (vty, " neighbor %s dont-capability-negotiate",addr); + vty_out (vty, " neighbor %s dont-capability-negotiate\n",addr); } } @@ -6898,7 +6910,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY)) { - vty_outln (vty, " neighbor %s override-capability",addr); + vty_out (vty, " neighbor %s override-capability\n",addr); } } @@ -6908,7 +6920,7 @@ bgp_config_write_peer_global (struct vty *vty, struct bgp *bgp, if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_STRICT_CAP_MATCH)) { - vty_outln (vty, " neighbor %s strict-capability-match",addr); + vty_out (vty, " neighbor %s strict-capability-match\n",addr); } } } @@ -6942,16 +6954,16 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { afi_header_vty_out (vty, afi, safi, write, - " no neighbor %s activate%s", - addr, VTYNL); + " no neighbor %s activate\n", + addr); } /* If the peer-group is not active but peer is, print an 'activate' */ else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s activate%s", - addr, VTYNL); + " neighbor %s activate\n", + addr); } } else @@ -6963,14 +6975,14 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)) { afi_header_vty_out(vty, afi, safi, write, - " neighbor %s activate%s", - addr, VTYNL); + " neighbor %s activate\n", + addr); } } else afi_header_vty_out (vty, afi, safi, write, - " neighbor %s activate%s", - addr, VTYNL); + " neighbor %s activate\n", + addr); } else { @@ -6979,8 +6991,8 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, if (!bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)) { afi_header_vty_out (vty, afi, safi, write, - " no neighbor %s activate%s", - addr, VTYNL); + " no neighbor %s activate\n", + addr); } } } @@ -6990,15 +7002,15 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_ADDPATH_TX_ALL_PATHS)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s addpath-tx-all-paths%s", - addr, VTYNL); + " neighbor %s addpath-tx-all-paths\n", + addr); } if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s addpath-tx-bestpath-per-AS%s", - addr, VTYNL); + " neighbor %s addpath-tx-bestpath-per-AS\n", + addr); } /* ORF capability. */ @@ -7016,68 +7028,68 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, vty_out (vty, " send"); else vty_out (vty, " receive"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* Route reflector client. */ if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_REFLECTOR_CLIENT)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s route-reflector-client%s", - addr, VTYNL); + " neighbor %s route-reflector-client\n", + addr); } /* next-hop-self force */ if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_FORCE_NEXTHOP_SELF)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s next-hop-self force%s", - addr, VTYNL); + " neighbor %s next-hop-self force\n", + addr); } /* next-hop-self */ if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s next-hop-self%s", - addr, VTYNL); + " neighbor %s next-hop-self\n", + addr); } /* remove-private-AS */ if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s remove-private-AS all replace-AS%s", - addr, VTYNL); + " neighbor %s remove-private-AS all replace-AS\n", + addr); } else if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s remove-private-AS replace-AS%s", - addr, VTYNL); + " neighbor %s remove-private-AS replace-AS\n", + addr); } else if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s remove-private-AS all%s", - addr, VTYNL); + " neighbor %s remove-private-AS all\n", + addr); } else if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s remove-private-AS%s", - addr, VTYNL); + " neighbor %s remove-private-AS\n", + addr); } /* as-override */ if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s as-override%s", - addr, VTYNL); + " neighbor %s as-override\n", + addr); } /* send-community print. */ @@ -7088,26 +7100,26 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, && peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_LARGE_COMMUNITY)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s send-community all%s", - addr, VTYNL); + " neighbor %s send-community all\n", + addr); } else if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_LARGE_COMMUNITY)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s send-community large%s", - addr, VTYNL); + " neighbor %s send-community large\n", + addr); } else if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s send-community extended%s", - addr, VTYNL); + " neighbor %s send-community extended\n", + addr); } else if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s send-community%s", - addr, VTYNL); + " neighbor %s send-community\n", + addr); } } else @@ -7120,8 +7132,8 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, (!g_peer || peer_af_flag_check (g_peer, afi, safi, PEER_FLAG_SEND_LARGE_COMMUNITY))) { afi_header_vty_out (vty, afi, safi, write, - " no neighbor %s send-community all%s", - addr, VTYNL); + " no neighbor %s send-community all\n", + addr); } else { @@ -7129,24 +7141,24 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, (!g_peer || peer_af_flag_check (g_peer, afi, safi, PEER_FLAG_SEND_LARGE_COMMUNITY))) { afi_header_vty_out (vty, afi, safi, write, - " no neighbor %s send-community large%s", - addr, VTYNL); + " no neighbor %s send-community large\n", + addr); } if (!peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY) && (!g_peer || peer_af_flag_check (g_peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY))) { afi_header_vty_out (vty, afi, safi, write, - " no neighbor %s send-community extended%s", - addr, VTYNL); + " no neighbor %s send-community extended\n", + addr); } if (!peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY) && (!g_peer || peer_af_flag_check (g_peer, afi, safi, PEER_FLAG_SEND_COMMUNITY))) { afi_header_vty_out (vty, afi, safi, write, - " no neighbor %s send-community%s", - addr, VTYNL); + " no neighbor %s send-community\n", + addr); } } } @@ -7163,15 +7175,15 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, " neighbor %s default-originate", addr); if (peer->default_rmap[afi][safi].name) vty_out (vty, " route-map %s", peer->default_rmap[afi][safi].name); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* Soft reconfiguration inbound. */ if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s soft-reconfiguration inbound%s", - addr, VTYNL); + " neighbor %s soft-reconfiguration inbound\n", + addr); } /* maximum-prefix. */ @@ -7191,23 +7203,23 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, vty_out (vty, " warning-only"); if (peer->pmax_restart[afi][safi]) vty_out (vty, " restart %u", peer->pmax_restart[afi][safi]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* Route server client. */ if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s route-server-client%s", - addr, VTYNL); + " neighbor %s route-server-client\n", + addr); } /* Nexthop-local unchanged. */ if (peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s nexthop-local unchanged%s", - addr, VTYNL); + " neighbor %s nexthop-local unchanged\n", + addr); } /* allowas-in <1-10> */ @@ -7220,14 +7232,14 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, if (peer->allowas_in[afi][safi] == 3) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s allowas-in%s", - addr, VTYNL); + " neighbor %s allowas-in\n", + addr); } else { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s allowas-in %d%s", - addr, peer->allowas_in[afi][safi], VTYNL); + " neighbor %s allowas-in %d\n", + addr, peer->allowas_in[afi][safi]); } } } @@ -7239,8 +7251,8 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, || ! peer_af_flag_check (g_peer, afi, safi, PEER_FLAG_ALLOWAS_IN_ORIGIN)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s allowas-in origin%s", - addr, VTYNL); + " neighbor %s allowas-in origin\n", + addr); } } @@ -7253,8 +7265,8 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, if (peer->weight[afi][safi]) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s weight %lu%s", - addr, peer->weight[afi][safi], VTYNL); + " neighbor %s weight %lu\n", + addr, peer->weight[afi][safi]); } } @@ -7271,19 +7283,19 @@ bgp_config_write_peer_af (struct vty *vty, struct bgp *bgp, && peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s attribute-unchanged%s", - addr, VTYNL); + " neighbor %s attribute-unchanged\n", + addr); } else { afi_header_vty_out (vty, afi, safi, write, - " neighbor %s attribute-unchanged%s%s%s%s", addr, + " neighbor %s attribute-unchanged%s%s%s\n", addr, peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) ? " as-path" : "", peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED) ? " next-hop" : "", peergroup_af_flag_check (peer, afi, safi, PEER_FLAG_MED_UNCHANGED) ? - " med" : "", VTYNL); + " med" : ""); } } } @@ -7296,7 +7308,7 @@ bgp_config_write_family_header (struct vty *vty, afi_t afi, safi_t safi, if (*write) return; - vty_out (vty, " !%s address-family ", VTYNL); + vty_out (vty, " !\n address-family "); if (afi == AFI_IP) { @@ -7329,7 +7341,7 @@ bgp_config_write_family_header (struct vty *vty, afi_t afi, safi_t safi, if (safi == SAFI_EVPN) vty_out (vty, "l2vpn evpn"); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); *write = 1; } @@ -7367,8 +7379,11 @@ bgp_config_write_family (struct vty *vty, struct bgp *bgp, afi_t afi, bgp_config_write_maxpaths (vty, bgp, afi, safi, &write); bgp_config_write_table_map (vty, bgp, afi, safi, &write); + if (safi == SAFI_EVPN) + bgp_config_write_evpn_info (vty, bgp, afi, safi, &write); + if (write) - vty_outln (vty, " exit-address-family"); + vty_out (vty, " exit-address-family\n"); return write; } @@ -7386,25 +7401,25 @@ bgp_config_write (struct vty *vty) /* BGP Multiple instance. */ if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) { - vty_outln (vty, "no bgp multiple-instance"); + vty_out (vty, "no bgp multiple-instance\n"); write++; } /* BGP Config type. */ if (bgp_option_check (BGP_OPT_CONFIG_CISCO)) { - vty_outln (vty, "bgp config-type cisco"); + vty_out (vty, "bgp config-type cisco\n"); write++; } if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) - vty_outln (vty, "bgp route-map delay-timer %u",bm->rmap_update_timer); + vty_out (vty, "bgp route-map delay-timer %u\n",bm->rmap_update_timer); /* BGP configuration. */ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) { if (write) - vty_outln (vty, "!"); + vty_out (vty, "!\n"); /* Router bgp ASN */ vty_out (vty, "router bgp %u", bgp->as); @@ -7416,66 +7431,66 @@ bgp_config_write (struct vty *vty) (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) ? "view" : "vrf", bgp->name); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); /* No Synchronization */ if (bgp_option_check (BGP_OPT_CONFIG_CISCO)) - vty_outln (vty, " no synchronization"); + vty_out (vty, " no synchronization\n"); /* BGP fast-external-failover. */ if (CHECK_FLAG (bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) - vty_outln (vty, " no bgp fast-external-failover"); + vty_out (vty, " no bgp fast-external-failover\n"); /* BGP router ID. */ if (bgp->router_id_static.s_addr != 0) - vty_outln (vty, " bgp router-id %s", + vty_out (vty, " bgp router-id %s\n", inet_ntoa(bgp->router_id_static)); /* BGP log-neighbor-changes. */ if (!!bgp_flag_check (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES) != DFLT_BGP_LOG_NEIGHBOR_CHANGES) - vty_outln (vty, " %sbgp log-neighbor-changes", + vty_out (vty, " %sbgp log-neighbor-changes\n", bgp_flag_check(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES) ? "" : "no "); /* BGP configuration. */ if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)) - vty_outln (vty, " bgp always-compare-med"); + vty_out (vty, " bgp always-compare-med\n"); /* BGP default ipv4-unicast. */ if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)) - vty_outln (vty, " no bgp default ipv4-unicast"); + vty_out (vty, " no bgp default ipv4-unicast\n"); /* BGP default local-preference. */ if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) - vty_outln (vty, " bgp default local-preference %u", + vty_out (vty, " bgp default local-preference %u\n", bgp->default_local_pref); /* BGP default show-hostname */ if (!!bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) != DFLT_BGP_SHOW_HOSTNAME) - vty_outln (vty, " %sbgp default show-hostname", + vty_out (vty, " %sbgp default show-hostname\n", bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) ? "" : "no "); /* BGP default subgroup-pkt-queue-max. */ if (bgp->default_subgroup_pkt_queue_max != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) - vty_outln (vty, " bgp default subgroup-pkt-queue-max %u", + vty_out (vty, " bgp default subgroup-pkt-queue-max %u\n", bgp->default_subgroup_pkt_queue_max); /* BGP client-to-client reflection. */ if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) - vty_outln (vty, " no bgp client-to-client reflection"); + vty_out (vty, " no bgp client-to-client reflection\n"); /* BGP cluster ID. */ if (CHECK_FLAG (bgp->config, BGP_CONFIG_CLUSTER_ID)) - vty_outln (vty, " bgp cluster-id %s",inet_ntoa(bgp->cluster_id)); + vty_out (vty, " bgp cluster-id %s\n",inet_ntoa(bgp->cluster_id)); /* Disable ebgp connected nexthop check */ if (bgp_flag_check (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) - vty_outln (vty, " bgp disable-ebgp-connected-route-check"); + vty_out (vty, " bgp disable-ebgp-connected-route-check\n"); /* Confederation identifier*/ if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)) - vty_outln (vty, " bgp confederation identifier %i",bgp->confed_id); + vty_out (vty, " bgp confederation identifier %i\n",bgp->confed_id); /* Confederation peer */ if (bgp->confed_peers_cnt > 0) @@ -7487,17 +7502,17 @@ bgp_config_write (struct vty *vty) for (i = 0; i < bgp->confed_peers_cnt; i++) vty_out(vty, " %u", bgp->confed_peers[i]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* BGP enforce-first-as. */ if (bgp_flag_check (bgp, BGP_FLAG_ENFORCE_FIRST_AS)) - vty_outln (vty, " bgp enforce-first-as"); + vty_out (vty, " bgp enforce-first-as\n"); /* BGP deterministic-med. */ if (!!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) != DFLT_BGP_DETERMINISTIC_MED) - vty_outln (vty, " %sbgp deterministic-med", + vty_out (vty, " %sbgp deterministic-med\n", bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) ? "" : "no "); /* BGP update-delay. */ @@ -7508,14 +7523,14 @@ bgp_config_write (struct vty *vty) vty_out (vty, " bgp max-med on-startup %u", bgp->v_maxmed_onstartup); if (bgp->maxmed_onstartup_value != BGP_MAXMED_VALUE_DEFAULT) vty_out (vty, " %u", bgp->maxmed_onstartup_value); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { vty_out (vty, " bgp max-med administrative"); if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) vty_out (vty, " %u", bgp->maxmed_admin_value); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* write quanta */ @@ -7526,42 +7541,42 @@ bgp_config_write (struct vty *vty) /* BGP graceful-restart. */ if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) - vty_outln (vty, " bgp graceful-restart stalepath-time %u", + vty_out (vty, " bgp graceful-restart stalepath-time %u\n", bgp->stalepath_time); if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) - vty_outln (vty, " bgp graceful-restart restart-time %u", + vty_out (vty, " bgp graceful-restart restart-time %u\n", bgp->restart_time); if (bgp_flag_check (bgp, BGP_FLAG_GRACEFUL_RESTART)) - vty_outln (vty, " bgp graceful-restart"); + vty_out (vty, " bgp graceful-restart\n"); /* BGP graceful-restart Preserve State F bit. */ if (bgp_flag_check (bgp, BGP_FLAG_GR_PRESERVE_FWD)) - vty_outln (vty, " bgp graceful-restart preserve-fw-state"); + vty_out (vty, " bgp graceful-restart preserve-fw-state\n"); /* BGP bestpath method. */ if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) - vty_outln (vty, " bgp bestpath as-path ignore"); + vty_out (vty, " bgp bestpath as-path ignore\n"); if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) - vty_outln (vty, " bgp bestpath as-path confed"); + vty_out (vty, " bgp bestpath as-path confed\n"); if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { if (bgp_flag_check (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { - vty_outln (vty, - " bgp bestpath as-path multipath-relax as-set"); + vty_out (vty, + " bgp bestpath as-path multipath-relax as-set\n"); } else { - vty_outln (vty, " bgp bestpath as-path multipath-relax"); + vty_out (vty, " bgp bestpath as-path multipath-relax\n"); } } if (bgp_flag_check (bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { - vty_outln (vty," bgp route-reflector allow-outbound-policy"); + vty_out (vty," bgp route-reflector allow-outbound-policy\n"); } if (bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)) - vty_outln (vty, " bgp bestpath compare-routerid"); + vty_out (vty, " bgp bestpath compare-routerid\n"); if (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) || bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { @@ -7570,13 +7585,13 @@ bgp_config_write (struct vty *vty) vty_out (vty, " confed"); if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) vty_out (vty, " missing-as-worst"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* BGP network import check. */ if (!!bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK) != DFLT_BGP_IMPORT_CHECK) - vty_outln (vty, " %sbgp network import-check", + vty_out (vty, " %sbgp network import-check\n", bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK) ? "" : "no "); /* BGP flag dampening. */ @@ -7587,7 +7602,7 @@ bgp_config_write (struct vty *vty) /* BGP timers configuration. */ if (bgp->default_keepalive != BGP_DEFAULT_KEEPALIVE && bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) - vty_outln (vty, " timers bgp %u %u", bgp->default_keepalive, + vty_out (vty, " timers bgp %u %u\n", bgp->default_keepalive, bgp->default_holdtime); /* peer-group */ @@ -7608,7 +7623,7 @@ bgp_config_write (struct vty *vty) /* No auto-summary */ if (bgp_option_check (BGP_OPT_CONFIG_CISCO)) - vty_outln (vty, " no auto-summary"); + vty_out (vty, " no auto-summary\n"); /* IPv4 unicast configuration. */ write += bgp_config_write_family (vty, bgp, AFI_IP, SAFI_UNICAST); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 5dc25d00a..31aa6163b 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -33,6 +33,7 @@ #include "linklist.h" #include "defaults.h" #include "bgp_memory.h" +#include "bitfield.h" #define BGP_MAX_HOSTNAME 64 /* Linux max, is larger than most other sys */ @@ -367,6 +368,20 @@ struct bgp struct rfapi *rfapi; #endif + /* EVPN related information */ + + /* EVI hash table */ + struct hash *vnihash; + + /* EVPN enable - advertise local VNIs and their MACs etc. */ + int advertise_all_vni; + + /* Hash table of Import RTs to EVIs */ + struct hash *import_rt_hash; + + /* Id space for automatic RD derivation for an EVI */ + bitfield_t rd_idspace; + QOBJ_FIELDS }; DECLARE_QOBJ_TYPE(bgp) diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 14cce2d60..d04b186df 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -299,8 +299,8 @@ DEFUN (vnc_advertise_un_method, if (!bgp->rfapi_cfg) { - vty_outln (vty, "VNC not configured"); - return CMD_WARNING; + vty_out (vty, "VNC not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } @@ -345,10 +345,10 @@ set_ecom_list ( ecomadd = ecommunity_str2com (argv[0]->arg, ECOMMUNITY_ROUTE_TARGET, 0); if (!ecomadd) { - vty_outln (vty, "Malformed community-list value"); + vty_out (vty, "Malformed community-list value\n"); if (ecom) ecommunity_free (&ecom); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (ecom) @@ -435,14 +435,14 @@ DEFUN (vnc_defaults_rd, if (!argv[1]->arg[8] || *end) { - vty_outln (vty, "%% Malformed rd"); - return CMD_WARNING; + vty_out (vty, "%% Malformed rd\n"); + return CMD_WARNING_CONFIG_FAILED; } if (value32 > 0xffff) { - vty_outln (vty, "%% Malformed rd (must be less than %u", + vty_out (vty, "%% Malformed rd (must be less than %u\n", 0x0ffff); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } memset (&prd, 0, sizeof (prd)); @@ -460,8 +460,8 @@ DEFUN (vnc_defaults_rd, ret = str2prefix_rd (argv[1]->arg, &prd); if (!ret) { - vty_outln (vty, "%% Malformed rd"); - return CMD_WARNING; + vty_out (vty, "%% Malformed rd\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -491,15 +491,15 @@ DEFUN (vnc_defaults_l2rd, value = value_l & 0xff; if (!argv[1]->arg[0] || *end) { - vty_outln (vty, "%% Malformed l2 nve ID \"%s\"",argv[1]->arg); - return CMD_WARNING; + vty_out (vty, "%% Malformed l2 nve ID \"%s\"\n",argv[1]->arg); + return CMD_WARNING_CONFIG_FAILED; } if ((value_l < 1) || (value_l > 0xff)) { - vty_outln (vty, - "%% Malformed l2 nve id (must be greater than 0 and less than %u", + vty_out (vty, + "%% Malformed l2 nve id (must be greater than 0 and less than %u\n", 0x100); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } bgp->rfapi_cfg->flags |= BGP_VNC_CONFIG_L2RD; @@ -536,7 +536,7 @@ DEFUN (vnc_defaults_responselifetime, h = bgp->rfapi; if (!h) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (strmatch(argv[1]->text, "infinite")) { @@ -800,21 +800,21 @@ DEFUN (vnc_redistribute_rh_roo_localadmin, if (!bgp->rfapi_cfg) { - vty_outln (vty, "RFAPI not configured"); - return CMD_WARNING; + vty_out (vty, "RFAPI not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } localadmin = strtoul (argv[4]->arg, &endptr, 0); if (!argv[4]->arg[0] || *endptr) { - vty_outln (vty, "%% Malformed value"); - return CMD_WARNING; + vty_out (vty, "%% Malformed value\n"); + return CMD_WARNING_CONFIG_FAILED; } if (localadmin > 0xffff) { - vty_outln (vty, "%% Value out of range (0-%d)", 0xffff); - return CMD_WARNING; + vty_out (vty, "%% Value out of range (0-%d)\n", 0xffff); + return CMD_WARNING_CONFIG_FAILED; } if (bgp->rfapi_cfg->resolve_nve_roo_local_admin == localadmin) @@ -856,8 +856,8 @@ DEFUN (vnc_redistribute_mode, if (!bgp->rfapi_cfg) { - vty_outln (vty, "RFAPI not configured"); - return CMD_WARNING; + vty_out (vty, "RFAPI not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } @@ -876,8 +876,8 @@ DEFUN (vnc_redistribute_mode, break; default: - vty_outln (vty, "unknown redistribute mode"); - return CMD_WARNING; + vty_out (vty, "unknown redistribute mode\n"); + return CMD_WARNING_CONFIG_FAILED; } if (newmode != bgp->rfapi_cfg->redist_mode) @@ -911,14 +911,14 @@ DEFUN (vnc_redistribute_protocol, if (!bgp->rfapi_cfg) { - vty_outln (vty, "RFAPI not configured"); - return CMD_WARNING; + vty_out (vty, "RFAPI not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (rfapi_str2route_type (argv[2]->arg, argv[3]->arg, &afi, &type)) { - vty_outln (vty, "%% Invalid route type"); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } if (type == ZEBRA_ROUTE_BGP_DIRECT_EXT) @@ -959,14 +959,14 @@ DEFUN (vnc_no_redistribute_protocol, if (!bgp->rfapi_cfg) { - vty_outln (vty, "RFAPI not configured"); - return CMD_WARNING; + vty_out (vty, "RFAPI not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (rfapi_str2route_type (argv[3]->arg, argv[4]->arg, &afi, &type)) { - vty_outln (vty, "%% Invalid route type"); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } VNC_REDIST_DISABLE (bgp, afi, type); @@ -1000,14 +1000,14 @@ DEFUN (vnc_redistribute_bgp_exterior, if (!bgp->rfapi_cfg) { - vty_outln (vty, "RFAPI not configured"); - return CMD_WARNING; + vty_out (vty, "RFAPI not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (rfapi_str2route_type (argv[2]->arg, "bgp-direct-to-nve-groups", &afi, &type)) { - vty_outln (vty, "%% Invalid route type"); - return CMD_WARNING; + vty_out (vty, "%% Invalid route type\n"); + return CMD_WARNING_CONFIG_FAILED; } if (bgp->rfapi_cfg->redist_bgp_exterior_view_name) @@ -1032,8 +1032,8 @@ DEFUN (vnc_redistribute_nvegroup, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } vnc_redistribute_prechange (bgp); @@ -1065,8 +1065,8 @@ DEFUN (vnc_redistribute_no_nvegroup, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } vnc_redistribute_prechange (bgp); @@ -1095,8 +1095,8 @@ DEFUN (vnc_redistribute_lifetime, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } vnc_redistribute_prechange (bgp); @@ -1135,8 +1135,8 @@ DEFUN (vnc_redist_bgpdirect_no_prefixlist, if (!(hc = bgp->rfapi_cfg)) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[3]->text, "bgp-direct")) @@ -1188,8 +1188,8 @@ DEFUN (vnc_redist_bgpdirect_prefixlist, if (!(hc = bgp->rfapi_cfg)) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[2]->text, "bgp-direct")) @@ -1238,8 +1238,8 @@ DEFUN (vnc_redist_bgpdirect_no_routemap, if (!(hc = bgp->rfapi_cfg)) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[3]->text, "bgp-direct")) @@ -1278,8 +1278,8 @@ DEFUN (vnc_redist_bgpdirect_routemap, if (!(hc = bgp->rfapi_cfg)) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[2]->text, "bgp-direct")) @@ -1323,16 +1323,16 @@ DEFUN (vnc_nve_group_redist_bgpdirect_no_prefixlist, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[3]->text, "ipv4")) @@ -1372,16 +1372,16 @@ DEFUN (vnc_nve_group_redist_bgpdirect_prefixlist, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[2]->text, "ipv4")) @@ -1419,16 +1419,16 @@ DEFUN (vnc_nve_group_redist_bgpdirect_no_routemap, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } vnc_redistribute_prechange (bgp); @@ -1455,16 +1455,16 @@ DEFUN (vnc_nve_group_redist_bgpdirect_routemap, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } vnc_redistribute_prechange (bgp); @@ -1504,8 +1504,8 @@ DEFUN (vnc_export_mode, if (!bgp->rfapi_cfg) { - vty_outln (vty, "VNC not configured"); - return CMD_WARNING; + vty_out (vty, "VNC not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argv[2]->arg[0] == 'b') @@ -1526,13 +1526,13 @@ DEFUN (vnc_export_mode, newmode = BGP_VNC_CONFIG_EXPORT_BGP_MODE_RH; break; default: - vty_outln (vty, "Invalid mode specified"); - return CMD_WARNING; + vty_out (vty, "Invalid mode specified\n"); + return CMD_WARNING_CONFIG_FAILED; } if (newmode == oldmode) { - vty_outln (vty, "Mode unchanged"); + vty_out (vty, "Mode unchanged\n"); return CMD_SUCCESS; } @@ -1550,8 +1550,8 @@ DEFUN (vnc_export_mode, /* * export to zebra with RH mode is not yet implemented */ - vty_outln (vty,"Changing modes for zebra export not implemented yet"); - return CMD_WARNING; + vty_out (vty,"Changing modes for zebra export not implemented yet\n"); + return CMD_WARNING_CONFIG_FAILED; oldmode = bgp->rfapi_cfg->flags & BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS; bgp->rfapi_cfg->flags &= ~BGP_VNC_CONFIG_EXPORT_ZEBRA_MODE_BITS; @@ -1590,8 +1590,8 @@ DEFUN (vnc_export_mode, } break; default: - vty_outln (vty, "Invalid mode"); - return CMD_WARNING; + vty_out (vty, "Invalid mode\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -1625,8 +1625,8 @@ DEFUN (vnc_export_nvegroup, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } rfg_new = bgp_rfapi_cfg_match_byname (bgp, argv[5]->arg, RFAPI_GROUP_CFG_NVE); @@ -1727,8 +1727,8 @@ DEFUN (vnc_no_export_nvegroup, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argv[2]->arg[0] == 'b') @@ -1788,16 +1788,16 @@ DEFUN (vnc_nve_group_export_no_prefixlist, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[3]->text, "ipv4")) @@ -1857,16 +1857,16 @@ DEFUN (vnc_nve_group_export_prefixlist, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[2]->text, "ipv4")) @@ -1914,16 +1914,16 @@ DEFUN (vnc_nve_group_export_no_routemap, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argv[2]->arg[0] == 'b') @@ -1973,16 +1973,16 @@ DEFUN (vnc_nve_group_export_routemap, if (!bgp->rfapi_cfg) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argv[1]->arg[0] == 'b') @@ -2024,8 +2024,8 @@ DEFUN (vnc_nve_export_no_prefixlist, if (!(hc = bgp->rfapi_cfg)) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[4]->text, "ipv4")) @@ -2085,8 +2085,8 @@ DEFUN (vnc_nve_export_prefixlist, if (!(hc = bgp->rfapi_cfg)) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[3]->text, "ipv4")) @@ -2132,8 +2132,8 @@ DEFUN (vnc_nve_export_no_routemap, if (!(hc = bgp->rfapi_cfg)) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argv[3]->arg[0] == 'b') @@ -2183,8 +2183,8 @@ DEFUN (vnc_nve_export_routemap, if (!(hc = bgp->rfapi_cfg)) { - vty_outln (vty, "rfapi not configured"); - return CMD_WARNING; + vty_out (vty, "rfapi not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argv[2]->arg[0] == 'b') @@ -2430,8 +2430,8 @@ DEFUN_NOSH (vnc_nve_group, if (!rfg) { /* Error out of memory */ - vty_out (vty, "Can't allocate memory for NVE group%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Can't allocate memory for NVE group\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Copy defaults from struct rfapi_cfg */ @@ -2606,7 +2606,7 @@ bgp_rfapi_delete_nve_group ( vty_out (vty, " un="); rfapiPrintRfapiIpAddr (vty, &rfd->un_addr); if (vty) - vty_outln (vty, " to new group \"%s\"",rfd->rfg->name); + vty_out (vty, " to new group \"%s\"\n",rfd->rfg->name); } } @@ -2620,7 +2620,7 @@ bgp_rfapi_delete_nve_group ( vty_out (vty, " un="); rfapiPrintRfapiIpAddr (vty, &rfd->un_addr); if (vty) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } list_delete (orphaned_nves); } @@ -2644,8 +2644,8 @@ bgp_rfapi_delete_named_nve_group ( if (!rfg) { if (vty) - vty_outln (vty, "No NVE group named \"%s\"",rfg_name); - return CMD_WARNING; + vty_out (vty, "No NVE group named \"%s\"\n",rfg_name); + return CMD_WARNING_CONFIG_FAILED; } } @@ -2734,21 +2734,21 @@ DEFUN (vnc_nve_group_prefix, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!str2prefix (argv[2]->arg, &p)) { - vty_outln (vty, "Malformed prefix \"%s\"", argv[2]->arg); - return CMD_WARNING; + vty_out (vty, "Malformed prefix \"%s\"\n", argv[2]->arg); + return CMD_WARNING_CONFIG_FAILED; } afi = family2afi (p.family); if (!afi) { - vty_outln (vty, "Unsupported address family"); - return CMD_WARNING; + vty_out (vty, "Unsupported address family\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argv[1]->arg[0] == 'u') @@ -2773,10 +2773,10 @@ DEFUN (vnc_nve_group_prefix, /* * different group name: fail */ - vty_outln (vty, "nve group \"%s\" already has \"%s\" prefix %s", + vty_out (vty, "nve group \"%s\" already has \"%s\" prefix %s\n", ((struct rfapi_nve_group_cfg *) (rn->info))->name, argv[1]->arg, argv[2]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } else { @@ -2853,8 +2853,8 @@ DEFUN (vnc_nve_group_rt_import, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } rc = set_ecom_list (vty, argc - 2, argv + 2, &rfg->rt_import_list); @@ -2919,8 +2919,8 @@ DEFUN (vnc_nve_group_rt_export, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (bgp->rfapi_cfg->rfg_redist == rfg) @@ -2957,8 +2957,8 @@ DEFUN (vnc_nve_group_rt_both, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } rc = set_ecom_list (vty, argc - 2, argv + 2, &rfg->rt_import_list); @@ -3038,8 +3038,8 @@ DEFUN (vnc_nve_group_l2rd, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[1]->text, "auto:vn")) @@ -3054,15 +3054,15 @@ DEFUN (vnc_nve_group_l2rd, if (!argv[1]->arg[0] || *end) { - vty_outln (vty, "%% Malformed l2 nve ID \"%s\"",argv[1]->arg); - return CMD_WARNING; + vty_out (vty, "%% Malformed l2 nve ID \"%s\"\n",argv[1]->arg); + return CMD_WARNING_CONFIG_FAILED; } if ((value_l < 1) || (value_l > 0xff)) { - vty_outln (vty, - "%% Malformed l2 nve id (must be greater than 0 and less than %u", + vty_out (vty, + "%% Malformed l2 nve id (must be greater than 0 and less than %u\n", 0x100); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } rfg->l2rd = value; @@ -3085,8 +3085,8 @@ DEFUN (vnc_nve_group_no_l2rd, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } rfg->l2rd = 0; @@ -3110,8 +3110,8 @@ DEFUN (vnc_nve_group_rd, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!strncmp (argv[1]->arg, "auto:vn:", 8)) @@ -3126,14 +3126,14 @@ DEFUN (vnc_nve_group_rd, if (!argv[1]->arg[8] || *end) { - vty_outln (vty, "%% Malformed rd"); - return CMD_WARNING; + vty_out (vty, "%% Malformed rd\n"); + return CMD_WARNING_CONFIG_FAILED; } if (value32 > 0xffff) { - vty_outln (vty, "%% Malformed rd (must be less than %u", + vty_out (vty, "%% Malformed rd (must be less than %u\n", 0x0ffff); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } memset (&prd, 0, sizeof (prd)); @@ -3151,8 +3151,8 @@ DEFUN (vnc_nve_group_rd, ret = str2prefix_rd (argv[1]->arg, &prd); if (!ret) { - vty_outln (vty, "%% Malformed rd"); - return CMD_WARNING; + vty_out (vty, "%% Malformed rd\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -3186,8 +3186,8 @@ DEFUN (vnc_nve_group_responselifetime, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[1]->text, "infinite")) @@ -3255,8 +3255,8 @@ DEFUN_NOSH (vnc_vrf_policy, if (!bgp) { - vty_out (vty, "No BGP process is configured%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Search for name */ @@ -3268,8 +3268,8 @@ DEFUN_NOSH (vnc_vrf_policy, if (!rfg) { /* Error out of memory */ - vty_out (vty, "Can't allocate memory for NVE group%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Can't allocate memory for NVE group\n"); + return CMD_WARNING_CONFIG_FAILED; } } /* @@ -3292,8 +3292,8 @@ DEFUN (vnc_no_vrf_policy, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_rfapi_delete_named_nve_group (vty, bgp, argv[2]->arg, RFAPI_GROUP_CFG_VRF); } @@ -3311,16 +3311,16 @@ DEFUN (vnc_vrf_policy_label, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } label = strtoul(argv[1]->arg, NULL, 10); @@ -3352,8 +3352,8 @@ DEFUN (vnc_vrf_policy_no_label, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current VRF group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current VRF group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (bgp->rfapi_cfg->rfg_redist == rfg) @@ -3387,8 +3387,8 @@ DEFUN (vnc_vrf_policy_nexthop, if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current VRF no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current VRF no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (bgp->rfapi_cfg->rfg_redist == rfg) @@ -3398,7 +3398,7 @@ DEFUN (vnc_vrf_policy_nexthop, if (!str2prefix (argv[1]->arg, &p) && p.family) { - //vty_out (vty, "Nexthop set to self%s", VTYNL); + //vty_out (vty, "Nexthop set to self\n"); SET_FLAG (rfg->flags, RFAPI_RFG_VPN_NH_SELF); memset(&rfg->vn_prefix, 0, sizeof(struct prefix)); } @@ -3437,16 +3437,16 @@ DEFUN (vnc_vrf_policy_rt_import, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } rc = set_ecom_list (vty, argc-2, argv+2, &rfg->rt_import_list); @@ -3509,16 +3509,16 @@ DEFUN (vnc_vrf_policy_rt_export, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (bgp->rfapi_cfg->rfg_redist == rfg) @@ -3553,16 +3553,16 @@ DEFUN (vnc_vrf_policy_rt_both, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } rc = set_ecom_list (vty, argc-2, argv+2, &rfg->rt_import_list); @@ -3641,16 +3641,16 @@ DEFUN (vnc_vrf_policy_rd, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current NVE group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!strncmp (argv[1]->arg, "auto:nh:", 8)) @@ -3665,14 +3665,14 @@ DEFUN (vnc_vrf_policy_rd, if (!*(argv[1]->arg + 5) || *end) { - vty_outln (vty, "%% Malformed rd"); - return CMD_WARNING; + vty_out (vty, "%% Malformed rd\n"); + return CMD_WARNING_CONFIG_FAILED; } if (value32 > 0xffff) { - vty_outln (vty, "%% Malformed rd (must be less than %u", + vty_out (vty, "%% Malformed rd (must be less than %u\n", 0x0ffff); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } memset (&prd, 0, sizeof (prd)); @@ -3690,8 +3690,8 @@ DEFUN (vnc_vrf_policy_rd, ret = str2prefix_rd (argv[1]->arg, &prd); if (!ret) { - vty_outln (vty, "%% Malformed rd"); - return CMD_WARNING; + vty_out (vty, "%% Malformed rd\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -3742,8 +3742,8 @@ DEFUN_NOSH (vnc_l2_group, if (!bgp) { - vty_out (vty, "No BGP process is configured%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Search for name */ @@ -3755,8 +3755,8 @@ DEFUN_NOSH (vnc_l2_group, if (!rfg) { /* Error out of memory */ - vty_out (vty, "Can't allocate memory for L2 group%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Can't allocate memory for L2 group\n"); + return CMD_WARNING_CONFIG_FAILED; } rfg->name = strdup (argv[1]->arg); /* add to tail of list */ @@ -3808,8 +3808,8 @@ bgp_rfapi_delete_named_l2_group ( if (!rfg) { if (vty) - vty_outln (vty, "No L2 group named \"%s\"",rfg_name); - return CMD_WARNING; + vty_out (vty, "No L2 group named \"%s\"\n",rfg_name); + return CMD_WARNING_CONFIG_FAILED; } } @@ -3833,8 +3833,8 @@ DEFUN (vnc_no_l2_group, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } return bgp_rfapi_delete_named_l2_group (vty, bgp, argv[3]->arg); } @@ -3851,16 +3851,16 @@ DEFUN (vnc_l2_group_lni, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current L2 group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current L2 group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } rfg->logical_net_id = strtoul(argv[1]->arg, NULL, 10); @@ -3880,16 +3880,16 @@ DEFUN (vnc_l2_group_labels, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current L2 group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current L2 group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } ll = rfg->labels; @@ -3924,23 +3924,23 @@ DEFUN (vnc_l2_group_no_labels, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current L2 group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current L2 group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } ll = rfg->labels; if (ll == NULL) { - vty_outln (vty, "Label no longer associated with group"); - return CMD_WARNING; + vty_out (vty, "Label no longer associated with group\n"); + return CMD_WARNING_CONFIG_FAILED; } argc-=2; @@ -3981,22 +3981,22 @@ DEFUN (vnc_l2_group_rt, do_export = 1; break; default: - vty_outln (vty, "Unknown option, %s", argv[1]->arg); + vty_out (vty, "Unknown option, %s\n", argv[1]->arg); return CMD_ERR_NO_MATCH; } if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make sure it's still in list */ if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current L2 group no longer exists"); - return CMD_WARNING; + vty_out (vty, "Current L2 group no longer exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (do_import) @@ -4271,20 +4271,20 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) if (bgp->rfapi == NULL || hc == NULL) return write; - vty_outln (vty, "!"); + vty_out (vty, "!\n"); for (ALL_LIST_ELEMENTS (hc->nve_groups_sequential, node, nnode, rfg)) if (rfg->type == RFAPI_GROUP_CFG_VRF) { ++write; - vty_outln (vty, " vrf-policy %s", rfg->name); + vty_out (vty, " vrf-policy %s\n", rfg->name); if (rfg->label <= MPLS_LABEL_MAX) { - vty_outln (vty, " label %u", rfg->label); + vty_out (vty, " label %u\n", rfg->label); } if (CHECK_FLAG (rfg->flags, RFAPI_RFG_VPN_NH_SELF)) { - vty_outln (vty, " nexthop self"); + vty_out (vty, " nexthop self\n"); } else @@ -4296,11 +4296,11 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) inet_ntop(rfg->vn_prefix.family, &rfg->vn_prefix.u.prefix, buf, sizeof(buf)); if (!buf[0] || buf[BUFSIZ - 1]) { - //vty_out (vty, "nexthop self%s", VTYNL); + //vty_out (vty, "nexthop self\n"); } else { - vty_outln (vty, " nexthop %s", buf); + vty_out (vty, " nexthop %s\n", buf); } } } @@ -4318,7 +4318,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) value = ((rfg->rd.val[6] << 8) & 0x0ff00) | (rfg->rd.val[7] & 0x0ff); - vty_outln (vty, " rd auto:nh:%d", value); + vty_out (vty, " rd auto:nh:%d\n", value); } else @@ -4328,11 +4328,11 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) !buf[0] || buf[BUFSIZ - 1]) { - vty_outln (vty, "!Error: Can't convert rd"); + vty_out (vty, "!Error: Can't convert rd\n"); } else { - vty_outln (vty, " rd %s", buf); + vty_out (vty, " rd %s\n", buf); } } } @@ -4342,7 +4342,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) { char *b = ecommunity_ecom2str (rfg->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt both %s", b); + vty_out (vty, " rt both %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } else @@ -4351,14 +4351,14 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) { char *b = ecommunity_ecom2str (rfg->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt import %s", b); + vty_out (vty, " rt import %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } if (rfg->rt_export_list) { char *b = ecommunity_ecom2str (rfg->rt_export_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt export %s", b); + vty_out (vty, " rt export %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } } @@ -4373,12 +4373,12 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) if (rfg->plist_export_bgp_name[afi]) { - vty_outln (vty, " export bgp %s prefix-list %s", + vty_out (vty, " export bgp %s prefix-list %s\n", afistr,rfg->plist_export_bgp_name[afi]); } if (rfg->plist_export_zebra_name[afi]) { - vty_outln (vty, " export zebra %s prefix-list %s", + vty_out (vty, " export zebra %s prefix-list %s\n", afistr,rfg->plist_export_zebra_name[afi]); } /* @@ -4388,14 +4388,14 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) */ if (rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]) { - vty_outln (vty, " redistribute bgp-direct %s prefix-list %s", + vty_out (vty, " redistribute bgp-direct %s prefix-list %s\n", afistr, rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]); } if (rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT_EXT][afi]) { - vty_outln (vty, - " redistribute bgp-direct-to-nve-groups %s prefix-list %s", + vty_out (vty, + " redistribute bgp-direct-to-nve-groups %s prefix-list %s\n", afistr, rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT_EXT][afi]); } @@ -4403,31 +4403,31 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) if (rfg->routemap_export_bgp_name) { - vty_outln (vty, " export bgp route-map %s", + vty_out (vty, " export bgp route-map %s\n", rfg->routemap_export_bgp_name); } if (rfg->routemap_export_zebra_name) { - vty_outln (vty, " export zebra route-map %s", + vty_out (vty, " export zebra route-map %s\n", rfg->routemap_export_zebra_name); } if (rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]) { - vty_outln (vty, " redistribute bgp-direct route-map %s", + vty_out (vty, " redistribute bgp-direct route-map %s\n", rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]); } if (rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT_EXT]) { - vty_outln (vty, - " redistribute bgp-direct-to-nve-groups route-map %s", + vty_out (vty, + " redistribute bgp-direct-to-nve-groups route-map %s\n", rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT_EXT]); } - vty_outln (vty, " exit-vrf-policy"); - vty_outln (vty, "!"); + vty_out (vty, " exit-vrf-policy\n"); + vty_out (vty, "!\n"); } if (hc->flags & BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP) { - vty_outln (vty, " vnc advertise-un-method encap-safi"); + vty_out (vty, " vnc advertise-un-method encap-safi\n"); write++; } @@ -4437,7 +4437,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) write += (bgp->rfapi->rfp_methods.cfg_cb) (vty, bgp->rfapi->rfp); if (write) - vty_outln (vty, "!"); + vty_out (vty, "!\n"); if (hc->l2_groups) { @@ -4448,9 +4448,9 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) struct listnode *lnode; void *data; ++write; - vty_outln (vty, " vnc l2-group %s", rfg->name); + vty_out (vty, " vnc l2-group %s\n", rfg->name); if (rfg->logical_net_id != 0) - vty_outln (vty, " logical-network-id %u", + vty_out (vty, " logical-network-id %u\n", rfg->logical_net_id); if (rfg->labels != NULL && listhead (rfg->labels) != NULL) { @@ -4459,7 +4459,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) { vty_out (vty, "%hu ", (uint16_t) ((uintptr_t) data)); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (rfg->rt_import_list && rfg->rt_export_list && @@ -4467,7 +4467,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) { char *b = ecommunity_ecom2str (rfg->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt both %s", b); + vty_out (vty, " rt both %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } else @@ -4476,14 +4476,14 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) { char *b = ecommunity_ecom2str (rfg->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt import %s", b); + vty_out (vty, " rt import %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } if (rfg->rt_export_list) { char *b = ecommunity_ecom2str (rfg->rt_export_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt export %s", b); + vty_out (vty, " rt export %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } } @@ -4494,8 +4494,8 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) RFAPI_RFP_CFG_GROUP_L2, rfg->name, rfg->rfp_cfg); - vty_outln (vty, " exit-vnc"); - vty_outln (vty, "!"); + vty_out (vty, " exit-vnc\n"); + vty_out (vty, "!\n"); } } @@ -4507,7 +4507,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) ++write; - vty_outln (vty, " vnc defaults"); + vty_out (vty, " vnc defaults\n"); if (hc->default_rd.prefixlen) { @@ -4521,7 +4521,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) value = ((hc->default_rd.val[6] << 8) & 0x0ff00) | (hc->default_rd.val[7] & 0x0ff); - vty_outln (vty, " rd auto:vn:%d", value); + vty_out (vty, " rd auto:vn:%d\n", value); } else @@ -4531,11 +4531,11 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) !buf[0] || buf[BUFSIZ - 1]) { - vty_outln (vty, "!Error: Can't convert rd"); + vty_out (vty, "!Error: Can't convert rd\n"); } else { - vty_outln (vty, " rd %s", buf); + vty_out (vty, " rd %s\n", buf); } } } @@ -4546,7 +4546,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) vty_out (vty, "%d", hc->default_response_lifetime); else vty_out (vty, "infinite"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (hc->default_rt_import_list && hc->default_rt_export_list && ecommunity_cmp (hc->default_rt_import_list, @@ -4554,7 +4554,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) { char *b = ecommunity_ecom2str (hc->default_rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt both %s", b); + vty_out (vty, " rt both %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } else @@ -4563,14 +4563,14 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) { char *b = ecommunity_ecom2str (hc->default_rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt import %s", b); + vty_out (vty, " rt import %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } if (hc->default_rt_export_list) { char *b = ecommunity_ecom2str (hc->default_rt_export_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt export %s", b); + vty_out (vty, " rt export %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } } @@ -4581,15 +4581,15 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) RFAPI_RFP_CFG_GROUP_DEFAULT, NULL, bgp->rfapi_cfg->default_rfp_cfg); - vty_outln (vty, " exit-vnc"); - vty_outln (vty, "!"); + vty_out (vty, " exit-vnc\n"); + vty_out (vty, "!\n"); } for (ALL_LIST_ELEMENTS (hc->nve_groups_sequential, node, nnode, rfg)) if (rfg->type == RFAPI_GROUP_CFG_NVE) { ++write; - vty_outln (vty, " vnc nve-group %s", rfg->name); + vty_out (vty, " vnc nve-group %s\n", rfg->name); if (rfg->vn_prefix.family && rfg->vn_node) { @@ -4599,11 +4599,11 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) prefix2str (&rfg->vn_prefix, buf, BUFSIZ); if (!buf[0] || buf[BUFSIZ - 1]) { - vty_outln (vty, "!Error: Can't convert prefix"); + vty_out (vty, "!Error: Can't convert prefix\n"); } else { - vty_outln (vty, " prefix %s %s", "vn", buf); + vty_out (vty, " prefix %s %s\n", "vn", buf); } } @@ -4614,11 +4614,11 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) prefix2str (&rfg->un_prefix, buf, BUFSIZ); if (!buf[0] || buf[BUFSIZ - 1]) { - vty_outln (vty, "!Error: Can't convert prefix"); + vty_out (vty, "!Error: Can't convert prefix\n"); } else { - vty_outln (vty, " prefix %s %s", "un", buf); + vty_out (vty, " prefix %s %s\n", "un", buf); } } @@ -4636,7 +4636,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) value = ((rfg->rd.val[6] << 8) & 0x0ff00) | (rfg->rd.val[7] & 0x0ff); - vty_outln (vty, " rd auto:vn:%d", value); + vty_out (vty, " rd auto:vn:%d\n", value); } else @@ -4646,11 +4646,11 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) !buf[0] || buf[BUFSIZ - 1]) { - vty_outln (vty, "!Error: Can't convert rd"); + vty_out (vty, "!Error: Can't convert rd\n"); } else { - vty_outln (vty, " rd %s", buf); + vty_out (vty, " rd %s\n", buf); } } } @@ -4661,7 +4661,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) vty_out (vty, "%d", rfg->response_lifetime); else vty_out (vty, "infinite"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (rfg->rt_import_list && rfg->rt_export_list && @@ -4670,7 +4670,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) char *b = ecommunity_ecom2str (rfg->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt both %s", b); + vty_out (vty, " rt both %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } else @@ -4680,14 +4680,14 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) char *b = ecommunity_ecom2str (rfg->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt import %s", b); + vty_out (vty, " rt import %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } if (rfg->rt_export_list) { char *b = ecommunity_ecom2str (rfg->rt_export_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); - vty_outln (vty, " rt export %s", b); + vty_out (vty, " rt export %s\n", b); XFREE (MTYPE_ECOMMUNITY_STR, b); } } @@ -4702,12 +4702,12 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) if (rfg->plist_export_bgp_name[afi]) { - vty_outln (vty, " export bgp %s prefix-list %s", + vty_out (vty, " export bgp %s prefix-list %s\n", afistr,rfg->plist_export_bgp_name[afi]); } if (rfg->plist_export_zebra_name[afi]) { - vty_outln (vty, " export zebra %s prefix-list %s", + vty_out (vty, " export zebra %s prefix-list %s\n", afistr,rfg->plist_export_zebra_name[afi]); } /* @@ -4717,14 +4717,14 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) */ if (rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]) { - vty_outln (vty, " redistribute bgp-direct %s prefix-list %s", + vty_out (vty, " redistribute bgp-direct %s prefix-list %s\n", afistr, rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]); } if (rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT_EXT][afi]) { - vty_outln (vty, - " redistribute bgp-direct-to-nve-groups %s prefix-list %s", + vty_out (vty, + " redistribute bgp-direct-to-nve-groups %s prefix-list %s\n", afistr, rfg->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT_EXT][afi]); } @@ -4732,23 +4732,23 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) if (rfg->routemap_export_bgp_name) { - vty_outln (vty, " export bgp route-map %s", + vty_out (vty, " export bgp route-map %s\n", rfg->routemap_export_bgp_name); } if (rfg->routemap_export_zebra_name) { - vty_outln (vty, " export zebra route-map %s", + vty_out (vty, " export zebra route-map %s\n", rfg->routemap_export_zebra_name); } if (rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]) { - vty_outln (vty, " redistribute bgp-direct route-map %s", + vty_out (vty, " redistribute bgp-direct route-map %s\n", rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]); } if (rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT_EXT]) { - vty_outln (vty, - " redistribute bgp-direct-to-nve-groups route-map %s", + vty_out (vty, + " redistribute bgp-direct-to-nve-groups route-map %s\n", rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT_EXT]); } if (bgp->rfapi->rfp_methods.cfg_group_cb) @@ -4757,8 +4757,8 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) bgp->rfapi->rfp, RFAPI_RFP_CFG_GROUP_NVE, rfg->name, rfg->rfp_cfg); - vty_outln (vty, " exit-vnc"); - vty_outln (vty, "!"); + vty_out (vty, " exit-vnc\n"); + vty_out (vty, "!\n"); } } /* have listen ports */ @@ -4767,24 +4767,24 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) */ if (VNC_EXPORT_BGP_GRP_ENABLED (hc)) { - vty_outln (vty, " vnc export bgp mode group-nve"); + vty_out (vty, " vnc export bgp mode group-nve\n"); } else if (VNC_EXPORT_BGP_RH_ENABLED (hc)) { - vty_outln (vty, " vnc export bgp mode registering-nve"); + vty_out (vty, " vnc export bgp mode registering-nve\n"); } else if (VNC_EXPORT_BGP_CE_ENABLED (hc)) { - vty_outln (vty, " vnc export bgp mode ce"); + vty_out (vty, " vnc export bgp mode ce\n"); } if (VNC_EXPORT_ZEBRA_GRP_ENABLED (hc)) { - vty_outln (vty, " vnc export zebra mode group-nve"); + vty_out (vty, " vnc export zebra mode group-nve\n"); } else if (VNC_EXPORT_ZEBRA_RH_ENABLED (hc)) { - vty_outln (vty, " vnc export zebra mode registering-nve"); + vty_out (vty, " vnc export zebra mode registering-nve\n"); } if (hc->rfg_export_direct_bgp_l) @@ -4792,7 +4792,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) for (ALL_LIST_ELEMENTS (hc->rfg_export_direct_bgp_l, node, nnode, rfgn)) { - vty_outln (vty, " vnc export bgp group-nve group %s", + vty_out (vty, " vnc export bgp group-nve group %s\n", rfgn->name); } } @@ -4802,7 +4802,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) for (ALL_LIST_ELEMENTS (hc->rfg_export_zebra_l, node, nnode, rfgn)) { - vty_outln (vty, " vnc export zebra group-nve group %s", + vty_out (vty, " vnc export zebra group-nve group %s\n", rfgn->name); } } @@ -4810,19 +4810,19 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) if (hc->rfg_redist_name) { - vty_outln (vty, " vnc redistribute nve-group %s", + vty_out (vty, " vnc redistribute nve-group %s\n", hc->rfg_redist_name); } if (hc->redist_lifetime) { - vty_outln (vty, " vnc redistribute lifetime %d", + vty_out (vty, " vnc redistribute lifetime %d\n", hc->redist_lifetime); } if (hc->resolve_nve_roo_local_admin != BGP_VNC_CONFIG_RESOLVE_NVE_ROO_LOCAL_ADMIN_DEFAULT) { - vty_outln (vty, " vnc redistribute resolve-nve roo-ec-local-admin %d", + vty_out (vty, " vnc redistribute resolve-nve roo-ec-local-admin %d\n", hc->resolve_nve_roo_local_admin); } @@ -4844,7 +4844,7 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) } if (s) { - vty_outln (vty, " vnc redistribute mode %s", s); + vty_out (vty, " vnc redistribute mode %s\n", s); } } @@ -4858,34 +4858,34 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) if (hc->plist_export_bgp_name[afi]) { - vty_outln (vty, " vnc export bgp %s prefix-list %s", + vty_out (vty, " vnc export bgp %s prefix-list %s\n", afistr, hc->plist_export_bgp_name[afi]); } if (hc->plist_export_zebra_name[afi]) { - vty_outln (vty, " vnc export zebra %s prefix-list %s", + vty_out (vty, " vnc export zebra %s prefix-list %s\n", afistr, hc->plist_export_zebra_name[afi]); } if (hc->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]) { - vty_outln (vty, " vnc redistribute bgp-direct %s prefix-list %s", + vty_out (vty, " vnc redistribute bgp-direct %s prefix-list %s\n", afistr,hc->plist_redist_name[ZEBRA_ROUTE_BGP_DIRECT][afi]); } } if (hc->routemap_export_bgp_name) { - vty_outln (vty, " vnc export bgp route-map %s", + vty_out (vty, " vnc export bgp route-map %s\n", hc->routemap_export_bgp_name); } if (hc->routemap_export_zebra_name) { - vty_outln (vty, " vnc export zebra route-map %s", + vty_out (vty, " vnc export zebra route-map %s\n", hc->routemap_export_zebra_name); } if (hc->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]) { - vty_outln (vty, " vnc redistribute bgp-direct route-map %s", + vty_out (vty, " vnc redistribute bgp-direct route-map %s\n", hc->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]); } @@ -4898,14 +4898,14 @@ bgp_rfapi_cfg_write (struct vty *vty, struct bgp *bgp) if (type == ZEBRA_ROUTE_BGP_DIRECT_EXT && hc->redist_bgp_exterior_view_name) { - vty_outln (vty, " vnc redistribute %s %s view %s", + vty_out (vty, " vnc redistribute %s %s view %s\n", ((afi == AFI_IP) ? "ipv4" : "ipv6"), zebra_route_string (type), hc->redist_bgp_exterior_view_name); } else { - vty_outln (vty, " vnc redistribute %s %s", + vty_out (vty, " vnc redistribute %s %s\n", ((afi == AFI_IP) ? "ipv4" : "ipv6"), zebra_route_string(type)); } @@ -4924,7 +4924,7 @@ bgp_rfapi_show_summary (struct bgp *bgp, struct vty *vty) if (hc == NULL) return; - vty_outln (vty, "%-39s %-19s %s", "VNC Advertise method:", + vty_out (vty, "%-39s %-19s %s\n", "VNC Advertise method:", (hc->flags & BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP ? "Encapsulation SAFI" : "Tunnel Encap attribute"), ((hc->flags & BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP) == (BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP & BGP_VNC_CONFIG_FLAGS_DEFAULT) ? "(default)" : "")); @@ -4991,7 +4991,7 @@ bgp_rfapi_show_summary (struct bgp *bgp, struct vty *vty) vty_out (vty, "%sToZebra {Registering NVE}", (redist == 1 ? "" : " ")); /* note filters, route-maps not shown */ } - vty_outln (vty, "%-19s %s", (redist ? "" : "Off"), + vty_out (vty, "%-19s %s\n", (redist ? "" : "Off"), (redist ? "" : "(default)")); /* Redistribution */ @@ -5010,28 +5010,28 @@ bgp_rfapi_show_summary (struct bgp *bgp, struct vty *vty) } } } - vty_outln (vty, "%-19s %s", (redist ? "" : "Off"), + vty_out (vty, "%-19s %s\n", (redist ? "" : "Off"), (redist ? "" : "(default)")); - vty_outln (vty, "%-39s %3u%-16s %s", "RFP Registration Hold-Down Factor:", + vty_out (vty, "%-39s %3u%-16s %s\n", "RFP Registration Hold-Down Factor:", hc->rfp_cfg.holddown_factor, "%", (hc->rfp_cfg.holddown_factor == RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR ? "(default)" : "")); - vty_outln (vty, "%-39s %-19s %s", "RFP Updated responses:", + vty_out (vty, "%-39s %-19s %s\n", "RFP Updated responses:", (hc->rfp_cfg.use_updated_response == 0 ? "Off" : "On"), (hc->rfp_cfg.use_updated_response == 0 ? "(default)" : "")); - vty_outln (vty, "%-39s %-19s %s", "RFP Removal responses:", + vty_out (vty, "%-39s %-19s %s\n", "RFP Removal responses:", (hc->rfp_cfg.use_removes == 0 ? "Off" : "On"), (hc->rfp_cfg.use_removes == 0 ? "(default)" : "")); - vty_outln (vty, "%-39s %-19s %s", "RFP Full table download:", + vty_out (vty, "%-39s %-19s %s\n", "RFP Full table download:", (hc->rfp_cfg.download_type == RFAPI_RFP_DOWNLOAD_FULL ? "On" : "Off"), (hc->rfp_cfg.download_type == RFAPI_RFP_DOWNLOAD_PARTIAL ? "(default)" : "")); sprintf (tmp, "%u seconds", hc->rfp_cfg.ftd_advertisement_interval); - vty_outln (vty, "%-39s %-19s %s", " Advertisement Interval:", tmp, + vty_out (vty, "%-39s %-19s %s\n", " Advertisement Interval:", tmp, (hc->rfp_cfg.ftd_advertisement_interval == RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL ? "(default)" : "")); - vty_outln (vty, "%-39s %d seconds", "Default RFP response lifetime:", + vty_out (vty, "%-39s %d seconds\n", "Default RFP response lifetime:", hc->default_response_lifetime); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return; } diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index ffd4e3e32..a959b9827 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -715,7 +715,6 @@ add_vnc_route ( /* Cripes, the memory management of attributes is byzantine */ bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); - assert (attr.extra); /* * At this point: @@ -772,7 +771,6 @@ add_vnc_route ( /* Encap SAFI not used with MPLS */ vnc_zlog_debug_verbose ("%s: mpls tunnel type, encap safi omitted", __func__); aspath_unintern (&attr.aspath); /* Unintern original. */ - bgp_attr_extra_free (&attr); return; } } @@ -790,7 +788,7 @@ add_vnc_route ( } /* override default weight assigned by bgp_attr_default_set() */ - attr.extra->weight = rfd->peer ? rfd->peer->weight[afi][safi] : 0; + attr.weight = rfd->peer ? rfd->peer->weight[afi][safi] : 0; /* * NB: ticket 81: do not reset attr.aspath here because it would @@ -808,7 +806,7 @@ add_vnc_route ( if (type == ZEBRA_ROUTE_BGP_DIRECT || type == ZEBRA_ROUTE_BGP_DIRECT_EXT) { attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID); - attr.extra->originator_id = bgp->router_id; + attr.originator_id = bgp->router_id; } @@ -825,7 +823,7 @@ add_vnc_route ( encaptlv->length = 4; lt = htonl (*lifetime); memcpy (encaptlv->value, <, 4); - attr.extra->vnc_subtlvs = encaptlv; + attr.vnc_subtlvs = encaptlv; vnc_zlog_debug_verbose ("%s: set Encap Attr Prefix Lifetime to %d", __func__, *lifetime); } @@ -845,13 +843,13 @@ add_vnc_route ( */ encaptlv = encap_tlv_dup ((struct bgp_attr_encap_subtlv *) rfp_options); - if (attr.extra->vnc_subtlvs) + if (attr.vnc_subtlvs) { - attr.extra->vnc_subtlvs->next = encaptlv; + attr.vnc_subtlvs->next = encaptlv; } else { - attr.extra->vnc_subtlvs = encaptlv; + attr.vnc_subtlvs = encaptlv; } } @@ -859,7 +857,7 @@ add_vnc_route ( { struct bgp_tea_options *hop; /* XXX max of one tlv present so far from above code */ - struct bgp_attr_encap_subtlv *tail = attr.extra->vnc_subtlvs; + struct bgp_attr_encap_subtlv *tail = attr.vnc_subtlvs; for (hop = rfp_options; hop; hop = hop->next) { @@ -887,7 +885,7 @@ add_vnc_route ( } else { - attr.extra->vnc_subtlvs = encaptlv; + attr.vnc_subtlvs = encaptlv; } tail = encaptlv; } @@ -903,8 +901,8 @@ add_vnc_route ( */ - attr.extra->ecommunity = ecommunity_new (); - assert (attr.extra->ecommunity); + attr.ecommunity = ecommunity_new (); + assert (attr.ecommunity); if (TunnelType != BGP_ENCAP_TYPE_MPLS && TunnelType != BGP_ENCAP_TYPE_RESERVED) @@ -921,7 +919,7 @@ add_vnc_route ( beec.val[1] = ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP; beec.val[6] = ((TunnelType) >> 8) & 0xff; beec.val[7] = (TunnelType) & 0xff; - ecommunity_add_val (attr.extra->ecommunity, &beec); + ecommunity_add_val (attr.ecommunity, &beec); } /* @@ -929,21 +927,21 @@ add_vnc_route ( */ if (rt_export_list) { - attr.extra->ecommunity = - ecommunity_merge (attr.extra->ecommunity, rt_export_list); + attr.ecommunity = + ecommunity_merge (attr.ecommunity, rt_export_list); } - if (attr.extra->ecommunity->size) + if (attr.ecommunity->size) { attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES); } else { - ecommunity_free (&attr.extra->ecommunity); - attr.extra->ecommunity = NULL; + ecommunity_free (&attr.ecommunity); + attr.ecommunity = NULL; } - vnc_zlog_debug_verbose ("%s: attr.extra->ecommunity=%p", __func__, - attr.extra->ecommunity); + vnc_zlog_debug_verbose ("%s: attr.ecommunity=%p", __func__, + attr.ecommunity); /* @@ -965,13 +963,13 @@ add_vnc_route ( */ attr.nexthop.s_addr = nexthop->addr.v4.s_addr; - attr.extra->mp_nexthop_global_in = nexthop->addr.v4; - attr.extra->mp_nexthop_len = 4; + attr.mp_nexthop_global_in = nexthop->addr.v4; + attr.mp_nexthop_len = 4; break; case AF_INET6: - attr.extra->mp_nexthop_global = nexthop->addr.v6; - attr.extra->mp_nexthop_len = 16; + attr.mp_nexthop_global = nexthop->addr.v6; + attr.mp_nexthop_len = 16; break; default: @@ -1016,7 +1014,6 @@ add_vnc_route ( new_attr = bgp_attr_intern (&attr); aspath_unintern (&attr.aspath); /* Unintern original. */ - bgp_attr_extra_free (&attr); /* * At this point: @@ -3101,13 +3098,13 @@ DEFUN ( if (!str2prefix (argv[5]->arg, &pfx)) { - vty_outln (vty, "Malformed address \"%s\"", argv[5]->arg); - return CMD_WARNING; + vty_out (vty, "Malformed address \"%s\"\n", argv[5]->arg); + return CMD_WARNING_CONFIG_FAILED; } if (pfx.family != AF_INET && pfx.family != AF_INET6) { - vty_outln (vty, "Invalid address \"%s\"", argv[5]->arg); - return CMD_WARNING; + vty_out (vty, "Invalid address \"%s\"\n", argv[5]->arg); + return CMD_WARNING_CONFIG_FAILED; } if (argv[4]->arg[0] == 'u') @@ -3144,7 +3141,7 @@ test_nexthops_callback ( fp (out, "Nexthops Callback, Target=("); //rfapiPrintRfapiIpAddr(stream, target); - fp (out, ")%s", VTYNL); + fp (out, ")\n"); rfapiPrintNhl (stream, next_hops); @@ -3185,12 +3182,12 @@ DEFUN (debug_rfapi_open, rc = rfapi_open (rfapi_get_rfp_start_val_by_bgp (bgp_get_default ()), &vn, &un, /*&uo */ NULL, &lifetime, NULL, &handle); - vty_outln (vty, "rfapi_open: status %d, handle %p, lifetime %d", + vty_out (vty, "rfapi_open: status %d, handle %p, lifetime %d\n", rc, handle, lifetime); rc = rfapi_set_response_cb (handle, test_nexthops_callback); - vty_outln (vty, "rfapi_set_response_cb: status %d", rc); + vty_out (vty, "rfapi_set_response_cb: status %d\n", rc); return CMD_SUCCESS; } @@ -3230,14 +3227,14 @@ DEFUN (debug_rfapi_close_vn_un, if (rfapi_find_handle_vty (vty, &vn, &un, &handle)) { - vty_outln (vty, "can't locate handle matching vn=%s, un=%s", + vty_out (vty, "can't locate handle matching vn=%s, un=%s\n", argv[4]->arg, argv[6]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } rc = rfapi_close (handle); - vty_outln (vty, "rfapi_close(handle=%p): status %d", handle,rc); + vty_out (vty, "rfapi_close(handle=%p): status %d\n", handle,rc); return CMD_SUCCESS; } @@ -3258,13 +3255,13 @@ DEFUN (debug_rfapi_close_rfd, if (*endptr != '\0' || (uintptr_t) handle == UINTPTR_MAX) { - vty_outln (vty, "Invalid value: %s", argv[4]->arg); - return CMD_WARNING; + vty_out (vty, "Invalid value: %s\n", argv[4]->arg); + return CMD_WARNING_CONFIG_FAILED; } rc = rfapi_close (handle); - vty_outln (vty, "rfapi_close(handle=%p): status %d", handle,rc); + vty_out (vty, "rfapi_close(handle=%p): status %d\n", handle,rc); return CMD_SUCCESS; } @@ -3311,9 +3308,9 @@ DEFUN (debug_rfapi_register_vn_un, if (rfapi_find_handle_vty (vty, &vn, &un, &handle)) { - vty_outln (vty, "can't locate handle matching vn=%s, un=%s", + vty_out (vty, "can't locate handle matching vn=%s, un=%s\n", argv[4]->arg, argv[6]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* @@ -3321,13 +3318,13 @@ DEFUN (debug_rfapi_register_vn_un, */ if (!str2prefix (argv[8]->arg, &pfx)) { - vty_outln (vty, "Malformed prefix \"%s\"", argv[8]->arg); - return CMD_WARNING; + vty_out (vty, "Malformed prefix \"%s\"\n", argv[8]->arg); + return CMD_WARNING_CONFIG_FAILED; } if (pfx.family != AF_INET && pfx.family != AF_INET6) { - vty_outln (vty, "Bad family for prefix \"%s\"", argv[8]->arg); - return CMD_WARNING; + vty_out (vty, "Bad family for prefix \"%s\"\n", argv[8]->arg); + return CMD_WARNING_CONFIG_FAILED; } rfapiQprefix2Rprefix (&pfx, &hpfx); @@ -3344,7 +3341,7 @@ DEFUN (debug_rfapi_register_vn_un, rc = rfapi_register (handle, &hpfx, lifetime, NULL, NULL, 0); if (rc) { - vty_outln (vty, "rfapi_register failed with rc=%d (%s)", rc, + vty_out (vty, "rfapi_register failed with rc=%d (%s)\n", rc, strerror(rc)); } @@ -3400,9 +3397,9 @@ DEFUN (debug_rfapi_register_vn_un_l2o, if (rfapi_find_handle_vty (vty, &vn, &un, &handle)) { - vty_outln (vty, "can't locate handle matching vn=%s, un=%s", + vty_out (vty, "can't locate handle matching vn=%s, un=%s\n", argv[4]->arg, argv[6]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* @@ -3410,13 +3407,13 @@ DEFUN (debug_rfapi_register_vn_un_l2o, */ if (!str2prefix (argv[8]->arg, &pfx)) { - vty_outln (vty, "Malformed prefix \"%s\"", argv[8]->arg); - return CMD_WARNING; + vty_out (vty, "Malformed prefix \"%s\"\n", argv[8]->arg); + return CMD_WARNING_CONFIG_FAILED; } if (pfx.family != AF_INET && pfx.family != AF_INET6) { - vty_outln (vty, "Bad family for prefix \"%s\"", argv[8]->arg); - return CMD_WARNING; + vty_out (vty, "Bad family for prefix \"%s\"\n", argv[8]->arg); + return CMD_WARNING_CONFIG_FAILED; } rfapiQprefix2Rprefix (&pfx, &hpfx); @@ -3434,8 +3431,8 @@ DEFUN (debug_rfapi_register_vn_un_l2o, optary[opt_next].v.l2addr.logical_net_id = strtoul(argv[14]->arg, NULL, 10); if ((rc = rfapiStr2EthAddr (argv[12]->arg, &optary[opt_next].v.l2addr.macaddr))) { - vty_outln (vty, "Bad mac address \"%s\"", argv[12]->arg); - return CMD_WARNING; + vty_out (vty, "Bad mac address \"%s\"\n", argv[12]->arg); + return CMD_WARNING_CONFIG_FAILED; } optary[opt_next].type = RFAPI_VN_OPTION_TYPE_L2ADDR; if (opt_next) @@ -3453,7 +3450,7 @@ DEFUN (debug_rfapi_register_vn_un_l2o, rc = rfapi_register (handle, &hpfx, lifetime, NULL /* &uo */ , opt, 0); if (rc) { - vty_outln (vty, "rfapi_register failed with rc=%d (%s)", rc, + vty_out (vty, "rfapi_register failed with rc=%d (%s)\n", rc, strerror(rc)); } @@ -3496,9 +3493,9 @@ DEFUN (debug_rfapi_unregister_vn_un, if (rfapi_find_handle_vty (vty, &vn, &un, &handle)) { - vty_outln (vty, "can't locate handle matching vn=%s, un=%s", + vty_out (vty, "can't locate handle matching vn=%s, un=%s\n", argv[4]->arg, argv[6]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* @@ -3506,13 +3503,13 @@ DEFUN (debug_rfapi_unregister_vn_un, */ if (!str2prefix (argv[8]->arg, &pfx)) { - vty_outln (vty, "Malformed prefix \"%s\"", argv[8]->arg); - return CMD_WARNING; + vty_out (vty, "Malformed prefix \"%s\"\n", argv[8]->arg); + return CMD_WARNING_CONFIG_FAILED; } if (pfx.family != AF_INET && pfx.family != AF_INET6) { - vty_outln (vty, "Bad family for prefix \"%s\"", argv[8]->arg); - return CMD_WARNING; + vty_out (vty, "Bad family for prefix \"%s\"\n", argv[8]->arg); + return CMD_WARNING_CONFIG_FAILED; } rfapiQprefix2Rprefix (&pfx, &hpfx); @@ -3567,9 +3564,9 @@ DEFUN (debug_rfapi_query_vn_un, if (rfapi_find_handle_vty (vty, &vn, &un, &handle)) { - vty_outln (vty, "can't locate handle matching vn=%s, un=%s", + vty_out (vty, "can't locate handle matching vn=%s, un=%s\n", argv[4]->arg, argv[6]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* @@ -3579,7 +3576,7 @@ DEFUN (debug_rfapi_query_vn_un, if (rc) { - vty_outln (vty, "rfapi_query failed with rc=%d (%s)", rc, + vty_out (vty, "rfapi_query failed with rc=%d (%s)\n", rc, strerror(rc)); } else @@ -3642,15 +3639,15 @@ DEFUN (debug_rfapi_query_vn_un_l2o, if ((rc = rfapiCliGetRfapiIpAddr (vty, argv[2], &target))) return rc; #else - vty_outln (vty, "%% This command is broken."); - return CMD_WARNING; + vty_out (vty, "%% This command is broken.\n"); + return CMD_WARNING_CONFIG_FAILED; #endif if (rfapi_find_handle_vty (vty, &vn, &un, &handle)) { - vty_outln (vty, "can't locate handle matching vn=%s, un=%s", + vty_out (vty, "can't locate handle matching vn=%s, un=%s\n", argv[4]->arg, argv[6]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* @@ -3659,8 +3656,8 @@ DEFUN (debug_rfapi_query_vn_un_l2o, memset (&l2o_buf, 0, sizeof (l2o_buf)); if (rfapiStr2EthAddr (argv[10]->arg, &l2o_buf.macaddr)) { - vty_outln (vty, "Bad mac address \"%s\"", argv[10]->arg); - return CMD_WARNING; + vty_out (vty, "Bad mac address \"%s\"\n", argv[10]->arg); + return CMD_WARNING_CONFIG_FAILED; } l2o_buf.logical_net_id = strtoul(argv[8]->arg, NULL, 10); @@ -3688,7 +3685,7 @@ DEFUN (debug_rfapi_query_vn_un_l2o, if (rc) { - vty_outln (vty, "rfapi_query failed with rc=%d (%s)", rc, + vty_out (vty, "rfapi_query failed with rc=%d (%s)\n", rc, strerror(rc)); } else @@ -3750,9 +3747,9 @@ DEFUN (debug_rfapi_query_done_vn_un, if (rfapi_find_handle_vty (vty, &vn, &un, &handle)) { - vty_outln (vty, "can't locate handle matching vn=%s, un=%s", + vty_out (vty, "can't locate handle matching vn=%s, un=%s\n", argv[5]->arg, argv[7]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* @@ -3760,7 +3757,7 @@ DEFUN (debug_rfapi_query_done_vn_un, */ rc = rfapi_query_done (handle, &target); - vty_outln (vty, "rfapi_query_done returned %d", rc); + vty_out (vty, "rfapi_query_done returned %d\n", rc); return CMD_SUCCESS; } @@ -3786,15 +3783,15 @@ DEFUN (debug_rfapi_show_import, bgp = bgp_get_default (); /* assume 1 instance for now */ if (!bgp) { - vty_outln (vty, "No BGP instance"); - return CMD_WARNING; + vty_out (vty, "No BGP instance\n"); + return CMD_WARNING_CONFIG_FAILED; } h = bgp->rfapi; if (!h) { - vty_outln (vty, "No RFAPI instance"); - return CMD_WARNING; + vty_out (vty, "No RFAPI instance\n"); + return CMD_WARNING_CONFIG_FAILED; } /* @@ -3807,7 +3804,7 @@ DEFUN (debug_rfapi_show_import, { s = ecommunity_ecom2str (it->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - vty_outln (vty, "Import Table %p, RTs: %s", it, s); + vty_out (vty, "Import Table %p, RTs: %s\n", it, s); XFREE (MTYPE_ECOMMUNITY_STR, s); rfapiShowImportTable (vty, "IP VPN", it->imported_vpn[AFI_IP], 1); @@ -3837,8 +3834,7 @@ DEFUN (debug_rfapi_show_import, lni = lni_as_ptr; if (first_l2) { - vty_outln (vty, "%sLNI-based Ethernet Tables:", - VTYNL); + vty_out (vty, "\nLNI-based Ethernet Tables:\n"); first_l2 = 0; } snprintf (buf, BUFSIZ, "L2VPN LNI=%u", lni); @@ -3889,9 +3885,9 @@ DEFUN (debug_rfapi_show_import_vn_un, if (rfapi_find_handle_vty (vty, &vn, &un, &handle)) { - vty_outln (vty, "can't locate handle matching vn=%s, un=%s", + vty_out (vty, "can't locate handle matching vn=%s, un=%s\n", argv[5]->arg, argv[7]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } rfd = (struct rfapi_descriptor *) handle; @@ -3920,13 +3916,13 @@ DEFUN (debug_rfapi_response_omit_self, if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!bgp->rfapi_cfg) { - vty_outln (vty, "VNC not configured"); - return CMD_WARNING; + vty_out (vty, "VNC not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch(argv[3]->text, "on")) @@ -4191,7 +4187,7 @@ rfapi_rfp_get_or_init_group_config_nve ( if (!rfg || !listnode_lookup (rfc->nve_groups_sequential, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current NVE group no longer exists"); + vty_out (vty, "Current NVE group no longer exists\n"); return NULL; } @@ -4216,7 +4212,7 @@ rfapi_rfp_get_or_init_group_config_l2 ( if (!rfg || !listnode_lookup (rfc->l2_groups, rfg)) { /* Not in list anymore */ - vty_outln (vty, "Current L2 group no longer exists"); + vty_out (vty, "Current L2 group no longer exists\n"); return NULL; } if (rfg->rfp_cfg == NULL && size > 0) diff --git a/bgpd/rfapi/rfapi_encap_tlv.c b/bgpd/rfapi/rfapi_encap_tlv.c index 04f8b249f..24bfb41bf 100644 --- a/bgpd/rfapi/rfapi_encap_tlv.c +++ b/bgpd/rfapi/rfapi_encap_tlv.c @@ -162,28 +162,24 @@ rfapi_tunneltype_option_to_tlv ( struct rfapi_un_option * rfapi_encap_tlv_to_un_option (struct attr *attr) { - struct attr_extra *attre = attr->extra; struct rfapi_un_option *uo = NULL; struct rfapi_tunneltype_option *tto; int rc; struct bgp_attr_encap_subtlv *stlv; - if (!attre) - return NULL; - /* no tunnel encap attr stored */ - if (!attre->encap_tunneltype) + if (!attr->encap_tunneltype) return NULL; - stlv = attre->encap_subtlvs; + stlv = attr->encap_subtlvs; uo = XCALLOC (MTYPE_RFAPI_UN_OPTION, sizeof (struct rfapi_un_option)); assert (uo); uo->type = RFAPI_UN_OPTION_TYPE_TUNNELTYPE; - uo->v.tunnel.type = attre->encap_tunneltype; + uo->v.tunnel.type = attr->encap_tunneltype; tto = &uo->v.tunnel; - switch (attre->encap_tunneltype) + switch (attr->encap_tunneltype) { case BGP_ENCAP_TYPE_L2TPV3_OVER_IP: rc = tlv_to_bgp_encap_type_l2tpv3overip (stlv, &tto->bgpinfo.l2tpv3_ip); @@ -249,7 +245,7 @@ rfapi_encap_tlv_to_un_option (struct attr *attr) default: vnc_zlog_debug_verbose ("%s: unknown tunnel type %d", - __func__, attre->encap_tunneltype); + __func__, attr->encap_tunneltype); rc = -1; break; } diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index b6c0e3029..dc8dc1ed2 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -1,4 +1,4 @@ -/* + /* * * Copyright 2009-2016, LabN Consulting, L.L.C. * @@ -308,12 +308,12 @@ rfapi_deferred_close_workfunc (struct work_queue *q, void *data) int rfapiGetL2o (struct attr *attr, struct rfapi_l2address_option *l2o) { - if (attr && attr->extra) + if (attr) { struct bgp_attr_encap_subtlv *pEncap; - for (pEncap = attr->extra->vnc_subtlvs; pEncap; pEncap = pEncap->next) + for (pEncap = attr->vnc_subtlvs; pEncap; pEncap = pEncap->next) { if (pEncap->type == BGP_VNC_SUBTLV_TYPE_RFPOPTION) @@ -358,10 +358,10 @@ rfapiGetVncLifetime (struct attr *attr, uint32_t * lifetime) *lifetime = RFAPI_INFINITE_LIFETIME; /* default to infinite */ - if (attr && attr->extra) + if (attr) { - for (pEncap = attr->extra->vnc_subtlvs; pEncap; pEncap = pEncap->next) + for (pEncap = attr->vnc_subtlvs; pEncap; pEncap = pEncap->next) { if (pEncap->type == BGP_VNC_SUBTLV_TYPE_LIFETIME) @@ -387,9 +387,9 @@ rfapiGetTunnelType (struct attr *attr, bgp_encap_types *type) { *type = BGP_ENCAP_TYPE_MPLS; /* default to MPLS */ - if (attr && attr->extra && attr->extra->ecommunity) + if (attr && attr->ecommunity) { - struct ecommunity *ecom = attr->extra->ecommunity; + struct ecommunity *ecom = attr->ecommunity; int i; for (i = 0; i < (ecom->size * ECOMMUNITY_SIZE); i += ECOMMUNITY_SIZE) @@ -431,9 +431,9 @@ rfapiGetVncTunnelUnAddr (struct attr *attr, struct prefix *p) return ENOENT; } - if (attr && attr->extra) + if (attr) { - for (pEncap = attr->extra->encap_subtlvs; pEncap; pEncap = pEncap->next) + for (pEncap = attr->encap_subtlvs; pEncap; pEncap = pEncap->next) { if (pEncap->type == BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT) @@ -1184,7 +1184,7 @@ rfapiVpnBiNhEqualsPt (struct bgp_info *bi, struct rfapi_ip_addr *hpt) if (!hpt || !bi) return 0; - family = BGP_MP_NEXTHOP_FAMILY (bi->attr->extra->mp_nexthop_len); + family = BGP_MP_NEXTHOP_FAMILY (bi->attr->mp_nexthop_len); if (hpt->addr_family != family) return 0; @@ -1192,12 +1192,12 @@ rfapiVpnBiNhEqualsPt (struct bgp_info *bi, struct rfapi_ip_addr *hpt) switch (family) { case AF_INET: - if (bi->attr->extra->mp_nexthop_global_in.s_addr != hpt->addr.v4.s_addr) + if (bi->attr->mp_nexthop_global_in.s_addr != hpt->addr.v4.s_addr) return 0; break; case AF_INET6: - if (IPV6_ADDR_CMP (&bi->attr->extra->mp_nexthop_global, &hpt->addr.v6)) + if (IPV6_ADDR_CMP (&bi->attr->mp_nexthop_global, &hpt->addr.v6)) return 0; break; @@ -1225,31 +1225,27 @@ rfapiVpnBiSamePtUn (struct bgp_info *bi1, struct bgp_info *bi2) if (!bi1->attr || !bi2->attr) return 0; - if (!bi1->attr->extra || !bi2->attr->extra) - return 0; - /* * VN address comparisons */ - if (BGP_MP_NEXTHOP_FAMILY (bi1->attr->extra->mp_nexthop_len) != - BGP_MP_NEXTHOP_FAMILY (bi2->attr->extra->mp_nexthop_len)) + if (BGP_MP_NEXTHOP_FAMILY (bi1->attr->mp_nexthop_len) != + BGP_MP_NEXTHOP_FAMILY (bi2->attr->mp_nexthop_len)) { return 0; } - switch (BGP_MP_NEXTHOP_FAMILY (bi1->attr->extra->mp_nexthop_len)) + switch (BGP_MP_NEXTHOP_FAMILY (bi1->attr->mp_nexthop_len)) { - case AF_INET: - if (bi1->attr->extra->mp_nexthop_global_in.s_addr != - bi2->attr->extra->mp_nexthop_global_in.s_addr) + if (bi1->attr->mp_nexthop_global_in.s_addr != + bi2->attr->mp_nexthop_global_in.s_addr) return 0; break; case AF_INET6: - if (IPV6_ADDR_CMP (&bi1->attr->extra->mp_nexthop_global, - &bi2->attr->extra->mp_nexthop_global)) + if (IPV6_ADDR_CMP (&bi1->attr->mp_nexthop_global, + &bi2->attr->mp_nexthop_global)) return 0; break; @@ -1419,11 +1415,11 @@ rfapiRouteInfo2NextHopEntry ( memcpy (&vo->v.l2addr.macaddr, &rn->p.u.prefix_eth.octet, ETHER_ADDR_LEN); /* only low 3 bytes of this are significant */ - if (bi->attr && bi->attr->extra) + if (bi->attr) { - (void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity, + (void) rfapiEcommunityGetLNI (bi->attr->ecommunity, &vo->v.l2addr.logical_net_id); - (void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity, + (void) rfapiEcommunityGetEthernetTag (bi->attr->ecommunity, &vo->v.l2addr.tag_id); } @@ -1451,132 +1447,129 @@ rfapiRouteInfo2NextHopEntry ( bgp_encap_types tun_type; new->prefix.cost = rfapiRfpCost (bi->attr); - if (bi->attr->extra) + struct bgp_attr_encap_subtlv *pEncap; + + switch (BGP_MP_NEXTHOP_FAMILY (bi->attr->mp_nexthop_len)) { + case AF_INET: + new->vn_address.addr_family = AF_INET; + new->vn_address.addr.v4 = bi->attr->mp_nexthop_global_in; + break; - struct bgp_attr_encap_subtlv *pEncap; + case AF_INET6: + new->vn_address.addr_family = AF_INET6; + new->vn_address.addr.v6 = bi->attr->mp_nexthop_global; + break; - switch (BGP_MP_NEXTHOP_FAMILY (bi->attr->extra->mp_nexthop_len)) - { - case AF_INET: - new->vn_address.addr_family = AF_INET; - new->vn_address.addr.v4 = bi->attr->extra->mp_nexthop_global_in; - break; + default: + zlog_warn ("%s: invalid vpn nexthop length: %d", + __func__, bi->attr->mp_nexthop_len); + rfapi_free_next_hop_list (new); + return NULL; + } - case AF_INET6: - new->vn_address.addr_family = AF_INET6; - new->vn_address.addr.v6 = bi->attr->extra->mp_nexthop_global; + for (pEncap = bi->attr->vnc_subtlvs; pEncap; + pEncap = pEncap->next) + { + switch (pEncap->type) + { + case BGP_VNC_SUBTLV_TYPE_LIFETIME: + /* use configured lifetime, not attr lifetime */ break; default: - zlog_warn ("%s: invalid vpn nexthop length: %d", - __func__, bi->attr->extra->mp_nexthop_len); - rfapi_free_next_hop_list (new); - return NULL; - } + zlog_warn ("%s: unknown VNC option type %d", + __func__, pEncap->type); - for (pEncap = bi->attr->extra->vnc_subtlvs; pEncap; - pEncap = pEncap->next) - { - switch (pEncap->type) - { - case BGP_VNC_SUBTLV_TYPE_LIFETIME: - /* use configured lifetime, not attr lifetime */ - break; - default: - zlog_warn ("%s: unknown VNC option type %d", - __func__, pEncap->type); - - - break; - } + break; } + } - rfapiGetTunnelType (bi->attr, &tun_type); - if (tun_type == BGP_ENCAP_TYPE_MPLS) + rfapiGetTunnelType (bi->attr, &tun_type); + if (tun_type == BGP_ENCAP_TYPE_MPLS) + { + struct prefix p; + /* MPLS carries UN address in next hop */ + rfapiNexthop2Prefix (bi->attr, &p); + if (p.family != 0) { - struct prefix p; - /* MPLS carries UN address in next hop */ - rfapiNexthop2Prefix (bi->attr, &p); - if (p.family != 0) - { - rfapiQprefix2Raddr(&p, &new->un_address); - have_vnc_tunnel_un = 1; - } + rfapiQprefix2Raddr(&p, &new->un_address); + have_vnc_tunnel_un = 1; } + } - for (pEncap = bi->attr->extra->encap_subtlvs; pEncap; - pEncap = pEncap->next) + for (pEncap = bi->attr->encap_subtlvs; pEncap; + pEncap = pEncap->next) + { + switch (pEncap->type) { - switch (pEncap->type) + case BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT: + /* + * Overrides ENCAP UN address, if any + */ + switch (pEncap->length) { - case BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT: - /* - * Overrides ENCAP UN address, if any - */ - switch (pEncap->length) - { - case 8: - new->un_address.addr_family = AF_INET; - memcpy (&new->un_address.addr.v4, pEncap->value, 4); - have_vnc_tunnel_un = 1; - break; - - case 20: - new->un_address.addr_family = AF_INET6; - memcpy (&new->un_address.addr.v6, pEncap->value, 16); - have_vnc_tunnel_un = 1; - break; - - default: - zlog_warn - ("%s: invalid tunnel subtlv UN addr length (%d) for bi %p", - __func__, pEncap->length, bi); - } + case 8: + new->un_address.addr_family = AF_INET; + memcpy (&new->un_address.addr.v4, pEncap->value, 4); + have_vnc_tunnel_un = 1; + break; + + case 20: + new->un_address.addr_family = AF_INET6; + memcpy (&new->un_address.addr.v6, pEncap->value, 16); + have_vnc_tunnel_un = 1; break; default: - zlog_warn ("%s: unknown Encap Attribute option type %d", - __func__, pEncap->type); + zlog_warn + ("%s: invalid tunnel subtlv UN addr length (%d) for bi %p", + __func__, pEncap->length, bi); + } + break; + default: + zlog_warn ("%s: unknown Encap Attribute option type %d", + __func__, pEncap->type); - break; - } + + break; } + } - new->un_options = rfapi_encap_tlv_to_un_option (bi->attr); + new->un_options = rfapi_encap_tlv_to_un_option (bi->attr); #if DEBUG_ENCAP_MONITOR - vnc_zlog_debug_verbose ("%s: line %d: have_vnc_tunnel_un=%d", - __func__, __LINE__, have_vnc_tunnel_un); + vnc_zlog_debug_verbose ("%s: line %d: have_vnc_tunnel_un=%d", + __func__, __LINE__, have_vnc_tunnel_un); #endif - if (!have_vnc_tunnel_un && bi && bi->extra) + if (!have_vnc_tunnel_un && bi && bi->extra) + { + /* + * use cached UN address from ENCAP route + */ + new->un_address.addr_family = bi->extra->vnc.import.un_family; + switch (new->un_address.addr_family) { - /* - * use cached UN address from ENCAP route - */ - new->un_address.addr_family = bi->extra->vnc.import.un_family; - switch (new->un_address.addr_family) - { - case AF_INET: - new->un_address.addr.v4 = bi->extra->vnc.import.un.addr4; - break; - case AF_INET6: - new->un_address.addr.v6 = bi->extra->vnc.import.un.addr6; - break; - default: - zlog_warn ("%s: invalid UN addr family (%d) for bi %p", - __func__, new->un_address.addr_family, bi); - rfapi_free_next_hop_list (new); - return NULL; - break; - } + case AF_INET: + new->un_address.addr.v4 = bi->extra->vnc.import.un.addr4; + break; + case AF_INET6: + new->un_address.addr.v6 = bi->extra->vnc.import.un.addr6; + break; + default: + zlog_warn ("%s: invalid UN addr family (%d) for bi %p", + __func__, new->un_address.addr_family, bi); + rfapi_free_next_hop_list (new); + return NULL; + break; } } } + new->lifetime = lifetime; return new; } @@ -2123,6 +2116,8 @@ rfapiBgpInfoAttachSorted ( struct bgp *bgp; struct bgp_info *prev; struct bgp_info *next; + char pfx_buf[PREFIX2STR_BUFFER]; + bgp = bgp_get_default (); /* assume 1 instance for now */ @@ -2138,7 +2133,7 @@ rfapiBgpInfoAttachSorted ( if (!bgp || (!CHECK_FLAG (info_new->flags, BGP_INFO_REMOVED) && CHECK_FLAG (next->flags, BGP_INFO_REMOVED)) || - bgp_info_cmp_compatible (bgp, info_new, next, afi, safi) == -1) + bgp_info_cmp_compatible (bgp, info_new, next, pfx_buf, afi, safi) == -1) { /* -1 if 1st is better */ break; } @@ -2702,19 +2697,18 @@ rfapiNexthop2Prefix (struct attr *attr, struct prefix *p) { assert (p); assert (attr); - assert (attr->extra); memset (p, 0, sizeof (struct prefix)); - switch (p->family = BGP_MP_NEXTHOP_FAMILY (attr->extra->mp_nexthop_len)) + switch (p->family = BGP_MP_NEXTHOP_FAMILY (attr->mp_nexthop_len)) { case AF_INET: - p->u.prefix4 = attr->extra->mp_nexthop_global_in; + p->u.prefix4 = attr->mp_nexthop_global_in; p->prefixlen = 32; break; case AF_INET6: - p->u.prefix6 = attr->extra->mp_nexthop_global; + p->u.prefix6 = attr->mp_nexthop_global; p->prefixlen = 128; break; @@ -2779,9 +2773,7 @@ rfapiAttrNexthopAddrDifferent (struct prefix *p1, struct prefix *p2) static void rfapiCopyUnEncap2VPN (struct bgp_info *encap_bi, struct bgp_info *vpn_bi) { - struct attr_extra *attre; - - if (!encap_bi->attr || !encap_bi->attr->extra) + if (!encap_bi->attr) { zlog_warn ("%s: no encap bi attr/extra, can't copy UN address", __func__); @@ -2795,9 +2787,7 @@ rfapiCopyUnEncap2VPN (struct bgp_info *encap_bi, struct bgp_info *vpn_bi) return; } - attre = encap_bi->attr->extra; - - switch (BGP_MP_NEXTHOP_FAMILY (attre->mp_nexthop_len)) + switch (BGP_MP_NEXTHOP_FAMILY (encap_bi->attr->mp_nexthop_len)) { case AF_INET: @@ -2811,17 +2801,17 @@ rfapiCopyUnEncap2VPN (struct bgp_info *encap_bi, struct bgp_info *vpn_bi) } vpn_bi->extra->vnc.import.un_family = AF_INET; - vpn_bi->extra->vnc.import.un.addr4 = attre->mp_nexthop_global_in; + vpn_bi->extra->vnc.import.un.addr4 = encap_bi->attr->mp_nexthop_global_in; break; case AF_INET6: vpn_bi->extra->vnc.import.un_family = AF_INET6; - vpn_bi->extra->vnc.import.un.addr6 = attre->mp_nexthop_global; + vpn_bi->extra->vnc.import.un.addr6 = encap_bi->attr->mp_nexthop_global; break; default: zlog_warn ("%s: invalid encap nexthop length: %d", - __func__, attre->mp_nexthop_len); + __func__, encap_bi->attr->mp_nexthop_len); vpn_bi->extra->vnc.import.un_family = 0; break; } @@ -3102,21 +3092,21 @@ rfapiExpireEncapNow ( static int rfapiGetNexthop (struct attr *attr, struct prefix *prefix) { - switch (BGP_MP_NEXTHOP_FAMILY (attr->extra->mp_nexthop_len)) + switch (BGP_MP_NEXTHOP_FAMILY (attr->mp_nexthop_len)) { case AF_INET: prefix->family = AF_INET; prefix->prefixlen = 32; - prefix->u.prefix4 = attr->extra->mp_nexthop_global_in; + prefix->u.prefix4 = attr->mp_nexthop_global_in; break; case AF_INET6: prefix->family = AF_INET6; prefix->prefixlen = 128; - prefix->u.prefix6 = attr->extra->mp_nexthop_global; + prefix->u.prefix6 = attr->mp_nexthop_global; break; default: - vnc_zlog_debug_verbose ("%s: unknown attr->extra->mp_nexthop_len %d", __func__, - attr->extra->mp_nexthop_len); + vnc_zlog_debug_verbose ("%s: unknown attr->mp_nexthop_len %d", __func__, + attr->mp_nexthop_len); return EINVAL; } return 0; @@ -3187,7 +3177,7 @@ rfapiBgpInfoFilteredImportEncap ( * On a withdraw, peer and RD are sufficient to determine if * we should act. */ - if (!attr || !attr->extra || !attr->extra->ecommunity) + if (!attr || !attr->ecommunity) { vnc_zlog_debug_verbose ("%s: attr, extra, or ecommunity missing, not importing", @@ -3195,7 +3185,7 @@ rfapiBgpInfoFilteredImportEncap ( return; } #if RFAPI_REQUIRE_ENCAP_BEEC - if (!rfapiEcommunitiesMatchBeec (attr->extra->ecommunity)) + if (!rfapiEcommunitiesMatchBeec (attr->ecommunity)) { vnc_zlog_debug_verbose ("%s: it=%p: no match for BGP Encapsulation ecommunity", __func__, import_table); @@ -3203,7 +3193,7 @@ rfapiBgpInfoFilteredImportEncap ( } #endif if (!rfapiEcommunitiesIntersect (import_table->rt_import_list, - attr->extra->ecommunity)) + attr->ecommunity)) { vnc_zlog_debug_verbose ("%s: it=%p: no ecommunity intersection", @@ -3669,7 +3659,7 @@ rfapiBgpInfoFilteredImportVPN ( */ if (action == FIF_ACTION_UPDATE) { - if (!attr || !attr->extra || !attr->extra->ecommunity) + if (!attr || !attr->ecommunity) { vnc_zlog_debug_verbose ("%s: attr, extra, or ecommunity missing, not importing", @@ -3678,7 +3668,7 @@ rfapiBgpInfoFilteredImportVPN ( } if ((import_table != bgp->rfapi->it_ce) && !rfapiEcommunitiesIntersect (import_table->rt_import_list, - attr->extra->ecommunity)) + attr->ecommunity)) { vnc_zlog_debug_verbose ("%s: it=%p: no ecommunity intersection", @@ -4162,12 +4152,12 @@ rfapiProcessUpdate ( * Find rt containing LNI (Logical Network ID), which * _should_ always be present when mac address is present */ - rc = rfapiEcommunityGetLNI (attr->extra->ecommunity, &lni); + rc = rfapiEcommunityGetLNI (attr->ecommunity, &lni); vnc_zlog_debug_verbose - ("%s: rfapiEcommunityGetLNI returned %d, lni=%d, attr=%p, attr->extra=%p", - __func__, rc, lni, attr, attr->extra); - if (attr && attr->extra && !rc) + ("%s: rfapiEcommunityGetLNI returned %d, lni=%d, attr=%p", + __func__, rc, lni, attr); + if (attr && !rc) { it = rfapiMacImportTableGet (bgp, lni); diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 855901b5a..902e70207 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -664,7 +664,7 @@ rfapiRibBi2Ri( ri->lifetime = lifetime; /* This loop based on rfapiRouteInfo2NextHopEntry() */ - for (pEncap = bi->attr->extra->vnc_subtlvs; pEncap; pEncap = pEncap->next) + for (pEncap = bi->attr->vnc_subtlvs; pEncap; pEncap = pEncap->next) { struct bgp_tea_options *hop; @@ -723,11 +723,11 @@ rfapiRibBi2Ri( memcpy (&vo->v.l2addr.macaddr, bi->extra->vnc.import.rd.val+2, ETHER_ADDR_LEN); - if (bi->attr && bi->attr->extra) + if (bi->attr) { - (void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity, + (void) rfapiEcommunityGetLNI (bi->attr->ecommunity, &vo->v.l2addr.logical_net_id); - (void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity, + (void) rfapiEcommunityGetEthernetTag (bi->attr->ecommunity, &vo->v.l2addr.tag_id); } @@ -2296,7 +2296,7 @@ rfapiRibShowResponsesSummary (void *stream) fp (out, "%-24s ", "Responses: (Prefixes)"); fp (out, "%-8s %-8u ", "Active:", bgp->rfapi->rib_prefix_count_total); fp (out, "%-8s %-8u", "Maximum:", bgp->rfapi->rib_prefix_count_total_max); - fp (out, "%s", VTYNL); + fp (out, "\n"); fp (out, "%-24s ", " (Updated)"); fp (out, "%-8s %-8u ", "Update:", @@ -2306,7 +2306,7 @@ rfapiRibShowResponsesSummary (void *stream) fp (out, "%-8s %-8u", "Total:", bgp->rfapi->stat.count_updated_response_updates + bgp->rfapi->stat.count_updated_response_deletes); - fp (out, "%s", VTYNL); + fp (out, "\n"); fp (out, "%-24s ", " (NVEs)"); for (ALL_LIST_ELEMENTS_RO (&bgp->rfapi->descriptors, node, rfd)) @@ -2317,7 +2317,7 @@ rfapiRibShowResponsesSummary (void *stream) } fp (out, "%-8s %-8u ", "Active:", nves_with_nonempty_ribs); fp (out, "%-8s %-8u", "Total:", nves); - fp (out, "%s", VTYNL); + fp (out, "\n"); } @@ -2387,10 +2387,10 @@ print_rib_sl ( prefix_rd2str(&ri->rk.rd, str_rd+1, BUFSIZ-1); #endif - fp (out, " %c %-20s %-15s %-15s %-4u %-8s %-8s%s%s", + fp (out, " %c %-20s %-15s %-15s %-4u %-8s %-8s%s\n", deleted ? 'r' : ' ', *printedprefix ? "" : str_pfx, - str_vn, str_un, ri->cost, str_lifetime, str_age, str_rd, VTYNL); + str_vn, str_un, ri->cost, str_lifetime, str_age, str_rd); if (!*printedprefix) *printedprefix = 1; @@ -2502,20 +2502,18 @@ rfapiRibShowResponses ( { ++printedheader; - fp (out, "%s[%s]%s", - VTYNL, - show_removed ? "Removed" : "Active", VTYNL); - fp (out, "%-15s %-15s%s", "Querying VN", "Querying UN", - VTYNL); - fp (out, " %-20s %-15s %-15s %4s %-8s %-8s%s", + fp (out, "\n[%s]\n", + show_removed ? "Removed" : "Active"); + fp (out, "%-15s %-15s\n", "Querying VN", "Querying UN"); + fp (out, " %-20s %-15s %-15s %4s %-8s %-8s\n", "Prefix", "Registered VN", "Registered UN", "Cost", "Lifetime", #if RFAPI_REGISTRATIONS_REPORT_AGE - "Age", + "Age" #else - "Remaining", + "Remaining" #endif - VTYNL); + ); } if (!printednve) { @@ -2525,14 +2523,13 @@ rfapiRibShowResponses ( ++printednve; ++nves_displayed; - fp (out, "%-15s %-15s%s", + fp (out, "%-15s %-15s\n", rfapiRfapiIpAddr2Str (&rfd->vn_addr, str_vn, BUFSIZ), - rfapiRfapiIpAddr2Str (&rfd->un_addr, str_un, BUFSIZ), - VTYNL); + rfapiRfapiIpAddr2Str (&rfd->un_addr, str_un, BUFSIZ)); } prefix2str (&rn->p, str_pfx, BUFSIZ); - //fp(out, " %s%s", buf, VTYNL); /* prefix */ + //fp(out, " %s\n", buf); /* prefix */ routes_displayed++; nhs_displayed += print_rib_sl (fp, vty, out, sl, @@ -2544,12 +2541,12 @@ rfapiRibShowResponses ( if (routes_total) { - fp (out, "%s", VTYNL); + fp (out, "\n"); fp (out, "Displayed %u NVEs, and %u out of %u %s prefixes", nves_displayed, routes_displayed, routes_total, show_removed ? "removed" : "active"); if (nhs_displayed != routes_displayed || nhs_total != routes_total) fp (out, " with %u out of %u next hops", nhs_displayed, nhs_total); - fp (out, "%s", VTYNL); + fp (out, "\n"); } } diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index d12958a60..103f87ed0 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -385,14 +385,14 @@ rfapiStdioPrintf (void *stream, const char *format, ...) /* Fake out for debug logging */ static struct vty vty_dummy_zlog; static struct vty vty_dummy_stdio; -#define HVTYNL ((vty == &vty_dummy_zlog)? "": VTYNL) +#define HVTYNL ((vty == &vty_dummy_zlog)? "": "\n") static const char * str_vty_newline (struct vty *vty) { if (vty == &vty_dummy_zlog) return ""; - return VTYNL; + return "\n"; } int @@ -469,9 +469,9 @@ rfapi_vty_out_vncinfo ( } } - if (bi->attr && bi->attr->extra && bi->attr->extra->ecommunity) + if (bi->attr && bi->attr->ecommunity) { - s = ecommunity_ecom2str (bi->attr->extra->ecommunity, + s = ecommunity_ecom2str (bi->attr->ecommunity, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); vty_out (vty, " EC{%s}", s); XFREE (MTYPE_ECOMMUNITY_STR, s); @@ -499,7 +499,6 @@ rfapiPrintAttrPtrs (void *stream, struct attr *attr) void *out; const char *vty_newline; - struct attr_extra *ae; char buf[BUFSIZ]; if (rfapiStream2Vty (stream, &fp, &vty, &out, &vty_newline) == 0) @@ -518,15 +517,12 @@ rfapiPrintAttrPtrs (void *stream, struct attr *attr) fp (out, " community=%p, refcnt=%d%s", attr->community, (attr->community ? attr->community->refcnt : 0), HVTYNL); - if ((ae = attr->extra)) - { - fp (out, " ecommunity=%p, refcnt=%d%s", ae->ecommunity, - (ae->ecommunity ? ae->ecommunity->refcnt : 0), HVTYNL); - fp (out, " cluster=%p, refcnt=%d%s", ae->cluster, - (ae->cluster ? ae->cluster->refcnt : 0), HVTYNL); - fp (out, " transit=%p, refcnt=%d%s", ae->transit, - (ae->transit ? ae->transit->refcnt : 0), HVTYNL); - } + fp (out, " ecommunity=%p, refcnt=%d%s", attr->ecommunity, + (attr->ecommunity ? attr->ecommunity->refcnt : 0), HVTYNL); + fp (out, " cluster=%p, refcnt=%d%s", attr->cluster, + (attr->cluster ? attr->cluster->refcnt : 0), HVTYNL); + fp (out, " transit=%p, refcnt=%d%s", attr->transit, + (attr->transit ? attr->transit->refcnt : 0), HVTYNL); } /* @@ -593,26 +589,26 @@ rfapiPrintBi (void *stream, struct bgp_info *bi) * RFP option sizes (they are opaque values) * extended communities (RTs) */ - if (bi->attr && bi->attr->extra) + if (bi->attr) { uint32_t lifetime; int printed_1st_gol = 0; struct bgp_attr_encap_subtlv *pEncap; struct prefix pfx_un; - int af = BGP_MP_NEXTHOP_FAMILY (bi->attr->extra->mp_nexthop_len); + int af = BGP_MP_NEXTHOP_FAMILY (bi->attr->mp_nexthop_len); /* Nexthop */ if (af == AF_INET) { r = snprintf (p, REMAIN, "%s", inet_ntop (AF_INET, - &bi->attr->extra->mp_nexthop_global_in, + &bi->attr->mp_nexthop_global_in, buf, BUFSIZ)); INCP; } else if (af == AF_INET6) { r = snprintf (p, REMAIN, "%s", inet_ntop (AF_INET6, - &bi->attr->extra->mp_nexthop_global, + &bi->attr->mp_nexthop_global, buf, BUFSIZ)); INCP; } @@ -650,7 +646,7 @@ rfapiPrintBi (void *stream, struct bgp_info *bi) } /* RFP option lengths */ - for (pEncap = bi->attr->extra->vnc_subtlvs; pEncap; + for (pEncap = bi->attr->vnc_subtlvs; pEncap; pEncap = pEncap->next) { @@ -673,9 +669,9 @@ rfapiPrintBi (void *stream, struct bgp_info *bi) } /* RT list */ - if (bi->attr->extra->ecommunity) + if (bi->attr->ecommunity) { - s = ecommunity_ecom2str (bi->attr->extra->ecommunity, + s = ecommunity_ecom2str (bi->attr->ecommunity, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); r = snprintf (p, REMAIN, " %s", s); INCP; @@ -704,9 +700,9 @@ rfapiPrintBi (void *stream, struct bgp_info *bi) if (bi->attr) { - if (bi->attr->extra) + if (bi->attr->weight) { - r = snprintf (p, REMAIN, " W=%d", bi->attr->extra->weight); + r = snprintf (p, REMAIN, " W=%d", bi->attr->weight); INCP; } @@ -939,14 +935,14 @@ rfapiShowVncQueries (void *stream, struct prefix *pfx_match) bgp = bgp_get_default (); /* assume 1 instance for now */ if (!bgp) { - vty_outln (vty, "No BGP instance"); + vty_out (vty, "No BGP instance\n"); return CMD_WARNING; } h = bgp->rfapi; if (!h) { - vty_outln (vty, "No RFAPI instance"); + vty_out (vty, "No RFAPI instance\n"); return CMD_WARNING; } @@ -995,10 +991,10 @@ rfapiShowVncQueries (void *stream, struct prefix *pfx_match) if (!printedheader) { ++printedheader; - fp (out, "%s", VTYNL); - fp (out, "%-15s %-15s %-15s %-10s%s", + fp (out, "\n"); + fp (out, "%-15s %-15s %-15s %-10s\n", "VN Address", "UN Address", - "Target", "Remaining", VTYNL); + "Target", "Remaining"); } if (!printedquerier) @@ -1022,9 +1018,9 @@ rfapiShowVncQueries (void *stream, struct prefix *pfx_match) rfapiFormatSeconds (thread_timer_remain_second (m->timer), buf_remain, BUFSIZ); } - fp (out, " %-15s %-10s%s", + fp (out, " %-15s %-10s\n", inet_ntop (m->p.family, &m->p.u.prefix, buf_pfx, BUFSIZ), - buf_remain, VTYNL); + buf_remain); } } @@ -1070,10 +1066,10 @@ rfapiShowVncQueries (void *stream, struct prefix *pfx_match) if (!printedheader) { ++printedheader; - fp (out, "%s", VTYNL); - fp (out, "%-15s %-15s %-17s %10s %-10s%s", + fp (out, "\n"); + fp (out, "%-15s %-15s %-17s %10s %-10s\n", "VN Address", "UN Address", - "Target", "LNI", "Remaining", VTYNL); + "Target", "LNI", "Remaining"); } if (!printedquerier) @@ -1097,19 +1093,18 @@ rfapiShowVncQueries (void *stream, struct prefix *pfx_match) rfapiFormatSeconds (thread_timer_remain_second (mon_eth->timer), buf_remain, BUFSIZ); } - fp (out, " %-17s %10d %-10s%s", + fp (out, " %-17s %10d %-10s\n", rfapi_ntop (pfx_mac.family, &pfx_mac.u.prefix, buf_pfx, - BUFSIZ), mon_eth->logical_net_id, buf_remain, - VTYNL); + BUFSIZ), mon_eth->logical_net_id, buf_remain); } } } if (queries_total) { - fp (out, "%s", VTYNL); - fp (out, "Displayed %d out of %d total queries%s", - queries_displayed, queries_total, VTYNL); + fp (out, "\n"); + fp (out, "Displayed %d out of %d total queries\n", + queries_displayed, queries_total); } return CMD_SUCCESS; } @@ -2208,7 +2203,7 @@ register_add ( struct rfapi_vn_option *opt = NULL; int opt_next = 0; - int rc = CMD_WARNING; + int rc = CMD_WARNING_CONFIG_FAILED; char *endptr; struct bgp *bgp; struct rfapi *h; @@ -2221,8 +2216,8 @@ register_add ( if (!bgp) { if (vty) - vty_outln (vty, "BGP not configured"); - return CMD_WARNING; + vty_out (vty, "BGP not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } h = bgp->rfapi; @@ -2230,8 +2225,8 @@ register_add ( if (!h || !rfapi_cfg) { if (vty) - vty_outln (vty, "RFAPI not configured"); - return CMD_WARNING; + vty_out (vty, "RFAPI not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } for (; argc; --argc, ++argv) @@ -2240,13 +2235,13 @@ register_add ( { if (arg_lnh) { - vty_outln (vty,"local-next-hop specified more than once"); - return CMD_WARNING; + vty_out (vty,"local-next-hop specified more than once\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argc <= 1) { - vty_outln (vty,"Missing parameter for local-next-hop"); - return CMD_WARNING; + vty_out (vty,"Missing parameter for local-next-hop\n"); + return CMD_WARNING_CONFIG_FAILED; } ++argv, --argc; arg_lnh = argv[0]->arg; @@ -2255,13 +2250,13 @@ register_add ( { if (arg_lnh_cost) { - vty_outln (vty,"local-cost specified more than once"); - return CMD_WARNING; + vty_out (vty,"local-cost specified more than once\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argc <= 1) { - vty_outln (vty,"Missing parameter for local-cost"); - return CMD_WARNING; + vty_out (vty,"Missing parameter for local-cost\n"); + return CMD_WARNING_CONFIG_FAILED; } ++argv, --argc; arg_lnh_cost = argv[0]->arg; @@ -2288,21 +2283,21 @@ register_add ( arg_prefix = "0::0/128"; break; default: - vty_outln (vty,"Internal error, unknown VN address family"); - return CMD_WARNING; + vty_out (vty,"Internal error, unknown VN address family\n"); + return CMD_WARNING_CONFIG_FAILED; } } if (!str2prefix (arg_prefix, &pfx)) { - vty_outln (vty, "Malformed prefix \"%s\"",arg_prefix); + vty_out (vty, "Malformed prefix \"%s\"\n",arg_prefix); goto fail; } if (pfx.family != AF_INET && pfx.family != AF_INET6) { - vty_outln (vty, "prefix \"%s\" has invalid address family", + vty_out (vty, "prefix \"%s\" has invalid address family\n", arg_prefix); goto fail; } @@ -2316,7 +2311,7 @@ register_add ( cost = strtoul (arg_cost, &endptr, 10); if (*endptr != '\0' || cost > 255) { - vty_outln (vty, "%% Invalid %s value", "cost"); + vty_out (vty, "%% Invalid %s value\n", "cost"); goto fail; } } @@ -2337,7 +2332,7 @@ register_add ( lifetime = strtoul (arg_lifetime, &endptr, 10); if (*endptr != '\0') { - vty_outln (vty, "%% Invalid %s value","lifetime"); + vty_out (vty, "%% Invalid %s value\n","lifetime"); goto fail; } } @@ -2351,8 +2346,8 @@ register_add ( { if (!arg_lnh) { - vty_outln (vty, - "%% %s may only be specified with local-next-hop", + vty_out (vty, + "%% %s may only be specified with local-next-hop\n", "local-cost"); goto fail; } @@ -2360,7 +2355,7 @@ register_add ( lnh_cost = strtoul (arg_lnh_cost, &endptr, 10); if (*endptr != '\0' || lnh_cost > 255) { - vty_outln (vty, "%% Invalid %s value","local-cost"); + vty_out (vty, "%% Invalid %s value\n","local-cost"); goto fail; } } @@ -2373,7 +2368,7 @@ register_add ( { if (!arg_prefix) { - vty_outln (vty, "%% %s may only be specified with prefix", + vty_out (vty, "%% %s may only be specified with prefix\n", "local-next-hop"); goto fail; } @@ -2401,7 +2396,7 @@ register_add ( if (arg_vni && !arg_macaddr) { - vty_outln (vty, "%% %s may only be specified with mac address", + vty_out (vty, "%% %s may only be specified with mac address\n", "virtual-network-identifier"); goto fail; } @@ -2410,9 +2405,9 @@ register_add ( { if (!arg_vni) { - vty_outln (vty, - "Missing \"vni\" parameter (mandatory with mac)"); - return CMD_WARNING; + vty_out (vty, + "Missing \"vni\" parameter (mandatory with mac)\n"); + return CMD_WARNING_CONFIG_FAILED; } optary[opt_next].v.l2addr.logical_net_id = strtoul(arg_vni, NULL, 10); @@ -2420,7 +2415,7 @@ register_add ( if ((rc = rfapiStr2EthAddr (arg_macaddr, &optary[opt_next].v.l2addr.macaddr))) { - vty_outln (vty, "Invalid %s value","mac address"); + vty_out (vty, "Invalid %s value\n","mac address"); goto fail; } /* TBD label, NVE ID */ @@ -2472,15 +2467,15 @@ register_add ( &rfd); if (rc) { - vty_outln (vty, "Can't open session for this NVE: %s", + vty_out (vty, "Can't open session for this NVE: %s\n", rfapi_error_str(rc)); - rc = CMD_WARNING; + rc = CMD_WARNING_CONFIG_FAILED; goto fail; } } else { - vty_outln (vty, "Can't find session for this NVE: %s", + vty_out (vty, "Can't find session for this NVE: %s\n", rfapi_error_str(rc)); goto fail; } @@ -2516,11 +2511,11 @@ register_add ( } vnc_zlog_debug_verbose ("%s: rfapi_register failed", __func__); - vty_out (vty, VTYNL); - vty_outln (vty, "Registration failed."); - vty_outln (vty, - "Confirm that either the VN or UN address matches a configured NVE group."); - return CMD_WARNING; + vty_out (vty, "\n"); + vty_out (vty, "Registration failed.\n"); + vty_out (vty, + "Confirm that either the VN or UN address matches a configured NVE group.\n"); + return CMD_WARNING_CONFIG_FAILED; fail: vnc_zlog_debug_verbose ("%s: fail, rc=%d", __func__, rc); @@ -3129,7 +3124,7 @@ parse_deleter_args ( if (!str2prefix (arg_prefix, &rcdarg->prefix)) { - vty_outln (vty, "Malformed prefix \"%s\"", arg_prefix); + vty_out (vty, "Malformed prefix \"%s\"\n", arg_prefix); return rc; } } @@ -3138,14 +3133,14 @@ parse_deleter_args ( { if (!arg_vni) { - vty_outln (vty, "Missing VNI"); + vty_out (vty, "Missing VNI\n"); return rc; } if (strcmp (arg_l2addr, "*")) { if ((rc = rfapiStr2EthAddr (arg_l2addr, &rcdarg->l2o.o.macaddr))) { - vty_outln (vty, "Malformed L2 Address \"%s\"", + vty_out (vty, "Malformed L2 Address \"%s\"\n", arg_l2addr); return rc; } @@ -3161,7 +3156,7 @@ parse_deleter_args ( { if (!str2prefix_rd (arg_rd, &rcdarg->rd)) { - vty_outln (vty, "Malformed RD \"%s\"", + vty_out (vty, "Malformed RD \"%s\"\n", arg_rd); return rc; } @@ -3705,12 +3700,12 @@ print_cleared_stats (struct rfapi_local_reg_delete_arg *cda) cda->nves = NULL; } if (cda->failed_pfx_count) - vty_outln (vty, "Failed to delete %d prefixes", + vty_out (vty, "Failed to delete %d prefixes\n", cda->failed_pfx_count); /* left as "prefixes" even in single case for ease of machine parsing */ - vty_outln (vty, - "[Local] Cleared %u registrations, %u prefixes, %u responses from %d NVEs", + vty_out (vty, + "[Local] Cleared %u registrations, %u prefixes, %u responses from %d NVEs\n", cda->reg_count, cda->pfx_count, cda->query_count,cda->nve_count); /* @@ -3718,7 +3713,7 @@ print_cleared_stats (struct rfapi_local_reg_delete_arg *cda) * the command line */ - vty_outln (vty, "[Holddown] Cleared %u prefixes from %u NVEs", + vty_out (vty, "[Holddown] Cleared %u prefixes from %u NVEs\n", cda->remote_holddown_pfx_count,cda->remote_holddown_nve_count); } @@ -4395,8 +4390,8 @@ check_and_display_is_vnc_running (struct vty *vty) if (vty) { - vty_outln (vty, - "VNC is not configured. (There are no configured BGP VPN SAFI peers.)"); + vty_out (vty, + "VNC is not configured. (There are no configured BGP VPN SAFI peers.)\n"); } return 0; /* not running */ } @@ -4459,10 +4454,10 @@ rfapi_vty_show_nve_summary (struct vty *vty, show_nve_summary_t show_type) h->stat.count_registrations_failed); vty_out (vty, "%-8s %-8u", "Total:", h->stat.count_registrations); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } vty_out (vty, "%-24s ", "Prefixes registered:"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); rfapiCountAllItRoutes (&active_local_routes, &active_remote_routes, @@ -4474,16 +4469,16 @@ rfapi_vty_show_nve_summary (struct vty *vty, show_nve_summary_t show_type) { vty_out (vty, " %-20s ", "Locally:"); vty_out (vty, "%-8s %-8u ", "Active:", active_local_routes); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } vty_out (vty, " %-20s ", "Remotely:"); vty_out (vty, "%-8s %-8u", "Active:", active_remote_routes); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, " %-20s ", "In Holddown:"); vty_out (vty, "%-8s %-8u", "Active:", holddown_remote_routes); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, " %-20s ", "Imported:"); vty_out (vty, "%-8s %-8u", "Active:", imported_remote_routes); break; @@ -4502,12 +4497,12 @@ rfapi_vty_show_nve_summary (struct vty *vty, show_nve_summary_t show_type) default: break; } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return 0; notcfg: - vty_outln (vty, "VNC is not configured."); + vty_out (vty, "VNC is not configured.\n"); return CMD_WARNING; } @@ -4574,9 +4569,9 @@ rfapi_show_nves ( if (!printed) { /* print out a header */ - vty_outln (vty, - " " "Active Next Hops"); - vty_outln (vty, "%-15s %-15s %-5s %-5s %-6s %-6s %s", + vty_out (vty, + " Active Next Hops\n"); + vty_out (vty, "%-15s %-15s %-5s %-5s %-6s %-6s %s\n", "VN Address", "UN Address", "Regis", "Resps", "Reach", "Remove", "Age"); @@ -4584,7 +4579,7 @@ rfapi_show_nves ( ++printed; - vty_outln (vty, "%-15s %-15s %-5u %-5u %-6u %-6u %s", + vty_out (vty, "%-15s %-15s %-5u %-5u %-6u %-6u %s\n", vn_addr_buf, un_addr_buf, rfapiApCount (rfd), @@ -4595,13 +4590,13 @@ rfapi_show_nves ( } if (printed > 0 || vn_prefix || un_prefix) - vty_outln (vty, "Displayed %d out of %d active NVEs", + vty_out (vty, "Displayed %d out of %d active NVEs\n", printed, total); return 0; notcfg: - vty_outln (vty, "VNC is not configured."); + vty_out (vty, "VNC is not configured.\n"); return CMD_WARNING; } @@ -4616,7 +4611,7 @@ DEFUN (vnc_show_summary, if (!check_and_display_is_vnc_running (vty)) return CMD_SUCCESS; bgp_rfapi_show_summary (bgp_get_default (), vty); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); rfapi_vty_show_nve_summary (vty, SHOW_NVE_SUMMARY_ACTIVE_NVES); rfapi_vty_show_nve_summary (vty, SHOW_NVE_SUMMARY_QUERIES); rfapi_vty_show_nve_summary (vty, SHOW_NVE_SUMMARY_RESPONSES); @@ -4653,12 +4648,12 @@ DEFUN (vnc_show_nves_ptct, if (!str2prefix (argv[4]->arg, &pfx)) { - vty_outln (vty, "Malformed address \"%s\"", argv[4]->arg); + vty_out (vty, "Malformed address \"%s\"\n", argv[4]->arg); return CMD_WARNING; } if (pfx.family != AF_INET && pfx.family != AF_INET6) { - vty_outln (vty, "Invalid address \"%s\"", argv[4]->arg); + vty_out (vty, "Invalid address \"%s\"\n", argv[4]->arg); return CMD_WARNING; } @@ -4713,7 +4708,7 @@ rfapi_show_registrations ( } if (!printed) { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } @@ -4734,7 +4729,7 @@ DEFUN (vnc_show_registrations_pfx, { if (!str2prefix (argv[3]->arg, &p)) { - vty_outln (vty, "Invalid prefix: %s", argv[3]->arg); + vty_out (vty, "Invalid prefix: %s\n", argv[3]->arg); return CMD_SUCCESS; } else @@ -4774,7 +4769,7 @@ DEFUN (vnc_show_registrations_some_pfx, { if (!str2prefix (argv[4]->arg, &p)) { - vty_outln (vty, "Invalid prefix: %s", argv[4]->arg); + vty_out (vty, "Invalid prefix: %s\n", argv[4]->arg); return CMD_SUCCESS; } else @@ -4831,7 +4826,7 @@ DEFUN (vnc_show_responses_pfx, { if (!str2prefix (argv[3]->arg, &p)) { - vty_outln (vty, "Invalid prefix: %s", argv[3]->arg); + vty_out (vty, "Invalid prefix: %s\n", argv[3]->arg); return CMD_SUCCESS; } else @@ -4874,7 +4869,7 @@ DEFUN (vnc_show_responses_some_pfx, { if (!str2prefix (argv[4]->arg, &p)) { - vty_outln (vty, "Invalid prefix: %s", argv[4]->arg); + vty_out (vty, "Invalid prefix: %s\n", argv[4]->arg); return CMD_SUCCESS; } else @@ -4923,7 +4918,7 @@ DEFUN (show_vnc_queries_pfx, { if (!str2prefix (argv[3]->arg, &pfx)) { - vty_outln (vty, "Invalid prefix: %s", argv[3]->arg); + vty_out (vty, "Invalid prefix: %s\n", argv[3]->arg); return CMD_WARNING; } p = &pfx; @@ -4976,7 +4971,7 @@ DEFUN (vnc_clear_counters, return CMD_SUCCESS; notcfg: - vty_outln (vty, "VNC is not configured."); + vty_out (vty, "VNC is not configured.\n"); return CMD_WARNING; } @@ -5006,46 +5001,46 @@ vnc_add_vrf_prefix (struct vty *vty, bgp = bgp_get_default (); /* assume main instance for now */ if (!bgp) { - vty_outln (vty, "No BGP process is configured"); - return CMD_WARNING; + vty_out (vty, "No BGP process is configured\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!bgp->rfapi || !bgp->rfapi_cfg) { - vty_outln (vty, "VRF support not configured"); - return CMD_WARNING; + vty_out (vty, "VRF support not configured\n"); + return CMD_WARNING_CONFIG_FAILED; } rfg = bgp_rfapi_cfg_match_byname (bgp, arg_vrf, RFAPI_GROUP_CFG_VRF); /* arg checks */ if (!rfg) { - vty_outln (vty, "VRF \"%s\" appears not to be configured.", + vty_out (vty, "VRF \"%s\" appears not to be configured.\n", arg_vrf); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (!rfg->rt_export_list || !rfg->rfapi_import_table) { - vty_outln (vty, "VRF \"%s\" is missing RT import/export RT configuration.", + vty_out (vty, "VRF \"%s\" is missing RT import/export RT configuration.\n", arg_vrf); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (!rfg->rd.family && !arg_rd) { - vty_outln (vty, "VRF \"%s\" isn't configured with an RD, so RD must be provided.", + vty_out (vty, "VRF \"%s\" isn't configured with an RD, so RD must be provided.\n", arg_vrf); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (rfg->label > MPLS_LABEL_MAX && !arg_label) { - vty_outln (vty, "VRF \"%s\" isn't configured with a default labels, so a label must be provided.", + vty_out (vty, "VRF \"%s\" isn't configured with a default labels, so a label must be provided.\n", arg_vrf); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (!str2prefix (arg_prefix, &pfx)) { - vty_outln (vty, "Malformed prefix \"%s\"", + vty_out (vty, "Malformed prefix \"%s\"\n", arg_prefix); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } rfapiQprefix2Rprefix (&pfx, &rpfx); memset (optary, 0, sizeof (optary)); @@ -5057,9 +5052,9 @@ vnc_add_vrf_prefix (struct vty *vty, opt->type = RFAPI_VN_OPTION_TYPE_INTERNAL_RD; if (!str2prefix_rd (arg_rd, &opt->v.internal_rd)) { - vty_outln (vty, "Malformed RD \"%s\"", + vty_out (vty, "Malformed RD \"%s\"\n", arg_rd); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } if (rfg->label <= MPLS_LABEL_MAX || arg_label) @@ -5085,9 +5080,9 @@ vnc_add_vrf_prefix (struct vty *vty, pref = strtoul (arg_pref, &endptr, 10); if (*endptr != '\0') { - vty_outln (vty, "%% Invalid local-preference value \"%s\"", + vty_out (vty, "%% Invalid local-preference value \"%s\"\n", arg_pref); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } rpfx.cost = 255 - (pref & 255) ; @@ -5150,8 +5145,8 @@ vnc_add_vrf_prefix (struct vty *vty, } vnc_zlog_debug_verbose ("%s: rfapi_register failed", __func__); - vty_outln (vty, "Add failed."); - return CMD_WARNING; + vty_out (vty, "Add failed.\n"); + return CMD_WARNING_CONFIG_FAILED; } DEFUN (add_vrf_prefix_rd_label_pref, @@ -5260,19 +5255,19 @@ vnc_clear_vrf (struct vty *vty, bgp = bgp_get_default (); /* assume main instance for now */ if (!bgp) { - vty_outln (vty, "No BGP process is configured"); + vty_out (vty, "No BGP process is configured\n"); return CMD_WARNING; } if (!bgp->rfapi || !bgp->rfapi_cfg) { - vty_outln (vty, "VRF support not configured"); + vty_out (vty, "VRF support not configured\n"); return CMD_WARNING; } rfg = bgp_rfapi_cfg_match_byname (bgp, arg_vrf, RFAPI_GROUP_CFG_VRF); /* arg checks */ if (!rfg) { - vty_outln (vty, "VRF \"%s\" appears not to be configured.", + vty_out (vty, "VRF \"%s\" appears not to be configured.\n", arg_vrf); return CMD_WARNING; } @@ -5284,7 +5279,7 @@ vnc_clear_vrf (struct vty *vty, start_count = rfapi_cfg_group_it_count(rfg); clear_vnc_prefix (&cda); clear_vnc_vrf_closer (rfg); - vty_outln (vty, "Cleared %u out of %d prefixes.", + vty_out (vty, "Cleared %u out of %d prefixes.\n", cda.pfx_count, start_count); return CMD_SUCCESS; } diff --git a/bgpd/rfapi/vnc_debug.c b/bgpd/rfapi/vnc_debug.c index e43b152e5..1f9e1b10f 100644 --- a/bgpd/rfapi/vnc_debug.c +++ b/bgpd/rfapi/vnc_debug.c @@ -79,14 +79,14 @@ DEFUN (debug_bgp_vnc, else { term_vnc_debug |= vncdebug[i].bit; - vty_outln (vty, "BGP vnc %s debugging is on", + vty_out (vty, "BGP vnc %s debugging is on\n", vncdebug[i].name); } return CMD_SUCCESS; } } - vty_outln (vty, "Unknown debug flag: %s", argv[3]->arg); - return CMD_WARNING; + vty_out (vty, "Unknown debug flag: %s\n", argv[3]->arg); + return CMD_WARNING_CONFIG_FAILED; } DEFUN (no_debug_bgp_vnc, @@ -118,14 +118,14 @@ DEFUN (no_debug_bgp_vnc, else { term_vnc_debug &= ~vncdebug[i].bit; - vty_outln (vty, "BGP vnc %s debugging is off", + vty_out (vty, "BGP vnc %s debugging is off\n", vncdebug[i].name); } return CMD_SUCCESS; } } - vty_outln (vty, "Unknown debug flag: %s", argv[3]->arg); - return CMD_WARNING; + vty_out (vty, "Unknown debug flag: %s\n", argv[3]->arg); + return CMD_WARNING_CONFIG_FAILED; } @@ -144,7 +144,7 @@ DEFUN (no_debug_bgp_vnc_all, VNC_STR) { term_vnc_debug = 0; - vty_outln (vty, "All possible VNC debugging has been turned off"); + vty_out (vty, "All possible VNC debugging has been turned off\n"); return CMD_SUCCESS; } @@ -163,17 +163,17 @@ DEFUN (show_debugging_bgp_vnc, { size_t i; - vty_outln (vty, "BGP VNC debugging status:"); + vty_out (vty, "BGP VNC debugging status:\n"); for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) { if (term_vnc_debug & vncdebug[i].bit) { - vty_outln (vty, " BGP VNC %s debugging is on", + vty_out (vty, " BGP VNC %s debugging is on\n", vncdebug[i].name); } } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -187,7 +187,7 @@ bgp_vnc_config_write_debug (struct vty *vty) { if (conf_vnc_debug & vncdebug[i].bit) { - vty_outln (vty, "debug bgp vnc %s", vncdebug[i].name); + vty_out (vty, "debug bgp vnc %s\n", vncdebug[i].name); write++; } } diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index bca95e47c..342dc6a19 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -74,7 +74,6 @@ encap_attr_export_ce ( */ memset (new, 0, sizeof (struct attr)); bgp_attr_dup (new, orig); - bgp_attr_extra_get (new); /* * Set nexthop @@ -83,17 +82,13 @@ encap_attr_export_ce ( { case AF_INET: new->nexthop = use_nexthop->u.prefix4; - new->extra->mp_nexthop_len = 4; /* bytes */ + new->mp_nexthop_len = 4; /* bytes */ new->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); break; case AF_INET6: - if (!new->extra) - { - new->extra = XCALLOC (MTYPE_ATTR_EXTRA, sizeof (struct attr_extra)); - } - new->extra->mp_nexthop_global = use_nexthop->u.prefix6; - new->extra->mp_nexthop_len = 16; /* bytes */ + new->mp_nexthop_global = use_nexthop->u.prefix6; + new->mp_nexthop_len = 16; /* bytes */ break; default: @@ -133,7 +128,6 @@ encap_attr_export_ce ( * * Caller should, after using the attr, call: * - bgp_attr_flush() to free non-interned parts - * - call bgp_attr_extra_free() to free extra */ } @@ -144,8 +138,8 @@ getce (struct bgp *bgp, struct attr *attr, struct prefix *pfx_ce) int i; uint16_t localadmin = bgp->rfapi_cfg->resolve_nve_roo_local_admin; - for (ecp = attr->extra->ecommunity->val, i = 0; - i < attr->extra->ecommunity->size; ++i, ecp += ECOMMUNITY_SIZE) + for (ecp = attr->ecommunity->val, i = 0; + i < attr->ecommunity->size; ++i, ecp += ECOMMUNITY_SIZE) { if (VNC_DEBUG(EXPORT_BGP_GETCE)) @@ -309,14 +303,12 @@ vnc_direct_bgp_add_route_ce ( if (ret == RMAP_DENYMATCH) { bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); return; } } iattr = bgp_attr_intern (&hattr); bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); /* * Rule: disallow route-map alteration of next-hop, because it @@ -563,14 +555,14 @@ vnc_route_origin_ecom (struct route_node *rn) struct ecommunity_val roec; - switch (BGP_MP_NEXTHOP_FAMILY (bi->attr->extra->mp_nexthop_len)) + switch (BGP_MP_NEXTHOP_FAMILY (bi->attr->mp_nexthop_len)) { case AF_INET: memset (&roec, 0, sizeof (roec)); roec.val[0] = 0x01; roec.val[1] = 0x03; memcpy (roec.val + 2, - &bi->attr->extra->mp_nexthop_global_in.s_addr, 4); + &bi->attr->mp_nexthop_global_in.s_addr, 4); roec.val[6] = 0; roec.val[7] = 0; ecommunity_add_val (new, &roec); @@ -642,16 +634,16 @@ encap_attr_export ( { use_nexthop = &orig_nexthop; orig_nexthop.family = - BGP_MP_NEXTHOP_FAMILY (orig->extra->mp_nexthop_len); + BGP_MP_NEXTHOP_FAMILY (orig->mp_nexthop_len); if (orig_nexthop.family == AF_INET) { orig_nexthop.prefixlen = 32; - orig_nexthop.u.prefix4 = orig->extra->mp_nexthop_global_in; + orig_nexthop.u.prefix4 = orig->mp_nexthop_global_in; } else if (orig_nexthop.family == AF_INET6) { orig_nexthop.prefixlen = 128; - orig_nexthop.u.prefix6 = orig->extra->mp_nexthop_global; + orig_nexthop.u.prefix6 = orig->mp_nexthop_global; } else { @@ -673,17 +665,13 @@ encap_attr_export ( { case AF_INET: new->nexthop = use_nexthop->u.prefix4; - new->extra->mp_nexthop_len = 4; /* bytes */ + new->mp_nexthop_len = 4; /* bytes */ new->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); break; case AF_INET6: - if (!new->extra) - { - new->extra = XCALLOC (MTYPE_ATTR_EXTRA, sizeof (struct attr_extra)); - } - new->extra->mp_nexthop_global = use_nexthop->u.prefix6; - new->extra->mp_nexthop_len = 16; /* bytes */ + new->mp_nexthop_global = use_nexthop->u.prefix6; + new->mp_nexthop_len = 16; /* bytes */ break; default: @@ -691,7 +679,6 @@ encap_attr_export ( break; } - bgp_attr_extra_get (new); if (rn) { ecom_ro = vnc_route_origin_ecom (rn); @@ -701,17 +688,14 @@ encap_attr_export ( /* TBD test/assert for IPv6 */ ecom_ro = vnc_route_origin_ecom_single (&use_nexthop->u.prefix4); } - if (new->extra->ecommunity) + if (new->ecommunity) { if (ecom_ro) - { - new->extra->ecommunity = - ecommunity_merge (ecom_ro, new->extra->ecommunity); - } + new->ecommunity = ecommunity_merge (ecom_ro, new->ecommunity); } else { - new->extra->ecommunity = ecom_ro; + new->ecommunity = ecom_ro; } if (ecom_ro) { @@ -750,7 +734,6 @@ encap_attr_export ( * * Caller should, after using the attr, call: * - bgp_attr_flush() to free non-interned parts - * - call bgp_attr_extra_free() to free extra */ return 0; @@ -887,7 +870,6 @@ vnc_direct_bgp_add_prefix ( if (ret == RMAP_DENYMATCH) { bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); vnc_zlog_debug_verbose ("%s: route map says DENY, so not calling bgp_update", __func__); @@ -903,7 +885,6 @@ vnc_direct_bgp_add_prefix ( iattr = bgp_attr_intern (&hattr); bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); bgp_update (irfd->peer, &rn->p, /* prefix */ 0, /* addpath_id */ @@ -917,7 +898,6 @@ vnc_direct_bgp_add_prefix ( } aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); } /* @@ -1134,7 +1114,6 @@ vnc_direct_bgp_add_nve (struct bgp *bgp, struct rfapi_descriptor *rfd) if (ret == RMAP_DENYMATCH) { bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); continue; } @@ -1142,7 +1121,6 @@ vnc_direct_bgp_add_nve (struct bgp *bgp, struct rfapi_descriptor *rfd) iattr = bgp_attr_intern (&hattr); bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); bgp_update (irfd->peer, &rn->p, /* prefix */ 0, /* addpath_id */ @@ -1157,7 +1135,6 @@ vnc_direct_bgp_add_nve (struct bgp *bgp, struct rfapi_descriptor *rfd) } aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); } } } @@ -1361,7 +1338,6 @@ vnc_direct_bgp_add_group_afi ( if (ret == RMAP_DENYMATCH) { bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); continue; } @@ -1369,7 +1345,6 @@ vnc_direct_bgp_add_group_afi ( iattr = bgp_attr_intern (&hattr); bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); bgp_update (irfd->peer, &rn->p, /* prefix */ 0, /* addpath_id */ @@ -1384,7 +1359,6 @@ vnc_direct_bgp_add_group_afi ( } aspath_unintern (&attr.aspath); - bgp_attr_extra_free (&attr); } @@ -1744,14 +1718,12 @@ vnc_direct_bgp_rh_add_route ( if (ret == RMAP_DENYMATCH) { bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); return; } } iattr = bgp_attr_intern (&hattr); bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); /* * record route information that we will need to expire @@ -1983,7 +1955,6 @@ vnc_direct_bgp_rh_vpn_enable (struct bgp *bgp, afi_t afi) if (ret == RMAP_DENYMATCH) { bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); vnc_zlog_debug_verbose ("%s: route map says DENY", __func__); continue; } @@ -1991,7 +1962,6 @@ vnc_direct_bgp_rh_vpn_enable (struct bgp *bgp, afi_t afi) iattr = bgp_attr_intern (&hattr); bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); /* * record route information that we will need to expire diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index 47203cd23..1daf02a6b 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -393,7 +393,6 @@ process_unicast_route ( if (ret == RMAP_DENYMATCH) { bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); vnc_zlog_debug_verbose ("%s: route map \"%s\" says DENY, returning", __func__, rmap->name); return -1; @@ -406,8 +405,8 @@ process_unicast_route ( */ rfapiUnicastNexthop2Prefix (afi, &hattr, unicast_nexthop); - if (hattr.extra && hattr.extra->ecommunity) - *ecom = ecommunity_dup (hattr.extra->ecommunity); + if (hattr.ecommunity) + *ecom = ecommunity_dup (hattr.ecommunity); else *ecom = ecommunity_new (); @@ -415,7 +414,6 @@ process_unicast_route ( * Done with hattr, clean up */ bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); /* * Add EC that carries original NH of iBGP route (2 bytes = magic @@ -510,18 +508,18 @@ vnc_import_bgp_add_route_mode_resolve_nve_one_bi ( plifetime = &lifetime; } - if (bi->attr && bi->attr->extra) + if (bi->attr) { - encaptlvs = bi->attr->extra->vnc_subtlvs; - if (bi->attr->extra->encap_tunneltype != BGP_ENCAP_TYPE_RESERVED && - bi->attr->extra->encap_tunneltype != BGP_ENCAP_TYPE_MPLS) + encaptlvs = bi->attr->vnc_subtlvs; + if (bi->attr->encap_tunneltype != BGP_ENCAP_TYPE_RESERVED && + bi->attr->encap_tunneltype != BGP_ENCAP_TYPE_MPLS) { if (opt != NULL) opt->next = &optary[cur_opt]; opt = &optary[cur_opt++]; memset (opt, 0, sizeof (struct rfapi_un_option)); opt->type = RFAPI_UN_OPTION_TYPE_TUNNELTYPE; - opt->v.tunnel.type = bi->attr->extra->encap_tunneltype; + opt->v.tunnel.type = bi->attr->encap_tunneltype; /* TBD parse bi->attr->extra->encap_subtlvs */ } } @@ -532,8 +530,8 @@ vnc_import_bgp_add_route_mode_resolve_nve_one_bi ( struct ecommunity *new_ecom = ecommunity_dup (ecom); - if (bi->attr && bi->attr->extra && bi->attr->extra->ecommunity) - ecommunity_merge (new_ecom, bi->attr->extra->ecommunity); + if (bi->attr && bi->attr->ecommunity) + ecommunity_merge (new_ecom, bi->attr->ecommunity); if (bi->extra) label = decode_label (&bi->extra->label); @@ -891,7 +889,6 @@ vnc_import_bgp_add_route_mode_plain (struct bgp *bgp, if (ret == RMAP_DENYMATCH) { bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); vnc_zlog_debug_verbose ("%s: route map \"%s\" says DENY, returning", __func__, rmap->name); return; @@ -900,7 +897,6 @@ vnc_import_bgp_add_route_mode_plain (struct bgp *bgp, iattr = bgp_attr_intern (&hattr); bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); /* Now iattr is an allocated interned attr */ @@ -925,8 +921,8 @@ vnc_import_bgp_add_route_mode_plain (struct bgp *bgp, memset (&prd, 0, sizeof (prd)); rfapi_set_autord_from_vn (&prd, &vnaddr); - if (iattr && iattr->extra && iattr->extra->ecommunity) - ecom = ecommunity_dup (iattr->extra->ecommunity); + if (iattr && iattr->ecommunity) + ecom = ecommunity_dup (iattr->ecommunity); } @@ -1103,7 +1099,6 @@ vnc_import_bgp_add_route_mode_nvegroup (struct bgp *bgp, if (ret == RMAP_DENYMATCH) { bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); vnc_zlog_debug_verbose ("%s: route map \"%s\" says DENY, returning", __func__, rmap->name); return; @@ -1112,7 +1107,6 @@ vnc_import_bgp_add_route_mode_nvegroup (struct bgp *bgp, iattr = bgp_attr_intern (&hattr); bgp_attr_flush (&hattr); - bgp_attr_extra_free (&hattr); /* Now iattr is an allocated interned attr */ @@ -1139,8 +1133,8 @@ vnc_import_bgp_add_route_mode_nvegroup (struct bgp *bgp, else ecom = ecommunity_new (); - if (iattr && iattr->extra && iattr->extra->ecommunity) - ecom = ecommunity_merge (ecom, iattr->extra->ecommunity); + if (iattr && iattr->ecommunity) + ecom = ecommunity_merge (ecom, iattr->ecommunity); } local_pref = calc_local_pref (iattr, peer); @@ -1942,7 +1936,6 @@ vnc_import_bgp_exterior_add_route_it ( ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); - bgp_attr_extra_free (&new_attr); } if (have_usable_route) @@ -2273,7 +2266,6 @@ vnc_import_bgp_exterior_add_route_interior ( ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); - bgp_attr_extra_free (&new_attr); } vnc_zlog_debug_verbose ("%s: finished constructing exteriors based on existing monitors", @@ -2412,7 +2404,6 @@ vnc_import_bgp_exterior_add_route_interior ( ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); - bgp_attr_extra_free (&new_attr); } } @@ -2536,7 +2527,6 @@ vnc_import_bgp_exterior_add_route_interior ( ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); - bgp_attr_extra_free (&new_attr); } } if (list_adopted) @@ -2740,7 +2730,6 @@ vnc_import_bgp_exterior_del_route_interior ( ZEBRA_ROUTE_BGP_DIRECT_EXT, BGP_ROUTE_REDISTRIBUTE, &label); - bgp_attr_extra_free (&new_attr); } } diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index 6a8b4a83f..de1249ff2 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -1036,7 +1036,7 @@ vnc_redistribute_set (struct bgp *bgp, afi_t afi, int type) { if (!bgp->rfapi_cfg) { - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Set flag to BGP instance. */ @@ -1046,7 +1046,7 @@ vnc_redistribute_set (struct bgp *bgp, afi_t afi, int type) /* Return if already redistribute flag is set. */ if (zclient_vnc->redist[afi][type]) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; vrf_bitmap_set (zclient_vnc->redist[afi][type], VRF_DEFAULT); @@ -1054,7 +1054,7 @@ vnc_redistribute_set (struct bgp *bgp, afi_t afi, int type) /* Return if zebra connection is not established. */ if (zclient_vnc->sock < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (BGP_DEBUG (zebra, ZEBRA)) vnc_zlog_debug_verbose ("Zebra send: redistribute add %s", zebra_route_string (type)); @@ -1074,7 +1074,7 @@ vnc_redistribute_unset (struct bgp *bgp, afi_t afi, int type) if (!bgp->rfapi_cfg) { vnc_zlog_debug_verbose ("%s: return (no rfapi_cfg)", __func__); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Unset flag from BGP instance. */ @@ -1082,7 +1082,7 @@ vnc_redistribute_unset (struct bgp *bgp, afi_t afi, int type) /* Return if zebra connection is disabled. */ if (!zclient_vnc->redist[afi][type]) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; zclient_vnc->redist[afi][type] = 0; if (bgp->rfapi_cfg->redist[AFI_IP][type] == 0 diff --git a/bgpd/rfp-example/librfp/rfp_example.c b/bgpd/rfp-example/librfp/rfp_example.c index a0ba82908..451be7770 100644 --- a/bgpd/rfp-example/librfp/rfp_example.c +++ b/bgpd/rfp-example/librfp/rfp_example.c @@ -197,7 +197,7 @@ rfp_cfg_write_cb (struct vty *vty, void *rfp_start_val) if (rfi->config_var != 0) { vty_out (vty, " rfp example-config-value %u", rfi->config_var); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write++; } diff --git a/buildtest.sh b/buildtest.sh index cbe6962a4..b4b02d10b 100755 --- a/buildtest.sh +++ b/buildtest.sh @@ -1,7 +1,7 @@ #!/bin/bash # written 2012-2013 by David Lamparter, placed in Public Domain. # -# builds some git commit of Quagga in some different configurations +# builds some git commit of FRR in some different configurations # usage: buildtest.sh [commit [configurations...]] basecfg="--prefix=/usr --enable-user=frr --enable-group=frr --enable-vty-group=frr --enable-configfile-mask=0660 --enable-logfile-mask=0640 --enable-vtysh --sysconfdir=/etc/frr --enable-exampledir=/etc/frr/samples --localstatedir=/var/run/frr --libdir=/usr/lib64/frr --enable-rtadv --disable-static --enable-isisd --enable-multipath=0 --enable-pimd --enable-werror" diff --git a/configure.ac b/configure.ac index 03951503c..cbda2fc84 100755 --- a/configure.ac +++ b/configure.ac @@ -127,7 +127,7 @@ dnl autoconf 2.59 appears not to support AC_PROG_SED dnl AC_PROG_SED AC_CHECK_PROG([SED],[sed],[sed],[/bin/false]) -dnl try and enable CFLAGS that are useful for Quagga +dnl try and enable CFLAGS that are useful for FRR dnl - specifically, options to control warnings AC_USE_SYSTEM_EXTENSIONS @@ -249,7 +249,7 @@ AX_PTHREAD([ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" ], [ - AC_MSG_FAILURE([This Quagga version needs pthreads]) + AC_MSG_FAILURE([This FRR version needs pthreads]) ]) dnl -------------- @@ -283,7 +283,7 @@ AC_ARG_WITH(vtysh_pager, AS_HELP_STRING([--with-vtysh-pager=PAGER], [control what pager is compiled in as default]), VTYSH_PAGER=$withval, VTYSH_PAGER="more") AC_ARG_ENABLE(vtysh, - AS_HELP_STRING([--disable-vtysh], [do not build integrated vty shell for Quagga])) + AS_HELP_STRING([--disable-vtysh], [do not build integrated vty shell for FRR])) AC_ARG_ENABLE(doc, AS_HELP_STRING([--disable-doc], [do not build docs])) AC_ARG_ENABLE(zebra, @@ -939,7 +939,7 @@ AM_CONDITIONAL(VTYSH, test "x$VTYSH" = "xvtysh") dnl ---------- dnl PAM module dnl -dnl Quagga detects the PAM library it is built against by checking for a +dnl FRR detects the PAM library it is built against by checking for a dnl functional pam_misc.h (Linux-PAM) or openpam.h (OpenPAM) header. pam_misc.h dnl is known to #include pam_appl.h, the standard header of a PAM library, and dnl openpam.h doesn't do that, although depends on the header too. Hence a @@ -1759,10 +1759,10 @@ dnl -------------------------------------- AM_PROG_LEX AC_MSG_CHECKING(version of flex) -quagga_ac_flex_version="$(eval $LEX -V | grep flex | head -n 1)" -quagga_ac_flex_version="${quagga_ac_flex_version##* }" -AC_MSG_RESULT([$quagga_ac_flex_version]) -AX_COMPARE_VERSION([$quagga_ac_flex_version], [lt], [2.5.20], [ +frr_ac_flex_version="$(eval $LEX -V | grep flex | head -n 1)" +frr_ac_flex_version="${frr_ac_flex_version##* }" +AC_MSG_RESULT([$frr_ac_flex_version]) +AX_COMPARE_VERSION([$frr_ac_flex_version], [lt], [2.5.20], [ LEX="$SHELL $missing_dir/missing flex" if test -f "${srcdir}/lib/command_lex.c" -a -f "${srcdir}/lib/command_lex.h"; then AC_MSG_WARN([using pregenerated flex output files]) @@ -1776,38 +1776,38 @@ AX_COMPARE_VERSION([$quagga_ac_flex_version], [lt], [2.5.20], [ AC_PROG_YACC dnl thanks GNU bison for this b*llshit... AC_MSG_CHECKING(version of bison) -quagga_ac_bison_version="$(eval $YACC -V | grep bison | head -n 1)" -quagga_ac_bison_version="${quagga_ac_bison_version##* }" -quagga_ac_bison_missing="false" -case "x${quagga_ac_bison_version}" in +frr_ac_bison_version="$(eval $YACC -V | grep bison | head -n 1)" +frr_ac_bison_version="${frr_ac_bison_version##* }" +frr_ac_bison_missing="false" +case "x${frr_ac_bison_version}" in x2.7*) BISON_OPENBRACE='"' BISON_CLOSEBRACE='"' BISON_VERBOSE='' - AC_MSG_RESULT([$quagga_ac_bison_version - 2.7 or older]) + AC_MSG_RESULT([$frr_ac_bison_version - 2.7 or older]) ;; x2.*|x1.*) - AC_MSG_RESULT([$quagga_ac_bison_version]) + AC_MSG_RESULT([$frr_ac_bison_version]) AC_MSG_WARN([installed bison is too old. Please install GNU bison 2.7.x or newer.]) - quagga_ac_bison_missing="true" + frr_ac_bison_missing="true" ;; x) AC_MSG_RESULT([none]) AC_MSG_WARN([could not determine bison version. Please install GNU bison 2.7.x or newer.]) - quagga_ac_bison_missing="true" + frr_ac_bison_missing="true" ;; *) BISON_OPENBRACE='{' BISON_CLOSEBRACE='}' BISON_VERBOSE='-Dparse.error=verbose' - AC_MSG_RESULT([$quagga_ac_bison_version - 3.0 or newer]) + AC_MSG_RESULT([$frr_ac_bison_version - 3.0 or newer]) ;; esac AC_SUBST(BISON_OPENBRACE) AC_SUBST(BISON_CLOSEBRACE) AC_SUBST(BISON_VERBOSE) -if $quagga_ac_bison_missing; then +if $frr_ac_bison_missing; then YACC="$SHELL $missing_dir/missing bison -y" if test -f "${srcdir}/lib/command_parse.c" -a -f "${srcdir}/lib/command_parse.h"; then AC_MSG_WARN([using pregenerated bison output files]) @@ -1969,10 +1969,11 @@ AC_CACHE_VAL(ac_cv_htonl_works, ) AC_MSG_RESULT($ac_cv_htonl_works) -AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile +AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile ripngd/Makefile bgpd/Makefile ospfd/Makefile watchfrr/Makefile ospf6d/Makefile ldpd/Makefile isisd/Makefile vtysh/Makefile doc/Makefile ospfclient/Makefile tests/Makefile m4/Makefile + bgpd/rfp-example/rfptest/Makefile bgpd/rfp-example/librfp/Makefile babeld/Makefile pimd/Makefile eigrpd/Makefile @@ -1982,7 +1983,7 @@ AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile pkgsrc/Makefile python/Makefile fpm/Makefile - redhat/frr.spec + redhat/frr.spec snapcraft/Makefile snapcraft/snapcraft.yaml lib/version.h @@ -2007,19 +2008,12 @@ AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile pkgsrc/ripd.sh pkgsrc/ripngd.sh pkgsrc/zebra.sh pkgsrc/eigrpd.sh]) -if test "${enable_bgp_vnc}" != "no"; then - if test "${with_rfp_path}" = "bgpd/rfp-example" ; then - AC_CONFIG_FILES([bgpd/rfp-example/rfptest/Makefile bgpd/rfp-example/librfp/Makefile]) - else - AC_CONFIG_FILES([${with_rfp_path}/rfptest/Makefile ${with_rfp_path}/librfp/Makefile]) - fi -fi AC_CONFIG_FILES([solaris/Makefile]) AC_CONFIG_FILES([vtysh/extract.pl],[chmod +x vtysh/extract.pl]) -## Hack, but working solution to avoid rebuilding of quagga.info. +## Hack, but working solution to avoid rebuilding of frr.info. ## It's already in CVS until texinfo 4.7 is more common. AC_OUTPUT diff --git a/doc/Building_FRR_on_CentOS6.md b/doc/Building_FRR_on_CentOS6.md index d88f8144a..45477a6bb 100644 --- a/doc/Building_FRR_on_CentOS6.md +++ b/doc/Building_FRR_on_CentOS6.md @@ -1,6 +1,10 @@ Building FRR on CentOS 6 from Git Source ======================================== +(As an alternative to this installation, you may prefer to create a FRR +rpm package yourself and install that package instead. See instructions +in redhat/README.rpm_build.md on how to build a rpm package) + Instructions are tested with `CentOS 6.8` on `x86_64` platform CentOS 6 restrictions: @@ -16,13 +20,15 @@ Install required packages Add packages: - sudo yum install git autoconf automake libtool make gawk readline-devel \ - texinfo net-snmp-devel groff pkgconfig json-c-devel pam-devel \ - flex c-ares-devel epel-release rpm-build libcap-devel texi2html + sudo yum install git autoconf automake libtool make gawk \ + readline-devel texinfo net-snmp-devel groff pkgconfig \ + json-c-devel pam-devel flex epel-release perl-XML-LibXML \ + c-ares-devel Install newer version of bison (CentOS 6 package source is too old) from CentOS 7 + sudo yum install rpm-build curl -O http://vault.centos.org/7.0.1406/os/Source/SPackages/bison-2.7-4.el7.src.rpm rpmbuild --rebuild ./bison-2.7-4.el7.src.rpm sudo yum install ./rpmbuild/RPMS/x86_64/bison-2.7-4.el6.x86_64.rpm @@ -46,13 +52,14 @@ Install newer version of autoconf and automake (Package versions are too old) sudo make install cd .. -Install `Python 2.7` in parallel to default 2.6 +Install `Python 2.7` in parallel to default 2.6. Make sure you've install EPEL (`epel-release` as above). Then install current -`python2.7` and `pytest` +`python27`, `python27-devel` and `pytest` - rpm -ivh https://centos6.iuscommunity.org/ius-release.rpm - yum install python27 python27-devel python27-pip - pip2.7 install pytest + sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm + sudo rpm -ivh https://centos6.iuscommunity.org/ius-release.rpm + sudo yum install python27 python27-pip python27-devel + sudo pip2.7 install pytest Please note that `CentOS 6` needs to keep python pointing to version 2.6 for `yum` to keep working, so don't create a symlink for python2.7 to python @@ -74,17 +81,17 @@ any packages** (You may prefer different options on configure statement. These are just an example.) -You may want to pay special attention to `/usr/lib64` paths and change -them if you are not building on a x86_64 architecture - git clone https://github.com/frrouting/frr.git frr cd frr ./bootstrap.sh ./configure \ + --bindir=/usr/bin \ + --sbindir=/usr/lib/frr \ --sysconfdir=/etc/frr \ - --libdir=/usr/lib64/frr \ - --libexecdir=/usr/lib64/frr \ + --libdir=/usr/lib/frr \ + --libexecdir=/usr/lib/frr \ --localstatedir=/var/run/frr \ + --with-moduledir=/usr/lib/frr/modules \ --disable-pimd \ --enable-snmp=agentx \ --enable-multipath=64 \ @@ -97,9 +104,13 @@ them if you are not building on a x86_64 architecture --disable-exampledir \ --enable-watchfrr \ --enable-tcp-zebra \ + --disable-ldpd \ --enable-fpm \ + --enable-nhrpd \ + --enable-eigrpd \ + --enable-babeld \ --with-pkg-git-version \ - --with-pkg-extra-version=-MyOwnFRRVersion + --with-pkg-extra-version=-MyOwnFRRVersion make make check PYTHON=/usr/bin/python2.7 sudo make install @@ -114,11 +125,23 @@ them if you are not building on a x86_64 architecture sudo touch /etc/frr/isisd.conf sudo touch /etc/frr/ripd.conf sudo touch /etc/frr/ripngd.conf + sudo touch /etc/frr/nhrpd.conf + sudo touch /etc/frr/eigrpd.conf + sudo touch /etc/frr/babeld.conf sudo chown -R frr:frr /etc/frr/ sudo touch /etc/frr/vtysh.conf sudo chown frr:frrvt /etc/frr/vtysh.conf sudo chmod 640 /etc/frr/*.conf +### Install daemon config file + sudo install -p -m 644 redhat/daemons /etc/frr/ + sudo chown frr:frr /etc/frr/daemons + +### Edit /etc/frr/daemons as needed to select the required daemons + +Look for the section with `watchfrr_enable=...` and `zebra=...` etc. +Enable the daemons as required by changing the value to `yes` + ### Enable IP & IPv6 forwarding Edit `/etc/sysctl.conf` and set the following values (ignore the other @@ -131,28 +154,16 @@ settings) # Controls source route verification net.ipv4.conf.default.rp_filter = 0 -**Reboot** or use `sysctl` to apply the same config to the running system +Load the modifed sysctl's on the system: + + sudo sysctl -p /etc/sysctl.d/90-routing-sysctl.conf ### Add init.d startup files - sudo cp redhat/bgpd.init /etc/init.d/bgpd - sudo cp redhat/isisd.init /etc/init.d/isisd - sudo cp redhat/ospfd.init /etc/init.d/ospfd - sudo cp redhat/ospf6d.init /etc/init.d/ospf6d - sudo cp redhat/ripngd.init /etc/init.d/ripngd - sudo cp redhat/ripd.init /etc/init.d/ripd - sudo cp redhat/zebra.init /etc/init.d/zebra - sudo chkconfig --add zebra - sudo chkconfig --add ripd - sudo chkconfig --add ripngd - sudo chkconfig --add ospf6d - sudo chkconfig --add ospfd - sudo chkconfig --add bgpd - sudo chkconfig --add isisd - -### Enable required daemons at startup -Only enable zebra and the daemons which are needed for your setup - - sudo chkconfig zebra on - sudo chkconfig ospfd on - sudo chkconfig bgpd on - [...] etc (as needed) + sudo install -p -m 755 redhat/frr.init /etc/init.d/frr + sudo chkconfig --add frr + +### Enable frr daemon at startup + sudo chkconfig frr on + +### Start FRR manually (or reboot) + sudo /etc/init.d/frr start diff --git a/doc/Building_FRR_on_CentOS7.md b/doc/Building_FRR_on_CentOS7.md index 0ab5c0ff5..932459167 100644 --- a/doc/Building_FRR_on_CentOS7.md +++ b/doc/Building_FRR_on_CentOS7.md @@ -1,6 +1,10 @@ Building FRR on CentOS 7 from Git Source ======================================== +(As an alternative to this installation, you may prefer to create a FRR +rpm package yourself and install that package instead. See instructions +in redhat/README.rpm_build.md on how to build a rpm package) + CentOS 7 restrictions: ---------------------- @@ -13,13 +17,10 @@ Install required packages Add packages: - sudo yum install git autoconf automake libtool make gawk readline-devel \ - texinfo net-snmp-devel groff pkgconfig json-c-devel pam-devel \ - bison flex pytest c-ares-devel python-devel rpm-build - -To build from git (in difference to building from distribution tar.gz as created by `make dist`), the python development libraries are needed. (Make sure you've installed EPEL libraries as shown above for this to work) - - yum install python34-devel + sudo yum install git autoconf automake libtool make gawk \ + readline-devel texinfo net-snmp-devel groff pkgconfig \ + json-c-devel pam-devel bison flex pytest c-ares-devel \ + perl-XML-LibXML python-devel Get FRR, compile it and install it (from Git) --------------------------------------------- @@ -38,17 +39,18 @@ any packages** (You may prefer different options on configure statement. These are just an example.) -You may want to pay special attention to `/usr/lib64` paths and change -them if you are not building on a x86_64 architecture - git clone https://github.com/frrouting/frr.git frr cd frr ./bootstrap.sh ./configure \ + --bindir=/usr/bin \ + --sbindir=/usr/lib/frr \ --sysconfdir=/etc/frr \ - --libdir=/usr/lib64/frr \ - --libexecdir=/usr/lib64/frr \ + --libdir=/usr/lib/frr \ + --libexecdir=/usr/lib/frr \ --localstatedir=/var/run/frr \ + --with-moduledir=/usr/lib/frr/modules \ + --enable-pimd \ --enable-snmp=agentx \ --enable-multipath=64 \ --enable-ospfclient=yes \ @@ -60,9 +62,13 @@ them if you are not building on a x86_64 architecture --disable-exampledir \ --enable-watchfrr \ --enable-tcp-zebra \ + --disable-ldpd \ --enable-fpm \ + --enable-nhrpd \ + --enable-eigrpd \ + --enable-babeld \ --with-pkg-git-version \ - --with-pkg-extra-version=-MyOwnFRRVersion + --with-pkg-extra-version=-MyOwnFRRVersion make make check sudo make install @@ -78,11 +84,23 @@ them if you are not building on a x86_64 architecture sudo touch /etc/frr/ripd.conf sudo touch /etc/frr/ripngd.conf sudo touch /etc/frr/pimd.conf + sudo touch /etc/frr/nhrpd.conf + sudo touch /etc/frr/eigrpd.conf + sudo touch /etc/frr/babeld.conf sudo chown -R frr:frr /etc/frr/ sudo touch /etc/frr/vtysh.conf sudo chown frr:frrvt /etc/frr/vtysh.conf sudo chmod 640 /etc/frr/*.conf +### Install daemon config file + sudo install -p -m 644 redhat/daemons /etc/frr/ + sudo chown frr:frr /etc/frr/daemons + +### Edit /etc/frr/daemons as needed to select the required daemons + +Look for the section with `watchfrr_enable=...` and `zebra=...` etc. +Enable the daemons as required by changing the value to `yes` + ### Enable IP & IPv6 forwarding Create a new file `/etc/sysctl.d/90-routing-sysctl.conf` with the @@ -94,33 +112,19 @@ following content: net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1 -**Reboot** or use `sysctl` to apply the same config to the running system +Load the modifed sysctl's on the system: -### Install Service files - sudo install -p -m 644 redhat/zebra.service /usr/lib/systemd/system/zebra.service - sudo install -p -m 644 redhat/isisd.service /usr/lib/systemd/system/isisd.service - sudo install -p -m 644 redhat/ripd.service /usr/lib/systemd/system/ripd.service - sudo install -p -m 644 redhat/ospfd.service /usr/lib/systemd/system/ospfd.service - sudo install -p -m 644 redhat/bgpd.service /usr/lib/systemd/system/bgpd.service - sudo install -p -m 644 redhat/ospf6d.service /usr/lib/systemd/system/ospf6d.service - sudo install -p -m 644 redhat/ripngd.service /usr/lib/systemd/system/ripngd.service - sudo install -p -m 644 redhat/pimd.service /usr/lib/systemd/system/pimd.service - sudo install -p -m 644 redhat/frr.sysconfig /etc/sysconfig/frr - sudo install -p -m 644 redhat/frr.logrotate /etc/logrotate.d/frr + sudo sysctl -p /etc/sysctl.d/90-routing-sysctl.conf + +### Install frr Service and redhat init files + sudo install -p -m 644 redhat/frr.service /usr/lib/systemd/system/frr.service + sudo install -p -m 755 redhat/frr.init /usr/lib/frr/frr ### Register the systemd files - sudo systemctl preset zebra.service - sudo systemctl preset ripd.service - sudo systemctl preset ospfd.service - sudo systemctl preset bgpd.service - sudo systemctl preset ospf6d.service - sudo systemctl preset ripngd.service - sudo systemctl preset pimd.service - -### Enable required daemons at startup -Only enable zebra and the daemons which are needed for your setup - - sudo systemctl enable zebra - sudo systemctl enable ospfd - sudo systemctl enable bgpd - [...] etc (as needed) + sudo systemctl preset frr.service + +### Enable required frr at startup + sudo systemctl enable frr + +### Reboot or start FRR manually + sudo systemctl start frr diff --git a/doc/Building_FRR_on_Fedora24.md b/doc/Building_FRR_on_Fedora24.md index bb5b52c62..c161b9b12 100644 --- a/doc/Building_FRR_on_Fedora24.md +++ b/doc/Building_FRR_on_Fedora24.md @@ -1,14 +1,19 @@ Building FRR on Fedora 24 from Git Source ========================================= +(As an alternative to this installation, you may prefer to create a FRR +rpm package yourself and install that package instead. See instructions +in redhat/README.rpm_build.md on how to build a rpm package) + Install required packages ------------------------- Add packages: sudo dnf install git autoconf automake libtool make gawk \ - readline-devel texinfo net-snmp-devel groff pkgconfig \ - json-c-devel pam-devel c-ares-devel python3-devel + readline-devel texinfo net-snmp-devel groff pkgconfig \ + json-c-devel pam-devel perl-XML-LibXML pytest bison flex \ + c-ares-devel python3-devel Get FRR, compile it and install it (from Git) --------------------------------------------- @@ -27,17 +32,17 @@ using any packages** (You may prefer different options on configure statement. These are just an example.) -You may want to pay special attention to `/usr/lib64` paths and change -them if you are not building on a x86_64 architecture - git clone https://github.com/frrouting/frr.git frr cd frr ./bootstrap.sh ./configure \ + --bindir=/usr/bin \ + --sbindir=/usr/lib/frr \ --sysconfdir=/etc/frr \ - --libdir=/usr/lib64/frr \ - --libexecdir=/usr/lib64/frr \ + --libdir=/usr/lib/frr \ + --libexecdir=/usr/lib/frr \ --localstatedir=/var/run/frr \ + --with-moduledir=/usr/lib/frr/modules \ --enable-pimd \ --enable-snmp=agentx \ --enable-multipath=64 \ @@ -50,7 +55,11 @@ them if you are not building on a x86_64 architecture --disable-exampledir \ --enable-watchfrr \ --enable-tcp-zebra \ + --enable-ldpd \ --enable-fpm \ + --enable-nhrpd \ + --enable-eigrpd \ + --enable-babeld \ --with-pkg-git-version \ --with-pkg-extra-version=-MyOwnFRRVersion make @@ -70,11 +79,22 @@ them if you are not building on a x86_64 architecture sudo touch /etc/frr/pimd.conf sudo touch /etc/frr/ldpd.conf sudo touch /etc/frr/nhrpd.conf + sudo touch /etc/frr/eigrpd.conf + sudo touch /etc/frr/babeld.conf sudo chown -R frr:frr /etc/frr/ sudo touch /etc/frr/vtysh.conf sudo chown frr:frrvt /etc/frr/vtysh.conf sudo chmod 640 /etc/frr/*.conf +### Install daemon config file + sudo install -p -m 644 redhat/daemons /etc/frr/ + sudo chown frr:frr /etc/frr/daemons + +### Edit /etc/frr/daemons as needed to select the required daemons + +Look for the section with `watchfrr_enable=...` and `zebra=...` etc. +Enable the daemons as required by changing the value to `yes` + ### Enable IP & IPv6 forwarding (and MPLS) Create a new file `/etc/sysctl.d/90-routing-sysctl.conf` with the @@ -94,41 +114,26 @@ to `net.mpls.conf.eth0.input=1`) net.mpls.conf.eth2.input=1 net.mpls.platform_labels=100000 +Load the modifed sysctl's on the system: + + sudo sysctl -p /etc/sysctl.d/90-routing-sysctl.conf + Create a new file `/etc/modules-load.d/mpls.conf` with the following content: # Load MPLS Kernel Modules mpls-router mpls-iptunnel -**Reboot** or use `sysctl` to apply the same config to the running system - -### Install Service files - install -p -m 644 redhat/zebra.service /usr/lib/systemd/system/zebra.service - install -p -m 644 redhat/isisd.service /usr/lib/systemd/system/isisd.service - install -p -m 644 redhat/ripd.service /usr/lib/systemd/system/ripd.service - install -p -m 644 redhat/ospfd.service /usr/lib/systemd/system/ospfd.service - install -p -m 644 redhat/bgpd.service /usr/lib/systemd/system/bgpd.service - install -p -m 644 redhat/ospf6d.service /usr/lib/systemd/system/ospf6d.service - install -p -m 644 redhat/ripngd.service /usr/lib/systemd/system/ripngd.service - install -p -m 644 redhat/pimd.service /usr/lib/systemd/system/pimd.service - install -p -m 644 redhat/ldpd.service /usr/lib/systemd/system/ldpd.service - install -p -m 644 redhat/frr.sysconfig /etc/sysconfig/frr - install -p -m 644 redhat/frr.logrotate /etc/logrotate.d/frr - -### Register the systemd files - systemctl preset zebra.service - systemctl preset ripd.service - systemctl preset ospfd.service - systemctl preset bgpd.service - systemctl preset ospf6d.service - systemctl preset ripngd.service - systemctl preset pimd.service - systemctl preset ldpd.service - -### Enable required daemons at startup -Only enable zebra and the daemons which are needed for your setup - - systemctl enable zebra - systemctl enable ospfd - systemctl enable bgpd - [...] etc (as needed) +And load the kernel modules on the running system: + + sudo modprobe mpls-router mpls-iptunnel + +### Install frr Service and redhat init files + sudo install -p -m 644 redhat/frr.service /usr/lib/systemd/system/frr.service + sudo install -p -m 755 redhat/frr.init /usr/lib/frr/frr + +### Enable required frr at startup + sudo systemctl enable frr + +### Reboot or start FRR manually + sudo systemctl start frr diff --git a/doc/appendix.texi b/doc/appendix.texi index 3904c5f0c..2e1c9deb1 100644 --- a/doc/appendix.texi +++ b/doc/appendix.texi @@ -1,7 +1,7 @@ @node Packet Binary Dump Format @appendix Packet Binary Dump Format - Quagga can dump routing protocol packet into file with a binary format + FRR can dump routing protocol packet into file with a binary format (@pxref{Dump BGP packets and table}). It seems to be better that we share the MRT's header format for diff --git a/doc/babeld.texi b/doc/babeld.texi index 6b4cca1e1..2dfb5f8c0 100644 --- a/doc/babeld.texi +++ b/doc/babeld.texi @@ -1,7 +1,7 @@ @c -*-texinfo-*- -@c This is part of the Quagga Manual. +@c This is part of the FRR Manual. @c @value{COPYRIGHT_STR} -@c See file quagga.texi for copying conditions. +@c See file frr.texi for copying conditions. @node Babel @chapter Babel @@ -14,7 +14,7 @@ perform reliable link quality estimation on wireless links. Babel is a double-stack routing protocol, meaning that a single Babel instance is able to perform routing for both IPv4 and IPv6. -Quagga implements Babel as described in RFC6126. +FRR implements Babel as described in RFC6126. @menu * Configuring babeld:: diff --git a/doc/ospfclient.8.in b/doc/ospfclient.8.in index fb996a541..a304beffd 100644 --- a/doc/ospfclient.8.in +++ b/doc/ospfclient.8.in @@ -1,5 +1,5 @@ .\" This file was originally generated by help2man 1.36. -.TH OSPFCLIENT "1" "July 2010" +.TH OSPFCLIENT "8" "July 2010" .SH NAME ospfclient \- an example ospf-api client .SH SYNOPSIS diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c index a32ccb58b..9e18c0dca 100644 --- a/eigrpd/eigrp_dump.c +++ b/eigrpd/eigrp_dump.c @@ -84,7 +84,7 @@ config_write_debug (struct vty *vty) if (conf_debug_eigrp_packet[i] == 0 && term_debug_eigrp_packet[i] == 0 ) continue; - vty_outln (vty, "debug eigrp packet %s%s", + vty_out (vty, "debug eigrp packet %s%s\n", type_str[i],detail_str[conf_debug_eigrp_packet[i]]); write = 1; } @@ -210,12 +210,11 @@ void show_ip_eigrp_interface_header (struct vty *vty, struct eigrp *eigrp) { - vty_outln (vty, "%s%s%d%s%s%s %-10s %-10s %-10s %-6s %-12s %-7s %-14s %-12s %-8s %-8s %-8s%s %-39s %-12s %-7s %-14s %-12s %-8s", - VTYNL, - "EIGRP interfaces for AS(",eigrp->AS,")",VTYNL,VTYNL, + vty_out (vty, "\nEIGRP interfaces for AS(%d)\n\n %-10s %-10s %-10s %-6s %-12s %-7s %-14s %-12s %-8s %-8s %-8s\n %-39s %-12s %-7s %-14s %-12s %-8s\n", + eigrp->AS, "Interface", "Bandwidth", "Delay", "Peers", "Xmit Queue", "Mean", "Pacing Time", "Multicast", "Pending", "Hello", "Holdtime", - VTYNL,"","Un/Reliable","SRTT","Un/Reliable","Flow Timer", + "","Un/Reliable","SRTT","Un/Reliable","Flow Timer", "Routes"); } @@ -229,7 +228,7 @@ show_ip_eigrp_interface_sub (struct vty *vty, struct eigrp *eigrp, vty_out (vty, "%-7u", ei->nbrs->count); vty_out (vty, "%u %c %-10u",0,'/', eigrp_neighbor_packet_queue_sum (ei)); vty_out (vty, "%-7u %-14u %-12u %-8u", 0, 0, 0, 0); - vty_outln (vty, "%-8u %-8u ", + vty_out (vty, "%-8u %-8u \n", IF_DEF_PARAMS (ei->ifp)->v_hello, IF_DEF_PARAMS(ei->ifp)->v_wait); } @@ -238,31 +237,30 @@ void show_ip_eigrp_interface_detail (struct vty *vty, struct eigrp *eigrp, struct eigrp_interface *ei) { - vty_outln (vty, "%-2s %s %d %-3s ","","Hello interval is ", 0, " sec"); - vty_outln (vty, "%-2s %s %s ","", "Next xmit serial","<none>"); - vty_outln (vty, "%-2s %s %d %s %d %s %d %s %d ", + vty_out (vty, "%-2s %s %d %-3s \n","","Hello interval is ", 0, " sec"); + vty_out (vty, "%-2s %s %s \n","", "Next xmit serial","<none>"); + vty_out (vty, "%-2s %s %d %s %d %s %d %s %d \n", "", "Un/reliable mcasts: ", 0, "/", 0, "Un/reliable ucasts: ", 0, "/", 0); - vty_outln (vty, "%-2s %s %d %s %d %s %d ", + vty_out (vty, "%-2s %s %d %s %d %s %d \n", "", "Mcast exceptions: ", 0, " CR packets: ", 0, " ACKs supressed: ", 0); - vty_outln (vty, "%-2s %s %d %s %d ", + vty_out (vty, "%-2s %s %d %s %d \n", "", "Retransmissions sent: ", 0, "Out-of-sequence rcvd: ", 0); - vty_outln (vty, "%-2s %s %s %s ", + vty_out (vty, "%-2s %s %s %s \n", "", "Authentication mode is ", "not","set"); - vty_outln (vty, "%-2s %s ", "", "Use multicast"); + vty_out (vty, "%-2s %s \n", "", "Use multicast"); } void show_ip_eigrp_neighbor_header (struct vty *vty, struct eigrp *eigrp) { - vty_outln (vty, "%s%s%d%s%s%s%-3s %-17s %-20s %-6s %-8s %-6s %-5s %-5s %-5s%s %-41s %-6s %-8s %-6s %-4s %-6s %-5s ", - VTYNL, - "EIGRP neighbors for AS(",eigrp->AS,")",VTYNL,VTYNL, + vty_out (vty, "\nEIGRP neighbors for AS(%d)\n\n%-3s %-17s %-20s %-6s %-8s %-6s %-5s %-5s %-5s\n %-41s %-6s %-8s %-6s %-4s %-6s %-5s \n", + eigrp->AS, "H", "Address", "Interface", "Hold", "Uptime", - "SRTT", "RTO", "Q", "Seq", VTYNL - ,"","(sec)","","(ms)","","Cnt","Num"); + "SRTT", "RTO", "Q", "Seq", + "","(sec)","","(ms)","","Cnt","Num"); } void @@ -275,7 +273,7 @@ show_ip_eigrp_neighbor_sub (struct vty *vty, struct eigrp_neighbor *nbr, vty_out (vty,"%-7lu", thread_timer_remain_second (nbr->t_holddown)); vty_out (vty,"%-8u %-6u %-5u", 0, 0, EIGRP_PACKET_RETRANS_TIME); vty_out (vty,"%-7lu", nbr->retrans_queue->count); - vty_outln (vty,"%u", nbr->recv_sequence_number); + vty_out (vty,"%u\n", nbr->recv_sequence_number); if (detail) @@ -285,7 +283,7 @@ show_ip_eigrp_neighbor_sub (struct vty *vty, struct eigrp_neighbor *nbr, nbr->tlv_rel_major, nbr->tlv_rel_minor); vty_out(vty,", Retrans: %lu, Retries: %lu", nbr->retrans_queue->count, 0UL); - vty_outln (vty,", %s", eigrp_nbr_state_str(nbr)); + vty_out (vty,", %s\n", eigrp_nbr_state_str(nbr)); } } @@ -298,11 +296,9 @@ show_ip_eigrp_topology_header (struct vty *vty, struct eigrp *eigrp) struct in_addr router_id; router_id.s_addr = eigrp->router_id; - vty_outln (vty, "%sEIGRP Topology Table for AS(%d)/ID(%s)%s", - VTYNL, eigrp->AS, inet_ntoa(router_id), VTYNL); - vty_outln (vty, "Codes: P - Passive, A - Active, U - Update, Q - Query, " - "R - Reply%s r - reply Status, s - sia Status%s", - VTYNL, VTYNL); + vty_out (vty, "\nEIGRP Topology Table for AS(%d)/ID(%s)\n\n", eigrp->AS, inet_ntoa(router_id)); + vty_out (vty, "Codes: P - Passive, A - Active, U - Update, Q - Query, " + "R - Reply\n r - reply Status, s - sia Status\n\n"); } void @@ -315,7 +311,7 @@ show_ip_eigrp_prefix_entry (struct vty *vty, struct eigrp_prefix_entry *tn) vty_out (vty, "%s/%u, ", inet_ntoa (tn->destination_ipv4->prefix), tn->destination_ipv4->prefixlen); vty_out (vty, "%u successors, ", successors->count); - vty_outln (vty, "FD is %u, serno: %" PRIu64 " ", tn->fdistance, tn->serno); + vty_out (vty, "FD is %u, serno: %" PRIu64 " \n", tn->fdistance, tn->serno); list_delete(successors); } @@ -334,11 +330,11 @@ show_ip_eigrp_neighbor_entry (struct vty *vty, struct eigrp *eigrp, } if (te->adv_router == eigrp->neighbor_self) - vty_outln (vty, "%-7s%s, %s", " ", "via Connected", + vty_out (vty, "%-7s%s, %s\n", " ", "via Connected", eigrp_if_name_string(te->ei)); else { - vty_outln (vty, "%-7s%s%s (%u/%u), %s", + vty_out (vty, "%-7s%s%s (%u/%u), %s\n", " ", "via ", inet_ntoa (te->adv_router->src), te->distance, te->reported_distance, eigrp_if_name_string(te->ei)); @@ -355,11 +351,11 @@ DEFUN (show_debugging_eigrp, { int i; - vty_outln (vty, "EIGRP debugging status:"); + vty_out (vty, "EIGRP debugging status:\n"); /* Show debug status for events. */ if (IS_DEBUG_EIGRP(event,EVENT)) - vty_outln (vty, " EIGRP event debugging is on"); + vty_out (vty, " EIGRP event debugging is on\n"); /* Show debug status for EIGRP Packets. */ for (i = 0; i < 11 ; i++) @@ -369,18 +365,18 @@ DEFUN (show_debugging_eigrp, if (IS_DEBUG_EIGRP_PACKET (i, SEND) && IS_DEBUG_EIGRP_PACKET (i, RECV)) { - vty_outln (vty, " EIGRP packet %s%s debugging is on", + vty_out (vty, " EIGRP packet %s%s debugging is on\n", lookup_msg(eigrp_packet_type_str, i + 1, NULL), IS_DEBUG_EIGRP_PACKET (i, PACKET_DETAIL) ? " detail" : ""); } else { if (IS_DEBUG_EIGRP_PACKET (i, SEND)) - vty_outln (vty, " EIGRP packet %s send%s debugging is on", + vty_out (vty, " EIGRP packet %s send%s debugging is on\n", lookup_msg(eigrp_packet_type_str, i + 1, NULL), IS_DEBUG_EIGRP_PACKET (i, PACKET_DETAIL) ? " detail" : ""); if (IS_DEBUG_EIGRP_PACKET (i, RECV)) - vty_outln (vty, " EIGRP packet %s receive%s debugging is on", + vty_out (vty, " EIGRP packet %s receive%s debugging is on\n", lookup_msg(eigrp_packet_type_str, i + 1, NULL), IS_DEBUG_EIGRP_PACKET (i, PACKET_DETAIL) ? " detail" : ""); } diff --git a/eigrpd/eigrp_neighbor.c b/eigrpd/eigrp_neighbor.c index c0bb2afaf..bf3fc216c 100644 --- a/eigrpd/eigrp_neighbor.c +++ b/eigrpd/eigrp_neighbor.c @@ -366,7 +366,7 @@ void eigrp_nbr_hard_restart(struct eigrp_neighbor *nbr, struct vty *vty) if(vty != NULL) { vty_time_print (vty, 0); - vty_outln (vty, "Neighbor %s (%s) is down: manually cleared", + vty_out (vty, "Neighbor %s (%s) is down: manually cleared\n", inet_ntoa (nbr->src), ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT)); } diff --git a/eigrpd/eigrp_routemap.c b/eigrpd/eigrp_routemap.c index 01fc97073..1d85e7646 100644 --- a/eigrpd/eigrp_routemap.c +++ b/eigrpd/eigrp_routemap.c @@ -154,11 +154,11 @@ eigrp_route_match_add (struct vty *vty, struct route_map_index *index, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% Can't find rule."); - return CMD_WARNING; + vty_out (vty, "%% Can't find rule.\n"); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% Argument is malformed."); - return CMD_WARNING; + vty_out (vty, "%% Argument is malformed.\n"); + return CMD_WARNING_CONFIG_FAILED; } } return CMD_SUCCESS; @@ -176,11 +176,11 @@ eigrp_route_match_delete (struct vty *vty, struct route_map_index *index, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% Can't find rule."); - return CMD_WARNING; + vty_out (vty, "%% Can't find rule.\n"); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% Argument is malformed."); - return CMD_WARNING; + vty_out (vty, "%% Argument is malformed.\n"); + return CMD_WARNING_CONFIG_FAILED; } } return CMD_SUCCESS; @@ -199,16 +199,16 @@ eigrp_route_set_add (struct vty *vty, struct route_map_index *index, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% Can't find rule."); - return CMD_WARNING; + vty_out (vty, "%% Can't find rule.\n"); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: /* rip, ripng and other protocols share the set metric command but only values from 0 to 16 are valid for rip and ripng if metric is out of range for rip and ripng, it is not for other protocols. Do not return an error */ if (strcmp(command, "metric")) { - vty_outln (vty, "%% Argument is malformed."); - return CMD_WARNING; + vty_out (vty, "%% Argument is malformed.\n"); + return CMD_WARNING_CONFIG_FAILED; } } } @@ -228,11 +228,11 @@ eigrp_route_set_delete (struct vty *vty, struct route_map_index *index, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% Can't find rule."); - return CMD_WARNING; + vty_out (vty, "%% Can't find rule.\n"); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% Argument is malformed."); - return CMD_WARNING; + vty_out (vty, "%% Argument is malformed.\n"); + return CMD_WARNING_CONFIG_FAILED; } } return CMD_SUCCESS; @@ -1124,8 +1124,8 @@ DEFUN (set_ip_nexthop, ret = str2sockunion (argv[0], &su); if (ret < 0) { - vty_outln (vty, "%% Malformed next-hop address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed next-hop address\n"); + return CMD_WARNING_CONFIG_FAILED; } return eigrp_route_set_add (vty, vty->index, "ip next-hop", argv[0]); diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c index 24fd7074f..93b2ceb9d 100644 --- a/eigrpd/eigrp_update.c +++ b/eigrpd/eigrp_update.c @@ -1047,7 +1047,7 @@ eigrp_update_send_GR (struct eigrp_neighbor *nbr, enum GR_type gr_type, struct v if(vty != NULL) { vty_time_print (vty, 0); - vty_outln (vty, "Neighbor %s (%s) is resync: manually cleared", + vty_out (vty, "Neighbor %s (%s) is resync: manually cleared\n", inet_ntoa (nbr->src), ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT)); } diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c index e283c7365..49fb729ca 100644 --- a/eigrpd/eigrp_vty.c +++ b/eigrpd/eigrp_vty.c @@ -65,18 +65,18 @@ config_write_network (struct vty *vty, struct eigrp *eigrp) if (rn->info) { /* Network print. */ - vty_outln (vty, " network %s/%d ", + vty_out (vty, " network %s/%d \n", inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); } if (eigrp->max_paths != EIGRP_MAX_PATHS_DEFAULT) - vty_outln (vty, " maximum-paths %d", eigrp->max_paths); + vty_out (vty, " maximum-paths %d\n", eigrp->max_paths); if (eigrp->variance != EIGRP_VARIANCE_DEFAULT) - vty_outln (vty, " variance %d", eigrp->variance); + vty_out (vty, " variance %d\n", eigrp->variance); /*Separate EIGRP configuration from the rest of the config*/ - vty_outln (vty, "!"); + vty_out (vty, "!\n"); return 0; } @@ -89,39 +89,39 @@ config_write_interfaces (struct vty *vty, struct eigrp *eigrp) for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei)) { - vty_outln (vty, "interface %s", ei->ifp->name); + vty_out (vty, "interface %s\n", ei->ifp->name); if ((IF_DEF_PARAMS (ei->ifp)->auth_type) == EIGRP_AUTH_TYPE_MD5) { - vty_outln (vty, " ip authentication mode eigrp %d md5", eigrp->AS); + vty_out (vty, " ip authentication mode eigrp %d md5\n", eigrp->AS); } if ((IF_DEF_PARAMS (ei->ifp)->auth_type) == EIGRP_AUTH_TYPE_SHA256) { - vty_outln (vty, " ip authentication mode eigrp %d hmac-sha-256", + vty_out (vty, " ip authentication mode eigrp %d hmac-sha-256\n", eigrp->AS); } if(IF_DEF_PARAMS (ei->ifp)->auth_keychain) { - vty_outln (vty, " ip authentication key-chain eigrp %d %s",eigrp->AS, + vty_out (vty, " ip authentication key-chain eigrp %d %s\n",eigrp->AS, IF_DEF_PARAMS(ei->ifp)->auth_keychain); } if ((IF_DEF_PARAMS (ei->ifp)->v_hello) != EIGRP_HELLO_INTERVAL_DEFAULT) { - vty_outln (vty, " ip hello-interval eigrp %d", + vty_out (vty, " ip hello-interval eigrp %d\n", IF_DEF_PARAMS(ei->ifp)->v_hello); } if ((IF_DEF_PARAMS (ei->ifp)->v_wait) != EIGRP_HOLD_INTERVAL_DEFAULT) { - vty_outln (vty, " ip hold-time eigrp %d", + vty_out (vty, " ip hold-time eigrp %d\n", IF_DEF_PARAMS(ei->ifp)->v_wait); } /*Separate this EIGRP interface configuration from the others*/ - vty_outln (vty, "!"); + vty_out (vty, "!\n"); } return 0; @@ -134,23 +134,23 @@ eigrp_write_interface (struct vty *vty) struct interface *ifp; for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp)) { - vty_outln (vty, "interface %s",ifp->name); + vty_out (vty, "interface %s\n",ifp->name); if (ifp->desc) - vty_outln (vty, " description %s",ifp->desc); + vty_out (vty, " description %s\n",ifp->desc); if (IF_DEF_PARAMS (ifp)->bandwidth != EIGRP_BANDWIDTH_DEFAULT) - vty_outln (vty, " bandwidth %u",IF_DEF_PARAMS(ifp)->bandwidth); + vty_out (vty, " bandwidth %u\n",IF_DEF_PARAMS(ifp)->bandwidth); if (IF_DEF_PARAMS (ifp)->delay != EIGRP_DELAY_DEFAULT) - vty_outln (vty, " delay %u", IF_DEF_PARAMS(ifp)->delay); + vty_out (vty, " delay %u\n", IF_DEF_PARAMS(ifp)->delay); if (IF_DEF_PARAMS (ifp)->v_hello != EIGRP_HELLO_INTERVAL_DEFAULT) - vty_outln (vty, " ip hello-interval eigrp %u", + vty_out (vty, " ip hello-interval eigrp %u\n", IF_DEF_PARAMS(ifp)->v_hello); if (IF_DEF_PARAMS (ifp)->v_wait != EIGRP_HOLD_INTERVAL_DEFAULT) - vty_outln (vty, " ip hold-time eigrp %u", + vty_out (vty, " ip hold-time eigrp %u\n", IF_DEF_PARAMS(ifp)->v_wait); - vty_outln (vty, "!"); + vty_out (vty, "!\n"); } return 0; @@ -179,7 +179,7 @@ config_write_eigrp_router (struct vty *vty, struct eigrp *eigrp) int write=0; /* `router eigrp' print. */ - vty_outln (vty, "router eigrp %d", eigrp->AS); + vty_out (vty, "router eigrp %d\n", eigrp->AS); write++; @@ -191,7 +191,7 @@ config_write_eigrp_router (struct vty *vty, struct eigrp *eigrp) { struct in_addr router_id_static; router_id_static.s_addr = htonl(eigrp->router_id_static); - vty_outln (vty, " eigrp router-id %s", + vty_out (vty, " eigrp router-id %s\n", inet_ntoa(router_id_static)); } @@ -202,7 +202,7 @@ config_write_eigrp_router (struct vty *vty, struct eigrp *eigrp) config_write_eigrp_distribute (vty, eigrp); /*Separate EIGRP configuration from the rest of the config*/ - vty_outln (vty, "!"); + vty_out (vty, "!\n"); return write; } @@ -235,8 +235,8 @@ DEFUN (no_router_eigrp, eigrp = eigrp_lookup (); if (eigrp->AS != atoi (argv[3]->arg)) { - vty_outln (vty,"%% Attempting to deconfigure non-existent AS"); - return CMD_WARNING; + vty_out (vty,"%% Attempting to deconfigure non-existent AS\n"); + return CMD_WARNING_CONFIG_FAILED; } eigrp_finish_final (eigrp); @@ -393,8 +393,8 @@ DEFUN (eigrp_network, if (ret == 0) { - vty_outln (vty, "There is already same network statement."); - return CMD_WARNING; + vty_out (vty, "There is already same network statement.\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -417,8 +417,8 @@ DEFUN (no_eigrp_network, if (ret == 0) { - vty_outln (vty,"Can't find specified network configuration."); - return CMD_WARNING; + vty_out (vty,"Can't find specified network configuration.\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -465,7 +465,7 @@ DEFUN (show_ip_eigrp_topology, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -521,7 +521,7 @@ DEFUN (show_ip_eigrp_interfaces, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, "EIGRP Routing Process not enabled"); + vty_out (vty, "EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -568,7 +568,7 @@ DEFUN (show_ip_eigrp_neighbors, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -607,7 +607,7 @@ DEFUN (eigrp_if_delay, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -633,7 +633,7 @@ DEFUN (no_eigrp_if_delay, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -658,7 +658,7 @@ DEFUN (eigrp_if_bandwidth, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -684,7 +684,7 @@ DEFUN (no_eigrp_if_bandwidth, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -709,7 +709,7 @@ DEFUN (eigrp_if_ip_hellointerval, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -737,7 +737,7 @@ DEFUN (no_eigrp_if_ip_hellointerval, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -771,7 +771,7 @@ DEFUN (eigrp_if_ip_holdinterval, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -798,7 +798,7 @@ DEFUN (eigrp_ip_summary_address, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -826,7 +826,7 @@ DEFUN (no_eigrp_ip_summary_address, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -852,7 +852,7 @@ DEFUN (no_eigrp_if_ip_holdinterval, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -866,7 +866,7 @@ str2auth_type (const char *str, struct interface *ifp) { /* Sanity check. */ if (str == NULL) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if(strncmp(str, "md5",3) == 0) { @@ -879,7 +879,7 @@ str2auth_type (const char *str, struct interface *ifp) return CMD_SUCCESS; } - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (eigrp_authentication_mode, @@ -899,7 +899,7 @@ DEFUN (eigrp_authentication_mode, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -929,7 +929,7 @@ DEFUN (no_eigrp_authentication_mode, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -955,7 +955,7 @@ DEFUN (eigrp_authentication_keychain, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, "EIGRP Routing Process not enabled"); + vty_out (vty, "EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -971,7 +971,7 @@ DEFUN (eigrp_authentication_keychain, IF_DEF_PARAMS (ifp)->auth_keychain = strdup(keychain->name); } else - vty_outln (vty,"Key chain with specified name not found"); + vty_out (vty,"Key chain with specified name not found\n"); return CMD_SUCCESS; } @@ -993,7 +993,7 @@ DEFUN (no_eigrp_authentication_keychain, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, "EIGRP Routing Process not enabled"); + vty_out (vty, "EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1004,8 +1004,8 @@ DEFUN (no_eigrp_authentication_keychain, IF_DEF_PARAMS (ifp)->auth_keychain = NULL; } else - vty_outln (vty, - "Key chain with specified name not configured on interface"); + vty_out (vty, + "Key chain with specified name not configured on interface\n"); return CMD_SUCCESS; } @@ -1032,7 +1032,7 @@ DEFUN (eigrp_redistribute_source_metric, argv_find (argv, argc, "redistribute", &idx); source = proto_redistnum(AFI_IP, argv[idx+1]->arg); if (source < 0 ) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Get metrics values */ @@ -1061,7 +1061,7 @@ DEFUN (no_eigrp_redistribute_source_metric, argv_find (argv, argc, "redistribute", &idx); source = proto_redistnum(AFI_IP, argv[idx+1]->arg); if (source < 0 ) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Get metrics values */ @@ -1080,7 +1080,7 @@ DEFUN (eigrp_variance, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, "EIGRP Routing Process not enabled"); + vty_out (vty, "EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } variance = atoi(argv[1]->arg); @@ -1103,7 +1103,7 @@ DEFUN (no_eigrp_variance, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, "EIGRP Routing Process not enabled"); + vty_out (vty, "EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1126,7 +1126,7 @@ DEFUN (eigrp_maximum_paths, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, "EIGRP Routing Process not enabled"); + vty_out (vty, "EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1151,7 +1151,7 @@ DEFUN (no_eigrp_maximum_paths, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, "EIGRP Routing Process not enabled"); + vty_out (vty, "EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1182,7 +1182,7 @@ DEFUN (clear_ip_eigrp_neighbors, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1201,7 +1201,7 @@ DEFUN (clear_ip_eigrp_neighbors, inet_ntoa (nbr->src), ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT)); vty_time_print (vty, 0); - vty_outln (vty, "Neighbor %s (%s) is down: manually cleared", + vty_out (vty, "Neighbor %s (%s) is down: manually cleared\n", inet_ntoa (nbr->src), ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT)); @@ -1238,7 +1238,7 @@ DEFUN (clear_ip_eigrp_neighbors_int, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1247,7 +1247,7 @@ DEFUN (clear_ip_eigrp_neighbors_int, ei = eigrp_if_lookup_by_name(eigrp, argv[idx]->arg); if(ei == NULL) { - vty_outln (vty, " Interface (%s) doesn't exist", argv[idx]->arg); + vty_out (vty, " Interface (%s) doesn't exist\n", argv[idx]->arg); return CMD_WARNING; } @@ -1263,7 +1263,7 @@ DEFUN (clear_ip_eigrp_neighbors_int, inet_ntoa (nbr->src), ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT)); vty_time_print (vty, 0); - vty_outln (vty, "Neighbor %s (%s) is down: manually cleared", + vty_out (vty, "Neighbor %s (%s) is down: manually cleared\n", inet_ntoa (nbr->src), ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT)); @@ -1299,7 +1299,7 @@ DEFUN (clear_ip_eigrp_neighbors_IP, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1309,7 +1309,7 @@ DEFUN (clear_ip_eigrp_neighbors_IP, /* if neighbor doesn't exists, notify user and exit */ if(nbr == NULL) { - vty_outln (vty, "Neighbor with entered address doesn't exists."); + vty_out (vty, "Neighbor with entered address doesn't exists.\n"); return CMD_WARNING; } @@ -1337,7 +1337,7 @@ DEFUN (clear_ip_eigrp_neighbors_soft, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1367,7 +1367,7 @@ DEFUN (clear_ip_eigrp_neighbors_int_soft, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1375,7 +1375,7 @@ DEFUN (clear_ip_eigrp_neighbors_int_soft, ei = eigrp_if_lookup_by_name(eigrp, argv[4]->arg); if(ei == NULL) { - vty_outln (vty, " Interface (%s) doesn't exist", argv[4]->arg); + vty_out (vty, " Interface (%s) doesn't exist\n", argv[4]->arg); return CMD_WARNING; } @@ -1407,7 +1407,7 @@ DEFUN (clear_ip_eigrp_neighbors_IP_soft, eigrp = eigrp_lookup (); if (eigrp == NULL) { - vty_outln (vty, " EIGRP Routing Process not enabled"); + vty_out (vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -1417,7 +1417,7 @@ DEFUN (clear_ip_eigrp_neighbors_IP_soft, /* if neighbor doesn't exists, notify user and exit */ if(nbr == NULL) { - vty_outln (vty, "Neighbor with entered address doesn't exists."); + vty_out (vty, "Neighbor with entered address doesn't exists.\n"); return CMD_WARNING; } diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c index efe5e6721..e4a4e0c42 100644 --- a/isisd/isis_adjacency.c +++ b/isisd/isis_adjacency.c @@ -402,13 +402,13 @@ isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty, char detail) else vty_out (vty, "- "); vty_out (vty, "%-10s", snpa_print (adj->snpa)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (detail == ISIS_UI_LEVEL_DETAIL) { level = adj->level; - vty_out (vty, VTYNL); + vty_out (vty, "\n"); if (adj->circuit) vty_out (vty, " Interface: %s", adj->circuit->interface->name); else @@ -421,18 +421,18 @@ isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty, char detail) time2string (adj->last_upd + adj->hold_time - now)); else vty_out (vty, ", Expires in %s", time2string (adj->hold_time)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, " Adjacency flaps: %u", adj->flaps); vty_out (vty, ", Last: %s ago", time2string (now - adj->last_flap)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, " Circuit type: %s", circuit_t2string (adj->circuit_t)); vty_out (vty, ", Speaks: %s", nlpid2string (&adj->nlpids)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); if (adj->mt_count != 1 || adj->mt_set[0] != ISIS_MT_IPV4_UNICAST) { - vty_outln (vty, " Topologies:"); + vty_out (vty, " Topologies:\n"); for (unsigned int i = 0; i < adj->mt_count; i++) - vty_outln (vty, " %s", isis_mtid2str(adj->mt_set[i])); + vty_out (vty, " %s\n", isis_mtid2str(adj->mt_set[i])); } vty_out (vty, " SNPA: %s", snpa_print (adj->snpa)); if (adj->circuit && (adj->circuit->circ_type == CIRCUIT_T_BROADCAST)) @@ -445,7 +445,7 @@ isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty, char detail) vty_out (vty, ", LAN id: %s.%02x", sysid_print (adj->lanid), adj->lanid[ISIS_SYS_ID_LEN]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, " LAN Priority: %u", adj->prio[adj->level - 1]); vty_out (vty, ", %s, DIS flaps: %u, Last: %s ago", @@ -455,32 +455,32 @@ isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty, char detail) (adj->dis_record[ISIS_LEVELS + level - 1]. last_dis_change))); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); if (adj->area_addrs && listcount (adj->area_addrs) > 0) { struct area_addr *area_addr; - vty_outln (vty, " Area Address(es):"); + vty_out (vty, " Area Address(es):\n"); for (ALL_LIST_ELEMENTS_RO (adj->area_addrs, node, area_addr)) - vty_outln (vty, " %s", + vty_out (vty, " %s\n", isonet_print(area_addr->area_addr, area_addr->addr_len)); } if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0) { - vty_outln (vty, " IPv4 Address(es):"); + vty_out (vty, " IPv4 Address(es):\n"); for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ip_addr)) - vty_outln (vty, " %s", inet_ntoa(*ip_addr)); + vty_out (vty, " %s\n", inet_ntoa(*ip_addr)); } if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0) { - vty_outln (vty, " IPv6 Address(es):"); + vty_out (vty, " IPv6 Address(es):\n"); for (ALL_LIST_ELEMENTS_RO (adj->ipv6_addrs, node, ipv6_addr)) { inet_ntop (AF_INET6, ipv6_addr, (char *)ip6, INET6_ADDRSTRLEN); - vty_outln (vty, " %s", ip6); + vty_out (vty, " %s\n", ip6); } } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return; } diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 73affa91d..d07ea27c4 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -878,7 +878,7 @@ isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty, vty_out (vty, "%-9s", circuit_state2string (circuit->state)); vty_out (vty, "%-9s", circuit_type2string (circuit->circ_type)); vty_out (vty, "%-9s", circuit_t2string (circuit->is_type)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (detail == ISIS_UI_LEVEL_DETAIL) @@ -894,15 +894,15 @@ isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty, else vty_out (vty, ", Active"); vty_out (vty, ", Circuit Id: 0x%x", circuit->circuit_id); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, " Type: %s", circuit_type2string (circuit->circ_type)); vty_out (vty, ", Level: %s", circuit_t2string (circuit->is_type)); if (circuit->circ_type == CIRCUIT_T_BROADCAST) vty_out (vty, ", SNPA: %-10s", snpa_print (circuit->u.bc.snpa)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); if (circuit->is_type & IS_LEVEL_1) { - vty_outln (vty, " Level-1 Information:"); + vty_out (vty, " Level-1 Information:\n"); if (circuit->area->newmetric) vty_out (vty, " Metric: %d", circuit->te_metric[0]); else @@ -910,30 +910,30 @@ isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty, circuit->metric[0]); if (!circuit->is_passive) { - vty_outln (vty, ", Active neighbors: %u", + vty_out (vty, ", Active neighbors: %u\n", circuit->upadjcount[0]); - vty_outln (vty, " Hello interval: %u, " - "Holddown count: %u %s", + vty_out (vty, " Hello interval: %u, " + "Holddown count: %u %s\n", circuit->hello_interval[0], circuit->hello_multiplier[0], (circuit->pad_hellos ? "(pad)" : "(no-pad)")); - vty_outln (vty, " CNSP interval: %u, " - "PSNP interval: %u", + vty_out (vty, " CNSP interval: %u, " + "PSNP interval: %u\n", circuit->csnp_interval[0], circuit->psnp_interval[0]); if (circuit->circ_type == CIRCUIT_T_BROADCAST) - vty_outln (vty, " LAN Priority: %u, %s", + vty_out (vty, " LAN Priority: %u, %s\n", circuit->priority[0], (circuit->u.bc.is_dr[0] ? "is DIS" : "is not DIS")); } else { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } if (circuit->is_type & IS_LEVEL_2) { - vty_outln (vty, " Level-2 Information:"); + vty_out (vty, " Level-2 Information:\n"); if (circuit->area->newmetric) vty_out (vty, " Metric: %d", circuit->te_metric[1]); else @@ -941,56 +941,56 @@ isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty, circuit->metric[1]); if (!circuit->is_passive) { - vty_outln (vty, ", Active neighbors: %u", + vty_out (vty, ", Active neighbors: %u\n", circuit->upadjcount[1]); - vty_outln (vty, " Hello interval: %u, " - "Holddown count: %u %s", + vty_out (vty, " Hello interval: %u, " + "Holddown count: %u %s\n", circuit->hello_interval[1], circuit->hello_multiplier[1], (circuit->pad_hellos ? "(pad)" : "(no-pad)")); - vty_outln (vty, " CNSP interval: %u, " - "PSNP interval: %u", + vty_out (vty, " CNSP interval: %u, " + "PSNP interval: %u\n", circuit->csnp_interval[1], circuit->psnp_interval[1]); if (circuit->circ_type == CIRCUIT_T_BROADCAST) - vty_outln (vty, " LAN Priority: %u, %s", + vty_out (vty, " LAN Priority: %u, %s\n", circuit->priority[1], (circuit->u.bc.is_dr[1] ? "is DIS" : "is not DIS")); } else { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } if (circuit->ip_addrs && listcount (circuit->ip_addrs) > 0) { - vty_outln (vty, " IP Prefix(es):"); + vty_out (vty, " IP Prefix(es):\n"); for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip_addr)) { prefix2str (ip_addr, buf, sizeof (buf)), - vty_outln (vty, " %s", buf); + vty_out (vty, " %s\n", buf); } } if (circuit->ipv6_link && listcount(circuit->ipv6_link) > 0) { - vty_outln (vty, " IPv6 Link-Locals:"); + vty_out (vty, " IPv6 Link-Locals:\n"); for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, ip_addr)) { prefix2str(ip_addr, (char*)buf, BUFSIZ), - vty_outln (vty, " %s", buf); + vty_out (vty, " %s\n", buf); } } if (circuit->ipv6_non_link && listcount(circuit->ipv6_non_link) > 0) { - vty_outln (vty, " IPv6 Prefixes:"); + vty_out (vty, " IPv6 Prefixes:\n"); for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, ip_addr)) { prefix2str(ip_addr, (char*)buf, BUFSIZ), - vty_outln (vty, " %s", buf); + vty_out (vty, " %s\n", buf); } } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return; } @@ -1011,12 +1011,12 @@ isis_interface_config_write (struct vty *vty) continue; /* IF name */ - vty_outln (vty, "interface %s", ifp->name); + vty_out (vty, "interface %s\n", ifp->name); write++; /* IF desc */ if (ifp->desc) { - vty_outln (vty, " description %s", ifp->desc); + vty_out (vty, " description %s\n", ifp->desc); write++; } /* ISIS Circuit */ @@ -1027,36 +1027,36 @@ isis_interface_config_write (struct vty *vty) continue; if (circuit->ip_router) { - vty_outln (vty, " ip router isis %s",area->area_tag); + vty_out (vty, " ip router isis %s\n",area->area_tag); write++; } if (circuit->is_passive) { - vty_outln (vty, " isis passive"); + vty_out (vty, " isis passive\n"); write++; } if (circuit->circ_type_config == CIRCUIT_T_P2P) { - vty_outln (vty, " isis network point-to-point"); + vty_out (vty, " isis network point-to-point\n"); write++; } if (circuit->ipv6_router) { - vty_outln (vty, " ipv6 router isis %s",area->area_tag); + vty_out (vty, " ipv6 router isis %s\n",area->area_tag); write++; } /* ISIS - circuit type */ if (circuit->is_type == IS_LEVEL_1) { - vty_outln (vty, " isis circuit-type level-1"); + vty_out (vty, " isis circuit-type level-1\n"); write++; } else { if (circuit->is_type == IS_LEVEL_2) { - vty_outln (vty," isis circuit-type level-2-only"); + vty_out (vty," isis circuit-type level-2-only\n"); write++; } } @@ -1066,7 +1066,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->csnp_interval[0] != DEFAULT_CSNP_INTERVAL) { - vty_outln (vty, " isis csnp-interval %d", + vty_out (vty, " isis csnp-interval %d\n", circuit->csnp_interval[0]); write++; } @@ -1077,7 +1077,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->csnp_interval[i] != DEFAULT_CSNP_INTERVAL) { - vty_outln (vty, " isis csnp-interval %d level-%d", + vty_out (vty, " isis csnp-interval %d level-%d\n", circuit->csnp_interval[i], i + 1); write++; } @@ -1089,7 +1089,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->psnp_interval[0] != DEFAULT_PSNP_INTERVAL) { - vty_outln (vty, " isis psnp-interval %d", + vty_out (vty, " isis psnp-interval %d\n", circuit->psnp_interval[0]); write++; } @@ -1100,7 +1100,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->psnp_interval[i] != DEFAULT_PSNP_INTERVAL) { - vty_outln (vty, " isis psnp-interval %d level-%d", + vty_out (vty, " isis psnp-interval %d level-%d\n", circuit->psnp_interval[i], i + 1); write++; } @@ -1110,7 +1110,7 @@ isis_interface_config_write (struct vty *vty) /* ISIS - Hello padding - Defaults to true so only display if false */ if (circuit->pad_hellos == 0) { - vty_outln (vty, " no isis hello padding"); + vty_out (vty, " no isis hello padding\n"); write++; } @@ -1119,7 +1119,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->hello_interval[0] != DEFAULT_HELLO_INTERVAL) { - vty_outln (vty, " isis hello-interval %d", + vty_out (vty, " isis hello-interval %d\n", circuit->hello_interval[0]); write++; } @@ -1130,7 +1130,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->hello_interval[i] != DEFAULT_HELLO_INTERVAL) { - vty_outln (vty, " isis hello-interval %d level-%d", + vty_out (vty, " isis hello-interval %d level-%d\n", circuit->hello_interval[i], i + 1); write++; } @@ -1142,7 +1142,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->hello_multiplier[0] != DEFAULT_HELLO_MULTIPLIER) { - vty_outln (vty, " isis hello-multiplier %d", + vty_out (vty, " isis hello-multiplier %d\n", circuit->hello_multiplier[0]); write++; } @@ -1153,7 +1153,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->hello_multiplier[i] != DEFAULT_HELLO_MULTIPLIER) { - vty_outln (vty, " isis hello-multiplier %d level-%d", + vty_out (vty, " isis hello-multiplier %d level-%d\n", circuit->hello_multiplier[i],i + 1); write++; } @@ -1165,7 +1165,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->priority[0] != DEFAULT_PRIORITY) { - vty_outln (vty, " isis priority %d", + vty_out (vty, " isis priority %d\n", circuit->priority[0]); write++; } @@ -1176,7 +1176,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->priority[i] != DEFAULT_PRIORITY) { - vty_outln (vty, " isis priority %d level-%d", + vty_out (vty, " isis priority %d level-%d\n", circuit->priority[i], i + 1); write++; } @@ -1188,7 +1188,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->te_metric[0] != DEFAULT_CIRCUIT_METRIC) { - vty_outln (vty, " isis metric %d",circuit->te_metric[0]); + vty_out (vty, " isis metric %d\n",circuit->te_metric[0]); write++; } } @@ -1198,7 +1198,7 @@ isis_interface_config_write (struct vty *vty) { if (circuit->te_metric[i] != DEFAULT_CIRCUIT_METRIC) { - vty_outln (vty, " isis metric %d level-%d", + vty_out (vty, " isis metric %d level-%d\n", circuit->te_metric[i], i + 1); write++; } @@ -1206,19 +1206,19 @@ isis_interface_config_write (struct vty *vty) } if (circuit->passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5) { - vty_outln (vty, " isis password md5 %s", + vty_out (vty, " isis password md5 %s\n", circuit->passwd.passwd); write++; } else if (circuit->passwd.type == ISIS_PASSWD_TYPE_CLEARTXT) { - vty_outln (vty, " isis password clear %s", + vty_out (vty, " isis password clear %s\n", circuit->passwd.passwd); write++; } write += circuit_write_mt_settings(circuit, vty); } - vty_outln (vty, "!"); + vty_out (vty, "!\n"); } return write; diff --git a/isisd/isis_dynhn.c b/isisd/isis_dynhn.c index e124bb467..35d573d30 100644 --- a/isisd/isis_dynhn.c +++ b/isisd/isis_dynhn.c @@ -159,13 +159,13 @@ dynhn_print_all (struct vty *vty) struct listnode *node; struct isis_dynhn *dyn; - vty_outln (vty, "Level System ID Dynamic Hostname"); + vty_out (vty, "Level System ID Dynamic Hostname\n"); for (ALL_LIST_ELEMENTS_RO (dyn_cache, node, dyn)) { vty_out (vty, "%-7d", dyn->level); - vty_outln (vty, "%-15s%-15s", sysid_print (dyn->id),dyn->name.name); + vty_out (vty, "%-15s%-15s\n", sysid_print (dyn->id),dyn->name.name); } - vty_outln (vty, " * %s %s", sysid_print (isis->sysid),unix_hostname()); + vty_out (vty, " * %s %s\n", sysid_print (isis->sysid),unix_hostname()); return; } diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index d0c4ccc30..ed376058b 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -824,7 +824,7 @@ lsp_print (struct isis_lsp *lsp, struct vty *vty, char dynhost) } else vty_out (vty, " %5u ", ntohs (lsp->lsp_header->rem_lifetime)); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", lsp_bits2string(&lsp->lsp_header->lsp_bits)); } @@ -842,12 +842,12 @@ lsp_print_mt_reach(struct list *list, struct vty *vty, lspid_print(neigh->neigh_id, lspid, dynhost, 0); if (mtid == ISIS_MT_IPV4_UNICAST) { - vty_outln(vty, " Metric : %-8u IS-Extended : %s", + vty_out(vty, " Metric : %-8u IS-Extended : %s\n", GET_TE_METRIC(neigh), lspid); } else { - vty_outln(vty, " Metric : %-8u MT-Reach : %s %s", + vty_out(vty, " Metric : %-8u MT-Reach : %s %s\n", GET_TE_METRIC(neigh), lspid, isis_mtid2str(mtid)); } @@ -874,11 +874,11 @@ lsp_print_mt_ipv6_reach(struct list *list, struct vty *vty, uint16_t mtid) { if ((ipv6_reach->control_info & CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL) - vty_outln (vty, " Metric : %-8" PRIu32 " IPv6-Internal : %s/%d", + vty_out (vty, " Metric : %-8" PRIu32 " IPv6-Internal : %s/%d\n", ntohl (ipv6_reach->metric), buff, ipv6_reach->prefix_len); else - vty_outln (vty, " Metric : %-8" PRIu32 " IPv6-External : %s/%d", + vty_out (vty, " Metric : %-8" PRIu32 " IPv6-External : %s/%d\n", ntohl (ipv6_reach->metric), buff, ipv6_reach->prefix_len); } @@ -886,12 +886,12 @@ lsp_print_mt_ipv6_reach(struct list *list, struct vty *vty, uint16_t mtid) { if ((ipv6_reach->control_info & CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL) - vty_outln (vty, " Metric : %-8" PRIu32 " IPv6-MT-Int : %s/%d %s", + vty_out (vty, " Metric : %-8" PRIu32 " IPv6-MT-Int : %s/%d %s\n", ntohl (ipv6_reach->metric), buff, ipv6_reach->prefix_len, isis_mtid2str(mtid)); else - vty_outln (vty, " Metric : %-8" PRIu32 " IPv6-MT-Ext : %s/%d %s", + vty_out (vty, " Metric : %-8" PRIu32 " IPv6-MT-Ext : %s/%d %s\n", ntohl (ipv6_reach->metric), buff, ipv6_reach->prefix_len, isis_mtid2str(mtid)); @@ -910,7 +910,7 @@ lsp_print_mt_ipv4_reach(struct list *list, struct vty *vty, uint16_t mtid) if (mtid == ISIS_MT_IPV4_UNICAST) { /* FIXME: There should be better way to output this stuff. */ - vty_outln (vty, " Metric : %-8" PRIu32 " IPv4-Extended : %s/%d", + vty_out (vty, " Metric : %-8" PRIu32 " IPv4-Extended : %s/%d\n", ntohl (te_ipv4_reach->te_metric), inet_ntoa (newprefix2inaddr (&te_ipv4_reach->prefix_start, te_ipv4_reach->control)), @@ -919,7 +919,7 @@ lsp_print_mt_ipv4_reach(struct list *list, struct vty *vty, uint16_t mtid) else { /* FIXME: There should be better way to output this stuff. */ - vty_outln (vty, " Metric : %-8" PRIu32 " IPv4-MT : %s/%d %s", + vty_out (vty, " Metric : %-8" PRIu32 " IPv4-MT : %s/%d %s\n", ntohl (te_ipv4_reach->te_metric), inet_ntoa (newprefix2inaddr (&te_ipv4_reach->prefix_start, te_ipv4_reach->control)), @@ -955,7 +955,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) if (lsp->tlv_data.area_addrs) for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.area_addrs, lnode, area_addr)) { - vty_outln (vty, " Area Address: %s", + vty_out (vty, " Area Address: %s\n", isonet_print(area_addr->area_addr, area_addr->addr_len)); } @@ -968,11 +968,11 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) { case NLPID_IP: case NLPID_IPV6: - vty_outln (vty, " NLPID : 0x%X", + vty_out (vty, " NLPID : 0x%X\n", lsp->tlv_data.nlpids->nlpids[i]); break; default: - vty_outln (vty, " NLPID : %s", "unknown"); + vty_out (vty, " NLPID : %s\n", "unknown"); break; } } @@ -980,7 +980,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) for (ALL_LIST_ELEMENTS_RO(lsp->tlv_data.mt_router_info, lnode, mt_router_info)) { - vty_outln (vty, " MT : %s%s", + vty_out (vty, " MT : %s%s\n", isis_mtid2str(mt_router_info->mtid), mt_router_info->overload ? " (overload)" : ""); } @@ -991,16 +991,16 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) bzero (hostname, sizeof (hostname)); memcpy (hostname, lsp->tlv_data.hostname->name, lsp->tlv_data.hostname->namelen); - vty_outln (vty, " Hostname : %s", hostname); + vty_out (vty, " Hostname : %s\n", hostname); } /* authentication tlv */ if (lsp->tlv_data.auth_info.type != ISIS_PASSWD_TYPE_UNUSED) { if (lsp->tlv_data.auth_info.type == ISIS_PASSWD_TYPE_HMAC_MD5) - vty_outln (vty, " Auth type : md5"); + vty_out (vty, " Auth type : md5\n"); else if (lsp->tlv_data.auth_info.type == ISIS_PASSWD_TYPE_CLEARTXT) - vty_outln (vty, " Auth type : clear text"); + vty_out (vty, " Auth type : clear text\n"); } /* TE router id */ @@ -1008,14 +1008,14 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) { memcpy (ipv4_address, inet_ntoa (lsp->tlv_data.router_id->id), sizeof (ipv4_address)); - vty_outln (vty, " Router ID : %s", ipv4_address); + vty_out (vty, " Router ID : %s\n", ipv4_address); } if (lsp->tlv_data.ipv4_addrs) for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_addrs, lnode, ipv4_addr)) { memcpy (ipv4_address, inet_ntoa (*ipv4_addr), sizeof (ipv4_address)); - vty_outln (vty, " IPv4 Address: %s", ipv4_address); + vty_out (vty, " IPv4 Address: %s\n", ipv4_address); } /* for the IS neighbor tlv */ @@ -1023,7 +1023,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.is_neighs, lnode, is_neigh)) { lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0); - vty_outln (vty, " Metric : %-8" PRIu8 " IS : %s", + vty_out (vty, " Metric : %-8" PRIu8 " IS : %s\n", is_neigh->metrics.metric_default, LSPid); } @@ -1036,7 +1036,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) sizeof (ipv4_reach_prefix)); memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), sizeof (ipv4_reach_mask)); - vty_outln (vty, " Metric : %-8" PRIu8 " IPv4-Internal : %s %s", + vty_out (vty, " Metric : %-8" PRIu8 " IPv4-Internal : %s %s\n", ipv4_reach->metrics.metric_default, ipv4_reach_prefix, ipv4_reach_mask); } @@ -1050,7 +1050,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) sizeof (ipv4_reach_prefix)); memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), sizeof (ipv4_reach_mask)); - vty_outln (vty, " Metric : %-8" PRIu8 " IPv4-External : %s %s", + vty_out (vty, " Metric : %-8" PRIu8 " IPv4-External : %s %s\n", ipv4_reach->metrics.metric_default, ipv4_reach_prefix, ipv4_reach_mask); } @@ -1079,7 +1079,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.mt_ipv4_reachs, lnode, mt_ipv4_reachs)) lsp_print_mt_ipv4_reach(mt_ipv4_reachs->list, vty, mt_ipv4_reachs->mtid); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return; } diff --git a/isisd/isis_mt.c b/isisd/isis_mt.c index 9c3bc1fe6..26e02498b 100644 --- a/isisd/isis_mt.c +++ b/isisd/isis_mt.c @@ -193,7 +193,7 @@ area_write_mt_settings(struct isis_area *area, struct vty *vty) { if (setting->mtid == ISIS_MT_IPV4_UNICAST) continue; /* always enabled, no need to write out config */ - vty_outln (vty, " topology %s%s", name, + vty_out (vty, " topology %s%s\n", name, setting->overload ? " overload" : ""); written++; } @@ -325,7 +325,7 @@ circuit_write_mt_settings(struct isis_circuit *circuit, struct vty *vty) const char *name = isis_mtid2str(setting->mtid); if (name && !setting->enabled) { - vty_outln (vty, " no isis topology %s", name); + vty_out (vty, " no isis topology %s\n", name); written++; } } diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 25fdf717b..b3f29fd20 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -581,27 +581,27 @@ DEFUN (isis_redistribute, family = str2family(argv[idx_afi]->text); if (family < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; afi = family2afi(family); if (!afi) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; type = proto_redistnum(afi, argv[idx_protocol]->text); if (type < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (!strcmp("level-1", argv[idx_level]->arg)) level = 1; else if (!strcmp("level-2", argv[idx_level]->arg)) level = 2; else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if ((area->is_type & level) != level) { - vty_outln (vty, "Node is not a level-%d IS", level); - return CMD_WARNING; + vty_out (vty, "Node is not a level-%d IS\n", level); + return CMD_WARNING_CONFIG_FAILED; } metric = 0xffffffff; @@ -610,7 +610,7 @@ DEFUN (isis_redistribute, if (argc > idx_metric_rmap + 1) { if (argv[idx_metric_rmap + 1]->arg[0] == '\0') - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (strmatch(argv[idx_metric_rmap]->text, "metric")) { @@ -618,7 +618,7 @@ DEFUN (isis_redistribute, metric = strtoul(argv[idx_metric_rmap + 1]->arg, &endp, 10); if (*endp != '\0') - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } else { @@ -652,15 +652,15 @@ DEFUN (no_isis_redistribute, family = str2family(argv[idx_afi]->arg); if (family < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; afi = family2afi(family); if (!afi) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; type = proto_redistnum(afi, argv[idx_protocol]->text); if (type < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2; @@ -696,14 +696,14 @@ DEFUN (isis_default_originate, family = str2family(argv[idx_afi]->text); if (family < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2; if ((area->is_type & level) != level) { - vty_outln (vty, "Node is not a level-%d IS", level); - return CMD_WARNING; + vty_out (vty, "Node is not a level-%d IS\n", level); + return CMD_WARNING_CONFIG_FAILED; } if (argc > idx_always && strmatch (argv[idx_always]->text, "always")) @@ -722,9 +722,9 @@ DEFUN (isis_default_originate, if (family == AF_INET6 && originate_type != DEFAULT_ORIGINATE_ALWAYS) { - vty_outln (vty, - "Zebra doesn't implement default-originate for IPv6 yet"); - vty_outln (vty, "so use with care or use default-originate always."); + vty_out (vty, + "Zebra doesn't implement default-originate for IPv6 yet\n"); + vty_out (vty, "so use with care or use default-originate always.\n"); } isis_redist_set(area, level, family, DEFAULT_ROUTE, metric, routemap, originate_type); @@ -750,14 +750,14 @@ DEFUN (no_isis_default_originate, family = str2family(argv[idx_afi]->text); if (family < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (strmatch ("level-1", argv[idx_level]->text)) level = 1; else if (strmatch ("level-2", argv[idx_level]->text)) level = 2; else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; isis_redist_unset(area, level, family, DEFAULT_ROUTE); return 0; @@ -796,7 +796,7 @@ isis_redist_config_write(struct vty *vty, struct isis_area *area, vty_out(vty, " metric %u", redist->metric); if (redist->map_name) vty_out(vty, " route-map %s", redist->map_name); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write++; } } @@ -814,7 +814,7 @@ isis_redist_config_write(struct vty *vty, struct isis_area *area, vty_out(vty, " metric %u", redist->metric); if (redist->map_name) vty_out(vty, " route-map %s", redist->map_name); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write++; } diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index f19c81336..4b5592c15 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -1321,8 +1321,8 @@ isis_print_paths (struct vty *vty, struct list *paths, u_char *root_sysid) struct isis_adjacency *adj; char buff[PREFIX2STR_BUFFER]; - vty_outln (vty, - "Vertex Type Metric " "Next-Hop Interface Parent"); + vty_out (vty, + "Vertex Type Metric Next-Hop Interface Parent\n"); for (ALL_LIST_ELEMENTS_RO (paths, node, vertex)) { if (memcmp (vertex->N.id, root_sysid, ISIS_SYS_ID_LEN) == 0) { @@ -1336,7 +1336,7 @@ isis_print_paths (struct vty *vty, struct list *paths, u_char *root_sysid) for (ALL_LIST_ELEMENTS_RO (vertex->Adj_N, anode, adj)) { if (adj) { if (rows) { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, "%-20s %-12s %-6s ", "", "", ""); } vty_out (vty, "%-20s %-9s ", @@ -1356,7 +1356,7 @@ isis_print_paths (struct vty *vty, struct list *paths, u_char *root_sysid) int rows = 0; for (ALL_LIST_ELEMENTS_RO (vertex->parents, pnode, pvertex)) { if (rows) { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, "%-72s", ""); } vty_out (vty, "%s(%d)", @@ -1367,7 +1367,7 @@ isis_print_paths (struct vty *vty, struct list *paths, u_char *root_sysid) vty_out (vty, " NULL "); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } @@ -1396,7 +1396,7 @@ DEFUN (show_isis_topology, for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) { - vty_outln (vty, "Area %s:",area->area_tag ? area->area_tag : "null"); + vty_out (vty, "Area %s:\n",area->area_tag ? area->area_tag : "null"); for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { @@ -1406,23 +1406,23 @@ DEFUN (show_isis_topology, if (area->ip_circuits > 0 && area->spftree[level-1] && area->spftree[level-1]->paths->count > 0) { - vty_outln (vty, "IS-IS paths to level-%d routers that speak IP", + vty_out (vty, "IS-IS paths to level-%d routers that speak IP\n", level); isis_print_paths (vty, area->spftree[level-1]->paths, isis->sysid); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (area->ipv6_circuits > 0 && area->spftree6[level-1] && area->spftree6[level-1]->paths->count > 0) { - vty_outln (vty, - "IS-IS paths to level-%d routers that speak IPv6", + vty_out (vty, + "IS-IS paths to level-%d routers that speak IPv6\n", level); isis_print_paths (vty, area->spftree6[level-1]->paths, isis->sysid); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return CMD_SUCCESS; diff --git a/isisd/isis_te.c b/isisd/isis_te.c index c4a0b9230..271545744 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -685,7 +685,7 @@ show_vty_subtlv_admin_grp (struct vty *vty, struct te_subtlv_admin_grp *tlv) { if (vty != NULL) - vty_outln (vty, " Administrative Group: 0x%x", + vty_out (vty, " Administrative Group: 0x%x\n", (u_int32_t)ntohl(tlv->value)); else zlog_debug (" Administrative Group: 0x%x", @@ -699,8 +699,8 @@ show_vty_subtlv_llri (struct vty *vty, struct te_subtlv_llri *tlv) { if (vty != NULL) { - vty_outln (vty, " Link Local ID: %d",(u_int32_t)ntohl(tlv->local)); - vty_outln (vty, " Link Remote ID: %d", + vty_out (vty, " Link Local ID: %d\n",(u_int32_t)ntohl(tlv->local)); + vty_out (vty, " Link Remote ID: %d\n", (u_int32_t)ntohl(tlv->remote)); } else @@ -716,7 +716,7 @@ static u_char show_vty_subtlv_local_ipaddr (struct vty *vty, struct te_subtlv_local_ipaddr *tlv) { if (vty != NULL) - vty_outln (vty, " Local Interface IP Address(es): %s", + vty_out (vty, " Local Interface IP Address(es): %s\n", inet_ntoa(tlv->value)); else zlog_debug (" Local Interface IP Address(es): %s", inet_ntoa (tlv->value)); @@ -728,7 +728,7 @@ static u_char show_vty_subtlv_rmt_ipaddr (struct vty *vty, struct te_subtlv_rmt_ipaddr *tlv) { if (vty != NULL) - vty_outln (vty, " Remote Interface IP Address(es): %s", + vty_out (vty, " Remote Interface IP Address(es): %s\n", inet_ntoa(tlv->value)); else zlog_debug (" Remote Interface IP Address(es): %s", inet_ntoa (tlv->value)); @@ -744,7 +744,7 @@ show_vty_subtlv_max_bw (struct vty *vty, struct te_subtlv_max_bw *tlv) fval = ntohf (tlv->value); if (vty != NULL) - vty_outln (vty, " Maximum Bandwidth: %g (Bytes/sec)", fval); + vty_out (vty, " Maximum Bandwidth: %g (Bytes/sec)\n", fval); else zlog_debug (" Maximum Bandwidth: %g (Bytes/sec)", fval); @@ -759,7 +759,7 @@ show_vty_subtlv_max_rsv_bw (struct vty *vty, struct te_subtlv_max_rsv_bw *tlv) fval = ntohf (tlv->value); if (vty != NULL) - vty_outln (vty, " Maximum Reservable Bandwidth: %g (Bytes/sec)",fval); + vty_out (vty, " Maximum Reservable Bandwidth: %g (Bytes/sec)\n",fval); else zlog_debug (" Maximum Reservable Bandwidth: %g (Bytes/sec)", fval); @@ -773,7 +773,7 @@ show_vty_subtlv_unrsv_bw (struct vty *vty, struct te_subtlv_unrsv_bw *tlv) int i; if (vty != NULL) - vty_outln (vty, " Unreserved Bandwidth:"); + vty_out (vty, " Unreserved Bandwidth:\n"); else zlog_debug (" Unreserved Bandwidth:"); @@ -782,7 +782,7 @@ show_vty_subtlv_unrsv_bw (struct vty *vty, struct te_subtlv_unrsv_bw *tlv) fval1 = ntohf (tlv->value[i]); fval2 = ntohf (tlv->value[i+1]); if (vty != NULL) - vty_outln (vty, " [%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)", i, fval1, i+1, + vty_out (vty, " [%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", i, fval1, i+1, fval2); else zlog_debug (" [%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)", i, fval1, i+1, fval2); @@ -798,7 +798,7 @@ show_vty_subtlv_te_metric (struct vty *vty, struct te_subtlv_te_metric *tlv) te_metric = tlv->value[2] | tlv->value[1] << 8 | tlv->value[0] << 16; if (vty != NULL) - vty_outln (vty, " Traffic Engineering Metric: %u", te_metric); + vty_out (vty, " Traffic Engineering Metric: %u\n", te_metric); else zlog_debug (" Traffic Engineering Metric: %u", te_metric); @@ -809,7 +809,7 @@ static u_char show_vty_subtlv_ras (struct vty *vty, struct te_subtlv_ras *tlv) { if (vty != NULL) - vty_outln (vty, " Inter-AS TE Remote AS number: %u", + vty_out (vty, " Inter-AS TE Remote AS number: %u\n", ntohl(tlv->value)); else zlog_debug (" Inter-AS TE Remote AS number: %u", ntohl (tlv->value)); @@ -821,7 +821,7 @@ static u_char show_vty_subtlv_rip (struct vty *vty, struct te_subtlv_rip *tlv) { if (vty != NULL) - vty_outln (vty, " Inter-AS TE Remote ASBR IP address: %s", + vty_out (vty, " Inter-AS TE Remote ASBR IP address: %s\n", inet_ntoa(tlv->value)); else zlog_debug (" Inter-AS TE Remote ASBR IP address: %s", inet_ntoa (tlv->value)); @@ -839,7 +839,7 @@ show_vty_subtlv_av_delay (struct vty *vty, struct te_subtlv_av_delay *tlv) A = (u_int32_t) ntohl (tlv->value) & TE_EXT_ANORMAL; if (vty != NULL) - vty_outln (vty, " %s Average Link Delay: %d (micro-sec)", A ? "Anomalous" : "Normal", + vty_out (vty, " %s Average Link Delay: %d (micro-sec)\n", A ? "Anomalous" : "Normal", delay); else zlog_debug (" %s Average Link Delay: %d (micro-sec)", A ? "Anomalous" : "Normal", delay); @@ -858,7 +858,7 @@ show_vty_subtlv_mm_delay (struct vty *vty, struct te_subtlv_mm_delay *tlv) high = (u_int32_t) ntohl (tlv->high) & TE_EXT_MASK; if (vty != NULL) - vty_outln (vty, " %s Min/Max Link Delay: %d / %d (micro-sec)", A ? "Anomalous" : "Normal", low, + vty_out (vty, " %s Min/Max Link Delay: %d / %d (micro-sec)\n", A ? "Anomalous" : "Normal", low, high); else zlog_debug (" %s Min/Max Link Delay: %d / %d (micro-sec)", A ? "Anomalous" : "Normal", low, high); @@ -874,7 +874,7 @@ show_vty_subtlv_delay_var (struct vty *vty, struct te_subtlv_delay_var *tlv) jitter = (u_int32_t) ntohl (tlv->value) & TE_EXT_MASK; if (vty != NULL) - vty_outln (vty, " Delay Variation: %d (micro-sec)", jitter); + vty_out (vty, " Delay Variation: %d (micro-sec)\n", jitter); else zlog_debug (" Delay Variation: %d (micro-sec)", jitter); @@ -893,7 +893,7 @@ show_vty_subtlv_pkt_loss (struct vty *vty, struct te_subtlv_pkt_loss *tlv) A = (u_int32_t) ntohl (tlv->value) & TE_EXT_ANORMAL; if (vty != NULL) - vty_outln (vty, " %s Link Packet Loss: %g (%%)", A ? "Anomalous" : "Normal", + vty_out (vty, " %s Link Packet Loss: %g (%%)\n", A ? "Anomalous" : "Normal", fval); else zlog_debug (" %s Link Packet Loss: %g (%%)", A ? "Anomalous" : "Normal", fval); @@ -909,7 +909,7 @@ show_vty_subtlv_res_bw (struct vty *vty, struct te_subtlv_res_bw *tlv) fval = ntohf(tlv->value); if (vty != NULL) - vty_outln (vty, " Unidirectional Residual Bandwidth: %g (Bytes/sec)", + vty_out (vty, " Unidirectional Residual Bandwidth: %g (Bytes/sec)\n", fval); else zlog_debug (" Unidirectional Residual Bandwidth: %g (Bytes/sec)", fval); @@ -925,7 +925,7 @@ show_vty_subtlv_ava_bw (struct vty *vty, struct te_subtlv_ava_bw *tlv) fval = ntohf (tlv->value); if (vty != NULL) - vty_outln (vty, " Unidirectional Available Bandwidth: %g (Bytes/sec)", + vty_out (vty, " Unidirectional Available Bandwidth: %g (Bytes/sec)\n", fval); else zlog_debug (" Unidirectional Available Bandwidth: %g (Bytes/sec)", fval); @@ -941,7 +941,7 @@ show_vty_subtlv_use_bw (struct vty *vty, struct te_subtlv_use_bw *tlv) fval = ntohf (tlv->value); if (vty != NULL) - vty_outln (vty, " Unidirectional Utilized Bandwidth: %g (Bytes/sec)", + vty_out (vty, " Unidirectional Utilized Bandwidth: %g (Bytes/sec)\n", fval); else zlog_debug (" Unidirectional Utilized Bandwidth: %g (Bytes/sec)", fval); @@ -959,7 +959,7 @@ show_vty_unknown_tlv (struct vty *vty, struct subtlv_header *tlvh) { if (tlvh->length != 0) { - vty_outln (vty, " Unknown TLV: [type(%#.2x), length(%#.2x)]", + vty_out (vty, " Unknown TLV: [type(%#.2x), length(%#.2x)]\n", tlvh->type, tlvh->length); vty_out(vty, " Dump: [00]"); rtn = 1; /* initialize end of line counter */ @@ -968,16 +968,16 @@ show_vty_unknown_tlv (struct vty *vty, struct subtlv_header *tlvh) vty_out (vty, " %#.2x", v[i]); if (rtn == 8) { - vty_out (vty, "%s [%.2x]", VTYNL, i + 1); + vty_out (vty, "\n [%.2x]", i + 1); rtn = 1; } else rtn++; } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } else - vty_outln (vty, " Unknown TLV: [type(%#.2x), length(%#.2x)]", + vty_out (vty, " Unknown TLV: [type(%#.2x), length(%#.2x)]\n", tlvh->type, tlvh->length); } else @@ -1069,8 +1069,8 @@ isis_mpls_te_config_write_router (struct vty *vty) { if (IS_MPLS_TE(isisMplsTE)) { - vty_outln (vty, " mpls-te on"); - vty_outln (vty, " mpls-te router-address %s", + vty_out (vty, " mpls-te on\n"); + vty_out (vty, " mpls-te router-address %s\n", inet_ntoa(isisMplsTE.router_id)); } @@ -1173,8 +1173,8 @@ DEFUN (isis_mpls_te_router_addr, if (! inet_aton (argv[idx_ipv4]->arg, &value)) { - vty_outln (vty, "Please specify Router-Addr by A.B.C.D"); - return CMD_WARNING; + vty_out (vty, "Please specify Router-Addr by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } isisMplsTE.router_id.s_addr = value.s_addr; @@ -1201,7 +1201,7 @@ DEFUN (isis_mpls_te_inter_as, "AREA native mode self originate INTER-AS LSP with L1 and L2 flooding scope)\n" "AS native mode self originate INTER-AS LSP with L2 only flooding scope\n") { - vty_outln (vty, "Not yet supported"); + vty_out (vty, "Not yet supported\n"); return CMD_SUCCESS; } @@ -1213,7 +1213,7 @@ DEFUN (no_isis_mpls_te_inter_as, "Disable MPLS-TE Inter-AS support\n") { - vty_outln (vty, "Not yet supported"); + vty_out (vty, "Not yet supported\n"); return CMD_SUCCESS; } @@ -1227,16 +1227,16 @@ DEFUN (show_isis_mpls_te_router, { if (IS_MPLS_TE(isisMplsTE)) { - vty_outln (vty, "--- MPLS-TE router parameters ---"); + vty_out (vty, "--- MPLS-TE router parameters ---\n"); if (ntohs (isisMplsTE.router_id.s_addr) != 0) - vty_outln (vty, " Router-Address: %s", + vty_out (vty, " Router-Address: %s\n", inet_ntoa(isisMplsTE.router_id)); else - vty_outln (vty, " N/A"); + vty_out (vty, " N/A\n"); } else - vty_outln (vty, " MPLS-TE is disable on this router"); + vty_out (vty, " MPLS-TE is disable on this router\n"); return CMD_SUCCESS; } @@ -1254,21 +1254,21 @@ show_mpls_te_sub (struct vty *vty, struct interface *ifp) { if (IS_INTER_AS(mtc->type)) { - vty_outln (vty, "-- Inter-AS TEv2 link parameters for %s --", + vty_out (vty, "-- Inter-AS TEv2 link parameters for %s --\n", ifp->name); } else { /* MPLS-TE is not activate on this interface */ /* or this interface is passive and Inter-AS TEv2 is not activate */ - vty_outln (vty, " %s: MPLS-TE is disabled on this interface", + vty_out (vty, " %s: MPLS-TE is disabled on this interface\n", ifp->name); return; } } else { - vty_outln (vty, "-- MPLS-TE link parameters for %s --", + vty_out (vty, "-- MPLS-TE link parameters for %s --\n", ifp->name); } @@ -1299,11 +1299,11 @@ show_mpls_te_sub (struct vty *vty, struct interface *ifp) show_vty_subtlv_res_bw (vty, &mtc->res_bw); show_vty_subtlv_ava_bw (vty, &mtc->ava_bw); show_vty_subtlv_use_bw (vty, &mtc->use_bw); - vty_outln (vty, "---------------%s", VTYNL); + vty_out (vty, "---------------\n\n"); } else { - vty_outln (vty, " %s: MPLS-TE is disabled on this interface", + vty_out (vty, " %s: MPLS-TE is disabled on this interface\n", ifp->name); } @@ -1333,7 +1333,7 @@ DEFUN (show_isis_mpls_te_interface, else { if ((ifp = if_lookup_by_name (argv[idx_interface]->arg, VRF_DEFAULT)) == NULL) - vty_outln (vty, "No such interface name"); + vty_out (vty, "No such interface name\n"); else show_mpls_te_sub (vty, ifp); } diff --git a/isisd/isis_vty.c b/isisd/isis_vty.c index f0e2831bf..157962dad 100644 --- a/isisd/isis_vty.c +++ b/isisd/isis_vty.c @@ -40,14 +40,14 @@ isis_circuit_lookup (struct vty *vty) if (!ifp) { - vty_outln (vty, "Invalid interface "); + vty_out (vty, "Invalid interface \n"); return NULL; } circuit = circuit_scan_by_ifp (ifp); if (!circuit) { - vty_outln (vty, "ISIS is not enabled on circuit %s", + vty_out (vty, "ISIS is not enabled on circuit %s\n", ifp->name); return NULL; } @@ -77,7 +77,7 @@ DEFUN (ip_router_isis, { if (strcmp (circuit->area->area_tag, area_tag)) { - vty_outln (vty, "ISIS circuit is already defined on %s", + vty_out (vty, "ISIS circuit is already defined on %s\n", circuit->area->area_tag); return CMD_ERR_NOTHING_TODO; } @@ -92,8 +92,8 @@ DEFUN (ip_router_isis, if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP) { - vty_outln (vty, "Couldn't bring up interface, please check log."); - return CMD_WARNING; + vty_out (vty, "Couldn't bring up interface, please check log.\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -139,7 +139,7 @@ DEFUN (no_ip_router_isis, area = isis_area_lookup (area_tag); if (!area) { - vty_outln (vty, "Can't find ISIS instance %s", + vty_out (vty, "Can't find ISIS instance %s\n", argv[idx_afi]->arg); return CMD_ERR_NO_MATCH; } @@ -147,7 +147,7 @@ DEFUN (no_ip_router_isis, circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); if (!circuit) { - vty_outln (vty, "ISIS is not enabled on circuit %s", + vty_out (vty, "ISIS is not enabled on circuit %s\n", ifp->name); return CMD_ERR_NO_MATCH; } @@ -189,7 +189,7 @@ DEFUN (no_isis_passive, if (if_is_loopback (circuit->interface)) { - vty_outln (vty,"Can't set no passive for loopback interface"); + vty_out (vty,"Can't set no passive for loopback interface\n"); return CMD_ERR_AMBIGUOUS; } @@ -215,7 +215,7 @@ DEFUN (isis_circuit_type, is_type = string2circuit_t (argv[idx_level]->arg); if (!is_type) { - vty_outln (vty, "Unknown circuit-type "); + vty_out (vty, "Unknown circuit-type \n"); return CMD_ERR_AMBIGUOUS; } @@ -223,7 +223,7 @@ DEFUN (isis_circuit_type, circuit->area->is_type != IS_LEVEL_1_AND_2 && circuit->area->is_type != is_type) { - vty_outln (vty, "Invalid circuit level for area %s.", + vty_out (vty, "Invalid circuit level for area %s.\n", circuit->area->area_tag); return CMD_ERR_AMBIGUOUS; } @@ -272,8 +272,8 @@ DEFUN (isis_network, if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_P2P)) { - vty_outln (vty, - "isis network point-to-point " "is valid only on broadcast interfaces"); + vty_out (vty, + "isis network point-to-point is valid only on broadcast interfaces\n"); return CMD_ERR_AMBIGUOUS; } @@ -294,8 +294,8 @@ DEFUN (no_isis_network, if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_BROADCAST)) { - vty_outln (vty, - "isis network point-to-point " "is valid only on broadcast interfaces"); + vty_out (vty, + "isis network point-to-point is valid only on broadcast interfaces\n"); return CMD_ERR_AMBIGUOUS; } @@ -324,7 +324,7 @@ DEFUN (isis_passwd, rv = isis_circuit_passwd_cleartext_set(circuit, argv[idx_word]->arg); if (rv) { - vty_outln (vty, "Too long circuit password (>254)"); + vty_out (vty, "Too long circuit password (>254)\n"); return CMD_ERR_AMBIGUOUS; } @@ -367,7 +367,7 @@ DEFUN (isis_priority, prio = atoi (argv[idx_number]->arg); if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { - vty_outln (vty, "Invalid priority %d - should be <0-127>", + vty_out (vty, "Invalid priority %d - should be <0-127>\n", prio); return CMD_ERR_AMBIGUOUS; } @@ -414,7 +414,7 @@ DEFUN (isis_priority_l1, prio = atoi (argv[idx_number]->arg); if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { - vty_outln (vty, "Invalid priority %d - should be <0-127>", + vty_out (vty, "Invalid priority %d - should be <0-127>\n", prio); return CMD_ERR_AMBIGUOUS; } @@ -460,7 +460,7 @@ DEFUN (isis_priority_l2, prio = atoi (argv[idx_number]->arg); if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { - vty_outln (vty, "Invalid priority %d - should be <0-127>", + vty_out (vty, "Invalid priority %d - should be <0-127>\n", prio); return CMD_ERR_AMBIGUOUS; } @@ -509,8 +509,8 @@ DEFUN (isis_metric, if (circuit->area && circuit->area->oldmetric == 1 && met > MAX_NARROW_LINK_METRIC) { - vty_outln (vty, "Invalid metric %d - should be <0-63> " - "when narrow metric type enabled", + vty_out (vty, "Invalid metric %d - should be <0-63> " + "when narrow metric type enabled\n", met); return CMD_ERR_AMBIGUOUS; } @@ -519,8 +519,8 @@ DEFUN (isis_metric, if (circuit->area && circuit->area->newmetric == 1 && met > MAX_WIDE_LINK_METRIC) { - vty_outln (vty, "Invalid metric %d - should be <0-16777215> " - "when wide metric type enabled", + vty_out (vty, "Invalid metric %d - should be <0-16777215> " + "when wide metric type enabled\n", met); return CMD_ERR_AMBIGUOUS; } @@ -569,8 +569,8 @@ DEFUN (isis_metric_l1, if (circuit->area && circuit->area->oldmetric == 1 && met > MAX_NARROW_LINK_METRIC) { - vty_outln (vty, "Invalid metric %d - should be <0-63> " - "when narrow metric type enabled", + vty_out (vty, "Invalid metric %d - should be <0-63> " + "when narrow metric type enabled\n", met); return CMD_ERR_AMBIGUOUS; } @@ -579,8 +579,8 @@ DEFUN (isis_metric_l1, if (circuit->area && circuit->area->newmetric == 1 && met > MAX_WIDE_LINK_METRIC) { - vty_outln (vty, "Invalid metric %d - should be <0-16777215> " - "when wide metric type enabled", + vty_out (vty, "Invalid metric %d - should be <0-16777215> " + "when wide metric type enabled\n", met); return CMD_ERR_AMBIGUOUS; } @@ -628,8 +628,8 @@ DEFUN (isis_metric_l2, if (circuit->area && circuit->area->oldmetric == 1 && met > MAX_NARROW_LINK_METRIC) { - vty_outln (vty, "Invalid metric %d - should be <0-63> " - "when narrow metric type enabled", + vty_out (vty, "Invalid metric %d - should be <0-63> " + "when narrow metric type enabled\n", met); return CMD_ERR_AMBIGUOUS; } @@ -638,8 +638,8 @@ DEFUN (isis_metric_l2, if (circuit->area && circuit->area->newmetric == 1 && met > MAX_WIDE_LINK_METRIC) { - vty_outln (vty, "Invalid metric %d - should be <0-16777215> " - "when wide metric type enabled", + vty_out (vty, "Invalid metric %d - should be <0-16777215> " + "when wide metric type enabled\n", met); return CMD_ERR_AMBIGUOUS; } @@ -684,7 +684,7 @@ DEFUN (isis_hello_interval, interval = atoi (argv[idx_number]->arg); if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { - vty_outln (vty, "Invalid hello-interval %d - should be <1-600>", + vty_out (vty, "Invalid hello-interval %d - should be <1-600>\n", interval); return CMD_ERR_AMBIGUOUS; } @@ -732,7 +732,7 @@ DEFUN (isis_hello_interval_l1, interval = atoi (argv[idx_number]->arg); if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { - vty_outln (vty, "Invalid hello-interval %ld - should be <1-600>", + vty_out (vty, "Invalid hello-interval %ld - should be <1-600>\n", interval); return CMD_ERR_AMBIGUOUS; } @@ -779,7 +779,7 @@ DEFUN (isis_hello_interval_l2, interval = atoi (argv[idx_number]->arg); if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { - vty_outln (vty, "Invalid hello-interval %ld - should be <1-600>", + vty_out (vty, "Invalid hello-interval %ld - should be <1-600>\n", interval); return CMD_ERR_AMBIGUOUS; } @@ -825,7 +825,7 @@ DEFUN (isis_hello_multiplier, mult = atoi (argv[idx_number]->arg); if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { - vty_outln (vty, "Invalid hello-multiplier %d - should be <2-100>", + vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>\n", mult); return CMD_ERR_AMBIGUOUS; } @@ -873,7 +873,7 @@ DEFUN (isis_hello_multiplier_l1, mult = atoi (argv[idx_number]->arg); if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { - vty_outln (vty, "Invalid hello-multiplier %d - should be <2-100>", + vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>\n", mult); return CMD_ERR_AMBIGUOUS; } @@ -920,7 +920,7 @@ DEFUN (isis_hello_multiplier_l2, mult = atoi (argv[idx_number]->arg); if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { - vty_outln (vty, "Invalid hello-multiplier %d - should be <2-100>", + vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>\n", mult); return CMD_ERR_AMBIGUOUS; } @@ -999,7 +999,7 @@ DEFUN (csnp_interval, interval = atol (argv[idx_number]->arg); if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { - vty_outln (vty, "Invalid csnp-interval %lu - should be <1-600>", + vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>\n", interval); return CMD_ERR_AMBIGUOUS; } @@ -1047,7 +1047,7 @@ DEFUN (csnp_interval_l1, interval = atol (argv[idx_number]->arg); if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { - vty_outln (vty, "Invalid csnp-interval %lu - should be <1-600>", + vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>\n", interval); return CMD_ERR_AMBIGUOUS; } @@ -1094,7 +1094,7 @@ DEFUN (csnp_interval_l2, interval = atol (argv[idx_number]->arg); if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { - vty_outln (vty, "Invalid csnp-interval %lu - should be <1-600>", + vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>\n", interval); return CMD_ERR_AMBIGUOUS; } @@ -1140,7 +1140,7 @@ DEFUN (psnp_interval, interval = atol (argv[idx_number]->arg); if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { - vty_outln (vty, "Invalid psnp-interval %lu - should be <1-120>", + vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>\n", interval); return CMD_ERR_AMBIGUOUS; } @@ -1188,7 +1188,7 @@ DEFUN (psnp_interval_l1, interval = atol (argv[idx_number]->arg); if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { - vty_outln (vty, "Invalid psnp-interval %lu - should be <1-120>", + vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>\n", interval); return CMD_ERR_AMBIGUOUS; } @@ -1235,7 +1235,7 @@ DEFUN (psnp_interval_l2, interval = atol (argv[idx_number]->arg); if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { - vty_outln (vty, "Invalid psnp-interval %lu - should be <1-120>", + vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>\n", interval); return CMD_ERR_AMBIGUOUS; } @@ -1279,14 +1279,14 @@ DEFUN (circuit_topology, if (circuit->area && circuit->area->oldmetric) { - vty_outln (vty, - "Multi topology IS-IS can only be used with wide metrics"); + vty_out (vty, + "Multi topology IS-IS can only be used with wide metrics\n"); return CMD_ERR_AMBIGUOUS; } if (mtid == (uint16_t)-1) { - vty_outln (vty, "Don't know topology '%s'", arg); + vty_out (vty, "Don't know topology '%s'\n", arg); return CMD_ERR_AMBIGUOUS; } @@ -1309,14 +1309,14 @@ DEFUN (no_circuit_topology, if (circuit->area && circuit->area->oldmetric) { - vty_outln (vty, - "Multi topology IS-IS can only be used with wide metrics"); + vty_out (vty, + "Multi topology IS-IS can only be used with wide metrics\n"); return CMD_ERR_AMBIGUOUS; } if (mtid == (uint16_t)-1) { - vty_outln (vty, "Don't know topology '%s'", arg); + vty_out (vty, "Don't know topology '%s'\n", arg); return CMD_ERR_AMBIGUOUS; } @@ -1334,7 +1334,7 @@ validate_metric_style_narrow (struct vty *vty, struct isis_area *area) if (! area) { - vty_outln (vty, "ISIS area is invalid"); + vty_out (vty, "ISIS area is invalid\n"); return CMD_ERR_AMBIGUOUS; } @@ -1344,7 +1344,7 @@ validate_metric_style_narrow (struct vty *vty, struct isis_area *area) (circuit->is_type & IS_LEVEL_1) && (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC)) { - vty_outln (vty, "ISIS circuit %s metric is invalid", + vty_out (vty, "ISIS circuit %s metric is invalid\n", circuit->interface->name); return CMD_ERR_AMBIGUOUS; } @@ -1352,7 +1352,7 @@ validate_metric_style_narrow (struct vty *vty, struct isis_area *area) (circuit->is_type & IS_LEVEL_2) && (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC)) { - vty_outln (vty, "ISIS circuit %s metric is invalid", + vty_out (vty, "ISIS circuit %s metric is invalid\n", circuit->interface->name); return CMD_ERR_AMBIGUOUS; } @@ -1381,8 +1381,8 @@ DEFUN (metric_style, if (area_is_mt(area)) { - vty_outln (vty, - "Narrow metrics cannot be used while multi topology IS-IS is active"); + vty_out (vty, + "Narrow metrics cannot be used while multi topology IS-IS is active\n"); return CMD_ERR_AMBIGUOUS; } @@ -1410,8 +1410,8 @@ DEFUN (no_metric_style, if (area_is_mt(area)) { - vty_outln (vty, - "Narrow metrics cannot be used while multi topology IS-IS is active"); + vty_out (vty, + "Narrow metrics cannot be used while multi topology IS-IS is active\n"); return CMD_ERR_AMBIGUOUS; } @@ -1506,7 +1506,7 @@ static int area_lsp_mtu_set(struct vty *vty, unsigned int lsp_mtu) continue; if(lsp_mtu > isis_circuit_pdu_size(circuit)) { - vty_outln (vty, "ISIS area contains circuit %s, which has a maximum PDU size of %zu.", + vty_out (vty, "ISIS area contains circuit %s, which has a maximum PDU size of %zu.\n", circuit->interface->name,isis_circuit_pdu_size(circuit)); return CMD_ERR_AMBIGUOUS; } @@ -1557,7 +1557,7 @@ DEFUN (is_type, type = string2circuit_t (argv[idx_level]->arg); if (!type) { - vty_outln (vty, "Unknown IS level "); + vty_out (vty, "Unknown IS level \n"); return CMD_SUCCESS; } @@ -1606,8 +1606,8 @@ set_lsp_gen_interval (struct vty *vty, struct isis_area *area, if (interval >= area->lsp_refresh[lvl-1]) { - vty_outln (vty, "LSP gen interval %us must be less than " - "the LSP refresh interval %us", + vty_out (vty, "LSP gen interval %us must be less than " + "the LSP refresh interval %us\n", interval, area->lsp_refresh[lvl - 1]); return CMD_ERR_AMBIGUOUS; } @@ -1845,17 +1845,17 @@ area_max_lsp_lifetime_set(struct vty *vty, int level, if (refresh_interval < area->lsp_refresh[lvl-1]) { - vty_outln (vty, "Level %d Max LSP lifetime %us must be 300s greater than " - "the configured LSP refresh interval %us", + vty_out (vty, "Level %d Max LSP lifetime %us must be 300s greater than " + "the configured LSP refresh interval %us\n", lvl, interval, area->lsp_refresh[lvl - 1]); - vty_outln (vty, "Automatically reducing level %d LSP refresh interval " - "to %us", lvl, refresh_interval); + vty_out (vty, "Automatically reducing level %d LSP refresh interval " + "to %us\n", lvl, refresh_interval); set_refresh_interval[lvl-1] = 1; if (refresh_interval <= area->lsp_gen_interval[lvl-1]) { - vty_outln (vty, "LSP refresh interval %us must be greater than " - "the configured LSP gen interval %us", + vty_out (vty, "LSP refresh interval %us must be greater than " + "the configured LSP gen interval %us\n", refresh_interval,area->lsp_gen_interval[lvl - 1]); return CMD_ERR_AMBIGUOUS; } @@ -1929,15 +1929,15 @@ area_lsp_refresh_interval_set(struct vty *vty, int level, uint16_t interval) continue; if (interval <= area->lsp_gen_interval[lvl-1]) { - vty_outln (vty, "LSP refresh interval %us must be greater than " - "the configured LSP gen interval %us", + vty_out (vty, "LSP refresh interval %us must be greater than " + "the configured LSP gen interval %us\n", interval,area->lsp_gen_interval[lvl - 1]); return CMD_ERR_AMBIGUOUS; } if (interval > (area->max_lsp_lifetime[lvl-1] - 300)) { - vty_outln (vty, "LSP refresh interval %us must be less than " - "the configured LSP lifetime %us less 300", + vty_out (vty, "LSP refresh interval %us must be less than " + "the configured LSP lifetime %us less 300\n", interval,area->max_lsp_lifetime[lvl - 1]); return CMD_ERR_AMBIGUOUS; } @@ -2004,7 +2004,7 @@ area_passwd_set(struct vty *vty, int level, if (passwd && strlen(passwd) > 254) { - vty_outln (vty, "Too long area password (>254)"); + vty_out (vty, "Too long area password (>254)\n"); return CMD_ERR_AMBIGUOUS; } diff --git a/isisd/isisd.c b/isisd/isisd.c index cf3b32513..473b6594e 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -218,7 +218,7 @@ isis_area_destroy (struct vty *vty, const char *area_tag) if (area == NULL) { - vty_outln (vty, "Can't find ISIS instance "); + vty_out (vty, "Can't find ISIS instance \n"); return CMD_ERR_NO_MATCH; } @@ -352,7 +352,7 @@ area_net_title (struct vty *vty, const char *net_title) /* We check that we are not over the maximal number of addresses */ if (listcount (area->area_addrs) >= isis->max_area_addrs) { - vty_outln (vty, "Maximum of area addresses (%d) already reached ", + vty_out (vty, "Maximum of area addresses (%d) already reached \n", isis->max_area_addrs); return CMD_ERR_NOTHING_TODO; } @@ -366,7 +366,7 @@ area_net_title (struct vty *vty, const char *net_title) #endif /* EXTREME_DEBUG */ if (addr->addr_len < 8 || addr->addr_len > 20) { - vty_outln (vty, "area address must be at least 8..20 octets long (%d)", + vty_out (vty, "area address must be at least 8..20 octets long (%d)\n", addr->addr_len); XFREE (MTYPE_ISIS_AREA_ADDR, addr); return CMD_ERR_AMBIGUOUS; @@ -374,7 +374,7 @@ area_net_title (struct vty *vty, const char *net_title) if (addr->area_addr[addr->addr_len-1] != 0) { - vty_outln (vty,"nsel byte (last byte) in area address must be 0"); + vty_out (vty,"nsel byte (last byte) in area address must be 0\n"); XFREE (MTYPE_ISIS_AREA_ADDR, addr); return CMD_ERR_AMBIGUOUS; } @@ -396,8 +396,8 @@ area_net_title (struct vty *vty, const char *net_title) */ if (memcmp (isis->sysid, GETSYSID (addr), ISIS_SYS_ID_LEN)) { - vty_outln (vty, - "System ID must not change when defining additional area" " addresses"); + vty_out (vty, + "System ID must not change when defining additional area addresses\n"); XFREE (MTYPE_ISIS_AREA_ADDR, addr); return CMD_ERR_AMBIGUOUS; } @@ -444,7 +444,7 @@ area_clear_net_title (struct vty *vty, const char *net_title) addr.addr_len = dotformat2buff (buff, net_title); if (addr.addr_len < 8 || addr.addr_len > 20) { - vty_outln (vty, "Unsupported area address length %d, should be 8...20 ", + vty_out (vty, "Unsupported area address length %d, should be 8...20 \n", addr.addr_len); return CMD_ERR_AMBIGUOUS; } @@ -458,7 +458,7 @@ area_clear_net_title (struct vty *vty, const char *net_title) if (!addrp) { - vty_outln (vty, "No area address %s for area %s ", net_title, + vty_out (vty, "No area address %s for area %s \n", net_title, area->area_tag); return CMD_ERR_NO_MATCH; } @@ -493,16 +493,16 @@ show_isis_interface_common (struct vty *vty, const char *ifname, char detail) if (!isis) { - vty_outln (vty, "IS-IS Routing Process not enabled"); + vty_out (vty, "IS-IS Routing Process not enabled\n"); return CMD_SUCCESS; } for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area)) { - vty_outln (vty, "Area %s:", area->area_tag); + vty_out (vty, "Area %s:\n", area->area_tag); if (detail == ISIS_UI_LEVEL_BRIEF) - vty_outln (vty," Interface CircId State Type Level"); + vty_out (vty," Interface CircId State Type Level\n"); for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit)) if (!ifname) @@ -565,7 +565,7 @@ show_isis_neighbor_common (struct vty *vty, const char *id, char detail) if (!isis) { - vty_outln (vty, "IS-IS Routing Process not enabled"); + vty_out (vty, "IS-IS Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -577,7 +577,7 @@ show_isis_neighbor_common (struct vty *vty, const char *id, char detail) dynhn = dynhn_find_by_name (id); if (dynhn == NULL) { - vty_outln (vty, "Invalid system id %s", id); + vty_out (vty, "Invalid system id %s\n", id); return CMD_SUCCESS; } memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN); @@ -586,11 +586,11 @@ show_isis_neighbor_common (struct vty *vty, const char *id, char detail) for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area)) { - vty_outln (vty, "Area %s:", area->area_tag); + vty_out (vty, "Area %s:\n", area->area_tag); if (detail == ISIS_UI_LEVEL_BRIEF) - vty_outln (vty, - " System Id Interface L State" " Holdtime SNPA"); + vty_out (vty, + " System Id Interface L State Holdtime SNPA\n"); for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit)) { @@ -638,7 +638,7 @@ clear_isis_neighbor_common (struct vty *vty, const char *id) if (!isis) { - vty_outln (vty, "IS-IS Routing Process not enabled"); + vty_out (vty, "IS-IS Routing Process not enabled\n"); return CMD_SUCCESS; } @@ -650,7 +650,7 @@ clear_isis_neighbor_common (struct vty *vty, const char *id) dynhn = dynhn_find_by_name (id); if (dynhn == NULL) { - vty_outln (vty, "Invalid system id %s", id); + vty_out (vty, "Invalid system id %s\n", id); return CMD_SUCCESS; } memcpy (sysid, dynhn->id, ISIS_SYS_ID_LEN); @@ -757,35 +757,35 @@ print_debug (struct vty *vty, int flags, int onoff) strcpy (onoffs, "off"); if (flags & DEBUG_ADJ_PACKETS) - vty_outln (vty, "IS-IS Adjacency related packets debugging is %s", + vty_out (vty, "IS-IS Adjacency related packets debugging is %s\n", onoffs); if (flags & DEBUG_CHECKSUM_ERRORS) - vty_outln (vty, "IS-IS checksum errors debugging is %s",onoffs); + vty_out (vty, "IS-IS checksum errors debugging is %s\n",onoffs); if (flags & DEBUG_LOCAL_UPDATES) - vty_outln (vty, "IS-IS local updates debugging is %s",onoffs); + vty_out (vty, "IS-IS local updates debugging is %s\n",onoffs); if (flags & DEBUG_PROTOCOL_ERRORS) - vty_outln (vty, "IS-IS protocol errors debugging is %s",onoffs); + vty_out (vty, "IS-IS protocol errors debugging is %s\n",onoffs); if (flags & DEBUG_SNP_PACKETS) - vty_outln (vty, "IS-IS CSNP/PSNP packets debugging is %s",onoffs); + vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s\n",onoffs); if (flags & DEBUG_SPF_EVENTS) - vty_outln (vty, "IS-IS SPF events debugging is %s", onoffs); + vty_out (vty, "IS-IS SPF events debugging is %s\n", onoffs); if (flags & DEBUG_SPF_STATS) - vty_outln (vty, "IS-IS SPF Timing and Statistics Data debugging is %s", + vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s\n", onoffs); if (flags & DEBUG_SPF_TRIGGERS) - vty_outln (vty, "IS-IS SPF triggering events debugging is %s",onoffs); + vty_out (vty, "IS-IS SPF triggering events debugging is %s\n",onoffs); if (flags & DEBUG_UPDATE_PACKETS) - vty_outln (vty, "IS-IS Update related packet debugging is %s",onoffs); + vty_out (vty, "IS-IS Update related packet debugging is %s\n",onoffs); if (flags & DEBUG_RTE_EVENTS) - vty_outln (vty, "IS-IS Route related debuggin is %s",onoffs); + vty_out (vty, "IS-IS Route related debuggin is %s\n",onoffs); if (flags & DEBUG_EVENTS) - vty_outln (vty, "IS-IS Event debugging is %s", onoffs); + vty_out (vty, "IS-IS Event debugging is %s\n", onoffs); if (flags & DEBUG_PACKET_DUMP) - vty_outln (vty, "IS-IS Packet dump debugging is %s", onoffs); + vty_out (vty, "IS-IS Packet dump debugging is %s\n", onoffs); if (flags & DEBUG_LSP_GEN) - vty_outln (vty, "IS-IS LSP generation debugging is %s", onoffs); + vty_out (vty, "IS-IS LSP generation debugging is %s\n", onoffs); if (flags & DEBUG_LSP_SCHED) - vty_outln (vty, "IS-IS LSP scheduling debugging is %s", onoffs); + vty_out (vty, "IS-IS LSP scheduling debugging is %s\n", onoffs); } DEFUN (show_debugging, @@ -796,7 +796,7 @@ DEFUN (show_debugging, ISIS_STR) { if (isis->debugs) { - vty_outln (vty, "IS-IS:"); + vty_out (vty, "IS-IS:\n"); print_debug (vty, isis->debugs, 1); } return CMD_SUCCESS; @@ -817,72 +817,72 @@ config_write_debug (struct vty *vty) if (flags & DEBUG_ADJ_PACKETS) { - vty_outln (vty, "debug isis adj-packets"); + vty_out (vty, "debug isis adj-packets\n"); write++; } if (flags & DEBUG_CHECKSUM_ERRORS) { - vty_outln (vty, "debug isis checksum-errors"); + vty_out (vty, "debug isis checksum-errors\n"); write++; } if (flags & DEBUG_LOCAL_UPDATES) { - vty_outln (vty, "debug isis local-updates"); + vty_out (vty, "debug isis local-updates\n"); write++; } if (flags & DEBUG_PROTOCOL_ERRORS) { - vty_outln (vty, "debug isis protocol-errors"); + vty_out (vty, "debug isis protocol-errors\n"); write++; } if (flags & DEBUG_SNP_PACKETS) { - vty_outln (vty, "debug isis snp-packets"); + vty_out (vty, "debug isis snp-packets\n"); write++; } if (flags & DEBUG_SPF_EVENTS) { - vty_outln (vty, "debug isis spf-events"); + vty_out (vty, "debug isis spf-events\n"); write++; } if (flags & DEBUG_SPF_STATS) { - vty_outln (vty, "debug isis spf-statistics"); + vty_out (vty, "debug isis spf-statistics\n"); write++; } if (flags & DEBUG_SPF_TRIGGERS) { - vty_outln (vty, "debug isis spf-triggers"); + vty_out (vty, "debug isis spf-triggers\n"); write++; } if (flags & DEBUG_UPDATE_PACKETS) { - vty_outln (vty, "debug isis update-packets"); + vty_out (vty, "debug isis update-packets\n"); write++; } if (flags & DEBUG_RTE_EVENTS) { - vty_outln (vty, "debug isis route-events"); + vty_out (vty, "debug isis route-events\n"); write++; } if (flags & DEBUG_EVENTS) { - vty_outln (vty, "debug isis events"); + vty_out (vty, "debug isis events\n"); write++; } if (flags & DEBUG_PACKET_DUMP) { - vty_outln (vty, "debug isis packet-dump"); + vty_out (vty, "debug isis packet-dump\n"); write++; } if (flags & DEBUG_LSP_GEN) { - vty_outln (vty, "debug isis lsp-gen"); + vty_out (vty, "debug isis lsp-gen\n"); write++; } if (flags & DEBUG_LSP_SCHED) { - vty_outln (vty, "debug isis lsp-sched"); + vty_out (vty, "debug isis lsp-sched\n"); write++; } write += spf_backoff_write_config(vty); @@ -1312,7 +1312,7 @@ DEFUN (show_isis_spf_ietf, { if (!isis) { - vty_outln (vty, "ISIS is not running"); + vty_out (vty, "ISIS is not running\n"); return CMD_SUCCESS; } @@ -1321,31 +1321,31 @@ DEFUN (show_isis_spf_ietf, for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) { - vty_outln (vty, "Area %s:",area->area_tag ? area->area_tag : "null"); + vty_out (vty, "Area %s:\n",area->area_tag ? area->area_tag : "null"); for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { if ((area->is_type & level) == 0) continue; - vty_outln (vty, " Level-%d:", level); + vty_out (vty, " Level-%d:\n", level); vty_out (vty, " SPF delay status: "); if (area->spf_timer[level -1]) { struct timeval remain = thread_timer_remain(area->spf_timer[level - 1]); - vty_outln (vty, "Pending, due in %ld msec", + vty_out (vty, "Pending, due in %ld msec\n", remain.tv_sec * 1000 + remain.tv_usec / 1000); } else { - vty_outln (vty, "Not scheduled"); + vty_out (vty, "Not scheduled\n"); } if (area->spf_delay_ietf[level - 1]) { - vty_outln (vty, " Using draft-ietf-rtgwg-backoff-algo-04"); + vty_out (vty, " Using draft-ietf-rtgwg-backoff-algo-04\n"); spf_backoff_show(area->spf_delay_ietf[level - 1], vty, " "); } else { - vty_outln (vty, " Using legacy backoff algo"); + vty_out (vty, " Using legacy backoff algo\n"); } } } @@ -1364,31 +1364,31 @@ DEFUN (show_isis_summary, if (isis == NULL) { - vty_outln (vty, "ISIS is not running"); + vty_out (vty, "ISIS is not running\n"); return CMD_SUCCESS; } - vty_outln (vty, "Process Id : %ld",isis->process_id); + vty_out (vty, "Process Id : %ld\n",isis->process_id); if (isis->sysid_set) - vty_outln (vty, "System Id : %s",sysid_print(isis->sysid)); + vty_out (vty, "System Id : %s\n",sysid_print(isis->sysid)); vty_out (vty, "Up time : "); vty_out_timestr(vty, isis->uptime); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); if (isis->area_list) - vty_outln (vty, "Number of areas : %d",isis->area_list->count); + vty_out (vty, "Number of areas : %d\n",isis->area_list->count); for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) { - vty_outln (vty, "Area %s:",area->area_tag ? area->area_tag : "null"); + vty_out (vty, "Area %s:\n",area->area_tag ? area->area_tag : "null"); if (listcount (area->area_addrs) > 0) { struct area_addr *area_addr; for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr)) { - vty_outln (vty, " Net: %s", + vty_out (vty, " Net: %s\n", isonet_print(area_addr->area_addr, area_addr->addr_len + ISIS_SYS_ID_LEN + 1)); } } @@ -1398,45 +1398,45 @@ DEFUN (show_isis_summary, if ((area->is_type & level) == 0) continue; - vty_outln (vty, " Level-%d:", level); + vty_out (vty, " Level-%d:\n", level); spftree = area->spftree[level - 1]; if (area->spf_timer[level - 1]) - vty_outln (vty, " SPF: (pending)"); + vty_out (vty, " SPF: (pending)\n"); else - vty_outln (vty, " SPF:"); + vty_out (vty, " SPF:\n"); vty_out (vty, " minimum interval : %d", area->min_spf_interval[level - 1]); if (area->spf_delay_ietf[level - 1]) vty_out (vty, " (not used, IETF SPF delay activated)"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); - vty_outln (vty, " IPv4 route computation:"); + vty_out (vty, " IPv4 route computation:\n"); vty_out (vty, " last run elapsed : "); vty_out_timestr(vty, spftree->last_run_timestamp); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); - vty_outln (vty, " last run duration : %u usec", + vty_out (vty, " last run duration : %u usec\n", (u_int32_t)spftree->last_run_duration); - vty_outln (vty, " run count : %d", + vty_out (vty, " run count : %d\n", spftree->runcount); spftree = area->spftree6[level - 1]; - vty_outln (vty, " IPv6 route computation:"); + vty_out (vty, " IPv6 route computation:\n"); vty_out (vty, " last run elapsed : "); vty_out_timestr(vty, spftree->last_run_timestamp); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); - vty_outln (vty, " last run duration : %llu msec", + vty_out (vty, " last run duration : %llu msec\n", (unsigned long long)spftree->last_run_duration); - vty_outln (vty, " run count : %d", + vty_out (vty, " run count : %d\n", spftree->runcount); } } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -1508,7 +1508,7 @@ show_isis_database (struct vty *vty, const char *argv, int ui_level) for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) { - vty_outln (vty, "Area %s:",area->area_tag ? area->area_tag : "null"); + vty_out (vty, "Area %s:\n",area->area_tag ? area->area_tag : "null"); for (level = 0; level < ISIS_LEVELS; level++) { @@ -1539,12 +1539,12 @@ show_isis_database (struct vty *vty, const char *argv, int ui_level) if (lsp != NULL || argv == NULL) { - vty_outln (vty, "IS-IS Level-%d link-state database:", + vty_out (vty, "IS-IS Level-%d link-state database:\n", level + 1); /* print the title in all cases */ - vty_outln (vty, - "LSP ID PduLen " "SeqNumber Chksum Holdtime ATT/P/OL"); + vty_out (vty, + "LSP ID PduLen SeqNumber Chksum Holdtime ATT/P/OL\n"); } if (lsp) @@ -1560,8 +1560,8 @@ show_isis_database (struct vty *vty, const char *argv, int ui_level) ui_level, area->dynhostname); - vty_outln (vty, " %u LSPs%s", - lsp_count, VTYNL); + vty_out (vty, " %u LSPs\n\n", + lsp_count); } } } @@ -1652,19 +1652,19 @@ DEFUN (isis_topology, if (area->oldmetric) { - vty_outln (vty, - "Multi topology IS-IS can only be used with wide metrics"); + vty_out (vty, + "Multi topology IS-IS can only be used with wide metrics\n"); return CMD_ERR_AMBIGUOUS; } if (mtid == (uint16_t)-1) { - vty_outln (vty, "Don't know topology '%s'", arg); + vty_out (vty, "Don't know topology '%s'\n", arg); return CMD_ERR_AMBIGUOUS; } if (mtid == ISIS_MT_IPV4_UNICAST) { - vty_outln (vty, "Cannot configure IPv4 unicast topology"); + vty_out (vty, "Cannot configure IPv4 unicast topology\n"); return CMD_ERR_AMBIGUOUS; } @@ -1688,19 +1688,19 @@ DEFUN (no_isis_topology, if (area->oldmetric) { - vty_outln (vty, - "Multi topology IS-IS can only be used with wide metrics"); + vty_out (vty, + "Multi topology IS-IS can only be used with wide metrics\n"); return CMD_ERR_AMBIGUOUS; } if (mtid == (uint16_t)-1) { - vty_outln (vty, "Don't know topology '%s'", arg); + vty_out (vty, "Don't know topology '%s'\n", arg); return CMD_ERR_AMBIGUOUS; } if (mtid == ISIS_MT_IPV4_UNICAST) { - vty_outln (vty, "Cannot configure IPv4 unicast topology"); + vty_out (vty, "Cannot configure IPv4 unicast topology\n"); return CMD_ERR_AMBIGUOUS; } @@ -1990,7 +1990,7 @@ isis_config_write (struct vty *vty) for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) { /* ISIS - Area name */ - vty_outln (vty, "router isis %s", area->area_tag); + vty_out (vty, "router isis %s\n", area->area_tag); write++; /* ISIS - Net */ if (listcount (area->area_addrs) > 0) @@ -1998,7 +1998,7 @@ isis_config_write (struct vty *vty) struct area_addr *area_addr; for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr)) { - vty_outln (vty, " net %s", + vty_out (vty, " net %s\n", isonet_print(area_addr->area_addr, area_addr->addr_len + ISIS_SYS_ID_LEN + 1)); write++; } @@ -2007,38 +2007,38 @@ isis_config_write (struct vty *vty) * false. */ if (!area->dynhostname) { - vty_outln (vty, " no hostname dynamic"); + vty_out (vty, " no hostname dynamic\n"); write++; } /* ISIS - Metric-Style - when true displays wide */ if (area->newmetric) { if (!area->oldmetric) - vty_outln (vty, " metric-style wide"); + vty_out (vty, " metric-style wide\n"); else - vty_outln (vty, " metric-style transition"); + vty_out (vty, " metric-style transition\n"); write++; } else { - vty_outln (vty, " metric-style narrow"); + vty_out (vty, " metric-style narrow\n"); write++; } /* ISIS - overload-bit */ if (area->overload_bit) { - vty_outln (vty, " set-overload-bit"); + vty_out (vty, " set-overload-bit\n"); write++; } /* ISIS - Area is-type (level-1-2 is default) */ if (area->is_type == IS_LEVEL_1) { - vty_outln (vty, " is-type level-1"); + vty_out (vty, " is-type level-1\n"); write++; } else if (area->is_type == IS_LEVEL_2) { - vty_outln (vty, " is-type level-2-only"); + vty_out (vty, " is-type level-2-only\n"); write++; } write += isis_redist_config_write(vty, area, AF_INET); @@ -2048,7 +2048,7 @@ isis_config_write (struct vty *vty) { if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL) { - vty_outln (vty, " lsp-gen-interval %d", + vty_out (vty, " lsp-gen-interval %d\n", area->lsp_gen_interval[0]); write++; } @@ -2057,13 +2057,13 @@ isis_config_write (struct vty *vty) { if (area->lsp_gen_interval[0] != DEFAULT_MIN_LSP_GEN_INTERVAL) { - vty_outln (vty, " lsp-gen-interval level-1 %d", + vty_out (vty, " lsp-gen-interval level-1 %d\n", area->lsp_gen_interval[0]); write++; } if (area->lsp_gen_interval[1] != DEFAULT_MIN_LSP_GEN_INTERVAL) { - vty_outln (vty, " lsp-gen-interval level-2 %d", + vty_out (vty, " lsp-gen-interval level-2 %d\n", area->lsp_gen_interval[1]); write++; } @@ -2073,7 +2073,7 @@ isis_config_write (struct vty *vty) { if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME) { - vty_outln (vty, " max-lsp-lifetime %u", + vty_out (vty, " max-lsp-lifetime %u\n", area->max_lsp_lifetime[0]); write++; } @@ -2082,13 +2082,13 @@ isis_config_write (struct vty *vty) { if (area->max_lsp_lifetime[0] != DEFAULT_LSP_LIFETIME) { - vty_outln (vty, " max-lsp-lifetime level-1 %u", + vty_out (vty, " max-lsp-lifetime level-1 %u\n", area->max_lsp_lifetime[0]); write++; } if (area->max_lsp_lifetime[1] != DEFAULT_LSP_LIFETIME) { - vty_outln (vty, " max-lsp-lifetime level-2 %u", + vty_out (vty, " max-lsp-lifetime level-2 %u\n", area->max_lsp_lifetime[1]); write++; } @@ -2098,7 +2098,7 @@ isis_config_write (struct vty *vty) { if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL) { - vty_outln (vty, " lsp-refresh-interval %u", + vty_out (vty, " lsp-refresh-interval %u\n", area->lsp_refresh[0]); write++; } @@ -2107,20 +2107,20 @@ isis_config_write (struct vty *vty) { if (area->lsp_refresh[0] != DEFAULT_MAX_LSP_GEN_INTERVAL) { - vty_outln (vty, " lsp-refresh-interval level-1 %u", + vty_out (vty, " lsp-refresh-interval level-1 %u\n", area->lsp_refresh[0]); write++; } if (area->lsp_refresh[1] != DEFAULT_MAX_LSP_GEN_INTERVAL) { - vty_outln (vty, " lsp-refresh-interval level-2 %u", + vty_out (vty, " lsp-refresh-interval level-2 %u\n", area->lsp_refresh[1]); write++; } } if (area->lsp_mtu != DEFAULT_LSP_MTU) { - vty_outln (vty, " lsp-mtu %u", area->lsp_mtu); + vty_out (vty, " lsp-mtu %u\n", area->lsp_mtu); write++; } @@ -2129,7 +2129,7 @@ isis_config_write (struct vty *vty) { if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL) { - vty_outln (vty, " spf-interval %d", + vty_out (vty, " spf-interval %d\n", area->min_spf_interval[0]); write++; } @@ -2138,13 +2138,13 @@ isis_config_write (struct vty *vty) { if (area->min_spf_interval[0] != MINIMUM_SPF_INTERVAL) { - vty_outln (vty, " spf-interval level-1 %d", + vty_out (vty, " spf-interval level-1 %d\n", area->min_spf_interval[0]); write++; } if (area->min_spf_interval[1] != MINIMUM_SPF_INTERVAL) { - vty_outln (vty, " spf-interval level-2 %d", + vty_out (vty, " spf-interval level-2 %d\n", area->min_spf_interval[1]); write++; } @@ -2153,7 +2153,7 @@ isis_config_write (struct vty *vty) /* IETF SPF interval */ if (area->spf_delay_ietf[0]) { - vty_outln (vty, " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld", + vty_out (vty, " spf-delay-ietf init-delay %ld short-delay %ld long-delay %ld holddown %ld time-to-learn %ld\n", spf_backoff_init_delay(area->spf_delay_ietf[0]), spf_backoff_short_delay(area->spf_delay_ietf[0]), spf_backoff_long_delay(area->spf_delay_ietf[0]), @@ -2174,7 +2174,7 @@ isis_config_write (struct vty *vty) else vty_out(vty, "send-only"); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write++; } else if (area->area_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT) @@ -2188,7 +2188,7 @@ isis_config_write (struct vty *vty) else vty_out(vty, "send-only"); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write++; } if (area->domain_passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5) @@ -2203,7 +2203,7 @@ isis_config_write (struct vty *vty) else vty_out(vty, "send-only"); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write++; } else if (area->domain_passwd.type == ISIS_PASSWD_TYPE_CLEARTXT) @@ -2218,13 +2218,13 @@ isis_config_write (struct vty *vty) else vty_out(vty, "send-only"); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write++; } if (area->log_adj_changes) { - vty_outln (vty, " log-adjacency-changes"); + vty_out (vty, " log-adjacency-changes\n"); write++; } diff --git a/ldpd/ldp_debug.c b/ldpd/ldp_debug.c index 466b6af8b..c9c7160ae 100644 --- a/ldpd/ldp_debug.c +++ b/ldpd/ldp_debug.c @@ -43,7 +43,7 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str, { if (strcmp(type_str, "discovery") == 0) { if (dir_str == NULL) - return (CMD_WARNING); + return (CMD_WARNING_CONFIG_FAILED); if (dir_str[0] == 'r') { if (disable) @@ -68,7 +68,7 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str, DEBUG_ON(event, EVENT); } else if (strcmp(type_str, "messages") == 0) { if (dir_str == NULL) - return (CMD_WARNING); + return (CMD_WARNING_CONFIG_FAILED); if (dir_str[0] == 'r') { if (disable) { @@ -105,29 +105,29 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str, int ldp_vty_show_debugging(struct vty *vty) { - vty_outln (vty, "LDP debugging status:"); + vty_out (vty, "LDP debugging status:\n"); if (LDP_DEBUG(hello, HELLO_RECV)) - vty_outln (vty," LDP discovery debugging is on (inbound)"); + vty_out (vty," LDP discovery debugging is on (inbound)\n"); if (LDP_DEBUG(hello, HELLO_SEND)) - vty_outln (vty," LDP discovery debugging is on (outbound)"); + vty_out (vty," LDP discovery debugging is on (outbound)\n"); if (LDP_DEBUG(errors, ERRORS)) - vty_outln (vty, " LDP errors debugging is on"); + vty_out (vty, " LDP errors debugging is on\n"); if (LDP_DEBUG(event, EVENT)) - vty_outln (vty, " LDP events debugging is on"); + vty_out (vty, " LDP events debugging is on\n"); if (LDP_DEBUG(msg, MSG_RECV_ALL)) - vty_outln (vty, - " LDP detailed messages debugging is on " "(inbound)"); + vty_out (vty, + " LDP detailed messages debugging is on (inbound)\n"); else if (LDP_DEBUG(msg, MSG_RECV)) - vty_outln (vty," LDP messages debugging is on (inbound)"); + vty_out (vty," LDP messages debugging is on (inbound)\n"); if (LDP_DEBUG(msg, MSG_SEND_ALL)) - vty_outln (vty, - " LDP detailed messages debugging is on " "(outbound)"); + vty_out (vty, + " LDP detailed messages debugging is on (outbound)\n"); else if (LDP_DEBUG(msg, MSG_SEND)) - vty_outln (vty," LDP messages debugging is on (outbound)"); + vty_out (vty," LDP messages debugging is on (outbound)\n"); if (LDP_DEBUG(zebra, ZEBRA)) - vty_outln (vty, " LDP zebra debugging is on"); - vty_out (vty, VTYNL); + vty_out (vty, " LDP zebra debugging is on\n"); + vty_out (vty, "\n"); return (CMD_SUCCESS); } @@ -138,43 +138,43 @@ ldp_debug_config_write(struct vty *vty) int write = 0; if (CONF_LDP_DEBUG(hello, HELLO_RECV)) { - vty_outln (vty,"debug mpls ldp discovery hello recv"); + vty_out (vty,"debug mpls ldp discovery hello recv\n"); write = 1; } if (CONF_LDP_DEBUG(hello, HELLO_SEND)) { - vty_outln (vty,"debug mpls ldp discovery hello sent"); + vty_out (vty,"debug mpls ldp discovery hello sent\n"); write = 1; } if (CONF_LDP_DEBUG(errors, ERRORS)) { - vty_outln (vty, "debug mpls ldp errors"); + vty_out (vty, "debug mpls ldp errors\n"); write = 1; } if (CONF_LDP_DEBUG(event, EVENT)) { - vty_outln (vty, "debug mpls ldp event"); + vty_out (vty, "debug mpls ldp event\n"); write = 1; } if (CONF_LDP_DEBUG(msg, MSG_RECV_ALL)) { - vty_outln (vty, "debug mpls ldp messages recv all"); + vty_out (vty, "debug mpls ldp messages recv all\n"); write = 1; } else if (CONF_LDP_DEBUG(msg, MSG_RECV)) { - vty_outln (vty, "debug mpls ldp messages recv"); + vty_out (vty, "debug mpls ldp messages recv\n"); write = 1; } if (CONF_LDP_DEBUG(msg, MSG_SEND_ALL)) { - vty_outln (vty, "debug mpls ldp messages sent all"); + vty_out (vty, "debug mpls ldp messages sent all\n"); write = 1; } else if (CONF_LDP_DEBUG(msg, MSG_SEND)) { - vty_outln (vty, "debug mpls ldp messages sent"); + vty_out (vty, "debug mpls ldp messages sent\n"); write = 1; } if (CONF_LDP_DEBUG(zebra, ZEBRA)) { - vty_outln (vty, "debug mpls ldp zebra"); + vty_out (vty, "debug mpls ldp zebra\n"); write = 1; } diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index 900be046e..4e900ca93 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -115,16 +115,16 @@ ldp_af_iface_config_write(struct vty *vty, int af) if (!ia->enabled) continue; - vty_outln (vty, " !"); - vty_outln (vty, " interface %s", iface->name); + vty_out (vty, " !\n"); + vty_out (vty, " interface %s\n", iface->name); if (ia->hello_holdtime != LINK_DFLT_HOLDTIME && ia->hello_holdtime != 0) - vty_outln (vty, " discovery hello holdtime %u", + vty_out (vty, " discovery hello holdtime %u\n", ia->hello_holdtime); if (ia->hello_interval != DEFAULT_HELLO_INTERVAL && ia->hello_interval != 0) - vty_outln (vty, " discovery hello interval %u", + vty_out (vty, " discovery hello interval %u\n", ia->hello_interval); } } @@ -138,16 +138,16 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf, if (!(af_conf->flags & F_LDPD_AF_ENABLED)) return; - vty_outln (vty, " !"); - vty_outln (vty, " address-family %s", af_name(af)); + vty_out (vty, " !\n"); + vty_out (vty, " address-family %s\n", af_name(af)); if (af_conf->lhello_holdtime != LINK_DFLT_HOLDTIME && af_conf->lhello_holdtime != 0 ) - vty_outln (vty, " discovery hello holdtime %u", + vty_out (vty, " discovery hello holdtime %u\n", af_conf->lhello_holdtime); if (af_conf->lhello_interval != DEFAULT_HELLO_INTERVAL && af_conf->lhello_interval != 0) - vty_outln (vty, " discovery hello interval %u", + vty_out (vty, " discovery hello interval %u\n", af_conf->lhello_interval); if (af_conf->flags & F_LDPD_AF_THELLO_ACCEPT) { @@ -155,24 +155,24 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf, if (af_conf->acl_thello_accept_from[0] != '\0') vty_out(vty, " from %s", af_conf->acl_thello_accept_from); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (af_conf->thello_holdtime != TARGETED_DFLT_HOLDTIME && af_conf->thello_holdtime != 0) - vty_outln (vty, " discovery targeted-hello holdtime %u", + vty_out (vty, " discovery targeted-hello holdtime %u\n", af_conf->thello_holdtime); if (af_conf->thello_interval != DEFAULT_HELLO_INTERVAL && af_conf->thello_interval != 0) - vty_outln (vty, " discovery targeted-hello interval %u", + vty_out (vty, " discovery targeted-hello interval %u\n", af_conf->thello_interval); if (ldp_addrisset(af, &af_conf->trans_addr)) - vty_outln (vty, " discovery transport-address %s", + vty_out (vty, " discovery transport-address %s\n", log_addr(af, &af_conf->trans_addr)); else - vty_outln (vty, - " ! Incomplete config, specify a discovery " "transport-address"); + vty_out (vty, + " ! Incomplete config, specify a discovery transport-address\n"); if ((af_conf->flags & F_LDPD_AF_ALLOCHOSTONLY) || af_conf->acl_label_allocate_for[0] != '\0') { @@ -182,7 +182,7 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf, else vty_out(vty, " for %s", af_conf->acl_label_allocate_for); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (af_conf->acl_label_advertise_for[0] != '\0' || @@ -194,7 +194,7 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf, if (af_conf->acl_label_advertise_for[0] != '\0') vty_out(vty, " for %s", af_conf->acl_label_advertise_for); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (af_conf->flags & F_LDPD_AF_EXPNULL) { @@ -202,7 +202,7 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf, if (af_conf->acl_label_expnull_for[0] != '\0') vty_out(vty, " for %s", af_conf->acl_label_expnull_for); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (af_conf->acl_label_accept_for[0] != '\0' || @@ -214,26 +214,26 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf, if (af_conf->acl_label_accept_for[0] != '\0') vty_out(vty, " for %s", af_conf->acl_label_accept_for); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (af_conf->flags & F_LDPD_AF_NO_GTSM) - vty_outln (vty, " ttl-security disable"); + vty_out (vty, " ttl-security disable\n"); if (af_conf->keepalive != DEFAULT_KEEPALIVE) - vty_outln (vty, " session holdtime %u",af_conf->keepalive); + vty_out (vty, " session holdtime %u\n",af_conf->keepalive); RB_FOREACH(tnbr, tnbr_head, &ldpd_conf->tnbr_tree) { if (tnbr->af == af) { - vty_outln (vty, " !"); - vty_outln (vty, " neighbor %s targeted", + vty_out (vty, " !\n"); + vty_out (vty, " neighbor %s targeted\n", log_addr(tnbr->af, &tnbr->addr)); } } ldp_af_iface_config_write(vty, af); - vty_outln (vty, " !"); + vty_out (vty, " !\n"); } int @@ -244,61 +244,61 @@ ldp_config_write(struct vty *vty) if (!(ldpd_conf->flags & F_LDPD_ENABLED)) return (0); - vty_outln (vty, "mpls ldp"); + vty_out (vty, "mpls ldp\n"); if (ldpd_conf->rtr_id.s_addr != 0) - vty_outln (vty, " router-id %s", + vty_out (vty, " router-id %s\n", inet_ntoa(ldpd_conf->rtr_id)); if (ldpd_conf->lhello_holdtime != LINK_DFLT_HOLDTIME && ldpd_conf->lhello_holdtime != 0) - vty_outln (vty, " discovery hello holdtime %u", + vty_out (vty, " discovery hello holdtime %u\n", ldpd_conf->lhello_holdtime); if (ldpd_conf->lhello_interval != DEFAULT_HELLO_INTERVAL && ldpd_conf->lhello_interval != 0) - vty_outln (vty, " discovery hello interval %u", + vty_out (vty, " discovery hello interval %u\n", ldpd_conf->lhello_interval); if (ldpd_conf->thello_holdtime != TARGETED_DFLT_HOLDTIME && ldpd_conf->thello_holdtime != 0) - vty_outln (vty, " discovery targeted-hello holdtime %u", + vty_out (vty, " discovery targeted-hello holdtime %u\n", ldpd_conf->thello_holdtime); if (ldpd_conf->thello_interval != DEFAULT_HELLO_INTERVAL && ldpd_conf->thello_interval != 0) - vty_outln (vty, " discovery targeted-hello interval %u", + vty_out (vty, " discovery targeted-hello interval %u\n", ldpd_conf->thello_interval); if (ldpd_conf->trans_pref == DUAL_STACK_LDPOV4) - vty_outln (vty, - " dual-stack transport-connection prefer ipv4"); + vty_out (vty, + " dual-stack transport-connection prefer ipv4\n"); if (ldpd_conf->flags & F_LDPD_DS_CISCO_INTEROP) - vty_outln (vty, " dual-stack cisco-interop"); + vty_out (vty, " dual-stack cisco-interop\n"); RB_FOREACH(nbrp, nbrp_head, &ldpd_conf->nbrp_tree) { if (nbrp->flags & F_NBRP_KEEPALIVE) - vty_outln (vty, " neighbor %s session holdtime %u", + vty_out (vty, " neighbor %s session holdtime %u\n", inet_ntoa(nbrp->lsr_id),nbrp->keepalive); if (nbrp->flags & F_NBRP_GTSM) { if (nbrp->gtsm_enabled) - vty_outln (vty, " neighbor %s ttl-security hops " - "%u", inet_ntoa(nbrp->lsr_id), + vty_out (vty, " neighbor %s ttl-security hops " + "%u\n", inet_ntoa(nbrp->lsr_id), nbrp->gtsm_hops); else - vty_outln (vty, " neighbor %s ttl-security " - "disable",inet_ntoa(nbrp->lsr_id)); + vty_out (vty, " neighbor %s ttl-security " + "disable\n",inet_ntoa(nbrp->lsr_id)); } if (nbrp->auth.method == AUTH_MD5SIG) - vty_outln (vty, " neighbor %s password %s", + vty_out (vty, " neighbor %s password %s\n", inet_ntoa(nbrp->lsr_id),nbrp->auth.md5key); } ldp_af_config_write(vty, AF_INET, ldpd_conf, &ldpd_conf->ipv4); ldp_af_config_write(vty, AF_INET6, ldpd_conf, &ldpd_conf->ipv6); - vty_outln (vty, " !"); - vty_outln (vty, "!"); + vty_out (vty, " !\n"); + vty_out (vty, "!\n"); return (1); } @@ -309,34 +309,34 @@ ldp_l2vpn_pw_config_write(struct vty *vty, struct l2vpn_pw *pw) int missing_lsrid = 0; int missing_pwid = 0; - vty_outln (vty, " !"); - vty_outln (vty, " member pseudowire %s", pw->ifname); + vty_out (vty, " !\n"); + vty_out (vty, " member pseudowire %s\n", pw->ifname); if (pw->lsr_id.s_addr != INADDR_ANY) - vty_outln (vty, " neighbor lsr-id %s",inet_ntoa(pw->lsr_id)); + vty_out (vty, " neighbor lsr-id %s\n",inet_ntoa(pw->lsr_id)); else missing_lsrid = 1; if (pw->flags & F_PW_STATIC_NBR_ADDR) - vty_outln (vty, " neighbor address %s", + vty_out (vty, " neighbor address %s\n", log_addr(pw->af, &pw->addr)); if (pw->pwid != 0) - vty_outln (vty, " pw-id %u", pw->pwid); + vty_out (vty, " pw-id %u\n", pw->pwid); else missing_pwid = 1; if (!(pw->flags & F_PW_CWORD_CONF)) - vty_outln (vty, " control-word exclude"); + vty_out (vty, " control-word exclude\n"); if (!(pw->flags & F_PW_STATUSTLV_CONF)) - vty_outln (vty, " pw-status disable"); + vty_out (vty, " pw-status disable\n"); if (missing_lsrid) - vty_outln (vty, - " ! Incomplete config, specify a neighbor " "lsr-id"); + vty_out (vty, + " ! Incomplete config, specify a neighbor lsr-id\n"); if (missing_pwid) - vty_outln (vty," ! Incomplete config, specify a pw-id"); + vty_out (vty," ! Incomplete config, specify a pw-id\n"); } int @@ -347,27 +347,27 @@ ldp_l2vpn_config_write(struct vty *vty) struct l2vpn_pw *pw; RB_FOREACH(l2vpn, l2vpn_head, &ldpd_conf->l2vpn_tree) { - vty_outln (vty, "l2vpn %s type vpls", l2vpn->name); + vty_out (vty, "l2vpn %s type vpls\n", l2vpn->name); if (l2vpn->pw_type != DEFAULT_PW_TYPE) - vty_outln (vty, " vc type ethernet-tagged"); + vty_out (vty, " vc type ethernet-tagged\n"); if (l2vpn->mtu != DEFAULT_L2VPN_MTU) - vty_outln (vty, " mtu %u", l2vpn->mtu); + vty_out (vty, " mtu %u\n", l2vpn->mtu); if (l2vpn->br_ifname[0] != '\0') - vty_outln (vty, " bridge %s",l2vpn->br_ifname); + vty_out (vty, " bridge %s\n",l2vpn->br_ifname); RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree) - vty_outln (vty, " member interface %s",lif->ifname); + vty_out (vty, " member interface %s\n",lif->ifname); RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) ldp_l2vpn_pw_config_write(vty, pw); RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree) ldp_l2vpn_pw_config_write(vty, pw); - vty_outln (vty, " !"); - vty_outln (vty, "!"); + vty_out (vty, " !\n"); + vty_out (vty, "!\n"); } return (0); @@ -434,7 +434,7 @@ ldp_vty_address_family(struct vty *vty, int disable, const char *af_str) af = AF_INET6; af_conf = &vty_conf->ipv6; } else - return (CMD_WARNING); + return (CMD_WARNING_CONFIG_FAILED); if (disable) { af_conf->flags &= ~F_LDPD_AF_ENABLED; @@ -473,8 +473,8 @@ ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str, secs = strtol(seconds_str, &ep, 10); if (*ep != '\0' || secs < MIN_HOLDTIME || secs > MAX_HOLDTIME) { - vty_outln (vty, "%% Invalid holdtime"); - return (CMD_WARNING); + vty_out (vty, "%% Invalid holdtime\n"); + return (CMD_WARNING_CONFIG_FAILED); } if (hello_type_str[0] == 'h') @@ -568,8 +568,8 @@ ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str, secs = strtol(seconds_str, &ep, 10); if (*ep != '\0' || secs < MIN_HELLO_INTERVAL || secs > MAX_HELLO_INTERVAL) { - vty_outln (vty, "%% Invalid interval"); - return (CMD_WARNING); + vty_out (vty, "%% Invalid interval\n"); + return (CMD_WARNING_CONFIG_FAILED); } if (hello_type_str[0] == 'h') @@ -686,13 +686,13 @@ ldp_vty_nbr_session_holdtime(struct vty *vty, int disable, if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 || bad_addr_v4(lsr_id)) { - vty_outln (vty, "%% Malformed address"); - return (CMD_WARNING); + vty_out (vty, "%% Malformed address\n"); + return (CMD_WARNING_CONFIG_FAILED); } secs = strtol(seconds_str, &ep, 10); if (*ep != '\0' || secs < MIN_KEEPALIVE || secs > MAX_KEEPALIVE) { - vty_outln (vty, "%% Invalid holdtime"); + vty_out (vty, "%% Invalid holdtime\n"); return (CMD_SUCCESS); } @@ -732,7 +732,7 @@ ldp_vty_af_session_holdtime(struct vty *vty, int disable, secs = strtol(seconds_str, &ep, 10); if (*ep != '\0' || secs < MIN_KEEPALIVE || secs > MAX_KEEPALIVE) { - vty_outln (vty, "%% Invalid holdtime"); + vty_out (vty, "%% Invalid holdtime\n"); return (CMD_SUCCESS); } @@ -778,7 +778,7 @@ ldp_vty_interface(struct vty *vty, int disable, const char *ifname) if (iface == NULL) { if (ldp_iface_is_configured(vty_conf, ifname)) { - vty_outln (vty,"%% Interface is already in use"); + vty_out (vty,"%% Interface is already in use\n"); return (CMD_SUCCESS); } @@ -825,7 +825,7 @@ ldp_vty_trans_addr(struct vty *vty, int disable, const char *addr_str) else { if (inet_pton(af, addr_str, &af_conf->trans_addr) != 1 || bad_addr(af, &af_conf->trans_addr)) { - vty_outln (vty, "%% Malformed address"); + vty_out (vty, "%% Malformed address\n"); return (CMD_SUCCESS); } } @@ -846,12 +846,12 @@ ldp_vty_neighbor_targeted(struct vty *vty, int disable, const char *addr_str) if (inet_pton(af, addr_str, &addr) != 1 || bad_addr(af, &addr)) { - vty_outln (vty, "%% Malformed address"); - return (CMD_WARNING); + vty_out (vty, "%% Malformed address\n"); + return (CMD_WARNING_CONFIG_FAILED); } if (af == AF_INET6 && IN6_IS_SCOPE_EMBED(&addr.v6)) { - vty_outln (vty, "%% Address can not be link-local"); - return (CMD_WARNING); + vty_out (vty, "%% Address can not be link-local\n"); + return (CMD_WARNING_CONFIG_FAILED); } tnbr = tnbr_find(vty_conf, af, &addr); @@ -1022,7 +1022,7 @@ ldp_vty_router_id(struct vty *vty, int disable, const char *addr_str) else { if (inet_pton(AF_INET, addr_str, &vty_conf->rtr_id) != 1 || bad_addr_v4(vty_conf->rtr_id)) { - vty_outln (vty, "%% Malformed address"); + vty_out (vty, "%% Malformed address\n"); return (CMD_SUCCESS); } } @@ -1068,8 +1068,8 @@ ldp_vty_neighbor_password(struct vty *vty, int disable, const char *lsr_id_str, if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 || bad_addr_v4(lsr_id)) { - vty_outln (vty, "%% Malformed address"); - return (CMD_WARNING); + vty_out (vty, "%% Malformed address\n"); + return (CMD_WARNING_CONFIG_FAILED); } nbrp = nbr_params_find(vty_conf, lsr_id); @@ -1114,14 +1114,14 @@ ldp_vty_neighbor_ttl_security(struct vty *vty, int disable, if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 || bad_addr_v4(lsr_id)) { - vty_outln (vty, "%% Malformed address"); - return (CMD_WARNING); + vty_out (vty, "%% Malformed address\n"); + return (CMD_WARNING_CONFIG_FAILED); } if (hops_str) { hops = strtol(hops_str, &ep, 10); if (*ep != '\0' || hops < 1 || hops > 254) { - vty_outln (vty, "%% Invalid hop count"); + vty_out (vty, "%% Invalid hop count\n"); return (CMD_SUCCESS); } } @@ -1226,8 +1226,8 @@ ldp_vty_l2vpn_mtu(struct vty *vty, int disable, const char *mtu_str) mtu = strtol(mtu_str, &ep, 10); if (*ep != '\0' || mtu < MIN_L2VPN_MTU || mtu > MAX_L2VPN_MTU) { - vty_outln (vty, "%% Invalid MTU"); - return (CMD_WARNING); + vty_out (vty, "%% Invalid MTU\n"); + return (CMD_WARNING_CONFIG_FAILED); } if (disable) @@ -1286,7 +1286,7 @@ ldp_vty_l2vpn_interface(struct vty *vty, int disable, const char *ifname) return (CMD_SUCCESS); if (ldp_iface_is_configured(vty_conf, ifname)) { - vty_outln (vty, "%% Interface is already in use"); + vty_out (vty, "%% Interface is already in use\n"); return (CMD_SUCCESS); } @@ -1329,7 +1329,7 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, int disable, const char *ifname) } if (ldp_iface_is_configured(vty_conf, ifname)) { - vty_outln (vty, "%% Interface is already in use"); + vty_out (vty, "%% Interface is already in use\n"); return (CMD_SUCCESS); } @@ -1373,8 +1373,8 @@ ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, int disable, const char *addr_str) if (ldp_get_address(addr_str, &af, &addr) == -1 || bad_addr(af, &addr)) { - vty_outln (vty, "%% Malformed address"); - return (CMD_WARNING); + vty_out (vty, "%% Malformed address\n"); + return (CMD_WARNING_CONFIG_FAILED); } if (disable) { @@ -1400,8 +1400,8 @@ ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, int disable, const char *lsr_id_str) if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 || bad_addr_v4(lsr_id)) { - vty_outln (vty, "%% Malformed address"); - return (CMD_WARNING); + vty_out (vty, "%% Malformed address\n"); + return (CMD_WARNING_CONFIG_FAILED); } if (disable) @@ -1423,8 +1423,8 @@ ldp_vty_l2vpn_pw_pwid(struct vty *vty, int disable, const char *pwid_str) pwid = strtol(pwid_str, &ep, 10); if (*ep != '\0' || pwid < MIN_PWID_ID || pwid > MAX_PWID_ID) { - vty_outln (vty, "%% Invalid pw-id"); - return (CMD_WARNING); + vty_out (vty, "%% Invalid pw-id\n"); + return (CMD_WARNING_CONFIG_FAILED); } if (disable) diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c index c95606702..bec1375bd 100644 --- a/ldpd/ldp_vty_exec.c +++ b/ldpd/ldp_vty_exec.c @@ -128,14 +128,14 @@ show_interface_msg(struct vty *vty, struct imsg *imsg, snprintf(timers, sizeof(timers), "%u/%u", iface->hello_interval, iface->hello_holdtime); - vty_outln (vty, "%-4s %-11s %-6s %-8s %-12s %3u", + vty_out (vty, "%-4s %-11s %-6s %-8s %-12s %3u\n", af_name(iface->af), iface->name, if_state_name(iface->state), iface->uptime == 0 ? "00:00:00" : log_time(iface->uptime), timers, iface->adj_cnt); break; case IMSG_CTL_END: - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return (1); default: break; @@ -211,13 +211,13 @@ show_discovery_msg(struct vty *vty, struct imsg *imsg, vty_out(vty, "%-8s %-15s ", "Targeted", addr); if (strlen(addr) > 15) - vty_out(vty, "%s%46s", VTYNL, " "); + vty_out(vty, "\n%46s", " "); break; } - vty_outln (vty, "%9u", adj->holdtime); + vty_out (vty, "%9u\n", adj->holdtime); break; case IMSG_CTL_END: - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return (1); default: break; @@ -232,23 +232,23 @@ show_discovery_detail_adj(struct vty *vty, char *buffer, struct ctl_adj *adj) size_t buflen = strlen(buffer); snprintf(buffer + buflen, LDPBUFSIZ - buflen, - " LSR Id: %s:0%s", inet_ntoa(adj->id), VTYNL); + " LSR Id: %s:0\n", inet_ntoa(adj->id)); buflen = strlen(buffer); snprintf(buffer + buflen, LDPBUFSIZ - buflen, - " Source address: %s%s", - log_addr(adj->af, &adj->src_addr), VTYNL); + " Source address: %s\n", + log_addr(adj->af, &adj->src_addr)); buflen = strlen(buffer); snprintf(buffer + buflen, LDPBUFSIZ - buflen, - " Transport address: %s%s", - log_addr(adj->af, &adj->trans_addr), VTYNL); + " Transport address: %s\n", + log_addr(adj->af, &adj->trans_addr)); buflen = strlen(buffer); snprintf(buffer + buflen, LDPBUFSIZ - buflen, - " Hello hold time: %u secs (due in %u secs)%s", - adj->holdtime, adj->holdtime_remaining, VTYNL); + " Hello hold time: %u secs (due in %u secs)\n", + adj->holdtime, adj->holdtime_remaining); buflen = strlen(buffer); snprintf(buffer + buflen, LDPBUFSIZ - buflen, - " Dual-stack capability TLV: %s%s", - (adj->ds_tlv) ? "yes" : "no", VTYNL); + " Dual-stack capability TLV: %s\n", + (adj->ds_tlv) ? "yes" : "no"); } static int @@ -279,8 +279,8 @@ show_discovery_detail_msg(struct vty *vty, struct imsg *imsg, buflen = strlen(ifaces_buffer); snprintf(ifaces_buffer + buflen, LDPBUFSIZ - buflen, - " %s: %s%s", iface->name, (iface->no_adj) ? - "(no adjacencies)" : "", VTYNL); + " %s: %s\n", iface->name, (iface->no_adj) ? + "(no adjacencies)" : ""); break; case IMSG_CTL_SHOW_DISC_TNBR: tnbr = imsg->data; @@ -292,9 +292,9 @@ show_discovery_detail_msg(struct vty *vty, struct imsg *imsg, tnbr->af))->trans_addr; buflen = strlen(tnbrs_buffer); snprintf(tnbrs_buffer + buflen, LDPBUFSIZ - buflen, - " %s -> %s: %s%s", log_addr(tnbr->af, trans_addr), + " %s -> %s: %s\n", log_addr(tnbr->af, trans_addr), log_addr(tnbr->af, &tnbr->addr), (tnbr->no_adj) ? - "(no adjacencies)" : "", VTYNL); + "(no adjacencies)" : ""); break; case IMSG_CTL_SHOW_DISC_ADJ: adj = imsg->data; @@ -313,20 +313,20 @@ show_discovery_detail_msg(struct vty *vty, struct imsg *imsg, break; case IMSG_CTL_END: rtr_id.s_addr = ldp_rtr_id_get(ldpd_conf); - vty_outln (vty, "Local:"); - vty_outln (vty, " LSR Id: %s:0",inet_ntoa(rtr_id)); + vty_out (vty, "Local:\n"); + vty_out (vty, " LSR Id: %s:0\n",inet_ntoa(rtr_id)); if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED) - vty_outln (vty, " Transport Address (IPv4): %s", + vty_out (vty, " Transport Address (IPv4): %s\n", log_addr(AF_INET, &ldpd_conf->ipv4.trans_addr)); if (ldpd_conf->ipv6.flags & F_LDPD_AF_ENABLED) - vty_outln (vty, " Transport Address (IPv6): %s", + vty_out (vty, " Transport Address (IPv6): %s\n", log_addr(AF_INET6, &ldpd_conf->ipv6.trans_addr)); - vty_outln (vty, "Discovery Sources:"); - vty_outln (vty, " Interfaces:"); + vty_out (vty, "Discovery Sources:\n"); + vty_out (vty, " Interfaces:\n"); vty_out(vty, "%s", ifaces_buffer); - vty_outln (vty, " Targeted Hellos:"); + vty_out (vty, " Targeted Hellos:\n"); vty_out(vty, "%s", tnbrs_buffer); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return (1); default: break; @@ -511,8 +511,8 @@ show_nbr_msg(struct vty *vty, struct imsg *imsg, struct show_params *params) af_name(nbr->af), inet_ntoa(nbr->id), nbr_state_name(nbr->nbr_state), addr); if (strlen(addr) > 15) - vty_out(vty, "%s%48s", VTYNL, " "); - vty_outln (vty, " %8s", log_time(nbr->uptime)); + vty_out(vty, "\n%48s", " "); + vty_out (vty, " %8s\n", log_time(nbr->uptime)); break; case IMSG_CTL_END: return (1); @@ -531,12 +531,12 @@ show_nbr_detail_adj(struct vty *vty, char *buffer, struct ctl_adj *adj) switch (adj->type) { case HELLO_LINK: snprintf(buffer + buflen, LDPBUFSIZ - buflen, - " Interface: %s%s", adj->ifname, VTYNL); + " Interface: %s\n", adj->ifname); break; case HELLO_TARGETED: snprintf(buffer + buflen, LDPBUFSIZ - buflen, - " Targeted Hello: %s%s", log_addr(adj->af, - &adj->src_addr), VTYNL); + " Targeted Hello: %s\n", log_addr(adj->af, + &adj->src_addr)); break; } } @@ -557,41 +557,41 @@ show_nbr_detail_msg(struct vty *vty, struct imsg *imsg, v4adjs_buffer[0] = '\0'; v6adjs_buffer[0] = '\0'; - vty_outln (vty, "Peer LDP Identifier: %s:0", + vty_out (vty, "Peer LDP Identifier: %s:0\n", inet_ntoa(nbr->id)); - vty_outln (vty, " TCP connection: %s:%u - %s:%u", + vty_out (vty, " TCP connection: %s:%u - %s:%u\n", log_addr(nbr->af, &nbr->laddr), ntohs(nbr->lport), log_addr(nbr->af, &nbr->raddr),ntohs(nbr->rport)); - vty_outln (vty, " Authentication: %s", + vty_out (vty, " Authentication: %s\n", (nbr->auth_method == AUTH_MD5SIG) ? "TCP MD5 Signature" : "none"); - vty_outln(vty, " Session Holdtime: %u secs; " - "KeepAlive interval: %u secs", nbr->holdtime, + vty_out(vty, " Session Holdtime: %u secs; " + "KeepAlive interval: %u secs\n", nbr->holdtime, nbr->holdtime / KEEPALIVE_PER_PERIOD); - vty_outln(vty, " State: %s; Downstream-Unsolicited", + vty_out(vty, " State: %s; Downstream-Unsolicited\n", nbr_state_name(nbr->nbr_state)); - vty_outln (vty, " Up time: %s",log_time(nbr->uptime)); + vty_out (vty, " Up time: %s\n",log_time(nbr->uptime)); stats = &nbr->stats; - vty_outln (vty, " Messages sent/rcvd:"); - vty_outln (vty, " - Keepalive Messages: %u/%u", + vty_out (vty, " Messages sent/rcvd:\n"); + vty_out (vty, " - Keepalive Messages: %u/%u\n", stats->kalive_sent, stats->kalive_rcvd); - vty_outln (vty, " - Address Messages: %u/%u", + vty_out (vty, " - Address Messages: %u/%u\n", stats->addr_sent, stats->addr_rcvd); - vty_outln (vty, " - Address Withdraw Messages: %u/%u", + vty_out (vty, " - Address Withdraw Messages: %u/%u\n", stats->addrwdraw_sent, stats->addrwdraw_rcvd); - vty_outln (vty, " - Notification Messages: %u/%u", + vty_out (vty, " - Notification Messages: %u/%u\n", stats->notif_sent, stats->notif_rcvd); - vty_outln (vty, " - Capability Messages: %u/%u", + vty_out (vty, " - Capability Messages: %u/%u\n", stats->capability_sent, stats->capability_rcvd); - vty_outln (vty, " - Label Mapping Messages: %u/%u", + vty_out (vty, " - Label Mapping Messages: %u/%u\n", stats->labelmap_sent, stats->labelmap_rcvd); - vty_outln (vty, " - Label Request Messages: %u/%u", + vty_out (vty, " - Label Request Messages: %u/%u\n", stats->labelreq_sent, stats->labelreq_rcvd); - vty_outln (vty, " - Label Withdraw Messages: %u/%u", + vty_out (vty, " - Label Withdraw Messages: %u/%u\n", stats->labelwdraw_sent, stats->labelwdraw_rcvd); - vty_outln (vty, " - Label Release Messages: %u/%u", + vty_out (vty, " - Label Release Messages: %u/%u\n", stats->labelrel_sent, stats->labelrel_rcvd); - vty_outln (vty, " - Label Abort Request Messages: %u/%u", + vty_out (vty, " - Label Abort Request Messages: %u/%u\n", stats->labelabreq_sent, stats->labelabreq_rcvd); show_nbr_capabilities(vty, nbr); @@ -611,16 +611,16 @@ show_nbr_detail_msg(struct vty *vty, struct imsg *imsg, } break; case IMSG_CTL_SHOW_NBR_END: - vty_outln (vty, " LDP Discovery Sources:"); + vty_out (vty, " LDP Discovery Sources:\n"); if (v4adjs_buffer[0] != '\0') { - vty_outln (vty, " IPv4:"); + vty_out (vty, " IPv4:\n"); vty_out(vty, "%s", v4adjs_buffer); } if (v6adjs_buffer[0] != '\0') { - vty_outln (vty, " IPv6:"); + vty_out (vty, " IPv6:\n"); vty_out(vty, "%s", v6adjs_buffer); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); break; case IMSG_CTL_END: return (1); @@ -869,18 +869,17 @@ show_nbr_detail_msg_json(struct imsg *imsg, struct show_params *params, void show_nbr_capabilities(struct vty *vty, struct ctl_nbr *nbr) { - vty_outln (vty, " Capabilities Sent:%s" - " - Dynamic Announcement (0x0506)%s" - " - Typed Wildcard (0x050B)%s" - " - Unrecognized Notification (0x0603)", - VTYNL, VTYNL, VTYNL); - vty_outln (vty, " Capabilities Received:"); + vty_out (vty, " Capabilities Sent:\n" + " - Dynamic Announcement (0x0506)\n" + " - Typed Wildcard (0x050B)\n" + " - Unrecognized Notification (0x0603)\n"); + vty_out (vty, " Capabilities Received:\n"); if (nbr->flags & F_NBR_CAP_DYNAMIC) - vty_outln (vty," - Dynamic Announcement (0x0506)"); + vty_out (vty," - Dynamic Announcement (0x0506)\n"); if (nbr->flags & F_NBR_CAP_TWCARD) - vty_outln (vty, " - Typed Wildcard (0x050B)"); + vty_out (vty, " - Typed Wildcard (0x050B)\n"); if (nbr->flags & F_NBR_CAP_UNOTIF) - vty_outln (vty," - Unrecognized Notification (0x0603)"); + vty_out (vty," - Unrecognized Notification (0x0603)\n"); } static int @@ -895,13 +894,13 @@ show_nbr_capabilities_msg(struct vty *vty, struct imsg *imsg, struct show_params if (nbr->nbr_state != NBR_STA_OPER) break; - vty_outln (vty, "Peer LDP Identifier: %s:0", + vty_out (vty, "Peer LDP Identifier: %s:0\n", inet_ntoa(nbr->id)); show_nbr_capabilities(vty, nbr); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); break; case IMSG_CTL_END: - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return (1); default: break; @@ -1021,13 +1020,13 @@ show_lib_msg(struct vty *vty, struct imsg *imsg, struct show_params *params) vty_out(vty, "%-4s %-20s", af_name(rt->af), dstnet); if (strlen(dstnet) > 20) - vty_out(vty, "%s%25s", VTYNL, " "); - vty_outln (vty, " %-15s %-11s %-13s %6s", inet_ntoa(rt->nexthop), + vty_out(vty, "\n%25s", " "); + vty_out (vty, " %-15s %-11s %-13s %6s\n", inet_ntoa(rt->nexthop), log_label(rt->local_label), log_label(rt->remote_label), rt->in_use ? "yes" : "no"); break; case IMSG_CTL_END: - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return (1); default: break; @@ -1069,37 +1068,37 @@ show_lib_detail_msg(struct vty *vty, struct imsg *imsg, struct show_params *para snprintf(dstnet, sizeof(dstnet), "%s/%d", log_addr(rt->af, &rt->prefix), rt->prefixlen); - vty_outln (vty, "%s", dstnet); - vty_outln (vty, "%-8sLocal binding: label: %s", "", + vty_out (vty, "%s\n", dstnet); + vty_out (vty, "%-8sLocal binding: label: %s\n", "", log_label(rt->local_label)); break; case IMSG_CTL_SHOW_LIB_SENT: upstream = 1; buflen = strlen(sent_buffer); snprintf(sent_buffer + buflen, LDPBUFSIZ - buflen, - "%12s%s:0%s", "", inet_ntoa(rt->nexthop), VTYNL); + "%12s%s:0\n", "", inet_ntoa(rt->nexthop)); break; case IMSG_CTL_SHOW_LIB_RCVD: downstream = 1; buflen = strlen(rcvd_buffer); snprintf(rcvd_buffer + buflen, LDPBUFSIZ - buflen, - "%12s%s:0, label %s%s%s", "", inet_ntoa(rt->nexthop), + "%12s%s:0, label %s%s\n", "", inet_ntoa(rt->nexthop), log_label(rt->remote_label), - rt->in_use ? " (in use)" : "", VTYNL); + rt->in_use ? " (in use)" : ""); break; case IMSG_CTL_SHOW_LIB_END: if (upstream) { - vty_outln (vty, "%-8sAdvertised to:", ""); + vty_out (vty, "%-8sAdvertised to:\n", ""); vty_out(vty, "%s", sent_buffer); } if (downstream) { - vty_outln (vty, "%-8sRemote bindings:", ""); + vty_out (vty, "%-8sRemote bindings:\n", ""); vty_out(vty, "%s", rcvd_buffer); } else - vty_outln (vty, "%-8sNo remote bindings",""); + vty_out (vty, "%-8sNo remote bindings\n",""); break; case IMSG_CTL_END: - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return (1); default: break; @@ -1235,33 +1234,33 @@ show_l2vpn_binding_msg(struct vty *vty, struct imsg *imsg, case IMSG_CTL_SHOW_L2VPN_BINDING: pw = imsg->data; - vty_outln (vty, " Destination Address: %s, VC ID: %u", + vty_out (vty, " Destination Address: %s, VC ID: %u\n", inet_ntoa(pw->lsr_id), pw->pwid); /* local binding */ if (pw->local_label != NO_LABEL) { - vty_outln (vty, " Local Label: %u", + vty_out (vty, " Local Label: %u\n", pw->local_label); - vty_outln (vty, "%-8sCbit: %u, VC Type: %s, " - "GroupID: %u", "", pw->local_cword, + vty_out (vty, "%-8sCbit: %u, VC Type: %s, " + "GroupID: %u\n", "", pw->local_cword, pw_type_name(pw->type),pw->local_gid); - vty_outln (vty, "%-8sMTU: %u", "",pw->local_ifmtu); + vty_out (vty, "%-8sMTU: %u\n", "",pw->local_ifmtu); } else - vty_outln (vty," Local Label: unassigned"); + vty_out (vty," Local Label: unassigned\n"); /* remote binding */ if (pw->remote_label != NO_LABEL) { - vty_outln (vty, " Remote Label: %u", + vty_out (vty, " Remote Label: %u\n", pw->remote_label); - vty_outln (vty, "%-8sCbit: %u, VC Type: %s, " - "GroupID: %u", "", pw->remote_cword, + vty_out (vty, "%-8sCbit: %u, VC Type: %s, " + "GroupID: %u\n", "", pw->remote_cword, pw_type_name(pw->type),pw->remote_gid); - vty_outln (vty, "%-8sMTU: %u", "",pw->remote_ifmtu); + vty_out (vty, "%-8sMTU: %u\n", "",pw->remote_ifmtu); } else - vty_outln (vty," Remote Label: unassigned"); + vty_out (vty," Remote Label: unassigned\n"); break; case IMSG_CTL_END: - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return (1); default: break; @@ -1340,12 +1339,12 @@ show_l2vpn_pw_msg(struct vty *vty, struct imsg *imsg, struct show_params *params case IMSG_CTL_SHOW_L2VPN_PW: pw = imsg->data; - vty_outln (vty, "%-9s %-15s %-10u %-16s %-10s", pw->ifname, + vty_out (vty, "%-9s %-15s %-10u %-16s %-10s\n", pw->ifname, inet_ntoa(pw->lsr_id), pw->pwid, pw->l2vpn_name, (pw->status ? "UP" : "DOWN")); break; case IMSG_CTL_END: - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return (1); default: break; @@ -1540,7 +1539,7 @@ ldp_vty_dispatch(struct vty *vty, struct imsgbuf *ibuf, enum show_command cmd, done: close(ibuf->fd); if (json) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -1584,7 +1583,7 @@ ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json) params.json = json; if (!params.detail && !params.json) - vty_outln (vty, "%-4s %-20s %-15s %-11s %-13s %6s", "AF", + vty_out (vty, "%-4s %-20s %-15s %-11s %-13s %6s\n", "AF", "Destination", "Nexthop", "Local Label", "Remote Label", "In Use"); @@ -1612,7 +1611,7 @@ ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail, params.json = json; if (!params.detail && !params.json) - vty_outln (vty, "%-4s %-15s %-8s %-15s %9s", + vty_out (vty, "%-4s %-15s %-8s %-15s %9s\n", "AF", "ID", "Type", "Source", "Holdtime"); if (params.detail) @@ -1643,7 +1642,7 @@ ldp_vty_show_interface(struct vty *vty, const char *af_str, int json) /* header */ if (!params.json) { - vty_outln (vty, "%-4s %-11s %-6s %-8s %-12s %3s", "AF", + vty_out (vty, "%-4s %-11s %-6s %-8s %-12s %3s\n", "AF", "Interface", "State", "Uptime", "Hello Timers","ac"); } @@ -1688,18 +1687,17 @@ ldp_vty_show_capabilities(struct vty *vty, int json) "0x0603"); json_object_array_add(json_array, json_cap); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); return (0); } - vty_outln (vty, - "Supported LDP Capabilities%s" - " * Dynamic Announcement (0x0506)%s" - " * Typed Wildcard (0x050B)%s" - " * Unrecognized Notification (0x0603)%s", VTYNL, - VTYNL, VTYNL, VTYNL); + vty_out (vty, + "Supported LDP Capabilities\n" + " * Dynamic Announcement (0x0506)\n" + " * Typed Wildcard (0x050B)\n" + " * Unrecognized Notification (0x0603)\n\n"); return (0); } @@ -1722,7 +1720,7 @@ ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json) params.detail = 1; if (!params.detail && !params.json) - vty_outln (vty, "%-4s %-15s %-11s %-15s %8s", + vty_out (vty, "%-4s %-15s %-11s %-15s %8s\n", "AF", "ID", "State", "Remote Address","Uptime"); imsg_compose(&ibuf, IMSG_CTL_SHOW_NBR, 0, 0, -1, NULL, 0); @@ -1759,9 +1757,9 @@ ldp_vty_show_atom_vc(struct vty *vty, int json) if (!params.json) { /* header */ - vty_outln (vty, "%-9s %-15s %-10s %-16s %-10s", + vty_out (vty, "%-9s %-15s %-10s %-16s %-10s\n", "Interface", "Peer ID", "VC ID", "Name","Status"); - vty_outln (vty, "%-9s %-15s %-10s %-16s %-10s", + vty_out (vty, "%-9s %-15s %-10s %-16s %-10s\n", "---------", "---------------", "----------", "----------------", "----------"); } @@ -1780,7 +1778,7 @@ ldp_vty_clear_nbr(struct vty *vty, const char *addr_str) if (addr_str && (ldp_get_address(addr_str, &nbr.af, &nbr.raddr) == -1 || bad_addr(nbr.af, &nbr.raddr))) { - vty_outln (vty, "%% Malformed address"); + vty_out (vty, "%% Malformed address\n"); return (CMD_WARNING); } diff --git a/lib/agentx.c b/lib/agentx.c index d058779af..30c03e6cf 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -168,7 +168,7 @@ static int config_write_agentx (struct vty *vty) { if (agentx_enabled) - vty_outln (vty, "agentx"); + vty_out (vty, "agentx\n"); return 1; } @@ -185,7 +185,7 @@ DEFUN (agentx_enable, agentx_enabled = 1; return CMD_SUCCESS; } - vty_outln (vty, "SNMP AgentX already enabled"); + vty_out (vty, "SNMP AgentX already enabled\n"); return CMD_SUCCESS; } @@ -196,8 +196,8 @@ DEFUN (no_agentx, "SNMP AgentX protocol settings\n") { if (!agentx_enabled) return CMD_SUCCESS; - vty_outln (vty, "SNMP AgentX support cannot be disabled once enabled"); - return CMD_WARNING; + vty_out (vty, "SNMP AgentX support cannot be disabled once enabled\n"); + return CMD_WARNING_CONFIG_FAILED; } void @@ -394,8 +394,8 @@ bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, int bfd_tag, } else { - vty_outln (vty, " %s%sDetect Mul: %d, Min Rx interval: %d," - " Min Tx interval: %d", + vty_out (vty, " %s%sDetect Mul: %d, Min Rx interval: %d," + " Min Tx interval: %d\n", (extra_space) ? " ": "", (bfd_tag) ? "BFD: " : " ", bfd_info->detect_mult, bfd_info->required_min_rx, bfd_info->desired_min_tx); @@ -423,7 +423,7 @@ bfd_show_status(struct vty *vty, struct bfd_info *bfd_info, int bfd_tag, } else { - vty_outln (vty, " %s%sStatus: %s, Last update: %s", + vty_out (vty, " %s%sStatus: %s, Last update: %s\n", (extra_space) ? " ": "", (bfd_tag) ? "BFD: " : " ", bfd_get_status_str(bfd_info->status), time_buf); } @@ -451,7 +451,7 @@ bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, int multihop, } else { - vty_outln (vty, " %sBFD: Type: %s", (extra_space) ? " " : "", + vty_out (vty, " %sBFD: Type: %s\n", (extra_space) ? " " : "", (multihop) ? "multi hop" : "single hop"); } @@ -461,7 +461,7 @@ bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, int multihop, if (use_json) json_object_object_add(json_obj, "peerBfdInfo", json_bfd); else - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* diff --git a/lib/buffer.c b/lib/buffer.c index 649677fc9..5d458901e 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -199,6 +199,50 @@ buffer_putstr (struct buffer *b, const char *c) buffer_put(b, c, strlen(c)); } +/* Expand \n to \r\n */ +void +buffer_put_crlf(struct buffer *b, const void *origp, size_t origsize) +{ + struct buffer_data *data = b->tail; + const char *p = origp, *end = p + origsize, *lf; + size_t size; + + lf = memchr(p, '\n', end - p); + + /* We use even last one byte of data buffer. */ + while (p < end) + { + size_t avail, chunk; + + /* If there is no data buffer add it. */ + if (data == NULL || data->cp == b->size) + data = buffer_add (b); + + size = (lf ? lf : end) - p; + avail = b->size - data->cp; + + chunk = (size <= avail) ? size : avail; + memcpy (data->data + data->cp, p, chunk); + + p += chunk; + data->cp += chunk; + + if (lf && size <= avail) + { + /* we just copied up to (including) a '\n' */ + if (data->cp == b->size) + data = buffer_add (b); + data->data[data->cp++] = '\r'; + if (data->cp == b->size) + data = buffer_add (b); + data->data[data->cp++] = '\n'; + + p++; + lf = memchr(p, '\n', end - p); + } + } +} + /* Keep flushing data to the fd until the buffer is empty or an error is encountered or the operation would block. */ buffer_status_t diff --git a/lib/buffer.h b/lib/buffer.h index 67ac71cad..059f2cf33 100644 --- a/lib/buffer.h +++ b/lib/buffer.h @@ -41,6 +41,8 @@ extern void buffer_put (struct buffer *, const void *, size_t); extern void buffer_putc (struct buffer *, u_char); /* Add a NUL-terminated string to the end of the buffer. */ extern void buffer_putstr (struct buffer *, const char *); +/* Add given data, inline-expanding \n to \r\n */ +extern void buffer_put_crlf(struct buffer *b, const void *p, size_t size); /* Combine all accumulated (and unflushed) data inside the buffer into a single NUL-terminated string allocated using XMALLOC(MTYPE_TMP). Note diff --git a/lib/command.c b/lib/command.c index 5ca4a0fda..a631cf1c6 100644 --- a/lib/command.c +++ b/lib/command.c @@ -433,27 +433,27 @@ static int config_write_host (struct vty *vty) { if (host.name) - vty_outln (vty, "hostname %s", host.name); + vty_out (vty, "hostname %s\n", host.name); if (host.encrypt) { if (host.password_encrypt) - vty_outln (vty, "password 8 %s", host.password_encrypt); + vty_out (vty, "password 8 %s\n", host.password_encrypt); if (host.enable_encrypt) - vty_outln (vty, "enable password 8 %s", host.enable_encrypt); + vty_out (vty, "enable password 8 %s\n", host.enable_encrypt); } else { if (host.password) - vty_outln (vty, "password %s", host.password); + vty_out (vty, "password %s\n", host.password); if (host.enable) - vty_outln (vty, "enable password %s", host.enable); + vty_out (vty, "enable password %s\n", host.enable); } if (zlog_default->default_lvl != LOG_DEBUG) { - vty_outln (vty,"! N.B. The 'log trap' command is deprecated."); - vty_outln (vty, "log trap %s", + vty_out (vty,"! N.B. The 'log trap' command is deprecated.\n"); + vty_out (vty, "log trap %s\n", zlog_priority[zlog_default->default_lvl]); } @@ -463,7 +463,7 @@ config_write_host (struct vty *vty) if (zlog_default->maxlvl[ZLOG_DEST_FILE] != zlog_default->default_lvl) vty_out (vty, " %s", zlog_priority[zlog_default->maxlvl[ZLOG_DEST_FILE]]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != ZLOG_DISABLED) @@ -472,13 +472,13 @@ config_write_host (struct vty *vty) if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != zlog_default->default_lvl) vty_out (vty, " %s", zlog_priority[zlog_default->maxlvl[ZLOG_DEST_STDOUT]]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED) - vty_outln (vty,"no log monitor"); + vty_out (vty,"no log monitor\n"); else if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] != zlog_default->default_lvl) - vty_outln (vty,"log monitor %s", + vty_out (vty,"log monitor %s\n", zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]]); if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != ZLOG_DISABLED) @@ -487,33 +487,33 @@ config_write_host (struct vty *vty) if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != zlog_default->default_lvl) vty_out (vty, " %s", zlog_priority[zlog_default->maxlvl[ZLOG_DEST_SYSLOG]]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (zlog_default->facility != LOG_DAEMON) - vty_outln (vty, "log facility %s", + vty_out (vty, "log facility %s\n", facility_name(zlog_default->facility)); if (zlog_default->record_priority == 1) - vty_outln (vty, "log record-priority"); + vty_out (vty, "log record-priority\n"); if (zlog_default->timestamp_precision > 0) - vty_outln (vty, "log timestamp precision %d", + vty_out (vty, "log timestamp precision %d\n", zlog_default->timestamp_precision); if (host.advanced) - vty_outln (vty, "service advanced-vty"); + vty_out (vty, "service advanced-vty\n"); if (host.encrypt) - vty_outln (vty, "service password-encryption"); + vty_out (vty, "service password-encryption\n"); if (host.lines >= 0) - vty_outln (vty, "service terminal-length %d",host.lines); + vty_out (vty, "service terminal-length %d\n",host.lines); if (host.motdfile) - vty_outln (vty, "banner motd file %s", host.motdfile); + vty_out (vty, "banner motd file %s\n", host.motdfile); else if (! host.motd) - vty_outln (vty, "no banner motd"); + vty_out (vty, "no banner motd\n"); return 1; } @@ -715,6 +715,40 @@ cmd_variable_complete (struct cmd_token *token, const char *arg, vector comps) vector_free(tmpcomps); } +#define AUTOCOMP_INDENT 5 + +char * +cmd_variable_comp2str(vector comps, unsigned short cols) +{ + size_t bsz = 16; + char *buf = XCALLOC(MTYPE_TMP, bsz); + int lc = AUTOCOMP_INDENT; + size_t cs = AUTOCOMP_INDENT; + size_t itemlen; + snprintf(buf, bsz, "%*s", AUTOCOMP_INDENT, ""); + for (size_t j = 0; j < vector_active (comps); j++) + { + char *item = vector_slot (comps, j); + itemlen = strlen(item); + + if (cs + itemlen + AUTOCOMP_INDENT + 3 >= bsz) + buf = XREALLOC(MTYPE_TMP, buf, (bsz *= 2)); + + if (lc + itemlen + 1 >= cols) + { + cs += snprintf(&buf[cs], bsz - cs, "\n%*s", AUTOCOMP_INDENT, ""); + lc = AUTOCOMP_INDENT; + } + + size_t written = snprintf(&buf[cs], bsz - cs, "%s ", item); + lc += written; + cs += written; + XFREE (MTYPE_COMPLETION, item); + vector_set_index (comps, j, NULL); + } + return buf; +} + void cmd_variable_handler_register (const struct cmd_variable_handler *cvh) { @@ -875,6 +909,9 @@ node_parent ( enum node_type node ) case BGP_IPV6L_NODE: ret = BGP_NODE; break; + case BGP_EVPN_VNI_NODE: + ret = BGP_EVPN_NODE; + break; case KEYCHAIN_KEY_NODE: ret = KEYCHAIN_NODE; break; @@ -1149,8 +1186,8 @@ DEFUN (config_terminal, vty->node = CONFIG_NODE; else { - vty_outln (vty, "VTY configuration is locked by other VTY"); - return CMD_WARNING; + vty_out (vty, "VTY configuration is locked by other VTY\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -1244,6 +1281,9 @@ cmd_exit (struct vty *vty) case BGP_IPV6L_NODE: vty->node = BGP_NODE; break; + case BGP_EVPN_VNI_NODE: + vty->node = BGP_EVPN_NODE; + break; case LDP_IPV4_NODE: case LDP_IPV6_NODE: vty->node = LDP_NODE; @@ -1312,6 +1352,7 @@ DEFUN (config_end, case BGP_IPV6_NODE: case BGP_IPV6M_NODE: case BGP_EVPN_NODE: + case BGP_EVPN_VNI_NODE: case BGP_IPV6L_NODE: case RMAP_NODE: case OSPF_NODE: @@ -1346,10 +1387,10 @@ DEFUN (show_version, SHOW_STR "Displays zebra version\n") { - vty_outln (vty, "%s %s (%s).", FRR_FULL_NAME, FRR_VERSION, + vty_out (vty, "%s %s (%s).\n", FRR_FULL_NAME, FRR_VERSION, host.name ? host.name : ""); - vty_outln (vty, "%s%s", FRR_COPYRIGHT, GIT_INFO); - vty_outln (vty, "configured with:%s %s", VTYNL, + vty_out (vty, "%s%s\n", FRR_COPYRIGHT, GIT_INFO); + vty_out (vty, "configured with:\n %s\n", FRR_CONFIG_ARGS); return CMD_SUCCESS; @@ -1373,21 +1414,19 @@ DEFUN (config_help, "help", "Description of the interactive help system\n") { - vty_outln (vty, - "Quagga VTY provides advanced help feature. When you need help,%s\ -anytime at the command line please press '?'.%s\ -%s\ -If nothing matches, the help list will be empty and you must backup%s\ - until entering a '?' shows the available options.%s\ -Two styles of help are provided:%s\ -1. Full help is available when you are ready to enter a%s\ -command argument (e.g. 'show ?') and describes each possible%s\ -argument.%s\ -2. Partial help is provided when an abbreviated argument is entered%s\ - and you want to know what arguments match the input%s\ - (e.g. 'show me?'.)%s", VTYNL, VTYNL, VTYNL, - VTYNL, VTYNL, VTYNL, VTYNL, VTYNL, - VTYNL, VTYNL, VTYNL, VTYNL); + vty_out (vty, + "Quagga VTY provides advanced help feature. When you need help,\n\ +anytime at the command line please press '?'.\n\ +\n\ +If nothing matches, the help list will be empty and you must backup\n\ + until entering a '?' shows the available options.\n\ +Two styles of help are provided:\n\ +1. Full help is available when you are ready to enter a\n\ +command argument (e.g. 'show ?') and describes each possible\n\ +argument.\n\ +2. Partial help is provided when an abbreviated argument is entered\n\ + and you want to know what arguments match the input\n\ + (e.g. 'show me?'.)\n\n"); return CMD_SUCCESS; } @@ -1421,7 +1460,7 @@ permute (struct graph_node *start, struct vty *vty) } if (gn == start) vty_out (vty, "..."); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } else { @@ -1455,7 +1494,7 @@ cmd_list_cmds (struct vty *vty, int do_permute) if ((element = vector_slot (node->cmd_vector, i)) && element->attr != CMD_ATTR_DEPRECATED && element->attr != CMD_ATTR_HIDDEN) - vty_outln (vty, " %s", element->string); + vty_out (vty, " %s\n", element->string); } return CMD_SUCCESS; } @@ -1488,25 +1527,25 @@ vty_write_config (struct vty *vty) if (vty->type == VTY_TERM) { - vty_outln (vty, "%sCurrent configuration:",VTYNL); - vty_outln (vty, "!"); + vty_out (vty, "\nCurrent configuration:\n"); + vty_out (vty, "!\n"); } - vty_outln (vty, "frr version %s", FRR_VER_SHORT); - vty_outln (vty, "frr defaults %s", DFLT_NAME); - vty_outln (vty, "!"); + vty_out (vty, "frr version %s\n", FRR_VER_SHORT); + vty_out (vty, "frr defaults %s\n", DFLT_NAME); + vty_out (vty, "!\n"); for (i = 0; i < vector_active (cmdvec); i++) if ((node = vector_slot (cmdvec, i)) && node->func && (node->vtysh || vty->type != VTY_SHELL)) { if ((*node->func) (vty)) - vty_outln (vty, "!"); + vty_out (vty, "!\n"); } if (vty->type == VTY_TERM) { - vty_outln (vty, "end"); + vty_out (vty, "end\n"); } } @@ -1543,7 +1582,7 @@ DEFUN (config_write, /* Check and see if we are operating under vtysh configuration */ if (host.config == NULL) { - vty_outln (vty,"Can't save to configuration file, using vtysh."); + vty_out (vty,"Can't save to configuration file, using vtysh.\n"); return CMD_WARNING; } @@ -1578,12 +1617,12 @@ DEFUN (config_write, fd = mkstemp (config_file_tmp); if (fd < 0) { - vty_outln (vty, "Can't open configuration file %s.",config_file_tmp); + vty_out (vty, "Can't open configuration file %s.\n",config_file_tmp); goto finished; } if (fchmod (fd, CONFIGFILE_MASK) != 0) { - vty_outln (vty, "Can't chmod configuration file %s: %s (%d).", + vty_out (vty, "Can't chmod configuration file %s: %s (%d).\n", config_file_tmp, safe_strerror(errno), errno); goto finished; } @@ -1605,13 +1644,13 @@ DEFUN (config_write, if (unlink (config_file_sav) != 0) if (errno != ENOENT) { - vty_outln (vty, "Can't unlink backup configuration file %s.", + vty_out (vty, "Can't unlink backup configuration file %s.\n", config_file_sav); goto finished; } if (link (config_file, config_file_sav) != 0) { - vty_outln (vty, "Can't backup old configuration file %s.", + vty_out (vty, "Can't backup old configuration file %s.\n", config_file_sav); goto finished; } @@ -1620,13 +1659,13 @@ DEFUN (config_write, } if (rename (config_file_tmp, config_file) != 0) { - vty_outln (vty, "Can't save configuration file %s.",config_file); + vty_out (vty, "Can't save configuration file %s.\n",config_file); goto finished; } if (dirfd >= 0) fsync (dirfd); - vty_outln (vty, "Configuration saved to %s",config_file); + vty_out (vty, "Configuration saved to %s\n",config_file); ret = CMD_SUCCESS; finished: @@ -1681,7 +1720,7 @@ DEFUN (show_startup_config, confp = fopen (host.config, "r"); if (confp == NULL) { - vty_outln (vty, "Can't open configuration file [%s] due to '%s'", + vty_out (vty, "Can't open configuration file [%s] due to '%s'\n", host.config, safe_strerror(errno)); return CMD_WARNING; } @@ -1694,7 +1733,7 @@ DEFUN (show_startup_config, cp++; *cp = '\0'; - vty_outln (vty, "%s", buf); + vty_out (vty, "%s\n", buf); } fclose (confp); @@ -1721,8 +1760,8 @@ DEFUN (config_hostname, if (!isalpha((int) word->arg[0])) { - vty_outln (vty, "Please specify string starting with alphabet"); - return CMD_WARNING; + vty_out (vty, "Please specify string starting with alphabet\n"); + return CMD_WARNING_CONFIG_FAILED; } return cmd_hostname_set (word->arg); @@ -1761,9 +1800,9 @@ DEFUN (config_password, if (!isalnum (argv[idx_8]->arg[0])) { - vty_outln (vty, - "Please specify string starting with alphanumeric"); - return CMD_WARNING; + vty_out (vty, + "Please specify string starting with alphanumeric\n"); + return CMD_WARNING_CONFIG_FAILED; } if (host.password) @@ -1811,16 +1850,16 @@ DEFUN (config_enable_password, } else { - vty_outln (vty, "Unknown encryption type."); - return CMD_WARNING; + vty_out (vty, "Unknown encryption type.\n"); + return CMD_WARNING_CONFIG_FAILED; } } if (!isalnum (argv[idx_8]->arg[0])) { - vty_outln (vty, - "Please specify string starting with alphanumeric"); - return CMD_WARNING; + vty_out (vty, + "Please specify string starting with alphanumeric\n"); + return CMD_WARNING_CONFIG_FAILED; } if (host.enable) @@ -1968,7 +2007,7 @@ DEFUN_HIDDEN (do_echo, { char *message; - vty_outln (vty, "%s", + vty_out (vty, "%s\n", ((message = argv_concat(argv, argc, 1)) ? message : "")); if (message) XFREE(MTYPE_TMP, message); @@ -2012,7 +2051,7 @@ DEFUN (show_logging, vty_out (vty, "level %s, facility %s, ident %s", zlog_priority[zl->maxlvl[ZLOG_DEST_SYSLOG]], facility_name(zl->facility), zl->ident); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, "Stdout logging: "); if (zl->maxlvl[ZLOG_DEST_STDOUT] == ZLOG_DISABLED) @@ -2020,7 +2059,7 @@ DEFUN (show_logging, else vty_out (vty, "level %s", zlog_priority[zl->maxlvl[ZLOG_DEST_STDOUT]]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, "Monitor logging: "); if (zl->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED) @@ -2028,7 +2067,7 @@ DEFUN (show_logging, else vty_out (vty, "level %s", zlog_priority[zl->maxlvl[ZLOG_DEST_MONITOR]]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, "File logging: "); if ((zl->maxlvl[ZLOG_DEST_FILE] == ZLOG_DISABLED) || @@ -2038,13 +2077,13 @@ DEFUN (show_logging, vty_out (vty, "level %s, filename %s", zlog_priority[zl->maxlvl[ZLOG_DEST_FILE]], zl->filename); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); - vty_outln (vty, "Protocol name: %s", + vty_out (vty, "Protocol name: %s\n", zl->protoname); - vty_outln (vty, "Record priority: %s", + vty_out (vty, "Record priority: %s\n", (zl->record_priority ? "enabled" : "disabled")); - vty_outln (vty, "Timestamp precision: %d", + vty_out (vty, "Timestamp precision: %d\n", zl->timestamp_precision); return CMD_SUCCESS; @@ -2134,14 +2173,14 @@ set_log_file(struct vty *vty, const char *fname, int loglevel) if (getcwd (cwd, MAXPATHLEN) == NULL) { zlog_err ("config_log_file: Unable to alloc mem!"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if ( (p = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (fname) + 2)) == NULL) { zlog_err ("config_log_file: Unable to alloc mem!"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } sprintf (p, "%s/%s", cwd, fname); fullpath = p; @@ -2157,7 +2196,7 @@ set_log_file(struct vty *vty, const char *fname, int loglevel) if (!ret) { vty_out (vty, "can't open logfile %s\n", fname); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (host.logfile) @@ -2371,7 +2410,7 @@ cmd_banner_motd_file (const char *file) host.motdfile = XSTRDUP (MTYPE_HOST, file); } else - success = CMD_WARNING; + success = CMD_WARNING_CONFIG_FAILED; return success; } @@ -2390,7 +2429,7 @@ DEFUN (banner_motd_file, if (cmd == CMD_ERR_NO_FILE) vty_out (vty, "%s does not exist", filename); - else if (cmd == CMD_WARNING) + else if (cmd == CMD_WARNING_CONFIG_FAILED) vty_out (vty, "%s must be in %s", filename, SYSCONFDIR); return cmd; diff --git a/lib/command.h b/lib/command.h index 927c04006..4c2c5716b 100644 --- a/lib/command.h +++ b/lib/command.h @@ -136,6 +136,7 @@ enum node_type MPLS_NODE, /* MPLS config node */ VTY_NODE, /* Vty node. */ LINK_PARAMS_NODE, /* Link-parameters node */ + BGP_EVPN_VNI_NODE, /* BGP EVPN VNI */ }; /* Node which has some commands and prompt string and configuration @@ -178,6 +179,7 @@ struct cmd_node #define CMD_SUCCESS_DAEMON 10 #define CMD_ERR_NO_FILE 11 #define CMD_SUSPEND 12 +#define CMD_WARNING_CONFIG_FAILED 13 /* Argc max counts. */ #define CMD_ARGC_MAX 25 @@ -293,6 +295,7 @@ struct cmd_node */ #define CMD_CREATE_STR(s) CMD_CREATE_STR_HELPER(s) #define CMD_CREATE_STR_HELPER(s) #s +#define CMD_RANGE_STR(a,s) "(" CMD_CREATE_STR(a) "-" CMD_CREATE_STR(s) ")" /* Common descriptions. */ #define SHOW_STR "Show running system information\n" @@ -404,5 +407,6 @@ struct cmd_variable_handler { extern void cmd_variable_complete (struct cmd_token *token, const char *arg, vector comps); extern void cmd_variable_handler_register (const struct cmd_variable_handler *cvh); +extern char *cmd_variable_comp2str (vector comps, unsigned short cols); #endif /* _ZEBRA_COMMAND_H */ diff --git a/lib/distribute.c b/lib/distribute.c index 79d7b18ff..34ccfb4c7 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -349,8 +349,8 @@ DEFUN (no_distribute_list, if (! ret) { - vty_outln (vty, "distribute list doesn't exist"); - return CMD_WARNING; + vty_out (vty, "distribute list doesn't exist\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -393,9 +393,9 @@ config_show_distribute (struct vty *vty) DISTRIBUTE_V6_OUT, has_print); } if (has_print) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); else - vty_outln (vty, " not set"); + vty_out (vty, " not set\n"); for (i = 0; i < disthash->size; i++) for (mp = disthash->index[i]; mp; mp = mp->next) @@ -414,9 +414,9 @@ config_show_distribute (struct vty *vty) has_print = distribute_print(vty, dist->prefix, 1, DISTRIBUTE_V6_OUT, has_print); if (has_print) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); else - vty_outln (vty, " nothing"); + vty_out (vty, " nothing\n"); } } @@ -437,9 +437,9 @@ config_show_distribute (struct vty *vty) DISTRIBUTE_V6_IN, has_print); } if (has_print) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); else - vty_outln (vty, " not set"); + vty_out (vty, " not set\n"); for (i = 0; i < disthash->size; i++) for (mp = disthash->index[i]; mp; mp = mp->next) @@ -458,9 +458,9 @@ config_show_distribute (struct vty *vty) has_print = distribute_print(vty, dist->prefix, 1, DISTRIBUTE_V6_IN, has_print); if (has_print) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); else - vty_outln (vty, " nothing"); + vty_out (vty, " nothing\n"); } } return 0; @@ -487,7 +487,7 @@ config_write_distribute (struct vty *vty) if (dist->list[j]) { output = j == DISTRIBUTE_V4_OUT || j == DISTRIBUTE_V6_OUT; v6 = j == DISTRIBUTE_V6_IN || j == DISTRIBUTE_V6_OUT; - vty_outln (vty, " %sdistribute-list %s %s %s", + vty_out (vty, " %sdistribute-list %s %s %s\n", v6 ? "ipv6 " : "", dist->list[j], output ? "out" : "in", @@ -499,7 +499,7 @@ config_write_distribute (struct vty *vty) if (dist->prefix[j]) { output = j == DISTRIBUTE_V4_OUT || j == DISTRIBUTE_V6_OUT; v6 = j == DISTRIBUTE_V6_IN || j == DISTRIBUTE_V6_OUT; - vty_outln (vty, " %sdistribute-list prefix %s %s %s", + vty_out (vty, " %sdistribute-list prefix %s %s %s\n", v6 ? "ipv6 " : "", dist->prefix[j], output ? "out" : "in", diff --git a/lib/filter.c b/lib/filter.c index 3cef49b2d..c1e922f5b 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -576,8 +576,8 @@ vty_access_list_remark_unset (struct vty *vty, afi_t afi, const char *name) access = access_list_lookup (afi, name); if (! access) { - vty_outln (vty, "%% access-list %s doesn't exist",name); - return CMD_WARNING; + vty_out (vty, "%% access-list %s doesn't exist\n",name); + return CMD_WARNING_CONFIG_FAILED; } if (access->remark) @@ -615,22 +615,22 @@ filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str, type = FILTER_DENY; else { - vty_outln (vty, "%% filter type must be permit or deny"); - return CMD_WARNING; + vty_out (vty, "%% filter type must be permit or deny\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = inet_aton (addr_str, &addr); if (ret <= 0) { - vty_outln (vty,"%%Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty,"%%Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = inet_aton (addr_mask_str, &addr_mask); if (ret <= 0) { - vty_outln (vty,"%%Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty,"%%Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } if (extended) @@ -638,15 +638,15 @@ filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str, ret = inet_aton (mask_str, &mask); if (ret <= 0) { - vty_outln (vty,"%%Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty,"%%Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = inet_aton (mask_mask_str, &mask_mask); if (ret <= 0) { - vty_outln (vty,"%%Inconsistent address and mask"); - return CMD_WARNING; + vty_out (vty,"%%Inconsistent address and mask\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -1256,10 +1256,10 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str, if (strlen(name_str) > ACL_NAMSIZ) { - vty_outln (vty, "%% ACL name %s is invalid: length exceeds " - "%d characters", + vty_out (vty, "%% ACL name %s is invalid: length exceeds " + "%d characters\n", name_str, ACL_NAMSIZ); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Check of filter type. */ @@ -1269,8 +1269,8 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str, type = FILTER_DENY; else { - vty_outln (vty, "filter type must be [permit|deny]"); - return CMD_WARNING; + vty_out (vty, "filter type must be [permit|deny]\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Check string format of prefix and prefixlen. */ @@ -1279,8 +1279,8 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str, ret = str2prefix_ipv4 (prefix_str, (struct prefix_ipv4 *)&p); if (ret <= 0) { - vty_outln (vty,"IP address prefix/prefixlen is malformed"); - return CMD_WARNING; + vty_out (vty,"IP address prefix/prefixlen is malformed\n"); + return CMD_WARNING_CONFIG_FAILED; } } else if (afi == AFI_IP6) @@ -1288,12 +1288,12 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str, ret = str2prefix_ipv6 (prefix_str, (struct prefix_ipv6 *) &p); if (ret <= 0) { - vty_outln (vty,"IPv6 address prefix/prefixlen is malformed"); - return CMD_WARNING; + vty_out (vty,"IPv6 address prefix/prefixlen is malformed\n"); + return CMD_WARNING_CONFIG_FAILED; } } else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; mfilter = filter_new (); mfilter->type = type; @@ -1424,8 +1424,8 @@ DEFUN (no_access_list_all, access = access_list_lookup (AFI_IP, argv[idx_acl]->arg); if (access == NULL) { - vty_outln (vty, "%% access-list %s doesn't exist",argv[idx_acl]->arg); - return CMD_WARNING; + vty_out (vty, "%% access-list %s doesn't exist\n",argv[idx_acl]->arg); + return CMD_WARNING_CONFIG_FAILED; } master = access->master; @@ -1601,8 +1601,8 @@ DEFUN (no_ipv6_access_list_all, access = access_list_lookup (AFI_IP6, argv[idx_word]->arg); if (access == NULL) { - vty_outln (vty, "%% access-list %s doesn't exist",argv[idx_word]->arg); - return CMD_WARNING; + vty_out (vty, "%% access-list %s doesn't exist\n",argv[idx_word]->arg); + return CMD_WARNING_CONFIG_FAILED; } master = access->master; @@ -1688,7 +1688,7 @@ filter_show (struct vty *vty, const char *name, afi_t afi) return 0; /* Print the name of the protocol */ - vty_outln (vty, "%s:", frr_protoname); + vty_out (vty, "%s:\n", frr_protoname); for (access = master->num.head; access; access = access->next) { @@ -1703,7 +1703,7 @@ filter_show (struct vty *vty, const char *name, afi_t afi) if (write) { - vty_outln (vty, "%s IP%s access list %s", + vty_out (vty, "%s IP%s access list %s\n", mfilter->cisco ? (filter->extended ? "Extended" : "Standard") : "Zebra", afi == AFI_IP6 ? "v6" : "", @@ -1721,13 +1721,13 @@ filter_show (struct vty *vty, const char *name, afi_t afi) else { if (filter->addr_mask.s_addr == 0xffffffff) - vty_outln (vty, " any"); + vty_out (vty, " any\n"); else { vty_out (vty, " %s", inet_ntoa (filter->addr)); if (filter->addr_mask.s_addr != 0) vty_out (vty, ", wildcard bits %s", inet_ntoa (filter->addr_mask)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } } @@ -1746,7 +1746,7 @@ filter_show (struct vty *vty, const char *name, afi_t afi) if (write) { - vty_outln (vty, "%s IP%s access list %s", + vty_out (vty, "%s IP%s access list %s\n", mfilter->cisco ? (filter->extended ? "Extended" : "Standard") : "Zebra", afi == AFI_IP6 ? "v6" : "", @@ -1764,13 +1764,13 @@ filter_show (struct vty *vty, const char *name, afi_t afi) else { if (filter->addr_mask.s_addr == 0xffffffff) - vty_outln (vty, " any"); + vty_out (vty, " any\n"); else { vty_out (vty, " %s", inet_ntoa (filter->addr)); if (filter->addr_mask.s_addr != 0) vty_out (vty, ", wildcard bits %s", inet_ntoa (filter->addr_mask)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } } @@ -1855,18 +1855,18 @@ config_write_access_cisco (struct vty *vty, struct filter *mfilter) vty_out (vty, " %s", inet_ntoa (filter->mask)); vty_out (vty, " %s", inet_ntoa (filter->mask_mask)); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } else { if (filter->addr_mask.s_addr == 0xffffffff) - vty_outln (vty, " any"); + vty_out (vty, " any\n"); else { vty_out (vty, " %s", inet_ntoa (filter->addr)); if (filter->addr_mask.s_addr != 0) vty_out (vty, " %s", inet_ntoa (filter->addr_mask)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } } @@ -1889,7 +1889,7 @@ config_write_access_zebra (struct vty *vty, struct filter *mfilter) p->prefixlen, filter->exact ? " exact-match" : ""); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } static int @@ -1908,7 +1908,7 @@ config_write_access (struct vty *vty, afi_t afi) { if (access->remark) { - vty_outln (vty, "%saccess-list %s remark %s", + vty_out (vty, "%saccess-list %s remark %s\n", afi == AFI_IP ? "" : "ipv6 ", access->name,access->remark); write++; @@ -1934,7 +1934,7 @@ config_write_access (struct vty *vty, afi_t afi) { if (access->remark) { - vty_outln (vty, "%saccess-list %s remark %s", + vty_out (vty, "%saccess-list %s remark %s\n", afi == AFI_IP ? "" : "ipv6 ", access->name,access->remark); write++; diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index 9bb672dc5..9f4c071ab 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -50,6 +50,12 @@ init_cmdgraph (struct vty *, struct graph **); /** shim interface commands **/ struct graph *nodegraph = NULL, *nodegraph_free = NULL; +#define check_nodegraph() \ + do { if (!nodegraph) { \ + vty_out(vty, "nodegraph not initialized\n"); \ + return CMD_WARNING; \ + } } while (0) + DEFUN (grammar_test, grammar_test_cmd, "grammar parse LINE...", @@ -57,6 +63,8 @@ DEFUN (grammar_test, "parse a command\n" "command to pass to new parser\n") { + check_nodegraph(); + int idx_command = 2; // make a string from tokenized command line char *command = argv_concat (argv, argc, idx_command); @@ -85,6 +93,8 @@ DEFUN (grammar_test_complete, "attempt to complete input on DFA\n" "command to complete\n") { + check_nodegraph(); + int idx_command = 2; char *cmdstr = argv_concat (argv, argc, idx_command); if (!cmdstr) @@ -118,7 +128,7 @@ DEFUN (grammar_test_complete, // print completions for (i = 0; i < vector_active (comps); i++) { tkn = vector_slot (comps, i); - vty_outln (vty, " %-*s %s", width, tkn->text, tkn->desc); + vty_out (vty, " %-*s %s\n", width, tkn->text, tkn->desc); } for (i = 0; i < vector_active (comps); i++) @@ -126,7 +136,7 @@ DEFUN (grammar_test_complete, vector_free (comps); } else - vty_outln (vty, "%% No match"); + vty_out (vty, "%% No match\n"); // free resources list_delete (completions); @@ -143,6 +153,8 @@ DEFUN (grammar_test_match, "attempt to match input on DFA\n" "command to match\n") { + check_nodegraph(); + int idx_command = 2; if (argv[2]->arg[0] == '#') return CMD_SUCCESS; @@ -164,13 +176,13 @@ DEFUN (grammar_test_match, // print completions or relevant error message if (element) { - vty_outln (vty, "Matched: %s", element->string); + vty_out (vty, "Matched: %s\n", element->string); struct listnode *ln; struct cmd_token *token; for (ALL_LIST_ELEMENTS_RO(argvv,ln,token)) - vty_outln (vty, "%s -- %s", token->text, token->arg); + vty_out (vty, "%s -- %s\n", token->text, token->arg); - vty_outln (vty, "func: %p", element->func); + vty_out (vty, "func: %p\n", element->func); list_delete (argvv); } @@ -178,16 +190,16 @@ DEFUN (grammar_test_match, assert(MATCHER_ERROR(result)); switch (result) { case MATCHER_NO_MATCH: - vty_outln (vty, "%% Unknown command"); + vty_out (vty, "%% Unknown command\n"); break; case MATCHER_INCOMPLETE: - vty_outln (vty, "%% Incomplete command"); + vty_out (vty, "%% Incomplete command\n"); break; case MATCHER_AMBIGUOUS: - vty_outln (vty, "%% Ambiguous command"); + vty_out (vty, "%% Ambiguous command\n"); break; default: - vty_outln (vty, "%% Unknown error"); + vty_out (vty, "%% Unknown error\n"); break; } } @@ -209,6 +221,8 @@ DEFUN (grammar_test_doc, "Test function for docstring\n" "Command end\n") { + check_nodegraph(); + // create cmd_element with docstring struct cmd_element *cmd = XCALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_element)); cmd->string = XSTRDUP (MTYPE_CMD_TOKENS, "test docstring <example|selector follow> (1-255) end VARIABLE [OPTION|set lol] . VARARG"); @@ -243,12 +257,10 @@ DEFUN (grammar_test_show, "print current accumulated DFA\n" "include docstrings\n") { - struct graph_node *stack[MAXDEPTH]; + check_nodegraph(); - if (!nodegraph) - vty_out(vty, "nodegraph uninitialized\r\n"); - else - pretty_print_graph (vty, vector_slot (nodegraph->nodes, 0), 0, argc >= 3, stack, 0); + struct graph_node *stack[MAXDEPTH]; + pretty_print_graph (vty, vector_slot (nodegraph->nodes, 0), 0, argc >= 3, stack, 0); return CMD_SUCCESS; } @@ -259,14 +271,12 @@ DEFUN (grammar_test_dot, "print current graph for dot\n" ".dot filename\n") { + check_nodegraph(); + struct graph_node *stack[MAXDEPTH]; struct graph_node *visited[MAXDEPTH*MAXDEPTH]; size_t vpos = 0; - if (!nodegraph) { - vty_out(vty, "nodegraph uninitialized\r\n"); - return CMD_SUCCESS; - } FILE *ofd = fopen(argv[2]->arg, "w"); if (!ofd) { vty_out(vty, "%s: %s\r\n", argv[2]->arg, strerror(errno)); @@ -389,7 +399,7 @@ DEFUN (grammar_findambig, if (!scan && !nodegraph) { vty_out(vty, "nodegraph uninitialized\r\n"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } do { @@ -401,7 +411,7 @@ DEFUN (grammar_findambig, nodegraph = cnode->cmdgraph; if (!nodegraph) continue; - vty_outln (vty, "scanning node %d", scannode - 1); + vty_out (vty, "scanning node %d\n", scannode - 1); } commands = cmd_graph_permutations (nodegraph); @@ -410,29 +420,29 @@ DEFUN (grammar_findambig, { int same = prev && !strcmp (prev->cmd, cur->cmd); if (printall && !same) - vty_outln (vty, "'%s' [%x]", cur->cmd, cur->el->daemon); + vty_out (vty, "'%s' [%x]\n", cur->cmd, cur->el->daemon); if (same) { - vty_outln (vty, "'%s' AMBIGUOUS:", cur->cmd); - vty_outln (vty, " %s%s '%s'", prev->el->name, VTYNL, + vty_out (vty, "'%s' AMBIGUOUS:\n", cur->cmd); + vty_out (vty, " %s\n '%s'\n", prev->el->name, prev->el->string); - vty_outln (vty, " %s%s '%s'", cur->el->name, VTYNL, + vty_out (vty, " %s\n '%s'\n", cur->el->name, cur->el->string); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); ambig++; } prev = cur; } list_delete (commands); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } while (scan && scannode < LINK_PARAMS_NODE); - vty_outln (vty, "%d ambiguous commands found.", ambig); + vty_out (vty, "%d ambiguous commands found.\n", ambig); if (scan) nodegraph = NULL; - return ambig == 0 ? CMD_SUCCESS : CMD_WARNING; + return ambig == 0 ? CMD_SUCCESS : CMD_WARNING_CONFIG_FAILED; } DEFUN (grammar_init_graph, @@ -465,19 +475,17 @@ DEFUN (grammar_access, cnode = vector_slot (cmdvec, atoi (argv[2]->arg)); if (!cnode) { - vty_outln (vty, "%% no such node"); - return CMD_WARNING; + vty_out (vty, "%% no such node\n"); + return CMD_WARNING_CONFIG_FAILED; } - vty_outln (vty, "node %d", (int)cnode->node); + vty_out (vty, "node %d\n", (int)cnode->node); nodegraph = cnode->cmdgraph; return CMD_SUCCESS; } /* this is called in vtysh.c to set up the testing shim */ void grammar_sandbox_init(void) { - init_cmdgraph (NULL, &nodegraph); - // install all enable elements install_element (ENABLE_NODE, &grammar_test_cmd); install_element (ENABLE_NODE, &grammar_test_show_cmd); @@ -534,7 +542,7 @@ pretty_print_graph (struct vty *vty, struct graph_node *start, int level, if (stackpos == MAXDEPTH) { - vty_outln (vty, " -aborting! (depth limit)"); + vty_out (vty, " -aborting! (depth limit)\n"); return; } stack[stackpos++] = start; @@ -543,7 +551,7 @@ pretty_print_graph (struct vty *vty, struct graph_node *start, int level, if (numto) { if (numto > 1) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); for (unsigned int i = 0; i < vector_active (start->to); i++) { struct graph_node *adj = vector_slot (start->to, i); @@ -555,12 +563,12 @@ pretty_print_graph (struct vty *vty, struct graph_node *start, int level, if (adj == start) vty_out(vty, "*"); else if (((struct cmd_token *)adj->data)->type == END_TKN) - vty_outln (vty, "--END"); + vty_out (vty, "--END\n"); else { size_t k; for (k = 0; k < stackpos; k++) if (stack[k] == adj) { - vty_outln (vty, "<<loop@%zu ", k); + vty_out (vty, "<<loop@%zu \n", k); break; } if (k == stackpos) @@ -569,7 +577,7 @@ pretty_print_graph (struct vty *vty, struct graph_node *start, int level, } } else - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } static void @@ -652,5 +660,5 @@ init_cmdgraph (struct vty *vty, struct graph **graph) struct cmd_token *token = cmd_token_new (START_TKN, 0, NULL, NULL); graph_new_node (*graph, token, (void (*)(void *)) &cmd_token_del); if (vty) - vty_outln (vty, "initialized graph"); + vty_out (vty, "initialized graph\n"); } diff --git a/lib/hash.c b/lib/hash.c index 95643bbae..7c355b2d8 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -87,13 +87,8 @@ hash_alloc_intern (void *arg) } #define hash_update_ssq(hz, old, new) \ - do { \ - long double res; \ - res = powl(old, 2.0); \ - hz->stats.ssq -= (uint64_t) res;\ - res = powl(new, 2.0); \ - hz->stats.ssq += (uint64_t) res; \ - } while (0); \ + atomic_fetch_add_explicit(&hz->stats.ssq, (new + old)*(new - old),\ + memory_order_relaxed); /* Expand hash if the chain length exceeds the threshold. */ static void hash_expand (struct hash *hash) @@ -428,6 +423,13 @@ DEFUN(show_hash_stats, long double ssq; // ssq casted to long double pthread_mutex_lock (&_hashes_mtx); + if (!_hashes) + { + pthread_mutex_unlock (&_hashes_mtx); + vty_out (vty, "No hash tables in use.\n"); + return CMD_SUCCESS; + } + for (ALL_LIST_ELEMENTS_RO (_hashes, ln, h)) { if (!h->name) @@ -458,21 +460,21 @@ DEFUN(show_hash_stats, char underln[sizeof(header) + strlen(frr_protonameinst)]; memset (underln, '-', sizeof(underln)); underln[sizeof(underln) - 1] = '\0'; - vty_outln (vty, "%s%s", header, frr_protonameinst); - vty_outln (vty, "%s", underln); + vty_out (vty, "%s%s\n", header, frr_protonameinst); + vty_out (vty, "%s\n", underln); - vty_outln (vty, "# allocated: %d", _hashes->count); - vty_outln (vty, "# named: %d%s", tt->nrows - 1, VTYNL); + vty_out (vty, "# allocated: %d\n", _hashes->count); + vty_out (vty, "# named: %d\n\n", tt->nrows - 1); if (tt->nrows > 1) { ttable_colseps (tt, 0, RIGHT, true, '|'); - char *table = ttable_dump (tt, VTYNL); - vty_out (vty, "%s%s", table, VTYNL); + char *table = ttable_dump (tt, "\n"); + vty_out (vty, "%s\n", table); XFREE (MTYPE_TMP, table); } else - vty_outln (vty, "No named hash tables to display."); + vty_out (vty, "No named hash tables to display.\n"); ttable_del (tt); @@ -482,6 +484,5 @@ DEFUN(show_hash_stats, void hash_cmd_init () { - _hashes = list_new(); install_element (ENABLE_NODE, &show_hash_stats_cmd); } diff --git a/lib/hash.h b/lib/hash.h index 01d2b1ddc..3b2671afa 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -53,9 +53,9 @@ struct hash_backet struct hashstats { /* number of empty hash buckets */ - _Atomic int empty; + _Atomic uint_fast32_t empty; /* sum of squares of bucket length */ - _Atomic uint64_t ssq; + _Atomic uint_fast32_t ssq; }; struct hash @@ -690,10 +690,10 @@ DEFUN (interface, if ((sl = strlen(ifname)) > INTERFACE_NAMSIZ) { - vty_outln (vty, "%% Interface name %s is invalid: length exceeds " - "%d characters", + vty_out (vty, "%% Interface name %s is invalid: length exceeds " + "%d characters\n", ifname, INTERFACE_NAMSIZ); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /*Pending: need proper vrf name based lookup/(possible creation of VRF) @@ -709,8 +709,8 @@ DEFUN (interface, if (!ifp) { - vty_outln (vty, "%% interface %s not in %s", ifname, vrfname); - return CMD_WARNING; + vty_out (vty, "%% interface %s not in %s\n", ifname, vrfname); + return CMD_WARNING_CONFIG_FAILED; } VTY_PUSH_CONTEXT (INTERFACE_NODE, ifp); @@ -739,15 +739,14 @@ DEFUN_NOSH (no_interface, if (ifp == NULL) { - vty_out (vty, "%% Interface %s does not exist%s", ifname, VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Interface %s does not exist\n", ifname); + return CMD_WARNING_CONFIG_FAILED; } if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) { - vty_out (vty, "%% Only inactive interfaces can be deleted%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Only inactive interfaces can be deleted\n"); + return CMD_WARNING_CONFIG_FAILED; } if_delete(ifp); @@ -793,8 +792,7 @@ DEFUN (show_address, p = ifc->address; if (p->family == AF_INET) - vty_out (vty, "%s/%d%s", inet_ntoa (p->u.prefix4), p->prefixlen, - VTYNL); + vty_out (vty, "%s/%d\n", inet_ntoa (p->u.prefix4), p->prefixlen); } } return CMD_SUCCESS; @@ -819,8 +817,7 @@ DEFUN (show_address_vrf_all, if (!vrf->iflist || !listcount (vrf->iflist)) continue; - vty_out (vty, "%sVRF %u%s%s", VTYNL, vrf->vrf_id, VTYNL, - VTYNL); + vty_out (vty, "\nVRF %u\n\n", vrf->vrf_id); for (ALL_LIST_ELEMENTS_RO (vrf->iflist, node, ifp)) { @@ -829,8 +826,7 @@ DEFUN (show_address_vrf_all, p = ifc->address; if (p->family == AF_INET) - vty_out (vty, "%s/%d%s", inet_ntoa (p->u.prefix4), p->prefixlen, - VTYNL); + vty_out (vty, "%s/%d\n", inet_ntoa (p->u.prefix4), p->prefixlen); } } } diff --git a/lib/if_rmap.c b/lib/if_rmap.c index 32bebd67f..a0c40d5af 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -228,8 +228,8 @@ DEFUN (if_rmap, type = IF_RMAP_OUT; else { - vty_outln (vty, "route-map direction must be [in|out]"); - return CMD_WARNING; + vty_out (vty, "route-map direction must be [in|out]\n"); + return CMD_WARNING_CONFIG_FAILED; } if_rmap_set (argv[idx_ifname]->arg, type, argv[idx_rmap_name]->arg); @@ -259,15 +259,15 @@ DEFUN (no_if_rmap, type = IF_RMAP_OUT; else { - vty_outln (vty, "route-map direction must be [in|out]"); - return CMD_WARNING; + vty_out (vty, "route-map direction must be [in|out]\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = if_rmap_unset (argv[idx_ifname]->arg, type, argv[idx_routemap_name]->arg); if (! ret) { - vty_outln (vty, "route-map doesn't exist"); - return CMD_WARNING; + vty_out (vty, "route-map doesn't exist\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -290,7 +290,7 @@ config_write_if_rmap (struct vty *vty) if (if_rmap->routemap[IF_RMAP_IN]) { - vty_outln (vty, " route-map %s in %s", + vty_out (vty, " route-map %s in %s\n", if_rmap->routemap[IF_RMAP_IN], if_rmap->ifname); write++; @@ -298,7 +298,7 @@ config_write_if_rmap (struct vty *vty) if (if_rmap->routemap[IF_RMAP_OUT]) { - vty_outln (vty, " route-map %s out %s", + vty_out (vty, " route-map %s out %s\n", if_rmap->routemap[IF_RMAP_OUT], if_rmap->ifname); write++; diff --git a/lib/keychain.c b/lib/keychain.c index 9fe887c2c..f768933b7 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -271,8 +271,8 @@ DEFUN (no_key_chain, if (! keychain) { - vty_outln (vty, "Can't find keychain %s", argv[idx_word]->arg); - return CMD_WARNING; + vty_out (vty, "Can't find keychain %s\n", argv[idx_word]->arg); + return CMD_WARNING_CONFIG_FAILED; } keychain_delete (keychain); @@ -314,8 +314,8 @@ DEFUN (no_key, key = key_lookup (keychain, index); if (! key) { - vty_outln (vty, "Can't find key %d", index); - return CMD_WARNING; + vty_out (vty, "Can't find key %d\n", index); + return CMD_WARNING_CONFIG_FAILED; } key_delete (keychain, key); @@ -477,21 +477,21 @@ key_lifetime_set (struct vty *vty, struct key_range *krange, time_start = key_str2time (stime_str, sday_str, smonth_str, syear_str); if (time_start < 0) { - vty_outln (vty, "Malformed time value"); - return CMD_WARNING; + vty_out (vty, "Malformed time value\n"); + return CMD_WARNING_CONFIG_FAILED; } time_end = key_str2time (etime_str, eday_str, emonth_str, eyear_str); if (time_end < 0) { - vty_outln (vty, "Malformed time value"); - return CMD_WARNING; + vty_out (vty, "Malformed time value\n"); + return CMD_WARNING_CONFIG_FAILED; } if (time_end <= time_start) { - vty_outln (vty, "Expire time is not later than start time"); - return CMD_WARNING; + vty_out (vty, "Expire time is not later than start time\n"); + return CMD_WARNING_CONFIG_FAILED; } krange->start = time_start; @@ -512,8 +512,8 @@ key_lifetime_duration_set (struct vty *vty, struct key_range *krange, time_start = key_str2time (stime_str, sday_str, smonth_str, syear_str); if (time_start < 0) { - vty_outln (vty, "Malformed time value"); - return CMD_WARNING; + vty_out (vty, "Malformed time value\n"); + return CMD_WARNING_CONFIG_FAILED; } krange->start = time_start; @@ -534,8 +534,8 @@ key_lifetime_infinite_set (struct vty *vty, struct key_range *krange, time_start = key_str2time (stime_str, sday_str, smonth_str, syear_str); if (time_start < 0) { - vty_outln (vty, "Malformed time value"); - return CMD_WARNING; + vty_out (vty, "Malformed time value\n"); + return CMD_WARNING_CONFIG_FAILED; } krange->start = time_start; @@ -966,14 +966,14 @@ keychain_config_write (struct vty *vty) for (ALL_LIST_ELEMENTS_RO (keychain_list, node, keychain)) { - vty_outln (vty, "key chain %s", keychain->name); + vty_out (vty, "key chain %s\n", keychain->name); for (ALL_LIST_ELEMENTS_RO (keychain->key, knode, key)) { - vty_outln (vty, " key %d", key->index); + vty_out (vty, " key %d\n", key->index); if (key->string) - vty_outln (vty, " key-string %s", key->string); + vty_out (vty, " key-string %s\n", key->string); if (key->accept.start) { @@ -990,7 +990,7 @@ keychain_config_write (struct vty *vty) keychain_strftime (buf, BUFSIZ, &key->accept.end); vty_out (vty, " %s", buf); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (key->send.start) @@ -1007,10 +1007,10 @@ keychain_config_write (struct vty *vty) keychain_strftime (buf, BUFSIZ, &key->send.end); vty_out (vty, " %s", buf); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } - vty_outln (vty, "!"); + vty_out (vty, "!\n"); } return 0; @@ -946,6 +946,15 @@ static const struct zebra_desc_table command_types[] = { DESC_ENTRY (ZEBRA_LABEL_MANAGER_CONNECT), DESC_ENTRY (ZEBRA_GET_LABEL_CHUNK), DESC_ENTRY (ZEBRA_RELEASE_LABEL_CHUNK), + DESC_ENTRY (ZEBRA_ADVERTISE_ALL_VNI), + DESC_ENTRY (ZEBRA_VNI_ADD), + DESC_ENTRY (ZEBRA_VNI_DEL), + DESC_ENTRY (ZEBRA_REMOTE_VTEP_ADD), + DESC_ENTRY (ZEBRA_REMOTE_VTEP_DEL), + DESC_ENTRY (ZEBRA_MACIP_ADD), + DESC_ENTRY (ZEBRA_MACIP_DEL), + DESC_ENTRY (ZEBRA_REMOTE_MACIP_ADD), + DESC_ENTRY (ZEBRA_REMOTE_MACIP_DEL), }; #undef DESC_ENTRY diff --git a/lib/memory_vty.c b/lib/memory_vty.c index 5983efbdc..f65952e8a 100644 --- a/lib/memory_vty.c +++ b/lib/memory_vty.c @@ -44,26 +44,26 @@ show_memory_mallinfo (struct vty *vty) struct mallinfo minfo = mallinfo(); char buf[MTYPE_MEMSTR_LEN]; - vty_outln (vty, "System allocator statistics:"); - vty_outln (vty, " Total heap allocated: %s", + vty_out (vty, "System allocator statistics:\n"); + vty_out (vty, " Total heap allocated: %s\n", mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.arena)); - vty_outln (vty, " Holding block headers: %s", + vty_out (vty, " Holding block headers: %s\n", mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.hblkhd)); - vty_outln (vty, " Used small blocks: %s", + vty_out (vty, " Used small blocks: %s\n", mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.usmblks)); - vty_outln (vty, " Used ordinary blocks: %s", + vty_out (vty, " Used ordinary blocks: %s\n", mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.uordblks)); - vty_outln (vty, " Free small blocks: %s", + vty_out (vty, " Free small blocks: %s\n", mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.fsmblks)); - vty_outln (vty, " Free ordinary blocks: %s", + vty_out (vty, " Free ordinary blocks: %s\n", mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.fordblks)); - vty_outln (vty, " Ordinary blocks: %ld", + vty_out (vty, " Ordinary blocks: %ld\n", (unsigned long)minfo.ordblks); - vty_outln (vty, " Small blocks: %ld", + vty_out (vty, " Small blocks: %ld\n", (unsigned long)minfo.smblks); - vty_outln (vty, " Holding blocks: %ld", + vty_out (vty, " Holding blocks: %ld\n", (unsigned long)minfo.hblks); - vty_outln (vty,"(see system documentation for 'mallinfo' for meaning)"); + vty_out (vty,"(see system documentation for 'mallinfo' for meaning)\n"); return 1; } #endif /* HAVE_MALLINFO */ @@ -72,12 +72,12 @@ static int qmem_walker(void *arg, struct memgroup *mg, struct memtype *mt) { struct vty *vty = arg; if (!mt) - vty_outln (vty, "--- qmem %s ---", mg->name); + vty_out (vty, "--- qmem %s ---\n", mg->name); else { if (mt->n_alloc != 0) { char size[32]; snprintf(size, sizeof(size), "%6zu", mt->size); - vty_outln (vty, "%-30s: %10zu %s", + vty_out (vty, "%-30s: %10zu %s\n", mt->name, mt->n_alloc, mt->size == 0 ? "" : mt->size == SIZE_VAR ? "(variably sized)" : size); } @@ -108,14 +108,13 @@ DEFUN (show_modules, { struct frrmod_runtime *plug = frrmod_list; - vty_outln (vty, "%-12s %-25s %s%s", - "Module Name", "Version", "Description", - VTYNL); + vty_out (vty, "%-12s %-25s %s\n\n", + "Module Name", "Version", "Description"); while (plug) { const struct frrmod_info *i = plug->info; - vty_outln (vty, "%-12s %-25s %s", i->name, i->version,i->description); + vty_out (vty, "%-12s %-25s %s\n", i->name, i->version,i->description); if (plug->dl_handle) { #ifdef HAVE_DLINFO_ORIGIN @@ -129,13 +128,13 @@ DEFUN (show_modules, { name = strrchr(lm->l_name, '/'); name = name ? name + 1 : lm->l_name; - vty_outln (vty, "\tfrom: %s/%s", origin, name); + vty_out (vty, "\tfrom: %s/%s\n", origin, name); } # else - vty_outln (vty, "\tfrom: %s ", origin, plug->load_name); + vty_out (vty, "\tfrom: %s \n", origin, plug->load_name); # endif #else - vty_outln (vty, "\tfrom: %s", plug->load_name); + vty_out (vty, "\tfrom: %s\n", plug->load_name); #endif } plug = plug->next; diff --git a/lib/module.c b/lib/module.c index c7dd5538c..140fd87b9 100644 --- a/lib/module.c +++ b/lib/module.c @@ -110,7 +110,7 @@ struct frrmod_runtime *frrmod_load(const char *spec, dlclose(handle); if (err) snprintf(err, err_len, - "\"%s\" is not a Quagga module: %s", + "\"%s\" is not an FRR module: %s", name, dlerror()); return NULL; } diff --git a/lib/nexthop.c b/lib/nexthop.c index 725b52c05..e9ffea0a0 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -135,7 +135,7 @@ nexthop_add (struct nexthop **target, struct nexthop *nexthop) } void -copy_nexthops (struct nexthop **tnh, struct nexthop *nh) +copy_nexthops (struct nexthop **tnh, struct nexthop *nh, struct nexthop *rparent) { struct nexthop *nexthop; struct nexthop *nh1; @@ -143,18 +143,20 @@ copy_nexthops (struct nexthop **tnh, struct nexthop *nh) for (nh1 = nh; nh1; nh1 = nh1->next) { nexthop = nexthop_new(); - nexthop->flags = nh->flags; - nexthop->type = nh->type; nexthop->ifindex = nh->ifindex; - memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr)); - memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr)); + nexthop->type = nh->type; + nexthop->flags = nh->flags; + memcpy(&nexthop->gate, &nh->gate, sizeof(nh->gate)); + memcpy(&nexthop->src, &nh->src, sizeof(nh->src)); + memcpy(&nexthop->rmap_src, &nh->rmap_src, sizeof(nh->rmap_src)); + nexthop->rparent = rparent; if (nh->nh_label) nexthop_add_labels (nexthop, nh->nh_label_type, - nh->nh_label->num_labels, &nh->nh_label->label[0]); + nh->nh_label->num_labels, &nh->nh_label->label[0]); nexthop_add(tnh, nexthop); if (CHECK_FLAG(nh1->flags, NEXTHOP_FLAG_RECURSIVE)) - copy_nexthops(&nexthop->resolved, nh1->resolved); + copy_nexthops(&nexthop->resolved, nh1->resolved, nexthop); } } @@ -241,3 +243,45 @@ nexthop2str (struct nexthop *nexthop, char *str, int size) return str; } + +/* + * Iteration step for ALL_NEXTHOPS macro: + * This is the tricky part. Check if `nexthop' has + * NEXTHOP_FLAG_RECURSIVE set. If yes, this implies that `nexthop' has + * at least one nexthop attached to `nexthop->resolved', which will be + * the next one. + * + * If NEXTHOP_FLAG_RECURSIVE is not set, `nexthop' will progress in its + * current chain. In case its current chain end is reached, it will move + * upwards in the recursion levels and progress there. Whenever a step + * forward in a chain is done, recursion will be checked again. + * In a nustshell, it's equivalent to a pre-traversal order assuming that + * left branch is 'resolved' and right branch is 'next': + * https://en.wikipedia.org/wiki/Tree_traversal#/media/File:Sorted_binary_tree_preorder.svg + */ +struct nexthop * +nexthop_next(struct nexthop *nexthop) +{ + if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) + return nexthop->resolved; + + if (nexthop->next) + return nexthop->next; + + for (struct nexthop *par = nexthop->rparent; par; par = par->rparent) + if (par->next) + return par->next; + + return NULL; +} + +unsigned int +nexthop_level(struct nexthop *nexthop) +{ + unsigned int rv = 0; + + for (struct nexthop *par = nexthop->rparent; par; par = par->rparent) + rv++; + + return rv; +} diff --git a/lib/nexthop.h b/lib/nexthop.h index 8c9c801c9..e9d937f94 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -81,8 +81,10 @@ struct nexthop * If the nexthop struct needs to be resolved recursively, * NEXTHOP_FLAG_RECURSIVE will be set in flags and the nexthops * obtained by recursive resolution will be added to `resolved'. - * Only one level of recursive resolution is currently supported. */ + */ struct nexthop *resolved; + /* Recursive parent */ + struct nexthop *rparent; /* Type of label(s), if any */ enum lsp_types_t nh_label_type; @@ -91,6 +93,17 @@ struct nexthop struct nexthop_label *nh_label; }; +/* The following for loop allows to iterate over the nexthop + * structure of routes. + * + * head: The pointer to the first nexthop in the chain. + * + * nexthop: The pointer to the current nexthop, either in the + * top-level chain or in a resolved chain. + */ +#define ALL_NEXTHOPS(head, nexthop) \ + (nexthop) = (head); (nexthop); (nexthop) = nexthop_next(nexthop) + extern int zebra_rnh_ip_default_route; extern int zebra_rnh_ipv6_default_route; @@ -107,7 +120,7 @@ nh_resolve_via_default(int family) struct nexthop *nexthop_new (void); void nexthop_add (struct nexthop **target, struct nexthop *nexthop); -void copy_nexthops (struct nexthop **tnh, struct nexthop *nh); +void copy_nexthops (struct nexthop **tnh, struct nexthop *nh, struct nexthop *rparent); void nexthop_free (struct nexthop *nexthop); void nexthops_free (struct nexthop *nexthop); @@ -119,4 +132,6 @@ extern int nexthop_same_no_recurse (struct nexthop *next1, struct nexthop *next2 extern int nexthop_labels_match (struct nexthop *nh1, struct nexthop *nh2); extern const char * nexthop2str (struct nexthop *nexthop, char *str, int size); +extern struct nexthop *nexthop_next(struct nexthop *nexthop); +extern unsigned int nexthop_level(struct nexthop *nexthop); #endif /*_LIB_NEXTHOP_H */ @@ -296,7 +296,7 @@ ns_netns_pathname (struct vty *vty, const char *name) if (! result) { - vty_outln (vty, "Invalid pathname: %s",safe_strerror(errno)); + vty_out (vty, "Invalid pathname: %s\n",safe_strerror(errno)); return NULL; } return pathname; @@ -317,16 +317,16 @@ DEFUN_NOSH (ns_netns, char *pathname = ns_netns_pathname (vty, argv[idx_name]->arg); if (!pathname) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ns_id = strtoul (argv[idx_number]->arg, NULL, 10); ns = ns_get (ns_id); if (ns->name && strcmp (ns->name, pathname) != 0) { - vty_out (vty, "NS %u is already configured with NETNS %s%s", - ns->ns_id, ns->name, VTYNL); - return CMD_WARNING; + vty_out (vty, "NS %u is already configured with NETNS %s\n", + ns->ns_id, ns->name); + return CMD_WARNING_CONFIG_FAILED; } if (!ns->name) @@ -334,9 +334,9 @@ DEFUN_NOSH (ns_netns, if (!ns_enable (ns)) { - vty_out (vty, "Can not associate NS %u with NETNS %s%s", - ns->ns_id, ns->name, VTYNL); - return CMD_WARNING; + vty_out (vty, "Can not associate NS %u with NETNS %s\n", + ns->ns_id, ns->name); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -358,21 +358,21 @@ DEFUN (no_ns_netns, char *pathname = ns_netns_pathname (vty, argv[idx_name]->arg); if (!pathname) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ns_id = strtoul(argv[idx_number]->arg, NULL, 10); ns = ns_lookup (ns_id); if (!ns) { - vty_outln (vty, "NS %u is not found", ns_id); + vty_out (vty, "NS %u is not found\n", ns_id); return CMD_SUCCESS; } if (ns->name && strcmp (ns->name, pathname) != 0) { - vty_outln (vty, "Incorrect NETNS file name"); - return CMD_WARNING; + vty_out (vty, "Incorrect NETNS file name\n"); + return CMD_WARNING_CONFIG_FAILED; } ns_disable (ns); @@ -405,7 +405,7 @@ ns_config_write (struct vty *vty) if (ns->ns_id == NS_DEFAULT || ns->name == NULL) continue; - vty_outln (vty, "logical-router %u netns %s", ns->ns_id,ns->name); + vty_out (vty, "logical-router %u netns %s\n", ns->ns_id,ns->name); write = 1; } diff --git a/lib/plist.c b/lib/plist.c index 339540a2b..96c60a489 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -882,9 +882,9 @@ prefix_entry_dup_check (struct prefix_list *plist, static int vty_invalid_prefix_range (struct vty *vty, const char *prefix) { - vty_outln (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value", + vty_out (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value\n", prefix); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } static int @@ -920,8 +920,8 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name, type = PREFIX_DENY; else { - vty_outln (vty, "%% prefix type must be permit or deny"); - return CMD_WARNING; + vty_out (vty, "%% prefix type must be permit or deny\n"); + return CMD_WARNING_CONFIG_FAILED; } /* "any" is special token for matching any IPv4 addresses. */ @@ -940,8 +940,8 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name, if (ret <= 0) { - vty_outln (vty, "%% Malformed IPv4 prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed IPv4 prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make a copy to verify prefix matches mask length */ @@ -962,8 +962,8 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name, if (ret <= 0) { - vty_outln (vty, "%% Malformed IPv6 prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed IPv6 prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } /* make a copy to verify prefix matches mask length */ @@ -973,8 +973,8 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name, break; case AFI_L2VPN: default: - vty_outln (vty, "%% Unrecognized AFI (%d)", afi); - return CMD_WARNING; + vty_out (vty, "%% Unrecognized AFI (%d)\n", afi); + return CMD_WARNING_CONFIG_FAILED; break; } @@ -1042,8 +1042,8 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name, plist = prefix_list_lookup (afi, name); if (! plist) { - vty_outln (vty, "%% Can't find specified prefix-list"); - return CMD_WARNING; + vty_out (vty, "%% Can't find specified prefix-list\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Only prefix-list name specified, delete the entire prefix-list. */ @@ -1057,8 +1057,8 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name, /* We must have, at a minimum, both the type and prefix here */ if ((typestr == NULL) || (prefix == NULL)) { - vty_outln (vty, "%% Both prefix and type required"); - return CMD_WARNING; + vty_out (vty, "%% Both prefix and type required\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Check sequence number. */ @@ -1078,8 +1078,8 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name, type = PREFIX_DENY; else { - vty_outln (vty, "%% prefix type must be permit or deny"); - return CMD_WARNING; + vty_out (vty, "%% prefix type must be permit or deny\n"); + return CMD_WARNING_CONFIG_FAILED; } /* "any" is special token for matching any IPv4 addresses. */ @@ -1096,8 +1096,8 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name, if (ret <= 0) { - vty_outln (vty, "%% Malformed IPv4 prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed IPv4 prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } } else if (afi == AFI_IP6) @@ -1113,8 +1113,8 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name, if (ret <= 0) { - vty_outln (vty, "%% Malformed IPv6 prefix"); - return CMD_WARNING; + vty_out (vty, "%% Malformed IPv6 prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -1123,8 +1123,8 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name, if (pentry == NULL) { - vty_outln (vty, "%% Can't find specified prefix-list"); - return CMD_WARNING; + vty_out (vty, "%% Can't find specified prefix-list\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Install new filter to the access_list. */ @@ -1141,8 +1141,8 @@ vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, const char *name) plist = prefix_list_lookup (afi, name); if (! plist) { - vty_outln (vty, "%% Can't find specified prefix-list"); - return CMD_WARNING; + vty_out (vty, "%% Can't find specified prefix-list\n"); + return CMD_WARNING_CONFIG_FAILED; } if (plist->desc) @@ -1179,21 +1179,21 @@ vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist, if (dtype == normal_display) { - vty_outln (vty, "ip%s prefix-list %s: %d entries", + vty_out (vty, "ip%s prefix-list %s: %d entries\n", afi == AFI_IP ? "" : "v6", plist->name, plist->count); if (plist->desc) - vty_outln (vty, " Description: %s", plist->desc); + vty_out (vty, " Description: %s\n", plist->desc); } else if (dtype == summary_display || dtype == detail_display) { - vty_outln (vty, "ip%s prefix-list %s:", + vty_out (vty, "ip%s prefix-list %s:\n", afi == AFI_IP ? "" : "v6", plist->name); if (plist->desc) - vty_outln (vty, " Description: %s", plist->desc); + vty_out (vty, " Description: %s\n", plist->desc); - vty_outln (vty, " count: %d, range entries: %d, sequences: %u - %u", + vty_out (vty, " count: %d, range entries: %d, sequences: %u - %u\n", plist->count, plist->rangecount, plist->head ? plist->head->seq : 0, plist->tail ? plist->tail->seq : 0); @@ -1234,7 +1234,7 @@ vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist, vty_out (vty, " (hit count: %ld, refcount: %ld)", pentry->hitcnt, pentry->refcnt); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } } @@ -1259,7 +1259,7 @@ vty_show_prefix_list (struct vty *vty, afi_t afi, const char *name, plist = prefix_list_lookup (afi, name); if (! plist) { - vty_outln (vty, "%% Can't find specified prefix-list"); + vty_out (vty, "%% Can't find specified prefix-list\n"); return CMD_WARNING; } vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum); @@ -1269,7 +1269,7 @@ vty_show_prefix_list (struct vty *vty, afi_t afi, const char *name, if (dtype == detail_display || dtype == summary_display) { if (master->recent) - vty_outln (vty, "Prefix-list with the last deletion/insertion: %s", + vty_out (vty, "Prefix-list with the last deletion/insertion: %s\n", master->recent->name); } @@ -1296,14 +1296,14 @@ vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, const char *name, plist = prefix_list_lookup (afi, name); if (! plist) { - vty_outln (vty, "%% Can't find specified prefix-list"); + vty_out (vty, "%% Can't find specified prefix-list\n"); return CMD_WARNING; } ret = str2prefix (prefix, &p); if (ret <= 0) { - vty_outln (vty, "%% prefix is malformed"); + vty_out (vty, "%% prefix is malformed\n"); return CMD_WARNING; } @@ -1346,7 +1346,7 @@ vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, const char *name, vty_out (vty, " (hit count: %ld, refcount: %ld)", pentry->hitcnt, pentry->refcnt); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); if (type == first_match_display) return CMD_SUCCESS; @@ -1384,7 +1384,7 @@ vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name, plist = prefix_list_lookup (afi, name); if (! plist) { - vty_outln (vty, "%% Can't find specified prefix-list"); + vty_out (vty, "%% Can't find specified prefix-list\n"); return CMD_WARNING; } @@ -1393,7 +1393,7 @@ vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name, ret = str2prefix (prefix, &p); if (ret <= 0) { - vty_outln (vty, "%% prefix is malformed"); + vty_out (vty, "%% prefix is malformed\n"); return CMD_WARNING; } } @@ -1816,16 +1816,16 @@ config_write_prefix_afi (afi_t afi, struct vty *vty) if (! master->seqnum) { - vty_outln (vty, "no ip%s prefix-list sequence-number", + vty_out (vty, "no ip%s prefix-list sequence-number\n", afi == AFI_IP ? "" : "v6"); - vty_outln (vty, "!"); + vty_out (vty, "!\n"); } for (plist = master->num.head; plist; plist = plist->next) { if (plist->desc) { - vty_outln (vty, "ip%s prefix-list %s description %s", + vty_out (vty, "ip%s prefix-list %s description %s\n", afi == AFI_IP ? "" : "v6", plist->name, plist->desc); write++; @@ -1858,17 +1858,17 @@ config_write_prefix_afi (afi_t afi, struct vty *vty) if (pentry->le) vty_out (vty, " le %d", pentry->le); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write++; } - /* vty_out (vty, "!%s", VTYNL); */ + /* vty_out (vty, "!\n"); */ } for (plist = master->str.head; plist; plist = plist->next) { if (plist->desc) { - vty_outln (vty, "ip%s prefix-list %s description %s", + vty_out (vty, "ip%s prefix-list %s description %s\n", afi == AFI_IP ? "" : "v6", plist->name, plist->desc); write++; @@ -1901,7 +1901,7 @@ config_write_prefix_afi (afi_t afi, struct vty *vty) if (pentry->le) vty_out (vty, " le %d", pentry->le); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write++; } } @@ -1944,18 +1944,18 @@ prefix_bgp_orf_set (char *name, afi_t afi, struct orf_prefix *orfp, /* ge and le value check */ if (orfp->ge && orfp->ge <= orfp->p.prefixlen) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (orfp->le && orfp->le <= orfp->p.prefixlen) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (orfp->le && orfp->ge > orfp->le) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (orfp->ge && orfp->le == (afi == AFI_IP ? 32 : 128)) orfp->le = 0; plist = prefix_list_get (afi, 1, name); if (! plist) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (set) { @@ -1966,7 +1966,7 @@ prefix_bgp_orf_set (char *name, afi_t afi, struct orf_prefix *orfp, if (prefix_entry_dup_check (plist, pentry)) { prefix_list_entry_free (pentry); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } prefix_list_entry_add (plist, pentry); @@ -1978,7 +1978,7 @@ prefix_bgp_orf_set (char *name, afi_t afi, struct orf_prefix *orfp, orfp->seq, orfp->le, orfp->ge); if (! pentry) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; prefix_list_entry_delete (plist, pentry, 1); } @@ -2046,13 +2046,13 @@ prefix_bgp_show_prefix_list (struct vty *vty, afi_t afi, char *name, u_char use_ else json_object_object_add(json, "ipv6PrefixList", json_prefix); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { - vty_outln (vty, "ip%s prefix-list %s: %d entries", + vty_out (vty, "ip%s prefix-list %s: %d entries\n", afi == AFI_IP ? "" : "v6", plist->name, plist->count); @@ -2071,7 +2071,7 @@ prefix_bgp_show_prefix_list (struct vty *vty, afi_t afi, char *name, u_char use_ if (pentry->le) vty_out (vty, " le %d", pentry->le); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } return plist->count; diff --git a/lib/route_types.pl b/lib/route_types.pl index 29bcd3a67..9d50acaae 100755 --- a/lib/route_types.pl +++ b/lib/route_types.pl @@ -113,19 +113,15 @@ sub codelist { $protodetail{$p}->{"shorthelp"}); if (length($str . $s) > 70) { $str =~ s/ $//; - push @lines, $str . "%s\" \\\n"; + push @lines, $str . "\\n\" \\\n"; $str = " \" "; } $str .= $s; } $str =~ s/ $//; - push @lines, $str . "%s\" \\\n"; - push @lines, " \" > - selected route, * - FIB route%s%s\", \\\n"; - my @nl = (); - for (my $c = 0; $c < @lines + 1; $c++) { - push @nl, "VTYNL" - } - return join("", @lines) ." ". join(", ", @nl); + push @lines, $str . "\\n\" \\\n"; + push @lines, " \" > - selected route, * - FIB route\\n\\n\""; + return join("", @lines); } print "\n"; diff --git a/lib/routemap.c b/lib/routemap.c index caba8afd7..9ceaa1115 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -521,12 +521,12 @@ generic_match_add (struct vty *vty, struct route_map_index *index, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst); - return CMD_WARNING; + vty_out (vty, "%% [%s] Can't find rule.\n", frr_protonameinst); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.", + vty_out (vty, "%% [%s] Argument form is unsupported or malformed.\n", frr_protonameinst); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } @@ -568,10 +568,10 @@ generic_match_delete (struct vty *vty, struct route_map_index *index, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst); + vty_out (vty, "%% [%s] Can't find rule.\n", frr_protonameinst); break; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.", + vty_out (vty, "%% [%s] Argument form is unsupported or malformed.\n", frr_protonameinst); break; } @@ -579,7 +579,7 @@ generic_match_delete (struct vty *vty, struct route_map_index *index, XFREE(MTYPE_ROUTE_MAP_RULE, dep_name); if (rmap_name) XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (type != RMAP_EVENT_MATCH_DELETED && dep_name) @@ -605,12 +605,12 @@ generic_set_add (struct vty *vty, struct route_map_index *index, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst); - return CMD_WARNING; + vty_out (vty, "%% [%s] Can't find rule.\n", frr_protonameinst); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.", + vty_out (vty, "%% [%s] Argument form is unsupported or malformed.\n", frr_protonameinst); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } return CMD_SUCCESS; @@ -628,12 +628,12 @@ generic_set_delete (struct vty *vty, struct route_map_index *index, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst); - return CMD_WARNING; + vty_out (vty, "%% [%s] Can't find rule.\n", frr_protonameinst); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.", + vty_out (vty, "%% [%s] Argument form is unsupported or malformed.\n", frr_protonameinst); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } return CMD_SUCCESS; @@ -993,43 +993,43 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map) struct route_map_index *index; struct route_map_rule *rule; - vty_outln (vty, "%s:", frr_protonameinst); + vty_out (vty, "%s:\n", frr_protonameinst); for (index = map->head; index; index = index->next) { - vty_outln (vty, "route-map %s, %s, sequence %d", + vty_out (vty, "route-map %s, %s, sequence %d\n", map->name, route_map_type_str (index->type), index->pref); /* Description */ if (index->description) - vty_outln (vty, " Description:%s %s", VTYNL, + vty_out (vty, " Description:\n %s\n", index->description); /* Match clauses */ - vty_outln (vty, " Match clauses:"); + vty_out (vty, " Match clauses:\n"); for (rule = index->match_list.head; rule; rule = rule->next) - vty_outln (vty, " %s %s", + vty_out (vty, " %s %s\n", rule->cmd->str, rule->rule_str); - vty_outln (vty, " Set clauses:"); + vty_out (vty, " Set clauses:\n"); for (rule = index->set_list.head; rule; rule = rule->next) - vty_outln (vty, " %s %s", + vty_out (vty, " %s %s\n", rule->cmd->str, rule->rule_str); /* Call clause */ - vty_outln (vty, " Call clause:"); + vty_out (vty, " Call clause:\n"); if (index->nextrm) - vty_outln (vty, " Call %s", index->nextrm); + vty_out (vty, " Call %s\n", index->nextrm); /* Exit Policy */ - vty_outln (vty, " Action:"); + vty_out (vty, " Action:\n"); if (index->exitpolicy == RMAP_GOTO) - vty_outln (vty, " Goto %d", index->nextpref); + vty_out (vty, " Goto %d\n", index->nextpref); else if (index->exitpolicy == RMAP_NEXT) - vty_outln (vty, " Continue to next entry"); + vty_out (vty, " Continue to next entry\n"); else if (index->exitpolicy == RMAP_EXIT) - vty_outln (vty, " Exit routemap"); + vty_out (vty, " Exit routemap\n"); } } @@ -1049,7 +1049,7 @@ vty_show_route_map (struct vty *vty, const char *name) } else { - vty_outln (vty, "%s: 'route-map %s' not found", frr_protonameinst, + vty_out (vty, "%s: 'route-map %s' not found\n", frr_protonameinst, name); return CMD_SUCCESS; } @@ -2359,15 +2359,15 @@ DEFUN (set_ip_nexthop, ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { - vty_outln (vty, "%% Malformed nexthop address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed nexthop address\n"); + return CMD_WARNING_CONFIG_FAILED; } if (su.sin.sin_addr.s_addr == 0 || IPV4_CLASS_DE(su.sin.sin_addr.s_addr)) { - vty_outln (vty, - "%% nexthop address cannot be 0.0.0.0, multicast " "or reserved"); - return CMD_WARNING; + vty_out (vty, + "%% nexthop address cannot be 0.0.0.0, multicast or reserved\n"); + return CMD_WARNING_CONFIG_FAILED; } if (rmap_match_set_hook.set_ip_nexthop) @@ -2416,13 +2416,13 @@ DEFUN (set_ipv6_nexthop_local, ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr); if (!ret) { - vty_outln (vty, "%% Malformed nexthop address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed nexthop address\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!IN6_IS_ADDR_LINKLOCAL(&addr)) { - vty_outln (vty, "%% Invalid link-local nexthop address"); - return CMD_WARNING; + vty_out (vty, "%% Invalid link-local nexthop address\n"); + return CMD_WARNING_CONFIG_FAILED; } if (rmap_match_set_hook.set_ipv6_nexthop_local) @@ -2577,8 +2577,8 @@ DEFUN (no_route_map_all, map = route_map_lookup_by_name (mapname); if (map == NULL) { - vty_outln (vty, "%% Could not find route-map %s", mapname); - return CMD_WARNING; + vty_out (vty, "%% Could not find route-map %s\n", mapname); + return CMD_WARNING_CONFIG_FAILED; } route_map_delete (map); @@ -2612,17 +2612,17 @@ DEFUN (no_route_map, map = route_map_lookup_by_name (mapname); if (map == NULL) { - vty_outln (vty, "%% Could not find route-map %s", mapname); - return CMD_WARNING; + vty_out (vty, "%% Could not find route-map %s\n", mapname); + return CMD_WARNING_CONFIG_FAILED; } /* Lookup route map index. */ index = route_map_index_lookup (map, permit, pref); if (index == NULL) { - vty_outln (vty, "%% Could not find route-map entry %s %s", + vty_out (vty, "%% Could not find route-map entry %s %s\n", mapname, prefstr); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Delete index from route map. */ @@ -2648,8 +2648,8 @@ DEFUN (rmap_onmatch_next, if (index->type == RMAP_DENY) { /* Under a deny clause, match means it's finished. No need to set next */ - vty_outln (vty,"on-match next not supported under route-map deny"); - return CMD_WARNING; + vty_out (vty,"on-match next not supported under route-map deny\n"); + return CMD_WARNING_CONFIG_FAILED; } index->exitpolicy = RMAP_NEXT; } @@ -2689,8 +2689,8 @@ DEFUN (rmap_onmatch_goto, if (index->type == RMAP_DENY) { /* Under a deny clause, match means it's finished. No need to go anywhere */ - vty_outln (vty,"on-match goto not supported under route-map deny"); - return CMD_WARNING; + vty_out (vty,"on-match goto not supported under route-map deny\n"); + return CMD_WARNING_CONFIG_FAILED; } if (num) @@ -2701,8 +2701,8 @@ DEFUN (rmap_onmatch_goto, if (d <= index->pref) { /* Can't allow you to do that, Dave */ - vty_outln (vty, "can't jump backwards in route-maps"); - return CMD_WARNING; + vty_out (vty, "can't jump backwards in route-maps\n"); + return CMD_WARNING_CONFIG_FAILED; } else { @@ -2860,31 +2860,31 @@ route_map_config_write (struct vty *vty) for (index = map->head; index; index = index->next) { if (!first) - vty_outln (vty, "!"); + vty_out (vty, "!\n"); else first = 0; - vty_outln (vty, "route-map %s %s %d", + vty_out (vty, "route-map %s %s %d\n", map->name, route_map_type_str (index->type), index->pref); if (index->description) - vty_outln (vty, " description %s", index->description); + vty_out (vty, " description %s\n", index->description); for (rule = index->match_list.head; rule; rule = rule->next) - vty_outln (vty, " match %s %s", rule->cmd->str, + vty_out (vty, " match %s %s\n", rule->cmd->str, rule->rule_str ? rule->rule_str : ""); for (rule = index->set_list.head; rule; rule = rule->next) - vty_outln (vty, " set %s %s", rule->cmd->str, + vty_out (vty, " set %s %s\n", rule->cmd->str, rule->rule_str ? rule->rule_str : ""); if (index->nextrm) - vty_outln (vty, " call %s", index->nextrm); + vty_out (vty, " call %s\n", index->nextrm); if (index->exitpolicy == RMAP_GOTO) - vty_outln (vty, " on-match goto %d", index->nextpref); + vty_out (vty, " on-match goto %d\n", index->nextpref); if (index->exitpolicy == RMAP_NEXT) - vty_outln (vty," on-match next"); + vty_out (vty," on-match next\n"); write++; } diff --git a/lib/skiplist.c b/lib/skiplist.c index 5ba1c80e4..fd772b64c 100644 --- a/lib/skiplist.c +++ b/lib/skiplist.c @@ -602,9 +602,9 @@ skiplist_debug(struct vty *vty, struct skiplist *l) if (!l) l = skiplist_last_created; - vty_outln (vty, "Skiplist %p has max level %d", l, l->level); + vty_out (vty, "Skiplist %p has max level %d\n", l, l->level); for (i = l->level; i >= 0; --i) - vty_outln (vty, " @%d: %ld", + vty_out (vty, " @%d: %ld\n", i,(long)((l->stats->forward[i]) - (struct skiplistnode *)NULL)); } diff --git a/lib/smux.c b/lib/smux.c index 6f4b45f9a..d7d99cc8a 100644 --- a/lib/smux.c +++ b/lib/smux.c @@ -1278,8 +1278,8 @@ smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str) ret = smux_str2oid (oid_str, oid, &oid_len); if (ret != 0) { - vty_out (vty, "object ID malformed%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "object ID malformed\n"); + return CMD_WARNING_CONFIG_FAILED; } if (smux_oid) @@ -1339,7 +1339,7 @@ DEFUN (smux_peer, return CMD_SUCCESS; } else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (smux_peer_password, @@ -1357,7 +1357,7 @@ DEFUN (smux_peer_password, return CMD_SUCCESS; } else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (no_smux_peer, @@ -1387,7 +1387,7 @@ config_write_smux (struct vty *vty) vty_out (vty, "%s%d", first ? "" : ".", (int) smux_oid[i]); first = 0; } - vty_outln (vty, " %s", smux_passwd); + vty_out (vty, " %s\n", smux_passwd); } return 0; } diff --git a/lib/spf_backoff.c b/lib/spf_backoff.c index 7cbb300c5..10f00426c 100644 --- a/lib/spf_backoff.c +++ b/lib/spf_backoff.c @@ -223,43 +223,43 @@ void spf_backoff_show(struct spf_backoff *backoff, struct vty *vty, const char *prefix) { - vty_outln (vty, "%sCurrent state: %s", prefix, + vty_out (vty, "%sCurrent state: %s\n", prefix, spf_backoff_state2str(backoff->state)); - vty_outln (vty, "%sInit timer: %ld msec", prefix, + vty_out (vty, "%sInit timer: %ld msec\n", prefix, backoff->init_delay); - vty_outln (vty, "%sShort timer: %ld msec", prefix, + vty_out (vty, "%sShort timer: %ld msec\n", prefix, backoff->short_delay); - vty_outln (vty, "%sLong timer: %ld msec", prefix, + vty_out (vty, "%sLong timer: %ld msec\n", prefix, backoff->long_delay); - vty_outln (vty, "%sHolddown timer: %ld msec", prefix, + vty_out (vty, "%sHolddown timer: %ld msec\n", prefix, backoff->holddown); if (backoff->t_holddown) { struct timeval remain = thread_timer_remain(backoff->t_holddown); - vty_outln (vty, "%s Still runs for %ld msec", + vty_out (vty, "%s Still runs for %ld msec\n", prefix, remain.tv_sec * 1000 + remain.tv_usec / 1000); } else { - vty_outln (vty, "%s Inactive", prefix); + vty_out (vty, "%s Inactive\n", prefix); } - vty_outln (vty, "%sTimeToLearn timer: %ld msec", prefix, + vty_out (vty, "%sTimeToLearn timer: %ld msec\n", prefix, backoff->timetolearn); if (backoff->t_timetolearn) { struct timeval remain = thread_timer_remain(backoff->t_timetolearn); - vty_outln (vty, "%s Still runs for %ld msec", + vty_out (vty, "%s Still runs for %ld msec\n", prefix, remain.tv_sec * 1000 + remain.tv_usec / 1000); } else { - vty_outln (vty, "%s Inactive", prefix); + vty_out (vty, "%s Inactive\n", prefix); } - vty_outln (vty, "%sFirst event: %s", prefix, + vty_out (vty, "%sFirst event: %s\n", prefix, timeval_format(&backoff->first_event_time)); - vty_outln (vty, "%sLast event: %s", prefix, + vty_out (vty, "%sLast event: %s\n", prefix, timeval_format(&backoff->last_event_time)); } @@ -291,7 +291,7 @@ spf_backoff_write_config(struct vty *vty) if (debug_spf_backoff) { - vty_outln (vty, "debug spf-delay-ietf"); + vty_out (vty, "debug spf-delay-ietf\n"); written++; } diff --git a/lib/thread.c b/lib/thread.c index 4e72d4c96..2c87c099d 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -95,7 +95,7 @@ vty_out_cpu_thread_history(struct vty* vty, a->total_active, a->cpu.total/1000, a->cpu.total%1000, a->total_calls, a->cpu.total/a->total_calls, a->cpu.max, a->real.total/a->total_calls, a->real.max); - vty_outln (vty, " %c%c%c%c%c %s", + vty_out (vty, " %c%c%c%c%c %s\n", a->types & (1 << THREAD_READ) ? 'R':' ', a->types & (1 << THREAD_WRITE) ? 'W':' ', a->types & (1 << THREAD_TIMER) ? 'T':' ', @@ -147,13 +147,13 @@ cpu_record_print(struct vty *vty, thread_type filter) memset (underline, '-', sizeof (underline)); underline[sizeof(underline)] = '\0'; - vty_out (vty, VTYNL); - vty_outln(vty, "Showing statistics for pthread %s", name); - vty_outln(vty, "-------------------------------%s", underline); - vty_outln(vty, "%21s %18s %18s", "", "CPU (user+system):", "Real (wall-clock):"); + vty_out (vty, "\n"); + vty_out(vty, "Showing statistics for pthread %s\n", name); + vty_out(vty, "-------------------------------%s\n", underline); + vty_out(vty, "%21s %18s %18s\n", "", "CPU (user+system):", "Real (wall-clock):"); vty_out(vty, "Active Runtime(ms) Invoked Avg uSec Max uSecs"); vty_out(vty, " Avg uSec Max uSecs"); - vty_outln(vty, " Type Thread"); + vty_out(vty, " Type Thread\n"); if (m->cpu_record->count) hash_iterate(m->cpu_record, @@ -161,20 +161,20 @@ cpu_record_print(struct vty *vty, thread_type filter) cpu_record_hash_print, args); else - vty_outln(vty, "No data to display yet."); + vty_out(vty, "No data to display yet.\n"); - vty_out(vty, VTYNL); + vty_out(vty, "\n"); } } pthread_mutex_unlock (&masters_mtx); - vty_out(vty, VTYNL); - vty_outln(vty, "Total thread statistics"); - vty_outln(vty, "-------------------------"); - vty_outln(vty, "%21s %18s %18s", "", "CPU (user+system):", "Real (wall-clock):"); + vty_out(vty, "\n"); + vty_out(vty, "Total thread statistics\n"); + vty_out(vty, "-------------------------\n"); + vty_out(vty, "%21s %18s %18s\n", "", "CPU (user+system):", "Real (wall-clock):"); vty_out(vty, "Active Runtime(ms) Invoked Avg uSec Max uSecs"); vty_out(vty, " Avg uSec Max uSecs"); - vty_outln(vty, " Type Thread"); + vty_out(vty, " Type Thread\n"); if (tmp.total_calls > 0) vty_out_cpu_thread_history(vty, &tmp); @@ -270,8 +270,8 @@ DEFUN (show_thread_cpu, if (argv_find (argv, argc, "FILTER", &idx)) { filter = parse_filter (argv[idx]->arg); if (!filter) { - vty_outln(vty, "Invalid filter \"%s\" specified; must contain at least" - "one of 'RWTEXB'", argv[idx]->arg); + vty_out(vty, "Invalid filter \"%s\" specified; must contain at least" + "one of 'RWTEXB'\n", argv[idx]->arg); return CMD_WARNING; } } @@ -294,8 +294,8 @@ DEFUN (clear_thread_cpu, if (argv_find (argv, argc, "FILTER", &idx)) { filter = parse_filter (argv[idx]->arg); if (!filter) { - vty_outln(vty, "Invalid filter \"%s\" specified; must contain at least" - "one of 'RWTEXB'", argv[idx]->arg); + vty_out(vty, "Invalid filter \"%s\" specified; must contain at least" + "one of 'RWTEXB'\n", argv[idx]->arg); return CMD_WARNING; } } @@ -564,6 +564,12 @@ thread_master_free_unused (struct thread_master *m) void thread_master_free (struct thread_master *m) { + pthread_mutex_lock (&masters_mtx); + { + listnode_delete (masters, m); + } + pthread_mutex_unlock (&masters_mtx); + thread_array_free (m, m->read); thread_array_free (m, m->write); thread_queue_free (m, m->timer); @@ -474,9 +474,9 @@ DEFUN_NOSH (vrf, if (strlen(vrfname) > VRF_NAMSIZ) { vty_out (vty, "%% VRF name %s is invalid: length exceeds " - "%d characters%s", - vrfname, VRF_NAMSIZ, VTYNL); - return CMD_WARNING; + "%d characters\n", + vrfname, VRF_NAMSIZ); + return CMD_WARNING_CONFIG_FAILED; } vrfp = vrf_get (VRF_UNKNOWN, vrfname); @@ -501,15 +501,14 @@ DEFUN_NOSH (no_vrf, if (vrfp == NULL) { - vty_out (vty, "%% VRF %s does not exist%s", vrfname, VTYNL); - return CMD_WARNING; + vty_out (vty, "%% VRF %s does not exist\n", vrfname); + return CMD_WARNING_CONFIG_FAILED; } if (CHECK_FLAG (vrfp->status, VRF_ACTIVE)) { - vty_out (vty, "%% Only inactive VRFs can be deleted%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Only inactive VRFs can be deleted\n"); + return CMD_WARNING_CONFIG_FAILED; } vrf_delete(vrfp); @@ -555,7 +554,7 @@ static int vrf_write_host (struct vty *vty) { if (debug_vrf) - vty_outln (vty, "debug vrf"); + vty_out (vty, "debug vrf\n"); return 1; } @@ -115,12 +115,12 @@ extern vrf_id_t vrf_name_to_id (const char *); struct vrf *vrf; \ if (!(vrf = vrf_lookup_by_name(NAME))) \ { \ - vty_out (vty, "%% VRF %s not found%s", NAME, VTYNL);\ + vty_out (vty, "%% VRF %s not found\n", NAME);\ return CMD_WARNING; \ } \ if (vrf->vrf_id == VRF_UNKNOWN) \ { \ - vty_out (vty, "%% VRF %s not active%s", NAME, VTYNL);\ + vty_out (vty, "%% VRF %s not active\n", NAME);\ return CMD_WARNING; \ } \ (V) = vrf->vrf_id; \ @@ -92,23 +92,28 @@ char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG; static int do_log_commands = 0; -static int -vty_out_variadic (struct vty *vty, const char *format, va_list args) +/* VTY standard output function. */ +int +vty_out (struct vty *vty, const char *format, ...) { + va_list args; int len = 0; int size = 1024; char buf[1024]; char *p = NULL; - va_list cp; if (vty_shell (vty)) - vprintf (format, args); + { + va_start (args, format); + vprintf (format, args); + va_end (args); + } else { /* Try to write to initial buffer. */ - va_copy (cp, args); - len = vsnprintf (buf, sizeof(buf), format, cp); - va_end (cp); + va_start (args, format); + len = vsnprintf (buf, sizeof(buf), format, args); + va_end (args); /* Initial buffer is not enough. */ if (len < 0 || len >= size) @@ -124,9 +129,9 @@ vty_out_variadic (struct vty *vty, const char *format, va_list args) if (! p) return -1; - va_copy (cp, args); - len = vsnprintf (p, size, format, cp); - va_end (cp); + va_start (args, format); + len = vsnprintf (p, size, format, args); + va_end (args); if (len > -1 && len < size) break; @@ -138,7 +143,10 @@ vty_out_variadic (struct vty *vty, const char *format, va_list args) p = buf; /* Pointer p must point out buffer. */ - buffer_put (vty->obuf, (u_char *) p, len); + if (vty->type != VTY_TERM) + buffer_put (vty->obuf, (u_char *) p, len); + else + buffer_put_crlf (vty->obuf, (u_char *) p, len); /* If p is not different with buf, it is allocated buffer. */ if (p != buf) @@ -147,32 +155,6 @@ vty_out_variadic (struct vty *vty, const char *format, va_list args) return len; } -/* VTY standard output function. */ -int -vty_out (struct vty *vty, const char *format, ...) -{ - int len; - va_list args; - - va_start (args, format); - len = vty_out_variadic (vty, format, args); - va_end (args); - - return len; -} - -int -vty_outln (struct vty *vty, const char *format, ...) -{ - int len; - va_list args; - - va_start (args, format); - len = vty_out_variadic (vty, format, args); - va_end (args); - - return len + vty_out (vty, "%s", VTYNL); -} static int vty_log_out (struct vty *vty, const char *level, const char *proto_str, @@ -265,12 +247,12 @@ vty_hello (struct vty *vty) for (s = buf + strlen (buf); (s > buf) && isspace ((int)*(s - 1)); s--); *s = '\0'; - vty_outln (vty, "%s", buf); + vty_out (vty, "%s\n", buf); } fclose (f); } else - vty_outln (vty, "MOTD file not found"); + vty_out (vty, "MOTD file not found\n"); } else if (host.motd) vty_out (vty, "%s", host.motd); @@ -403,14 +385,14 @@ vty_auth (struct vty *vty, char *buf) { if (vty->node == AUTH_NODE) { - vty_outln (vty, "%% Bad passwords, too many failures!"); + vty_out (vty, "%% Bad passwords, too many failures!\n"); vty->status = VTY_CLOSE; } else { /* AUTH_ENABLE_NODE */ vty->fail = 0; - vty_outln (vty, "%% Bad enable passwords, too many failures!"); + vty_out (vty, "%% Bad enable passwords, too many failures!\n"); vty->status = VTY_CLOSE; } } @@ -495,16 +477,16 @@ vty_command (struct vty *vty, char *buf) { case CMD_WARNING: if (vty->type == VTY_FILE) - vty_outln (vty, "Warning..."); + vty_out (vty, "Warning...\n"); break; case CMD_ERR_AMBIGUOUS: - vty_outln (vty, "%% Ambiguous command."); + vty_out (vty, "%% Ambiguous command.\n"); break; case CMD_ERR_NO_MATCH: - vty_outln (vty, "%% [%s] Unknown command: %s", protocolname, buf); + vty_out (vty, "%% [%s] Unknown command: %s\n", protocolname, buf); break; case CMD_ERR_INCOMPLETE: - vty_outln (vty, "%% Command incomplete."); + vty_out (vty, "%% Command incomplete.\n"); break; } cmd_free_strvec (vline); @@ -732,7 +714,7 @@ vty_backward_word (struct vty *vty) static void vty_down_level (struct vty *vty) { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); cmd_exit (vty); vty_prompt (vty); vty->cp = 0; @@ -742,7 +724,7 @@ vty_down_level (struct vty *vty) static void vty_end_config (struct vty *vty) { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); switch (vty->node) { @@ -786,6 +768,7 @@ vty_end_config (struct vty *vty) case MASC_NODE: case PIM_NODE: case VTY_NODE: + case BGP_EVPN_VNI_NODE: vty_config_unlock (vty); vty->node = ENABLE_NODE; break; @@ -947,16 +930,16 @@ vty_complete_command (struct vty *vty) cmd_free_strvec (vline); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); switch (ret) { case CMD_ERR_AMBIGUOUS: - vty_outln (vty, "%% Ambiguous command."); + vty_out (vty, "%% Ambiguous command.\n"); vty_prompt (vty); vty_redraw_line (vty); break; case CMD_ERR_NO_MATCH: - /* vty_out (vty, "%% There is no matched command.%s", VTYNL); */ + /* vty_out (vty, "%% There is no matched command.\n"); */ vty_prompt (vty); vty_redraw_line (vty); break; @@ -964,7 +947,7 @@ vty_complete_command (struct vty *vty) if (!matched[0]) { /* 2016-11-28 equinox -- need to debug, SEGV here */ - vty_outln (vty, "%% CLI BUG: FULL_MATCH with NULL str"); + vty_out (vty, "%% CLI BUG: FULL_MATCH with NULL str\n"); vty_prompt (vty); vty_redraw_line (vty); break; @@ -987,11 +970,11 @@ vty_complete_command (struct vty *vty) for (i = 0; matched[i] != NULL; i++) { if (i != 0 && ((i % 6) == 0)) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, "%-10s ", matched[i]); XFREE (MTYPE_COMPLETION, matched[i]); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_prompt (vty); vty_redraw_line (vty); @@ -1019,7 +1002,7 @@ vty_describe_fold (struct vty *vty, int cmd_width, if (desc_width <= 0) { - vty_outln (vty, " %-*s %s", cmd_width, cmd, token->desc); + vty_out (vty, " %-*s %s\n", cmd_width, cmd, token->desc); return; } @@ -1036,12 +1019,12 @@ vty_describe_fold (struct vty *vty, int cmd_width, strncpy (buf, p, pos); buf[pos] = '\0'; - vty_outln (vty, " %-*s %s", cmd_width, cmd, buf); + vty_out (vty, " %-*s %s\n", cmd_width, cmd, buf); cmd = ""; } - vty_outln (vty, " %-*s %s", cmd_width, cmd, p); + vty_out (vty, " %-*s %s\n", cmd_width, cmd, p); XFREE (MTYPE_TMP, buf); } @@ -1070,17 +1053,17 @@ vty_describe_command (struct vty *vty) describe = cmd_describe_command (vline, vty, &ret); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); /* Ambiguous error. */ switch (ret) { case CMD_ERR_AMBIGUOUS: - vty_outln (vty, "%% Ambiguous command."); + vty_out (vty, "%% Ambiguous command.\n"); goto out; break; case CMD_ERR_NO_MATCH: - vty_outln (vty, "%% There is no matched command."); + vty_out (vty, "%% There is no matched command.\n"); goto out; break; } @@ -1118,10 +1101,10 @@ vty_describe_command (struct vty *vty) } if (!token->desc) - vty_outln (vty, " %-s", + vty_out (vty, " %-s\n", token->text); else if (desc_width >= strlen (token->desc)) - vty_outln (vty, " %-*s %s", width, + vty_out (vty, " %-*s %s\n", width, token->text, token->desc); else @@ -1134,33 +1117,29 @@ vty_describe_command (struct vty *vty) vector varcomps = vector_init (VECTOR_MIN_SIZE); cmd_variable_complete (token, ref, varcomps); - if (vector_active(varcomps) > 0) + if (vector_active (varcomps) > 0) { - vty_out(vty, " "); - for (size_t j = 0; j < vector_active (varcomps); j++) - { - char *item = vector_slot (varcomps, j); - vty_out(vty, " %s", item); - XFREE(MTYPE_COMPLETION, item); - } - vty_out (vty, VTYNL); + char *ac = cmd_variable_comp2str(varcomps, vty->width); + vty_out(vty, "%s\n", ac); + XFREE(MTYPE_TMP, ac); } + vector_free(varcomps); } #if 0 - vty_out (vty, " %-*s %s%s", width + vty_out (vty, " %-*s %s\n", width desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd, - desc->str ? desc->str : "", VTYNL); + desc->str ? desc->str : ""); #endif /* 0 */ } if ((token = token_cr)) { if (!token->desc) - vty_outln (vty, " %-s", + vty_out (vty, " %-s\n", token->text); else if (desc_width >= strlen (token->desc)) - vty_outln (vty, " %-*s %s", width, + vty_out (vty, " %-*s %s\n", width, token->text, token->desc); else @@ -1188,7 +1167,7 @@ vty_stop_input (struct vty *vty) { vty->cp = vty->length = 0; vty_clear_buf (vty); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); switch (vty->node) { @@ -1299,20 +1278,20 @@ vty_telnet_option (struct vty *vty, unsigned char *buf, int nbytes) vty_out (vty, "SE "); break; case TELOPT_ECHO: - vty_outln (vty, "TELOPT_ECHO "); + vty_out (vty, "TELOPT_ECHO \n"); break; case TELOPT_SGA: - vty_outln (vty, "TELOPT_SGA "); + vty_out (vty, "TELOPT_SGA \n"); break; case TELOPT_NAWS: - vty_outln (vty, "TELOPT_NAWS "); + vty_out (vty, "TELOPT_NAWS \n"); break; default: vty_out (vty, "%x ", buf[i]); break; } } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); #endif /* TELNET_OPTION_DEBUG */ @@ -1349,8 +1328,8 @@ vty_telnet_option (struct vty *vty, unsigned char *buf, int nbytes) vty->width = ((vty->sb_buf[1] << 8)|vty->sb_buf[2]); vty->height = ((vty->sb_buf[3] << 8)|vty->sb_buf[4]); #ifdef TELNET_OPTION_DEBUG - vty_outln (vty, "TELNET NAWS window size negotiation completed: " - "width %d, height %d", + vty_out (vty, "TELNET NAWS window size negotiation completed: " + "width %d, height %d\n", vty->width, vty->height); #endif } @@ -1608,7 +1587,7 @@ vty_read (struct thread *thread) break; case '\n': case '\r': - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_execute (vty); break; case '\t': @@ -1767,7 +1746,7 @@ vty_create (int vty_sock, union sockunion *su) /* Vty is not available if password isn't set. */ if (host.password == NULL && host.password_encrypt == NULL) { - vty_outln (vty, "Vty password is not set."); + vty_out (vty, "Vty password is not set.\n"); vty->status = VTY_CLOSE; vty_close (vty); return NULL; @@ -1777,8 +1756,7 @@ vty_create (int vty_sock, union sockunion *su) /* Say hello to the world. */ vty_hello (vty); if (! no_password_check) - vty_outln (vty, "%sUser Access Verification%s", VTYNL, - VTYNL); + vty_out (vty, "\nUser Access Verification\n\n"); /* Setting up terminal. */ vty_will_echo (vty); @@ -2195,7 +2173,7 @@ vtysh_read (struct thread *thread) /* Clear command line buffer. */ vty->cp = vty->length = 0; vty_clear_buf (vty); - vty_outln (vty, "%% Command is too long."); + vty_out (vty, "%% Command is too long.\n"); } else { @@ -2221,7 +2199,7 @@ vtysh_read (struct thread *thread) if (ret == CMD_SUSPEND) break; - /* warning: watchquagga hardcodes this result write */ + /* warning: watchfrr hardcodes this result write */ header[3] = ret; buffer_put(vty->obuf, header, 4); @@ -2338,7 +2316,7 @@ vty_timeout (struct thread *thread) /* Clear buffer*/ buffer_reset (vty->obuf); - vty_outln (vty, "%sVty connection is timed out.", VTYNL); + vty_out (vty, "\nVty connection is timed out.\n"); /* Close connection. */ vty->status = VTY_CLOSE; @@ -2719,9 +2697,9 @@ DEFUN_NOSH (config_who, for (i = 0; i < vector_active (vtyvec); i++) if ((v = vector_slot (vtyvec, i)) != NULL) - vty_out (vty, "%svty[%d] connected from %s.%s", + vty_out (vty, "%svty[%d] connected from %s.\n", v->config ? "*" : " ", - i, v->address, VTYNL); + i, v->address); return CMD_SUCCESS; } @@ -2819,8 +2797,8 @@ DEFUN (no_vty_access_class, const char *accesslist = (argc == 3) ? argv[idx_word]->arg : NULL; if (! vty_accesslist_name || (argc == 3 && strcmp(vty_accesslist_name, accesslist))) { - vty_outln (vty,"Access-class is not currently applied to vty"); - return CMD_WARNING; + vty_out (vty,"Access-class is not currently applied to vty\n"); + return CMD_WARNING_CONFIG_FAILED; } XFREE(MTYPE_VTY, vty_accesslist_name); @@ -2862,8 +2840,8 @@ DEFUN (no_vty_ipv6_access_class, if (! vty_ipv6_accesslist_name || (argc == 4 && strcmp(vty_ipv6_accesslist_name, accesslist))) { - vty_outln (vty,"IPv6 access-class is not currently applied to vty"); - return CMD_WARNING; + vty_out (vty,"IPv6 access-class is not currently applied to vty\n"); + return CMD_WARNING_CONFIG_FAILED; } XFREE(MTYPE_VTY, vty_ipv6_accesslist_name); @@ -2963,7 +2941,7 @@ DEFUN_NOSH (show_history, } if (vty->hist[index] != NULL) - vty_out (vty, " %s%s", vty->hist[index], VTYNL); + vty_out (vty, " %s\n", vty->hist[index]); index++; } @@ -2986,30 +2964,30 @@ DEFUN (log_commands, static int vty_config_write (struct vty *vty) { - vty_outln (vty, "line vty"); + vty_out (vty, "line vty\n"); if (vty_accesslist_name) - vty_outln (vty, " access-class %s", + vty_out (vty, " access-class %s\n", vty_accesslist_name); if (vty_ipv6_accesslist_name) - vty_outln (vty, " ipv6 access-class %s", + vty_out (vty, " ipv6 access-class %s\n", vty_ipv6_accesslist_name); /* exec-timeout */ if (vty_timeout_val != VTY_TIMEOUT_DEFAULT) - vty_outln (vty, " exec-timeout %ld %ld", + vty_out (vty, " exec-timeout %ld %ld\n", vty_timeout_val / 60, vty_timeout_val % 60); /* login */ if (no_password_check) - vty_outln (vty, " no login"); + vty_out (vty, " no login\n"); if (do_log_commands) - vty_outln (vty, "log commands"); + vty_out (vty, "log commands\n"); - vty_outln (vty, "!"); + vty_out (vty, "!\n"); return CMD_SUCCESS; } @@ -156,7 +156,7 @@ static inline void vty_push_context(struct vty *vty, #define VTY_CHECK_CONTEXT(ptr) \ if (!ptr) { \ vty_out (vty, "Current configuration object was deleted " \ - "by another process.%s", VTYNL); \ + "by another process.\n"); \ return CMD_WARNING; \ } @@ -179,8 +179,43 @@ struct vty_arg /* Integrated configuration file. */ #define INTEGRATE_DEFAULT_CONFIG "frr.conf" -/* Small macro to determine newline is newline only or linefeed needed. */ -#define VTYNL ((vty->type == VTY_TERM) ? "\r\n" : "\n") +/* for compatibility */ +#if defined(__ICC) +#define CPP_WARN_STR(X) #X +#define CPP_WARN(text) _Pragma(CPP_WARN_STR(message __FILE__ ": " text)) + +#elif (defined(__GNUC__) && \ + (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \ + (defined(__clang__) && \ + (__clang_major__ >= 4 || (__clang_major__ == 3 && __clang_minor__ >= 5))) +#define CPP_WARN_STR(X) #X +#define CPP_WARN(text) _Pragma(CPP_WARN_STR(GCC warning text)) + +#else +#define CPP_WARN(text) +#endif + +#define VNL "\n" \ + CPP_WARN("VNL has been replaced with \\n.") +#define VTYNL "\n" \ + CPP_WARN("VTYNL has been replaced with \\n.") +#define VTY_NEWLINE "\n" \ + CPP_WARN("VTY_NEWLINE has been replaced with \\n.") +#define VTY_GET_INTEGER(desc,v,str) {(v)=strtoul ((str), NULL, 10);} \ + CPP_WARN("VTY_GET_INTEGER is no longer useful, use strtoul() or DEFPY.") +#define VTY_GET_INTEGER_RANGE(desc,v,str,min,max) {(v)=strtoul ((str), NULL, 10);} \ + CPP_WARN("VTY_GET_INTEGER_RANGE is no longer useful, use strtoul() or DEFPY.") +#define VTY_GET_ULONG(desc,v,str) {(v)=strtoul ((str), NULL, 10);} \ + CPP_WARN("VTY_GET_ULONG is no longer useful, use strtoul() or DEFPY.") +#define VTY_GET_ULL(desc,v,str) {(v)=strtoull ((str), NULL, 10);} \ + CPP_WARN("VTY_GET_ULL is no longer useful, use strtoull() or DEFPY.") +#define VTY_GET_IPV4_ADDRESS(desc,v,str) inet_aton ((str), &(v)) \ + CPP_WARN("VTY_GET_IPV4_ADDRESS is no longer useful, use inet_aton() or DEFPY.") +#define VTY_GET_IPV4_PREFIX(desc,v,str) str2prefix_ipv4 ((str), &(v)) \ + CPP_WARN("VTY_GET_IPV4_PREFIX is no longer useful, use str2prefix_ipv4() or DEFPY.") +#define vty_outln(vty, str, ...) \ + vty_out(vty, str "\n", ## __VA_ARGS__) \ + CPP_WARN("vty_outln is no longer useful, use vty_out(...\\n...)") /* Default time out value */ #define VTY_TIMEOUT_DEFAULT 600 @@ -208,7 +243,6 @@ extern void vty_reset (void); extern struct vty *vty_new (void); extern struct vty *vty_stdio (void (*atclose)(void)); extern int vty_out (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3); -extern int vty_outln (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3); extern void vty_read_config (const char *, char *); extern void vty_time_print (struct vty *, int); extern void vty_serv_sock (const char *, unsigned short, const char *); diff --git a/lib/workqueue.c b/lib/workqueue.c index 374934419..3600df2f2 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -191,11 +191,11 @@ DEFUN (show_work_queues, struct listnode *node; struct work_queue *wq; - vty_outln (vty, - "%c %8s %5s %8s %8s %21s", + vty_out (vty, + "%c %8s %5s %8s %8s %21s\n", ' ', "List","(ms) ","Q. Runs","Yields","Cycle Counts "); - vty_outln (vty, - "%c %8s %5s %8s %8s %7s %6s %8s %6s %s", + vty_out (vty, + "%c %8s %5s %8s %8s %7s %6s %8s %6s %s\n", 'P', "Items", "Hold", @@ -205,7 +205,7 @@ DEFUN (show_work_queues, for (ALL_LIST_ELEMENTS_RO (work_queues, node, wq)) { - vty_outln (vty,"%c %8d %5d %8ld %8ld %7d %6d %8ld %6u %s", + vty_out (vty,"%c %8d %5d %8ld %8ld %7d %6d %8ld %6u %s\n", (CHECK_FLAG (wq->flags, WQ_UNPLUGGED) ? ' ' : 'P'), listcount (wq->items), wq->spec.hold, diff --git a/lib/zclient.c b/lib/zclient.c index 679b7004c..efe8f5662 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -2047,6 +2047,22 @@ zclient_read (struct thread *thread) if (zclient->fec_update) (*zclient->fec_update) (command, zclient, length); break; + case ZEBRA_VNI_ADD: + if (zclient->local_vni_add) + (*zclient->local_vni_add) (command, zclient, length, vrf_id); + break; + case ZEBRA_VNI_DEL: + if (zclient->local_vni_del) + (*zclient->local_vni_del) (command, zclient, length, vrf_id); + break; + case ZEBRA_MACIP_ADD: + if (zclient->local_macip_add) + (*zclient->local_macip_add) (command, zclient, length, vrf_id); + break; + case ZEBRA_MACIP_DEL: + if (zclient->local_macip_del) + (*zclient->local_macip_del) (command, zclient, length, vrf_id); + break; default: break; } diff --git a/lib/zclient.h b/lib/zclient.h index 59412fdd4..c7cc857ef 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -96,6 +96,15 @@ typedef enum { ZEBRA_FEC_REGISTER, ZEBRA_FEC_UNREGISTER, ZEBRA_FEC_UPDATE, + ZEBRA_ADVERTISE_ALL_VNI, + ZEBRA_VNI_ADD, + ZEBRA_VNI_DEL, + ZEBRA_REMOTE_VTEP_ADD, + ZEBRA_REMOTE_VTEP_DEL, + ZEBRA_MACIP_ADD, + ZEBRA_MACIP_DEL, + ZEBRA_REMOTE_MACIP_ADD, + ZEBRA_REMOTE_MACIP_DEL, } zebra_message_types_t; struct redist_proto @@ -167,6 +176,10 @@ struct zclient int (*redistribute_route_ipv6_add) (int, struct zclient *, uint16_t, vrf_id_t); int (*redistribute_route_ipv6_del) (int, struct zclient *, uint16_t, vrf_id_t); int (*fec_update) (int, struct zclient *, uint16_t); + int (*local_vni_add) (int, struct zclient *, uint16_t, vrf_id_t); + int (*local_vni_del) (int, struct zclient *, uint16_t, vrf_id_t); + int (*local_macip_add) (int, struct zclient *, uint16_t, vrf_id_t); + int (*local_macip_del) (int, struct zclient *, uint16_t, vrf_id_t); }; /* Zebra API message flag. */ diff --git a/lib/zebra.h b/lib/zebra.h index 901a49073..7f2609c12 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -126,7 +126,7 @@ typedef unsigned char u_int8_t; #define __APPLE_USE_RFC_3542 #endif -#include "lib/openbsd-tree.h" +#include "openbsd-tree.h" #include <netinet/in.h> #include <netinet/in_systm.h> diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index 5410027e7..af7fb0a50 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -83,9 +83,9 @@ static int nhrp_vty_return(struct vty *vty, int ret) snprintf(buf, sizeof(buf), "Unknown error %d", ret); } - vty_outln (vty, "%% %s", str); + vty_out (vty, "%% %s\n", str); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED;; } static int toggle_flag( @@ -104,8 +104,8 @@ static int toggle_flag( return CMD_SUCCESS; } - vty_outln (vty, "%% Invalid value %s", name); - return CMD_WARNING; + vty_out (vty, "%% Invalid value %s\n", name); + return CMD_WARNING_CONFIG_FAILED;; } #ifndef NO_DEBUG @@ -118,7 +118,7 @@ DEFUN(show_debugging_nhrp, show_debugging_nhrp_cmd, { int i; - vty_outln (vty, "NHRP debugging status:"); + vty_out (vty, "NHRP debugging status:\n"); for (i = 0; debug_flags_desc[i].str != NULL; i++) { if (debug_flags_desc[i].key == NHRP_DEBUG_ALL) @@ -126,7 +126,7 @@ DEFUN(show_debugging_nhrp, show_debugging_nhrp_cmd, if (!(debug_flags_desc[i].key & debug_flags)) continue; - vty_outln (vty, " NHRP %s debugging is on", + vty_out (vty, " NHRP %s debugging is on\n", debug_flags_desc[i].str); } @@ -158,7 +158,7 @@ static int nhrp_config_write(struct vty *vty) { #ifndef NO_DEBUG if (debug_flags == NHRP_DEBUG_ALL) { - vty_outln (vty, "debug nhrp all"); + vty_out (vty, "debug nhrp all\n"); } else { int i; @@ -167,19 +167,19 @@ static int nhrp_config_write(struct vty *vty) continue; if (!(debug_flags & debug_flags_desc[i].key)) continue; - vty_outln (vty, "debug nhrp %s", + vty_out (vty, "debug nhrp %s\n", debug_flags_desc[i].str); } } - vty_outln (vty, "!"); + vty_out (vty, "!\n"); #endif /* NO_DEBUG */ if (nhrp_event_socket_path) { - vty_outln (vty, "nhrp event socket %s", + vty_out (vty, "nhrp event socket %s\n", nhrp_event_socket_path); } if (netlink_nflog_group) { - vty_outln (vty, "nhrp nflog-group %d", + vty_out (vty, "nhrp nflog-group %d\n", netlink_nflog_group); } @@ -598,7 +598,7 @@ static void show_ip_nhrp_cache(struct nhrp_cache *c, void *pctx) return; if (!ctx->count) { - vty_outln (vty, "%-8s %-8s %-24s %-24s %-6s %s", + vty_out (vty, "%-8s %-8s %-24s %-24s %-6s %s\n", "Iface", "Type", "Protocol", @@ -608,7 +608,7 @@ static void show_ip_nhrp_cache(struct nhrp_cache *c, void *pctx) } ctx->count++; - vty_outln(ctx->vty, "%-8s %-8s %-24s %-24s %c%c%c %s", + vty_out(ctx->vty, "%-8s %-8s %-24s %-24s %c%c%c %s\n", c->ifp->name, nhrp_cache_type_str[c->cur.type], sockunion2str(&c->remote_addr, buf[0], sizeof buf[0]), @@ -626,7 +626,7 @@ static void show_ip_nhrp_nhs(struct nhrp_nhs *n, struct nhrp_registration *reg, char buf[2][SU_ADDRSTRLEN]; if (!ctx->count) { - vty_outln (vty, "%-8s %-24s %-16s %-16s", + vty_out (vty, "%-8s %-24s %-16s %-16s\n", "Iface", "FQDN", "NBMA", @@ -634,7 +634,7 @@ static void show_ip_nhrp_nhs(struct nhrp_nhs *n, struct nhrp_registration *reg, } ctx->count++; - vty_outln (vty, "%-8s %-24s %-16s %-16s", + vty_out (vty, "%-8s %-24s %-16s %-16s\n", n->ifp->name, n->nbma_fqdn, (reg && reg->peer) ? sockunion2str(®->peer->vc->remote.nbma, @@ -652,7 +652,7 @@ static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx) char buf1[PREFIX_STRLEN], buf2[SU_ADDRSTRLEN]; if (!ctx->count) { - vty_outln (vty, "%-8s %-24s %-24s %s", + vty_out (vty, "%-8s %-24s %-24s %s\n", "Type", "Prefix", "Via", @@ -661,7 +661,7 @@ static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx) ctx->count++; c = s->cache; - vty_outln(ctx->vty, "%-8s %-24s %-24s %s", + vty_out(ctx->vty, "%-8s %-24s %-24s %s\n", nhrp_cache_type_str[s->type], prefix2str(s->p, buf1, sizeof buf1), c ? sockunion2str(&c->remote_addr, buf2, sizeof buf2) : "", @@ -677,32 +677,30 @@ static void show_ip_opennhrp_cache(struct nhrp_cache *c, void *pctx) if (ctx->afi != family2afi(sockunion_family(&c->remote_addr))) return; - vty_outln(ctx->vty, - "Type: %s%s" - "Flags:%s%s%s" - "Protocol-Address: %s/%zu", + vty_out(ctx->vty, + "Type: %s\n" + "Flags:%s%s\n" + "Protocol-Address: %s/%zu\n", nhrp_cache_type_str[c->cur.type], - VTYNL, (c->cur.peer && c->cur.peer->online) ? " up": "", c->used ? " used": "", - VTYNL, sockunion2str(&c->remote_addr, buf, sizeof buf), 8 * family2addrsize(sockunion_family(&c->remote_addr))); if (c->cur.peer) { - vty_outln(ctx->vty, - "NBMA-Address: %s", + vty_out(ctx->vty, + "NBMA-Address: %s\n", sockunion2str(&c->cur.peer->vc->remote.nbma, buf, sizeof buf)); } if (sockunion_family(&c->cur.remote_nbma_natoa) != AF_UNSPEC) { - vty_outln(ctx->vty, - "NBMA-NAT-OA-Address: %s", + vty_out(ctx->vty, + "NBMA-NAT-OA-Address: %s\n", sockunion2str(&c->cur.remote_nbma_natoa, buf, sizeof buf)); } - vty_outln(ctx->vty, VTYNL); + vty_out(ctx->vty, "\n\n"); } DEFUN(show_ip_nhrp, show_ip_nhrp_cmd, @@ -731,14 +729,14 @@ DEFUN(show_ip_nhrp, show_ip_nhrp_cmd, } else if (argv[3]->text[0] == 's') { nhrp_shortcut_foreach(ctx.afi, show_ip_nhrp_shortcut, &ctx); } else { - vty_outln (vty, "Status: ok%s", VTYNL); + vty_out (vty, "Status: ok\n\n"); ctx.count++; for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) nhrp_cache_foreach(ifp, show_ip_opennhrp_cache, &ctx); } if (!ctx.count) { - vty_outln (vty, "%% No entries"); + vty_out (vty, "%% No entries\n"); return CMD_WARNING; } @@ -750,7 +748,7 @@ static void show_dmvpn_entry(struct nhrp_vc *vc, void *ctx) struct vty *vty = ctx; char buf[2][SU_ADDRSTRLEN]; - vty_outln (vty, "%-24s %-24s %c %-4d %-24s", + vty_out (vty, "%-24s %-24s %c %-4d %-24s\n", sockunion2str(&vc->local.nbma, buf[0], sizeof buf[0]), sockunion2str(&vc->remote.nbma, buf[1], sizeof buf[1]), notifier_active(&vc->notifier_list) ? 'n' : ' ', @@ -763,7 +761,7 @@ DEFUN(show_dmvpn, show_dmvpn_cmd, SHOW_STR "DMVPN information\n") { - vty_outln (vty, "%-24s %-24s %-6s %-4s %-24s", + vty_out (vty, "%-24s %-24s %-6s %-4s %-24s\n", "Src", "Dst", "Flags", @@ -815,11 +813,11 @@ DEFUN(clear_nhrp, clear_nhrp_cmd, } if (!ctx.count) { - vty_outln (vty, "%% No entries"); + vty_out (vty, "%% No entries\n"); return CMD_WARNING; } - vty_outln (vty, "%% %d entries cleared", ctx.count); + vty_out (vty, "%% %d entries cleared\n", ctx.count); return CMD_SUCCESS; } @@ -838,7 +836,7 @@ static void interface_config_write_nhrp_map(struct nhrp_cache *c, void *data) if (!c->map) return; if (sockunion_family(&c->remote_addr) != ctx->family) return; - vty_outln (vty, " %s nhrp map %s %s", + vty_out (vty, " %s nhrp map %s %s\n", ctx->aficmd, sockunion2str(&c->remote_addr, buf[0], sizeof buf[0]), c->cur.type == NHRP_CACHE_LOCAL ? "local" : sockunion2str(&c->cur.peer->vc->remote.nbma, buf[1], sizeof buf[1])); @@ -857,9 +855,9 @@ static int interface_config_write(struct vty *vty) int i; for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) { - vty_outln (vty, "interface %s", ifp->name); + vty_out (vty, "interface %s\n", ifp->name); if (ifp->desc) - vty_outln (vty, " description %s", ifp->desc); + vty_out (vty, " description %s\n", ifp->desc); nifp = ifp->info; if (nifp->ipsec_profile) { @@ -868,10 +866,10 @@ static int interface_config_write(struct vty *vty) if (nifp->ipsec_fallback_profile) vty_out(vty, " fallback-profile %s", nifp->ipsec_fallback_profile); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (nifp->source) - vty_outln (vty, " tunnel source %s", + vty_out (vty, " tunnel source %s\n", nifp->source); for (afi = 0; afi < AFI_MAX; afi++) { @@ -880,24 +878,24 @@ static int interface_config_write(struct vty *vty) aficmd = afi_to_cmd(afi); if (ad->network_id) - vty_outln (vty, " %s nhrp network-id %u", + vty_out (vty, " %s nhrp network-id %u\n", aficmd,ad->network_id); if (ad->holdtime != NHRPD_DEFAULT_HOLDTIME) - vty_outln (vty, " %s nhrp holdtime %u", + vty_out (vty, " %s nhrp holdtime %u\n", aficmd,ad->holdtime); if (ad->configured_mtu < 0) - vty_outln (vty, " %s nhrp mtu opennhrp", + vty_out (vty, " %s nhrp mtu opennhrp\n", aficmd); else if (ad->configured_mtu) - vty_outln (vty, " %s nhrp mtu %u", + vty_out (vty, " %s nhrp mtu %u\n", aficmd,ad->configured_mtu); for (i = 0; interface_flags_desc[i].str != NULL; i++) { if (!(ad->flags & interface_flags_desc[i].key)) continue; - vty_outln (vty, " %s nhrp %s", + vty_out (vty, " %s nhrp %s\n", aficmd, interface_flags_desc[i].str); } @@ -909,14 +907,14 @@ static int interface_config_write(struct vty *vty) nhrp_cache_foreach(ifp, interface_config_write_nhrp_map, &mapctx); list_for_each_entry(nhs, &ad->nhslist_head, nhslist_entry) { - vty_outln (vty, " %s nhrp nhs %s nbma %s", + vty_out (vty, " %s nhrp nhs %s nbma %s\n", aficmd, sockunion_family(&nhs->proto_addr) == AF_UNSPEC ? "dynamic" : sockunion2str(&nhs->proto_addr, buf, sizeof buf), nhs->nbma_fqdn); } } - vty_outln (vty, "!"); + vty_out (vty, "!\n"); } return 0; diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 5ef6604cc..2e195d0af 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -1062,16 +1062,16 @@ ospf6_inter_area_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) prefix_lsa = (struct ospf6_inter_prefix_lsa *) OSPF6_LSA_HEADER_END (lsa->header); - vty_out (vty, " Metric: %lu%s", - (u_long) OSPF6_ABR_SUMMARY_METRIC (prefix_lsa), VNL); + vty_out (vty, " Metric: %lu\n", + (u_long) OSPF6_ABR_SUMMARY_METRIC (prefix_lsa)); ospf6_prefix_options_printbuf (prefix_lsa->prefix.prefix_options, buf, sizeof (buf)); - vty_out (vty, " Prefix Options: %s%s", buf, VNL); + vty_out (vty, " Prefix Options: %s\n", buf); - vty_out (vty, " Prefix: %s%s", + vty_out (vty, " Prefix: %s\n", ospf6_inter_area_prefix_lsa_get_prefix_str (lsa, buf, sizeof(buf), - 0), VNL); + 0)); return 0; } @@ -1105,12 +1105,12 @@ ospf6_inter_area_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) OSPF6_LSA_HEADER_END (lsa->header); ospf6_options_printbuf (router_lsa->options, buf, sizeof (buf)); - vty_out (vty, " Options: %s%s", buf, VNL); - vty_out (vty, " Metric: %lu%s", - (u_long) OSPF6_ABR_SUMMARY_METRIC (router_lsa), VNL); + vty_out (vty, " Options: %s\n", buf); + vty_out (vty, " Metric: %lu\n", + (u_long) OSPF6_ABR_SUMMARY_METRIC (router_lsa)); inet_ntop (AF_INET, &router_lsa->router_id, buf, sizeof (buf)); - vty_out (vty, " Destination Router ID: %s%s", buf, VNL); + vty_out (vty, " Destination Router ID: %s\n", buf); return 0; } @@ -1145,7 +1145,7 @@ int config_write_ospf6_debug_abr (struct vty *vty) { if (IS_OSPF6_DEBUG_ABR) - vty_out (vty, "debug ospf6 abr%s", VNL); + vty_out (vty, "debug ospf6 abr\n"); return 0; } diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 826a66ccc..8e6408bf4 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -371,43 +371,43 @@ ospf6_area_show (struct vty *vty, struct ospf6_area *oa) unsigned long result; if (!IS_AREA_STUB (oa)) - vty_out (vty, " Area %s%s", oa->name, VNL); + vty_out (vty, " Area %s\n", oa->name); else { if (oa->no_summary) { - vty_out (vty, " Area %s[Stub, No Summary]%s", oa->name, VNL); + vty_out (vty, " Area %s[Stub, No Summary]\n", oa->name); } else { - vty_out (vty, " Area %s[Stub]%s", oa->name, VNL); + vty_out (vty, " Area %s[Stub]\n", oa->name); } } - vty_out (vty, " Number of Area scoped LSAs is %u%s", - oa->lsdb->count, VNL); + vty_out (vty, " Number of Area scoped LSAs is %u\n", + oa->lsdb->count); vty_out (vty, " Interface attached to this area:"); for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi)) vty_out (vty, " %s", oi->interface->name); - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); if (oa->ts_spf.tv_sec || oa->ts_spf.tv_usec) { result = monotime_since(&oa->ts_spf, NULL); if (result/TIMER_SECOND_MICRO > 0) { - vty_outln (vty, "SPF last executed %ld.%lds ago", + vty_out (vty, "SPF last executed %ld.%lds ago\n", result/TIMER_SECOND_MICRO, result % TIMER_SECOND_MICRO); } else { - vty_outln (vty, "SPF last executed %ldus ago", + vty_out (vty, "SPF last executed %ldus ago\n", result); } } else - vty_outln (vty, "SPF has not been run"); + vty_out (vty, "SPF has not been run\n"); } @@ -417,7 +417,7 @@ ospf6_area_show (struct vty *vty, struct ospf6_area *oa) u_int32_t area_id = htonl (strtoul (str, &ep, 10)); \ if (*ep && inet_pton (AF_INET, str, &area_id) != 1) \ { \ - vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \ + vty_out (vty, "Malformed Area-ID: %s\n", str); \ return CMD_SUCCESS; \ } \ int format = !*ep ? OSPF6_AREA_FMT_DECIMAL : \ @@ -454,7 +454,7 @@ DEFUN (area_range, ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &prefix); if (ret != 1 || prefix.family != AF_INET6) { - vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv6_prefixlen]->arg, VNL); + vty_out (vty, "Malformed argument: %s\n", argv[idx_ipv6_prefixlen]->arg); return CMD_SUCCESS; } @@ -528,14 +528,14 @@ DEFUN (no_area_range, ret = str2prefix (argv[idx_ipv6]->arg, &prefix); if (ret != 1 || prefix.family != AF_INET6) { - vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv6]->arg, VNL); + vty_out (vty, "Malformed argument: %s\n", argv[idx_ipv6]->arg); return CMD_SUCCESS; } range = ospf6_route_lookup (&prefix, oa->range_table); if (range == NULL) { - vty_out (vty, "Range %s does not exists.%s", argv[idx_ipv6]->arg, VNL); + vty_out (vty, "Range %s does not exists.\n", argv[idx_ipv6]->arg); return CMD_SUCCESS; } @@ -583,28 +583,28 @@ ospf6_area_config_write (struct vty *vty) if (range->path.u.cost_config != OSPF_AREA_RANGE_COST_UNSPEC) vty_out (vty, " cost %d", range->path.u.cost_config); } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); } if (IS_AREA_STUB (oa)) { if (oa->no_summary) - vty_out (vty, " area %s stub no-summary%s", oa->name, VNL); + vty_out (vty, " area %s stub no-summary\n", oa->name); else - vty_out (vty, " area %s stub%s", oa->name, VNL); + vty_out (vty, " area %s stub\n", oa->name); } if (PREFIX_NAME_IN (oa)) - vty_out (vty, " area %s filter-list prefix %s in%s", - oa->name, PREFIX_NAME_IN (oa), VNL); + vty_out (vty, " area %s filter-list prefix %s in\n", + oa->name, PREFIX_NAME_IN (oa)); if (PREFIX_NAME_OUT (oa)) - vty_out (vty, " area %s filter-list prefix %s out%s", - oa->name, PREFIX_NAME_OUT (oa), VNL); + vty_out (vty, " area %s filter-list prefix %s out\n", + oa->name, PREFIX_NAME_OUT (oa)); if (IMPORT_NAME (oa)) - vty_out (vty, " area %s import-list %s%s", - oa->name, IMPORT_NAME (oa), VNL); + vty_out (vty, " area %s import-list %s\n", + oa->name, IMPORT_NAME (oa)); if (EXPORT_NAME (oa)) - vty_out (vty, " area %s export-list %s%s", - oa->name, EXPORT_NAME (oa), VNL); + vty_out (vty, " area %s export-list %s\n", + oa->name, EXPORT_NAME (oa)); } } @@ -831,8 +831,8 @@ DEFUN (show_ipv6_ospf6_spf_tree, route = ospf6_route_lookup (&prefix, oa->spf_table); if (route == NULL) { - vty_out (vty, "LS entry for root not found in area %s%s", - oa->name, VNL); + vty_out (vty, "LS entry for root not found in area %s\n", + oa->name); continue; } root = (struct ospf6_vertex *) route->route_option; @@ -866,21 +866,21 @@ DEFUN (show_ipv6_ospf6_area_spf_tree, if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { - vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); + vty_out (vty, "Malformed Area-ID: %s\n", argv[idx_ipv4]->arg); return CMD_SUCCESS; } oa = ospf6_area_lookup (area_id, ospf6); if (oa == NULL) { - vty_out (vty, "No such Area: %s%s", argv[idx_ipv4]->arg, VNL); + vty_out (vty, "No such Area: %s\n", argv[idx_ipv4]->arg); return CMD_SUCCESS; } route = ospf6_route_lookup (&prefix, oa->spf_table); if (route == NULL) { - vty_out (vty, "LS entry for root not found in area %s%s", - oa->name, VNL); + vty_out (vty, "LS entry for root not found in area %s\n", + oa->name); return CMD_SUCCESS; } root = (struct ospf6_vertex *) route->route_option; @@ -919,13 +919,13 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, if (inet_pton (AF_INET, argv[idx_ipv4_2]->arg, &area_id) != 1) { - vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4_2]->arg, VNL); + vty_out (vty, "Malformed Area-ID: %s\n", argv[idx_ipv4_2]->arg); return CMD_SUCCESS; } oa = ospf6_area_lookup (area_id, ospf6); if (oa == NULL) { - vty_out (vty, "No such Area: %s%s", argv[idx_ipv4_2]->arg, VNL); + vty_out (vty, "No such Area: %s\n", argv[idx_ipv4_2]->arg); return CMD_SUCCESS; } @@ -968,8 +968,8 @@ DEFUN (ospf6_area_stub, if (!ospf6_area_stub_set (ospf6, area)) { - vty_outln (vty,"First deconfigure all virtual link through this area"); - return CMD_WARNING; + vty_out (vty,"First deconfigure all virtual link through this area\n"); + return CMD_WARNING_CONFIG_FAILED; } ospf6_area_no_summary_unset (ospf6, area); @@ -993,8 +993,8 @@ DEFUN (ospf6_area_stub_no_summary, if (!ospf6_area_stub_set (ospf6, area)) { - vty_outln (vty,"First deconfigure all virtual link through this area"); - return CMD_WARNING; + vty_out (vty,"First deconfigure all virtual link through this area\n"); + return CMD_WARNING_CONFIG_FAILED; } ospf6_area_no_summary_set (ospf6, area); diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index f04c13209..3404ba020 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -691,7 +691,7 @@ DEFUN (ospf6_redistribute, char *proto = argv[argc - 1]->text; type = proto_redistnum(AFI_IP6, proto); if (type < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ospf6_asbr_redistribute_unset (type); ospf6_asbr_redistribute_set (type); @@ -713,7 +713,7 @@ DEFUN (ospf6_redistribute_routemap, char *proto = argv[idx_protocol]->text; type = proto_redistnum(AFI_IP6, proto); if (type < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ospf6_asbr_redistribute_unset (type); ospf6_asbr_routemap_set (type, argv[idx_word]->arg); @@ -736,7 +736,7 @@ DEFUN (no_ospf6_redistribute, char *proto = argv[idx_protocol]->text; type = proto_redistnum(AFI_IP6, proto); if (type < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ospf6_asbr_redistribute_unset (type); @@ -756,11 +756,11 @@ ospf6_redistribute_config_write (struct vty *vty) continue; if (ospf6->rmap[type].name) - vty_out (vty, " redistribute %s route-map %s%s", - ZROUTE_NAME (type), ospf6->rmap[type].name, VNL); + vty_out (vty, " redistribute %s route-map %s\n", + ZROUTE_NAME (type), ospf6->rmap[type].name); else - vty_out (vty, " redistribute %s%s", - ZROUTE_NAME (type), VNL); + vty_out (vty, " redistribute %s\n", + ZROUTE_NAME (type)); } return 0; @@ -786,7 +786,7 @@ ospf6_redistribute_show_config (struct vty *vty) total++; } - vty_out (vty, "Redistributing External Routes from:%s", VNL); + vty_out (vty, "Redistributing External Routes from:\n"); for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { if (type == ZEBRA_ROUTE_OSPF6) @@ -795,15 +795,14 @@ ospf6_redistribute_show_config (struct vty *vty) continue; if (ospf6->rmap[type].name) - vty_out (vty, " %d: %s with route-map \"%s\"%s%s", nroute[type], + vty_out (vty, " %d: %s with route-map \"%s\"%s\n", nroute[type], ZROUTE_NAME (type), ospf6->rmap[type].name, - (ospf6->rmap[type].map ? "" : " (not found !)"), - VNL); + (ospf6->rmap[type].map ? "" : " (not found !)")); else - vty_out (vty, " %d: %s%s", nroute[type], - ZROUTE_NAME (type), VNL); + vty_out (vty, " %d: %s\n", nroute[type], + ZROUTE_NAME (type)); } - vty_out (vty, "Total %d routes%s", total, VNL); + vty_out (vty, "Total %d routes\n", total); } @@ -1079,16 +1078,16 @@ route_map_command_status (struct vty *vty, int ret) switch (ret) { case RMAP_RULE_MISSING: - vty_out (vty, "OSPF6 Can't find rule.%s", VNL); + vty_out (vty, "OSPF6 Can't find rule.\n"); break; case RMAP_COMPILE_ERROR: - vty_out (vty, "OSPF6 Argument is malformed.%s", VNL); + vty_out (vty, "OSPF6 Argument is malformed.\n"); break; default: - vty_out (vty, "OSPF6 route-map add set failed.%s", VNL); + vty_out (vty, "OSPF6 route-map add set failed.\n"); break; } - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* add "set metric-type" */ @@ -1244,35 +1243,31 @@ ospf6_as_external_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_F) ? 'F' : '-'), (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T' : '-')); - vty_out (vty, " Bits: %s%s", buf, VNL); - vty_out (vty, " Metric: %5lu%s", (u_long) OSPF6_ASBR_METRIC (external), - VNL); + vty_out (vty, " Bits: %s\n", buf); + vty_out (vty, " Metric: %5lu\n", (u_long) OSPF6_ASBR_METRIC (external)); ospf6_prefix_options_printbuf (external->prefix.prefix_options, buf, sizeof (buf)); - vty_out (vty, " Prefix Options: %s%s", buf, - VNL); + vty_out (vty, " Prefix Options: %s\n", buf); - vty_out (vty, " Referenced LSType: %d%s", - ntohs (external->prefix.prefix_refer_lstype), - VNL); + vty_out (vty, " Referenced LSType: %d\n", + ntohs (external->prefix.prefix_refer_lstype)); - vty_out (vty, " Prefix: %s%s", - ospf6_as_external_lsa_get_prefix_str (lsa, buf, sizeof(buf), 0), VNL); + vty_out (vty, " Prefix: %s\n", + ospf6_as_external_lsa_get_prefix_str (lsa, buf, sizeof(buf), 0)); /* Forwarding-Address */ if (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_F)) { - vty_out (vty, " Forwarding-Address: %s%s", - ospf6_as_external_lsa_get_prefix_str (lsa, buf, sizeof(buf), 1), - VNL); + vty_out (vty, " Forwarding-Address: %s\n", + ospf6_as_external_lsa_get_prefix_str (lsa, buf, sizeof(buf), 1)); } /* Tag */ if (CHECK_FLAG (external->bits_metric, OSPF6_ASBR_BIT_T)) { - vty_out (vty, " Tag: %"ROUTE_TAG_PRI"%s", - ospf6_as_external_lsa_get_tag (lsa), VNL); + vty_out (vty, " Tag: %"ROUTE_TAG_PRI"\n", + ospf6_as_external_lsa_get_tag (lsa)); } return 0; @@ -1294,12 +1289,12 @@ ospf6_asbr_external_route_show (struct vty *vty, struct ospf6_route *route) snprintf (forwarding, sizeof (forwarding), ":: (ifindex %d)", ospf6_route_get_first_nh_index (route)); - vty_out (vty, "%c %-32s %-15s type-%d %5lu %s%s", + vty_out (vty, "%c %-32s %-15s type-%d %5lu %s\n", zebra_route_char(info->type), prefix, id, route->path.metric_type, (u_long) (route->path.metric_type == 2 ? route->path.u.cost_e2 : route->path.cost), - forwarding, VNL); + forwarding); } DEFUN (show_ipv6_ospf6_redistribute, @@ -1396,7 +1391,7 @@ int config_write_ospf6_debug_asbr (struct vty *vty) { if (IS_OSPF6_DEBUG_ASBR) - vty_out (vty, "debug ospf6 asbr%s", VNL); + vty_out (vty, "debug ospf6 asbr\n"); return 0; } diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c index 6ca56869d..f460bf065 100644 --- a/ospf6d/ospf6_bfd.c +++ b/ospf6d/ospf6_bfd.c @@ -295,11 +295,11 @@ ospf6_bfd_write_config(struct vty *vty, struct ospf6_interface *oi) bfd_info = (struct bfd_info *)oi->bfd_info; if (CHECK_FLAG(bfd_info->flags, BFD_FLAG_PARAM_CFG)) - vty_outln (vty, " ipv6 ospf6 bfd %d %d %d", + vty_out (vty, " ipv6 ospf6 bfd %d %d %d\n", bfd_info->detect_mult, bfd_info->required_min_rx, bfd_info->desired_min_tx); else - vty_outln (vty, " ipv6 ospf6 bfd"); + vty_out (vty, " ipv6 ospf6 bfd\n"); } /* diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c index 8a8dcfcd2..f816c6f48 100644 --- a/ospf6d/ospf6_flood.c +++ b/ospf6d/ospf6_flood.c @@ -1032,7 +1032,7 @@ int config_write_ospf6_debug_flood (struct vty *vty) { if (IS_OSPF6_DEBUG_FLOODING) - vty_out (vty, "debug ospf6 flooding%s", VNL); + vty_out (vty, "debug ospf6 flooding\n"); return 0; } diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index bff320008..ab5b4f935 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -917,20 +917,19 @@ ospf6_interface_show (struct vty *vty, struct interface *ifp) else type = "UNKNOWN"; - vty_out (vty, "%s is %s, type %s%s", - ifp->name, updown[if_is_operative (ifp)], type, - VNL); - vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL); + vty_out (vty, "%s is %s, type %s\n", + ifp->name, updown[if_is_operative (ifp)], type); + vty_out (vty, " Interface ID: %d\n", ifp->ifindex); if (ifp->info == NULL) { - vty_out (vty, " OSPF not enabled on this interface%s", VNL); + vty_out (vty, " OSPF not enabled on this interface\n"); return 0; } else oi = (struct ospf6_interface *) ifp->info; - vty_out (vty, " Internet Address:%s", VNL); + vty_out (vty, " Internet Address:\n"); for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c)) { @@ -939,49 +938,43 @@ ospf6_interface_show (struct vty *vty, struct interface *ifp) switch (p->family) { case AF_INET: - vty_out (vty, " inet : %s%s", strbuf, - VNL); + vty_out (vty, " inet : %s\n", strbuf); break; case AF_INET6: - vty_out (vty, " inet6: %s%s", strbuf, - VNL); + vty_out (vty, " inet6: %s\n", strbuf); break; default: - vty_out (vty, " ??? : %s%s", strbuf, - VNL); + vty_out (vty, " ??? : %s\n", strbuf); break; } } if (oi->area) { - vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s", - oi->instance_id, oi->ifmtu, ifp->mtu6, VNL); - vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ? - "disabled" : "enabled", VNL); + vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)\n", + oi->instance_id, oi->ifmtu, ifp->mtu6); + vty_out (vty, " MTU mismatch detection: %s\n", oi->mtu_ignore ? + "disabled" : "enabled"); inet_ntop (AF_INET, &oi->area->area_id, strbuf, sizeof (strbuf)); - vty_out (vty, " Area ID %s, Cost %u%s", strbuf, oi->cost, - VNL); + vty_out (vty, " Area ID %s, Cost %u\n", strbuf, oi->cost); } else - vty_out (vty, " Not Attached to Area%s", VNL); + vty_out (vty, " Not Attached to Area\n"); - vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s", + vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d\n", ospf6_interface_state_str[oi->state], - oi->transdelay, oi->priority, - VNL); - vty_out (vty, " Timer intervals configured:%s", VNL); - vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s", - oi->hello_interval, oi->dead_interval, oi->rxmt_interval, - VNL); + oi->transdelay, oi->priority); + vty_out (vty, " Timer intervals configured:\n"); + vty_out (vty, " Hello %d, Dead %d, Retransmit %d\n", + oi->hello_interval, oi->dead_interval, oi->rxmt_interval); inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter)); inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter)); - vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL); + vty_out (vty, " DR: %s BDR: %s\n", drouter, bdrouter); - vty_out (vty, " Number of I/F scoped LSAs is %u%s", - oi->lsdb->count, VNL); + vty_out (vty, " Number of I/F scoped LSAs is %u\n", + oi->lsdb->count); monotime(&now); @@ -989,23 +982,21 @@ ospf6_interface_show (struct vty *vty, struct interface *ifp) if (oi->thread_send_lsupdate) timersub (&oi->thread_send_lsupdate->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", + vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n", oi->lsupdate_list->count, duration, - (oi->thread_send_lsupdate ? "on" : "off"), - VNL); + (oi->thread_send_lsupdate ? "on" : "off")); for (ALL_LSDB(oi->lsupdate_list, lsa)) - vty_out (vty, " %s%s", lsa->name, VNL); + vty_out (vty, " %s\n", lsa->name); timerclear (&res); if (oi->thread_send_lsack) timersub (&oi->thread_send_lsack->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", + vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]\n", oi->lsack_list->count, duration, - (oi->thread_send_lsack ? "on" : "off"), - VNL); + (oi->thread_send_lsack ? "on" : "off")); for (ALL_LSDB(oi->lsack_list, lsa)) - vty_out (vty, " %s%s", lsa->name, VNL); + vty_out (vty, " %s\n", lsa->name); ospf6_bfd_show_info(vty, oi->bfd_info, 1); return 0; } @@ -1029,8 +1020,7 @@ DEFUN (show_ipv6_ospf6_interface, ifp = if_lookup_by_name (argv[idx_ifname]->arg, VRF_DEFAULT); if (ifp == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, - VNL); + vty_out (vty, "No such Interface: %s\n", argv[idx_ifname]->arg); return CMD_WARNING; } ospf6_interface_show (vty, ifp); @@ -1066,14 +1056,14 @@ DEFUN (show_ipv6_ospf6_interface_ifname_prefix, ifp = if_lookup_by_name (argv[idx_ifname]->arg, VRF_DEFAULT); if (ifp == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL); + vty_out (vty, "No such Interface: %s\n", argv[idx_ifname]->arg); return CMD_WARNING; } oi = ifp->info; if (oi == NULL) { - vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[idx_ifname]->arg, VNL); + vty_out (vty, "OSPFv3 is not enabled on %s\n", argv[idx_ifname]->arg); return CMD_WARNING; } @@ -1143,9 +1133,9 @@ DEFUN (ipv6_ospf6_ifmtu, if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu) { - vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s", - ifp->name, ifp->mtu6, VNL); - return CMD_WARNING; + vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)\n", + ifp->name, ifp->mtu6); + return CMD_WARNING_CONFIG_FAILED; } if (oi->ifmtu < ifmtu) @@ -1153,8 +1143,8 @@ DEFUN (ipv6_ospf6_ifmtu, iobuflen = ospf6_iobuf_size (ifmtu); if (iobuflen < ifmtu) { - vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s", - ifp->name, iobuflen, VNL); + vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).\n", + ifp->name, iobuflen); oi->ifmtu = oi->c_ifmtu = iobuflen; } else @@ -1201,8 +1191,8 @@ DEFUN (no_ipv6_ospf6_ifmtu, iobuflen = ospf6_iobuf_size (ifp->mtu); if (iobuflen < ifp->mtu) { - vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s", - ifp->name, iobuflen, VNL); + vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).\n", + ifp->name, iobuflen); oi->ifmtu = iobuflen; } else @@ -1248,8 +1238,8 @@ DEFUN (ipv6_ospf6_cost, if (lcost > UINT32_MAX) { - vty_out (vty, "Cost %ld is out of range%s", lcost, VNL); - return CMD_WARNING; + vty_out (vty, "Cost %ld is out of range\n", lcost); + return CMD_WARNING_CONFIG_FAILED; } if (oi->cost == lcost) @@ -1305,8 +1295,8 @@ DEFUN (auto_cost_reference_bandwidth, refbw = strtol (argv[idx_number]->arg, NULL, 10); if (refbw < 1 || refbw > 4294967) { - vty_outln (vty, "reference-bandwidth value is invalid"); - return CMD_WARNING; + vty_out (vty, "reference-bandwidth value is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } /* If reference bandwidth is changed. */ @@ -1767,63 +1757,63 @@ config_write_ospf6_interface (struct vty *vty) if (oi == NULL) continue; - vty_out (vty, "interface %s%s", - oi->interface->name, VNL); + vty_out (vty, "interface %s\n", + oi->interface->name); if (ifp->desc) - vty_out (vty, " description %s%s", ifp->desc, VNL); + vty_out (vty, " description %s\n", ifp->desc); if (oi->c_ifmtu) - vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->c_ifmtu, VNL); + vty_out (vty, " ipv6 ospf6 ifmtu %d\n", oi->c_ifmtu); if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_NOAUTOCOST)) - vty_out (vty, " ipv6 ospf6 cost %d%s", - oi->cost, VNL); + vty_out (vty, " ipv6 ospf6 cost %d\n", + oi->cost); if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL) - vty_out (vty, " ipv6 ospf6 hello-interval %d%s", - oi->hello_interval, VNL); + vty_out (vty, " ipv6 ospf6 hello-interval %d\n", + oi->hello_interval); if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL) - vty_out (vty, " ipv6 ospf6 dead-interval %d%s", - oi->dead_interval, VNL); + vty_out (vty, " ipv6 ospf6 dead-interval %d\n", + oi->dead_interval); if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL) - vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s", - oi->rxmt_interval, VNL); + vty_out (vty, " ipv6 ospf6 retransmit-interval %d\n", + oi->rxmt_interval); if (oi->priority != OSPF6_INTERFACE_PRIORITY) - vty_out (vty, " ipv6 ospf6 priority %d%s", - oi->priority, VNL); + vty_out (vty, " ipv6 ospf6 priority %d\n", + oi->priority); if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY) - vty_out (vty, " ipv6 ospf6 transmit-delay %d%s", - oi->transdelay, VNL); + vty_out (vty, " ipv6 ospf6 transmit-delay %d\n", + oi->transdelay); if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID) - vty_out (vty, " ipv6 ospf6 instance-id %d%s", - oi->instance_id, VNL); + vty_out (vty, " ipv6 ospf6 instance-id %d\n", + oi->instance_id); if (oi->plist_name) - vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s", - oi->plist_name, VNL); + vty_out (vty, " ipv6 ospf6 advertise prefix-list %s\n", + oi->plist_name); if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE)) - vty_out (vty, " ipv6 ospf6 passive%s", VNL); + vty_out (vty, " ipv6 ospf6 passive\n"); if (oi->mtu_ignore) - vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL); + vty_out (vty, " ipv6 ospf6 mtu-ignore\n"); if (oi->type != ospf6_default_iftype(ifp)) { if (oi->type == OSPF_IFTYPE_POINTOPOINT) - vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL); + vty_out (vty, " ipv6 ospf6 network point-to-point\n"); else if (oi->type == OSPF_IFTYPE_BROADCAST) - vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL); + vty_out (vty, " ipv6 ospf6 network broadcast\n"); } ospf6_bfd_write_config(vty, oi); - vty_out (vty, "!%s", VNL); + vty_out (vty, "!\n"); } return 0; } @@ -1920,7 +1910,7 @@ DEFUN (clear_ipv6_ospf6_interface, { if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg, VRF_DEFAULT)) == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL); + vty_out (vty, "No such Interface: %s\n", argv[idx_ifname]->arg); return CMD_WARNING; } ospf6_interface_clear (vty, ifp); @@ -1964,7 +1954,7 @@ int config_write_ospf6_debug_interface (struct vty *vty) { if (IS_OSPF6_DEBUG_INTERFACE) - vty_out (vty, "debug ospf6 interface%s", VNL); + vty_out (vty, "debug ospf6 interface\n"); return 0; } diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 4238fd224..0ab503d15 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -105,7 +105,7 @@ ospf6_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) ospf6_capability_printbuf (router_lsa->bits, bits, sizeof (bits)); ospf6_options_printbuf (router_lsa->options, options, sizeof (options)); - vty_out (vty, " Bits: %s Options: %s%s", bits, options, VNL); + vty_out (vty, " Bits: %s Options: %s\n", bits, options); start = (char *) router_lsa + sizeof (struct ospf6_router_lsa); end = (char *) lsa->header + ntohs (lsa->header->length); @@ -125,17 +125,17 @@ ospf6_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) else snprintf (name, sizeof (name), "Unknown (%#x)", lsdesc->type); - vty_out (vty, " Type: %s Metric: %d%s", - name, ntohs (lsdesc->metric), VNL); - vty_out (vty, " Interface ID: %s%s", + vty_out (vty, " Type: %s Metric: %d\n", + name, ntohs (lsdesc->metric)); + vty_out (vty, " Interface ID: %s\n", inet_ntop (AF_INET, &lsdesc->interface_id, - buf, sizeof (buf)), VNL); - vty_out (vty, " Neighbor Interface ID: %s%s", + buf, sizeof (buf))); + vty_out (vty, " Neighbor Interface ID: %s\n", inet_ntop (AF_INET, &lsdesc->neighbor_interface_id, - buf, sizeof (buf)), VNL); - vty_out (vty, " Neighbor Router ID: %s%s", + buf, sizeof (buf))); + vty_out (vty, " Neighbor Router ID: %s\n", inet_ntop (AF_INET, &lsdesc->neighbor_router_id, - buf, sizeof (buf)), VNL); + buf, sizeof (buf))); } return 0; } @@ -407,7 +407,7 @@ ospf6_network_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); ospf6_options_printbuf (network_lsa->options, options, sizeof (options)); - vty_out (vty, " Options: %s%s", options, VNL); + vty_out (vty, " Options: %s\n", options); start = (char *) network_lsa + sizeof (struct ospf6_network_lsa); end = (char *) lsa->header + ntohs (lsa->header->length); @@ -416,7 +416,7 @@ ospf6_network_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) { lsdesc = (struct ospf6_network_lsdesc *) current; inet_ntop (AF_INET, &lsdesc->router_id, buf, sizeof (buf)); - vty_out (vty, " Attached Router: %s%s", buf, VNL); + vty_out (vty, " Attached Router: %s\n", buf); } return 0; } @@ -621,10 +621,10 @@ ospf6_link_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) inet_ntop (AF_INET6, &link_lsa->linklocal_addr, buf, sizeof (buf)); prefixnum = ntohl (link_lsa->prefix_num); - vty_out (vty, " Priority: %d Options: %s%s", - link_lsa->priority, options, VNL); - vty_out (vty, " LinkLocal Address: %s%s", buf, VNL); - vty_out (vty, " Number of Prefix: %d%s", prefixnum, VNL); + vty_out (vty, " Priority: %d Options: %s\n", + link_lsa->priority, options); + vty_out (vty, " LinkLocal Address: %s\n", buf); + vty_out (vty, " Number of Prefix: %d\n", prefixnum); start = (char *) link_lsa + sizeof (struct ospf6_link_lsa); end = (char *) lsa->header + ntohs (lsa->header->length); @@ -643,15 +643,15 @@ ospf6_link_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) "LA" : "--"); nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ? "NU" : "--"); - vty_out (vty, " Prefix Options: %s|%s|%s|%s%s", - p, mc, la, nu, VNL); + vty_out (vty, " Prefix Options: %s|%s|%s|%s\n", + p, mc, la, nu); memset (&in6, 0, sizeof (in6)); memcpy (&in6, OSPF6_PREFIX_BODY (prefix), OSPF6_PREFIX_SPACE (prefix->prefix_length)); inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); - vty_out (vty, " Prefix: %s/%d%s", - buf, prefix->prefix_length, VNL); + vty_out (vty, " Prefix: %s/%d\n", + buf, prefix->prefix_length); } return 0; @@ -823,14 +823,13 @@ ospf6_intra_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) prefixnum = ntohs (intra_prefix_lsa->prefix_num); - vty_out (vty, " Number of Prefix: %d%s", prefixnum, VNL); + vty_out (vty, " Number of Prefix: %d\n", prefixnum); inet_ntop (AF_INET, &intra_prefix_lsa->ref_id, id, sizeof (id)); inet_ntop (AF_INET, &intra_prefix_lsa->ref_adv_router, adv_router, sizeof (adv_router)); - vty_out (vty, " Reference: %s Id: %s Adv: %s%s", - ospf6_lstype_name (intra_prefix_lsa->ref_type), id, adv_router, - VNL); + vty_out (vty, " Reference: %s Id: %s Adv: %s\n", + ospf6_lstype_name (intra_prefix_lsa->ref_type), id, adv_router); start = (char *) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa); end = (char *) lsa->header + ntohs (lsa->header->length); @@ -849,15 +848,15 @@ ospf6_intra_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) "LA" : "--"); nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ? "NU" : "--"); - vty_out (vty, " Prefix Options: %s|%s|%s|%s%s", - p, mc, la, nu, VNL); + vty_out (vty, " Prefix Options: %s|%s|%s|%s\n", + p, mc, la, nu); memset (&in6, 0, sizeof (in6)); memcpy (&in6, OSPF6_PREFIX_BODY (prefix), OSPF6_PREFIX_SPACE (prefix->prefix_length)); inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); - vty_out (vty, " Prefix: %s/%d%s", - buf, prefix->prefix_length, VNL); + vty_out (vty, " Prefix: %s/%d\n", + buf, prefix->prefix_length); } return 0; @@ -1789,18 +1788,18 @@ config_write_ospf6_debug_brouter (struct vty *vty) { char buf[16]; if (IS_OSPF6_DEBUG_BROUTER) - vty_out (vty, "debug ospf6 border-routers%s", VNL); + vty_out (vty, "debug ospf6 border-routers\n"); if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER) { inet_ntop (AF_INET, &conf_debug_ospf6_brouter_specific_router_id, buf, sizeof (buf)); - vty_out (vty, "debug ospf6 border-routers router-id %s%s", buf, VNL); + vty_out (vty, "debug ospf6 border-routers router-id %s\n", buf); } if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA) { inet_ntop (AF_INET, &conf_debug_ospf6_brouter_specific_area_id, buf, sizeof (buf)); - vty_out (vty, "debug ospf6 border-routers area-id %s%s", buf, VNL); + vty_out (vty, "debug ospf6 border-routers area-id %s\n", buf); } return 0; } diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c index 624acb9c6..7817448b7 100644 --- a/ospf6d/ospf6_lsa.c +++ b/ospf6d/ospf6_lsa.c @@ -54,11 +54,11 @@ ospf6_unknown_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) start = (u_char *) lsa->header + sizeof (struct ospf6_lsa_header); end = (u_char *) lsa->header + ntohs (lsa->header->length); - vty_out (vty, " Unknown contents:%s", VNL); + vty_out (vty, " Unknown contents:\n"); for (current = start; current < end; current ++) { if ((current - start) % 16 == 0) - vty_out (vty, "%s ", VNL); + vty_out (vty, "\n "); else if ((current - start) % 4 == 0) vty_out (vty, " "); @@ -66,7 +66,7 @@ ospf6_unknown_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) vty_out (vty, "%s", byte); } - vty_out (vty, "%s%s", VNL, VNL); + vty_out (vty, "\n\n"); return 0; } @@ -381,9 +381,9 @@ ospf6_lsa_header_print (struct ospf6_lsa *lsa) void ospf6_lsa_show_summary_header (struct vty *vty) { - vty_out (vty, "%-4s %-15s%-15s%4s %8s %30s%s", + vty_out (vty, "%-4s %-15s%-15s%4s %8s %30s\n", "Type", "LSId", "AdvRouter", "Age", "SeqNum", - "Payload", VNL); + "Payload"); } void @@ -408,11 +408,11 @@ ospf6_lsa_show_summary (struct vty *vty, struct ospf6_lsa *lsa) (type == OSPF6_LSTYPE_INTER_ROUTER) || (type == OSPF6_LSTYPE_AS_EXTERNAL)) { - vty_out (vty, "%-4s %-15s%-15s%4hu %8lx %30s%s", + vty_out (vty, "%-4s %-15s%-15s%4hu %8lx %30s\n", ospf6_lstype_short_name (lsa->header->type), id, adv_router, ospf6_lsa_age_current (lsa), (u_long) ntohl (lsa->header->seqnum), - handler->get_prefix_str(lsa, buf, sizeof(buf), 0), VNL); + handler->get_prefix_str(lsa, buf, sizeof(buf), 0)); } else if (type != OSPF6_LSTYPE_UNKNOWN) { @@ -423,16 +423,16 @@ ospf6_lsa_show_summary (struct vty *vty, struct ospf6_lsa *lsa) while (handler->get_prefix_str(lsa, buf, sizeof(buf), cnt) != NULL) { - vty_out (vty, "%s %30s%s", tmpbuf, buf, VNL); + vty_out (vty, "%s %30s\n", tmpbuf, buf); cnt++; } } else { - vty_out (vty, "%-4s %-15s%-15s%4hu %8lx%s", + vty_out (vty, "%-4s %-15s%-15s%4hu %8lx\n", ospf6_lstype_short_name (lsa->header->type), id, adv_router, ospf6_lsa_age_current (lsa), - (u_long) ntohl (lsa->header->seqnum), VNL); + (u_long) ntohl (lsa->header->seqnum)); } } @@ -445,13 +445,13 @@ ospf6_lsa_show_dump (struct vty *vty, struct ospf6_lsa *lsa) start = (u_char *) lsa->header; end = (u_char *) lsa->header + ntohs (lsa->header->length); - vty_out (vty, "%s", VNL); - vty_out (vty, "%s:%s", lsa->name, VNL); + vty_out (vty, "\n"); + vty_out (vty, "%s:\n", lsa->name); for (current = start; current < end; current ++) { if ((current - start) % 16 == 0) - vty_out (vty, "%s ", VNL); + vty_out (vty, "\n "); else if ((current - start) % 4 == 0) vty_out (vty, " "); @@ -459,7 +459,7 @@ ospf6_lsa_show_dump (struct vty *vty, struct ospf6_lsa *lsa) vty_out (vty, "%s", byte); } - vty_out (vty, "%s%s", VNL, VNL); + vty_out (vty, "\n\n"); return; } @@ -474,22 +474,22 @@ ospf6_lsa_show_internal (struct vty *vty, struct ospf6_lsa *lsa) inet_ntop (AF_INET, &lsa->header->adv_router, adv_router, sizeof (adv_router)); - vty_out (vty, "%s", VNL); - vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa), - ospf6_lstype_name (lsa->header->type), VNL); - vty_out (vty, "Link State ID: %s%s", id, VNL); - vty_out (vty, "Advertising Router: %s%s", adv_router, VNL); - vty_out (vty, "LS Sequence Number: %#010lx%s", - (u_long) ntohl (lsa->header->seqnum), VNL); - vty_out (vty, "CheckSum: %#06hx Length: %hu%s", + vty_out (vty, "\n"); + vty_out (vty, "Age: %4hu Type: %s\n", ospf6_lsa_age_current (lsa), + ospf6_lstype_name (lsa->header->type)); + vty_out (vty, "Link State ID: %s\n", id); + vty_out (vty, "Advertising Router: %s\n", adv_router); + vty_out (vty, "LS Sequence Number: %#010lx\n", + (u_long) ntohl (lsa->header->seqnum)); + vty_out (vty, "CheckSum: %#06hx Length: %hu\n", ntohs (lsa->header->checksum), - ntohs (lsa->header->length), VNL); - vty_out (vty, "Flag: %x %s", lsa->flag, VNL); - vty_out (vty, "Lock: %d %s", lsa->lock, VNL); - vty_out (vty, "ReTx Count: %d%s", lsa->retrans_count, VNL); - vty_out (vty, "Threads: Expire: 0x%p, Refresh: 0x%p %s", - (void *)lsa->expire, (void *)lsa->refresh, VNL); - vty_out (vty, "%s", VNL); + ntohs (lsa->header->length)); + vty_out (vty, "Flag: %x \n", lsa->flag); + vty_out (vty, "Lock: %d \n", lsa->lock); + vty_out (vty, "ReTx Count: %d\n", lsa->retrans_count); + vty_out (vty, "Threads: Expire: 0x%p, Refresh: 0x%p \n", + (void *)lsa->expire, (void *)lsa->refresh); + vty_out (vty, "\n"); return; } @@ -511,23 +511,23 @@ ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) timersub (&now, &lsa->installed, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa), - ospf6_lstype_name (lsa->header->type), VNL); - vty_out (vty, "Link State ID: %s%s", id, VNL); - vty_out (vty, "Advertising Router: %s%s", adv_router, VNL); - vty_out (vty, "LS Sequence Number: %#010lx%s", - (u_long) ntohl (lsa->header->seqnum), VNL); - vty_out (vty, "CheckSum: %#06hx Length: %hu%s", + vty_out (vty, "Age: %4hu Type: %s\n", ospf6_lsa_age_current (lsa), + ospf6_lstype_name (lsa->header->type)); + vty_out (vty, "Link State ID: %s\n", id); + vty_out (vty, "Advertising Router: %s\n", adv_router); + vty_out (vty, "LS Sequence Number: %#010lx\n", + (u_long) ntohl (lsa->header->seqnum)); + vty_out (vty, "CheckSum: %#06hx Length: %hu\n", ntohs (lsa->header->checksum), - ntohs (lsa->header->length), VNL); - vty_out (vty, "Duration: %s%s", duration, VNL); + ntohs (lsa->header->length)); + vty_out (vty, "Duration: %s\n", duration); handler = ospf6_get_lsa_handler (lsa->header->type); if (handler->show == NULL) handler = &unknown_handler; (*handler->show) (vty, lsa); - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); } /* OSPFv3 LSA creation/deletion function */ @@ -937,17 +937,17 @@ config_write_ospf6_debug_lsa (struct vty *vty) if (handler == NULL) continue; if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG)) - vty_out (vty, "debug ospf6 lsa %s%s", - ospf6_lsa_handler_name (handler), VNL); + vty_out (vty, "debug ospf6 lsa %s\n", + ospf6_lsa_handler_name (handler)); if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE)) - vty_out (vty, "debug ospf6 lsa %s originate%s", - ospf6_lsa_handler_name (handler), VNL); + vty_out (vty, "debug ospf6 lsa %s originate\n", + ospf6_lsa_handler_name (handler)); if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN)) - vty_out (vty, "debug ospf6 lsa %s examine%s", - ospf6_lsa_handler_name (handler), VNL); + vty_out (vty, "debug ospf6 lsa %s examine\n", + ospf6_lsa_handler_name (handler)); if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD)) - vty_out (vty, "debug ospf6 lsa %s flooding%s", - ospf6_lsa_handler_name (handler), VNL); + vty_out (vty, "debug ospf6 lsa %s flooding\n", + ospf6_lsa_handler_name (handler)); } return 0; diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index 1eba30625..fb226072f 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -2451,41 +2451,39 @@ config_write_ospf6_debug_message (struct vty *vty) if (s == 0x3f && r == 0x3f) { - vty_out (vty, "debug ospf6 message all%s", VNL); + vty_out (vty, "debug ospf6 message all\n"); return 0; } if (s == 0x3f && r == 0) { - vty_out (vty, "debug ospf6 message all send%s", VNL); + vty_out (vty, "debug ospf6 message all send\n"); return 0; } else if (s == 0 && r == 0x3f) { - vty_out (vty, "debug ospf6 message all recv%s", VNL); + vty_out (vty, "debug ospf6 message all recv\n"); return 0; } /* Unknown message is logged by default */ if (! IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, SEND) && ! IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) - vty_out (vty, "no debug ospf6 message unknown%s", VNL); + vty_out (vty, "no debug ospf6 message unknown\n"); else if (! IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, SEND)) - vty_out (vty, "no debug ospf6 message unknown send%s", VNL); + vty_out (vty, "no debug ospf6 message unknown send\n"); else if (! IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) - vty_out (vty, "no debug ospf6 message unknown recv%s", VNL); + vty_out (vty, "no debug ospf6 message unknown recv\n"); for (i = 1; i < 6; i++) { if (IS_OSPF6_DEBUG_MESSAGE (i, SEND) && IS_OSPF6_DEBUG_MESSAGE (i, RECV)) - vty_out (vty, "debug ospf6 message %s%s", type_str[i], VNL); + vty_out (vty, "debug ospf6 message %s\n", type_str[i]); else if (IS_OSPF6_DEBUG_MESSAGE (i, SEND)) - vty_out (vty, "debug ospf6 message %s send%s", type_str[i], - VNL); + vty_out (vty, "debug ospf6 message %s send\n", type_str[i]); else if (IS_OSPF6_DEBUG_MESSAGE (i, RECV)) - vty_out (vty, "debug ospf6 message %s recv%s", type_str[i], - VNL); + vty_out (vty, "debug ospf6 message %s recv\n", type_str[i]); } return 0; diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index 9ff4e5583..d0a97eea4 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -664,16 +664,16 @@ ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on) timerstring (&res, duration, sizeof (duration)); /* - vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s", + vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n", "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration", - "I/F", "State", VNL); + "I/F", "State"); */ - vty_out (vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]%s", + vty_out (vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n", router_id, on->priority, deadtime, ospf6_neighbor_state_str[on->state], nstate, duration, on->ospf6_if->interface->name, - ospf6_interface_state_str[on->ospf6_if->state], VNL); + ospf6_interface_state_str[on->ospf6_if->state]); } static void @@ -685,9 +685,9 @@ ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on) struct timeval now, res; /* - vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", + vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n", "RouterID", "State", "Duration", "DR", "BDR", "I/F", - "State", VNL); + "State"); */ inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id)); @@ -698,11 +698,10 @@ ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on) timersub (&now, &on->last_changed, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]%s", + vty_out (vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id, ospf6_neighbor_state_str[on->state], duration, drouter, bdrouter, on->ospf6_if->interface->name, - ospf6_interface_state_str[on->ospf6_if->state], - VNL); + ospf6_interface_state_str[on->ospf6_if->state]); } static void @@ -722,87 +721,74 @@ ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on) timersub (&now, &on->last_changed, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, " Neighbor %s%s", on->name, - VNL); - vty_out (vty, " Area %s via interface %s (ifindex %d)%s", + vty_out (vty, " Neighbor %s\n", on->name); + vty_out (vty, " Area %s via interface %s (ifindex %d)\n", on->ospf6_if->area->name, on->ospf6_if->interface->name, - on->ospf6_if->interface->ifindex, - VNL); - vty_out (vty, " His IfIndex: %d Link-local address: %s%s", - on->ifindex, linklocal_addr, - VNL); - vty_out (vty, " State %s for a duration of %s%s", - ospf6_neighbor_state_str[on->state], duration, - VNL); - vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s", - drouter, bdrouter, on->priority, - VNL); - vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s", + on->ospf6_if->interface->ifindex); + vty_out (vty, " His IfIndex: %d Link-local address: %s\n", + on->ifindex, linklocal_addr); + vty_out (vty, " State %s for a duration of %s\n", + ospf6_neighbor_state_str[on->state], duration); + vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d\n", + drouter, bdrouter, on->priority); + vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx\n", (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""), (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""), (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ? - "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum), - VNL); + "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum)); - vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count, - VNL); + vty_out (vty, " Summary-List: %d LSAs\n", on->summary_list->count); for (ALL_LSDB(on->summary_list, lsa)) - vty_out (vty, " %s%s", lsa->name, VNL); + vty_out (vty, " %s\n", lsa->name); - vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count, - VNL); + vty_out (vty, " Request-List: %d LSAs\n", on->request_list->count); for (ALL_LSDB(on->request_list, lsa)) - vty_out (vty, " %s%s", lsa->name, VNL); + vty_out (vty, " %s\n", lsa->name); - vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count, - VNL); + vty_out (vty, " Retrans-List: %d LSAs\n", on->retrans_list->count); for (ALL_LSDB(on->retrans_list, lsa)) - vty_out (vty, " %s%s", lsa->name, VNL); + vty_out (vty, " %s\n", lsa->name); timerclear (&res); if (on->thread_send_dbdesc) timersub (&on->thread_send_dbdesc->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s", + vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]\n", on->dbdesc_list->count, duration, - (on->thread_send_dbdesc ? "on" : "off"), - VNL); + (on->thread_send_dbdesc ? "on" : "off")); for (ALL_LSDB(on->dbdesc_list, lsa)) - vty_out (vty, " %s%s", lsa->name, VNL); + vty_out (vty, " %s\n", lsa->name); timerclear (&res); if (on->thread_send_lsreq) timersub (&on->thread_send_lsreq->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s", + vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]\n", on->request_list->count, duration, - (on->thread_send_lsreq ? "on" : "off"), - VNL); + (on->thread_send_lsreq ? "on" : "off")); for (ALL_LSDB(on->request_list, lsa)) - vty_out (vty, " %s%s", lsa->name, VNL); + vty_out (vty, " %s\n", lsa->name); timerclear (&res); if (on->thread_send_lsupdate) timersub (&on->thread_send_lsupdate->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", + vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n", on->lsupdate_list->count, duration, - (on->thread_send_lsupdate ? "on" : "off"), - VNL); + (on->thread_send_lsupdate ? "on" : "off")); for (ALL_LSDB(on->lsupdate_list, lsa)) - vty_out (vty, " %s%s", lsa->name, VNL); + vty_out (vty, " %s\n", lsa->name); timerclear (&res); if (on->thread_send_lsack) timersub (&on->thread_send_lsack->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", + vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]\n", on->lsack_list->count, duration, - (on->thread_send_lsack ? "on" : "off"), - VNL); + (on->thread_send_lsack ? "on" : "off")); for (ALL_LSDB(on->lsack_list, lsa)) - vty_out (vty, " %s%s", lsa->name, VNL); + vty_out (vty, " %s\n", lsa->name); ospf6_bfd_show_info(vty, on->bfd_info, 0); } @@ -836,13 +822,13 @@ DEFUN (show_ipv6_ospf6_neighbor, } if (showfunc == ospf6_neighbor_show) - vty_out (vty, "%-15s %3s %11s %8s/%-12s %11s %s[%s]%s", + vty_out (vty, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n", "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration", - "I/F", "State", VNL); + "I/F", "State"); else if (showfunc == ospf6_neighbor_show_drchoice) - vty_out (vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]%s", + vty_out (vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", "RouterID", "State", "Duration", "DR", "BDR", "I/F", - "State", VNL); + "State"); for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa)) for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) @@ -876,8 +862,7 @@ DEFUN (show_ipv6_ospf6_neighbor_one, if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1) { - vty_out (vty, "Router-ID is not parsable: %s%s", argv[idx_ipv4]->arg, - VNL); + vty_out (vty, "Router-ID is not parsable: %s\n", argv[idx_ipv4]->arg); return CMD_SUCCESS; } @@ -1000,11 +985,11 @@ config_write_ospf6_debug_neighbor (struct vty *vty) { if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) && IS_OSPF6_DEBUG_NEIGHBOR (EVENT)) - vty_out (vty, "debug ospf6 neighbor%s", VNL); + vty_out (vty, "debug ospf6 neighbor\n"); else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE)) - vty_out (vty, "debug ospf6 neighbor state%s", VNL); + vty_out (vty, "debug ospf6 neighbor state\n"); else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT)) - vty_out (vty, "debug ospf6 neighbor event%s", VNL); + vty_out (vty, "debug ospf6 neighbor event\n"); return 0; } diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index a6bb099dd..7b01c69a8 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -1043,16 +1043,16 @@ ospf6_route_show (struct vty *vty, struct ospf6_route *route) if (!i) { - vty_out (vty, "%c%1s %2s %-30s %-25s %6.*s %s%s", + vty_out (vty, "%c%1s %2s %-30s %-25s %6.*s %s\n", (ospf6_route_is_best (route) ? '*' : ' '), OSPF6_DEST_TYPE_SUBSTR (route->type), OSPF6_PATH_TYPE_SUBSTR (route->path.type), - destination, nexthop, IFNAMSIZ, ifname, duration, VNL); + destination, nexthop, IFNAMSIZ, ifname, duration); i++; } else - vty_out (vty, "%c%1s %2s %-30s %-25s %6.*s %s%s", - ' ', "", "", "", nexthop, IFNAMSIZ, ifname, "", VNL); + vty_out (vty, "%c%1s %2s %-30s %-25s %6.*s %s\n", + ' ', "", "", "", nexthop, IFNAMSIZ, ifname, ""); } } @@ -1078,77 +1078,74 @@ ospf6_route_show_detail (struct vty *vty, struct ospf6_route *route) destination, sizeof (destination)); else prefix2str (&route->prefix, destination, sizeof (destination)); - vty_out (vty, "Destination: %s%s", destination, VNL); + vty_out (vty, "Destination: %s\n", destination); /* destination type */ - vty_out (vty, "Destination type: %s%s", - OSPF6_DEST_TYPE_NAME (route->type), - VNL); + vty_out (vty, "Destination type: %s\n", + OSPF6_DEST_TYPE_NAME (route->type)); /* Time */ timersub (&now, &route->installed, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, "Installed Time: %s ago%s", duration, VNL); + vty_out (vty, "Installed Time: %s ago\n", duration); timersub (&now, &route->changed, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, " Changed Time: %s ago%s", duration, VNL); + vty_out (vty, " Changed Time: %s ago\n", duration); /* Debugging info */ - vty_out (vty, "Lock: %d Flags: %s%s%s%s%s", route->lock, + vty_out (vty, "Lock: %d Flags: %s%s%s%s\n", route->lock, (CHECK_FLAG (route->flag, OSPF6_ROUTE_BEST) ? "B" : "-"), (CHECK_FLAG (route->flag, OSPF6_ROUTE_ADD) ? "A" : "-"), (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE) ? "R" : "-"), - (CHECK_FLAG (route->flag, OSPF6_ROUTE_CHANGE) ? "C" : "-"), - VNL); - vty_out (vty, "Memory: prev: %p this: %p next: %p%s", - (void *)route->prev, (void *)route, (void *)route->next, VNL); + (CHECK_FLAG (route->flag, OSPF6_ROUTE_CHANGE) ? "C" : "-")); + vty_out (vty, "Memory: prev: %p this: %p next: %p\n", + (void *)route->prev, (void *)route, (void *)route->next); /* Path section */ /* Area-ID */ inet_ntop (AF_INET, &route->path.area_id, area_id, sizeof (area_id)); - vty_out (vty, "Associated Area: %s%s", area_id, VNL); + vty_out (vty, "Associated Area: %s\n", area_id); /* Path type */ - vty_out (vty, "Path Type: %s%s", - OSPF6_PATH_TYPE_NAME (route->path.type), VNL); + vty_out (vty, "Path Type: %s\n", + OSPF6_PATH_TYPE_NAME (route->path.type)); /* LS Origin */ inet_ntop (AF_INET, &route->path.origin.id, id, sizeof (id)); inet_ntop (AF_INET, &route->path.origin.adv_router, adv_router, sizeof (adv_router)); - vty_out (vty, "LS Origin: %s Id: %s Adv: %s%s", + vty_out (vty, "LS Origin: %s Id: %s Adv: %s\n", ospf6_lstype_name (route->path.origin.type), - id, adv_router, VNL); + id, adv_router); /* Options */ ospf6_options_printbuf (route->path.options, options, sizeof (options)); - vty_out (vty, "Options: %s%s", options, VNL); + vty_out (vty, "Options: %s\n", options); /* Router Bits */ ospf6_capability_printbuf (route->path.router_bits, capa, sizeof (capa)); - vty_out (vty, "Router Bits: %s%s", capa, VNL); + vty_out (vty, "Router Bits: %s\n", capa); /* Prefix Options */ - vty_out (vty, "Prefix Options: xxx%s", VNL); + vty_out (vty, "Prefix Options: xxx\n"); /* Metrics */ - vty_out (vty, "Metric Type: %d%s", route->path.metric_type, - VNL); - vty_out (vty, "Metric: %d (%d)%s", - route->path.cost, route->path.u.cost_e2, VNL); + vty_out (vty, "Metric Type: %d\n", route->path.metric_type); + vty_out (vty, "Metric: %d (%d)\n", + route->path.cost, route->path.u.cost_e2); /* Nexthops */ - vty_out (vty, "Nexthop:%s", VNL); + vty_out (vty, "Nexthop:\n"); for (ALL_LIST_ELEMENTS_RO (route->nh_list, node, nh)) { /* nexthop */ inet_ntop (AF_INET6, &nh->address, nexthop, sizeof (nexthop)); ifname = ifindex2ifname (nh->ifindex, VRF_DEFAULT); - vty_out (vty, " %s %.*s%s", nexthop, IFNAMSIZ, ifname, VNL); + vty_out (vty, " %s %.*s\n", nexthop, IFNAMSIZ, ifname); } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); } static void @@ -1184,14 +1181,14 @@ ospf6_route_show_table_summary (struct vty *vty, assert (number == table->count); - vty_out (vty, "Number of OSPFv3 routes: %d%s", number, VNL); - vty_out (vty, "Number of Destination: %d%s", destination, VNL); - vty_out (vty, "Number of Alternative routes: %d%s", alternative, VNL); - vty_out (vty, "Number of Equal Cost Multi Path: %d%s", ecmp, VNL); + vty_out (vty, "Number of OSPFv3 routes: %d\n", number); + vty_out (vty, "Number of Destination: %d\n", destination); + vty_out (vty, "Number of Alternative routes: %d\n", alternative); + vty_out (vty, "Number of Equal Cost Multi Path: %d\n", ecmp); for (i = OSPF6_PATH_TYPE_INTRA; i <= OSPF6_PATH_TYPE_EXTERNAL2; i++) { - vty_out (vty, "Number of %s routes: %d%s", - OSPF6_PATH_TYPE_NAME (i), pathtype[i], VNL); + vty_out (vty, "Number of %s routes: %d\n", + OSPF6_PATH_TYPE_NAME (i), pathtype[i]); } } @@ -1364,7 +1361,7 @@ ospf6_route_table_show (struct vty *vty, int argc_start, int argc, struct cmd_to continue; } - vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL); + vty_out (vty, "Malformed argument: %s\n", argv[i]->arg); return CMD_SUCCESS; } @@ -1400,8 +1397,8 @@ ospf6_route_table_show (struct vty *vty, int argc_start, int argc, struct cmd_to static void ospf6_linkstate_show_header (struct vty *vty) { - vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %s%s", - "Type", "Router-ID", "Net-ID", "Rtr-Bits", "Options", "Cost", VNL); + vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %s\n", + "Type", "Router-ID", "Net-ID", "Rtr-Bits", "Options", "Cost"); } static void @@ -1419,13 +1416,13 @@ ospf6_linkstate_show (struct vty *vty, struct ospf6_route *route) ospf6_options_printbuf (route->path.options, options, sizeof (options)); if (ntohl (id)) - vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %lu%s", + vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %lu\n", "Network", routername, idname, rbits, options, - (unsigned long) route->path.cost, VNL); + (unsigned long) route->path.cost); else - vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %lu%s", + vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %lu\n", "Router", routername, idname, rbits, options, - (unsigned long) route->path.cost, VNL); + (unsigned long) route->path.cost); } @@ -1502,7 +1499,7 @@ ospf6_linkstate_table_show (struct vty *vty, int idx_ipv4, int argc, is_router++; continue; } - vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL); + vty_out (vty, "Malformed argument: %s\n", argv[i]->arg); return CMD_SUCCESS; } @@ -1514,11 +1511,11 @@ ospf6_linkstate_table_show (struct vty *vty, int idx_ipv4, int argc, is_id++; continue; } - vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL); + vty_out (vty, "Malformed argument: %s\n", argv[i]->arg); return CMD_SUCCESS; } - vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL); + vty_out (vty, "Malformed argument: %s\n", argv[i]->arg); return CMD_SUCCESS; } @@ -1538,8 +1535,8 @@ ospf6_linkstate_table_show (struct vty *vty, int idx_ipv4, int argc, void ospf6_brouter_show_header (struct vty *vty) { - vty_out (vty, "%-15s %-8s %-14s %-10s %-15s%s", - "Router-ID", "Rtr-Bits", "Options", "Path-Type", "Area", VNL); + vty_out (vty, "%-15s %-8s %-14s %-10s %-15s\n", + "Router-ID", "Rtr-Bits", "Options", "Path-Type", "Area"); } void @@ -1554,11 +1551,11 @@ ospf6_brouter_show (struct vty *vty, struct ospf6_route *route) ospf6_options_printbuf (route->path.options, options, sizeof (options)); inet_ntop (AF_INET, &route->path.area_id, area, sizeof (area)); - /* vty_out (vty, "%-15s %-8s %-14s %-10s %-15s%s", - "Router-ID", "Rtr-Bits", "Options", "Path-Type", "Area", VNL); */ - vty_out (vty, "%-15s %-8s %-14s %-10s %-15s%s", + /* vty_out (vty, "%-15s %-8s %-14s %-10s %-15s\n", + "Router-ID", "Rtr-Bits", "Options", "Path-Type", "Area"); */ + vty_out (vty, "%-15s %-8s %-14s %-10s %-15s\n", adv, rbits, options, OSPF6_PATH_TYPE_NAME (route->path.type), - area, VNL); + area); } DEFUN (debug_ospf6_route, @@ -1619,11 +1616,11 @@ int config_write_ospf6_debug_route (struct vty *vty) { if (IS_OSPF6_DEBUG_ROUTE (TABLE)) - vty_out (vty, "debug ospf6 route table%s", VNL); + vty_out (vty, "debug ospf6 route table\n"); if (IS_OSPF6_DEBUG_ROUTE (INTRA)) - vty_out (vty, "debug ospf6 route intra-area%s", VNL); + vty_out (vty, "debug ospf6 route intra-area\n"); if (IS_OSPF6_DEBUG_ROUTE (INTER)) - vty_out (vty, "debug ospf6 route inter-area%s", VNL); + vty_out (vty, "debug ospf6 route inter-area\n"); return 0; } diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 93f46951b..8d2e244c8 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -741,13 +741,13 @@ ospf6_spf_display_subtree (struct vty *vty, const char *prefix, int rest, int restnum; /* "prefix" is the space prefix of the display line */ - vty_out (vty, "%s+-%s [%d]%s", prefix, v->name, v->cost, VNL); + vty_out (vty, "%s+-%s [%d]\n", prefix, v->name, v->cost); len = strlen (prefix) + 4; next_prefix = (char *) malloc (len); if (next_prefix == NULL) { - vty_out (vty, "malloc failed%s", VNL); + vty_out (vty, "malloc failed\n"); return; } snprintf (next_prefix, len, "%s%s", prefix, (rest ? "| " : " ")); @@ -913,11 +913,11 @@ int config_write_ospf6_debug_spf (struct vty *vty) { if (IS_OSPF6_DEBUG_SPF (PROCESS)) - vty_out (vty, "debug ospf6 spf process%s", VNL); + vty_out (vty, "debug ospf6 spf process\n"); if (IS_OSPF6_DEBUG_SPF (TIME)) - vty_out (vty, "debug ospf6 spf time%s", VNL); + vty_out (vty, "debug ospf6 spf time\n"); if (IS_OSPF6_DEBUG_SPF (DATABASE)) - vty_out (vty, "debug ospf6 spf database%s", VNL); + vty_out (vty, "debug ospf6 spf database\n"); return 0; } @@ -928,7 +928,7 @@ ospf6_spf_config_write (struct vty *vty) if (ospf6->spf_delay != OSPF_SPF_DELAY_DEFAULT || ospf6->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || ospf6->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) - vty_outln (vty, " timers throttle spf %d %d %d", + vty_out (vty, " timers throttle spf %d %d %d\n", ospf6->spf_delay, ospf6->spf_holdtime, ospf6->spf_max_holdtime); diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 268b7a60a..9e0b86b7b 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -315,7 +315,7 @@ DEFUN (no_router_ospf6, OSPF6_STR) { if (ospf6 == NULL) - vty_out (vty, "OSPFv3 is not configured%s", VNL); + vty_out (vty, "OSPFv3 is not configured\n"); else { ospf6_delete (ospf6); @@ -343,7 +343,7 @@ DEFUN (ospf6_router_id, ret = inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id); if (ret == 0) { - vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[idx_ipv4]->arg, VNL); + vty_out (vty, "malformed OSPF Router-ID: %s\n", argv[idx_ipv4]->arg); return CMD_SUCCESS; } @@ -588,15 +588,15 @@ DEFUN (ospf6_interface_area, oi = ospf6_interface_create (ifp); if (oi->area) { - vty_out (vty, "%s already attached to Area %s%s", - oi->interface->name, oi->area->name, VNL); + vty_out (vty, "%s already attached to Area %s\n", + oi->interface->name, oi->area->name); return CMD_SUCCESS; } /* parse Area-ID */ if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { - vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); + vty_out (vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg); return CMD_SUCCESS; } @@ -645,35 +645,35 @@ DEFUN (no_ospf6_interface_area, ifp = if_lookup_by_name (argv[idx_ifname]->arg, VRF_DEFAULT); if (ifp == NULL) { - vty_out (vty, "No such interface %s%s", argv[idx_ifname]->arg, VNL); + vty_out (vty, "No such interface %s\n", argv[idx_ifname]->arg); return CMD_SUCCESS; } oi = (struct ospf6_interface *) ifp->info; if (oi == NULL) { - vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL); + vty_out (vty, "Interface %s not enabled\n", ifp->name); return CMD_SUCCESS; } /* parse Area-ID */ if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { - vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); + vty_out (vty, "Invalid Area-ID: %s\n", argv[idx_ipv4]->arg); return CMD_SUCCESS; } /* Verify Area */ if (oi->area == NULL) { - vty_out (vty, "No such Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); + vty_out (vty, "No such Area-ID: %s\n", argv[idx_ipv4]->arg); return CMD_SUCCESS; } if (oi->area->area_id != area_id) { - vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s", - oi->interface->name, oi->area->name, VNL); + vty_out (vty, "Wrong Area-ID: %s is attached to area %s\n", + oi->interface->name, oi->area->name); return CMD_SUCCESS; } @@ -799,29 +799,29 @@ ospf6_show (struct vty *vty, struct ospf6 *o) /* process id, router id */ inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id)); - vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s", - router_id, VNL); + vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s\n", + router_id); /* running time */ monotime(&now); timersub (&now, &o->starttime, &running); timerstring (&running, duration, sizeof (duration)); - vty_out (vty, " Running %s%s", duration, VNL); + vty_out (vty, " Running %s\n", duration); /* Redistribute configuration */ /* XXX */ - vty_outln (vty, " LSA minimum arrival %d msecs",o->lsa_minarrival); + vty_out (vty, " LSA minimum arrival %d msecs\n",o->lsa_minarrival); /* Show SPF parameters */ - vty_out(vty, " Initial SPF scheduling delay %d millisec(s)%s" - " Minimum hold time between consecutive SPFs %d millsecond(s)%s" - " Maximum hold time between consecutive SPFs %d millsecond(s)%s" - " Hold time multiplier is currently %d%s", - o->spf_delay, VNL, - o->spf_holdtime, VNL, - o->spf_max_holdtime, VNL, - o->spf_hold_multiplier, VNL); + vty_out(vty, " Initial SPF scheduling delay %d millisec(s)\n" + " Minimum hold time between consecutive SPFs %d millsecond(s)\n" + " Maximum hold time between consecutive SPFs %d millsecond(s)\n" + " Hold time multiplier is currently %d\n", + o->spf_delay, + o->spf_holdtime, + o->spf_max_holdtime, + o->spf_hold_multiplier); vty_out(vty, " SPF algorithm "); if (o->ts_spf.tv_sec || o->ts_spf.tv_usec) @@ -829,37 +829,37 @@ ospf6_show (struct vty *vty, struct ospf6 *o) timersub(&now, &o->ts_spf, &result); timerstring(&result, buf, sizeof(buf)); ospf6_spf_reason_string(o->last_spf_reason, rbuf, sizeof(rbuf)); - vty_out(vty, "last executed %s ago, reason %s%s", buf, rbuf, VNL); - vty_out (vty, " Last SPF duration %lld sec %lld usec%s", + vty_out(vty, "last executed %s ago, reason %s\n", buf, rbuf); + vty_out (vty, " Last SPF duration %lld sec %lld usec\n", (long long)o->ts_spf_duration.tv_sec, - (long long)o->ts_spf_duration.tv_usec, VNL); + (long long)o->ts_spf_duration.tv_usec); } else - vty_out(vty, "has not been run$%s", VNL); + vty_out(vty, "has not been run$\n"); threadtimer_string(now, o->t_spf_calc, buf, sizeof(buf)); - vty_out (vty, " SPF timer %s%s%s", - (o->t_spf_calc ? "due in " : "is "), buf, VNL); + vty_out (vty, " SPF timer %s%s\n", + (o->t_spf_calc ? "due in " : "is "), buf); if (CHECK_FLAG (o->flag, OSPF6_STUB_ROUTER)) - vty_out (vty, " Router Is Stub Router%s", VNL); + vty_out (vty, " Router Is Stub Router\n"); /* LSAs */ - vty_out (vty, " Number of AS scoped LSAs is %u%s", - o->lsdb->count, VNL); + vty_out (vty, " Number of AS scoped LSAs is %u\n", + o->lsdb->count); /* Areas */ - vty_out (vty, " Number of areas in this router is %u%s", - listcount (o->area_list), VNL); + vty_out (vty, " Number of areas in this router is %u\n", + listcount (o->area_list)); if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) { if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) - vty_outln (vty, " All adjacency changes are logged"); + vty_out (vty, " All adjacency changes are logged\n"); else - vty_outln (vty, " Adjacency changes are logged"); + vty_out (vty, " Adjacency changes are logged\n"); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa)) ospf6_area_show (vty, oa); @@ -963,7 +963,7 @@ ospf6_stub_router_config_write (struct vty *vty) { if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER)) { - vty_out (vty, " stub-router administrative%s", VNL); + vty_out (vty, " stub-router administrative\n"); } return; } @@ -975,7 +975,7 @@ ospf6_distance_config_write (struct vty *vty) struct ospf6_distance *odistance; if (ospf6->distance_all) - vty_outln (vty, " distance %u", ospf6->distance_all); + vty_out (vty, " distance %u\n", ospf6->distance_all); if (ospf6->distance_intra || ospf6->distance_inter @@ -990,7 +990,7 @@ ospf6_distance_config_write (struct vty *vty) if (ospf6->distance_external) vty_out (vty, " external %u", ospf6->distance_external); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } for (rn = route_top (ospf6->distance_table); rn; rn = route_next (rn)) @@ -998,7 +998,7 @@ ospf6_distance_config_write (struct vty *vty) { char buf[PREFIX_STRLEN]; - vty_outln (vty, " distance %u %s %s", odistance->distance, + vty_out (vty, " distance %u %s %s\n", odistance->distance, prefix2str (&rn->p, buf, sizeof (buf)), odistance->access_list ? odistance->access_list : ""); } @@ -1019,30 +1019,29 @@ config_write_ospf6 (struct vty *vty) return CMD_SUCCESS; inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id)); - vty_out (vty, "router ospf6%s", VNL); + vty_out (vty, "router ospf6\n"); if (ospf6->router_id_static != 0) - vty_out (vty, " router-id %s%s", router_id, VNL); + vty_out (vty, " router-id %s\n", router_id); /* log-adjacency-changes flag print. */ if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) { if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) - vty_outln (vty, " log-adjacency-changes detail"); + vty_out (vty, " log-adjacency-changes detail\n"); else if (!DFLT_OSPF6_LOG_ADJACENCY_CHANGES) - vty_outln (vty, " log-adjacency-changes"); + vty_out (vty, " log-adjacency-changes\n"); } else if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES) { - vty_outln (vty, " no log-adjacency-changes"); + vty_out (vty, " no log-adjacency-changes\n"); } if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH) - vty_out (vty, " auto-cost reference-bandwidth %d%s", ospf6->ref_bandwidth, - VNL); + vty_out (vty, " auto-cost reference-bandwidth %d\n", ospf6->ref_bandwidth); /* LSA timers print. */ if (ospf6->lsa_minarrival != OSPF_MIN_LS_ARRIVAL) - vty_outln (vty, " timers lsa min-arrival %d",ospf6->lsa_minarrival); + vty_out (vty, " timers lsa min-arrival %d\n",ospf6->lsa_minarrival); ospf6_stub_router_config_write (vty); ospf6_redistribute_config_write (vty); @@ -1053,10 +1052,10 @@ config_write_ospf6 (struct vty *vty) for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa)) { for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi)) - vty_out (vty, " interface %s area %s%s", - oi->interface->name, oa->name, VNL); + vty_out (vty, " interface %s area %s\n", + oi->interface->name, oa->name); } - vty_out (vty, "!%s", VNL); + vty_out (vty, "!\n"); return 0; } diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index ea36ceabd..ddd2f3f1b 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -315,23 +315,22 @@ DEFUN (show_zebra, int i; if (zclient == NULL) { - vty_out (vty, "Not connected to zebra%s", VNL); + vty_out (vty, "Not connected to zebra\n"); return CMD_SUCCESS; } - vty_out (vty, "Zebra Infomation%s", VNL); - vty_out (vty, " enable: %d fail: %d%s", - zclient->enable, zclient->fail, VNL); - vty_out (vty, " redistribute default: %d%s", - vrf_bitmap_check (zclient->default_information, VRF_DEFAULT), - VNL); + vty_out (vty, "Zebra Infomation\n"); + vty_out (vty, " enable: %d fail: %d\n", + zclient->enable, zclient->fail); + vty_out (vty, " redistribute default: %d\n", + vrf_bitmap_check (zclient->default_information, VRF_DEFAULT)); vty_out (vty, " redistribute:"); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { if (vrf_bitmap_check (zclient->redist[AFI_IP6][i], VRF_DEFAULT)) vty_out (vty, " %s", zebra_route_string(i)); } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -341,15 +340,15 @@ config_write_ospf6_zebra (struct vty *vty) { if (! zclient->enable) { - vty_out (vty, "no router zebra%s", VNL); - vty_out (vty, "!%s", VNL); + vty_out (vty, "no router zebra\n"); + vty_out (vty, "!\n"); } else if (! vrf_bitmap_check (zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6], VRF_DEFAULT)) { - vty_out (vty, "router zebra%s", VNL); - vty_out (vty, " no redistribute ospf6%s", VNL); - vty_out (vty, "!%s", VNL); + vty_out (vty, "router zebra\n"); + vty_out (vty, " no redistribute ospf6\n"); + vty_out (vty, "!\n"); } return 0; } @@ -683,8 +682,8 @@ ospf6_distance_set (struct vty *vty, struct ospf6 *o, ret = str2prefix_ipv6 (ip_str, &p); if (ret == 0) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } distance = atoi (distance_str); @@ -731,15 +730,15 @@ ospf6_distance_unset (struct vty *vty, struct ospf6 *o, ret = str2prefix_ipv6 (ip_str, &p); if (ret == 0) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } rn = route_node_lookup (o->distance_table, (struct prefix *) &p); if (!rn) { - vty_outln (vty, "Cant't find specified prefix"); - return CMD_WARNING; + vty_out (vty, "Cant't find specified prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } odistance = rn->info; @@ -905,13 +904,13 @@ int config_write_ospf6_debug_zebra (struct vty *vty) { if (IS_OSPF6_DEBUG_ZEBRA (SEND) && IS_OSPF6_DEBUG_ZEBRA (RECV)) - vty_out (vty, "debug ospf6 zebra%s", VNL); + vty_out (vty, "debug ospf6 zebra\n"); else { if (IS_OSPF6_DEBUG_ZEBRA (SEND)) - vty_out (vty, "debug ospf6 zebra send%s", VNL); + vty_out (vty, "debug ospf6 zebra send\n"); if (IS_OSPF6_DEBUG_ZEBRA (RECV)) - vty_out (vty, "debug ospf6 zebra recv%s", VNL); + vty_out (vty, "debug ospf6 zebra recv\n"); } return 0; } diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 1ccf7ce7a..c4a499031 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -83,8 +83,8 @@ DEFUN (show_version_ospf6, "Display ospf6d version\n" ) { - vty_out (vty, "Zebra OSPF6d Version: %s%s", - ospf6_daemon_version, VNL); + vty_out (vty, "Zebra OSPF6d Version: %s\n", + ospf6_daemon_version); return CMD_SUCCESS; } @@ -110,16 +110,16 @@ config_write_ospf6_debug (struct vty *vty) config_write_ospf6_debug_asbr (vty); config_write_ospf6_debug_abr (vty); config_write_ospf6_debug_flood (vty); - vty_out (vty, "!%s", VNL); + vty_out (vty, "!\n"); return 0; } #define AREA_LSDB_TITLE_FORMAT \ - "%s Area Scoped Link State Database (Area %s)%s%s" + "\n Area Scoped Link State Database (Area %s)\n\n" #define IF_LSDB_TITLE_FORMAT \ - "%s I/F Scoped Link State Database (I/F %s in Area %s)%s%s" + "\n I/F Scoped Link State Database (I/F %s in Area %s)\n\n" #define AS_LSDB_TITLE_FORMAT \ - "%s AS Scoped Link State Database%s%s" + "\n AS Scoped Link State Database\n\n" static int parse_show_level (int idx_level, int argc, struct cmd_token **argv) @@ -189,7 +189,7 @@ DEFUN (show_ipv6_ospf6_database, for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, NULL, NULL, NULL, oa->lsdb); } @@ -197,16 +197,16 @@ DEFUN (show_ipv6_ospf6_database, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, NULL, NULL, NULL, oi->lsdb); } } - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, NULL, NULL, NULL, o->lsdb); - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -250,7 +250,7 @@ DEFUN (show_ipv6_ospf6_database_type, case OSPF6_SCOPE_AREA: for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, &type, NULL, NULL, oa->lsdb); } break; @@ -260,15 +260,15 @@ DEFUN (show_ipv6_ospf6_database_type, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, &type, NULL, NULL, oi->lsdb); } } break; case OSPF6_SCOPE_AS: - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, &type, NULL, NULL, o->lsdb); break; @@ -277,7 +277,7 @@ DEFUN (show_ipv6_ospf6_database_type, break; } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -313,7 +313,7 @@ DEFUN (show_ipv6_ospf6_database_id, for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, NULL, &id, NULL, oa->lsdb); } @@ -321,16 +321,16 @@ DEFUN (show_ipv6_ospf6_database_id, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, NULL, &id, NULL, oi->lsdb); } } - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, NULL, &id, NULL, o->lsdb); - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -364,7 +364,7 @@ DEFUN (show_ipv6_ospf6_database_router, for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oa->lsdb); } @@ -372,16 +372,16 @@ DEFUN (show_ipv6_ospf6_database_router, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oi->lsdb); } } - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, o->lsdb); - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -430,7 +430,7 @@ DEFUN (show_ipv6_ospf6_database_type_id, case OSPF6_SCOPE_AREA: for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, &type, &id, NULL, oa->lsdb); } break; @@ -440,15 +440,15 @@ DEFUN (show_ipv6_ospf6_database_type_id, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, &type, &id, NULL, oi->lsdb); } } break; case OSPF6_SCOPE_AS: - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, &type, &id, NULL, o->lsdb); break; @@ -457,7 +457,7 @@ DEFUN (show_ipv6_ospf6_database_type_id, break; } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -507,7 +507,7 @@ DEFUN (show_ipv6_ospf6_database_type_router, case OSPF6_SCOPE_AREA: for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oa->lsdb); } break; @@ -517,15 +517,15 @@ DEFUN (show_ipv6_ospf6_database_type_router, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb); } } break; case OSPF6_SCOPE_AS: - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, o->lsdb); break; @@ -534,7 +534,7 @@ DEFUN (show_ipv6_ospf6_database_type_router, break; } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -572,7 +572,7 @@ DEFUN (show_ipv6_ospf6_database_id_router, for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oa->lsdb); } @@ -580,16 +580,16 @@ DEFUN (show_ipv6_ospf6_database_id_router, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oi->lsdb); } } - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, o->lsdb); - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -627,7 +627,7 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id, for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oa->lsdb); } @@ -635,16 +635,16 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oi->lsdb); } } - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, o->lsdb); - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -694,7 +694,7 @@ DEFUN (show_ipv6_ospf6_database_type_id_router, case OSPF6_SCOPE_AREA: for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb); } break; @@ -704,15 +704,15 @@ DEFUN (show_ipv6_ospf6_database_type_id_router, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb); } } break; case OSPF6_SCOPE_AS: - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, o->lsdb); break; @@ -721,7 +721,7 @@ DEFUN (show_ipv6_ospf6_database_type_id_router, break; } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -774,7 +774,7 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, case OSPF6_SCOPE_AREA: for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb); } break; @@ -784,15 +784,15 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb); } } break; case OSPF6_SCOPE_AS: - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, o->lsdb); break; @@ -801,7 +801,7 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, break; } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -831,7 +831,7 @@ DEFUN (show_ipv6_ospf6_database_self_originated, for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oa->lsdb); } @@ -839,16 +839,16 @@ DEFUN (show_ipv6_ospf6_database_self_originated, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oi->lsdb); } } - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, o->lsdb); - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -896,7 +896,7 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated, case OSPF6_SCOPE_AREA: for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oa->lsdb); } break; @@ -906,15 +906,15 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb); } } break; case OSPF6_SCOPE_AS: - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, o->lsdb); break; @@ -923,7 +923,7 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated, break; } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -974,7 +974,7 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, case OSPF6_SCOPE_AREA: for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb); } break; @@ -984,15 +984,15 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb); } } break; case OSPF6_SCOPE_AS: - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, o->lsdb); break; @@ -1001,7 +1001,7 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, break; } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -1051,7 +1051,7 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated, case OSPF6_SCOPE_AREA: for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) { - vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL); + vty_out (vty, AREA_LSDB_TITLE_FORMAT, oa->name); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb); } break; @@ -1061,15 +1061,15 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated, { for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) { - vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL, - oi->interface->name, oa->name, VNL, VNL); + vty_out (vty, IF_LSDB_TITLE_FORMAT, + oi->interface->name, oa->name); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb); } } break; case OSPF6_SCOPE_AS: - vty_out (vty, AS_LSDB_TITLE_FORMAT, VNL, VNL, VNL); + vty_out (vty, AS_LSDB_TITLE_FORMAT); ospf6_lsdb_show (vty, level, &type, &id, &adv_router, o->lsdb); break; @@ -1078,7 +1078,7 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated, break; } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -1115,7 +1115,7 @@ DEFUN (show_ipv6_ospf6_border_routers, ro = ospf6_route_lookup (&prefix, ospf6->brouter_table); if (!ro) { - vty_out (vty, "No Route found for Router ID: %s%s", argv[4]->arg, VNL); + vty_out (vty, "No Route found for Router ID: %s\n", argv[4]->arg); return CMD_SUCCESS; } @@ -1157,12 +1157,11 @@ DEFUN (show_ipv6_ospf6_linkstate, for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) { - vty_out (vty, "%s SPF Result in Area %s%s%s", - VNL, oa->name, VNL, VNL); + vty_out (vty, "\n SPF Result in Area %s\n\n", oa->name); ospf6_linkstate_table_show (vty, idx_ipv4, argc, argv, oa->spf_table); } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -1185,12 +1184,11 @@ DEFUN (show_ipv6_ospf6_linkstate_detail, for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) { - vty_out (vty, "%s SPF Result in Area %s%s%s", - VNL, oa->name, VNL, VNL); + vty_out (vty, "\n SPF Result in Area %s\n\n", oa->name); ospf6_linkstate_table_show (vty, idx_detail, argc, argv, oa->spf_table); } - vty_out (vty, "%s", VNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6d.h b/ospf6d/ospf6d.h index 41082e451..2da11d0ab 100644 --- a/ospf6d/ospf6d.h +++ b/ospf6d/ospf6d.h @@ -90,11 +90,10 @@ extern struct thread_master *master; #define OSPF6_ROUTER_ID_STR "Specify Router-ID\n" #define OSPF6_LS_ID_STR "Specify Link State ID\n" -#define VNL VTYNL #define OSPF6_CMD_CHECK_RUNNING() \ if (ospf6 == NULL) \ { \ - vty_out (vty, "OSPFv3 is not running%s", VTYNL); \ + vty_out (vty, "OSPFv3 is not running\n"); \ return CMD_SUCCESS; \ } diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index d09290e52..2b72abcd7 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -2192,7 +2192,7 @@ ospf_apiserver_show_info (struct vty *vty, struct ospf_lsa *lsa) if (vty != NULL) { int i; - vty_outln (vty, " Added using OSPF API: %u octets of opaque data %s", + vty_out (vty, " Added using OSPF API: %u octets of opaque data %s\n", opaquelen, VALID_OPAQUE_INFO_LEN(lsa->data) ? "" : "(Invalid length?)"); vty_out (vty, " Opaque data: "); @@ -2201,7 +2201,7 @@ ospf_apiserver_show_info (struct vty *vty, struct ospf_lsa *lsa) { vty_out (vty, "0x%x ", olsa->data[i]); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } else { diff --git a/ospfd/ospf_bfd.c b/ospfd/ospf_bfd.c index f8fa9bbb3..1bcffea6f 100644 --- a/ospfd/ospf_bfd.c +++ b/ospfd/ospf_bfd.c @@ -307,11 +307,11 @@ ospf_bfd_write_config(struct vty *vty, struct ospf_if_params *params) bfd_info = (struct bfd_info *)params->bfd_info; if (CHECK_FLAG(bfd_info->flags, BFD_FLAG_PARAM_CFG)) - vty_outln (vty, " ip ospf bfd %d %d %d", + vty_out (vty, " ip ospf bfd %d %d %d\n", bfd_info->detect_mult, bfd_info->required_min_rx, bfd_info->desired_min_tx); else - vty_outln (vty, " ip ospf bfd"); + vty_out (vty, " ip ospf bfd\n"); } /* diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 3947d5182..f233f79c0 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -1568,92 +1568,91 @@ show_debugging_ospf_common (struct vty *vty, struct ospf *ospf) int i; if (ospf->instance) - vty_outln (vty, "%sOSPF Instance: %d%s", VTYNL, ospf->instance, - VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); - vty_outln (vty, "OSPF debugging status:"); + vty_out (vty, "OSPF debugging status:\n"); /* Show debug status for events. */ if (IS_DEBUG_OSPF(event,EVENT)) - vty_outln (vty, " OSPF event debugging is on"); + vty_out (vty, " OSPF event debugging is on\n"); /* Show debug status for ISM. */ if (IS_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM) - vty_outln (vty, " OSPF ISM debugging is on"); + vty_out (vty, " OSPF ISM debugging is on\n"); else { if (IS_DEBUG_OSPF (ism, ISM_STATUS)) - vty_outln (vty, " OSPF ISM status debugging is on"); + vty_out (vty, " OSPF ISM status debugging is on\n"); if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) - vty_outln (vty, " OSPF ISM event debugging is on"); + vty_out (vty, " OSPF ISM event debugging is on\n"); if (IS_DEBUG_OSPF (ism, ISM_TIMERS)) - vty_outln (vty, " OSPF ISM timer debugging is on"); + vty_out (vty, " OSPF ISM timer debugging is on\n"); } /* Show debug status for NSM. */ if (IS_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM) - vty_outln (vty, " OSPF NSM debugging is on"); + vty_out (vty, " OSPF NSM debugging is on\n"); else { if (IS_DEBUG_OSPF (nsm, NSM_STATUS)) - vty_outln (vty, " OSPF NSM status debugging is on"); + vty_out (vty, " OSPF NSM status debugging is on\n"); if (IS_DEBUG_OSPF (nsm, NSM_EVENTS)) - vty_outln (vty, " OSPF NSM event debugging is on"); + vty_out (vty, " OSPF NSM event debugging is on\n"); if (IS_DEBUG_OSPF (nsm, NSM_TIMERS)) - vty_outln (vty, " OSPF NSM timer debugging is on"); + vty_out (vty, " OSPF NSM timer debugging is on\n"); } /* Show debug status for OSPF Packets. */ for (i = 0; i < 5; i++) if (IS_DEBUG_OSPF_PACKET (i, SEND) && IS_DEBUG_OSPF_PACKET (i, RECV)) { - vty_outln (vty, " OSPF packet %s%s debugging is on", + vty_out (vty, " OSPF packet %s%s debugging is on\n", lookup_msg(ospf_packet_type_str, i + 1, NULL), IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : ""); } else { if (IS_DEBUG_OSPF_PACKET (i, SEND)) - vty_outln (vty, " OSPF packet %s send%s debugging is on", + vty_out (vty, " OSPF packet %s send%s debugging is on\n", lookup_msg(ospf_packet_type_str, i + 1, NULL), IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : ""); if (IS_DEBUG_OSPF_PACKET (i, RECV)) - vty_outln (vty, " OSPF packet %s receive%s debugging is on", + vty_out (vty, " OSPF packet %s receive%s debugging is on\n", lookup_msg(ospf_packet_type_str, i + 1, NULL), IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : ""); } /* Show debug status for OSPF LSAs. */ if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA) - vty_outln (vty, " OSPF LSA debugging is on"); + vty_out (vty, " OSPF LSA debugging is on\n"); else { if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) - vty_outln (vty, " OSPF LSA generation debugging is on"); + vty_out (vty, " OSPF LSA generation debugging is on\n"); if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) - vty_outln (vty, " OSPF LSA flooding debugging is on"); + vty_out (vty, " OSPF LSA flooding debugging is on\n"); if (IS_DEBUG_OSPF (lsa, LSA_INSTALL)) - vty_outln (vty, " OSPF LSA install debugging is on"); + vty_out (vty, " OSPF LSA install debugging is on\n"); if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) - vty_outln (vty, " OSPF LSA refresh debugging is on"); + vty_out (vty, " OSPF LSA refresh debugging is on\n"); } /* Show debug status for Zebra. */ if (IS_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA) - vty_outln (vty, " OSPF Zebra debugging is on"); + vty_out (vty, " OSPF Zebra debugging is on\n"); else { if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) - vty_outln (vty, " OSPF Zebra interface debugging is on"); + vty_out (vty, " OSPF Zebra interface debugging is on\n"); if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) - vty_outln (vty, " OSPF Zebra redistribute debugging is on"); + vty_out (vty, " OSPF Zebra redistribute debugging is on\n"); } /* Show debug status for NSSA. */ if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA) - vty_outln (vty, " OSPF NSSA debugging is on"); + vty_out (vty, " OSPF NSSA debugging is on\n"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -1722,56 +1721,56 @@ config_write_debug (struct vty *vty) /* debug ospf ism (status|events|timers). */ if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM) - vty_outln (vty, "debug ospf%s ism", str); + vty_out (vty, "debug ospf%s ism\n", str); else { if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS)) - vty_outln (vty, "debug ospf%s ism status", str); + vty_out (vty, "debug ospf%s ism status\n", str); if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS)) - vty_outln (vty, "debug ospf%s ism event", str); + vty_out (vty, "debug ospf%s ism event\n", str); if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS)) - vty_outln (vty, "debug ospf%s ism timer", str); + vty_out (vty, "debug ospf%s ism timer\n", str); } /* debug ospf nsm (status|events|timers). */ if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM) - vty_outln (vty, "debug ospf%s nsm", str); + vty_out (vty, "debug ospf%s nsm\n", str); else { if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS)) - vty_outln (vty, "debug ospf%s nsm status", str); + vty_out (vty, "debug ospf%s nsm status\n", str); if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS)) - vty_outln (vty, "debug ospf%s nsm event", str); + vty_out (vty, "debug ospf%s nsm event\n", str); if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS)) - vty_outln (vty, "debug ospf%s nsm timer", str); + vty_out (vty, "debug ospf%s nsm timer\n", str); } /* debug ospf lsa (generate|flooding|install|refresh). */ if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA) - vty_outln (vty, "debug ospf%s lsa", str); + vty_out (vty, "debug ospf%s lsa\n", str); else { if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE)) - vty_outln (vty, "debug ospf%s lsa generate", str); + vty_out (vty, "debug ospf%s lsa generate\n", str); if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING)) - vty_outln (vty, "debug ospf%s lsa flooding", str); + vty_out (vty, "debug ospf%s lsa flooding\n", str); if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL)) - vty_outln (vty, "debug ospf%s lsa install", str); + vty_out (vty, "debug ospf%s lsa install\n", str); if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH)) - vty_outln (vty, "debug ospf%s lsa refresh", str); + vty_out (vty, "debug ospf%s lsa refresh\n", str); write = 1; } /* debug ospf zebra (interface|redistribute). */ if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA) - vty_outln (vty, "debug ospf%s zebra", str); + vty_out (vty, "debug ospf%s zebra\n", str); else { if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) - vty_outln (vty, "debug ospf%s zebra interface", str); + vty_out (vty, "debug ospf%s zebra interface\n", str); if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) - vty_outln (vty, "debug ospf%s zebra redistribute", str); + vty_out (vty, "debug ospf%s zebra redistribute\n", str); write = 1; } @@ -1779,14 +1778,14 @@ config_write_debug (struct vty *vty) /* debug ospf event. */ if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT) { - vty_outln (vty, "debug ospf%s event", str); + vty_out (vty, "debug ospf%s event\n", str); write = 1; } /* debug ospf nssa. */ if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA) { - vty_outln (vty, "debug ospf%s nssa", str); + vty_out (vty, "debug ospf%s nssa\n", str); write = 1; } @@ -1796,7 +1795,7 @@ config_write_debug (struct vty *vty) r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL); if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL)) { - vty_outln (vty, "debug ospf%s packet all detail", str); + vty_out (vty, "debug ospf%s packet all detail\n", str); return 1; } @@ -1806,10 +1805,10 @@ config_write_debug (struct vty *vty) r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV; if (r == OSPF_DEBUG_SEND_RECV) { - vty_outln (vty, "debug ospf%s packet all", str); + vty_out (vty, "debug ospf%s packet all\n", str); for (i = 0; i < 5; i++) if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL) - vty_outln (vty, "debug ospf%s packet %s detail", str, + vty_out (vty, "debug ospf%s packet %s detail\n", str, type_str[i]); return 1; } @@ -1821,7 +1820,7 @@ config_write_debug (struct vty *vty) if (conf_debug_ospf_packet[i] == 0) continue; - vty_outln (vty, "debug ospf%s packet %s%s", str, + vty_out (vty, "debug ospf%s packet %s%s\n", str, type_str[i],detail_str[conf_debug_ospf_packet[i]]); write = 1; } diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index 09d218f81..f3db6afd1 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -1120,7 +1120,7 @@ ospf_opaque_config_write_router (struct vty *vty, struct ospf *ospf) struct list *funclist; if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) - vty_outln (vty, " capability opaque"); + vty_out (vty, " capability opaque\n"); funclist = ospf_opaque_wildcard_funclist; opaque_lsa_config_write_router_callback (funclist, vty); @@ -1189,11 +1189,11 @@ show_opaque_info_detail (struct vty *vty, struct ospf_lsa *lsa) /* Switch output functionality by vty address. */ if (vty != NULL) { - vty_outln (vty, " Opaque-Type %u (%s)", opaque_type, + vty_out (vty, " Opaque-Type %u (%s)\n", opaque_type, ospf_opaque_type_name(opaque_type)); - vty_outln (vty, " Opaque-ID 0x%x", opaque_id); + vty_out (vty, " Opaque-ID 0x%x\n", opaque_id); - vty_outln (vty, " Opaque-Info: %u octets of data%s", + vty_out (vty, " Opaque-Info: %u octets of data%s\n", ntohs (lsah->length) - OSPF_LSA_HEADER_SIZE, VALID_OPAQUE_INFO_LEN(lsah) ? "" : "(Invalid length?)"); } diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index 1fb52a94b..0f1ef35e4 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -906,7 +906,7 @@ show_vty_router_cap (struct vty *vty, struct ri_tlv_header *tlvh) struct ri_tlv_router_cap *top = (struct ri_tlv_router_cap *) tlvh; if (vty != NULL) - vty_outln (vty, " Router Capabilities: 0x%x",ntohl(top->value)); + vty_out (vty, " Router Capabilities: 0x%x\n",ntohl(top->value)); else zlog_debug (" Router Capabilities: 0x%x", ntohl (top->value)); @@ -921,7 +921,7 @@ show_vty_pce_subtlv_address (struct vty *vty, struct ri_tlv_header *tlvh) if (ntohs (top->address.type) == PCE_ADDRESS_TYPE_IPV4) { if (vty != NULL) - vty_outln (vty, " PCE Address: %s",inet_ntoa(top->address.value)); + vty_out (vty, " PCE Address: %s\n",inet_ntoa(top->address.value)); else zlog_debug (" PCE Address: %s", inet_ntoa (top->address.value)); } @@ -929,7 +929,7 @@ show_vty_pce_subtlv_address (struct vty *vty, struct ri_tlv_header *tlvh) { /* TODO: Add support to IPv6 with inet_ntop() */ if (vty != NULL) - vty_outln (vty, " PCE Address: 0x%x", + vty_out (vty, " PCE Address: 0x%x\n", ntohl(top->address.value.s_addr)); else zlog_debug (" PCE Address: 0x%x", @@ -946,7 +946,7 @@ show_vty_pce_subtlv_path_scope (struct vty *vty, struct ri_tlv_header *tlvh) (struct ri_pce_subtlv_path_scope *) tlvh; if (vty != NULL) - vty_outln (vty, " PCE Path Scope: 0x%x",ntohl(top->value)); + vty_out (vty, " PCE Path Scope: 0x%x\n",ntohl(top->value)); else zlog_debug (" PCE Path Scope: 0x%x", ntohl (top->value)); @@ -963,14 +963,14 @@ show_vty_pce_subtlv_domain (struct vty *vty, struct ri_tlv_header *tlvh) { tmp.s_addr = top->value; if (vty != NULL) - vty_outln (vty, " PCE domain Area: %s",inet_ntoa(tmp)); + vty_out (vty, " PCE domain Area: %s\n",inet_ntoa(tmp)); else zlog_debug (" PCE domain Area: %s", inet_ntoa (tmp)); } else { if (vty != NULL) - vty_outln (vty, " PCE domain AS: %d",ntohl(top->value)); + vty_out (vty, " PCE domain AS: %d\n",ntohl(top->value)); else zlog_debug (" PCE domain AS: %d", ntohl (top->value)); } @@ -988,14 +988,14 @@ show_vty_pce_subtlv_neighbor (struct vty *vty, struct ri_tlv_header *tlvh) { tmp.s_addr = top->value; if (vty != NULL) - vty_outln (vty, " PCE neighbor Area: %s",inet_ntoa(tmp)); + vty_out (vty, " PCE neighbor Area: %s\n",inet_ntoa(tmp)); else zlog_debug (" PCE neighbor Area: %s", inet_ntoa (tmp)); } else { if (vty != NULL) - vty_outln (vty, " PCE neighbor AS: %d",ntohl(top->value)); + vty_out (vty, " PCE neighbor AS: %d\n",ntohl(top->value)); else zlog_debug (" PCE neighbor AS: %d", ntohl (top->value)); } @@ -1008,7 +1008,7 @@ show_vty_pce_subtlv_cap_flag (struct vty *vty, struct ri_tlv_header *tlvh) struct ri_pce_subtlv_cap_flag *top = (struct ri_pce_subtlv_cap_flag *) tlvh; if (vty != NULL) - vty_outln (vty, " PCE Capabilities Flag: 0x%x",ntohl(top->value)); + vty_out (vty, " PCE Capabilities Flag: 0x%x\n",ntohl(top->value)); else zlog_debug (" PCE Capabilities Flag: 0x%x", ntohl (top->value)); @@ -1019,7 +1019,7 @@ static u_int16_t show_vty_unknown_tlv (struct vty *vty, struct ri_tlv_header *tlvh) { if (vty != NULL) - vty_outln (vty, " Unknown TLV: [type(0x%x), length(0x%x)]", + vty_out (vty, " Unknown TLV: [type(0x%x), length(0x%x)]\n", ntohs (tlvh->type), ntohs(tlvh->length)); else zlog_debug (" Unknown TLV: [type(0x%x), length(0x%x)]", @@ -1105,16 +1105,16 @@ ospf_router_info_config_write_router (struct vty *vty) if (OspfRI.status == enabled) { if (OspfRI.scope == OSPF_OPAQUE_AS_LSA) - vty_outln (vty, " router-info as"); + vty_out (vty, " router-info as\n"); else - vty_outln (vty, " router-info area %s",inet_ntoa(OspfRI.area_id)); + vty_out (vty, " router-info area %s\n",inet_ntoa(OspfRI.area_id)); if (pce->pce_address.header.type != 0) - vty_outln (vty, " pce address %s", + vty_out (vty, " pce address %s\n", inet_ntoa(pce->pce_address.address.value)); if (pce->pce_cap_flag.header.type != 0) - vty_outln (vty, " pce flag 0x%x",ntohl(pce->pce_cap_flag.value)); + vty_out (vty, " pce flag 0x%x\n",ntohl(pce->pce_cap_flag.value)); for (ALL_LIST_ELEMENTS_RO (pce->pce_domain, node, domain)) { @@ -1123,11 +1123,11 @@ ospf_router_info_config_write_router (struct vty *vty) if (domain->type == PCE_DOMAIN_TYPE_AREA) { tmp.s_addr = domain->value; - vty_outln (vty, " pce domain area %s",inet_ntoa(tmp)); + vty_out (vty, " pce domain area %s\n",inet_ntoa(tmp)); } else { - vty_outln (vty, " pce domain as %d",ntohl(domain->value)); + vty_out (vty, " pce domain as %d\n",ntohl(domain->value)); } } } @@ -1139,18 +1139,18 @@ ospf_router_info_config_write_router (struct vty *vty) if (neighbor->type == PCE_DOMAIN_TYPE_AREA) { tmp.s_addr = neighbor->value; - vty_outln (vty, " pce neighbor area %s",inet_ntoa(tmp)); + vty_out (vty, " pce neighbor area %s\n",inet_ntoa(tmp)); } else { - vty_outln (vty, " pce neighbor as %d", + vty_out (vty, " pce neighbor as %d\n", ntohl(neighbor->value)); } } } if (pce->pce_scope.header.type != 0) - vty_outln (vty, " pce scope 0x%x", + vty_out (vty, " pce scope 0x%x\n", ntohl(OspfRI.pce_info.pce_scope.value)); } return; @@ -1181,9 +1181,9 @@ DEFUN (router_info, { if (!inet_aton (area, &OspfRI.area_id)) { - vty_outln (vty, "%% specified Area ID %s is invalid", + vty_out (vty, "%% specified Area ID %s is invalid\n", area); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } scope = OSPF_OPAQUE_AREA_LSA; } @@ -1197,7 +1197,7 @@ DEFUN (router_info, if ((ospf_router_info_register (scope)) != 0) { zlog_warn ("Enable to register Router Information callbacks. Abort!"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } OspfRI.status = enabled; @@ -1257,7 +1257,7 @@ ospf_ri_enabled (struct vty *vty) return 1; if (vty) - vty_outln (vty, "%% OSPF RI is not turned on"); + vty_out (vty, "%% OSPF RI is not turned on\n"); return 0; } @@ -1274,12 +1274,12 @@ DEFUN (pce_address, struct ospf_pce_info *pi = &OspfRI.pce_info; if (!ospf_ri_enabled (vty)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (!inet_aton (argv[idx_ipv4]->arg, &value)) { - vty_outln (vty, "Please specify PCE Address by A.B.C.D"); - return CMD_WARNING; + vty_out (vty, "Please specify PCE Address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } if (ntohs (pi->pce_address.header.type) == 0 @@ -1326,12 +1326,12 @@ DEFUN (pce_path_scope, struct ospf_pce_info *pi = &OspfRI.pce_info; if (!ospf_ri_enabled (vty)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &scope) != 1) { - vty_outln (vty, "pce_path_scope: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "pce_path_scope: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } if (ntohl (pi->pce_scope.header.type) == 0 || scope != pi->pce_scope.value) @@ -1380,12 +1380,12 @@ DEFUN (pce_domain, struct ri_pce_subtlv_domain *domain; if (!ospf_ri_enabled (vty)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { - vty_outln (vty, "pce_domain: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "pce_domain: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } /* Check if the domain is not already in the domain list */ @@ -1421,8 +1421,8 @@ DEFUN (no_pce_domain, if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { - vty_outln (vty, "no_pce_domain: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "no_pce_domain: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } /* Unset corresponding PCE domain */ @@ -1451,12 +1451,12 @@ DEFUN (pce_neigbhor, struct ri_pce_subtlv_neighbor *neighbor; if (!ospf_ri_enabled (vty)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { - vty_outln (vty, "pce_neighbor: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "pce_neighbor: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } /* Check if the domain is not already in the domain list */ @@ -1492,8 +1492,8 @@ DEFUN (no_pce_neighbor, if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { - vty_outln (vty, "no_pce_neighbor: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "no_pce_neighbor: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } /* Unset corresponding PCE domain */ @@ -1519,12 +1519,12 @@ DEFUN (pce_cap_flag, struct ospf_pce_info *pce = &OspfRI.pce_info; if (!ospf_ri_enabled (vty)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &cap) != 1) { - vty_outln (vty, "pce_cap_flag: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "pce_cap_flag: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } if (ntohl (pce->pce_cap_flag.header.type) == 0 @@ -1568,13 +1568,13 @@ DEFUN (show_ip_ospf_router_info, if (OspfRI.status == enabled) { - vty_outln (vty, "--- Router Information parameters ---"); + vty_out (vty, "--- Router Information parameters ---\n"); show_vty_router_cap (vty, &OspfRI.router_cap.header); } else { if (vty != NULL) - vty_outln (vty, " Router Information is disabled on this router"); + vty_out (vty, " Router Information is disabled on this router\n"); } return CMD_SUCCESS; } @@ -1596,7 +1596,7 @@ DEFUN (show_ip_opsf_router_info_pce, if (OspfRI.status == enabled) { - vty_outln (vty, "--- PCE parameters ---"); + vty_out (vty, "--- PCE parameters ---\n"); if (pce->pce_address.header.type != 0) show_vty_pce_subtlv_address (vty, &pce->pce_address.header); @@ -1622,7 +1622,7 @@ DEFUN (show_ip_opsf_router_info_pce, } else { - vty_outln (vty," Router Information is disabled on this router"); + vty_out (vty," Router Information is disabled on this router\n"); } return CMD_SUCCESS; diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index aafc0a98e..c34d97ff2 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -1671,7 +1671,7 @@ show_vty_router_addr (struct vty *vty, struct te_tlv_header *tlvh) struct te_tlv_router_addr *top = (struct te_tlv_router_addr *) tlvh; if (vty != NULL) - vty_outln (vty, " Router-Address: %s",inet_ntoa(top->value)); + vty_out (vty, " Router-Address: %s\n",inet_ntoa(top->value)); else zlog_debug (" Router-Address: %s", inet_ntoa (top->value)); @@ -1684,7 +1684,7 @@ show_vty_link_header (struct vty *vty, struct te_tlv_header *tlvh) struct te_tlv_link *top = (struct te_tlv_link *) tlvh; if (vty != NULL) - vty_outln (vty, " Link: %u octets of data",ntohs(top->header.length)); + vty_out (vty, " Link: %u octets of data\n",ntohs(top->header.length)); else zlog_debug (" Link: %u octets of data", ntohs (top->header.length)); @@ -1711,7 +1711,7 @@ show_vty_link_subtlv_link_type (struct vty *vty, struct te_tlv_header *tlvh) } if (vty != NULL) - vty_outln (vty, " Link-Type: %s (%u)", cp,top->link_type.value); + vty_out (vty, " Link-Type: %s (%u)\n", cp,top->link_type.value); else zlog_debug (" Link-Type: %s (%u)", cp, top->link_type.value); @@ -1725,7 +1725,7 @@ show_vty_link_subtlv_link_id (struct vty *vty, struct te_tlv_header *tlvh) top = (struct te_link_subtlv_link_id *) tlvh; if (vty != NULL) - vty_outln (vty, " Link-ID: %s", inet_ntoa(top->value)); + vty_out (vty, " Link-ID: %s\n", inet_ntoa(top->value)); else zlog_debug (" Link-ID: %s", inet_ntoa (top->value)); @@ -1743,14 +1743,14 @@ show_vty_link_subtlv_lclif_ipaddr (struct vty *vty, n = ntohs (tlvh->length) / sizeof (top->value[0]); if (vty != NULL) - vty_outln (vty, " Local Interface IP Address(es): %d", n); + vty_out (vty, " Local Interface IP Address(es): %d\n", n); else zlog_debug (" Local Interface IP Address(es): %d", n); for (i = 0; i < n; i++) { if (vty != NULL) - vty_outln (vty, " #%d: %s", i,inet_ntoa(top->value[i])); + vty_out (vty, " #%d: %s\n", i,inet_ntoa(top->value[i])); else zlog_debug (" #%d: %s", i, inet_ntoa (top->value[i])); } @@ -1767,14 +1767,14 @@ show_vty_link_subtlv_rmtif_ipaddr (struct vty *vty, top = (struct te_link_subtlv_rmtif_ipaddr *) tlvh; n = ntohs (tlvh->length) / sizeof (top->value[0]); if (vty != NULL) - vty_outln (vty, " Remote Interface IP Address(es): %d", n); + vty_out (vty, " Remote Interface IP Address(es): %d\n", n); else zlog_debug (" Remote Interface IP Address(es): %d", n); for (i = 0; i < n; i++) { if (vty != NULL) - vty_outln (vty, " #%d: %s", i,inet_ntoa(top->value[i])); + vty_out (vty, " #%d: %s\n", i,inet_ntoa(top->value[i])); else zlog_debug (" #%d: %s", i, inet_ntoa (top->value[i])); } @@ -1788,7 +1788,7 @@ show_vty_link_subtlv_te_metric (struct vty *vty, struct te_tlv_header *tlvh) top = (struct te_link_subtlv_te_metric *) tlvh; if (vty != NULL) - vty_outln (vty, " Traffic Engineering Metric: %u", + vty_out (vty, " Traffic Engineering Metric: %u\n", (u_int32_t)ntohl(top->value)); else zlog_debug (" Traffic Engineering Metric: %u", @@ -1807,7 +1807,7 @@ show_vty_link_subtlv_max_bw (struct vty *vty, struct te_tlv_header *tlvh) fval = ntohf (top->value); if (vty != NULL) - vty_outln (vty, " Maximum Bandwidth: %g (Bytes/sec)", fval); + vty_out (vty, " Maximum Bandwidth: %g (Bytes/sec)\n", fval); else zlog_debug (" Maximum Bandwidth: %g (Bytes/sec)", fval); @@ -1824,7 +1824,7 @@ show_vty_link_subtlv_max_rsv_bw (struct vty *vty, struct te_tlv_header *tlvh) fval = ntohf (top->value); if (vty != NULL) - vty_outln (vty, " Maximum Reservable Bandwidth: %g (Bytes/sec)",fval); + vty_out (vty, " Maximum Reservable Bandwidth: %g (Bytes/sec)\n",fval); else zlog_debug (" Maximum Reservable Bandwidth: %g (Bytes/sec)", fval); @@ -1840,7 +1840,7 @@ show_vty_link_subtlv_unrsv_bw (struct vty *vty, struct te_tlv_header *tlvh) top = (struct te_link_subtlv_unrsv_bw *) tlvh; if (vty != NULL) - vty_outln (vty, " Unreserved Bandwidth per Class Type in Byte/s:"); + vty_out (vty, " Unreserved Bandwidth per Class Type in Byte/s:\n"); else zlog_debug (" Unreserved Bandwidth per Class Type in Byte/s:"); for (i = 0; i < MAX_CLASS_TYPE; i+=2) @@ -1849,7 +1849,7 @@ show_vty_link_subtlv_unrsv_bw (struct vty *vty, struct te_tlv_header *tlvh) fval2 = ntohf (top->value[i+1]); if (vty != NULL) - vty_outln (vty, " [%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)", + vty_out (vty, " [%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", i, fval1, i+1, fval2); else zlog_debug (" [%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)", @@ -1866,7 +1866,7 @@ show_vty_link_subtlv_rsc_clsclr (struct vty *vty, struct te_tlv_header *tlvh) top = (struct te_link_subtlv_rsc_clsclr *) tlvh; if (vty != NULL) - vty_outln (vty, " Resource class/color: 0x%x", + vty_out (vty, " Resource class/color: 0x%x\n", (u_int32_t)ntohl(top->value)); else zlog_debug (" Resource Class/Color: 0x%x", @@ -1884,8 +1884,8 @@ show_vty_link_subtlv_lrrid (struct vty *vty, struct te_tlv_header *tlvh) if (vty != NULL) { - vty_outln (vty, " Local TE Router ID: %s",inet_ntoa(top->local)); - vty_outln (vty, " Remote TE Router ID: %s",inet_ntoa(top->remote)); + vty_out (vty, " Local TE Router ID: %s\n",inet_ntoa(top->local)); + vty_out (vty, " Remote TE Router ID: %s\n",inet_ntoa(top->remote)); } else { @@ -1905,8 +1905,8 @@ show_vty_link_subtlv_llri (struct vty *vty, struct te_tlv_header *tlvh) if (vty != NULL) { - vty_outln (vty, " Link Local ID: %d",(u_int32_t)ntohl(top->local)); - vty_outln (vty, " Link Remote ID: %d",(u_int32_t)ntohl(top->remote)); + vty_out (vty, " Link Local ID: %d\n",(u_int32_t)ntohl(top->local)); + vty_out (vty, " Link Remote ID: %d\n",(u_int32_t)ntohl(top->remote)); } else { @@ -1925,7 +1925,7 @@ show_vty_link_subtlv_rip (struct vty *vty, struct te_tlv_header *tlvh) top = (struct te_link_subtlv_rip *) tlvh; if (vty != NULL) - vty_outln (vty, " Inter-AS TE Remote ASBR IP address: %s", + vty_out (vty, " Inter-AS TE Remote ASBR IP address: %s\n", inet_ntoa(top->value)); else zlog_debug (" Inter-AS TE Remote ASBR IP address: %s", @@ -1942,7 +1942,7 @@ show_vty_link_subtlv_ras (struct vty *vty, struct te_tlv_header *tlvh) top = (struct te_link_subtlv_ras *) tlvh; if (vty != NULL) - vty_outln (vty, " Inter-AS TE Remote AS number: %u",ntohl(top->value)); + vty_out (vty, " Inter-AS TE Remote AS number: %u\n",ntohl(top->value)); else zlog_debug (" Inter-AS TE Remote AS number: %u", ntohl (top->value)); @@ -1961,7 +1961,7 @@ show_vty_link_subtlv_av_delay (struct vty *vty, struct te_tlv_header *tlvh) anomalous = (u_int32_t) ntohl (top->value) & TE_EXT_ANORMAL; if (vty != NULL) - vty_outln (vty, " %s Average Link Delay: %d (micro-sec)", + vty_out (vty, " %s Average Link Delay: %d (micro-sec)\n", anomalous ? "Anomalous" : "Normal", delay); else zlog_debug (" %s Average Link Delay: %d (micro-sec)", @@ -1983,7 +1983,7 @@ show_vty_link_subtlv_mm_delay (struct vty *vty, struct te_tlv_header *tlvh) high = (u_int32_t) ntohl (top->high); if (vty != NULL) - vty_outln (vty, " %s Min/Max Link Delay: %d/%d (micro-sec)", + vty_out (vty, " %s Min/Max Link Delay: %d/%d (micro-sec)\n", anomalous ? "Anomalous" : "Normal", low, high); else zlog_debug (" %s Min/Max Link Delay: %d/%d (micro-sec)", @@ -2002,7 +2002,7 @@ show_vty_link_subtlv_delay_var (struct vty *vty, struct te_tlv_header *tlvh) jitter = (u_int32_t) ntohl (top->value) & TE_EXT_MASK; if (vty != NULL) - vty_outln (vty, " Delay Variation: %d (micro-sec)", jitter); + vty_out (vty, " Delay Variation: %d (micro-sec)\n", jitter); else zlog_debug (" Delay Variation: %d (micro-sec)", jitter); @@ -2023,7 +2023,7 @@ show_vty_link_subtlv_pkt_loss (struct vty *vty, struct te_tlv_header *tlvh) anomalous = (u_int32_t) ntohl (top->value) & TE_EXT_ANORMAL; if (vty != NULL) - vty_outln (vty, " %s Link Loss: %g (%%)", anomalous ? "Anomalous" : "Normal", + vty_out (vty, " %s Link Loss: %g (%%)\n", anomalous ? "Anomalous" : "Normal", fval); else zlog_debug (" %s Link Loss: %g (%%)", anomalous ? "Anomalous" : "Normal", @@ -2042,7 +2042,7 @@ show_vty_link_subtlv_res_bw (struct vty *vty, struct te_tlv_header *tlvh) fval = ntohf (top->value); if (vty != NULL) - vty_outln (vty, " Unidirectional Residual Bandwidth: %g (Bytes/sec)", + vty_out (vty, " Unidirectional Residual Bandwidth: %g (Bytes/sec)\n", fval); else zlog_debug (" Unidirectional Residual Bandwidth: %g (Bytes/sec)", @@ -2061,7 +2061,7 @@ show_vty_link_subtlv_ava_bw (struct vty *vty, struct te_tlv_header *tlvh) fval = ntohf (top->value); if (vty != NULL) - vty_outln (vty, " Unidirectional Available Bandwidth: %g (Bytes/sec)", + vty_out (vty, " Unidirectional Available Bandwidth: %g (Bytes/sec)\n", fval); else zlog_debug (" Unidirectional Available Bandwidth: %g (Bytes/sec)", @@ -2080,7 +2080,7 @@ show_vty_link_subtlv_use_bw (struct vty *vty, struct te_tlv_header *tlvh) fval = ntohf (top->value); if (vty != NULL) - vty_outln (vty, " Unidirectional Utilized Bandwidth: %g (Bytes/sec)", + vty_out (vty, " Unidirectional Utilized Bandwidth: %g (Bytes/sec)\n", fval); else zlog_debug (" Unidirectional Utilized Bandwidth: %g (Bytes/sec)", @@ -2093,7 +2093,7 @@ static u_int16_t show_vty_unknown_tlv (struct vty *vty, struct te_tlv_header *tlvh) { if (vty != NULL) - vty_outln (vty, " Unknown TLV: [type(0x%x), length(0x%x)]", + vty_out (vty, " Unknown TLV: [type(0x%x), length(0x%x)]\n", ntohs (tlvh->type), ntohs(tlvh->length)); else zlog_debug (" Unknown TLV: [type(0x%x), length(0x%x)]", @@ -2230,15 +2230,15 @@ ospf_mpls_te_config_write_router (struct vty *vty) if (OspfMplsTE.status == enabled) { - vty_outln (vty, " mpls-te on"); - vty_outln (vty, " mpls-te router-address %s", + vty_out (vty, " mpls-te on\n"); + vty_out (vty, " mpls-te router-address %s\n", inet_ntoa(OspfMplsTE.router_addr.value)); } if (OspfMplsTE.inter_as == AS) - vty_outln (vty, " mpls-te inter-as as"); + vty_out (vty, " mpls-te inter-as as\n"); if (OspfMplsTE.inter_as == Area) - vty_outln (vty, " mpls-te inter-as area %s ", + vty_out (vty, " mpls-te inter-as area %s \n", inet_ntoa(OspfMplsTE.interas_areaid)); return; @@ -2325,7 +2325,7 @@ DEFUN (ospf_mpls_te_router_addr, if (! inet_aton (argv[idx_ipv4]->arg, &value)) { - vty_outln (vty, "Please specify Router-Addr by A.B.C.D"); + vty_out (vty, "Please specify Router-Addr by A.B.C.D\n"); return CMD_WARNING; } @@ -2393,7 +2393,7 @@ set_inter_as_mode (struct vty *vty, const char *mode_name, } else { - vty_outln (vty,"Unknown mode. Please choose between as or area"); + vty_out (vty,"Unknown mode. Please choose between as or area\n"); return CMD_WARNING; } @@ -2404,8 +2404,8 @@ set_inter_as_mode (struct vty *vty, const char *mode_name, /* Register new callbacks regarding the flooding scope (AS or Area) */ if (ospf_mpls_te_register (mode) < 0) { - vty_outln (vty, - "Internal error: Unable to register Inter-AS functions"); + vty_out (vty, + "Internal error: Unable to register Inter-AS functions\n"); return CMD_WARNING; } @@ -2428,14 +2428,14 @@ set_inter_as_mode (struct vty *vty, const char *mode_name, } else { - vty_outln (vty, "Please change Inter-AS support to disable first before going to mode %s", + vty_out (vty, "Please change Inter-AS support to disable first before going to mode %s\n", mode2text[mode]); return CMD_WARNING; } } else { - vty_outln (vty, "mpls-te has not been turned on"); + vty_out (vty, "mpls-te has not been turned on\n"); return CMD_WARNING; } return CMD_SUCCESS; @@ -2505,12 +2505,12 @@ DEFUN (show_ip_ospf_mpls_te_router, { if (OspfMplsTE.status == enabled) { - vty_outln (vty, "--- MPLS-TE router parameters ---"); + vty_out (vty, "--- MPLS-TE router parameters ---\n"); if (ntohs (OspfMplsTE.router_addr.header.type) != 0) show_vty_router_addr (vty, &OspfMplsTE.router_addr.header); else if (vty != NULL) - vty_outln (vty, " N/A"); + vty_out (vty, " N/A\n"); } return CMD_SUCCESS; } @@ -2531,21 +2531,21 @@ show_mpls_te_link_sub (struct vty *vty, struct interface *ifp) { if (IS_INTER_AS (lp->type)) { - vty_outln (vty, "-- Inter-AS TEv2 link parameters for %s --", + vty_out (vty, "-- Inter-AS TEv2 link parameters for %s --\n", ifp->name); } else { /* MPLS-TE is not activate on this interface */ /* or this interface is passive and Inter-AS TEv2 is not activate */ - vty_outln (vty, " %s: MPLS-TE is disabled on this interface", + vty_out (vty, " %s: MPLS-TE is disabled on this interface\n", ifp->name); return; } } else { - vty_outln (vty, "-- MPLS-TE link parameters for %s --", + vty_out (vty, "-- MPLS-TE link parameters for %s --\n", ifp->name); } @@ -2585,11 +2585,11 @@ show_mpls_te_link_sub (struct vty *vty, struct interface *ifp) show_vty_link_subtlv_ava_bw (vty, &lp->ava_bw.header); if (TLV_TYPE(lp->use_bw) != 0) show_vty_link_subtlv_use_bw (vty, &lp->use_bw.header); - vty_outln (vty, "---------------%s", VTYNL); + vty_out (vty, "---------------\n\n"); } else { - vty_outln (vty, " %s: MPLS-TE is disabled on this interface", + vty_out (vty, " %s: MPLS-TE is disabled on this interface\n", ifp->name); } @@ -2620,7 +2620,7 @@ DEFUN (show_ip_ospf_mpls_te_link, else { if ((ifp = if_lookup_by_name (argv[idx_interface]->arg, VRF_DEFAULT)) == NULL) - vty_outln (vty, "No such interface name"); + vty_out (vty, "No such interface name\n"); else show_mpls_te_link_sub (vty, ifp); } diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index bc98da45e..f6387b759 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -100,7 +100,7 @@ str2metric (const char *str, int *metric) *metric = strtol (str, NULL, 10); if (*metric < 0 && *metric > 16777214) { - /* vty_out (vty, "OSPF metric value is invalid%s", VTYNL); */ + /* vty_out (vty, "OSPF metric value is invalid\n"); */ return 0; } @@ -150,8 +150,8 @@ DEFUN_NOSH (router_ospf, ospf = ospf_lookup(); if (!ospf) { - vty_out (vty, "There isn't active ospf instance %s", VTYNL); - return CMD_WARNING; + vty_out (vty, "There isn't active ospf instance \n"); + return CMD_WARNING_CONFIG_FAILED; } if (argc > 2) @@ -213,8 +213,8 @@ DEFUN (ospf_router_id, ret = inet_aton (argv[idx_ipv4]->arg, &router_id); if (!ret) { - vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify Router ID by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } ospf->router_id_static = router_id; @@ -223,7 +223,7 @@ DEFUN (ospf_router_id, if (area->full_nbrs) { vty_out (vty, "For this router-id change to take effect," - " save config and restart ospfd%s", VTYNL); + " save config and restart ospfd\n"); return CMD_SUCCESS; } @@ -248,8 +248,8 @@ DEFUN_HIDDEN (ospf_router_id_old, ret = inet_aton (argv[idx_ipv4]->arg, &router_id); if (!ret) { - vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify Router ID by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } ospf->router_id_static = router_id; @@ -258,7 +258,7 @@ DEFUN_HIDDEN (ospf_router_id_old, if (area->full_nbrs) { vty_out (vty, "For this router-id change to take effect," - " save config and restart ospfd%s", VTYNL); + " save config and restart ospfd\n"); return CMD_SUCCESS; } @@ -285,7 +285,7 @@ DEFUN (no_ospf_router_id, if (area->full_nbrs) { vty_out (vty, "For this router-id change to take effect," - " save config and restart ospfd%s", VTYNL); + " save config and restart ospfd\n"); return CMD_SUCCESS; } @@ -389,9 +389,8 @@ DEFUN (ospf_passive_interface, ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -459,9 +458,8 @@ DEFUN (no_ospf_passive_interface, ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); @@ -510,16 +508,14 @@ DEFUN (ospf_network_area, if (ospf->instance) { - vty_out (vty, "The network command is not supported in multi-instance ospf%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "The network command is not supported in multi-instance ospf\n"); + return CMD_WARNING_CONFIG_FAILED; } if (ospf->if_ospf_cli_count > 0) { - vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Get network prefix and Area ID. */ @@ -529,8 +525,8 @@ DEFUN (ospf_network_area, ret = ospf_network_set (ospf, &p, area_id, format); if (ret == 0) { - vty_out (vty, "There is already same network statement.%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "There is already same network statement.\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -555,9 +551,8 @@ DEFUN (no_ospf_network_area, if (ospf->instance) { - vty_out (vty, "The network command is not supported in multi-instance ospf%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "The network command is not supported in multi-instance ospf\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Get network prefix and Area ID. */ @@ -567,9 +562,8 @@ DEFUN (no_ospf_network_area, ret = ospf_network_unset (ospf, &p, area_id); if (ret == 0) { - vty_out (vty, "Can't find specified network area configuration.%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Can't find specified network area configuration.\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -812,8 +806,7 @@ ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) if (area_id.s_addr == OSPF_AREA_BACKBONE) { vty_out (vty, - "Configuring VLs over the backbone is not allowed%s", - VTYNL); + "Configuring VLs over the backbone is not allowed\n"); return NULL; } area = ospf_area_get (ospf, area_id); @@ -822,15 +815,13 @@ ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) if (area->external_routing != OSPF_AREA_DEFAULT) { if (vl_config->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) - vty_out (vty, "Area %s is %s%s", + vty_out (vty, "Area %s is %s\n", inet_ntoa (area_id), - area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", - VTYNL); + area->external_routing == OSPF_AREA_NSSA?"nssa":"stub"); else - vty_out (vty, "Area %ld is %s%s", + vty_out (vty, "Area %ld is %s\n", (u_long)ntohl (area_id.s_addr), - area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", - VTYNL); + area->external_routing == OSPF_AREA_NSSA?"nssa":"stub"); return NULL; } @@ -875,9 +866,9 @@ ospf_vl_set_security (struct ospf_vl_data *vl_data, if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) != NULL) { - vty_out (vty, "OSPF: Key %d already exists%s", - vl_config->crypto_key_id, VTYNL); - return CMD_WARNING; + vty_out (vty, "OSPF: Key %d already exists\n", + vl_config->crypto_key_id); + return CMD_WARNING_CONFIG_FAILED; } ck = ospf_crypt_key_new (); ck->key_id = vl_config->crypto_key_id; @@ -893,9 +884,9 @@ ospf_vl_set_security (struct ospf_vl_data *vl_data, if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) == NULL) { - vty_out (vty, "OSPF: Key %d does not exist%s", - vl_config->crypto_key_id, VTYNL); - return CMD_WARNING; + vty_out (vty, "OSPF: Key %d does not exist\n", + vl_config->crypto_key_id); + return CMD_WARNING_CONFIG_FAILED; } ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); @@ -949,7 +940,7 @@ ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) vl_data = ospf_find_vl_data (ospf, vl_config); if (!vl_data) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* Process this one first as it can have a fatal result, which can only logically occur if the virtual link exists already @@ -1037,16 +1028,15 @@ DEFUN (ospf_area_vlink, &vl_config.area_id_fmt); if (ret < 0) { - vty_out (vty, "OSPF area ID is invalid%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "OSPF area ID is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); if (! ret) { - vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify valid Router ID as a.b.c.d\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argc <=4) @@ -1060,7 +1050,7 @@ DEFUN (ospf_area_vlink, for (i=5; i < argc; i++) { - /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTYNL); */ + /* vty_out (vty, "argv[%d]->arg - %s\n", i, argv[i]->text); */ switch (argv[i]->arg[0]) { @@ -1107,7 +1097,7 @@ DEFUN (ospf_area_vlink, { vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); if (vl_config.crypto_key_id < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; i++; if (i < argc) { @@ -1157,23 +1147,22 @@ DEFUN (no_ospf_area_vlink, ret = str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format); if (ret < 0) { - vty_out (vty, "OSPF area ID is invalid%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "OSPF area ID is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); if (!area) { - vty_out (vty, "Area does not exist%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Area does not exist\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); if (! ret) { - vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify valid Router ID as a.b.c.d\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argc <=5) @@ -1193,7 +1182,7 @@ DEFUN (no_ospf_area_vlink, /* Deal with other parameters */ for (i=6; i < argc; i++) { - /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTYNL); */ + /* vty_out (vty, "argv[%d] - %s\n", i, argv[i]); */ switch (argv[i]->arg[0]) { @@ -1223,11 +1212,11 @@ DEFUN (no_ospf_area_vlink, { vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); if (vl_config.crypto_key_id < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; vl_config.md5_key = NULL; } else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; break; } @@ -1257,15 +1246,15 @@ DEFUN (ospf_area_vlink_intervals, ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); if (ret < 0) { - vty_out (vty, "OSPF area ID is invalid%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "OSPF area ID is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = inet_aton (router_id, &vl_config.vl_peer); if (! ret) { - vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify valid Router ID as a.b.c.d\n"); + return CMD_WARNING_CONFIG_FAILED; } for (int idx = 4; idx < argc; idx++) @@ -1303,15 +1292,15 @@ DEFUN (no_ospf_area_vlink_intervals, ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); if (ret < 0) { - vty_out (vty, "OSPF area ID is invalid%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "OSPF area ID is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = inet_aton (router_id, &vl_config.vl_peer); if (! ret) { - vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify valid Router ID as a.b.c.d\n"); + return CMD_WARNING_CONFIG_FAILED; } for (int idx = 5; idx < argc; idx++) @@ -1361,14 +1350,13 @@ DEFUN (ospf_area_shortcut, else if (strncmp (argv[idx_enable_disable]->arg, "e", 1) == 0) mode = OSPF_SHORTCUT_ENABLE; else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ospf_area_shortcut_set (ospf, area, mode); if (ospf->abr_type != OSPF_ABR_SHORTCUT) vty_out (vty, "Shortcut area setting will take effect " - "only when the router is configured as Shortcut ABR%s", - VTYNL); + "only when the router is configured as Shortcut ABR\n"); return CMD_SUCCESS; } @@ -1421,9 +1409,8 @@ DEFUN (ospf_area_stub, ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); if (ret == 0) { - vty_out (vty, "First deconfigure all virtual link through this area%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "First deconfigure all virtual link through this area\n"); + return CMD_WARNING_CONFIG_FAILED; } ospf_area_no_summary_unset (ospf, area_id); @@ -1451,9 +1438,8 @@ DEFUN (ospf_area_stub_no_summary, ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); if (ret == 0) { - vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Area cannot be stub as it contains a virtual link\n"); + return CMD_WARNING_CONFIG_FAILED; } ospf_area_no_summary_set (ospf, area_id); @@ -1518,9 +1504,8 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv, ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); if (ret == 0) { - vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "%% Area cannot be nssa as it contains a virtual link\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argc > 3) @@ -1658,8 +1643,8 @@ DEFUN (ospf_area_default_cost, if (area->external_routing == OSPF_AREA_DEFAULT) { - vty_out (vty, "The area is neither stub, nor NSSA%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "The area is neither stub, nor NSSA\n"); + return CMD_WARNING_CONFIG_FAILED; } area->default_cost = cost; @@ -1701,8 +1686,8 @@ DEFUN (no_ospf_area_default_cost, if (area->external_routing == OSPF_AREA_DEFAULT) { - vty_out (vty, "The area is neither stub, nor NSSA%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "The area is neither stub, nor NSSA\n"); + return CMD_WARNING_CONFIG_FAILED; } area->default_cost = 1; @@ -2031,7 +2016,7 @@ DEFUN (ospf_abr_type, else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) abr_type = OSPF_ABR_STAND; else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* If ABR type value is changed, schedule ABR task. */ if (ospf->abr_type != abr_type) @@ -2067,7 +2052,7 @@ DEFUN (no_ospf_abr_type, else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) abr_type = OSPF_ABR_STAND; else - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; /* If ABR type value is changed, schedule ABR task. */ if (ospf->abr_type == abr_type) @@ -2205,8 +2190,8 @@ DEFUN (ospf_timers_min_ls_interval, if (argc < 5) { - vty_out (vty, "Insufficient arguments%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Insufficient arguments\n"); + return CMD_WARNING_CONFIG_FAILED; } interval = strtoul(argv[idx_number]->arg, NULL, 10); @@ -2247,8 +2232,8 @@ DEFUN (ospf_timers_min_ls_arrival, if (argc < 4) { - vty_out (vty, "Insufficient arguments%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Insufficient arguments\n"); + return CMD_WARNING_CONFIG_FAILED; } arrival = strtoul(argv[idx_number]->arg, NULL, 10); @@ -2292,8 +2277,8 @@ DEFUN (ospf_timers_throttle_spf, if (argc < 6) { - vty_out (vty, "Insufficient arguments%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Insufficient arguments\n"); + return CMD_WARNING_CONFIG_FAILED; } delay = strtoul(argv[idx_number]->arg, NULL, 10); @@ -2335,8 +2320,8 @@ DEFUN (ospf_timers_lsa, if (argc < 4) { - vty_out (vty, "Insufficient number of arguments%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Insufficient number of arguments\n"); + return CMD_WARNING_CONFIG_FAILED; } minarrival = strtoul(argv[idx_number]->arg, NULL, 10); @@ -2549,8 +2534,8 @@ DEFUN (ospf_auto_cost_reference_bandwidth, refbw = strtol (argv[idx_number]->arg, NULL, 10); if (refbw < 1 || refbw > 4294967) { - vty_out (vty, "reference-bandwidth value is invalid%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "reference-bandwidth value is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } /* If reference bandwidth is changed. */ @@ -2580,8 +2565,8 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth, return CMD_SUCCESS; ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; - vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTYNL); - vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTYNL); + vty_out (vty, "%% OSPF: Reference bandwidth is changed.\n"); + vty_out (vty, " Please ensure reference bandwidth is consistent across all routers\n"); for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) ospf_if_recalculate_output_cost (ifp); @@ -2608,8 +2593,8 @@ DEFUN (ospf_write_multiplier, write_oi_count = strtol (argv[idx_number]->arg, NULL, 10); if (write_oi_count < 1 || write_oi_count > 100) { - vty_out (vty, "write-multiplier value is invalid%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "write-multiplier value is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } ospf->write_oi_count = write_oi_count; @@ -2677,7 +2662,7 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_ar if (use_json) json_object_boolean_true_add(json_area, "backbone"); else - vty_out (vty, " (Backbone)%s", VTYNL); + vty_out (vty, " (Backbone)\n"); } else { @@ -2714,11 +2699,11 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_ar area->no_summary ? ", no summary" : "", area->shortcut_configured ? "; " : ""); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); vty_out (vty, " Shortcutting mode: %s", ospf_shortcut_mode_descr_str[area->shortcut_configured]); - vty_out (vty, ", S-bit consensus: %s%s", - area->shortcut_capability ? "ok" : "no", VTYNL); + vty_out (vty, ", S-bit consensus: %s\n", + area->shortcut_capability ? "ok" : "no"); } } @@ -2730,8 +2715,8 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_ar } else vty_out (vty, " Number of interfaces in this area: Total: %d, " - "Active: %d%s", listcount (area->oiflist), - area->act_ints, VTYNL); + "Active: %d\n", listcount (area->oiflist), + area->act_ints); if (area->external_routing == OSPF_AREA_NSSA) { @@ -2759,29 +2744,24 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_ar } else { - vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTYNL, VTYNL); + vty_out (vty, " It is an NSSA configuration. \n Elected NSSA/ABR performs type-7/type-5 LSA translation. \n"); if (! IS_OSPF_ABR (area->ospf)) - vty_out (vty, " It is not ABR, therefore not Translator. %s", - VTYNL); + vty_out (vty, " It is not ABR, therefore not Translator. \n"); else if (area->NSSATranslatorState) { vty_out (vty, " We are an ABR and "); if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) - vty_out (vty, "the NSSA Elected Translator. %s", - VTYNL); + vty_out (vty, "the NSSA Elected Translator. \n"); else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) - vty_out (vty, "always an NSSA Translator. %s", - VTYNL); + vty_out (vty, "always an NSSA Translator. \n"); } else { vty_out (vty, " We are an ABR, but "); if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) - vty_out (vty, "not the NSSA Elected Translator. %s", - VTYNL); + vty_out (vty, "not the NSSA Elected Translator. \n"); else - vty_out (vty, "never an NSSA Translator. %s", - VTYNL); + vty_out (vty, "never an NSSA Translator. \n"); } } } @@ -2805,15 +2785,13 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_ar } else { - vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", - VTYNL); + vty_out (vty, " Originating stub / maximum-distance Router-LSA\n"); if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) - vty_out (vty, " Administratively activated (indefinitely)%s", - VTYNL); + vty_out (vty, " Administratively activated (indefinitely)\n"); if (area->t_stub_router) - vty_out (vty, " Active from startup, %s remaining%s", + vty_out (vty, " Active from startup, %s remaining\n", ospf_timer_dump (area->t_stub_router, timebuf, - sizeof(timebuf)), VTYNL); + sizeof(timebuf))); } } @@ -2851,42 +2829,42 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_ar { /* Show number of fully adjacent neighbors. */ vty_out (vty, " Number of fully adjacent neighbors in this area:" - " %d%s", area->full_nbrs, VTYNL); + " %d\n", area->full_nbrs); /* Show authentication type. */ vty_out (vty, " Area has "); if (area->auth_type == OSPF_AUTH_NULL) - vty_out (vty, "no authentication%s", VTYNL); + vty_out (vty, "no authentication\n"); else if (area->auth_type == OSPF_AUTH_SIMPLE) - vty_out (vty, "simple password authentication%s", VTYNL); + vty_out (vty, "simple password authentication\n"); else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) - vty_out (vty, "message digest authentication%s", VTYNL); + vty_out (vty, "message digest authentication\n"); if (!OSPF_IS_AREA_BACKBONE (area)) vty_out (vty, " Number of full virtual adjacencies going through" - " this area: %d%s", area->full_vls, VTYNL); + " this area: %d\n", area->full_vls); /* Show SPF calculation times. */ - vty_out (vty, " SPF algorithm executed %d times%s", - area->spf_calculation, VTYNL); + vty_out (vty, " SPF algorithm executed %d times\n", + area->spf_calculation); /* Show number of LSA. */ - vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTYNL); - vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", + vty_out (vty, " Number of LSA %ld\n", area->lsdb->total); + vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x\n", ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), - ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTYNL); - vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA)); + vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x\n", ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), - ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTYNL); - vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA)); + vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x\n", ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), - ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTYNL); - vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA)); + vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n", ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), - ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTYNL); - vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); + vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), - ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTYNL); + ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA)); } if (use_json) @@ -2898,18 +2876,18 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_ar } else { - vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", + vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), - ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTYNL); - vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", + ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA)); + vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), - ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTYNL); + ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA)); } if (use_json) json_object_object_add(json_areas, inet_ntoa (area->area_id), json_area); else - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } static int @@ -2936,8 +2914,7 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); } } @@ -2948,9 +2925,8 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, " OSPF Routing Process, Router ID: %s%s", - inet_ntoa (ospf->router_id), - VTYNL); + vty_out (vty, " OSPF Routing Process, Router ID: %s\n", + inet_ntoa (ospf->router_id)); } /* Graceful shutdown */ @@ -2964,9 +2940,9 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, " Deferred shutdown in progress, %s remaining%s", + vty_out (vty, " Deferred shutdown in progress, %s remaining\n", ospf_timer_dump (ospf->t_deferred_shutdown, - timebuf, sizeof (timebuf)), VTYNL); + timebuf, sizeof (timebuf))); } } @@ -2982,11 +2958,11 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTYNL); - vty_out (vty, " This implementation conforms to RFC2328%s", VTYNL); - vty_out (vty, " RFC1583Compatibility flag is %s%s", + vty_out (vty, " Supports only single TOS (TOS0) routes\n"); + vty_out (vty, " This implementation conforms to RFC2328\n"); + vty_out (vty, " RFC1583Compatibility flag is %s\n", CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? - "enabled" : "disabled", VTYNL); + "enabled" : "disabled"); } if (use_json) @@ -2998,9 +2974,8 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, " OpaqueCapability flag is %s%s", - CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled", - VTYNL); + vty_out (vty, " OpaqueCapability flag is %s\n", + CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled"); } /* Show stub-router configuration */ @@ -3017,14 +2992,13 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, " Stub router advertisement is configured%s", - VTYNL); + vty_out (vty, " Stub router advertisement is configured\n"); if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) - vty_out (vty, " Enabled for %us after start-up%s", - ospf->stub_router_startup_time, VTYNL); + vty_out (vty, " Enabled for %us after start-up\n", + ospf->stub_router_startup_time); if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) - vty_out (vty, " Enabled for %us prior to full shutdown%s", - ospf->stub_router_shutdown_time, VTYNL); + vty_out (vty, " Enabled for %us prior to full shutdown\n", + ospf->stub_router_shutdown_time); } } @@ -3038,14 +3012,14 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" - " Minimum hold time between consecutive SPFs %d millisec(s)%s" - " Maximum hold time between consecutive SPFs %d millisec(s)%s" - " Hold time multiplier is currently %d%s", - ospf->spf_delay, VTYNL, - ospf->spf_holdtime, VTYNL, - ospf->spf_max_holdtime, VTYNL, - ospf->spf_hold_multiplier, VTYNL); + vty_out (vty, " Initial SPF scheduling delay %d millisec(s)\n" + " Minimum hold time between consecutive SPFs %d millisec(s)\n" + " Maximum hold time between consecutive SPFs %d millisec(s)\n" + " Hold time multiplier is currently %d\n", + ospf->spf_delay, + ospf->spf_holdtime, + ospf->spf_max_holdtime, + ospf->spf_hold_multiplier); } if (use_json) @@ -3069,15 +3043,13 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) { monotime_since(&ospf->ts_spf, &result); - vty_out (vty, "last executed %s ago%s", - ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), - VTYNL); - vty_out (vty, " Last SPF duration %s%s", - ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), - VTYNL); + vty_out (vty, "last executed %s ago\n", + ospf_timeval_dump (&result, timebuf, sizeof (timebuf))); + vty_out (vty, " Last SPF duration %s\n", + ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf))); } else - vty_out (vty, "has not been run%s", VTYNL); + vty_out (vty, "has not been run\n"); } if (use_json) @@ -3098,23 +3070,22 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, " SPF timer %s%s%s", + vty_out (vty, " SPF timer %s%s\n", (ospf->t_spf_calc ? "due in " : "is "), - ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), - VTYNL); + ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf))); - vty_out (vty, " LSA minimum interval %d msecs%s", - ospf->min_ls_interval, VTYNL); - vty_out (vty, " LSA minimum arrival %d msecs%s", - ospf->min_ls_arrival, VTYNL); + vty_out (vty, " LSA minimum interval %d msecs\n", + ospf->min_ls_interval); + vty_out (vty, " LSA minimum arrival %d msecs\n", + ospf->min_ls_arrival); /* Show write multiplier values */ - vty_out (vty, " Write Multiplier set to %d %s", - ospf->write_oi_count, VTYNL); + vty_out (vty, " Write Multiplier set to %d \n", + ospf->write_oi_count); /* Show refresh parameters. */ - vty_out (vty, " Refresh timer %d secs%s", - ospf->lsa_refresh_interval, VTYNL); + vty_out (vty, " Refresh timer %d secs\n", + ospf->lsa_refresh_interval); } /* Show ABR/ASBR flags. */ @@ -3123,8 +3094,8 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) if (use_json) json_object_string_add(json, "abrType", ospf_abr_type_descr_str[ospf->abr_type]); else - vty_out (vty, " This router is an ABR, ABR type is: %s%s", - ospf_abr_type_descr_str[ospf->abr_type], VTYNL); + vty_out (vty, " This router is an ABR, ABR type is: %s\n", + ospf_abr_type_descr_str[ospf->abr_type]); } if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) { @@ -3132,7 +3103,7 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) json_object_string_add(json, "asbrRouter", "injectingExternalRoutingInformation"); else vty_out (vty, " This router is an ASBR " - "(injecting external routing information)%s", VTYNL); + "(injecting external routing information)\n"); } /* Show Number of AS-external-LSAs. */ @@ -3145,9 +3116,9 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", + vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x\n", ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), - ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTYNL); + ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); } if (use_json) @@ -3159,17 +3130,17 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) } else { - vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", + vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n", ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), - ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTYNL); + ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); } /* Show number of areas attached. */ if (use_json) json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas)); else - vty_out (vty, " Number of areas attached to this router: %d%s", - listcount (ospf->areas), VTYNL); + vty_out (vty, " Number of areas attached to this router: %d\n", + listcount (ospf->areas)); if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) { @@ -3178,14 +3149,14 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) if (use_json) json_object_boolean_true_add(json, "adjacencyChangesLoggedAll"); else - vty_out(vty, " All adjacency changes are logged%s",VTYNL); + vty_out(vty, " All adjacency changes are logged\n"); } else { if (use_json) json_object_boolean_true_add(json, "adjacencyChangesLogged"); else - vty_out(vty, " Adjacency changes are logged%s",VTYNL); + vty_out(vty, " Adjacency changes are logged\n"); } } /* Show each area status. */ @@ -3195,11 +3166,11 @@ show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) if (use_json) { json_object_object_add(json, "areas", json_areas); - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_out (vty, "%s",VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -3267,9 +3238,9 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface } else { - vty_outln (vty, "%s is %s", ifp->name, + vty_out (vty, "%s is %s\n", ifp->name, ((is_up = if_is_operative(ifp)) ? "up" : "down")); - vty_outln (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s", + vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n", ifp->ifindex, ifp->mtu, bandwidth, if_flag_dump(ifp->flags)); } @@ -3293,13 +3264,12 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface { if (ospf_oi_count(ifp) == 0) { - vty_out (vty, " OSPF not enabled on this interface%s", VTYNL); + vty_out (vty, " OSPF not enabled on this interface\n"); return; } else if (!is_up) { - vty_out (vty, " OSPF is enabled, but not running on this interface%s", - VTYNL); + vty_out (vty, " OSPF is enabled, but not running on this interface\n"); return; } } @@ -3375,16 +3345,16 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface } else { - vty_outln (vty, " Area %s", ospf_area_desc_string (oi->area)); + vty_out (vty, " Area %s\n", ospf_area_desc_string (oi->area)); - vty_outln (vty, " MTU mismatch detection: %s", + vty_out (vty, " MTU mismatch detection: %s\n", OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled"); - vty_outln (vty, " Router ID %s, Network Type %s, Cost: %d", + vty_out (vty, " Router ID %s, Network Type %s, Cost: %d\n", inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], oi->output_cost); - vty_outln (vty, " Transmit Delay is %d sec, State %s, Priority %d", + vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d\n", OSPF_IF_PARAM (oi,transmit_delay), lookup_msg(ospf_ism_state_msg, oi->state, NULL), PRIORITY (oi)); } @@ -3393,7 +3363,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface if (DR (oi).s_addr == 0) { if (!use_json) - vty_outln (vty, " No backup designated router on this network"); + vty_out (vty, " No backup designated router on this network\n"); } else { @@ -3401,7 +3371,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface if (nbr == NULL) { if (!use_json) - vty_outln (vty, " No backup designated router on this network"); + vty_out (vty, " No backup designated router on this network\n"); } else { @@ -3414,7 +3384,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface { vty_out (vty, " Backup Designated Router (ID) %s,", inet_ntoa (nbr->router_id)); - vty_outln (vty, " Interface Address %s", + vty_out (vty, " Interface Address %s\n", inet_ntoa (nbr->address.u.prefix4)); } } @@ -3426,8 +3396,8 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface if (use_json) json_object_int_add(json_interface_sub, "networkLsaSequence", ntohl (oi->params->network_lsa_seqnum)); else - vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", - ntohl (oi->params->network_lsa_seqnum), VTYNL); + vty_out (vty, " Saved Network-LSA sequence number 0x%x\n", + ntohl (oi->params->network_lsa_seqnum)); } if (use_json) @@ -3454,7 +3424,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface } else vty_out (vty, " <None>"); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } if (use_json) @@ -3475,11 +3445,10 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); else vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); - vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", + vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d\n", OSPF_IF_PARAM (oi, v_wait), OSPF_IF_PARAM (oi, v_wait), - OSPF_IF_PARAM (oi, retransmit_interval), - VTYNL); + OSPF_IF_PARAM (oi, retransmit_interval)); } if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) @@ -3493,16 +3462,15 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store); } else - vty_out (vty, " Hello due in %s%s", - ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), - VTYNL); + vty_out (vty, " Hello due in %s\n", + ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf))); } else /* passive-interface is set */ { if (use_json) json_object_boolean_true_add(json_interface_sub, "timerPassiveIface"); else - vty_out (vty, " No Hellos (Passive interface)%s", VTYNL); + vty_out (vty, " No Hellos (Passive interface)\n"); } if (use_json) @@ -3511,9 +3479,8 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface json_object_int_add(json_interface_sub, "nbrAdjacentCount", ospf_nbr_count (oi, NSM_Full)); } else - vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", - ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), - VTYNL); + vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d\n", + ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full)); ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); } } @@ -3537,8 +3504,7 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, if (use_json) json_object_int_add(json, "ospfInstance", ospf->instance); else - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); } if (argc == iface_argv) @@ -3566,7 +3532,7 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, if (use_json) json_object_boolean_true_add(json, "noSuchIface"); else - vty_out (vty, "No such interface name%s", VTYNL); + vty_out (vty, "No such interface name\n"); } else { @@ -3582,11 +3548,11 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -3642,11 +3608,9 @@ DEFUN (show_ip_ospf_instance_interface, static void show_ip_ospf_neighbour_header (struct vty *vty) { - vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", - VTYNL, + vty_out (vty, "\n%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s\n", "Neighbor ID", "Pri", "State", "Dead Time", - "Address", "Interface", "RXmtL", "RqstL", "DBsmL", - VTYNL); + "Address", "Interface", "RXmtL", "RqstL", "DBsmL"); } static void @@ -3707,10 +3671,9 @@ show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_obje ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof(timebuf))); vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); - vty_out (vty, "%-20s %5ld %5ld %5d%s", + vty_out (vty, "%-20s %5ld %5ld %5d\n", IF_NAME (oi), ospf_ls_retransmit_count (nbr), - ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), - VTYNL); + ospf_ls_request_count (nbr), ospf_db_summary_count (nbr)); } } } @@ -3735,8 +3698,7 @@ show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_jso if (use_json) json_object_int_add(json, "ospfInstance", ospf->instance); else - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); } for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) @@ -3744,11 +3706,11 @@ show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_jso if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -3815,8 +3777,7 @@ show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use if (use_json) json_object_int_add(json, "ospfInstance", ospf->instance); else - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); } for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) @@ -3846,9 +3807,9 @@ show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use { vty_out (vty, "%-15s %3d %-15s %9s ", "-", nbr_nbma->priority, "Down", "-"); - vty_out (vty, "%-15s %-20s %5d %5d %5d%s", + vty_out (vty, "%-15s %-20s %5d %5d %5d\n", inet_ntoa (nbr_nbma->addr), IF_NAME (oi), - 0, 0, 0, VTYNL); + 0, 0, 0); } } } @@ -3856,11 +3817,11 @@ show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -3925,8 +3886,7 @@ show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_ba if (use_json) json_object_int_add(json, "ospfInstance", ospf->instance); else - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); } ifp = if_lookup_by_name (argv[arg_base]->arg, VRF_DEFAULT); @@ -3935,7 +3895,7 @@ show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_ba if (use_json) json_object_boolean_true_add(json, "noSuchIface"); else - vty_out (vty, "No such interface.%s", VTYNL); + vty_out (vty, "No such interface.\n"); return CMD_WARNING; } @@ -3951,11 +3911,11 @@ show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_ba if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -4018,8 +3978,8 @@ show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, st if (use_json) json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr_nbma->addr)); else - vty_out (vty, " interface address %s%s", - inet_ntoa (nbr_nbma->addr), VTYNL); + vty_out (vty, " interface address %s\n", + inet_ntoa (nbr_nbma->addr)); /* Show Area ID. */ if (use_json) @@ -4028,8 +3988,8 @@ show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, st json_object_string_add(json_sub, "iface", IF_NAME (oi)); } else - vty_out (vty, " In the area %s via interface %s%s", - ospf_area_desc_string (oi->area), IF_NAME (oi), VTYNL); + vty_out (vty, " In the area %s via interface %s\n", + ospf_area_desc_string (oi->area), IF_NAME (oi)); /* Show neighbor priority and state. */ if (use_json) @@ -4045,13 +4005,13 @@ show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, st if (use_json) json_object_int_add(json_sub, "stateChangeCounter", nbr_nbma->state_change); else - vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTYNL); + vty_out (vty, " %d state changes\n", nbr_nbma->state_change); /* Show PollInterval */ if (use_json) json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll); else - vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTYNL); + vty_out (vty, " Poll interval %d\n", nbr_nbma->v_poll); /* Show poll-interval timer. */ if (use_json) @@ -4061,9 +4021,8 @@ show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, st json_object_int_add(json_sub, "pollIntervalTimerDueMsec", time_store); } else - vty_out (vty, " Poll timer due in %s%s", - ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), - VTYNL); + vty_out (vty, " Poll timer due in %s\n", + ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf))); /* Show poll-interval timer thread. */ if (use_json) @@ -4072,8 +4031,8 @@ show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, st json_object_string_add(json_sub, "pollIntervalTimerThread", "on"); } else - vty_out (vty, " Thread Poll Timer %s%s", - nbr_nbma->t_poll != NULL ? "on" : "off", VTYNL); + vty_out (vty, " Thread Poll Timer %s\n", + nbr_nbma->t_poll != NULL ? "on" : "off"); if (use_json) json_object_object_add(json, "noNbrId", json_sub); @@ -4101,8 +4060,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, if (use_json) json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr->address.u.prefix4)); else - vty_out (vty, " interface address %s%s", - inet_ntoa (nbr->address.u.prefix4), VTYNL); + vty_out (vty, " interface address %s\n", + inet_ntoa (nbr->address.u.prefix4)); /* Show Area ID. */ if (use_json) @@ -4111,8 +4070,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, json_object_string_add(json_sub, "ifaceName", oi->ifp->name); } else - vty_out (vty, " In the area %s via interface %s%s", - ospf_area_desc_string (oi->area), oi->ifp->name, VTYNL); + vty_out (vty, " In the area %s via interface %s\n", + ospf_area_desc_string (oi->area), oi->ifp->name); /* Show neighbor priority and state. */ if (use_json) @@ -4128,7 +4087,7 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, if (use_json) json_object_int_add(json_sub, "stateChangeCounter", nbr->state_change); else - vty_out (vty, " %d state changes%s", nbr->state_change, VTYNL); + vty_out (vty, " %d state changes\n", nbr->state_change); if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) { @@ -4142,11 +4101,9 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, } else { - vty_out (vty, " Most recent state change statistics:%s", - VTYNL); - vty_out (vty, " Progressive change %s ago%s", - ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), - VTYNL); + vty_out (vty, " Most recent state change statistics:\n"); + vty_out (vty, " Progressive change %s ago\n", + ospf_timeval_dump (&res, timebuf, sizeof(timebuf))); } } @@ -4164,10 +4121,9 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, } else { - vty_out (vty, " Regressive change %s ago, due to %s%s", + vty_out (vty, " Regressive change %s ago, due to %s\n", ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), - (nbr->last_regress_str ? nbr->last_regress_str : "??"), - VTYNL); + (nbr->last_regress_str ? nbr->last_regress_str : "??")); } } @@ -4181,7 +4137,7 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, if (use_json) json_object_string_add(json_sub, "routerDesignatedBackupId", inet_ntoa (nbr->bd_router)); else - vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTYNL); + vty_out (vty, " BDR is %s\n", inet_ntoa (nbr->bd_router)); /* Show options. */ if (use_json) @@ -4190,8 +4146,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, json_object_string_add(json_sub, "optionsList", ospf_options_dump (nbr->options)); } else - vty_out (vty, " Options %d %s%s", nbr->options, - ospf_options_dump (nbr->options), VTYNL); + vty_out (vty, " Options %d %s\n", nbr->options, + ospf_options_dump (nbr->options)); /* Show Router Dead interval timer. */ if (use_json) @@ -4206,30 +4162,29 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", -1); } else - vty_out (vty, " Dead timer due in %s%s", - ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), - VTYNL); + vty_out (vty, " Dead timer due in %s\n", + ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf))); /* Show Database Summary list. */ if (use_json) json_object_int_add(json_sub, "databaseSummaryListCounter", ospf_db_summary_count (nbr)); else - vty_out (vty, " Database Summary List %d%s", - ospf_db_summary_count (nbr), VTYNL); + vty_out (vty, " Database Summary List %d\n", + ospf_db_summary_count (nbr)); /* Show Link State Request list. */ if (use_json) json_object_int_add(json_sub, "linkStateRequestListCounter", ospf_ls_request_count (nbr)); else - vty_out (vty, " Link State Request List %ld%s", - ospf_ls_request_count (nbr), VTYNL); + vty_out (vty, " Link State Request List %ld\n", + ospf_ls_request_count (nbr)); /* Show Link State Retransmission list. */ if (use_json) json_object_int_add(json_sub, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr)); else - vty_out (vty, " Link State Retransmission List %ld%s", - ospf_ls_retransmit_count (nbr), VTYNL); + vty_out (vty, " Link State Retransmission List %ld\n", + ospf_ls_retransmit_count (nbr)); /* Show inactivity timer thread. */ if (use_json) @@ -4238,8 +4193,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, json_object_string_add(json_sub, "threadInactivityTimer", "on"); } else - vty_out (vty, " Thread Inactivity Timer %s%s", - nbr->t_inactivity != NULL ? "on" : "off", VTYNL); + vty_out (vty, " Thread Inactivity Timer %s\n", + nbr->t_inactivity != NULL ? "on" : "off"); /* Show Database Description retransmission thread. */ if (use_json) @@ -4248,8 +4203,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, json_object_string_add(json_sub, "threadDatabaseDescriptionRetransmission", "on"); } else - vty_out (vty, " Thread Database Description Retransmision %s%s", - nbr->t_db_desc != NULL ? "on" : "off", VTYNL); + vty_out (vty, " Thread Database Description Retransmision %s\n", + nbr->t_db_desc != NULL ? "on" : "off"); /* Show Link State Request Retransmission thread. */ if (use_json) @@ -4258,8 +4213,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, json_object_string_add(json_sub, "threadLinkStateRequestRetransmission", "on"); } else - vty_out (vty, " Thread Link State Request Retransmission %s%s", - nbr->t_ls_req != NULL ? "on" : "off", VTYNL); + vty_out (vty, " Thread Link State Request Retransmission %s\n", + nbr->t_ls_req != NULL ? "on" : "off"); /* Show Link State Update Retransmission thread. */ if (use_json) @@ -4268,8 +4223,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, json_object_string_add(json_sub, "threadLinkStateUpdateRetransmission", "on"); } else - vty_out (vty, " Thread Link State Update Retransmission %s%s%s", - nbr->t_ls_upd != NULL ? "on" : "off", VTYNL, VTYNL); + vty_out (vty, " Thread Link State Update Retransmission %s\n\n", + nbr->t_ls_upd != NULL ? "on" : "off"); if (use_json) { @@ -4301,15 +4256,14 @@ show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, if (use_json) json_object_int_add(json, "ospfInstance", ospf->instance); else - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); } ret = inet_aton (argv[arg_base]->arg, &router_id); if (!ret) { if (!use_json) - vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTYNL); + vty_out (vty, "Please specify Neighbor ID by A.B.C.D\n"); return CMD_WARNING; } @@ -4323,11 +4277,11 @@ show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -4389,8 +4343,7 @@ show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char if (use_json) json_object_int_add(json, "ospfInstance", ospf->instance); else - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); } for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) @@ -4415,11 +4368,11 @@ show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -4481,8 +4434,7 @@ show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_c if (use_json) json_object_int_add(json, "ospfInstance", ospf->instance); else - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); } for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) @@ -4511,12 +4463,12 @@ show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_c if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } return CMD_SUCCESS; @@ -4584,15 +4536,14 @@ show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, if (use_json) json_object_int_add(json, "ospfInstance", ospf->instance); else - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); } ifp = if_lookup_by_name (argv[arg_base]->arg, VRF_DEFAULT); if (!ifp) { if (!use_json) - vty_out (vty, "No such interface.%s", VTYNL); + vty_out (vty, "No such interface.\n"); return CMD_WARNING; } @@ -4616,11 +4567,11 @@ show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, if (use_json) { - vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -4726,7 +4677,7 @@ show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) default: break; } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return 0; @@ -4769,10 +4720,10 @@ show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) { struct router_lsa *rlsa = (struct router_lsa*) lsa->data; - vty_outln (vty, " LS age: %d", LS_AGE (lsa)); - vty_outln (vty, " Options: 0x%-2x : %s", lsa->data->options, + vty_out (vty, " LS age: %d\n", LS_AGE (lsa)); + vty_out (vty, " Options: 0x%-2x : %s\n", lsa->data->options, ospf_options_dump(lsa->data->options)); - vty_outln (vty, " LS Flags: 0x%-2x %s", + vty_out (vty, " LS Flags: 0x%-2x %s\n", lsa->flags, ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : "")); @@ -4788,16 +4739,16 @@ show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } - vty_outln (vty, " LS Type: %s", + vty_out (vty, " LS Type: %s\n", lookup_msg(ospf_lsa_type_msg, lsa->data->type, NULL)); - vty_outln (vty, " Link State ID: %s %s", inet_ntoa (lsa->data->id), + vty_out (vty, " Link State ID: %s %s\n", inet_ntoa (lsa->data->id), lookup_msg(ospf_link_state_id_type_msg, lsa->data->type, NULL)); - vty_outln (vty, " Advertising Router: %s", inet_ntoa (lsa->data->adv_router)); - vty_outln (vty, " LS Seq Number: %08lx", (u_long)ntohl (lsa->data->ls_seqnum)); - vty_outln (vty, " Checksum: 0x%04x", ntohs (lsa->data->checksum)); - vty_outln (vty, " Length: %d%s", ntohs (lsa->data->length), VTYNL); + vty_out (vty, " Advertising Router: %s\n", inet_ntoa (lsa->data->adv_router)); + vty_out (vty, " LS Seq Number: %08lx\n", (u_long)ntohl (lsa->data->ls_seqnum)); + vty_out (vty, " Checksum: 0x%04x\n", ntohs (lsa->data->checksum)); + vty_out (vty, " Length: %d\n\n", ntohs (lsa->data->length)); } const char *link_type_desc[] = @@ -4840,16 +4791,16 @@ show_ip_ospf_database_router_links (struct vty *vty, { type = rl->link[i].type; - vty_out (vty, " Link connected to: %s%s", - link_type_desc[type], VTYNL); - vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], - inet_ntoa (rl->link[i].link_id), VTYNL); - vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], - inet_ntoa (rl->link[i].link_data), VTYNL); - vty_out (vty, " Number of TOS metrics: 0%s", VTYNL); - vty_out (vty, " TOS 0 Metric: %d%s", - ntohs (rl->link[i].metric), VTYNL); - vty_out (vty, "%s", VTYNL); + vty_out (vty, " Link connected to: %s\n", + link_type_desc[type]); + vty_out (vty, " (Link ID) %s: %s\n", link_id_desc[type], + inet_ntoa (rl->link[i].link_id)); + vty_out (vty, " (Link Data) %s: %s\n", link_data_desc[type], + inet_ntoa (rl->link[i].link_data)); + vty_out (vty, " Number of TOS metrics: 0\n"); + vty_out (vty, " TOS 0 Metric: %d\n", + ntohs (rl->link[i].metric)); + vty_out (vty, "\n"); } } @@ -4863,11 +4814,10 @@ show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) show_ip_ospf_database_header (vty, lsa); - vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), - VTYNL, VTYNL); + vty_out (vty, " Number of Links: %d\n\n", ntohs (rl->links)); show_ip_ospf_database_router_links (vty, rl); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } return 0; @@ -4885,16 +4835,16 @@ show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) show_ip_ospf_database_header (vty, lsa); - vty_out (vty, " Network Mask: /%d%s", - ip_masklen (nl->mask), VTYNL); + vty_out (vty, " Network Mask: /%d\n", + ip_masklen (nl->mask)); length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; for (i = 0; length > 0; i++, length -= 4) - vty_out (vty, " Attached Router: %s%s", - inet_ntoa (nl->routers[i]), VTYNL); + vty_out (vty, " Attached Router: %s\n", + inet_ntoa (nl->routers[i])); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } return 0; @@ -4910,11 +4860,9 @@ show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) show_ip_ospf_database_header (vty, lsa); - vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), - VTYNL); - vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), - VTYNL); - vty_out (vty, "%s", VTYNL); + vty_out (vty, " Network Mask: /%d\n", ip_masklen (sl->mask)); + vty_out (vty, " TOS: 0 Metric: %d\n", GET_METRIC (sl->metric)); + vty_out (vty, "\n"); } return 0; @@ -4930,11 +4878,10 @@ show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) show_ip_ospf_database_header (vty, lsa); - vty_out (vty, " Network Mask: /%d%s", - ip_masklen (sl->mask), VTYNL); - vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), - VTYNL); - vty_out (vty, "%s", VTYNL); + vty_out (vty, " Network Mask: /%d\n", + ip_masklen (sl->mask)); + vty_out (vty, " TOS: 0 Metric: %d\n", GET_METRIC (sl->metric)); + vty_out (vty, "\n"); } return 0; @@ -4950,19 +4897,19 @@ show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) show_ip_ospf_database_header (vty, lsa); - vty_out (vty, " Network Mask: /%d%s", - ip_masklen (al->mask), VTYNL); - vty_out (vty, " Metric Type: %s%s", + vty_out (vty, " Network Mask: /%d\n", + ip_masklen (al->mask)); + vty_out (vty, " Metric Type: %s\n", IS_EXTERNAL_METRIC (al->e[0].tos) ? - "2 (Larger than any link state path)" : "1", VTYNL); - vty_out (vty, " TOS: 0%s", VTYNL); - vty_out (vty, " Metric: %d%s", - GET_METRIC (al->e[0].metric), VTYNL); - vty_out (vty, " Forward Address: %s%s", - inet_ntoa (al->e[0].fwd_addr), VTYNL); + "2 (Larger than any link state path)" : "1"); + vty_out (vty, " TOS: 0\n"); + vty_out (vty, " Metric: %d\n", + GET_METRIC (al->e[0].metric)); + vty_out (vty, " Forward Address: %s\n", + inet_ntoa (al->e[0].fwd_addr)); - vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", - (route_tag_t)ntohl (al->e[0].route_tag), VTYNL, VTYNL); + vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"\n\n", + (route_tag_t)ntohl (al->e[0].route_tag)); } return 0; @@ -5002,19 +4949,19 @@ show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) show_ip_ospf_database_header (vty, lsa); - vty_out (vty, " Network Mask: /%d%s", - ip_masklen (al->mask), VTYNL); - vty_out (vty, " Metric Type: %s%s", + vty_out (vty, " Network Mask: /%d\n", + ip_masklen (al->mask)); + vty_out (vty, " Metric Type: %s\n", IS_EXTERNAL_METRIC (al->e[0].tos) ? - "2 (Larger than any link state path)" : "1", VTYNL); - vty_out (vty, " TOS: 0%s", VTYNL); - vty_out (vty, " Metric: %d%s", - GET_METRIC (al->e[0].metric), VTYNL); - vty_out (vty, " NSSA: Forward Address: %s%s", - inet_ntoa (al->e[0].fwd_addr), VTYNL); + "2 (Larger than any link state path)" : "1"); + vty_out (vty, " TOS: 0\n"); + vty_out (vty, " Metric: %d\n", + GET_METRIC (al->e[0].metric)); + vty_out (vty, " NSSA: Forward Address: %s\n", + inet_ntoa (al->e[0].fwd_addr)); - vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", - (route_tag_t)ntohl (al->e[0].route_tag), VTYNL, VTYNL); + vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"\n\n", + (route_tag_t)ntohl (al->e[0].route_tag)); } return 0; @@ -5034,7 +4981,7 @@ show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) show_ip_ospf_database_header (vty, lsa); show_opaque_info_detail (vty, lsa); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } return 0; } @@ -5112,17 +5059,15 @@ show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, { case OSPF_AS_EXTERNAL_LSA: case OSPF_OPAQUE_AS_LSA: - vty_out (vty, " %s %s%s", - show_database_desc[type], - VTYNL, VTYNL); + vty_out (vty, " %s \n\n", + show_database_desc[type]); show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); break; default: for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) { - vty_out (vty, "%s %s (Area %s)%s%s", - VTYNL, show_database_desc[type], - ospf_area_desc_string (area), VTYNL, VTYNL); + vty_out (vty, "\n %s (Area %s)\n\n", show_database_desc[type], + ospf_area_desc_string (area)); show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); } break; @@ -5159,18 +5104,16 @@ show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, { case OSPF_AS_EXTERNAL_LSA: case OSPF_OPAQUE_AS_LSA: - vty_out (vty, " %s %s%s", - show_database_desc[type], - VTYNL, VTYNL); + vty_out (vty, " %s \n\n", + show_database_desc[type]); show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), adv_router); break; default: for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) { - vty_out (vty, "%s %s (Area %s)%s%s", - VTYNL, show_database_desc[type], - ospf_area_desc_string (area), VTYNL, VTYNL); + vty_out (vty, "\n %s (Area %s)\n\n", show_database_desc[type], + ospf_area_desc_string (area)); show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), adv_router); } @@ -5202,16 +5145,15 @@ show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) if (ospf_lsdb_count_self (area->lsdb, type) > 0 || (!self && ospf_lsdb_count (area->lsdb, type) > 0)) { - vty_out (vty, " %s (Area %s)%s%s", + vty_out (vty, " %s (Area %s)\n\n", show_database_desc[type], - ospf_area_desc_string (area), - VTYNL, VTYNL); - vty_out (vty, "%s%s", show_database_header[type], VTYNL); + ospf_area_desc_string (area)); + vty_out (vty, "%s\n", show_database_header[type]); LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) show_lsa_summary (vty, lsa, self); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } } @@ -5229,20 +5171,18 @@ show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) if (ospf_lsdb_count_self (ospf->lsdb, type) || (!self && ospf_lsdb_count (ospf->lsdb, type))) { - vty_out (vty, " %s%s%s", - show_database_desc[type], - VTYNL, VTYNL); - vty_out (vty, "%s%s", show_database_header[type], - VTYNL); + vty_out (vty, " %s\n\n", + show_database_desc[type]); + vty_out (vty, "%s\n", show_database_header[type]); LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) show_lsa_summary (vty, lsa, self); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } static void @@ -5250,8 +5190,7 @@ show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) { struct route_node *rn; - vty_out (vty, "%s MaxAge Link States:%s%s", - VTYNL, VTYNL, VTYNL); + vty_out (vty, "\n MaxAge Link States:\n\n"); for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) { @@ -5259,13 +5198,13 @@ show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) if ((lsa = rn->info) != NULL) { - vty_out (vty, "Link type: %d%s", lsa->data->type, VTYNL); - vty_out (vty, "Link State ID: %s%s", - inet_ntoa (lsa->data->id), VTYNL); - vty_out (vty, "Advertising Router: %s%s", - inet_ntoa (lsa->data->adv_router), VTYNL); - vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTYNL); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "Link type: %d\n", lsa->data->type); + vty_out (vty, "Link State ID: %s\n", + inet_ntoa (lsa->data->id)); + vty_out (vty, "Advertising Router: %s\n", + inet_ntoa (lsa->data->adv_router)); + vty_out (vty, "LSA lock count: %d\n", lsa->lock); + vty_out (vty, "\n"); } } } @@ -5298,11 +5237,10 @@ show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, struct in_addr id, adv_router; if (ospf->instance) - vty_out (vty, "%sOSPF Instance: %d%s", VTYNL, ospf->instance, - VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n", ospf->instance); - vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTYNL, - inet_ntoa (ospf->router_id), VTYNL, VTYNL); + vty_out (vty, "\n OSPF Router with ID (%s)\n\n", + inet_ntoa (ospf->router_id)); /* Show all LSA. */ if (argc == arg_base + 4) @@ -5457,11 +5395,10 @@ show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf struct in_addr adv_router; if (ospf->instance) - vty_out (vty, "%sOSPF Instance: %d%s", VTYNL, ospf->instance, - VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n", ospf->instance); - vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTYNL, - inet_ntoa (ospf->router_id), VTYNL, VTYNL); + vty_out (vty, "\n OSPF Router with ID (%s)\n\n", + inet_ntoa (ospf->router_id)); /* Set database type to show. */ if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) @@ -5555,9 +5492,8 @@ DEFUN (ip_ospf_authentication_args, ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -5580,8 +5516,8 @@ DEFUN (ip_ospf_authentication_args, return CMD_SUCCESS; } - vty_out (vty, "You shouldn't get here!%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "You shouldn't get here!\n"); + return CMD_WARNING_CONFIG_FAILED; } DEFUN (ip_ospf_authentication, @@ -5605,9 +5541,8 @@ DEFUN (ip_ospf_authentication, ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -5647,16 +5582,15 @@ DEFUN (no_ip_ospf_authentication_args, ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); if (params == NULL) { - vty_out (vty, "Ip Address specified is unknown%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Ip Address specified is unknown\n"); + return CMD_WARNING_CONFIG_FAILED; } params->auth_type = OSPF_AUTH_NOTSET; UNSET_IF_PARAM (params, auth_type); @@ -5678,8 +5612,8 @@ DEFUN (no_ip_ospf_authentication_args, } else { - vty_out (vty, "Unexpected input encountered%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Unexpected input encountered\n"); + return CMD_WARNING_CONFIG_FAILED; } /* * Here we have a case where the user has entered @@ -5737,16 +5671,15 @@ DEFUN (no_ip_ospf_authentication, ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); if (params == NULL) { - vty_out (vty, "Ip Address specified is unknown%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Ip Address specified is unknown\n"); + return CMD_WARNING_CONFIG_FAILED; } params->auth_type = OSPF_AUTH_NOTSET; @@ -5817,9 +5750,8 @@ DEFUN (ip_ospf_authentication_key, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -5863,9 +5795,8 @@ DEFUN (no_ip_ospf_authentication_key, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); @@ -5925,9 +5856,8 @@ DEFUN (ip_ospf_message_digest_key, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -5937,8 +5867,8 @@ DEFUN (ip_ospf_message_digest_key, key_id = strtol (keyid, NULL, 10); if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) { - vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTYNL); - return CMD_WARNING; + vty_out (vty, "OSPF: Key %d already exists\n", key_id); + return CMD_WARNING_CONFIG_FAILED; } ck = ospf_crypt_key_new (); @@ -5992,9 +5922,8 @@ DEFUN (no_ip_ospf_message_digest_key, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); @@ -6006,8 +5935,8 @@ DEFUN (no_ip_ospf_message_digest_key, ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); if (ck == NULL) { - vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTYNL); - return CMD_WARNING; + vty_out (vty, "OSPF: Key %d does not exist\n", key_id); + return CMD_WARNING_CONFIG_FAILED; } ospf_crypt_key_delete (params->auth_crypt, key_id); @@ -6060,9 +5989,8 @@ DEFUN (ip_ospf_cost, { if(!inet_aton(ifaddr, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -6115,9 +6043,8 @@ DEFUN (no_ip_ospf_cost, { if (!inet_aton(ifaddr, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); @@ -6187,9 +6114,8 @@ ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, ret = inet_aton(nbr_str, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -6214,9 +6140,8 @@ ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, } else { - vty_out (vty, "Please specify dead-interval or hello-multiplier%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify dead-interval or hello-multiplier\n"); + return CMD_WARNING_CONFIG_FAILED; } SET_IF_PARAM (params, v_wait); @@ -6314,9 +6239,8 @@ DEFUN (no_ip_ospf_dead_interval, ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); @@ -6393,9 +6317,8 @@ DEFUN (ip_ospf_hello_interval, { if(!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -6440,9 +6363,8 @@ DEFUN (no_ip_ospf_hello_interval, { if(!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); @@ -6492,8 +6414,8 @@ DEFUN (ip_ospf_network, if (old_type == OSPF_IFTYPE_LOOPBACK) { - vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "This is a loopback interface. Can't set network type.\n"); + return CMD_WARNING_CONFIG_FAILED; } if (argv_find (argv, argc, "broadcast", &idx)) @@ -6620,9 +6542,8 @@ DEFUN (ip_ospf_priority, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -6682,9 +6603,8 @@ DEFUN (no_ip_ospf_priority, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); @@ -6753,9 +6673,8 @@ DEFUN (ip_ospf_retransmit_interval, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -6800,9 +6719,8 @@ DEFUN (no_ip_ospf_retransmit_interval, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); @@ -6857,9 +6775,8 @@ DEFUN (ip_ospf_transmit_delay, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); @@ -6903,9 +6820,8 @@ DEFUN (no_ip_ospf_transmit_delay, { if (!inet_aton(argv[idx]->arg, &addr)) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_lookup_if_params (ifp, addr); @@ -6981,23 +6897,21 @@ DEFUN (ip_ospf_area, ret = str2area_id (areaid, &area_id, &format); if (ret < 0) { - vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>\n"); + return CMD_WARNING_CONFIG_FAILED; } if (memcmp (ifp->name, "VLINK", 5) == 0) { - vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Cannot enable OSPF on a virtual link.\n"); + return CMD_WARNING_CONFIG_FAILED; } params = IF_DEF_PARAMS (ifp); - if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) + if (OSPF_IF_PARAM_CONFIGURED(params, if_area) && !IPV4_ADDR_SAME(¶ms->if_area, &area_id)) { vty_out (vty, - "Must remove previous area config before changing ospf area %s", - VTYNL); - return CMD_WARNING; + "Must remove previous area config before changing ospf area \n"); + return CMD_WARNING_CONFIG_FAILED; } // Check if we have an address arg and proccess it @@ -7009,7 +6923,7 @@ DEFUN (ip_ospf_area, { vty_out (vty, "Must remove previous area/address config before changing ospf area"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } ospf_if_update_params ((ifp), (addr)); } @@ -7018,8 +6932,8 @@ DEFUN (ip_ospf_area, { if (rn->info != NULL) { - vty_out (vty, "Please remove all network commands first.%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "Please remove all network commands first.\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -7071,8 +6985,8 @@ DEFUN (no_ip_ospf_area, if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) { - vty_outln (vty, "Can't find specified interface area configuration."); - return CMD_WARNING; + vty_out (vty, "Can't find specified interface area configuration.\n"); + return CMD_WARNING_CONFIG_FAILED; } UNSET_IF_PARAM (params, if_area); @@ -7113,19 +7027,19 @@ DEFUN (ospf_redistribute_source, /* Get distribute source. */ source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); if (source < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; red = ospf_redist_add(ospf, source, 0); /* Get metric value. */ if (argv_find (argv, argc, "(0-16777214)", &idx)) { if (!str2metric (argv[idx]->arg, &metric)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Get metric type. */ else if (argv_find (argv, argc, "(1-2)", &idx)) { if (!str2metric_type (argv[idx]->arg, &type)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Get route-map */ else if (argv_find (argv, argc, "WORD", &idx)) { @@ -7157,7 +7071,7 @@ DEFUN (no_ospf_redistribute_source, source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); if (source < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; red = ospf_redist_lookup(ospf, source, 0); if (!red) @@ -7203,28 +7117,26 @@ DEFUN (ospf_redistribute_instance_source, if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) { - vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed\n"); + return CMD_WARNING_CONFIG_FAILED; } if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) { - vty_out (vty, "Same instance OSPF redistribution not allowed%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Same instance OSPF redistribution not allowed\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Get metric value. */ if (argv_find (argv, argc, "metric", &idx)) if (!str2metric (argv[idx+1]->arg, &metric)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; idx = 3; /* Get metric type. */ if (argv_find (argv, argc, "metric-type", &idx)) if (!str2metric_type (argv[idx+1]->arg, &type)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; red = ospf_redist_add(ospf, source, instance); @@ -7268,16 +7180,14 @@ DEFUN (no_ospf_redistribute_instance_source, if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) { - vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed\n"); + return CMD_WARNING_CONFIG_FAILED; } if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) { - vty_out (vty, "Same instance OSPF redistribution not allowed%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Same instance OSPF redistribution not allowed\n"); + return CMD_WARNING_CONFIG_FAILED; } red = ospf_redist_lookup(ospf, source, instance); @@ -7305,7 +7215,7 @@ DEFUN (ospf_distribute_list_out, /* Get distribute source. */ source = proto_redistnum(AFI_IP, proto); if (source < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; return ospf_distribute_list_out_set (ospf, source, argv[idx_word]->arg); } @@ -7326,7 +7236,7 @@ DEFUN (no_ospf_distribute_list_out, char *proto = argv[argc - 1]->text; source = proto_redistnum(AFI_IP, proto); if (source < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; return ospf_distribute_list_out_unset (ospf, source, argv[idx_word]->arg); } @@ -7360,12 +7270,12 @@ DEFUN (ospf_default_information_originate, /* Get metric value */ else if (argv_find (argv, argc, "(0-16777214)", &idx)) { if (!str2metric (argv[idx]->arg, &metric)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Get metric type. */ else if (argv_find (argv, argc, "(1-2)", &idx)) { if (!str2metric_type (argv[idx]->arg, &type)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Get route-map */ else if (argv_find (argv, argc, "WORD", &idx)) @@ -7427,7 +7337,7 @@ DEFUN (ospf_default_metric, int metric = -1; if (!str2metric (argv[idx_number]->arg, &metric)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; ospf->default_metric = metric; @@ -7638,9 +7548,8 @@ DEFUN (ip_ospf_mtu_ignore, ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); ospf_if_update_params (ifp, addr); @@ -7681,9 +7590,8 @@ DEFUN (no_ip_ospf_mtu_ignore, ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTYNL); - return CMD_WARNING; + vty_out (vty, "Please specify interface address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } params = ospf_get_if_params (ifp, addr); ospf_if_update_params (ifp, addr); @@ -7772,7 +7680,7 @@ DEFUN (ospf_max_metric_router_lsa_startup, if (argc != 1) { vty_out (vty, "%% Must supply stub-router period"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } seconds = strtoul(argv[idx_number]->arg, NULL, 10); @@ -7828,7 +7736,7 @@ DEFUN (ospf_max_metric_router_lsa_shutdown, if (argc != 1) { vty_out (vty, "%% Must supply stub-router shutdown period"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } seconds = strtoul(argv[idx_number]->arg, NULL, 10); @@ -7861,17 +7769,16 @@ config_write_stub_router (struct vty *vty, struct ospf *ospf) struct ospf_area *area; if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) - vty_out (vty, " max-metric router-lsa on-startup %u%s", - ospf->stub_router_startup_time, VTYNL); + vty_out (vty, " max-metric router-lsa on-startup %u\n", + ospf->stub_router_startup_time); if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) - vty_out (vty, " max-metric router-lsa on-shutdown %u%s", - ospf->stub_router_shutdown_time, VTYNL); + vty_out (vty, " max-metric router-lsa on-shutdown %u\n", + ospf->stub_router_shutdown_time); for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) { if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) { - vty_out (vty, " max-metric router-lsa administrative%s", - VTYNL); + vty_out (vty, " max-metric router-lsa administrative\n"); break; } } @@ -7886,8 +7793,7 @@ show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) struct listnode *pnode, *pnnode; struct ospf_path *path; - vty_out (vty, "============ OSPF network routing table ============%s", - VTYNL); + vty_out (vty, "============ OSPF network routing table ============\n"); for (rn = route_top (rt); rn; rn = route_next (rn)) if ((or = rn->info) != NULL) @@ -7900,14 +7806,14 @@ show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) { case OSPF_PATH_INTER_AREA: if (or->type == OSPF_DESTINATION_NETWORK) - vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, - inet_ntoa (or->u.std.area_id), VTYNL); + vty_out (vty, "N IA %-18s [%d] area: %s\n", buf1, or->cost, + inet_ntoa (or->u.std.area_id)); else if (or->type == OSPF_DESTINATION_DISCARD) - vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTYNL); + vty_out (vty, "D IA %-18s Discard entry\n", buf1); break; case OSPF_PATH_INTRA_AREA: - vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, - inet_ntoa (or->u.std.area_id), VTYNL); + vty_out (vty, "N %-18s [%d] area: %s\n", buf1, or->cost, + inet_ntoa (or->u.std.area_id)); break; default: break; @@ -7919,16 +7825,16 @@ show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) if (if_lookup_by_index(path->ifindex, VRF_DEFAULT)) { if (path->nexthop.s_addr == 0) - vty_out (vty, "%24s directly attached to %s%s", - "", ifindex2ifname (path->ifindex, VRF_DEFAULT), VTYNL); + vty_out (vty, "%24s directly attached to %s\n", + "", ifindex2ifname (path->ifindex, VRF_DEFAULT)); else - vty_out (vty, "%24s via %s, %s%s", "", + vty_out (vty, "%24s via %s, %s\n", "", inet_ntoa (path->nexthop), - ifindex2ifname (path->ifindex, VRF_DEFAULT), VTYNL); + ifindex2ifname (path->ifindex, VRF_DEFAULT)); } } } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } static void @@ -7940,8 +7846,7 @@ show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) struct listnode *node; struct ospf_path *path; - vty_out (vty, "============ OSPF router routing table =============%s", - VTYNL); + vty_out (vty, "============ OSPF router routing table =============\n"); for (rn = route_top (rtrs); rn; rn = route_next (rn)) if (rn->info) { @@ -7959,29 +7864,26 @@ show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), or->cost, inet_ntoa (or->u.std.area_id)); /* Show flags. */ - vty_out (vty, "%s%s%s", + vty_out (vty, "%s%s\n", (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), - (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), - VTYNL); + (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : "")); for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) { if (if_lookup_by_index(path->ifindex, VRF_DEFAULT)) { if (path->nexthop.s_addr == 0) - vty_out (vty, "%24s directly attached to %s%s", - "", ifindex2ifname (path->ifindex, VRF_DEFAULT), - VTYNL); + vty_out (vty, "%24s directly attached to %s\n", + "", ifindex2ifname (path->ifindex, VRF_DEFAULT)); else - vty_out (vty, "%24s via %s, %s%s", "", + vty_out (vty, "%24s via %s, %s\n", "", inet_ntoa (path->nexthop), - ifindex2ifname (path->ifindex, VRF_DEFAULT), - VTYNL); + ifindex2ifname (path->ifindex, VRF_DEFAULT)); } } } } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } static void @@ -7992,8 +7894,7 @@ show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) struct listnode *pnode, *pnnode; struct ospf_path *path; - vty_out (vty, "============ OSPF external routing table ===========%s", - VTYNL); + vty_out (vty, "============ OSPF external routing table ===========\n"); for (rn = route_top (rt); rn; rn = route_next (rn)) if ((er = rn->info) != NULL) { @@ -8004,12 +7905,12 @@ show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) switch (er->path_type) { case OSPF_PATH_TYPE1_EXTERNAL: - vty_out (vty, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI"%s", buf1, - er->cost, er->u.ext.tag, VTYNL); + vty_out (vty, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI"\n", buf1, + er->cost, er->u.ext.tag); break; case OSPF_PATH_TYPE2_EXTERNAL: - vty_out (vty, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI"%s", buf1, er->cost, - er->u.ext.type2_cost, er->u.ext.tag, VTYNL); + vty_out (vty, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI"\n", buf1, er->cost, + er->u.ext.type2_cost, er->u.ext.tag); break; } @@ -8018,29 +7919,27 @@ show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) if (if_lookup_by_index(path->ifindex, VRF_DEFAULT)) { if (path->nexthop.s_addr == 0) - vty_out (vty, "%24s directly attached to %s%s", - "", ifindex2ifname (path->ifindex, VRF_DEFAULT), VTYNL); + vty_out (vty, "%24s directly attached to %s\n", + "", ifindex2ifname (path->ifindex, VRF_DEFAULT)); else - vty_out (vty, "%24s via %s, %s%s", "", + vty_out (vty, "%24s via %s, %s\n", "", inet_ntoa (path->nexthop), - ifindex2ifname (path->ifindex, VRF_DEFAULT), - VTYNL); + ifindex2ifname (path->ifindex, VRF_DEFAULT)); } } } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } static int show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) { if (ospf->instance) - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); if (ospf->new_table == NULL) { - vty_out (vty, "No OSPF routing information exist%s", VTYNL); + vty_out (vty, "No OSPF routing information exist\n"); return CMD_SUCCESS; } @@ -8050,7 +7949,7 @@ show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) /* Show Router routes. */ show_ip_ospf_route_router (vty, ospf->new_rtrs); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -8095,12 +7994,11 @@ static int show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) { if (ospf->instance) - vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, - VTYNL, VTYNL); + vty_out (vty, "\nOSPF Instance: %d\n\n", ospf->instance); if (ospf->new_table == NULL) { - vty_out (vty, "No OSPF routing information exist%s", VTYNL); + vty_out (vty, "No OSPF routing information exist\n"); return CMD_SUCCESS; } @@ -8113,7 +8011,7 @@ show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) /* Show AS External routes. */ show_ip_ospf_route_external (vty, ospf->old_external_route); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -8201,12 +8099,10 @@ config_write_interface (struct vty *vty) if (ifp->ifindex == IFINDEX_DELETED) continue; - vty_out (vty, "!%s", VTYNL); - vty_out (vty, "interface %s%s", ifp->name, - VTYNL); + vty_out (vty, "!\n"); + vty_out (vty, "interface %s\n", ifp->name); if (ifp->desc) - vty_out (vty, " description %s%s", ifp->desc, - VTYNL); + vty_out (vty, " description %s\n", ifp->desc); write++; @@ -8223,7 +8119,7 @@ config_write_interface (struct vty *vty) ospf_int_type_str[params->type]); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } @@ -8258,7 +8154,7 @@ config_write_interface (struct vty *vty) vty_out (vty, " ip ospf authentication%s", auth_str); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Simple Authentication Password print. */ @@ -8269,7 +8165,7 @@ config_write_interface (struct vty *vty) params->auth_simple); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Cryptographic Authentication Key print. */ @@ -8279,7 +8175,7 @@ config_write_interface (struct vty *vty) ck->key_id, ck->auth_key); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Interface Output Cost print. */ @@ -8288,7 +8184,7 @@ config_write_interface (struct vty *vty) vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Hello Interval print. */ @@ -8298,7 +8194,7 @@ config_write_interface (struct vty *vty) vty_out (vty, " ip ospf hello-interval %u", params->v_hello); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } @@ -8317,7 +8213,7 @@ config_write_interface (struct vty *vty) if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Router Priority print. */ @@ -8327,7 +8223,7 @@ config_write_interface (struct vty *vty) vty_out (vty, " ip ospf priority %u", params->priority); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Retransmit Interval print. */ @@ -8338,7 +8234,7 @@ config_write_interface (struct vty *vty) params->retransmit_interval); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Transmit Delay print. */ @@ -8348,7 +8244,7 @@ config_write_interface (struct vty *vty) vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } /* Area print. */ @@ -8362,7 +8258,7 @@ config_write_interface (struct vty *vty) vty_out (vty, " area %s", inet_ntoa (params->if_area)); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* bfd print. */ @@ -8378,7 +8274,7 @@ config_write_interface (struct vty *vty) vty_out (vty, " ip ospf mtu-ignore"); if (params != IF_DEF_PARAMS (ifp)) vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } @@ -8425,9 +8321,9 @@ config_write_network_area (struct vty *vty, struct ospf *ospf) (unsigned long int) ntohl (n->area_id.s_addr)); /* Network print. */ - vty_out (vty, " network %s/%d area %s%s", + vty_out (vty, " network %s/%d area %s\n", inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, - buf, VTYNL); + buf); } return 0; @@ -8451,16 +8347,15 @@ config_write_ospf_area (struct vty *vty, struct ospf *ospf) if (area->auth_type != OSPF_AUTH_NULL) { if (area->auth_type == OSPF_AUTH_SIMPLE) - vty_out (vty, " area %s authentication%s", buf, VTYNL); + vty_out (vty, " area %s authentication\n", buf); else - vty_out (vty, " area %s authentication message-digest%s", - buf, VTYNL); + vty_out (vty, " area %s authentication message-digest\n", + buf); } if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) - vty_out (vty, " area %s shortcut %s%s", buf, - ospf_shortcut_mode_str[area->shortcut_configured], - VTYNL); + vty_out (vty, " area %s shortcut %s\n", buf, + ospf_shortcut_mode_str[area->shortcut_configured]); if ((area->external_routing == OSPF_AREA_STUB) || (area->external_routing == OSPF_AREA_NSSA) @@ -8488,11 +8383,11 @@ config_write_ospf_area (struct vty *vty, struct ospf *ospf) if (area->no_summary) vty_out (vty, " no-summary"); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); if (area->default_cost != 1) - vty_out (vty, " area %s default-cost %d%s", buf, - area->default_cost, VTYNL); + vty_out (vty, " area %s default-cost %d\n", buf, + area->default_cost); } for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) @@ -8513,24 +8408,24 @@ config_write_ospf_area (struct vty *vty, struct ospf *ospf) vty_out (vty, " substitute %s/%d", inet_ntoa (range->subst_addr), range->subst_masklen); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } if (EXPORT_NAME (area)) - vty_out (vty, " area %s export-list %s%s", buf, - EXPORT_NAME (area), VTYNL); + vty_out (vty, " area %s export-list %s\n", buf, + EXPORT_NAME (area)); if (IMPORT_NAME (area)) - vty_out (vty, " area %s import-list %s%s", buf, - IMPORT_NAME (area), VTYNL); + vty_out (vty, " area %s import-list %s\n", buf, + IMPORT_NAME (area)); if (PREFIX_NAME_IN (area)) - vty_out (vty, " area %s filter-list prefix %s in%s", buf, - PREFIX_NAME_IN (area), VTYNL); + vty_out (vty, " area %s filter-list prefix %s in\n", buf, + PREFIX_NAME_IN (area)); if (PREFIX_NAME_OUT (area)) - vty_out (vty, " area %s filter-list prefix %s out%s", buf, - PREFIX_NAME_OUT (area), VTYNL); + vty_out (vty, " area %s filter-list prefix %s out\n", buf, + PREFIX_NAME_OUT (area)); } return 0; @@ -8554,7 +8449,7 @@ config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } return 0; @@ -8586,32 +8481,30 @@ config_write_virtual_link (struct vty *vty, struct ospf *ospf) OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) - vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", + vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n", buf, inet_ntoa (vl_data->vl_peer), OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, retransmit_interval), OSPF_IF_PARAM (oi, transmit_delay), - OSPF_IF_PARAM (oi, v_wait), - VTYNL); + OSPF_IF_PARAM (oi, v_wait)); else - vty_out (vty, " area %s virtual-link %s%s", buf, - inet_ntoa (vl_data->vl_peer), VTYNL); + vty_out (vty, " area %s virtual-link %s\n", buf, + inet_ntoa (vl_data->vl_peer)); /* Auth key */ if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') - vty_out (vty, " area %s virtual-link %s authentication-key %s%s", + vty_out (vty, " area %s virtual-link %s authentication-key %s\n", buf, inet_ntoa (vl_data->vl_peer), - IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, - VTYNL); + IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple); /* md5 keys */ for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, n2, ck)) vty_out (vty, " area %s virtual-link %s" - " message-digest-key %d md5 %s%s", + " message-digest-key %d md5 %s\n", buf, inet_ntoa (vl_data->vl_peer), - ck->key_id, ck->auth_key, VTYNL); + ck->key_id, ck->auth_key); } } @@ -8651,7 +8544,7 @@ config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) if (ROUTEMAP_NAME (red)) vty_out (vty, " route-map %s", ROUTEMAP_NAME (red)); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } @@ -8662,8 +8555,7 @@ static int config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) { if (ospf->default_metric != -1) - vty_out (vty, " default-metric %d%s", ospf->default_metric, - VTYNL); + vty_out (vty, " default-metric %d\n", ospf->default_metric); return 0; } @@ -8678,9 +8570,9 @@ config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) /* distribute-list print. */ for (type = 0; type < ZEBRA_ROUTE_MAX; type++) if (DISTRIBUTE_NAME (ospf, type)) - vty_out (vty, " distribute-list %s out %s%s", + vty_out (vty, " distribute-list %s out %s\n", DISTRIBUTE_NAME (ospf, type), - zebra_route_string(type), VTYNL); + zebra_route_string(type)); /* default-information print. */ if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) @@ -8703,7 +8595,7 @@ config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) ROUTEMAP_NAME (red)); } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } @@ -8718,7 +8610,7 @@ config_write_ospf_distance (struct vty *vty, struct ospf *ospf) struct ospf_distance *odistance; if (ospf->distance_all) - vty_out (vty, " distance %d%s", ospf->distance_all, VTYNL); + vty_out (vty, " distance %d\n", ospf->distance_all); if (ospf->distance_intra || ospf->distance_inter @@ -8733,16 +8625,15 @@ config_write_ospf_distance (struct vty *vty, struct ospf *ospf) if (ospf->distance_external) vty_out (vty, " external %d", ospf->distance_external); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) if ((odistance = rn->info) != NULL) { - vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, + vty_out (vty, " distance %d %s/%d %s\n", odistance->distance, inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, - odistance->access_list ? odistance->access_list : "", - VTYNL); + odistance->access_list ? odistance->access_list : ""); } return 0; } @@ -8762,9 +8653,9 @@ ospf_config_write (struct vty *vty) { /* `router ospf' print. */ if (ospf->instance) - vty_out (vty, "router ospf %d%s", ospf->instance, VTYNL); + vty_out (vty, "router ospf %d\n", ospf->instance); else - vty_out (vty, "router ospf%s", VTYNL); + vty_out (vty, "router ospf\n"); write++; @@ -8773,84 +8664,84 @@ ospf_config_write (struct vty *vty) /* Router ID print. */ if (ospf->router_id_static.s_addr != 0) - vty_out (vty, " ospf router-id %s%s", - inet_ntoa (ospf->router_id_static), VTYNL); + vty_out (vty, " ospf router-id %s\n", + inet_ntoa (ospf->router_id_static)); /* ABR type print. */ if (ospf->abr_type != OSPF_ABR_DEFAULT) - vty_out (vty, " ospf abr-type %s%s", - ospf_abr_type_str[ospf->abr_type], VTYNL); + vty_out (vty, " ospf abr-type %s\n", + ospf_abr_type_str[ospf->abr_type]); /* log-adjacency-changes flag print. */ if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) { if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) - vty_out(vty, " log-adjacency-changes detail%s", VTYNL); + vty_out(vty, " log-adjacency-changes detail\n"); else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES) - vty_out(vty, " log-adjacency-changes%s", VTYNL); + vty_out(vty, " log-adjacency-changes\n"); } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES) { - vty_out(vty, " no log-adjacency-changes%s", VTYNL); + vty_out(vty, " no log-adjacency-changes\n"); } /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) - vty_out (vty, " compatible rfc1583%s", VTYNL); + vty_out (vty, " compatible rfc1583\n"); /* auto-cost reference-bandwidth configuration. */ if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) { vty_out (vty, "! Important: ensure reference bandwidth " - "is consistent across all routers%s", VTYNL); - vty_out (vty, " auto-cost reference-bandwidth %d%s", - ospf->ref_bandwidth, VTYNL); + "is consistent across all routers\n"); + vty_out (vty, " auto-cost reference-bandwidth %d\n", + ospf->ref_bandwidth); } /* SPF timers print. */ if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) - vty_out (vty, " timers throttle spf %d %d %d%s", + vty_out (vty, " timers throttle spf %d %d %d\n", ospf->spf_delay, ospf->spf_holdtime, - ospf->spf_max_holdtime, VTYNL); + ospf->spf_max_holdtime); /* LSA timers print. */ if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) - vty_out (vty, " timers throttle lsa all %d%s", - ospf->min_ls_interval, VTYNL); + vty_out (vty, " timers throttle lsa all %d\n", + ospf->min_ls_interval); if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) - vty_out (vty, " timers lsa min-arrival %d%s", - ospf->min_ls_arrival, VTYNL); + vty_out (vty, " timers lsa min-arrival %d\n", + ospf->min_ls_arrival); /* Write multiplier print. */ if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) - vty_out (vty, " ospf write-multiplier %d%s", - ospf->write_oi_count, VTYNL); + vty_out (vty, " ospf write-multiplier %d\n", + ospf->write_oi_count); /* Max-metric router-lsa print */ config_write_stub_router (vty, ospf); /* SPF refresh parameters print. */ if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) - vty_out (vty, " refresh timer %d%s", - ospf->lsa_refresh_interval, VTYNL); + vty_out (vty, " refresh timer %d\n", + ospf->lsa_refresh_interval); /* Redistribute information print. */ config_write_ospf_redistribute (vty, ospf); /* passive-interface print. */ if (ospf->passive_interface_default == OSPF_IF_PASSIVE) - vty_out (vty, " passive-interface default%s", VTYNL); + vty_out (vty, " passive-interface default\n"); for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) && IF_DEF_PARAMS (ifp)->passive_interface != ospf->passive_interface_default) { - vty_out (vty, " %spassive-interface %s%s", + vty_out (vty, " %spassive-interface %s\n", IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", - ifp->name, VTYNL); + ifp->name); } for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) { @@ -8865,10 +8756,10 @@ ospf_config_write (struct vty *vty) else if (oi->params->passive_interface == ospf->passive_interface_default) continue; - vty_out (vty, " %spassive-interface %s %s%s", + vty_out (vty, " %spassive-interface %s %s\n", oi->params->passive_interface ? "" : "no ", oi->ifp->name, - inet_ntoa (oi->address->u.prefix4), VTYNL); + inet_ntoa (oi->address->u.prefix4)); } /* Network area print. */ @@ -9098,7 +8989,7 @@ DEFUN (clear_ip_ospf_interface, else /* Interface name is specified. */ { if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg, VRF_DEFAULT)) == NULL) - vty_out (vty, "No such interface name%s", VTYNL); + vty_out (vty, "No such interface name\n"); else ospf_interface_clear(ifp); } diff --git a/ospfd/ospf_vty.h b/ospfd/ospf_vty.h index 0bb5b6f3f..ba7b24ed9 100644 --- a/ospfd/ospf_vty.h +++ b/ospfd/ospf_vty.h @@ -28,7 +28,7 @@ retv = str2area_id ((STR), &(V), &(F)); \ if (retv < 0) \ { \ - vty_out (vty, "%% Invalid OSPF area ID%s", VTYNL); \ + vty_out (vty, "%% Invalid OSPF area ID\n"); \ return CMD_WARNING; \ } \ } @@ -39,13 +39,13 @@ retv = str2area_id ((STR), &(V), &(F)); \ if (retv < 0) \ { \ - vty_out (vty, "%% Invalid OSPF area ID%s", VTYNL); \ + vty_out (vty, "%% Invalid OSPF area ID\n"); \ return CMD_WARNING; \ } \ if (OSPF_IS_AREA_ID_BACKBONE ((V))) \ { \ - vty_out (vty, "%% You can't configure %s to backbone%s", \ - NAME, VTYNL); \ + vty_out (vty, "%% You can't configure %s to backbone\n", \ + NAME); \ } \ } diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 715f24061..e262bd8aa 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -1445,8 +1445,8 @@ ospf_distance_set (struct vty *vty, struct ospf *ospf, ret = str2prefix_ipv4 (ip_str, &p); if (ret == 0) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } distance = atoi (distance_str); @@ -1493,15 +1493,15 @@ ospf_distance_unset (struct vty *vty, struct ospf *ospf, ret = str2prefix_ipv4 (ip_str, &p); if (ret == 0) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } rn = route_node_lookup (ospf->distance_table, (struct prefix *) &p); if (!rn) { - vty_outln (vty, "Can't find specified prefix"); - return CMD_WARNING; + vty_out (vty, "Can't find specified prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } odistance = rn->info; diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c index 2a90eea3b..af8a8e2c5 100644 --- a/pimd/pim_bfd.c +++ b/pimd/pim_bfd.c @@ -52,11 +52,11 @@ pim_bfd_write_config (struct vty *vty, struct interface *ifp) return; if (CHECK_FLAG (bfd_info->flags, BFD_FLAG_PARAM_CFG)) - vty_outln (vty, " ip pim bfd %d %d %d", + vty_out (vty, " ip pim bfd %d %d %d\n", bfd_info->detect_mult, bfd_info->required_min_rx, bfd_info->desired_min_tx); else - vty_outln (vty, " ip pim bfd"); + vty_out (vty, " ip pim bfd\n"); } /* diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index b0afc7828..88c43104c 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -173,8 +173,8 @@ static void pim_show_assert(struct vty *vty) now = pim_time_monotonic_sec(); - vty_outln (vty, - "Interface Address Source Group State Winner Uptime Timer"); + vty_out (vty, + "Interface Address Source Group State Winner Uptime Timer\n"); for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) { char ch_src_str[INET_ADDRSTRLEN]; @@ -201,7 +201,7 @@ static void pim_show_assert(struct vty *vty) pim_time_timer_to_mmss(timer, sizeof(timer), ch->t_ifassert_timer); - vty_outln (vty, "%-9s %-15s %-15s %-15s %-6s %-15s %-8s %-5s", + vty_out (vty, "%-9s %-15s %-15s %-15s %-6s %-15s %-8s %-5s\n", ch->interface->name, inet_ntoa(ifaddr), ch_src_str, @@ -220,15 +220,14 @@ static void pim_show_assert_internal(struct vty *vty) struct pim_ifchannel *ch; struct in_addr ifaddr; - vty_outln (vty, - "CA: CouldAssert%s" - "ECA: Evaluate CouldAssert%s" - "ATD: AssertTrackingDesired%s" - "eATD: Evaluate AssertTrackingDesired%s", - VTYNL, VTYNL, VTYNL, VTYNL); + vty_out (vty, + "CA: CouldAssert\n" + "ECA: Evaluate CouldAssert\n" + "ATD: AssertTrackingDesired\n" + "eATD: Evaluate AssertTrackingDesired\n\n"); - vty_outln (vty, - "Interface Address Source Group CA eCA ATD eATD"); + vty_out (vty, + "Interface Address Source Group CA eCA ATD eATD\n"); for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) { pim_ifp = ch->interface->info; @@ -245,7 +244,7 @@ static void pim_show_assert_internal(struct vty *vty) ch_src_str, sizeof(ch_src_str)); pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, sizeof(ch_grp_str)); - vty_outln (vty, "%-9s %-15s %-15s %-15s %-3s %-3s %-3s %-4s", + vty_out (vty, "%-9s %-15s %-15s %-15s %-3s %-3s %-3s %-4s\n", ch->interface->name, inet_ntoa(ifaddr), ch_src_str, @@ -264,8 +263,8 @@ static void pim_show_assert_metric(struct vty *vty) struct pim_ifchannel *ch; struct in_addr ifaddr; - vty_outln (vty, - "Interface Address Source Group RPT Pref Metric Address "); + vty_out (vty, + "Interface Address Source Group RPT Pref Metric Address \n"); for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) { pim_ifp = ch->interface->info; @@ -289,7 +288,7 @@ static void pim_show_assert_metric(struct vty *vty) pim_inet4_dump("<addr?>", am.ip_address, addr_str, sizeof(addr_str)); - vty_outln (vty, "%-9s %-15s %-15s %-15s %-3s %4u %6u %-15s", + vty_out (vty, "%-9s %-15s %-15s %-15s %-3s %4u %6u %-15s\n", ch->interface->name, inet_ntoa(ifaddr), ch_src_str, @@ -308,8 +307,8 @@ static void pim_show_assert_winner_metric(struct vty *vty) struct pim_ifchannel *ch; struct in_addr ifaddr; - vty_outln (vty, - "Interface Address Source Group RPT Pref Metric Address "); + vty_out (vty, + "Interface Address Source Group RPT Pref Metric Address \n"); for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) { pim_ifp = ch->interface->info; @@ -345,7 +344,7 @@ static void pim_show_assert_winner_metric(struct vty *vty) else snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric); - vty_outln (vty, "%-9s %-15s %-15s %-15s %-3s %-4s %-6s %-15s", + vty_out (vty, "%-9s %-15s %-15s %-15s %-3s %-4s %-6s %-15s\n", ch->interface->name, inet_ntoa(ifaddr), ch_src_str, @@ -431,11 +430,11 @@ static void pim_show_membership(struct vty *vty, u_char uj) } /* scan interface channels */ if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); } else { - vty_outln (vty, - "Interface Address Source Group Membership"); + vty_out (vty, + "Interface Address Source Group Membership\n"); /* * Example of the json data we are traversing @@ -480,7 +479,7 @@ static void pim_show_membership(struct vty *vty, u_char uj) vty_out(vty, "%-15s ", if_field_key); json_object_object_get_ex(if_field_val, "localMembership", &json_tmp); - vty_outln (vty, "%-10s", json_object_get_string(json_tmp)); + vty_out (vty, "%-10s\n", json_object_get_string(json_tmp)); } } } @@ -491,22 +490,22 @@ static void pim_show_membership(struct vty *vty, u_char uj) static void pim_print_ifp_flags(struct vty *vty, struct interface *ifp, int mloop) { - vty_outln (vty, "Flags"); - vty_outln (vty, "-----"); - vty_outln (vty, "All Multicast : %s", + vty_out (vty, "Flags\n"); + vty_out (vty, "-----\n"); + vty_out (vty, "All Multicast : %s\n", (ifp->flags & IFF_ALLMULTI) ? "yes" : "no"); - vty_outln (vty, "Broadcast : %s", + vty_out (vty, "Broadcast : %s\n", if_is_broadcast(ifp) ? "yes" : "no"); - vty_outln (vty, "Deleted : %s", + vty_out (vty, "Deleted : %s\n", PIM_IF_IS_DELETED(ifp) ? "yes" : "no"); - vty_outln (vty, "Interface Index : %d", ifp->ifindex); - vty_outln (vty, "Multicast : %s", + vty_out (vty, "Interface Index : %d\n", ifp->ifindex); + vty_out (vty, "Multicast : %s\n", if_is_multicast(ifp) ? "yes" : "no"); - vty_outln (vty, "Multicast Loop : %d", mloop); - vty_outln (vty, "Promiscuous : %s", + vty_out (vty, "Multicast Loop : %d\n", mloop); + vty_out (vty, "Promiscuous : %s\n", (ifp->flags & IFF_PROMISC) ? "yes" : "no"); - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); + vty_out (vty, "\n"); } static void igmp_show_interfaces(struct vty *vty, u_char uj) @@ -522,8 +521,8 @@ static void igmp_show_interfaces(struct vty *vty, u_char uj) if (uj) json = json_object_new_object(); else - vty_outln (vty, - "Interface State Address V Querier Query Timer Uptime"); + vty_out (vty, + "Interface State Address V Querier Query Timer Uptime\n"); for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { struct pim_interface *pim_ifp; @@ -556,7 +555,7 @@ static void igmp_show_interfaces(struct vty *vty, u_char uj) json_object_object_add(json, ifp->name, json_row); } else { - vty_outln (vty, "%-9s %5s %15s %d %7s %11s %8s", + vty_out (vty, "%-9s %5s %15s %d %7s %11s %8s\n", ifp->name, if_is_up(ifp) ? "up" : "down", inet_ntoa(igmp->ifaddr), @@ -569,7 +568,7 @@ static void igmp_show_interfaces(struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -659,44 +658,44 @@ static void igmp_show_interfaces_single(struct vty *vty, const char *ifname, u_c json_object_object_add(json, ifp->name, json_row); } else { - vty_outln (vty, "Interface : %s", ifp->name); - vty_outln (vty, "State : %s", if_is_up(ifp) ? "up" : "down"); - vty_outln (vty, "Address : %s", + vty_out (vty, "Interface : %s\n", ifp->name); + vty_out (vty, "State : %s\n", if_is_up(ifp) ? "up" : "down"); + vty_out (vty, "Address : %s\n", inet_ntoa(pim_ifp->primary_address)); - vty_outln (vty, "Uptime : %s", uptime); - vty_outln (vty, "Version : %d", pim_ifp->igmp_version); - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); - - vty_outln (vty, "Querier"); - vty_outln (vty, "-------"); - vty_outln (vty, "Querier : %s", + vty_out (vty, "Uptime : %s\n", uptime); + vty_out (vty, "Version : %d\n", pim_ifp->igmp_version); + vty_out (vty, "\n"); + vty_out (vty, "\n"); + + vty_out (vty, "Querier\n"); + vty_out (vty, "-------\n"); + vty_out (vty, "Querier : %s\n", igmp->t_igmp_query_timer ? "local" : "other"); - vty_outln (vty, "Start Count : %d", igmp->startup_query_count); - vty_outln (vty, "Query Timer : %s", query_hhmmss); - vty_outln (vty, "Other Timer : %s", other_hhmmss); - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); - - vty_outln (vty, "Timers"); - vty_outln (vty, "------"); - vty_outln (vty, "Group Membership Interval : %lis", + vty_out (vty, "Start Count : %d\n", igmp->startup_query_count); + vty_out (vty, "Query Timer : %s\n", query_hhmmss); + vty_out (vty, "Other Timer : %s\n", other_hhmmss); + vty_out (vty, "\n"); + vty_out (vty, "\n"); + + vty_out (vty, "Timers\n"); + vty_out (vty, "------\n"); + vty_out (vty, "Group Membership Interval : %lis\n", gmi_msec / 1000); - vty_outln (vty, "Last Member Query Time : %lis", + vty_out (vty, "Last Member Query Time : %lis\n", lmqt_msec / 1000); - vty_outln (vty, "Older Host Present Interval : %lis", + vty_out (vty, "Older Host Present Interval : %lis\n", ohpi_msec / 1000); - vty_outln (vty, "Other Querier Present Interval : %lis", + vty_out (vty, "Other Querier Present Interval : %lis\n", oqpi_msec / 1000); - vty_outln (vty, "Query Interval : %ds", + vty_out (vty, "Query Interval : %ds\n", igmp->querier_query_interval); - vty_outln (vty, "Query Response Interval : %lis", + vty_out (vty, "Query Response Interval : %lis\n", qri_msec / 1000); - vty_outln (vty, "Robustness Variable : %d", + vty_out (vty, "Robustness Variable : %d\n", igmp->querier_robustness_variable); - vty_outln (vty, "Startup Query Interval : %ds", sqi); - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); + vty_out (vty, "Startup Query Interval : %ds\n", sqi); + vty_out (vty, "\n"); + vty_out (vty, "\n"); pim_print_ifp_flags(vty, ifp, mloop); } @@ -704,12 +703,12 @@ static void igmp_show_interfaces_single(struct vty *vty, const char *ifname, u_c } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { if (!found_ifname) - vty_outln (vty, "%% No such interface"); + vty_out (vty, "%% No such interface\n"); } } @@ -721,8 +720,8 @@ static void igmp_show_interface_join(struct vty *vty) now = pim_time_monotonic_sec(); - vty_outln (vty, - "Interface Address Source Group Socket Uptime "); + vty_out (vty, + "Interface Address Source Group Socket Uptime \n"); for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { struct pim_interface *pim_ifp; @@ -751,7 +750,7 @@ static void igmp_show_interface_join(struct vty *vty) pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str)); pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str)); - vty_outln (vty, "%-9s %-15s %-15s %-15s %6d %8s", + vty_out (vty, "%-9s %-15s %-15s %-15s %6d %8s\n", ifp->name, pri_addr_str, source_str, @@ -925,23 +924,23 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch json_object_object_add(json, ifp->name, json_row); } else { - vty_outln (vty, "Interface : %s", ifp->name); - vty_outln (vty, "State : %s", if_is_up(ifp) ? "up" : "down"); + vty_out (vty, "Interface : %s\n", ifp->name); + vty_out (vty, "State : %s\n", if_is_up(ifp) ? "up" : "down"); if (pim_ifp->update_source.s_addr != INADDR_ANY) { - vty_outln (vty, "Use Source : %s", inet_ntoa(pim_ifp->update_source)); + vty_out (vty, "Use Source : %s\n", inet_ntoa(pim_ifp->update_source)); } if (pim_ifp->sec_addr_list) { char pbuf[PREFIX2STR_BUFFER]; - vty_outln (vty, "Address : %s (primary)", + vty_out (vty, "Address : %s (primary)\n", inet_ntoa(ifaddr)); for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, sec_node, sec_addr)) { - vty_outln (vty, " %s", + vty_out (vty, " %s\n", prefix2str(&sec_addr->addr, pbuf, sizeof(pbuf))); } } else { - vty_outln (vty, "Address : %s", inet_ntoa(ifaddr)); + vty_out (vty, "Address : %s\n", inet_ntoa(ifaddr)); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); // PIM neighbors print_header = 1; @@ -949,32 +948,32 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) { if (print_header) { - vty_outln (vty, "PIM Neighbors"); - vty_outln (vty, "-------------"); + vty_out (vty, "PIM Neighbors\n"); + vty_out (vty, "-------------\n"); print_header = 0; } pim_inet4_dump("<src?>", neigh->source_addr, neigh_src_str, sizeof(neigh_src_str)); pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation); pim_time_timer_to_hhmmss(expire, sizeof(expire), neigh->t_expire_timer); - vty_outln (vty, "%-15s : up for %s, holdtime expires in %s", neigh_src_str, uptime, + vty_out (vty, "%-15s : up for %s, holdtime expires in %s\n", neigh_src_str, uptime, expire); } if (!print_header) { - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); + vty_out (vty, "\n"); } - vty_outln (vty, "Designated Router"); - vty_outln (vty, "-----------------"); - vty_outln (vty, "Address : %s", dr_str); - vty_outln (vty, "Priority : %d", pim_ifp->pim_dr_priority); - vty_outln (vty, "Uptime : %s", dr_uptime); - vty_outln (vty, "Elections : %d", pim_ifp->pim_dr_election_count); - vty_outln (vty, "Changes : %d", pim_ifp->pim_dr_election_changes); - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); + vty_out (vty, "Designated Router\n"); + vty_out (vty, "-----------------\n"); + vty_out (vty, "Address : %s\n", dr_str); + vty_out (vty, "Priority : %d\n", pim_ifp->pim_dr_priority); + vty_out (vty, "Uptime : %s\n", dr_uptime); + vty_out (vty, "Elections : %d\n", pim_ifp->pim_dr_election_count); + vty_out (vty, "Changes : %d\n", pim_ifp->pim_dr_election_changes); + vty_out (vty, "\n"); + vty_out (vty, "\n"); // FHR print_header = 1; @@ -983,77 +982,77 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch if (up->flags & PIM_UPSTREAM_FLAG_MASK_FHR) { if (print_header) { - vty_outln (vty, "FHR - First Hop Router"); - vty_outln (vty, "----------------------"); + vty_out (vty, "FHR - First Hop Router\n"); + vty_out (vty, "----------------------\n"); print_header = 0; } pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str)); pim_inet4_dump("<grp?>", up->sg.grp, grp_str, sizeof(grp_str)); pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition); - vty_outln (vty, "%s : %s is a source, uptime is %s", grp_str, src_str, + vty_out (vty, "%s : %s is a source, uptime is %s\n", grp_str, src_str, uptime); } } } if (!print_header) { - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); + vty_out (vty, "\n"); } - vty_outln (vty, "Hellos"); - vty_outln (vty, "------"); - vty_outln (vty, "Period : %d", pim_ifp->pim_hello_period); - vty_outln (vty, "Timer : %s", hello_timer); - vty_outln (vty, "StatStart : %s", stat_uptime); - vty_outln (vty, "Receive : %d", pim_ifp->pim_ifstat_hello_recv); - vty_outln (vty, "Receive Failed : %d", + vty_out (vty, "Hellos\n"); + vty_out (vty, "------\n"); + vty_out (vty, "Period : %d\n", pim_ifp->pim_hello_period); + vty_out (vty, "Timer : %s\n", hello_timer); + vty_out (vty, "StatStart : %s\n", stat_uptime); + vty_out (vty, "Receive : %d\n", pim_ifp->pim_ifstat_hello_recv); + vty_out (vty, "Receive Failed : %d\n", pim_ifp->pim_ifstat_hello_recvfail); - vty_outln (vty, "Send : %d", pim_ifp->pim_ifstat_hello_sent); - vty_outln (vty, "Send Failed : %d", + vty_out (vty, "Send : %d\n", pim_ifp->pim_ifstat_hello_sent); + vty_out (vty, "Send Failed : %d\n", pim_ifp->pim_ifstat_hello_sendfail); - vty_outln (vty, "Generation ID : %08x", pim_ifp->pim_generation_id); - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); + vty_out (vty, "Generation ID : %08x\n", pim_ifp->pim_generation_id); + vty_out (vty, "\n"); + vty_out (vty, "\n"); pim_print_ifp_flags(vty, ifp, mloop); - vty_outln (vty, "Join Prune Interval"); - vty_outln (vty, "-------------------"); - vty_outln (vty, "LAN Delay : %s", + vty_out (vty, "Join Prune Interval\n"); + vty_out (vty, "-------------------\n"); + vty_out (vty, "LAN Delay : %s\n", pim_if_lan_delay_enabled(ifp) ? "yes" : "no"); - vty_outln (vty, "Effective Propagation Delay : %d msec", + vty_out (vty, "Effective Propagation Delay : %d msec\n", pim_if_effective_propagation_delay_msec(ifp)); - vty_outln (vty, "Effective Override Interval : %d msec", + vty_out (vty, "Effective Override Interval : %d msec\n", pim_if_effective_override_interval_msec(ifp)); - vty_outln (vty, "Join Prune Override Interval : %d msec", + vty_out (vty, "Join Prune Override Interval : %d msec\n", pim_if_jp_override_interval_msec(ifp)); - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); + vty_out (vty, "\n"); - vty_outln (vty, "LAN Prune Delay"); - vty_outln (vty, "---------------"); - vty_outln (vty, "Propagation Delay : %d msec", + vty_out (vty, "LAN Prune Delay\n"); + vty_out (vty, "---------------\n"); + vty_out (vty, "Propagation Delay : %d msec\n", pim_ifp->pim_propagation_delay_msec); - vty_outln (vty, "Propagation Delay (Highest) : %d msec", + vty_out (vty, "Propagation Delay (Highest) : %d msec\n", pim_ifp->pim_neighbors_highest_propagation_delay_msec); - vty_outln (vty, "Override Interval : %d msec", + vty_out (vty, "Override Interval : %d msec\n", pim_ifp->pim_override_interval_msec); - vty_outln (vty, "Override Interval (Highest) : %d msec", + vty_out (vty, "Override Interval (Highest) : %d msec\n", pim_ifp->pim_neighbors_highest_override_interval_msec); - vty_out (vty, VTYNL); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); + vty_out (vty, "\n"); } } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { if (!found_ifname) - vty_outln (vty, "%% No such interface"); + vty_out (vty, "%% No such interface\n"); } } @@ -1105,11 +1104,11 @@ static void pim_show_interfaces(struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); } else { - vty_outln (vty, - "Interface State Address PIM Nbrs PIM DR FHR IfChannels"); + vty_out (vty, + "Interface State Address PIM Nbrs PIM DR FHR IfChannels\n"); json_object_object_foreach(json, key, val) { vty_out(vty, "%-9s ", key); @@ -1134,7 +1133,7 @@ static void pim_show_interfaces(struct vty *vty, u_char uj) vty_out(vty, "%3d ", json_object_get_int(json_tmp)); json_object_object_get_ex(val, "pimIfChannels", &json_tmp); - vty_outln (vty, "%9d", json_object_get_int(json_tmp)); + vty_out (vty, "%9d\n", json_object_get_int(json_tmp)); } } @@ -1153,16 +1152,16 @@ static void pim_show_interface_traffic (struct vty *vty, u_char uj) json = json_object_new_object (); else { - vty_out (vty, VTYNL); - vty_outln (vty, "%-12s%-17s%-17s%-17s%-17s%-17s%-17s", "Interface", + vty_out (vty, "\n"); + vty_out (vty, "%-12s%-17s%-17s%-17s%-17s%-17s%-17s\n", "Interface", " HELLO", " JOIN", " PRUNE", " REGISTER", " REGISTER-STOP", " ASSERT"); - vty_outln (vty, - "%-10s%-18s%-17s%-17s%-17s%-17s%-17s", + vty_out (vty, + "%-10s%-18s%-17s%-17s%-17s%-17s%-17s\n", "", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx"); - vty_outln (vty, - "---------------------------------------------------------------------------------------------------------------"); + vty_out (vty, + "---------------------------------------------------------------------------------------------------------------\n"); } for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) @@ -1193,8 +1192,8 @@ static void pim_show_interface_traffic (struct vty *vty, u_char uj) } else { - vty_outln (vty, - "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u ", + vty_out (vty, + "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u \n", ifp->name, pim_ifp->pim_ifstat_hello_recv, pim_ifp->pim_ifstat_hello_sent, pim_ifp->pim_ifstat_join_recv, pim_ifp->pim_ifstat_join_send, pim_ifp->pim_ifstat_prune_recv, @@ -1208,7 +1207,7 @@ static void pim_show_interface_traffic (struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free (json); } @@ -1227,16 +1226,16 @@ static void pim_show_interface_traffic_single (struct vty *vty, const char *ifna json = json_object_new_object (); else { - vty_out (vty, VTYNL); - vty_outln (vty, "%-12s%-17s%-17s%-17s%-17s%-17s%-17s", "Interface", + vty_out (vty, "\n"); + vty_out (vty, "%-12s%-17s%-17s%-17s%-17s%-17s%-17s\n", "Interface", " HELLO", " JOIN", " PRUNE", " REGISTER", " REGISTER-STOP", " ASSERT"); - vty_outln (vty, - "%-10s%-18s%-17s%-17s%-17s%-17s%-17s", + vty_out (vty, + "%-10s%-18s%-17s%-17s%-17s%-17s%-17s\n", "", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx"); - vty_outln (vty, - "---------------------------------------------------------------------------------------------------------------"); + vty_out (vty, + "---------------------------------------------------------------------------------------------------------------\n"); } for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) @@ -1272,8 +1271,8 @@ static void pim_show_interface_traffic_single (struct vty *vty, const char *ifna } else { - vty_outln (vty, - "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u ", + vty_out (vty, + "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u \n", ifp->name, pim_ifp->pim_ifstat_hello_recv, pim_ifp->pim_ifstat_hello_sent, pim_ifp->pim_ifstat_join_recv, pim_ifp->pim_ifstat_join_send, pim_ifp->pim_ifstat_prune_recv, @@ -1287,14 +1286,14 @@ static void pim_show_interface_traffic_single (struct vty *vty, const char *ifna } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free (json); } else { if (!found_ifname) - vty_outln (vty, "%% No such interface"); + vty_out (vty, "%% No such interface\n"); } } @@ -1315,8 +1314,8 @@ static void pim_show_join(struct vty *vty, u_char uj) if (uj) json = json_object_new_object(); else - vty_outln (vty, - "Interface Address Source Group State Uptime Expire Prune"); + vty_out (vty, + "Interface Address Source Group State Uptime Expire Prune\n"); for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) { @@ -1374,7 +1373,7 @@ static void pim_show_join(struct vty *vty, u_char uj) else json_object_object_add(json_grp, ch_src_str, json_row); } else { - vty_outln (vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s", + vty_out (vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s\n", ch->interface->name, inet_ntoa(ifaddr), ch_src_str, @@ -1387,7 +1386,7 @@ static void pim_show_join(struct vty *vty, u_char uj) } /* scan interface channels */ if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -1512,44 +1511,44 @@ static void pim_show_neighbors_single(struct vty *vty, const char *neighbor, u_c json_object_object_add(json_ifp, neigh_src_str, json_row); } else { - vty_outln (vty, "Interface : %s", ifp->name); - vty_outln (vty, "Neighbor : %s", neigh_src_str); - vty_outln (vty, " Uptime : %s", uptime); - vty_outln (vty, " Holdtime : %s", expire); - vty_outln (vty, " DR Priority : %d", + vty_out (vty, "Interface : %s\n", ifp->name); + vty_out (vty, "Neighbor : %s\n", neigh_src_str); + vty_out (vty, " Uptime : %s\n", uptime); + vty_out (vty, " Holdtime : %s\n", expire); + vty_out (vty, " DR Priority : %d\n", neigh->dr_priority); - vty_outln (vty, " Generation ID : %08x", + vty_out (vty, " Generation ID : %08x\n", neigh->generation_id); - vty_outln (vty, " Override Interval (msec) : %d", + vty_out (vty, " Override Interval (msec) : %d\n", neigh->override_interval_msec); - vty_outln (vty, " Propagation Delay (msec) : %d", + vty_out (vty, " Propagation Delay (msec) : %d\n", neigh->propagation_delay_msec); - vty_outln (vty, " Hello Option - Address List : %s", + vty_out (vty, " Hello Option - Address List : %s\n", option_address_list ? "yes" : "no"); - vty_outln (vty, " Hello Option - DR Priority : %s", + vty_out (vty, " Hello Option - DR Priority : %s\n", option_dr_priority ? "yes" : "no"); - vty_outln (vty, " Hello Option - Generation ID : %s", + vty_out (vty, " Hello Option - Generation ID : %s\n", option_generation_id ? "yes" : "no"); - vty_outln (vty, " Hello Option - Holdtime : %s", + vty_out (vty, " Hello Option - Holdtime : %s\n", option_holdtime ? "yes" : "no"); - vty_outln (vty, " Hello Option - LAN Prune Delay : %s", + vty_out (vty, " Hello Option - LAN Prune Delay : %s\n", option_lan_prune_delay ? "yes" : "no"); - vty_outln (vty, " Hello Option - T-bit : %s", + vty_out (vty, " Hello Option - T-bit : %s\n", option_t_bit ? "yes" : "no"); pim_bfd_show_info (vty, neigh->bfd_info, json_ifp, uj, 0); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { { if (!found_neighbor) - vty_outln (vty, "%% No such interface or neighbor"); + vty_out (vty, "%% No such interface or neighbor\n"); } } } @@ -1572,8 +1571,7 @@ pim_show_state(struct vty *vty, const char *src_or_group, const char *group, u_c json = json_object_new_object(); } else { vty_out(vty, "Codes: J -> Pim Join, I -> IGMP Report, S -> Source, * -> Inherited from (*,G)"); - vty_outln (vty, "%sInstalled Source Group IIF OIL", - VTYNL); + vty_out (vty, "\nInstalled Source Group IIF OIL\n"); } for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) { @@ -1690,16 +1688,16 @@ pim_show_state(struct vty *vty, const char *src_or_group, const char *group, u_c } if (!uj) - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } @@ -1723,7 +1721,7 @@ static void pim_show_neighbors(struct vty *vty, u_char uj) if (uj) { json = json_object_new_object(); } else { - vty_outln (vty, "Interface Neighbor Uptime Holdtime DR Pri"); + vty_out (vty, "Interface Neighbor Uptime Holdtime DR Pri\n"); } for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { @@ -1755,7 +1753,7 @@ static void pim_show_neighbors(struct vty *vty, u_char uj) json_object_object_add(json_ifp_rows, neigh_src_str, json_row); } else { - vty_outln (vty, "%-9s %15s %8s %8s %6d", + vty_out (vty, "%-9s %15s %8s %8s %6d\n", ifp->name, neigh_src_str, uptime, @@ -1771,7 +1769,7 @@ static void pim_show_neighbors(struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -1782,8 +1780,8 @@ static void pim_show_neighbors_secondary(struct vty *vty) struct listnode *node; struct interface *ifp; - vty_outln (vty, - "Interface Address Neighbor Secondary "); + vty_out (vty, + "Interface Address Neighbor Secondary \n"); for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { struct pim_interface *pim_ifp; @@ -1817,7 +1815,7 @@ static void pim_show_neighbors_secondary(struct vty *vty) prefix2str(p, neigh_sec_str, sizeof(neigh_sec_str)); - vty_outln (vty, "%-9s %-15s %-15s %-15s", + vty_out (vty, "%-9s %-15s %-15s %-15s\n", ifp->name, inet_ntoa(ifaddr), neigh_src_str, @@ -1905,8 +1903,8 @@ static void pim_show_upstream(struct vty *vty, u_char uj) if (uj) json = json_object_new_object(); else - vty_outln (vty, - "Iif Source Group State Uptime JoinTimer RSTimer KATimer RefCnt"); + vty_out (vty, + "Iif Source Group State Uptime JoinTimer RSTimer KATimer RefCnt\n"); for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, upnode, up)) { char src_str[INET_ADDRSTRLEN]; @@ -1973,7 +1971,7 @@ static void pim_show_upstream(struct vty *vty, u_char uj) json_object_int_add(json_row, "sptBit", up->sptbit); json_object_object_add(json_group, src_str, json_row); } else { - vty_outln (vty, "%-10s%-15s %-15s %-11s %-8s %-9s %-9s %-9s %6d", + vty_out (vty, "%-10s%-15s %-15s %-11s %-8s %-9s %-9s %-9s %6d\n", up->rpf.source_nexthop.interface->name, src_str, grp_str, @@ -1987,7 +1985,7 @@ static void pim_show_upstream(struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -2007,8 +2005,8 @@ static void pim_show_join_desired(struct vty *vty, u_char uj) if (uj) json = json_object_new_object(); else - vty_outln (vty, - "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD"); + vty_out (vty, + "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD\n"); /* scan per-interface (S,G) state */ for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, chnode, ch)) { @@ -2051,7 +2049,7 @@ static void pim_show_join_desired(struct vty *vty, u_char uj) json_object_object_add(json_group, src_str, json_row); } else { - vty_outln (vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s", + vty_out (vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s\n", ch->interface->name, src_str, grp_str, @@ -2064,7 +2062,7 @@ static void pim_show_join_desired(struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -2081,8 +2079,8 @@ static void pim_show_upstream_rpf(struct vty *vty, u_char uj) if (uj) json = json_object_new_object(); else - vty_outln (vty, - "Source Group RpfIface RibNextHop RpfAddress "); + vty_out (vty, + "Source Group RpfIface RibNextHop RpfAddress \n"); for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, upnode, up)) { char src_str[INET_ADDRSTRLEN]; @@ -2118,7 +2116,7 @@ static void pim_show_upstream_rpf(struct vty *vty, u_char uj) json_object_string_add(json_row, "rpfAddress", rpf_addr_str); json_object_object_add(json_group, src_str, json_row); } else { - vty_outln (vty, "%-15s %-15s %-8s %-15s %-15s", + vty_out (vty, "%-15s %-15s %-8s %-15s %-15s\n", src_str, grp_str, rpf_ifname, @@ -2128,7 +2126,7 @@ static void pim_show_upstream_rpf(struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -2149,20 +2147,20 @@ static void show_rpf_refresh_stats(struct vty *vty, time_t now, json_object *jso json_object_int_add(json, "nexthopLookups", qpim_nexthop_lookups); json_object_int_add(json, "nexthopLookupsAvoided", nexthop_lookups_avoided); } else { - vty_outln (vty, - "RPF Cache Refresh Delay: %ld msecs%s" - "RPF Cache Refresh Timer: %ld msecs%s" - "RPF Cache Refresh Requests: %lld%s" - "RPF Cache Refresh Events: %lld%s" - "RPF Cache Refresh Last: %s%s" - "Nexthop Lookups: %lld%s" - "Nexthop Lookups Avoided: %lld", - qpim_rpf_cache_refresh_delay_msec, VTYNL, - pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTYNL, - (long long)qpim_rpf_cache_refresh_requests, VTYNL, - (long long)qpim_rpf_cache_refresh_events, VTYNL, - refresh_uptime, VTYNL, - (long long) qpim_nexthop_lookups, VTYNL, + vty_out (vty, + "RPF Cache Refresh Delay: %ld msecs\n" + "RPF Cache Refresh Timer: %ld msecs\n" + "RPF Cache Refresh Requests: %lld\n" + "RPF Cache Refresh Events: %lld\n" + "RPF Cache Refresh Last: %s\n" + "Nexthop Lookups: %lld\n" + "Nexthop Lookups Avoided: %lld\n", + qpim_rpf_cache_refresh_delay_msec, + pim_time_timer_remain_msec(qpim_rpf_cache_refresher), + (long long)qpim_rpf_cache_refresh_requests, + (long long)qpim_rpf_cache_refresh_events, + refresh_uptime, + (long long) qpim_nexthop_lookups, (long long)nexthop_lookups_avoided); } } @@ -2177,12 +2175,12 @@ static void show_scan_oil_stats(struct vty *vty, time_t now) pim_time_uptime_begin(uptime_mroute_add, sizeof(uptime_mroute_add), now, qpim_mroute_add_last); pim_time_uptime_begin(uptime_mroute_del, sizeof(uptime_mroute_del), now, qpim_mroute_del_last); - vty_outln (vty, - "Scan OIL - Last: %s Events: %lld%s" - "MFC Add - Last: %s Events: %lld%s" - "MFC Del - Last: %s Events: %lld", - uptime_scan_oil, (long long) qpim_scan_oil_events, VTYNL, - uptime_mroute_add, (long long) qpim_mroute_add_events, VTYNL, + vty_out (vty, + "Scan OIL - Last: %s Events: %lld\n" + "MFC Add - Last: %s Events: %lld\n" + "MFC Del - Last: %s Events: %lld\n", + uptime_scan_oil, (long long) qpim_scan_oil_events, + uptime_mroute_add, (long long) qpim_mroute_add_events, uptime_mroute_del, (long long)qpim_mroute_del_events); } @@ -2200,9 +2198,9 @@ static void pim_show_rpf(struct vty *vty, u_char uj) show_rpf_refresh_stats(vty, now, json); } else { show_rpf_refresh_stats(vty, now, json); - vty_out (vty, VTYNL); - vty_outln (vty, - "Source Group RpfIface RpfAddress RibNextHop Metric Pref"); + vty_out (vty, "\n"); + vty_out (vty, + "Source Group RpfIface RpfAddress RibNextHop Metric Pref\n"); } for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, up_node, up)) { @@ -2239,7 +2237,7 @@ static void pim_show_rpf(struct vty *vty, u_char uj) json_object_object_add(json_group, src_str, json_row); } else { - vty_outln (vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d", + vty_out (vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d\n", src_str, grp_str, rpf_ifname, @@ -2251,7 +2249,7 @@ static void pim_show_rpf(struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -2277,7 +2275,7 @@ pim_print_pnc_cache_walkcb (struct hash_backet *backet, void *arg) vty_out (vty, "%-15s ", inet_ntoa (pnc->rpf.rpf_addr.u.prefix4)); vty_out (vty, "%-14s ", ifp ? ifp->name : "NULL"); vty_out (vty, "%s ", inet_ntoa (nh_node->gate.ipv4)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return CMD_SUCCESS; } @@ -2288,14 +2286,14 @@ pim_show_nexthop (struct vty *vty) if (pimg && !pimg->rpf_hash) { - vty_outln (vty, "no nexthop cache "); + vty_out (vty, "no nexthop cache \n"); return; } - vty_outln (vty, "Number of registered addresses: %lu ", + vty_out (vty, "Number of registered addresses: %lu \n", pimg->rpf_hash->count); - vty_outln (vty, "Address Interface Nexthop"); - vty_outln (vty, "-------------------------------------------"); + vty_out (vty, "Address Interface Nexthop\n"); + vty_out (vty, "-------------------------------------------\n"); hash_walk (pimg->rpf_hash, pim_print_pnc_cache_walkcb, vty); @@ -2315,8 +2313,8 @@ static void igmp_show_groups(struct vty *vty, u_char uj) if (uj) json = json_object_new_object(); else - vty_outln (vty, - "Interface Address Group Mode Timer Srcs V Uptime "); + vty_out (vty, + "Interface Address Group Mode Timer Srcs V Uptime \n"); /* scan interfaces */ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { @@ -2368,7 +2366,7 @@ static void igmp_show_groups(struct vty *vty, u_char uj) json_object_object_add(json_iface, group_str, json_row); } else { - vty_outln (vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s", + vty_out (vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s\n", ifp->name, ifaddr_str, group_str, @@ -2383,7 +2381,7 @@ static void igmp_show_groups(struct vty *vty, u_char uj) } /* scan interfaces */ if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -2394,8 +2392,8 @@ static void igmp_show_group_retransmission(struct vty *vty) struct listnode *ifnode; struct interface *ifp; - vty_outln (vty, - "Interface Address Group RetTimer Counter RetSrcs"); + vty_out (vty, + "Interface Address Group RetTimer Counter RetSrcs\n"); /* scan interfaces */ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { @@ -2433,7 +2431,7 @@ static void igmp_show_group_retransmission(struct vty *vty) } } - vty_outln (vty, "%-9s %-15s %-15s %-8s %7d %7d", + vty_out (vty, "%-9s %-15s %-15s %-8s %7d %7d\n", ifp->name, ifaddr_str, group_str, @@ -2454,8 +2452,8 @@ static void igmp_show_sources(struct vty *vty) now = pim_time_monotonic_sec(); - vty_outln (vty, - "Interface Address Group Source Timer Fwd Uptime "); + vty_out (vty, + "Interface Address Group Source Timer Fwd Uptime \n"); /* scan interfaces */ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { @@ -2494,7 +2492,7 @@ static void igmp_show_sources(struct vty *vty) pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation); - vty_outln (vty, "%-9s %-15s %-15s %-15s %5s %3s %8s", + vty_out (vty, "%-9s %-15s %-15s %-15s %5s %3s %8s\n", ifp->name, ifaddr_str, group_str, @@ -2514,8 +2512,8 @@ static void igmp_show_source_retransmission(struct vty *vty) struct listnode *ifnode; struct interface *ifp; - vty_outln (vty, - "Interface Address Group Source Counter"); + vty_out (vty, + "Interface Address Group Source Counter\n"); /* scan interfaces */ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { @@ -2548,7 +2546,7 @@ static void igmp_show_source_retransmission(struct vty *vty) pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str)); - vty_outln (vty, "%-9s %-15s %-15s %-15s %7d", + vty_out (vty, "%-9s %-15s %-15s %-15s %7d\n", ifp->name, ifaddr_str, group_str, @@ -3113,14 +3111,14 @@ DEFUN (show_ip_pim_nexthop_lookup, result = inet_pton (AF_INET, addr_str, &src_addr); if (result <= 0) { - vty_outln (vty, "Bad unicast address %s: errno=%d: %s", + vty_out (vty, "Bad unicast address %s: errno=%d: %s\n", addr_str, errno, safe_strerror(errno)); return CMD_WARNING; } if (pim_is_group_224_4 (src_addr)) { - vty_outln (vty, "Invalid argument. Expected Valid Source Address."); + vty_out (vty, "Invalid argument. Expected Valid Source Address.\n"); return CMD_WARNING; } @@ -3128,15 +3126,15 @@ DEFUN (show_ip_pim_nexthop_lookup, result = inet_pton (AF_INET, addr_str1, &grp_addr); if (result <= 0) { - vty_outln (vty, "Bad unicast address %s: errno=%d: %s", + vty_out (vty, "Bad unicast address %s: errno=%d: %s\n", addr_str, errno, safe_strerror(errno)); return CMD_WARNING; } if (!pim_is_group_224_4 (grp_addr)) { - vty_outln (vty, - "Invalid argument. Expected Valid Multicast Group Address."); + vty_out (vty, + "Invalid argument. Expected Valid Multicast Group Address.\n"); return CMD_WARNING; } @@ -3163,7 +3161,7 @@ DEFUN (show_ip_pim_nexthop_lookup, pim_addr_dump ("<grp?>", &grp, grp_str, sizeof (grp_str)); pim_addr_dump ("<nexthop?>", &nexthop.mrib_nexthop_addr, nexthop_addr_str, sizeof (nexthop_addr_str)); - vty_outln (vty, "Group %s --- Nexthop %s Interface %s ", grp_str, + vty_out (vty, "Group %s --- Nexthop %s Interface %s \n", grp_str, nexthop_addr_str, nexthop.interface->name); return CMD_SUCCESS; @@ -3196,10 +3194,10 @@ static void show_multicast_interfaces(struct vty *vty) struct listnode *node; struct interface *ifp; - vty_out (vty, VTYNL); + vty_out (vty, "\n"); - vty_outln (vty, - "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut"); + vty_out (vty, + "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut\n"); for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { struct pim_interface *pim_ifp; @@ -3215,18 +3213,17 @@ static void show_multicast_interfaces(struct vty *vty) vreq.vifi = pim_ifp->mroute_vif_index; if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) { - zlog_warn("ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s%s", + zlog_warn("ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s\n", (unsigned long)SIOCGETVIFCNT, ifp->name, pim_ifp->mroute_vif_index, errno, - safe_strerror(errno), - VTYNL); + safe_strerror(errno)); } ifaddr = pim_ifp->primary_address; - vty_outln (vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu", + vty_out (vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu\n", ifp->name, inet_ntoa(ifaddr), ifp->ifindex, @@ -3249,37 +3246,37 @@ DEFUN (show_ip_multicast, char uptime[10]; - vty_outln (vty, "Mroute socket descriptor: %d", + vty_out (vty, "Mroute socket descriptor: %d\n", qpim_mroute_socket_fd); pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation); - vty_outln (vty, "Mroute socket uptime: %s", + vty_out (vty, "Mroute socket uptime: %s\n", uptime); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); pim_zebra_zclient_update (vty); pim_zlookup_show_ip_multicast (vty); - vty_out (vty, VTYNL); - vty_outln (vty, "Maximum highest VifIndex: %d", + vty_out (vty, "\n"); + vty_out (vty, "Maximum highest VifIndex: %d\n", PIM_MAX_USABLE_VIFS); - vty_out (vty, VTYNL); - vty_outln (vty, "Upstream Join Timer: %d secs", + vty_out (vty, "\n"); + vty_out (vty, "Upstream Join Timer: %d secs\n", qpim_t_periodic); - vty_outln (vty, "Join/Prune Holdtime: %d secs", + vty_out (vty, "Join/Prune Holdtime: %d secs\n", PIM_JP_HOLDTIME); - vty_outln (vty, "PIM ECMP: %s", + vty_out (vty, "PIM ECMP: %s\n", qpim_ecmp_enable ? "Enable" : "Disable"); - vty_outln (vty, "PIM ECMP Rebalance: %s", + vty_out (vty, "PIM ECMP Rebalance: %s\n", qpim_ecmp_rebalance_enable ? "Enable" : "Disable"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); show_rpf_refresh_stats(vty, now, NULL); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); show_scan_oil_stats(vty, now); @@ -3312,8 +3309,8 @@ static void show_mroute(struct vty *vty, u_char uj) if (uj) { json = json_object_new_object(); } else { - vty_outln (vty, - "Source Group Proto Input Output TTL Uptime"); + vty_out (vty, + "Source Group Proto Input Output TTL Uptime\n"); } now = pim_time_monotonic_sec(); @@ -3424,7 +3421,7 @@ static void show_mroute(struct vty *vty, u_char uj) strcpy(proto, "STAR"); } - vty_outln (vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s", + vty_out (vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s\n", src_str, grp_str, proto, @@ -3444,7 +3441,7 @@ static void show_mroute(struct vty *vty, u_char uj) } if (!uj && !found_oif) { - vty_outln (vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s", + vty_out (vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s\n", src_str, grp_str, "none", @@ -3531,7 +3528,7 @@ static void show_mroute(struct vty *vty, u_char uj) } json_object_object_add(json_oil, out_ifname, json_ifp_out); } else { - vty_outln (vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s", + vty_out (vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s\n", src_str, grp_str, proto, @@ -3550,7 +3547,7 @@ static void show_mroute(struct vty *vty, u_char uj) } if (!uj && !found_oif) { - vty_outln (vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s", + vty_out (vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s\n", src_str, grp_str, proto, @@ -3562,7 +3559,7 @@ static void show_mroute(struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -3587,10 +3584,10 @@ static void show_mroute_count(struct vty *vty) struct channel_oil *c_oil; struct static_route *s_route; - vty_out (vty, VTYNL); + vty_out (vty, "\n"); - vty_outln (vty, - "Source Group LastUsed Packets Bytes WrongIf "); + vty_out (vty, + "Source Group LastUsed Packets Bytes WrongIf \n"); /* Print PIM and IGMP route counts */ for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) { @@ -3605,7 +3602,7 @@ static void show_mroute_count(struct vty *vty) pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str)); pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str)); - vty_outln (vty, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld", + vty_out (vty, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld\n", source_str, group_str, c_oil->cc.lastused/100, @@ -3627,7 +3624,7 @@ static void show_mroute_count(struct vty *vty) pim_inet4_dump("<group?>", s_route->c_oil.oil.mfcc_mcastgrp, group_str, sizeof(group_str)); pim_inet4_dump("<source?>", s_route->c_oil.oil.mfcc_origin, source_str, sizeof(source_str)); - vty_outln (vty, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld", + vty_out (vty, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld\n", source_str, group_str, s_route->c_oil.cc.lastused, @@ -3668,24 +3665,24 @@ DEFUN (show_ip_rib, addr_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, addr_str, &addr); if (result <= 0) { - vty_outln (vty, "Bad unicast address %s: errno=%d: %s", + vty_out (vty, "Bad unicast address %s: errno=%d: %s\n", addr_str, errno, safe_strerror(errno)); return CMD_WARNING; } if (pim_nexthop_lookup(&nexthop, addr, 0)) { - vty_outln (vty, "Failure querying RIB nexthop for unicast address %s", + vty_out (vty, "Failure querying RIB nexthop for unicast address %s\n", addr_str); return CMD_WARNING; } - vty_outln (vty, - "Address NextHop Interface Metric Preference"); + vty_out (vty, + "Address NextHop Interface Metric Preference\n"); pim_addr_dump("<nexthop?>", &nexthop.mrib_nexthop_addr, nexthop_addr_str, sizeof(nexthop_addr_str)); - vty_outln (vty, "%-15s %-15s %-9s %6d %10d", + vty_out (vty, "%-15s %-15s %-9s %6d %10d\n", addr_str, nexthop_addr_str, nexthop.interface ? nexthop.interface->name : "<ifname?>", @@ -3701,8 +3698,8 @@ static void show_ssmpingd(struct vty *vty) struct ssmpingd_sock *ss; time_t now; - vty_outln (vty, - "Source Socket Address Port Uptime Requests"); + vty_out (vty, + "Source Socket Address Port Uptime Requests\n"); if (!qpim_ssmpingd_list) return; @@ -3719,14 +3716,14 @@ static void show_ssmpingd(struct vty *vty) pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str)); if (pim_socket_getsockname(ss->sock_fd, (struct sockaddr *) &bind_addr, &len)) { - vty_outln (vty, "%% Failure reading socket name for ssmpingd source %s on fd=%d", + vty_out (vty, "%% Failure reading socket name for ssmpingd source %s on fd=%d\n", source_str, ss->sock_fd); } pim_inet4_dump("<addr?>", bind_addr.sin_addr, bind_addr_str, sizeof(bind_addr_str)); pim_time_uptime(ss_uptime, sizeof(ss_uptime), now - ss->creation); - vty_outln (vty, "%-15s %6d %-15s %5d %8s %8lld", + vty_out (vty, "%-15s %6d %-15s %5d %8s %8lld\n", source_str, ss->sock_fd, bind_addr_str, @@ -3756,46 +3753,46 @@ pim_rp_cmd_worker (struct vty *vty, const char *rp, const char *group, const cha if (result == PIM_MALLOC_FAIL) { - vty_outln (vty, "%% Out of memory"); - return CMD_WARNING; + vty_out (vty, "%% Out of memory\n"); + return CMD_WARNING_CONFIG_FAILED; } if (result == PIM_GROUP_BAD_ADDRESS) { - vty_outln (vty, "%% Bad group address specified: %s", group); - return CMD_WARNING; + vty_out (vty, "%% Bad group address specified: %s\n", group); + return CMD_WARNING_CONFIG_FAILED; } if (result == PIM_RP_BAD_ADDRESS) { - vty_outln (vty, "%% Bad RP address specified: %s", rp); - return CMD_WARNING; + vty_out (vty, "%% Bad RP address specified: %s\n", rp); + return CMD_WARNING_CONFIG_FAILED; } if (result == PIM_RP_NO_PATH) { - vty_outln (vty, "%% No Path to RP address specified: %s", rp); - return CMD_WARNING; + vty_out (vty, "%% No Path to RP address specified: %s\n", rp); + return CMD_WARNING_CONFIG_FAILED; } if (result == PIM_GROUP_OVERLAP) { - vty_outln (vty, "%% Group range specified cannot overlap"); - return CMD_WARNING; + vty_out (vty, "%% Group range specified cannot overlap\n"); + return CMD_WARNING_CONFIG_FAILED; } if (result == PIM_GROUP_PFXLIST_OVERLAP) { - vty_outln (vty, - "%% This group is already covered by a RP prefix-list"); - return CMD_WARNING; + vty_out (vty, + "%% This group is already covered by a RP prefix-list\n"); + return CMD_WARNING_CONFIG_FAILED; } if (result == PIM_RP_PFXLIST_IN_USE) { - vty_outln (vty, - "%% The same prefix-list cannot be applied to multiple RPs"); - return CMD_WARNING; + vty_out (vty, + "%% The same prefix-list cannot be applied to multiple RPs\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -4042,20 +4039,20 @@ pim_no_rp_cmd_worker (struct vty *vty, const char *rp, const char *group, if (result == PIM_GROUP_BAD_ADDRESS) { - vty_outln (vty, "%% Bad group address specified: %s", group); - return CMD_WARNING; + vty_out (vty, "%% Bad group address specified: %s\n", group); + return CMD_WARNING_CONFIG_FAILED; } if (result == PIM_RP_BAD_ADDRESS) { - vty_outln (vty, "%% Bad RP address specified: %s", rp); - return CMD_WARNING; + vty_out (vty, "%% Bad RP address specified: %s\n", rp); + return CMD_WARNING_CONFIG_FAILED; } if (result == PIM_RP_NOT_FOUND) { - vty_outln (vty, "%% Unable to find specified RP"); - return CMD_WARNING; + vty_out (vty, "%% Unable to find specified RP\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -4104,16 +4101,16 @@ pim_ssm_cmd_worker (struct vty *vty, const char *plist) switch (result) { case PIM_SSM_ERR_NO_VRF: - vty_outln (vty, "%% VRF doesn't exist"); + vty_out (vty, "%% VRF doesn't exist\n"); break; case PIM_SSM_ERR_DUP: - vty_outln (vty, "%% duplicate config"); + vty_out (vty, "%% duplicate config\n"); break; default: - vty_outln (vty, "%% ssm range config failed"); + vty_out (vty, "%% ssm range config failed\n"); } - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (ip_pim_ssm_prefix_list, @@ -4155,10 +4152,10 @@ DEFUN (no_ip_pim_ssm_prefix_list_name, if (ssm->plist_name && !strcmp(ssm->plist_name, argv[0]->arg)) return pim_ssm_cmd_worker (vty, NULL); - vty_outln (vty, "%% pim ssm prefix-list %s doesn't exist", + vty_out (vty, "%% pim ssm prefix-list %s doesn't exist\n", argv[0]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } static void @@ -4172,12 +4169,12 @@ ip_pim_ssm_show_group_range(struct vty *vty, u_char uj) json_object *json; json = json_object_new_object(); json_object_string_add(json, "ssmGroups", range_str); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_outln (vty, "SSM group range : %s", range_str); + vty_out (vty, "SSM group range : %s\n", range_str); } DEFUN (show_ip_pim_ssm_range, @@ -4218,12 +4215,12 @@ ip_pim_ssm_show_group_type(struct vty *vty, u_char uj, const char *group) json_object *json; json = json_object_new_object(); json_object_string_add(json, "groupType", type_str); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else - vty_outln (vty, "Group type : %s", type_str); + vty_out (vty, "Group type : %s\n", type_str); } DEFUN (show_ip_pim_group_type, @@ -4258,8 +4255,8 @@ DEFUN_HIDDEN (no_ip_multicast_routing, IP_STR "Enable IP multicast forwarding\n") { - vty_outln (vty, - "Command is Disabled and will be removed in a future version"); + vty_out (vty, + "Command is Disabled and will be removed in a future version\n"); return CMD_SUCCESS; } @@ -4277,16 +4274,16 @@ DEFUN (ip_ssmpingd, result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { - vty_outln (vty, "%% Bad source address %s: errno=%d: %s", + vty_out (vty, "%% Bad source address %s: errno=%d: %s\n", source_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_ssmpingd_start(source_addr); if (result) { - vty_outln (vty, "%% Failure starting ssmpingd for source %s: %d", + vty_out (vty, "%% Failure starting ssmpingd for source %s: %d\n", source_str, result); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -4307,16 +4304,16 @@ DEFUN (no_ip_ssmpingd, result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { - vty_outln (vty, "%% Bad source address %s: errno=%d: %s", + vty_out (vty, "%% Bad source address %s: errno=%d: %s\n", source_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_ssmpingd_stop(source_addr); if (result) { - vty_outln (vty, "%% Failure stopping ssmpingd for source %s: %d", + vty_out (vty, "%% Failure stopping ssmpingd for source %s: %d\n", source_str, result); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -4388,9 +4385,9 @@ pim_cmd_igmp_start (struct vty *vty, struct interface *ifp) pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */); if (!pim_ifp) { - vty_outln (vty, "Could not enable IGMP on interface %s", + vty_out (vty, "Could not enable IGMP on interface %s\n", ifp->name); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } need_startup = 1; } @@ -4473,25 +4470,25 @@ DEFUN (interface_ip_igmp_join, group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { - vty_outln (vty, "Bad group address %s: errno=%d: %s", + vty_out (vty, "Bad group address %s: errno=%d: %s\n", group_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Source address */ source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { - vty_outln (vty, "Bad source address %s: errno=%d: %s", + vty_out (vty, "Bad source address %s: errno=%d: %s\n", source_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_if_igmp_join_add(ifp, group_addr, source_addr); if (result) { - vty_outln (vty, "%% Failure joining IGMP group %s source %s on interface %s: %d", + vty_out (vty, "%% Failure joining IGMP group %s source %s on interface %s: %d\n", group_str, source_str, ifp->name, result); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -4520,25 +4517,25 @@ DEFUN (interface_no_ip_igmp_join, group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { - vty_outln (vty, "Bad group address %s: errno=%d: %s", + vty_out (vty, "Bad group address %s: errno=%d: %s\n", group_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Source address */ source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { - vty_outln (vty, "Bad source address %s: errno=%d: %s", + vty_out (vty, "Bad source address %s: errno=%d: %s\n", source_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_if_igmp_join_del(ifp, group_addr, source_addr); if (result) { - vty_outln (vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d", + vty_out (vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d\n", group_str, source_str, ifp->name, result); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -4704,23 +4701,23 @@ DEFUN (interface_ip_igmp_query_interval, already, but we verify them anyway for extra safety. */ if (query_interval < IGMP_QUERY_INTERVAL_MIN) { - vty_outln (vty, "General query interval %d lower than minimum %d", + vty_out (vty, "General query interval %d lower than minimum %d\n", query_interval, IGMP_QUERY_INTERVAL_MIN); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (query_interval > IGMP_QUERY_INTERVAL_MAX) { - vty_outln (vty, "General query interval %d higher than maximum %d", + vty_out (vty, "General query interval %d higher than maximum %d\n", query_interval, IGMP_QUERY_INTERVAL_MAX); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) { - vty_outln (vty, - "Can't set general query interval %d dsec <= query max response time %d dsec.", + vty_out (vty, + "Can't set general query interval %d dsec <= query max response time %d dsec.\n", query_interval_dsec,pim_ifp->igmp_query_max_response_time_dsec); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } change_query_interval(pim_ifp, query_interval); @@ -4746,11 +4743,11 @@ DEFUN (interface_no_ip_igmp_query_interval, default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10; if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) { - vty_outln (vty, - "Can't set default general query interval %d dsec <= query max response time %d dsec.", + vty_out (vty, + "Can't set default general query interval %d dsec <= query max response time %d dsec.\n", default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL); @@ -4845,10 +4842,10 @@ DEFUN (interface_ip_igmp_query_max_response_time, query_max_response_time = atoi(argv[3]->arg); if (query_max_response_time >= pim_ifp->igmp_default_query_interval * 10) { - vty_outln (vty, - "Can't set query max response time %d sec >= general query interval %d sec", + vty_out (vty, + "Can't set query max response time %d sec >= general query interval %d sec\n", query_max_response_time,pim_ifp->igmp_default_query_interval); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } change_query_max_response_time(pim_ifp, query_max_response_time); @@ -4905,10 +4902,10 @@ DEFUN_HIDDEN (interface_ip_igmp_query_max_response_time_dsec, default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval; if (query_max_response_time_dsec >= default_query_interval_dsec) { - vty_outln (vty, - "Can't set query max response time %d dsec >= general query interval %d dsec", + vty_out (vty, + "Can't set query max response time %d dsec >= general query interval %d dsec\n", query_max_response_time_dsec,default_query_interval_dsec); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } change_query_max_response_time(pim_ifp, query_max_response_time_dsec); @@ -4949,8 +4946,8 @@ DEFUN (interface_ip_pim_drprio, uint32_t old_dr_prio; if (!pim_ifp) { - vty_outln (vty, "Please enable PIM on interface, first"); - return CMD_WARNING; + vty_out (vty, "Please enable PIM on interface, first\n"); + return CMD_WARNING_CONFIG_FAILED; } old_dr_prio = pim_ifp->pim_dr_priority; @@ -4978,8 +4975,8 @@ DEFUN (interface_no_ip_pim_drprio, struct pim_interface *pim_ifp = ifp->info; if (!pim_ifp) { - vty_outln (vty, "Pim not enabled on this interface"); - return CMD_WARNING; + vty_out (vty, "Pim not enabled on this interface\n"); + return CMD_WARNING_CONFIG_FAILED; } if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) { @@ -5021,12 +5018,12 @@ DEFUN_HIDDEN (interface_ip_pim_ssm, VTY_DECLVAR_CONTEXT(interface, ifp); if (!pim_cmd_interface_add(ifp)) { - vty_outln (vty, "Could not enable PIM SM on interface"); - return CMD_WARNING; + vty_out (vty, "Could not enable PIM SM on interface\n"); + return CMD_WARNING_CONFIG_FAILED; } - vty_outln(vty, "WARN: Enabled PIM SM on interface; configure PIM SSM " - "range if needed"); + vty_out(vty, "WARN: Enabled PIM SM on interface; configure PIM SSM " + "range if needed\n"); return CMD_SUCCESS; } @@ -5039,8 +5036,8 @@ DEFUN (interface_ip_pim_sm, { VTY_DECLVAR_CONTEXT(interface, ifp); if (!pim_cmd_interface_add(ifp)) { - vty_outln (vty, "Could not enable PIM SM on interface"); - return CMD_WARNING; + vty_out (vty, "Could not enable PIM SM on interface\n"); + return CMD_WARNING_CONFIG_FAILED; } pim_if_create_pimreg(); @@ -5084,8 +5081,8 @@ DEFUN_HIDDEN (interface_no_ip_pim_ssm, { VTY_DECLVAR_CONTEXT(interface, ifp); if (!pim_cmd_interface_delete(ifp)) { - vty_outln (vty, "Unable to delete interface information"); - return CMD_WARNING; + vty_out (vty, "Unable to delete interface information\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -5101,8 +5098,8 @@ DEFUN (interface_no_ip_pim_sm, { VTY_DECLVAR_CONTEXT(interface, ifp); if (!pim_cmd_interface_delete(ifp)) { - vty_outln (vty, "Unable to delete interface information"); - return CMD_WARNING; + vty_out (vty, "Unable to delete interface information\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -5129,24 +5126,24 @@ DEFUN (interface_ip_mroute, oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname, VRF_DEFAULT); if (!oif) { - vty_outln (vty, "No such interface name %s", + vty_out (vty, "No such interface name %s\n", oifname); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { - vty_outln (vty, "Bad group address %s: errno=%d: %s", + vty_out (vty, "Bad group address %s: errno=%d: %s\n", grp_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } src_addr.s_addr = INADDR_ANY; if (pim_static_add(iif, oif, grp_addr, src_addr)) { - vty_outln (vty, "Failed to add route"); - return CMD_WARNING; + vty_out (vty, "Failed to add route\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -5176,30 +5173,30 @@ DEFUN (interface_ip_mroute_source, oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname, VRF_DEFAULT); if (!oif) { - vty_outln (vty, "No such interface name %s", + vty_out (vty, "No such interface name %s\n", oifname); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { - vty_outln (vty, "Bad group address %s: errno=%d: %s", + vty_out (vty, "Bad group address %s: errno=%d: %s\n", grp_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } src_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, src_str, &src_addr); if (result <= 0) { - vty_outln (vty, "Bad source address %s: errno=%d: %s", + vty_out (vty, "Bad source address %s: errno=%d: %s\n", src_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (pim_static_add(iif, oif, grp_addr, src_addr)) { - vty_outln (vty, "Failed to add route"); - return CMD_WARNING; + vty_out (vty, "Failed to add route\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -5227,24 +5224,24 @@ DEFUN (interface_no_ip_mroute, oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname, VRF_DEFAULT); if (!oif) { - vty_outln (vty, "No such interface name %s", + vty_out (vty, "No such interface name %s\n", oifname); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { - vty_outln (vty, "Bad group address %s: errno=%d: %s", + vty_out (vty, "Bad group address %s: errno=%d: %s\n", grp_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } src_addr.s_addr = INADDR_ANY; if (pim_static_del(iif, oif, grp_addr, src_addr)) { - vty_outln (vty, "Failed to remove route"); - return CMD_WARNING; + vty_out (vty, "Failed to remove route\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -5275,30 +5272,30 @@ DEFUN (interface_no_ip_mroute_source, oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname, VRF_DEFAULT); if (!oif) { - vty_outln (vty, "No such interface name %s", + vty_out (vty, "No such interface name %s\n", oifname); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { - vty_outln (vty, "Bad group address %s: errno=%d: %s", + vty_out (vty, "Bad group address %s: errno=%d: %s\n", grp_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } src_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, src_str, &src_addr); if (result <= 0) { - vty_outln (vty, "Bad source address %s: errno=%d: %s", + vty_out (vty, "Bad source address %s: errno=%d: %s\n", src_str, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (pim_static_del(iif, oif, grp_addr, src_addr)) { - vty_outln (vty, "Failed to remove route"); - return CMD_WARNING; + vty_out (vty, "Failed to remove route\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -5322,8 +5319,8 @@ DEFUN (interface_ip_pim_hello, { if (!pim_cmd_interface_add(ifp)) { - vty_outln (vty, "Could not enable PIM SM on interface"); - return CMD_WARNING; + vty_out (vty, "Could not enable PIM SM on interface\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -5352,8 +5349,8 @@ DEFUN (interface_no_ip_pim_hello, struct pim_interface *pim_ifp = ifp->info; if (!pim_ifp) { - vty_outln (vty, "Pim not enabled on this interface"); - return CMD_WARNING; + vty_out (vty, "Pim not enabled on this interface\n"); + return CMD_WARNING_CONFIG_FAILED; } pim_ifp->pim_hello_period = PIM_DEFAULT_HELLO_PERIOD; @@ -5597,22 +5594,22 @@ DEFUN (debug_pim_packets, if (argv_find (argv, argc, "hello", &idx)) { PIM_DO_DEBUG_PIM_HELLO; - vty_outln (vty, "PIM Hello debugging is on"); + vty_out (vty, "PIM Hello debugging is on\n"); } else if (argv_find (argv, argc ,"joins", &idx)) { PIM_DO_DEBUG_PIM_J_P; - vty_outln (vty, "PIM Join/Prune debugging is on"); + vty_out (vty, "PIM Join/Prune debugging is on\n"); } else if (argv_find (argv, argc, "register", &idx)) { PIM_DO_DEBUG_PIM_REG; - vty_outln (vty, "PIM Register debugging is on"); + vty_out (vty, "PIM Register debugging is on\n"); } else { PIM_DO_DEBUG_PIM_PACKETS; - vty_outln (vty, "PIM Packet debugging is on "); + vty_out (vty, "PIM Packet debugging is on \n"); } return CMD_SUCCESS; } @@ -5632,17 +5629,17 @@ DEFUN (no_debug_pim_packets, if (argv_find (argv, argc,"hello",&idx)) { PIM_DONT_DEBUG_PIM_HELLO; - vty_outln (vty, "PIM Hello debugging is off "); + vty_out (vty, "PIM Hello debugging is off \n"); } else if (argv_find (argv, argc, "joins", &idx)) { PIM_DONT_DEBUG_PIM_J_P; - vty_outln (vty, "PIM Join/Prune debugging is off "); + vty_out (vty, "PIM Join/Prune debugging is off \n"); } else if (argv_find (argv, argc, "register", &idx)) { PIM_DONT_DEBUG_PIM_REG; - vty_outln (vty, "PIM Register debugging is off"); + vty_out (vty, "PIM Register debugging is off\n"); } else PIM_DONT_DEBUG_PIM_PACKETS; @@ -5882,9 +5879,9 @@ interface_pim_use_src_cmd_worker(struct vty *vty, const char *source) result = inet_pton(AF_INET, source, &source_addr); if (result <= 0) { - vty_outln (vty, "%% Bad source address %s: errno=%d: %s", + vty_out (vty, "%% Bad source address %s: errno=%d: %s\n", source, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_update_source_set(ifp, source_addr); @@ -5892,16 +5889,16 @@ interface_pim_use_src_cmd_worker(struct vty *vty, const char *source) case PIM_SUCCESS: break; case PIM_IFACE_NOT_FOUND: - vty_outln (vty, "Pim not enabled on this interface"); + vty_out (vty, "Pim not enabled on this interface\n"); break; case PIM_UPDATE_SOURCE_DUP: - vty_outln (vty, "%% Source already set to %s", source); + vty_out (vty, "%% Source already set to %s\n", source); break; default: - vty_outln (vty, "%% Source set failed"); + vty_out (vty, "%% Source set failed\n"); } - return result?CMD_WARNING:CMD_SUCCESS; + return result ? CMD_WARNING_CONFIG_FAILED : CMD_SUCCESS; } DEFUN (interface_pim_use_source, @@ -6022,16 +6019,16 @@ ip_msdp_peer_cmd_worker (struct vty *vty, const char *peer, const char *local) result = inet_pton(AF_INET, peer, &peer_addr); if (result <= 0) { - vty_outln (vty, "%% Bad peer address %s: errno=%d: %s", + vty_out (vty, "%% Bad peer address %s: errno=%d: %s\n", peer, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = inet_pton(AF_INET, local, &local_addr); if (result <= 0) { - vty_outln (vty, "%% Bad source address %s: errno=%d: %s", + vty_out (vty, "%% Bad source address %s: errno=%d: %s\n", local, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_msdp_peer_add(peer_addr, local_addr, "default", NULL/* mp_p */); @@ -6039,19 +6036,19 @@ ip_msdp_peer_cmd_worker (struct vty *vty, const char *peer, const char *local) case PIM_MSDP_ERR_NONE: break; case PIM_MSDP_ERR_OOM: - vty_outln (vty, "%% Out of memory"); + vty_out (vty, "%% Out of memory\n"); break; case PIM_MSDP_ERR_PEER_EXISTS: - vty_outln (vty, "%% Peer exists"); + vty_out (vty, "%% Peer exists\n"); break; case PIM_MSDP_ERR_MAX_MESH_GROUPS: - vty_outln (vty, "%% Only one mesh-group allowed currently"); + vty_out (vty, "%% Only one mesh-group allowed currently\n"); break; default: - vty_outln (vty, "%% peer add failed"); + vty_out (vty, "%% peer add failed\n"); } - return result?CMD_WARNING:CMD_SUCCESS; + return result ? CMD_WARNING_CONFIG_FAILED : CMD_SUCCESS; } DEFUN_HIDDEN (ip_msdp_peer, @@ -6075,9 +6072,9 @@ ip_no_msdp_peer_cmd_worker (struct vty *vty, const char *peer) result = inet_pton(AF_INET, peer, &peer_addr); if (result <= 0) { - vty_outln (vty, "%% Bad peer address %s: errno=%d: %s", + vty_out (vty, "%% Bad peer address %s: errno=%d: %s\n", peer, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_msdp_peer_del(peer_addr); @@ -6085,13 +6082,13 @@ ip_no_msdp_peer_cmd_worker (struct vty *vty, const char *peer) case PIM_MSDP_ERR_NONE: break; case PIM_MSDP_ERR_NO_PEER: - vty_outln (vty, "%% Peer does not exist"); + vty_out (vty, "%% Peer does not exist\n"); break; default: - vty_outln (vty, "%% peer del failed"); + vty_out (vty, "%% peer del failed\n"); } - return result?CMD_WARNING:CMD_SUCCESS; + return result ? CMD_WARNING_CONFIG_FAILED : CMD_SUCCESS; } DEFUN_HIDDEN (no_ip_msdp_peer, @@ -6114,9 +6111,9 @@ ip_msdp_mesh_group_member_cmd_worker(struct vty *vty, const char *mg, const char result = inet_pton(AF_INET, mbr, &mbr_ip); if (result <= 0) { - vty_outln (vty, "%% Bad member address %s: errno=%d: %s", + vty_out (vty, "%% Bad member address %s: errno=%d: %s\n", mbr, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_msdp_mg_mbr_add(mg, mbr_ip); @@ -6124,19 +6121,19 @@ ip_msdp_mesh_group_member_cmd_worker(struct vty *vty, const char *mg, const char case PIM_MSDP_ERR_NONE: break; case PIM_MSDP_ERR_OOM: - vty_outln (vty, "%% Out of memory"); + vty_out (vty, "%% Out of memory\n"); break; case PIM_MSDP_ERR_MG_MBR_EXISTS: - vty_outln (vty, "%% mesh-group member exists"); + vty_out (vty, "%% mesh-group member exists\n"); break; case PIM_MSDP_ERR_MAX_MESH_GROUPS: - vty_outln (vty, "%% Only one mesh-group allowed currently"); + vty_out (vty, "%% Only one mesh-group allowed currently\n"); break; default: - vty_outln (vty, "%% member add failed"); + vty_out (vty, "%% member add failed\n"); } - return result?CMD_WARNING:CMD_SUCCESS; + return result ? CMD_WARNING_CONFIG_FAILED : CMD_SUCCESS; } DEFUN (ip_msdp_mesh_group_member, @@ -6160,9 +6157,9 @@ ip_no_msdp_mesh_group_member_cmd_worker(struct vty *vty, const char *mg, const c result = inet_pton(AF_INET, mbr, &mbr_ip); if (result <= 0) { - vty_outln (vty, "%% Bad member address %s: errno=%d: %s", + vty_out (vty, "%% Bad member address %s: errno=%d: %s\n", mbr, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_msdp_mg_mbr_del(mg, mbr_ip); @@ -6170,16 +6167,16 @@ ip_no_msdp_mesh_group_member_cmd_worker(struct vty *vty, const char *mg, const c case PIM_MSDP_ERR_NONE: break; case PIM_MSDP_ERR_NO_MG: - vty_outln (vty, "%% mesh-group does not exist"); + vty_out (vty, "%% mesh-group does not exist\n"); break; case PIM_MSDP_ERR_NO_MG_MBR: - vty_outln (vty, "%% mesh-group member does not exist"); + vty_out (vty, "%% mesh-group member does not exist\n"); break; default: - vty_outln (vty, "%% mesh-group member del failed"); + vty_out (vty, "%% mesh-group member del failed\n"); } - return result?CMD_WARNING:CMD_SUCCESS; + return result ? CMD_WARNING_CONFIG_FAILED : CMD_SUCCESS; } DEFUN (no_ip_msdp_mesh_group_member, no_ip_msdp_mesh_group_member_cmd, @@ -6203,9 +6200,9 @@ ip_msdp_mesh_group_source_cmd_worker(struct vty *vty, const char *mg, const char result = inet_pton(AF_INET, src, &src_ip); if (result <= 0) { - vty_outln (vty, "%% Bad source address %s: errno=%d: %s", + vty_out (vty, "%% Bad source address %s: errno=%d: %s\n", src, errno, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } result = pim_msdp_mg_src_add(mg, src_ip); @@ -6213,16 +6210,16 @@ ip_msdp_mesh_group_source_cmd_worker(struct vty *vty, const char *mg, const char case PIM_MSDP_ERR_NONE: break; case PIM_MSDP_ERR_OOM: - vty_outln (vty, "%% Out of memory"); + vty_out (vty, "%% Out of memory\n"); break; case PIM_MSDP_ERR_MAX_MESH_GROUPS: - vty_outln (vty, "%% Only one mesh-group allowed currently"); + vty_out (vty, "%% Only one mesh-group allowed currently\n"); break; default: - vty_outln (vty, "%% source add failed"); + vty_out (vty, "%% source add failed\n"); } - return result?CMD_WARNING:CMD_SUCCESS; + return result ? CMD_WARNING_CONFIG_FAILED : CMD_SUCCESS; } @@ -6249,13 +6246,13 @@ ip_no_msdp_mesh_group_source_cmd_worker(struct vty *vty, const char *mg) case PIM_MSDP_ERR_NONE: break; case PIM_MSDP_ERR_NO_MG: - vty_outln (vty, "%% mesh-group does not exist"); + vty_out (vty, "%% mesh-group does not exist\n"); break; default: - vty_outln (vty, "%% mesh-group source del failed"); + vty_out (vty, "%% mesh-group source del failed\n"); } - return result?CMD_WARNING:CMD_SUCCESS; + return result ? CMD_WARNING_CONFIG_FAILED : CMD_SUCCESS; } static int @@ -6268,13 +6265,13 @@ ip_no_msdp_mesh_group_cmd_worker(struct vty *vty, const char *mg) case PIM_MSDP_ERR_NONE: break; case PIM_MSDP_ERR_NO_MG: - vty_outln (vty, "%% mesh-group does not exist"); + vty_out (vty, "%% mesh-group does not exist\n"); break; default: - vty_outln (vty, "%% mesh-group source del failed"); + vty_out (vty, "%% mesh-group source del failed\n"); } - return result ? CMD_WARNING : CMD_SUCCESS; + return result ? CMD_WARNING_CONFIG_FAILED : CMD_SUCCESS; } DEFUN (no_ip_msdp_mesh_group_source, @@ -6299,7 +6296,7 @@ print_empty_json_obj(struct vty *vty) { json_object *json; json = json_object_new_object(); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -6334,9 +6331,9 @@ ip_msdp_show_mesh_group(struct vty *vty, u_char uj) json_object_string_add(json_mg_row, "name", mg->mesh_group_name); json_object_string_add(json_mg_row, "source", src_str); } else { - vty_outln (vty, "Mesh group : %s", mg->mesh_group_name); - vty_outln (vty, " Source : %s", src_str); - vty_outln (vty, " Member State"); + vty_out (vty, "Mesh group : %s\n", mg->mesh_group_name); + vty_out (vty, " Source : %s\n", src_str); + vty_out (vty, " Member State\n"); } for (ALL_LIST_ELEMENTS_RO(mg->mbr_list, mbrnode, mbr)) { @@ -6357,14 +6354,14 @@ ip_msdp_show_mesh_group(struct vty *vty, u_char uj) } json_object_object_add(json_members, mbr_str, json_row); } else { - vty_outln (vty, " %-15s %11s", + vty_out (vty, " %-15s %11s\n", mbr_str, state_str); } } if (uj) { json_object_object_add(json, mg->mesh_group_name, json_mg_row); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -6402,8 +6399,8 @@ ip_msdp_show_peers(struct vty *vty, u_char uj) if (uj) { json = json_object_new_object(); } else { - vty_outln (vty, - "Peer Local State Uptime SaCnt"); + vty_out (vty, + "Peer Local State Uptime SaCnt\n"); } for (ALL_LIST_ELEMENTS_RO(msdp->peer_list, mpnode, mp)) { @@ -6425,14 +6422,14 @@ ip_msdp_show_peers(struct vty *vty, u_char uj) json_object_int_add(json_row, "saCount", mp->sa_cnt); json_object_object_add(json, peer_str, json_row); } else { - vty_outln (vty, "%-15s %15s %11s %8s %6d", + vty_out (vty, "%-15s %15s %11s %8s %6d\n", peer_str, local_str, state_str, timebuf, mp->sa_cnt); } } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -6496,31 +6493,31 @@ ip_msdp_show_peers_detail(struct vty *vty, const char *peer, u_char uj) json_object_int_add(json_row, "saRcvd", mp->sa_rx_cnt); json_object_object_add(json, peer_str, json_row); } else { - vty_outln (vty, "Peer : %s", peer_str); - vty_outln (vty, " Local : %s", local_str); - vty_outln (vty, " Mesh Group : %s", mp->mesh_group_name); - vty_outln (vty, " State : %s", state_str); - vty_outln (vty, " Uptime : %s", timebuf); - - vty_outln (vty, " Keepalive Timer : %s", katimer); - vty_outln (vty, " Conn Retry Timer : %s", crtimer); - vty_outln (vty, " Hold Timer : %s", holdtimer); - vty_outln (vty, " Last Reset : %s", mp->last_reset); - vty_outln (vty, " Conn Attempts : %d", mp->conn_attempts); - vty_outln (vty, " Established Changes : %d", mp->est_flaps); - vty_outln (vty, " SA Count : %d", mp->sa_cnt); - vty_outln (vty, " Statistics :"); - vty_outln (vty, " Sent Rcvd"); - vty_outln (vty, " Keepalives : %10d %10d", + vty_out (vty, "Peer : %s\n", peer_str); + vty_out (vty, " Local : %s\n", local_str); + vty_out (vty, " Mesh Group : %s\n", mp->mesh_group_name); + vty_out (vty, " State : %s\n", state_str); + vty_out (vty, " Uptime : %s\n", timebuf); + + vty_out (vty, " Keepalive Timer : %s\n", katimer); + vty_out (vty, " Conn Retry Timer : %s\n", crtimer); + vty_out (vty, " Hold Timer : %s\n", holdtimer); + vty_out (vty, " Last Reset : %s\n", mp->last_reset); + vty_out (vty, " Conn Attempts : %d\n", mp->conn_attempts); + vty_out (vty, " Established Changes : %d\n", mp->est_flaps); + vty_out (vty, " SA Count : %d\n", mp->sa_cnt); + vty_out (vty, " Statistics :\n"); + vty_out (vty, " Sent Rcvd\n"); + vty_out (vty, " Keepalives : %10d %10d\n", mp->ka_tx_cnt, mp->ka_rx_cnt); - vty_outln (vty, " SAs : %10d %10d", + vty_out (vty, " SAs : %10d %10d\n", mp->sa_tx_cnt, mp->sa_rx_cnt); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -6568,8 +6565,8 @@ ip_msdp_show_sa(struct vty *vty, u_char uj) if (uj) { json = json_object_new_object(); } else { - vty_outln (vty, - "Source Group RP Local SPT Uptime"); + vty_out (vty, + "Source Group RP Local SPT Uptime\n"); } for (ALL_LIST_ELEMENTS_RO(msdp->sa_list, sanode, sa)) { @@ -6610,14 +6607,14 @@ ip_msdp_show_sa(struct vty *vty, u_char uj) json_object_string_add(json_row, "upTime", timebuf); json_object_object_add(json_group, src_str, json_row); } else { - vty_outln (vty, "%-15s %15s %15s %5c %3c %8s", + vty_out (vty, "%-15s %15s %15s %5c %3c %8s\n", src_str, grp_str, rp_str, local_str[0], spt_str[0], timebuf); } } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -6677,14 +6674,14 @@ ip_msdp_show_sa_entry_detail(struct pim_msdp_sa *sa, const char *src_str, json_object_string_add(json_row, "stateTimer", statetimer); json_object_object_add(json_group, src_str, json_row); } else { - vty_outln (vty, "SA : %s", sa->sg_str); - vty_outln (vty, " RP : %s", rp_str); - vty_outln (vty, " Peer : %s", peer_str); - vty_outln (vty, " Local : %s", local_str); - vty_outln (vty, " SPT Setup : %s", spt_str); - vty_outln (vty, " Uptime : %s", timebuf); - vty_outln (vty, " State Timer : %s", statetimer); - vty_out (vty, VTYNL); + vty_out (vty, "SA : %s\n", sa->sg_str); + vty_out (vty, " RP : %s\n", rp_str); + vty_out (vty, " Peer : %s\n", peer_str); + vty_out (vty, " Local : %s\n", local_str); + vty_out (vty, " SPT Setup : %s\n", spt_str); + vty_out (vty, " Uptime : %s\n", timebuf); + vty_out (vty, " State Timer : %s\n", statetimer); + vty_out (vty, "\n"); } } @@ -6708,7 +6705,7 @@ ip_msdp_show_sa_detail(struct vty *vty, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -6752,7 +6749,7 @@ ip_msdp_show_sa_addr(struct vty *vty, const char *addr, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -6780,7 +6777,7 @@ ip_msdp_show_sa_sg(struct vty *vty, const char *src, const char *grp, u_char uj) } if (uj) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c index 71a286981..170692e7f 100644 --- a/pimd/pim_msdp.c +++ b/pimd/pim_msdp.c @@ -1533,14 +1533,14 @@ pim_msdp_config_write(struct vty *vty) if (mg->src_ip.s_addr != INADDR_ANY) { pim_inet4_dump("<src?>", mg->src_ip, src_str, sizeof(src_str)); - vty_outln (vty, "ip msdp mesh-group %s source %s", + vty_out (vty, "ip msdp mesh-group %s source %s\n", mg->mesh_group_name, src_str); ++count; } for (ALL_LIST_ELEMENTS_RO(mg->mbr_list, mbrnode, mbr)) { pim_inet4_dump("<mbr?>", mbr->mbr_ip, mbr_str, sizeof(mbr_str)); - vty_outln (vty, "ip msdp mesh-group %s member %s", + vty_out (vty, "ip msdp mesh-group %s member %s\n", mg->mesh_group_name, mbr_str); ++count; } diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 324541caa..28300dbdf 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -821,11 +821,11 @@ pim_rp_config_write (struct vty *vty) continue; if (rp_info->plist) - vty_outln (vty, "ip pim rp %s prefix-list %s", + vty_out (vty, "ip pim rp %s prefix-list %s\n", inet_ntop(AF_INET, &rp_info->rp.rpf_addr.u.prefix4, rp_buffer, 32), rp_info->plist); else - vty_outln (vty, "ip pim rp %s %s", + vty_out (vty, "ip pim rp %s %s\n", inet_ntop(AF_INET, &rp_info->rp.rpf_addr.u.prefix4, rp_buffer, 32), prefix2str(&rp_info->group, group_buffer, 32)); count++; @@ -878,8 +878,8 @@ pim_rp_show_information (struct vty *vty, u_char uj) if (uj) json = json_object_new_object(); else - vty_outln (vty, - "RP address group/prefix-list OIF I am RP"); + vty_out (vty, + "RP address group/prefix-list OIF I am RP\n"); for (ALL_LIST_ELEMENTS_RO (qpim_rp_list, node, rp_info)) { @@ -931,9 +931,9 @@ pim_rp_show_information (struct vty *vty, u_char uj) vty_out (vty, "%-10s ", "(Unknown)"); if (rp_info->i_am_rp) - vty_outln (vty, "yes"); + vty_out (vty, "yes\n"); else - vty_outln (vty, "no"); + vty_out (vty, "no\n"); } prev_rp_info = rp_info; @@ -944,7 +944,7 @@ pim_rp_show_information (struct vty *vty, u_char uj) if (prev_rp_info && json_rp_rows) json_object_object_add(json, inet_ntoa (prev_rp_info->rp.rpf_addr.u.prefix4), json_rp_rows); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } diff --git a/pimd/pim_static.c b/pimd/pim_static.c index a35bb60f4..d373581fe 100644 --- a/pimd/pim_static.c +++ b/pimd/pim_static.c @@ -337,9 +337,9 @@ pim_static_write_mroute (struct vty *vty, struct interface *ifp) { struct interface *oifp = pim_if_find_by_vif_index (i); if (sroute->source.s_addr == 0) - vty_outln (vty, " ip mroute %s %s", oifp->name, gbuf); + vty_out (vty, " ip mroute %s %s\n", oifp->name, gbuf); else - vty_outln (vty, " ip mroute %s %s %s", oifp->name, gbuf, + vty_out (vty, " ip mroute %s %s %s\n", oifp->name, gbuf, sbuf); count ++; } diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index 5526881d2..81b49c630 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -46,97 +46,97 @@ pim_debug_config_write (struct vty *vty) int writes = 0; if (PIM_DEBUG_MSDP_EVENTS) { - vty_outln (vty, "debug msdp events"); + vty_out (vty, "debug msdp events\n"); ++writes; } if (PIM_DEBUG_MSDP_PACKETS) { - vty_outln (vty, "debug msdp packets"); + vty_out (vty, "debug msdp packets\n"); ++writes; } if (PIM_DEBUG_MSDP_INTERNAL) { - vty_outln (vty, "debug msdp internal"); + vty_out (vty, "debug msdp internal\n"); ++writes; } if (PIM_DEBUG_IGMP_EVENTS) { - vty_outln (vty, "debug igmp events"); + vty_out (vty, "debug igmp events\n"); ++writes; } if (PIM_DEBUG_IGMP_PACKETS) { - vty_outln (vty, "debug igmp packets"); + vty_out (vty, "debug igmp packets\n"); ++writes; } if (PIM_DEBUG_IGMP_TRACE) { - vty_outln (vty, "debug igmp trace"); + vty_out (vty, "debug igmp trace\n"); ++writes; } if (PIM_DEBUG_IGMP_TRACE_DETAIL) { - vty_outln (vty, "debug igmp trace detail"); + vty_out (vty, "debug igmp trace detail\n"); ++writes; } if (PIM_DEBUG_MROUTE) { - vty_outln (vty, "debug mroute"); + vty_out (vty, "debug mroute\n"); ++writes; } if (PIM_DEBUG_MROUTE_DETAIL) { - vty_outln (vty, "debug mroute detail"); + vty_out (vty, "debug mroute detail\n"); ++writes; } if (PIM_DEBUG_PIM_EVENTS) { - vty_outln (vty, "debug pim events"); + vty_out (vty, "debug pim events\n"); ++writes; } if (PIM_DEBUG_PIM_PACKETS) { - vty_outln (vty, "debug pim packets"); + vty_out (vty, "debug pim packets\n"); ++writes; } if (PIM_DEBUG_PIM_PACKETDUMP_SEND) { - vty_outln (vty, "debug pim packet-dump send"); + vty_out (vty, "debug pim packet-dump send\n"); ++writes; } if (PIM_DEBUG_PIM_PACKETDUMP_RECV) { - vty_outln (vty, "debug pim packet-dump receive"); + vty_out (vty, "debug pim packet-dump receive\n"); ++writes; } if (PIM_DEBUG_PIM_TRACE) { - vty_outln (vty, "debug pim trace"); + vty_out (vty, "debug pim trace\n"); ++writes; } if (PIM_DEBUG_PIM_TRACE_DETAIL) { - vty_outln (vty, "debug pim trace detail"); + vty_out (vty, "debug pim trace detail\n"); ++writes; } if (PIM_DEBUG_ZEBRA) { - vty_outln (vty, "debug pim zebra"); + vty_out (vty, "debug pim zebra\n"); ++writes; } if (PIM_DEBUG_SSMPINGD) { - vty_outln (vty, "debug ssmpingd"); + vty_out (vty, "debug ssmpingd\n"); ++writes; } if (PIM_DEBUG_PIM_HELLO) { - vty_outln (vty, "debug pim packets hello"); + vty_out (vty, "debug pim packets hello\n"); ++writes; } if (PIM_DEBUG_PIM_J_P) { - vty_outln (vty, "debug pim packets joins"); + vty_out (vty, "debug pim packets joins\n"); ++writes; } if (PIM_DEBUG_PIM_REG) { - vty_outln (vty, "debug pim packets register"); + vty_out (vty, "debug pim packets register\n"); ++writes; } if (PIM_DEBUG_STATIC) { - vty_outln (vty, "debug pim static"); + vty_out (vty, "debug pim static\n"); ++writes; } @@ -152,7 +152,7 @@ int pim_global_config_write(struct vty *vty) if (!pimg->send_v6_secondary) { - vty_outln (vty, "no ip pim send-v6-secondary"); + vty_out (vty, "no ip pim send-v6-secondary\n"); ++writes; } @@ -160,62 +160,62 @@ int pim_global_config_write(struct vty *vty) if (qpim_register_suppress_time != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) { - vty_outln (vty, "ip pim register-suppress-time %d", + vty_out (vty, "ip pim register-suppress-time %d\n", qpim_register_suppress_time); ++writes; } if (qpim_t_periodic != PIM_DEFAULT_T_PERIODIC) { - vty_outln (vty, "ip pim join-prune-interval %d", + vty_out (vty, "ip pim join-prune-interval %d\n", qpim_t_periodic); ++writes; } if (qpim_keep_alive_time != PIM_KEEPALIVE_PERIOD) { - vty_outln (vty, "ip pim keep-alive-timer %d", + vty_out (vty, "ip pim keep-alive-timer %d\n", qpim_keep_alive_time); ++writes; } if (qpim_packet_process != PIM_DEFAULT_PACKET_PROCESS) { - vty_outln (vty, "ip pim packets %d", + vty_out (vty, "ip pim packets %d\n", qpim_packet_process); ++writes; } if (ssm->plist_name) { - vty_outln (vty, "ip pim ssm prefix-list %s", + vty_out (vty, "ip pim ssm prefix-list %s\n", ssm->plist_name); ++writes; } if (pimg->spt.switchover == PIM_SPT_INFINITY) { if (pimg->spt.plist) - vty_outln (vty, "ip pim spt-switchover infinity-and-beyond prefix-list %s", + vty_out (vty, "ip pim spt-switchover infinity-and-beyond prefix-list %s\n", pimg->spt.plist); else - vty_outln (vty,"ip pim spt-switchover infinity-and-beyond"); + vty_out (vty,"ip pim spt-switchover infinity-and-beyond\n"); ++writes; } if (qpim_ecmp_rebalance_enable) { - vty_outln (vty, "ip pim ecmp rebalance"); + vty_out (vty, "ip pim ecmp rebalance\n"); ++writes; } else if (qpim_ecmp_enable) { - vty_outln (vty, "ip pim ecmp"); + vty_out (vty, "ip pim ecmp\n"); ++writes; } if (qpim_ssmpingd_list) { struct listnode *node; struct ssmpingd_sock *ss; - vty_outln (vty, "!"); + vty_out (vty, "!\n"); ++writes; for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) { char source_str[INET_ADDRSTRLEN]; pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str)); - vty_outln (vty, "ip ssmpingd %s", source_str); + vty_out (vty, "ip ssmpingd %s\n", source_str); ++writes; } } @@ -232,20 +232,20 @@ int pim_interface_config_write(struct vty *vty) for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { /* IF name */ - vty_outln (vty, "interface %s", ifp->name); + vty_out (vty, "interface %s\n", ifp->name); ++writes; if (ifp->info) { struct pim_interface *pim_ifp = ifp->info; if (PIM_IF_TEST_PIM(pim_ifp->options)) { - vty_outln (vty, " ip pim sm"); + vty_out (vty, " ip pim sm\n"); ++writes; } /* IF ip pim drpriority */ if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) { - vty_outln (vty, " ip pim drpriority %u",pim_ifp->pim_dr_priority); + vty_out (vty, " ip pim drpriority %u\n",pim_ifp->pim_dr_priority); ++writes; } @@ -254,7 +254,7 @@ int pim_interface_config_write(struct vty *vty) vty_out(vty, " ip pim hello %d", pim_ifp->pim_hello_period); if (pim_ifp->pim_default_holdtime != -1) vty_out(vty, " %d", pim_ifp->pim_default_holdtime); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* update source */ @@ -262,20 +262,20 @@ int pim_interface_config_write(struct vty *vty) char src_str[INET_ADDRSTRLEN]; pim_inet4_dump("<src?>", pim_ifp->update_source, src_str, sizeof(src_str)); - vty_outln (vty, " ip pim use-source %s", src_str); + vty_out (vty, " ip pim use-source %s\n", src_str); ++writes; } /* IF ip igmp */ if (PIM_IF_TEST_IGMP(pim_ifp->options)) { - vty_outln (vty, " ip igmp"); + vty_out (vty, " ip igmp\n"); ++writes; } /* ip igmp version */ if (pim_ifp->igmp_version != IGMP_DEFAULT_VERSION) { - vty_outln (vty, " ip igmp version %d", + vty_out (vty, " ip igmp version %d\n", pim_ifp->igmp_version); ++writes; } @@ -283,7 +283,7 @@ int pim_interface_config_write(struct vty *vty) /* IF ip igmp query-interval */ if (pim_ifp->igmp_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL) { - vty_outln (vty, " ip igmp query-interval %d", + vty_out (vty, " ip igmp query-interval %d\n", pim_ifp->igmp_default_query_interval); ++writes; } @@ -291,7 +291,7 @@ int pim_interface_config_write(struct vty *vty) /* IF ip igmp query-max-response-time */ if (pim_ifp->igmp_query_max_response_time_dsec != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) { - vty_outln (vty, " ip igmp query-max-response-time %d", + vty_out (vty, " ip igmp query-max-response-time %d\n", pim_ifp->igmp_query_max_response_time_dsec); ++writes; } @@ -305,7 +305,7 @@ int pim_interface_config_write(struct vty *vty) char source_str[INET_ADDRSTRLEN]; pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str)); inet_ntop(AF_INET, &ij->source_addr, source_str, sizeof(source_str)); - vty_outln (vty, " ip igmp join %s %s", + vty_out (vty, " ip igmp join %s %s\n", group_str,source_str); ++writes; } @@ -313,7 +313,7 @@ int pim_interface_config_write(struct vty *vty) writes += pim_static_write_mroute (vty, ifp); } - vty_outln (vty, "!"); + vty_out (vty, "!\n"); ++writes; /* PIM BFD write */ pim_bfd_write_config (vty, ifp); diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 908c0a1f8..b4fff9712 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -1151,11 +1151,11 @@ pim_zebra_zclient_update (struct vty *vty) vty_out(vty, "Zclient update socket: "); if (zclient) { - vty_outln (vty, "%d failures=%d", zclient->sock, + vty_out (vty, "%d failures=%d\n", zclient->sock, zclient->fail); } else { - vty_outln (vty, "<null zclient>"); + vty_out (vty, "<null zclient>\n"); } } diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index e7ffe0f4a..f405a39c9 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -439,11 +439,11 @@ pim_zlookup_show_ip_multicast (struct vty *vty) { vty_out(vty, "Zclient lookup socket: "); if (zlookup) { - vty_outln (vty, "%d failures=%d", zlookup->sock, + vty_out (vty, "%d failures=%d\n", zlookup->sock, zlookup->fail); } else { - vty_outln (vty, "<null zclient>"); + vty_out (vty, "<null zclient>\n"); } } diff --git a/python/clidef.py b/python/clidef.py index 1bf3c24aa..069d80fb7 100644 --- a/python/clidef.py +++ b/python/clidef.py @@ -142,7 +142,7 @@ $argdecls continue; _fail = 0;$argblocks if (_fail) - vty_outln (vty, "%% invalid input for %s: %s", + vty_out (vty, "%% invalid input for %s: %s\\n", argv[_i]->varname, argv[_i]->arg); _failcnt += _fail; } diff --git a/redhat/daemons b/redhat/daemons index e08302cb5..94d6c72c3 100644 --- a/redhat/daemons +++ b/redhat/daemons @@ -45,8 +45,10 @@ ripd=no ripngd=no isisd=no ldpd=no +pimd=no nhrpd=no eigrpd=no +babeld=no # # Command line options for the daemons # @@ -58,6 +60,8 @@ ripd_options=("-A 127.0.0.1") ripngd_options=("-A ::1") isisd_options=("-A 127.0.0.1") ldpd_options=("-A 127.0.0.1") +pimd_options=("-A 127.0.0.1") nhrpd_options=("-A 127.0.0.1") eigrpd_options=("-A 127.0.0.1") +babeld_options=("-A 127.0.0.1") diff --git a/redhat/frr.init b/redhat/frr.init index 0a922aab5..cf01e4c6e 100755 --- a/redhat/frr.init +++ b/redhat/frr.init @@ -33,7 +33,7 @@ V_PATH=/var/run/frr # Local Daemon selection may be done by using /etc/frr/daemons. # See /usr/share/doc/frr/README.Debian.gz for further information. # Keep zebra first and do not list watchfrr! -DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd pimd ldpd nhrpd eigrpd" +DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd pimd ldpd nhrpd eigrpd babeld" MAX_INSTANCES=5 RELOAD_SCRIPT=/usr/lib/frr/frr-reload.py diff --git a/ripd/rip_debug.c b/ripd/rip_debug.c index 775fe3879..04252a85f 100644 --- a/ripd/rip_debug.c +++ b/ripd/rip_debug.c @@ -34,28 +34,28 @@ DEFUN (show_debugging_rip, DEBUG_STR RIP_STR) { - vty_outln (vty, "RIP debugging status:"); + vty_out (vty, "RIP debugging status:\n"); if (IS_RIP_DEBUG_EVENT) - vty_outln (vty, " RIP event debugging is on"); + vty_out (vty, " RIP event debugging is on\n"); if (IS_RIP_DEBUG_PACKET) { if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) { - vty_outln (vty," RIP packet debugging is on"); + vty_out (vty," RIP packet debugging is on\n"); } else { if (IS_RIP_DEBUG_SEND) - vty_outln (vty," RIP packet send debugging is on"); + vty_out (vty," RIP packet send debugging is on\n"); else - vty_outln (vty," RIP packet receive debugging is on"); + vty_out (vty," RIP packet receive debugging is on\n"); } } if (IS_RIP_DEBUG_ZEBRA) - vty_outln (vty, " RIP zebra debugging is on"); + vty_out (vty, " RIP zebra debugging is on\n"); return CMD_SUCCESS; } @@ -68,7 +68,7 @@ DEFUN (debug_rip_events, "RIP events\n") { rip_debug_event = RIP_DEBUG_EVENT; - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (debug_rip_packet, @@ -110,7 +110,7 @@ DEFUN (debug_rip_zebra, "RIP and ZEBRA communication\n") { rip_debug_zebra = RIP_DEBUG_ZEBRA; - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (no_debug_rip_events, @@ -174,7 +174,7 @@ DEFUN (no_debug_rip_zebra, "RIP and ZEBRA communication\n") { rip_debug_zebra = 0; - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Debug node. */ @@ -192,28 +192,28 @@ config_write_debug (struct vty *vty) if (IS_RIP_DEBUG_EVENT) { - vty_outln (vty, "debug rip events"); + vty_out (vty, "debug rip events\n"); write++; } if (IS_RIP_DEBUG_PACKET) { if (IS_RIP_DEBUG_SEND && IS_RIP_DEBUG_RECV) { - vty_outln (vty,"debug rip packet"); + vty_out (vty,"debug rip packet\n"); write++; } else { if (IS_RIP_DEBUG_SEND) - vty_outln (vty,"debug rip packet send"); + vty_out (vty,"debug rip packet send\n"); else - vty_outln (vty,"debug rip packet recv"); + vty_out (vty,"debug rip packet recv\n"); write++; } } if (IS_RIP_DEBUG_ZEBRA) { - vty_outln (vty, "debug rip zebra"); + vty_out (vty, "debug rip zebra\n"); write++; } return write; diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 4ce1b9b65..357856e1e 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -1168,7 +1168,7 @@ static int rip_passive_nondefault_set (struct vty *vty, const char *ifname) { if (rip_passive_nondefault_lookup (ifname) >= 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; vector_set (Vrip_passive_nondefault, strdup (ifname)); @@ -1185,7 +1185,7 @@ rip_passive_nondefault_unset (struct vty *vty, const char *ifname) i = rip_passive_nondefault_lookup (ifname); if (i < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; str = vector_slot (Vrip_passive_nondefault, i); free (str); @@ -1233,9 +1233,9 @@ DEFUN (rip_network, if (ret < 0) { - vty_outln (vty, "There is a same network configuration %s", + vty_out (vty, "There is a same network configuration %s\n", argv[idx_ipv4_word]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -1263,9 +1263,9 @@ DEFUN (no_rip_network, if (ret < 0) { - vty_outln (vty, "Can't find network configuration %s", + vty_out (vty, "Can't find network configuration %s\n", argv[idx_ipv4_word]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -1286,8 +1286,8 @@ DEFUN (rip_neighbor, if (ret <= 0) { - vty_outln (vty, "Please specify address by A.B.C.D"); - return CMD_WARNING; + vty_out (vty, "Please specify address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } rip_neighbor_add (&p); @@ -1311,8 +1311,8 @@ DEFUN (no_rip_neighbor, if (ret <= 0) { - vty_outln (vty, "Please specify address by A.B.C.D"); - return CMD_WARNING; + vty_out (vty, "Please specify address by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } rip_neighbor_delete (&p); @@ -1351,7 +1351,7 @@ DEFUN (ip_rip_receive_version, break; } - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (ip_rip_receive_version_1, @@ -1422,7 +1422,7 @@ DEFUN (ip_rip_send_version, ri->ri_send = RI_RIP_VERSION_2; return CMD_SUCCESS; } - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (ip_rip_send_version_1, @@ -1534,8 +1534,8 @@ DEFUN (ip_rip_authentication_mode, { if (auth_type != RIP_AUTH_MD5) { - vty_outln (vty, "auth length argument only valid for md5"); - return CMD_WARNING; + vty_out (vty, "auth length argument only valid for md5\n"); + return CMD_WARNING_CONFIG_FAILED; } if (strmatch ("rfc", authlen)) ri->md5_auth_len = RIP_AUTH_MD5_SIZE; @@ -1591,15 +1591,15 @@ DEFUN (ip_rip_authentication_string, if (strlen (argv[idx_line]->arg) > 16) { - vty_outln (vty, - "%% RIPv2 authentication string must be shorter than 16"); - return CMD_WARNING; + vty_out (vty, + "%% RIPv2 authentication string must be shorter than 16\n"); + return CMD_WARNING_CONFIG_FAILED; } if (ri->key_chain) { - vty_outln (vty, "%% key-chain configuration exists"); - return CMD_WARNING; + vty_out (vty, "%% key-chain configuration exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (ri->auth_str) @@ -1651,8 +1651,8 @@ DEFUN (ip_rip_authentication_key_chain, if (ri->auth_str) { - vty_outln (vty,"%% authentication string configuration exists"); - return CMD_WARNING; + vty_out (vty,"%% authentication string configuration exists\n"); + return CMD_WARNING_CONFIG_FAILED; } if (ri->key_chain) @@ -1837,43 +1837,43 @@ rip_interface_config_write (struct vty *vty) (!ri->key_chain) ) continue; - vty_outln (vty, "interface %s",ifp->name); + vty_out (vty, "interface %s\n",ifp->name); if (ifp->desc) - vty_outln (vty, " description %s",ifp->desc); + vty_out (vty, " description %s\n",ifp->desc); /* Split horizon. */ if (ri->split_horizon != ri->split_horizon_default) { switch (ri->split_horizon) { case RIP_SPLIT_HORIZON: - vty_outln (vty, " ip rip split-horizon"); + vty_out (vty, " ip rip split-horizon\n"); break; case RIP_SPLIT_HORIZON_POISONED_REVERSE: - vty_outln (vty," ip rip split-horizon poisoned-reverse"); + vty_out (vty," ip rip split-horizon poisoned-reverse\n"); break; case RIP_NO_SPLIT_HORIZON: default: - vty_outln (vty, " no ip rip split-horizon"); + vty_out (vty, " no ip rip split-horizon\n"); break; } } /* RIP version setting. */ if (ri->ri_send != RI_RIP_UNSPEC) - vty_outln (vty, " ip rip send version %s", + vty_out (vty, " ip rip send version %s\n", lookup_msg(ri_version_msg, ri->ri_send, NULL)); if (ri->ri_receive != RI_RIP_UNSPEC) - vty_outln (vty, " ip rip receive version %s ", + vty_out (vty, " ip rip receive version %s \n", lookup_msg(ri_version_msg, ri->ri_receive, NULL)); if (ri->v2_broadcast) - vty_outln (vty, " ip rip v2-broadcast"); + vty_out (vty, " ip rip v2-broadcast\n"); /* RIP authentication. */ if (ri->auth_type == RIP_AUTH_SIMPLE_PASSWORD) - vty_outln (vty, " ip rip authentication mode text"); + vty_out (vty, " ip rip authentication mode text\n"); if (ri->auth_type == RIP_AUTH_MD5) { @@ -1882,18 +1882,18 @@ rip_interface_config_write (struct vty *vty) vty_out (vty, " auth-length old-ripd"); else vty_out (vty, " auth-length rfc"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (ri->auth_str) - vty_outln (vty, " ip rip authentication string %s", + vty_out (vty, " ip rip authentication string %s\n", ri->auth_str); if (ri->key_chain) - vty_outln (vty, " ip rip authentication key-chain %s", + vty_out (vty, " ip rip authentication key-chain %s\n", ri->key_chain); - vty_outln (vty, "!"); + vty_out (vty, "!\n"); } return 0; } @@ -1908,7 +1908,7 @@ config_write_rip_network (struct vty *vty, int config_mode) /* Network type RIP enable interface statement. */ for (node = route_top (rip_enable_network); node; node = route_next (node)) if (node->info) - vty_outln (vty, "%s%s/%d", + vty_out (vty, "%s%s/%d\n", config_mode ? " network " : " ", inet_ntoa (node->p.u.prefix4), node->p.prefixlen); @@ -1916,24 +1916,24 @@ config_write_rip_network (struct vty *vty, int config_mode) /* Interface name RIP enable statement. */ for (i = 0; i < vector_active (rip_enable_interface); i++) if ((ifname = vector_slot (rip_enable_interface, i)) != NULL) - vty_outln (vty, "%s%s", + vty_out (vty, "%s%s\n", config_mode ? " network " : " ", ifname); /* RIP neighbors listing. */ for (node = route_top (rip->neighbor); node; node = route_next (node)) if (node->info) - vty_outln (vty, "%s%s", + vty_out (vty, "%s%s\n", config_mode ? " neighbor " : " ", inet_ntoa(node->p.u.prefix4)); /* RIP passive interface listing. */ if (config_mode) { if (passive_default) - vty_outln (vty, " passive-interface default"); + vty_out (vty, " passive-interface default\n"); for (i = 0; i < vector_active (Vrip_passive_nondefault); i++) if ((ifname = vector_slot (Vrip_passive_nondefault, i)) != NULL) - vty_outln (vty, " %spassive-interface %s", + vty_out (vty, " %spassive-interface %s\n", (passive_default ? "no " : ""), ifname); } diff --git a/ripd/rip_offset.c b/ripd/rip_offset.c index c047bb776..63f93d139 100644 --- a/ripd/rip_offset.c +++ b/ripd/rip_offset.c @@ -117,16 +117,16 @@ rip_offset_list_set (struct vty *vty, const char *alist, const char *direct_str, direct = RIP_OFFSET_LIST_OUT; else { - vty_outln (vty, "Invalid direction: %s", direct_str); - return CMD_WARNING; + vty_out (vty, "Invalid direction: %s\n", direct_str); + return CMD_WARNING_CONFIG_FAILED; } /* Check metric. */ metric = atoi (metric_str); if (metric < 0 || metric > 16) { - vty_outln (vty, "Invalid metric: %s", metric_str); - return CMD_WARNING; + vty_out (vty, "Invalid metric: %s\n", metric_str); + return CMD_WARNING_CONFIG_FAILED; } /* Get offset-list structure with interface name. */ @@ -156,16 +156,16 @@ rip_offset_list_unset (struct vty *vty, const char *alist, direct = RIP_OFFSET_LIST_OUT; else { - vty_outln (vty, "Invalid direction: %s", direct_str); - return CMD_WARNING; + vty_out (vty, "Invalid direction: %s\n", direct_str); + return CMD_WARNING_CONFIG_FAILED; } /* Check metric. */ metric = atoi (metric_str); if (metric < 0 || metric > 16) { - vty_outln (vty, "Invalid metric: %s", metric_str); - return CMD_WARNING; + vty_out (vty, "Invalid metric: %s\n", metric_str); + return CMD_WARNING_CONFIG_FAILED; } /* Get offset-list structure with interface name. */ @@ -188,8 +188,8 @@ rip_offset_list_unset (struct vty *vty, const char *alist, } else { - vty_outln (vty, "Can't find offset-list"); - return CMD_WARNING; + vty_out (vty, "Can't find offset-list\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -397,23 +397,23 @@ config_write_rip_offset_list (struct vty *vty) if (! offset->ifname) { if (offset->direct[RIP_OFFSET_LIST_IN].alist_name) - vty_outln (vty, " offset-list %s in %d", + vty_out (vty, " offset-list %s in %d\n", offset->direct[RIP_OFFSET_LIST_IN].alist_name, offset->direct[RIP_OFFSET_LIST_IN].metric); if (offset->direct[RIP_OFFSET_LIST_OUT].alist_name) - vty_outln (vty, " offset-list %s out %d", + vty_out (vty, " offset-list %s out %d\n", offset->direct[RIP_OFFSET_LIST_OUT].alist_name, offset->direct[RIP_OFFSET_LIST_OUT].metric); } else { if (offset->direct[RIP_OFFSET_LIST_IN].alist_name) - vty_outln (vty, " offset-list %s in %d %s", + vty_out (vty, " offset-list %s in %d %s\n", offset->direct[RIP_OFFSET_LIST_IN].alist_name, offset->direct[RIP_OFFSET_LIST_IN].metric, offset->ifname); if (offset->direct[RIP_OFFSET_LIST_OUT].alist_name) - vty_outln (vty, " offset-list %s out %d %s", + vty_out (vty, " offset-list %s out %d %s\n", offset->direct[RIP_OFFSET_LIST_OUT].alist_name, offset->direct[RIP_OFFSET_LIST_OUT].metric, offset->ifname); diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c index 636aa80a9..7f494a098 100644 --- a/ripd/rip_peer.c +++ b/ripd/rip_peer.c @@ -185,7 +185,7 @@ rip_peer_display (struct vty *vty) for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer)) { - vty_outln (vty, " %-16s %9d %9d %9d %s", inet_ntoa (peer->addr), + vty_out (vty, " %-16s %9d %9d %9d %s\n", inet_ntoa (peer->addr), peer->recv_badpackets, peer->recv_badroutes, ZEBRA_RIP_DISTANCE_DEFAULT, rip_peer_uptime(peer, timebuf, RIP_UPTIME_LEN)); diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 31204872a..dffa9db7c 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -347,9 +347,9 @@ DEFUN (rip_redistribute_type, } } - vty_outln (vty, "Invalid type %s",argv[1]->arg); + vty_out (vty, "Invalid type %s\n",argv[1]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (no_rip_redistribute_type, @@ -373,9 +373,9 @@ DEFUN (no_rip_redistribute_type, } } - vty_outln (vty, "Invalid type %s",argv[2]->arg); + vty_out (vty, "Invalid type %s\n",argv[2]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (rip_redistribute_type_routemap, @@ -400,9 +400,9 @@ DEFUN (rip_redistribute_type_routemap, } } - vty_outln (vty, "Invalid type %s", argv[idx_protocol]->text); + vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (no_rip_redistribute_type_routemap, @@ -422,15 +422,15 @@ DEFUN (no_rip_redistribute_type_routemap, if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) { if (rip_routemap_unset (redist_type[i].type,argv[idx_word]->arg)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; rip_redistribute_unset (redist_type[i].type); return CMD_SUCCESS; } } - vty_outln (vty, "Invalid type %s", argv[idx_protocol]->text); + vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (rip_redistribute_type_metric, @@ -458,9 +458,9 @@ DEFUN (rip_redistribute_type_metric, } } - vty_outln (vty, "Invalid type %s", argv[idx_protocol]->text); + vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (no_rip_redistribute_type_metric, @@ -480,15 +480,15 @@ DEFUN (no_rip_redistribute_type_metric, if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) { if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; rip_redistribute_unset (redist_type[i].type); return CMD_SUCCESS; } } - vty_outln (vty, "Invalid type %s", argv[idx_protocol]->text); + vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (rip_redistribute_type_metric_routemap, @@ -520,9 +520,9 @@ DEFUN (rip_redistribute_type_metric_routemap, } } - vty_outln (vty, "Invalid type %s", argv[idx_protocol]->text); + vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } @@ -546,20 +546,20 @@ DEFUN (no_rip_redistribute_type_metric_routemap, if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) { if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg)) { rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } rip_redistribute_unset (redist_type[i].type); return CMD_SUCCESS; } } - vty_outln (vty, "Invalid type %s", argv[idx_protocol]->text); + vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Default information originate. */ @@ -614,13 +614,13 @@ config_write_zebra (struct vty *vty) { if (! zclient->enable) { - vty_outln (vty, "no router zebra"); + vty_out (vty, "no router zebra\n"); return 1; } else if (! vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP], VRF_DEFAULT)) { - vty_outln (vty, "router zebra"); - vty_outln (vty, " no redistribute rip"); + vty_out (vty, "router zebra\n"); + vty_out (vty, " no redistribute rip\n"); return 1; } return 0; @@ -640,20 +640,20 @@ config_write_rip_redistribute (struct vty *vty, int config_mode) if (rip->route_map[i].metric_config) { if (rip->route_map[i].name) - vty_outln (vty, " redistribute %s metric %d route-map %s", + vty_out (vty, " redistribute %s metric %d route-map %s\n", zebra_route_string(i), rip->route_map[i].metric, rip->route_map[i].name); else - vty_outln (vty, " redistribute %s metric %d", + vty_out (vty, " redistribute %s metric %d\n", zebra_route_string(i),rip->route_map[i].metric); } else { if (rip->route_map[i].name) - vty_outln (vty, " redistribute %s route-map %s", + vty_out (vty, " redistribute %s route-map %s\n", zebra_route_string(i),rip->route_map[i].name); else - vty_outln (vty, " redistribute %s",zebra_route_string(i)); + vty_out (vty, " redistribute %s\n",zebra_route_string(i)); } } else diff --git a/ripd/ripd.c b/ripd/ripd.c index c07831fdd..8578dc3d2 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -2815,7 +2815,7 @@ DEFUN_NOSH (router_rip, if (ret < 0) { zlog_info ("Can't create RIP"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } VTY_PUSH_CONTEXT(RIP_NODE, rip); @@ -2847,8 +2847,8 @@ DEFUN (rip_version, version = atoi (argv[idx_number]->arg); if (version != RIPv1 && version != RIPv2) { - vty_outln (vty, "invalid rip version %d",version); - return CMD_WARNING; + vty_out (vty, "invalid rip version %d\n",version); + return CMD_WARNING_CONFIG_FAILED; } rip->version_send = version; rip->version_recv = version; @@ -2885,8 +2885,8 @@ DEFUN (rip_route, ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret < 0) { - vty_outln (vty, "Malformed address"); - return CMD_WARNING; + vty_out (vty, "Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask_ipv4 (&p); @@ -2895,9 +2895,9 @@ DEFUN (rip_route, if (node->info) { - vty_outln (vty, "There is already same static route."); + vty_out (vty, "There is already same static route.\n"); route_unlock_node (node); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } node->info = (void *)1; @@ -2922,8 +2922,8 @@ DEFUN (no_rip_route, ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret < 0) { - vty_outln (vty, "Malformed address"); - return CMD_WARNING; + vty_out (vty, "Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask_ipv4 (&p); @@ -2931,8 +2931,8 @@ DEFUN (no_rip_route, node = route_node_lookup (rip->route, (struct prefix *) &p); if (! node) { - vty_outln (vty, "Can't find route %s.",argv[idx_ipv4_prefixlen]->arg); - return CMD_WARNING; + vty_out (vty, "Can't find route %s.\n",argv[idx_ipv4_prefixlen]->arg); + return CMD_WARNING_CONFIG_FAILED; } rip_redistribute_delete (ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0); @@ -3014,22 +3014,22 @@ DEFUN (rip_timers, update = strtoul (argv[idx_number]->arg, &endptr, 10); if (update > RIP_TIMER_MAX || update < RIP_TIMER_MIN || *endptr != '\0') { - vty_outln (vty, "update timer value error"); - return CMD_WARNING; + vty_out (vty, "update timer value error\n"); + return CMD_WARNING_CONFIG_FAILED; } timeout = strtoul (argv[idx_number_2]->arg, &endptr, 10); if (timeout > RIP_TIMER_MAX || timeout < RIP_TIMER_MIN || *endptr != '\0') { - vty_outln (vty, "timeout timer value error"); - return CMD_WARNING; + vty_out (vty, "timeout timer value error\n"); + return CMD_WARNING_CONFIG_FAILED; } garbage = strtoul (argv[idx_number_3]->arg, &endptr, 10); if (garbage > RIP_TIMER_MAX || garbage < RIP_TIMER_MIN || *endptr != '\0') { - vty_outln (vty, "garbage timer value error"); - return CMD_WARNING; + vty_out (vty, "garbage timer value error\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Set each timer value. */ @@ -3102,8 +3102,8 @@ rip_distance_set (struct vty *vty, const char *distance_str, const char *ip_str, ret = str2prefix_ipv4 (ip_str, &p); if (ret == 0) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } distance = atoi (distance_str); @@ -3148,15 +3148,15 @@ rip_distance_unset (struct vty *vty, const char *distance_str, ret = str2prefix_ipv4 (ip_str, &p); if (ret == 0) { - vty_outln (vty, "Malformed prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } rn = route_node_lookup (rip_distance_table, (struct prefix *)&p); if (! rn) { - vty_outln (vty, "Can't find specified prefix"); - return CMD_WARNING; + vty_out (vty, "Can't find specified prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } rdistance = rn->info; @@ -3241,7 +3241,7 @@ rip_distance_show (struct vty *vty) int header = 1; char buf[BUFSIZ]; - vty_outln (vty, " Distance: (default is %d)", + vty_out (vty, " Distance: (default is %d)\n", rip->distance ? rip->distance : ZEBRA_RIP_DISTANCE_DEFAULT); for (rn = route_top (rip_distance_table); rn; rn = route_next (rn)) @@ -3249,11 +3249,11 @@ rip_distance_show (struct vty *vty) { if (header) { - vty_outln (vty," Address Distance List"); + vty_out (vty," Address Distance List\n"); header = 0; } sprintf (buf, "%s/%d", inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); - vty_outln (vty, " %-20s %4d %s", + vty_out (vty, " %-20s %4d %s\n", buf, rdistance->distance, rdistance->access_list ? rdistance->access_list : ""); } @@ -3386,8 +3386,8 @@ DEFUN (rip_allow_ecmp, { if (rip->ecmp) { - vty_outln (vty, "ECMP is already enabled."); - return CMD_WARNING; + vty_out (vty, "ECMP is already enabled.\n"); + return CMD_WARNING_CONFIG_FAILED; } rip->ecmp = 1; @@ -3403,8 +3403,8 @@ DEFUN (no_rip_allow_ecmp, { if (!rip->ecmp) { - vty_outln (vty, "ECMP is already disabled."); - return CMD_WARNING; + vty_out (vty, "ECMP is already disabled.\n"); + return CMD_WARNING_CONFIG_FAILED; } rip->ecmp = 0; @@ -3474,12 +3474,11 @@ DEFUN (show_ip_rip, if (! rip) return CMD_SUCCESS; - vty_outln (vty, "Codes: R - RIP, C - connected, S - Static, O - OSPF, B - BGP%s" - "Sub-codes:%s" - " (n) - normal, (s) - static, (d) - default, (r) - redistribute,%s" - " (i) - interface%s%s" - " Network Next Hop Metric From Tag Time", - VTYNL, VTYNL, VTYNL, VTYNL, VTYNL); + vty_out (vty, "Codes: R - RIP, C - connected, S - Static, O - OSPF, B - BGP\n" + "Sub-codes:\n" + " (n) - normal, (s) - static, (d) - default, (r) - redistribute,\n" + " (i) - interface\n\n" + " Network Next Hop Metric From Tag Time\n"); for (np = route_top (rip->table); np; np = route_next (np)) if ((list = np->info) != NULL) @@ -3534,7 +3533,7 @@ DEFUN (show_ip_rip, vty_out (vty, "%3"ROUTE_TAG_PRI, (route_tag_t)rinfo->tag); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } return CMD_SUCCESS; } @@ -3558,35 +3557,35 @@ DEFUN (show_ip_rip_status, if (! rip) return CMD_SUCCESS; - vty_outln (vty, "Routing Protocol is \"rip\""); + vty_out (vty, "Routing Protocol is \"rip\"\n"); vty_out (vty, " Sending updates every %ld seconds with +/-50%%,", rip->update_time); - vty_outln (vty, " next due in %lu seconds", + vty_out (vty, " next due in %lu seconds\n", thread_timer_remain_second(rip->t_update)); vty_out (vty, " Timeout after %ld seconds,", rip->timeout_time); - vty_outln (vty, " garbage collect after %ld seconds",rip->garbage_time); + vty_out (vty, " garbage collect after %ld seconds\n",rip->garbage_time); /* Filtering status show. */ config_show_distribute (vty); /* Default metric information. */ - vty_outln (vty, " Default redistribution metric is %d", + vty_out (vty, " Default redistribution metric is %d\n", rip->default_metric); /* Redistribute information. */ vty_out (vty, " Redistributing:"); config_write_rip_redistribute (vty, 0); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, " Default version control: send version %s,", lookup_msg(ri_version_msg,rip->version_send, NULL)); if (rip->version_recv == RI_RIP_VERSION_1_AND_2) - vty_outln (vty, " receive any version "); + vty_out (vty, " receive any version \n"); else - vty_outln (vty, " receive version %s ", + vty_out (vty, " receive version %s \n", lookup_msg(ri_version_msg,rip->version_recv, NULL)); - vty_outln (vty, " Interface Send Recv Key-chain"); + vty_out (vty, " Interface Send Recv Key-chain\n"); for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { @@ -3607,14 +3606,14 @@ DEFUN (show_ip_rip_status, else receive_version = lookup_msg(ri_version_msg, ri->ri_receive, NULL); - vty_outln (vty, " %-17s%-3s %-3s %s", ifp->name, + vty_out (vty, " %-17s%-3s %-3s %s\n", ifp->name, send_version, receive_version, ri->key_chain ? ri->key_chain : ""); } } - vty_outln (vty, " Routing for Networks:"); + vty_out (vty, " Routing for Networks:\n"); config_write_rip_network (vty, 0); { @@ -3627,17 +3626,17 @@ DEFUN (show_ip_rip_status, { if (!found_passive) { - vty_outln (vty, " Passive Interface(s):"); + vty_out (vty, " Passive Interface(s):\n"); found_passive = 1; } - vty_outln (vty, " %s", ifp->name); + vty_out (vty, " %s\n", ifp->name); } } } - vty_outln (vty, " Routing Information Sources:"); - vty_outln (vty, - " Gateway BadPackets BadRoutes Distance Last Update"); + vty_out (vty, " Routing Information Sources:\n"); + vty_out (vty, + " Gateway BadPackets BadRoutes Distance Last Update\n"); rip_peer_display (vty); rip_distance_show (vty); @@ -3656,19 +3655,19 @@ config_write_rip (struct vty *vty) if (rip) { /* Router RIP statement. */ - vty_outln (vty, "router rip"); + vty_out (vty, "router rip\n"); write++; /* RIP version statement. Default is RIP version 2. */ if (rip->version_send != RI_RIP_VERSION_2 || rip->version_recv != RI_RIP_VERSION_1_AND_2) - vty_outln (vty, " version %d",rip->version_send); + vty_out (vty, " version %d\n",rip->version_send); /* RIP timer configuration. */ if (rip->update_time != RIP_UPDATE_TIMER_DEFAULT || rip->timeout_time != RIP_TIMEOUT_TIMER_DEFAULT || rip->garbage_time != RIP_GARBAGE_TIMER_DEFAULT) - vty_outln (vty, " timers basic %lu %lu %lu", + vty_out (vty, " timers basic %lu %lu %lu\n", rip->update_time, rip->timeout_time, rip->garbage_time); @@ -3677,10 +3676,10 @@ config_write_rip (struct vty *vty) if (rip->default_information) { if (rip->default_information_route_map) - vty_outln (vty, " default-information originate route-map %s", + vty_out (vty, " default-information originate route-map %s\n", rip->default_information_route_map); else - vty_outln (vty," default-information originate"); + vty_out (vty," default-information originate\n"); } /* Redistribute configuration. */ @@ -3694,7 +3693,7 @@ config_write_rip (struct vty *vty) /* RIP default metric configuration */ if (rip->default_metric != RIP_DEFAULT_METRIC_DEFAULT) - vty_outln (vty, " default-metric %d", + vty_out (vty, " default-metric %d\n", rip->default_metric); /* Distribute configuration. */ @@ -3705,23 +3704,23 @@ config_write_rip (struct vty *vty) /* Distance configuration. */ if (rip->distance) - vty_outln (vty, " distance %d", rip->distance); + vty_out (vty, " distance %d\n", rip->distance); /* RIP source IP prefix distance configuration. */ for (rn = route_top (rip_distance_table); rn; rn = route_next (rn)) if ((rdistance = rn->info) != NULL) - vty_outln (vty, " distance %d %s/%d %s", rdistance->distance, + vty_out (vty, " distance %d %s/%d %s\n", rdistance->distance, inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, rdistance->access_list ? rdistance->access_list : ""); /* ECMP configuration. */ if (rip->ecmp) - vty_outln (vty, " allow-ecmp"); + vty_out (vty, " allow-ecmp\n"); /* RIP static route configuration. */ for (rn = route_top (rip->route); rn; rn = route_next (rn)) if (rn->info) - vty_outln (vty, " route %s/%d", + vty_out (vty, " route %s/%d\n", inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index 9ba0e10e4..3bc9b4b21 100644 --- a/ripngd/ripng_debug.c +++ b/ripngd/ripng_debug.c @@ -35,28 +35,28 @@ DEFUN (show_debugging_ripng, DEBUG_STR "RIPng configuration\n") { - vty_outln (vty, "RIPng debugging status:"); + vty_out (vty, "RIPng debugging status:\n"); if (IS_RIPNG_DEBUG_EVENT) - vty_outln (vty, " RIPng event debugging is on"); + vty_out (vty, " RIPng event debugging is on\n"); if (IS_RIPNG_DEBUG_PACKET) { if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) { - vty_outln (vty," RIPng packet debugging is on"); + vty_out (vty," RIPng packet debugging is on\n"); } else { if (IS_RIPNG_DEBUG_SEND) - vty_outln (vty," RIPng packet send debugging is on"); + vty_out (vty," RIPng packet send debugging is on\n"); else - vty_outln (vty," RIPng packet receive debugging is on"); + vty_out (vty," RIPng packet receive debugging is on\n"); } } if (IS_RIPNG_DEBUG_ZEBRA) - vty_outln (vty, " RIPng zebra debugging is on"); + vty_out (vty, " RIPng zebra debugging is on\n"); return CMD_SUCCESS; } @@ -69,7 +69,7 @@ DEFUN (debug_ripng_events, "Debug option set for ripng events\n") { ripng_debug_event = RIPNG_DEBUG_EVENT; - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (debug_ripng_packet, @@ -112,7 +112,7 @@ DEFUN (debug_ripng_zebra, "Debug option set for ripng and zebra communication\n") { ripng_debug_zebra = RIPNG_DEBUG_ZEBRA; - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (no_debug_ripng_events, @@ -176,7 +176,7 @@ DEFUN (no_debug_ripng_zebra, "Debug option set for ripng and zebra communication\n") { ripng_debug_zebra = 0; - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Debug node. */ @@ -194,28 +194,28 @@ config_write_debug (struct vty *vty) if (IS_RIPNG_DEBUG_EVENT) { - vty_outln (vty, "debug ripng events"); + vty_out (vty, "debug ripng events\n"); write++; } if (IS_RIPNG_DEBUG_PACKET) { if (IS_RIPNG_DEBUG_SEND && IS_RIPNG_DEBUG_RECV) { - vty_outln (vty,"debug ripng packet"); + vty_out (vty,"debug ripng packet\n"); write++; } else { if (IS_RIPNG_DEBUG_SEND) - vty_outln (vty,"debug ripng packet send"); + vty_out (vty,"debug ripng packet send\n"); else - vty_outln (vty,"debug ripng packet recv"); + vty_out (vty,"debug ripng packet recv\n"); write++; } } if (IS_RIPNG_DEBUG_ZEBRA) { - vty_outln (vty, "debug ripng zebra"); + vty_out (vty, "debug ripng zebra\n"); write++; } return write; diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index d739540c2..e4b45c54a 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -858,7 +858,7 @@ static int ripng_passive_interface_set (struct vty *vty, const char *ifname) { if (ripng_passive_interface_lookup (ifname) >= 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; vector_set (Vripng_passive_interface, strdup (ifname)); @@ -875,7 +875,7 @@ ripng_passive_interface_unset (struct vty *vty, const char *ifname) i = ripng_passive_interface_lookup (ifname); if (i < 0) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; str = vector_slot (Vripng_passive_interface, i); free (str); @@ -916,7 +916,7 @@ ripng_network_write (struct vty *vty, int config_mode) if (node->info) { struct prefix *p = &node->p; - vty_outln (vty, "%s%s/%d", + vty_out (vty, "%s%s/%d\n", config_mode ? " network " : " ", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen); @@ -926,7 +926,7 @@ ripng_network_write (struct vty *vty, int config_mode) /* Write enable interface. */ for (i = 0; i < vector_active (ripng_enable_if); i++) if ((ifname = vector_slot (ripng_enable_if, i)) != NULL) - vty_outln (vty, "%s%s", + vty_out (vty, "%s%s\n", config_mode ? " network " : " ", ifname); @@ -934,7 +934,7 @@ ripng_network_write (struct vty *vty, int config_mode) if (config_mode) for (i = 0; i < vector_active (Vripng_passive_interface); i++) if ((ifname = vector_slot (Vripng_passive_interface, i)) != NULL) - vty_outln (vty, " passive-interface %s", ifname); + vty_out (vty, " passive-interface %s\n", ifname); return 0; } @@ -960,9 +960,9 @@ DEFUN (ripng_network, if (ret < 0) { - vty_outln (vty, "There is same network configuration %s", + vty_out (vty, "There is same network configuration %s\n", argv[idx_if_or_addr]->arg); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -990,8 +990,8 @@ DEFUN (no_ripng_network, if (ret < 0) { - vty_outln (vty, "can't find network %s",argv[idx_if_or_addr]->arg); - return CMD_WARNING; + vty_out (vty, "can't find network %s\n",argv[idx_if_or_addr]->arg); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -1121,28 +1121,28 @@ interface_config_write (struct vty *vty) (ri->split_horizon == ri->split_horizon_default)) continue; - vty_outln (vty, "interface %s",ifp->name); + vty_out (vty, "interface %s\n",ifp->name); if (ifp->desc) - vty_outln (vty, " description %s",ifp->desc); + vty_out (vty, " description %s\n",ifp->desc); /* Split horizon. */ if (ri->split_horizon != ri->split_horizon_default) { switch (ri->split_horizon) { case RIPNG_SPLIT_HORIZON: - vty_outln (vty, " ipv6 ripng split-horizon"); + vty_out (vty, " ipv6 ripng split-horizon\n"); break; case RIPNG_SPLIT_HORIZON_POISONED_REVERSE: - vty_outln (vty," ipv6 ripng split-horizon poisoned-reverse"); + vty_out (vty," ipv6 ripng split-horizon poisoned-reverse\n"); break; case RIPNG_NO_SPLIT_HORIZON: default: - vty_outln (vty, " no ipv6 ripng split-horizon"); + vty_out (vty, " no ipv6 ripng split-horizon\n"); break; } } - vty_outln (vty, "!"); + vty_out (vty, "!\n"); write++; } diff --git a/ripngd/ripng_offset.c b/ripngd/ripng_offset.c index 51385dd93..81e892d7d 100644 --- a/ripngd/ripng_offset.c +++ b/ripngd/ripng_offset.c @@ -125,16 +125,16 @@ ripng_offset_list_set (struct vty *vty, const char *alist, direct = RIPNG_OFFSET_LIST_OUT; else { - vty_outln (vty, "Invalid direction: %s", direct_str); - return CMD_WARNING; + vty_out (vty, "Invalid direction: %s\n", direct_str); + return CMD_WARNING_CONFIG_FAILED; } /* Check metric. */ metric = atoi (metric_str); if (metric < 0 || metric > 16) { - vty_outln (vty, "Invalid metric: %s", metric_str); - return CMD_WARNING; + vty_out (vty, "Invalid metric: %s\n", metric_str); + return CMD_WARNING_CONFIG_FAILED; } /* Get offset-list structure with interface name. */ @@ -164,16 +164,16 @@ ripng_offset_list_unset (struct vty *vty, const char *alist, direct = RIPNG_OFFSET_LIST_OUT; else { - vty_outln (vty, "Invalid direction: %s", direct_str); - return CMD_WARNING; + vty_out (vty, "Invalid direction: %s\n", direct_str); + return CMD_WARNING_CONFIG_FAILED; } /* Check metric. */ metric = atoi (metric_str); if (metric < 0 || metric > 16) { - vty_outln (vty, "Invalid metric: %s", metric_str); - return CMD_WARNING; + vty_out (vty, "Invalid metric: %s\n", metric_str); + return CMD_WARNING_CONFIG_FAILED; } /* Get offset-list structure with interface name. */ @@ -196,8 +196,8 @@ ripng_offset_list_unset (struct vty *vty, const char *alist, } else { - vty_outln (vty, "Can't find offset-list"); - return CMD_WARNING; + vty_out (vty, "Can't find offset-list\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; } @@ -405,23 +405,23 @@ config_write_ripng_offset_list (struct vty *vty) if (! offset->ifname) { if (offset->direct[RIPNG_OFFSET_LIST_IN].alist_name) - vty_outln (vty, " offset-list %s in %d", + vty_out (vty, " offset-list %s in %d\n", offset->direct[RIPNG_OFFSET_LIST_IN].alist_name, offset->direct[RIPNG_OFFSET_LIST_IN].metric); if (offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name) - vty_outln (vty, " offset-list %s out %d", + vty_out (vty, " offset-list %s out %d\n", offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name, offset->direct[RIPNG_OFFSET_LIST_OUT].metric); } else { if (offset->direct[RIPNG_OFFSET_LIST_IN].alist_name) - vty_outln (vty, " offset-list %s in %d %s", + vty_out (vty, " offset-list %s in %d %s\n", offset->direct[RIPNG_OFFSET_LIST_IN].alist_name, offset->direct[RIPNG_OFFSET_LIST_IN].metric, offset->ifname); if (offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name) - vty_outln (vty, " offset-list %s out %d %s", + vty_out (vty, " offset-list %s out %d %s\n", offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name, offset->direct[RIPNG_OFFSET_LIST_OUT].metric, offset->ifname); diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c index 51f1a4009..f27c33f37 100644 --- a/ripngd/ripng_peer.c +++ b/ripngd/ripng_peer.c @@ -193,8 +193,8 @@ ripng_peer_display (struct vty *vty) for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer)) { - vty_outln (vty, " %s %s%14s %10d %10d %10d %s", inet6_ntoa (peer->addr), - VTYNL, " ", + vty_out (vty, " %s \n%14s %10d %10d %10d %s\n", inet6_ntoa (peer->addr), + " ", peer->recv_badpackets, peer->recv_badroutes, ZEBRA_RIPNG_DISTANCE_DEFAULT, ripng_peer_uptime(peer, timebuf, RIPNG_UPTIME_LEN)); diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index 465d33992..b49de9902 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -337,8 +337,8 @@ DEFUN (ripng_redistribute_type, if (type < 0) { - vty_outln (vty, "Invalid type %s", proto); - return CMD_WARNING; + vty_out (vty, "Invalid type %s\n", proto); + return CMD_WARNING_CONFIG_FAILED; } zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT); @@ -363,8 +363,8 @@ DEFUN (no_ripng_redistribute_type, if (type < 0) { - vty_outln (vty, "Invalid type %s", proto); - return CMD_WARNING; + vty_out (vty, "Invalid type %s\n", proto); + return CMD_WARNING_CONFIG_FAILED; } ripng_redistribute_metric_unset (type); @@ -391,8 +391,8 @@ DEFUN (ripng_redistribute_type_metric, if (type < 0) { - vty_outln (vty, "Invalid type %s", argv[idx_protocol]->text); - return CMD_WARNING; + vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); + return CMD_WARNING_CONFIG_FAILED; } ripng_redistribute_metric_set (type, metric); @@ -417,8 +417,8 @@ DEFUN (ripng_redistribute_type_routemap, if (type < 0) { - vty_outln (vty, "Invalid type %s", argv[idx_protocol]->text); - return CMD_WARNING; + vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); + return CMD_WARNING_CONFIG_FAILED; } ripng_redistribute_routemap_set (type, argv[idx_word]->text); @@ -448,8 +448,8 @@ DEFUN (ripng_redistribute_type_metric_routemap, if (type < 0) { - vty_outln (vty, "Invalid type %s", argv[idx_protocol]->text); - return CMD_WARNING; + vty_out (vty, "Invalid type %s\n", argv[idx_protocol]->text); + return CMD_WARNING_CONFIG_FAILED; } ripng_redistribute_metric_set (type, metric); @@ -472,20 +472,20 @@ ripng_redistribute_write (struct vty *vty, int config_mode) if (ripng->route_map[i].metric_config) { if (ripng->route_map[i].name) - vty_outln (vty, " redistribute %s metric %d route-map %s", + vty_out (vty, " redistribute %s metric %d route-map %s\n", zebra_route_string(i), ripng->route_map[i].metric, ripng->route_map[i].name); else - vty_outln (vty, " redistribute %s metric %d", + vty_out (vty, " redistribute %s metric %d\n", zebra_route_string(i),ripng->route_map[i].metric); } else { if (ripng->route_map[i].name) - vty_outln (vty, " redistribute %s route-map %s", + vty_out (vty, " redistribute %s route-map %s\n", zebra_route_string(i),ripng->route_map[i].name); else - vty_outln (vty, " redistribute %s",zebra_route_string(i)); + vty_out (vty, " redistribute %s\n",zebra_route_string(i)); } } else @@ -499,13 +499,13 @@ zebra_config_write (struct vty *vty) { if (! zclient->enable) { - vty_outln (vty, "no router zebra"); + vty_out (vty, "no router zebra\n"); return 1; } else if (! vrf_bitmap_check (zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], VRF_DEFAULT)) { - vty_outln (vty, "router zebra"); - vty_outln (vty, " no redistribute ripng"); + vty_out (vty, "router zebra\n"); + vty_out (vty, " no redistribute ripng\n"); return 1; } return 0; diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index bfec173ef..8b4c3e850 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -2004,13 +2004,11 @@ DEFUN (show_ipv6_ripng, return CMD_SUCCESS; /* Header of display. */ - vty_outln (vty, "Codes: R - RIPng, C - connected, S - Static, O - OSPF, B - BGP%s" - "Sub-codes:%s" - " (n) - normal, (s) - static, (d) - default, (r) - redistribute,%s" - " (i) - interface, (a/S) - aggregated/Suppressed%s%s" - " Network Next Hop Via Metric Tag Time", - VTYNL, VTYNL, VTYNL, - VTYNL, VTYNL); + vty_out (vty, "Codes: R - RIPng, C - connected, S - Static, O - OSPF, B - BGP\n" + "Sub-codes:\n" + " (n) - normal, (s) - static, (d) - default, (r) - redistribute,\n" + " (i) - interface, (a/S) - aggregated/Suppressed\n\n" + " Network Next Hop Via Metric Tag Time\n"); for (rp = route_top (ripng->table); rp; rp = route_next (rp)) { @@ -2026,11 +2024,11 @@ DEFUN (show_ipv6_ripng, vty_out (vty, "R(a) %s/%d ", inet6_ntoa (p->prefix), p->prefixlen); #endif /* DEBUG */ - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, "%*s", 18, " "); vty_out (vty, "%*s", 28, " "); - vty_outln (vty, "self %2d %3"ROUTE_TAG_PRI"", aggregate->metric, + vty_out (vty, "self %2d %3"ROUTE_TAG_PRI"\n", aggregate->metric, (route_tag_t)aggregate->tag); } @@ -2051,7 +2049,7 @@ DEFUN (show_ipv6_ripng, ripng_route_subtype_print(rinfo), inet6_ntoa (p->prefix), p->prefixlen); #endif /* DEBUG */ - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, "%*s", 18, " "); len = vty_out (vty, "%s", inet6_ntoa (rinfo->nexthop)); @@ -2089,7 +2087,7 @@ DEFUN (show_ipv6_ripng, ripng_vty_out_uptime (vty, rinfo); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } @@ -2110,30 +2108,30 @@ DEFUN (show_ipv6_ripng_status, if (! ripng) return CMD_SUCCESS; - vty_outln (vty, "Routing Protocol is \"RIPng\""); + vty_out (vty, "Routing Protocol is \"RIPng\"\n"); vty_out (vty, " Sending updates every %ld seconds with +/-50%%,", ripng->update_time); - vty_outln (vty, " next due in %lu seconds", + vty_out (vty, " next due in %lu seconds\n", thread_timer_remain_second(ripng->t_update)); vty_out (vty, " Timeout after %ld seconds,", ripng->timeout_time); - vty_outln (vty, " garbage collect after %ld seconds",ripng->garbage_time); + vty_out (vty, " garbage collect after %ld seconds\n",ripng->garbage_time); /* Filtering status show. */ config_show_distribute (vty); /* Default metric information. */ - vty_outln (vty, " Default redistribution metric is %d", + vty_out (vty, " Default redistribution metric is %d\n", ripng->default_metric); /* Redistribute information. */ vty_out (vty, " Redistributing:"); ripng_redistribute_write (vty, 0); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); vty_out (vty, " Default version control: send version %d,", ripng->version); - vty_outln (vty, " receive version %d ",ripng->version); + vty_out (vty, " receive version %d \n",ripng->version); - vty_outln (vty, " Interface Send Recv"); + vty_out (vty, " Interface Send Recv\n"); for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { @@ -2144,18 +2142,18 @@ DEFUN (show_ipv6_ripng_status, if (ri->enable_network || ri->enable_interface) { - vty_outln (vty, " %-17s%-3d %-3d", ifp->name, + vty_out (vty, " %-17s%-3d %-3d\n", ifp->name, ripng->version, ripng->version); } } - vty_outln (vty, " Routing for Networks:"); + vty_out (vty, " Routing for Networks:\n"); ripng_network_write (vty, 0); - vty_outln (vty, " Routing Information Sources:"); - vty_outln (vty, - " Gateway BadPackets BadRoutes Distance Last Update"); + vty_out (vty, " Routing Information Sources:\n"); + vty_out (vty, + " Gateway BadPackets BadRoutes Distance Last Update\n"); ripng_peer_display (vty); return CMD_SUCCESS; @@ -2227,7 +2225,7 @@ DEFUN_NOSH (router_ripng, if (ret < 0) { zlog_warn ("can't create RIPng"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } @@ -2260,17 +2258,17 @@ DEFUN (ripng_route, ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p); if (ret <= 0) { - vty_outln (vty, "Malformed address"); - return CMD_WARNING; + vty_out (vty, "Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask_ipv6 (&p); rp = route_node_get (ripng->route, (struct prefix *) &p); if (rp->info) { - vty_outln (vty, "There is already same static route."); + vty_out (vty, "There is already same static route.\n"); route_unlock_node (rp); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } rp->info = (void *)1; @@ -2294,16 +2292,16 @@ DEFUN (no_ripng_route, ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p); if (ret <= 0) { - vty_outln (vty, "Malformed address"); - return CMD_WARNING; + vty_out (vty, "Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask_ipv6 (&p); rp = route_node_lookup (ripng->route, (struct prefix *) &p); if (! rp) { - vty_outln (vty, "Can't find static route."); - return CMD_WARNING; + vty_out (vty, "Can't find static route.\n"); + return CMD_WARNING_CONFIG_FAILED; } ripng_redistribute_delete (ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p, 0); @@ -2329,17 +2327,17 @@ DEFUN (ripng_aggregate_address, ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *)&p); if (ret <= 0) { - vty_outln (vty, "Malformed address"); - return CMD_WARNING; + vty_out (vty, "Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Check aggregate alredy exist or not. */ node = route_node_get (ripng->aggregate, &p); if (node->info) { - vty_outln (vty, "There is already same aggregate route."); + vty_out (vty, "There is already same aggregate route.\n"); route_unlock_node (node); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } node->info = (void *)1; @@ -2363,15 +2361,15 @@ DEFUN (no_ripng_aggregate_address, ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *) &p); if (ret <= 0) { - vty_outln (vty, "Malformed address"); - return CMD_WARNING; + vty_out (vty, "Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } rn = route_node_lookup (ripng->aggregate, &p); if (! rn) { - vty_outln (vty, "Can't find aggregate route."); - return CMD_WARNING; + vty_out (vty, "Can't find aggregate route.\n"); + return CMD_WARNING_CONFIG_FAILED; } route_unlock_node (rn); rn->info = NULL; @@ -2425,8 +2423,8 @@ DEFUN (ripng_update_timer, update = strtoul (argv[0], &endptr, 10); if (update == ULONG_MAX || *endptr != '\0') { - vty_out (vty, "update timer value error%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "update timer value error\n"); + return CMD_WARNING_CONFIG_FAILED; } ripng->update_time = update; @@ -2460,8 +2458,8 @@ DEFUN (ripng_timeout_timer, timeout = strtoul (argv[0], &endptr, 10); if (timeout == ULONG_MAX || *endptr != '\0') { - vty_out (vty, "timeout timer value error%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "timeout timer value error\n"); + return CMD_WARNING_CONFIG_FAILED; } ripng->timeout_time = timeout; @@ -2493,8 +2491,8 @@ DEFUN (ripng_garbage_timer, garbage = strtoul (argv[0], &endptr, 10); if (garbage == ULONG_MAX || *endptr != '\0') { - vty_out (vty, "garbage timer value error%s", VTYNL); - return CMD_WARNING; + vty_out (vty, "garbage timer value error\n"); + return CMD_WARNING_CONFIG_FAILED; } ripng->garbage_time = garbage; @@ -2577,16 +2575,14 @@ DEFUN (show_ipv6_protocols, if (! ripng) return CMD_SUCCESS; - vty_out (vty, "Routing Protocol is \"ripng\"%s", VTYNL); + vty_out (vty, "Routing Protocol is \"ripng\"\n"); - vty_out (vty, "Sending updates every %ld seconds, next due in %d seconds%s", - ripng->update_time, 0, - VTYNL); + vty_out (vty, "Sending updates every %ld seconds, next due in %d seconds\n", + ripng->update_time, 0); - vty_out (vty, "Timerout after %ld seconds, garbage correct %ld%s", + vty_out (vty, "Timerout after %ld seconds, garbage correct %ld\n", ripng->timeout_time, - ripng->garbage_time, - VTYNL); + ripng->garbage_time); vty_out (vty, "Outgoing update filter list for all interfaces is not set"); vty_out (vty, "Incoming update filter list for all interfaces is not set"); @@ -2680,8 +2676,8 @@ DEFUN (ripng_allow_ecmp, { if (ripng->ecmp) { - vty_outln (vty, "ECMP is already enabled."); - return CMD_WARNING; + vty_out (vty, "ECMP is already enabled.\n"); + return CMD_WARNING_CONFIG_FAILED; } ripng->ecmp = 1; @@ -2697,8 +2693,8 @@ DEFUN (no_ripng_allow_ecmp, { if (!ripng->ecmp) { - vty_outln (vty, "ECMP is already disabled."); - return CMD_WARNING; + vty_out (vty, "ECMP is already disabled.\n"); + return CMD_WARNING_CONFIG_FAILED; } ripng->ecmp = 0; @@ -2720,16 +2716,16 @@ ripng_config_write (struct vty *vty) { /* RIPng router. */ - vty_outln (vty, "router ripng"); + vty_out (vty, "router ripng\n"); if (ripng->default_information) - vty_outln (vty, " default-information originate"); + vty_out (vty, " default-information originate\n"); ripng_network_write (vty, 1); /* RIPng default metric configuration */ if (ripng->default_metric != RIPNG_DEFAULT_METRIC_DEFAULT) - vty_outln (vty, " default-metric %d", + vty_out (vty, " default-metric %d\n", ripng->default_metric); ripng_redistribute_write (vty, 1); @@ -2740,18 +2736,18 @@ ripng_config_write (struct vty *vty) /* RIPng aggregate routes. */ for (rp = route_top (ripng->aggregate); rp; rp = route_next (rp)) if (rp->info != NULL) - vty_outln (vty, " aggregate-address %s/%d", + vty_out (vty, " aggregate-address %s/%d\n", inet6_ntoa (rp->p.u.prefix6), rp->p.prefixlen); /* ECMP configuration. */ if (ripng->ecmp) - vty_outln (vty, " allow-ecmp"); + vty_out (vty, " allow-ecmp\n"); /* RIPng static routes. */ for (rp = route_top (ripng->route); rp; rp = route_next (rp)) if (rp->info != NULL) - vty_outln (vty, " route %s/%d", inet6_ntoa (rp->p.u.prefix6), + vty_out (vty, " route %s/%d\n", inet6_ntoa (rp->p.u.prefix6), rp->p.prefixlen); /* RIPng timers configuration. */ @@ -2759,21 +2755,18 @@ ripng_config_write (struct vty *vty) ripng->timeout_time != RIPNG_TIMEOUT_TIMER_DEFAULT || ripng->garbage_time != RIPNG_GARBAGE_TIMER_DEFAULT) { - vty_outln (vty, " timers basic %ld %ld %ld", + vty_out (vty, " timers basic %ld %ld %ld\n", ripng->update_time, ripng->timeout_time, ripng->garbage_time); } #if 0 if (ripng->update_time != RIPNG_UPDATE_TIMER_DEFAULT) - vty_out (vty, " update-timer %d%s", ripng->update_time, - VTYNL); + vty_out (vty, " update-timer %d\n", ripng->update_time); if (ripng->timeout_time != RIPNG_TIMEOUT_TIMER_DEFAULT) - vty_out (vty, " timeout-timer %d%s", ripng->timeout_time, - VTYNL); + vty_out (vty, " timeout-timer %d\n", ripng->timeout_time); if (ripng->garbage_time != RIPNG_GARBAGE_TIMER_DEFAULT) - vty_out (vty, " garbage-timer %d%s", ripng->garbage_time, - VTYNL); + vty_out (vty, " garbage-timer %d\n", ripng->garbage_time); #endif /* 0 */ write += config_write_distribute (vty); diff --git a/snapcraft/.gitignore b/snapcraft/.gitignore index e050ff0c8..ac7860290 100644 --- a/snapcraft/.gitignore +++ b/snapcraft/.gitignore @@ -2,5 +2,5 @@ snapcraft.yaml parts prime stage -quagga*.snap +frr*.snap !*/Makefile diff --git a/solaris/.gitignore b/solaris/.gitignore index 63afe3fdb..a2c7946e7 100644 --- a/solaris/.gitignore +++ b/solaris/.gitignore @@ -14,7 +14,7 @@ depend.dev depend.doc depend.libs depend.smf -quagga.init +frr.init *.pkg *.pkg.gz *~ diff --git a/tests/Makefile.am b/tests/Makefile.am index c10c3def6..43003e707 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -164,6 +164,7 @@ EXTRA_DIST = \ lib/test_table.py \ lib/test_timer_correctness.py \ lib/test_ttable.py \ + lib/test_ttable.refout \ ospf6d/test_lsdb.py \ ospf6d/test_lsdb.in \ ospf6d/test_lsdb.refout \ diff --git a/tests/helpers/c/prng.c b/tests/helpers/c/prng.c index 4b9fd5715..0f78366fc 100644 --- a/tests/helpers/c/prng.c +++ b/tests/helpers/c/prng.c @@ -4,6 +4,7 @@ * * Copyright (C) 2012 by Open Source Routing. * Copyright (C) 2012 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2017 Christian Franke * * This file is part of Quagga * @@ -32,49 +33,32 @@ struct prng { - unsigned long long state1; - unsigned long long state2; + uint64_t state; }; -static char -prng_bit(struct prng *prng) -{ - prng->state1 *= 2416; - prng->state1 += 374441; - prng->state1 %= 1771875; - - if (prng->state1 % 2) - { - prng->state2 *= 84589; - prng->state2 += 45989; - prng->state2 %= 217728; - } - - return prng->state2 % 2; -} - struct prng* prng_new(unsigned long long seed) { struct prng *rv = calloc(sizeof(*rv), 1); assert(rv); - rv->state1 = rv->state2 = seed; + rv->state = seed; return rv; } -unsigned int +/* + * This implementation has originally been provided to musl libc by + * Szabolcs Nagy <nsz at port70 dot net> in 2013 under the terms of + * the MIT license. + * It is a simple LCG which D.E. Knuth attributes to C.E. Haynes in + * TAOCP Vol2 3.3.4 + */ +int prng_rand(struct prng *prng) { - unsigned int i, rv = 0; - - for (i = 0; i < 32; i++) - { - rv |= prng_bit(prng); - rv <<= 1; - } - return rv; + prng->state = 6364136223846793005ULL*prng->state + 1; + return prng->state>>33; } const char * diff --git a/tests/helpers/c/prng.h b/tests/helpers/c/prng.h index 6cc6289a1..7b2ab924e 100644 --- a/tests/helpers/c/prng.h +++ b/tests/helpers/c/prng.h @@ -27,7 +27,7 @@ struct prng; struct prng* prng_new(unsigned long long seed); -unsigned int prng_rand(struct prng*); +int prng_rand(struct prng*); const char * prng_fuzz(struct prng*, const char *string, const char *charset, diff --git a/tests/lib/cli/common_cli.c b/tests/lib/cli/common_cli.c index 728ae8cb0..f1b07ce22 100644 --- a/tests/lib/cli/common_cli.c +++ b/tests/lib/cli/common_cli.c @@ -36,10 +36,10 @@ int dump_args(struct vty *vty, const char *descr, int argc, struct cmd_token *argv[]) { int i; - vty_outln (vty, "%s with %d args.", descr, argc); + vty_out (vty, "%s with %d args.\n", descr, argc); for (i = 0; i < argc; i++) { - vty_outln (vty, "[%02d] %s@%s: %s", i, argv[i]->text, argv[i]->varname, argv[i]->arg); + vty_out (vty, "[%02d] %s@%s: %s\n", i, argv[i]->text, argv[i]->varname, argv[i]->arg); } return CMD_SUCCESS; diff --git a/tests/lib/cli/test_cli.c b/tests/lib/cli/test_cli.c index 43366d49e..a4d3fb4e8 100644 --- a/tests/lib/cli/test_cli.c +++ b/tests/lib/cli/test_cli.c @@ -47,10 +47,10 @@ DEFPY(magic_test, magic_test_cmd, "1\n2\n3\n4\n5\n") { char buf[256]; - vty_outln(vty, "def: %s", self->string); - vty_outln(vty, "num: %ld", magic); - vty_outln(vty, "ipv4: %s", prefix2str(ipv4net, buf, sizeof(buf))); - vty_outln(vty, "ipv6: %s", inet_ntop(AF_INET6, &ipv6, buf, sizeof(buf))); + vty_out(vty, "def: %s\n", self->string); + vty_out(vty, "num: %ld\n", magic); + vty_out(vty, "ipv4: %s\n", prefix2str(ipv4net, buf, sizeof(buf))); + vty_out(vty, "ipv6: %s\n", inet_ntop(AF_INET6, &ipv6, buf, sizeof(buf))); return CMD_SUCCESS; } diff --git a/tests/lib/test_heavy.c b/tests/lib/test_heavy.c index 810d9fda7..c6f6bbba2 100644 --- a/tests/lib/test_heavy.c +++ b/tests/lib/test_heavy.c @@ -63,7 +63,7 @@ slow_func (struct vty *vty, const char *str, const int i) printf ("%s: hard error\n", __func__); if ((i % ITERS_PRINT) == 0) - printf ("%s did %d, x = %g%s", str, i, x, VTYNL); + printf ("%s did %d, x = %g\n", str, i, x); } static void @@ -88,7 +88,7 @@ DEFUN (clear_foo, char *str; if (!argc) { - vty_outln (vty, "%% string argument required"); + vty_out (vty, "%% string argument required\n"); return CMD_WARNING; } diff --git a/tests/lib/test_heavy_thread.c b/tests/lib/test_heavy_thread.c index 80c54a827..9e1d70adc 100644 --- a/tests/lib/test_heavy_thread.c +++ b/tests/lib/test_heavy_thread.c @@ -112,7 +112,7 @@ DEFUN (clear_foo, if (!argc) { - vty_outln (vty, "%% string argument required"); + vty_out (vty, "%% string argument required\n"); return CMD_WARNING; } diff --git a/tests/lib/test_heavy_wq.c b/tests/lib/test_heavy_wq.c index 13641f6ed..18b80d081 100644 --- a/tests/lib/test_heavy_wq.c +++ b/tests/lib/test_heavy_wq.c @@ -146,7 +146,7 @@ DEFUN (clear_foo, char *str; if (!argc) { - vty_outln (vty, "%% string argument required"); + vty_out (vty, "%% string argument required\n"); return CMD_WARNING; } diff --git a/tests/lib/test_nexthop_iter.c b/tests/lib/test_nexthop_iter.c index 77515386c..18628ec16 100644 --- a/tests/lib/test_nexthop_iter.c +++ b/tests/lib/test_nexthop_iter.c @@ -1,6 +1,6 @@ /* * Recursive Nexthop Iterator test. - * This tests the ALL_NEXTHOPS_RO macro. + * This tests the ALL_NEXTHOPS macro. * * Copyright (C) 2012 by Open Source Routing. * Copyright (C) 2012 by Internet Systems Consortium, Inc. ("ISC") @@ -108,6 +108,29 @@ nexthop_chain_add_top(struct nexthop_chain *nc) } static void +add_string_representation (char **repr, struct nexthop *nh) +{ + struct nexthop *parent; + + /* add indentations first */ + parent = nh->rparent; + while (parent) + { + str_appendf(repr, " "); + parent = parent->rparent; + } + str_appendf(repr, "%p\n", nh); +} + +static void +start_recursive_chain (struct nexthop_chain *nc, struct nexthop *nh) +{ + SET_FLAG(nc->current_top->flags, NEXTHOP_FLAG_RECURSIVE); + nc->current_top->resolved = nh; + nh->rparent = nc->current_top; + nc->current_recursive = nh; +} +static void nexthop_chain_add_recursive(struct nexthop_chain *nc) { struct nexthop *nh; @@ -120,36 +143,52 @@ nexthop_chain_add_recursive(struct nexthop_chain *nc) { nc->current_recursive->next = nh; nh->prev = nc->current_recursive; + nh->rparent = nc->current_recursive->rparent; nc->current_recursive = nh; } else + start_recursive_chain (nc, nh); + + add_string_representation (&nc->repr, nh); +} + +static void +nexthop_chain_add_recursive_level(struct nexthop_chain *nc) +{ + struct nexthop *nh; + + nh = calloc(sizeof(*nh), 1); + assert(nh); + + assert(nc->current_top); + if (nc->current_recursive) { - SET_FLAG(nc->current_top->flags, NEXTHOP_FLAG_RECURSIVE); - nc->current_top->resolved = nh; + SET_FLAG(nc->current_recursive->flags, NEXTHOP_FLAG_RECURSIVE); + nc->current_recursive->resolved = nh; + nh->rparent = nc->current_recursive; nc->current_recursive = nh; } - str_appendf(&nc->repr, " %p\n", nh); + else + start_recursive_chain (nc, nh); + + add_string_representation (&nc->repr, nh); } static void +nexthop_clear_recursive (struct nexthop *tcur) +{ + if (!tcur) + return; + if (CHECK_FLAG(tcur->flags, NEXTHOP_FLAG_RECURSIVE)) + nexthop_clear_recursive (tcur->resolved); + if (tcur->next) + nexthop_clear_recursive (tcur->next); + free (tcur); +} +static void nexthop_chain_clear(struct nexthop_chain *nc) { - struct nexthop *tcur, *tnext; - - for (tcur = nc->head; tcur; tcur = tnext) - { - tnext = tcur->next; - if (CHECK_FLAG(tcur->flags, NEXTHOP_FLAG_RECURSIVE)) - { - struct nexthop *rcur, *rnext; - for (rcur = tcur->resolved; rcur; rcur = rnext) - { - rnext = rcur->next; - free(rcur); - } - } - free(tcur); - } + nexthop_clear_recursive (nc->head); nc->head = nc->current_top = nc->current_recursive = NULL; free(nc->repr); nc->repr = NULL; @@ -165,25 +204,19 @@ nexthop_chain_free(struct nexthop_chain *nc) } /* This function builds a string representation of - * the nexthop chain using the ALL_NEXTHOPS_RO macro. - * It verifies that the ALL_NEXTHOPS_RO macro iterated + * the nexthop chain using the ALL_NEXTHOPS macro. + * It verifies that the ALL_NEXTHOPS macro iterated * correctly over the nexthop chain by comparing the * generated representation with the expected representation. */ static void nexthop_chain_verify_iter(struct nexthop_chain *nc) { - struct nexthop *nh, *tnh; - int recursing; + struct nexthop *nh; char *repr = NULL; - for (ALL_NEXTHOPS_RO(nc->head, nh, tnh, recursing)) - { - if (recursing) - str_appendf(&repr, " %p\n", nh); - else - str_appendf(&repr, "%p\n", nh); - } + for (ALL_NEXTHOPS(nc->head, nh)) + add_string_representation (&repr, nh); if (repr && verbose) printf("===\n%s", repr); @@ -234,6 +267,18 @@ test_run_first(void) nexthop_chain_add_recursive(nc); nexthop_chain_verify_iter(nc); + nexthop_chain_add_recursive_level(nc); + nexthop_chain_verify_iter(nc); + + nexthop_chain_add_recursive(nc); + nexthop_chain_verify_iter(nc); + + nexthop_chain_add_recursive(nc); + nexthop_chain_verify_iter(nc); + + nexthop_chain_add_top(nc); + nexthop_chain_verify_iter(nc); + nexthop_chain_free(nc); } @@ -268,10 +313,13 @@ test_run_prng(void) case 6: case 7: case 8: - case 9: if (nc->current_top) nexthop_chain_add_recursive(nc); break; + case 9: + if (nc->current_top) + nexthop_chain_add_recursive_level(nc); + break; } nexthop_chain_verify_iter(nc); } diff --git a/tests/lib/test_srcdest_table.c b/tests/lib/test_srcdest_table.c index 792e2696e..111b11a1e 100644 --- a/tests/lib/test_srcdest_table.c +++ b/tests/lib/test_srcdest_table.c @@ -386,7 +386,13 @@ static void test_state_del_one_route(struct test_state *test, struct prng *prng) { - unsigned int which_route = prng_rand(prng) % test->log->count; + unsigned int which_route; + + if (test->log->count == 0) + return; + + which_route = prng_rand(prng) % test->log->count; + struct route_node *rn; struct prefix *dst_p, *src_p; struct prefix_ipv6 dst6_p, src6_p; diff --git a/tools/Makefile.am b/tools/Makefile.am index dd32d0dab..e5a118972 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -11,6 +11,6 @@ permutations_LDADD = ../lib/libfrr.la sbin_SCRIPTS = frr-reload.py frr -EXTRA_DIST += frr.service frr-reload.py frr +EXTRA_DIST += frr.service frr-reload.py frr etc ssd_SOURCES = start-stop-daemon.c diff --git a/tools/frr-reload.py b/tools/frr-reload.py index a7a04be63..bfdc08ab4 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -812,7 +812,7 @@ def compare_context_objects(newconf, running): delete_bgpd = True lines_to_del.append((running_ctx_keys, None)) - # We cannot do 'no interface' in quagga, and so deal with it + # We cannot do 'no interface' in FRR, and so deal with it elif running_ctx_keys[0].startswith('interface'): for line in running_ctx.lines: lines_to_del.append((running_ctx_keys, line)) @@ -1010,7 +1010,7 @@ if __name__ == '__main__': # the "neighbor 1.1.1.1 route-map FOO out" line...so we compare the # configs again to put this line back. - # There are many keywords in quagga that can only appear one time under + # There are many keywords in FRR that can only appear one time under # a context, take "bgp router-id" for example. If the config that we are # reloading against has the following: # @@ -1038,7 +1038,7 @@ if __name__ == '__main__': lines_to_add.extend(lines_to_add_first_pass) # Only do deletes on the first pass. The reason being if we - # configure a bgp neighbor via "neighbor swp1 interface" quagga + # configure a bgp neighbor via "neighbor swp1 interface" FRR # will automatically add: # # interface swp1 diff --git a/tools/multiple-bgpd.sh b/tools/multiple-bgpd.sh index 20a92a916..6dee1bafc 100644 --- a/tools/multiple-bgpd.sh +++ b/tools/multiple-bgpd.sh @@ -10,8 +10,8 @@ PREFIX=192.168.145. #PREFIX=3ffe:123:456:: ADDRPLEN=32 CONFBASE=/tmp -PIDBASE=/var/run/quagga -CHOWNSTR=quagga:quagga +PIDBASE=/var/run/frr +CHOWNSTR=frr:frr for H in `seq 1 ${NUM}` ; do CONF="${CONFBASE}"/bgpd${H}.conf diff --git a/tools/vty_index.cocci b/tools/vty_index.cocci index 8290e80b9..eabbaa1aa 100644 --- a/tools/vty_index.cocci +++ b/tools/vty_index.cocci @@ -141,7 +141,7 @@ fn << rule11.fn; @@ print "R11 removing vty-index argument on %s(...)" % (fn) -#/* find type of the argument - note args are mostly unnamed in Quagga :( */ +#/* find type of the argument - note args are mostly unnamed in FRR :( */ @ rule12 @ identifier rule11.fn; identifier T, argname; diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index f02bd0c88..ec8a365c3 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -291,6 +291,7 @@ vtysh_execute_func (const char *line, int pager) * Changing vty->node is enough to try it just out without actual walkup in * the vtysh. */ while (ret != CMD_SUCCESS && ret != CMD_SUCCESS_DAEMON && ret != CMD_WARNING + && ret != CMD_WARNING_CONFIG_FAILED && vty->node > CONFIG_NODE) { vty->node = node_parent(vty->node); @@ -313,6 +314,10 @@ vtysh_execute_func (const char *line, int pager) { vtysh_execute("exit-address-family"); } + else if ((saved_node == BGP_EVPN_VNI_NODE) && (tried == 1)) + { + vtysh_execute("exit-vni"); + } else if (saved_node == BGP_VRF_POLICY_NODE && (tried == 1)) { vtysh_execute("exit-vrf-policy"); @@ -350,6 +355,7 @@ vtysh_execute_func (const char *line, int pager) switch (ret) { case CMD_WARNING: + case CMD_WARNING_CONFIG_FAILED: if (vty->type == VTY_FILE) fprintf (stdout,"Warning...\n"); break; @@ -553,6 +559,7 @@ vtysh_mark_file (const char *filename) * Changing vty->node is enough to try it just out without actual walkup in * the vtysh. */ while (ret != CMD_SUCCESS && ret != CMD_SUCCESS_DAEMON && ret != CMD_WARNING + && ret != CMD_WARNING_CONFIG_FAILED && vty->node > CONFIG_NODE) { vty->node = node_parent(vty->node); @@ -573,6 +580,10 @@ vtysh_mark_file (const char *filename) { fprintf(stdout, "exit-address-family\n"); } + else if ((prev_node == BGP_EVPN_VNI_NODE) && (tried == 1)) + { + fprintf(stdout, "exit-vni\n"); + } else if ((prev_node == KEYCHAIN_KEY_NODE) && (tried == 1)) { fprintf(stdout, "exit\n"); @@ -594,12 +605,13 @@ vtysh_mark_file (const char *filename) switch (ret) { case CMD_WARNING: + case CMD_WARNING_CONFIG_FAILED: if (vty->type == VTY_FILE) fprintf (stderr,"line %d: Warning...: %s\n", lineno, vty->buf); fclose(confp); vty_close(vty); XFREE(MTYPE_VTYSH_CMD, vty_buf_copy); - return CMD_WARNING; + return ret; case CMD_ERR_AMBIGUOUS: fprintf (stderr,"line %d: %% Ambiguous command: %s\n", lineno, vty->buf); fclose(confp); @@ -674,9 +686,10 @@ vtysh_config_from_file (struct vty *vty, FILE *fp) switch (ret) { case CMD_WARNING: + case CMD_WARNING_CONFIG_FAILED: if (vty->type == VTY_FILE) fprintf (stderr,"line %d: Warning[%d]...: %s\n", lineno, vty->node, vty->buf); - retcode = CMD_WARNING; /* once we have an error, we remember & return that */ + retcode = ret; /* once we have an error, we remember & return that */ break; case CMD_ERR_AMBIGUOUS: fprintf (stderr,"line %d: %% Ambiguous command[%d]: %s\n", lineno, vty->node, vty->buf); @@ -771,7 +784,7 @@ vtysh_rl_describe (void) rl_on_new_line (); return 0; break; - } + } /* Get width of command string. */ width = 0; @@ -808,15 +821,14 @@ vtysh_rl_describe (void) if (vector_active (varcomps) > 0) { - fprintf(stdout, " "); - for (size_t j = 0; j < vector_active (varcomps); j++) - { - char *item = vector_slot (varcomps, j); - fprintf (stdout, " %s", item); - XFREE (MTYPE_COMPLETION, item); - } - vty_out (vty, VTYNL); + int rows, cols; + rl_get_screen_size(&rows, &cols); + + char *ac = cmd_variable_comp2str(varcomps, cols); + fprintf(stdout, "%s\n", ac); + XFREE(MTYPE_TMP, ac); } + vector_free (varcomps); } } @@ -985,6 +997,12 @@ static struct cmd_node bgp_evpn_node = "%s(config-router-af)# " }; +static struct cmd_node bgp_evpn_vni_node = +{ + BGP_EVPN_VNI_NODE, + "%s(config-router-af-vni)# " +}; + static struct cmd_node bgp_ipv6l_node = { BGP_IPV6L_NODE, @@ -1271,14 +1289,38 @@ DEFUNSH (VTYSH_BGPD, address_family_evpn, address_family_evpn_cmd, "address-family <l2vpn evpn>", - "Enter Address Family command mode\n" - "Address Family\n" - "Address Family modifier\n") + "Enter Address Family command mode\n" + "Address Family\n" + "Address Family modifier\n") { vty->node = BGP_EVPN_NODE; return CMD_SUCCESS; } +#if defined (HAVE_CUMULUS) +DEFUNSH (VTYSH_BGPD, + address_family_evpn2, + address_family_evpn2_cmd, + "address-family evpn", + "Enter Address Family command mode\n" + "EVPN Address family\n") +{ + vty->node = BGP_EVPN_NODE; + return CMD_SUCCESS; +} +#endif + +DEFUNSH (VTYSH_BGPD, + bgp_evpn_vni, + bgp_evpn_vni_cmd, + "vni (1-16777215)", + "VXLAN Network Identifier\n" + "VNI number\n") +{ + vty->node = BGP_EVPN_VNI_NODE; + return CMD_SUCCESS; +} + #if defined (ENABLE_BGP_VNC) DEFUNSH (VTYSH_BGPD, vnc_defaults, @@ -1618,6 +1660,9 @@ vtysh_exit (struct vty *vty) case BGP_VNC_L2_GROUP_NODE: vty->node = BGP_NODE; break; + case BGP_EVPN_VNI_NODE: + vty->node = BGP_EVPN_NODE; + break; case LDP_IPV4_NODE: case LDP_IPV6_NODE: vty->node = LDP_NODE; @@ -1674,12 +1719,24 @@ DEFUNSH (VTYSH_BGPD, || vty->node == BGP_VPNV6_NODE || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6L_NODE - || vty->node == BGP_IPV6M_NODE) + || vty->node == BGP_IPV6M_NODE + || vty->node == BGP_EVPN_NODE) vty->node = BGP_NODE; return CMD_SUCCESS; } DEFUNSH (VTYSH_BGPD, + exit_vni, + exit_vni_cmd, + "exit-vni", + "Exit from VNI mode\n") +{ + if (vty->node == BGP_EVPN_VNI_NODE) + vty->node = BGP_EVPN_NODE; + return CMD_SUCCESS; +} + +DEFUNSH (VTYSH_BGPD, exit_vnc_config, exit_vnc_config_cmd, "exit-vnc", @@ -2445,20 +2502,10 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, vtysh_config_password, vtysh_password_cmd, - "password [(8-8)] WORD", + "password [(8-8)] LINE", "Assign the terminal connection password\n" "Specifies a HIDDEN password will follow\n" - "The HIDDEN line password string\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - vtysh_password_text, - vtysh_password_text_cmd, - "password LINE", - "Assign the terminal connection password\n" - "The UNENCRYPTED (cleartext) line password\n") + "The password string\n") { return CMD_SUCCESS; } @@ -2466,22 +2513,11 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_ALL, vtysh_config_enable_password, vtysh_enable_password_cmd, - "enable password (8-8) WORD", + "enable password [(8-8)] LINE", "Modify enable password parameters\n" "Assign the privileged level password\n" "Specifies a HIDDEN password will follow\n" - "The HIDDEN 'enable' password string\n") -{ - return CMD_SUCCESS; -} - -DEFUNSH (VTYSH_ALL, - vtysh_enable_password_text, - vtysh_enable_password_text_cmd, - "enable password LINE", - "Modify enable password parameters\n" - "Assign the privileged level password\n" - "The UNENCRYPTED (cleartext) 'enable' password\n") + "The 'enable' password string\n") { return CMD_SUCCESS; } @@ -2528,9 +2564,9 @@ DEFUN (vtysh_write_terminal, else fp = stdout; - vty_outln (vty, "Building configuration..."); - vty_outln (vty, "%sCurrent configuration:",VTYNL); - vty_outln (vty, "!"); + vty_out (vty, "Building configuration...\n"); + vty_out (vty, "\nCurrent configuration:\n"); + vty_out (vty, "!\n"); for (i = 0; i < array_size(vtysh_client); i++) if ((argc < 3 ) || (strmatch (vtysh_client[i].name, argv[2]->text))) @@ -2552,7 +2588,7 @@ DEFUN (vtysh_write_terminal, fp = NULL; } - vty_outln (vty, "end"); + vty_out (vty, "end\n"); return CMD_SUCCESS; } @@ -2633,7 +2669,7 @@ vtysh_write_config_integrated(void) { fprintf (stdout,"%% Error: failed to open configuration file %s: %s\n", quagga_config, safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } fd = fileno (fp); @@ -2735,7 +2771,7 @@ DEFUN (vtysh_write_memory, /* If integrated frr.conf explicitely set. */ if (want_config_integrated()) { - ret = CMD_WARNING; + ret = CMD_WARNING_CONFIG_FAILED; for (i = 0; i < array_size(vtysh_client); i++) if (vtysh_client[i].flag == VTYSH_WATCHFRR) break; @@ -2785,7 +2821,7 @@ DEFUN (vtysh_terminal_length, lines = strtol (argv[idx_number]->arg, &endptr, 10); if (lines < 0 || lines > 512 || *endptr != '\0') { - vty_outln (vty, "length is malformed"); + vty_out (vty, "length is malformed\n"); return CMD_WARNING; } @@ -2832,7 +2868,7 @@ DEFUN (vtysh_show_daemons, for (i = 0; i < array_size(vtysh_client); i++) if ( vtysh_client[i].fd >= 0 ) vty_out(vty, " %s", vtysh_client[i].name); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); return CMD_SUCCESS; } @@ -3037,7 +3073,7 @@ vtysh_connect (struct vtysh_client *vclient) { fprintf (stderr, "vtysh_connect(%s): stat = %s\n", path, safe_strerror(errno)); - exit(1); + exit (1); } if (ret >= 0) @@ -3306,6 +3342,7 @@ vtysh_init_vty (void) install_node (&bgp_ipv6l_node, NULL); install_node (&bgp_vrf_policy_node, NULL); install_node (&bgp_evpn_node, NULL); + install_node (&bgp_evpn_vni_node, NULL); install_node (&bgp_vnc_defaults_node, NULL); install_node (&bgp_vnc_nve_group_node, NULL); install_node (&bgp_vnc_l2_group_node, NULL); @@ -3344,6 +3381,7 @@ vtysh_init_vty (void) vtysh_install_default (BGP_IPV6_NODE); vtysh_install_default (BGP_IPV6M_NODE); vtysh_install_default (BGP_EVPN_NODE); + vtysh_install_default (BGP_EVPN_VNI_NODE); vtysh_install_default (BGP_IPV6L_NODE); #if ENABLE_BGP_VNC vtysh_install_default (BGP_VRF_POLICY_NODE); @@ -3422,6 +3460,9 @@ vtysh_init_vty (void) install_element (BGP_IPV6M_NODE, &vtysh_exit_bgpd_cmd); install_element (BGP_IPV6M_NODE, &vtysh_quit_bgpd_cmd); install_element (BGP_EVPN_NODE, &vtysh_quit_bgpd_cmd); + install_element (BGP_EVPN_NODE, &vtysh_exit_bgpd_cmd); + install_element (BGP_EVPN_VNI_NODE, &vtysh_exit_bgpd_cmd); + install_element (BGP_EVPN_VNI_NODE, &vtysh_quit_bgpd_cmd); install_element (BGP_IPV6L_NODE, &vtysh_exit_bgpd_cmd); install_element (BGP_IPV6L_NODE, &vtysh_quit_bgpd_cmd); #if defined (ENABLE_BGP_VNC) @@ -3472,6 +3513,7 @@ vtysh_init_vty (void) install_element (BGP_IPV6L_NODE, &vtysh_end_all_cmd); install_element (BGP_VRF_POLICY_NODE, &vtysh_end_all_cmd); install_element (BGP_EVPN_NODE, &vtysh_end_all_cmd); + install_element (BGP_EVPN_VNI_NODE, &vtysh_end_all_cmd); install_element (BGP_VNC_DEFAULTS_NODE, &vtysh_end_all_cmd); install_element (BGP_VNC_NVE_GROUP_NODE, &vtysh_end_all_cmd); install_element (BGP_VNC_L2_GROUP_NODE, &vtysh_end_all_cmd); @@ -3534,6 +3576,9 @@ vtysh_init_vty (void) install_element (BGP_NODE, &address_family_ipv6_vpn_cmd); install_element (BGP_NODE, &address_family_ipv6_labeled_unicast_cmd); install_element (BGP_NODE, &address_family_evpn_cmd); +#if defined (HAVE_CUMULUS) + install_element (BGP_NODE, &address_family_evpn2_cmd); +#endif install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); install_element (BGP_IPV4_NODE, &exit_address_family_cmd); @@ -3544,6 +3589,10 @@ vtysh_init_vty (void) install_element (BGP_EVPN_NODE, &exit_address_family_cmd); install_element (BGP_IPV6L_NODE, &exit_address_family_cmd); + /* EVPN commands */ + install_element (BGP_EVPN_NODE, &bgp_evpn_vni_cmd); + install_element (BGP_EVPN_VNI_NODE, &exit_vni_cmd); + install_element (BGP_VRF_POLICY_NODE, &exit_vrf_policy_cmd); install_element (BGP_VNC_DEFAULTS_NODE, &exit_vnc_config_cmd); install_element (BGP_VNC_NVE_GROUP_NODE, &exit_vnc_config_cmd); @@ -3630,8 +3679,6 @@ vtysh_init_vty (void) install_element (CONFIG_NODE, &no_vtysh_service_password_encrypt_cmd); install_element (CONFIG_NODE, &vtysh_password_cmd); - install_element (CONFIG_NODE, &vtysh_password_text_cmd); install_element (CONFIG_NODE, &vtysh_enable_password_cmd); - install_element (CONFIG_NODE, &vtysh_enable_password_text_cmd); install_element (CONFIG_NODE, &no_vtysh_enable_password_cmd); } diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c index 3ff4a4096..53d58668d 100644 --- a/watchfrr/watchfrr.c +++ b/watchfrr/watchfrr.c @@ -1294,7 +1294,7 @@ int main(int argc, char **argv) if (watchfrr_di.daemon_mode) { zlog_set_level(ZLOG_DEST_SYSLOG, MIN(gs.loglevel, LOG_DEBUG)); if (daemon (0, 0) < 0) { - fprintf(stderr, "Watchquagga daemon failed: %s", + fprintf(stderr, "Watchfrr daemon failed: %s", strerror(errno)); exit (1); } diff --git a/watchfrr/watchfrr_vty.c b/watchfrr/watchfrr_vty.c index 819d896af..276e186c4 100644 --- a/watchfrr/watchfrr_vty.c +++ b/watchfrr/watchfrr_vty.c @@ -41,7 +41,7 @@ DEFUN(config_write_integrated, sigset_t oldmask, sigmask; if (integrated_write_pid != -1) { - vty_outln (vty,"%% configuration write already in progress."); + vty_out (vty,"%% configuration write already in progress.\n"); return CMD_WARNING; } @@ -59,7 +59,7 @@ DEFUN(config_write_integrated, child = fork(); if (child == -1) { - vty_outln (vty, "%% configuration write fork() failed: %s.", + vty_out (vty, "%% configuration write fork() failed: %s.\n", safe_strerror(errno)); sigprocmask(SIG_SETMASK, &oldmask, NULL); return CMD_WARNING; diff --git a/zebra/Makefile.am b/zebra/Makefile.am index 541496174..46ecad5e4 100644 --- a/zebra/Makefile.am +++ b/zebra/Makefile.am @@ -33,6 +33,8 @@ zebra_SOURCES = \ zebra_ns.c zebra_vrf.c zebra_static.c zebra_mpls.c zebra_mpls_vty.c \ zebra_mroute.c \ label_manager.c \ + zebra_l2.c \ + zebra_vxlan.c \ # end noinst_HEADERS = \ @@ -42,7 +44,8 @@ noinst_HEADERS = \ rt_netlink.h zebra_fpm_private.h zebra_rnh.h \ zebra_ptm_redistribute.h zebra_ptm.h zebra_routemap.h \ zebra_ns.h zebra_vrf.h ioctl_solaris.h zebra_static.h zebra_mpls.h \ - kernel_netlink.h if_netlink.h zebra_mroute.h label_manager.h + kernel_netlink.h if_netlink.h zebra_mroute.h label_manager.h \ + zebra_l2.h zebra_vxlan_private.h zebra_vxlan.h zebra_LDADD = $(otherobj) ../lib/libfrr.la $(LIBCAP) @@ -85,7 +88,7 @@ EXTRA_DIST = if_ioctl.c if_ioctl_solaris.c if_netlink.c \ client : client_main.o ../lib/libfrr.la $(CC) -g -o client client_main.o ../liblzebra.la $(LIBS) $(LIB_IPV6) -quaggaconfdir = $(sysconfdir) +frrconfdir = $(sysconfdir) examplesdir = $(exampledir) dist_examples_DATA = zebra.conf.sample diff --git a/zebra/debug.c b/zebra/debug.c index ba2a9ad2a..1c3cf9a3d 100644 --- a/zebra/debug.c +++ b/zebra/debug.c @@ -31,6 +31,7 @@ unsigned long zebra_debug_rib; unsigned long zebra_debug_fpm; unsigned long zebra_debug_nht; unsigned long zebra_debug_mpls; +unsigned long zebra_debug_vxlan; DEFUN (show_debugging_zebra, show_debugging_zebra_cmd, @@ -39,51 +40,48 @@ DEFUN (show_debugging_zebra, "Debugging information\n" "Zebra configuration\n") { - vty_out (vty, "Zebra debugging status:%s", VTYNL); + vty_out (vty, "Zebra debugging status:\n"); if (IS_ZEBRA_DEBUG_EVENT) - vty_out (vty, " Zebra event debugging is on%s", VTYNL); + vty_out (vty, " Zebra event debugging is on\n"); if (IS_ZEBRA_DEBUG_PACKET) { if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV) { - vty_out (vty, " Zebra packet%s debugging is on%s", - IS_ZEBRA_DEBUG_DETAIL ? " detail" : "", - VTYNL); + vty_out (vty, " Zebra packet%s debugging is on\n", + IS_ZEBRA_DEBUG_DETAIL ? " detail" : ""); } else { if (IS_ZEBRA_DEBUG_SEND) - vty_out (vty, " Zebra packet send%s debugging is on%s", - IS_ZEBRA_DEBUG_DETAIL ? " detail" : "", - VTYNL); + vty_out (vty, " Zebra packet send%s debugging is on\n", + IS_ZEBRA_DEBUG_DETAIL ? " detail" : ""); else - vty_out (vty, " Zebra packet receive%s debugging is on%s", - IS_ZEBRA_DEBUG_DETAIL ? " detail" : "", - VTYNL); + vty_out (vty, " Zebra packet receive%s debugging is on\n", + IS_ZEBRA_DEBUG_DETAIL ? " detail" : ""); } } if (IS_ZEBRA_DEBUG_KERNEL) - vty_out (vty, " Zebra kernel debugging is on%s", VTYNL); + vty_out (vty, " Zebra kernel debugging is on\n"); if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) - vty_out (vty, " Zebra kernel netlink message dumps (send) are on%s", VTYNL); + vty_out (vty, " Zebra kernel netlink message dumps (send) are on\n"); if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) - vty_out (vty, " Zebra kernel netlink message dumps (recv) are on%s", VTYNL); + vty_out (vty, " Zebra kernel netlink message dumps (recv) are on\n"); /* Check here using flags as the 'macro' does an OR */ if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB)) - vty_out (vty, " Zebra RIB debugging is on%s", VTYNL); + vty_out (vty, " Zebra RIB debugging is on\n"); if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) - vty_out (vty, " Zebra RIB detailed debugging is on%s", VTYNL); + vty_out (vty, " Zebra RIB detailed debugging is on\n"); if (IS_ZEBRA_DEBUG_FPM) - vty_out (vty, " Zebra FPM debugging is on%s", VTYNL); + vty_out (vty, " Zebra FPM debugging is on\n"); if (IS_ZEBRA_DEBUG_NHT) - vty_out (vty, " Zebra next-hop tracking debugging is on%s", VTYNL); + vty_out (vty, " Zebra next-hop tracking debugging is on\n"); if (IS_ZEBRA_DEBUG_MPLS) - vty_out (vty, " Zebra MPLS debugging is on%s", VTYNL); + vty_out (vty, " Zebra MPLS debugging is on\n"); return CMD_SUCCESS; } @@ -96,7 +94,7 @@ DEFUN (debug_zebra_events, "Debug option set for zebra events\n") { zebra_debug_event = ZEBRA_DEBUG_EVENT; - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (debug_zebra_nht, @@ -107,7 +105,7 @@ DEFUN (debug_zebra_nht, "Debug option set for zebra next hop tracking\n") { zebra_debug_nht = ZEBRA_DEBUG_NHT; - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } DEFUN (debug_zebra_mpls, @@ -118,6 +116,17 @@ DEFUN (debug_zebra_mpls, "Debug option set for zebra MPLS LSPs\n") { zebra_debug_mpls = ZEBRA_DEBUG_MPLS; + return CMD_WARNING_CONFIG_FAILED; +} + +DEFUN (debug_zebra_vxlan, + debug_zebra_vxlan_cmd, + "debug zebra vxlan", + DEBUG_STR + "Zebra configuration\n" + "Debug option set for zebra VxLAN (EVPN)\n") +{ + zebra_debug_vxlan = ZEBRA_DEBUG_VXLAN; return CMD_WARNING; } @@ -251,6 +260,18 @@ DEFUN (no_debug_zebra_mpls, return CMD_SUCCESS; } +DEFUN (no_debug_zebra_vxlan, + no_debug_zebra_vxlan_cmd, + "no debug zebra vxlan", + NO_STR + DEBUG_STR + "Zebra configuration\n" + "Debug option set for zebra VxLAN (EVPN)\n") +{ + zebra_debug_vxlan = 0; + return CMD_SUCCESS; +} + DEFUN (no_debug_zebra_packet, no_debug_zebra_packet_cmd, "no debug zebra packet [<recv|send>]", @@ -353,70 +374,72 @@ config_write_debug (struct vty *vty) if (IS_ZEBRA_DEBUG_EVENT) { - vty_out (vty, "debug zebra events%s", VTYNL); + vty_out (vty, "debug zebra events\n"); write++; } if (IS_ZEBRA_DEBUG_PACKET) { if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV) { - vty_out (vty, "debug zebra packet%s%s", - IS_ZEBRA_DEBUG_DETAIL ? " detail" : "", - VTYNL); + vty_out (vty, "debug zebra packet%s\n", + IS_ZEBRA_DEBUG_DETAIL ? " detail" : ""); write++; } else { if (IS_ZEBRA_DEBUG_SEND) - vty_out (vty, "debug zebra packet send%s%s", - IS_ZEBRA_DEBUG_DETAIL ? " detail" : "", - VTYNL); + vty_out (vty, "debug zebra packet send%s\n", + IS_ZEBRA_DEBUG_DETAIL ? " detail" : ""); else - vty_out (vty, "debug zebra packet recv%s%s", - IS_ZEBRA_DEBUG_DETAIL ? " detail" : "", - VTYNL); + vty_out (vty, "debug zebra packet recv%s\n", + IS_ZEBRA_DEBUG_DETAIL ? " detail" : ""); write++; } } if (IS_ZEBRA_DEBUG_KERNEL) { - vty_out (vty, "debug zebra kernel%s", VTYNL); + vty_out (vty, "debug zebra kernel\n"); write++; } if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) { - vty_out (vty, "debug zebra kernel msgdump recv%s", VTYNL); + vty_out (vty, "debug zebra kernel msgdump recv\n"); write++; } if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) { - vty_out (vty, "debug zebra kernel msgdump send%s", VTYNL); + vty_out (vty, "debug zebra kernel msgdump send\n"); write++; } /* Check here using flags as the 'macro' does an OR */ if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB)) { - vty_out (vty, "debug zebra rib%s", VTYNL); + vty_out (vty, "debug zebra rib\n"); write++; } if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) { - vty_out (vty, "debug zebra rib detailed%s", VTYNL); + vty_out (vty, "debug zebra rib detailed\n"); write++; } if (IS_ZEBRA_DEBUG_FPM) { - vty_out (vty, "debug zebra fpm%s", VTYNL); + vty_out (vty, "debug zebra fpm\n"); write++; } if (IS_ZEBRA_DEBUG_NHT) { - vty_out (vty, "debug zebra nht%s", VTYNL); + vty_out (vty, "debug zebra nht\n"); write++; } if (IS_ZEBRA_DEBUG_MPLS) { - vty_out (vty, "debug zebra mpls%s", VTYNL); + vty_out (vty, "debug zebra mpls\n"); + write++; + } + if (IS_ZEBRA_DEBUG_VXLAN) + { + vty_out (vty, "debug zebra vxlan\n"); write++; } return write; @@ -431,6 +454,7 @@ zebra_debug_init (void) zebra_debug_rib = 0; zebra_debug_fpm = 0; zebra_debug_mpls = 0; + zebra_debug_vxlan = 0; install_node (&debug_node, config_write_debug); @@ -439,6 +463,7 @@ zebra_debug_init (void) install_element (ENABLE_NODE, &debug_zebra_events_cmd); install_element (ENABLE_NODE, &debug_zebra_nht_cmd); install_element (ENABLE_NODE, &debug_zebra_mpls_cmd); + install_element (ENABLE_NODE, &debug_zebra_vxlan_cmd); install_element (ENABLE_NODE, &debug_zebra_packet_cmd); install_element (ENABLE_NODE, &debug_zebra_kernel_cmd); install_element (ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd); @@ -448,6 +473,7 @@ zebra_debug_init (void) install_element (ENABLE_NODE, &no_debug_zebra_events_cmd); install_element (ENABLE_NODE, &no_debug_zebra_nht_cmd); install_element (ENABLE_NODE, &no_debug_zebra_mpls_cmd); + install_element (ENABLE_NODE, &no_debug_zebra_vxlan_cmd); install_element (ENABLE_NODE, &no_debug_zebra_packet_cmd); install_element (ENABLE_NODE, &no_debug_zebra_kernel_cmd); install_element (ENABLE_NODE, &no_debug_zebra_kernel_msgdump_cmd); @@ -458,6 +484,7 @@ zebra_debug_init (void) install_element (CONFIG_NODE, &debug_zebra_events_cmd); install_element (CONFIG_NODE, &debug_zebra_nht_cmd); install_element (CONFIG_NODE, &debug_zebra_mpls_cmd); + install_element (CONFIG_NODE, &debug_zebra_vxlan_cmd); install_element (CONFIG_NODE, &debug_zebra_packet_cmd); install_element (CONFIG_NODE, &debug_zebra_kernel_cmd); install_element (CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd); @@ -467,6 +494,7 @@ zebra_debug_init (void) install_element (CONFIG_NODE, &no_debug_zebra_events_cmd); install_element (CONFIG_NODE, &no_debug_zebra_nht_cmd); install_element (CONFIG_NODE, &no_debug_zebra_mpls_cmd); + install_element (CONFIG_NODE, &no_debug_zebra_vxlan_cmd); install_element (CONFIG_NODE, &no_debug_zebra_packet_cmd); install_element (CONFIG_NODE, &no_debug_zebra_kernel_cmd); install_element (CONFIG_NODE, &no_debug_zebra_kernel_msgdump_cmd); diff --git a/zebra/debug.h b/zebra/debug.h index 0a50da817..5687a3516 100644 --- a/zebra/debug.h +++ b/zebra/debug.h @@ -42,6 +42,8 @@ #define ZEBRA_DEBUG_MPLS 0x01 +#define ZEBRA_DEBUG_VXLAN 0x01 + /* Debug related macro. */ #define IS_ZEBRA_DEBUG_EVENT (zebra_debug_event & ZEBRA_DEBUG_EVENT) @@ -63,6 +65,7 @@ #define IS_ZEBRA_DEBUG_FPM (zebra_debug_fpm & ZEBRA_DEBUG_FPM) #define IS_ZEBRA_DEBUG_NHT (zebra_debug_nht & ZEBRA_DEBUG_NHT) #define IS_ZEBRA_DEBUG_MPLS (zebra_debug_mpls & ZEBRA_DEBUG_MPLS) +#define IS_ZEBRA_DEBUG_VXLAN (zebra_debug_vxlan & ZEBRA_DEBUG_VXLAN) extern unsigned long zebra_debug_event; extern unsigned long zebra_debug_packet; @@ -71,6 +74,7 @@ extern unsigned long zebra_debug_rib; extern unsigned long zebra_debug_fpm; extern unsigned long zebra_debug_nht; extern unsigned long zebra_debug_mpls; +extern unsigned long zebra_debug_vxlan; extern void zebra_debug_init (void); diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 5af6c3a08..d0907a267 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -20,6 +20,15 @@ */ #include <zebra.h> + +/* The following definition is to workaround an issue in the Linux kernel + * header files with redefinition of 'struct in6_addr' in both + * netinet/in.h and linux/in6.h. + * Reference - https://sourceware.org/ml/libc-alpha/2013-01/msg00599.html + */ +#define _LINUX_IN6_H + +#include <linux/if_bridge.h> #include <net/if_arp.h> #include <linux/sockios.h> #include <linux/ethtool.h> @@ -175,6 +184,23 @@ netlink_to_zebra_link_type (unsigned int hwt) } } +static void +netlink_determine_zebra_iftype (char *kind, zebra_iftype_t *zif_type) +{ + *zif_type = ZEBRA_IF_OTHER; + + if (!kind) + return; + + if (strcmp(kind, "vrf") == 0) + *zif_type = ZEBRA_IF_VRF; + else if (strcmp(kind, "bridge") == 0) + *zif_type = ZEBRA_IF_BRIDGE; + else if (strcmp(kind, "vlan") == 0) + *zif_type = ZEBRA_IF_VLAN; + else if (strcmp(kind, "vxlan") == 0) + *zif_type = ZEBRA_IF_VXLAN; +} //Temporary Assignments to compile on older platforms. #ifndef IFLA_BR_MAX @@ -341,6 +367,173 @@ get_iflink_speed (const char *ifname) return (ecmd.speed_hi << 16 ) | ecmd.speed; } +static int +netlink_extract_bridge_info (struct rtattr *link_data, + struct zebra_l2info_bridge *bridge_info) +{ + struct rtattr *attr[IFLA_BR_MAX+1]; + + memset (bridge_info, 0, sizeof (*bridge_info)); + memset (attr, 0, sizeof attr); + parse_rtattr_nested(attr, IFLA_BR_MAX, link_data); + if (attr[IFLA_BR_VLAN_FILTERING]) + bridge_info->vlan_aware = *(u_char *)RTA_DATA(attr[IFLA_BR_VLAN_FILTERING]); + return 0; +} + +static int +netlink_extract_vlan_info (struct rtattr *link_data, + struct zebra_l2info_vlan *vlan_info) +{ + struct rtattr *attr[IFLA_VLAN_MAX+1]; + vlanid_t vid_in_msg; + + memset (vlan_info, 0, sizeof (*vlan_info)); + memset (attr, 0, sizeof attr); + parse_rtattr_nested(attr, IFLA_VLAN_MAX, link_data); + if (!attr[IFLA_VLAN_ID]) + { + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("IFLA_VLAN_ID missing from VLAN IF message"); + return -1; + } + + vid_in_msg = *(vlanid_t *)RTA_DATA(attr[IFLA_VLAN_ID]); + vlan_info->vid = vid_in_msg; + return 0; +} + +static int +netlink_extract_vxlan_info (struct rtattr *link_data, + struct zebra_l2info_vxlan *vxl_info) +{ + struct rtattr *attr[IFLA_VXLAN_MAX+1]; + vni_t vni_in_msg; + struct in_addr vtep_ip_in_msg; + + memset (vxl_info, 0, sizeof (*vxl_info)); + memset (attr, 0, sizeof attr); + parse_rtattr_nested(attr, IFLA_VXLAN_MAX, link_data); + if (!attr[IFLA_VXLAN_ID]) + { + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("IFLA_VXLAN_ID missing from VXLAN IF message"); + return -1; + } + + vni_in_msg = *(vni_t *)RTA_DATA(attr[IFLA_VXLAN_ID]); + vxl_info->vni = vni_in_msg; + if (!attr[IFLA_VXLAN_LOCAL]) + { + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("IFLA_VXLAN_LOCAL missing from VXLAN IF message"); + } + else + { + vtep_ip_in_msg = *(struct in_addr *)RTA_DATA(attr[IFLA_VXLAN_LOCAL]); + vxl_info->vtep_ip = vtep_ip_in_msg; + } + + return 0; +} + +/* + * Extract and save L2 params (of interest) for an interface. When a + * bridge interface is added or updated, take further actions to map + * its members. Likewise, for VxLAN interface. + */ +static void +netlink_interface_update_l2info (struct interface *ifp, + struct rtattr *link_data, + int add) +{ + if (!link_data) + return; + + if (IS_ZEBRA_IF_BRIDGE(ifp)) + { + struct zebra_l2info_bridge bridge_info; + + netlink_extract_bridge_info (link_data, &bridge_info); + zebra_l2_bridge_add_update (ifp, &bridge_info, add); + } + else if (IS_ZEBRA_IF_VLAN(ifp)) + { + struct zebra_l2info_vlan vlan_info; + + netlink_extract_vlan_info (link_data, &vlan_info); + zebra_l2_vlanif_update (ifp, &vlan_info); + } + else if (IS_ZEBRA_IF_VXLAN(ifp)) + { + struct zebra_l2info_vxlan vxlan_info; + + netlink_extract_vxlan_info (link_data, &vxlan_info); + zebra_l2_vxlanif_add_update (ifp, &vxlan_info, add); + } +} + +static int +netlink_bridge_interface (struct nlmsghdr *h, int len, + ns_id_t ns_id, int startup) +{ + char *name = NULL; + struct ifinfomsg *ifi; + struct rtattr *tb[IFLA_MAX + 1]; + struct interface *ifp; + struct rtattr *aftb[IFLA_BRIDGE_MAX + 1]; + struct + { + u_int16_t flags; + u_int16_t vid; + } *vinfo; + vlanid_t access_vlan; + + /* Fetch name and ifindex */ + ifi = NLMSG_DATA (h); + memset (tb, 0, sizeof tb); + netlink_parse_rtattr (tb, IFLA_MAX, IFLA_RTA (ifi), len); + + if (tb[IFLA_IFNAME] == NULL) + return -1; + name = (char *) RTA_DATA (tb[IFLA_IFNAME]); + + /* The interface should already be known, if not discard. */ + ifp = if_lookup_by_index_per_ns (zebra_ns_lookup (ns_id), + ifi->ifi_index); + if (!ifp) + { + zlog_warn ("Cannot find bridge IF %s(%u)", + name, ifi->ifi_index); + return 0; + } + if (!IS_ZEBRA_IF_VXLAN(ifp)) + return 0; + + /* We are only interested in the access VLAN i.e., AF_SPEC */ + if (!tb[IFLA_AF_SPEC]) + return 0; + + /* There is a 1-to-1 mapping of VLAN to VxLAN - hence + * only 1 access VLAN is accepted. + */ + memset (aftb, 0, sizeof aftb); + parse_rtattr_nested(aftb, IFLA_BRIDGE_MAX, tb[IFLA_AF_SPEC]); + if (!aftb[IFLA_BRIDGE_VLAN_INFO]) + return 0; + + vinfo = RTA_DATA(aftb[IFLA_BRIDGE_VLAN_INFO]); + if (!(vinfo->flags & BRIDGE_VLAN_INFO_PVID)) + return 0; + + access_vlan = (vlanid_t) vinfo->vid; + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("Access VLAN %u for VxLAN IF %s(%u)", + access_vlan, name, ifi->ifi_index); + zebra_l2_vxlanif_update_access_vlan (ifp, access_vlan); + return 0; +} + /* Called from interface_lookup_netlink(). This function is only used during bootstrap. */ static int @@ -355,9 +548,12 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h, char *name = NULL; char *kind = NULL; char *slave_kind = NULL; - int vrf_device = 0; struct zebra_ns *zns; vrf_id_t vrf_id = VRF_DEFAULT; + zebra_iftype_t zif_type = ZEBRA_IF_OTHER; + zebra_slave_iftype_t zif_slave_type = ZEBRA_IF_SLAVE_NONE; + ifindex_t bridge_ifindex = IFINDEX_INTERNAL; + ifindex_t link_ifindex = IFINDEX_INTERNAL; zns = zebra_ns_lookup (ns_id); ifi = NLMSG_DATA (h); @@ -369,11 +565,13 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h, if (len < 0) return -1; + /* We are interested in some AF_BRIDGE notifications. */ if (ifi->ifi_family == AF_BRIDGE) - return 0; + return netlink_bridge_interface (h, len, ns_id, startup); /* Looking up interface name. */ memset (tb, 0, sizeof tb); + memset (linkinfo, 0, sizeof linkinfo); netlink_parse_rtattr (tb, IFLA_MAX, IFLA_RTA (ifi), len); #ifdef IFLA_WIRELESS @@ -392,7 +590,6 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h, if (tb[IFLA_LINKINFO]) { - memset (linkinfo, 0, sizeof linkinfo); parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb[IFLA_LINKINFO]); if (linkinfo[IFLA_INFO_KIND]) @@ -403,37 +600,64 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h, slave_kind = RTA_DATA(linkinfo[IFLA_INFO_SLAVE_KIND]); #endif - if (kind && strcmp(kind, "vrf") == 0) - { - vrf_device = 1; - netlink_vrf_change(h, tb[IFLA_LINKINFO], name); - vrf_id = (vrf_id_t)ifi->ifi_index; - } + netlink_determine_zebra_iftype (kind, &zif_type); + } + + /* If VRF, create the VRF structure itself. */ + if (zif_type == ZEBRA_IF_VRF) + { + netlink_vrf_change(h, tb[IFLA_LINKINFO], name); + vrf_id = (vrf_id_t)ifi->ifi_index; } if (tb[IFLA_MASTER]) { if (slave_kind && (strcmp(slave_kind, "vrf") == 0)) - vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]); + { + zif_slave_type = ZEBRA_IF_SLAVE_VRF; + vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]); + } + else if (slave_kind && (strcmp(slave_kind, "bridge") == 0)) + { + zif_slave_type = ZEBRA_IF_SLAVE_BRIDGE; + bridge_ifindex = *(ifindex_t *)RTA_DATA(tb[IFLA_MASTER]); + } + else + zif_slave_type = ZEBRA_IF_SLAVE_OTHER; } + /* If linking to another interface, note it. */ + if (tb[IFLA_LINK]) + link_ifindex = *(ifindex_t *)RTA_DATA(tb[IFLA_LINK]); + /* Add interface. */ ifp = if_get_by_name (name, vrf_id); set_ifindex(ifp, ifi->ifi_index, zns); ifp->flags = ifi->ifi_flags & 0x0000fffff; - if (vrf_device) + if (IS_ZEBRA_IF_VRF(ifp)) SET_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK); ifp->mtu6 = ifp->mtu = *(uint32_t *) RTA_DATA (tb[IFLA_MTU]); ifp->metric = 0; ifp->speed = get_iflink_speed (name); ifp->ptm_status = ZEBRA_PTM_STATUS_UNKNOWN; + /* Set zebra interface type */ + zebra_if_set_ziftype (ifp, zif_type, zif_slave_type); + + /* Update link. */ + zebra_if_update_link (ifp, link_ifindex); + /* Hardware type and address. */ ifp->ll_type = netlink_to_zebra_link_type (ifi->ifi_type); netlink_interface_update_hw_addr (tb, ifp); if_add_update (ifp); + /* Extract and save L2 interface information, take additional actions. */ + netlink_interface_update_l2info (ifp, linkinfo[IFLA_INFO_DATA], 1); + if (IS_ZEBRA_IF_BRIDGE_SLAVE (ifp)) + zebra_l2if_update_bridge_slave (ifp, bridge_ifindex); + return 0; } @@ -477,6 +701,24 @@ interface_lookup_netlink (struct zebra_ns *zns) if (ret < 0) return ret; + /* Get interface information - for bridge interfaces. */ + ret = netlink_request_intf_addr (zns, AF_BRIDGE, RTM_GETLINK, + RTEXT_FILTER_BRVLAN); + if (ret < 0) + return ret; + ret = netlink_parse_info (netlink_interface, &zns->netlink_cmd, zns, 0, 0); + if (ret < 0) + return ret; + + /* Get interface information - for bridge interfaces. */ + ret = netlink_request_intf_addr (zns, AF_BRIDGE, RTM_GETLINK, + RTEXT_FILTER_BRVLAN); + if (ret < 0) + return ret; + ret = netlink_parse_info (netlink_interface, &zns->netlink_cmd, zns, 0, 0); + if (ret < 0) + return ret; + /* Get IPv4 address of the interfaces. */ ret = netlink_request_intf_addr (zns, AF_INET, RTM_GETADDR, 0); if (ret < 0) @@ -712,9 +954,13 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h, char *name = NULL; char *kind = NULL; char *slave_kind = NULL; - int vrf_device = 0; struct zebra_ns *zns; vrf_id_t vrf_id = VRF_DEFAULT; + zebra_iftype_t zif_type = ZEBRA_IF_OTHER; + zebra_slave_iftype_t zif_slave_type = ZEBRA_IF_SLAVE_NONE; + ifindex_t bridge_ifindex = IFINDEX_INTERNAL; + ifindex_t link_ifindex = IFINDEX_INTERNAL; + zns = zebra_ns_lookup (ns_id); ifi = NLMSG_DATA (h); @@ -731,11 +977,13 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h, if (len < 0) return -1; + /* We are interested in some AF_BRIDGE notifications. */ if (ifi->ifi_family == AF_BRIDGE) - return 0; + return netlink_bridge_interface (h, len, ns_id, startup); /* Looking up interface name. */ memset (tb, 0, sizeof tb); + memset (linkinfo, 0, sizeof linkinfo); netlink_parse_rtattr (tb, IFLA_MAX, IFLA_RTA (ifi), len); #ifdef IFLA_WIRELESS @@ -754,7 +1002,6 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h, if (tb[IFLA_LINKINFO]) { - memset (linkinfo, 0, sizeof linkinfo); parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb[IFLA_LINKINFO]); if (linkinfo[IFLA_INFO_KIND]) @@ -765,12 +1012,18 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h, slave_kind = RTA_DATA(linkinfo[IFLA_INFO_SLAVE_KIND]); #endif - if (kind && strcmp(kind, "vrf") == 0) - { - vrf_device = 1; - netlink_vrf_change(h, tb[IFLA_LINKINFO], name); - vrf_id = (vrf_id_t)ifi->ifi_index; - } + netlink_determine_zebra_iftype (kind, &zif_type); + } + + /* If linking to another interface, note it. */ + if (tb[IFLA_LINK]) + link_ifindex = *(ifindex_t *)RTA_DATA(tb[IFLA_LINK]); + + /* If VRF, create or update the VRF structure itself. */ + if (zif_type == ZEBRA_IF_VRF) + { + netlink_vrf_change(h, tb[IFLA_LINKINFO], name); + vrf_id = (vrf_id_t)ifi->ifi_index; } /* See if interface is present. */ @@ -781,15 +1034,27 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h, if (tb[IFLA_MASTER]) { if (slave_kind && (strcmp(slave_kind, "vrf") == 0)) - vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]); + { + zif_slave_type = ZEBRA_IF_SLAVE_VRF; + vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]); + } + else if (slave_kind && (strcmp(slave_kind, "bridge") == 0)) + { + zif_slave_type = ZEBRA_IF_SLAVE_BRIDGE; + bridge_ifindex = *(ifindex_t *)RTA_DATA(tb[IFLA_MASTER]); + } + else + zif_slave_type = ZEBRA_IF_SLAVE_OTHER; } if (ifp == NULL || !CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) { /* Add interface notification from kernel */ if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug ("RTM_NEWLINK for %s(%u) (ifp %p) vrf_id %u flags 0x%x", - name, ifi->ifi_index, ifp, vrf_id, ifi->ifi_flags); + zlog_debug ("RTM_NEWLINK ADD for %s(%u) vrf_id %u type %d " + "sl_type %d master %u flags 0x%x", + name, ifi->ifi_index, vrf_id, zif_type, zif_slave_type, + bridge_ifindex, ifi->ifi_flags); if (ifp == NULL) { @@ -806,16 +1071,27 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h, /* Update interface information. */ set_ifindex(ifp, ifi->ifi_index, zns); ifp->flags = ifi->ifi_flags & 0x0000fffff; - if (vrf_device) + if (IS_ZEBRA_IF_VRF(ifp)) SET_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK); ifp->mtu6 = ifp->mtu = *(int *) RTA_DATA (tb[IFLA_MTU]); ifp->metric = 0; ifp->ptm_status = ZEBRA_PTM_STATUS_UNKNOWN; + /* Set interface type */ + zebra_if_set_ziftype (ifp, zif_type, zif_slave_type); + + /* Update link. */ + zebra_if_update_link (ifp, link_ifindex); + netlink_interface_update_hw_addr (tb, ifp); /* Inform clients, install any configured addresses. */ if_add_update (ifp); + + /* Extract and save L2 interface information, take additional actions. */ + netlink_interface_update_l2info (ifp, linkinfo[IFLA_INFO_DATA], 1); + if (IS_ZEBRA_IF_BRIDGE_SLAVE (ifp)) + zebra_l2if_update_bridge_slave (ifp, bridge_ifindex); } else if (ifp->vrf_id != vrf_id) { @@ -830,32 +1106,59 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h, } else { - /* Interface status change. */ + int was_bridge_slave; + + /* Interface update. */ if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug ("RTM_NEWLINK status for %s(%u) flags 0x%x", - name, ifp->ifindex, ifi->ifi_flags); + zlog_debug ("RTM_NEWLINK update for %s(%u) " + "sl_type %d master %u flags 0x%x", + name, ifp->ifindex, zif_slave_type, + bridge_ifindex, ifi->ifi_flags); set_ifindex(ifp, ifi->ifi_index, zns); ifp->mtu6 = ifp->mtu = *(int *) RTA_DATA (tb[IFLA_MTU]); ifp->metric = 0; + /* Update interface type - NOTE: Only slave_type can change. */ + was_bridge_slave = IS_ZEBRA_IF_BRIDGE_SLAVE (ifp); + zebra_if_set_ziftype (ifp, zif_type, zif_slave_type); + netlink_interface_update_hw_addr (tb, ifp); if (if_is_no_ptm_operative (ifp)) { ifp->flags = ifi->ifi_flags & 0x0000fffff; if (!if_is_no_ptm_operative (ifp)) - if_down (ifp); + { + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("Intf %s(%u) has gone DOWN", + name, ifp->ifindex); + if_down (ifp); + } else if (if_is_operative (ifp)) - /* Must notify client daemons of new interface status. */ - zebra_interface_up_update (ifp); + { + /* Must notify client daemons of new interface status. */ + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("Intf %s(%u) PTM up, notifying clients", + name, ifp->ifindex); + zebra_interface_up_update (ifp); + } } else { ifp->flags = ifi->ifi_flags & 0x0000fffff; if (if_is_operative (ifp)) - if_up (ifp); + { + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("Intf %s(%u) has come UP", name, ifp->ifindex); + if_up (ifp); + } } + + /* Extract and save L2 interface information, take additional actions. */ + netlink_interface_update_l2info (ifp, linkinfo[IFLA_INFO_DATA], 0); + if (IS_ZEBRA_IF_BRIDGE_SLAVE (ifp) || was_bridge_slave) + zebra_l2if_update_bridge_slave (ifp, bridge_ifindex); } } else @@ -873,7 +1176,13 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h, UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK); - if (!vrf_device) + /* Special handling for bridge or VxLAN interfaces. */ + if (IS_ZEBRA_IF_BRIDGE (ifp)) + zebra_l2_bridge_del (ifp); + else if (IS_ZEBRA_IF_VXLAN (ifp)) + zebra_l2_vxlanif_del (ifp); + + if (!IS_ZEBRA_IF_VRF(ifp)) if_delete_update (ifp); } diff --git a/zebra/interface.c b/zebra/interface.c index b8426c689..9618e9bb1 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -47,6 +47,7 @@ #include "zebra/zebra_ptm.h" #include "zebra/rt_netlink.h" #include "zebra/interface.h" +#include "zebra/zebra_vxlan.h" #define ZEBRA_PTM_SUPPORT @@ -680,6 +681,8 @@ if_delete_connected (struct interface *ifp) void if_delete_update (struct interface *ifp) { + struct zebra_if *zif; + if (if_is_up(ifp)) { zlog_err ("interface %s vrf %u index %d is still up while being deleted.", @@ -713,6 +716,16 @@ if_delete_update (struct interface *ifp) /* if the ifp is in a vrf, move it to default so vrf can be deleted if desired */ if (ifp->vrf_id) if_handle_vrf_change (ifp, VRF_DEFAULT); + + /* Reset some zebra interface params to default values. */ + zif = ifp->info; + if (zif) + { + zif->zif_type = ZEBRA_IF_OTHER; + zif->zif_slave_type = ZEBRA_IF_SLAVE_NONE; + memset (&zif->l2info, 0, sizeof (union zebra_l2if_info)); + memset (&zif->brslave_info, 0, sizeof (struct zebra_l2info_brslave)); + } } /* VRF change for an interface */ @@ -834,6 +847,7 @@ void if_up (struct interface *ifp) { struct zebra_if *zif; + struct interface *link_if; zif = ifp->info; zif->up_count++; @@ -868,6 +882,24 @@ if_up (struct interface *ifp) rib_update (ifp->vrf_id, RIB_UPDATE_IF_CHANGE); zebra_vrf_static_route_interface_fixup (ifp); + + /* Handle interface up for specific types for EVPN. Non-VxLAN interfaces + * are checked to see if (remote) neighbor entries need to be installed + * on them for ARP suppression. + */ + if (IS_ZEBRA_IF_VXLAN (ifp)) + zebra_vxlan_if_up (ifp); + else if (IS_ZEBRA_IF_BRIDGE (ifp)) + { + link_if = ifp; + zebra_vxlan_svi_up (ifp, link_if); + } + else if (IS_ZEBRA_IF_VLAN (ifp)) + { + link_if = zif->link; + if (link_if) + zebra_vxlan_svi_up (ifp, link_if); + } } /* Interface goes down. We have to manage different behavior of based @@ -876,11 +908,31 @@ void if_down (struct interface *ifp) { struct zebra_if *zif; + struct interface *link_if; zif = ifp->info; zif->down_count++; quagga_timestamp (2, zif->down_last, sizeof (zif->down_last)); + /* Handle interface down for specific types for EVPN. Non-VxLAN interfaces + * are checked to see if (remote) neighbor entries need to be purged + * for ARP suppression. + */ + if (IS_ZEBRA_IF_VXLAN (ifp)) + zebra_vxlan_if_down (ifp); + else if (IS_ZEBRA_IF_BRIDGE (ifp)) + { + link_if = ifp; + zebra_vxlan_svi_down (ifp, link_if); + } + else if (IS_ZEBRA_IF_VLAN (ifp)) + { + link_if = zif->link; + if (link_if) + zebra_vxlan_svi_down (ifp, link_if); + } + + /* Notify to the protocol daemons. */ zebra_interface_down_update (ifp); @@ -904,6 +956,17 @@ if_refresh (struct interface *ifp) if_get_flags (ifp); } +void +zebra_if_update_link (struct interface *ifp, ifindex_t link_ifindex) +{ + struct zebra_if *zif; + + zif = (struct zebra_if *)ifp->info; + zif->link_ifindex = link_ifindex; + zif->link = if_lookup_by_index_per_ns (zebra_ns_lookup (NS_DEFAULT), + link_ifindex); +} + /* Output prefix string to vty. */ static int @@ -944,7 +1007,7 @@ connected_dump_vty (struct vty *vty, struct connected *connected) if (connected->label) vty_out (vty, " %s", connected->label); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* Dump interface neighbor address information to vty. */ @@ -959,7 +1022,7 @@ nbr_connected_dump_vty (struct vty *vty, struct nbr_connected *connected) prefix_vty_out (vty, p); vty_out (vty, "/%d", p->prefixlen); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } #if defined (HAVE_RTADV) @@ -976,50 +1039,81 @@ nd_dump_vty (struct vty *vty, struct interface *ifp) if (rtadv->AdvSendAdvertisements) { - vty_outln (vty, " ND advertised reachable time is %d milliseconds", + vty_out (vty, " ND advertised reachable time is %d milliseconds\n", rtadv->AdvReachableTime); - vty_outln (vty, " ND advertised retransmit interval is %d milliseconds", + vty_out (vty, " ND advertised retransmit interval is %d milliseconds\n", rtadv->AdvRetransTimer); - vty_outln (vty, " ND router advertisements sent: %d rcvd: %d", + vty_out (vty, " ND router advertisements sent: %d rcvd: %d\n", zif->ra_sent, zif->ra_rcvd); interval = rtadv->MaxRtrAdvInterval; if (interval % 1000) - vty_outln (vty, " ND router advertisements are sent every " - "%d milliseconds",interval); + vty_out (vty, " ND router advertisements are sent every " + "%d milliseconds\n",interval); else - vty_outln (vty, " ND router advertisements are sent every " - "%d seconds",interval / 1000); + vty_out (vty, " ND router advertisements are sent every " + "%d seconds\n",interval / 1000); if (rtadv->AdvDefaultLifetime != -1) - vty_outln (vty, " ND router advertisements live for %d seconds", + vty_out (vty, " ND router advertisements live for %d seconds\n", rtadv->AdvDefaultLifetime); else - vty_outln (vty, - " ND router advertisements lifetime tracks ra-interval"); - vty_outln (vty, " ND router advertisement default router preference is " - "%s",rtadv_pref_strs[rtadv->DefaultPreference]); + vty_out (vty, + " ND router advertisements lifetime tracks ra-interval\n"); + vty_out (vty, " ND router advertisement default router preference is " + "%s\n",rtadv_pref_strs[rtadv->DefaultPreference]); if (rtadv->AdvManagedFlag) - vty_outln (vty," Hosts use DHCP to obtain routable addresses."); + vty_out (vty," Hosts use DHCP to obtain routable addresses.\n"); else - vty_outln (vty," Hosts use stateless autoconfig for addresses."); + vty_out (vty," Hosts use stateless autoconfig for addresses.\n"); if (rtadv->AdvHomeAgentFlag) { - vty_outln (vty, - " ND router advertisements with " "Home Agent flag bit set."); + vty_out (vty, + " ND router advertisements with Home Agent flag bit set.\n"); if (rtadv->HomeAgentLifetime != -1) - vty_outln (vty, " Home Agent lifetime is %u seconds", + vty_out (vty, " Home Agent lifetime is %u seconds\n", rtadv->HomeAgentLifetime); else - vty_outln (vty," Home Agent lifetime tracks ra-lifetime"); - vty_outln (vty, " Home Agent preference is %u", + vty_out (vty," Home Agent lifetime tracks ra-lifetime\n"); + vty_out (vty, " Home Agent preference is %u\n", rtadv->HomeAgentPreference); } if (rtadv->AdvIntervalOption) - vty_outln (vty, - " ND router advertisements with Adv. Interval option."); + vty_out (vty, + " ND router advertisements with Adv. Interval option.\n"); } } #endif /* HAVE_RTADV */ +static const char * +zebra_ziftype_2str (zebra_iftype_t zif_type) +{ + switch (zif_type) + { + case ZEBRA_IF_OTHER: + return "Other"; + break; + + case ZEBRA_IF_BRIDGE: + return "Bridge"; + break; + + case ZEBRA_IF_VLAN: + return "Vlan"; + break; + + case ZEBRA_IF_VXLAN: + return "Vxlan"; + break; + + case ZEBRA_IF_VRF: + return "VRF"; + break; + + default: + return "Unknown"; + break; + } +} + /* Interface's information print out to vty interface. */ static void if_dump_vty (struct vty *vty, struct interface *ifp) @@ -1039,36 +1133,36 @@ if_dump_vty (struct vty *vty, struct interface *ifp) if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) { if (if_is_running(ifp)) - vty_outln (vty, "is up"); + vty_out (vty, "is up\n"); else - vty_outln (vty, "is down"); + vty_out (vty, "is down\n"); } else { - vty_outln (vty, "detection is disabled"); + vty_out (vty, "detection is disabled\n"); } } else { - vty_outln (vty, "down"); + vty_out (vty, "down\n"); } - vty_outln (vty, " Link ups: %5u last: %s", zebra_if->up_count, + vty_out (vty, " Link ups: %5u last: %s\n", zebra_if->up_count, zebra_if->up_last[0] ? zebra_if->up_last : "(never)"); - vty_outln (vty, " Link downs: %5u last: %s", zebra_if->down_count, + vty_out (vty, " Link downs: %5u last: %s\n", zebra_if->down_count, zebra_if->down_last[0] ? zebra_if->down_last : "(never)"); zebra_ptm_show_status(vty, ifp); vrf = vrf_lookup_by_id (ifp->vrf_id); - vty_outln (vty, " vrf: %s", vrf->name); + vty_out (vty, " vrf: %s\n", vrf->name); if (ifp->desc) - vty_outln (vty, " Description: %s",ifp->desc); + vty_out (vty, " Description: %s\n",ifp->desc); if (ifp->ifindex == IFINDEX_INTERNAL) { - vty_outln (vty, " pseudo interface"); + vty_out (vty, " pseudo interface\n"); return; } else if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) { - vty_outln (vty, " index %d inactive interface", + vty_out (vty, " index %d inactive interface\n", ifp->ifindex); return; } @@ -1077,11 +1171,11 @@ if_dump_vty (struct vty *vty, struct interface *ifp) ifp->ifindex, ifp->metric, ifp->mtu, ifp->speed); if (ifp->mtu6 != ifp->mtu) vty_out (vty, "mtu6 %d ", ifp->mtu6); - vty_outln (vty, "%s flags: %s", VTYNL, + vty_out (vty, "\n flags: %s\n", if_flag_dump(ifp->flags)); /* Hardware address. */ - vty_outln (vty, " Type: %s", if_link_type_str(ifp->ll_type)); + vty_out (vty, " Type: %s\n", if_link_type_str(ifp->ll_type)); if (ifp->hw_addr_len != 0) { int i; @@ -1089,14 +1183,14 @@ if_dump_vty (struct vty *vty, struct interface *ifp) vty_out (vty, " HWaddr: "); for (i = 0; i < ifp->hw_addr_len; i++) vty_out (vty, "%s%02x", i == 0 ? "" : ":", ifp->hw_addr[i]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* Bandwidth in Mbps */ if (ifp->bandwidth != 0) { vty_out(vty, " bandwidth %u Mbps", ifp->bandwidth); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } for (rn = route_top (zebra_if->ipv4_subnets); rn; rn = route_next (rn)) @@ -1115,27 +1209,72 @@ if_dump_vty (struct vty *vty, struct interface *ifp) connected_dump_vty (vty, connected); } + vty_out(vty, " Interface Type %s\n", + zebra_ziftype_2str (zebra_if->zif_type)); + if (IS_ZEBRA_IF_BRIDGE (ifp)) + { + struct zebra_l2info_bridge *bridge_info; + + bridge_info = &zebra_if->l2info.br; + vty_out(vty, " Bridge VLAN-aware: %s\n", + bridge_info->vlan_aware ? "yes" : "no"); + } + else if (IS_ZEBRA_IF_VLAN(ifp)) + { + struct zebra_l2info_vlan *vlan_info; + + vlan_info = &zebra_if->l2info.vl; + vty_out(vty, " VLAN Id %u\n", + vlan_info->vid); + } + else if (IS_ZEBRA_IF_VXLAN (ifp)) + { + struct zebra_l2info_vxlan *vxlan_info; + + vxlan_info = &zebra_if->l2info.vxl; + vty_out(vty, " VxLAN Id %u", vxlan_info->vni); + if (vxlan_info->vtep_ip.s_addr != INADDR_ANY) + vty_out(vty, " VTEP IP: %s", inet_ntoa (vxlan_info->vtep_ip)); + if (vxlan_info->access_vlan) + vty_out(vty, " Access VLAN Id %u", vxlan_info->access_vlan); + vty_out(vty, "\n"); + } + + if (IS_ZEBRA_IF_BRIDGE_SLAVE (ifp)) + { + struct zebra_l2info_brslave *br_slave; + + br_slave = &zebra_if->brslave_info; + if (br_slave->bridge_ifindex != IFINDEX_INTERNAL) + vty_out(vty, " Master (bridge) ifindex %u\n", + br_slave->bridge_ifindex); + } + + if (zebra_if->link_ifindex != IFINDEX_INTERNAL) + vty_out(vty, " Link ifindex %u\n", + zebra_if->link_ifindex); + if (HAS_LINK_PARAMS(ifp)) { int i; struct if_link_params *iflp = ifp->link_params; - vty_outln (vty, " Traffic Engineering Link Parameters:"); + vty_out (vty, " Traffic Engineering Link Parameters:\n"); if (IS_PARAM_SET(iflp, LP_TE_METRIC)) - vty_outln (vty, " TE metric %u",iflp->te_metric); + vty_out (vty, " TE metric %u\n",iflp->te_metric); if (IS_PARAM_SET(iflp, LP_MAX_BW)) - vty_outln (vty, " Maximum Bandwidth %g (Byte/s)", iflp->max_bw); + vty_out (vty, " Maximum Bandwidth %g (Byte/s)\n", iflp->max_bw); if (IS_PARAM_SET(iflp, LP_MAX_RSV_BW)) - vty_outln (vty, " Maximum Reservable Bandwidth %g (Byte/s)", + vty_out (vty, " Maximum Reservable Bandwidth %g (Byte/s)\n", iflp->max_rsv_bw); if (IS_PARAM_SET(iflp, LP_UNRSV_BW)) { - vty_outln (vty, " Unreserved Bandwidth per Class Type in Byte/s:"); + vty_out (vty, " Unreserved Bandwidth per Class Type in Byte/s:\n"); for (i = 0; i < MAX_CLASS_TYPE; i+=2) - vty_outln (vty, " [%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)", + vty_out (vty, " [%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", i, iflp->unrsv_bw[i], i+1, iflp->unrsv_bw[i + 1]); } if (IS_PARAM_SET(iflp, LP_ADM_GRP)) - vty_outln (vty, " Administrative Group:%u", iflp->admin_grp); + vty_out (vty, " Administrative Group:%u\n", iflp->admin_grp); if (IS_PARAM_SET(iflp, LP_DELAY)) { vty_out(vty, " Link Delay Average: %u (micro-sec.)", iflp->av_delay); @@ -1144,21 +1283,21 @@ if_dump_vty (struct vty *vty, struct interface *ifp) vty_out(vty, " Min: %u (micro-sec.)", iflp->min_delay); vty_out(vty, " Max: %u (micro-sec.)", iflp->max_delay); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (IS_PARAM_SET(iflp, LP_DELAY_VAR)) - vty_outln (vty, " Link Delay Variation %u (micro-sec.)", + vty_out (vty, " Link Delay Variation %u (micro-sec.)\n", iflp->delay_var); if (IS_PARAM_SET(iflp, LP_PKT_LOSS)) - vty_outln (vty, " Link Packet Loss %g (in %%)", iflp->pkt_loss); + vty_out (vty, " Link Packet Loss %g (in %%)\n", iflp->pkt_loss); if (IS_PARAM_SET(iflp, LP_AVA_BW)) - vty_outln (vty, " Available Bandwidth %g (Byte/s)", iflp->ava_bw); + vty_out (vty, " Available Bandwidth %g (Byte/s)\n", iflp->ava_bw); if (IS_PARAM_SET(iflp, LP_RES_BW)) - vty_outln (vty, " Residual Bandwidth %g (Byte/s)", iflp->res_bw); + vty_out (vty, " Residual Bandwidth %g (Byte/s)\n", iflp->res_bw); if (IS_PARAM_SET(iflp, LP_USE_BW)) - vty_outln (vty, " Utilized Bandwidth %g (Byte/s)", iflp->use_bw); + vty_out (vty, " Utilized Bandwidth %g (Byte/s)\n", iflp->use_bw); if (IS_PARAM_SET(iflp, LP_RMT_AS)) - vty_outln (vty, " Neighbor ASBR IP: %s AS: %u ", inet_ntoa(iflp->rmt_ip), + vty_out (vty, " Neighbor ASBR IP: %s AS: %u \n", inet_ntoa(iflp->rmt_ip), iflp->rmt_as); } @@ -1169,82 +1308,82 @@ if_dump_vty (struct vty *vty, struct interface *ifp) nd_dump_vty (vty, ifp); #endif /* HAVE_RTADV */ if (listhead(ifp->nbr_connected)) - vty_outln (vty, " Neighbor address(s):"); + vty_out (vty, " Neighbor address(s):\n"); for (ALL_LIST_ELEMENTS_RO (ifp->nbr_connected, node, nbr_connected)) nbr_connected_dump_vty (vty, nbr_connected); #ifdef HAVE_PROC_NET_DEV /* Statistics print out using proc file system. */ - vty_outln (vty, " %lu input packets (%lu multicast), %lu bytes, " - "%lu dropped", + vty_out (vty, " %lu input packets (%lu multicast), %lu bytes, " + "%lu dropped\n", ifp->stats.rx_packets, ifp->stats.rx_multicast, ifp->stats.rx_bytes, ifp->stats.rx_dropped); - vty_outln (vty, " %lu input errors, %lu length, %lu overrun," - " %lu CRC, %lu frame", + vty_out (vty, " %lu input errors, %lu length, %lu overrun," + " %lu CRC, %lu frame\n", ifp->stats.rx_errors, ifp->stats.rx_length_errors, ifp->stats.rx_over_errors, ifp->stats.rx_crc_errors, ifp->stats.rx_frame_errors); - vty_outln (vty, " %lu fifo, %lu missed", ifp->stats.rx_fifo_errors, + vty_out (vty, " %lu fifo, %lu missed\n", ifp->stats.rx_fifo_errors, ifp->stats.rx_missed_errors); - vty_outln (vty, " %lu output packets, %lu bytes, %lu dropped", + vty_out (vty, " %lu output packets, %lu bytes, %lu dropped\n", ifp->stats.tx_packets, ifp->stats.tx_bytes, ifp->stats.tx_dropped); - vty_outln (vty, " %lu output errors, %lu aborted, %lu carrier," - " %lu fifo, %lu heartbeat", + vty_out (vty, " %lu output errors, %lu aborted, %lu carrier," + " %lu fifo, %lu heartbeat\n", ifp->stats.tx_errors, ifp->stats.tx_aborted_errors, ifp->stats.tx_carrier_errors, ifp->stats.tx_fifo_errors, ifp->stats.tx_heartbeat_errors); - vty_outln (vty, " %lu window, %lu collisions", + vty_out (vty, " %lu window, %lu collisions\n", ifp->stats.tx_window_errors, ifp->stats.collisions); #endif /* HAVE_PROC_NET_DEV */ #ifdef HAVE_NET_RT_IFLIST #if defined (__bsdi__) || defined (__NetBSD__) /* Statistics print out using sysctl (). */ - vty_outln (vty, " input packets %llu, bytes %llu, dropped %llu," - " multicast packets %llu", + vty_out (vty, " input packets %llu, bytes %llu, dropped %llu," + " multicast packets %llu\n", (unsigned long long)ifp->stats.ifi_ipackets, (unsigned long long)ifp->stats.ifi_ibytes, (unsigned long long)ifp->stats.ifi_iqdrops, (unsigned long long)ifp->stats.ifi_imcasts); - vty_outln (vty, " input errors %llu", + vty_out (vty, " input errors %llu\n", (unsigned long long)ifp->stats.ifi_ierrors); - vty_outln (vty, " output packets %llu, bytes %llu," - " multicast packets %llu", + vty_out (vty, " output packets %llu, bytes %llu," + " multicast packets %llu\n", (unsigned long long)ifp->stats.ifi_opackets, (unsigned long long)ifp->stats.ifi_obytes, (unsigned long long)ifp->stats.ifi_omcasts); - vty_outln (vty, " output errors %llu", + vty_out (vty, " output errors %llu\n", (unsigned long long)ifp->stats.ifi_oerrors); - vty_outln (vty, " collisions %llu", + vty_out (vty, " collisions %llu\n", (unsigned long long)ifp->stats.ifi_collisions); #else /* Statistics print out using sysctl (). */ - vty_outln (vty, " input packets %lu, bytes %lu, dropped %lu," - " multicast packets %lu", + vty_out (vty, " input packets %lu, bytes %lu, dropped %lu," + " multicast packets %lu\n", ifp->stats.ifi_ipackets, ifp->stats.ifi_ibytes, ifp->stats.ifi_iqdrops,ifp->stats.ifi_imcasts); - vty_outln (vty, " input errors %lu", + vty_out (vty, " input errors %lu\n", ifp->stats.ifi_ierrors); - vty_outln (vty, " output packets %lu, bytes %lu, multicast packets %lu", + vty_out (vty, " output packets %lu, bytes %lu, multicast packets %lu\n", ifp->stats.ifi_opackets, ifp->stats.ifi_obytes, ifp->stats.ifi_omcasts); - vty_outln (vty, " output errors %lu", + vty_out (vty, " output errors %lu\n", ifp->stats.ifi_oerrors); - vty_outln (vty, " collisions %lu", + vty_out (vty, " collisions %lu\n", ifp->stats.ifi_collisions); #endif /* __bsdi__ || __NetBSD__ */ #endif /* HAVE_NET_RT_IFLIST */ @@ -1340,7 +1479,7 @@ DEFUN (show_interface_name_vrf, ifp = if_lookup_by_name (argv[idx_ifname]->arg, vrf_id); if (ifp == NULL) { - vty_outln (vty, "%% Can't find interface %s",argv[idx_ifname]->arg); + vty_out (vty, "%% Can't find interface %s\n",argv[idx_ifname]->arg); return CMD_WARNING; } if_dump_vty (vty, ifp); @@ -1378,7 +1517,7 @@ DEFUN (show_interface_name_vrf_all, if (!found) { - vty_outln (vty, "%% Can't find interface %s", argv[idx_ifname]->arg); + vty_out (vty, "%% Can't find interface %s\n", argv[idx_ifname]->arg); return CMD_WARNING; } @@ -1392,7 +1531,7 @@ if_show_description (struct vty *vty, vrf_id_t vrf_id) struct listnode *node; struct interface *ifp; - vty_outln (vty, "Interface Status Protocol Description"); + vty_out (vty, "Interface Status Protocol Description\n"); for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp)) { int len; @@ -1422,7 +1561,7 @@ if_show_description (struct vty *vty, vrf_id_t vrf_id) if (ifp->desc) vty_out (vty, "%s", ifp->desc); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } @@ -1458,8 +1597,7 @@ DEFUN (show_interface_desc_vrf_all, RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) if (!list_isempty (vrf->iflist)) { - vty_outln (vty, "%s\tVRF %u%s", VTYNL, vrf->vrf_id, - VTYNL); + vty_out (vty, "\n\tVRF %u\n\n", vrf->vrf_id); if_show_description (vty, vrf->vrf_id); } @@ -1480,8 +1618,8 @@ DEFUN (multicast, ret = if_set_flags (ifp, IFF_MULTICAST); if (ret < 0) { - vty_outln (vty, "Can't set multicast flag"); - return CMD_WARNING; + vty_out (vty, "Can't set multicast flag\n"); + return CMD_WARNING_CONFIG_FAILED; } if_refresh (ifp); } @@ -1506,8 +1644,8 @@ DEFUN (no_multicast, ret = if_unset_flags (ifp, IFF_MULTICAST); if (ret < 0) { - vty_outln (vty, "Can't unset multicast flag"); - return CMD_WARNING; + vty_out (vty, "Can't unset multicast flag\n"); + return CMD_WARNING_CONFIG_FAILED; } if_refresh (ifp); } @@ -1572,8 +1710,8 @@ DEFUN (shutdown_if, ret = if_unset_flags (ifp, IFF_UP); if (ret < 0) { - vty_outln (vty, "Can't shutdown interface"); - return CMD_WARNING; + vty_out (vty, "Can't shutdown interface\n"); + return CMD_WARNING_CONFIG_FAILED; } if_refresh (ifp); } @@ -1598,8 +1736,8 @@ DEFUN (no_shutdown_if, ret = if_set_flags (ifp, IFF_UP | IFF_RUNNING); if (ret < 0) { - vty_outln (vty, "Can't up interface"); - return CMD_WARNING; + vty_out (vty, "Can't up interface\n"); + return CMD_WARNING_CONFIG_FAILED; } if_refresh (ifp); @@ -1630,8 +1768,8 @@ DEFUN (bandwidth_if, /* bandwidth range is <1-100000> */ if (bandwidth < 1 || bandwidth > 100000) { - vty_outln (vty, "Bandwidth is invalid"); - return CMD_WARNING; + vty_out (vty, "Bandwidth is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } ifp->bandwidth = bandwidth; @@ -1755,7 +1893,7 @@ DEFUN (link_params_enable, if (IS_ZEBRA_DEBUG_EVENT) zlog_debug ("Link-params: failed to init TE link parameters %s", ifp->name); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* force protocols to update LINK STATE due to parameters change */ @@ -1832,8 +1970,8 @@ DEFUN (link_params_maxbw, if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { - vty_outln (vty, "link_params_maxbw: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "link_params_maxbw: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } /* Check that Maximum bandwidth is not lower than other bandwidth parameters */ @@ -1850,9 +1988,9 @@ DEFUN (link_params_maxbw, || (bw <= iflp->res_bw) || (bw <= iflp->use_bw)) { - vty_outln (vty, - "Maximum Bandwidth could not be lower than others bandwidth"); - return CMD_WARNING; + vty_out (vty, + "Maximum Bandwidth could not be lower than others bandwidth\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Update Maximum Bandwidth if needed */ @@ -1874,18 +2012,18 @@ DEFUN (link_params_max_rsv_bw, if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { - vty_outln (vty, "link_params_max_rsv_bw: fscanf: %s", + vty_out (vty, "link_params_max_rsv_bw: fscanf: %s\n", safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Check that bandwidth is not greater than maximum bandwidth parameter */ if (bw > iflp->max_bw) { - vty_outln (vty, - "Maximum Reservable Bandwidth could not be greater than Maximum Bandwidth (%g)", + vty_out (vty, + "Maximum Reservable Bandwidth could not be greater than Maximum Bandwidth (%g)\n", iflp->max_bw); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Update Maximum Reservable Bandwidth if needed */ @@ -1911,25 +2049,25 @@ DEFUN (link_params_unrsv_bw, /* We don't have to consider about range check here. */ if (sscanf (argv[idx_number]->arg, "%d", &priority) != 1) { - vty_outln (vty, "link_params_unrsv_bw: fscanf: %s", + vty_out (vty, "link_params_unrsv_bw: fscanf: %s\n", safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { - vty_outln (vty, "link_params_unrsv_bw: fscanf: %s", + vty_out (vty, "link_params_unrsv_bw: fscanf: %s\n", safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Check that bandwidth is not greater than maximum bandwidth parameter */ if (bw > iflp->max_bw) { - vty_outln (vty, - "UnReserved Bandwidth could not be greater than Maximum Bandwidth (%g)", + vty_out (vty, + "UnReserved Bandwidth could not be greater than Maximum Bandwidth (%g)\n", iflp->max_bw); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Update Unreserved Bandwidth if needed */ @@ -1951,9 +2089,9 @@ DEFUN (link_params_admin_grp, if (sscanf (argv[idx_bitpattern]->arg, "0x%lx", &value) != 1) { - vty_outln (vty, "link_params_admin_grp: fscanf: %s", + vty_out (vty, "link_params_admin_grp: fscanf: %s\n", safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Update Administrative Group if needed */ @@ -1995,8 +2133,8 @@ DEFUN (link_params_inter_as, if (!inet_aton (argv[idx_ipv4]->arg, &addr)) { - vty_outln (vty, "Please specify Router-Addr by A.B.C.D"); - return CMD_WARNING; + vty_out (vty, "Please specify Router-Addr by A.B.C.D\n"); + return CMD_WARNING_CONFIG_FAILED; } as = strtoul(argv[idx_number]->arg, NULL, 10); @@ -2069,9 +2207,9 @@ DEFUN (link_params_delay, if (IS_PARAM_SET(iflp, LP_MM_DELAY) && (delay <= iflp->min_delay || delay >= iflp->max_delay)) { - vty_outln (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay", + vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay\n", iflp->min_delay, iflp->max_delay); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Update delay if value is not set or change */ if (IS_PARAM_UNSET(iflp, LP_DELAY)|| iflp->av_delay != delay) @@ -2094,9 +2232,9 @@ DEFUN (link_params_delay, /* Check new delays value coherency */ if (delay <= low || delay >= high) { - vty_outln (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay", + vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay\n", low, high); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Update Delays if needed */ if (IS_PARAM_UNSET(iflp, LP_DELAY) @@ -2190,9 +2328,9 @@ DEFUN (link_params_pkt_loss, if (sscanf (argv[idx_percentage]->arg, "%g", &fval) != 1) { - vty_outln (vty, "link_params_pkt_loss: fscanf: %s", + vty_out (vty, "link_params_pkt_loss: fscanf: %s\n", safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } if (fval > MAX_PKT_LOSS) @@ -2231,17 +2369,17 @@ DEFUN (link_params_res_bw, if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { - vty_outln (vty, "link_params_res_bw: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "link_params_res_bw: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } /* Check that bandwidth is not greater than maximum bandwidth parameter */ if (bw > iflp->max_bw) { - vty_outln (vty, - "Residual Bandwidth could not be greater than Maximum Bandwidth (%g)", + vty_out (vty, + "Residual Bandwidth could not be greater than Maximum Bandwidth (%g)\n", iflp->max_bw); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Update Residual Bandwidth if needed */ @@ -2277,17 +2415,17 @@ DEFUN (link_params_ava_bw, if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { - vty_outln (vty, "link_params_ava_bw: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "link_params_ava_bw: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } /* Check that bandwidth is not greater than maximum bandwidth parameter */ if (bw > iflp->max_bw) { - vty_outln (vty, - "Available Bandwidth could not be greater than Maximum Bandwidth (%g)", + vty_out (vty, + "Available Bandwidth could not be greater than Maximum Bandwidth (%g)\n", iflp->max_bw); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Update Residual Bandwidth if needed */ @@ -2323,17 +2461,17 @@ DEFUN (link_params_use_bw, if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { - vty_outln (vty, "link_params_use_bw: fscanf: %s",safe_strerror(errno)); - return CMD_WARNING; + vty_out (vty, "link_params_use_bw: fscanf: %s\n",safe_strerror(errno)); + return CMD_WARNING_CONFIG_FAILED; } /* Check that bandwidth is not greater than maximum bandwidth parameter */ if (bw > iflp->max_bw) { - vty_outln (vty, - "Utilised Bandwidth could not be greater than Maximum Bandwidth (%g)", + vty_out (vty, + "Utilised Bandwidth could not be greater than Maximum Bandwidth (%g)\n", iflp->max_bw); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* Update Utilized Bandwidth if needed */ @@ -2372,14 +2510,14 @@ ip_address_install (struct vty *vty, struct interface *ifp, ret = str2prefix_ipv4 (addr_str, &cp); if (ret <= 0) { - vty_outln (vty, "%% Malformed address "); - return CMD_WARNING; + vty_out (vty, "%% Malformed address \n"); + return CMD_WARNING_CONFIG_FAILED; } if (ipv4_martian(&cp.prefix)) { - vty_outln (vty, "%% Invalid address"); - return CMD_WARNING; + vty_out (vty, "%% Invalid address\n"); + return CMD_WARNING_CONFIG_FAILED; } ifc = connected_check (ifp, (struct prefix *) &cp); @@ -2429,9 +2567,9 @@ ip_address_install (struct vty *vty, struct interface *ifp, ret = if_set_prefix (ifp, ifc); if (ret < 0) { - vty_outln (vty, "%% Can't set interface IP address: %s.", + vty_out (vty, "%% Can't set interface IP address: %s.\n", safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); @@ -2456,21 +2594,21 @@ ip_address_uninstall (struct vty *vty, struct interface *ifp, ret = str2prefix_ipv4 (addr_str, &cp); if (ret <= 0) { - vty_outln (vty, "%% Malformed address "); - return CMD_WARNING; + vty_out (vty, "%% Malformed address \n"); + return CMD_WARNING_CONFIG_FAILED; } /* Check current interface address. */ ifc = connected_check (ifp, (struct prefix *) &cp); if (! ifc) { - vty_outln (vty, "%% Can't find address"); - return CMD_WARNING; + vty_out (vty, "%% Can't find address\n"); + return CMD_WARNING_CONFIG_FAILED; } /* This is not configured address. */ if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); @@ -2480,16 +2618,16 @@ ip_address_uninstall (struct vty *vty, struct interface *ifp, { listnode_delete (ifp->connected, ifc); connected_free (ifc); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* This is real route. */ ret = if_unset_prefix (ifp, ifc); if (ret < 0) { - vty_outln (vty, "%% Can't unset interface IP address: %s.", + vty_out (vty, "%% Can't unset interface IP address: %s.\n", safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); /* we will receive a kernel notification about this route being removed. @@ -2572,14 +2710,14 @@ ipv6_address_install (struct vty *vty, struct interface *ifp, ret = str2prefix_ipv6 (addr_str, &cp); if (ret <= 0) { - vty_outln (vty, "%% Malformed address "); - return CMD_WARNING; + vty_out (vty, "%% Malformed address \n"); + return CMD_WARNING_CONFIG_FAILED; } if (ipv6_martian(&cp.prefix)) { - vty_outln (vty, "%% Invalid address"); - return CMD_WARNING; + vty_out (vty, "%% Invalid address\n"); + return CMD_WARNING_CONFIG_FAILED; } ifc = connected_check (ifp, (struct prefix *) &cp); @@ -2625,9 +2763,9 @@ ipv6_address_install (struct vty *vty, struct interface *ifp, if (ret < 0) { - vty_outln (vty, "%% Can't set interface IP address: %s.", + vty_out (vty, "%% Can't set interface IP address: %s.\n", safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); @@ -2665,21 +2803,21 @@ ipv6_address_uninstall (struct vty *vty, struct interface *ifp, ret = str2prefix_ipv6 (addr_str, &cp); if (ret <= 0) { - vty_outln (vty, "%% Malformed address "); - return CMD_WARNING; + vty_out (vty, "%% Malformed address \n"); + return CMD_WARNING_CONFIG_FAILED; } /* Check current interface address. */ ifc = connected_check (ifp, (struct prefix *) &cp); if (! ifc) { - vty_outln (vty, "%% Can't find address"); - return CMD_WARNING; + vty_out (vty, "%% Can't find address\n"); + return CMD_WARNING_CONFIG_FAILED; } /* This is not configured address. */ if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); @@ -2689,16 +2827,16 @@ ipv6_address_uninstall (struct vty *vty, struct interface *ifp, { listnode_delete (ifp->connected, ifc); connected_free (ifc); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } /* This is real route. */ ret = if_prefix_delete_ipv6 (ifp, ifc); if (ret < 0) { - vty_outln (vty, "%% Can't unset interface IP address: %s.", + vty_out (vty, "%% Can't unset interface IP address: %s.\n", safe_strerror(errno)); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); @@ -2742,23 +2880,23 @@ link_params_config_write (struct vty *vty, struct interface *ifp) struct if_link_params *iflp = ifp->link_params; - vty_outln (vty, " link-params"); - vty_outln (vty, " enable"); + vty_out (vty, " link-params\n"); + vty_out (vty, " enable\n"); if (IS_PARAM_SET(iflp, LP_TE_METRIC) && iflp->te_metric != ifp->metric) - vty_outln (vty, " metric %u",iflp->te_metric); + vty_out (vty, " metric %u\n",iflp->te_metric); if (IS_PARAM_SET(iflp, LP_MAX_BW) && iflp->max_bw != iflp->default_bw) - vty_outln (vty, " max-bw %g", iflp->max_bw); + vty_out (vty, " max-bw %g\n", iflp->max_bw); if (IS_PARAM_SET(iflp, LP_MAX_RSV_BW) && iflp->max_rsv_bw != iflp->default_bw) - vty_outln (vty, " max-rsv-bw %g", iflp->max_rsv_bw); + vty_out (vty, " max-rsv-bw %g\n", iflp->max_rsv_bw); if (IS_PARAM_SET(iflp, LP_UNRSV_BW)) { for (i = 0; i < 8; i++) if (iflp->unrsv_bw[i] != iflp->default_bw) - vty_outln (vty, " unrsv-bw %d %g", + vty_out (vty, " unrsv-bw %d %g\n", i, iflp->unrsv_bw[i]); } if (IS_PARAM_SET(iflp, LP_ADM_GRP)) - vty_outln (vty, " admin-grp 0x%x", iflp->admin_grp); + vty_out (vty, " admin-grp 0x%x\n", iflp->admin_grp); if (IS_PARAM_SET(iflp, LP_DELAY)) { vty_out(vty, " delay %u", iflp->av_delay); @@ -2767,22 +2905,22 @@ link_params_config_write (struct vty *vty, struct interface *ifp) vty_out(vty, " min %u", iflp->min_delay); vty_out(vty, " max %u", iflp->max_delay); } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } if (IS_PARAM_SET(iflp, LP_DELAY_VAR)) - vty_outln (vty, " delay-variation %u", iflp->delay_var); + vty_out (vty, " delay-variation %u\n", iflp->delay_var); if (IS_PARAM_SET(iflp, LP_PKT_LOSS)) - vty_outln (vty, " packet-loss %g", iflp->pkt_loss); + vty_out (vty, " packet-loss %g\n", iflp->pkt_loss); if (IS_PARAM_SET(iflp, LP_AVA_BW)) - vty_outln (vty, " ava-bw %g", iflp->ava_bw); + vty_out (vty, " ava-bw %g\n", iflp->ava_bw); if (IS_PARAM_SET(iflp, LP_RES_BW)) - vty_outln (vty, " res-bw %g", iflp->res_bw); + vty_out (vty, " res-bw %g\n", iflp->res_bw); if (IS_PARAM_SET(iflp, LP_USE_BW)) - vty_outln (vty, " use-bw %g", iflp->use_bw); + vty_out (vty, " use-bw %g\n", iflp->use_bw); if (IS_PARAM_SET(iflp, LP_RMT_AS)) - vty_outln (vty, " neighbor %s as %u", inet_ntoa(iflp->rmt_ip), + vty_out (vty, " neighbor %s as %u\n", inet_ntoa(iflp->rmt_ip), iflp->rmt_as); - vty_outln (vty, " exit-link-params"); + vty_out (vty, " exit-link-params\n"); return 0; } @@ -2808,28 +2946,28 @@ if_config_write (struct vty *vty) vrf = vrf_lookup_by_id (ifp->vrf_id); if (ifp->vrf_id == VRF_DEFAULT) - vty_outln (vty, "interface %s", ifp->name); + vty_out (vty, "interface %s\n", ifp->name); else - vty_outln (vty, "interface %s vrf %s", ifp->name,vrf->name); + vty_out (vty, "interface %s vrf %s\n", ifp->name,vrf->name); if (if_data) { if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) - vty_outln (vty, " shutdown"); + vty_out (vty, " shutdown\n"); zebra_ptm_if_write(vty, if_data); } if (ifp->desc) - vty_outln (vty, " description %s",ifp->desc); + vty_out (vty, " description %s\n",ifp->desc); /* Assign bandwidth here to avoid unnecessary interface flap while processing config script */ if (ifp->bandwidth != 0) - vty_outln (vty, " bandwidth %u", ifp->bandwidth); + vty_out (vty, " bandwidth %u\n", ifp->bandwidth); if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) - vty_outln (vty, " no link-detect"); + vty_out (vty, " no link-detect\n"); for (ALL_LIST_ELEMENTS_RO (ifp->connected, addrnode, ifc)) { @@ -2844,14 +2982,14 @@ if_config_write (struct vty *vty) if (ifc->label) vty_out (vty, " label %s", ifc->label); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } if (if_data) { if (if_data->multicast != IF_ZEBRA_MULTICAST_UNSPEC) - vty_outln (vty, " %smulticast", + vty_out (vty, " %smulticast\n", if_data->multicast == IF_ZEBRA_MULTICAST_ON ? "" : "no "); } @@ -2865,7 +3003,7 @@ if_config_write (struct vty *vty) link_params_config_write (vty, ifp); - vty_outln (vty, "!"); + vty_out (vty, "!\n"); } return 0; } diff --git a/zebra/interface.h b/zebra/interface.h index b276edc35..f5ca00c4a 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -28,6 +28,8 @@ #include "zebra/irdp.h" #endif +#include "zebra/zebra_l2.h" + /* For interface multicast configuration. */ #define IF_ZEBRA_MULTICAST_UNSPEC 0 #define IF_ZEBRA_MULTICAST_ON 1 @@ -180,6 +182,25 @@ struct rtadvconf #endif /* HAVE_RTADV */ +/* Zebra interface type - ones of interest. */ +typedef enum +{ + ZEBRA_IF_VXLAN, /* VxLAN interface */ + ZEBRA_IF_VRF, /* VRF device */ + ZEBRA_IF_BRIDGE, /* bridge device */ + ZEBRA_IF_VLAN, /* VLAN sub-interface */ + ZEBRA_IF_OTHER, /* Anything else */ +} zebra_iftype_t; + +/* Zebra "slave" interface type */ +typedef enum +{ + ZEBRA_IF_SLAVE_NONE, /* Not a slave */ + ZEBRA_IF_SLAVE_VRF, /* Member of a VRF */ + ZEBRA_IF_SLAVE_BRIDGE, /* Member of a bridge */ + ZEBRA_IF_SLAVE_OTHER, /* Something else - e.g., bond slave */ +} zebra_slave_iftype_t; + /* `zebra' daemon local interface structure. */ struct zebra_if { @@ -231,8 +252,53 @@ struct zebra_if /* ptm enable configuration */ u_char ptm_enable; + + /* Zebra interface and "slave" interface type */ + zebra_iftype_t zif_type; + zebra_slave_iftype_t zif_slave_type; + + /* Additional L2 info, depends on zif_type */ + union zebra_l2if_info l2info; + + /* For members of a bridge, link to bridge. */ + /* Note: If additional fields become necessary, this can be modified to + * be a pointer to a dynamically allocd struct. + */ + struct zebra_l2info_brslave brslave_info; + + /* Link fields - for sub-interfaces. */ + ifindex_t link_ifindex; + struct interface *link; }; +static inline void +zebra_if_set_ziftype (struct interface *ifp, zebra_iftype_t zif_type, + zebra_slave_iftype_t zif_slave_type) +{ + struct zebra_if *zif; + + zif = (struct zebra_if *)ifp->info; + zif->zif_type = zif_type; + zif->zif_slave_type = zif_slave_type; +} + +#define IS_ZEBRA_IF_VRF(ifp) \ + (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF) + +#define IS_ZEBRA_IF_BRIDGE(ifp) \ + (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_BRIDGE) + +#define IS_ZEBRA_IF_VLAN(ifp) \ + (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VLAN) + +#define IS_ZEBRA_IF_VXLAN(ifp) \ + (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VXLAN) + +#define IS_ZEBRA_IF_BRIDGE_SLAVE(ifp) \ + (((struct zebra_if *)(ifp->info))->zif_slave_type == ZEBRA_IF_SLAVE_BRIDGE) + +#define IS_ZEBRA_IF_VRF_SLAVE(ifp) \ + (((struct zebra_if *)(ifp->info))->zif_slave_type == ZEBRA_IF_SLAVE_VRF) extern struct interface *if_lookup_by_index_per_ns (struct zebra_ns *, u_int32_t); extern struct interface *if_lookup_by_name_per_ns (struct zebra_ns *, const char *); @@ -253,6 +319,7 @@ extern int if_subnet_add (struct interface *, struct connected *); extern int if_subnet_delete (struct interface *, struct connected *); extern int ipv6_address_configured (struct interface *ifp); extern void if_handle_vrf_change (struct interface *ifp, vrf_id_t vrf_id); +extern void zebra_if_update_link (struct interface *ifp, ifindex_t link_ifindex); extern void vrf_add_update (struct vrf *vrfp); diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index ca932ac43..323e94818 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -343,28 +343,28 @@ void irdp_config_write (struct vty *vty, struct interface *ifp) if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) { if( irdp->flags & IF_SHUTDOWN) - vty_outln (vty, " ip irdp shutdown "); + vty_out (vty, " ip irdp shutdown \n"); if( irdp->flags & IF_BROADCAST) - vty_outln (vty, " ip irdp broadcast"); + vty_out (vty, " ip irdp broadcast\n"); else - vty_outln (vty, " ip irdp multicast"); + vty_out (vty, " ip irdp multicast\n"); - vty_outln (vty, " ip irdp preference %ld", + vty_out (vty, " ip irdp preference %ld\n", irdp->Preference); for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv)) - vty_outln (vty, " ip irdp address %s preference %d", + vty_out (vty, " ip irdp address %s preference %d\n", inet_2a(adv->ip.s_addr, b1), adv->pref); - vty_outln (vty, " ip irdp holdtime %d", + vty_out (vty, " ip irdp holdtime %d\n", irdp->Lifetime); - vty_outln (vty, " ip irdp minadvertinterval %ld", + vty_out (vty, " ip irdp minadvertinterval %ld\n", irdp->MinAdvertInterval); - vty_outln (vty, " ip irdp maxadvertinterval %ld", + vty_out (vty, " ip irdp maxadvertinterval %ld\n", irdp->MaxAdvertInterval); } @@ -478,9 +478,9 @@ DEFUN (ip_irdp_minadvertinterval, return CMD_SUCCESS; } else { - vty_outln (vty, "%% MinAdvertInterval must be less than or equal to " - "MaxAdvertInterval"); - return CMD_WARNING; + vty_out (vty, "%% MinAdvertInterval must be less than or equal to " + "MaxAdvertInterval\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -505,9 +505,9 @@ DEFUN (ip_irdp_maxadvertinterval, return CMD_SUCCESS; } else { - vty_outln (vty, "%% MaxAdvertInterval must be greater than or equal to " - "MinAdvertInterval"); - return CMD_WARNING; + vty_out (vty, "%% MaxAdvertInterval must be greater than or equal to " + "MinAdvertInterval\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -561,7 +561,7 @@ DEFUN (ip_irdp_address_preference, irdp=&zi->irdp; ret = inet_aton(argv[idx_ipv4]->arg, &ip); - if(!ret) return CMD_WARNING; + if(!ret) return CMD_WARNING_CONFIG_FAILED; pref = atoi(argv[idx_number]->arg); @@ -603,7 +603,7 @@ DEFUN (no_ip_irdp_address_preference, ret = inet_aton(argv[idx_ipv4]->arg, &ip); if (!ret) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; for (ALL_LIST_ELEMENTS (irdp->AdvPrefList, node, nnode, adv)) { diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index 3570676a4..91d4946b5 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -269,6 +269,12 @@ netlink_information_fetch (struct sockaddr_nl *snl, struct nlmsghdr *h, case RTM_DELADDR: return netlink_interface_addr (snl, h, ns_id, startup); break; + case RTM_NEWNEIGH: + return netlink_neigh_change (snl, h, ns_id); + break; + case RTM_DELNEIGH: + return netlink_neigh_change (snl, h, ns_id); + break; default: zlog_warn ("Unknown netlink nlmsg_type %d vrf %u\n", h->nlmsg_type, ns_id); @@ -297,17 +303,21 @@ static void netlink_install_filter (int sock, __u32 pid) struct sock_filter filter[] = { /* 0: ldh [4] */ BPF_STMT(BPF_LD|BPF_ABS|BPF_H, offsetof(struct nlmsghdr, nlmsg_type)), - /* 1: jeq 0x18 jt 3 jf 6 */ - BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_NEWROUTE), 1, 0), - /* 2: jeq 0x19 jt 3 jf 6 */ - BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_DELROUTE), 0, 3), - /* 3: ldw [12] */ + /* 1: jeq 0x18 jt 5 jf next */ + BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_NEWROUTE), 3, 0), + /* 2: jeq 0x19 jt 5 jf next */ + BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_DELROUTE), 2, 0), + /* 3: jeq 0x19 jt 5 jf next */ + BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_NEWNEIGH), 1, 0), + /* 4: jeq 0x19 jt 5 jf 8 */ + BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_DELNEIGH), 0, 3), + /* 5: ldw [12] */ BPF_STMT(BPF_LD|BPF_ABS|BPF_W, offsetof(struct nlmsghdr, nlmsg_pid)), - /* 4: jeq XX jt 5 jf 6 */ + /* 6: jeq XX jt 7 jf 8 */ BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htonl(pid), 0, 1), - /* 5: ret 0 (skip) */ + /* 7: ret 0 (skip) */ BPF_STMT(BPF_RET|BPF_K, 0), - /* 6: ret 0xffff (keep) */ + /* 8: ret 0xffff (keep) */ BPF_STMT(BPF_RET|BPF_K, 0xffff), }; @@ -786,7 +796,7 @@ kernel_init (struct zebra_ns *zns) /* Initialize netlink sockets */ groups = RTMGRP_LINK | RTMGRP_IPV4_ROUTE | RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_ROUTE | RTMGRP_IPV6_IFADDR | - RTMGRP_IPV4_MROUTE; + RTMGRP_IPV4_MROUTE | RTMGRP_NEIGH; snprintf (zns->netlink.name, sizeof (zns->netlink.name), "netlink-listen (NS %u)", zns->ns_id); diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 1b34e46ec..97616a2a9 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -552,10 +552,7 @@ zebra_add_import_table_entry (struct route_node *rn, struct route_entry *re, con newre->nexthop_num = 0; newre->uptime = time(NULL); newre->instance = re->table; - - /* Assuming these routes are never recursive */ - for (nhop = re->nexthop; nhop; nhop = nhop->next) - route_entry_copy_nexthops(newre, nhop); + route_entry_copy_nexthops(newre, re->nexthop); rib_add_multipath(AFI_IP, SAFI_UNICAST, &p, NULL, newre); } @@ -698,7 +695,7 @@ zebra_import_table_config (struct vty *vty) if (rmap_name) vty_out(vty, " route-map %s", rmap_name); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write = 1; } } diff --git a/zebra/rib.h b/zebra/rib.h index 88f2bf39a..999266241 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -178,52 +178,6 @@ typedef struct rib_dest_t_ #define RNODE_FOREACH_RE_SAFE(rn, re, next) \ RE_DEST_FOREACH_ROUTE_SAFE (rib_dest_from_rnode (rn), re, next) -/* The following for loop allows to iterate over the nexthop - * structure of routes. - * - * We have to maintain quite a bit of state: - * - * nexthop: The pointer to the current nexthop, either in the - * top-level chain or in the resolved chain of ni. - * tnexthop: The pointer to the current nexthop in the top-level - * nexthop chain. - * recursing: Information if nh currently is in the top-level chain - * (0) or in a resolved chain (1). - * - * Initialization: Set `nexthop' and `tnexthop' to the head of the - * top-level chain. As nexthop is in the top level chain, set recursing - * to 0. - * - * Iteration check: Check that the `nexthop' pointer is not NULL. - * - * Iteration step: This is the tricky part. Check if `nexthop' has - * NEXTHOP_FLAG_RECURSIVE set. If yes, this implies that `nexthop' is in - * the top level chain and has at least one nexthop attached to - * `nexthop->resolved'. As we want to descend into `nexthop->resolved', - * set `recursing' to 1 and set `nexthop' to `nexthop->resolved'. - * `tnexthop' is left alone in that case so we can remember which nexthop - * in the top level chain we are currently handling. - * - * If NEXTHOP_FLAG_RECURSIVE is not set, `nexthop' will progress in its - * current chain. If we are recursing, `nexthop' will be set to - * `nexthop->next' and `tnexthop' will be left alone. If we are not - * recursing, both `tnexthop' and `nexthop' will be set to `nexthop->next' - * as we are progressing in the top level chain. - * If we encounter `nexthop->next == NULL', we will clear the `recursing' - * flag as we arived either at the end of the resolved chain or at the end - * of the top level chain. In both cases, we set `tnexthop' and `nexthop' - * to `tnexthop->next', progressing to the next position in the top-level - * chain and possibly to its end marked by NULL. - */ -#define ALL_NEXTHOPS_RO(head, nexthop, tnexthop, recursing) \ - (tnexthop) = (nexthop) = (head), (recursing) = 0; \ - (nexthop); \ - (nexthop) = CHECK_FLAG((nexthop)->flags, NEXTHOP_FLAG_RECURSIVE) \ - ? (((recursing) = 1), (nexthop)->resolved) \ - : ((nexthop)->next ? ((recursing) ? (nexthop)->next \ - : ((tnexthop) = (nexthop)->next)) \ - : (((recursing) = 0),((tnexthop) = (tnexthop)->next))) - #if defined (HAVE_RTADV) /* Structure which hold status of router advertisement. */ struct rtadv diff --git a/zebra/router-id.c b/zebra/router-id.c index 07caef7ab..e23178cb7 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -202,10 +202,10 @@ router_id_write (struct vty *vty) if (zvrf->rid_user_assigned.u.prefix4.s_addr) { if (zvrf_id (zvrf) == VRF_DEFAULT) - vty_outln (vty, "router-id %s", + vty_out (vty, "router-id %s\n", inet_ntoa(zvrf->rid_user_assigned.u.prefix4)); else - vty_outln (vty, "router-id %s vrf %s", + vty_out (vty, "router-id %s vrf %s\n", inet_ntoa (zvrf->rid_user_assigned.u.prefix4), zvrf_name(zvrf)); } @@ -226,7 +226,7 @@ DEFUN (router_id, rid.u.prefix4.s_addr = inet_addr (argv[idx_ipv4]->arg); if (!rid.u.prefix4.s_addr) - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; rid.prefixlen = 32; rid.family = AF_INET; diff --git a/zebra/rt.h b/zebra/rt.h index a39af87b5..90654fb3e 100644 --- a/zebra/rt.h +++ b/zebra/rt.h @@ -24,6 +24,8 @@ #include "prefix.h" #include "if.h" +#include "vlan.h" +#include "vxlan.h" #include "zebra/rib.h" #include "zebra/zebra_ns.h" #include "zebra/zebra_mpls.h" @@ -41,4 +43,18 @@ extern int kernel_del_lsp (zebra_lsp_t *); extern int mpls_kernel_init (void); extern int kernel_get_ipmr_sg_stats (void *mroute); +extern int kernel_add_vtep (vni_t vni, struct interface *ifp, + struct in_addr *vtep_ip); +extern int kernel_del_vtep (vni_t vni, struct interface *ifp, + struct in_addr *vtep_ip); +extern int kernel_add_mac (struct interface *ifp, vlanid_t vid, + struct ethaddr *mac, struct in_addr vtep_ip, + u_char sticky); +extern int kernel_del_mac (struct interface *ifp, vlanid_t vid, + struct ethaddr *mac, struct in_addr vtep_ip, int local); + +extern int kernel_add_neigh (struct interface *ifp, struct ipaddr *ip, + struct ethaddr *mac); +extern int kernel_del_neigh (struct interface *ifp, struct ipaddr *ip); + #endif /* _ZEBRA_RT_H */ diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 471f65058..e017eb78e 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -41,6 +41,7 @@ #include "vrf.h" #include "vty.h" #include "mpls.h" +#include "vxlan.h" #include "zebra/zserv.h" #include "zebra/zebra_ns.h" @@ -55,6 +56,7 @@ #include "zebra/kernel_netlink.h" #include "zebra/rt_netlink.h" #include "zebra/zebra_mroute.h" +#include "zebra/zebra_vxlan.h" /* TODO - Temporary definitions, need to refine. */ @@ -93,8 +95,30 @@ #ifndef NDA_MASTER #define NDA_MASTER 9 #endif + +#ifndef NTF_MASTER +#define NTF_MASTER 0x04 +#endif + +#ifndef NTF_SELF +#define NTF_SELF 0x02 +#endif + +#ifndef NTF_EXT_LEARNED +#define NTF_EXT_LEARNED 0x10 +#endif + +#ifndef NDA_IFINDEX +#define NDA_IFINDEX 8 +#endif + +#ifndef NDA_VLAN +#define NDA_VLAN 5 +#endif /* End of temporary definitions */ +static vlanid_t filter_vlan = 0; + struct gw_family_t { u_int16_t filler; @@ -1209,8 +1233,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, { int bytelen; struct sockaddr_nl snl; - struct nexthop *nexthop = NULL, *tnexthop; - int recursing; + struct nexthop *nexthop = NULL; unsigned int nexthop_num; int discard; int family = PREFIX_FAMILY(p); @@ -1302,7 +1325,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, if (discard) { if (cmd == RTM_NEWROUTE) - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { /* We shouldn't encounter recursive nexthops on discard routes, * but it is probably better to handle that case correctly anyway. @@ -1316,7 +1339,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, /* Count overall nexthops so we can decide whether to use singlepath * or multipath case. */ nexthop_num = 0; - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) continue; @@ -1332,7 +1355,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, if (nexthop_num == 1 || multipath_num == 1) { nexthop_num = 0; - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) { @@ -1373,7 +1396,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, || (cmd == RTM_DELROUTE && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))) { - routedesc = recursing ? "recursive, 1 hop" : "single hop"; + routedesc = nexthop->rparent ? "recursive, 1 hop" : "single hop"; _netlink_route_debug(cmd, p, nexthop, routedesc, family, zvrf); _netlink_route_build_singlepath(routedesc, bytelen, @@ -1403,7 +1426,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, rtnh = RTA_DATA (rta); nexthop_num = 0; - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { if (nexthop_num >= multipath_num) break; @@ -1448,7 +1471,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, || (cmd == RTM_DELROUTE && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))) { - routedesc = recursing ? "recursive, multihop" : "multihop"; + routedesc = nexthop->rparent ? "recursive, multihop" : "multihop"; nexthop_num++; _netlink_route_debug(cmd, p, nexthop, @@ -1556,6 +1579,712 @@ kernel_neigh_update (int add, int ifindex, uint32_t addr, char *lla, int llalen) } /* + * Add remote VTEP to the flood list for this VxLAN interface (VNI). This + * is done by adding an FDB entry with a MAC of 00:00:00:00:00:00. + */ +static int +netlink_vxlan_flood_list_update (struct interface *ifp, + struct in_addr *vtep_ip, + int cmd) +{ + struct zebra_ns *zns = zebra_ns_lookup (NS_DEFAULT); + struct + { + struct nlmsghdr n; + struct ndmsg ndm; + char buf[256]; + } req; + u_char dst_mac[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; + + memset(&req.n, 0, sizeof(req.n)); + memset(&req.ndm, 0, sizeof(req.ndm)); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST; + if (cmd == RTM_NEWNEIGH) + req.n.nlmsg_flags |= (NLM_F_CREATE | NLM_F_APPEND); + req.n.nlmsg_type = cmd; + req.ndm.ndm_family = PF_BRIDGE; + req.ndm.ndm_state = NUD_NOARP | NUD_PERMANENT; + req.ndm.ndm_flags |= NTF_SELF; // Handle by "self", not "master" + + + addattr_l (&req.n, sizeof (req), NDA_LLADDR, &dst_mac, 6); + req.ndm.ndm_ifindex = ifp->ifindex; + addattr_l (&req.n, sizeof (req), NDA_DST, &vtep_ip->s_addr, 4); + + return netlink_talk (netlink_talk_filter, &req.n, &zns->netlink_cmd, zns, 0); +} + +/* + * Add remote VTEP for this VxLAN interface (VNI). In Linux, this involves adding + * a "flood" MAC FDB entry. + */ +int +kernel_add_vtep (vni_t vni, struct interface *ifp, struct in_addr *vtep_ip) +{ + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("Install %s into flood list for VNI %u intf %s(%u)", + inet_ntoa (*vtep_ip), vni, ifp->name, ifp->ifindex); + + return netlink_vxlan_flood_list_update (ifp, vtep_ip, RTM_NEWNEIGH); +} + +/* + * Remove remote VTEP for this VxLAN interface (VNI). In Linux, this involves + * deleting the "flood" MAC FDB entry. + */ +int +kernel_del_vtep (vni_t vni, struct interface *ifp, struct in_addr *vtep_ip) +{ + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("Uninstall %s from flood list for VNI %u intf %s(%u)", + inet_ntoa (*vtep_ip), vni, ifp->name, ifp->ifindex); + + return netlink_vxlan_flood_list_update (ifp, vtep_ip, RTM_DELNEIGH); +} + +#ifndef NDA_RTA +#define NDA_RTA(r) \ + ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) +#endif + +static int +netlink_macfdb_change (struct sockaddr_nl *snl, struct nlmsghdr *h, int len) +{ + struct ndmsg *ndm; + struct interface *ifp; + struct zebra_if *zif; + struct zebra_vrf *zvrf; + struct rtattr *tb[NDA_MAX + 1]; + struct interface *br_if; + struct ethaddr mac; + vlanid_t vid = 0; + struct prefix vtep_ip; + int vid_present = 0, dst_present = 0; + char buf[ETHER_ADDR_STRLEN]; + char vid_buf[20]; + char dst_buf[30]; + u_char sticky = 0; + + ndm = NLMSG_DATA (h); + + /* The interface should exist. */ + ifp = if_lookup_by_index_per_ns (zebra_ns_lookup (NS_DEFAULT), ndm->ndm_ifindex); + if (!ifp) + return 0; + + /* Locate VRF corresponding to interface. We only process MAC notifications + * if EVPN is enabled on this VRF. + */ + zvrf = vrf_info_lookup(ifp->vrf_id); + if (!zvrf || !EVPN_ENABLED(zvrf)) + return 0; + if (!ifp->info) + return 0; + + /* The interface should be something we're interested in. */ + if (!IS_ZEBRA_IF_BRIDGE_SLAVE(ifp)) + return 0; + + /* Drop "permanent" entries. */ + if (ndm->ndm_state & NUD_PERMANENT) + return 0; + + zif = (struct zebra_if *)ifp->info; + if ((br_if = zif->brslave_info.br_if) == NULL) + { + zlog_warn ("%s family %s IF %s(%u) brIF %u - no bridge master", + nl_msg_type_to_str (h->nlmsg_type), + nl_family_to_str (ndm->ndm_family), + ifp->name, ndm->ndm_ifindex, + zif->brslave_info.bridge_ifindex); + return 0; + } + + /* Parse attributes and extract fields of interest. */ + memset (tb, 0, sizeof tb); + netlink_parse_rtattr (tb, NDA_MAX, NDA_RTA (ndm), len); + + if (!tb[NDA_LLADDR]) + { + zlog_warn ("%s family %s IF %s(%u) brIF %u - no LLADDR", + nl_msg_type_to_str (h->nlmsg_type), + nl_family_to_str (ndm->ndm_family), + ifp->name, ndm->ndm_ifindex, + zif->brslave_info.bridge_ifindex); + return 0; + } + + if (RTA_PAYLOAD (tb[NDA_LLADDR]) != ETHER_ADDR_LEN) + { + zlog_warn ("%s family %s IF %s(%u) brIF %u - LLADDR is not MAC, len %ld", + nl_msg_type_to_str (h->nlmsg_type), + nl_family_to_str (ndm->ndm_family), + ifp->name, ndm->ndm_ifindex, + zif->brslave_info.bridge_ifindex, + RTA_PAYLOAD (tb[NDA_LLADDR])); + return 0; + } + + memcpy (&mac, RTA_DATA (tb[NDA_LLADDR]), ETHER_ADDR_LEN); + + if ((NDA_VLAN <= NDA_MAX) && tb[NDA_VLAN]) + { + vid_present = 1; + vid = *(u_int16_t *) RTA_DATA(tb[NDA_VLAN]); + sprintf (vid_buf, " VLAN %u", vid); + } + + if (tb[NDA_DST]) + { + /* TODO: Only IPv4 supported now. */ + dst_present = 1; + vtep_ip.family = AF_INET; + vtep_ip.prefixlen = IPV4_MAX_BITLEN; + memcpy (&(vtep_ip.u.prefix4.s_addr), RTA_DATA (tb[NDA_DST]), IPV4_MAX_BYTELEN); + sprintf (dst_buf, " dst %s", inet_ntoa (vtep_ip.u.prefix4)); + } + + sticky = (ndm->ndm_state & NUD_NOARP) ? 1 : 0; + + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("Rx %s family %s IF %s(%u)%s %sMAC %s%s", + nl_msg_type_to_str (h->nlmsg_type), + nl_family_to_str (ndm->ndm_family), + ifp->name, ndm->ndm_ifindex, + vid_present ? vid_buf : "", + sticky ? "sticky " : "", + prefix_mac2str (&mac, buf, sizeof (buf)), + dst_present ? dst_buf: ""); + + if (filter_vlan && vid != filter_vlan) + return 0; + + /* If add or update, do accordingly if learnt on a "local" interface; if + * the notification is over VxLAN, this has to be related to multi-homing, + * so perform an implicit delete of any local entry (if it exists). + */ + if (h->nlmsg_type == RTM_NEWNEIGH) + { + /* Drop "permanent" entries. */ + if (ndm->ndm_state & NUD_PERMANENT) + return 0; + + if (IS_ZEBRA_IF_VXLAN(ifp)) + return zebra_vxlan_check_del_local_mac (ifp, br_if, &mac, vid); + + return zebra_vxlan_local_mac_add_update (ifp, br_if, &mac, vid, sticky); + } + + /* This is a delete notification. + * 1. For a MAC over VxLan, check if it needs to be refreshed(readded) + * 2. For a MAC over "local" interface, delete the mac + * Note: We will get notifications from both bridge driver and VxLAN driver. + * Ignore the notification from VxLan driver as it is also generated + * when mac moves from remote to local. + */ + if (dst_present) + return 0; + + if (IS_ZEBRA_IF_VXLAN(ifp)) + return zebra_vxlan_check_readd_remote_mac (ifp, br_if, &mac, vid); + + return zebra_vxlan_local_mac_del (ifp, br_if, &mac, vid); +} + +static int +netlink_macfdb_table (struct sockaddr_nl *snl, struct nlmsghdr *h, + ns_id_t ns_id, int startup) +{ + int len; + struct ndmsg *ndm; + + if (h->nlmsg_type != RTM_NEWNEIGH) + return 0; + + /* Length validity. */ + len = h->nlmsg_len - NLMSG_LENGTH (sizeof (struct ndmsg)); + if (len < 0) + return -1; + + /* We are interested only in AF_BRIDGE notifications. */ + ndm = NLMSG_DATA (h); + if (ndm->ndm_family != AF_BRIDGE) + return 0; + + return netlink_macfdb_change (snl, h, len); +} + +/* Request for MAC FDB information from the kernel */ +static int +netlink_request_macs (struct zebra_ns *zns, int family, int type, + ifindex_t master_ifindex) +{ + struct + { + struct nlmsghdr n; + struct ifinfomsg ifm; + char buf[256]; + } req; + + /* Form the request, specifying filter (rtattr) if needed. */ + memset (&req, 0, sizeof (req)); + req.n.nlmsg_type = type; + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); + req.ifm.ifi_family = family; + if (master_ifindex) + addattr32 (&req.n, sizeof(req), IFLA_MASTER, master_ifindex); + + return netlink_request (&zns->netlink_cmd, &req.n); +} + +/* + * MAC forwarding database read using netlink interface. This is invoked + * at startup. + */ +int +netlink_macfdb_read (struct zebra_ns *zns) +{ + int ret; + + /* Get bridge FDB table. */ + ret = netlink_request_macs (zns, AF_BRIDGE, RTM_GETNEIGH, 0); + if (ret < 0) + return ret; + /* We are reading entire table. */ + filter_vlan = 0; + ret = netlink_parse_info (netlink_macfdb_table, &zns->netlink_cmd, zns, 0, 1); + + return ret; +} + +/* + * MAC forwarding database read using netlink interface. This is for a + * specific bridge and matching specific access VLAN (if VLAN-aware bridge). + */ +int +netlink_macfdb_read_for_bridge (struct zebra_ns *zns, struct interface *ifp, + struct interface *br_if) +{ + struct zebra_if *br_zif; + struct zebra_if *zif; + struct zebra_l2info_vxlan *vxl; + int ret = 0; + + + /* Save VLAN we're filtering on, if needed. */ + br_zif = (struct zebra_if *) br_if->info; + zif = (struct zebra_if *) ifp->info; + vxl = &zif->l2info.vxl; + if (IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(br_zif)) + filter_vlan = vxl->access_vlan; + + /* Get bridge FDB table for specific bridge - we do the VLAN filtering. */ + ret = netlink_request_macs (zns, AF_BRIDGE, RTM_GETNEIGH, br_if->ifindex); + if (ret < 0) + return ret; + ret = netlink_parse_info (netlink_macfdb_table, &zns->netlink_cmd, zns, 0, 0); + + /* Reset VLAN filter. */ + filter_vlan = 0; + return ret; +} + +static int +netlink_macfdb_update (struct interface *ifp, vlanid_t vid, + struct ethaddr *mac, + struct in_addr vtep_ip, + int local, int cmd, + u_char sticky) +{ + struct zebra_ns *zns = zebra_ns_lookup (NS_DEFAULT); + struct + { + struct nlmsghdr n; + struct ndmsg ndm; + char buf[256]; + } req; + int dst_alen; + struct zebra_if *zif; + struct interface *br_if; + struct zebra_if *br_zif; + char buf[ETHER_ADDR_STRLEN]; + int vid_present = 0, dst_present = 0; + char vid_buf[20]; + char dst_buf[30]; + + zif = ifp->info; + if ((br_if = zif->brslave_info.br_if) == NULL) + { + zlog_warn ("MAC %s on IF %s(%u) - no mapping to bridge", + (cmd == RTM_NEWNEIGH) ? "add" : "del", + ifp->name, ifp->ifindex); + return -1; + } + + memset(&req.n, 0, sizeof(req.n)); + memset(&req.ndm, 0, sizeof(req.ndm)); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST; + if (cmd == RTM_NEWNEIGH) + req.n.nlmsg_flags |= (NLM_F_CREATE | NLM_F_REPLACE); + req.n.nlmsg_type = cmd; + req.ndm.ndm_family = AF_BRIDGE; + req.ndm.ndm_flags |= NTF_SELF | NTF_MASTER; + req.ndm.ndm_state = NUD_REACHABLE; + + if (sticky) + req.ndm.ndm_state |= NUD_NOARP; + else + req.ndm.ndm_flags |= NTF_EXT_LEARNED; + + addattr_l (&req.n, sizeof (req), NDA_LLADDR, mac, 6); + req.ndm.ndm_ifindex = ifp->ifindex; + if (!local) + { + dst_alen = 4; // TODO: hardcoded + addattr_l (&req.n, sizeof (req), NDA_DST, &vtep_ip, dst_alen); + dst_present = 1; + sprintf (dst_buf, " dst %s", inet_ntoa (vtep_ip)); + } + br_zif = (struct zebra_if *) br_if->info; + if (IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(br_zif) && vid > 0) + { + addattr16 (&req.n, sizeof (req), NDA_VLAN, vid); + vid_present = 1; + sprintf (vid_buf, " VLAN %u", vid); + } + addattr32 (&req.n, sizeof (req), NDA_MASTER, br_if->ifindex); + + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("Tx %s family %s IF %s(%u)%s %sMAC %s%s", + nl_msg_type_to_str (cmd), + nl_family_to_str (req.ndm.ndm_family), + ifp->name, ifp->ifindex, + vid_present ? vid_buf : "", + sticky ? "sticky " : "", + prefix_mac2str (mac, buf, sizeof (buf)), + dst_present ? dst_buf : ""); + + return netlink_talk (netlink_talk_filter, &req.n, &zns->netlink_cmd, zns, 0); +} + +#define NUD_VALID (NUD_PERMANENT | NUD_NOARP | NUD_REACHABLE | \ + NUD_PROBE | NUD_STALE | NUD_DELAY) + +static int +netlink_ipneigh_change (struct sockaddr_nl *snl, struct nlmsghdr *h, int len) +{ + struct ndmsg *ndm; + struct interface *ifp; + struct zebra_if *zif; + struct zebra_vrf *zvrf; + struct rtattr *tb[NDA_MAX + 1]; + struct interface *link_if; + struct ethaddr mac; + struct ipaddr ip; + char buf[ETHER_ADDR_STRLEN]; + char buf2[INET6_ADDRSTRLEN]; + int mac_present = 0; + u_char ext_learned; + + ndm = NLMSG_DATA (h); + + /* The interface should exist. */ + ifp = if_lookup_by_index_per_ns (zebra_ns_lookup (NS_DEFAULT), ndm->ndm_ifindex); + if (!ifp) + return 0; + + /* Locate VRF corresponding to interface. We only process neigh notifications + * if EVPN is enabled on this VRF. + */ + zvrf = vrf_info_lookup(ifp->vrf_id); + if (!zvrf || !EVPN_ENABLED(zvrf)) + return 0; + if (!ifp->info) + return 0; + + /* Drop "permanent" entries. */ + if (ndm->ndm_state & NUD_PERMANENT) + return 0; + + zif = (struct zebra_if *)ifp->info; + /* The neighbor is present on an SVI. From this, we locate the underlying + * bridge because we're only interested in neighbors on a VxLAN bridge. + * The bridge is located based on the nature of the SVI: + * (a) In the case of a VLAN-aware bridge, the SVI is a L3 VLAN interface + * and is linked to the bridge + * (b) In the case of a VLAN-unaware bridge, the SVI is the bridge inteface + * itself + */ + if (IS_ZEBRA_IF_VLAN(ifp)) + { + link_if = zif->link; + if (!link_if) + return 0; + } + else if (IS_ZEBRA_IF_BRIDGE(ifp)) + link_if = ifp; + else + return 0; + + /* Parse attributes and extract fields of interest. */ + memset (tb, 0, sizeof tb); + netlink_parse_rtattr (tb, NDA_MAX, NDA_RTA (ndm), len); + + if (!tb[NDA_DST]) + { + zlog_warn ("%s family %s IF %s(%u) - no DST", + nl_msg_type_to_str (h->nlmsg_type), + nl_family_to_str (ndm->ndm_family), + ifp->name, ndm->ndm_ifindex); + return 0; + } + memset (&mac, 0, sizeof (struct ethaddr)); + memset (&ip, 0, sizeof (struct ipaddr)); + ip.ipa_type = (ndm->ndm_family == AF_INET) ? IPADDR_V4 : IPADDR_V6; + memcpy (&ip.ip.addr, RTA_DATA(tb[NDA_DST]), RTA_PAYLOAD(tb[NDA_DST])); + + if (h->nlmsg_type == RTM_NEWNEIGH) + { + if (tb[NDA_LLADDR]) + { + if (RTA_PAYLOAD (tb[NDA_LLADDR]) != ETHER_ADDR_LEN) + { + zlog_warn ("%s family %s IF %s(%u) - LLADDR is not MAC, len %ld", + nl_msg_type_to_str (h->nlmsg_type), + nl_family_to_str (ndm->ndm_family), + ifp->name, ndm->ndm_ifindex, + RTA_PAYLOAD (tb[NDA_LLADDR])); + return 0; + } + + mac_present = 1; + memcpy (&mac, RTA_DATA (tb[NDA_LLADDR]), ETHER_ADDR_LEN); + } + + ext_learned = (ndm->ndm_flags & NTF_EXT_LEARNED) ? 1 : 0; + + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("Rx %s family %s IF %s(%u) IP %s MAC %s state 0x%x flags 0x%x", + nl_msg_type_to_str (h->nlmsg_type), + nl_family_to_str (ndm->ndm_family), + ifp->name, ndm->ndm_ifindex, + ipaddr2str (&ip, buf2, sizeof(buf2)), + mac_present ? prefix_mac2str (&mac, buf, sizeof (buf)) : "", + ndm->ndm_state, ndm->ndm_flags); + + /* If the neighbor state is valid for use, process as an add or update + * else process as a delete. Note that the delete handling may result + * in re-adding the neighbor if it is a valid "remote" neighbor. + */ + if (ndm->ndm_state & NUD_VALID) + return zebra_vxlan_local_neigh_add_update (ifp, link_if, + &ip, &mac, + ndm->ndm_state, ext_learned); + + return zebra_vxlan_local_neigh_del (ifp, link_if, &ip); + } + + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("Rx %s family %s IF %s(%u) IP %s", + nl_msg_type_to_str (h->nlmsg_type), + nl_family_to_str (ndm->ndm_family), + ifp->name, ndm->ndm_ifindex, + ipaddr2str (&ip, buf2, sizeof(buf2))); + + /* Process the delete - it may result in re-adding the neighbor if it is + * a valid "remote" neighbor. + */ + return zebra_vxlan_local_neigh_del (ifp, link_if, &ip); +} + +static int +netlink_neigh_table (struct sockaddr_nl *snl, struct nlmsghdr *h, + ns_id_t ns_id, int startup) +{ + int len; + struct ndmsg *ndm; + + if (h->nlmsg_type != RTM_NEWNEIGH) + return 0; + + /* Length validity. */ + len = h->nlmsg_len - NLMSG_LENGTH (sizeof (struct ndmsg)); + if (len < 0) + return -1; + + /* We are interested only in AF_INET or AF_INET6 notifications. */ + ndm = NLMSG_DATA (h); + if (ndm->ndm_family != AF_INET && ndm->ndm_family != AF_INET6) + return 0; + + return netlink_neigh_change (snl, h, len); +} + +/* Request for IP neighbor information from the kernel */ +static int +netlink_request_neigh (struct zebra_ns *zns, int family, int type, + ifindex_t ifindex) +{ + struct + { + struct nlmsghdr n; + struct ndmsg ndm; + char buf[256]; + } req; + + /* Form the request, specifying filter (rtattr) if needed. */ + memset (&req, 0, sizeof (req)); + req.n.nlmsg_type = type; + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)); + req.ndm.ndm_family = family; + if (ifindex) + addattr32 (&req.n, sizeof(req), NDA_IFINDEX, ifindex); + + return netlink_request (&zns->netlink_cmd, &req.n); +} + +/* + * IP Neighbor table read using netlink interface. This is invoked + * at startup. + */ +int +netlink_neigh_read (struct zebra_ns *zns) +{ + int ret; + + /* Get IP neighbor table. */ + ret = netlink_request_neigh (zns, AF_UNSPEC, RTM_GETNEIGH, 0); + if (ret < 0) + return ret; + ret = netlink_parse_info (netlink_neigh_table, &zns->netlink_cmd, zns, 0, 1); + + return ret; +} + +/* + * IP Neighbor table read using netlink interface. This is for a specific + * VLAN device. + */ +int +netlink_neigh_read_for_vlan (struct zebra_ns *zns, struct interface *vlan_if) +{ + int ret = 0; + + ret = netlink_request_neigh (zns, AF_UNSPEC, RTM_GETNEIGH, vlan_if->ifindex); + if (ret < 0) + return ret; + ret = netlink_parse_info (netlink_neigh_table, &zns->netlink_cmd, zns, 0, 0); + + return ret; +} + +int +netlink_neigh_change (struct sockaddr_nl *snl, struct nlmsghdr *h, + ns_id_t ns_id) +{ + int len; + struct ndmsg *ndm; + + if (!(h->nlmsg_type == RTM_NEWNEIGH || h->nlmsg_type == RTM_DELNEIGH)) + return 0; + + /* Length validity. */ + len = h->nlmsg_len - NLMSG_LENGTH (sizeof (struct ndmsg)); + if (len < 0) + return -1; + + /* Is this a notification for the MAC FDB or IP neighbor table? */ + ndm = NLMSG_DATA (h); + if (ndm->ndm_family == AF_BRIDGE) + return netlink_macfdb_change (snl, h, len); + + if (ndm->ndm_type != RTN_UNICAST) + return 0; + + if (ndm->ndm_family == AF_INET || ndm->ndm_family == AF_INET6) + return netlink_ipneigh_change (snl, h, len); + + return 0; +} + +static int +netlink_neigh_update2 (struct interface *ifp, struct ipaddr *ip, + struct ethaddr *mac, u_int32_t flags, int cmd) +{ + struct { + struct nlmsghdr n; + struct ndmsg ndm; + char buf[256]; + } req; + int ipa_len; + + struct zebra_ns *zns = zebra_ns_lookup (NS_DEFAULT); + char buf[INET6_ADDRSTRLEN]; + char buf2[ETHER_ADDR_STRLEN]; + + memset(&req.n, 0, sizeof(req.n)); + memset(&req.ndm, 0, sizeof(req.ndm)); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST; + if (cmd == RTM_NEWNEIGH) + req.n.nlmsg_flags |= (NLM_F_CREATE | NLM_F_REPLACE); + req.n.nlmsg_type = cmd; //RTM_NEWNEIGH or RTM_DELNEIGH + req.ndm.ndm_family = IS_IPADDR_V4(ip) ? AF_INET : AF_INET6; + req.ndm.ndm_state = flags; + req.ndm.ndm_ifindex = ifp->ifindex; + req.ndm.ndm_type = RTN_UNICAST; + req.ndm.ndm_flags = NTF_EXT_LEARNED; + + + ipa_len = IS_IPADDR_V4(ip) ? IPV4_MAX_BYTELEN : IPV6_MAX_BYTELEN; + addattr_l(&req.n, sizeof(req), NDA_DST, &ip->ip.addr, ipa_len); + if (mac) + addattr_l (&req.n, sizeof (req), NDA_LLADDR, mac, 6); + + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug ("Tx %s family %s IF %s(%u) Neigh %s MAC %s", + nl_msg_type_to_str (cmd), + nl_family_to_str (req.ndm.ndm_family), + ifp->name, ifp->ifindex, + ipaddr2str (ip, buf, sizeof(buf)), + mac ? prefix_mac2str (mac, buf2, sizeof (buf2)) : "null"); + + return netlink_talk (netlink_talk_filter, &req.n, &zns->netlink_cmd, zns, 0); +} + +int +kernel_add_mac (struct interface *ifp, vlanid_t vid, + struct ethaddr *mac, struct in_addr vtep_ip, + u_char sticky) +{ + return netlink_macfdb_update (ifp, vid, mac, vtep_ip, 0, RTM_NEWNEIGH, sticky); +} + +int +kernel_del_mac (struct interface *ifp, vlanid_t vid, + struct ethaddr *mac, struct in_addr vtep_ip, int local) +{ + return netlink_macfdb_update (ifp, vid, mac, vtep_ip, local, RTM_DELNEIGH, 0); +} + +int kernel_add_neigh (struct interface *ifp, struct ipaddr *ip, + struct ethaddr *mac) +{ + return netlink_neigh_update2 (ifp, ip, mac, NUD_REACHABLE, + RTM_NEWNEIGH); +} + +int kernel_del_neigh (struct interface *ifp, struct ipaddr *ip) +{ + return netlink_neigh_update2 (ifp, ip, NULL, 0, RTM_DELNEIGH); +} + +/* * MPLS label forwarding table change via netlink interface. */ int diff --git a/zebra/rt_netlink.h b/zebra/rt_netlink.h index 9ba86003b..8b061fc2e 100644 --- a/zebra/rt_netlink.h +++ b/zebra/rt_netlink.h @@ -51,6 +51,15 @@ extern int netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h, ns_id_t ns_id, int startup); extern int netlink_route_read (struct zebra_ns *zns); +extern int netlink_neigh_change (struct sockaddr_nl *snl, struct nlmsghdr *h, + ns_id_t ns_id); +extern int netlink_macfdb_read (struct zebra_ns *zns); +extern int netlink_macfdb_read_for_bridge (struct zebra_ns *zns, + struct interface *ifp, struct interface *br_if); +extern int netlink_neigh_read (struct zebra_ns *zns); +extern int netlink_neigh_read_for_vlan (struct zebra_ns *zns, + struct interface *vlan_if); + #endif /* HAVE_NETLINK */ #endif /* _ZEBRA_RT_NETLINK_H */ diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 9859a3162..fd8010ca0 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -29,6 +29,7 @@ #include "sockunion.h" #include "log.h" #include "privs.h" +#include "vxlan.h" #include "zebra/debug.h" #include "zebra/rib.h" @@ -80,8 +81,7 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct route_entry *re) struct sockaddr_mpls smpls; #endif union sockunion *smplsp = NULL; - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; int nexthop_num = 0; ifindex_t ifindex = 0; int gate = 0; @@ -106,7 +106,7 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct route_entry *re) #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ /* Make gateway. */ - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) continue; @@ -226,7 +226,7 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct route_entry *re) if (IS_ZEBRA_DEBUG_RIB) zlog_debug ("%s: odd command %s for flags %d", __func__, lookup_msg(rtm_type_str, cmd, NULL), nexthop->flags); - } /* for (ALL_NEXTHOPS_RO(...))*/ + } /* for (ALL_NEXTHOPS(...))*/ /* If there was no useful nexthop, then complain. */ if (nexthop_num == 0 && IS_ZEBRA_DEBUG_KERNEL) @@ -266,8 +266,7 @@ kernel_rtm_ipv6 (int cmd, struct prefix *p, struct route_entry *re) { struct sockaddr_in6 *mask; struct sockaddr_in6 sin_dest, sin_mask, sin_gate; - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; int nexthop_num = 0; ifindex_t ifindex = 0; int gate = 0; @@ -289,7 +288,7 @@ kernel_rtm_ipv6 (int cmd, struct prefix *p, struct route_entry *re) #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ /* Make gateway. */ - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) continue; @@ -428,3 +427,41 @@ kernel_get_ipmr_sg_stats (void *mroute) { return 0; } + +int +kernel_add_vtep (vni_t vni, struct interface *ifp, struct in_addr *vtep_ip) +{ + return 0; +} + +int +kernel_del_vtep (vni_t vni, struct interface *ifp, struct in_addr *vtep_ip) +{ + return 0; +} + +int +kernel_add_mac (struct interface *ifp, vlanid_t vid, + struct ethaddr *mac, struct in_addr vtep_ip, + u_char sticky) +{ + return 0; +} + +int +kernel_del_mac (struct interface *ifp, vlanid_t vid, + struct ethaddr *mac, struct in_addr vtep_ip, int local) +{ + return 0; +} + +int kernel_add_neigh (struct interface *ifp, struct ipaddr *ip, + struct ethaddr *mac) +{ + return 0; +} + +int kernel_del_neigh (struct interface *ifp, struct ipaddr *ip) +{ + return 0; +} diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 677189751..589ecc949 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -877,9 +877,9 @@ DEFUN (ipv6_nd_suppress_ra, if (if_is_loopback (ifp) || CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK)) { - vty_outln (vty, - "Cannot configure IPv6 Router Advertisements on this interface"); - return CMD_WARNING; + vty_out (vty, + "Cannot configure IPv6 Router Advertisements on this interface\n"); + return CMD_WARNING_CONFIG_FAILED; } ipv6_nd_suppress_ra_set (ifp, RA_SUPPRESS); @@ -901,9 +901,9 @@ DEFUN (no_ipv6_nd_suppress_ra, if (if_is_loopback (ifp) || CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK)) { - vty_outln (vty, - "Cannot configure IPv6 Router Advertisements on this interface"); - return CMD_WARNING; + vty_out (vty, + "Cannot configure IPv6 Router Advertisements on this interface\n"); + return CMD_WARNING_CONFIG_FAILED; } ipv6_nd_suppress_ra_set (ifp, RA_ENABLE); @@ -931,9 +931,9 @@ DEFUN (ipv6_nd_ra_interval_msec, interval = strtoul(argv[idx_number]->arg, NULL, 10); if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime * 1000)) { - vty_outln (vty, - "This ra-interval would conflict with configured ra-lifetime!"); - return CMD_WARNING; + vty_out (vty, + "This ra-interval would conflict with configured ra-lifetime!\n"); + return CMD_WARNING_CONFIG_FAILED; } if (zif->rtadv.MaxRtrAdvInterval % 1000) @@ -968,9 +968,9 @@ DEFUN (ipv6_nd_ra_interval, interval = strtoul(argv[idx_number]->arg, NULL, 10); if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime)) { - vty_outln (vty, - "This ra-interval would conflict with configured ra-lifetime!"); - return CMD_WARNING; + vty_out (vty, + "This ra-interval would conflict with configured ra-lifetime!\n"); + return CMD_WARNING_CONFIG_FAILED; } if (zif->rtadv.MaxRtrAdvInterval % 1000) @@ -1036,9 +1036,9 @@ DEFUN (ipv6_nd_ra_lifetime, * MaxRtrAdvInterval and 9000 seconds. -- RFC4861, 6.2.1 */ if ((lifetime != 0 && lifetime * 1000 < zif->rtadv.MaxRtrAdvInterval)) { - vty_outln (vty, - "This ra-lifetime would conflict with configured ra-interval"); - return CMD_WARNING; + vty_out (vty, + "This ra-lifetime would conflict with configured ra-interval\n"); + return CMD_WARNING_CONFIG_FAILED; } zif->rtadv.AdvDefaultLifetime = lifetime; @@ -1333,8 +1333,8 @@ DEFUN (ipv6_nd_prefix, ret = str2prefix_ipv6 (prefix, &rp.prefix); if (!ret) { - vty_outln (vty, "Malformed IPv6 prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed IPv6 prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask_ipv6 (&rp.prefix); /* RFC4861 4.6.2 */ rp.AdvOnLinkFlag = !offlink; @@ -1349,8 +1349,8 @@ DEFUN (ipv6_nd_prefix, rp.AdvPreferredLifetime = strmatch (preflifetime, "infinite") ? UINT32_MAX : strtoll (preflifetime, NULL, 10); if (rp.AdvPreferredLifetime > rp.AdvValidLifetime) { - vty_outln (vty, "Invalid preferred lifetime"); - return CMD_WARNING; + vty_out (vty, "Invalid preferred lifetime\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -1386,16 +1386,16 @@ DEFUN (no_ipv6_nd_prefix, ret = str2prefix_ipv6 (prefix, &rp.prefix); if (!ret) { - vty_outln (vty, "Malformed IPv6 prefix"); - return CMD_WARNING; + vty_out (vty, "Malformed IPv6 prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } apply_mask_ipv6 (&rp.prefix); /* RFC4861 4.6.2 */ ret = rtadv_prefix_reset (zebra_if, &rp); if (!ret) { - vty_outln (vty, "Non-existant IPv6 prefix"); - return CMD_WARNING; + vty_out (vty, "Non-existant IPv6 prefix\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -1495,49 +1495,49 @@ rtadv_config_write (struct vty *vty, struct interface *ifp) CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK))) { if (zif->rtadv.AdvSendAdvertisements) - vty_outln (vty, " no ipv6 nd suppress-ra"); + vty_out (vty, " no ipv6 nd suppress-ra\n"); } interval = zif->rtadv.MaxRtrAdvInterval; if (interval % 1000) - vty_outln (vty, " ipv6 nd ra-interval msec %d",interval); + vty_out (vty, " ipv6 nd ra-interval msec %d\n",interval); else if (interval != RTADV_MAX_RTR_ADV_INTERVAL) - vty_outln (vty, " ipv6 nd ra-interval %d",interval / 1000); + vty_out (vty, " ipv6 nd ra-interval %d\n",interval / 1000); if (zif->rtadv.AdvIntervalOption) - vty_outln (vty, " ipv6 nd adv-interval-option"); + vty_out (vty, " ipv6 nd adv-interval-option\n"); if (zif->rtadv.AdvDefaultLifetime != -1) - vty_outln (vty, " ipv6 nd ra-lifetime %d",zif->rtadv.AdvDefaultLifetime); + vty_out (vty, " ipv6 nd ra-lifetime %d\n",zif->rtadv.AdvDefaultLifetime); if (zif->rtadv.HomeAgentPreference) - vty_outln (vty, " ipv6 nd home-agent-preference %u", + vty_out (vty, " ipv6 nd home-agent-preference %u\n", zif->rtadv.HomeAgentPreference); if (zif->rtadv.HomeAgentLifetime != -1) - vty_outln (vty, " ipv6 nd home-agent-lifetime %u", + vty_out (vty, " ipv6 nd home-agent-lifetime %u\n", zif->rtadv.HomeAgentLifetime); if (zif->rtadv.AdvHomeAgentFlag) - vty_outln (vty, " ipv6 nd home-agent-config-flag"); + vty_out (vty, " ipv6 nd home-agent-config-flag\n"); if (zif->rtadv.AdvReachableTime) - vty_outln (vty, " ipv6 nd reachable-time %d", + vty_out (vty, " ipv6 nd reachable-time %d\n", zif->rtadv.AdvReachableTime); if (zif->rtadv.AdvManagedFlag) - vty_outln (vty, " ipv6 nd managed-config-flag"); + vty_out (vty, " ipv6 nd managed-config-flag\n"); if (zif->rtadv.AdvOtherConfigFlag) - vty_outln (vty, " ipv6 nd other-config-flag"); + vty_out (vty, " ipv6 nd other-config-flag\n"); if (zif->rtadv.DefaultPreference != RTADV_PREF_MEDIUM) - vty_outln (vty, " ipv6 nd router-preference %s", + vty_out (vty, " ipv6 nd router-preference %s\n", rtadv_pref_strs[zif->rtadv.DefaultPreference]); if (zif->rtadv.AdvLinkMTU) - vty_outln (vty, " ipv6 nd mtu %d", zif->rtadv.AdvLinkMTU); + vty_out (vty, " ipv6 nd mtu %d\n", zif->rtadv.AdvLinkMTU); for (ALL_LIST_ELEMENTS_RO (zif->rtadv.AdvPrefixList, node, rprefix)) { @@ -1561,7 +1561,7 @@ rtadv_config_write (struct vty *vty, struct interface *ifp) vty_out (vty, " no-autoconfig"); if (rprefix->AdvRouterAddressFlag) vty_out (vty, " router-address"); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } diff --git a/zebra/rtread_getmsg.c b/zebra/rtread_getmsg.c index 1fb2984dd..b1bef571b 100644 --- a/zebra/rtread_getmsg.c +++ b/zebra/rtread_getmsg.c @@ -237,3 +237,23 @@ route_read (struct zebra_ns *zns) exit: close (dev); } + +/* Only implemented for netlink method */ +void +macfdb_read (struct zebra_ns *zns) +{ +} + +void macfdb_read_for_bridge (struct zebra_ns *zns, struct interface *ifp, + struct interface *br_if) +{ +} + +void +neigh_read (struct zebra_ns *zns) +{ +} + +void neigh_read_for_vlan (struct zebra_ns *zns, struct interface *vlan_if) +{ +} diff --git a/zebra/rtread_netlink.c b/zebra/rtread_netlink.c index d59883445..d26aa59f8 100644 --- a/zebra/rtread_netlink.c +++ b/zebra/rtread_netlink.c @@ -29,3 +29,24 @@ void route_read (struct zebra_ns *zns) { netlink_route_read (zns); } + +void macfdb_read (struct zebra_ns *zns) +{ + netlink_macfdb_read (zns); +} + +void macfdb_read_for_bridge (struct zebra_ns *zns, struct interface *ifp, + struct interface *br_if) +{ + netlink_macfdb_read_for_bridge (zns, ifp, br_if); +} + +void neigh_read (struct zebra_ns *zns) +{ + netlink_neigh_read (zns); +} + +void neigh_read_for_vlan (struct zebra_ns *zns, struct interface *vlan_if) +{ + netlink_neigh_read_for_vlan (zns, vlan_if); +} diff --git a/zebra/rtread_sysctl.c b/zebra/rtread_sysctl.c index cabb1f771..30e593d87 100644 --- a/zebra/rtread_sysctl.c +++ b/zebra/rtread_sysctl.c @@ -83,3 +83,23 @@ route_read (struct zebra_ns *zns) return; } + +/* Only implemented for the netlink method. */ +void +macfdb_read (struct zebra_ns *zns) +{ +} + +void macfdb_read_for_bridge (struct zebra_ns *zns, struct interface *ifp, + struct interface *br_if) +{ +} + +void +neigh_read (struct zebra_ns *zns) +{ +} + +void neigh_read_for_vlan (struct zebra_ns *zns, struct interface *vlan_if) +{ +} diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 3e408c929..d04aff2d3 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1438,7 +1438,7 @@ zfpm_start_stats_timer (void) */ #define ZFPM_SHOW_STAT(counter) \ do { \ - vty_outln (vty, "%-40s %10lu %16lu", #counter, total_stats.counter, \ + vty_out (vty, "%-40s %10lu %16lu\n", #counter, total_stats.counter, \ zfpm_g->last_ivl_stats.counter); \ } while (0) @@ -1451,8 +1451,8 @@ zfpm_show_stats (struct vty *vty) zfpm_stats_t total_stats; time_t elapsed; - vty_outln (vty, "%s%-40s %10s Last %2d secs%s", VTYNL, "Counter", - "Total", ZFPM_STATS_IVL_SECS, VTYNL); + vty_out (vty, "\n%-40s %10s Last %2d secs\n\n", "Counter", + "Total", ZFPM_STATS_IVL_SECS); /* * Compute the total stats up to this instant. @@ -1490,7 +1490,7 @@ zfpm_show_stats (struct vty *vty) elapsed = zfpm_get_elapsed_time (zfpm_g->last_stats_clear_time); - vty_outln (vty, "%sStats were cleared %lu seconds ago", VTYNL, + vty_out (vty, "\nStats were cleared %lu seconds ago\n", (unsigned long)elapsed); } @@ -1502,7 +1502,7 @@ zfpm_clear_stats (struct vty *vty) { if (!zfpm_is_enabled ()) { - vty_outln (vty, "The FPM module is not enabled..."); + vty_out (vty, "The FPM module is not enabled...\n"); return; } @@ -1515,7 +1515,7 @@ zfpm_clear_stats (struct vty *vty) zfpm_g->last_stats_clear_time = monotime(NULL); - vty_outln (vty, "Cleared FPM stats"); + vty_out (vty, "Cleared FPM stats\n"); } /* @@ -1671,7 +1671,7 @@ static int fpm_remote_srv_write (struct vty *vty) if (zfpm_g->fpm_server != FPM_DEFAULT_IP || zfpm_g->fpm_port != FPM_DEFAULT_PORT) - vty_outln (vty,"fpm connection ip %s port %d", inet_ntoa (in), + vty_out (vty,"fpm connection ip %s port %d\n", inet_ntoa (in), zfpm_g->fpm_port); return 0; diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index c5647debc..d935826db 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -154,8 +154,7 @@ typedef struct netlink_route_info_t_ * Returns TRUE if a nexthop was added, FALSE otherwise. */ static int -netlink_route_info_add_nh (netlink_route_info_t *ri, struct nexthop *nexthop, - int recursive) +netlink_route_info_add_nh (netlink_route_info_t *ri, struct nexthop *nexthop) { netlink_nh_info_t nhi; union g_addr *src; @@ -166,7 +165,7 @@ netlink_route_info_add_nh (netlink_route_info_t *ri, struct nexthop *nexthop, if (ri->num_nhs >= (int) ZEBRA_NUM_OF (ri->nhs)) return 0; - nhi.recursive = recursive; + nhi.recursive = nexthop->rparent ? 1 : 0; nhi.type = nexthop->type; nhi.if_index = nexthop->ifindex; @@ -233,8 +232,7 @@ static int netlink_route_info_fill (netlink_route_info_t *ri, int cmd, rib_dest_t *dest, struct route_entry *re) { - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; int discard; memset (ri, 0, sizeof (*ri)); @@ -286,7 +284,7 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd, if (discard) return 1; - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { if (ri->num_nhs >= multipath_num) break; @@ -299,7 +297,7 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd, || (cmd == RTM_DELROUTE && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))) { - netlink_route_info_add_nh (ri, nexthop, recursing); + netlink_route_info_add_nh (ri, nexthop); } } diff --git a/zebra/zebra_fpm_protobuf.c b/zebra/zebra_fpm_protobuf.c index 375fde921..1e8af19ea 100644 --- a/zebra/zebra_fpm_protobuf.c +++ b/zebra/zebra_fpm_protobuf.c @@ -145,8 +145,7 @@ create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, { Fpm__AddRoute *msg; int discard; - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; uint num_nhs, u; struct nexthop *nexthops[MULTIPATH_NUM]; @@ -195,7 +194,7 @@ create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, * Figure out the set of nexthops to be added to the message. */ num_nhs = 0; - for (ALL_NEXTHOPS_RO (re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS (re->nexthop, nexthop)) { if (num_nhs >= multipath_num) break; diff --git a/zebra/zebra_l2.c b/zebra/zebra_l2.c new file mode 100644 index 000000000..b71b96a18 --- /dev/null +++ b/zebra/zebra_l2.c @@ -0,0 +1,251 @@ +/* + * Zebra Layer-2 interface handling code + * Copyright (C) 2016, 2017 Cumulus Networks, Inc. + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <zebra.h> + +#include "if.h" +#include "prefix.h" +#include "table.h" +#include "memory.h" +#include "log.h" +#include "linklist.h" +#include "stream.h" +#include "hash.h" +#include "jhash.h" + +#include "zebra/rib.h" +#include "zebra/rt.h" +#include "zebra/zebra_ns.h" +#include "zebra/zserv.h" +#include "zebra/debug.h" +#include "zebra/interface.h" +#include "zebra/zebra_memory.h" +#include "zebra/zebra_vrf.h" +#include "zebra/rt_netlink.h" +#include "zebra/zebra_l2.h" +#include "zebra/zebra_vxlan.h" + +/* definitions */ + +/* static function declarations */ + +/* Private functions */ +static void +map_slaves_to_bridge (struct interface *br_if, int link) +{ + struct vrf *vrf; + struct listnode *node; + struct interface *ifp; + + RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) + { + for (ALL_LIST_ELEMENTS_RO (vrf->iflist, node, ifp)) + { + struct zebra_if *zif; + struct zebra_l2info_brslave *br_slave; + + if (ifp->ifindex == IFINDEX_INTERNAL || + !ifp->info) + continue; + if (!IS_ZEBRA_IF_BRIDGE_SLAVE (ifp)) + continue; + + /* NOTE: This assumes 'zebra_l2info_brslave' is the first field + * for any L2 interface. + */ + zif = (struct zebra_if *) ifp->info; + br_slave = &zif->brslave_info; + + if (link) + { + if (br_slave->bridge_ifindex == br_if->ifindex) + br_slave->br_if = br_if; + } + else + { + if (br_slave->br_if == br_if) + br_slave->br_if = NULL; + } + } + } +} + +/* Public functions */ +void +zebra_l2_map_slave_to_bridge (struct zebra_l2info_brslave *br_slave) +{ + struct interface *br_if; + + /* TODO: Handle change of master */ + br_if = if_lookup_by_index_per_ns (zebra_ns_lookup (NS_DEFAULT), + br_slave->bridge_ifindex); + if (br_if) + br_slave->br_if = br_if; +} + +void +zebra_l2_unmap_slave_from_bridge (struct zebra_l2info_brslave *br_slave) +{ + br_slave->br_if = NULL; +} + +/* + * Handle Bridge interface add or update. Update relevant info, + * map slaves (if any) to the bridge. + */ +void +zebra_l2_bridge_add_update (struct interface *ifp, + struct zebra_l2info_bridge *bridge_info, + int add) +{ + struct zebra_if *zif; + + zif = ifp->info; + assert(zif); + + /* Copy over the L2 information. */ + memcpy (&zif->l2info.br, bridge_info, sizeof (*bridge_info)); + + /* Link all slaves to this bridge */ + map_slaves_to_bridge (ifp, 1); +} + +/* + * Handle Bridge interface delete. + */ +void +zebra_l2_bridge_del (struct interface *ifp) +{ + /* Unlink all slaves to this bridge */ + map_slaves_to_bridge (ifp, 0); +} + +/* + * Update L2 info for a VLAN interface. Only relevant parameter is the + * VLAN Id and this cannot change. + */ +void +zebra_l2_vlanif_update (struct interface *ifp, + struct zebra_l2info_vlan *vlan_info) +{ + struct zebra_if *zif; + + zif = ifp->info; + assert(zif); + + /* Copy over the L2 information. */ + memcpy (&zif->l2info.vl, vlan_info, sizeof (*vlan_info)); +} + +/* + * Update L2 info for a VxLAN interface. This is called upon interface + * addition as well as update. Upon add, need to invoke the VNI create + * function. Upon update, the params of interest are the local tunnel + * IP and VLAN mapping, but the latter is handled separately. + */ +void +zebra_l2_vxlanif_add_update (struct interface *ifp, + struct zebra_l2info_vxlan *vxlan_info, + int add) +{ + struct zebra_if *zif; + struct in_addr old_vtep_ip; + + zif = ifp->info; + assert(zif); + + if (add) + { + memcpy (&zif->l2info.vxl, vxlan_info, sizeof (*vxlan_info)); + zebra_vxlan_if_add (ifp); + return; + } + + old_vtep_ip = zif->l2info.vxl.vtep_ip; + if (IPV4_ADDR_SAME(&old_vtep_ip, &vxlan_info->vtep_ip)) + return; + + zif->l2info.vxl.vtep_ip = vxlan_info->vtep_ip; + zebra_vxlan_if_update (ifp, ZEBRA_VXLIF_LOCAL_IP_CHANGE); +} + +/* + * Handle change to VLAN to VNI mapping. + */ +void +zebra_l2_vxlanif_update_access_vlan (struct interface *ifp, + vlanid_t access_vlan) +{ + struct zebra_if *zif; + vlanid_t old_access_vlan; + + zif = ifp->info; + assert(zif); + + old_access_vlan = zif->l2info.vxl.access_vlan; + if (old_access_vlan == access_vlan) + return; + + zif->l2info.vxl.access_vlan = access_vlan; + zebra_vxlan_if_update (ifp, ZEBRA_VXLIF_VLAN_CHANGE); +} + +/* + * Handle VxLAN interface delete. + */ +void +zebra_l2_vxlanif_del (struct interface *ifp) +{ + zebra_vxlan_if_del (ifp); +} + +/* + * Map or unmap interface from bridge. + * NOTE: It is currently assumped that an interface has to be unmapped + * from a bridge before it can be mapped to another bridge. + */ +void +zebra_l2if_update_bridge_slave (struct interface *ifp, + ifindex_t bridge_ifindex) +{ + struct zebra_if *zif; + ifindex_t old_bridge_ifindex; + + zif = ifp->info; + assert(zif); + + old_bridge_ifindex = zif->brslave_info.bridge_ifindex; + if (old_bridge_ifindex == bridge_ifindex) + return; + + zif->brslave_info.bridge_ifindex = bridge_ifindex; + + /* Set up or remove link with master */ + if (bridge_ifindex != IFINDEX_INTERNAL) + zebra_l2_map_slave_to_bridge (&zif->brslave_info); + else if (old_bridge_ifindex != IFINDEX_INTERNAL) + zebra_l2_unmap_slave_from_bridge (&zif->brslave_info); + + /* In the case of VxLAN, invoke the handler for EVPN. */ + if (zif->zif_type == ZEBRA_IF_VXLAN) + zebra_vxlan_if_update (ifp, ZEBRA_VXLIF_MASTER_CHANGE); +} diff --git a/zebra/zebra_l2.h b/zebra/zebra_l2.h new file mode 100644 index 000000000..5cfc6dee4 --- /dev/null +++ b/zebra/zebra_l2.h @@ -0,0 +1,94 @@ +/* + * Zebra Layer-2 interface Data structures and definitions + * Copyright (C) 2016, 2017 Cumulus Networks, Inc. + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _ZEBRA_L2_H +#define _ZEBRA_L2_H + +#include <zebra.h> + +#include "if.h" +#include "vlan.h" +#include "vxlan.h" + +/* zebra L2 interface information - bridge slave (linkage to bridge) */ +struct zebra_l2info_brslave +{ + ifindex_t bridge_ifindex; /* Bridge Master */ + struct interface *br_if; /* Pointer to master */ +}; + +/* zebra L2 interface information - bridge interface */ +struct zebra_l2info_bridge +{ + u_char vlan_aware; /* VLAN-aware bridge? */ +}; + +/* zebra L2 interface information - VLAN interface */ +struct zebra_l2info_vlan +{ + vlanid_t vid; /* VLAN id */ +}; + +/* zebra L2 interface information - VXLAN interface */ +struct zebra_l2info_vxlan +{ + vni_t vni; /* VNI */ + struct in_addr vtep_ip; /* Local tunnel IP */ + vlanid_t access_vlan; /* Access VLAN - for VLAN-aware bridge. */ +}; + +union zebra_l2if_info +{ + struct zebra_l2info_bridge br; + struct zebra_l2info_vlan vl; + struct zebra_l2info_vxlan vxl; +}; + +/* NOTE: These macros are to be invoked only in the "correct" context. + * IOW, the macro VNI_FROM_ZEBRA_IF() will assume the interface is + * of type ZEBRA_IF_VXLAN. + */ +#define VNI_FROM_ZEBRA_IF(zif) (zif)->l2info.vxl.vni +#define VLAN_ID_FROM_ZEBRA_IF(zif) (zif)->l2info.vl.vid + +#define IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(zif) \ + ((zif)->l2info.br.vlan_aware == 1) + + +extern void zebra_l2_map_slave_to_bridge (struct zebra_l2info_brslave *br_slave); +extern void zebra_l2_unmap_slave_from_bridge (struct zebra_l2info_brslave *br_slave); +extern void zebra_l2_bridge_add_update (struct interface *ifp, + struct zebra_l2info_bridge *bridge_info, + int add); +extern void zebra_l2_bridge_del (struct interface *ifp); +extern void zebra_l2_vlanif_update (struct interface *ifp, + struct zebra_l2info_vlan *vlan_info); +extern void zebra_l2_vxlanif_add_update (struct interface *ifp, + struct zebra_l2info_vxlan *vxlan_info, + int add); +extern void zebra_l2_vxlanif_update_access_vlan (struct interface *ifp, + vlanid_t access_vlan); +extern void zebra_l2_vxlanif_del (struct interface *ifp); +extern void zebra_l2if_update_bridge_slave (struct interface *ifp, + ifindex_t bridge_ifindex); + +#endif /* _ZEBRA_L2_H */ diff --git a/zebra/zebra_l2_null.c b/zebra/zebra_l2_null.c new file mode 100644 index 000000000..d50107f65 --- /dev/null +++ b/zebra/zebra_l2_null.c @@ -0,0 +1,76 @@ +/* + * Zebra Layer-2 interface Data structures and definitions + * Copyright (C) 2016, 2017 Cumulus Networks, Inc. + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <zebra.h> + +#include "if.h" +#include "zebra/debug.h" +#include "zebra/zserv.h" +#include "zebra/rib.h" +#include "zebra/zebra_vrf.h" +#include "zebra/zebra_l2.h" + +void zebra_l2_map_slave_to_bridge (struct zebra_l2info_brslave *br_slave) +{ +} + +void +zebra_l2_unmap_slave_from_bridge (struct zebra_l2info_brslave *br_slave) +{ +} + +void zebra_l2_bridge_add_update (struct interface *ifp, + struct zebra_l2info_bridge *bridge_info, + int add) +{ +} + +void zebra_l2_bridge_del (struct interface *ifp) +{ +} + +void zebra_l2_vlanif_update (struct interface *ifp, + struct zebra_l2info_vlan *vlan_info) +{ +} + +void zebra_l2_vxlanif_add_update (struct interface *ifp, + struct zebra_l2info_vxlan *vxlan_info, + int add) +{ +} + +void +zebra_l2_vxlanif_update_access_vlan (struct interface *ifp, + vlanid_t access_vlan) +{ +} + +void zebra_l2_vxlanif_del (struct interface *ifp) +{ +} + +void +zebra_l2if_update_bridge_slave (struct interface *ifp, + ifindex_t bridge_ifindex) +{ +} diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 510d79693..3c8503878 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -530,18 +530,18 @@ fec_print (zebra_fec_t *fec, struct vty *vty) rn = fec->rn; prefix2str(&rn->p, buf, BUFSIZ); - vty_outln (vty, "%s", buf); + vty_out (vty, "%s\n", buf); vty_out(vty, " Label: %s", label2str(fec->label, buf, BUFSIZ)); if (fec->label_index != MPLS_INVALID_LABEL_INDEX) vty_out(vty, ", Label Index: %u", fec->label_index); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); if (!list_isempty(fec->client_list)) { vty_out(vty, " Client list:"); for (ALL_LIST_ELEMENTS_RO(fec->client_list, node, client)) vty_out(vty, " %s(fd %d)", zebra_route_string(client->proto), client->sock); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } } @@ -1398,7 +1398,7 @@ nhlfe_print (zebra_nhlfe_t *nhlfe, struct vty *vty) if (!nexthop || !nexthop->nh_label) // unexpected return; - vty_outln (vty, " type: %s remote label: %s distance: %d", + vty_out (vty, " type: %s remote label: %s distance: %d\n", nhlfe_type2str(nhlfe->type), label2str(nexthop->nh_label->label[0], buf, BUFSIZ), nhlfe->distance); @@ -1422,7 +1422,7 @@ nhlfe_print (zebra_nhlfe_t *nhlfe, struct vty *vty) } vty_out(vty, "%s", CHECK_FLAG (nhlfe->flags, NHLFE_FLAG_INSTALLED) ? " (installed)" : ""); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* @@ -1436,7 +1436,7 @@ lsp_print (zebra_lsp_t *lsp, void *ctxt) vty = (struct vty *) ctxt; - vty_outln (vty, "Local label: %u%s", + vty_out (vty, "Local label: %u%s\n", lsp->ile.in_label, CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED) ? " (installed)" : ""); @@ -2238,7 +2238,7 @@ zebra_mpls_write_fec_config (struct vty *vty, struct zebra_vrf *zvrf) write = 1; prefix2str(&rn->p, buf, BUFSIZ); - vty_outln (vty, "mpls label bind %s %s", buf, + vty_out (vty, "mpls label bind %s %s\n", buf, label2str(fec->label, lstr, BUFSIZ)); } } @@ -2809,7 +2809,7 @@ zebra_mpls_print_lsp (struct vty *vty, struct zebra_vrf *zvrf, mpls_label_t labe if (use_json) { json = lsp_json(lsp); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -2840,15 +2840,15 @@ zebra_mpls_print_lsp_table (struct vty *vty, struct zebra_vrf *zvrf, json_object_object_add(json, label2str(lsp->ile.in_label, buf, BUFSIZ), lsp_json(lsp)); - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { - vty_outln (vty, " Inbound Outbound"); - vty_outln (vty, " Label Type Nexthop Label"); - vty_outln (vty, "-------- ------- --------------- --------"); + vty_out (vty, " Inbound Outbound\n"); + vty_out (vty, " Label Type Nexthop Label\n"); + vty_out (vty, "-------- ------- --------------- --------\n"); for (ALL_LIST_ELEMENTS_RO(lsp_list, node, lsp)) { @@ -2871,11 +2871,11 @@ zebra_mpls_print_lsp_table (struct vty *vty, struct zebra_vrf *zvrf, break; } - vty_outln (vty, " %8d", nexthop->nh_label->label[0]); + vty_out (vty, " %8d\n", nexthop->nh_label->label[0]); } } - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } list_delete (lsp_list); @@ -2913,7 +2913,7 @@ zebra_mpls_write_lsp_config (struct vty *vty, struct zebra_vrf *zvrf) break; } - vty_outln (vty, "mpls lsp %u %s %s", + vty_out (vty, "mpls lsp %u %s %s\n", slsp->ile.in_label, buf, lstr); } } @@ -2963,7 +2963,7 @@ zebra_mpls_write_label_block_config (struct vty *vty, struct zebra_vrf *zvrf) if ((zvrf->mpls_srgb.start_label != MPLS_DEFAULT_MIN_SRGB_LABEL) || (zvrf->mpls_srgb.end_label != MPLS_DEFAULT_MAX_SRGB_LABEL)) { - vty_outln (vty, "mpls label global-block %u %u", + vty_out (vty, "mpls label global-block %u %u\n", zvrf->mpls_srgb.start_label,zvrf->mpls_srgb.end_label); } diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c index 6c2dbca3a..938e8ef7c 100644 --- a/zebra/zebra_mpls_vty.c +++ b/zebra/zebra_mpls_vty.c @@ -53,42 +53,42 @@ zebra_mpls_transit_lsp (struct vty *vty, int add_cmd, const char *inlabel_str, if (!mpls_enabled) { - vty_outln (vty,"%% MPLS not turned on in kernel, ignoring command"); - return CMD_WARNING; + vty_out (vty,"%% MPLS not turned on in kernel, ignoring command\n"); + return CMD_WARNING_CONFIG_FAILED; } zvrf = vrf_info_lookup(VRF_DEFAULT); if (!zvrf) { - vty_outln (vty, "%% Default VRF does not exist"); - return CMD_WARNING; + vty_out (vty, "%% Default VRF does not exist\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!inlabel_str) { - vty_outln (vty, "%% No Label Information"); - return CMD_WARNING; + vty_out (vty, "%% No Label Information\n"); + return CMD_WARNING_CONFIG_FAILED; } out_label = MPLS_IMP_NULL_LABEL; /* as initialization */ label = atoi(inlabel_str); if (!IS_MPLS_UNRESERVED_LABEL(label)) { - vty_outln (vty, "%% Invalid label"); - return CMD_WARNING; + vty_out (vty, "%% Invalid label\n"); + return CMD_WARNING_CONFIG_FAILED; } if (add_cmd) { if (!gate_str) { - vty_outln (vty, "%% No Nexthop Information"); - return CMD_WARNING; + vty_out (vty, "%% No Nexthop Information\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!outlabel_str) { - vty_outln (vty, "%% No Outgoing label Information"); - return CMD_WARNING; + vty_out (vty, "%% No Outgoing label Information\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -108,8 +108,8 @@ zebra_mpls_transit_lsp (struct vty *vty, int add_cmd, const char *inlabel_str, gtype = NEXTHOP_TYPE_IPV4; else { - vty_outln (vty, "%% Invalid nexthop"); - return CMD_WARNING; + vty_out (vty, "%% Invalid nexthop\n"); + return CMD_WARNING_CONFIG_FAILED; } } } @@ -133,8 +133,8 @@ zebra_mpls_transit_lsp (struct vty *vty, int add_cmd, const char *inlabel_str, if (!zebra_mpls_lsp_label_consistent (zvrf, in_label, out_label, gtype, &gate, 0)) { - vty_outln (vty,"%% Label value not consistent"); - return CMD_WARNING; + vty_out (vty,"%% Label value not consistent\n"); + return CMD_WARNING_CONFIG_FAILED; } #endif /* HAVE_CUMULUS */ @@ -146,9 +146,9 @@ zebra_mpls_transit_lsp (struct vty *vty, int add_cmd, const char *inlabel_str, if (ret) { - vty_outln (vty, "%% LSP cannot be %s", + vty_out (vty, "%% LSP cannot be %s\n", add_cmd ? "added" : "deleted"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -218,24 +218,24 @@ zebra_mpls_bind (struct vty *vty, int add_cmd, const char *prefix, zvrf = vrf_info_lookup(VRF_DEFAULT); if (!zvrf) { - vty_outln (vty, "%% Default VRF does not exist"); - return CMD_WARNING; + vty_out (vty, "%% Default VRF does not exist\n"); + return CMD_WARNING_CONFIG_FAILED; } memset(&p, 0, sizeof(struct prefix)); ret = str2prefix(prefix, &p); if (ret <= 0) { - vty_outln (vty, "%% Malformed address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } if (add_cmd) { if (!label_str) { - vty_outln (vty, "%% No label binding specified"); - return CMD_WARNING; + vty_out (vty, "%% No label binding specified\n"); + return CMD_WARNING_CONFIG_FAILED; } if (!strcmp(label_str, "implicit-null")) @@ -252,13 +252,13 @@ zebra_mpls_bind (struct vty *vty, int add_cmd, const char *prefix, label = atoi(label_str); if (!IS_MPLS_UNRESERVED_LABEL(label)) { - vty_outln (vty, "%% Invalid label"); - return CMD_WARNING; + vty_out (vty, "%% Invalid label\n"); + return CMD_WARNING_CONFIG_FAILED; } if (zebra_mpls_label_already_bound (zvrf, label)) { - vty_outln (vty,"%% Label already bound to a FEC"); - return CMD_WARNING; + vty_out (vty,"%% Label already bound to a FEC\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -269,9 +269,9 @@ zebra_mpls_bind (struct vty *vty, int add_cmd, const char *prefix, if (ret) { - vty_outln (vty, "%% FEC to label binding cannot be %s", + vty_out (vty, "%% FEC to label binding cannot be %s\n", add_cmd ? "added" : "deleted"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -874,7 +874,7 @@ DEFUN (show_mpls_fec, ret = str2prefix(argv[3]->arg, &p); if (ret <= 0) { - vty_outln (vty, "%% Malformed address"); + vty_out (vty, "%% Malformed address\n"); return CMD_WARNING; } zebra_mpls_print_fec (vty, zvrf, &p); @@ -925,7 +925,7 @@ DEFUN (show_mpls_status, "MPLS information\n" "MPLS status\n") { - vty_outln (vty, "MPLS support enabled: %s", + vty_out (vty, "MPLS support enabled: %s\n", (mpls_enabled) ? "yes" : "no (mpls kernel extensions not detected)"); return CMD_SUCCESS; } @@ -942,16 +942,16 @@ zebra_mpls_global_block (struct vty *vty, int add_cmd, zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); if (!zvrf) { - vty_outln (vty, "%% Default VRF does not exist"); - return CMD_WARNING; + vty_out (vty, "%% Default VRF does not exist\n"); + return CMD_WARNING_CONFIG_FAILED; } if (add_cmd) { if (!start_label_str || !end_label_str) { - vty_outln (vty, "%% Labels not specified"); - return CMD_WARNING; + vty_out (vty, "%% Labels not specified\n"); + return CMD_WARNING_CONFIG_FAILED; } start_label = atoi(start_label_str); @@ -959,13 +959,13 @@ zebra_mpls_global_block (struct vty *vty, int add_cmd, if (!IS_MPLS_UNRESERVED_LABEL(start_label) || !IS_MPLS_UNRESERVED_LABEL(end_label)) { - vty_outln (vty, "%% Invalid label"); - return CMD_WARNING; + vty_out (vty, "%% Invalid label\n"); + return CMD_WARNING_CONFIG_FAILED; } if (end_label < start_label) { - vty_outln (vty,"%% End label is less than Start label"); - return CMD_WARNING; + vty_out (vty,"%% End label is less than Start label\n"); + return CMD_WARNING_CONFIG_FAILED; } ret = zebra_mpls_label_block_add (zvrf, start_label, end_label); @@ -975,9 +975,9 @@ zebra_mpls_global_block (struct vty *vty, int add_cmd, if (ret) { - vty_outln (vty, "%% Global label block could not be %s", + vty_out (vty, "%% Global label block could not be %s\n", add_cmd ? "added" : "deleted"); - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 9a7b029dd..39779793f 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -374,7 +374,7 @@ void zebra_ptm_write (struct vty *vty) { if (ptm_cb.ptm_enable) - vty_outln (vty, "ptm-enable"); + vty_out (vty, "ptm-enable\n"); return; } @@ -1089,9 +1089,9 @@ zebra_ptm_show_status(struct vty *vty, struct interface *ifp) { vty_out (vty, " PTM status: "); if (ifp->ptm_enable) { - vty_outln (vty, "%s",zebra_ptm_get_status_str(ifp->ptm_status)); + vty_out (vty, "%s\n",zebra_ptm_get_status_str(ifp->ptm_status)); } else { - vty_outln (vty, "disabled"); + vty_out (vty, "disabled\n"); } } @@ -1161,5 +1161,5 @@ void zebra_ptm_if_write (struct vty *vty, struct zebra_if *zebra_ifp) { if (zebra_ifp->ptm_enable == ZEBRA_IF_PTM_ENABLE_OFF) - vty_outln (vty, " no ptm-enable"); + vty_out (vty, " no ptm-enable\n"); } diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index c2af0a0d2..b07a0cf05 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -198,20 +198,10 @@ route_entry_nexthop_add (struct route_entry *re, struct nexthop *nexthop) void route_entry_copy_nexthops (struct route_entry *re, struct nexthop *nh) { - struct nexthop *nexthop; - - nexthop = nexthop_new(); - nexthop->flags = nh->flags; - nexthop->type = nh->type; - nexthop->ifindex = nh->ifindex; - memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr)); - memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr)); - if (nh->nh_label) - nexthop_add_labels (nexthop, nh->nh_label_type, nh->nh_label->num_labels, - &nh->nh_label->label[0]); - route_entry_nexthop_add(re, nexthop); - if (CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE)) - copy_nexthops(&nexthop->resolved, nh->resolved); + assert(!re->nexthop); + copy_nexthops(&re->nexthop, nh, NULL); + for (struct nexthop *nexthop = nh; nexthop; nexthop = nexthop->next) + re->nexthop_num++; } /* Delete specified nexthop from the list. */ @@ -389,6 +379,7 @@ nexthop_set_resolved (afi_t afi, struct nexthop *newhop, struct nexthop *nexthop resolved_hop->ifindex = newhop->ifindex; } + resolved_hop->rparent = nexthop; nexthop_add(&nexthop->resolved, resolved_hop); } @@ -403,8 +394,7 @@ nexthop_active (afi_t afi, struct route_entry *re, struct nexthop *nexthop, int struct route_node *rn; struct route_entry *match; int resolved; - struct nexthop *newhop, *tnewhop; - int recursing = 0; + struct nexthop *newhop; struct interface *ifp; if ((nexthop->type == NEXTHOP_TYPE_IPV4) || nexthop->type == NEXTHOP_TYPE_IPV6) @@ -528,7 +518,7 @@ nexthop_active (afi_t afi, struct route_entry *re, struct nexthop *nexthop, int else if (CHECK_FLAG (re->flags, ZEBRA_FLAG_INTERNAL)) { resolved = 0; - for (newhop = match->nexthop; newhop; newhop = newhop->next) + for (ALL_NEXTHOPS(match->nexthop, newhop)) if (CHECK_FLAG (newhop->flags, NEXTHOP_FLAG_FIB) && ! CHECK_FLAG (newhop->flags, NEXTHOP_FLAG_RECURSIVE)) { @@ -546,7 +536,7 @@ nexthop_active (afi_t afi, struct route_entry *re, struct nexthop *nexthop, int else if (re->type == ZEBRA_ROUTE_STATIC) { resolved = 0; - for (ALL_NEXTHOPS_RO(match->nexthop, newhop, tnewhop, recursing)) + for (ALL_NEXTHOPS(match->nexthop, newhop)) if (CHECK_FLAG (newhop->flags, NEXTHOP_FLAG_FIB)) { if (set) @@ -577,8 +567,7 @@ rib_match (afi_t afi, safi_t safi, vrf_id_t vrf_id, struct route_table *table; struct route_node *rn; struct route_entry *match; - struct nexthop *newhop, *tnewhop; - int recursing; + struct nexthop *newhop; /* Lookup table. */ table = zebra_vrf_table (afi, safi, vrf_id); @@ -628,7 +617,7 @@ rib_match (afi_t afi, safi_t safi, vrf_id_t vrf_id, if (match->type != ZEBRA_ROUTE_CONNECT) { int found = 0; - for (ALL_NEXTHOPS_RO(match->nexthop, newhop, tnewhop, recursing)) + for (ALL_NEXTHOPS(match->nexthop, newhop)) if (CHECK_FLAG (newhop->flags, NEXTHOP_FLAG_FIB)) { found = 1; @@ -724,8 +713,7 @@ rib_lookup_ipv4 (struct prefix_ipv4 *p, vrf_id_t vrf_id) struct route_table *table; struct route_node *rn; struct route_entry *match; - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; /* Lookup table. */ table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); @@ -754,8 +742,8 @@ rib_lookup_ipv4 (struct prefix_ipv4 *p, vrf_id_t vrf_id) if (match->type == ZEBRA_ROUTE_CONNECT) return match; - - for (ALL_NEXTHOPS_RO(match->nexthop, nexthop, tnexthop, recursing)) + + for (ALL_NEXTHOPS(match->nexthop, nexthop)) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) return match; @@ -781,8 +769,7 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate, struct route_table *table; struct route_node *rn; struct route_entry *match; - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; int nexthops_active; /* Lookup table. */ @@ -818,7 +805,7 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate, /* Ok, we have a cood candidate, let's check it's nexthop list... */ nexthops_active = 0; - for (ALL_NEXTHOPS_RO(match->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(match->nexthop, nexthop)) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) { nexthops_active = 1; @@ -830,7 +817,7 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate, inet_ntop (AF_INET, &nexthop->gate.ipv4.s_addr, gate_buf, INET_ADDRSTRLEN); inet_ntop (AF_INET, &sockunion2ip(qgate), qgate_buf, INET_ADDRSTRLEN); zlog_debug ("%s: qgate == %s, %s == %s", __func__, - qgate_buf, recursing ? "rgate" : "gate", gate_buf); + qgate_buf, nexthop->rparent ? "rgate" : "gate", gate_buf); } } @@ -1025,13 +1012,12 @@ nexthop_active_update (struct route_node *rn, struct route_entry *re, int set) int zebra_rib_labeled_unicast (struct route_entry *re) { - struct nexthop *nexthop = NULL, *tnexthop; - int recursing; + struct nexthop *nexthop = NULL; if (re->type != ZEBRA_ROUTE_BGP) return 0; - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) if (!nexthop->nh_label || !nexthop->nh_label->num_labels) return 0; @@ -1045,9 +1031,8 @@ int rib_install_kernel (struct route_node *rn, struct route_entry *re, struct route_entry *old) { int ret = 0; - struct nexthop *nexthop, *tnexthop; + struct nexthop *nexthop; rib_table_info_t *info = srcdest_rnode_table_info(rn); - int recursing; struct prefix *p, *src_p; struct zebra_vrf *zvrf = vrf_info_lookup (re->vrf_id); @@ -1055,7 +1040,7 @@ rib_install_kernel (struct route_node *rn, struct route_entry *re, struct route_ if (info->safi != SAFI_UNICAST) { - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); return ret; } @@ -1071,7 +1056,7 @@ rib_install_kernel (struct route_node *rn, struct route_entry *re, struct route_ /* If install succeeds, update FIB flag for nexthops. */ if (!ret) { - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) continue; @@ -1091,9 +1076,8 @@ int rib_uninstall_kernel (struct route_node *rn, struct route_entry *re) { int ret = 0; - struct nexthop *nexthop, *tnexthop; + struct nexthop *nexthop; rib_table_info_t *info = srcdest_rnode_table_info(rn); - int recursing; struct prefix *p, *src_p; struct zebra_vrf *zvrf = vrf_info_lookup (re->vrf_id); @@ -1101,7 +1085,7 @@ rib_uninstall_kernel (struct route_node *rn, struct route_entry *re) if (info->safi != SAFI_UNICAST) { - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); return ret; } @@ -1114,7 +1098,7 @@ rib_uninstall_kernel (struct route_node *rn, struct route_entry *re) ret = kernel_route_rib (p, src_p, re, NULL); zvrf->removals++; - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); return ret; @@ -1284,8 +1268,7 @@ static void rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *old, struct route_entry *new) { - struct nexthop *nexthop = NULL, *tnexthop; - int recursing; + struct nexthop *nexthop = NULL; int nh_active = 0; int installed = 1; @@ -1403,7 +1386,7 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, { int in_fib = 0; - for (ALL_NEXTHOPS_RO(new->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(new->nexthop, nexthop)) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) { in_fib = 1; @@ -1634,13 +1617,11 @@ rib_process (struct route_node *rn) /* Redistribute SELECTED entry */ if (old_selected != new_selected || selected_changed) { - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; /* Check if we have a FIB route for the destination, otherwise, * don't redistribute it */ - for (ALL_NEXTHOPS_RO(new_fib ? new_fib->nexthop : NULL, nexthop, - tnexthop, recursing)) + for (ALL_NEXTHOPS(new_fib ? new_fib->nexthop : NULL, nexthop)) { if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)) { @@ -2141,8 +2122,7 @@ void _route_entry_dump (const char * func, bool is_srcdst = src_p && src_p->prefixlen; char straddr[PREFIX_STRLEN]; char srcaddr[PREFIX_STRLEN]; - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; zlog_debug ("%s: dumping RE entry %p for %s%s%s vrf %u", func, (const void *)re, prefix2str(pp, straddr, sizeof(straddr)), @@ -2177,14 +2157,14 @@ void _route_entry_dump (const char * func, re->nexthop_active_num ); - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { inet_ntop (p->family, &nexthop->gate, straddr, INET6_ADDRSTRLEN); zlog_debug ( "%s: %s %s with flags %s%s%s", func, - (recursing ? " NH" : "NH"), + (nexthop->rparent ? " NH" : "NH"), straddr, (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE) ? "ACTIVE " : ""), (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? "FIB " : ""), @@ -2391,8 +2371,7 @@ rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, struct route_entry *re; struct route_entry *fib = NULL; struct route_entry *same = NULL; - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; char buf2[INET6_ADDRSTRLEN]; assert(!src_p || afi == AFI_IP6); @@ -2463,7 +2442,7 @@ rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, same = re; break; } - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) if (IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) || IPV6_ADDR_SAME (&nexthop->gate.ipv6, gate)) { diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 5dc504b41..c82712b9c 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -420,12 +420,11 @@ zebra_rnh_eval_import_check_entry (vrf_id_t vrfid, int family, int force, struct zserv *client; char bufn[INET6_ADDRSTRLEN]; struct listnode *node; - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; if (re && (rnh->state == NULL)) { - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) { state_changed = 1; @@ -831,7 +830,6 @@ static void copy_state (struct rnh *rnh, struct route_entry *re, struct route_node *rn) { struct route_entry *state; - struct nexthop *nh; if (rnh->state) { @@ -846,8 +844,7 @@ copy_state (struct rnh *rnh, struct route_entry *re, struct route_node *rn) state->type = re->type; state->metric = re->metric; - for (nh = re->nexthop; nh; nh = nh->next) - route_entry_copy_nexthops(state, nh); + route_entry_copy_nexthops(state, re->nexthop); rnh->state = state; } @@ -996,7 +993,7 @@ print_nh (struct nexthop *nexthop, struct vty *vty) default: break; } - vty_out(vty, "%s", VTYNL); + vty_out(vty, "\n"); } static void @@ -1009,20 +1006,18 @@ print_rnh (struct route_node *rn, struct vty *vty) char buf[BUFSIZ]; rnh = rn->info; - vty_out(vty, "%s%s%s", inet_ntop(rn->p.family, &rn->p.u.prefix, buf, BUFSIZ), - CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED) ? "(Connected)" : "", - VTYNL); + vty_out(vty, "%s%s\n", inet_ntop(rn->p.family, &rn->p.u.prefix, buf, BUFSIZ), + CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED) ? "(Connected)" : ""); if (rnh->state) { - vty_out(vty, " resolved via %s%s", - zebra_route_string(rnh->state->type), VTYNL); + vty_out(vty, " resolved via %s\n", + zebra_route_string(rnh->state->type)); for (nexthop = rnh->state->nexthop; nexthop; nexthop = nexthop->next) print_nh(nexthop, vty); } else - vty_out(vty, " unresolved%s%s", - CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED) ? "(Connected)" : "", - VTYNL); + vty_out(vty, " unresolved%s\n", + CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED) ? "(Connected)" : ""); vty_out(vty, " Client list:"); for (ALL_LIST_ELEMENTS_RO(rnh->client_list, node, client)) @@ -1030,5 +1025,5 @@ print_rnh (struct route_node *rn, struct vty *vty) client->sock, rnh->filtered[client->proto] ? "(filtered)" : ""); if (!list_isempty(rnh->zebra_static_route_list)) vty_out(vty, " zebra%s", rnh->filtered[ZEBRA_ROUTE_STATIC] ? "(filtered)" : ""); - vty_out(vty, "%s", VTYNL); + vty_out(vty, "\n"); } diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index c4f417d88..a7b47165d 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -73,11 +73,11 @@ zebra_route_match_add(struct vty *vty, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% Zebra Can't find rule."); - return CMD_WARNING; + vty_out (vty, "%% Zebra Can't find rule.\n"); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% Zebra Argument is malformed."); - return CMD_WARNING; + vty_out (vty, "%% Zebra Argument is malformed.\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -121,11 +121,11 @@ zebra_route_match_delete (struct vty *vty, switch (ret) { case RMAP_RULE_MISSING: - vty_outln (vty, "%% Zebra Can't find rule."); - return CMD_WARNING; + vty_out (vty, "%% Zebra Can't find rule.\n"); + return CMD_WARNING_CONFIG_FAILED; case RMAP_COMPILE_ERROR: - vty_outln (vty, "%% Zebra Argument is malformed."); - return CMD_WARNING; + vty_out (vty, "%% Zebra Argument is malformed.\n"); + return CMD_WARNING_CONFIG_FAILED; } } @@ -302,8 +302,8 @@ DEFUN (match_source_protocol, i = proto_name2num(proto); if (i < 0) { - vty_outln (vty, "invalid protocol name \"%s\"", proto); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"\n", proto); + return CMD_WARNING_CONFIG_FAILED; } return zebra_route_match_add (vty, "source-protocol", proto, RMAP_EVENT_MATCH_ADDED); } @@ -350,8 +350,8 @@ DEFUN (set_src, { if (inet_pton(AF_INET6, argv[idx_ip]->arg, &src.ipv6) != 1) { - vty_outln (vty, "%% not a valid IPv4/v6 address"); - return CMD_WARNING; + vty_out (vty, "%% not a valid IPv4/v6 address\n"); + return CMD_WARNING_CONFIG_FAILED; } p.family = family = AF_INET6; @@ -367,8 +367,8 @@ DEFUN (set_src, if (!zebra_check_addr(&p)) { - vty_outln (vty, "%% not a valid source IPv4/v6 address"); - return CMD_WARNING; + vty_out (vty, "%% not a valid source IPv4/v6 address\n"); + return CMD_WARNING_CONFIG_FAILED; } RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) @@ -386,8 +386,8 @@ DEFUN (set_src, if (!pif) { - vty_outln (vty, "%% not a local address"); - return CMD_WARNING; + vty_out (vty, "%% not a local address\n"); + return CMD_WARNING_CONFIG_FAILED; } VTY_DECLVAR_CONTEXT (route_map_index, index); @@ -459,8 +459,8 @@ DEFUN (ip_protocol, i = proto_name2num(proto); if (i < 0) { - vty_outln (vty, "invalid protocol name \"%s\"", proto); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"\n", proto); + return CMD_WARNING_CONFIG_FAILED; } if (proto_rm[AFI_IP][i]) { @@ -500,8 +500,8 @@ DEFUN (no_ip_protocol, if (i < 0) { - vty_outln (vty, "invalid protocol name \"%s\"", proto); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"\n", proto); + return CMD_WARNING_CONFIG_FAILED; } if (!proto_rm[AFI_IP][i]) @@ -529,20 +529,20 @@ DEFUN (show_ip_protocol, { int i; - vty_outln (vty, "Protocol : route-map "); - vty_outln (vty, "------------------------"); + vty_out (vty, "Protocol : route-map \n"); + vty_out (vty, "------------------------\n"); for (i=0;i<ZEBRA_ROUTE_MAX;i++) { if (proto_rm[AFI_IP][i]) - vty_outln (vty, "%-10s : %-10s", zebra_route_string(i), + vty_out (vty, "%-10s : %-10s\n", zebra_route_string(i), proto_rm[AFI_IP][i]); else - vty_outln (vty, "%-10s : none", zebra_route_string(i)); + vty_out (vty, "%-10s : none\n", zebra_route_string(i)); } if (proto_rm[AFI_IP][i]) - vty_outln (vty, "%-10s : %-10s", "any",proto_rm[AFI_IP][i]); + vty_out (vty, "%-10s : %-10s\n", "any",proto_rm[AFI_IP][i]); else - vty_outln (vty, "%-10s : none", "any"); + vty_out (vty, "%-10s : none\n", "any"); return CMD_SUCCESS; } @@ -566,8 +566,8 @@ DEFUN (ipv6_protocol, i = proto_name2num(proto); if (i < 0) { - vty_outln (vty, "invalid protocol name \"%s\"", proto); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"\n", proto); + return CMD_WARNING_CONFIG_FAILED; } if (proto_rm[AFI_IP6][i]) { @@ -606,8 +606,8 @@ DEFUN (no_ipv6_protocol, i = proto_name2num(proto); if (i < 0) { - vty_outln (vty, "invalid protocol name \"%s\"", proto); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"\n", proto); + return CMD_WARNING_CONFIG_FAILED; } if (!proto_rm[AFI_IP6][i]) return CMD_SUCCESS; @@ -635,20 +635,20 @@ DEFUN (show_ipv6_protocol, { int i; - vty_outln (vty, "Protocol : route-map "); - vty_outln (vty, "------------------------"); + vty_out (vty, "Protocol : route-map \n"); + vty_out (vty, "------------------------\n"); for (i=0;i<ZEBRA_ROUTE_MAX;i++) { if (proto_rm[AFI_IP6][i]) - vty_outln (vty, "%-10s : %-10s", zebra_route_string(i), + vty_out (vty, "%-10s : %-10s\n", zebra_route_string(i), proto_rm[AFI_IP6][i]); else - vty_outln (vty, "%-10s : none", zebra_route_string(i)); + vty_out (vty, "%-10s : none\n", zebra_route_string(i)); } if (proto_rm[AFI_IP6][i]) - vty_outln (vty, "%-10s : %-10s", "any",proto_rm[AFI_IP6][i]); + vty_out (vty, "%-10s : %-10s\n", "any",proto_rm[AFI_IP6][i]); else - vty_outln (vty, "%-10s : none", "any"); + vty_out (vty, "%-10s : none\n", "any"); return CMD_SUCCESS; } @@ -672,8 +672,8 @@ DEFUN (ip_protocol_nht_rmap, i = proto_name2num(proto); if (i < 0) { - vty_outln (vty, "invalid protocol name \"%s\"", proto); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"\n", proto); + return CMD_WARNING_CONFIG_FAILED; } if (nht_rm[AFI_IP][i]) { @@ -707,8 +707,8 @@ DEFUN (no_ip_protocol_nht_rmap, if (i < 0) { - vty_outln (vty, "invalid protocol name \"%s\"", proto); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"\n", proto); + return CMD_WARNING_CONFIG_FAILED; } if (!nht_rm[AFI_IP][i]) @@ -733,20 +733,20 @@ DEFUN (show_ip_protocol_nht, { int i; - vty_outln (vty, "Protocol : route-map "); - vty_outln (vty, "------------------------"); + vty_out (vty, "Protocol : route-map \n"); + vty_out (vty, "------------------------\n"); for (i=0;i<ZEBRA_ROUTE_MAX;i++) { if (nht_rm[AFI_IP][i]) - vty_outln (vty, "%-10s : %-10s", zebra_route_string(i), + vty_out (vty, "%-10s : %-10s\n", zebra_route_string(i), nht_rm[AFI_IP][i]); else - vty_outln (vty, "%-10s : none", zebra_route_string(i)); + vty_out (vty, "%-10s : none\n", zebra_route_string(i)); } if (nht_rm[AFI_IP][i]) - vty_outln (vty, "%-10s : %-10s", "any",nht_rm[AFI_IP][i]); + vty_out (vty, "%-10s : %-10s\n", "any",nht_rm[AFI_IP][i]); else - vty_outln (vty, "%-10s : none", "any"); + vty_out (vty, "%-10s : none\n", "any"); return CMD_SUCCESS; } @@ -770,8 +770,8 @@ DEFUN (ipv6_protocol_nht_rmap, i = proto_name2num(proto); if (i < 0) { - vty_outln (vty, "invalid protocol name \"%s\"", proto); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"\n", proto); + return CMD_WARNING_CONFIG_FAILED; } if (nht_rm[AFI_IP6][i]) XFREE (MTYPE_ROUTE_MAP_NAME, nht_rm[AFI_IP6][i]); @@ -801,14 +801,14 @@ DEFUN (no_ipv6_protocol_nht_rmap, i = proto_name2num(proto); if (i < 0) { - vty_outln (vty, "invalid protocol name \"%s\"", proto); - return CMD_WARNING; + vty_out (vty, "invalid protocol name \"%s\"\n", proto); + return CMD_WARNING_CONFIG_FAILED; } if (nht_rm[AFI_IP6][i] && rmap && strcmp(rmap, nht_rm[AFI_IP6][i])) { - vty_outln (vty, "invalid route-map \"%s\"", rmap); - return CMD_WARNING; + vty_out (vty, "invalid route-map \"%s\"\n", rmap); + return CMD_WARNING_CONFIG_FAILED; } if (nht_rm[AFI_IP6][i]) @@ -832,20 +832,20 @@ DEFUN (show_ipv6_protocol_nht, { int i; - vty_outln (vty, "Protocol : route-map "); - vty_outln (vty, "------------------------"); + vty_out (vty, "Protocol : route-map \n"); + vty_out (vty, "------------------------\n"); for (i=0;i<ZEBRA_ROUTE_MAX;i++) { if (nht_rm[AFI_IP6][i]) - vty_outln (vty, "%-10s : %-10s", zebra_route_string(i), + vty_out (vty, "%-10s : %-10s\n", zebra_route_string(i), nht_rm[AFI_IP6][i]); else - vty_outln (vty, "%-10s : none", zebra_route_string(i)); + vty_out (vty, "%-10s : none\n", zebra_route_string(i)); } if (nht_rm[AFI_IP][i]) - vty_outln (vty, "%-10s : %-10s", "any",nht_rm[AFI_IP6][i]); + vty_out (vty, "%-10s : %-10s\n", "any",nht_rm[AFI_IP6][i]); else - vty_outln (vty, "%-10s : none", "any"); + vty_out (vty, "%-10s : none\n", "any"); return CMD_SUCCESS; } @@ -1294,7 +1294,7 @@ void zebra_route_map_write_delay_timer (struct vty *vty) { if (vty && (zebra_rmap_update_timer != ZEBRA_RMAP_DEFAULT_UPDATE_TIMER)) - vty_outln (vty, "zebra route-map delay-timer %d", + vty_out (vty, "zebra route-map delay-timer %d\n", zebra_rmap_update_timer); return; } @@ -1431,40 +1431,40 @@ zebra_routemap_config_write_protocol (struct vty *vty) for (i=0;i<ZEBRA_ROUTE_MAX;i++) { if (proto_rm[AFI_IP][i]) - vty_outln (vty, "ip protocol %s route-map %s", zebra_route_string(i), + vty_out (vty, "ip protocol %s route-map %s\n", zebra_route_string(i), proto_rm[AFI_IP][i]); if (proto_rm[AFI_IP6][i]) - vty_outln (vty, "ipv6 protocol %s route-map %s", zebra_route_string(i), + vty_out (vty, "ipv6 protocol %s route-map %s\n", zebra_route_string(i), proto_rm[AFI_IP6][i]); if (nht_rm[AFI_IP][i]) - vty_outln (vty, "ip nht %s route-map %s", zebra_route_string(i), + vty_out (vty, "ip nht %s route-map %s\n", zebra_route_string(i), nht_rm[AFI_IP][i]); if (nht_rm[AFI_IP6][i]) - vty_outln (vty, "ipv6 nht %s route-map %s", zebra_route_string(i), + vty_out (vty, "ipv6 nht %s route-map %s\n", zebra_route_string(i), nht_rm[AFI_IP6][i]); } if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX]) - vty_outln (vty, "ip protocol %s route-map %s", "any", + vty_out (vty, "ip protocol %s route-map %s\n", "any", proto_rm[AFI_IP][ZEBRA_ROUTE_MAX]); if (proto_rm[AFI_IP6][ZEBRA_ROUTE_MAX]) - vty_outln (vty, "ipv6 protocol %s route-map %s", "any", + vty_out (vty, "ipv6 protocol %s route-map %s\n", "any", proto_rm[AFI_IP6][ZEBRA_ROUTE_MAX]); if (nht_rm[AFI_IP][ZEBRA_ROUTE_MAX]) - vty_outln (vty, "ip nht %s route-map %s", "any", + vty_out (vty, "ip nht %s route-map %s\n", "any", nht_rm[AFI_IP][ZEBRA_ROUTE_MAX]); if (nht_rm[AFI_IP6][ZEBRA_ROUTE_MAX]) - vty_outln (vty, "ipv6 nht %s route-map %s", "any", + vty_out (vty, "ipv6 nht %s route-map %s\n", "any", nht_rm[AFI_IP6][ZEBRA_ROUTE_MAX]); if (zebra_rmap_update_timer != ZEBRA_RMAP_DEFAULT_UPDATE_TIMER) - vty_outln (vty, "zebra route-map delay-timer %d", + vty_out (vty, "zebra route-map delay-timer %d\n", zebra_rmap_update_timer); } diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 165689267..b5d6f8c06 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -37,6 +37,7 @@ #include "zebra/zebra_static.h" #include "zebra/interface.h" #include "zebra/zebra_mpls.h" +#include "zebra/zebra_vxlan.h" extern struct zebra_t zebrad; @@ -244,6 +245,9 @@ zebra_vrf_delete (struct vrf *vrf) rib_close_table (zvrf->other_table[afi][table_id]); } + /* Cleanup Vxlan table and update kernel */ + zebra_vxlan_close_tables (zvrf); + zebra_mpls_close_tables (zvrf); for (ALL_LIST_ELEMENTS_RO (vrf->iflist, node, ifp)) @@ -421,6 +425,7 @@ zebra_vrf_alloc (void) zvrf->import_check_table[afi] = table; } + zebra_vxlan_init_tables (zvrf); zebra_mpls_init_tables (zvrf); return zvrf; @@ -524,8 +529,8 @@ vrf_config_write (struct vty *vty) zvrf = vrf->info; if (! zvrf || strcmp (zvrf_name (zvrf), VRF_DEFAULT_NAME)) { - vty_outln (vty, "vrf %s", zvrf_name(zvrf)); - vty_outln (vty, "!"); + vty_out (vty, "vrf %s\n", zvrf_name(zvrf)); + vty_out (vty, "!\n"); } } return 0; diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h index 790e2e53d..29f7df00f 100644 --- a/zebra/zebra_vrf.h +++ b/zebra/zebra_vrf.h @@ -95,6 +95,15 @@ struct zebra_vrf u_int16_t mpls_flags; #define MPLS_FLAG_SCHEDULE_LSPS (1 << 0) + /* + * VNI hash table (for EVPN). Only in default instance. + */ + struct hash *vni_table; + /* + * Whether EVPN is enabled or not. + */ + int advertise_all_vni; + /* Route Installs */ uint64_t installs; uint64_t removals; diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 6ba4c1b9d..b1da38a7b 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -32,6 +32,7 @@ #include "mpls.h" #include "routemap.h" #include "srcdest_table.h" +#include "vxlan.h" #include "zebra/zserv.h" #include "zebra/zebra_vrf.h" @@ -41,6 +42,7 @@ #include "zebra/zebra_routemap.h" #include "zebra/zebra_static.h" #include "lib/json.h" +#include "zebra/zebra_vxlan.h" extern int allow_delete; @@ -54,6 +56,9 @@ static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, #define ONE_DAY_SECOND 60*60*24 #define ONE_WEEK_SECOND 60*60*24*7 +/* VNI range as per RFC 7432 */ +#define CMD_VNI_RANGE "(1-16777215)" + /* General function for static route. */ int zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, @@ -79,8 +84,8 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, ret = str2prefix (dest_str, &p); if (ret <= 0) { - vty_outln (vty, "%% Malformed address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } /* Cisco like mask notation. */ @@ -89,8 +94,8 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, ret = inet_aton (mask_str, &mask); if (ret == 0) { - vty_outln (vty, "%% Malformed address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } p.prefixlen = ip_masklen (mask); } @@ -113,8 +118,8 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, if (!zvrf) { - vty_outln (vty, "%% vrf %s is not defined", vrf_id_str); - return CMD_WARNING; + vty_out (vty, "%% vrf %s is not defined\n", vrf_id_str); + return CMD_WARNING_CONFIG_FAILED; } /* Labels */ @@ -122,9 +127,9 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, { if (!mpls_enabled) { - vty_outln (vty, - "%% MPLS not turned on in kernel, ignoring command"); - return CMD_WARNING; + vty_out (vty, + "%% MPLS not turned on in kernel, ignoring command\n"); + return CMD_WARNING_CONFIG_FAILED; } int rc = mpls_str2label (label_str, &snh_label.num_labels, snh_label.label); @@ -132,18 +137,18 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, { switch (rc) { case -1: - vty_outln (vty, "%% Malformed label(s)"); + vty_out (vty, "%% Malformed label(s)\n"); break; case -2: - vty_outln (vty, "%% Cannot use reserved label(s) (%d-%d)", + vty_out (vty, "%% Cannot use reserved label(s) (%d-%d)\n", MPLS_MIN_RESERVED_LABEL,MPLS_MAX_RESERVED_LABEL); break; case -3: - vty_outln (vty, "%% Too many labels. Enter %d or fewer", + vty_out (vty, "%% Too many labels. Enter %d or fewer\n", MPLS_MAX_LABELS); break; } - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } @@ -152,8 +157,8 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, { if (flag_str) { - vty_outln (vty, "%% can not have flag %s with Null0", flag_str); - return CMD_WARNING; + vty_out (vty, "%% can not have flag %s with Null0\n", flag_str); + return CMD_WARNING_CONFIG_FAILED; } if (add_cmd) static_add_route (AFI_IP, safi, type, &p, NULL, NULL, ifindex, ifname, @@ -176,8 +181,8 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE); break; default: - vty_outln (vty, "%% Malformed flag %s ", flag_str); - return CMD_WARNING; + vty_out (vty, "%% Malformed flag %s \n", flag_str); + return CMD_WARNING_CONFIG_FAILED; } } @@ -201,7 +206,7 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, struct interface *ifp = if_lookup_by_name (gate_str, zvrf_id (zvrf)); if (!ifp) { - vty_outln (vty, "%% Unknown interface: %s", gate_str); + vty_out (vty, "%% Unknown interface: %s\n", gate_str); ifindex = IFINDEX_DELETED; } else @@ -286,8 +291,8 @@ DEFUN (ip_multicast_mode, multicast_mode_ipv4_set (MCAST_MIX_PFXLEN); else { - vty_outln (vty, "Invalid mode specified"); - return CMD_WARNING; + vty_out (vty, "Invalid mode specified\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -340,7 +345,7 @@ DEFUN (show_ip_rpf_addr, ret = inet_aton (argv[idx_ipv4]->arg, &addr); if (ret == 0) { - vty_outln (vty, "%% Malformed address"); + vty_out (vty, "%% Malformed address\n"); return CMD_WARNING; } @@ -349,7 +354,7 @@ DEFUN (show_ip_rpf_addr, if (re) vty_show_ip_route_detail (vty, rn, 1); else - vty_outln (vty, "%% No match for RPF lookup"); + vty_out (vty, "%% No match for RPF lookup\n"); return CMD_SUCCESS; } @@ -640,8 +645,7 @@ static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) { struct route_entry *re; - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; char buf[SRCDEST2STR_BUFFER]; struct zebra_vrf *zvrf; @@ -656,9 +660,8 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) : " using Unicast RIB"; } - vty_out (vty, "Routing entry for %s%s%s", - srcdest_rnode2str(rn, buf, sizeof(buf)), mcast_info, - VTYNL); + vty_out (vty, "Routing entry for %s%s\n", + srcdest_rnode2str(rn, buf, sizeof(buf)), mcast_info); vty_out (vty, " Known via \"%s", zebra_route_string (re->type)); if (re->instance) vty_out (vty, "[%d]", re->instance); @@ -681,7 +684,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) vty_out (vty, ", blackhole"); if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT)) vty_out (vty, ", reject"); - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF @@ -709,16 +712,16 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) vty_out (vty, "%02dw%dd%02dh", tm->tm_yday/7, tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); - vty_out (vty, " ago%s", VTYNL); + vty_out (vty, " ago\n"); } - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) - { + for (ALL_NEXTHOPS(re->nexthop, nexthop)) + { char addrstr[32]; vty_out (vty, " %c%s", - CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ', - recursing ? " " : ""); + CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ', + nexthop->rparent ? " " : ""); switch (nexthop->type) { @@ -788,9 +791,9 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) nexthop->nh_label->label, buf, sizeof buf, 1)); } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } @@ -798,8 +801,7 @@ static void vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *re, json_object *json) { - struct nexthop *nexthop, *tnexthop; - int recursing; + struct nexthop *nexthop; int len = 0; char buf[SRCDEST2STR_BUFFER]; json_object *json_nexthops = NULL; @@ -860,7 +862,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *r json_object_string_add(json_route, "uptime", buf); } - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { json_nexthop = json_object_new_object(); @@ -954,7 +956,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *r } /* Nexthop information. */ - for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS(re->nexthop, nexthop)) { if (nexthop == re->nexthop) { @@ -977,9 +979,9 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *r } else vty_out (vty, " %c%*c", - CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) - ? '*' : ' ', - len - 3 + (2 * recursing), ' '); + CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) + ? '*' : ' ', + len - 3 + (2 * nexthop_level(nexthop)), ' '); switch (nexthop->type) { @@ -1078,7 +1080,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *r tm->tm_yday/7, tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); } - vty_out (vty, "%s", VTYNL); + vty_out (vty, "\n"); } } @@ -1107,18 +1109,18 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi, if (!(zvrf = zebra_vrf_lookup_by_name (vrf_name))) { if (use_json) - vty_outln (vty, "{}"); + vty_out (vty, "{}\n"); else - vty_outln (vty, "vrf %s not defined", vrf_name); + vty_out (vty, "vrf %s not defined\n", vrf_name); return CMD_SUCCESS; } if (zvrf_id (zvrf) == VRF_UNKNOWN) { if (use_json) - vty_outln (vty, "{}"); + vty_out (vty, "{}\n"); else - vty_outln (vty, "vrf %s inactive", vrf_name); + vty_out (vty, "vrf %s inactive\n", vrf_name); return CMD_SUCCESS; } @@ -1126,7 +1128,7 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi, if (! table) { if (use_json) - vty_outln (vty, "{}"); + vty_out (vty, "{}\n"); return CMD_SUCCESS; } @@ -1183,7 +1185,7 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi, vty_out (vty, SHOW_ROUTE_V6_HEADER); if (zvrf_id (zvrf) != VRF_DEFAULT) - vty_outln (vty, "%sVRF %s:", VTYNL, + vty_out (vty, "\nVRF %s:\n", zvrf_name(zvrf)); first = 0; @@ -1203,7 +1205,7 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi, if (use_json) { - vty_outln (vty, "%s", + vty_out (vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -1244,7 +1246,7 @@ DEFUN (show_ip_nht_vrf_all, RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) if ((zvrf = vrf->info) != NULL) { - vty_outln (vty, "%sVRF %s:", VTYNL, zvrf_name(zvrf)); + vty_out (vty, "\nVRF %s:\n", zvrf_name(zvrf)); zebra_print_rnh_table(zvrf_id (zvrf), AF_INET, vty, RNH_NEXTHOP_TYPE); } @@ -1284,7 +1286,7 @@ DEFUN (show_ipv6_nht_vrf_all, RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) if ((zvrf = vrf->info) != NULL) { - vty_outln (vty, "%sVRF %s:", VTYNL, zvrf_name(zvrf)); + vty_out (vty, "\nVRF %s:\n", zvrf_name(zvrf)); zebra_print_rnh_table(zvrf_id (zvrf), AF_INET6, vty, RNH_NEXTHOP_TYPE); } @@ -1440,7 +1442,7 @@ DEFUN (show_ip_route, if (type < 0) { - vty_outln (vty, "Unknown route type"); + vty_out (vty, "Unknown route type\n"); return CMD_WARNING; } } @@ -1493,7 +1495,7 @@ DEFUN (show_ip_route_addr, if (ret <= 0) { - vty_outln (vty, "%% Malformed IPv4 address"); + vty_out (vty, "%% Malformed IPv4 address\n"); return CMD_WARNING; } @@ -1504,7 +1506,7 @@ DEFUN (show_ip_route_addr, rn = route_node_match (table, (struct prefix *) &p); if (! rn) { - vty_outln (vty, "%% Network not in table"); + vty_out (vty, "%% Network not in table\n"); return CMD_WARNING; } @@ -1542,7 +1544,7 @@ DEFUN (show_ip_route_prefix, if (ret <= 0) { - vty_outln (vty, "%% Malformed IPv4 address"); + vty_out (vty, "%% Malformed IPv4 address\n"); return CMD_WARNING; } @@ -1553,7 +1555,7 @@ DEFUN (show_ip_route_prefix, rn = route_node_match (table, (struct prefix *) &p); if (! rn || rn->p.prefixlen != p.prefixlen) { - vty_outln (vty, "%% Network not in table"); + vty_out (vty, "%% Network not in table\n"); return CMD_WARNING; } @@ -1602,7 +1604,7 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table) } } - vty_outln (vty, "%-20s %-20s %s (vrf %s)", + vty_out (vty, "%-20s %-20s %s (vrf %s)\n", "Route Source", "Routes", "FIB", zvrf_name(((rib_table_info_t *)table->info)->zvrf)); @@ -1613,21 +1615,21 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table) { if (i == ZEBRA_ROUTE_BGP) { - vty_outln (vty, "%-20s %-20d %-20d ", "ebgp", + vty_out (vty, "%-20s %-20d %-20d \n", "ebgp", rib_cnt[ZEBRA_ROUTE_BGP],fib_cnt[ZEBRA_ROUTE_BGP]); - vty_outln (vty, "%-20s %-20d %-20d ", "ibgp", + vty_out (vty, "%-20s %-20d %-20d \n", "ibgp", rib_cnt[ZEBRA_ROUTE_IBGP],fib_cnt[ZEBRA_ROUTE_IBGP]); } else - vty_outln (vty, "%-20s %-20d %-20d ", zebra_route_string(i), + vty_out (vty, "%-20s %-20d %-20d \n", zebra_route_string(i), rib_cnt[i], fib_cnt[i]); } } - vty_outln (vty, "------"); - vty_outln (vty, "%-20s %-20d %-20d ", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], + vty_out (vty, "------\n"); + vty_out (vty, "%-20s %-20d %-20d \n", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], fib_cnt[ZEBRA_ROUTE_TOTAL]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* @@ -1680,7 +1682,7 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table) } } - vty_outln (vty, "%-20s %-20s %s (vrf %s)", + vty_out (vty, "%-20s %-20s %s (vrf %s)\n", "Route Source", "Prefix Routes", "FIB", zvrf_name(((rib_table_info_t *)table->info)->zvrf)); @@ -1690,22 +1692,22 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table) { if (i == ZEBRA_ROUTE_BGP) { - vty_outln (vty, "%-20s %-20d %-20d ", "ebgp", + vty_out (vty, "%-20s %-20d %-20d \n", "ebgp", rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP]); - vty_outln (vty, "%-20s %-20d %-20d ", "ibgp", + vty_out (vty, "%-20s %-20d %-20d \n", "ibgp", rib_cnt[ZEBRA_ROUTE_IBGP],fib_cnt[ZEBRA_ROUTE_IBGP]); } else - vty_outln (vty, "%-20s %-20d %-20d ", zebra_route_string(i), + vty_out (vty, "%-20s %-20d %-20d \n", zebra_route_string(i), rib_cnt[i], fib_cnt[i]); } } - vty_outln (vty, "------"); - vty_outln (vty, "%-20s %-20d %-20d ", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], + vty_out (vty, "------\n"); + vty_out (vty, "%-20s %-20d %-20d \n", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], fib_cnt[ZEBRA_ROUTE_TOTAL]); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); } /* Show route summary. */ @@ -1780,7 +1782,7 @@ DEFUN (show_ip_route_vrf_all_addr, ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p); if (ret <= 0) { - vty_outln (vty, "%% Malformed IPv4 address"); + vty_out (vty, "%% Malformed IPv4 address\n"); return CMD_WARNING; } @@ -1822,7 +1824,7 @@ DEFUN (show_ip_route_vrf_all_prefix, ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret <= 0) { - vty_outln (vty, "%% Malformed IPv4 address"); + vty_out (vty, "%% Malformed IPv4 address\n"); return CMD_WARNING; } @@ -1958,7 +1960,7 @@ static_config (struct vty *vty, afi_t afi, safi_t safi, const char *cmd) mpls_label2str (si->snh_label.num_labels, si->snh_label.label, buf, sizeof buf, 0)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); write = 1; } @@ -1992,8 +1994,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, ret = str2prefix (dest_str, &p); if (ret <= 0) { - vty_outln (vty, "%% Malformed address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } if (src_str) @@ -2001,8 +2003,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, ret = str2prefix (src_str, &src); if (ret <= 0 || src.family != AF_INET6) { - vty_outln (vty, "%% Malformed source address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed source address\n"); + return CMD_WARNING_CONFIG_FAILED; } src_p = (struct prefix_ipv6*)&src; } @@ -2029,8 +2031,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, if (!zvrf) { - vty_outln (vty, "%% vrf %s is not defined", vrf_id_str); - return CMD_WARNING; + vty_out (vty, "%% vrf %s is not defined\n", vrf_id_str); + return CMD_WARNING_CONFIG_FAILED; } /* Labels */ @@ -2039,9 +2041,9 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, { if (!mpls_enabled) { - vty_outln (vty, - "%% MPLS not turned on in kernel, ignoring command"); - return CMD_WARNING; + vty_out (vty, + "%% MPLS not turned on in kernel, ignoring command\n"); + return CMD_WARNING_CONFIG_FAILED; } int rc = mpls_str2label (label_str, &snh_label.num_labels, snh_label.label); @@ -2049,18 +2051,18 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, { switch (rc) { case -1: - vty_outln (vty, "%% Malformed label(s)"); + vty_out (vty, "%% Malformed label(s)\n"); break; case -2: - vty_outln (vty, "%% Cannot use reserved label(s) (%d-%d)", + vty_out (vty, "%% Cannot use reserved label(s) (%d-%d)\n", MPLS_MIN_RESERVED_LABEL,MPLS_MAX_RESERVED_LABEL); break; case -3: - vty_outln (vty, "%% Too many labels. Enter %d or fewer", + vty_out (vty, "%% Too many labels. Enter %d or fewer\n", MPLS_MAX_LABELS); break; } - return CMD_WARNING; + return CMD_WARNING_CONFIG_FAILED; } } @@ -2069,8 +2071,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, { if (flag_str) { - vty_outln (vty, "%% can not have flag %s with Null0", flag_str); - return CMD_WARNING; + vty_out (vty, "%% can not have flag %s with Null0\n", flag_str); + return CMD_WARNING_CONFIG_FAILED; } if (add_cmd) static_add_route (AFI_IP6, SAFI_UNICAST, type, &p, src_p, NULL, ifindex, ifname, @@ -2093,8 +2095,8 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE); break; default: - vty_outln (vty, "%% Malformed flag %s ", flag_str); - return CMD_WARNING; + vty_out (vty, "%% Malformed flag %s \n", flag_str); + return CMD_WARNING_CONFIG_FAILED; } } @@ -2104,16 +2106,16 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, address. */ if (ret != 1) { - vty_outln (vty, "%% Malformed address"); - return CMD_WARNING; + vty_out (vty, "%% Malformed address\n"); + return CMD_WARNING_CONFIG_FAILED; } type = STATIC_IPV6_GATEWAY_IFINDEX; gate = &gate_addr; ifp = if_lookup_by_name (ifname, zvrf_id (zvrf)); if (!ifp) { - vty_outln (vty, "%% Malformed Interface name %s", ifname); - return CMD_WARNING; + vty_out (vty, "%% Malformed Interface name %s\n", ifname); + return CMD_WARNING_CONFIG_FAILED; } ifindex = ifp->ifindex; } @@ -2130,7 +2132,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, ifp = if_lookup_by_name (gate_str, zvrf_id (zvrf)); if (!ifp) { - vty_outln (vty, "%% Malformed Interface name %s", gate_str); + vty_out (vty, "%% Malformed Interface name %s\n", gate_str); ifindex = IFINDEX_DELETED; } else @@ -2618,7 +2620,7 @@ DEFUN (show_ipv6_route, if (type < 0) { - vty_outln (vty, "Unknown route type"); + vty_out (vty, "Unknown route type\n"); return CMD_WARNING; } } @@ -2671,7 +2673,7 @@ DEFUN (show_ipv6_route_addr, if (ret <= 0) { - vty_outln (vty, "Malformed IPv6 address"); + vty_out (vty, "Malformed IPv6 address\n"); return CMD_WARNING; } @@ -2682,7 +2684,7 @@ DEFUN (show_ipv6_route_addr, rn = route_node_match (table, (struct prefix *) &p); if (! rn) { - vty_outln (vty, "%% Network not in table"); + vty_out (vty, "%% Network not in table\n"); return CMD_WARNING; } @@ -2718,7 +2720,7 @@ DEFUN (show_ipv6_route_prefix, if (ret <= 0) { - vty_outln (vty, "Malformed IPv6 prefix"); + vty_out (vty, "Malformed IPv6 prefix\n"); return CMD_WARNING; } @@ -2729,7 +2731,7 @@ DEFUN (show_ipv6_route_prefix, rn = route_node_match (table, (struct prefix *) &p); if (! rn || rn->p.prefixlen != p.prefixlen) { - vty_outln (vty, "%% Network not in table"); + vty_out (vty, "%% Network not in table\n"); return CMD_WARNING; } @@ -2853,7 +2855,7 @@ DEFUN (show_ipv6_route_vrf_all_addr, ret = str2prefix_ipv6 (argv[idx_ipv6]->arg, &p); if (ret <= 0) { - vty_outln (vty, "Malformed IPv6 address"); + vty_out (vty, "Malformed IPv6 address\n"); return CMD_WARNING; } @@ -2895,7 +2897,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix, ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, &p); if (ret <= 0) { - vty_outln (vty, "Malformed IPv6 prefix"); + vty_out (vty, "Malformed IPv6 prefix\n"); return CMD_WARNING; } @@ -3040,13 +3042,244 @@ DEFUN (show_vrf, vty_out (vty, "inactive"); else vty_out (vty, "id %u table %u", zvrf_id (zvrf), zvrf->table_id); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); + + } + + return CMD_SUCCESS; +} + +DEFUN (show_evpn_vni, + show_evpn_vni_cmd, + "show evpn vni", + SHOW_STR + "EVPN\n" + "VxLAN information\n") +{ + struct zebra_vrf *zvrf; + + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_vnis(vty, zvrf); + return CMD_SUCCESS; +} + +DEFUN (show_evpn_vni_vni, + show_evpn_vni_vni_cmd, + "show evpn vni " CMD_VNI_RANGE, + SHOW_STR + "EVPN\n" + "VxLAN Network Identifier\n" + "VNI number\n") +{ + struct zebra_vrf *zvrf; + vni_t vni; + vni = strtoul(argv[3]->arg, NULL, 10); + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_vni(vty, zvrf, vni); + return CMD_SUCCESS; +} + +DEFUN (show_evpn_mac_vni, + show_evpn_mac_vni_cmd, + "show evpn mac vni " CMD_VNI_RANGE, + SHOW_STR + "EVPN\n" + "MAC addresses\n" + "VxLAN Network Identifier\n" + "VNI number\n") +{ + struct zebra_vrf *zvrf; + vni_t vni; + + vni = strtoul(argv[4]->arg, NULL, 10); + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_macs_vni(vty, zvrf, vni); + return CMD_SUCCESS; +} + +DEFUN (show_evpn_mac_vni_all, + show_evpn_mac_vni_all_cmd, + "show evpn mac vni all", + SHOW_STR + "EVPN\n" + "MAC addresses\n" + "VxLAN Network Identifier\n" + "All VNIs\n") +{ + struct zebra_vrf *zvrf; + + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_macs_all_vni(vty, zvrf); + return CMD_SUCCESS; +} + +DEFUN (show_evpn_mac_vni_all_vtep, + show_evpn_mac_vni_all_vtep_cmd, + "show evpn mac vni all vtep A.B.C.D", + SHOW_STR + "EVPN\n" + "MAC addresses\n" + "VxLAN Network Identifier\n" + "All VNIs\n" + "Remote VTEP\n" + "Remote VTEP IP address\n") +{ + struct zebra_vrf *zvrf; + struct in_addr vtep_ip; + + if (!inet_aton (argv[6]->arg, &vtep_ip)) + { + vty_out (vty, "%% Malformed VTEP IP address\n"); + return CMD_WARNING; } + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_macs_all_vni_vtep(vty, zvrf, vtep_ip); return CMD_SUCCESS; } + +DEFUN (show_evpn_mac_vni_mac, + show_evpn_mac_vni_mac_cmd, + "show evpn mac vni " CMD_VNI_RANGE " mac WORD", + SHOW_STR + "EVPN\n" + "MAC addresses\n" + "VxLAN Network Identifier\n" + "VNI number\n" + "MAC\n" + "MAC address (e.g., 00:e0:ec:20:12:62)\n") +{ + struct zebra_vrf *zvrf; + vni_t vni; + struct ethaddr mac; + + vni = strtoul(argv[4]->arg, NULL, 10); + if (!prefix_str2mac (argv[6]->arg, &mac)) + { + vty_out (vty, "%% Malformed MAC address"); + return CMD_WARNING; + } + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_specific_mac_vni(vty, zvrf, vni, &mac); + return CMD_SUCCESS; +} + +DEFUN (show_evpn_mac_vni_vtep, + show_evpn_mac_vni_vtep_cmd, + "show evpn mac vni " CMD_VNI_RANGE " vtep A.B.C.D", + SHOW_STR + "EVPN\n" + "MAC addresses\n" + "VxLAN Network Identifier\n" + "VNI number\n" + "Remote VTEP\n" + "Remote VTEP IP address\n") +{ + struct zebra_vrf *zvrf; + vni_t vni; + struct in_addr vtep_ip; + + vni = strtoul(argv[4]->arg, NULL, 10); + if (!inet_aton (argv[6]->arg, &vtep_ip)) + { + vty_out (vty, "%% Malformed VTEP IP address\n"); + return CMD_WARNING; + } + + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_macs_vni_vtep(vty, zvrf, vni, vtep_ip); + return CMD_SUCCESS; +} + +DEFUN (show_evpn_neigh_vni, + show_evpn_neigh_vni_cmd, + "show evpn arp-cache vni " CMD_VNI_RANGE, + SHOW_STR + "EVPN\n" + "ARP and ND cache\n" + "VxLAN Network Identifier\n" + "VNI number\n") +{ + struct zebra_vrf *zvrf; + vni_t vni; + + vni = strtoul(argv[4]->arg, NULL, 10); + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_neigh_vni(vty, zvrf, vni); + return CMD_SUCCESS; +} + +DEFUN (show_evpn_neigh_vni_all, + show_evpn_neigh_vni_all_cmd, + "show evpn arp-cache vni all", + SHOW_STR + "EVPN\n" + "ARP and ND cache\n" + "VxLAN Network Identifier\n" + "All VNIs\n") +{ + struct zebra_vrf *zvrf; + + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_neigh_all_vni(vty, zvrf); + return CMD_SUCCESS; +} + +DEFUN (show_evpn_neigh_vni_neigh, + show_evpn_neigh_vni_neigh_cmd, + "show evpn arp-cache vni " CMD_VNI_RANGE " ip WORD", + SHOW_STR + "EVPN\n" + "ARP and ND cache\n" + "VxLAN Network Identifier\n" + "VNI number\n" + "Neighbor\n" + "Neighbor address (IPv4 or IPv6 address)\n") +{ + struct zebra_vrf *zvrf; + vni_t vni; + struct ipaddr ip; + + vni = strtoul(argv[4]->arg, NULL, 10); + if (str2ipaddr (argv[6]->arg, &ip) != 0) + { + vty_out (vty, "%% Malformed Neighbor address\n"); + return CMD_WARNING; + } + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_specific_neigh_vni(vty, zvrf, vni, &ip); + return CMD_SUCCESS; +} + +DEFUN (show_evpn_neigh_vni_vtep, + show_evpn_neigh_vni_vtep_cmd, + "show evpn arp-cache vni " CMD_VNI_RANGE " vtep A.B.C.D", + SHOW_STR + "EVPN\n" + "ARP and ND cache\n" + "VxLAN Network Identifier\n" + "VNI number\n" + "Remote VTEP\n" + "Remote VTEP IP address\n") +{ + struct zebra_vrf *zvrf; + vni_t vni; + struct in_addr vtep_ip; + + vni = strtoul(argv[4]->arg, NULL, 10); + if (!inet_aton (argv[6]->arg, &vtep_ip)) + { + vty_out (vty, "%% Malformed VTEP IP address\n"); + return CMD_WARNING; + } + + zvrf = vrf_info_lookup(VRF_DEFAULT); + zebra_vxlan_print_neigh_vni_vtep(vty, zvrf, vni, vtep_ip); + return CMD_SUCCESS; +} + /* Static ip route configuration write function. */ static int zebra_ip_config (struct vty *vty) @@ -3085,14 +3318,14 @@ DEFUN (ip_zebra_import_table_distance, if (!is_zebra_valid_kernel_table(table_id)) { - vty_outln (vty, "Invalid routing table ID, %d. Must be in range 1-252", + vty_out (vty, "Invalid routing table ID, %d. Must be in range 1-252\n", table_id); return CMD_WARNING; } if (is_zebra_main_routing_table(table_id)) { - vty_outln (vty, "Invalid routing table ID, %d. Must be non-default table", + vty_out (vty, "Invalid routing table ID, %d. Must be non-default table\n", table_id); return CMD_WARNING; } @@ -3121,13 +3354,13 @@ DEFUN (no_ip_zebra_import_table, if (!is_zebra_valid_kernel_table(table_id)) { - vty_outln (vty,"Invalid routing table ID. Must be in range 1-252"); + vty_out (vty,"Invalid routing table ID. Must be in range 1-252\n"); return CMD_WARNING; } if (is_zebra_main_routing_table(table_id)) { - vty_outln (vty, "Invalid routing table ID, %d. Must be non-default table", + vty_out (vty, "Invalid routing table ID, %d. Must be non-default table\n", table_id); return CMD_WARNING; } @@ -3142,18 +3375,18 @@ static int config_write_protocol (struct vty *vty) { if (allow_delete) - vty_outln (vty, "allow-external-route-update"); + vty_out (vty, "allow-external-route-update\n"); if (zebra_rnh_ip_default_route) - vty_outln (vty, "ip nht resolve-via-default"); + vty_out (vty, "ip nht resolve-via-default\n"); if (zebra_rnh_ipv6_default_route) - vty_outln (vty, "ipv6 nht resolve-via-default"); + vty_out (vty, "ipv6 nht resolve-via-default\n"); enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get (); if (ipv4_multicast_mode != MCAST_NO_CONFIG) - vty_outln (vty, "ip multicast rpf-lookup-mode %s", + vty_out (vty, "ip multicast rpf-lookup-mode %s\n", ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" : ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" : ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" : ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" : "longer-prefix"); zebra_routemap_config_write_protocol(vty); @@ -3237,4 +3470,16 @@ zebra_vty_init (void) install_element (VIEW_NODE, &show_ipv6_route_vrf_all_prefix_cmd); install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd); + + install_element (VIEW_NODE, &show_evpn_vni_cmd); + install_element (VIEW_NODE, &show_evpn_vni_vni_cmd); + install_element (VIEW_NODE, &show_evpn_mac_vni_cmd); + install_element (VIEW_NODE, &show_evpn_mac_vni_all_cmd); + install_element (VIEW_NODE, &show_evpn_mac_vni_all_vtep_cmd); + install_element (VIEW_NODE, &show_evpn_mac_vni_mac_cmd); + install_element (VIEW_NODE, &show_evpn_mac_vni_vtep_cmd); + install_element (VIEW_NODE, &show_evpn_neigh_vni_cmd); + install_element (VIEW_NODE, &show_evpn_neigh_vni_all_cmd); + install_element (VIEW_NODE, &show_evpn_neigh_vni_neigh_cmd); + install_element (VIEW_NODE, &show_evpn_neigh_vni_vtep_cmd); } diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c new file mode 100644 index 000000000..7df31cb93 --- /dev/null +++ b/zebra/zebra_vxlan.c @@ -0,0 +1,3380 @@ +/* + * Zebra EVPN for VxLAN code + * Copyright (C) 2016, 2017 Cumulus Networks, Inc. + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <zebra.h> + +#include "if.h" +#include "prefix.h" +#include "table.h" +#include "memory.h" +#include "log.h" +#include "linklist.h" +#include "stream.h" +#include "hash.h" +#include "jhash.h" +#include "vlan.h" +#include "vxlan.h" + +#include "zebra/rib.h" +#include "zebra/rt.h" +#include "zebra/zebra_ns.h" +#include "zebra/zserv.h" +#include "zebra/debug.h" +#include "zebra/interface.h" +#include "zebra/zebra_vrf.h" +#include "zebra/rt_netlink.h" +#include "zebra/zebra_vxlan_private.h" +#include "zebra/zebra_vxlan.h" +#include "zebra/zebra_memory.h" +#include "zebra/zebra_l2.h" + +DEFINE_MTYPE_STATIC(ZEBRA, ZVNI, "VNI hash"); +DEFINE_MTYPE_STATIC(ZEBRA, ZVNI_VTEP, "VNI remote VTEP"); +DEFINE_MTYPE_STATIC(ZEBRA, MAC, "VNI MAC"); +DEFINE_MTYPE_STATIC(ZEBRA, NEIGH, "VNI Neighbor"); + +/* definitions */ + + +/* static function declarations */ +static void +zvni_print_neigh (zebra_neigh_t *n, void *ctxt); +static void +zvni_print_neigh_hash (struct hash_backet *backet, void *ctxt); +static void +zvni_print_neigh_hash_all_vni (struct hash_backet *backet, void *ctxt); +static void +zvni_print_mac (zebra_mac_t *mac, void *ctxt); +static void +zvni_print_mac_hash (struct hash_backet *backet, void *ctxt); +static void +zvni_print_mac_hash_all_vni (struct hash_backet *backet, void *ctxt); +static void +zvni_print (zebra_vni_t *zvni, void *ctxt); +static void +zvni_print_hash (struct hash_backet *backet, void *ctxt); + +static int +zvni_macip_send_msg_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ethaddr *macaddr, + struct ipaddr *ip, u_char sticky, + u_int16_t cmd); +static unsigned int +neigh_hash_keymake (void *p); +static int +neigh_cmp (const void *p1, const void *p2); +static void * +zvni_neigh_alloc (void *p); +static zebra_neigh_t * +zvni_neigh_add (zebra_vni_t *zvni, struct ipaddr *ip); +static int +zvni_neigh_del (zebra_vni_t *zvni, zebra_neigh_t *n); +static int +zvni_neigh_del_hash_entry (struct hash_backet *backet, void *arg); +static void +zvni_neigh_del_from_vtep (zebra_vni_t *zvni, int uninstall, + struct in_addr *r_vtep_ip); +static void +zvni_neigh_del_all (struct zebra_vrf *zvrf, zebra_vni_t *zvni, + int uninstall, int upd_client, u_int32_t flags); +static zebra_neigh_t * +zvni_neigh_lookup (zebra_vni_t *zvni, struct ipaddr *ip); +static int +zvni_neigh_send_add_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ipaddr *ip, struct ethaddr *macaddr); +static int +zvni_neigh_send_del_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ipaddr *ip, struct ethaddr *macaddr); +static int +zvni_neigh_install (zebra_vni_t *zvni, zebra_neigh_t *n); +static int +zvni_neigh_uninstall (zebra_vni_t *zvni, zebra_neigh_t *n); +static zebra_vni_t * +zvni_map_svi (struct interface *ifp, struct interface *br_if); +static struct interface * +zvni_map_to_svi (struct zebra_vrf *zvrf, vlanid_t vid, + struct interface *br_if); + +static unsigned int +mac_hash_keymake (void *p); +static int +mac_cmp (const void *p1, const void *p2); +static void * +zvni_mac_alloc (void *p); +static zebra_mac_t * +zvni_mac_add (zebra_vni_t *zvni, struct ethaddr *macaddr); +static int +zvni_mac_del (zebra_vni_t *zvni, zebra_mac_t *mac); +static int +zvni_mac_del_hash_entry (struct hash_backet *backet, void *arg); +static void +zvni_mac_del_from_vtep (zebra_vni_t *zvni, int uninstall, + struct in_addr *r_vtep_ip); +static void +zvni_mac_del_all (struct zebra_vrf *zvrf, zebra_vni_t *zvni, + int uninstall, int upd_client, u_int32_t flags); +static zebra_mac_t * +zvni_mac_lookup (zebra_vni_t *zvni, struct ethaddr *macaddr); +static int +zvni_mac_send_add_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ethaddr *macaddr, u_char sticky); +static int +zvni_mac_send_del_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ethaddr *macaddr, u_char sticky); +static zebra_vni_t * +zvni_map_vlan (struct interface *ifp, struct interface *br_if, vlanid_t vid); +static int +zvni_mac_install (zebra_vni_t *zvni, zebra_mac_t *mac); +static int +zvni_mac_uninstall (zebra_vni_t *zvni, zebra_mac_t *mac, int local); +static void +zvni_install_mac_hash (struct hash_backet *backet, void *ctxt); + +static unsigned int +vni_hash_keymake (void *p); +static int +vni_hash_cmp (const void *p1, const void *p2); +static void * +zvni_alloc (void *p); +static zebra_vni_t * +zvni_lookup (struct zebra_vrf *zvrf, vni_t vni); +static zebra_vni_t * +zvni_add (struct zebra_vrf *zvrf, vni_t vni); +static int +zvni_del (struct zebra_vrf *zvrf, zebra_vni_t *zvni); +static int +zvni_send_add_to_client (struct zebra_vrf *zvrf, zebra_vni_t *zvni); +static int +zvni_send_del_to_client (struct zebra_vrf *zvrf, vni_t vni); +static void +zvni_build_hash_table (struct zebra_vrf *zvrf); +static int +zvni_vtep_match (struct in_addr *vtep_ip, zebra_vtep_t *zvtep); +static zebra_vtep_t * +zvni_vtep_find (zebra_vni_t *zvni, struct in_addr *vtep_ip); +static zebra_vtep_t * +zvni_vtep_add (zebra_vni_t *zvni, struct in_addr *vtep_ip); +static int +zvni_vtep_del (zebra_vni_t *zvni, zebra_vtep_t *zvtep); +static int +zvni_vtep_del_all (zebra_vni_t *zvni, int uninstall); +static int +zvni_vtep_install (zebra_vni_t *zvni, struct in_addr *vtep_ip); +static int +zvni_vtep_uninstall (zebra_vni_t *zvni, struct in_addr *vtep_ip); + + +/* Private functions */ + +/* + * Helper function to determine maximum width of neighbor IP address for + * display - just because we're dealing with IPv6 addresses that can + * widely vary. + */ +static void +zvni_find_neigh_addr_width (struct hash_backet *backet, void *ctxt) +{ + zebra_neigh_t *n; + char buf[INET6_ADDRSTRLEN]; + struct neigh_walk_ctx *wctx = ctxt; + int width; + + n = (zebra_neigh_t *) backet->data; + if (!n) + return; + + ipaddr2str (&n->ip, buf, sizeof(buf)), + width = strlen (buf); + if (width > wctx->addr_width) + wctx->addr_width = width; +} + +/* + * Print a specific neighbor entry. + */ +static void +zvni_print_neigh (zebra_neigh_t *n, void *ctxt) +{ + struct vty *vty; + char buf1[ETHER_ADDR_STRLEN]; + char buf2[INET6_ADDRSTRLEN]; + + ipaddr2str (&n->ip, buf2, sizeof(buf2)), + vty = (struct vty *) ctxt; + vty_out(vty, "IP: %s\n", + ipaddr2str (&n->ip, buf2, sizeof(buf2))); + vty_out(vty, " MAC: %s", prefix_mac2str (&n->emac, buf1, sizeof (buf1))); + if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) + vty_out(vty, " Remote VTEP: %s", inet_ntoa (n->r_vtep_ip)); + vty_out(vty, "\n"); +} + +/* + * Print neighbor hash entry - called for display of all neighbors. + */ +static void +zvni_print_neigh_hash (struct hash_backet *backet, void *ctxt) +{ + struct vty *vty; + zebra_neigh_t *n; + char buf1[ETHER_ADDR_STRLEN]; + char buf2[INET6_ADDRSTRLEN]; + struct neigh_walk_ctx *wctx = ctxt; + + vty = wctx->vty; + n = (zebra_neigh_t *) backet->data; + if (!n) + return; + + prefix_mac2str (&n->emac, buf1, sizeof (buf1)); + ipaddr2str (&n->ip, buf2, sizeof(buf2)); + if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL) && + !(wctx->flags & SHOW_REMOTE_NEIGH_FROM_VTEP)) + { + vty_out(vty, "%*s %-6s %-17s\n", + -wctx->addr_width, buf2, "local", buf1); + wctx->count++; + } + else + { + if (wctx->flags & SHOW_REMOTE_NEIGH_FROM_VTEP) + { + if (IPV4_ADDR_SAME(&n->r_vtep_ip, &wctx->r_vtep_ip)) + { + if (wctx->count == 0) + vty_out(vty, "%*s %-6s %-17s %-21s\n", + -wctx->addr_width, "Neighbor", "Type", "MAC", + "Remote VTEP"); + vty_out(vty, "%*s %-6s %-17s %-21s\n", + -wctx->addr_width, buf2, "remote", buf1, + inet_ntoa (n->r_vtep_ip)); + wctx->count++; + } + } + else + { + vty_out(vty, "%*s %-6s %-17s %-21s\n", + -wctx->addr_width, buf2, "remote", buf1, + inet_ntoa (n->r_vtep_ip)); + wctx->count++; + } + } +} + +/* + * Print neighbors for all VNI. + */ +static void +zvni_print_neigh_hash_all_vni (struct hash_backet *backet, void *ctxt) +{ + struct vty *vty; + zebra_vni_t *zvni; + u_int32_t num_neigh; + struct neigh_walk_ctx wctx; + + vty = (struct vty *) ctxt; + zvni = (zebra_vni_t *) backet->data; + if (!zvni) + return; + + num_neigh = hashcount(zvni->neigh_table); + vty_out(vty, "\nVNI %u #ARP (IPv4 and IPv6, local and remote) %u\n\n", + zvni->vni, num_neigh); + if (!num_neigh) + return; + + /* Since we have IPv6 addresses to deal with which can vary widely in + * size, we try to be a bit more elegant in display by first computing + * the maximum width. + */ + memset (&wctx, 0, sizeof (struct neigh_walk_ctx)); + wctx.zvni = zvni; + wctx.vty = vty; + wctx.addr_width = 15; + hash_iterate(zvni->neigh_table, zvni_find_neigh_addr_width, &wctx); + + vty_out(vty, "%*s %-6s %-17s %-21s\n", + -wctx.addr_width, "IP", "Type", "MAC", + "Remote VTEP"); + hash_iterate(zvni->neigh_table, zvni_print_neigh_hash, &wctx); +} + +/* + * Print a specific MAC entry. + */ +static void +zvni_print_mac (zebra_mac_t *mac, void *ctxt) +{ + struct vty *vty; + char buf1[20]; + + vty = (struct vty *) ctxt; + vty_out(vty, "MAC: %s", + prefix_mac2str (&mac->macaddr, buf1, sizeof (buf1))); + if (CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL)) + { + struct zebra_ns *zns; + struct interface *ifp; + ifindex_t ifindex; + + ifindex = mac->fwd_info.local.ifindex; + zns = zebra_ns_lookup (NS_DEFAULT); + ifp = if_lookup_by_index_per_ns (zns, ifindex); + if (!ifp) // unexpected + return; + vty_out(vty, " Intf: %s(%u)", ifp->name, ifindex); + if (mac->fwd_info.local.vid) + vty_out(vty, " VLAN: %u", mac->fwd_info.local.vid); + } + else + { + vty_out(vty, " Remote VTEP: %s", + inet_ntoa (mac->fwd_info.r_vtep_ip)); + } + vty_out(vty, " ARP ref: %u", mac->neigh_refcnt); + vty_out(vty, "\n"); +} + +/* + * Print MAC hash entry - called for display of all MACs. + */ +static void +zvni_print_mac_hash (struct hash_backet *backet, void *ctxt) +{ + struct vty *vty; + zebra_mac_t *mac; + char buf1[20]; + struct mac_walk_ctx *wctx = ctxt; + + vty = wctx->vty; + mac = (zebra_mac_t *) backet->data; + if (!mac) + return; + + prefix_mac2str (&mac->macaddr, buf1, sizeof (buf1)); + if (CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL) && + !(wctx->flags & SHOW_REMOTE_MAC_FROM_VTEP)) + { + struct zebra_ns *zns; + ifindex_t ifindex; + struct interface *ifp; + vlanid_t vid; + + zns = zebra_ns_lookup (NS_DEFAULT); + ifindex = mac->fwd_info.local.ifindex; + ifp = if_lookup_by_index_per_ns (zns, ifindex); + if (!ifp) // unexpected + return; + vid = mac->fwd_info.local.vid; + vty_out(vty, "%-17s %-6s %-21s", + buf1, "local", ifp->name); + if (vid) + vty_out(vty, " %-5u", vid); + vty_out(vty, "\n"); + wctx->count++; + } + else + { + if (wctx->flags & SHOW_REMOTE_MAC_FROM_VTEP) + { + if (IPV4_ADDR_SAME(&mac->fwd_info.r_vtep_ip, + &wctx->r_vtep_ip)) + { + if (wctx->count == 0) + { + vty_out(vty, "\nVNI %u", + wctx->zvni->vni); + vty_out(vty, "%-17s %-6s %-21s %-5s", + "MAC", "Type", "Intf/Remote VTEP", + "VLAN"); + } + vty_out(vty, "%-17s %-6s %-21s", + buf1, "remote", + inet_ntoa (mac->fwd_info.r_vtep_ip)); + wctx->count++; + } + } + else + { + vty_out(vty, "%-17s %-6s %-21s", + buf1, "remote", + inet_ntoa (mac->fwd_info.r_vtep_ip)); + wctx->count++; + } + } + +} + +/* + * Print MACs for all VNI. + */ +static void +zvni_print_mac_hash_all_vni (struct hash_backet *backet, void *ctxt) +{ + struct vty *vty; + zebra_vni_t *zvni; + u_int32_t num_macs; + struct mac_walk_ctx *wctx = ctxt; + + vty = (struct vty *) wctx->vty; + + zvni = (zebra_vni_t *) backet->data; + if (!zvni) + return; + wctx->zvni = zvni; + + /*We are iterating over a new VNI, set the count to 0*/ + wctx->count = 0; + + num_macs = hashcount(zvni->mac_table); + if (!num_macs) + return; + if (!CHECK_FLAG(wctx->flags, SHOW_REMOTE_MAC_FROM_VTEP)) + { + vty_out(vty, "\nVNI %u #MACs (local and remote) %u\n\n", + zvni->vni, num_macs); + vty_out(vty, "%-17s %-6s %-21s %-5s\n", + "MAC", "Type", "Intf/Remote VTEP", "VLAN"); + } + + hash_iterate(zvni->mac_table, zvni_print_mac_hash, wctx); +} + +/* + * Print a specific VNI entry. + */ +static void +zvni_print (zebra_vni_t *zvni, void *ctxt) +{ + struct vty *vty; + zebra_vtep_t *zvtep; + u_int32_t num_macs; + u_int32_t num_neigh; + + vty = (struct vty *) ctxt; + + vty_out(vty, "VNI: %u\n", zvni->vni); + if (!zvni->vxlan_if) + { // unexpected + vty_out(vty, " VxLAN interface: unknown\n"); + return; + } + vty_out(vty, " VxLAN interface: %s ifIndex: %u VTEP IP: %s\n", + zvni->vxlan_if->name, zvni->vxlan_if->ifindex, + inet_ntoa(zvni->local_vtep_ip)); + + if (!zvni->vteps) + { + vty_out(vty, " No remote VTEPs known for this VNI\n"); + } + else + { + vty_out(vty, " Remote VTEPs for this VNI:\n"); + for (zvtep = zvni->vteps; zvtep; zvtep = zvtep->next) + vty_out(vty, " %s\n", + inet_ntoa (zvtep->vtep_ip)); + } + num_macs = hashcount(zvni->mac_table); + vty_out(vty, " Number of MACs (local and remote) known for this VNI: %u\n", + num_macs); + num_neigh = hashcount(zvni->neigh_table); + vty_out(vty, " Number of ARPs (IPv4 and IPv6, local and remote) " + "known for this VNI: %u", num_neigh); +} + +/* + * Print a VNI hash entry - called for display of all VNIs. + */ +static void +zvni_print_hash (struct hash_backet *backet, void *ctxt) +{ + struct vty *vty; + zebra_vni_t *zvni; + zebra_vtep_t *zvtep; + u_int32_t num_vteps = 0; + u_int32_t num_macs = 0; + u_int32_t num_neigh = 0; + + vty = (struct vty *) ctxt; + zvni = (zebra_vni_t *) backet->data; + if (!zvni) + return; + + zvtep = zvni->vteps; + while (zvtep) + { + num_vteps++; + zvtep = zvtep->next; + } + + num_macs = hashcount(zvni->mac_table); + num_neigh = hashcount(zvni->neigh_table); + vty_out(vty, "%-10u %-21s %-15s %-8u %-8u %-15u\n", + zvni->vni, + zvni->vxlan_if ? zvni->vxlan_if->name : "unknown", + inet_ntoa(zvni->local_vtep_ip), + num_macs, num_neigh, num_vteps); +} + +/* + * Inform BGP about local MACIP. + */ +static int +zvni_macip_send_msg_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ethaddr *macaddr, + struct ipaddr *ip, u_char sticky, + u_int16_t cmd) +{ + struct zserv *client; + struct stream *s; + int ipa_len; + char buf[ETHER_ADDR_STRLEN]; + char buf2[INET6_ADDRSTRLEN]; + + client = zebra_find_client (ZEBRA_ROUTE_BGP); + /* BGP may not be running. */ + if (!client) + return 0; + + s = client->obuf; + stream_reset (s); + + zserv_create_header (s, cmd, zvrf_id (zvrf)); + stream_putl (s, vni); + stream_put (s, macaddr->octet, ETHER_ADDR_LEN); + if (ip) + { + ipa_len = 0; + if (IS_IPADDR_V4(ip)) + ipa_len = IPV4_MAX_BYTELEN; + else if (IS_IPADDR_V6(ip)) + ipa_len = IPV6_MAX_BYTELEN; + + stream_putl (s, ipa_len); /* IP address length */ + if (ipa_len) + stream_put (s, &ip->ip.addr, ipa_len); /* IP address */ + } + else + stream_putl (s, 0); /* Just MAC. */ + + stream_putc (s, sticky); /* Sticky MAC? */ + + /* Write packet size. */ + stream_putw_at (s, 0, stream_get_endp (s)); + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Send MACIP %s %sMAC %s IP %s VNI %u to %s", + zvrf_id (zvrf), (cmd == ZEBRA_MACIP_ADD) ? "Add" : "Del", + sticky ? "sticky " : "", + prefix_mac2str (macaddr, buf, sizeof (buf)), + ipaddr2str (ip, buf2, sizeof(buf2)), vni, + zebra_route_string (client->proto)); + + if (cmd == ZEBRA_MACIP_ADD) + client->macipadd_cnt++; + else + client->macipdel_cnt++; + + return zebra_server_send_message(client); +} + +/* + * Make hash key for neighbors. + */ +static unsigned int +neigh_hash_keymake (void *p) +{ + zebra_neigh_t *n = p; + struct ipaddr *ip = &n->ip; + + if (IS_IPADDR_V4(ip)) + return jhash_1word (ip->ipaddr_v4.s_addr, 0); + + return jhash2 (ip->ipaddr_v6.s6_addr32, + ZEBRA_NUM_OF(ip->ipaddr_v6.s6_addr32), 0); +} + +/* + * Compare two neighbor hash structures. + */ +static int +neigh_cmp (const void *p1, const void *p2) +{ + const zebra_neigh_t *n1 = p1; + const zebra_neigh_t *n2 = p2; + + if (n1 == NULL && n2 == NULL) + return 1; + + if (n1 == NULL || n2 == NULL) + return 0; + + return (memcmp(&n1->ip, &n2->ip, sizeof (struct ipaddr)) == 0); +} + +/* + * Callback to allocate neighbor hash entry. + */ +static void * +zvni_neigh_alloc (void *p) +{ + const zebra_neigh_t *tmp_n = p; + zebra_neigh_t *n; + + n = XCALLOC (MTYPE_NEIGH, sizeof(zebra_neigh_t)); + *n = *tmp_n; + + return ((void *)n); +} + +/* + * Add neighbor entry. + */ +static zebra_neigh_t * +zvni_neigh_add (zebra_vni_t *zvni, struct ipaddr *ip) +{ + zebra_neigh_t tmp_n; + zebra_neigh_t *n = NULL; + + memset (&tmp_n, 0, sizeof (zebra_neigh_t)); + memcpy (&tmp_n.ip, ip, sizeof (struct ipaddr)); + n = hash_get (zvni->neigh_table, &tmp_n, zvni_neigh_alloc); + assert (n); + + return n; +} + +/* + * Delete neighbor entry. + */ +static int +zvni_neigh_del (zebra_vni_t *zvni, zebra_neigh_t *n) +{ + zebra_neigh_t *tmp_n; + + /* Free the VNI hash entry and allocated memory. */ + tmp_n = hash_release (zvni->neigh_table, n); + if (tmp_n) + XFREE(MTYPE_NEIGH, tmp_n); + + return 0; +} + +/* + * Free neighbor hash entry (callback) + */ +static int +zvni_neigh_del_hash_entry (struct hash_backet *backet, void *arg) +{ + struct neigh_walk_ctx *wctx = arg; + zebra_neigh_t *n = backet->data; + + if (((wctx->flags & DEL_LOCAL_NEIGH) && (n->flags & ZEBRA_NEIGH_LOCAL)) || + ((wctx->flags & DEL_REMOTE_NEIGH) && (n->flags & ZEBRA_NEIGH_REMOTE)) || + ((wctx->flags & DEL_REMOTE_NEIGH_FROM_VTEP) && + (n->flags & ZEBRA_NEIGH_REMOTE) && + IPV4_ADDR_SAME(&n->r_vtep_ip, &wctx->r_vtep_ip) + )) + { + if (wctx->upd_client && (n->flags & ZEBRA_NEIGH_LOCAL)) + zvni_neigh_send_del_to_client (wctx->zvrf, wctx->zvni->vni, &n->ip, + &n->emac); + + if (wctx->uninstall) + zvni_neigh_uninstall (wctx->zvni, n); + + return zvni_neigh_del (wctx->zvni, n); + } + + return 0; +} + +/* + * Delete all neighbor entries from specific VTEP for a particular VNI. + */ +static void +zvni_neigh_del_from_vtep (zebra_vni_t *zvni, int uninstall, + struct in_addr *r_vtep_ip) +{ + struct neigh_walk_ctx wctx; + + if (!zvni->neigh_table) + return; + + memset (&wctx, 0, sizeof (struct neigh_walk_ctx)); + wctx.zvni = zvni; + wctx.uninstall = uninstall; + wctx.flags = DEL_REMOTE_NEIGH_FROM_VTEP; + wctx.r_vtep_ip = *r_vtep_ip; + + hash_iterate (zvni->neigh_table, + (void (*) (struct hash_backet *, void *)) + zvni_neigh_del_hash_entry, &wctx); +} + +/* + * Delete all neighbor entries for this VNI. + */ +static void +zvni_neigh_del_all (struct zebra_vrf *zvrf, zebra_vni_t *zvni, + int uninstall, int upd_client, u_int32_t flags) +{ + struct neigh_walk_ctx wctx; + + if (!zvni->neigh_table) + return; + + memset (&wctx, 0, sizeof (struct neigh_walk_ctx)); + wctx.zvni = zvni; + wctx.zvrf = zvrf; + wctx.uninstall = uninstall; + wctx.upd_client = upd_client; + wctx.flags = flags; + + hash_iterate (zvni->neigh_table, + (void (*) (struct hash_backet *, void *)) + zvni_neigh_del_hash_entry, &wctx); +} + +/* + * Look up neighbor hash entry. + */ +static zebra_neigh_t * +zvni_neigh_lookup (zebra_vni_t *zvni, struct ipaddr *ip) +{ + zebra_neigh_t tmp; + zebra_neigh_t *n; + + memset (&tmp, 0, sizeof(tmp)); + memcpy (&tmp.ip, ip, sizeof (struct ipaddr)); + n = hash_lookup (zvni->neigh_table, &tmp); + + return n; +} + +/* + * Inform BGP about local neighbor addition. + */ +static int +zvni_neigh_send_add_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ipaddr *ip, struct ethaddr *macaddr) +{ + return zvni_macip_send_msg_to_client (zvrf, vni, macaddr, ip, 0, + ZEBRA_MACIP_ADD); +} + +/* + * Inform BGP about local neighbor deletion. + */ +static int +zvni_neigh_send_del_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ipaddr *ip, struct ethaddr *macaddr) +{ + return zvni_macip_send_msg_to_client (zvrf, vni, macaddr, ip, 0, + ZEBRA_MACIP_DEL); +} + +/* + * Install remote neighbor into the kernel. + */ +static int +zvni_neigh_install (zebra_vni_t *zvni, zebra_neigh_t *n) +{ + struct zebra_vrf *zvrf; + struct zebra_if *zif; + struct zebra_l2info_vxlan *vxl; + struct interface *vlan_if; + + if (!(n->flags & ZEBRA_NEIGH_REMOTE)) + return 0; + + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); + assert(zvrf); + zif = zvni->vxlan_if->info; + if (!zif) + return -1; + vxl = &zif->l2info.vxl; + + vlan_if = zvni_map_to_svi (zvrf, vxl->access_vlan, + zif->brslave_info.br_if); + if (!vlan_if) + return -1; + + return kernel_add_neigh (vlan_if, &n->ip, &n->emac); +} + +/* + * Uninstall remote neighbor from the kernel. + */ +static int +zvni_neigh_uninstall (zebra_vni_t *zvni, zebra_neigh_t *n) +{ + struct zebra_vrf *zvrf; + struct zebra_if *zif; + struct zebra_l2info_vxlan *vxl; + struct interface *vlan_if; + + if (!(n->flags & ZEBRA_NEIGH_REMOTE)) + return 0; + + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); + assert(zvrf); + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p couldn't be uninstalled - no intf", + zvni->vni, zvni); + return -1; + } + + zif = zvni->vxlan_if->info; + if (!zif) + return -1; + vxl = &zif->l2info.vxl; + vlan_if = zvni_map_to_svi (zvrf, vxl->access_vlan, + zif->brslave_info.br_if); + if (!vlan_if) + return -1; + + return kernel_del_neigh (vlan_if, &n->ip); +} + +/* + * Install neighbor hash entry - called upon access VLAN change. + */ +static void +zvni_install_neigh_hash (struct hash_backet *backet, void *ctxt) +{ + zebra_neigh_t *n; + struct neigh_walk_ctx *wctx = ctxt; + + n = (zebra_neigh_t *) backet->data; + if (!n) + return; + + if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) + zvni_neigh_install (wctx->zvni, n); +} + +/* + * Make hash key for MAC. + */ +static unsigned int +mac_hash_keymake (void *p) +{ + zebra_mac_t *pmac = p; + char *pnt = (char *) pmac->macaddr.octet; + unsigned int key = 0; + int c = 0; + + key += pnt[c]; + key += pnt[c + 1]; + key += pnt[c + 2]; + key += pnt[c + 3]; + key += pnt[c + 4]; + key += pnt[c + 5]; + + return (key); +} + +/* + * Compare two MAC addresses. + */ +static int +mac_cmp (const void *p1, const void *p2) +{ + const zebra_mac_t *pmac1 = p1; + const zebra_mac_t *pmac2 = p2; + + if (pmac1 == NULL && pmac2 == NULL) + return 1; + + if (pmac1 == NULL || pmac2 == NULL) + return 0; + + return(memcmp(pmac1->macaddr.octet, pmac2->macaddr.octet, ETHER_ADDR_LEN) == 0); +} + +/* + * Callback to allocate MAC hash entry. + */ +static void * +zvni_mac_alloc (void *p) +{ + const zebra_mac_t *tmp_mac = p; + zebra_mac_t *mac; + + mac = XCALLOC (MTYPE_MAC, sizeof(zebra_mac_t)); + *mac = *tmp_mac; + + return ((void *)mac); +} + +/* + * Add MAC entry. + */ +static zebra_mac_t * +zvni_mac_add (zebra_vni_t *zvni, struct ethaddr *macaddr) +{ + zebra_mac_t tmp_mac; + zebra_mac_t *mac = NULL; + + memset (&tmp_mac, 0, sizeof (zebra_mac_t)); + memcpy(&tmp_mac.macaddr, macaddr, ETHER_ADDR_LEN); + mac = hash_get (zvni->mac_table, &tmp_mac, zvni_mac_alloc); + assert (mac); + + return mac; +} + +/* + * Delete MAC entry. + */ +static int +zvni_mac_del (zebra_vni_t *zvni, zebra_mac_t *mac) +{ + zebra_mac_t *tmp_mac; + + /* Free the VNI hash entry and allocated memory. */ + tmp_mac = hash_release (zvni->mac_table, mac); + if (tmp_mac) + XFREE(MTYPE_MAC, tmp_mac); + + return 0; +} + +/* + * Free MAC hash entry (callback) + */ +static int +zvni_mac_del_hash_entry (struct hash_backet *backet, void *arg) +{ + struct mac_walk_ctx *wctx = arg; + zebra_mac_t *mac = backet->data; + u_char sticky = 0; + + if (((wctx->flags & DEL_LOCAL_MAC) && (mac->flags & ZEBRA_MAC_LOCAL)) || + ((wctx->flags & DEL_REMOTE_MAC) && (mac->flags & ZEBRA_MAC_REMOTE)) || + ((wctx->flags & DEL_REMOTE_MAC_FROM_VTEP) && + (mac->flags & ZEBRA_MAC_REMOTE) && + IPV4_ADDR_SAME(&mac->fwd_info.r_vtep_ip, &wctx->r_vtep_ip) + )) + { + if (wctx->upd_client && (mac->flags & ZEBRA_MAC_LOCAL)) + { + sticky = CHECK_FLAG (mac->flags, ZEBRA_MAC_STICKY) ? 1: 0; + zvni_mac_send_del_to_client (wctx->zvrf, wctx->zvni->vni, + &mac->macaddr, sticky); + } + + if (wctx->uninstall) + zvni_mac_uninstall (wctx->zvni, mac, 0); + + return zvni_mac_del (wctx->zvni, mac); + } + + return 0; +} + +/* + * Delete all MAC entries from specific VTEP for a particular VNI. + */ +static void +zvni_mac_del_from_vtep (zebra_vni_t *zvni, int uninstall, + struct in_addr *r_vtep_ip) +{ + struct mac_walk_ctx wctx; + + if (!zvni->mac_table) + return; + + memset (&wctx, 0, sizeof (struct mac_walk_ctx)); + wctx.zvni = zvni; + wctx.uninstall = uninstall; + wctx.flags = DEL_REMOTE_MAC_FROM_VTEP; + wctx.r_vtep_ip = *r_vtep_ip; + + hash_iterate (zvni->mac_table, + (void (*) (struct hash_backet *, void *)) + zvni_mac_del_hash_entry, &wctx); +} + +/* + * Delete all MAC entries for this VNI. + */ +static void +zvni_mac_del_all (struct zebra_vrf *zvrf, zebra_vni_t *zvni, + int uninstall, int upd_client, u_int32_t flags) +{ + struct mac_walk_ctx wctx; + + if (!zvni->mac_table) + return; + + memset (&wctx, 0, sizeof (struct mac_walk_ctx)); + wctx.zvni = zvni; + wctx.zvrf = zvrf; + wctx.uninstall = uninstall; + wctx.upd_client = upd_client; + wctx.flags = flags; + + hash_iterate (zvni->mac_table, + (void (*) (struct hash_backet *, void *)) + zvni_mac_del_hash_entry, &wctx); +} + +/* + * Look up MAC hash entry. + */ +static zebra_mac_t * +zvni_mac_lookup (zebra_vni_t *zvni, struct ethaddr *mac) +{ + zebra_mac_t tmp; + zebra_mac_t *pmac; + + memset(&tmp, 0, sizeof(tmp)); + memcpy(&tmp.macaddr, mac, ETHER_ADDR_LEN); + pmac = hash_lookup (zvni->mac_table, &tmp); + + return pmac; +} + +/* + * Inform BGP about local MAC addition. + */ +static int +zvni_mac_send_add_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ethaddr *macaddr, u_char sticky) +{ + return zvni_macip_send_msg_to_client (zvrf, vni, macaddr, NULL, + sticky, ZEBRA_MACIP_ADD); +} + +/* + * Inform BGP about local MAC deletion. + */ +static int +zvni_mac_send_del_to_client (struct zebra_vrf *zvrf, vni_t vni, + struct ethaddr *macaddr, u_char sticky) +{ + return zvni_macip_send_msg_to_client (zvrf, vni, macaddr, NULL, + sticky, ZEBRA_MACIP_DEL); +} + +/* + * Map port or (port, VLAN) to a VNI. This is invoked upon getting MAC + * notifications, to see if there are of interest. + * TODO: Need to make this as a hash table. + */ +static zebra_vni_t * +zvni_map_vlan (struct interface *ifp, struct interface *br_if, vlanid_t vid) +{ + struct zebra_vrf *zvrf; + struct listnode *node; + struct interface *tmp_if; + struct zebra_if *zif; + struct zebra_l2info_bridge *br; + struct zebra_l2info_vxlan *vxl; + u_char bridge_vlan_aware; + zebra_vni_t *zvni; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + assert(zvrf); + + /* Determine if bridge is VLAN-aware or not */ + zif = br_if->info; + assert (zif); + br = &zif->l2info.br; + bridge_vlan_aware = br->vlan_aware; + + /* See if this interface (or interface plus VLAN Id) maps to a VxLAN */ + /* TODO: Optimize with a hash. */ + for (ALL_LIST_ELEMENTS_RO (vrf_iflist (zvrf_id (zvrf)), node, tmp_if)) + { + zif = tmp_if->info; + if (!zif || zif->zif_type != ZEBRA_IF_VXLAN) + continue; + if (!if_is_operative (tmp_if)) + continue; + vxl = &zif->l2info.vxl; + + if (zif->brslave_info.br_if != br_if) + continue; + + if (!bridge_vlan_aware) + break; + + if (vxl->access_vlan == vid) + break; + } + + if (!tmp_if) + return NULL; + + zvni = zvni_lookup (zvrf, vxl->vni); + return zvni; +} + +/* + * Map SVI and associated bridge to a VNI. This is invoked upon getting + * neighbor notifications, to see if they are of interest. + * TODO: Need to make this as a hash table. + */ +static zebra_vni_t * +zvni_map_svi (struct interface *ifp, struct interface *br_if) +{ + struct zebra_vrf *zvrf; + struct listnode *node; + struct interface *tmp_if; + struct zebra_if *zif; + struct zebra_l2info_bridge *br; + struct zebra_l2info_vxlan *vxl; + u_char bridge_vlan_aware; + vlanid_t vid = 0; + zebra_vni_t *zvni; + + /* Make sure the linked interface is a bridge. */ + if (!IS_ZEBRA_IF_BRIDGE (br_if)) + return NULL; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + assert(zvrf); + + /* Determine if bridge is VLAN-aware or not */ + zif = br_if->info; + assert (zif); + br = &zif->l2info.br; + bridge_vlan_aware = br->vlan_aware; + if (bridge_vlan_aware) + { + struct zebra_l2info_vlan *vl; + + if (!IS_ZEBRA_IF_VLAN(ifp)) + return NULL; + + zif = ifp->info; + assert (zif); + vl = &zif->l2info.vl; + vid = vl->vid; + } + + /* See if this interface (or interface plus VLAN Id) maps to a VxLAN */ + /* TODO: Optimize with a hash. */ + for (ALL_LIST_ELEMENTS_RO (vrf_iflist (zvrf_id (zvrf)), node, tmp_if)) + { + zif = tmp_if->info; + if (!zif || zif->zif_type != ZEBRA_IF_VXLAN) + continue; + if (!if_is_operative (tmp_if)) + continue; + vxl = &zif->l2info.vxl; + + if (zif->brslave_info.br_if != br_if) + continue; + + if (!bridge_vlan_aware) + break; + + if (vxl->access_vlan == vid) + break; + } + + if (!tmp_if) + return NULL; + + zvni = zvni_lookup (zvrf, vxl->vni); + return zvni; +} + +/* Map to SVI on bridge corresponding to specified VLAN. This can be one + * of two cases: + * (a) In the case of a VLAN-aware bridge, the SVI is a L3 VLAN interface + * linked to the bridge + * (b) In the case of a VLAN-unaware bridge, the SVI is the bridge inteface + * itself + */ +static struct interface * +zvni_map_to_svi (struct zebra_vrf *zvrf, vlanid_t vid, + struct interface *br_if) +{ + struct listnode *node; + struct interface *tmp_if; + struct zebra_if *zif; + struct zebra_l2info_bridge *br; + struct zebra_l2info_vlan *vl; + u_char bridge_vlan_aware; + + /* Determine if bridge is VLAN-aware or not */ + zif = br_if->info; + assert (zif); + br = &zif->l2info.br; + bridge_vlan_aware = br->vlan_aware; + + /* Check oper status of the SVI. */ + if (!bridge_vlan_aware) + return if_is_operative (br_if) ? br_if : NULL; + + /* Identify corresponding VLAN interface. */ + /* TODO: Optimize with a hash. */ + for (ALL_LIST_ELEMENTS_RO (vrf_iflist (zvrf_id (zvrf)), node, tmp_if)) + { + /* Check oper status of the SVI. */ + if (!if_is_operative (tmp_if)) + continue; + zif = tmp_if->info; + if (!zif || + zif->zif_type != ZEBRA_IF_VLAN || + zif->link != br_if) + continue; + vl = (struct zebra_l2info_vlan *)&zif->l2info.vl; + + if (vl->vid == vid) + break; + } + + return tmp_if; +} + +/* + * Install remote MAC into the kernel. + */ +static int +zvni_mac_install (zebra_vni_t *zvni, zebra_mac_t *mac) +{ + struct zebra_if *zif; + struct zebra_l2info_vxlan *vxl; + u_char sticky; + + if (!(mac->flags & ZEBRA_MAC_REMOTE)) + return 0; + + zif = zvni->vxlan_if->info; + if (!zif) + return -1; + vxl = &zif->l2info.vxl; + + sticky = CHECK_FLAG (mac->flags, ZEBRA_MAC_STICKY) ? 1: 0; + + return kernel_add_mac (zvni->vxlan_if, vxl->access_vlan, + &mac->macaddr, mac->fwd_info.r_vtep_ip, sticky); +} + +/* + * Uninstall remote MAC from the kernel. In the scenario where the MAC + * moves to remote, we have to uninstall any existing local entry first. + */ +static int +zvni_mac_uninstall (zebra_vni_t *zvni, zebra_mac_t *mac, int local) +{ + struct zebra_if *zif; + struct zebra_l2info_vxlan *vxl; + struct in_addr vtep_ip = { .s_addr = 0 }; + struct zebra_ns *zns; + struct interface *ifp; + + if (!local && !(mac->flags & ZEBRA_MAC_REMOTE)) + return 0; + + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p couldn't be uninstalled - no intf", + zvni->vni, zvni); + return -1; + } + + zif = zvni->vxlan_if->info; + if (!zif) + return -1; + vxl = &zif->l2info.vxl; + + if (local) + { + zns = zebra_ns_lookup (NS_DEFAULT); + ifp = if_lookup_by_index_per_ns (zns, mac->fwd_info.local.ifindex); + if (!ifp) // unexpected + return -1; + } + else + { + ifp = zvni->vxlan_if; + vtep_ip = mac->fwd_info.r_vtep_ip; + } + + return kernel_del_mac (ifp, vxl->access_vlan, + &mac->macaddr, vtep_ip, local); +} + +/* + * Install MAC hash entry - called upon access VLAN change. + */ +static void +zvni_install_mac_hash (struct hash_backet *backet, void *ctxt) +{ + zebra_mac_t *mac; + struct mac_walk_ctx *wctx = ctxt; + + mac = (zebra_mac_t *) backet->data; + if (!mac) + return; + + if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)) + zvni_mac_install (wctx->zvni, mac); +} + +/* + * Decrement neighbor refcount of MAC; uninstall and free it if + * appropriate. + */ +static void +zvni_deref_ip2mac (zebra_vni_t *zvni, zebra_mac_t *mac, int uninstall) +{ + if (mac->neigh_refcnt) + mac->neigh_refcnt--; + + if (!CHECK_FLAG (mac->flags, ZEBRA_MAC_AUTO) || + mac->neigh_refcnt > 0) + return; + + if (uninstall) + zvni_mac_uninstall (zvni, mac, 0); + + zvni_mac_del (zvni, mac); +} + +/* + * Read and populate local MACs and neighbors corresponding to this VNI. + */ +static void +zvni_read_mac_neigh (struct zebra_vrf *zvrf, zebra_vni_t *zvni, + struct interface *ifp) +{ + struct zebra_if *zif; + struct interface *vlan_if; + struct zebra_l2info_vxlan *vxl; + + zif = ifp->info; + vxl = &zif->l2info.vxl; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Reading MAC FDB and Neighbors for intf %s(%u) VNI %u master %u", + ifp->vrf_id, ifp->name, ifp->ifindex, zvni->vni, + zif->brslave_info.bridge_ifindex); + + macfdb_read_for_bridge (zvrf->zns, ifp, zif->brslave_info.br_if); + vlan_if = zvni_map_to_svi (zvrf, vxl->access_vlan, + zif->brslave_info.br_if); + if (vlan_if) + neigh_read_for_vlan (zvrf->zns, vlan_if); +} + +/* + * Hash function for VNI. + */ +static unsigned int +vni_hash_keymake (void *p) +{ + const zebra_vni_t *zvni = p; + + return (jhash_1word(zvni->vni, 0)); +} + +/* + * Compare 2 VNI hash entries. + */ +static int +vni_hash_cmp (const void *p1, const void *p2) +{ + const zebra_vni_t *zvni1 = p1; + const zebra_vni_t *zvni2 = p2; + + return (zvni1->vni == zvni2->vni); +} + +/* + * Callback to allocate VNI hash entry. + */ +static void * +zvni_alloc (void *p) +{ + const zebra_vni_t *tmp_vni = p; + zebra_vni_t *zvni; + + zvni = XCALLOC (MTYPE_ZVNI, sizeof(zebra_vni_t)); + zvni->vni = tmp_vni->vni; + return ((void *)zvni); +} + +/* + * Look up VNI hash entry. + */ +static zebra_vni_t * +zvni_lookup (struct zebra_vrf *zvrf, vni_t vni) +{ + zebra_vni_t tmp_vni; + zebra_vni_t *zvni = NULL; + + memset (&tmp_vni, 0, sizeof (zebra_vni_t)); + tmp_vni.vni = vni; + zvni = hash_lookup (zvrf->vni_table, &tmp_vni); + + return zvni; +} + +/* + * Add VNI hash entry. + */ +static zebra_vni_t * +zvni_add (struct zebra_vrf *zvrf, vni_t vni) +{ + zebra_vni_t tmp_zvni; + zebra_vni_t *zvni = NULL; + + memset (&tmp_zvni, 0, sizeof (zebra_vni_t)); + tmp_zvni.vni = vni; + zvni = hash_get (zvrf->vni_table, &tmp_zvni, zvni_alloc); + assert (zvni); + + /* Create hash table for MAC */ + zvni->mac_table = hash_create(mac_hash_keymake, + mac_cmp, + "Zebra VNI MAC Table"); + + /* Create hash table for neighbors */ + zvni->neigh_table = hash_create(neigh_hash_keymake, + neigh_cmp, + "Zebra VNI Neighbor Table"); + + return zvni; +} + +/* + * Delete VNI hash entry. + */ +static int +zvni_del (struct zebra_vrf *zvrf, zebra_vni_t *zvni) +{ + zebra_vni_t *tmp_zvni; + + zvni->vxlan_if = NULL; + + /* Free the neighbor hash table. */ + hash_free(zvni->neigh_table); + zvni->neigh_table = NULL; + + /* Free the MAC hash table. */ + hash_free(zvni->mac_table); + zvni->mac_table = NULL; + + /* Free the VNI hash entry and allocated memory. */ + tmp_zvni = hash_release (zvrf->vni_table, zvni); + if (tmp_zvni) + XFREE(MTYPE_ZVNI, tmp_zvni); + + return 0; +} + +/* + * Inform BGP about local VNI addition. + */ +static int +zvni_send_add_to_client (struct zebra_vrf *zvrf, + zebra_vni_t *zvni) +{ + struct zserv *client; + struct stream *s; + + client = zebra_find_client (ZEBRA_ROUTE_BGP); + /* BGP may not be running. */ + if (!client) + return 0; + + s = client->obuf; + stream_reset (s); + + zserv_create_header (s, ZEBRA_VNI_ADD, zvrf_id (zvrf)); + stream_putl (s, zvni->vni); + stream_put_in_addr (s, &zvni->local_vtep_ip); + + /* Write packet size. */ + stream_putw_at (s, 0, stream_get_endp (s)); + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Send VNI_ADD %u %s to %s", + zvrf_id (zvrf), zvni->vni, + inet_ntoa(zvni->local_vtep_ip), + zebra_route_string (client->proto)); + + client->vniadd_cnt++; + return zebra_server_send_message(client); +} + +/* + * Inform BGP about local VNI deletion. + */ +static int +zvni_send_del_to_client (struct zebra_vrf *zvrf, vni_t vni) +{ + struct zserv *client; + struct stream *s; + + client = zebra_find_client (ZEBRA_ROUTE_BGP); + /* BGP may not be running. */ + if (!client) + return 0; + + s = client->obuf; + stream_reset (s); + + zserv_create_header (s, ZEBRA_VNI_DEL, zvrf_id (zvrf)); + stream_putl (s, vni); + + /* Write packet size. */ + stream_putw_at (s, 0, stream_get_endp (s)); + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Send VNI_DEL %u to %s", zvrf_id (zvrf), vni, + zebra_route_string (client->proto)); + + client->vnidel_cnt++; + return zebra_server_send_message(client); +} + +/* + * Build the VNI hash table by going over the VxLAN interfaces. This + * is called when EVPN (advertise-all-vni) is enabled. + */ +static void +zvni_build_hash_table (struct zebra_vrf *zvrf) +{ + struct listnode *node; + struct interface *ifp; + + /* Walk VxLAN interfaces and create VNI hash. */ + for (ALL_LIST_ELEMENTS_RO (vrf_iflist (zvrf_id (zvrf)), node, ifp)) + { + struct zebra_if *zif; + struct zebra_l2info_vxlan *vxl; + zebra_vni_t *zvni; + vni_t vni; + + zif = ifp->info; + if (!zif || zif->zif_type != ZEBRA_IF_VXLAN) + continue; + vxl = &zif->l2info.vxl; + + vni = vxl->vni; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Create VNI hash for intf %s(%u) VNI %u local IP %s", + zvrf_id (zvrf), ifp->name, ifp->ifindex, vni, + inet_ntoa (vxl->vtep_ip)); + + /* VNI hash entry is not expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (zvni) + { + zlog_err ("VNI hash already present for VRF %d IF %s(%u) VNI %u", + zvrf_id (zvrf), ifp->name, ifp->ifindex, vni); + continue; + } + + zvni = zvni_add (zvrf, vni); + if (!zvni) + { + zlog_err ("Failed to add VNI hash, VRF %d IF %s(%u) VNI %u", + zvrf_id (zvrf), ifp->name, ifp->ifindex, vni); + return; + } + + zvni->local_vtep_ip = vxl->vtep_ip; + zvni->vxlan_if = ifp; + + /* Inform BGP if interface is up and mapped to bridge. */ + if (if_is_operative (ifp) && + zif->brslave_info.br_if) + zvni_send_add_to_client (zvrf, zvni); + } +} + +/* + * See if remote VTEP matches with prefix. + */ +static int +zvni_vtep_match (struct in_addr *vtep_ip, zebra_vtep_t *zvtep) +{ + return (IPV4_ADDR_SAME (vtep_ip, &zvtep->vtep_ip)); +} + +/* + * Locate remote VTEP in VNI hash table. + */ +static zebra_vtep_t * +zvni_vtep_find (zebra_vni_t *zvni, struct in_addr *vtep_ip) +{ + zebra_vtep_t *zvtep; + + if (!zvni) + return NULL; + + for (zvtep = zvni->vteps; zvtep; zvtep = zvtep->next) + { + if (zvni_vtep_match (vtep_ip, zvtep)) + break; + } + + return zvtep; +} + +/* + * Add remote VTEP to VNI hash table. + */ +static zebra_vtep_t * +zvni_vtep_add (zebra_vni_t *zvni, struct in_addr *vtep_ip) +{ + zebra_vtep_t *zvtep; + + zvtep = XCALLOC (MTYPE_ZVNI_VTEP, sizeof(zebra_vtep_t)); + if (!zvtep) + { + zlog_err ("Failed to alloc VTEP entry, VNI %u", zvni->vni); + return NULL; + } + + zvtep->vtep_ip = *vtep_ip; + + if (zvni->vteps) + zvni->vteps->prev = zvtep; + zvtep->next = zvni->vteps; + zvni->vteps = zvtep; + + return zvtep; +} + +/* + * Remove remote VTEP from VNI hash table. + */ +static int +zvni_vtep_del (zebra_vni_t *zvni, zebra_vtep_t *zvtep) +{ + if (zvtep->next) + zvtep->next->prev = zvtep->prev; + if (zvtep->prev) + zvtep->prev->next = zvtep->next; + else + zvni->vteps = zvtep->next; + + zvtep->prev = zvtep->next = NULL; + XFREE (MTYPE_ZVNI_VTEP, zvtep); + + return 0; +} + +/* + * Delete all remote VTEPs for this VNI (upon VNI delete). Also + * uninstall from kernel if asked to. + */ +static int +zvni_vtep_del_all (zebra_vni_t *zvni, int uninstall) +{ + zebra_vtep_t *zvtep, *zvtep_next; + + if (!zvni) + return -1; + + for (zvtep = zvni->vteps; zvtep; zvtep = zvtep_next) + { + zvtep_next = zvtep->next; + if (uninstall) + zvni_vtep_uninstall (zvni, &zvtep->vtep_ip); + zvni_vtep_del (zvni, zvtep); + } + + return 0; +} + +/* + * Install remote VTEP into the kernel. + */ +static int +zvni_vtep_install (zebra_vni_t *zvni, struct in_addr *vtep_ip) +{ + return kernel_add_vtep (zvni->vni, zvni->vxlan_if, vtep_ip); +} + +/* + * Uninstall remote VTEP from the kernel. + */ +static int +zvni_vtep_uninstall (zebra_vni_t *zvni, struct in_addr *vtep_ip) +{ + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p couldn't be uninstalled - no intf", + zvni->vni, zvni); + return -1; + } + + return kernel_del_vtep (zvni->vni, zvni->vxlan_if, vtep_ip); +} + +/* + * Cleanup VNI/VTEP and update kernel + */ +static void +zvni_cleanup_all (struct hash_backet *backet, void *zvrf) +{ + zebra_vni_t *zvni; + + zvni = (zebra_vni_t *) backet->data; + if (!zvni) + return; + + /* Free up all neighbors and MACs, if any. */ + zvni_neigh_del_all (zvrf, zvni, 1, 0, DEL_ALL_NEIGH); + zvni_mac_del_all (zvrf, zvni, 1, 0, DEL_ALL_MAC); + + /* Free up all remote VTEPs, if any. */ + zvni_vtep_del_all (zvni, 1); + + /* Delete the hash entry. */ + zvni_del (zvrf, zvni); +} + + +/* Public functions */ + +/* + * Display Neighbors for a VNI (VTY command handler). + */ +void +zebra_vxlan_print_neigh_vni (struct vty *vty, struct zebra_vrf *zvrf, vni_t vni) +{ + zebra_vni_t *zvni; + u_int32_t num_neigh; + struct neigh_walk_ctx wctx; + + if (!EVPN_ENABLED(zvrf)) + return; + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + vty_out (vty, "%% VNI %u does not exist\n", vni); + return; + } + num_neigh = hashcount(zvni->neigh_table); + if (!num_neigh) + return; + + /* Since we have IPv6 addresses to deal with which can vary widely in + * size, we try to be a bit more elegant in display by first computing + * the maximum width. + */ + memset (&wctx, 0, sizeof (struct neigh_walk_ctx)); + wctx.zvni = zvni; + wctx.vty = vty; + wctx.addr_width = 15; + hash_iterate(zvni->neigh_table, zvni_find_neigh_addr_width, &wctx); + + vty_out(vty, "Number of ARPs (local and remote) known for this VNI: %u\n", + num_neigh); + vty_out(vty, "%*s %-6s %-17s %-21s\n", + -wctx.addr_width, "IP", "Type", "MAC", + "Remote VTEP"); + + hash_iterate(zvni->neigh_table, zvni_print_neigh_hash, &wctx); +} + +/* + * Display neighbors across all VNIs (VTY command handler). + */ +void +zebra_vxlan_print_neigh_all_vni (struct vty *vty, struct zebra_vrf *zvrf) +{ + if (!EVPN_ENABLED(zvrf)) + return; + hash_iterate(zvrf->vni_table, zvni_print_neigh_hash_all_vni, vty); +} + +/* + * Display specific neighbor for a VNI, if present (VTY command handler). + */ +void +zebra_vxlan_print_specific_neigh_vni (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni, struct ipaddr *ip) +{ + zebra_vni_t *zvni; + zebra_neigh_t *n; + + if (!EVPN_ENABLED(zvrf)) + return; + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + vty_out (vty, "%% VNI %u does not exist", vni); + return; + } + n = zvni_neigh_lookup (zvni, ip); + if (!n) + { + vty_out (vty, "%% Requested neighbor does not exist in VNI %u\n", + vni); + return; + } + + zvni_print_neigh (n, vty); +} + +/* + * Display neighbors for a VNI from specific VTEP (VTY command handler). + * By definition, these are remote neighbors. + */ +void +zebra_vxlan_print_neigh_vni_vtep (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni, struct in_addr vtep_ip) +{ + zebra_vni_t *zvni; + u_int32_t num_neigh; + struct neigh_walk_ctx wctx; + + if (!EVPN_ENABLED(zvrf)) + return; + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + vty_out (vty, "%% VNI %u does not exist\n", vni); + return; + } + num_neigh = hashcount(zvni->neigh_table); + if (!num_neigh) + return; + + memset (&wctx, 0, sizeof (struct neigh_walk_ctx)); + wctx.zvni = zvni; + wctx.vty = vty; + wctx.flags = SHOW_REMOTE_NEIGH_FROM_VTEP; + wctx.r_vtep_ip = vtep_ip; + + hash_iterate(zvni->neigh_table, zvni_print_neigh_hash, &wctx); +} + +/* + * Display MACs for a VNI (VTY command handler). + */ +void +zebra_vxlan_print_macs_vni (struct vty *vty, struct zebra_vrf *zvrf, vni_t vni) +{ + zebra_vni_t *zvni; + u_int32_t num_macs; + struct mac_walk_ctx wctx; + + if (!EVPN_ENABLED(zvrf)) + return; + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + vty_out (vty, "%% VNI %u does not exist\n", vni); + return; + } + num_macs = hashcount(zvni->mac_table); + if (!num_macs) + return; + + memset (&wctx, 0, sizeof (struct mac_walk_ctx)); + wctx.zvni = zvni; + wctx.vty = vty; + + vty_out(vty, "Number of MACs (local and remote) known for this VNI: %u\n", + num_macs); + vty_out(vty, "%-17s %-6s %-21s %-5s\n", + "MAC", "Type", "Intf/Remote VTEP", "VLAN"); + + hash_iterate(zvni->mac_table, zvni_print_mac_hash, &wctx); +} + +/* + * Display MACs for all VNIs (VTY command handler). + */ +void +zebra_vxlan_print_macs_all_vni (struct vty *vty, struct zebra_vrf *zvrf) +{ + struct mac_walk_ctx wctx; + + if (!EVPN_ENABLED(zvrf)) + return; + memset (&wctx, 0, sizeof (struct mac_walk_ctx)); + wctx.vty = vty; + hash_iterate(zvrf->vni_table, zvni_print_mac_hash_all_vni, &wctx); +} + +/* + * Display MACs for all VNIs (VTY command handler). + */ +void +zebra_vxlan_print_macs_all_vni_vtep (struct vty *vty, struct zebra_vrf *zvrf, + struct in_addr vtep_ip) +{ + struct mac_walk_ctx wctx; + + if (!EVPN_ENABLED(zvrf)) + return; + memset (&wctx, 0, sizeof (struct mac_walk_ctx)); + wctx.vty = vty; + wctx.flags = SHOW_REMOTE_MAC_FROM_VTEP; + wctx.r_vtep_ip = vtep_ip; + hash_iterate(zvrf->vni_table, zvni_print_mac_hash_all_vni, &wctx); +} + +/* + * Display specific MAC for a VNI, if present (VTY command handler). + */ +void +zebra_vxlan_print_specific_mac_vni (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni, struct ethaddr *macaddr) +{ + zebra_vni_t *zvni; + zebra_mac_t *mac; + + if (!EVPN_ENABLED(zvrf)) + return; + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + vty_out (vty, "%% VNI %u does not exist\n", vni); + return; + } + mac = zvni_mac_lookup (zvni, macaddr); + if (!mac) + { + vty_out (vty, "%% Requested MAC does not exist in VNI %u\n", + vni); + return; + } + + zvni_print_mac (mac, vty); +} + +/* + * Display MACs for a VNI from specific VTEP (VTY command handler). + */ +void +zebra_vxlan_print_macs_vni_vtep (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni, struct in_addr vtep_ip) +{ + zebra_vni_t *zvni; + u_int32_t num_macs; + struct mac_walk_ctx wctx; + + if (!EVPN_ENABLED(zvrf)) + return; + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + vty_out (vty, "%% VNI %u does not exist\n", vni); + return; + } + num_macs = hashcount(zvni->mac_table); + if (!num_macs) + return; + memset (&wctx, 0, sizeof (struct mac_walk_ctx)); + wctx.zvni = zvni; + wctx.vty = vty; + wctx.flags = SHOW_REMOTE_MAC_FROM_VTEP; + wctx.r_vtep_ip = vtep_ip; + hash_iterate(zvni->mac_table, zvni_print_mac_hash, &wctx); +} + + +/* + * Display VNI information (VTY command handler). + */ +void +zebra_vxlan_print_vni (struct vty *vty, struct zebra_vrf *zvrf, vni_t vni) +{ + zebra_vni_t *zvni; + + if (!EVPN_ENABLED(zvrf)) + return; + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + vty_out (vty, "%% VNI %u does not exist\n", vni); + return; + } + zvni_print (zvni, (void *)vty); +} + +/* + * Display VNI hash table (VTY command handler). + */ +void +zebra_vxlan_print_vnis (struct vty *vty, struct zebra_vrf *zvrf) +{ + u_int32_t num_vnis; + + if (!EVPN_ENABLED(zvrf)) + return; + num_vnis = hashcount(zvrf->vni_table); + if (!num_vnis) + return; + vty_out(vty, "Number of VNIs: %u\n", num_vnis); + vty_out(vty, "%-10s %-21s %-15s %-8s %-8s %-15s\n", + "VNI", "VxLAN IF", "VTEP IP", "# MACs", "# ARPs", + "# Remote VTEPs"); + hash_iterate(zvrf->vni_table, zvni_print_hash, vty); +} + +/* + * Handle neighbor delete (on a VLAN device / L3 interface) from the + * kernel. This may result in either the neighbor getting deleted from + * our database or being re-added to the kernel (if it is a valid + * remote neighbor). + */ +int +zebra_vxlan_local_neigh_del (struct interface *ifp, + struct interface *link_if, + struct ipaddr *ip) +{ + zebra_vni_t *zvni; + zebra_neigh_t *n; + struct zebra_vrf *zvrf; + char buf[INET6_ADDRSTRLEN]; + + /* We are only interested in neighbors on an SVI that resides on top + * of a VxLAN bridge. + */ + zvni = zvni_map_svi (ifp, link_if); + if (!zvni) + return 0; + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p doesn't have intf upon local neighbor DEL", + zvni->vni, zvni); + return -1; + } + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Del neighbor %s intf %s(%u) -> VNI %u", + ifp->vrf_id, ipaddr2str (ip, buf, sizeof(buf)), + ifp->name, ifp->ifindex, zvni->vni); + + /* If entry doesn't exist, nothing to do. */ + n = zvni_neigh_lookup (zvni, ip); + if (!n) + return 0; + + /* If it is a remote entry, the kernel has aged this out or someone has + * deleted it, it needs to be re-installed as Quagga is the owner. + */ + if (CHECK_FLAG (n->flags, ZEBRA_NEIGH_REMOTE)) + { + zvni_neigh_install (zvni, n); + return 0; + } + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); + assert(zvrf); + + /* Remove neighbor from BGP. */ + zvni_neigh_send_del_to_client (zvrf, zvni->vni, &n->ip, &n->emac); + + /* Delete this neighbor entry. */ + zvni_neigh_del (zvni, n); + + return 0; +} + +/* + * Handle neighbor add or update (on a VLAN device / L3 interface) + * from the kernel. + */ +int +zebra_vxlan_local_neigh_add_update (struct interface *ifp, + struct interface *link_if, + struct ipaddr *ip, + struct ethaddr *macaddr, + u_int16_t state, + u_char ext_learned) +{ + zebra_vni_t *zvni; + zebra_neigh_t *n; + struct zebra_vrf *zvrf; + char buf[ETHER_ADDR_STRLEN]; + char buf2[INET6_ADDRSTRLEN]; + int send_upd = 1, send_del = 0; + + /* We are only interested in neighbors on an SVI that resides on top + * of a VxLAN bridge. + */ + zvni = zvni_map_svi (ifp, link_if); + if (!zvni) + return 0; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); + assert(zvrf); + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Add/Update neighbor %s MAC %s intf %s(%u) state 0x%x " + "%s-> VNI %u", + ifp->vrf_id, ipaddr2str (ip, buf2, sizeof(buf2)), + prefix_mac2str (macaddr, buf, sizeof (buf)), + ifp->name, ifp->ifindex, state, + ext_learned ? "ext-learned " : "", zvni->vni); + + /* If same entry already exists, it might be a change or it might be a + * move from remote to local. + */ + n = zvni_neigh_lookup (zvni, ip); + if (n) + { + if (CHECK_FLAG (n->flags, ZEBRA_NEIGH_LOCAL)) + { + if (memcmp (n->emac.octet, macaddr->octet, ETHER_ADDR_LEN) == 0) + { + if (n->ifindex == ifp->ifindex) + /* we're not interested in whatever has changed. */ + return 0; + /* client doesn't care about a purely local change. */ + send_upd = 0; + } + else + /* If the MAC has changed, issue a delete first as this means a + * different MACIP route. + */ + send_del = 1; + } + else if (ext_learned) + /* The neighbor is remote and that is the notification we got. */ + { + /* TODO: Evaluate if we need to do anything here. */ + return 0; + } + else + /* Neighbor has moved from remote to local. */ + { + UNSET_FLAG (n->flags, ZEBRA_NEIGH_REMOTE); + n->r_vtep_ip.s_addr = 0; + } + } + else + { + n = zvni_neigh_add (zvni, ip); + if (!n) + { + zlog_err ("%u:Failed to add neighbor %s MAC %s intf %s(%u) -> VNI %u", + ifp->vrf_id, ipaddr2str (ip, buf2, sizeof(buf2)), + prefix_mac2str (macaddr, buf, sizeof (buf)), + ifp->name, ifp->ifindex, zvni->vni); + return -1; + } + } + + /* Issue delete for older info, if needed. */ + if (send_del) + zvni_neigh_send_del_to_client (zvrf, zvni->vni, &n->ip, &n->emac); + + /* Set "local" forwarding info. */ + SET_FLAG (n->flags, ZEBRA_NEIGH_LOCAL); + memcpy (&n->emac, macaddr, ETHER_ADDR_LEN); + n->ifindex = ifp->ifindex; + + /* Inform BGP if required. */ + if (send_upd) + return zvni_neigh_send_add_to_client (zvrf, zvni->vni, ip, macaddr); + + return 0; +} + +/* + * Handle message from client to delete a remote MACIP for a VNI. + */ +int zebra_vxlan_remote_macip_del (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + struct stream *s; + vni_t vni; + struct ethaddr macaddr; + struct ipaddr ip; + struct in_addr vtep_ip; + zebra_vni_t *zvni; + zebra_mac_t *mac; + zebra_neigh_t *n; + u_short l = 0, ipa_len; + char buf[ETHER_ADDR_STRLEN]; + char buf1[INET6_ADDRSTRLEN]; + + s = client->ibuf; + + while (l < length) + { + /* Obtain each remote MACIP and process. */ + /* Message contains VNI, followed by MAC followed by IP (if any) + * followed by remote VTEP IP. + */ + mac = NULL; + n = NULL; + memset (&ip, 0, sizeof (ip)); + vni = (vni_t) stream_getl (s); + stream_get (&macaddr.octet, s, ETHER_ADDR_LEN); + ipa_len = stream_getl (s); + if (ipa_len) + { + ip.ipa_type = (ipa_len == IPV4_MAX_BYTELEN) ? IPADDR_V4: IPADDR_V6; + stream_get (&ip.ip.addr, s, ipa_len); + } + l += 4 + ETHER_ADDR_LEN + 4 + ipa_len; + vtep_ip.s_addr = stream_get_ipv4(s); + l += IPV4_MAX_BYTELEN; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Recv MACIP Del MAC %s IP %s VNI %u Remote VTEP %s from %s", + zvrf_id (zvrf), + prefix_mac2str (&macaddr, buf, sizeof (buf)), + ipaddr2str (&ip, buf1, sizeof (buf1)), + vni, inet_ntoa (vtep_ip), + zebra_route_string (client->proto)); + + /* Locate VNI hash entry - expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("Failed to locate VNI hash upon remote MACIP DEL, " + "VRF %d VNI %u", zvrf_id (zvrf), vni); + continue; + } + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p doesn't have intf upon remote MACIP DEL", + vni, zvni); + continue; + } + + /* The remote VTEP specified is normally expected to exist, but it is + * possible that the peer may delete the VTEP before deleting any MACs + * referring to the VTEP, in which case the handler (see remote_vtep_del) + * would have already deleted the MACs. + */ + if (!zvni_vtep_find (zvni, &vtep_ip)) + continue; + + /* If the local VxLAN interface is not up (should be a transient + * event), there's nothing more to do. + */ + if (!if_is_operative (zvni->vxlan_if)) + continue; + + mac = zvni_mac_lookup (zvni, &macaddr); + if (ipa_len) + n = zvni_neigh_lookup (zvni, &ip); + + if (n && !mac) + { + zlog_err ("failed to locate MAC %s for neigh %s in VRF %u VNI %u", + prefix_mac2str (&macaddr, buf, sizeof (buf)), + ipaddr2str (&ip, buf1, sizeof (buf1)), + zvrf_id (zvrf), vni); + continue; + } + + /* If the remote mac or neighbor doesn't exist there is nothing more + * to do. Otherwise, uninstall the entry and then remove it. + */ + if (!mac && !n) + continue; + + /* Uninstall remote neighbor or MAC. */ + if (n) + { + /* When the MAC changes for an IP, it is possible the client may + * update the new MAC before trying to delete the "old" neighbor + * (as these are two different MACIP routes). Do the delete only + * if the MAC matches. + */ + if (CHECK_FLAG (n->flags, ZEBRA_NEIGH_REMOTE) && + (memcmp (n->emac.octet, macaddr.octet, ETHER_ADDR_LEN) == 0)) + { + zvni_neigh_uninstall (zvni, n); + zvni_neigh_del (zvni, n); + zvni_deref_ip2mac (zvni, mac, 1); + } + } + else + { + if (CHECK_FLAG (mac->flags, ZEBRA_MAC_REMOTE)) + { + if (!mac->neigh_refcnt) + { + zvni_mac_uninstall (zvni, mac, 0); + zvni_mac_del (zvni, mac); + } + else + SET_FLAG (mac->flags, ZEBRA_MAC_AUTO); + } + } + } + + return 0; +} + +/* + * Handle message from client to add a remote MACIP for a VNI. This + * could be just the add of a MAC address or the add of a neighbor + * (IP+MAC). + */ +int +zebra_vxlan_remote_macip_add (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + struct stream *s; + vni_t vni; + struct ethaddr macaddr; + struct ipaddr ip; + struct in_addr vtep_ip; + zebra_vni_t *zvni; + zebra_vtep_t *zvtep; + zebra_mac_t *mac, *old_mac; + zebra_neigh_t *n; + u_short l = 0, ipa_len; + int update_mac = 0, update_neigh = 0; + char buf[ETHER_ADDR_STRLEN]; + char buf1[INET6_ADDRSTRLEN]; + u_char sticky; + + assert (EVPN_ENABLED (zvrf)); + + s = client->ibuf; + + while (l < length) + { + /* Obtain each remote MACIP and process. */ + /* Message contains VNI, followed by MAC followed by IP (if any) + * followed by remote VTEP IP. + */ + update_mac = update_neigh = 0; + mac = NULL; + n = NULL; + memset (&ip, 0, sizeof (ip)); + vni = (vni_t) stream_getl (s); + stream_get (&macaddr.octet, s, ETHER_ADDR_LEN); + ipa_len = stream_getl (s); + if (ipa_len) + { + ip.ipa_type = (ipa_len == IPV4_MAX_BYTELEN) ? IPADDR_V4: IPADDR_V6; + stream_get (&ip.ip.addr, s, ipa_len); + } + l += 4 + ETHER_ADDR_LEN + 4 + ipa_len; + vtep_ip.s_addr = stream_get_ipv4 (s); + l += IPV4_MAX_BYTELEN; + + /* Get 'sticky' flag. */ + sticky = stream_getc(s); + l++; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Recv MACIP Add %sMAC %s IP %s VNI %u Remote VTEP %s from %s", + zvrf_id (zvrf), + sticky ? "sticky " : "", + prefix_mac2str (&macaddr, buf, sizeof (buf)), + ipaddr2str (&ip, buf1, sizeof (buf1)), + vni, inet_ntoa (vtep_ip), + zebra_route_string (client->proto)); + + /* Locate VNI hash entry - expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + zlog_err ("Failed to locate VNI hash upon remote MACIP ADD, VRF %d VNI %u", + zvrf_id (zvrf), vni); + continue; + } + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p doesn't have intf upon remote MACIP add", + vni, zvni); + continue; + } + /* If the local VxLAN interface is not up (should be a transient + * event), there's nothing more to do. + */ + if (!if_is_operative (zvni->vxlan_if)) + continue; + + /* The remote VTEP specified should normally exist, but it is possible + * that when peering comes up, peer may advertise MACIP routes before + * advertising type-3 routes. + */ + zvtep = zvni_vtep_find (zvni, &vtep_ip); + if (!zvtep) + { + if (zvni_vtep_add (zvni, &vtep_ip) == NULL) + { + zlog_err ("Failed to add remote VTEP, VRF %d VNI %u zvni %p", + zvrf_id (zvrf), vni, zvni); + continue; + } + + zvni_vtep_install (zvni, &vtep_ip); + } + + /* First, check if the remote MAC is unknown or has a change. If so, + * that needs to be updated first. Note that client could install + * MAC and MACIP separately or just install the latter. + */ + mac = zvni_mac_lookup (zvni, &macaddr); + if (!mac || !CHECK_FLAG (mac->flags, ZEBRA_MAC_REMOTE) || + (CHECK_FLAG (mac->flags, ZEBRA_MAC_STICKY) ? 1: 0) != sticky || + !IPV4_ADDR_SAME(&mac->fwd_info.r_vtep_ip, &vtep_ip)) + update_mac = 1; + + if (update_mac) + { + if (!mac) + { + mac = zvni_mac_add (zvni, &macaddr); + if (!mac) + { + zlog_warn ("%u:Failed to add MAC %s VNI %u Remote VTEP %s", + zvrf_id (zvrf), + prefix_mac2str (&macaddr, buf, sizeof (buf)), + vni, inet_ntoa (vtep_ip)); + return -1; + } + + /* Is this MAC created for a MACIP? */ + if (ipa_len) + SET_FLAG (mac->flags, ZEBRA_MAC_AUTO); + } + else if (CHECK_FLAG (mac->flags, ZEBRA_MAC_LOCAL)) + { + /* Moving from local to remote, issue delete. */ + zvni_mac_uninstall (zvni, mac, 1); + } + + /* Set "auto" and "remote" forwarding info. */ + UNSET_FLAG (mac->flags, ZEBRA_MAC_LOCAL); + memset (&mac->fwd_info, 0, sizeof (mac->fwd_info)); + SET_FLAG (mac->flags, ZEBRA_MAC_REMOTE); + mac->fwd_info.r_vtep_ip = vtep_ip; + + if (sticky) + SET_FLAG (mac->flags, ZEBRA_MAC_STICKY); + else + UNSET_FLAG (mac->flags, ZEBRA_MAC_STICKY); + + /* Install the entry. */ + zvni_mac_install (zvni, mac); + } + + /* If there is no IP, continue - after clearing AUTO flag of MAC. */ + if (!ipa_len) + { + UNSET_FLAG (mac->flags, ZEBRA_MAC_AUTO); + continue; + } + + /* Check if the remote neighbor itself is unknown or has a change. + * If so, create or update and then install the entry. + */ + n = zvni_neigh_lookup (zvni, &ip); + if (!n || !CHECK_FLAG (n->flags, ZEBRA_NEIGH_REMOTE) || + (memcmp(&n->emac, &macaddr, sizeof (macaddr)) != 0) || + !IPV4_ADDR_SAME(&n->r_vtep_ip, &vtep_ip)) + update_neigh = 1; + + if (update_neigh) + { + if (!n) + { + n = zvni_neigh_add (zvni, &ip); + if (!n) + { + zlog_warn ("%u:Failed to add Neigh %s MAC %s VNI %u Remote VTEP %s", + zvrf_id (zvrf), ipaddr2str (&ip, buf1, sizeof (buf1)), + prefix_mac2str (&macaddr, buf, sizeof (buf)), + vni, inet_ntoa (vtep_ip)); + return -1; + } + + /* New neighbor referring to this MAC. */ + mac->neigh_refcnt++; + } + else if (memcmp(&n->emac, &macaddr, sizeof (macaddr)) != 0) + { + /* MAC change, update ref counts for old and new MAC. */ + old_mac = zvni_mac_lookup (zvni, &n->emac); + if (old_mac) + zvni_deref_ip2mac (zvni, old_mac, 1); + mac->neigh_refcnt++; + } + + /* Set "remote" forwarding info. */ + UNSET_FLAG (n->flags, ZEBRA_NEIGH_LOCAL); + /* TODO: Handle MAC change. */ + memcpy (&n->emac, &macaddr, ETHER_ADDR_LEN); + n->r_vtep_ip = vtep_ip; + SET_FLAG (n->flags, ZEBRA_NEIGH_REMOTE); + + /* Install the entry. */ + zvni_neigh_install (zvni, n); + } + } + + return 0; +} + +/* + * Handle notification of MAC add/update over VxLAN. If the kernel is notifying + * us, this must involve a multihoming scenario. Treat this as implicit delete + * of any prior local MAC. + */ +int +zebra_vxlan_check_del_local_mac (struct interface *ifp, + struct interface *br_if, + struct ethaddr *macaddr, + vlanid_t vid) +{ + struct zebra_if *zif; + struct zebra_vrf *zvrf; + struct zebra_l2info_vxlan *vxl; + vni_t vni; + zebra_vni_t *zvni; + zebra_mac_t *mac; + char buf[ETHER_ADDR_STRLEN]; + u_char sticky; + + zif = ifp->info; + assert(zif); + vxl = &zif->l2info.vxl; + vni = vxl->vni; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + assert(zvrf); + + /* If EVPN is not enabled, nothing to do. */ + if (!EVPN_ENABLED(zvrf)) + return 0; + + /* Locate hash entry; it is expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + return 0; + + /* If entry doesn't exist, nothing to do. */ + mac = zvni_mac_lookup (zvni, macaddr); + if (!mac) + return 0; + + /* Is it a local entry? */ + if (!CHECK_FLAG (mac->flags, ZEBRA_MAC_LOCAL)) + return 0; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Add/update remote MAC %s intf %s(%u) VNI %u - del local", + ifp->vrf_id, prefix_mac2str (macaddr, buf, sizeof (buf)), + ifp->name, ifp->ifindex, vni); + + /* Remove MAC from BGP. */ + sticky = CHECK_FLAG (mac->flags, ZEBRA_MAC_STICKY) ? 1: 0; + zvni_mac_send_del_to_client (zvrf, zvni->vni, macaddr, sticky); + + /* Delete this MAC entry. */ + zvni_mac_del (zvni, mac); + + return 0; +} + +/* + * Handle remote MAC delete by kernel; readd the remote MAC if we have it. + * This can happen because the remote MAC entries are also added as "dynamic", + * so the kernel can ageout the entry. + */ +int +zebra_vxlan_check_readd_remote_mac (struct interface *ifp, + struct interface *br_if, + struct ethaddr *macaddr, + vlanid_t vid) +{ + struct zebra_if *zif; + struct zebra_vrf *zvrf; + struct zebra_l2info_vxlan *vxl; + vni_t vni; + zebra_vni_t *zvni; + zebra_mac_t *mac; + char buf[ETHER_ADDR_STRLEN]; + + zif = ifp->info; + assert(zif); + vxl = &zif->l2info.vxl; + vni = vxl->vni; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + assert(zvrf); + + /* If EVPN is not enabled, nothing to do. */ + if (!EVPN_ENABLED(zvrf)) + return 0; + + /* Locate hash entry; it is expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + return 0; + + /* If entry doesn't exist, nothing to do. */ + mac = zvni_mac_lookup (zvni, macaddr); + if (!mac) + return 0; + + /* Is it a remote entry? */ + if (!CHECK_FLAG (mac->flags, ZEBRA_MAC_REMOTE)) + return 0; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Del remote MAC %s intf %s(%u) VNI %u - readd", + ifp->vrf_id, prefix_mac2str (macaddr, buf, sizeof (buf)), + ifp->name, ifp->ifindex, vni); + + zvni_mac_install (zvni, mac); + return 0; +} + +/* + * Handle local MAC delete (on a port or VLAN corresponding to this VNI). + */ +int +zebra_vxlan_local_mac_del (struct interface *ifp, struct interface *br_if, + struct ethaddr *macaddr, vlanid_t vid) +{ + zebra_vni_t *zvni; + zebra_mac_t *mac; + struct zebra_vrf *zvrf; + char buf[ETHER_ADDR_STRLEN]; + u_char sticky; + + /* We are interested in MACs only on ports or (port, VLAN) that + * map to a VNI. + */ + zvni = zvni_map_vlan (ifp, br_if, vid); + if (!zvni) + return 0; + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p doesn't have intf upon local MAC DEL", + zvni->vni, zvni); + return -1; + } + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Del MAC %s intf %s(%u) VID %u -> VNI %u", + ifp->vrf_id, prefix_mac2str (macaddr, buf, sizeof (buf)), + ifp->name, ifp->ifindex, vid, zvni->vni); + + /* If entry doesn't exist, nothing to do. */ + mac = zvni_mac_lookup (zvni, macaddr); + if (!mac) + return 0; + + /* Is it a local entry? */ + if (!CHECK_FLAG (mac->flags, ZEBRA_MAC_LOCAL)) + return 0; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); + assert(zvrf); + + /* Remove MAC from BGP. */ + sticky = CHECK_FLAG (mac->flags, ZEBRA_MAC_STICKY) ? 1: 0; + zvni_mac_send_del_to_client (zvrf, zvni->vni, macaddr, sticky); + + /* Delete this MAC entry. */ + zvni_mac_del (zvni, mac); + + return 0; +} + +/* + * Handle local MAC add (on a port or VLAN corresponding to this VNI). + */ +int +zebra_vxlan_local_mac_add_update (struct interface *ifp, struct interface *br_if, + struct ethaddr *macaddr, vlanid_t vid, + u_char sticky) +{ + zebra_vni_t *zvni; + zebra_mac_t *mac; + struct zebra_vrf *zvrf; + char buf[ETHER_ADDR_STRLEN]; + int add = 1; + u_char mac_sticky; + + /* We are interested in MACs only on ports or (port, VLAN) that + * map to a VNI. + */ + zvni = zvni_map_vlan (ifp, br_if, vid); + if (!zvni) + { + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Add/Update %sMAC %s intf %s(%u) VID %u, could not find VNI", + ifp->vrf_id, + sticky ? "sticky " : "", + prefix_mac2str (macaddr, buf, sizeof (buf)), + ifp->name, ifp->ifindex, vid); + return 0; + } + + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p doesn't have intf upon local MAC ADD", + zvni->vni, zvni); + return -1; + } + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Add/Update %sMAC %s intf %s(%u) VID %u -> VNI %u", + ifp->vrf_id, + sticky ? "sticky " : "", + prefix_mac2str (macaddr, buf, sizeof (buf)), + ifp->name, ifp->ifindex, vid, zvni->vni); + + /* If same entry already exists, nothing to do. */ + mac = zvni_mac_lookup (zvni, macaddr); + if (mac) + { + if (CHECK_FLAG (mac->flags, ZEBRA_MAC_LOCAL)) + { + mac_sticky = CHECK_FLAG (mac->flags, ZEBRA_MAC_STICKY) ? 1: 0; + + if (mac_sticky == sticky && + mac->fwd_info.local.ifindex == ifp->ifindex && + mac->fwd_info.local.vid == vid) + { + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Add/Update %sMAC %s intf %s(%u) VID %u -> VNI %u, " + "entry exists and has not changed ", + ifp->vrf_id, + sticky ? "sticky " : "", + prefix_mac2str (macaddr, buf, sizeof (buf)), + ifp->name, ifp->ifindex, vid, zvni->vni); + return 0; + } + + add = 0; /* This is an update of local interface. */ + } + } + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); + assert(zvrf); + + if (!mac) + { + mac = zvni_mac_add (zvni, macaddr); + if (!mac) + { + zlog_err ("%u:Failed to add MAC %s intf %s(%u) VID %u", + ifp->vrf_id, prefix_mac2str (macaddr, buf, sizeof (buf)), + ifp->name, ifp->ifindex, vid); + return -1; + } + } + + /* Set "local" forwarding info. */ + UNSET_FLAG (mac->flags, ZEBRA_MAC_REMOTE); + memset (&mac->fwd_info, 0, sizeof (mac->fwd_info)); + SET_FLAG (mac->flags, ZEBRA_MAC_LOCAL); + mac->fwd_info.local.ifindex = ifp->ifindex; + mac->fwd_info.local.vid = vid; + + if (sticky) + SET_FLAG (mac->flags, ZEBRA_MAC_STICKY); + else + UNSET_FLAG (mac->flags, ZEBRA_MAC_STICKY); + + /* Inform BGP if required. */ + if (add) + return zvni_mac_send_add_to_client (zvrf, zvni->vni, macaddr, sticky); + + return 0; +} + +/* + * Handle message from client to delete a remote VTEP for a VNI. + */ +int zebra_vxlan_remote_vtep_del (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + struct stream *s; + u_short l = 0; + vni_t vni; + struct in_addr vtep_ip; + zebra_vni_t *zvni; + zebra_vtep_t *zvtep; + + s = client->ibuf; + + while (l < length) + { + /* Obtain each remote VTEP and process. */ + vni = (vni_t) stream_getl (s); + l += 4; + vtep_ip.s_addr = stream_get_ipv4 (s); + l += IPV4_MAX_BYTELEN; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Recv VTEP_DEL %s VNI %u from %s", + zvrf_id (zvrf), inet_ntoa (vtep_ip), + vni, zebra_route_string (client->proto)); + + /* Locate VNI hash entry - expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("Failed to locate VNI hash upon remote VTEP DEL, " + "VRF %d VNI %u", zvrf_id (zvrf), vni); + continue; + } + + /* If the remote VTEP does not exist, there's nothing more to do. + * Otherwise, uninstall any remote MACs pointing to this VTEP and + * then, the VTEP entry itself and remove it. + */ + zvtep = zvni_vtep_find (zvni, &vtep_ip); + if (!zvtep) + continue; + + zvni_neigh_del_from_vtep (zvni, 1, &vtep_ip); + zvni_mac_del_from_vtep (zvni, 1, &vtep_ip); + zvni_vtep_uninstall (zvni, &vtep_ip); + zvni_vtep_del (zvni, zvtep); + } + + return 0; +} + +/* + * Handle message from client to add a remote VTEP for a VNI. + */ +int zebra_vxlan_remote_vtep_add (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + struct stream *s; + u_short l = 0; + vni_t vni; + struct in_addr vtep_ip; + zebra_vni_t *zvni; + + assert (EVPN_ENABLED (zvrf)); + + s = client->ibuf; + + while (l < length) + { + /* Obtain each remote VTEP and process. */ + vni = (vni_t) stream_getl (s); + l += 4; + vtep_ip.s_addr = stream_get_ipv4 (s); + l += IPV4_MAX_BYTELEN; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Recv VTEP_ADD %s VNI %u from %s", + zvrf_id (zvrf), inet_ntoa (vtep_ip), + vni, zebra_route_string (client->proto)); + + /* Locate VNI hash entry - expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + zlog_err ("Failed to locate VNI hash upon remote VTEP ADD, VRF %d VNI %u", + zvrf_id (zvrf), vni); + continue; + } + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p doesn't have intf upon remote VTEP ADD", + zvni->vni, zvni); + continue; + } + + + /* If the remote VTEP already exists, or the local VxLAN interface is + * not up (should be a transient event), there's nothing more to do. + * Otherwise, add and install the entry. + */ + if (zvni_vtep_find (zvni, &vtep_ip)) + continue; + + if (!if_is_operative (zvni->vxlan_if)) + continue; + + if (zvni_vtep_add (zvni, &vtep_ip) == NULL) + { + zlog_err ("Failed to add remote VTEP, VRF %d VNI %u zvni %p", + zvrf_id (zvrf), vni, zvni); + continue; + } + + zvni_vtep_install (zvni, &vtep_ip); + } + + return 0; +} + +/* + * Handle SVI interface going down. At this point, this is a NOP since + * the kernel deletes the neighbor entries on this SVI (if any). + */ +int +zebra_vxlan_svi_down (struct interface *ifp, struct interface *link_if) +{ + return 0; +} + +/* + * Handle SVI interface coming up. This may or may not be of interest, + * but if this is a SVI on a VxLAN bridge, we need to install any remote + * neighbor entries (which will be used for EVPN ARP suppression). + */ +int +zebra_vxlan_svi_up (struct interface *ifp, struct interface *link_if) +{ + zebra_vni_t *zvni; + struct neigh_walk_ctx n_wctx; + + zvni = zvni_map_svi (ifp, link_if); + if (!zvni) + return 0; + + if (!zvni->vxlan_if) + { + zlog_err ("VNI %u hash %p doesn't have intf upon SVI up", + zvni->vni, zvni); + return -1; + } + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:SVI %s(%u) VNI %u is UP, installing neighbors", + ifp->vrf_id, ifp->name, ifp->ifindex, zvni->vni); + + /* Install any remote neighbors for this VNI. */ + memset (&n_wctx, 0, sizeof (struct neigh_walk_ctx)); + n_wctx.zvni = zvni; + hash_iterate(zvni->neigh_table, zvni_install_neigh_hash, &n_wctx); + + return 0; +} + +/* + * Handle VxLAN interface down - update BGP if required, and do + * internal cleanup. + */ +int +zebra_vxlan_if_down (struct interface *ifp) +{ + struct zebra_if *zif; + struct zebra_vrf *zvrf; + zebra_vni_t *zvni; + struct zebra_l2info_vxlan *vxl; + vni_t vni; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + assert(zvrf); + + /* If EVPN is not enabled, nothing further to be done. */ + if (!EVPN_ENABLED(zvrf)) + return 0; + + zif = ifp->info; + assert(zif); + vxl = &zif->l2info.vxl; + vni = vxl->vni; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Intf %s(%u) VNI %u is DOWN", + ifp->vrf_id, ifp->name, ifp->ifindex, vni); + + /* Locate hash entry; it is expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + zlog_err ("Failed to locate VNI hash at DOWN, VRF %d IF %s(%u) VNI %u", + ifp->vrf_id, ifp->name, ifp->ifindex, vni); + return -1; + } + + assert (zvni->vxlan_if == ifp); + + /* Delete this VNI from BGP. */ + zvni_send_del_to_client (zvrf, zvni->vni); + + /* Free up all neighbors and MACs, if any. */ + zvni_neigh_del_all (zvrf, zvni, 1, 0, DEL_ALL_NEIGH); + zvni_mac_del_all (zvrf, zvni, 1, 0, DEL_ALL_MAC); + + /* Free up all remote VTEPs, if any. */ + zvni_vtep_del_all (zvni, 1); + + return 0; +} + +/* + * Handle VxLAN interface up - update BGP if required. + */ +int +zebra_vxlan_if_up (struct interface *ifp) +{ + struct zebra_if *zif; + struct zebra_vrf *zvrf; + zebra_vni_t *zvni; + struct zebra_l2info_vxlan *vxl; + vni_t vni; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + assert(zvrf); + + /* If EVPN is not enabled, nothing further to be done. */ + if (!EVPN_ENABLED(zvrf)) + return 0; + + zif = ifp->info; + assert(zif); + vxl = &zif->l2info.vxl; + vni = vxl->vni; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Intf %s(%u) VNI %u is UP", + ifp->vrf_id, ifp->name, ifp->ifindex, vni); + + /* Locate hash entry; it is expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + zlog_err ("Failed to locate VNI hash at UP, VRF %d IF %s(%u) VNI %u", + ifp->vrf_id, ifp->name, ifp->ifindex, vni); + return -1; + } + + assert (zvni->vxlan_if == ifp); + + /* If part of a bridge, inform BGP about this VNI. */ + /* Also, read and populate local MACs and neighbors. */ + if (zif->brslave_info.br_if) + { + zvni_send_add_to_client (zvrf, zvni); + zvni_read_mac_neigh (zvrf, zvni, ifp); + } + + return 0; +} + +/* + * Handle VxLAN interface delete. Locate and remove entry in hash table + * and update BGP, if required. + */ +int +zebra_vxlan_if_del (struct interface *ifp) +{ + struct zebra_if *zif; + struct zebra_vrf *zvrf; + zebra_vni_t *zvni; + struct zebra_l2info_vxlan *vxl; + vni_t vni; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + assert(zvrf); + + /* If EVPN is not enabled, nothing further to be done. */ + if (!EVPN_ENABLED(zvrf)) + return 0; + + zif = ifp->info; + assert(zif); + vxl = &zif->l2info.vxl; + vni = vxl->vni; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Del VNI %u intf %s(%u)", + ifp->vrf_id, vni, ifp->name, ifp->ifindex); + + /* Locate hash entry; it is expected to exist. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + zlog_err ("Failed to locate VNI hash at del, VRF %d IF %s(%u) VNI %u", + ifp->vrf_id, ifp->name, ifp->ifindex, vni); + return 0; + } + + /* Delete VNI from BGP. */ + zvni_send_del_to_client (zvrf, zvni->vni); + + /* Free up all neighbors and MAC, if any. */ + zvni_neigh_del_all (zvrf, zvni, 0, 0, DEL_ALL_NEIGH); + zvni_mac_del_all (zvrf, zvni, 0, 0, DEL_ALL_MAC); + + /* Free up all remote VTEPs, if any. */ + zvni_vtep_del_all (zvni, 0); + + /* Delete the hash entry. */ + if (zvni_del (zvrf, zvni)) + { + zlog_err ("Failed to del VNI hash %p, VRF %d IF %s(%u) VNI %u", + zvni, ifp->vrf_id, ifp->name, ifp->ifindex, zvni->vni); + return -1; + } + + return 0; +} + +/* + * Handle VxLAN interface update - change to tunnel IP, master or VLAN. + */ +int +zebra_vxlan_if_update (struct interface *ifp, u_int16_t chgflags) +{ + struct zebra_if *zif; + struct zebra_vrf *zvrf; + zebra_vni_t *zvni; + struct zebra_l2info_vxlan *vxl; + vni_t vni; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + assert(zvrf); + + /* If EVPN is not enabled, nothing further to be done. */ + if (!EVPN_ENABLED(zvrf)) + return 0; + + zif = ifp->info; + assert(zif); + vxl = &zif->l2info.vxl; + vni = vxl->vni; + + /* Update VNI hash. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + zlog_err ("Failed to find VNI hash on update, VRF %d IF %s(%u) VNI %u", + ifp->vrf_id, ifp->name, ifp->ifindex, vni); + return -1; + } + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Update VNI %u intf %s(%u) VLAN %u local IP %s " + "master %u chg 0x%x", + ifp->vrf_id, vni, ifp->name, ifp->ifindex, + vxl->access_vlan, inet_ntoa (vxl->vtep_ip), + zif->brslave_info.bridge_ifindex, chgflags); + + /* Removed from bridge? */ + if ((chgflags & ZEBRA_VXLIF_MASTER_CHANGE) && + (zif->brslave_info.bridge_ifindex == IFINDEX_INTERNAL)) + { + /* Delete from client, remove all remote VTEPs */ + /* Also, free up all MACs and neighbors. */ + zvni_send_del_to_client (zvrf, zvni->vni); + zvni_neigh_del_all (zvrf, zvni, 1, 0, DEL_ALL_NEIGH); + zvni_mac_del_all (zvrf, zvni, 1, 0, DEL_ALL_MAC); + zvni_vtep_del_all (zvni, 1); + } + else if (chgflags & ZEBRA_VXLIF_VLAN_CHANGE) + { + /* Remove all existing local neighbors and MACs for this VNI + * (including from BGP) + */ + zvni_neigh_del_all (zvrf, zvni, 0, 1, DEL_LOCAL_MAC); + zvni_mac_del_all (zvrf, zvni, 0, 1, DEL_LOCAL_MAC); + } + + zvni->local_vtep_ip = vxl->vtep_ip; + zvni->vxlan_if = ifp; + + /* Take further actions needed. Note that if we are here, there is a + * change of interest. + */ + /* If down or not mapped to a bridge, we're done. */ + if (!if_is_operative (ifp) || !zif->brslave_info.br_if) + return 0; + + /* Inform BGP, if there is a change of interest. */ + if (chgflags & (ZEBRA_VXLIF_MASTER_CHANGE | ZEBRA_VXLIF_LOCAL_IP_CHANGE)) + zvni_send_add_to_client (zvrf, zvni); + + /* If there is a valid new master or a VLAN mapping change, read and + * populate local MACs and neighbors. Also, reinstall any remote MACs + * and neighbors for this VNI (based on new VLAN). + */ + if (chgflags & ZEBRA_VXLIF_MASTER_CHANGE) + zvni_read_mac_neigh (zvrf, zvni, ifp); + else if (chgflags & ZEBRA_VXLIF_VLAN_CHANGE) + { + struct mac_walk_ctx m_wctx; + struct neigh_walk_ctx n_wctx; + + zvni_read_mac_neigh (zvrf, zvni, ifp); + + memset (&m_wctx, 0, sizeof (struct mac_walk_ctx)); + m_wctx.zvni = zvni; + hash_iterate(zvni->mac_table, zvni_install_mac_hash, &m_wctx); + + memset (&n_wctx, 0, sizeof (struct neigh_walk_ctx)); + n_wctx.zvni = zvni; + hash_iterate(zvni->neigh_table, zvni_install_neigh_hash, &n_wctx); + } + + return 0; +} + +/* + * Handle VxLAN interface add. + */ +int +zebra_vxlan_if_add (struct interface *ifp) +{ + struct zebra_if *zif; + struct zebra_vrf *zvrf; + zebra_vni_t *zvni; + struct zebra_l2info_vxlan *vxl; + vni_t vni; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + assert(zvrf); + + /* If EVPN is not enabled, nothing further to be done. */ + if (!EVPN_ENABLED(zvrf)) + return 0; + + zif = ifp->info; + assert(zif); + vxl = &zif->l2info.vxl; + vni = vxl->vni; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:Add VNI %u intf %s(%u) VLAN %u local IP %s master %u", + ifp->vrf_id, vni, ifp->name, ifp->ifindex, + vxl->access_vlan, inet_ntoa (vxl->vtep_ip), + zif->brslave_info.bridge_ifindex); + + /* Create or update VNI hash. */ + zvni = zvni_lookup (zvrf, vni); + if (!zvni) + { + zvni = zvni_add (zvrf, vni); + if (!zvni) + { + zlog_err ("Failed to add VNI hash, VRF %d IF %s(%u) VNI %u", + ifp->vrf_id, ifp->name, ifp->ifindex, vni); + return -1; + } + } + + zvni->local_vtep_ip = vxl->vtep_ip; + zvni->vxlan_if = ifp; + + /* If down or not mapped to a bridge, we're done. */ + if (!if_is_operative (ifp) || !zif->brslave_info.br_if) + return 0; + + /* Inform BGP */ + zvni_send_add_to_client (zvrf, zvni); + + /* Read and populate local MACs and neighbors */ + zvni_read_mac_neigh (zvrf, zvni, ifp); + + return 0; +} + +/* + * Handle message from client to learn (or stop learning) about VNIs and MACs. + * When enabled, the VNI hash table will be built and MAC FDB table read; + * when disabled, the entries should be deleted and remote VTEPs and MACs + * uninstalled from the kernel. + */ +int zebra_vxlan_advertise_all_vni (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + struct stream *s; + int advertise; + + s = client->ibuf; + advertise = stream_getc (s); + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug ("%u:EVPN VNI Adv %s, currently %s", + zvrf_id (zvrf), advertise ? "enabled" : "disabled", + EVPN_ENABLED(zvrf) ? "enabled" : "disabled"); + + if (zvrf->advertise_all_vni == advertise) + return 0; + + zvrf->advertise_all_vni = advertise; + if (EVPN_ENABLED(zvrf)) + { + /* Build VNI hash table and inform BGP. */ + zvni_build_hash_table (zvrf); + + /* Read the MAC FDB */ + macfdb_read (zvrf->zns); + + /* Read neighbors */ + neigh_read (zvrf->zns); + } + else + { + /* Cleanup VTEPs for all VNIs - uninstall from + * kernel and free entries. + */ + hash_iterate (zvrf->vni_table, zvni_cleanup_all, zvrf); + } + + return 0; +} + +/* + * Allocate VNI hash table for this VRF and do other initialization. + * NOTE: Currently supported only for default VRF. + */ +void +zebra_vxlan_init_tables (struct zebra_vrf *zvrf) +{ + if (!zvrf) + return; + zvrf->vni_table = hash_create(vni_hash_keymake, + vni_hash_cmp, + "Zebra VRF VNI Table"); +} + +/* Close all VNI handling */ +void +zebra_vxlan_close_tables (struct zebra_vrf *zvrf) +{ + hash_iterate (zvrf->vni_table, zvni_cleanup_all, zvrf); +} diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h new file mode 100644 index 000000000..e5f0bd2f6 --- /dev/null +++ b/zebra/zebra_vxlan.h @@ -0,0 +1,108 @@ +/* + * Zebra VxLAN (EVPN) Data structures and definitions + * These are public definitions referenced by other files. + * Copyright (C) 2016, 2017 Cumulus Networks, Inc. + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _ZEBRA_VXLAN_H +#define _ZEBRA_VXLAN_H + +#include <zebra.h> + +#include "linklist.h" +#include "if.h" +#include "vlan.h" +#include "vxlan.h" + +#include "zebra/zebra_vrf.h" + +/* Is EVPN enabled? */ +#define EVPN_ENABLED(zvrf) (zvrf)->advertise_all_vni + +/* VxLAN interface change flags of interest. */ +#define ZEBRA_VXLIF_LOCAL_IP_CHANGE 0x1 +#define ZEBRA_VXLIF_MASTER_CHANGE 0x2 +#define ZEBRA_VXLIF_VLAN_CHANGE 0x4 + +extern void zebra_vxlan_print_macs_vni (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni); +extern void zebra_vxlan_print_macs_all_vni (struct vty *vty, + struct zebra_vrf *zvrf); +extern void zebra_vxlan_print_macs_all_vni_vtep (struct vty *vty, + struct zebra_vrf *zvrf, + struct in_addr vtep_ip); +extern void zebra_vxlan_print_specific_mac_vni (struct vty *vty, + struct zebra_vrf *zvrf, vni_t vni, struct ethaddr *mac); +extern void zebra_vxlan_print_macs_vni_vtep (struct vty *vty, + struct zebra_vrf *zvrf, vni_t vni, struct in_addr vtep_ip); +extern void zebra_vxlan_print_neigh_vni (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni); +extern void zebra_vxlan_print_neigh_all_vni (struct vty *vty, + struct zebra_vrf *zvrf); +extern void zebra_vxlan_print_specific_neigh_vni (struct vty *vty, + struct zebra_vrf *zvrf, vni_t vni, struct ipaddr *ip); +extern void zebra_vxlan_print_neigh_vni_vtep (struct vty *vty, + struct zebra_vrf *zvrf, vni_t vni, struct in_addr vtep_ip); +extern void zebra_vxlan_print_vni (struct vty *vty, struct zebra_vrf *zvrf, vni_t vni); +extern void zebra_vxlan_print_vnis (struct vty *vty, struct zebra_vrf *zvrf); + +extern int zebra_vxlan_svi_up (struct interface *ifp, struct interface *link_if); +extern int zebra_vxlan_svi_down (struct interface *ifp, struct interface *link_if); +extern int zebra_vxlan_local_neigh_add_update (struct interface *ifp, + struct interface *link_if, + struct ipaddr *ip, + struct ethaddr *macaddr, + u_int16_t state, + u_char ext_learned); +extern int zebra_vxlan_local_neigh_del (struct interface *ifp, + struct interface *link_if, + struct ipaddr *ip); +extern int zebra_vxlan_remote_macip_add (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf); +extern int zebra_vxlan_remote_macip_del (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf); +extern int zebra_vxlan_local_mac_add_update (struct interface *ifp, + struct interface *br_if, + struct ethaddr *mac, vlanid_t vid, + u_char sticky); +extern int zebra_vxlan_local_mac_del (struct interface *ifp, + struct interface *br_if, + struct ethaddr *mac, vlanid_t vid); +extern int zebra_vxlan_check_readd_remote_mac (struct interface *ifp, + struct interface *br_if, + struct ethaddr *mac, vlanid_t vid); +extern int zebra_vxlan_check_del_local_mac (struct interface *ifp, + struct interface *br_if, + struct ethaddr *mac, vlanid_t vid); +extern int zebra_vxlan_if_up (struct interface *ifp); +extern int zebra_vxlan_if_down (struct interface *ifp); +extern int zebra_vxlan_if_add (struct interface *ifp); +extern int zebra_vxlan_if_update (struct interface *ifp, u_int16_t chgflags); +extern int zebra_vxlan_if_del (struct interface *ifp); +extern int zebra_vxlan_remote_vtep_add (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf); +extern int zebra_vxlan_remote_vtep_del (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf); +extern int zebra_vxlan_advertise_all_vni (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf); +extern void zebra_vxlan_init_tables (struct zebra_vrf *zvrf); +extern void zebra_vxlan_close_tables (struct zebra_vrf *); + +#endif /* _ZEBRA_VXLAN_H */ diff --git a/zebra/zebra_vxlan_null.c b/zebra/zebra_vxlan_null.c new file mode 100644 index 000000000..b0f09930b --- /dev/null +++ b/zebra/zebra_vxlan_null.c @@ -0,0 +1,197 @@ +/* + * Zebra VxLAN (EVPN) + * Copyright (C) 2016, 2017 Cumulus Networks, Inc. + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <zebra.h> + +#include "if.h" +#include "zebra/debug.h" +#include "zebra/zserv.h" +#include "zebra/rib.h" +#include "zebra/zebra_vrf.h" +#include "zebra/zebra_l2.h" +#include "zebra/zebra_vxlan.h" + +void +zebra_vxlan_print_macs_vni (struct vty *vty, struct zebra_vrf *zvrf, vni_t vni) +{ +} + +void zebra_vxlan_print_macs_all_vni (struct vty *vty, struct zebra_vrf *zvrf) +{ +} + +void zebra_vxlan_print_macs_all_vni_vtep (struct vty *vty, struct zebra_vrf *zvrf, struct in_addr vtep_ip) +{ +} + +void +zebra_vxlan_print_specific_mac_vni (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni, struct ethaddr *mac) +{ +} + +void +zebra_vxlan_print_macs_vni_vtep (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni, struct in_addr vtep_ip) +{ +} + +void +zebra_vxlan_print_neigh_vni (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni) +{ +} + +void +zebra_vxlan_print_neigh_all_vni (struct vty *vty, struct zebra_vrf *zvrf) +{ +} + +void +zebra_vxlan_print_specific_neigh_vni (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni, struct ipaddr *ip) +{ +} + +void zebra_vxlan_print_neigh_vni_vtep (struct vty *vty, struct zebra_vrf *zvrf, + vni_t vni, struct in_addr vtep_ip) +{ +} + +void +zebra_vxlan_print_vni (struct vty *vty, struct zebra_vrf *zvrf, vni_t vni) +{ +} + +void +zebra_vxlan_print_vnis (struct vty *vty, struct zebra_vrf *zvrf) +{ +} + +int zebra_vxlan_svi_up (struct interface *ifp, struct interface *link_if) +{ + return 0; +} + +int zebra_vxlan_svi_down (struct interface *ifp, struct interface *link_if) +{ + return 0; +} + +int zebra_vxlan_remote_macip_add (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + return 0; +} + +int zebra_vxlan_remote_macip_del (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + return 0; +} + +int zebra_vxlan_local_mac_add_update (struct interface *ifp, + struct interface *br_if, + struct ethaddr *mac, vlanid_t vid, + u_char sticky) +{ + return 0; +} + +int zebra_vxlan_local_mac_del (struct interface *ifp, + struct interface *br_if, + struct ethaddr *mac, vlanid_t vid) +{ + return 0; +} + +int zebra_vxlan_check_readd_remote_mac (struct interface *ifp, + struct interface *br_if, + struct ethaddr *mac, vlanid_t vid) +{ + return 0; +} + +int zebra_vxlan_check_del_local_mac (struct interface *ifp, + struct interface *br_if, + struct ethaddr *mac, vlanid_t vid) +{ + return 0; +} + +int +zebra_vxlan_if_up (struct interface *ifp) +{ + return 0; +} + +int +zebra_vxlan_if_down (struct interface *ifp) +{ + return 0; +} + +int +zebra_vxlan_if_add (struct interface *ifp) +{ + return 0; +} + +int +zebra_vxlan_if_update (struct interface *ifp, u_int16_t chgflags) +{ + return 0; +} + +int +zebra_vxlan_if_del (struct interface *ifp) +{ + return 0; +} + +int zebra_vxlan_remote_vtep_add (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + return 0; +} + +int zebra_vxlan_remote_vtep_del (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + return 0; +} + +int zebra_vxlan_advertise_all_vni (struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) +{ + return 0; +} + +void +zebra_vxlan_init_tables (struct zebra_vrf *zvrf) +{ +} + +void +zebra_vxlan_close_tables (struct zebra_vrf *zvrf) +{ +} diff --git a/zebra/zebra_vxlan_private.h b/zebra/zebra_vxlan_private.h new file mode 100644 index 000000000..0de86c3bc --- /dev/null +++ b/zebra/zebra_vxlan_private.h @@ -0,0 +1,199 @@ +/* + * Zebra VxLAN (EVPN) Data structures and definitions + * These are "internal" to this function. + * Copyright (C) 2016, 2017 Cumulus Networks, Inc. + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _ZEBRA_VXLAN_PRIVATE_H +#define _ZEBRA_VXLAN_PRIVATE_H + +#include <zebra.h> + +#include <zebra.h> + +#include "if.h" +#include "linklist.h" + +/* definitions */ +typedef struct zebra_vni_t_ zebra_vni_t; +typedef struct zebra_vtep_t_ zebra_vtep_t; +typedef struct zebra_mac_t_ zebra_mac_t; +typedef struct zebra_neigh_t_ zebra_neigh_t; + +/* + * VTEP info + * + * Right now, this just has each remote VTEP's IP address. + */ +struct zebra_vtep_t_ +{ + /* Remote IP. */ + /* NOTE: Can only be IPv4 right now. */ + struct in_addr vtep_ip; + + /* Links. */ + struct zebra_vtep_t_ *next; + struct zebra_vtep_t_ *prev; +}; + + +/* + * VNI hash table + * + * Contains information pertaining to a VNI: + * - the list of remote VTEPs (with this VNI) + */ +struct zebra_vni_t_ +{ + /* VNI - key */ + vni_t vni; + + /* Corresponding VxLAN interface. */ + struct interface *vxlan_if; + + /* List of remote VTEPs */ + zebra_vtep_t *vteps; + + /* Local IP */ + struct in_addr local_vtep_ip; + + /* List of local or remote MAC */ + struct hash *mac_table; + + /* List of local or remote neighbors (MAC+IP) */ + struct hash *neigh_table; +}; + +/* + * MAC hash table. + * + * This table contains the MAC addresses pertaining to this VNI. + * This includes local MACs learnt on an attached VLAN that maps + * to this VNI as well as remote MACs learnt and installed by BGP. + * Local MACs will be known either on a VLAN sub-interface or + * on (port, VLAN); however, it is sufficient for zebra to maintain + * against the VNI i.e., it does not need to retain the local "port" + * information. The correct VNI will be obtained as zebra maintains + * the mapping (of VLAN to VNI). + */ +struct zebra_mac_t_ +{ + /* MAC address. */ + struct ethaddr macaddr; + + u_int32_t flags; +#define ZEBRA_MAC_LOCAL 0x01 +#define ZEBRA_MAC_REMOTE 0x02 +#define ZEBRA_MAC_AUTO 0x04 /* Auto created for neighbor. */ +#define ZEBRA_MAC_STICKY 0x08 /* Static MAC */ + + /* Local or remote info. */ + union + { + struct + { + ifindex_t ifindex; + vlanid_t vid; + } local; + + struct in_addr r_vtep_ip; + } fwd_info; + + u_int32_t neigh_refcnt; +}; + +/* + * Context for MAC hash walk - used by callbacks. + */ +struct mac_walk_ctx +{ + zebra_vni_t *zvni; /* VNI hash */ + struct zebra_vrf *zvrf; /* VRF - for client notification. */ + int uninstall; /* uninstall from kernel? */ + int upd_client; /* uninstall from client? */ + + u_int32_t flags; +#define DEL_LOCAL_MAC 0x1 +#define DEL_REMOTE_MAC 0x2 +#define DEL_ALL_MAC (DEL_LOCAL_MAC | DEL_REMOTE_MAC) +#define DEL_REMOTE_MAC_FROM_VTEP 0x4 +#define SHOW_REMOTE_MAC_FROM_VTEP 0x8 + + struct in_addr r_vtep_ip; /* To walk MACs from specific VTEP */ + + struct vty *vty; /* Used by VTY handlers */ + u_int32_t count; /* Used by VTY handlers */ +}; + +/* + * Neighbor hash table. + * + * This table contains the neighbors (IP to MAC bindings) pertaining to + * this VNI. This includes local neighbors learnt on the attached VLAN + * device that maps to this VNI as well as remote neighbors learnt and + * installed by BGP. + * Local neighbors will be known against the VLAN device (SVI); however, + * it is sufficient for zebra to maintain against the VNI. The correct + * VNI will be obtained as zebra maintains the mapping (of VLAN to VNI). + */ +struct zebra_neigh_t_ +{ + /* IP address. */ + struct ipaddr ip; + + /* MAC address. */ + struct ethaddr emac; + + /* Underlying interface. */ + ifindex_t ifindex; + + u_int32_t flags; +#define ZEBRA_NEIGH_LOCAL 0x01 +#define ZEBRA_NEIGH_REMOTE 0x02 + + /* Remote VTEP IP - applicable only for remote neighbors. */ + struct in_addr r_vtep_ip; +}; + +/* + * Context for neighbor hash walk - used by callbacks. + */ +struct neigh_walk_ctx +{ + zebra_vni_t *zvni; /* VNI hash */ + struct zebra_vrf *zvrf; /* VRF - for client notification. */ + int uninstall; /* uninstall from kernel? */ + int upd_client; /* uninstall from client? */ + + u_int32_t flags; +#define DEL_LOCAL_NEIGH 0x1 +#define DEL_REMOTE_NEIGH 0x2 +#define DEL_ALL_NEIGH (DEL_LOCAL_NEIGH | DEL_REMOTE_NEIGH) +#define DEL_REMOTE_NEIGH_FROM_VTEP 0x4 +#define SHOW_REMOTE_NEIGH_FROM_VTEP 0x8 + + struct in_addr r_vtep_ip; /* To walk neighbors from specific VTEP */ + + struct vty *vty; /* Used by VTY handlers */ + u_int32_t count; /* Used by VTY handlers */ + u_char addr_width; /* Used by VTY handlers */ +}; + +#endif /* _ZEBRA_VXLAN_PRIVATE_H */ diff --git a/zebra/zserv.c b/zebra/zserv.c index 3da94459f..15feb78c0 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -54,6 +54,7 @@ #include "zebra/zebra_mpls.h" #include "zebra/zebra_mroute.h" #include "zebra/label_manager.h" +#include "zebra/zebra_vxlan.h" /* Event list of zebra. */ enum event { ZEBRA_SERV, ZEBRA_READ, ZEBRA_WRITE }; @@ -2434,6 +2435,21 @@ zebra_client_read (struct thread *thread) case ZEBRA_FEC_UNREGISTER: zserv_fec_unregister (client, sock, length); break; + case ZEBRA_ADVERTISE_ALL_VNI: + zebra_vxlan_advertise_all_vni (client, sock, length, zvrf); + break; + case ZEBRA_REMOTE_VTEP_ADD: + zebra_vxlan_remote_vtep_add (client, sock, length, zvrf); + break; + case ZEBRA_REMOTE_VTEP_DEL: + zebra_vxlan_remote_vtep_del (client, sock, length, zvrf); + break; + case ZEBRA_REMOTE_MACIP_ADD: + zebra_vxlan_remote_macip_add (client, sock, length, zvrf); + break; + case ZEBRA_REMOTE_MACIP_DEL: + zebra_vxlan_remote_macip_del (client, sock, length, zvrf); + break; default: zlog_info ("Zebra received unknown command %d", command); break; @@ -2676,57 +2692,61 @@ zebra_show_client_detail (struct vty *vty, struct zserv *client) vty_out (vty, "Client: %s", zebra_route_string(client->proto)); if (client->instance) vty_out (vty, " Instance: %d", client->instance); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); - vty_outln (vty, "------------------------ "); - vty_outln (vty, "FD: %d ", client->sock); - vty_outln (vty, "Route Table ID: %d ", client->rtm_table); + vty_out (vty, "------------------------ \n"); + vty_out (vty, "FD: %d \n", client->sock); + vty_out (vty, "Route Table ID: %d \n", client->rtm_table); - vty_outln (vty, "Connect Time: %s ", + vty_out (vty, "Connect Time: %s \n", zserv_time_buf(&client->connect_time, cbuf, ZEBRA_TIME_BUF)); if (client->nh_reg_time) { - vty_outln (vty, "Nexthop Registry Time: %s ", + vty_out (vty, "Nexthop Registry Time: %s \n", zserv_time_buf(&client->nh_reg_time, nhbuf, ZEBRA_TIME_BUF)); if (client->nh_last_upd_time) - vty_outln (vty, "Nexthop Last Update Time: %s ", + vty_out (vty, "Nexthop Last Update Time: %s \n", zserv_time_buf(&client->nh_last_upd_time, mbuf, ZEBRA_TIME_BUF)); else - vty_outln (vty, "No Nexthop Update sent"); + vty_out (vty, "No Nexthop Update sent\n"); } else - vty_outln (vty, "Not registered for Nexthop Updates"); + vty_out (vty, "Not registered for Nexthop Updates\n"); - vty_outln (vty, "Last Msg Rx Time: %s ", + vty_out (vty, "Last Msg Rx Time: %s \n", zserv_time_buf(&client->last_read_time, rbuf, ZEBRA_TIME_BUF)); - vty_outln (vty, "Last Msg Tx Time: %s ", + vty_out (vty, "Last Msg Tx Time: %s \n", zserv_time_buf(&client->last_write_time, wbuf, ZEBRA_TIME_BUF)); if (client->last_read_time) - vty_outln (vty, "Last Rcvd Cmd: %s ", + vty_out (vty, "Last Rcvd Cmd: %s \n", zserv_command_string(client->last_read_cmd)); if (client->last_write_time) - vty_outln (vty, "Last Sent Cmd: %s ", + vty_out (vty, "Last Sent Cmd: %s \n", zserv_command_string(client->last_write_cmd)); - vty_out (vty, VTYNL); + vty_out (vty, "\n"); - vty_outln (vty, "Type Add Update Del "); - vty_outln (vty, "================================================== "); - vty_outln (vty, "IPv4 %-12d%-12d%-12d", client->v4_route_add_cnt, + vty_out (vty, "Type Add Update Del \n"); + vty_out (vty, "================================================== \n"); + vty_out (vty, "IPv4 %-12d%-12d%-12d\n", client->v4_route_add_cnt, client->v4_route_upd8_cnt, client->v4_route_del_cnt); - vty_outln (vty, "IPv6 %-12d%-12d%-12d", client->v6_route_add_cnt, + vty_out (vty, "IPv6 %-12d%-12d%-12d\n", client->v6_route_add_cnt, client->v6_route_upd8_cnt, client->v6_route_del_cnt); - vty_outln (vty, "Redist:v4 %-12d%-12d%-12d", client->redist_v4_add_cnt, 0, + vty_out (vty, "Redist:v4 %-12d%-12d%-12d\n", client->redist_v4_add_cnt, 0, client->redist_v4_del_cnt); - vty_outln (vty, "Redist:v6 %-12d%-12d%-12d", client->redist_v6_add_cnt, 0, + vty_out (vty, "Redist:v6 %-12d%-12d%-12d\n", client->redist_v6_add_cnt, 0, client->redist_v6_del_cnt); - vty_outln (vty, "Connected %-12d%-12d%-12d", client->ifadd_cnt, 0, + vty_out (vty, "Connected %-12d%-12d%-12d\n", client->ifadd_cnt, 0, client->ifdel_cnt); - vty_outln (vty, "BFD peer %-12d%-12d%-12d", client->bfd_peer_add_cnt, + vty_out (vty, "BFD peer %-12d%-12d%-12d\n", client->bfd_peer_add_cnt, client->bfd_peer_upd8_cnt, client->bfd_peer_del_cnt); - vty_outln (vty, "Interface Up Notifications: %d",client->ifup_cnt); - vty_outln (vty, "Interface Down Notifications: %d",client->ifdown_cnt); - - vty_out (vty, VTYNL); + vty_out (vty, "Interface Up Notifications: %d\n",client->ifup_cnt); + vty_out (vty, "Interface Down Notifications: %d\n",client->ifdown_cnt); + vty_out (vty, "VNI add notifications: %d\n", client->vniadd_cnt); + vty_out (vty, "VNI delete notifications: %d\n", client->vnidel_cnt); + vty_out (vty, "MAC-IP add notifications: %d\n", client->macipadd_cnt); + vty_out (vty, "MAC-IP delete notifications: %d\n", client->macipdel_cnt); + + vty_out (vty, "\n"); return; } @@ -2736,7 +2756,7 @@ zebra_show_client_brief (struct vty *vty, struct zserv *client) char cbuf[ZEBRA_TIME_BUF], rbuf[ZEBRA_TIME_BUF]; char wbuf[ZEBRA_TIME_BUF]; - vty_outln (vty, "%-8s%12s %12s%12s%8d/%-8d%8d/%-8d", + vty_out (vty, "%-8s%12s %12s%12s%8d/%-8d%8d/%-8d\n", zebra_route_string(client->proto), zserv_time_buf(&client->connect_time, cbuf, ZEBRA_TIME_BUF), zserv_time_buf(&client->last_read_time, rbuf, ZEBRA_TIME_BUF), @@ -2771,7 +2791,7 @@ DEFUN (show_table, SHOW_STR "default routing table to use for all clients\n") { - vty_outln (vty, "table %d",zebrad.rtm_table_default); + vty_out (vty, "table %d\n",zebrad.rtm_table_default); return CMD_SUCCESS; } @@ -2811,8 +2831,8 @@ DEFUN (ip_forwarding, if (ret == 0) { - vty_outln (vty, "Can't turn on IP forwarding"); - return CMD_WARNING; + vty_out (vty, "Can't turn on IP forwarding\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -2833,8 +2853,8 @@ DEFUN (no_ip_forwarding, if (ret != 0) { - vty_outln (vty, "Can't turn off IP forwarding"); - return CMD_WARNING; + vty_out (vty, "Can't turn off IP forwarding\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -2848,14 +2868,14 @@ DEFUN (show_zebra, { struct vrf *vrf; - vty_outln (vty, - " Route Route Neighbor LSP LSP"); - vty_outln (vty, - "VRF Installs Removals Updates Installs Removals"); + vty_out (vty, + " Route Route Neighbor LSP LSP\n"); + vty_out (vty, + "VRF Installs Removals Updates Installs Removals\n"); RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { struct zebra_vrf *zvrf = vrf->info; - vty_outln (vty,"%-25s %10" PRIu64 " %10" PRIu64 " %10" PRIu64 " %10" PRIu64 " %10" PRIu64 "", + vty_out (vty,"%-25s %10" PRIu64 " %10" PRIu64 " %10" PRIu64 " %10" PRIu64 " %10" PRIu64 "\n", vrf->name, zvrf->installs, zvrf->removals, zvrf->neigh_updates, zvrf->lsp_installs,zvrf->lsp_removals); } @@ -2892,15 +2912,15 @@ DEFUN (show_zebra_client_summary, struct listnode *node; struct zserv *client; - vty_outln (vty, - "Name Connect Time Last Read Last Write IPv4 Routes IPv6 Routes "); - vty_outln (vty, - "--------------------------------------------------------------------------------"); + vty_out (vty, + "Name Connect Time Last Read Last Write IPv4 Routes IPv6 Routes \n"); + vty_out (vty, + "--------------------------------------------------------------------------------\n"); for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client)) zebra_show_client_brief(vty, client); - vty_outln (vty, "Routes column shows (added+updated)/deleted"); + vty_out (vty, "Routes column shows (added+updated)/deleted\n"); return CMD_SUCCESS; } @@ -2909,7 +2929,7 @@ static int config_write_table (struct vty *vty) { if (zebrad.rtm_table_default) - vty_outln (vty, "table %d",zebrad.rtm_table_default); + vty_out (vty, "table %d\n",zebrad.rtm_table_default); return 0; } @@ -2934,9 +2954,9 @@ DEFUN (show_ip_forwarding, ret = ipforward (); if (ret == 0) - vty_outln (vty, "IP forwarding is off"); + vty_out (vty, "IP forwarding is off\n"); else - vty_outln (vty, "IP forwarding is on"); + vty_out (vty, "IP forwarding is on\n"); return CMD_SUCCESS; } @@ -2955,16 +2975,16 @@ DEFUN (show_ipv6_forwarding, switch (ret) { case -1: - vty_outln (vty, "ipv6 forwarding is unknown"); + vty_out (vty, "ipv6 forwarding is unknown\n"); break; case 0: - vty_outln (vty, "ipv6 forwarding is %s", "off"); + vty_out (vty, "ipv6 forwarding is %s\n", "off"); break; case 1: - vty_outln (vty, "ipv6 forwarding is %s", "on"); + vty_out (vty, "ipv6 forwarding is %s\n", "on"); break; default: - vty_outln (vty, "ipv6 forwarding is %s", "off"); + vty_out (vty, "ipv6 forwarding is %s\n", "off"); break; } return CMD_SUCCESS; @@ -2984,8 +3004,8 @@ DEFUN (ipv6_forwarding, if (ret == 0) { - vty_outln (vty, "Can't turn on IPv6 forwarding"); - return CMD_WARNING; + vty_out (vty, "Can't turn on IPv6 forwarding\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -3006,8 +3026,8 @@ DEFUN (no_ipv6_forwarding, if (ret != 0) { - vty_outln (vty, "Can't turn off IPv6 forwarding"); - return CMD_WARNING; + vty_out (vty, "Can't turn off IPv6 forwarding\n"); + return CMD_WARNING_CONFIG_FAILED; } return CMD_SUCCESS; @@ -3021,10 +3041,10 @@ config_write_forwarding (struct vty *vty) router_id_write (vty); if (!ipforward ()) - vty_outln (vty, "no ip forwarding"); + vty_out (vty, "no ip forwarding\n"); if (!ipforward_ipv6 ()) - vty_outln (vty, "no ipv6 forwarding"); - vty_outln (vty, "!"); + vty_out (vty, "no ipv6 forwarding\n"); + vty_out (vty, "!\n"); return 0; } diff --git a/zebra/zserv.h b/zebra/zserv.h index dcc98d83f..2d6f6fae7 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -105,6 +105,10 @@ struct zserv u_int32_t vrfdel_cnt; u_int32_t if_vrfchg_cnt; u_int32_t bfd_client_reg_cnt; + u_int32_t vniadd_cnt; + u_int32_t vnidel_cnt; + u_int32_t macipadd_cnt; + u_int32_t macipdel_cnt; time_t connect_time; time_t last_read_time; @@ -145,6 +149,11 @@ extern void hostinfo_get (void); extern void rib_init (void); extern void interface_list (struct zebra_ns *); extern void route_read (struct zebra_ns *); +extern void macfdb_read (struct zebra_ns *); +extern void macfdb_read_for_bridge (struct zebra_ns *, struct interface *, + struct interface *); +extern void neigh_read (struct zebra_ns *); +extern void neigh_read_for_vlan (struct zebra_ns *, struct interface *); extern void kernel_init (struct zebra_ns *); extern void kernel_terminate (struct zebra_ns *); extern void zebra_route_map_init (void); |