summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/cocci.h37
-rw-r--r--tools/etc/frr/daemons5
-rw-r--r--tools/etc/frr/support_bundle_commands.conf2
-rwxr-xr-xtools/frr-reload.py44
-rwxr-xr-xtools/frr.in2
-rw-r--r--tools/frr@.service25
-rw-r--r--tools/frrcommon.sh.in22
-rw-r--r--tools/frrinit.sh.in5
-rw-r--r--tools/gcc-plugins/README.md15
-rw-r--r--tools/gcc-plugins/debian/changelog6
-rw-r--r--tools/gcc-plugins/debian/control4
-rw-r--r--tools/gcc-plugins/debian/source/format2
-rw-r--r--tools/gcc-plugins/format-test.c6
-rw-r--r--tools/gcc-plugins/format-test.py8
-rw-r--r--tools/gcc-plugins/frr-format.c90
-rw-r--r--tools/gcc-plugins/gcc-common.h6
-rw-r--r--tools/gen_northbound_callbacks.c2
-rw-r--r--tools/start-stop-daemon.c15
-rw-r--r--tools/stringmangle.py59
-rw-r--r--tools/subdir.am1
20 files changed, 268 insertions, 88 deletions
diff --git a/tools/cocci.h b/tools/cocci.h
index 8ca42b349f..7d6bb4cd7f 100644
--- a/tools/cocci.h
+++ b/tools/cocci.h
@@ -7,6 +7,18 @@
#define DEFUN_HIDDEN(funcname, cmdname, str, help) \
static int funcname(const struct cmd_element *self, struct vty *vty, \
int argc, struct cmd_token *argv[])
+#define DEFUN_NOSH(funcname, cmdname, str, help) \
+ static int funcname(const struct cmd_element *self, struct vty *vty, \
+ int argc, struct cmd_token *argv[])
+#define DEFPY(funcname, cmdname, str, help) \
+ static int funcname(const struct cmd_element *self, struct vty *vty, \
+ int argc, struct cmd_token *argv[])
+#define DEFPY_HIDDEN(funcname, cmdname, str, help) \
+ static int funcname(const struct cmd_element *self, struct vty *vty, \
+ int argc, struct cmd_token *argv[])
+#define DEFPY_NOSH(funcname, cmdname, str, help) \
+ static int funcname(const struct cmd_element *self, struct vty *vty, \
+ int argc, struct cmd_token *argv[])
#define ENABLE_BGP_VNC 1
#define ALL_LIST_ELEMENTS_RO(list, node, data) \
@@ -85,3 +97,28 @@
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
#define FOREACH_SAFI(safi) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
+
+#define frr_with_privs(p) \
+ for (int x = 1; x; x--)
+#define frr_with_mutex(m) \
+ for (int x = 1; x; x--)
+
+#define ALL_LSDB_TYPED_ADVRTR(lsdb, type, adv_router, lsa) \
+ const struct route_node *iterend = \
+ ospf6_lsdb_head(lsdb, 2, type, adv_router, &lsa); \
+ lsa; \
+ lsa = ospf6_lsdb_next(iterend, lsa)
+
+#define ALL_LSDB_TYPED(lsdb, type, lsa) \
+ const struct route_node *iterend = \
+ ospf6_lsdb_head(lsdb, 1, type, 0, &lsa); \
+ lsa; \
+ lsa = ospf6_lsdb_next(iterend, lsa)
+
+#define ALL_LSDB(lsdb, lsa) \
+ const struct route_node *iterend = \
+ ospf6_lsdb_head(lsdb, 0, 0, 0, &lsa); \
+ lsa; \
+ lsa = ospf6_lsdb_next(iterend, lsa)
+
+#define QOBJ_FIELDS struct qobj_node qobj_node;
diff --git a/tools/etc/frr/daemons b/tools/etc/frr/daemons
index 8bec3c5bb6..0221b0c19e 100644
--- a/tools/etc/frr/daemons
+++ b/tools/etc/frr/daemons
@@ -72,6 +72,11 @@ vrrpd_options=" -A 127.0.0.1"
# The list of daemons to watch is automatically generated by the init script.
#watchfrr_options=""
+# To make watchfrr create/join the specified netns, use the following option:
+#watchfrr_options="--netns"
+# This only has an effect in /etc/frr/<somename>/daemons, and you need to
+# start FRR with "/usr/lib/frr/frrinit.sh start <somename>".
+
# for debugging purposes, you can specify a "wrap" command to start instead
# of starting the daemon directly, e.g. to use valgrind on ospfd:
# ospfd_wrap="/usr/bin/valgrind"
diff --git a/tools/etc/frr/support_bundle_commands.conf b/tools/etc/frr/support_bundle_commands.conf
index 8845df5fc7..11f88e7101 100644
--- a/tools/etc/frr/support_bundle_commands.conf
+++ b/tools/etc/frr/support_bundle_commands.conf
@@ -38,8 +38,6 @@ PROC_NAME:zebra
CMD_LIST_START
show zebra
show zebra client summary
-show ip zebra route dump json
-show ipv6 zebra route dump json
show ip nht vrf all
show route-map
show memory
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
index 25922e3bf7..a72e5c2772 100755
--- a/tools/frr-reload.py
+++ b/tools/frr-reload.py
@@ -63,14 +63,17 @@ class VtyshException(Exception):
pass
class Vtysh(object):
- def __init__(self, bindir=None, confdir=None, sockdir=None):
+ def __init__(self, bindir=None, confdir=None, sockdir=None, pathspace=None):
self.bindir = bindir
self.confdir = confdir
+ self.pathspace = pathspace
self.common_args = [os.path.join(bindir or '', 'vtysh')]
if confdir:
self.common_args.extend(['--config_dir', confdir])
if sockdir:
self.common_args.extend(['--vty_socket', sockdir])
+ if pathspace:
+ self.common_args.extend(['-N', pathspace])
def _call(self, args, stdin=None, stdout=None, stderr=None):
kwargs = {}
@@ -728,6 +731,36 @@ def line_exist(lines, target_ctx_keys, target_line, exact_match=True):
return True
return False
+def check_for_exit_vrf(lines_to_add, lines_to_del):
+
+ # exit-vrf is a bit tricky. If the new config is missing it but we
+ # have configs under a vrf, we need to add it at the end to do the
+ # right context changes. If exit-vrf exists in both the running and
+ # new config, we cannot delete it or it will break context changes.
+ add_exit_vrf = False
+ index = 0
+
+ for (ctx_keys, line) in lines_to_add:
+ if add_exit_vrf == True:
+ if ctx_keys[0] != prior_ctx_key:
+ insert_key=(prior_ctx_key),
+ lines_to_add.insert(index, ((insert_key, "exit-vrf")))
+ add_exit_vrf = False
+
+ if ctx_keys[0].startswith('vrf') and line:
+ if line is not "exit-vrf":
+ add_exit_vrf = True
+ prior_ctx_key = (ctx_keys[0])
+ else:
+ add_exit_vrf = False
+ index+=1
+
+ for (ctx_keys, line) in lines_to_del:
+ if line == "exit-vrf":
+ if (line_exist(lines_to_add, ctx_keys, line)):
+ lines_to_del.remove((ctx_keys, line))
+
+ return (lines_to_add, lines_to_del)
def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
@@ -1155,6 +1188,7 @@ def compare_context_objects(newconf, running):
for line in newconf_ctx.lines:
lines_to_add.append((newconf_ctx_keys, line))
+ (lines_to_add, lines_to_del) = check_for_exit_vrf(lines_to_add, lines_to_del)
(lines_to_add, lines_to_del) = ignore_delete_re_add_lines(lines_to_add, lines_to_del)
(lines_to_add, lines_to_del) = ignore_unconfigurable_lines(lines_to_add, lines_to_del)
@@ -1174,6 +1208,7 @@ if __name__ == '__main__':
level_group.add_argument('--log-level', help='Log level', default="info",
choices=("critical", "error", "warning", "info", "debug"))
parser.add_argument('--stdout', action='store_true', help='Log to STDOUT', default=False)
+ parser.add_argument('--pathspace', '-N', metavar='NAME', help='Reload specified path/namespace', default=None)
parser.add_argument('filename', help='Location of new frr config file')
parser.add_argument('--overwrite', action='store_true', help='Overwrite frr.conf with running config output', default=False)
parser.add_argument('--bindir', help='path to the vtysh executable', default='/usr/bin')
@@ -1251,10 +1286,13 @@ if __name__ == '__main__':
log.error("Daemon %s is not a valid option for 'show running-config'" % args.daemon)
sys.exit(1)
- vtysh = Vtysh(args.bindir, args.confdir, args.vty_socket)
+ vtysh = Vtysh(args.bindir, args.confdir, args.vty_socket, args.pathspace)
# Verify that 'service integrated-vtysh-config' is configured
- vtysh_filename = args.confdir + '/vtysh.conf'
+ if args.pathspace:
+ vtysh_filename = args.confdir + '/' + args.pathspace + '/vtysh.conf'
+ else:
+ vtysh_filename = args.confdir + '/vtysh.conf'
service_integrated_vtysh_config = True
if os.path.isfile(vtysh_filename):
diff --git a/tools/frr.in b/tools/frr.in
index 40862aa4c9..b860797d5b 100755
--- a/tools/frr.in
+++ b/tools/frr.in
@@ -77,7 +77,7 @@ vtysh_b ()
{
# Rember, that all variables have been incremented by 1 in convert_daemon_prios()
if [ "$vtysh_enable" = 2 -a -f $C_PATH/frr.conf ]; then
- $VTYSH -b -n
+ $VTYSH -b
fi
}
diff --git a/tools/frr@.service b/tools/frr@.service
new file mode 100644
index 0000000000..0fa41c74a3
--- /dev/null
+++ b/tools/frr@.service
@@ -0,0 +1,25 @@
+[Unit]
+Description=FRRouting
+Documentation=https://frrouting.readthedocs.io/en/latest/setup.html
+Wants=network.target
+After=network-pre.target systemd-sysctl.service
+Before=network.target
+OnFailure=heartbeat-failed@%n.service
+
+[Service]
+Nice=-5
+Type=forking
+NotifyAccess=all
+StartLimitInterval=3m
+StartLimitBurst=3
+TimeoutSec=2m
+WatchdogSec=60s
+RestartSec=5
+Restart=on-abnormal
+LimitNOFILE=1024
+ExecStart=/usr/lib/frr/frrinit.sh start %I
+ExecStop=/usr/lib/frr/frrinit.sh stop %I
+ExecReload=/usr/lib/frr/frrinit.sh reload %I
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in
index 2955f74ce3..9a144b2b06 100644
--- a/tools/frrcommon.sh.in
+++ b/tools/frrcommon.sh.in
@@ -16,10 +16,14 @@
#
# This script should be installed in @CFG_SBIN@/frrcommon.sh
+# FRR_PATHSPACE is passed in from watchfrr
+suffix="${FRR_PATHSPACE:+/${FRR_PATHSPACE}}"
+nsopt="${FRR_PATHSPACE:+-N ${FRR_PATHSPACE}}"
+
PATH=/bin:/usr/bin:/sbin:/usr/sbin
D_PATH="@CFG_SBIN@" # /usr/lib/frr
-C_PATH="@CFG_SYSCONF@" # /etc/frr
-V_PATH="@CFG_STATE@" # /var/run/frr
+C_PATH="@CFG_SYSCONF@${suffix}" # /etc/frr
+V_PATH="@CFG_STATE@${suffix}" # /var/run/frr
VTYSH="@vtysh_bin@" # /usr/bin/vtysh
FRR_USER="@enable_user@" # frr
FRR_GROUP="@enable_group@" # frr
@@ -61,9 +65,9 @@ vtysh_b () {
[ "$1" = "watchfrr" ] && return 0
[ -r "$C_PATH/frr.conf" ] || return 0
if [ -n "$1" ]; then
- "$VTYSH" -b -n -d "$1"
+ "$VTYSH" `echo $nsopt` -b -d "$1"
else
- "$VTYSH" -b -n
+ "$VTYSH" `echo $nsopt` -b
fi
}
@@ -156,7 +160,7 @@ daemon_start() {
instopt="${inst:+-n $inst}"
eval args="\$${daemon}_options"
- if eval "$all_wrap $wrap $bin -d $frr_global_options $instopt $args"; then
+ if eval "$all_wrap $wrap $bin $nsopt -d $frr_global_options $instopt $args"; then
log_success_msg "Started $dmninst"
vtysh_b "$daemon"
else
@@ -292,9 +296,11 @@ load_old_config() {
}
. "$C_PATH/daemons"
-load_old_config "$C_PATH/daemons.conf"
-load_old_config "/etc/default/frr"
-load_old_config "/etc/sysconfig/frr"
+if [ -z "$FRR_PATHSPACE" ]; then
+ load_old_config "$C_PATH/daemons.conf"
+ load_old_config "/etc/default/frr"
+ load_old_config "/etc/sysconfig/frr"
+fi
if { declare -p watchfrr_options 2>/dev/null || true; } | grep -q '^declare \-a'; then
log_warning_msg "watchfrr_options contains a bash array value." \
diff --git a/tools/frrinit.sh.in b/tools/frrinit.sh.in
index 423d6b9b1d..539ab7d816 100644
--- a/tools/frrinit.sh.in
+++ b/tools/frrinit.sh.in
@@ -30,6 +30,9 @@ else
}
fi
+# "/usr/lib/frr/frrinit.sh start somenamespace"
+FRR_PATHSPACE="$2"
+
self="`dirname $0`"
if [ -r "$self/frrcommon.sh" ]; then
. "$self/frrcommon.sh"
@@ -105,7 +108,7 @@ reload)
NEW_CONFIG_FILE="${2:-$C_PATH/frr.conf}"
[ ! -r $NEW_CONFIG_FILE ] && log_failure_msg "Unable to read new configuration file $NEW_CONFIG_FILE" && exit 1
- "$RELOAD_SCRIPT" --reload "$NEW_CONFIG_FILE"
+ "$RELOAD_SCRIPT" --reload "$NEW_CONFIG_FILE" `echo $nsopt`
exit $?
;;
diff --git a/tools/gcc-plugins/README.md b/tools/gcc-plugins/README.md
index 94a9635e76..ab31d0e636 100644
--- a/tools/gcc-plugins/README.md
+++ b/tools/gcc-plugins/README.md
@@ -20,11 +20,14 @@ Can be found at [https://deb.nox.tf/devel/].
GCC requirements
----------------
-To use this plugin, you need a **patched 9.3.0** version of GCC using the
-[gcc-retain-typeinfo.patch] provided in this repo. Without this patch, GCC
-strips type information too early during compilation, leaving to the plugin
-being unable to perform more meaningful type checks. (Specifically, all
-`typedef` types will be "cooked down" to their final type.)
+To use this plugin, you need a **patched 9.3.0** or a **patched 10.1.0**
+version of GCC using the [gcc-retain-typeinfo.patch] provided in this repo.
+
+Without this patch, GCC strips type information too early during compilation,
+leaving to the plugin being unable to perform more meaningful type checks.
+(Specifically, all `typedef` casts will be "cooked down" to their final type.)
+If the patch is missing, `format-test.c` will show 4 false negative/positive
+warnings marked with `(need retain-typeinfo patch)`.
(@eqvinox has discussed this one-line diff with some GCC people on their
IRC channel around mid 2019, the consensus was that the line is an "early
@@ -32,7 +35,7 @@ optimization" and removing it should not be harmful. However, doing so is
likely to break GCC's unit tests since warnings would print different types.)
Other versions of gcc are not supported. gcc 8 previously did work but isn't
-actively tested/maintained. gcc 10 is not supported yet but may work.
+actively tested/maintained.
Usage
diff --git a/tools/gcc-plugins/debian/changelog b/tools/gcc-plugins/debian/changelog
index 62bbbcd46f..a772803b1c 100644
--- a/tools/gcc-plugins/debian/changelog
+++ b/tools/gcc-plugins/debian/changelog
@@ -1,3 +1,9 @@
+gcc-frr-plugin (9.3.0d15+equi1) unstable; urgency=medium
+
+ * update & rebuild for gcc 9.3.0-15+equi1
+
+ -- David Lamparter <equinox-debian@diac24.net> Tue, 14 Jul 2020 19:49:24 +0200
+
gcc-frr-plugin (9.3.0d8+equi2) unstable; urgency=medium
* package created (+equi1 used during development, never released.)
diff --git a/tools/gcc-plugins/debian/control b/tools/gcc-plugins/debian/control
index 6a9b886bef..b9b5134b46 100644
--- a/tools/gcc-plugins/debian/control
+++ b/tools/gcc-plugins/debian/control
@@ -3,7 +3,7 @@ Section: devel
Priority: optional
Maintainer: David Lamparter <equinox-debian@diac24.net>
Build-Depends:
- gcc-9-plugin-dev (=9.3.0-8+equi1),
+ gcc-9-plugin-dev (=9.3.0-15+equi1),
debhelper (>= 12)
Standards-Version: 4.4.1
Homepage: https://www.frrouting.org/
@@ -13,7 +13,7 @@ Vcs-Git: https://github.com/FRRouting/frr.git
Package: gcc-9-frr-plugin
Architecture: linux-any
Depends:
- gcc-9 (=9.3.0-8+equi1),
+ gcc-9 (=9.3.0-15+equi1),
${misc:Depends},
${shlibs:Depends}
Description: GCC plugin for FRRouting
diff --git a/tools/gcc-plugins/debian/source/format b/tools/gcc-plugins/debian/source/format
index af745b310b..89ae9db8f8 100644
--- a/tools/gcc-plugins/debian/source/format
+++ b/tools/gcc-plugins/debian/source/format
@@ -1 +1 @@
-3.0 (git)
+3.0 (native)
diff --git a/tools/gcc-plugins/format-test.c b/tools/gcc-plugins/format-test.c
index b031ca5ece..fb7e41c7be 100644
--- a/tools/gcc-plugins/format-test.c
+++ b/tools/gcc-plugins/format-test.c
@@ -82,6 +82,12 @@ int test(unsigned long long ay)
testfn("%Ld", v_pid_t); // WARN
testfn("%Ld", v_uint64_t); // NOWARN
+ /* retain-typeinfo patch */
+ testfn("%zu", (size_t)v_pid_t); // NOWARN (need retain-typeinfo patch)
+ testfn("%lu", (size_t)v_pid_t); // WARN (need retain-typeinfo patch)
+ testfn("%Lu", (uint64_t)v_pid_t); // NOWARN (need retain-typeinfo patch)
+ testfn("%lu", (uint64_t)v_pid_t); // WARN (need retain-typeinfo patch)
+
testfn("%pI4", &v_long); // WARN
in_addr_t v_in_addr_t;
diff --git a/tools/gcc-plugins/format-test.py b/tools/gcc-plugins/format-test.py
index cc6ca6100e..df2437d5bc 100644
--- a/tools/gcc-plugins/format-test.py
+++ b/tools/gcc-plugins/format-test.py
@@ -10,6 +10,10 @@ for k in list(os.environ.keys()):
if k.startswith('LC_'):
os.environ.pop(k)
+if len(sys.argv) < 2:
+ sys.stderr.write('start as format-test.py gcc-123.45 [-options ...]\n')
+ sys.exit(1)
+
c_re = re.compile(r'//\s+(NO)?WARN')
expect = {}
lines = {}
@@ -25,9 +29,9 @@ with open('format-test.c', 'r') as fd:
else:
expect[lno] = 'nowarn'
-cmd = shlex.split('gcc -Wall -Wextra -Wno-unused -fplugin=./frr-format.so -fno-diagnostics-show-caret -c -o format-test.o format-test.c')
+cmd = shlex.split('-Wall -Wextra -Wno-unused -fplugin=./frr-format.so -fno-diagnostics-show-caret -c -o format-test.o format-test.c')
-gcc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+gcc = subprocess.Popen(sys.argv[1:] + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
sout, serr = gcc.communicate()
gcc.wait()
diff --git a/tools/gcc-plugins/frr-format.c b/tools/gcc-plugins/frr-format.c
index 174f403d48..be56517171 100644
--- a/tools/gcc-plugins/frr-format.c
+++ b/tools/gcc-plugins/frr-format.c
@@ -268,8 +268,7 @@ check_format_string (tree fntype, unsigned HOST_WIDE_INT format_num,
/* We expect a string object type as the format arg. */
if (is_char_ref)
{
- error ("format argument should be a %qs reference but"
- " a string was found", format_name (expected_format_type));
+ error ("format argument should be a %qs reference but a string was found", format_name (expected_format_type));
*no_add_attrs = true;
return false;
}
@@ -360,7 +359,7 @@ decode_format_attr (tree args, function_format_info *info, int validated_p)
if (info->first_arg_num != 0 && info->first_arg_num <= info->format_num)
{
gcc_assert (!validated_p);
- error ("format string argument follows the args to be formatted");
+ error ("format string argument follows the arguments to be formatted");
return false;
}
@@ -490,10 +489,10 @@ static const format_flag_pair printf_flag_pairs[] =
#define ETAB_SZ 128
static kernel_ext_fmt ext_p[ETAB_SZ] = {
- { NULL }
+ { }
};
static kernel_ext_fmt ext_d[ETAB_SZ] = {
- { NULL }
+ { }
};
static const format_char_info print_char_table[] =
@@ -741,8 +740,8 @@ check_function_format (tree attrs, int nargs, tree *argarray,
break;
}
if (args != 0)
- warning (OPT_Wsuggest_attribute_format, "function %qD "
- "might be a candidate for %qs frr_format attribute",
+ warning (OPT_Wsuggest_attribute_format,
+ "function %qD might be a candidate for %qs %<frr_format%> attribute",
current_function_decl,
format_types[info.format_type].name);
}
@@ -924,7 +923,7 @@ avoid_dollar_number (const char *format)
format++;
if (*format == '$')
{
- warning (OPT_Wformat_, "$ operand number used after format without operand number");
+ warning (OPT_Wformat_, "%<$%> operand number used after format without operand number");
return true;
}
return false;
@@ -955,7 +954,7 @@ finish_dollar_format_checking (format_check_results *res, int pointer_gap_ok)
found_pointer_gap = true;
else
warning_at (res->format_string_loc, OPT_Wformat_,
- "format argument %d unused before used argument %d in $-style format",
+ "format argument %d unused before used argument %d in %<$%>-style format",
i + 1, dollar_max_arg_used);
}
}
@@ -1099,7 +1098,7 @@ check_format_info (function_format_info *info, tree params,
}
if (res.number_dollar_extra_args > 0 && res.number_non_literal == 0
&& res.number_other == 0)
- warning_at (loc, OPT_Wformat_extra_args, "unused arguments in $-style format");
+ warning_at (loc, OPT_Wformat_extra_args, "unused arguments in %<$%>-style format");
if (res.number_empty > 0 && res.number_non_literal == 0
&& res.number_other == 0)
warning_at (loc, OPT_Wformat_zero_length, "zero-length %s format string",
@@ -1534,8 +1533,7 @@ flag_chars_t::validate (const format_kind_info *fki,
: s->long_name);
if (ADJ_STD (t->std) > C_STD_VER)
warning_at (format_string_loc, OPT_Wformat_,
- "%s does not support %s with"
- " the %<%%%c%> %s format",
+ "%s does not support %s with the %<%%%c%> %s format",
C_STD_NAME (t->std), _(long_name),
format_char, fki->name);
}
@@ -2040,8 +2038,7 @@ argument_parser::find_format_char_info (char format_char)
format_warning_at_char (format_string_loc, format_string_cst,
format_chars - orig_format_chars,
OPT_Wformat_,
- "unknown conversion type character"
- " %qc in format",
+ "unknown conversion type character %qc in format",
format_char);
return NULL;
}
@@ -2128,8 +2125,7 @@ argument_parser::give_y2k_warnings (const format_char_info *fci,
y2k_level = 2;
if (y2k_level == 3)
warning_at (format_string_loc, OPT_Wformat_y2k,
- "%<%%%c%> yields only last 2 digits of "
- "year in some locales", format_char);
+ "%<%%%c%> yields only last 2 digits of year in some locales", format_char);
else if (y2k_level == 2)
warning_at (format_string_loc, OPT_Wformat_y2k,
"%<%%%c%> yields only last 2 digits of year",
@@ -2188,9 +2184,7 @@ argument_parser::handle_conversions (const format_char_info *fci,
format_warning_at_char (format_string_loc, format_string_cst,
format_chars - orig_format_chars,
OPT_Wformat_,
- "use of %qs length modifier with %qc type"
- " character has either no effect"
- " or undefined behavior",
+ "use of %qs length modifier with %qc type character has either no effect or undefined behavior",
len_modifier.chars, format_char);
/* Heuristic: skip one argument when an invalid length/type
combination is encountered. */
@@ -2249,12 +2243,10 @@ check_argument_type (const format_char_info *fci,
{
if (suppressed)
warning_at (format_string_loc, OPT_Wformat_,
- "operand number specified with "
- "suppressed assignment");
+ "operand number specified with suppressed assignment");
else
warning_at (format_string_loc, OPT_Wformat_,
- "operand number specified for format "
- "taking no argument");
+ "operand number specified for format taking no argument");
}
}
else
@@ -2576,8 +2568,7 @@ check_format_info_main (format_check_results *res,
format_warning_at_char (format_string_loc, format_string_cst,
format_chars - orig_format_chars,
OPT_Wformat_,
- "%qc directive redundant after prior "
- "occurence of the same", format_char);
+ "%qc directive redundant after prior occurence of the same", format_char);
else if (!color_begin)
format_warning_at_char (format_string_loc, format_string_cst,
format_chars - orig_format_chars,
@@ -2594,8 +2585,7 @@ check_format_info_main (format_check_results *res,
format_warning_at_char (format_string_loc, format_string_cst,
format_chars - orig_format_chars,
OPT_Wformat_,
- "%qc conversion used within a quoted "
- "sequence",
+ "%qc conversion used within a quoted sequence",
format_char);
}
@@ -2821,16 +2811,14 @@ check_format_types (const substring_loc &fmt_loc,
&& i == 0
&& cur_param != 0
&& integer_zerop (cur_param))
- warning (OPT_Wformat_, "writing through null pointer "
- "(argument %d)", arg_num);
+ warning (OPT_Wformat_, "writing through null pointer (argument %d)", arg_num);
/* Check for reading through a NULL pointer. */
if (types->reading_from_flag
&& i == 0
&& cur_param != 0
&& integer_zerop (cur_param))
- warning (OPT_Wformat_, "reading through null pointer "
- "(argument %d)", arg_num);
+ warning (OPT_Wformat_, "reading through null pointer (argument %d)", arg_num);
if (cur_param != 0 && TREE_CODE (cur_param) == ADDR_EXPR)
cur_param = TREE_OPERAND (cur_param, 0);
@@ -2849,8 +2837,7 @@ check_format_types (const substring_loc &fmt_loc,
&& (CONSTANT_CLASS_P (cur_param)
|| (DECL_P (cur_param)
&& TREE_READONLY (cur_param))))))
- warning (OPT_Wformat_, "writing into constant object "
- "(argument %d)", arg_num);
+ warning (OPT_Wformat_, "writing into constant object (argument %d)", arg_num);
/* If there are extra type qualifiers beyond the first
indirection, then this makes the types technically
@@ -2861,8 +2848,7 @@ check_format_types (const substring_loc &fmt_loc,
|| TYPE_VOLATILE (cur_type)
|| TYPE_ATOMIC (cur_type)
|| TYPE_RESTRICT (cur_type)))
- warning (OPT_Wformat_, "extra type qualifiers in format "
- "argument (argument %d)",
+ warning (OPT_Wformat_, "extra type qualifiers in format argument (argument %d)",
arg_num);
}
@@ -3095,8 +3081,7 @@ check_kef_type (const substring_loc &fmt_loc,
|| TYPE_VOLATILE (cur_type)
|| TYPE_ATOMIC (cur_type)
|| TYPE_RESTRICT (cur_type)))
- warning (OPT_Wformat_, "extra type qualifiers in format "
- "argument (argument %d)",
+ warning (OPT_Wformat_, "extra type qualifiers in format argument (argument %d)",
arg_num);
}
@@ -3541,17 +3526,24 @@ print_type (c_pretty_printer *cpp, tree t, bool *quoted)
/* C-specific implementation of range_label::get_text () vfunc for
range_label_for_type_mismatch. */
+#if BUILDING_GCC_VERSION >= 10000
+#define label_borrow(text) label_text::borrow(text)
+#define label_take(text) label_text::take(text)
+#else
+#define label_borrow(text) label_text((char *)text, false)
+#define label_take(text) label_text(text, true)
+#endif
label_text
frr_range_label_for_type_mismatch::get_text (unsigned /*range_idx*/) const
{
if (m_labelled_type == NULL_TREE)
- return label_text (NULL, false);
+ return label_borrow("(null tree)");
c_pretty_printer cpp;
bool quoted = false;
print_type (&cpp, m_labelled_type, &quoted);
- return label_text (xstrdup (pp_formatted_text (&cpp)), true);
+ return label_take(xstrdup (pp_formatted_text (&cpp)));
}
#define range_label_for_type_mismatch frr_range_label_for_type_mismatch
@@ -3583,7 +3575,7 @@ class range_label_for_format_type_mismatch
char *result = concat (text.m_buffer, p, NULL);
text.maybe_free ();
- return label_text (result, true);
+ return label_take(result);
}
private:
@@ -3695,8 +3687,7 @@ format_type_warning (const substring_loc &whole_fmt_loc,
format_warning_at_substring
(fmt_loc, &fmt_label, param_loc, &param_label,
corrected_substring, OPT_Wformat_,
- "%s %<%s%.*s%> expects argument of type %<%s%s%>, "
- "but argument %d has type %qT%s",
+ "%s %<%s%.*s%> expects argument of type %<%s%s%>, but argument %d has type %qT%s",
gettext (kind_descriptions[kind]),
(kind == CF_KIND_FORMAT ? "%" : ""),
format_length, format_start,
@@ -3716,8 +3707,7 @@ format_type_warning (const substring_loc &whole_fmt_loc,
format_warning_at_substring
(fmt_loc, &fmt_label, param_loc, &param_label,
corrected_substring, OPT_Wformat_,
- "%s %<%s%.*s%> expects argument of type %<%T%s%>, "
- "but argument %d has type %qT%s",
+ "%s %<%s%.*s%> expects argument of type %<%T%s%>, but argument %d has type %qT%s",
gettext (kind_descriptions[kind]),
(kind == CF_KIND_FORMAT ? "%" : ""),
format_length, format_start,
@@ -3875,7 +3865,7 @@ handle_frr_format_attribute (tree *node, tree ARG_UNUSED (name), tree args,
if (arg_num != info.first_arg_num)
{
if (!(flags & (int) ATTR_FLAG_BUILT_IN))
- error ("args to be formatted is not %<...%>");
+ error ("arguments to be formatted is not %<...%>");
*no_add_attrs = true;
return NULL_TREE;
}
@@ -4149,7 +4139,7 @@ setup_type (const char *name, tree *dst)
tmp = identifier_global_value (*dst);
if (tmp && TREE_CODE (tmp) != TYPE_DECL)
{
- warning (0, "%<%s%> is not defined as a type", name);
+ warning (0, "%qs is not defined as a type", name);
*dst = NULL;
return;
}
@@ -4316,7 +4306,7 @@ handle_pragma_printfrr_ext (cpp_reader *dummy)
if (0)
{
warning_at (loc, OPT_Wformat_,
- "%<#pragma FRR printfrr_ext%>: duplicate printf format suffix \"%s\"", s);
+ "%<#pragma FRR printfrr_ext%>: duplicate printf format suffix %qs", s);
warning_at (etab->origin_loc, OPT_Wformat_,
"%<#pragma FRR printfrr_ext%>: previous definition was here");
return;
@@ -4328,9 +4318,9 @@ handle_pragma_printfrr_ext (cpp_reader *dummy)
if (!strncmp(s + 2, etab->suffix, MIN(strlen(s + 2), strlen(etab->suffix))))
{
warning_at (loc, OPT_Wformat_,
- "%<#pragma FRR printfrr_ext%>: overlapping printf format suffix \"%s\"", s);
+ "%<#pragma FRR printfrr_ext%>: overlapping printf format suffix %qs", s);
warning_at (etab->origin_loc, OPT_Wformat_,
- "%<#pragma FRR printfrr_ext%>: previous definition for \"%%%c%s\" was here", s[1], etab->suffix);
+ "%<#pragma FRR printfrr_ext%>: previous definition for %<%%%c%s%> was here", s[1], etab->suffix);
return;
}
}
@@ -4388,7 +4378,7 @@ handle_pragma_printfrr_ext (cpp_reader *dummy)
{
switch (ttype) {
case CPP_NAME:
- error_at (loc, "%<#pragma FRR printfrr_ext%>: unexpected identifier. Note the only supported qualifier is \"const\".");
+ error_at (loc, "%<#pragma FRR printfrr_ext%>: unexpected identifier. Note the only supported qualifier is %<const%>");
goto out_drop;
case CPP_MULT:
diff --git a/tools/gcc-plugins/gcc-common.h b/tools/gcc-plugins/gcc-common.h
index 6b6c17231a..ec45de1a53 100644
--- a/tools/gcc-plugins/gcc-common.h
+++ b/tools/gcc-plugins/gcc-common.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 */
-/* FRR: imported from Linux kernel on 2019-07-29 */
+/* FRR: imported from Linux kernel on 2020-07-14 */
#ifndef GCC_COMMON_H_INCLUDED
#define GCC_COMMON_H_INCLUDED
@@ -38,7 +38,9 @@
#include "ggc.h"
#include "timevar.h"
+#if BUILDING_GCC_VERSION < 10000
#include "params.h"
+#endif
#if BUILDING_GCC_VERSION <= 4009
#include "pointer-set.h"
@@ -852,6 +854,7 @@ static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree l
return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT);
}
+#if BUILDING_GCC_VERSION < 10000
template <>
template <>
inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
@@ -865,6 +868,7 @@ inline bool is_a_helper<const greturn *>::test(const_gimple gs)
{
return gs->code == GIMPLE_RETURN;
}
+#endif
static inline gasm *as_a_gasm(gimple stmt)
{
diff --git a/tools/gen_northbound_callbacks.c b/tools/gen_northbound_callbacks.c
index 8dccbac3ae..eaab932228 100644
--- a/tools/gen_northbound_callbacks.c
+++ b/tools/gen_northbound_callbacks.c
@@ -194,7 +194,7 @@ static void generate_callback(const struct nb_callback_info *ncinfo,
case NB_OP_MODIFY:
case NB_OP_DESTROY:
case NB_OP_MOVE:
- printf("\tswitch (event) {\n"
+ printf("\tswitch (args->event) {\n"
"\tcase NB_EV_VALIDATE:\n"
"\tcase NB_EV_PREPARE:\n"
"\tcase NB_EV_ABORT:\n"
diff --git a/tools/start-stop-daemon.c b/tools/start-stop-daemon.c
index 7ad2a84500..0e4cf271f3 100644
--- a/tools/start-stop-daemon.c
+++ b/tools/start-stop-daemon.c
@@ -410,8 +410,7 @@ static void parse_schedule_item(const char *string, struct schedule_item *item)
item->type = sched_signal;
} else {
badusage(
- "invalid schedule item (must be [-]<signal-name>, "
- "-<signal-number>, <timeout> or `forever'");
+ "invalid schedule item (must be [-]<signal-name>, -<signal-number>, <timeout> or `forever'");
}
}
@@ -436,8 +435,7 @@ static void parse_schedule(const char *schedule_str)
parse_schedule_item(schedule_str, &schedule[1]);
if (schedule[1].type != sched_timeout) {
badusage(
- "--retry takes timeout, or schedule list"
- " of at least two items");
+ "--retry takes timeout, or schedule list of at least two items");
}
schedule[2].type = sched_signal;
schedule[2].value = SIGKILL;
@@ -451,8 +449,7 @@ static void parse_schedule(const char *schedule_str)
: (ptrdiff_t)strlen(schedule_str);
if (str_len >= (ptrdiff_t)sizeof(item_buf))
badusage(
- "invalid schedule item: far too long"
- " (you must delimit items with slashes)");
+ "invalid schedule item: far too long (you must delimit items with slashes)");
memcpy(item_buf, schedule_str, str_len);
item_buf[str_len] = 0;
schedule_str = slash ? slash + 1 : NULL;
@@ -461,8 +458,7 @@ static void parse_schedule(const char *schedule_str)
if (schedule[count].type == sched_forever) {
if (repeatat >= 0)
badusage(
- "invalid schedule: `forever'"
- " appears more than once");
+ "invalid schedule: `forever' appears more than once");
repeatat = count;
continue;
}
@@ -574,8 +570,7 @@ static void parse_options(int argc, char *const *argv)
if (signal_str != NULL) {
if (parse_signal(signal_str, &signal_nr) != 0)
badusage(
- "signal value must be numeric or name"
- " of signal (KILL, INTR, ...)");
+ "signal value must be numeric or name of signal (KILL, INTR, ...)");
}
if (schedule_str != NULL) {
diff --git a/tools/stringmangle.py b/tools/stringmangle.py
new file mode 100644
index 0000000000..a2eb37336a
--- /dev/null
+++ b/tools/stringmangle.py
@@ -0,0 +1,59 @@
+# 2020 by David Lamparter, placed in the public domain.
+
+import sys
+import os
+import re
+import argparse
+
+wrap_res = [
+ (re.compile(r'(?<!\\n)"\s*\n\s*"', re.M), r''),
+]
+pri_res = [
+ (re.compile(r'(PRI[udx][0-9]+)\s*\n\s*"', re.M), r'\1"'),
+ (re.compile(r'"\s*PRI([udx])32\s*"'), r'\1'),
+ (re.compile(r'"\s*PRI([udx])32'), r'\1"'),
+ (re.compile(r'"\s*PRI([udx])16\s*"'), r'h\1'),
+ (re.compile(r'"\s*PRI([udx])16'), r'h\1"'),
+ (re.compile(r'"\s*PRI([udx])8\s*"'), r'hh\1'),
+ (re.compile(r'"\s*PRI([udx])8'), r'hh\1"'),
+]
+
+def main():
+ argp = argparse.ArgumentParser(description = 'C string mangler')
+ argp.add_argument('--unwrap', action = 'store_const', const = True)
+ argp.add_argument('--pri8-16-32', action = 'store_const', const = True)
+ argp.add_argument('files', type = str, nargs = '+')
+ args = argp.parse_args()
+
+ regexes = []
+ if args.unwrap:
+ regexes.extend(wrap_res)
+ if args.pri8_16_32:
+ regexes.extend(pri_res)
+ if len(regexes) == 0:
+ sys.stderr.write('no action selected to execute\n')
+ sys.exit(1)
+
+ l = 0
+
+ for fn in args.files:
+ sys.stderr.write(fn + '\033[K\r')
+ with open(fn, 'r') as ifd:
+ data = ifd.read()
+
+ newdata = data
+ n = 0
+ for regex, repl in regexes:
+ newdata, m = regex.subn(repl, newdata)
+ n += m
+
+ if n > 0:
+ sys.stderr.write('changed: %s\n' % fn)
+ with open(fn + '.new', 'w') as ofd:
+ ofd.write(newdata)
+ os.rename(fn + '.new', fn)
+ l += 1
+
+ sys.stderr.write('%d files changed.\n' % (l))
+
+main()
diff --git a/tools/subdir.am b/tools/subdir.am
index 723a87d100..e159d82d4c 100644
--- a/tools/subdir.am
+++ b/tools/subdir.am
@@ -48,6 +48,7 @@ EXTRA_DIST += \
tools/frr-reload \
tools/frr-reload.py \
tools/frr.service \
+ tools/frr@.service \
tools/generate_support_bundle.py \
tools/multiple-bgpd.sh \
tools/rrcheck.pl \