int ifindex = if_nametoindex(ifp->name);
if(ifindex > 0) {
unsigned char eui[8];
- rc = if_eui64(ifp->name, ifindex, eui);
+ rc = if_eui64(ifindex, eui);
if(rc < 0)
continue;
memcpy(myid, eui, 8);
ifname = if_indextoname(i, buf);
if(ifname == NULL)
continue;
- rc = if_eui64(ifname, i, eui);
+ rc = if_eui64(i, eui);
if(rc < 0)
continue;
memcpy(myid, eui, 8);
}
int
-if_eui64(char *ifname, int ifindex, unsigned char *eui)
+if_eui64(int ifindex, unsigned char *eui)
{
struct interface *ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
if (ifp == NULL) {
const unsigned char *gate, int ifindex, unsigned int metric,
const unsigned char *newgate, int newifindex,
unsigned int newmetric);
-int if_eui64(char *ifname, int ifindex, unsigned char *eui);
+int if_eui64(int ifindex, unsigned char *eui);
int gettime(struct timeval *tv);
int read_random_bytes(void *buf, size_t len);
/*
* NOTE: intentional fall through
* - for consistency in rx processing
+ *
+ * The following comment is to signal GCC this intention
+ * and supress the warning
*/
+ /* FALLTHRU */
case BGP_ATTR_NHLEN_IPV4:
stream_get(&attr->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN);
/* Probably needed for RFC 2283 */
aggregator =
XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct aggregator));
- sscanf(arg, "%s %s", as, address);
+ if (sscanf(arg, "%s %s", as, address) != 2) {
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, aggregator);
+ return NULL;
+ }
aggregator->as = strtoul(as, NULL, 10);
ret = inet_aton(address, &aggregator->address);
#include "libfrr.h"
#include "version.h"
-#include "bgp_rpki_clippy.c"
+#ifndef VTYSH_EXTRACT_PL
+#include "bgpd/bgp_rpki_clippy.c"
+#endif
DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE, "BGP RPKI Cache server")
DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE_GROUP, "BGP RPKI Cache server group")
#ifndef VTYSH_EXTRACT_PL
-#include "bgp_vty_clippy.c"
+#include "bgpd/bgp_vty_clippy.c"
#endif
/* BGP global configuration. */
}
/* Check peer's AS number and determines if this peer is IBGP or EBGP */
-static bgp_peer_sort_t peer_calc_sort(struct peer *peer)
+static inline bgp_peer_sort_t peer_calc_sort(struct peer *peer)
{
struct bgp *bgp;
peer_dst->local_as = peer_src->local_as;
peer_dst->ifindex = peer_src->ifindex;
peer_dst->port = peer_src->port;
- peer_sort(peer_dst);
+ (void)peer_sort(peer_dst);
peer_dst->rmap_type = peer_src->rmap_type;
/* Timers */
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
}
+ if (peer->status == OpenSent || peer->status == OpenConfirm) {
+ peer->last_reset = PEER_DOWN_AF_ACTIVATE;
+ bgp_notify_send(peer, BGP_NOTIFY_CEASE,
+ BGP_NOTIFY_CEASE_CONFIG_CHANGE);
+ }
}
return 0;
__func__, __LINE__, have_vnc_tunnel_un);
#endif
- if (!have_vnc_tunnel_un && bi && bi->extra) {
+ if (!have_vnc_tunnel_un && bi->extra) {
/*
* use cached UN address from ENCAP route
*/
vnc_zlog_debug_verbose(
"%s: rfapiEcommunityGetLNI returned %d, lni=%d, attr=%p",
__func__, rc, lni, attr);
- if (attr && !rc) {
+ if (!rc) {
it = rfapiMacImportTableGet(bgp, lni);
rfapiBgpInfoFilteredImportVPN(
}
}
- if (checkstats && bgp && bgp->rfapi) {
+ if (checkstats && bgp->rfapi) {
if (t_pfx_active != bgp->rfapi->rib_prefix_count_total) {
vnc_zlog_debug_verbose(
"%s: actual total pfx count %u != running %u",
memcpy(&vo->v.l2addr.macaddr, bi->extra->vnc.import.rd.val + 2,
ETH_ALEN);
- if (bi->attr) {
- (void)rfapiEcommunityGetLNI(
- bi->attr->ecommunity,
- &vo->v.l2addr.logical_net_id);
- (void)rfapiEcommunityGetEthernetTag(
- bi->attr->ecommunity, &vo->v.l2addr.tag_id);
- }
+ (void)rfapiEcommunityGetLNI(bi->attr->ecommunity,
+ &vo->v.l2addr.logical_net_id);
+ (void)rfapiEcommunityGetEthernetTag(bi->attr->ecommunity,
+ &vo->v.l2addr.tag_id);
/* local_nve_id comes from RD */
vo->v.l2addr.local_nve_id = bi->extra->vnc.import.rd.val[1];
/*
* If there is an auxiliary IP address (L2 can have it), copy it
*/
- if (bi && bi->extra && bi->extra->vnc.import.aux_prefix.family) {
+ if (bi->extra && bi->extra->vnc.import.aux_prefix.family) {
ri->rk.aux_prefix = bi->extra->vnc.import.aux_prefix;
}
}
char buf_age[BUFSIZ];
- if (bi && bi->extra && bi->extra->vnc.import.create_time) {
+ if (bi->extra && bi->extra->vnc.import.create_time) {
rfapiFormatAge(bi->extra->vnc.import.create_time,
buf_age, BUFSIZ);
} else {
* print that on the next line
*/
- if (bi && bi->extra
+ if (bi->extra
&& bi->extra->vnc.import.aux_prefix.family) {
const char *sp;
assert(afi);
- assert((rfg = bgp->rfapi_cfg->rfg_redist));
+ rfg = bgp->rfapi_cfg->rfg_redist;
+ assert(rfg);
/*
* Compute VN address
return;
}
- if (bgp && bgp->rfapi)
+ if (bgp->rfapi)
sl = bgp->rfapi->resolve_nve_nexthop;
if (!sl) {
return;
}
- if (bgp && bgp->rfapi)
+ if (bgp->rfapi)
sl = bgp->rfapi->resolve_nve_nexthop;
if (!sl) {
backports/ubuntu16.04/debian/source/format \
backports/ubuntu16.04/exclude \
backports/ubuntu16.04/versionext \
+ backports/ubuntu17.10/debian/control \
+ backports/ubuntu17.10/debian/source/format \
+ backports/ubuntu17.10/exclude \
+ backports/ubuntu17.10/versionext \
frr-doc.docs frr-doc.info frr-doc.install \
frr-doc.lintian-overrides frr.conf \
frr.dirs frr.docs frr.install \
Building your own FRRouting Debian Package
==========================================
-(Tested on Ubuntu 12.04, 14.04, 16.04 and Debian 8)
+(Tested on Ubuntu 12.04, 14.04, 16.04, 17.10, Debian 8 and 9)
+
+**Note:** If you try to build for a different distro, then it will most likely
+fail because of the missing backport. See debianpkg/backports/README about
+adding a new backport.
1. Follow the package installation as outlined in doc/Building_on_XXXX.md
(XXXX refers your OS Distribution) to install the required build packages
2. Install the following additional packages:
- apt-get install realpath equivs groff fakeroot debhelper
+ apt-get install realpath equivs groff fakeroot debhelper devscripts
3. Checkout FRR under a **unpriviledged** user account
git clone https://github.com/frrouting/frr.git frr
+ cd frr
+ # git checkout <branch> - if different branch than master
4. Run Bootstrap and make distribution tar.gz
- cd frr
./bootstrap.sh
./configure --with-pkg-extra-version=-MyDebPkgVersion
make dist
and multiple `frr_*.debian.tar.xz` and `frr_*.dsc` for the debian package
source on each backport supported distribution
-6. Create a new directory to build the package and populate with package src
+7. Create a new directory to build the package and populate with package src
mkdir frrpkg
cd frrpkg
. /etc/os-release
tar xf ~/frr/frr_*${ID}${VERSION_ID}*.debian.tar.xz
-7. Build Debian Package Dependencies and install them as needed
+8. Build Debian Package Dependencies and install them as needed
sudo mk-build-deps --install debian/control
-8. Build Debian Package
+9. Build Debian Package
+
+ Building with standard options:
+
+ debuild -b -uc -us
+
+ Or change some options:
+ (see `rules` file for available options)
+ export WANT_BGP_VNC=1
+ export WANT_WANT_CUMULUS_MODE=1
debuild -b -uc -us
DONE.
sudo update-rc.d frr defaults
- - On `systemd` based systems (Debian 8, Ubuntu 14.04, 16.04)
+ - On `systemd` based systems (Debian 8, 9, Ubuntu 14.04, 16.04, 17.10)
sudo systemctl enable frr
sudo invoke-rc.d frr start
- - on `systemd` based systems (Debian 8, Ubuntu 14.04, 16.04)
+ - on `systemd` based systems (Debian 8, 9, Ubuntu 14.04, 16.04, 17.10)
sudo systemctl start frr
--- /dev/null
+Source: frr
+Section: net
+Priority: optional
+Maintainer: Nobody <nobody@frrouting.org>
+Uploaders: Nobody <nobody@frrouting.org>
+XSBC-Original-Maintainer: <maintainers@frrouting.org>
+Build-Depends: debhelper (>= 7.0.50~), libncurses5-dev, libreadline-dev, texlive-latex-base, texlive-generic-recommended, libpam0g-dev | libpam-dev, libcap-dev, texinfo (>= 4.7), imagemagick, ghostscript, groff, autotools-dev, libpcre3-dev, gawk, chrpath, libsnmp-dev, git, dh-autoreconf, libjson-c-dev, libjson-c2 | libjson-c3, dh-systemd, libsystemd-dev, bison, flex, libc-ares-dev, pkg-config, python (>= 2.7), python-ipaddr
+Standards-Version: 3.9.6
+Homepage: http://www.frrouting.org/
+
+Package: frr
+Architecture: any
+Depends: ${shlibs:Depends}, logrotate (>= 3.2-11), iproute2 | iproute, ${misc:Depends}, libc-ares2
+Pre-Depends: adduser
+Conflicts: zebra, zebra-pj, quagga
+Replaces: zebra, zebra-pj
+Suggests: snmpd
+Description: BGP/OSPF/RIP/RIPng/ISIS/PIM/LDP routing daemon forked from Quagga
+ FRR is free software which manages TCP/IP based routing protocols.
+ It supports BGP4, BGP4+, OSPFv2, OSPFv3, IS-IS, RIPv1, RIPv2, RIPng,
+ PIM and LDP as well as the IPv6 versions of these.
+ .
+ FRR is a fork of Quagga with an open community model. The main git
+ lives on https://github.com/frrouting/frr.git
+
+Package: frr-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, frr (= ${binary:Version})
+Priority: optional
+Section: debug
+Description: BGP/OSPF/RIP/RIPng/ISIS/PIM/LDP routing daemon (debug symbols)
+ This package provides debugging symbols for all binary packages built
+ from frr source package. It's highly recommended to have this package
+ installed before reporting any FRR crashes to either FRR developers or
+ Debian package maintainers.
+
+Package: frr-doc
+Section: net
+Architecture: all
+Depends: ${misc:Depends}
+Suggests: frr
+Description: BGP/OSPF/RIP/RIPng/ISIS/PIM/LDP routing daemon (documentation)
+ This package includes info files for frr, a free software which manages
+ TCP/IP based routing protocols. It supports BGP4, BGP4+, OSPFv2, OSPFv3,
+ IS-IS, RIPv1, RIPv2, RIPng, PIM and LDP as well as the IPv6 versions of these.
+
+Package: frr-pythontools
+Section: net
+Architecture: all
+Depends: ${misc:Depends}, frr (= ${binary:Version}), python (>= 2.7), python-ipaddr
+Description: BGP/OSPF/RIP/RIPng/ISIS/PIM/LDP routing daemon (Python Tools)
+ This package includes info files for frr, a free software which manages
+ TCP/IP based routing protocols. It supports BGP4, BGP4+, OSPFv2, OSPFv3,
+ IS-IS, RIPv1, RIPv2, RIPng, PIM and LDP as well as the IPv6 versions of these.
--- /dev/null
+3.0 (quilt)
--- /dev/null
+-1~ubuntu17.10+1
# frr and as such we need to intelligently
# check to see if the frr user is in the frrvty
# group.
-if ! /usr/bin/id frr | grep &>/dev/null 'frrvty'; then
+if ! id frr | grep &>/dev/null 'frrvty'; then
usermod -a -G frrvty frr >/dev/null
fi
# backports
SRCPKG = frr
-KNOWN_BACKPORTS = debian8 debian9 ubuntu12.04 ubuntu14.04 ubuntu16.04
+KNOWN_BACKPORTS = debian8 debian9 ubuntu12.04 ubuntu14.04 ubuntu16.04 ubuntu17.10
DEBIAN_VERSION := $(shell dh_testdir && \
dpkg-parsechangelog -c1 < debian/changelog | \
sed -rn 's/^Version: ?//p')
...
-#include "filename_clippy.c"
+#include "daemon/filename_clippy.c"
DEFPY(...)
DEFPY(...)
if (dir_str[0] == 'r') {
if (negate)
- DEBUG_OFF(hello, HELLO_RECV);
+ DEBUG_OFF(hello, LDP_DEBUG_HELLO_RECV);
else
- DEBUG_ON(hello, HELLO_RECV);
+ DEBUG_ON(hello, LDP_DEBUG_HELLO_RECV);
} else {
if (negate)
- DEBUG_OFF(hello, HELLO_SEND);
+ DEBUG_OFF(hello, LDP_DEBUG_HELLO_SEND);
else
- DEBUG_ON(hello, HELLO_SEND);
+ DEBUG_ON(hello, LDP_DEBUG_HELLO_SEND);
}
} else if (strcmp(type_str, "errors") == 0) {
if (negate)
- DEBUG_OFF(errors, ERRORS);
+ DEBUG_OFF(errors, LDP_DEBUG_ERRORS);
else
- DEBUG_ON(errors, ERRORS);
+ DEBUG_ON(errors, LDP_DEBUG_ERRORS);
} else if (strcmp(type_str, "event") == 0) {
if (negate)
- DEBUG_OFF(event, EVENT);
+ DEBUG_OFF(event, LDP_DEBUG_EVENT);
else
- DEBUG_ON(event, EVENT);
+ DEBUG_ON(event, LDP_DEBUG_EVENT);
} else if (strcmp(type_str, "labels") == 0) {
if (negate)
- DEBUG_OFF(labels, LABELS);
+ DEBUG_OFF(labels, LDP_DEBUG_LABELS);
else
- DEBUG_ON(labels, LABELS);
+ DEBUG_ON(labels, LDP_DEBUG_LABELS);
} else if (strcmp(type_str, "messages") == 0) {
if (dir_str == NULL)
return (CMD_WARNING_CONFIG_FAILED);
if (dir_str[0] == 'r') {
if (negate) {
- DEBUG_OFF(msg, MSG_RECV);
- DEBUG_OFF(msg, MSG_RECV_ALL);
+ DEBUG_OFF(msg, LDP_DEBUG_MSG_RECV);
+ DEBUG_OFF(msg, LDP_DEBUG_MSG_RECV_ALL);
} else {
- DEBUG_ON(msg, MSG_RECV);
+ DEBUG_ON(msg, LDP_DEBUG_MSG_RECV);
if (all)
- DEBUG_ON(msg, MSG_RECV_ALL);
+ DEBUG_ON(msg, LDP_DEBUG_MSG_RECV_ALL);
}
} else {
if (negate) {
- DEBUG_OFF(msg, MSG_SEND);
- DEBUG_OFF(msg, MSG_SEND_ALL);
+ DEBUG_OFF(msg, LDP_DEBUG_MSG_SEND);
+ DEBUG_OFF(msg, LDP_DEBUG_MSG_SEND_ALL);
} else {
- DEBUG_ON(msg, MSG_SEND);
+ DEBUG_ON(msg, LDP_DEBUG_MSG_SEND);
if (all)
- DEBUG_ON(msg, MSG_SEND_ALL);
+ DEBUG_ON(msg, LDP_DEBUG_MSG_SEND_ALL);
}
}
} else if (strcmp(type_str, "zebra") == 0) {
if (negate)
- DEBUG_OFF(zebra, ZEBRA);
+ DEBUG_OFF(zebra, LDP_DEBUG_ZEBRA);
else
- DEBUG_ON(zebra, ZEBRA);
+ DEBUG_ON(zebra, LDP_DEBUG_ZEBRA);
}
main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug,
{
vty_out (vty, "LDP debugging status:\n");
- if (LDP_DEBUG(hello, HELLO_RECV))
+ if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV))
vty_out (vty," LDP discovery debugging is on (inbound)\n");
- if (LDP_DEBUG(hello, HELLO_SEND))
+ if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND))
vty_out (vty," LDP discovery debugging is on (outbound)\n");
- if (LDP_DEBUG(errors, ERRORS))
+ if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS))
vty_out (vty, " LDP errors debugging is on\n");
- if (LDP_DEBUG(event, EVENT))
+ if (LDP_DEBUG(event, LDP_DEBUG_EVENT))
vty_out (vty, " LDP events debugging is on\n");
- if (LDP_DEBUG(labels, LABELS))
+ if (LDP_DEBUG(labels, LDP_DEBUG_LABELS))
vty_out (vty, " LDP labels debugging is on\n");
- if (LDP_DEBUG(msg, MSG_RECV_ALL))
+ if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL))
vty_out (vty,
" LDP detailed messages debugging is on (inbound)\n");
- else if (LDP_DEBUG(msg, MSG_RECV))
+ else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV))
vty_out (vty," LDP messages debugging is on (inbound)\n");
- if (LDP_DEBUG(msg, MSG_SEND_ALL))
+ if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL))
vty_out (vty,
" LDP detailed messages debugging is on (outbound)\n");
- else if (LDP_DEBUG(msg, MSG_SEND))
+ else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND))
vty_out (vty," LDP messages debugging is on (outbound)\n");
- if (LDP_DEBUG(zebra, ZEBRA))
+ if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA))
vty_out (vty, " LDP zebra debugging is on\n");
vty_out (vty, "\n");
{
int write = 0;
- if (CONF_LDP_DEBUG(hello, HELLO_RECV)) {
+ if (CONF_LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) {
vty_out (vty,"debug mpls ldp discovery hello recv\n");
write = 1;
}
- if (CONF_LDP_DEBUG(hello, HELLO_SEND)) {
+ if (CONF_LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) {
vty_out (vty,"debug mpls ldp discovery hello sent\n");
write = 1;
}
- if (CONF_LDP_DEBUG(errors, ERRORS)) {
+ if (CONF_LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) {
vty_out (vty, "debug mpls ldp errors\n");
write = 1;
}
- if (CONF_LDP_DEBUG(event, EVENT)) {
+ if (CONF_LDP_DEBUG(event, LDP_DEBUG_EVENT)) {
vty_out (vty, "debug mpls ldp event\n");
write = 1;
}
- if (CONF_LDP_DEBUG(labels, LABELS)) {
+ if (CONF_LDP_DEBUG(labels, LDP_DEBUG_LABELS)) {
vty_out (vty, "debug mpls ldp labels\n");
write = 1;
}
- if (CONF_LDP_DEBUG(msg, MSG_RECV_ALL)) {
+ if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) {
vty_out (vty, "debug mpls ldp messages recv all\n");
write = 1;
- } else if (CONF_LDP_DEBUG(msg, MSG_RECV)) {
+ } else if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) {
vty_out (vty, "debug mpls ldp messages recv\n");
write = 1;
}
- if (CONF_LDP_DEBUG(msg, MSG_SEND_ALL)) {
+ if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) {
vty_out (vty, "debug mpls ldp messages sent all\n");
write = 1;
- } else if (CONF_LDP_DEBUG(msg, MSG_SEND)) {
+ } else if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) {
vty_out (vty, "debug mpls ldp messages sent\n");
write = 1;
}
- if (CONF_LDP_DEBUG(zebra, ZEBRA)) {
+ if (CONF_LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) {
vty_out (vty, "debug mpls ldp zebra\n");
write = 1;
}
extern struct ldp_debug conf_ldp_debug;
extern struct ldp_debug ldp_debug;
-#define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (LDP_DEBUG_ ## b))
-#define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(LDP_DEBUG_ ## b))
+#define CONF_DEBUG_ON(a, b) (conf_ldp_debug.a |= (b))
+#define CONF_DEBUG_OFF(a, b) (conf_ldp_debug.a &= ~(b))
-#define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (LDP_DEBUG_ ## b))
-#define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(LDP_DEBUG_ ## b))
+#define TERM_DEBUG_ON(a, b) (ldp_debug.a |= (b))
+#define TERM_DEBUG_OFF(a, b) (ldp_debug.a &= ~(b))
#define DEBUG_ON(a, b) \
do { \
TERM_DEBUG_OFF(a, b); \
} while (0)
-#define LDP_DEBUG(a, b) (ldp_debug.a & LDP_DEBUG_ ## b)
-#define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & LDP_DEBUG_ ## b)
+#define LDP_DEBUG(a, b) (ldp_debug.a & b)
+#define CONF_LDP_DEBUG(a, b) (conf_ldp_debug.a & b)
#define debug_hello_recv(emsg, ...) \
do { \
- if (LDP_DEBUG(hello, HELLO_RECV)) \
+ if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) \
log_debug("discovery[recv]: " emsg, __VA_ARGS__); \
} while (0)
#define debug_hello_send(emsg, ...) \
do { \
- if (LDP_DEBUG(hello, HELLO_SEND)) \
+ if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) \
log_debug("discovery[send]: " emsg, __VA_ARGS__); \
} while (0)
#define debug_err(emsg, ...) \
do { \
- if (LDP_DEBUG(errors, ERRORS)) \
+ if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) \
log_debug("error: " emsg, __VA_ARGS__); \
} while (0)
#define debug_evt(emsg, ...) \
do { \
- if (LDP_DEBUG(event, EVENT)) \
+ if (LDP_DEBUG(event, LDP_DEBUG_EVENT)) \
log_debug("event: " emsg, __VA_ARGS__); \
} while (0)
#define debug_labels(emsg, ...) \
do { \
- if (LDP_DEBUG(labels, LABELS)) \
+ if (LDP_DEBUG(labels, LDP_DEBUG_LABELS)) \
log_debug("labels: " emsg, __VA_ARGS__); \
} while (0)
#define debug_msg_recv(emsg, ...) \
do { \
- if (LDP_DEBUG(msg, MSG_RECV)) \
+ if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) \
log_debug("msg[in]: " emsg, __VA_ARGS__); \
} while (0)
#define debug_msg_send(emsg, ...) \
do { \
- if (LDP_DEBUG(msg, MSG_SEND)) \
+ if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) \
log_debug("msg[out]: " emsg, __VA_ARGS__); \
} while (0)
#define debug_kalive_recv(emsg, ...) \
do { \
- if (LDP_DEBUG(msg, MSG_RECV_ALL)) \
+ if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) \
log_debug("kalive[in]: " emsg, __VA_ARGS__); \
} while (0)
#define debug_kalive_send(emsg, ...) \
do { \
- if (LDP_DEBUG(msg, MSG_SEND_ALL)) \
+ if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) \
log_debug("kalive[out]: " emsg, __VA_ARGS__); \
} while (0)
#define debug_zebra_in(emsg, ...) \
do { \
- if (LDP_DEBUG(zebra, ZEBRA)) \
+ if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
log_debug("zebra[in]: " emsg, __VA_ARGS__); \
} while (0)
#define debug_zebra_out(emsg, ...) \
do { \
- if (LDP_DEBUG(zebra, ZEBRA)) \
+ if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) \
log_debug("zebra[out]: " emsg, __VA_ARGS__); \
} while (0)
ldpd/util.c \
# end
+ldpd/ldp_vty_cmds_clippy.c: $(CLIPPY_DEPS)
ldpd/ldp_vty_cmds.$(OBJEXT): ldpd/ldp_vty_cmds_clippy.c
noinst_HEADERS += \
void csv_remove_record(csv_t *csv, csv_record_t *rec)
{
- csv_field_t *fld, *p_fld;
+ csv_field_t *fld = NULL, *p_fld;
/* first check if rec belongs to this csv */
if (!csv_is_record_valid(csv, rec)) {
}
#ifndef VTYSH_EXTRACT_PL
-#include "plist_clippy.c"
+#include "lib/plist_clippy.c"
#endif
DEFPY (ip_prefix_list,
return 0;
}
+int ptm_lib_cleanup_msg(ptm_lib_handle_t *hdl, void *ctxt)
+{
+ ptm_lib_msg_ctxt_t *p_ctxt = ctxt;
+ csv_t *csv;
+
+ if (!p_ctxt) {
+ ERRLOG("%s: no context \n", __FUNCTION__);
+ return -1;
+ }
+
+ csv = p_ctxt->csv;
+
+ csv_clean(csv);
+ csv_free(csv);
+ free(p_ctxt);
+
+ return 0;
+}
+
int ptm_lib_complete_msg(ptm_lib_handle_t *hdl, void *ctxt, char *buf, int *len)
{
ptm_lib_msg_ctxt_t *p_ctxt = ctxt;
int ptm_lib_init_msg(ptm_lib_handle_t *, int, int, void *, void **);
int ptm_lib_append_msg(ptm_lib_handle_t *, void *, const char *, const char *);
int ptm_lib_complete_msg(ptm_lib_handle_t *, void *, char *, int *);
+int ptm_lib_cleanup_msg(ptm_lib_handle_t *, void *);
#endif
{
struct listnode *anode, *bnode;
struct ospf6_nexthop *anh, *bnh;
+ bool identical = false;
if (a && b) {
if (listcount(a->nh_list) == listcount(b->nh_list)) {
for (ALL_LIST_ELEMENTS_RO(a->nh_list, anode, anh)) {
+ identical = false;
for (ALL_LIST_ELEMENTS_RO(b->nh_list, bnode,
- bnh))
- if (!ospf6_nexthop_is_same(anh, bnh))
- return (1);
+ bnh)) {
+ if (ospf6_nexthop_is_same(anh, bnh))
+ identical = true;
+ }
+ /* Currnet List A element not found List B
+ * Non-Identical lists return */
+ if (identical == false)
+ return 1;
}
- return (0);
+ return 0;
} else
- return (1);
+ return 1;
}
/* One of the routes doesn't exist ? */
return (1);
static int ospf6_nexthop_cmp(struct ospf6_nexthop *a, struct ospf6_nexthop *b)
{
- if ((a)->ifindex == (b)->ifindex &&
- IN6_ARE_ADDR_EQUAL(&(a)->address, &(b)->address))
+ if (a->ifindex < b->ifindex)
+ return -1;
+ else if (a->ifindex > b->ifindex)
return 1;
+ else
+ return memcmp(&a->address, &b->address,
+ sizeof(struct in6_addr));
+
return 0;
}
}
#ifndef VTYSH_EXTRACT_PL
-#include "ospf_vty_clippy.c"
+#include "ospfd/ospf_vty_clippy.c"
#endif
DEFUN_NOSH (router_ospf,
{
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
- struct interface *ifp;
+ struct interface *ifp = NULL;
struct in_addr addr = {.s_addr = INADDR_ANY};
int ret;
struct ospf_if_params *params;
ospf_passive_interface_default(ospf, OSPF_IF_PASSIVE);
return CMD_SUCCESS;
}
+ if (ospf->vrf_id != VRF_UNKNOWN)
+ ifp = if_get_by_name(argv[1]->arg, ospf->vrf_id, 0);
- ifp = if_get_by_name(argv[1]->arg, ospf->vrf_id, 0);
if (ifp == NULL) {
vty_out(vty, "interface %s not found.\n",
(char *)argv[1]->arg);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
params = IF_DEF_PARAMS(ifp);
{
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 3;
- struct interface *ifp;
+ struct interface *ifp = NULL;
struct in_addr addr = {.s_addr = INADDR_ANY};
struct ospf_if_params *params;
int ret;
return CMD_SUCCESS;
}
- ifp = if_get_by_name(argv[2]->arg, ospf->vrf_id, 0);
+ if (ospf->vrf_id != VRF_UNKNOWN)
+ ifp = if_get_by_name(argv[1]->arg, ospf->vrf_id, 0);
+
if (ifp == NULL) {
vty_out(vty, "interface %s not found.\n",
(char *)argv[1]->arg);
- return CMD_WARNING;
+ return CMD_WARNING_CONFIG_FAILED;
}
params = IF_DEF_PARAMS(ifp);
"virtual-link", /* should never be used. */
"loopback"};
-static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
+static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
{
- struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
struct listnode *node;
struct interface *ifp;
struct crypt_key *ck;
struct route_node *rn = NULL;
struct ospf_if_params *params;
int write = 0;
+ struct ospf *ospf = vrf->info;
FOR_ALL_INTERFACES (vrf, ifp) {
- struct vrf *vrf = NULL;
if (memcmp(ifp->name, "VLINK", 5) == 0)
continue;
- vrf = vrf_lookup_by_id(ifp->vrf_id);
-
vty_frame(vty, "!\n");
- if (ifp->vrf_id == VRF_DEFAULT || vrf == NULL)
+ if (ifp->vrf_id == VRF_DEFAULT)
vty_frame(vty, "interface %s\n", ifp->name);
else
vty_frame(vty, "interface %s vrf %s\n",
- ifp->name, vrf->name);
+ ifp->name, vrf->name);
if (ifp->desc)
vty_out(vty, " description %s\n", ifp->desc);
/* Interface Network print. */
if (OSPF_IF_PARAM_CONFIGURED(params, type)
&& params->type != OSPF_IFTYPE_LOOPBACK) {
- if (params->type != ospf_default_iftype(ifp)) {
+ if (params->type !=
+ ospf_default_iftype(ifp)) {
vty_out(vty, " ip ospf network %s",
ospf_int_type_str
[params->type]);
if (params != IF_DEF_PARAMS(ifp))
vty_out(vty, " %s",
inet_ntoa(
- rn->p.u.prefix4));
+ rn->p.u.prefix4));
vty_out(vty, "\n");
}
}
/* OSPF interface authentication print */
if (OSPF_IF_PARAM_CONFIGURED(params, auth_type)
- && params->auth_type != OSPF_AUTH_NOTSET) {
+ && params->auth_type != OSPF_AUTH_NOTSET) {
const char *auth_str;
/* Translation tables are not that much help
- * here due to syntax
- * of the simple option */
+ * here due to syntax
+ * of the simple option */
switch (params->auth_type) {
case OSPF_AUTH_NULL:
/* Simple Authentication Password print. */
if (OSPF_IF_PARAM_CONFIGURED(params, auth_simple)
- && params->auth_simple[0] != '\0') {
+ && params->auth_simple[0] != '\0') {
vty_out(vty, " ip ospf authentication-key %s",
params->auth_simple);
if (params != IF_DEF_PARAMS(ifp))
/* Cryptographic Authentication Key print. */
if (params && params->auth_crypt) {
- for (ALL_LIST_ELEMENTS_RO(params->auth_crypt,
- node, ck)) {
+ for (ALL_LIST_ELEMENTS_RO(
+ params->auth_crypt,
+ node, ck)) {
vty_out(vty,
" ip ospf message-digest-key %d md5 %s",
- ck->key_id, ck->auth_key);
+ ck->key_id,
+ ck->auth_key);
if (params != IF_DEF_PARAMS(ifp))
vty_out(vty, " %s",
- inet_ntoa(rn->p.u.prefix4));
+ inet_ntoa(rn->p.u.prefix4));
vty_out(vty, "\n");
}
}
/* Interface Output Cost print. */
if (OSPF_IF_PARAM_CONFIGURED(params,
- output_cost_cmd)) {
+ output_cost_cmd)) {
vty_out(vty, " ip ospf cost %u",
params->output_cost_cmd);
if (params != IF_DEF_PARAMS(ifp))
/* Hello Interval print. */
if (OSPF_IF_PARAM_CONFIGURED(params, v_hello)
- && params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) {
+ && params->v_hello !=
+ OSPF_HELLO_INTERVAL_DEFAULT) {
vty_out(vty, " ip ospf hello-interval %u",
params->v_hello);
if (params != IF_DEF_PARAMS(ifp))
/* Router Dead Interval print. */
if (OSPF_IF_PARAM_CONFIGURED(params, v_wait)
- && params->v_wait
- != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) {
+ && params->v_wait
+ != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) {
vty_out(vty, " ip ospf dead-interval ");
/* fast hello ? */
if (OSPF_IF_PARAM_CONFIGURED(params,
- fast_hello))
+ fast_hello))
vty_out(vty,
"minimal hello-multiplier %d",
params->fast_hello);
else
- vty_out(vty, "%u", params->v_wait);
+ vty_out(vty, "%u",
+ params->v_wait);
if (params != IF_DEF_PARAMS(ifp))
vty_out(vty, " %s",
/* Router Priority print. */
if (OSPF_IF_PARAM_CONFIGURED(params, priority)
- && params->priority
- != OSPF_ROUTER_PRIORITY_DEFAULT) {
+ && params->priority
+ != OSPF_ROUTER_PRIORITY_DEFAULT) {
vty_out(vty, " ip ospf priority %u",
params->priority);
if (params != IF_DEF_PARAMS(ifp))
/* Retransmit Interval print. */
if (OSPF_IF_PARAM_CONFIGURED(params,
- retransmit_interval)
- && params->retransmit_interval
- != OSPF_RETRANSMIT_INTERVAL_DEFAULT) {
+ retransmit_interval)
+ && params->retransmit_interval
+ != OSPF_RETRANSMIT_INTERVAL_DEFAULT) {
vty_out(vty, " ip ospf retransmit-interval %u",
params->retransmit_interval);
if (params != IF_DEF_PARAMS(ifp))
}
/* Transmit Delay print. */
- if (OSPF_IF_PARAM_CONFIGURED(params, transmit_delay)
- && params->transmit_delay
- != OSPF_TRANSMIT_DELAY_DEFAULT) {
+ if (OSPF_IF_PARAM_CONFIGURED(params,
+ transmit_delay)
+ && params->transmit_delay
+ != OSPF_TRANSMIT_DELAY_DEFAULT) {
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));
+ inet_ntoa(rn->p.u.prefix4));
vty_out(vty, "\n");
}
/* Area print. */
if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) {
- if (ospf->instance)
+ if (ospf && ospf->instance)
vty_out(vty, " ip ospf %d",
ospf->instance);
else
size_t buflen = MAX(strlen("4294967295"),
- strlen("255.255.255.255"));
+ strlen("255.255.255.255"));
char buf[buflen];
area_id2str(buf, sizeof(buf),
¶ms->if_area,
- params->if_area_id_fmt);
+ params->if_area_id_fmt);
vty_out(vty, " area %s", buf);
if (params != IF_DEF_PARAMS(ifp))
vty_out(vty, " %s",
- inet_ntoa(rn->p.u.prefix4));
+ inet_ntoa(rn->p.u.prefix4));
vty_out(vty, "\n");
}
/* bfd print. */
- ospf_bfd_write_config(vty, params);
+ if (params->bfd_info)
+ ospf_bfd_write_config(vty, params);
/* MTU ignore print. */
if (OSPF_IF_PARAM_CONFIGURED(params, mtu_ignore)
- && params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) {
+ && params->mtu_ignore !=
+ OSPF_MTU_IGNORE_DEFAULT) {
if (params->mtu_ignore == 0)
vty_out(vty, " no ip ospf mtu-ignore");
else
vty_out(vty, " ip ospf mtu-ignore");
if (params != IF_DEF_PARAMS(ifp))
vty_out(vty, " %s",
- inet_ntoa(rn->p.u.prefix4));
+ inet_ntoa(rn->p.u.prefix4));
vty_out(vty, "\n");
}
while (1) {
if (rn == NULL)
- rn = route_top(IF_OIFS_PARAMS(ifp));
+ rn = route_top(
+ IF_OIFS_PARAMS(ifp));
else
rn = route_next(rn);
vty_endframe(vty, NULL);
}
+
return write;
}
static int config_write_interface(struct vty *vty)
{
int write = 0;
- struct ospf *ospf = NULL;
- struct listnode *node = NULL;
+ struct vrf *vrf = NULL;
- /* Traverse all ospf [vrf] instances */
- for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf))
- write += config_write_interface_one(vty, ospf);
+ /* Display all VRF aware OSPF interface configuration */
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
+ write += config_write_interface_one(vty, vrf);
+ }
return write;
}
#include "sharpd/sharp_zebra.h"
#include "sharpd/sharp_vty.h"
+#ifndef VTYSH_EXTRACT_PL
#include "sharpd/sharp_vty_clippy.c"
+#endif
extern uint32_t total_routes;
extern uint32_t installed_routes;
FILE *fp;
fp = fopen(DAEMON_VTY_DIR "/watchfrr.started", "w");
- fclose(fp);
+ if (fp)
+ fclose(fp);
#if defined HAVE_SYSTEMD
zlog_notice(
"Watchfrr: Notifying Systemd we are up and running");
#define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
u_char inFastRexmit; /* True if we're rexmits faster than usual */
- u_char configured; /* Has operator configured RA? */
+
+ /* Track if RA was configured by BGP or by the Operator or both */
+ u_char ra_configured; /* Was RA configured? */
+#define BGP_RA_CONFIGURED (1<<0) /* BGP configured RA? */
+#define VTY_RA_CONFIGURED (1<<1) /* Operator configured RA? */
+#define VTY_RA_INTERVAL_CONFIGURED (1<<2) /* Operator configured RA interval */
int
NumFastReXmitsRemain; /* Loaded first with number of fast
rexmits to do */
int ipforward(void)
{
+ int ret = 0;
FILE *fp;
int ipforwarding = 0;
char buf[10];
1 => ip forwarding enabled
2 => ip forwarding off. */
if (fgets(buf, 6, fp))
- sscanf(buf, "Ip: %d", &ipforwarding);
+ ret = sscanf(buf, "Ip: %d", &ipforwarding);
fclose(fp);
- if (ipforwarding == 1)
+ if (ret == 1 && ipforwarding == 1)
return 1;
return 0;
int ipforward_ipv6(void)
{
+ int ret = 0;
FILE *fp;
char buf[5];
int ipforwarding = 0;
return -1;
if (fgets(buf, 2, fp))
- sscanf(buf, "%d", &ipforwarding);
+ ret = sscanf(buf, "%d", &ipforwarding);
fclose(fp);
+
+ if (ret != 1)
+ return 0;
+
return ipforwarding;
}
extern void rib_addnode(struct route_node *rn, struct route_entry *re,
int process);
extern void rib_delnode(struct route_node *rn, struct route_entry *re);
-extern int rib_install_kernel(struct route_node *rn, struct route_entry *re,
- struct route_entry *old);
-extern int rib_uninstall_kernel(struct route_node *rn, struct route_entry *re);
+extern void rib_install_kernel(struct route_node *rn, struct route_entry *re,
+ struct route_entry *old);
+extern void rib_uninstall_kernel(struct route_node *rn, struct route_entry *re);
/* NOTE:
* All rib_add function will not just add prefix into RIB, but
* success failure should be handled by the caller.
*/
-extern int kernel_route_rib(struct prefix *, struct prefix *,
- struct route_entry *, struct route_entry *);
+
+enum southbound_results {
+ SOUTHBOUND_INSTALL_SUCCESS,
+ SOUTHBOUND_INSTALL_FAILURE,
+ SOUTHBOUND_DELETE_SUCCESS,
+ SOUTHBOUND_DELETE_FAILURE,
+};
+
+/*
+ * Install/delete the specified prefix p from the kernel
+ *
+ * old = NULL, new = pointer - Install new
+ * old = pointer, new = pointer - Route replace Old w/ New
+ * old = pointer, new = NULL, - Route Delete
+ *
+ * Please note not all kernels support route replace
+ * semantics so we will end up with a delete than
+ * a re-add.
+ */
+extern void kernel_route_rib(struct prefix *p, struct prefix *src_p,
+ struct route_entry *old, struct route_entry *new);
+
+/*
+ * So route install/failure may not be immediately known
+ * so let's separate it out and allow the result to
+ * be passed back up.
+ */
+extern void kernel_route_rib_pass_fail(struct prefix *p,
+ struct route_entry *re,
+ enum southbound_results res);
extern int kernel_address_add_ipv4(struct interface *, struct connected *);
extern int kernel_address_delete_ipv4(struct interface *, struct connected *);
extern int kernel_neigh_update(int, int, uint32_t, char *, int);
extern int kernel_interface_set_master(struct interface *master,
struct interface *slave);
-extern int kernel_add_lsp(zebra_lsp_t *);
-extern int kernel_upd_lsp(zebra_lsp_t *);
-extern int kernel_del_lsp(zebra_lsp_t *);
+
+extern void kernel_add_lsp(zebra_lsp_t *lsp);
+extern void kernel_upd_lsp(zebra_lsp_t *lsp);
+extern void kernel_del_lsp(zebra_lsp_t *lsp);
+
+/*
+ * Add the ability to pass back up the lsp install/delete
+ * success/failure.
+ *
+ * This functions goal is similiar to kernel_route_rib_pass_fail
+ * in that we are separating out the mechanics for
+ * the install/failure to set/unset flags and to notify
+ * as needed.
+ */
+extern void kernel_lsp_pass_fail(zebra_lsp_t *lsp,
+ enum southbound_results res);
+
extern int mpls_kernel_init(void);
extern int kernel_get_ipmr_sg_stats(struct zebra_vrf *zvrf, void *mroute);
return suc;
}
-int kernel_route_rib(struct prefix *p, struct prefix *src_p,
- struct route_entry *old, struct route_entry *new)
+void kernel_route_rib(struct prefix *p, struct prefix *src_p,
+ struct route_entry *old, struct route_entry *new)
{
+ int ret = 0;
+
assert(old || new);
- if (!old && new)
- return netlink_route_multipath(RTM_NEWROUTE, p, src_p, new, 0);
- if (old && !new)
- return netlink_route_multipath(RTM_DELROUTE, p, src_p, old, 0);
+ if (new) {
+ if (p->family == AF_INET)
+ ret = netlink_route_multipath(RTM_NEWROUTE, p, src_p,
+ new, (old) ? 1 : 0);
+ else {
+ /*
+ * So v6 route replace semantics are not in
+ * the kernel at this point as I understand it.
+ * So let's do a delete than an add.
+ * In the future once v6 route replace semantics
+ * are in we can figure out what to do here to
+ * allow working with old and new kernels.
+ *
+ * I'm also intentionally ignoring the failure case
+ * of the route delete. If that happens yeah we're
+ * screwed.
+ */
+ if (old)
+ netlink_route_multipath(RTM_DELROUTE, p,
+ src_p, old, 0);
+ ret = netlink_route_multipath(RTM_NEWROUTE, p,
+ src_p, new, 0);
+ }
+ kernel_route_rib_pass_fail(p, new,
+ (!ret) ?
+ SOUTHBOUND_INSTALL_SUCCESS :
+ SOUTHBOUND_INSTALL_FAILURE);
+ return;
+ }
- if (p->family == AF_INET)
- return netlink_route_multipath(RTM_NEWROUTE, p, src_p, new, 1);
+ if (old) {
+ ret = netlink_route_multipath(RTM_DELROUTE, p, src_p, old, 0);
- /*
- * So v6 route replace semantics are not in the kernel at this
- * point as I understand it.
- * So let's do a delete than an add.
- * In the future once v6 route replace semantics are in
- * we can figure out what to do here to allow working
- * with old and new kernels.
- *
- * I'm also intentionally ignoring the failure case
- * of the route delete. If that happens yeah we're
- * screwed.
- */
- netlink_route_multipath(RTM_DELROUTE, p, src_p, old, 0);
- return netlink_route_multipath(RTM_NEWROUTE, p, src_p, new, 0);
+ kernel_route_rib_pass_fail(p, old,
+ (!ret) ?
+ SOUTHBOUND_DELETE_SUCCESS :
+ SOUTHBOUND_DELETE_FAILURE);
+ }
}
int kernel_neigh_update(int add, int ifindex, uint32_t addr, char *lla,
_netlink_mpls_build_singlepath(routedesc, nhlfe,
&req.n, &req.r,
sizeof req, cmd);
- if (cmd == RTM_NEWROUTE) {
- SET_FLAG(nhlfe->flags,
- NHLFE_FLAG_INSTALLED);
- SET_FLAG(nexthop->flags,
- NEXTHOP_FLAG_FIB);
- } else {
- UNSET_FLAG(nhlfe->flags,
- NHLFE_FLAG_INSTALLED);
- UNSET_FLAG(nexthop->flags,
- NEXTHOP_FLAG_FIB);
- }
nexthop_num++;
break;
}
rta, rtnh, &req.r,
&src1);
rtnh = RTNH_NEXT(rtnh);
-
- if (cmd == RTM_NEWROUTE) {
- SET_FLAG(nhlfe->flags,
- NHLFE_FLAG_INSTALLED);
- SET_FLAG(nexthop->flags,
- NEXTHOP_FLAG_FIB);
- } else {
- UNSET_FLAG(nhlfe->flags,
- NHLFE_FLAG_INSTALLED);
- UNSET_FLAG(nexthop->flags,
- NEXTHOP_FLAG_FIB);
- }
}
}
return 0;
}
-int kernel_route_rib(struct prefix *p, struct prefix *src_p,
- struct route_entry *old, struct route_entry *new)
+void kernel_route_rib(struct prefix *p, struct prefix *src_p,
+ struct route_entry *old, struct route_entry *new)
{
int route = 0;
if (src_p && src_p->prefixlen) {
zlog_err("route add: IPv6 sourcedest routes unsupported!");
- return 1;
+ return;
}
if (zserv_privs.change(ZPRIVS_RAISE))
if (zserv_privs.change(ZPRIVS_LOWER))
zlog_err("Can't lower privileges");
- return route;
+ if (new) {
+ kernel_route_rib_pass_fail(p, new,
+ (!route) ?
+ SOUTHBOUND_INSTALL_SUCCESS :
+ SOUTHBOUND_INSTALL_FAILURE);
+ } else {
+ kernel_route_rib_pass_fail(p, old,
+ (!route) ?
+ SOUTHBOUND_DELETE_SUCCESS :
+ SOUTHBOUND_DELETE_FAILURE);
+ }
}
int kernel_neigh_update(int add, int ifindex, uint32_t addr, char *lla,
zif = ifp->info;
if (enable) {
+ SET_FLAG(zif->rtadv.ra_configured, BGP_RA_CONFIGURED);
ipv6_nd_suppress_ra_set(ifp, RA_ENABLE);
if (ra_interval
- && (ra_interval * 1000) < zif->rtadv.MaxRtrAdvInterval)
+ && (ra_interval * 1000) < zif->rtadv.MaxRtrAdvInterval
+ && !CHECK_FLAG(zif->rtadv.ra_configured,
+ VTY_RA_INTERVAL_CONFIGURED))
zif->rtadv.MaxRtrAdvInterval = ra_interval * 1000;
} else {
- if (!zif->rtadv.configured) {
+ UNSET_FLAG(zif->rtadv.ra_configured, BGP_RA_CONFIGURED);
+ if (!CHECK_FLAG(zif->rtadv.ra_configured,
+ VTY_RA_INTERVAL_CONFIGURED))
zif->rtadv.MaxRtrAdvInterval =
RTADV_MAX_RTR_ADV_INTERVAL;
+ if (!CHECK_FLAG(zif->rtadv.ra_configured, VTY_RA_CONFIGURED))
ipv6_nd_suppress_ra_set(ifp, RA_SUPPRESS);
- }
}
stream_failure:
return;
return CMD_WARNING_CONFIG_FAILED;
}
- ipv6_nd_suppress_ra_set(ifp, RA_SUPPRESS);
- zif->rtadv.configured = 0;
+ if (!CHECK_FLAG(zif->rtadv.ra_configured, BGP_RA_CONFIGURED))
+ ipv6_nd_suppress_ra_set(ifp, RA_SUPPRESS);
+
+ UNSET_FLAG(zif->rtadv.ra_configured, VTY_RA_CONFIGURED);
return CMD_SUCCESS;
}
}
ipv6_nd_suppress_ra_set(ifp, RA_ENABLE);
- zif->rtadv.configured = 1;
+ SET_FLAG(zif->rtadv.ra_configured, VTY_RA_CONFIGURED);
return CMD_SUCCESS;
}
if (interval % 1000)
zns->rtadv.adv_msec_if_count++;
+ SET_FLAG(zif->rtadv.ra_configured, VTY_RA_INTERVAL_CONFIGURED);
zif->rtadv.MaxRtrAdvInterval = interval;
zif->rtadv.MinRtrAdvInterval = 0.33 * interval;
zif->rtadv.AdvIntervalTimer = 0;
/* convert to milliseconds */
interval = interval * 1000;
+ SET_FLAG(zif->rtadv.ra_configured, VTY_RA_INTERVAL_CONFIGURED);
zif->rtadv.MaxRtrAdvInterval = interval;
zif->rtadv.MinRtrAdvInterval = 0.33 * interval;
zif->rtadv.AdvIntervalTimer = 0;
if (zif->rtadv.MaxRtrAdvInterval % 1000)
zns->rtadv.adv_msec_if_count--;
- zif->rtadv.MaxRtrAdvInterval = RTADV_MAX_RTR_ADV_INTERVAL;
- zif->rtadv.MinRtrAdvInterval = RTADV_MIN_RTR_ADV_INTERVAL;
+ UNSET_FLAG(zif->rtadv.ra_configured, VTY_RA_INTERVAL_CONFIGURED);
+
+ if (CHECK_FLAG(zif->rtadv.ra_configured, BGP_RA_CONFIGURED))
+ zif->rtadv.MaxRtrAdvInterval = 10000;
+ else
+ zif->rtadv.MaxRtrAdvInterval = RTADV_MAX_RTR_ADV_INTERVAL;
+
zif->rtadv.AdvIntervalTimer = zif->rtadv.MaxRtrAdvInterval;
+ zif->rtadv.MinRtrAdvInterval = RTADV_MIN_RTR_ADV_INTERVAL;
return CMD_SUCCESS;
}
if (!(if_is_loopback(ifp)
|| CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK))) {
- if (zif->rtadv.AdvSendAdvertisements)
+ if (zif->rtadv.AdvSendAdvertisements
+ && CHECK_FLAG(zif->rtadv.ra_configured, VTY_RA_CONFIGURED))
vty_out(vty, " no ipv6 nd suppress-ra\n");
}
interval = zif->rtadv.MaxRtrAdvInterval;
- if (interval % 1000)
- vty_out(vty, " ipv6 nd ra-interval msec %d\n", interval);
- else if (interval != RTADV_MAX_RTR_ADV_INTERVAL)
- vty_out(vty, " ipv6 nd ra-interval %d\n", interval / 1000);
+ if (CHECK_FLAG(zif->rtadv.ra_configured, VTY_RA_INTERVAL_CONFIGURED)) {
+ if (interval % 1000)
+ vty_out(vty, " ipv6 nd ra-interval msec %d\n",
+ interval);
+ else if (interval != RTADV_MAX_RTR_ADV_INTERVAL)
+ vty_out(vty, " ipv6 nd ra-interval %d\n",
+ interval / 1000);
+ }
if (zif->rtadv.AdvIntervalOption)
vty_out(vty, " ipv6 nd adv-interval-option\n");
*/
static void lsp_uninstall_from_kernel(struct hash_backet *backet, void *ctxt)
{
- int ret;
zebra_lsp_t *lsp;
lsp = (zebra_lsp_t *)backet->data;
- if (CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) {
- ret = kernel_del_lsp(lsp);
-
- if (!ret) {
- UNSET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
- clear_nhlfe_installed(lsp);
- }
- }
+ if (CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED))
+ kernel_del_lsp(lsp);
}
/*
*/
static wq_item_status lsp_process(struct work_queue *wq, void *data)
{
- int ret = 1;
zebra_lsp_t *lsp;
zebra_nhlfe_t *oldbest, *newbest;
char buf[BUFSIZ], buf2[BUFSIZ];
if (newbest) {
UNSET_FLAG(lsp->flags, LSP_FLAG_CHANGED);
- ret = kernel_add_lsp(lsp);
-
- if (!ret)
- SET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
- else
- clear_nhlfe_installed(lsp);
+ kernel_add_lsp(lsp);
zvrf->lsp_installs++;
}
/* Installed, may need an update and/or delete. */
if (!newbest) {
- ret = kernel_del_lsp(lsp);
-
- if (!ret) {
- UNSET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
- clear_nhlfe_installed(lsp);
- }
+ kernel_del_lsp(lsp);
zvrf->lsp_removals++;
} else if (CHECK_FLAG(lsp->flags, LSP_FLAG_CHANGED)) {
+ zebra_nhlfe_t *nhlfe;
+ struct nexthop *nexthop;
UNSET_FLAG(lsp->flags, LSP_FLAG_CHANGED);
UNSET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
- ret = kernel_upd_lsp(lsp);
+ /*
+ * Any NHLFE that was installed but is not
+ * selected now needs to have its flags updated.
+ */
+ for (nhlfe = lsp->nhlfe_list;
+ nhlfe; nhlfe = nhlfe->next) {
+ nexthop = nhlfe->nexthop;
+ if (!nexthop)
+ continue;
+
+ if (CHECK_FLAG(nhlfe->flags,
+ NHLFE_FLAG_INSTALLED) &&
+ !CHECK_FLAG(nhlfe->flags,
+ NHLFE_FLAG_SELECTED)) {
+ UNSET_FLAG(nhlfe->flags,
+ NHLFE_FLAG_INSTALLED);
+ UNSET_FLAG(nexthop->flags,
+ NEXTHOP_FLAG_FIB);
+ }
+ }
- if (!ret)
- SET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
- else
- clear_nhlfe_installed(lsp);
+ kernel_upd_lsp(lsp);
zvrf->lsp_installs++;
}
/* Public functions */
+void kernel_lsp_pass_fail(zebra_lsp_t *lsp,
+ enum southbound_results res)
+{
+ struct nexthop *nexthop;
+ zebra_nhlfe_t *nhlfe;
+
+ if (!lsp)
+ return;
+
+ switch (res) {
+ case SOUTHBOUND_INSTALL_FAILURE:
+ UNSET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
+ clear_nhlfe_installed(lsp);
+ zlog_warn("LSP Install Failure: %u", lsp->ile.in_label);
+ break;
+ case SOUTHBOUND_INSTALL_SUCCESS:
+ SET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
+ for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe->next) {
+ nexthop = nhlfe->nexthop;
+ if (!nexthop)
+ continue;
+
+ SET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED);
+ SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
+ }
+ break;
+ case SOUTHBOUND_DELETE_SUCCESS:
+ UNSET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
+ clear_nhlfe_installed(lsp);
+ break;
+ case SOUTHBOUND_DELETE_FAILURE:
+ zlog_warn("LSP Deletion Failure: %u", lsp->ile.in_label);
+ break;
+ }
+}
+
/*
* String to label conversion, labels separated by '/'.
*
/*
* Install Label Forwarding entry into the kernel.
*/
-int kernel_add_lsp(zebra_lsp_t *lsp)
+void kernel_add_lsp(zebra_lsp_t *lsp)
{
int ret;
- if (!lsp || !lsp->best_nhlfe) // unexpected
- return -1;
+ if (!lsp || !lsp->best_nhlfe) { // unexpected
+ kernel_lsp_pass_fail(lsp, SOUTHBOUND_INSTALL_FAILURE);
+ return;
+ }
ret = netlink_mpls_multipath(RTM_NEWROUTE, lsp);
- return ret;
+ kernel_lsp_pass_fail(lsp,
+ (!ret) ?
+ SOUTHBOUND_INSTALL_SUCCESS :
+ SOUTHBOUND_INSTALL_FAILURE);
}
/*
* through the metric field (before kernel-MPLS). This shouldn't be an issue
* any longer, so REPLACE can be reintroduced.
*/
-int kernel_upd_lsp(zebra_lsp_t *lsp)
+void kernel_upd_lsp(zebra_lsp_t *lsp)
{
int ret;
- zebra_nhlfe_t *nhlfe;
- struct nexthop *nexthop;
- if (!lsp || !lsp->best_nhlfe) // unexpected
- return -1;
-
- /* Any NHLFE that was installed but is not selected now needs to
- * have its flags updated.
- */
- for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe->next) {
- nexthop = nhlfe->nexthop;
- if (!nexthop)
- continue;
-
- if (CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED) &&
- !CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_SELECTED)) {
- UNSET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED);
- UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
- }
+ if (!lsp || !lsp->best_nhlfe) { // unexpected
+ kernel_lsp_pass_fail(lsp, SOUTHBOUND_INSTALL_FAILURE);
+ return;
}
ret = netlink_mpls_multipath(RTM_NEWROUTE, lsp);
- return ret;
+ kernel_lsp_pass_fail(lsp,
+ (!ret) ?
+ SOUTHBOUND_INSTALL_SUCCESS :
+ SOUTHBOUND_INSTALL_FAILURE);
}
/*
* Delete Label Forwarding entry from the kernel.
*/
-int kernel_del_lsp(zebra_lsp_t *lsp)
+void kernel_del_lsp(zebra_lsp_t *lsp)
{
int ret;
- if (!lsp) // unexpected
- return -1;
+ if (!lsp) { // unexpected
+ kernel_lsp_pass_fail(lsp,
+ SOUTHBOUND_DELETE_FAILURE);
+ return;
+ }
- if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED))
- return -1;
+ if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) {
+ kernel_lsp_pass_fail(lsp,
+ SOUTHBOUND_DELETE_FAILURE);
+ return;
+ }
ret = netlink_mpls_multipath(RTM_DELROUTE, lsp);
- return ret;
+ kernel_lsp_pass_fail(lsp,
+ (!ret) ?
+ SOUTHBOUND_DELETE_SUCCESS :
+ SOUTHBOUND_DELETE_FAILURE);
}
int mpls_kernel_init(void)
#if !defined(HAVE_NETLINK) && !defined(OPEN_BSD)
-int kernel_add_lsp(zebra_lsp_t *lsp)
+void kernel_add_lsp(zebra_lsp_t *lsp)
{
- return 0;
+ return;
}
-int kernel_upd_lsp(zebra_lsp_t *lsp)
+void kernel_upd_lsp(zebra_lsp_t *lsp)
{
- return 0;
+ return;
}
-int kernel_del_lsp(zebra_lsp_t *lsp)
+void kernel_del_lsp(zebra_lsp_t *lsp)
{
- return 0;
+ return;
}
int mpls_kernel_init(void)
{
default:
break;
}
- if (action == RTM_ADD || action == RTM_CHANGE) {
- SET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED);
- SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
- } else {
- UNSET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED);
- UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
- }
}
}
return (0);
}
-int kernel_add_lsp(zebra_lsp_t *lsp)
+void kernel_add_lsp(zebra_lsp_t *lsp)
{
int ret;
- if (!lsp || !lsp->best_nhlfe) // unexpected
- return -1;
+ if (!lsp || !lsp->best_nhlfe) { // unexpected
+ kernel_lsp_pass_fail(lsp, SOUTHBOUND_INSTALL_FAILURE);
+ return;
+ }
ret = kernel_lsp_cmd(RTM_ADD, lsp);
- return ret;
+ kernel_lsp_pass_fail(lsp,
+ (!ret) ?
+ SOUTHBOUND_INSTALL_SUCCESS :
+ SOUTHBOUND_INSTALL_FAILURE);
}
-int kernel_upd_lsp(zebra_lsp_t *lsp)
+void kernel_upd_lsp(zebra_lsp_t *lsp)
{
int ret;
- if (!lsp || !lsp->best_nhlfe) // unexpected
- return -1;
+ if (!lsp || !lsp->best_nhlfe) { // unexpected
+ kernel_lsp_pass_fail(lsp, SOUTHBOUND_INSTALL_FAILURE);
+ return;
+ }
ret = kernel_lsp_cmd(RTM_CHANGE, lsp);
- return ret;
+ kernel_lsp_pass_fail(lsp,
+ (!ret) ?
+ SOUTHBOUND_INSTALL_SUCCESS :
+ SOUTHBOUND_INSTALL_FAILURE);
+ return;
}
-int kernel_del_lsp(zebra_lsp_t *lsp)
+void kernel_del_lsp(zebra_lsp_t *lsp)
{
int ret;
- if (!lsp) // unexpected
- return -1;
+ if (!lsp) { // unexpected
+ kernel_lsp_pass_fail(lsp,
+ SOUTHBOUND_DELETE_FAILURE);
+ return;
+ }
- if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED))
- return -1;
+ if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) {
+ kernel_lsp_pass_fail(lsp,
+ SOUTHBOUND_DELETE_FAILURE);
+ return;
+ }
ret = kernel_lsp_cmd(RTM_DELETE, lsp);
- return ret;
+ kernel_lsp_pass_fail(lsp,
+ (!ret) ?
+ SOUTHBOUND_DELETE_SUCCESS :
+ SOUTHBOUND_DELETE_FAILURE);
}
static int kmpw_install(struct zebra_pw *pw)
zebra_ptm_send_message(ptm_cb.out_data, data_len);
stream_failure:
+ ptm_lib_cleanup_msg(ptm_hdl, out_ctxt);
return 0;
}
zebra_ptm_send_message(ptm_cb.out_data, data_len);
stream_failure:
+ ptm_lib_cleanup_msg(ptm_hdl, out_ctxt);
return 0;
}
return 1;
}
+void kernel_route_rib_pass_fail(struct prefix *p, struct route_entry *re,
+ enum southbound_results res)
+{
+ struct nexthop *nexthop;
+ char buf[PREFIX_STRLEN];
+
+ switch (res) {
+ case SOUTHBOUND_INSTALL_SUCCESS:
+ for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
+ if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
+ continue;
+
+ if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
+ SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
+ else
+ UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
+ }
+ zsend_route_notify_owner(re->type, re->instance, re->vrf_id,
+ p, ZAPI_ROUTE_INSTALLED);
+ break;
+ case SOUTHBOUND_INSTALL_FAILURE:
+ zsend_route_notify_owner(re->type, re->instance, re->vrf_id,
+ p, ZAPI_ROUTE_FAIL_INSTALL);
+ zlog_warn("%u:%s: Route install failed", re->vrf_id,
+ prefix2str(p, buf, sizeof(buf)));
+ break;
+ case SOUTHBOUND_DELETE_SUCCESS:
+ for (ALL_NEXTHOPS(re->nexthop, nexthop))
+ UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
+ break;
+ case SOUTHBOUND_DELETE_FAILURE:
+ zlog_warn("%u:%s: Route Deletion failure", re->vrf_id,
+ prefix2str(p, buf, sizeof(buf)));
+ break;
+ }
+}
+
/* Update flag indicates whether this is a "replace" or not. Currently, this
* is only used for IPv4.
*/
-int rib_install_kernel(struct route_node *rn, struct route_entry *re,
- struct route_entry *old)
+void rib_install_kernel(struct route_node *rn, struct route_entry *re,
+ struct route_entry *old)
{
- int ret = 0;
struct nexthop *nexthop;
rib_table_info_t *info = srcdest_rnode_table_info(rn);
struct prefix *p, *src_p;
if (info->safi != SAFI_UNICAST) {
for (ALL_NEXTHOPS(re->nexthop, nexthop))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
- return ret;
+ return;
} else {
struct nexthop *prev;
* the kernel.
*/
hook_call(rib_update, rn, "installing in kernel");
- ret = kernel_route_rib(p, src_p, old, re);
+ kernel_route_rib(p, src_p, old, re);
zvrf->installs++;
- /* If install succeeds, update FIB flag for nexthops. */
- if (!ret) {
- for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
- if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
- continue;
-
- if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
- SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
- else
- UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
- }
- zsend_route_notify_owner(re->type, re->instance, re->vrf_id,
- p, ZAPI_ROUTE_INSTALLED);
- } else
- zsend_route_notify_owner(re->type, re->instance, re->vrf_id,
- p, ZAPI_ROUTE_FAIL_INSTALL);
-
- return ret;
+ return;
}
/* Uninstall the route from kernel. */
-int rib_uninstall_kernel(struct route_node *rn, struct route_entry *re)
+void rib_uninstall_kernel(struct route_node *rn, struct route_entry *re)
{
- int ret = 0;
struct nexthop *nexthop;
rib_table_info_t *info = srcdest_rnode_table_info(rn);
struct prefix *p, *src_p;
if (info->safi != SAFI_UNICAST) {
for (ALL_NEXTHOPS(re->nexthop, nexthop))
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
- return ret;
+ return;
}
/*
* the kernel.
*/
hook_call(rib_update, rn, "uninstalling from kernel");
- ret = kernel_route_rib(p, src_p, re, NULL);
+ kernel_route_rib(p, src_p, re, NULL);
zvrf->removals++;
- for (ALL_NEXTHOPS(re->nexthop, nexthop))
- UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
-
- return ret;
+ return;
}
/* Uninstall the route from kernel. */
if (zebra_rib_labeled_unicast(new))
zebra_mpls_lsp_install(zvrf, rn, new);
- if (!RIB_SYSTEM_ROUTE(new)) {
- if (rib_install_kernel(rn, new, NULL)) {
- char buf[SRCDEST2STR_BUFFER];
- srcdest_rnode2str(rn, buf, sizeof(buf));
- zlog_warn("%u:%s: Route install failed", zvrf_id(zvrf),
- buf);
- }
- }
+ if (!RIB_SYSTEM_ROUTE(new))
+ rib_install_kernel(rn, new, NULL);
UNSET_FLAG(new->status, ROUTE_ENTRY_CHANGED);
}
if (zebra_rib_labeled_unicast(new))
zebra_mpls_lsp_install(zvrf, rn, new);
- if (rib_install_kernel(rn, new, old)) {
- char buf[SRCDEST2STR_BUFFER];
- srcdest_rnode2str(rn, buf, sizeof(buf));
- installed = 0;
- zlog_warn("%u:%s: Route install failed",
- zvrf_id(zvrf), buf);
- }
+ rib_install_kernel(rn, new, old);
}
/* If install succeeded or system route, cleanup flags
struct route_entry *re;
struct route_entry *next;
struct nexthop *nexthop;
- int ret = 0;
if (!table)
return;
for (ALL_NEXTHOPS(re->nexthop, nexthop))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
- ret = rib_uninstall_kernel(rn, re);
- if (!ret)
- rib_delnode(rn, re);
+ rib_uninstall_kernel(rn, re);
+ rib_delnode(rn, re);
}
}
}