summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--babeld/babel_interface.h2
-rw-r--r--babeld/babel_main.c2
-rw-r--r--bgpd/bgp_attr.c4
-rw-r--r--bgpd/bgp_damp.c2
-rw-r--r--bgpd/bgp_debug.c4
-rw-r--r--bgpd/bgp_errors.c18
-rw-r--r--bgpd/bgp_evpn.c4
-rw-r--r--bgpd/bgp_evpn_vty.c2
-rw-r--r--bgpd/bgp_fsm.c2
-rw-r--r--bgpd/bgp_packet.c2
-rw-r--r--bgpd/bgp_route.c35
-rw-r--r--bgpd/bgp_vty.c16
-rw-r--r--debianpkg/frr.logrotate2
-rw-r--r--debianpkg/frr.manpages1
-rw-r--r--debianpkg/tests/daemons2
-rw-r--r--doc/manpages/common-options.rst2
-rw-r--r--doc/manpages/zebra.rst2
-rw-r--r--eigrpd/eigrp_const.h4
-rw-r--r--eigrpd/eigrp_dump.c2
-rw-r--r--eigrpd/eigrp_fsm.c4
-rw-r--r--eigrpd/eigrp_vty.c74
-rw-r--r--eigrpd/subdir.am3
-rw-r--r--isisd/isis_spf.c2
-rw-r--r--ldpd/ldp_vty_cmds.c2
-rw-r--r--ldpd/util.c2
-rw-r--r--lib/bfd.c2
-rw-r--r--lib/command.c4
-rw-r--r--lib/command.h2
-rw-r--r--lib/command_lex.l4
-rw-r--r--lib/filter.c4
-rw-r--r--lib/lib_errors.c4
-rw-r--r--lib/mpls.h2
-rw-r--r--lib/sockunion.c2
-rw-r--r--m4/ax_sys_weak_alias.m42
-rw-r--r--ospf6d/ospf6_abr.c2
-rw-r--r--ospf6d/ospf6_area.c4
-rw-r--r--ospfd/ospf_ism.c2
-rw-r--r--ospfd/ospf_nsm.c2
-rw-r--r--ospfd/ospf_opaque.c2
-rw-r--r--ospfd/ospf_packet.c2
-rw-r--r--ospfd/ospf_ri.c2
-rw-r--r--ospfd/ospf_te.c2
-rw-r--r--ospfd/ospfd.c2
-rw-r--r--pbrd/pbr_zebra.c4
-rw-r--r--pimd/pim_instance.c2
-rw-r--r--pimd/pim_msdp.c2
-rw-r--r--pimd/pim_upstream.c2
-rw-r--r--ripd/ripd.c4
-rw-r--r--ripngd/ripngd.c4
-rw-r--r--staticd/static_vrf.c2
-rw-r--r--staticd/static_vty.c12
-rw-r--r--tools/etc/frr/daemons1
-rw-r--r--tools/etc/frr/daemons.conf1
-rw-r--r--tools/etc/rsyslog.d/45-frr.conf2
-rwxr-xr-xtools/frr.in2
-rw-r--r--tools/start-stop-daemon.c2
-rwxr-xr-xvtysh/extract.pl.in2
-rw-r--r--vtysh/vtysh.c4
-rw-r--r--vtysh/vtysh.h1
-rw-r--r--vtysh/vtysh_config.c88
-rw-r--r--zebra/if_sysctl.c4
-rw-r--r--zebra/irdp_packet.c4
-rw-r--r--zebra/kernel_socket.c2
-rw-r--r--zebra/main.c6
-rw-r--r--zebra/rt_socket.c11
-rw-r--r--zebra/rtadv.c63
-rw-r--r--zebra/subdir.am2
-rw-r--r--zebra/zapi_msg.c21
-rw-r--r--zebra/zebra_ns.c152
-rw-r--r--zebra/zebra_ns.h37
-rw-r--r--zebra/zebra_pbr.c232
-rw-r--r--zebra/zebra_pbr.h65
-rw-r--r--zebra/zebra_rib.c5
-rw-r--r--zebra/zebra_rnh.c13
-rw-r--r--zebra/zebra_router.c189
-rw-r--r--zebra/zebra_router.h84
-rw-r--r--zebra/zebra_vrf.c31
-rw-r--r--zebra/zebra_vty.c9
-rw-r--r--zebra/zebra_vxlan.c69
79 files changed, 728 insertions, 647 deletions
diff --git a/babeld/babel_interface.h b/babeld/babel_interface.h
index 17d9bfb936..d9e2745827 100644
--- a/babeld/babel_interface.h
+++ b/babeld/babel_interface.h
@@ -32,7 +32,7 @@ THE SOFTWARE.
#define CONFIG_NO 1
#define CONFIG_YES 2
-/* babeld interface informations */
+/* babeld interface information */
struct babel_interface {
unsigned short flags; /* see below */
unsigned short cost;
diff --git a/babeld/babel_main.c b/babeld/babel_main.c
index d02d86f77b..f26d3a8872 100644
--- a/babeld/babel_main.c
+++ b/babeld/babel_main.c
@@ -385,7 +385,7 @@ show_babel_main_configuration (struct vty *vty)
vty_out (vty,
"state file = %s\n"
"configuration file = %s\n"
- "protocol informations:\n"
+ "protocol information:\n"
" multicast address = %s\n"
" port = %d\n"
"vty address = %s\n"
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 9523cca87e..65a46bb965 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1697,7 +1697,7 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
* - for consistency in rx processing
*
* The following comment is to signal GCC this intention
- * and supress the warning
+ * and suppress the warning
*/
/* FALLTHRU */
case BGP_ATTR_NHLEN_IPV4:
@@ -2624,7 +2624,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
return ret;
}
- /* If hard error occured immediately return to the caller. */
+ /* If hard error occurred immediately return to the caller. */
if (ret == BGP_ATTR_PARSE_ERROR) {
flog_warn(EC_BGP_ATTRIBUTE_PARSE_ERROR,
"%s: Attribute %s, parse error", peer->host,
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index 86cee39a62..cf085e46fb 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -689,7 +689,7 @@ int bgp_show_dampening_parameters(struct vty *vty, afi_t afi, safi_t safi)
vty_out(vty, "Suppress penalty: %d\n", damp->suppress_value);
vty_out(vty, "Max suppress time: %lld min\n",
(long long)damp->max_suppress_time / 60);
- vty_out(vty, "Max supress penalty: %u\n", damp->ceiling);
+ vty_out(vty, "Max suppress penalty: %u\n", damp->ceiling);
vty_out(vty, "\n");
} else
vty_out(vty, "dampening not enabled for %s\n",
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index f49f80b5d9..c7fad29cb0 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -1380,7 +1380,7 @@ DEFUN (no_debug_bgp_update_direct_peer,
DEFPY (debug_bgp_update_prefix_afi_safi,
debug_bgp_update_prefix_afi_safi_cmd,
- "debug bgp updates prefix l2vpn$afi evpn$safi type <macip mac <M:A:C|M:A:C/M> [ip <A.B.C.D|X:X::X:X>]|multicast ip <A.B.C.D|X:X::X:X>|prefix ip <A.B.C.D/M|X:X::X:X/M>>",
+ "debug bgp updates prefix l2vpn$afi evpn$safi type <macip mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|multicast ip <A.B.C.D|X:X::X:X>|prefix ip <A.B.C.D/M|X:X::X:X/M>>",
DEBUG_STR
BGP_STR
"BGP updates\n"
@@ -1443,7 +1443,7 @@ DEFPY (debug_bgp_update_prefix_afi_safi,
DEFPY (no_debug_bgp_update_prefix_afi_safi,
no_debug_bgp_update_prefix_afi_safi_cmd,
- "no debug bgp updates prefix l2vpn$afi evpn$safi type <macip mac <M:A:C|M:A:C/M> [ip <A.B.C.D|X:X::X:X>]|multicast ip <A.B.C.D|X:X::X:X>|prefix ip <A.B.C.D/M|X:X::X:X/M>>",
+ "no debug bgp updates prefix l2vpn$afi evpn$safi type <macip mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|multicast ip <A.B.C.D|X:X::X:X>|prefix ip <A.B.C.D/M|X:X::X:X/M>>",
NO_STR
DEBUG_STR
BGP_STR
diff --git a/bgpd/bgp_errors.c b/bgpd/bgp_errors.c
index 7cebd0e484..753ee6baf1 100644
--- a/bgpd/bgp_errors.c
+++ b/bgpd/bgp_errors.c
@@ -171,7 +171,7 @@ static struct log_ref ferr_bgp_warn[] = {
},
{
.code = EC_BGP_CAPABILITY_VENDOR,
- .title = "BGP has recieved capability data specific to a particular vendor",
+ .title = "BGP has received capability data specific to a particular vendor",
.description = "BGP has received a capability that is vendor specific and as such we have no knowledge of how to use this capability in FRR",
.suggestion = "On peer turn off this feature"
},
@@ -197,43 +197,43 @@ static struct log_ref ferr_bgp_err[] = {
.code = EC_BGP_ATTR_FLAG,
.title = "BGP attribute flag is incorrect",
.description = "BGP attribute flag is set to the wrong value (Optional/Transitive/Partial)",
- .suggestion = "Determine the soure of the attribute and determine why the attribute flag has been set incorrectly"
+ .suggestion = "Determine the source of the attribute and determine why the attribute flag has been set incorrectly"
},
{
.code = EC_BGP_ATTR_LEN,
.title = "BGP attribute length is incorrect",
.description = "BGP attribute length is incorrect",
- .suggestion = "Determine the soure of the attribute and determine why the attribute length has been set incorrectly"
+ .suggestion = "Determine the source of the attribute and determine why the attribute length has been set incorrectly"
},
{
.code = EC_BGP_ATTR_ORIGIN,
.title = "BGP attribute origin value invalid",
.description = "BGP attribute origin value is invalid",
- .suggestion = "Determine the soure of the attribute and determine why the origin attribute has been set incorrectly"
+ .suggestion = "Determine the source of the attribute and determine why the origin attribute has been set incorrectly"
},
{
.code = EC_BGP_ATTR_MAL_AS_PATH,
.title = "BGP as path is invalid",
.description = "BGP as path has been malformed",
- .suggestion = "Determine the soure of the update and determine why the as path has been set incorrectly"
+ .suggestion = "Determine the source of the update and determine why the as path has been set incorrectly"
},
{
.code = EC_BGP_ATTR_FIRST_AS,
.title = "BGP as path first as is invalid",
.description = "BGP update has invalid first as in as path",
- .suggestion = "Determine the soure of the update and determine why the as path first as value has been set incorrectly"
+ .suggestion = "Determine the source of the update and determine why the as path first as value has been set incorrectly"
},
{
.code = EC_BGP_ATTR_PMSI_TYPE,
.title = "BGP PMSI tunnel attribute type is invalid",
.description = "BGP update has invalid type for PMSI tunnel",
- .suggestion = "Determine the soure of the update and determine why the PMSI tunnel attribute type has been set incorrectly"
+ .suggestion = "Determine the source of the update and determine why the PMSI tunnel attribute type has been set incorrectly"
},
{
.code = EC_BGP_ATTR_PMSI_LEN,
.title = "BGP PMSI tunnel attribute length is invalid",
.description = "BGP update has invalid length for PMSI tunnel",
- .suggestion = "Determine the soure of the update and determine why the PMSI tunnel attribute length has been set incorrectly"
+ .suggestion = "Determine the source of the update and determine why the PMSI tunnel attribute length has been set incorrectly"
},
{
.code = EC_BGP_PEER_GROUP,
@@ -269,7 +269,7 @@ static struct log_ref ferr_bgp_err[] = {
.code = EC_BGP_JSON_MEM_ERROR,
.title = "BGP unable to allocate memory for JSON output",
.description = "BGP attempted to generate JSON output and was unable to allocate the memory required",
- .suggestion = "Ensure that the device has adequate memory to suport the required functions"
+ .suggestion = "Ensure that the device has adequate memory to support the required functions"
},
{
.code = EC_BGP_UPDGRP_ATTR_LEN,
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index b67d93d4f5..574ece8cc5 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -1449,7 +1449,7 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_def,
}
/*
- * create a new route entry if one doesnt exist.
+ * create a new route entry if one doesn't exist.
* Otherwise see if route attr has changed
*/
if (!local_pi) {
@@ -5288,7 +5288,7 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac,
}
as = bgp_def->as;
- /* if the BGP vrf instance doesnt exist - create one */
+ /* if the BGP vrf instance doesn't exist - create one */
bgp_vrf = bgp_lookup_by_name(vrf_id_to_name(vrf_id));
if (!bgp_vrf) {
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c
index 90c9db3dfe..29f9f64cca 100644
--- a/bgpd/bgp_evpn_vty.c
+++ b/bgpd/bgp_evpn_vty.c
@@ -3999,7 +3999,7 @@ DEFUN(test_withdraw_evpn_type4_route,
}
if (!bgp->peer_self) {
- vty_out(vty, "%%BGP instance doesnt have self peer\n");
+ vty_out(vty, "%%BGP instance doesn't have self peer\n");
return CMD_WARNING;
}
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index d17426e3ff..8aa35eddfc 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -931,7 +931,7 @@ static void bgp_update_delay_process_status_change(struct peer *peer)
}
}
-/* Called after event occured, this function change status and reset
+/* Called after event occurred, this function change status and reset
read/write and timer thread. */
void bgp_fsm_change_status(struct peer *peer, int status)
{
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 96f3c8324f..73a07c8232 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -272,7 +272,7 @@ static void bgp_update_explicit_eors(struct peer *peer)
PEER_STATUS_EOR_RECEIVED)) {
if (bgp_debug_neighbor_events(peer))
zlog_debug(
- " afi %d safi %d didnt receive EOR",
+ " afi %d safi %d didn't receive EOR",
afi, safi);
return;
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 379e44cd5d..c20b404f19 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -8306,7 +8306,6 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
unsigned long output_count = 0;
unsigned long total_count = 0;
struct prefix *p;
- char buf[BUFSIZ];
char buf2[BUFSIZ];
json_object *json_paths = NULL;
int first = 1;
@@ -8527,14 +8526,32 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
continue;
p = &rn->p;
- sprintf(buf2, "%s/%d",
- inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
- p->prefixlen);
- if (first)
- vty_out(vty, "\"%s\": ", buf2);
- else
- vty_out(vty, ",\"%s\": ", buf2);
-
+ /* encode prefix */
+ if (p->family == AF_FLOWSPEC) {
+ char retstr[BGP_FLOWSPEC_STRING_DISPLAY_MAX];
+
+ bgp_fs_nlri_get_string((unsigned char *)
+ p->u.prefix_flowspec.ptr,
+ p->u.prefix_flowspec
+ .prefixlen,
+ retstr,
+ NLRI_STRING_FORMAT_MIN,
+ NULL);
+ if (first)
+ vty_out(vty, "\"%s/%d\": ",
+ retstr,
+ p->u.prefix_flowspec.prefixlen);
+ else
+ vty_out(vty, ",\"%s/%d\": ",
+ retstr,
+ p->u.prefix_flowspec.prefixlen);
+ } else {
+ prefix2str(p, buf2, sizeof(buf2));
+ if (first)
+ vty_out(vty, "\"%s\": ", buf2);
+ else
+ vty_out(vty, ",\"%s\": ", buf2);
+ }
vty_out(vty, "%s",
json_object_to_json_string(json_paths));
json_object_free(json_paths);
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index a1c50a720f..ecbe33ff8c 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -2301,7 +2301,7 @@ DEFUN (bgp_default_show_hostname,
"bgp default show-hostname",
"BGP specific commands\n"
"Configure BGP defaults\n"
- "Show hostname in certain command ouputs\n")
+ "Show hostname in certain command outputs\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME);
@@ -2314,7 +2314,7 @@ DEFUN (no_bgp_default_show_hostname,
NO_STR
"BGP specific commands\n"
"Configure BGP defaults\n"
- "Show hostname in certain command ouputs\n")
+ "Show hostname in certain command outputs\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME);
@@ -6016,7 +6016,7 @@ DEFUN (neighbor_allowas_in,
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Accept as-path with my AS present in it\n"
- "Number of occurances of AS number\n"
+ "Number of occurences of AS number\n"
"Only accept my AS in the as-path if the route was originated in my AS\n")
{
int idx_peer = 1;
@@ -6050,7 +6050,7 @@ ALIAS_HIDDEN(
"neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
NEIGHBOR_STR NEIGHBOR_ADDR_STR2
"Accept as-path with my AS present in it\n"
- "Number of occurances of AS number\n"
+ "Number of occurences of AS number\n"
"Only accept my AS in the as-path if the route was originated in my AS\n")
DEFUN (no_neighbor_allowas_in,
@@ -6060,7 +6060,7 @@ DEFUN (no_neighbor_allowas_in,
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"allow local ASN appears in aspath attribute\n"
- "Number of occurances of AS number\n"
+ "Number of occurences of AS number\n"
"Only accept my AS in the as-path if the route was originated in my AS\n")
{
int idx_peer = 2;
@@ -6082,7 +6082,7 @@ ALIAS_HIDDEN(
"no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
"allow local ASN appears in aspath attribute\n"
- "Number of occurances of AS number\n"
+ "Number of occurences of AS number\n"
"Only accept my AS in the as-path if the route was originated in my AS\n")
DEFUN (neighbor_ttl_security,
@@ -9607,7 +9607,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
json_object_string_add(
json_nxt,
print_store,
- "recieved");
+ "received");
}
}
json_object_object_add(
@@ -10215,7 +10215,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
json_object_object_add(
json_neigh, "gracefulRestartInfo", json_grace);
} else {
- vty_out(vty, " Graceful restart informations:\n");
+ vty_out(vty, " Graceful restart information:\n");
if (p->status == Established) {
vty_out(vty, " End-of-RIB send: ");
FOREACH_AFI_SAFI (afi, safi) {
diff --git a/debianpkg/frr.logrotate b/debianpkg/frr.logrotate
index 750b9aef13..1dc9122ac4 100644
--- a/debianpkg/frr.logrotate
+++ b/debianpkg/frr.logrotate
@@ -17,7 +17,7 @@
# open, as well as the daemons, so always signal the daemons.
# It's safe, a NOP if (only) syslog is being used.
for i in babeld bgpd eigrpd isisd ldpd nhrpd ospf6d ospfd \
- pimd ripd ripngd zebra staticd ; do
+ pimd ripd ripngd zebra staticd fabricd; do
if [ -e /var/run/frr/$i.pid ] ; then
pids="$pids $(cat /var/run/frr/$i.pid)"
fi
diff --git a/debianpkg/frr.manpages b/debianpkg/frr.manpages
index d4bb920b46..f5aa972304 100644
--- a/debianpkg/frr.manpages
+++ b/debianpkg/frr.manpages
@@ -13,3 +13,4 @@ doc/manpages/_build/man/zebra.8
doc/manpages/_build/man/isisd.8
doc/manpages/_build/man/watchfrr.8
doc/manpages/_build/man/mtracebis.8
+doc/manpages/_build/man/fabricd.8
diff --git a/debianpkg/tests/daemons b/debianpkg/tests/daemons
index ac35ecd950..43966c8347 100644
--- a/debianpkg/tests/daemons
+++ b/debianpkg/tests/daemons
@@ -6,7 +6,7 @@ set -e
# modify config file to enable all daemons and copy config files
CONFIG_FILE=/etc/frr/daemons
-DAEMONS=("zebra" "bgpd" "ospfd" "ospf6d" "ripd" "ripngd" "isisd" "pimd")
+DAEMONS=("zebra" "bgpd" "ospfd" "ospf6d" "ripd" "ripngd" "isisd" "pimd" "fabricd")
for daemon in "${DAEMONS[@]}"
do
diff --git a/doc/manpages/common-options.rst b/doc/manpages/common-options.rst
index 74d3eb7bbd..a5977a6ebb 100644
--- a/doc/manpages/common-options.rst
+++ b/doc/manpages/common-options.rst
@@ -136,7 +136,7 @@ These following options control the daemon's VTY (interactive command line) inte
NB: Unlike the other options, this option specifies a directory, not a full path.
- This option is primarily used by the SNAP packaging system, its semantics may change. It should not be neccessary in most other scenarios.
+ This option is primarily used by the SNAP packaging system, its semantics may change. It should not be necessary in most other scenarios.
MODULE LOADING
--------------
diff --git a/doc/manpages/zebra.rst b/doc/manpages/zebra.rst
index a8a9301588..cfb368bf44 100644
--- a/doc/manpages/zebra.rst
+++ b/doc/manpages/zebra.rst
@@ -33,7 +33,7 @@ OPTIONS available for the |DAEMON| command:
Set netlink receive buffer size. There are cases where zebra daemon can't handle flood of netlink messages from kernel. If you ever see "recvmsg overrun" messages in zebra log, you are in trouble.
- Solution is to increase receive buffer of netlink socket. Note that kernel < 2.6.14 doesn't allow to increase it over maximum value defined in /proc/sys/net/core/rmem_max. If you want to do it, you have to increase maximum before starting zebra.
+ Solution is to increase receive buffer of netlink socket. Note that kernel < 2.6.14 doesn't allow increasing it over maximum value defined in /proc/sys/net/core/rmem_max. If you want to do it, you have to increase maximum before starting zebra.
Note that this affects Linux only.
diff --git a/eigrpd/eigrp_const.h b/eigrpd/eigrp_const.h
index 3d84c82179..895a141e4a 100644
--- a/eigrpd/eigrp_const.h
+++ b/eigrpd/eigrp_const.h
@@ -152,7 +152,7 @@ enum eigrp_fsm_states {
enum eigrp_fsm_events {
/*
* Input event other than query from succ,
- * FC is not satisified
+ * FC is not satisfied
*/
EIGRP_FSM_EVENT_NQ_FCN,
@@ -171,7 +171,7 @@ enum eigrp_fsm_events {
/* Query from succ while in active state */
EIGRP_FSM_EVENT_QACT,
- /* last reply, FC not satisified */
+ /* last reply, FC not satisfied */
EIGRP_FSM_EVENT_LR_FCN,
/*
diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c
index bbe2b88223..27e02630a6 100644
--- a/eigrpd/eigrp_dump.c
+++ b/eigrpd/eigrp_dump.c
@@ -228,7 +228,7 @@ void show_ip_eigrp_interface_detail(struct vty *vty, struct eigrp *eigrp,
"Un/reliable mcasts: ", 0, "/", 0, "Un/reliable ucasts: ", 0,
"/", 0);
vty_out(vty, "%-2s %s %d %s %d %s %d \n", "", "Mcast exceptions: ", 0,
- " CR packets: ", 0, " ACKs supressed: ", 0);
+ " CR packets: ", 0, " ACKs suppressed: ", 0);
vty_out(vty, "%-2s %s %d %s %d \n", "", "Retransmissions sent: ", 0,
"Out-of-sequence rcvd: ", 0);
vty_out(vty, "%-2s %s %s %s \n", "", "Authentication mode is ", "not",
diff --git a/eigrpd/eigrp_fsm.c b/eigrpd/eigrp_fsm.c
index f955e6df0f..374114cf55 100644
--- a/eigrpd/eigrp_fsm.c
+++ b/eigrpd/eigrp_fsm.c
@@ -222,9 +222,9 @@ static const char *fsm_state2str(enum eigrp_fsm_events event)
case EIGRP_FSM_EVENT_LR:
return "Last Reply Event";
case EIGRP_FSM_EVENT_Q_FCN:
- return "Query Event Feasability not satisified";
+ return "Query Event Feasability not satisfied";
case EIGRP_FSM_EVENT_LR_FCS:
- return "Last Reply Event Feasability satisified";
+ return "Last Reply Event Feasability satisfied";
case EIGRP_FSM_EVENT_DINC:
return "Distance Increase Event";
case EIGRP_FSM_EVENT_QACT:
diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c
index 311fbce4ab..a0c4fa887a 100644
--- a/eigrpd/eigrp_vty.c
+++ b/eigrpd/eigrp_vty.c
@@ -55,6 +55,10 @@
#include "eigrpd/eigrp_dump.h"
#include "eigrpd/eigrp_const.h"
+#ifndef VTYSH_EXTRACT_PL
+#include "eigrpd/eigrp_vty_clippy.c"
+#endif
+
static int config_write_network(struct vty *vty, struct eigrp *eigrp)
{
struct route_node *rn;
@@ -657,16 +661,15 @@ DEFUN (no_eigrp_if_delay,
return CMD_SUCCESS;
}
-DEFUN (eigrp_if_bandwidth,
+DEFPY (eigrp_if_bandwidth,
eigrp_if_bandwidth_cmd,
- "eigrp bandwidth (1-10000000)",
+ "eigrp bandwidth (1-10000000)$bw",
"EIGRP specific commands\n"
"Set bandwidth informational parameter\n"
"Bandwidth in kilobits\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct eigrp_interface *ei = ifp->info;
- uint32_t bandwidth;
struct eigrp *eigrp;
eigrp = eigrp_lookup();
@@ -680,9 +683,7 @@ DEFUN (eigrp_if_bandwidth,
return CMD_SUCCESS;
}
- bandwidth = atoi(argv[1]->arg);
-
- ei->params.bandwidth = bandwidth;
+ ei->params.bandwidth = bw;
eigrp_if_reset(ifp);
return CMD_SUCCESS;
@@ -975,9 +976,10 @@ DEFUN (no_eigrp_authentication_mode,
return CMD_SUCCESS;
}
-DEFUN (eigrp_authentication_keychain,
+DEFPY (eigrp_authentication_keychain,
eigrp_authentication_keychain_cmd,
- "ip authentication key-chain eigrp (1-65535) WORD",
+ "[no] ip authentication key-chain eigrp (1-65535)$as WORD$name",
+ NO_STR
"Interface Internet Protocol config commands\n"
"Authentication subcommands\n"
"Key-chain\n"
@@ -1001,52 +1003,29 @@ DEFUN (eigrp_authentication_keychain,
return CMD_SUCCESS;
}
- keychain = keychain_lookup(argv[4]->arg);
+ if (no) {
+ if ((ei->params.auth_keychain != NULL)
+ && (strcmp(ei->params.auth_keychain, name) == 0)) {
+ free(ei->params.auth_keychain);
+ ei->params.auth_keychain = NULL;
+ } else
+ vty_out(vty,
+ "Key chain with specified name not configured on interface\n");
+ return CMD_SUCCESS;
+ }
+
+ keychain = keychain_lookup(name);
if (keychain != NULL) {
if (ei->params.auth_keychain) {
free(ei->params.auth_keychain);
ei->params.auth_keychain = strdup(keychain->name);
} else
ei->params.auth_keychain = strdup(keychain->name);
- } else
- vty_out(vty, "Key chain with specified name not found\n");
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_eigrp_authentication_keychain,
- no_eigrp_authentication_keychain_cmd,
- "no ip authentication key-chain eigrp (1-65535) WORD",
- "Disable\n"
- "Interface Internet Protocol config commands\n"
- "Authentication subcommands\n"
- "Key-chain\n"
- "Enhanced Interior Gateway Routing Protocol (EIGRP)\n"
- "Autonomous system number\n"
- "Name of key-chain\n")
-{
- VTY_DECLVAR_CONTEXT(interface, ifp);
- struct eigrp_interface *ei = ifp->info;
- struct eigrp *eigrp;
-
- eigrp = eigrp_lookup();
- if (eigrp == NULL) {
- vty_out(vty, "EIGRP Routing Process not enabled\n");
- return CMD_SUCCESS;
- }
-
- if (!ei) {
- vty_out(vty, " EIGRP not configured on this interface\n");
- return CMD_SUCCESS;
- }
-
- if ((ei->params.auth_keychain != NULL)
- && (strcmp(ei->params.auth_keychain, argv[5]->arg) == 0)) {
- free(ei->params.auth_keychain);
- ei->params.auth_keychain = NULL;
- } else
+ } else {
vty_out(vty,
- "Key chain with specified name not configured on interface\n");
+ "Key chain with specified name not found\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
return CMD_SUCCESS;
}
@@ -1538,7 +1517,6 @@ void eigrp_vty_if_init(void)
install_element(INTERFACE_NODE, &eigrp_authentication_mode_cmd);
install_element(INTERFACE_NODE, &no_eigrp_authentication_mode_cmd);
install_element(INTERFACE_NODE, &eigrp_authentication_keychain_cmd);
- install_element(INTERFACE_NODE, &no_eigrp_authentication_keychain_cmd);
/*EIGRP Summarization commands*/
install_element(INTERFACE_NODE, &eigrp_ip_summary_address_cmd);
diff --git a/eigrpd/subdir.am b/eigrpd/subdir.am
index bc48173bba..86061b3ae3 100644
--- a/eigrpd/subdir.am
+++ b/eigrpd/subdir.am
@@ -44,6 +44,9 @@ eigrpdheader_HEADERS = \
eigrpd/eigrpd.h \
# end
+eigrpd/eigrp_vty_clippy.c: $(CLIPPY_DEPS)
+eigrpd/eigrp_vty.$(OBJEXT): eigrpd/eigrp_vty_clippy.c
+
noinst_HEADERS += \
eigrpd/eigrp_const.h \
eigrpd/eigrp_errors.h \
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index 1c4ca249ee..b6f751463a 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -887,7 +887,7 @@ static int isis_spf_preload_tent(struct isis_spftree *spftree,
case ISIS_SYSTYPE_UNKNOWN:
default:
zlog_warn(
- "isis_spf_preload_tent unknow adj type");
+ "isis_spf_preload_tent unknown adj type");
}
}
list_delete(&adj_list);
diff --git a/ldpd/ldp_vty_cmds.c b/ldpd/ldp_vty_cmds.c
index 8eed089900..c24e1917cc 100644
--- a/ldpd/ldp_vty_cmds.c
+++ b/ldpd/ldp_vty_cmds.c
@@ -156,7 +156,7 @@ DEFPY (ldp_dual_stack_transport_connection_prefer_ipv4,
NO_STR
"Configure dual stack parameters\n"
"Configure TCP transport parameters\n"
- "Configure prefered address family for TCP transport connection with neighbor\n"
+ "Configure preferred address family for TCP transport connection with neighbor\n"
"IPv4\n")
{
return (ldp_vty_trans_pref_ipv4(vty, no));
diff --git a/ldpd/util.c b/ldpd/util.c
index 12f9cb0ccf..b4d74f1950 100644
--- a/ldpd/util.c
+++ b/ldpd/util.c
@@ -259,7 +259,7 @@ embedscope(struct sockaddr_in6 *sin6)
if (IN6_IS_SCOPE_EMBED(&sin6->sin6_addr)) {
memcpy(&tmp16, &sin6->sin6_addr.s6_addr[2], sizeof(tmp16));
if (tmp16 != 0) {
- log_warnx("%s: address %s already has embeded scope %u",
+ log_warnx("%s: address %s already has embedded scope %u",
__func__, log_sockaddr(sin6), ntohs(tmp16));
}
tmp16 = htons(sin6->sin6_scope_id);
diff --git a/lib/bfd.c b/lib/bfd.c
index 1dfe583caf..178c203f5e 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -134,7 +134,7 @@ void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info,
int ret;
int len;
- /* Individual reg/dereg messages are supressed during shutdown. */
+ /* Individual reg/dereg messages are suppressed during shutdown. */
if (CHECK_FLAG(bfd_gbl.flags, BFD_GBL_FLAG_IN_SHUTDOWN)) {
if (bfd_debug)
zlog_debug(
diff --git a/lib/command.c b/lib/command.c
index 839c37b102..127e1a0a0a 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1323,7 +1323,9 @@ int command_config_read_one_line(struct vty *vty,
}
}
- if (ret != CMD_SUCCESS && ret != CMD_WARNING) {
+ if (ret != CMD_SUCCESS &&
+ ret != CMD_WARNING &&
+ ret != CMD_SUCCESS_DAEMON) {
struct vty_error *ve = XCALLOC(MTYPE_TMP, sizeof(*ve));
memcpy(ve->error_buf, vty->buf, VTY_BUFSIZ);
diff --git a/lib/command.h b/lib/command.h
index fbff1e67f4..de65c8bd98 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -355,7 +355,7 @@ struct cmd_node {
#define IN_STR "Filter incoming routing updates\n"
#define V4NOTATION_STR "specify by IPv4 address notation(e.g. 0.0.0.0)\n"
#define OSPF6_NUMBER_STR "Specify by number\n"
-#define INTERFACE_STR "Interface infomation\n"
+#define INTERFACE_STR "Interface information\n"
#define IFNAME_STR "Interface name(e.g. ep0)\n"
#define IP6_STR "IPv6 Information\n"
#define OSPF6_STR "Open Shortest Path First (OSPF) for IPv6\n"
diff --git a/lib/command_lex.l b/lib/command_lex.l
index 3b18b58a2e..f361db78e9 100644
--- a/lib/command_lex.l
+++ b/lib/command_lex.l
@@ -48,8 +48,8 @@ IPV4 A\.B\.C\.D
IPV4_PREFIX A\.B\.C\.D\/M
IPV6 X:X::X:X
IPV6_PREFIX X:X::X:X\/M
-MAC M:A:C
-MAC_PREFIX M:A:C\/M
+MAC X:X:X:X:X:X
+MAC_PREFIX X:X:X:X:X:X\/M
VARIABLE [A-Z][-_A-Z:0-9]+
WORD (\-|\+)?[a-zA-Z0-9\*][-+_a-zA-Z0-9\*]*
NUMBER (\-|\+)?[0-9]{1,20}
diff --git a/lib/filter.c b/lib/filter.c
index 0528b0f2ad..1aae58b61c 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -1302,7 +1302,7 @@ static int filter_set_zebra(struct vty *vty, const char *name_str,
DEFUN (mac_access_list,
mac_access_list_cmd,
- "mac access-list WORD <deny|permit> MAC",
+ "mac access-list WORD <deny|permit> X:X:X:X:X:X",
"Add a mac access-list\n"
"Add an access list entry\n"
"MAC zebra access-list name\n"
@@ -1316,7 +1316,7 @@ DEFUN (mac_access_list,
DEFUN (no_mac_access_list,
no_mac_access_list_cmd,
- "no mac access-list WORD <deny|permit> MAC",
+ "no mac access-list WORD <deny|permit> X:X:X:X:X:X",
NO_STR
"Remove a mac access-list\n"
"Remove an access list entry\n"
diff --git a/lib/lib_errors.c b/lib/lib_errors.c
index 03ad974da6..ad83ef1e51 100644
--- a/lib/lib_errors.c
+++ b/lib/lib_errors.c
@@ -89,8 +89,8 @@ static struct log_ref ferr_lib_err[] = {
{
.code = EC_LIB_SOCKET,
.title = "Socket Error",
- .description = "When attempting to access a socket a system error has occured and we were unable to properly complete the request",
- .suggestion = "Ensure that there are sufficient system resources available and ensure that the frr user has sufficient permisions to work. If necessary open an Issue",
+ .description = "When attempting to access a socket a system error has occurred and we were unable to properly complete the request",
+ .suggestion = "Ensure that there are sufficient system resources available and ensure that the frr user has sufficient permissions to work. If necessary open an Issue",
},
{
.code = EC_LIB_ZAPI_MISSMATCH,
diff --git a/lib/mpls.h b/lib/mpls.h
index c9dd60dce0..6146985610 100644
--- a/lib/mpls.h
+++ b/lib/mpls.h
@@ -171,7 +171,7 @@ static inline char *label2str(mpls_label_t label, char *buf, size_t len)
strlcpy(buf, "Router Alert", len);
return (buf);
case MPLS_LABEL_IPV6_EXPLICIT_NULL:
- strlcpy(buf, "IPv6 Explict Null", len);
+ strlcpy(buf, "IPv6 Explicit Null", len);
return (buf);
case MPLS_LABEL_IMPLICIT_NULL:
strlcpy(buf, "implicit-null", len);
diff --git a/lib/sockunion.c b/lib/sockunion.c
index bee82a067e..af4f41f37c 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -356,7 +356,7 @@ int sockopt_ttl(int family, int sock, int ttl)
* Which on linux is a no-op since it is enabled by
* default and on BSD it uses TCP_NOPUSH to do
* the same thing( which it was not configured to
- * use). This cleanup of the api occured on 8/1/17
+ * use). This cleanup of the api occurred on 8/1/17
* I imagine if after more than 1 year of no-one
* complaining, and a major upgrade release we
* can deprecate and remove this function call
diff --git a/m4/ax_sys_weak_alias.m4 b/m4/ax_sys_weak_alias.m4
index 27b0f0c4f0..37cbe9187c 100644
--- a/m4/ax_sys_weak_alias.m4
+++ b/m4/ax_sys_weak_alias.m4
@@ -22,7 +22,7 @@
# another object file.
#
# There are four known schemes of declaring weak symbols; each scheme is
-# checked in turn, and the first one found is prefered. Note that only one
+# checked in turn, and the first one found is preferred. Note that only one
# of the mentioned preprocessor macros will be defined!
#
# 1. Function attributes
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index 1890e9bdc3..53d545a24b 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -321,7 +321,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
/* if this is a route to ASBR */
if (route->type == OSPF6_DEST_TYPE_ROUTER) {
- /* Only the prefered best path is considered */
+ /* Only the preferred best path is considered */
if (!CHECK_FLAG(route->flag, OSPF6_ROUTE_BEST)) {
if (is_debug)
zlog_debug(
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index c848a16aa9..bc52864313 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -772,7 +772,7 @@ DEFUN (show_ipv6_ospf6_spf_tree,
SHOW_STR
IP6_STR
OSPF6_STR
- "Shortest Path First caculation\n"
+ "Shortest Path First calculation\n"
"Show SPF tree\n")
{
struct listnode *node;
@@ -807,7 +807,7 @@ DEFUN (show_ipv6_ospf6_area_spf_tree,
OSPF6_STR
OSPF6_AREA_STR
OSPF6_AREA_ID_STR
- "Shortest Path First caculation\n"
+ "Shortest Path First calculation\n"
"Show SPF tree\n")
{
int idx_ipv4 = 4;
diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c
index ad9b3efe6e..9fd9a70c78 100644
--- a/ospfd/ospf_ism.c
+++ b/ospfd/ospf_ism.c
@@ -277,7 +277,7 @@ static int ospf_wait_timer(struct thread *thread)
return 0;
}
-/* Hook function called after ospf ISM event is occured. And vty's
+/* Hook function called after ospf ISM event is occurred. And vty's
network command invoke this function after making interface
structure. */
static void ism_timer_set(struct ospf_interface *oi)
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index 91d187f412..f7c73fee33 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -94,7 +94,7 @@ static int ospf_db_desc_timer(struct thread *thread)
return 0;
}
-/* Hook function called after ospf NSM event is occured.
+/* Hook function called after ospf NSM event is occurred.
*
* Set/clear any timers whose condition is implicit to the neighbour
* state. There may be other timers which are set/unset according to other
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 7f96299768..147773ce23 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -500,7 +500,7 @@ struct opaque_info_per_type {
/* Collection of callback functions for this opaque-type. */
struct ospf_opaque_functab *functab;
- /* List of Opaque-LSA control informations per opaque-id. */
+ /* List of Opaque-LSA control information per opaque-id. */
struct list *id_list;
};
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 79b4648805..3bb3b79a6a 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -3368,7 +3368,7 @@ static int ospf_make_db_desc(struct ospf_interface *oi,
if (IS_OPAQUE_LSA(lsa->data->type)
&& (!CHECK_FLAG(options, OSPF_OPTION_O))) {
/* Suppress advertising
- * opaque-informations. */
+ * opaque-information. */
/* Remove LSA from DB summary list. */
ospf_lsdb_delete(lsdb, lsa);
continue;
diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c
index 3b0319b591..bef16761f2 100644
--- a/ospfd/ospf_ri.c
+++ b/ospfd/ospf_ri.c
@@ -591,7 +591,7 @@ static int is_mandated_params_set(struct ospf_router_info ori)
* @param enable To activate or not Segment Routing router Information flooding
* @param size Size of Label Range i.e. SRGB size
* @param lower Lower bound of the Label Range i.e. SRGB first label
- * @param msd Maximum label Stack Depth suported by the router
+ * @param msd Maximum label Stack Depth supported by the router
*
* @return none
*/
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index f43038ab8d..02698d770a 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -2406,7 +2406,7 @@ DEFUN (no_ospf_mpls_te_inter_as,
ospf_mpls_te_lsa_schedule(lp, FLUSH_THIS_LSA);
}
- /* Deregister the Callbacks for Inter-AS suport */
+ /* Deregister the Callbacks for Inter-AS support */
ospf_mpls_te_unregister();
return CMD_SUCCESS;
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index dc54f04c07..aa40dd0ebc 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -171,7 +171,7 @@ void ospf_router_id_update(struct ospf *ospf)
/* Flush (inline) all external LSAs which now match the new
router-id,
- need to adjust the OSPF_LSA_SELF flag, so the flush doesnt
+ need to adjust the OSPF_LSA_SELF flag, so the flush doesn't
hit
asserts in ospf_refresher_unregister_lsa(). This step is
needed
diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c
index 25d64238bf..b7391a171a 100644
--- a/pbrd/pbr_zebra.c
+++ b/pbrd/pbr_zebra.c
@@ -207,13 +207,13 @@ static int rule_notify_owner(int command, struct zclient *zclient,
switch (note) {
case ZAPI_RULE_FAIL_INSTALL:
- DEBUGD(&pbr_dbg_zebra, "%s: Recieved RULE_FAIL_INSTALL",
+ DEBUGD(&pbr_dbg_zebra, "%s: Received RULE_FAIL_INSTALL",
__PRETTY_FUNCTION__);
pbrms->installed &= ~installed;
break;
case ZAPI_RULE_INSTALLED:
pbrms->installed |= installed;
- DEBUGD(&pbr_dbg_zebra, "%s: Recived RULE_INSTALLED",
+ DEBUGD(&pbr_dbg_zebra, "%s: Received RULE_INSTALLED",
__PRETTY_FUNCTION__);
break;
case ZAPI_RULE_FAIL_REMOVE:
diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c
index 2550651464..b0d7a7b2db 100644
--- a/pimd/pim_instance.c
+++ b/pimd/pim_instance.c
@@ -188,7 +188,7 @@ static int pim_vrf_config_write(struct vty *vty)
pim_global_config_write_worker(pim, vty);
if (vrf->vrf_id != VRF_DEFAULT)
- vty_endframe(vty, "!\n");
+ vty_endframe(vty, " exit-vrf\n!\n");
}
return 0;
diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c
index 807ad2bd12..7e072e6ade 100644
--- a/pimd/pim_msdp.c
+++ b/pimd/pim_msdp.c
@@ -74,7 +74,7 @@ static int pim_msdp_sa_adv_timer_cb(struct thread *t)
struct pim_instance *pim = THREAD_ARG(t);
if (PIM_DEBUG_MSDP_EVENTS) {
- zlog_debug("MSDP SA advertisment timer expired");
+ zlog_debug("MSDP SA advertisement timer expired");
}
pim_msdp_sa_adv_timer_setup(pim, true /* start */);
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index e5f5b34f2f..cd5b632ded 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -462,7 +462,7 @@ static int pim_upstream_could_register(struct pim_upstream *up)
return 0;
}
-/* Source registration is supressed for SSM groups. When the SSM range changes
+/* Source registration is suppressed for SSM groups. When the SSM range changes
* we re-revaluate register setup for existing upstream entries */
void pim_upstream_register_reevaluate(struct pim_instance *pim)
{
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 444a09914c..dd0d17ee47 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -1238,7 +1238,7 @@ static void rip_response_process(struct rip_packet *packet, int size,
Ciscos before the 'ip subnet zero' option, it would be almost
right too :-)
- Cisco summarize ripv1 advertisments to the classful boundary
+ Cisco summarize ripv1 advertisements to the classful boundary
(/16 for class B's) except when the RIP packet does to inside
the classful network in question. */
@@ -2513,7 +2513,7 @@ static void rip_update_process(int route_type)
VRF_DEFAULT);
if (!connected) {
zlog_warn(
- "Neighbor %s doesnt have connected interface!",
+ "Neighbor %s doesn't have connected interface!",
inet_ntoa(p->u.prefix4));
continue;
}
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 08dc3d8b4d..2cbbbae7f5 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -1560,7 +1560,7 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
&& rinfo->suppress == 0) {
/* If no route-map are applied, the RTE will be these
* following
- * informations.
+ * information.
*/
p = (struct prefix_ipv6 *)&rp->p;
rinfo->metric_out = rinfo->metric;
@@ -1701,7 +1701,7 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
&& aggregate->suppress == 0) {
/* If no route-map are applied, the RTE will be these
* following
- * informations.
+ * information.
*/
p = (struct prefix_ipv6 *)&rp->p;
aggregate->metric_set = 0;
diff --git a/staticd/static_vrf.c b/staticd/static_vrf.c
index ad143209ee..9dd25fbdd1 100644
--- a/staticd/static_vrf.c
+++ b/staticd/static_vrf.c
@@ -164,7 +164,7 @@ static int static_vrf_config_write(struct vty *vty)
SAFI_UNICAST, "ipv6 route");
if (vrf->vrf_id != VRF_DEFAULT)
- vty_endframe(vty, "!\n");
+ vty_endframe(vty, " exit-vrf\n!\n");
}
return 0;
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
index 28fac0c870..bc8a429d56 100644
--- a/staticd/static_vty.c
+++ b/staticd/static_vty.c
@@ -199,7 +199,7 @@ static int zebra_static_route_holdem(
const char *dest_str, const char *mask_str, const char *src_str,
const char *gate_str, const char *ifname, const char *flag_str,
const char *tag_str, const char *distance_str, const char *label_str,
- const char *table_str)
+ const char *table_str, bool onlink)
{
struct static_hold_route *shr, *lookup;
struct listnode *node;
@@ -212,6 +212,7 @@ static int zebra_static_route_holdem(
shr->nhvrf_name = XSTRDUP(MTYPE_STATIC_ROUTE, nh_svrf->vrf->name);
shr->afi = afi;
shr->safi = safi;
+ shr->onlink = onlink;
if (dest)
prefix_copy(&shr->dest, dest);
if (dest_str)
@@ -347,7 +348,7 @@ static int static_route_leak(
return zebra_static_route_holdem(
svrf, nh_svrf, afi, safi, negate, &p, dest_str,
mask_str, src_str, gate_str, ifname, flag_str, tag_str,
- distance_str, label_str, table_str);
+ distance_str, label_str, table_str, onlink);
}
if (table_str) {
@@ -646,7 +647,9 @@ int static_config(struct vty *vty, struct static_vrf *svrf, afi_t afi,
if (shr->table_str)
vty_out(vty, "table %s", shr->table_str);
if (strcmp(shr->vrf_name, shr->nhvrf_name) != 0)
- vty_out(vty, "nexthop-vrf %s", shr->nhvrf_name);
+ vty_out(vty, "nexthop-vrf %s ", shr->nhvrf_name);
+ if (shr->onlink)
+ vty_out(vty, "onlink");
vty_out(vty, "\n");
}
@@ -717,6 +720,9 @@ int static_config(struct vty *vty, struct static_vrf *svrf, afi_t afi,
svrf->vrf->data.l.table_id == RT_TABLE_MAIN)
vty_out(vty, " table %u", si->table_id);
+ if (si->onlink)
+ vty_out(vty, " onlink");
+
vty_out(vty, "\n");
write = 1;
diff --git a/tools/etc/frr/daemons b/tools/etc/frr/daemons
index 474b299d90..1514082e90 100644
--- a/tools/etc/frr/daemons
+++ b/tools/etc/frr/daemons
@@ -36,3 +36,4 @@ babeld=no
sharpd=no
pbrd=no
bfdd=no
+fabricd=no
diff --git a/tools/etc/frr/daemons.conf b/tools/etc/frr/daemons.conf
index 640437f441..bd0e370d1e 100644
--- a/tools/etc/frr/daemons.conf
+++ b/tools/etc/frr/daemons.conf
@@ -20,6 +20,7 @@ sharpd_options=" --daemon -A 127.0.0.1"
pbrd_options=" --daemon -A 127.0.0.1"
staticd_options=" --daemon -A 127.0.0.1"
bfdd_options=" --daemon -A 127.0.0.1"
+fabricd_options=" --daemon -A 127.0.0.1"
# The list of daemons to watch is automatically generated by the init script.
watchfrr_enable=yes
diff --git a/tools/etc/rsyslog.d/45-frr.conf b/tools/etc/rsyslog.d/45-frr.conf
index ff7cd48318..4612e8beaf 100644
--- a/tools/etc/rsyslog.d/45-frr.conf
+++ b/tools/etc/rsyslog.d/45-frr.conf
@@ -8,6 +8,7 @@ if $programname == 'babeld' or
$programname == 'eigrpd' or
$programname == 'frr' or
$programname == 'isisd' or
+ $programname == 'fabricd' or
$programname == 'ldpd' or
$programname == 'nhrpd' or
$programname == 'ospf6d' or
@@ -24,6 +25,7 @@ if $programname == 'babeld' or
$programname == 'eigrpd' or
$programname == 'frr' or
$programname == 'isisd' or
+ $programname == 'fabricd' or
$programname == 'ldpd' or
$programname == 'nhrpd' or
$programname == 'ospf6d' or
diff --git a/tools/frr.in b/tools/frr.in
index c57ef6baf9..ee8dc883dc 100755
--- a/tools/frr.in
+++ b/tools/frr.in
@@ -25,7 +25,7 @@ FRR_VTY_GROUP="@enable_vty_group@" # frrvty
# 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 babeld pimd ldpd nhrpd eigrpd sharpd pbrd staticd bfdd"
+DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd babeld pimd ldpd nhrpd eigrpd sharpd pbrd staticd bfdd fabricd"
MAX_INSTANCES=5
RELOAD_SCRIPT="$D_PATH/frr-reload.py"
diff --git a/tools/start-stop-daemon.c b/tools/start-stop-daemon.c
index 8daeda7402..f2a1e9434b 100644
--- a/tools/start-stop-daemon.c
+++ b/tools/start-stop-daemon.c
@@ -1013,7 +1013,7 @@ int main(int argc, char **argv)
if (background) { /* ok, we need to detach this process */
int i, fd;
if (quietmode < 0)
- printf("Detatching to start %s...", startas);
+ printf("Detaching to start %s...", startas);
i = fork();
if (i < 0) {
fatal("Unable to fork.\n");
diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in
index 0f68e58d62..596f01738a 100755
--- a/vtysh/extract.pl.in
+++ b/vtysh/extract.pl.in
@@ -85,7 +85,7 @@ sub scan_file {
# $protocol is VTYSH_PROTO format for redirection of user input
if ($file =~ /lib\/keychain\.c$/) {
- $protocol = "VTYSH_RIPD";
+ $protocol = "VTYSH_RIPD|VTYSH_EIGRPD";
}
elsif ($file =~ /lib\/routemap\.c$/) {
$protocol = "VTYSH_RMAP";
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index a2154a9848..35f719fa54 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -1502,7 +1502,7 @@ DEFUNSH(VTYSH_BGPD, vnc_l2_group, vnc_l2_group_cmd, "vnc l2-group NAME",
}
#endif
-DEFUNSH(VTYSH_RIPD, key_chain, key_chain_cmd, "key chain WORD",
+DEFUNSH(VTYSH_KEYS, key_chain, key_chain_cmd, "key chain WORD",
"Authentication key management\n"
"Key-chain management\n"
"Key-chain name\n")
@@ -1511,7 +1511,7 @@ DEFUNSH(VTYSH_RIPD, key_chain, key_chain_cmd, "key chain WORD",
return CMD_SUCCESS;
}
-DEFUNSH(VTYSH_RIPD, key, key_cmd, "key (0-2147483647)",
+DEFUNSH(VTYSH_KEYS, key, key_cmd, "key (0-2147483647)",
"Configure a key\n"
"Key identifier number\n")
{
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index ee980d5128..430b117c50 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -55,6 +55,7 @@ DECLARE_MGROUP(MVTYSH)
#define VTYSH_INTERFACE VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_PBRD|VTYSH_FABRICD
#define VTYSH_NS VTYSH_ZEBRA
#define VTYSH_VRF VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_STATICD
+#define VTYSH_KEYS VTYSH_RIPD|VTYSH_EIGRPD
enum vtysh_write_integrated {
WRITE_INTEGRATED_UNSPECIFIED,
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index 7a7744f7c0..541eafcf7f 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -132,16 +132,83 @@ static void config_add_line_uniq(struct list *config, const char *line)
}
/*
- * I want to explicitly move this command to the end of the line
+ * Add a line that should only be shown once, and always show at the end of the
+ * config block.
+ *
+ * If the line already exists, it will be moved to the end of the block. If it
+ * does not exist, it will be added at the end of the block.
+ *
+ * Note that this only makes sense when there is just one such line that should
+ * show up at the very end of a config block. Furthermore, if the same block
+ * can show up from multiple daemons, all of them must make sure to print the
+ * line at the end of their config, otherwise the line will show at the end of
+ * the config for the last daemon that printed it.
+ *
+ * Here is a motivating example with the 'exit-vrf' command. Suppose we receive
+ * a config from Zebra like so:
+ *
+ * vrf BLUE
+ * ip route A
+ * ip route B
+ * exit-vrf
+ *
+ * Then suppose we later receive this config from PIM:
+ *
+ * vrf BLUE
+ * ip msdp mesh-group MyGroup member 1.2.3.4
+ * exit-vrf
+ *
+ * Then we will combine them into one config block like so:
+ *
+ * vrf BLUE
+ * ip route A
+ * ip route B
+ * ip msdp mesh-group MyGroup member 1.2.3.4
+ * exit-vrf
+ *
+ * Because PIM also sent us an 'exit-vrf', we noticed that we already had one
+ * under the 'vrf BLUE' config block and so we moved it to the end of the
+ * config block again. If PIM had neglected to send us 'exit-vrf', the result
+ * would be this:
+ *
+ * vrf BLUE
+ * ip route A
+ * ip route B
+ * exit-vrf
+ * ip msdp mesh-group MyGroup member 1.2.3.4
+ *
+ * Therefore, daemons that share config blocks must take care to consistently
+ * print the same block terminators.
+ *
+ * Ideally this would be solved by adding a string to struct config that is
+ * always printed at the end when dumping a config. However, this would only
+ * work when the user is using integrated config. In the non-integrated config
+ * case, daemons are responsible for writing their own config files, and so the
+ * must be able to print these blocks correctly independently of vtysh, which
+ * means they are the ones that need to handle printing the block terminators
+ * and VTYSH needs to be smart enough to combine them properly.
+ *
+ * ---
+ *
+ * config
+ * The config to add the line to
+ *
+ * line
+ * The line to add to the end of the config
*/
-static void config_add_line_end(struct list *config, const char *line)
+static void config_add_line_uniq_end(struct list *config, const char *line)
{
struct listnode *node;
- void *item = XSTRDUP(MTYPE_VTYSH_CONFIG_LINE, line);
+ char *pnt;
- listnode_add(config, item);
- node = listnode_lookup(config, item);
- if (node)
+ for (ALL_LIST_ELEMENTS_RO(config, node, pnt)) {
+ if (strcmp(pnt, line) == 0)
+ break;
+ }
+
+ if (!node)
+ config_add_line(config, line);
+ else
listnode_move_to_tail(config, node);
}
@@ -158,8 +225,6 @@ void vtysh_config_parse_line(void *arg, const char *line)
if (c == '\0')
return;
- /* printf ("[%s]\n", line); */
-
switch (c) {
/* Suppress exclamation points ! and commented lines. The !s are
* generated
@@ -178,10 +243,10 @@ void vtysh_config_parse_line(void *arg, const char *line)
} else if (strncmp(line, " ip multicast boundary",
strlen(" ip multicast boundary"))
== 0) {
- config_add_line_end(config->line, line);
+ config_add_line_uniq_end(config->line, line);
} else if (strncmp(line, " ip igmp query-interval",
strlen(" ip igmp query-interval")) == 0) {
- config_add_line_end(config->line, line);
+ config_add_line_uniq_end(config->line, line);
} else if (config->index == LINK_PARAMS_NODE
&& strncmp(line, " exit-link-params",
strlen(" exit"))
@@ -192,8 +257,7 @@ void vtysh_config_parse_line(void *arg, const char *line)
&& strncmp(line, " exit-vrf",
strlen(" exit-vrf"))
== 0) {
- config_add_line(config->line, line);
- config->index = CONFIG_NODE;
+ config_add_line_uniq_end(config->line, line);
} else if (config->index == RMAP_NODE
|| config->index == INTERFACE_NODE
|| config->index == LOGICALROUTER_NODE
diff --git a/zebra/if_sysctl.c b/zebra/if_sysctl.c
index 3f918c361a..44afd266bc 100644
--- a/zebra/if_sysctl.c
+++ b/zebra/if_sysctl.c
@@ -61,7 +61,7 @@ void ifstat_update_sysctl(void)
/* We free this memory at the end of this function. */
ref = buf = XMALLOC(MTYPE_TMP, bufsiz);
- /* Fetch interface informations into allocated buffer. */
+ /* Fetch interface information into allocated buffer. */
if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0) {
flog_warn(EC_ZEBRA_SYSCTL_FAILED, "sysctl error by %s",
safe_strerror(errno));
@@ -113,7 +113,7 @@ void interface_list(struct zebra_ns *zns)
/* We free this memory at the end of this function. */
ref = buf = XMALLOC(MTYPE_TMP, bufsiz);
- /* Fetch interface informations into allocated buffer. */
+ /* Fetch interface information into allocated buffer. */
if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0) {
flog_err_sys(EC_ZEBRA_IFLIST_FAILED,
"Could not enumerate interfaces: %s",
diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c
index 2b5bf04ade..bebccd7168 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -97,7 +97,7 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
if (len != iplen) {
flog_err(EC_ZEBRA_IRDP_LEN_MISMATCH,
- "IRDP: RX length doesnt match IP length");
+ "IRDP: RX length doesn't match IP length");
return;
}
@@ -108,7 +108,7 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
return;
}
- /* XXX: RAW doesnt receive link-layer, surely? ??? */
+ /* XXX: RAW doesn't receive link-layer, surely? ??? */
/* Check so we don't checksum packets longer than oure RX_BUF - (ethlen
+
len of IP-header) 14+20 */
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 8df5a37640..9c3d9adefb 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -469,7 +469,7 @@ int ifm_read(struct if_msghdr *ifm)
if (ifnlen && (strncmp(ifp->name, ifname, IFNAMSIZ) != 0)) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
- "%s: ifp name %s doesnt match sdl name %s",
+ "%s: ifp name %s doesn't match sdl name %s",
__func__, ifp->name, ifname);
ifp = NULL;
}
diff --git a/zebra/main.c b/zebra/main.c
index 148bcab7e4..d8952a7b28 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -39,6 +39,7 @@
#include "routemap.h"
#include "frr_pthread.h"
+#include "zebra/zebra_router.h"
#include "zebra/zebra_errors.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
@@ -174,6 +175,8 @@ static void sigint(void)
work_queue_free_and_null(&zebrad.ribq);
meta_queue_free(zebrad.mq);
+ zebra_router_terminate();
+
frr_fini();
exit(0);
}
@@ -354,6 +357,7 @@ int main(int argc, char **argv)
zebrad.master = frr_init();
/* Zebra related initialize. */
+ zebra_router_init();
zserv_init();
rib_init();
zebra_if_init();
@@ -418,7 +422,7 @@ int main(int argc, char **argv)
/* RNH init */
zebra_rnh_init();
-
+
/* Error init */
zebra_error_init();
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index e8d0b71605..c49dc7bab2 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -245,9 +245,12 @@ static int kernel_rtm_ipv4(int cmd, const struct prefix *p,
} /* for (ALL_NEXTHOPS(...))*/
/* If there was no useful nexthop, then complain. */
- if (nexthop_num == 0 && IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug("%s: No useful nexthops were found in RIB entry %p",
- __func__, re);
+ if (nexthop_num == 0) {
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug("%s: No useful nexthops were found in RIB entry %p",
+ __func__, re);
+ return 1;
+ }
return 0; /*XXX*/
}
@@ -374,7 +377,7 @@ static int kernel_rtm_ipv6(int cmd, const struct prefix *p,
if (nexthop_num == 0) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("kernel_rtm_ipv6(): No useful nexthop.");
- return 0;
+ return 1;
}
return 0; /*XXX*/
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 3bb75f3446..a22f6395c9 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -45,6 +45,7 @@
#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_errors.h"
+#include "zebra/zebra_router.h"
extern struct zebra_privs_t zserv_privs;
@@ -391,8 +392,8 @@ static int rtadv_timer(struct thread *thread)
struct zebra_if *zif;
int period;
- zns->rtadv.ra_timer = NULL;
- if (zns->rtadv.adv_msec_if_count == 0) {
+ zrouter.rtadv.ra_timer = NULL;
+ if (zrouter.rtadv.adv_msec_if_count == 0) {
period = 1000; /* 1 s */
rtadv_event(zns, RTADV_TIMER, 1 /* 1 s */);
} else {
@@ -424,7 +425,8 @@ static int rtadv_timer(struct thread *thread)
"Fast RA Rexmit on interface %s",
ifp->name);
- rtadv_send_packet(zns->rtadv.sock, ifp);
+ rtadv_send_packet(zrouter.rtadv.sock,
+ ifp);
} else {
zif->rtadv.AdvIntervalTimer -= period;
if (zif->rtadv.AdvIntervalTimer <= 0) {
@@ -437,7 +439,8 @@ static int rtadv_timer(struct thread *thread)
zif->rtadv
.MaxRtrAdvInterval;
rtadv_send_packet(
- zns->rtadv.sock, ifp);
+ zrouter.rtadv.sock,
+ ifp);
}
}
}
@@ -452,7 +455,7 @@ static void rtadv_process_solicit(struct interface *ifp)
struct zebra_ns *zns = zvrf->zns;
assert(zns);
- rtadv_send_packet(zns->rtadv.sock, ifp);
+ rtadv_send_packet(zrouter.rtadv.sock, ifp);
}
/*
@@ -649,7 +652,7 @@ static int rtadv_read(struct thread *thread)
struct zebra_ns *zns = THREAD_ARG(thread);
sock = THREAD_FD(thread);
- zns->rtadv.ra_read = NULL;
+ zrouter.rtadv.ra_read = NULL;
/* Register myself. */
rtadv_event(zns, RTADV_READ, sock);
@@ -808,18 +811,18 @@ static void ipv6_nd_suppress_ra_set(struct interface *ifp,
if (zif->rtadv.AdvSendAdvertisements) {
zif->rtadv.AdvSendAdvertisements = 0;
zif->rtadv.AdvIntervalTimer = 0;
- zns->rtadv.adv_if_count--;
+ zrouter.rtadv.adv_if_count--;
- if_leave_all_router(zns->rtadv.sock, ifp);
+ if_leave_all_router(zrouter.rtadv.sock, ifp);
- if (zns->rtadv.adv_if_count == 0)
+ if (zrouter.rtadv.adv_if_count == 0)
rtadv_event(zns, RTADV_STOP, 0);
}
} else {
if (!zif->rtadv.AdvSendAdvertisements) {
zif->rtadv.AdvSendAdvertisements = 1;
zif->rtadv.AdvIntervalTimer = 0;
- zns->rtadv.adv_if_count++;
+ zrouter.rtadv.adv_if_count++;
if (zif->rtadv.MaxRtrAdvInterval >= 1000) {
/* Enable Fast RA only when RA interval is in
@@ -829,10 +832,11 @@ static void ipv6_nd_suppress_ra_set(struct interface *ifp,
RTADV_NUM_FAST_REXMITS;
}
- if_join_all_router(zns->rtadv.sock, ifp);
+ if_join_all_router(zrouter.rtadv.sock, ifp);
- if (zns->rtadv.adv_if_count == 1)
- rtadv_event(zns, RTADV_START, zns->rtadv.sock);
+ if (zrouter.rtadv.adv_if_count == 1)
+ rtadv_event(zns, RTADV_START,
+ zrouter.rtadv.sock);
}
}
}
@@ -972,10 +976,7 @@ DEFUN (ipv6_nd_ra_interval_msec,
VTY_DECLVAR_CONTEXT(interface, ifp);
unsigned interval;
struct zebra_if *zif = ifp->info;
- struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id);
- struct zebra_ns *zns;
- zns = zvrf->zns;
interval = strtoul(argv[idx_number]->arg, NULL, 10);
if ((zif->rtadv.AdvDefaultLifetime != -1
&& interval > (unsigned)zif->rtadv.AdvDefaultLifetime * 1000)) {
@@ -985,10 +986,10 @@ DEFUN (ipv6_nd_ra_interval_msec,
}
if (zif->rtadv.MaxRtrAdvInterval % 1000)
- zns->rtadv.adv_msec_if_count--;
+ zrouter.rtadv.adv_msec_if_count--;
if (interval % 1000)
- zns->rtadv.adv_msec_if_count++;
+ zrouter.rtadv.adv_msec_if_count++;
SET_FLAG(zif->rtadv.ra_configured, VTY_RA_INTERVAL_CONFIGURED);
zif->rtadv.MaxRtrAdvInterval = interval;
@@ -1010,10 +1011,7 @@ DEFUN (ipv6_nd_ra_interval,
VTY_DECLVAR_CONTEXT(interface, ifp);
unsigned interval;
struct zebra_if *zif = ifp->info;
- struct zebra_vrf *zvrf = vrf_info_lookup(ifp->vrf_id);
- struct zebra_ns *zns;
- zns = zvrf->zns;
interval = strtoul(argv[idx_number]->arg, NULL, 10);
if ((zif->rtadv.AdvDefaultLifetime != -1
&& interval > (unsigned)zif->rtadv.AdvDefaultLifetime)) {
@@ -1023,7 +1021,7 @@ DEFUN (ipv6_nd_ra_interval,
}
if (zif->rtadv.MaxRtrAdvInterval % 1000)
- zns->rtadv.adv_msec_if_count--;
+ zrouter.rtadv.adv_msec_if_count--;
/* convert to milliseconds */
interval = interval * 1000;
@@ -1049,14 +1047,9 @@ DEFUN (no_ipv6_nd_ra_interval,
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct zebra_if *zif = ifp->info;
- struct zebra_vrf *zvrf;
- struct zebra_ns *zns;
-
- zvrf = vrf_info_lookup(ifp->vrf_id);
- zns = zvrf->zns;
if (zif->rtadv.MaxRtrAdvInterval % 1000)
- zns->rtadv.adv_msec_if_count--;
+ zrouter.rtadv.adv_msec_if_count--;
UNSET_FLAG(zif->rtadv.ra_configured, VTY_RA_INTERVAL_CONFIGURED);
@@ -1701,7 +1694,7 @@ static int rtadv_config_write(struct vty *vty, struct interface *ifp)
static void rtadv_event(struct zebra_ns *zns, enum rtadv_event event, int val)
{
- struct rtadv *rtadv = &zns->rtadv;
+ struct rtadv *rtadv = &zrouter.rtadv;
switch (event) {
case RTADV_START:
@@ -1740,19 +1733,19 @@ static void rtadv_event(struct zebra_ns *zns, enum rtadv_event event, int val)
void rtadv_init(struct zebra_ns *zns)
{
- zns->rtadv.sock = rtadv_make_socket(zns->ns_id);
+ zrouter.rtadv.sock = rtadv_make_socket(zns->ns_id);
}
void rtadv_terminate(struct zebra_ns *zns)
{
rtadv_event(zns, RTADV_STOP, 0);
- if (zns->rtadv.sock >= 0) {
- close(zns->rtadv.sock);
- zns->rtadv.sock = -1;
+ if (zrouter.rtadv.sock >= 0) {
+ close(zrouter.rtadv.sock);
+ zrouter.rtadv.sock = -1;
}
- zns->rtadv.adv_if_count = 0;
- zns->rtadv.adv_msec_if_count = 0;
+ zrouter.rtadv.adv_if_count = 0;
+ zrouter.rtadv.adv_msec_if_count = 0;
}
void rtadv_cmd_init(void)
diff --git a/zebra/subdir.am b/zebra/subdir.am
index bf2c393233..b8f5e0d409 100644
--- a/zebra/subdir.am
+++ b/zebra/subdir.am
@@ -79,6 +79,7 @@ zebra_zebra_SOURCES = \
zebra/zebra_ptm_redistribute.c \
zebra/zebra_pw.c \
zebra/zebra_rib.c \
+ zebra/zebra_router.c \
zebra/zebra_rnh.c \
zebra/zebra_routemap.c \
zebra/zebra_vrf.c \
@@ -131,6 +132,7 @@ noinst_HEADERS += \
zebra/zebra_pw.h \
zebra/zebra_rnh.h \
zebra/zebra_routemap.h \
+ zebra/zebra_router.h \
zebra/zebra_vrf.h \
zebra/zebra_vxlan.h \
zebra/zebra_vxlan_private.h \
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 149d2cb6a5..276b825b34 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -2243,10 +2243,11 @@ static inline void zread_rule(ZAPI_HANDLER_ARGS)
if (zpr.rule.filter.fwmark)
zpr.rule.filter.filter_bm |= PBR_FILTER_FWMARK;
+ zpr.vrf_id = zvrf->vrf->vrf_id;
if (hdr->command == ZEBRA_RULE_ADD)
- zebra_pbr_add_rule(zvrf->zns, &zpr);
+ zebra_pbr_add_rule(&zpr);
else
- zebra_pbr_del_rule(zvrf->zns, &zpr);
+ zebra_pbr_del_rule(&zpr);
}
stream_failure:
@@ -2272,9 +2273,9 @@ static inline void zread_ipset(ZAPI_HANDLER_ARGS)
STREAM_GET(&zpi.ipset_name, s, ZEBRA_IPSET_NAME_SIZE);
if (hdr->command == ZEBRA_IPSET_CREATE)
- zebra_pbr_create_ipset(zvrf->zns, &zpi);
+ zebra_pbr_create_ipset(&zpi);
else
- zebra_pbr_destroy_ipset(zvrf->zns, &zpi);
+ zebra_pbr_destroy_ipset(&zpi);
}
stream_failure:
@@ -2327,12 +2328,12 @@ static inline void zread_ipset_entry(ZAPI_HANDLER_ARGS)
zpi.filter_bm |= PBR_FILTER_PROTO;
/* calculate backpointer */
- zpi.backpointer = zebra_pbr_lookup_ipset_pername(
- zvrf->zns, ipset.ipset_name);
+ zpi.backpointer =
+ zebra_pbr_lookup_ipset_pername(ipset.ipset_name);
if (hdr->command == ZEBRA_IPSET_ENTRY_ADD)
- zebra_pbr_add_ipset_entry(zvrf->zns, &zpi);
+ zebra_pbr_add_ipset_entry(&zpi);
else
- zebra_pbr_del_ipset_entry(zvrf->zns, &zpi);
+ zebra_pbr_del_ipset_entry(&zpi);
}
stream_failure:
@@ -2367,9 +2368,9 @@ static inline void zread_iptable(ZAPI_HANDLER_ARGS)
zebra_pbr_iptable_update_interfacelist(s, &zpi);
if (hdr->command == ZEBRA_IPTABLE_ADD)
- zebra_pbr_add_iptable(zvrf->zns, &zpi);
+ zebra_pbr_add_iptable(&zpi);
else
- zebra_pbr_del_iptable(zvrf->zns, &zpi);
+ zebra_pbr_del_iptable(&zpi);
stream_failure:
return;
}
diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c
index e251b26be1..e65f23dc8a 100644
--- a/zebra/zebra_ns.c
+++ b/zebra/zebra_ns.c
@@ -44,28 +44,8 @@ extern struct zebra_privs_t zserv_privs;
DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space")
-static inline int zebra_ns_table_entry_compare(const struct zebra_ns_table *e1,
- const struct zebra_ns_table *e2);
-
-RB_GENERATE(zebra_ns_table_head, zebra_ns_table, zebra_ns_table_entry,
- zebra_ns_table_entry_compare);
-
static struct zebra_ns *dzns;
-static inline int zebra_ns_table_entry_compare(const struct zebra_ns_table *e1,
- const struct zebra_ns_table *e2)
-{
- if (e1->tableid < e2->tableid)
- return -1;
- if (e1->tableid > e2->tableid)
- return 1;
- if (e1->ns_id < e2->ns_id)
- return -1;
- if (e1->ns_id > e2->ns_id)
- return 1;
- return (e1->afi - e2->afi);
-}
-
static int logicalrouter_config_write(struct vty *vty);
struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id)
@@ -141,24 +121,6 @@ int zebra_ns_enable(ns_id_t ns_id, void **info)
zns->ns_id = ns_id;
- zns->rules_hash =
- hash_create_size(8, zebra_pbr_rules_hash_key,
- zebra_pbr_rules_hash_equal, "Rules Hash");
-
- zns->ipset_hash =
- hash_create_size(8, zebra_pbr_ipset_hash_key,
- zebra_pbr_ipset_hash_equal, "IPset Hash");
-
- zns->ipset_entry_hash =
- hash_create_size(8, zebra_pbr_ipset_entry_hash_key,
- zebra_pbr_ipset_entry_hash_equal,
- "IPset Hash Entry");
-
- zns->iptable_hash =
- hash_create_size(8, zebra_pbr_iptable_hash_key,
- zebra_pbr_iptable_hash_equal,
- "IPtable Hash Entry");
-
#if defined(HAVE_RTADV)
rtadv_init(zns);
#endif
@@ -173,123 +135,10 @@ int zebra_ns_enable(ns_id_t ns_id, void **info)
return 0;
}
-struct route_table *zebra_ns_find_table(struct zebra_ns *zns, uint32_t tableid,
- afi_t afi)
-{
- struct zebra_ns_table finder;
- struct zebra_ns_table *znst;
-
- memset(&finder, 0, sizeof(finder));
- finder.afi = afi;
- finder.tableid = tableid;
- finder.ns_id = zns->ns_id;
- znst = RB_FIND(zebra_ns_table_head, &zns->ns_tables, &finder);
-
- if (znst)
- return znst->table;
- else
- return NULL;
-}
-
-unsigned long zebra_ns_score_proto(uint8_t proto, unsigned short instance)
-{
- struct zebra_ns *zns;
- struct zebra_ns_table *znst;
- unsigned long cnt = 0;
-
- zns = zebra_ns_lookup(NS_DEFAULT);
-
- RB_FOREACH (znst, zebra_ns_table_head, &zns->ns_tables) {
- if (znst->ns_id != NS_DEFAULT)
- continue;
- cnt += rib_score_proto_table(proto, instance, znst->table);
- }
- return cnt;
-}
-
-void zebra_ns_sweep_route(void)
-{
- struct zebra_ns_table *znst;
- struct zebra_ns *zns;
-
- zns = zebra_ns_lookup(NS_DEFAULT);
-
- RB_FOREACH (znst, zebra_ns_table_head, &zns->ns_tables) {
- if (znst->ns_id != NS_DEFAULT)
- continue;
- rib_sweep_table(znst->table);
- }
-}
-
-struct route_table *zebra_ns_get_table(struct zebra_ns *zns,
- struct zebra_vrf *zvrf, uint32_t tableid,
- afi_t afi)
-{
- struct zebra_ns_table finder;
- struct zebra_ns_table *znst;
- rib_table_info_t *info;
-
- memset(&finder, 0, sizeof(finder));
- finder.afi = afi;
- finder.tableid = tableid;
- finder.ns_id = zns->ns_id;
- znst = RB_FIND(zebra_ns_table_head, &zns->ns_tables, &finder);
-
- if (znst)
- return znst->table;
-
- znst = XCALLOC(MTYPE_ZEBRA_NS, sizeof(*znst));
- znst->tableid = tableid;
- znst->afi = afi;
- znst->ns_id = zns->ns_id;
- znst->table =
- (afi == AFI_IP6) ? srcdest_table_init() : route_table_init();
-
- info = XCALLOC(MTYPE_RIB_TABLE_INFO, sizeof(*info));
- info->zvrf = zvrf;
- info->afi = afi;
- info->safi = SAFI_UNICAST;
- route_table_set_info(znst->table, info);
- znst->table->cleanup = zebra_rtable_node_cleanup;
-
- RB_INSERT(zebra_ns_table_head, &zns->ns_tables, znst);
- return znst->table;
-}
-
-static void zebra_ns_free_table(struct zebra_ns_table *znst)
-{
- void *table_info;
-
- rib_close_table(znst->table);
-
- table_info = route_table_get_info(znst->table);
- route_table_finish(znst->table);
- XFREE(MTYPE_RIB_TABLE_INFO, table_info);
- XFREE(MTYPE_ZEBRA_NS, znst);
-}
-
int zebra_ns_disable(ns_id_t ns_id, void **info)
{
- struct zebra_ns_table *znst, *tmp;
struct zebra_ns *zns = (struct zebra_ns *)(*info);
- hash_clean(zns->rules_hash, zebra_pbr_rules_free);
- hash_free(zns->rules_hash);
- hash_clean(zns->ipset_entry_hash, zebra_pbr_ipset_entry_free);
- hash_clean(zns->ipset_hash, zebra_pbr_ipset_free);
- hash_free(zns->ipset_hash);
- hash_free(zns->ipset_entry_hash);
- hash_clean(zns->iptable_hash,
- zebra_pbr_iptable_free);
- hash_free(zns->iptable_hash);
-
- RB_FOREACH_SAFE (znst, zebra_ns_table_head, &zns->ns_tables, tmp) {
- if (znst->ns_id != ns_id)
- continue;
- RB_REMOVE(zebra_ns_table_head, &zns->ns_tables, znst);
- zebra_ns_free_table(znst);
- }
-
route_table_finish(zns->if_table);
zebra_vxlan_ns_disable(zns);
#if defined(HAVE_RTADV)
@@ -339,6 +188,7 @@ int zebra_ns_init(void)
zebra_ns_notify_parse();
zebra_ns_notify_init();
}
+
return 0;
}
diff --git a/zebra/zebra_ns.h b/zebra/zebra_ns.h
index ed70a34c0b..c1a9b41b8d 100644
--- a/zebra/zebra_ns.h
+++ b/zebra/zebra_ns.h
@@ -38,19 +38,6 @@ struct nlsock {
};
#endif
-struct zebra_ns_table {
- RB_ENTRY(zebra_ns_table) zebra_ns_table_entry;
-
- uint32_t tableid;
- afi_t afi;
- ns_id_t ns_id;
-
- struct route_table *table;
-};
-RB_HEAD(zebra_ns_table_head, zebra_ns_table);
-RB_PROTOTYPE(zebra_ns_table_head, zebra_ns_table, zebra_ns_table_entry,
- zebra_ns_table_entry_compare)
-
struct zebra_ns {
/* net-ns name. */
char name[VRF_NAMSIZ];
@@ -66,23 +53,6 @@ struct zebra_ns {
struct route_table *if_table;
- /* L3-VNI hash table (for EVPN). Only in default instance */
- struct hash *l3vni_table;
-
-#if defined(HAVE_RTADV)
- struct rtadv rtadv;
-#endif /* HAVE_RTADV */
-
- struct zebra_ns_table_head ns_tables;
-
- struct hash *rules_hash;
-
- struct hash *ipset_hash;
-
- struct hash *ipset_entry_hash;
-
- struct hash *iptable_hash;
-
/* Back pointer */
struct ns *ns;
};
@@ -94,13 +64,6 @@ int zebra_ns_enable(ns_id_t ns_id, void **info);
int zebra_ns_disabled(struct ns *ns);
int zebra_ns_disable(ns_id_t ns_id, void **info);
-extern struct route_table *zebra_ns_find_table(struct zebra_ns *zns,
- uint32_t tableid, afi_t afi);
-extern struct route_table *zebra_ns_get_table(struct zebra_ns *zns,
- struct zebra_vrf *zvrf,
- uint32_t tableid, afi_t afi);
int zebra_ns_config_write(struct vty *vty, struct ns *ns);
-unsigned long zebra_ns_score_proto(uint8_t proto, unsigned short instance);
-void zebra_ns_sweep_route(void);
#endif
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c
index 1a528780c1..833306bcc4 100644
--- a/zebra/zebra_pbr.c
+++ b/zebra/zebra_pbr.c
@@ -26,6 +26,7 @@
#include <memory.h>
#include <hook.h>
+#include "zebra/zebra_router.h"
#include "zebra/zebra_pbr.h"
#include "zebra/rt.h"
#include "zebra/zapi_msg.h"
@@ -102,30 +103,24 @@ static const struct message fragment_value_str[] = {
};
/* static function declarations */
-DEFINE_HOOK(zebra_pbr_ipset_entry_wrap_script_get_stat, (struct zebra_ns *zns,
- struct zebra_pbr_ipset_entry *ipset,
- uint64_t *pkts, uint64_t *bytes),
- (zns, ipset, pkts, bytes))
-
-DEFINE_HOOK(zebra_pbr_iptable_wrap_script_get_stat, (struct zebra_ns *zns,
- struct zebra_pbr_iptable *iptable,
- uint64_t *pkts, uint64_t *bytes),
- (zns, iptable, pkts, bytes))
-
-DEFINE_HOOK(zebra_pbr_iptable_wrap_script_update, (struct zebra_ns *zns,
- int cmd,
- struct zebra_pbr_iptable *iptable),
- (zns, cmd, iptable));
-
-DEFINE_HOOK(zebra_pbr_ipset_entry_wrap_script_update, (struct zebra_ns *zns,
- int cmd,
- struct zebra_pbr_ipset_entry *ipset),
- (zns, cmd, ipset));
-
-DEFINE_HOOK(zebra_pbr_ipset_wrap_script_update, (struct zebra_ns *zns,
- int cmd,
- struct zebra_pbr_ipset *ipset),
- (zns, cmd, ipset));
+DEFINE_HOOK(zebra_pbr_ipset_entry_get_stat,
+ (struct zebra_pbr_ipset_entry *ipset, uint64_t *pkts,
+ uint64_t *bytes),
+ (ipset, pkts, bytes))
+
+DEFINE_HOOK(zebra_pbr_iptable_get_stat,
+ (struct zebra_pbr_iptable *iptable, uint64_t *pkts,
+ uint64_t *bytes),
+ (iptable, pkts, bytes))
+
+DEFINE_HOOK(zebra_pbr_iptable_update,
+ (int cmd, struct zebra_pbr_iptable *iptable), (cmd, iptable));
+
+DEFINE_HOOK(zebra_pbr_ipset_entry_update,
+ (int cmd, struct zebra_pbr_ipset_entry *ipset), (cmd, ipset));
+
+DEFINE_HOOK(zebra_pbr_ipset_update,
+ (int cmd, struct zebra_pbr_ipset *ipset), (cmd, ipset));
/* Private functions */
@@ -158,6 +153,9 @@ uint32_t zebra_pbr_rules_hash_key(void *arg)
key = jhash_1word(rule->rule.filter.fwmark, key);
else
key = jhash_1word(0, key);
+
+ key = jhash_1word(rule->vrf_id, key);
+
return jhash_3words(rule->rule.filter.src_port,
rule->rule.filter.dst_port,
prefix_hash_key(&rule->rule.filter.dst_ip),
@@ -201,6 +199,9 @@ bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
if (r1->ifp != r2->ifp)
return false;
+ if (r1->vrf_id != r2->vrf_id)
+ return false;
+
return true;
}
@@ -208,6 +209,7 @@ struct pbr_rule_unique_lookup {
struct zebra_pbr_rule *rule;
uint32_t unique;
struct interface *ifp;
+ vrf_id_t vrf_id;
};
static int pbr_rule_lookup_unique_walker(struct hash_backet *b, void *data)
@@ -215,7 +217,9 @@ static int pbr_rule_lookup_unique_walker(struct hash_backet *b, void *data)
struct pbr_rule_unique_lookup *pul = data;
struct zebra_pbr_rule *rule = b->data;
- if (pul->unique == rule->rule.unique && pul->ifp == rule->ifp) {
+ if (pul->unique == rule->rule.unique
+ && pul->ifp == rule->ifp
+ && pul->vrf_id == rule->vrf_id) {
pul->rule = rule;
return HASHWALK_ABORT;
}
@@ -223,16 +227,16 @@ static int pbr_rule_lookup_unique_walker(struct hash_backet *b, void *data)
return HASHWALK_CONTINUE;
}
-static struct zebra_pbr_rule *pbr_rule_lookup_unique(struct zebra_ns *zns,
- uint32_t unique,
- struct interface *ifp)
+static struct zebra_pbr_rule *
+pbr_rule_lookup_unique(struct zebra_pbr_rule *zrule)
{
struct pbr_rule_unique_lookup pul;
- pul.unique = unique;
- pul.ifp = ifp;
+ pul.unique = zrule->rule.unique;
+ pul.ifp = zrule->ifp;
pul.rule = NULL;
- hash_walk(zns->rules_hash, &pbr_rule_lookup_unique_walker, &pul);
+ pul.vrf_id = zrule->vrf_id;
+ hash_walk(zrouter.rules_hash, &pbr_rule_lookup_unique_walker, &pul);
return pul.rule;
}
@@ -240,15 +244,9 @@ static struct zebra_pbr_rule *pbr_rule_lookup_unique(struct zebra_ns *zns,
void zebra_pbr_ipset_free(void *arg)
{
struct zebra_pbr_ipset *ipset;
- struct zebra_ns *zns;
ipset = (struct zebra_pbr_ipset *)arg;
- if (vrf_is_backend_netns())
- zns = zebra_ns_lookup(ipset->vrf_id);
- else
- zns = zebra_ns_lookup(NS_DEFAULT);
- hook_call(zebra_pbr_ipset_wrap_script_update,
- zns, 0, ipset);
+ hook_call(zebra_pbr_ipset_update, 0, ipset);
XFREE(MTYPE_TMP, ipset);
}
@@ -256,8 +254,9 @@ uint32_t zebra_pbr_ipset_hash_key(void *arg)
{
struct zebra_pbr_ipset *ipset = (struct zebra_pbr_ipset *)arg;
uint32_t *pnt = (uint32_t *)&ipset->ipset_name;
+ uint32_t key = jhash_1word(ipset->vrf_id, 0x63ab42de);
- return jhash2(pnt, ZEBRA_IPSET_NAME_HASH_SIZE, 0x63ab42de);
+ return jhash2(pnt, ZEBRA_IPSET_NAME_HASH_SIZE, key);
}
bool zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2)
@@ -271,6 +270,9 @@ bool zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2)
return false;
if (r1->unique != r2->unique)
return false;
+ if (r1->vrf_id != r2->vrf_id)
+ return false;
+
if (strncmp(r1->ipset_name, r2->ipset_name,
ZEBRA_IPSET_NAME_SIZE))
return false;
@@ -280,17 +282,10 @@ bool zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2)
void zebra_pbr_ipset_entry_free(void *arg)
{
struct zebra_pbr_ipset_entry *ipset;
- struct zebra_ns *zns;
ipset = (struct zebra_pbr_ipset_entry *)arg;
- if (ipset->backpointer && vrf_is_backend_netns()) {
- struct zebra_pbr_ipset *ips = ipset->backpointer;
- zns = zebra_ns_lookup((ns_id_t)ips->vrf_id);
- } else
- zns = zebra_ns_lookup(NS_DEFAULT);
- hook_call(zebra_pbr_ipset_entry_wrap_script_update,
- zns, 0, ipset);
+ hook_call(zebra_pbr_ipset_entry_update, 0, ipset);
XFREE(MTYPE_TMP, ipset);
}
@@ -351,15 +346,9 @@ void zebra_pbr_iptable_free(void *arg)
struct zebra_pbr_iptable *iptable;
struct listnode *node, *nnode;
char *name;
- struct zebra_ns *zns;
iptable = (struct zebra_pbr_iptable *)arg;
- if (vrf_is_backend_netns())
- zns = zebra_ns_lookup((ns_id_t)iptable->vrf_id);
- else
- zns = zebra_ns_lookup(NS_DEFAULT);
- hook_call(zebra_pbr_iptable_wrap_script_update,
- zns, 0, iptable);
+ hook_call(zebra_pbr_iptable_update, 0, iptable);
for (ALL_LIST_ELEMENTS(iptable->interface_name_list,
node, nnode, name)) {
@@ -385,6 +374,8 @@ uint32_t zebra_pbr_iptable_hash_key(void *arg)
key = jhash_1word(iptable->tcp_mask_flags, key);
key = jhash_1word(iptable->dscp_value, key);
key = jhash_1word(iptable->fragment, key);
+ key = jhash_1word(iptable->vrf_id, key);
+
return jhash_3words(iptable->filter_bm, iptable->type,
iptable->unique, key);
}
@@ -396,6 +387,8 @@ bool zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2)
r1 = (const struct zebra_pbr_iptable *)arg1;
r2 = (const struct zebra_pbr_iptable *)arg2;
+ if (r1->vrf_id != r2->vrf_id)
+ return 0;
if (r1->type != r2->type)
return false;
if (r1->unique != r2->unique)
@@ -438,30 +431,30 @@ static void *pbr_rule_alloc_intern(void *arg)
return new;
}
-void zebra_pbr_add_rule(struct zebra_ns *zns, struct zebra_pbr_rule *rule)
+void zebra_pbr_add_rule(struct zebra_pbr_rule *rule)
{
struct zebra_pbr_rule *unique =
- pbr_rule_lookup_unique(zns, rule->rule.unique, rule->ifp);
+ pbr_rule_lookup_unique(rule);
- (void)hash_get(zns->rules_hash, rule, pbr_rule_alloc_intern);
+ (void)hash_get(zrouter.rules_hash, rule, pbr_rule_alloc_intern);
(void)kernel_add_pbr_rule(rule);
/*
* Rule Replace semantics, if we have an old, install the
* new rule, look above, and then delete the old
*/
if (unique)
- zebra_pbr_del_rule(zns, unique);
+ zebra_pbr_del_rule(unique);
}
-void zebra_pbr_del_rule(struct zebra_ns *zns, struct zebra_pbr_rule *rule)
+void zebra_pbr_del_rule(struct zebra_pbr_rule *rule)
{
struct zebra_pbr_rule *lookup;
- lookup = hash_lookup(zns->rules_hash, rule);
+ lookup = hash_lookup(zrouter.rules_hash, rule);
(void)kernel_del_pbr_rule(rule);
if (lookup) {
- hash_release(zns->rules_hash, lookup);
+ hash_release(zrouter.rules_hash, lookup);
XFREE(MTYPE_TMP, lookup);
} else
zlog_debug("%s: Rule being deleted we know nothing about",
@@ -470,70 +463,60 @@ void zebra_pbr_del_rule(struct zebra_ns *zns, struct zebra_pbr_rule *rule)
static void zebra_pbr_cleanup_rules(struct hash_backet *b, void *data)
{
- struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
struct zebra_pbr_rule *rule = b->data;
int *sock = data;
if (rule->sock == *sock) {
(void)kernel_del_pbr_rule(rule);
- hash_release(zns->rules_hash, rule);
+ hash_release(zrouter.rules_hash, rule);
XFREE(MTYPE_TMP, rule);
}
}
static void zebra_pbr_cleanup_ipset(struct hash_backet *b, void *data)
{
- struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
struct zebra_pbr_ipset *ipset = b->data;
int *sock = data;
if (ipset->sock == *sock) {
- hook_call(zebra_pbr_ipset_wrap_script_update,
- zns, 0, ipset);
- hash_release(zns->ipset_hash, ipset);
+ hook_call(zebra_pbr_ipset_update, 0, ipset);
+ hash_release(zrouter.ipset_hash, ipset);
}
}
static void zebra_pbr_cleanup_ipset_entry(struct hash_backet *b, void *data)
{
- struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
struct zebra_pbr_ipset_entry *ipset = b->data;
int *sock = data;
if (ipset->sock == *sock) {
- hook_call(zebra_pbr_ipset_entry_wrap_script_update,
- zns, 0, ipset);
- hash_release(zns->ipset_entry_hash, ipset);
+ hook_call(zebra_pbr_ipset_entry_update, 0, ipset);
+ hash_release(zrouter.ipset_entry_hash, ipset);
}
}
static void zebra_pbr_cleanup_iptable(struct hash_backet *b, void *data)
{
- struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
struct zebra_pbr_iptable *iptable = b->data;
int *sock = data;
if (iptable->sock == *sock) {
- hook_call(zebra_pbr_iptable_wrap_script_update,
- zns, 0, iptable);
- hash_release(zns->iptable_hash, iptable);
+ hook_call(zebra_pbr_iptable_update, 0, iptable);
+ hash_release(zrouter.iptable_hash, iptable);
}
}
static int zebra_pbr_client_close_cleanup(struct zserv *client)
{
int sock = client->sock;
- struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
if (!sock)
return 0;
- hash_iterate(zns->rules_hash, zebra_pbr_cleanup_rules, &sock);
- hash_iterate(zns->iptable_hash,
- zebra_pbr_cleanup_iptable, &sock);
- hash_iterate(zns->ipset_entry_hash,
- zebra_pbr_cleanup_ipset_entry, &sock);
- hash_iterate(zns->ipset_hash,
- zebra_pbr_cleanup_ipset, &sock);
+ hash_iterate(zrouter.rules_hash, zebra_pbr_cleanup_rules, &sock);
+ hash_iterate(zrouter.iptable_hash, zebra_pbr_cleanup_iptable, &sock);
+ hash_iterate(zrouter.ipset_entry_hash, zebra_pbr_cleanup_ipset_entry,
+ &sock);
+ hash_iterate(zrouter.ipset_hash, zebra_pbr_cleanup_ipset, &sock);
return 1;
}
@@ -556,29 +539,25 @@ static void *pbr_ipset_alloc_intern(void *arg)
return new;
}
-void zebra_pbr_create_ipset(struct zebra_ns *zns,
- struct zebra_pbr_ipset *ipset)
+void zebra_pbr_create_ipset(struct zebra_pbr_ipset *ipset)
{
int ret;
- (void)hash_get(zns->ipset_hash, ipset, pbr_ipset_alloc_intern);
- ret = hook_call(zebra_pbr_ipset_wrap_script_update,
- zns, 1, ipset);
+ (void)hash_get(zrouter.ipset_hash, ipset, pbr_ipset_alloc_intern);
+ ret = hook_call(zebra_pbr_ipset_update, 1, ipset);
kernel_pbr_ipset_add_del_status(ipset,
ret ? ZEBRA_DPLANE_INSTALL_SUCCESS
: ZEBRA_DPLANE_INSTALL_FAILURE);
}
-void zebra_pbr_destroy_ipset(struct zebra_ns *zns,
- struct zebra_pbr_ipset *ipset)
+void zebra_pbr_destroy_ipset(struct zebra_pbr_ipset *ipset)
{
struct zebra_pbr_ipset *lookup;
- lookup = hash_lookup(zns->ipset_hash, ipset);
- hook_call(zebra_pbr_ipset_wrap_script_update,
- zns, 0, ipset);
+ lookup = hash_lookup(zrouter.ipset_hash, ipset);
+ hook_call(zebra_pbr_ipset_update, 0, ipset);
if (lookup) {
- hash_release(zns->ipset_hash, lookup);
+ hash_release(zrouter.ipset_hash, lookup);
XFREE(MTYPE_TMP, lookup);
} else
zlog_debug(
@@ -611,8 +590,7 @@ static int zebra_pbr_ipset_pername_walkcb(struct hash_backet *backet, void *arg)
return HASHWALK_CONTINUE;
}
-struct zebra_pbr_ipset *zebra_pbr_lookup_ipset_pername(struct zebra_ns *zns,
- char *ipsetname)
+struct zebra_pbr_ipset *zebra_pbr_lookup_ipset_pername(char *ipsetname)
{
struct pbr_ipset_name_lookup pinl;
struct pbr_ipset_name_lookup *ptr = &pinl;
@@ -622,7 +600,7 @@ struct zebra_pbr_ipset *zebra_pbr_lookup_ipset_pername(struct zebra_ns *zns,
memset(ptr, 0, sizeof(struct pbr_ipset_name_lookup));
snprintf((char *)ptr->ipset_name, ZEBRA_IPSET_NAME_SIZE, "%s",
ipsetname);
- hash_walk(zns->ipset_hash, zebra_pbr_ipset_pername_walkcb, ptr);
+ hash_walk(zrouter.ipset_hash, zebra_pbr_ipset_pername_walkcb, ptr);
return ptr->ipset;
}
@@ -640,30 +618,26 @@ static void *pbr_ipset_entry_alloc_intern(void *arg)
return new;
}
-void zebra_pbr_add_ipset_entry(struct zebra_ns *zns,
- struct zebra_pbr_ipset_entry *ipset)
+void zebra_pbr_add_ipset_entry(struct zebra_pbr_ipset_entry *ipset)
{
int ret;
- (void)hash_get(zns->ipset_entry_hash, ipset,
+ (void)hash_get(zrouter.ipset_entry_hash, ipset,
pbr_ipset_entry_alloc_intern);
- ret = hook_call(zebra_pbr_ipset_entry_wrap_script_update,
- zns, 1, ipset);
+ ret = hook_call(zebra_pbr_ipset_entry_update, 1, ipset);
kernel_pbr_ipset_entry_add_del_status(ipset,
ret ? ZEBRA_DPLANE_INSTALL_SUCCESS
: ZEBRA_DPLANE_INSTALL_FAILURE);
}
-void zebra_pbr_del_ipset_entry(struct zebra_ns *zns,
- struct zebra_pbr_ipset_entry *ipset)
+void zebra_pbr_del_ipset_entry(struct zebra_pbr_ipset_entry *ipset)
{
struct zebra_pbr_ipset_entry *lookup;
- lookup = hash_lookup(zns->ipset_entry_hash, ipset);
- hook_call(zebra_pbr_ipset_entry_wrap_script_update,
- zns, 0, ipset);
+ lookup = hash_lookup(zrouter.ipset_entry_hash, ipset);
+ hook_call(zebra_pbr_ipset_entry_update, 0, ipset);
if (lookup) {
- hash_release(zns->ipset_entry_hash, lookup);
+ hash_release(zrouter.ipset_entry_hash, lookup);
XFREE(MTYPE_TMP, lookup);
} else
zlog_debug("%s: IPSet being deleted we know nothing about",
@@ -684,31 +658,28 @@ static void *pbr_iptable_alloc_intern(void *arg)
return new;
}
-void zebra_pbr_add_iptable(struct zebra_ns *zns,
- struct zebra_pbr_iptable *iptable)
+void zebra_pbr_add_iptable(struct zebra_pbr_iptable *iptable)
{
int ret;
- (void)hash_get(zns->iptable_hash, iptable,
- pbr_iptable_alloc_intern);
- ret = hook_call(zebra_pbr_iptable_wrap_script_update, zns, 1, iptable);
+ (void)hash_get(zrouter.iptable_hash, iptable, pbr_iptable_alloc_intern);
+ ret = hook_call(zebra_pbr_iptable_update, 1, iptable);
kernel_pbr_iptable_add_del_status(iptable,
ret ? ZEBRA_DPLANE_INSTALL_SUCCESS
: ZEBRA_DPLANE_INSTALL_FAILURE);
}
-void zebra_pbr_del_iptable(struct zebra_ns *zns,
- struct zebra_pbr_iptable *iptable)
+void zebra_pbr_del_iptable(struct zebra_pbr_iptable *iptable)
{
struct zebra_pbr_iptable *lookup;
- lookup = hash_lookup(zns->iptable_hash, iptable);
- hook_call(zebra_pbr_iptable_wrap_script_update, zns, 0, iptable);
+ lookup = hash_lookup(zrouter.iptable_hash, iptable);
+ hook_call(zebra_pbr_iptable_update, 0, iptable);
if (lookup) {
struct listnode *node, *nnode;
char *name;
- hash_release(zns->iptable_hash, lookup);
+ hash_release(zrouter.iptable_hash, lookup);
for (ALL_LIST_ELEMENTS(iptable->interface_name_list,
node, nnode, name)) {
XFREE(MTYPE_PBR_IPTABLE_IFNAME, name);
@@ -913,7 +884,6 @@ static int zebra_pbr_show_ipset_entry_walkcb(struct hash_backet *backet,
struct zebra_pbr_ipset_entry *zpie =
(struct zebra_pbr_ipset_entry *)backet->data;
uint64_t pkts = 0, bytes = 0;
- struct zebra_ns *zns = unique->zns;
int ret = 0;
if (zpie->backpointer != zpi)
@@ -971,8 +941,8 @@ static int zebra_pbr_show_ipset_entry_walkcb(struct hash_backet *backet,
}
vty_out(vty, " (%u)\n", zpie->unique);
- ret = hook_call(zebra_pbr_ipset_entry_wrap_script_get_stat,
- zns, zpie, &pkts, &bytes);
+ ret = hook_call(zebra_pbr_ipset_entry_get_stat, zpie, &pkts,
+ &bytes);
if (ret && pkts > 0)
vty_out(vty, "\t pkts %" PRIu64 ", bytes %" PRIu64"\n",
pkts, bytes);
@@ -993,7 +963,7 @@ static int zebra_pbr_show_ipset_walkcb(struct hash_backet *backet, void *arg)
unique.vty = vty;
unique.zpi = zpi;
unique.zns = zns;
- hash_walk(zns->ipset_entry_hash, zebra_pbr_show_ipset_entry_walkcb,
+ hash_walk(zrouter.ipset_entry_hash, zebra_pbr_show_ipset_entry_walkcb,
&unique);
vty_out(vty, "\n");
return HASHWALK_CONTINUE;
@@ -1029,7 +999,7 @@ void zebra_pbr_show_ipset_list(struct vty *vty, char *ipsetname)
struct zebra_pbr_env_display uniqueipset;
if (ipsetname) {
- zpi = zebra_pbr_lookup_ipset_pername(zns, ipsetname);
+ zpi = zebra_pbr_lookup_ipset_pername(ipsetname);
if (!zpi) {
vty_out(vty, "No IPset %s found\n", ipsetname);
return;
@@ -1040,15 +1010,14 @@ void zebra_pbr_show_ipset_list(struct vty *vty, char *ipsetname)
unique.vty = vty;
unique.zpi = zpi;
unique.zns = zns;
- hash_walk(zns->ipset_entry_hash,
- zebra_pbr_show_ipset_entry_walkcb,
- &unique);
+ hash_walk(zrouter.ipset_entry_hash,
+ zebra_pbr_show_ipset_entry_walkcb, &unique);
return;
}
uniqueipset.zns = zns;
uniqueipset.vty = vty;
uniqueipset.name = NULL;
- hash_walk(zns->ipset_hash, zebra_pbr_show_ipset_walkcb,
+ hash_walk(zrouter.ipset_hash, zebra_pbr_show_ipset_walkcb,
&uniqueipset);
}
@@ -1126,8 +1095,8 @@ static void zebra_pbr_show_iptable_unit(struct zebra_pbr_iptable *iptable,
" not" : "", lookup_msg(fragment_value_str,
iptable->fragment, val_str));
}
- ret = hook_call(zebra_pbr_iptable_wrap_script_get_stat,
- zns, iptable, &pkts, &bytes);
+ ret = hook_call(zebra_pbr_iptable_get_stat, iptable, &pkts,
+ &bytes);
if (ret && pkts > 0)
vty_out(vty, "\t pkts %" PRIu64 ", bytes %" PRIu64"\n",
pkts, bytes);
@@ -1136,7 +1105,7 @@ static void zebra_pbr_show_iptable_unit(struct zebra_pbr_iptable *iptable,
prfl.fwmark = iptable->fwmark;
prfl.ptr = NULL;
- hash_walk(zns->rules_hash,
+ hash_walk(zrouter.rules_hash,
&zebra_pbr_rule_lookup_fwmark_walkcb, &prfl);
if (prfl.ptr) {
struct zebra_pbr_rule *zpr = prfl.ptr;
@@ -1174,8 +1143,7 @@ void zebra_pbr_show_iptable(struct vty *vty, char *iptable_name)
env.vty = vty;
env.zns = zns;
env.name = iptable_name;
- hash_walk(zns->iptable_hash, zebra_pbr_show_iptable_walkcb,
- &env);
+ hash_walk(zrouter.iptable_hash, zebra_pbr_show_iptable_walkcb, &env);
}
void zebra_pbr_iptable_update_interfacelist(struct stream *s,
diff --git a/zebra/zebra_pbr.h b/zebra/zebra_pbr.h
index 093fcfa8b0..5b6c23896c 100644
--- a/zebra/zebra_pbr.h
+++ b/zebra/zebra_pbr.h
@@ -38,6 +38,8 @@ struct zebra_pbr_rule {
struct pbr_rule rule;
struct interface *ifp;
+
+ vrf_id_t vrf_id;
};
#define IS_RULE_FILTERING_ON_SRC_IP(r) \
@@ -151,23 +153,16 @@ extern const struct message icmp_typecode_str[];
const char *zebra_pbr_ipset_type2str(uint32_t type);
-void zebra_pbr_add_rule(struct zebra_ns *zns, struct zebra_pbr_rule *rule);
-void zebra_pbr_del_rule(struct zebra_ns *zns, struct zebra_pbr_rule *rule);
-void zebra_pbr_create_ipset(struct zebra_ns *zns,
- struct zebra_pbr_ipset *ipset);
-void zebra_pbr_destroy_ipset(struct zebra_ns *zns,
- struct zebra_pbr_ipset *ipset);
-struct zebra_pbr_ipset *zebra_pbr_lookup_ipset_pername(struct zebra_ns *zns,
- char *ipsetname);
-void zebra_pbr_add_ipset_entry(struct zebra_ns *zns,
- struct zebra_pbr_ipset_entry *ipset);
-void zebra_pbr_del_ipset_entry(struct zebra_ns *zns,
- struct zebra_pbr_ipset_entry *ipset);
-
-void zebra_pbr_add_iptable(struct zebra_ns *zns,
- struct zebra_pbr_iptable *iptable);
-void zebra_pbr_del_iptable(struct zebra_ns *zns,
- struct zebra_pbr_iptable *iptable);
+void zebra_pbr_add_rule(struct zebra_pbr_rule *rule);
+void zebra_pbr_del_rule(struct zebra_pbr_rule *rule);
+void zebra_pbr_create_ipset(struct zebra_pbr_ipset *ipset);
+void zebra_pbr_destroy_ipset(struct zebra_pbr_ipset *ipset);
+struct zebra_pbr_ipset *zebra_pbr_lookup_ipset_pername(char *ipsetname);
+void zebra_pbr_add_ipset_entry(struct zebra_pbr_ipset_entry *ipset);
+void zebra_pbr_del_ipset_entry(struct zebra_pbr_ipset_entry *ipset);
+
+void zebra_pbr_add_iptable(struct zebra_pbr_iptable *iptable);
+void zebra_pbr_del_iptable(struct zebra_pbr_iptable *iptable);
/*
* Install specified rule for a specific interface.
@@ -241,26 +236,20 @@ extern void zebra_pbr_iptable_update_interfacelist(struct stream *s,
size_t zebra_pbr_tcpflags_snprintf(char *buffer, size_t len,
uint16_t tcp_val);
-DECLARE_HOOK(zebra_pbr_ipset_entry_wrap_script_get_stat, (struct zebra_ns *zns,
- struct zebra_pbr_ipset_entry *ipset,
- uint64_t *pkts, uint64_t *bytes),
- (zns, ipset, pkts, bytes))
-DECLARE_HOOK(zebra_pbr_iptable_wrap_script_get_stat, (struct zebra_ns *zns,
- struct zebra_pbr_iptable *iptable,
- uint64_t *pkts, uint64_t *bytes),
- (zns, iptable, pkts, bytes))
-DECLARE_HOOK(zebra_pbr_iptable_wrap_script_update, (struct zebra_ns *zns,
- int cmd,
- struct zebra_pbr_iptable *iptable),
- (zns, cmd, iptable));
-
-DECLARE_HOOK(zebra_pbr_ipset_entry_wrap_script_update, (struct zebra_ns *zns,
- int cmd,
- struct zebra_pbr_ipset_entry *ipset),
- (zns, cmd, ipset));
-DECLARE_HOOK(zebra_pbr_ipset_wrap_script_update, (struct zebra_ns *zns,
- int cmd,
- struct zebra_pbr_ipset *ipset),
- (zns, cmd, ipset));
+DECLARE_HOOK(zebra_pbr_ipset_entry_get_stat,
+ (struct zebra_pbr_ipset_entry *ipset, uint64_t *pkts,
+ uint64_t *bytes),
+ (ipset, pkts, bytes))
+DECLARE_HOOK(zebra_pbr_iptable_get_stat,
+ (struct zebra_pbr_iptable *iptable, uint64_t *pkts,
+ uint64_t *bytes),
+ (iptable, pkts, bytes))
+DECLARE_HOOK(zebra_pbr_iptable_update,
+ (int cmd, struct zebra_pbr_iptable *iptable), (cmd, iptable));
+
+DECLARE_HOOK(zebra_pbr_ipset_entry_update,
+ (int cmd, struct zebra_pbr_ipset_entry *ipset), (cmd, ipset));
+DECLARE_HOOK(zebra_pbr_ipset_update,
+ (int cmd, struct zebra_pbr_ipset *ipset), (cmd, ipset));
#endif /* _ZEBRA_PBR_H */
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index db610098f0..89cbdaf373 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -38,6 +38,7 @@
#include "vrf.h"
#include "workqueue.h"
+#include "zebra/zebra_router.h"
#include "zebra/connected.h"
#include "zebra/debug.h"
#include "zebra/interface.h"
@@ -2930,7 +2931,7 @@ void rib_sweep_route(void)
rib_sweep_table(zvrf->table[AFI_IP6][SAFI_UNICAST]);
}
- zebra_ns_sweep_route();
+ zebra_router_sweep_route();
}
/* Remove specific by protocol routes from 'table'. */
@@ -2972,7 +2973,7 @@ unsigned long rib_score_proto(uint8_t proto, unsigned short instance)
proto, instance,
zvrf->table[AFI_IP6][SAFI_UNICAST]);
- cnt += zebra_ns_score_proto(proto, instance);
+ cnt += zebra_router_score_proto(proto, instance);
return cnt;
}
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index 0a531990dc..df4435b619 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -36,6 +36,7 @@
#include "nexthop.h"
#include "vrf.h"
+#include "zebra/zebra_router.h"
#include "zebra/rib.h"
#include "zebra/rt.h"
#include "zebra/zserv.h"
@@ -469,12 +470,11 @@ static void zebra_rnh_process_pbr_tables(int family,
struct route_node *prn,
struct route_entry *re)
{
- struct zebra_ns_table *znst;
+ struct zebra_router_table *zrt;
struct route_entry *o_re;
struct route_node *o_rn;
struct listnode *node;
struct zserv *client;
- struct zebra_ns *zns;
afi_t afi = AFI_IP;
if (family == AF_INET6)
@@ -492,13 +492,12 @@ static void zebra_rnh_process_pbr_tables(int family,
if (!client)
return;
- zns = zebra_ns_lookup(NS_DEFAULT);
- RB_FOREACH (znst, zebra_ns_table_head, &zns->ns_tables) {
- if (afi != znst->afi)
+ RB_FOREACH (zrt, zebra_router_table_head, &zrouter.tables) {
+ if (afi != zrt->afi)
continue;
- for (o_rn = route_top(znst->table);
- o_rn; o_rn = srcdest_route_next(o_rn)) {
+ for (o_rn = route_top(zrt->table); o_rn;
+ o_rn = srcdest_route_next(o_rn)) {
RNODE_FOREACH_RE (o_rn, o_re) {
if (o_re->type == ZEBRA_ROUTE_PBR)
break;
diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c
new file mode 100644
index 0000000000..99d96fd67f
--- /dev/null
+++ b/zebra/zebra_router.c
@@ -0,0 +1,189 @@
+/* Zebra Router Code.
+ * Copyright (C) 2018 Cumulus Networks, Inc.
+ * Donald Sharp
+ *
+ * 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 "zebra_router.h"
+#include "zebra_memory.h"
+#include "zebra_pbr.h"
+
+struct zebra_router zrouter;
+
+static inline int
+zebra_router_table_entry_compare(const struct zebra_router_table *e1,
+ const struct zebra_router_table *e2);
+
+RB_GENERATE(zebra_router_table_head, zebra_router_table,
+ zebra_router_table_entry, zebra_router_table_entry_compare);
+
+
+static inline int
+zebra_router_table_entry_compare(const struct zebra_router_table *e1,
+ const struct zebra_router_table *e2)
+{
+ if (e1->tableid < e2->tableid)
+ return -1;
+ if (e1->tableid > e2->tableid)
+ return 1;
+ if (e1->ns_id < e2->ns_id)
+ return -1;
+ if (e1->ns_id > e2->ns_id)
+ return 1;
+ if (e1->afi < e2->afi)
+ return -1;
+ if (e1->afi > e2->afi)
+ return 1;
+ return (e1->safi - e2->safi);
+}
+
+
+struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf,
+ uint32_t tableid, afi_t afi,
+ safi_t safi)
+{
+ struct zebra_router_table finder;
+ struct zebra_router_table *zrt;
+
+ memset(&finder, 0, sizeof(finder));
+ finder.afi = afi;
+ finder.safi = safi;
+ finder.tableid = tableid;
+ finder.ns_id = zvrf->zns->ns_id;
+ zrt = RB_FIND(zebra_router_table_head, &zrouter.tables, &finder);
+
+ if (zrt)
+ return zrt->table;
+ else
+ return NULL;
+}
+
+struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf,
+ uint32_t tableid, afi_t afi,
+ safi_t safi)
+{
+ struct zebra_router_table finder;
+ struct zebra_router_table *zrt;
+ rib_table_info_t *info;
+
+ memset(&finder, 0, sizeof(finder));
+ finder.afi = afi;
+ finder.safi = safi;
+ finder.tableid = tableid;
+ finder.ns_id = zvrf->zns->ns_id;
+ zrt = RB_FIND(zebra_router_table_head, &zrouter.tables, &finder);
+
+ if (zrt)
+ return zrt->table;
+
+ zrt = XCALLOC(MTYPE_ZEBRA_NS, sizeof(*zrt));
+ zrt->tableid = tableid;
+ zrt->afi = afi;
+ zrt->ns_id = zvrf->zns->ns_id;
+ zrt->table =
+ (afi == AFI_IP6) ? srcdest_table_init() : route_table_init();
+
+ info = XCALLOC(MTYPE_RIB_TABLE_INFO, sizeof(*info));
+ info->zvrf = zvrf;
+ info->afi = afi;
+ info->safi = SAFI_UNICAST;
+ route_table_set_info(zrt->table, info);
+ zrt->table->cleanup = zebra_rtable_node_cleanup;
+
+ RB_INSERT(zebra_router_table_head, &zrouter.tables, zrt);
+ return zrt->table;
+}
+
+unsigned long zebra_router_score_proto(uint8_t proto, unsigned short instance)
+{
+ struct zebra_router_table *zrt;
+ unsigned long cnt = 0;
+
+ RB_FOREACH (zrt, zebra_router_table_head, &zrouter.tables) {
+ if (zrt->ns_id != NS_DEFAULT)
+ continue;
+ cnt += rib_score_proto_table(proto, instance, zrt->table);
+ }
+ return cnt;
+}
+
+void zebra_router_sweep_route(void)
+{
+ struct zebra_router_table *zrt;
+
+ RB_FOREACH (zrt, zebra_router_table_head, &zrouter.tables) {
+ if (zrt->ns_id != NS_DEFAULT)
+ continue;
+ rib_sweep_table(zrt->table);
+ }
+}
+
+static void zebra_router_free_table(struct zebra_router_table *zrt)
+{
+ void *table_info;
+
+ rib_close_table(zrt->table);
+
+ table_info = route_table_get_info(zrt->table);
+ route_table_finish(zrt->table);
+ XFREE(MTYPE_RIB_TABLE_INFO, table_info);
+ XFREE(MTYPE_ZEBRA_NS, zrt);
+}
+
+void zebra_router_terminate(void)
+{
+ struct zebra_router_table *zrt, *tmp;
+
+ RB_FOREACH_SAFE (zrt, zebra_router_table_head, &zrouter.tables, tmp) {
+ RB_REMOVE(zebra_router_table_head, &zrouter.tables, zrt);
+ zebra_router_free_table(zrt);
+ }
+
+ hash_clean(zrouter.rules_hash, zebra_pbr_rules_free);
+ hash_free(zrouter.rules_hash);
+
+ hash_clean(zrouter.ipset_entry_hash, zebra_pbr_ipset_entry_free),
+ hash_clean(zrouter.ipset_hash, zebra_pbr_ipset_free);
+ hash_free(zrouter.ipset_hash);
+ hash_free(zrouter.ipset_entry_hash);
+ hash_clean(zrouter.iptable_hash, zebra_pbr_iptable_free);
+ hash_free(zrouter.iptable_hash);
+}
+
+void zebra_router_init(void)
+{
+ zrouter.l3vni_table = NULL;
+
+ zrouter.rules_hash = hash_create_size(8, zebra_pbr_rules_hash_key,
+ zebra_pbr_rules_hash_equal,
+ "Rules Hash");
+
+ zrouter.ipset_hash =
+ hash_create_size(8, zebra_pbr_ipset_hash_key,
+ zebra_pbr_ipset_hash_equal, "IPset Hash");
+
+ zrouter.ipset_entry_hash = hash_create_size(
+ 8, zebra_pbr_ipset_entry_hash_key,
+ zebra_pbr_ipset_entry_hash_equal, "IPset Hash Entry");
+
+ zrouter.iptable_hash = hash_create_size(8, zebra_pbr_iptable_hash_key,
+ zebra_pbr_iptable_hash_equal,
+ "IPtable Hash Entry");
+}
diff --git a/zebra/zebra_router.h b/zebra/zebra_router.h
new file mode 100644
index 0000000000..d6b8b66087
--- /dev/null
+++ b/zebra/zebra_router.h
@@ -0,0 +1,84 @@
+/* Zebra Router header.
+ * Copyright (C) 2018 Cumulus Networks, Inc.
+ * Donald Sharp
+ *
+ * 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_ROUTER_H__
+#define __ZEBRA_ROUTER_H__
+
+#include "zebra/zebra_ns.h"
+
+/*
+ * This header file contains the idea of a router and as such
+ * owns data that is associated with a router from zebra's
+ * perspective.
+ */
+
+struct zebra_router_table {
+ RB_ENTRY(zebra_router_table) zebra_router_table_entry;
+
+ uint32_t tableid;
+ afi_t afi;
+ safi_t safi;
+ ns_id_t ns_id;
+
+ struct route_table *table;
+};
+RB_HEAD(zebra_router_table_head, zebra_router_table);
+RB_PROTOTYPE(zebra_router_table_head, zebra_router_table,
+ zebra_router_table_entry, zebra_router_table_entry_compare)
+
+struct zebra_router {
+
+ struct zebra_router_table_head tables;
+
+ /* L3-VNI hash table (for EVPN). Only in default instance */
+ struct hash *l3vni_table;
+
+ struct hash *rules_hash;
+
+ struct hash *ipset_hash;
+
+ struct hash *ipset_entry_hash;
+
+ struct hash *iptable_hash;
+
+#if defined(HAVE_RTADV)
+ struct rtadv rtadv;
+#endif /* HAVE_RTADV */
+};
+
+extern struct zebra_router zrouter;
+
+extern void zebra_router_init(void);
+extern void zebra_router_terminate(void);
+
+extern struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf,
+ uint32_t tableid, afi_t afi,
+ safi_t safi);
+extern struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf,
+ uint32_t tableid, afi_t afi,
+ safi_t safi);
+
+extern int zebra_router_config_write(struct vty *vty);
+
+extern unsigned long zebra_router_score_proto(uint8_t proto,
+ unsigned short instance);
+extern void zebra_router_sweep_route(void);
+#endif
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index a1692d3c3e..e98a533609 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -28,6 +28,7 @@
#include "vrf.h"
#include "vty.h"
+#include "zebra/zebra_router.h"
#include "zebra/debug.h"
#include "zebra/zapi_msg.h"
#include "zebra/rib.h"
@@ -144,7 +145,6 @@ static int zebra_vrf_enable(struct vrf *vrf)
static int zebra_vrf_disable(struct vrf *vrf)
{
struct zebra_vrf *zvrf = vrf->info;
- struct route_table *table;
struct interface *ifp;
afi_t afi;
safi_t safi;
@@ -202,15 +202,16 @@ static int zebra_vrf_disable(struct vrf *vrf)
/* Cleanup (free) routing tables and NHT tables. */
for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
- void *table_info;
-
- for (safi = SAFI_UNICAST; safi <= SAFI_MULTICAST; safi++) {
- table = zvrf->table[afi][safi];
- table_info = route_table_get_info(table);
- route_table_finish(table);
- XFREE(MTYPE_RIB_TABLE_INFO, table_info);
+ /*
+ * Set the table pointer to NULL as that
+ * we no-longer need a copy of it, nor do we
+ * own this data, the zebra_router structure
+ * owns these tables. Once we've cleaned up the
+ * table, see rib_close_table above
+ * we no-longer need this pointer.
+ */
+ for (safi = SAFI_UNICAST; safi <= SAFI_MULTICAST; safi++)
zvrf->table[afi][safi] = NULL;
- }
route_table_finish(zvrf->rnh_table[afi]);
zvrf->rnh_table[afi] = NULL;
@@ -374,10 +375,8 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi,
assert(!zvrf->table[afi][safi]);
- if (afi == AFI_IP6)
- table = srcdest_table_init();
- else
- table = route_table_init();
+ table = zebra_router_get_table(zvrf, zvrf->table_id, afi, safi);
+
table->cleanup = zebra_rtable_node_cleanup;
zvrf->table[afi][safi] = table;
@@ -442,14 +441,11 @@ struct route_table *zebra_vrf_other_route_table(afi_t afi, uint32_t table_id,
vrf_id_t vrf_id)
{
struct zebra_vrf *zvrf;
- struct zebra_ns *zns;
zvrf = vrf_info_lookup(vrf_id);
if (!zvrf)
return NULL;
- zns = zvrf->zns;
-
if (afi >= AFI_MAX)
return NULL;
@@ -461,7 +457,8 @@ struct route_table *zebra_vrf_other_route_table(afi_t afi, uint32_t table_id,
* so in all cases, it does not use specific table
* so it is possible to configure tables in this VRF
*/
- return zebra_ns_get_table(zns, zvrf, table_id, afi);
+ return zebra_router_get_table(zvrf, table_id, afi,
+ SAFI_UNICAST);
}
}
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index fdedb30f84..dd0e270149 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -35,6 +35,7 @@
#include "srcdest_table.h"
#include "vxlan.h"
+#include "zebra/zebra_router.h"
#include "zebra/zserv.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_mpls.h"
@@ -295,7 +296,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
if (vrf)
vty_out(vty, "(vrf %s)", vrf->name);
else
- vty_out(vty, "(vrf UKNOWN)");
+ vty_out(vty, "(vrf UNKNOWN)");
}
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
@@ -670,7 +671,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
if (vrf)
vty_out(vty, "(vrf %s)", vrf->name);
else
- vty_out(vty, "(vrf UKNOWN)");
+ vty_out(vty, "(vrf UNKNOWN)");
}
if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
@@ -896,7 +897,7 @@ DEFPY (show_route_table,
struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
struct route_table *t;
- t = zebra_ns_find_table(zvrf->zns, table, afi);
+ t = zebra_router_find_table(zvrf, table, afi, SAFI_UNICAST);
if (t)
do_show_route_helper(vty, zvrf, t, afi, false, 0, false, false,
0, 0, !!json);
@@ -925,7 +926,7 @@ DEFPY (show_route_table_vrf,
VRF_GET_ID(vrf_id, vrf_name, !!json);
zvrf = zebra_vrf_lookup_by_id(vrf_id);
- t = zebra_ns_find_table(zvrf->zns, table, afi);
+ t = zebra_router_find_table(zvrf, table, afi, SAFI_UNICAST);
if (t)
do_show_route_helper(vty, zvrf, t, afi, false, 0, false, false,
0, 0, !!json);
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index fe182780be..58cf6eb30f 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -37,6 +37,7 @@
#include <linux/neighbour.h>
#endif
+#include "zebra/zebra_router.h"
#include "zebra/debug.h"
#include "zebra/interface.h"
#include "zebra/rib.h"
@@ -1855,7 +1856,7 @@ static int zvni_gw_macip_del(struct interface *ifp, zebra_vni_t *zvni,
/* mac entry should be present */
mac = zvni_mac_lookup(zvni, &n->emac);
if (!mac) {
- zlog_debug("MAC %s doesnt exists for neigh %s on VNI %u",
+ zlog_debug("MAC %s doesn't exist for neigh %s on VNI %u",
prefix_mac2str(&n->emac, buf1, sizeof(buf1)),
ipaddr2str(ip, buf2, sizeof(buf2)), zvni->vni);
return -1;
@@ -3643,15 +3644,12 @@ static void *zl3vni_alloc(void *p)
*/
static zebra_l3vni_t *zl3vni_lookup(vni_t vni)
{
- struct zebra_ns *zns;
zebra_l3vni_t tmp_l3vni;
zebra_l3vni_t *zl3vni = NULL;
- zns = zebra_ns_lookup(NS_DEFAULT);
- assert(zns);
memset(&tmp_l3vni, 0, sizeof(zebra_l3vni_t));
tmp_l3vni.vni = vni;
- zl3vni = hash_lookup(zns->l3vni_table, &tmp_l3vni);
+ zl3vni = hash_lookup(zrouter.l3vni_table, &tmp_l3vni);
return zl3vni;
}
@@ -3662,16 +3660,12 @@ static zebra_l3vni_t *zl3vni_lookup(vni_t vni)
static zebra_l3vni_t *zl3vni_add(vni_t vni, vrf_id_t vrf_id)
{
zebra_l3vni_t tmp_zl3vni;
- struct zebra_ns *zns = NULL;
zebra_l3vni_t *zl3vni = NULL;
- zns = zebra_ns_lookup(NS_DEFAULT);
- assert(zns);
-
memset(&tmp_zl3vni, 0, sizeof(zebra_l3vni_t));
tmp_zl3vni.vni = vni;
- zl3vni = hash_get(zns->l3vni_table, &tmp_zl3vni, zl3vni_alloc);
+ zl3vni = hash_get(zrouter.l3vni_table, &tmp_zl3vni, zl3vni_alloc);
assert(zl3vni);
zl3vni->vrf_id = vrf_id;
@@ -3696,12 +3690,8 @@ static zebra_l3vni_t *zl3vni_add(vni_t vni, vrf_id_t vrf_id)
*/
static int zl3vni_del(zebra_l3vni_t *zl3vni)
{
- struct zebra_ns *zns;
zebra_l3vni_t *tmp_zl3vni;
- zns = zebra_ns_lookup(NS_DEFAULT);
- assert(zns);
-
/* free the list of l2vnis */
list_delete(&zl3vni->l2vnis);
zl3vni->l2vnis = NULL;
@@ -3715,7 +3705,7 @@ static int zl3vni_del(zebra_l3vni_t *zl3vni)
zl3vni->nh_table = NULL;
/* Free the VNI hash entry and allocated memory. */
- tmp_zl3vni = hash_release(zns->l3vni_table, zl3vni);
+ tmp_zl3vni = hash_release(zrouter.l3vni_table, zl3vni);
if (tmp_zl3vni)
XFREE(MTYPE_ZL3VNI, tmp_zl3vni);
@@ -4564,7 +4554,7 @@ void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni,
if (use_json)
vty_out(vty, "{}\n");
else
- vty_out(vty, "%% L3-VNI %u doesnt exist\n", l3vni);
+ vty_out(vty, "%% L3-VNI %u doesn't exist\n", l3vni);
return;
}
@@ -4574,7 +4564,7 @@ void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni,
vty_out(vty, "{}\n");
else
vty_out(vty,
- "%% Requested RMAC doesnt exist in L3-VNI %u",
+ "%% Requested RMAC doesn't exist in L3-VNI %u",
l3vni);
return;
}
@@ -4634,7 +4624,6 @@ void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t l3vni, bool use_json)
void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, bool use_json)
{
- struct zebra_ns *zns = NULL;
json_object *json = NULL;
void *args[2];
@@ -4644,19 +4633,12 @@ void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, bool use_json)
return;
}
- zns = zebra_ns_lookup(NS_DEFAULT);
- if (!zns) {
- if (use_json)
- vty_out(vty, "{}\n");
- return;
- }
-
if (use_json)
json = json_object_new_object();
args[0] = vty;
args[1] = json;
- hash_iterate(zns->l3vni_table,
+ hash_iterate(zrouter.l3vni_table,
(void (*)(struct hash_backet *,
void *))zl3vni_print_rmac_hash_all_vni,
args);
@@ -4759,7 +4741,6 @@ void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t l3vni, bool use_json)
void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, bool use_json)
{
- struct zebra_ns *zns = NULL;
json_object *json = NULL;
void *args[2];
@@ -4769,16 +4750,12 @@ void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, bool use_json)
return;
}
- zns = zebra_ns_lookup(NS_DEFAULT);
- if (!zns)
- return;
-
if (use_json)
json = json_object_new_object();
args[0] = vty;
args[1] = json;
- hash_iterate(zns->l3vni_table,
+ hash_iterate(zrouter.l3vni_table,
(void (*)(struct hash_backet *,
void *))zl3vni_print_nh_hash_all_vni,
args);
@@ -5273,21 +5250,16 @@ void zebra_vxlan_print_evpn(struct vty *vty, bool uj)
int num_l3vnis = 0;
int num_vnis = 0;
json_object *json = NULL;
- struct zebra_ns *zns = NULL;
struct zebra_vrf *zvrf = NULL;
if (!is_evpn_enabled())
return;
- zns = zebra_ns_lookup(NS_DEFAULT);
- if (!zns)
- return;
-
zvrf = vrf_info_lookup(VRF_DEFAULT);
if (!zvrf)
return;
- num_l3vnis = hashcount(zns->l3vni_table);
+ num_l3vnis = hashcount(zrouter.l3vni_table);
num_l2vnis = hashcount(zvrf->vni_table);
num_vnis = num_l2vnis + num_l3vnis;
@@ -5319,17 +5291,11 @@ void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,
bool use_json)
{
json_object *json = NULL;
- struct zebra_ns *zns = NULL;
void *args[2];
if (!is_evpn_enabled())
return;
- zns = zebra_ns_lookup(NS_DEFAULT);
- if (!zns)
- return;
-
-
if (use_json)
json = json_object_new_object();
else
@@ -5346,7 +5312,7 @@ void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,
args);
/* Display all L3-VNIs */
- hash_iterate(zns->l3vni_table,
+ hash_iterate(zrouter.l3vni_table,
(void (*)(struct hash_backet *, void *))zl3vni_print_hash,
args);
@@ -7160,7 +7126,6 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
{
struct stream *s = NULL;
int advertise = 0;
- struct zebra_ns *zns = NULL;
enum vxlan_flood_control flood_ctrl;
if (zvrf_id(zvrf) != VRF_DEFAULT) {
@@ -7206,11 +7171,7 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
hash_iterate(zvrf->vni_table, zvni_cleanup_all, zvrf);
/* cleanup all l3vnis */
- zns = zebra_ns_lookup(NS_DEFAULT);
- if (!zns)
- return;
-
- hash_iterate(zns->l3vni_table, zl3vni_cleanup_all, NULL);
+ hash_iterate(zrouter.l3vni_table, zl3vni_cleanup_all, NULL);
}
stream_failure:
@@ -7249,14 +7210,14 @@ void zebra_vxlan_close_tables(struct zebra_vrf *zvrf)
/* init the l3vni table */
void zebra_vxlan_ns_init(struct zebra_ns *zns)
{
- zns->l3vni_table = hash_create(l3vni_hash_keymake, l3vni_hash_cmp,
- "Zebra VRF L3 VNI table");
+ zrouter.l3vni_table = hash_create(l3vni_hash_keymake, l3vni_hash_cmp,
+ "Zebra VRF L3 VNI table");
}
/* free l3vni table */
void zebra_vxlan_ns_disable(struct zebra_ns *zns)
{
- hash_free(zns->l3vni_table);
+ hash_free(zrouter.l3vni_table);
}
/* get the l3vni svi ifindex */