distribution/packages/sysutils/busybox/patches/busybox-20-add-not-tables-support.patch
2022-05-11 17:47:42 -07:00

78 lines
2.9 KiB
Diff

kkoshelev@gmail.com
Those to support ip commands needed by wg-quick script.
1. "ip rule" now supports "not" keyword.
2. "ip" command now supports arbitrary numeric routing tables above 1024.
--- a/networking/libiproute/iprule.c 2021-01-01 05:30:02.000000000 -0800
+++ b/iprule.c 2022-05-10 16:32:10.781087924 -0700
@@ -19,6 +19,7 @@
/* from <linux/fib_rules.h>: */
#define FRA_SUPPRESS_IFGROUP 13
#define FRA_SUPPRESS_PREFIXLEN 14
+#define FIB_RULE_INVERT 0x00000002
#include "ip_common.h" /* #include "libbb.h" is inside */
#include "rt_names.h"
@@ -31,18 +32,18 @@
/* If you add stuff here, update iprule_full_usage */
static const char keywords[] ALIGN1 =
- "from\0""to\0""preference\0""order\0""priority\0"
+ "not\0""from\0""to\0""preference\0""order\0""priority\0"
"tos\0""fwmark\0""realms\0""table\0""lookup\0"
"suppress_prefixlength\0""suppress_ifgroup\0"
"dev\0""iif\0""nat\0""map-to\0""type\0""help\0"
;
-#define keyword_preference (keywords + sizeof("from") + sizeof("to"))
+#define keyword_preference (keywords + sizeof("not") + sizeof("from") + sizeof("to"))
#define keyword_fwmark (keyword_preference + sizeof("preference") + sizeof("order") + sizeof("priority") + sizeof("tos"))
#define keyword_realms (keyword_fwmark + sizeof("fwmark"))
#define keyword_suppress_prefixlength (keyword_realms + sizeof("realms") + sizeof("table") + sizeof("lookup"))
#define keyword_suppress_ifgroup (keyword_suppress_prefixlength + sizeof("suppress_prefixlength"))
enum {
- ARG_from = 1, ARG_to, ARG_preference, ARG_order, ARG_priority,
+ ARG_not = 1, ARG_from, ARG_to, ARG_preference, ARG_order, ARG_priority,
ARG_tos, ARG_fwmark, ARG_realms, ARG_table, ARG_lookup,
ARG_suppress_prefixlength, ARG_suppress_ifgroup,
ARG_dev, ARG_iif, ARG_nat, ARG_map_to, ARG_type, ARG_help,
@@ -78,6 +79,10 @@
printf("%u:\t", tb[RTA_PRIORITY] ?
*(unsigned*)RTA_DATA(tb[RTA_PRIORITY])
: 0);
+
+ if (r->rtm_flags & FIB_RULE_INVERT)
+ printf("not ");
+
printf("from ");
if (tb[RTA_SRC]) {
if (r->rtm_src_len != host_len) {
@@ -230,7 +235,9 @@
key = index_in_substrings(keywords, *argv) + 1;
if (key == 0) /* no match found in keywords array, bail out. */
invarg_1_to_2(*argv, applet_name);
- if (key == ARG_from) {
+ if (key == ARG_not) {
+ req.r.rtm_flags |= FIB_RULE_INVERT;
+ } else if (key == ARG_from) {
inet_prefix dst;
NEXT_ARG();
get_prefix(&dst, *argv, req.r.rtm_family);
--- a/networking/libiproute/rt_names.c 2021-01-01 05:30:02.000000000 -0800
+++ b/rt_names.c 2022-05-10 16:50:30.298597124 -0700
@@ -251,7 +251,14 @@
int FAST_FUNC rtnl_rttable_a2n(uint32_t *id, char *arg)
{
rtnl_rttable_initialize();
- return rtnl_a2n(rtnl_rttable_tab, id, arg, 0);
+ if (!rtnl_a2n(rtnl_rttable_tab, id, arg, 0)) return 0;
+
+ unsigned i = bb_strtou(arg, NULL, 0);
+ if (i > RT_TABLE_MAX) {
+ *id = i;
+ return 0;
+ }
+ return -1;
}
#endif