.description = "BGP attempted to setup TCP MD5 configuration on the socket as per configuration but was unable to",
.suggestion = "Please collect log files and open Issue",
},
- {
- .code = EC_BGP_NO_SOCKOPT_MARK,
- .title = "Unable to set socket MARK option",
- .description = "BGP attempted to set the SO_MARK option for a socket and was unable to do so",
- .suggestion = "Please collect log files and open Issue",
- },
{
.code = EC_BGP_EVPN_PMSI_PRESENT,
.title = "BGP Received a EVPN NLRI with PMSI included",
EC_BGP_UPDATE_PACKET_LONG,
EC_BGP_UNRECOGNIZED_CAPABILITY,
EC_BGP_NO_TCP_MD5,
- EC_BGP_NO_SOCKOPT_MARK,
EC_BGP_EVPN_PMSI_PRESENT,
EC_BGP_EVPN_VPN_VNI,
EC_BGP_EVPN_ESI,
return ret;
}
-#define DATAPLANE_MARK 254 /* main table ID */
-
/* BGP try to connect to the peer. */
int bgp_connect(struct peer *peer)
{
sockopt_reuseaddr(peer->fd);
sockopt_reuseport(peer->fd);
- if (sockopt_mark_default(peer->fd, DATAPLANE_MARK, &bgpd_privs) < 0)
- flog_warn(EC_BGP_NO_SOCKOPT_MARK,
- "Unable to set mark on FD for peer %s, err=%s",
- peer->host, safe_strerror(errno));
#ifdef IPTOS_PREC_INTERNETCONTROL
frr_elevate_privs(&bgpd_privs) {
vty_out(vty, " ");
}
+static char *bgp_nexthop_fqdn(struct peer *peer)
+{
+ if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME))
+ return peer->hostname;
+ return NULL;
+}
+
/* called from terminal list command */
void route_vty_out(struct vty *vty, struct prefix *p,
struct bgp_path_info *path, int display, safi_t safi,
bool nexthop_othervrf = false;
vrf_id_t nexthop_vrfid = VRF_DEFAULT;
const char *nexthop_vrfname = VRF_DEFAULT_NAME;
+ char *nexthop_fqdn = bgp_nexthop_fqdn(path->peer);
if (json_paths)
json_path = json_object_new_object();
if (json_paths) {
json_nexthop_global = json_object_new_object();
- json_object_string_add(json_nexthop_global, "afi",
- (af == AF_INET) ? "ip" : "ipv6");
- json_object_string_add(json_nexthop_global,
- (af == AF_INET) ? "ip" : "ipv6",
- nexthop);
+ json_object_string_add(
+ json_nexthop_global, "afi",
+ nexthop_fqdn ? "fqdn"
+ : (af == AF_INET) ? "ip" : "ipv6");
+ json_object_string_add(
+ json_nexthop_global,
+ nexthop_fqdn ? "fqdn"
+ : (af == AF_INET) ? "ip" : "ipv6",
+ nexthop_fqdn ? nexthop_fqdn : nexthop);
json_object_boolean_true_add(json_nexthop_global,
"used");
} else
- vty_out(vty, "%s%s", nexthop, vrf_id_str);
+ vty_out(vty, "%s%s",
+ nexthop_fqdn ? nexthop_fqdn : nexthop,
+ vrf_id_str);
} else if (safi == SAFI_EVPN) {
if (json_paths) {
json_nexthop_global = json_object_new_object();
- json_object_string_add(json_nexthop_global, "ip",
- inet_ntoa(attr->nexthop));
+ json_object_string_add(
+ json_nexthop_global,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn ? nexthop_fqdn
+ : 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, "%-16s%s", inet_ntoa(attr->nexthop),
+ vty_out(vty, "%-16s%s",
+ nexthop_fqdn ?: inet_ntoa(attr->nexthop),
vrf_id_str);
} else if (safi == SAFI_FLOWSPEC) {
if (attr->nexthop.s_addr != 0) {
if (json_paths) {
json_nexthop_global = json_object_new_object();
json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntoa(attr->nexthop));
+ json_nexthop_global,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : 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, "%-16s", inet_ntoa(attr->nexthop));
+ vty_out(vty, "%-16s",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntoa(attr->nexthop));
}
}
} else if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN))
json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntoa(attr->mp_nexthop_global_in));
+ json_nexthop_global,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntoa(
+ attr->mp_nexthop_global_in));
else
json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntoa(attr->nexthop));
+ json_nexthop_global,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntoa(attr->nexthop));
json_object_string_add(json_nexthop_global, "afi",
"ipv4");
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%s%s",
- inet_ntoa(attr->nexthop), vrf_id_str);
+ nexthop_fqdn ? nexthop_fqdn
+ : inet_ntoa(attr->nexthop),
+ vrf_id_str);
vty_out(vty, "%-16s", buf);
}
}
if (json_paths) {
json_nexthop_global = json_object_new_object();
json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntop(AF_INET6, &attr->mp_nexthop_global,
- buf, BUFSIZ));
+ json_nexthop_global,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntop(AF_INET6,
+ &attr->mp_nexthop_global,
+ buf, BUFSIZ));
json_object_string_add(json_nexthop_global, "afi",
"ipv6");
json_object_string_add(json_nexthop_global, "scope",
|| (path->peer->conf_if)) {
json_nexthop_ll = json_object_new_object();
json_object_string_add(
- json_nexthop_ll, "ip",
- inet_ntop(AF_INET6,
- &attr->mp_nexthop_local, buf,
- BUFSIZ));
+ json_nexthop_ll,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntop(
+ AF_INET6,
+ &attr->mp_nexthop_local,
+ buf, BUFSIZ));
json_object_string_add(json_nexthop_ll, "afi",
"ipv6");
json_object_string_add(json_nexthop_ll, "scope",
} else {
len = vty_out(
vty, "%s%s",
- inet_ntop(
- AF_INET6,
- &attr->mp_nexthop_local,
- buf, BUFSIZ),
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntop(
+ AF_INET6,
+ &attr->mp_nexthop_local,
+ buf, BUFSIZ),
vrf_id_str);
len = 16 - len;
} else {
len = vty_out(
vty, "%s%s",
- inet_ntop(AF_INET6,
- &attr->mp_nexthop_global, buf,
- BUFSIZ),
- vrf_id_str);
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntop(
+ AF_INET6,
+ &attr->mp_nexthop_global,
+ buf, BUFSIZ),
+ vrf_id_str);
len = 16 - len;
if (len < 1)
vty_out(vty, "%s", str);
else
json_object_string_add(json_overlay, "esi", str);
-
+
XFREE(MTYPE_TMP, str);
if (is_evpn_prefix_ipaddr_v4((struct prefix_evpn *)p)) {
bool nexthop_self =
CHECK_FLAG(path->flags, BGP_PATH_ANNC_NH_SELF) ? true : false;
int i;
+ char *nexthop_fqdn = bgp_nexthop_fqdn(path->peer);
if (json_paths) {
json_path = json_object_new_object();
|| safi == SAFI_EVPN) {
if (json_paths)
json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntoa(
- attr->mp_nexthop_global_in));
+ json_nexthop_global,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntoa(
+ attr->mp_nexthop_global_in));
else
vty_out(vty, " %s",
- inet_ntoa(
- attr->mp_nexthop_global_in));
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntoa(
+ attr->mp_nexthop_global_in));
} else {
if (json_paths)
json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntoa(attr->nexthop));
+ json_nexthop_global,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntoa(
+ attr->nexthop));
else
vty_out(vty, " %s",
- inet_ntoa(attr->nexthop));
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntoa(
+ attr->nexthop));
}
if (json_paths)
} else {
if (json_paths) {
json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntop(AF_INET6,
- &attr->mp_nexthop_global, buf,
- INET6_ADDRSTRLEN));
+ json_nexthop_global,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : 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");
} else {
vty_out(vty, " %s",
- inet_ntop(AF_INET6,
- &attr->mp_nexthop_global, buf,
- INET6_ADDRSTRLEN));
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : inet_ntop(
+ AF_INET6,
+ &attr->mp_nexthop_global,
+ buf,
+ INET6_ADDRSTRLEN));
}
}
if (json_paths) {
json_nexthop_ll = json_object_new_object();
json_object_string_add(
- json_nexthop_ll, "ip",
- inet_ntop(AF_INET6,
- &attr->mp_nexthop_local, buf,
- INET6_ADDRSTRLEN));
+ json_nexthop_ll,
+ nexthop_fqdn ? "fqdn" : "ip",
+ nexthop_fqdn
+ ? nexthop_fqdn
+ : 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",
prefix->prefixlen, &result);
// Print Debug output
- prefix_string =
- inet_ntop(prefix->family, &prefix->u.prefix, buf, BUFSIZ);
+ prefix_string = prefix2str(prefix, buf, sizeof(buf));
switch (result) {
case BGP_PFXV_STATE_VALID:
RPKI_DEBUG(
- "Validating Prefix %s/%hhu from asn %u Result: VALID",
- prefix_string, prefix->prefixlen, as_number);
+ "Validating Prefix %s from asn %u Result: VALID",
+ prefix_string, as_number);
return RPKI_VALID;
case BGP_PFXV_STATE_NOT_FOUND:
RPKI_DEBUG(
- "Validating Prefix %s/%hhu from asn %u Result: NOT FOUND",
- prefix_string, prefix->prefixlen, as_number);
+ "Validating Prefix %s from asn %u Result: NOT FOUND",
+ prefix_string, as_number);
return RPKI_NOTFOUND;
case BGP_PFXV_STATE_INVALID:
RPKI_DEBUG(
- "Validating Prefix %s/%hhu from asn %u Result: INVALID",
- prefix_string, prefix->prefixlen, as_number);
+ "Validating Prefix %s from asn %u Result: INVALID",
+ prefix_string, as_number);
return RPKI_INVALID;
default:
RPKI_DEBUG(
- "Validating Prefix %s/%hhu from asn %u Result: CANNOT VALIDATE",
- prefix_string, prefix->prefixlen, as_number);
+ "Validating Prefix %s from asn %u Result: CANNOT VALIDATE",
+ prefix_string, as_number);
break;
}
return 0;
if (p->password)
vty_out(vty, "Peer Authentication Enabled\n");
- vty_out(vty, "Read thread: %s Write thread: %s\n",
+ vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n",
p->t_read ? "on" : "off",
CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)
? "on"
- : "off");
+ : "off", p->fd);
}
if (p->notify.code == BGP_NOTIFY_OPEN_ERR
SET_FLAG(peer->flags, PEER_FLAG_DELETE);
+ bgp_bfd_deregister_peer(peer);
+
/* If this peer belongs to peer group, clear up the
relationship. */
if (peer->group) {
+------------------------------------+------+------+------+---------+------------+
| _find_lt, _find_gteq | -- | -- | -- | yes | yes |
+------------------------------------+------+------+------+---------+------------+
-| use with for_each() macros | yes | yes | yes | yes | yes |
+| use with frr_each() macros | yes | yes | yes | yes | yes |
+------------------------------------+------+------+------+---------+------------+
The following iteration macros work across all data structures:
-.. c:function:: for_each(Z, &head, item)
+.. c:function:: frr_each(Z, &head, item)
Equivalent to:
Note that this will fail if the list is modified while being iterated
over.
-.. c:function:: for_each_safe(Z, &head, item)
+.. c:function:: frr_each_safe(Z, &head, item)
Same as the previous, but the next element is pre-loaded into a "hidden"
variable (named ``Z_safe``.) Equivalent to:
tables is resized while iterating. This will cause items to be
skipped or iterated over twice.
-.. c:function:: for_each_from(Z, &head, item, from)
+.. c:function:: frr_each_from(Z, &head, item, from)
Iterates over the list, starting at item ``from``. This variant is "safe"
as in the previous macro. Equivalent to:
itemtype *prev = NULL, *item;
- for_each_safe(Z, head, item) {
+ frr_each_safe(Z, head, item) {
if (something) {
Z_add_after(head, prev, item);
break;
struct item *i;
pthread_rwlock_rdlock(&itemhead_rwlock);
- for_each(itemlist, &itemhead, i) {
+ frr_each(itemlist, &itemhead, i) {
/* lock must remain held while iterating */
...
}
pthread_rwlock_unlock(&itemhead_rwlock);
/* i might still be visible for another thread doing an
- * for_each() (but won't be returned by another pop()) */
+ * frr_each() (but won't be returned by another pop()) */
...
pthread_rwlock_wrlock(&itemhead_rwlock);
(view) show [ip] bgp l2vpn evpn all overlay
...
+.. _common-show-commands:
+
+.. index:: show thread cpu
+.. clicmd:: show thread cpu [r|w|t|e|x]
+
+ This command displays system run statistics for all the different event
+ types. If no options is specified all different run types are displayed
+ together. Additionally you can ask to look at (r)ead, (w)rite, (t)imer,
+ (e)vent and e(x)ecute thread event types.
+
+.. index:: show thread poll
+.. clicmd:: show thread poll
+
+ This command displays FRR's poll data. It allows a glimpse into how
+ we are setting each individual fd for the poll command at that point
+ in time.
.. _common-invocation-options:
After installing FRR, some basic configuration must be completed before it is
ready to use.
-Daemons File
-------------
+Daemons Configuration File
+--------------------------
After a fresh install, starting FRR will do nothing. This is because daemons
must be explicitly enabled by editing a file in your configuration directory.
This file is usually located at :file:`/etc/frr/daemons` and determines which
bfdd=no
fabricd=no
-To enable a particular daemon, simply change the corresponding 'no' to 'yes'.
-Subsequent service restarts should start the daemon.
-
-Daemons Configuration File
---------------------------
-There is another file that controls the default options passed to daemons when
-starting FRR as a service. This file is located in your configuration
-directory, usually at :file:`/etc/frr/daemons`.
-
-This file has several parts. Here is an example:
-
-::
-
#
# If this option is set the /etc/init.d/frr script automatically loads
# the config via "vtysh -b" when the servers are started.
bfdd_options=" --daemon -A 127.0.0.1"
fabricd_options=" --daemon -A 127.0.0.1"
+ #MAX_FDS=1024
# The list of daemons to watch is automatically generated by the init script.
#watchfrr_options=""
Breaking this file down:
+::
+
+ bgpd=yes
+
+To enable a particular daemon, simply change the corresponding 'no' to 'yes'.
+Subsequent service restarts should start the daemon.
+
::
vtysh_enable=yes
configuration when starting the daemons. This is useful for a variety of
reasons touched on in the VTYSH documentation and should generally be enabled.
+::
+
+ MAX_FDS=1024
+
+This allows the operator to control the number of open file descriptors
+each daemon is allowed to start with. The current assumed value on
+most operating systems is 1024. If the operator plans to run bgp with
+several thousands of peers than this is where we would modify FRR to
+allow this to happen.
+
::
zebra_options=" -s 90000000 --daemon -A 127.0.0.1"
Runs in batch mode. *zebra* parses configuration file and terminates
immediately.
-.. option:: -k, --keep_kernel
+.. option:: -K TIME, --graceful_restart TIME
- When zebra starts up, don't delete old self inserted routes.
+ If this option is specified, the graceful restart time is TIME seconds.
+ Zebra, when started, will read in routes. Those routes that Zebra
+ identifies that it was the originator of will be swept in TIME seconds.
+ If no time is specified then we will sweep those routes immediately.
.. option:: -r, --retain
return nustr;
}
-bool begins_with(const char *str, const char *prefix)
+bool frrstr_startswith(const char *str, const char *prefix)
{
if (!str || !prefix)
return false;
return strncmp(str, prefix, lenprefix) == 0;
}
+bool frrstr_endswith(const char *str, const char *suffix)
+{
+ if (!str || !suffix)
+ return false;
+
+ size_t lenstr = strlen(str);
+ size_t lensuffix = strlen(suffix);
+
+ if (lensuffix > lenstr)
+ return false;
+
+ return strncmp(&str[lenstr - lensuffix], suffix, lensuffix) == 0;
+}
+
int all_digit(const char *str)
{
for (; *str != '\0'; str++)
* the replacement on 'str'. This must be freed by the caller.
*/
char *frrstr_replace(const char *str, const char *find, const char *replace);
+
/*
* Prefix match for string.
*
* prefix to look for
*
* Returns:
- * true str starts with prefix, false otherwise
+ * true if str starts with prefix, false otherwise
+ */
+bool frrstr_startswith(const char *str, const char *prefix);
+
+/*
+ * Suffix match for string.
+ *
+ * str
+ * string to check for suffix match
+ *
+ * suffix
+ * suffix to look for
+ *
+ * Returns:
+ * true if str ends with suffix, false otherwise
*/
-bool begins_with(const char *str, const char *prefix);
+bool frrstr_endswith(const char *str, const char *suffix);
/*
* Check the string only contains digit characters.
return 0;
}
-int sockopt_mark_default(int sock, int mark, struct zebra_privs_t *cap)
-{
-#ifdef SO_MARK
- int ret;
-
- frr_elevate_privs(cap) {
- ret = setsockopt(sock, SOL_SOCKET, SO_MARK, &mark,
- sizeof(mark));
- }
- return ret;
-#else
- return 0;
-#endif
-}
-
int sockopt_minttl(int family, int sock, int minttl)
{
#ifdef IP_MINTTL
extern int sockopt_ttl(int family, int sock, int ttl);
extern int sockopt_minttl(int family, int sock, int minttl);
extern int sockopt_cork(int sock, int onoff);
-extern int sockopt_mark_default(int sock, int mark, struct zebra_privs_t *);
extern int sockunion_socket(const union sockunion *su);
extern const char *inet_sutop(const union sockunion *su, char *str);
extern enum connect_result sockunion_connect(int fd, const union sockunion *su,
SHOW_STR
"Thread information\n"
"Thread CPU usage\n"
- "Display filter (rwtexb)\n")
+ "Display filter (rwtex)\n")
{
uint8_t filter = (uint8_t)-1U;
int idx = 0;
vty_out(vty, "\nShowing poll FD's for %s\n", name);
vty_out(vty, "----------------------%s\n", underline);
- vty_out(vty, "Count: %u\n", (uint32_t)m->handler.pfdcount);
+ vty_out(vty, "Count: %u/%d\n", (uint32_t)m->handler.pfdcount,
+ m->fd_limit);
for (i = 0; i < m->handler.pfdcount; i++)
vty_out(vty, "\t%6d fd:%6d events:%2d revents:%2d\n", i,
m->handler.pfds[i].fd,
--- /dev/null
+router bgp 65000
+ neighbor 192.168.255.2 remote-as 65001
+ address-family ipv4 unicast
+ redistribute connected
--- /dev/null
+!
+interface lo
+ ip address 172.16.255.254/32
+!
+interface r1-eth0
+ ip address 192.168.255.1/24
+!
+ip forwarding
+!
--- /dev/null
+router bgp 65001
+ bgp default show-hostname
+ neighbor 192.168.255.1 remote-as 65000
+ address-family ipv4 unicast
+ redistribute connected
--- /dev/null
+!
+interface lo
+ ip address 172.16.255.253/32
+!
+interface r2-eth0
+ ip address 192.168.255.2/24
+!
+ip forwarding
+!
--- /dev/null
+#!/usr/bin/env python
+
+#
+# test_bgp_show_ip_bgp_fqdn.py
+# Part of NetDEF Topology Tests
+#
+# Copyright (c) 2019 by
+# Network Device Education Foundation, Inc. ("NetDEF")
+#
+# Permission to use, copy, modify, and/or distribute this software
+# for any purpose with or without fee is hereby granted, provided
+# that the above copyright notice and this permission notice appear
+# in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+#
+
+"""
+test_bgp_show_ip_bgp_fqdn.py:
+Test if FQND is visible in `show [ip] bgp` output if
+`bgp default show-hostname` is toggled.
+"""
+
+import os
+import sys
+import json
+import time
+import pytest
+
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, '../'))
+
+# pylint: disable=C0413
+from lib import topotest
+from lib.topogen import Topogen, TopoRouter, get_topogen
+from lib.topolog import logger
+from mininet.topo import Topo
+
+class TemplateTopo(Topo):
+ def build(self, *_args, **_opts):
+ tgen = get_topogen(self)
+
+ for routern in range(1, 3):
+ tgen.add_router('r{}'.format(routern))
+
+ switch = tgen.add_switch('s1')
+ switch.add_link(tgen.gears['r1'])
+ switch.add_link(tgen.gears['r2'])
+
+def setup_module(mod):
+ tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen.start_topology()
+
+ router_list = tgen.routers()
+
+ for i, (rname, router) in enumerate(router_list.iteritems(), 1):
+ router.load_config(
+ TopoRouter.RD_ZEBRA,
+ os.path.join(CWD, '{}/zebra.conf'.format(rname))
+ )
+ router.load_config(
+ TopoRouter.RD_BGP,
+ os.path.join(CWD, '{}/bgpd.conf'.format(rname))
+ )
+
+ tgen.start_router()
+
+def teardown_module(mod):
+ tgen = get_topogen()
+ tgen.stop_topology()
+
+def test_bgp_maximum_prefix_invalid():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ def _bgp_converge(router, neighbor):
+ cmd = "show ip bgp neighbor {0} json".format(neighbor)
+ while True:
+ output = json.loads(tgen.gears[router].vtysh_cmd(cmd))
+ if output[neighbor]['bgpState'] == 'Established':
+ time.sleep(3)
+ return True
+
+ def _bgp_show_nexthop(router, prefix):
+ cmd = "show ip bgp json"
+ output = json.loads(tgen.gears[router].vtysh_cmd(cmd))
+ for nh in output['routes'][prefix][0]['nexthops']:
+ if 'fqdn' in nh:
+ return 'fqdn'
+ return 'ip'
+
+ if _bgp_converge('r2', '192.168.255.1'):
+ assert _bgp_show_nexthop('r2', '172.16.255.254/32') == 'fqdn'
+
+ if _bgp_converge('r1', '192.168.255.2'):
+ assert _bgp_show_nexthop('r1', '172.16.255.253/32') == 'ip'
+
+if __name__ == '__main__':
+ args = ["-s"] + sys.argv[1:]
+ sys.exit(pytest.main(args))
fabricd_options="-A 127.0.0.1"
vrrpd_options=" -A 127.0.0.1"
+#
+# This is the maximum number of FD's that will be available.
+# Upon startup this is read by the control files and ulimit
+# is called. Uncomment and use a reasonable value for your
+# setup if you are expecting a large number of peers in
+# say BGP.
+#MAX_FDS=1024
+
# The list of daemons to watch is automatically generated by the init script.
#watchfrr_options=""
dir = opendir(vtydir);
if (dir) {
while ((file = readdir(dir)) != NULL) {
- if (begins_with(file->d_name, "ospfd-")
+ if (frrstr_startswith(file->d_name, "ospfd-")
&& ends_with(file->d_name, ".vty")) {
if (n == MAXIMUM_INSTANCES) {
fprintf(stderr,
/* Allow non-quagga entities to delete quagga routes */
int allow_delete = 0;
-/* Don't delete kernel route. */
-int keep_kernel_mode = 0;
+int graceful_restart;
bool v6_rr_semantics = false;
{"label_socket", no_argument, NULL, 'l'},
{"retain", no_argument, NULL, 'r'},
{"vrfdefaultname", required_argument, NULL, 'o'},
+ {"graceful_restart", required_argument, NULL, 'K'},
#ifdef HAVE_NETLINK
{"vrfwnetns", no_argument, NULL, 'n'},
{"nl-bufsize", required_argument, NULL, 's'},
char *netlink_fuzzing = NULL;
#endif /* HANDLE_NETLINK_FUZZING */
+ graceful_restart = 0;
vrf_configure_backend(VRF_BACKEND_VRF_LITE);
logicalrouter_configure_backend(LOGICALROUTER_BACKEND_NETNS);
frr_preinit(&zebra_di, argc, argv);
frr_opt_add(
- "bakz:e:l:o:r"
+ "baz:e:l:o:rK:"
#ifdef HAVE_NETLINK
"s:n"
#endif
#endif /* HANDLE_NETLINK_FUZZING */
,
longopts,
- " -b, --batch Runs in batch mode\n"
- " -a, --allow_delete Allow other processes to delete zebra routes\n"
- " -z, --socket Set path of zebra socket\n"
- " -e, --ecmp Specify ECMP to use.\n"
- " -l, --label_socket Socket to external label manager\n"
- " -k, --keep_kernel Don't delete old routes which were installed by zebra.\n"
- " -r, --retain When program terminates, retain added route by zebra.\n"
- " -o, --vrfdefaultname Set default VRF name.\n"
+ " -b, --batch Runs in batch mode\n"
+ " -a, --allow_delete Allow other processes to delete zebra routes\n"
+ " -z, --socket Set path of zebra socket\n"
+ " -e, --ecmp Specify ECMP to use.\n"
+ " -l, --label_socket Socket to external label manager\n"
+ " -r, --retain When program terminates, retain added route by zebra.\n"
+ " -o, --vrfdefaultname Set default VRF name.\n"
+ " -K, --graceful_restart Graceful restart at the kernel level, timer in seconds for expiration\n"
#ifdef HAVE_NETLINK
- " -n, --vrfwnetns Use NetNS as VRF backend\n"
- " -s, --nl-bufsize Set netlink receive buffer size\n"
- " --v6-rr-semantics Use v6 RR semantics\n"
+ " -n, --vrfwnetns Use NetNS as VRF backend\n"
+ " -s, --nl-bufsize Set netlink receive buffer size\n"
+ " --v6-rr-semantics Use v6 RR semantics\n"
#endif /* HAVE_NETLINK */
#if defined(HANDLE_ZAPI_FUZZING)
- " -c <file> Bypass normal startup and use this file for testing of zapi\n"
+ " -c <file> Bypass normal startup and use this file for testing of zapi\n"
#endif /* HANDLE_ZAPI_FUZZING */
#if defined(HANDLE_NETLINK_FUZZING)
- " -w <file> Bypass normal startup and use this file for testing of netlink input\n"
+ " -w <file> Bypass normal startup and use this file for testing of netlink input\n"
#endif /* HANDLE_NETLINK_FUZZING */
);
case 'a':
allow_delete = 1;
break;
- case 'k':
- keep_kernel_mode = 1;
- break;
case 'e':
zrouter.multipath_num = atoi(optarg);
if (zrouter.multipath_num > MULTIPATH_NUM
case 'r':
retain_mode = 1;
break;
+ case 'K':
+ graceful_restart = atoi(optarg);
+ break;
#ifdef HAVE_NETLINK
case 's':
nl_rcvbufsize = atoi(optarg);
* will be equal to the current getpid(). To know about such routes,
* we have to have route_read() called before.
*/
- if (!keep_kernel_mode)
- rib_sweep_route();
+ zrouter.startup_time = monotime(NULL);
+ thread_add_timer(zrouter.master, rib_sweep_route,
+ NULL, graceful_restart, NULL);
/* Needed for BSD routing socket. */
pid = getpid();
extern void rib_update(vrf_id_t vrf_id, rib_update_event_t event);
extern void rib_update_table(struct route_table *table,
rib_update_event_t event);
-extern void rib_sweep_route(void);
+extern int rib_sweep_route(struct thread *t);
extern void rib_sweep_table(struct route_table *table);
extern void rib_close_table(struct route_table *table);
extern void rib_init(void);
for (rn = route_top(table); rn; rn = srcdest_route_next(rn)) {
RNODE_FOREACH_RE_SAFE (rn, re, next) {
+
if (IS_ZEBRA_DEBUG_RIB)
route_entry_dump(&rn->p, NULL, re);
if (!CHECK_FLAG(re->flags, ZEBRA_FLAG_SELFROUTE))
continue;
+ /*
+ * If routes are older than startup_time then
+ * we know we read them in from the kernel.
+ * As such we can safely remove them.
+ */
+ if (zrouter.startup_time < re->uptime)
+ continue;
+
/*
* So we are starting up and have received
* routes from the kernel that we have installed
}
/* Sweep all RIB tables. */
-void rib_sweep_route(void)
+int rib_sweep_route(struct thread *t)
{
struct vrf *vrf;
struct zebra_vrf *zvrf;
}
zebra_router_sweep_route();
+
+ return 0;
}
/* Remove specific by protocol routes from 'table'. */
struct zebra_vrf *evpn_vrf;
uint32_t multipath_num;
+
+ /*
+ * Time for when we sweep the rib from old routes
+ */
+ time_t startup_time;
};
+#define GRACEFUL_RESTART_TIME 60
+
extern struct zebra_router zrouter;
extern void zebra_router_init(void);