diff --git a/patches/routing/to-upstream/0001-bird1-update-to-version-1.6.5.patch b/patches/routing/to-upstream/0001-bird1-update-to-version-1.6.5.patch new file mode 100644 index 0000000000000000000000000000000000000000..f499f98b642e313e7434956bb9fecba257bd8440 --- /dev/null +++ b/patches/routing/to-upstream/0001-bird1-update-to-version-1.6.5.patch @@ -0,0 +1,56 @@ +From e6da44830d376cad42884419c18a0363f291da42 Mon Sep 17 00:00:00 2001 +From: Josef Schlehofer <josef.schlehofer@nic.cz> +Date: Mon, 14 Jan 2019 13:19:30 +0100 +Subject: [PATCH 1/1] bird1: update to version 1.6.5 + +URL changed from HTTP to HTTPS + +Signed-off-by: Josef Schlehofer <josef.schlehofer@nic.cz> +--- + bird1/Makefile | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/bird1/Makefile b/bird1/Makefile +index e5e32a8..bc19808 100644 +--- a/bird1/Makefile ++++ b/bird1/Makefile +@@ -7,12 +7,12 @@ + include $(TOPDIR)/rules.mk + + PKG_NAME:=bird1 +-PKG_VERSION:=1.6.4 ++PKG_VERSION:=1.6.5 + PKG_RELEASE:=1 + + PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz + PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird +-PKG_MD5SUM:=c26b8caae988dba81a9dbbee93502463d4326d1b749d728d62aa5529c605afc0 ++PKG_HASH:=cc40c851afc354cd5348a63fc5f6fe75de590182522102e348b30a995733d21a + PKG_BUILD_DEPENDS:=ncurses readline + PKG_MAINTAINER:=Ălvaro Fernández Rojas <noltari@gmail.com> + PKG_BUILD_DIR:=$(BUILD_DIR)/bird-$(PKG_VERSION) +@@ -23,19 +23,19 @@ include $(INCLUDE_DIR)/package.mk + + define Package/bird1/Default + TITLE:=The BIRD Internet Routing Daemon (v1.6) +- URL:=http://bird.network.cz/ ++ URL:=https://bird.network.cz/ + DEPENDS:=+libpthread + endef + + define Package/bird1c/Default + TITLE:=The BIRD command-line client (v1.6) +- URL:=http://bird.network.cz/ ++ URL:=https://bird.network.cz/ + DEPENDS:= +libreadline +libncurses + endef + + define Package/bird1cl/Default + TITLE:=The BIRD lightweight command-line client (v1.6) +- URL:=http://bird.network.cz/ ++ URL:=https://bird.network.cz/ + endef + + define Package/bird1/Default/description1 +-- +2.17.1 diff --git a/patches/routing/to-upstream/0002-bird2-update-to-version-2.0.3.patch b/patches/routing/to-upstream/0002-bird2-update-to-version-2.0.3.patch new file mode 100644 index 0000000000000000000000000000000000000000..181c4a92bd8991415e5697459f0f36a89431ac08 --- /dev/null +++ b/patches/routing/to-upstream/0002-bird2-update-to-version-2.0.3.patch @@ -0,0 +1,540 @@ +From 22c295e9ec41a07785c0e2d4996afe964b927b0c Mon Sep 17 00:00:00 2001 +From: Josef Schlehofer <josef.schlehofer@nic.cz> +Date: Mon, 14 Jan 2019 13:11:12 +0100 +Subject: [PATCH 1/1] bird2: update to version 2.0.3 + +URL changed from HTTP to HTTPS as bird use HSTS +Removed all patches as they're in upstream + +Signed-off-by: Josef Schlehofer <josef.schlehofer@nic.cz> +--- + bird2/Makefile | 10 +- + ...1-BGP-Fix-extended-next-hop-handling.patch | 29 ----- + ...dded-missing-instruction-comparators.patch | 37 ------ + ...el-Fix-type-of-route-entry-router-ID.patch | 33 ----- + ...el-Add-option-to-randomize-router-ID.patch | 118 ------------------ + ...r-initialization-of-random-generator.patch | 30 ----- + ...-flag-for-IPv4-routes-with-unreachab.patch | 40 ------ + bird2/patches/0007-Fix-build-version.patch | 28 ----- + ...rt-for-src-filter-op-to-access-SADR-.patch | 99 --------------- + 9 files changed, 5 insertions(+), 419 deletions(-) + delete mode 100644 bird2/patches/0001-BGP-Fix-extended-next-hop-handling.patch + delete mode 100644 bird2/patches/0002-Filter-Added-missing-instruction-comparators.patch + delete mode 100644 bird2/patches/0003-babel-Fix-type-of-route-entry-router-ID.patch + delete mode 100644 bird2/patches/0004-Babel-Add-option-to-randomize-router-ID.patch + delete mode 100644 bird2/patches/0005-Better-initialization-of-random-generator.patch + delete mode 100644 bird2/patches/0006-babel-Set-onlink-flag-for-IPv4-routes-with-unreachab.patch + delete mode 100644 bird2/patches/0007-Fix-build-version.patch + delete mode 100644 bird2/patches/0008-Filter-Add-support-for-src-filter-op-to-access-SADR-.patch + +diff --git a/bird2/Makefile b/bird2/Makefile +index 26b5e4a..915b3d6 100644 +--- a/bird2/Makefile ++++ b/bird2/Makefile +@@ -7,12 +7,12 @@ + include $(TOPDIR)/rules.mk + + PKG_NAME:=bird2 +-PKG_VERSION:=2.0.2 ++PKG_VERSION:=2.0.3 + PKG_RELEASE:=1 + + PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz + PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird +-PKG_HASH:=035f91d6f568f8ed438a0814235ac4c5c79147cd2acf201322c307732883480f ++PKG_HASH:=0f49b38327d3109553acfa662ac0cf0377719226a03c124cd2e0ea2265ecb1de + PKG_BUILD_DEPENDS:=ncurses readline + PKG_MAINTAINER:=Toke Høiland-Jørgensen <toke@toke.dk> + PKG_BUILD_DIR:=$(BUILD_DIR)/bird-$(PKG_VERSION) +@@ -31,7 +31,7 @@ endef + + define Package/bird2 + TITLE:=The BIRD Internet Routing Daemon (v2) +- URL:=http://bird.network.cz/ ++ URL:=https://bird.network.cz/ + SECTION:=net + CATEGORY:=Network + SUBMENU:=Routing and Redirection +@@ -41,7 +41,7 @@ endef + + define Package/bird2c + TITLE:=The BIRD command-line client (v2) +- URL:=http://bird.network.cz/ ++ URL:=https://bird.network.cz/ + SECTION:=net + CATEGORY:=Network + SUBMENU:=Routing and Redirection +@@ -51,7 +51,7 @@ endef + + define Package/bird2cl + TITLE:=The BIRD lightweight command-line client (v2) +- URL:=http://bird.network.cz/ ++ URL:=https://bird.network.cz/ + SECTION:=net + CATEGORY:=Network + SUBMENU:=Routing and Redirection +diff --git a/bird2/patches/0001-BGP-Fix-extended-next-hop-handling.patch b/bird2/patches/0001-BGP-Fix-extended-next-hop-handling.patch +deleted file mode 100644 +index 7f73f66..0000000 +--- a/bird2/patches/0001-BGP-Fix-extended-next-hop-handling.patch ++++ /dev/null +@@ -1,29 +0,0 @@ +-From f3a8cf050e6181e158dcde2fe885d7bf220eedc3 Mon Sep 17 00:00:00 2001 +-From: "Ondrej Zajicek (work)" <santiago@crfreenet.org> +-Date: Thu, 12 Apr 2018 16:55:56 +0200 +-Subject: [PATCH] BGP: Fix extended next hop handling +- +-For IPv4 with extended next hop, we use MP-BGP format and therefore no +-independent NEXT_HOP attribute. +- +-Thanks to Arvin Gan for the bugreport. +---- +- proto/bgp/attrs.c | 2 +- +- 1 file changed, 1 insertion(+), 1 deletion(-) +- +-diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c +-index 0f41f818..9003feb2 100644 +---- a/proto/bgp/attrs.c +-+++ b/proto/bgp/attrs.c +-@@ -295,7 +295,7 @@ bgp_encode_next_hop(struct bgp_write_state *s, eattr *a, byte *buf, uint size) +- * store it and encode it later by AFI-specific hooks. +- */ +- +-- if (s->channel->afi == BGP_AF_IPV4) +-+ if ((s->channel->afi == BGP_AF_IPV4) && !s->channel->ext_next_hop) +- { +- ASSERT(a->u.ptr->length == sizeof(ip_addr)); +- +--- +-2.17.0 +- +diff --git a/bird2/patches/0002-Filter-Added-missing-instruction-comparators.patch b/bird2/patches/0002-Filter-Added-missing-instruction-comparators.patch +deleted file mode 100644 +index 3daefb4..0000000 +--- a/bird2/patches/0002-Filter-Added-missing-instruction-comparators.patch ++++ /dev/null +@@ -1,37 +0,0 @@ +-From 823ad12191e66e243dd088a81c66e4a518563e40 Mon Sep 17 00:00:00 2001 +-From: Jan Maria Matejka <mq@ucw.cz> +-Date: Fri, 27 Apr 2018 14:38:41 +0200 +-Subject: [PATCH] Filter: Added missing instruction comparators. +- +-These instructions caused SIGABORTs on reconfiguration. +---- +- filter/filter.c | 5 +++++ +- 1 file changed, 5 insertions(+) +- +-diff --git a/filter/filter.c b/filter/filter.c +-index bb3146e7..881ba420 100644 +---- a/filter/filter.c +-+++ b/filter/filter.c +-@@ -1712,7 +1712,10 @@ i_same(struct f_inst *f1, struct f_inst *f2) +- case FI_EA_SET: ONEARG; A2_SAME; break; +- +- case FI_RETURN: ONEARG; break; +-+ case FI_ROA_MAXLEN: ONEARG; break; +-+ case FI_ROA_ASN: ONEARG; break; +- case FI_IP: ONEARG; break; +-+ case FI_IS_V4: ONEARG; break; +- case FI_ROUTE_DISTINGUISHER: ONEARG; break; +- case FI_CALL: /* Call rewriting trickery to avoid exponential behaviour */ +- ONEARG; +-@@ -1735,6 +1738,8 @@ i_same(struct f_inst *f1, struct f_inst *f2) +- ((struct f_inst_roa_check *) f2)->rtc->name)) +- return 0; +- break; +-+ case FI_FORMAT: ONEARG; break; +-+ case FI_ASSERT: ONEARG; break; +- default: +- bug( "Unknown instruction %d in same (%c)", f1->fi_code, f1->fi_code & 0xff); +- } +--- +-2.17.0 +- +diff --git a/bird2/patches/0003-babel-Fix-type-of-route-entry-router-ID.patch b/bird2/patches/0003-babel-Fix-type-of-route-entry-router-ID.patch +deleted file mode 100644 +index f4ce573..0000000 +--- a/bird2/patches/0003-babel-Fix-type-of-route-entry-router-ID.patch ++++ /dev/null +@@ -1,33 +0,0 @@ +-From 40e7bd0e39849a03bd3f6f44d6719a5f8b1dd291 Mon Sep 17 00:00:00 2001 +-From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk> +-Date: Mon, 30 Apr 2018 16:29:20 +0200 +-Subject: [PATCH] babel: Fix type of route entry router ID +-MIME-Version: 1.0 +-Content-Type: text/plain; charset=UTF-8 +-Content-Transfer-Encoding: 8bit +- +-The router ID being assigned to routes was a uint, which discards the upper +-32 bits. This also has the nice side effect of echoing the wrong router ID +-back to other routers. +- +-Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk> +---- +- proto/babel/babel.c | 2 +- +- 1 file changed, 1 insertion(+), 1 deletion(-) +- +-diff --git a/proto/babel/babel.c b/proto/babel/babel.c +-index 4fd88042..a8eb5ea8 100644 +---- a/proto/babel/babel.c +-+++ b/proto/babel/babel.c +-@@ -2140,7 +2140,7 @@ babel_rt_notify(struct proto *P, struct channel *c UNUSED, struct network *net, +- uint internal = (new->attrs->src->proto == P); +- uint rt_seqno = internal ? new->u.babel.seqno : p->update_seqno; +- uint rt_metric = ea_get_int(attrs, EA_BABEL_METRIC, 0); +-- uint rt_router_id = internal ? new->u.babel.router_id : p->router_id; +-+ u64 rt_router_id = internal ? new->u.babel.router_id : p->router_id; +- +- if (rt_metric > BABEL_INFINITY) +- { +--- +-2.17.0 +- +diff --git a/bird2/patches/0004-Babel-Add-option-to-randomize-router-ID.patch b/bird2/patches/0004-Babel-Add-option-to-randomize-router-ID.patch +deleted file mode 100644 +index 161b73e..0000000 +--- a/bird2/patches/0004-Babel-Add-option-to-randomize-router-ID.patch ++++ /dev/null +@@ -1,118 +0,0 @@ +-From 70fab17837dbb4c5848681e4c6b9b90891891130 Mon Sep 17 00:00:00 2001 +-From: "Ondrej Zajicek (work)" <santiago@crfreenet.org> +-Date: Thu, 3 May 2018 16:55:11 +0200 +-Subject: [PATCH 1/2] Babel: Add option to randomize router ID +- +-When a Babel node restarts, it loses its sequence number, which can cause +-its routes to be rejected by peers until the state is cleared out by other +-nodes in the network (which can take on the order of minutes). +- +-There are two ways to fix this: Having stable storage to keep the sequence +-number across restarts, or picking a different router ID each time. +- +-This implements the latter, by introducing a new option that will cause +-BIRD to randomize a high 32 bits of router ID every time it starts up. +-This avoids the problem at the cost of not having stable router IDs in +-the network. +- +-Thanks to Toke Hoiland-Jorgensen for the patch. +---- +- doc/bird.sgml | 10 ++++++++++ +- proto/babel/babel.c | 11 +++++++++++ +- proto/babel/babel.h | 1 + +- proto/babel/config.Y | 3 ++- +- 4 files changed, 24 insertions(+), 1 deletion(-) +- +-diff --git a/doc/bird.sgml b/doc/bird.sgml +-index 1191fa03..ae308d4c 100644 +---- a/doc/bird.sgml +-+++ b/doc/bird.sgml +-@@ -1691,6 +1691,7 @@ supports the following per-interface configuration options: +- protocol babel [<name>] { +- ipv4 { <channel config> }; +- ipv6 [sadr] { <channel config> }; +-+ randomize router id <switch>; +- interface <interface pattern> { +- type <wired|wireless>; +- rxcost <number>; +-@@ -1713,6 +1714,15 @@ protocol babel [<name>] { +- <tag><label id="babel-channel">ipv4 | ipv6 [sadr] <m/channel config/</tag> +- The supported channels are IPv4, IPv6, and IPv6 SADR. +- +-+ <tag><label id="babel-random-router-id">randomize router id <m/switch/</tag> +-+ If enabled, Bird will randomize the top 32 bits of its router ID whenever +-+ the protocol instance starts up. If a Babel node restarts, it loses its +-+ sequence number, which can cause its routes to be rejected by peers until +-+ the state is cleared out by other nodes in the network (which can take on +-+ the order of minutes). Enabling this option causes Bird to pick a random +-+ router ID every time it starts up, which avoids this problem at the cost +-+ of not having stable router IDs in the network. Default: no. +-+ +- <tag><label id="babel-type">type wired|wireless </tag> +- This option specifies the interface type: Wired or wireless. On wired +- interfaces a neighbor is considered unreachable after a small number of +-diff --git a/proto/babel/babel.c b/proto/babel/babel.c +-index 797a83d4..ce05191c 100644 +---- a/proto/babel/babel.c +-+++ b/proto/babel/babel.c +-@@ -2226,6 +2226,14 @@ babel_init(struct proto_config *CF) +- return P; +- } +- +-+static inline void +-+babel_randomize_router_id(struct babel_proto *p) +-+{ +-+ p->router_id &= (u64) 0xffffffff; +-+ p->router_id |= ((u64) random()) << 32; +-+ TRACE(D_EVENTS, "Randomized router ID to %lR", p->router_id); +-+} +-+ +- static int +- babel_start(struct proto *P) +- { +-@@ -2244,6 +2252,9 @@ babel_start(struct proto *P) +- p->update_seqno = 1; +- p->router_id = proto_get_router_id(&cf->c); +- +-+ if (cf->randomize_router_id) +-+ babel_randomize_router_id(p); +-+ +- p->route_slab = sl_new(P->pool, sizeof(struct babel_route)); +- p->source_slab = sl_new(P->pool, sizeof(struct babel_source)); +- p->msg_slab = sl_new(P->pool, sizeof(struct babel_msg_node)); +-diff --git a/proto/babel/babel.h b/proto/babel/babel.h +-index b194ce30..e5c9cd5b 100644 +---- a/proto/babel/babel.h +-+++ b/proto/babel/babel.h +-@@ -112,6 +112,7 @@ struct babel_config { +- struct proto_config c; +- list iface_list; /* List of iface configs (struct babel_iface_config) */ +- uint hold_time; /* Time to hold stale entries and unreachable routes */ +-+ u8 randomize_router_id; +- +- struct channel_config *ip4_channel; +- struct channel_config *ip6_channel; +-diff --git a/proto/babel/config.Y b/proto/babel/config.Y +-index 7adfb4bb..205b4e4f 100644 +---- a/proto/babel/config.Y +-+++ b/proto/babel/config.Y +-@@ -25,7 +25,7 @@ CF_DECLS +- CF_KEYWORDS(BABEL, INTERFACE, METRIC, RXCOST, HELLO, UPDATE, INTERVAL, PORT, +- TYPE, WIRED, WIRELESS, RX, TX, BUFFER, PRIORITY, LENGTH, CHECK, LINK, +- NEXT, HOP, IPV4, IPV6, BABEL_METRIC, SHOW, INTERFACES, NEIGHBORS, +-- ENTRIES) +-+ ENTRIES, RANDOMIZE, ROUTER, ID) +- +- CF_GRAMMAR +- +-@@ -42,6 +42,7 @@ babel_proto_item: +- proto_item +- | proto_channel +- | INTERFACE babel_iface +-+ | RANDOMIZE ROUTER ID bool { BABEL_CFG->randomize_router_id = $4; } +- ; +- +- babel_proto_opts: +--- +-2.17.0 +- +diff --git a/bird2/patches/0005-Better-initialization-of-random-generator.patch b/bird2/patches/0005-Better-initialization-of-random-generator.patch +deleted file mode 100644 +index 21c6dc3..0000000 +--- a/bird2/patches/0005-Better-initialization-of-random-generator.patch ++++ /dev/null +@@ -1,30 +0,0 @@ +-From eaf63d314d50cba5b2cfa8f18de64a91d3131b94 Mon Sep 17 00:00:00 2001 +-From: "Ondrej Zajicek (work)" <santiago@crfreenet.org> +-Date: Thu, 3 May 2018 17:07:39 +0200 +-Subject: [PATCH 2/2] Better initialization of random generator +- +-Use full time precision to initialize random generator. The old +-code was prone to initialize it to the same values in specific +-circumstances (boot without RTC, multiple VMs starting at once). +---- +- sysdep/unix/io.c | 4 +++- +- 1 file changed, 3 insertions(+), 1 deletion(-) +- +-diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c +-index 012deaf0..11a0d6f1 100644 +---- a/sysdep/unix/io.c +-+++ b/sysdep/unix/io.c +-@@ -2144,7 +2144,9 @@ io_init(void) +- // XXX init_times(); +- // XXX update_times(); +- boot_time = current_time(); +-- srandom((uint) (current_real_time() TO_S)); +-+ +-+ u64 now = (u64) current_real_time(); +-+ srandom((uint) (now ^ (now >> 32))); +- } +- +- static int short_loops = 0; +--- +-2.17.0 +- +diff --git a/bird2/patches/0006-babel-Set-onlink-flag-for-IPv4-routes-with-unreachab.patch b/bird2/patches/0006-babel-Set-onlink-flag-for-IPv4-routes-with-unreachab.patch +deleted file mode 100644 +index 528051d..0000000 +--- a/bird2/patches/0006-babel-Set-onlink-flag-for-IPv4-routes-with-unreachab.patch ++++ /dev/null +@@ -1,40 +0,0 @@ +-From 0ca3156f64a46c52c6d6fc913958f83970d3e57f Mon Sep 17 00:00:00 2001 +-From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk> +-Date: Mon, 30 Apr 2018 11:13:02 +0200 +-Subject: [PATCH] babel: Set onlink flag for IPv4 routes with unreachable next +- hop +-MIME-Version: 1.0 +-Content-Type: text/plain; charset=UTF-8 +-Content-Transfer-Encoding: 8bit +- +-If the next hop of a route is not a reachable address, the route should be +-installed as onlink. This enables a configuration common in mesh networks +-where the mesh interface is assigned a /32 and babel handles the routing by +-installing onlink routes. +- +-Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk> +---- +- proto/babel/babel.c | 7 +++++++ +- 1 file changed, 7 insertions(+) +- +-diff --git a/proto/babel/babel.c b/proto/babel/babel.c +-index ce05191c..afd2eb19 100644 +---- a/proto/babel/babel.c +-+++ b/proto/babel/babel.c +-@@ -640,6 +640,13 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e) +- .nh.iface = r->neigh->ifa->iface, +- }; +- +-+ /* If we cannot find a reachable neighbour, set the entry to be onlink. This +-+ * makes it possible to, e.g., assign /32 addresses on a mesh interface and +-+ * have routing work. +-+ */ +-+ if (!neigh_find2(&p->p, &r->next_hop, r->neigh->ifa->iface, 0)) +-+ a0.nh.flags = RNF_ONLINK; +-+ +- rta *a = rta_lookup(&a0); +- rte *rte = rte_get_temp(a); +- rte->u.babel.seqno = r->seqno; +--- +-2.17.0 +- +diff --git a/bird2/patches/0007-Fix-build-version.patch b/bird2/patches/0007-Fix-build-version.patch +deleted file mode 100644 +index 84096ad..0000000 +--- a/bird2/patches/0007-Fix-build-version.patch ++++ /dev/null +@@ -1,28 +0,0 @@ +-diff --git a/Makefile.in b/Makefile.in +-index c8168bb..eb6cc5c 100644 +---- a/Makefile.in +-+++ b/Makefile.in +-@@ -21,11 +21,6 @@ INSTALL=@INSTALL@ +- INSTALL_PROGRAM=@INSTALL_PROGRAM@ +- INSTALL_DATA=@INSTALL_DATA@ +- +--git-label:=$(strip $(shell git describe --always --dirty=-x 2>/dev/null)) +--ifneq ($(git-label),) +-- CFLAGS += -DGIT_LABEL="$(git-label)" +--endif +-- +- client=$(addprefix $(exedir)/,@CLIENT@) +- daemon=$(exedir)/bird +- protocols=@protocols@ +-@@ -42,6 +37,11 @@ srcdir := @srcdir@ +- objdir := @objdir@ +- exedir := @exedir@ +- +-+git-label:=$(strip $(shell cd $(srcdir) && [ "$$(git rev-parse --show-toplevel)" = "$$(readlink -f .)" ] && git describe --always --dirty=-x 2>/dev/null)) +-+ifneq ($(git-label),) +-+ CFLAGS += -DGIT_LABEL="$(git-label)" +-+endif +-+ +- ifeq ($(objdir),.) +- objdir := $(realpath .) +- endif +diff --git a/bird2/patches/0008-Filter-Add-support-for-src-filter-op-to-access-SADR-.patch b/bird2/patches/0008-Filter-Add-support-for-src-filter-op-to-access-SADR-.patch +deleted file mode 100644 +index dc2ed34..0000000 +--- a/bird2/patches/0008-Filter-Add-support-for-src-filter-op-to-access-SADR-.patch ++++ /dev/null +@@ -1,99 +0,0 @@ +-From b24b781117179f301116837f0a39468343e4805b Mon Sep 17 00:00:00 2001 +-From: "Ondrej Zajicek (work)" <santiago@crfreenet.org> +-Date: Wed, 16 May 2018 11:19:29 +0200 +-Subject: [PATCH] Filter: Add support for src filter op to access SADR source +- prefix +- +-The patch allows to use 'net.src' to access SADR source prefix +-from filters. +- +-Thanks to Toke Hoiland-Jorgensen for the original patch for srclen. +---- +- filter/config.Y | 3 ++- +- filter/filter.c | 15 +++++++++++++++ +- filter/filter.h | 1 + +- lib/net.h | 2 ++ +- 4 files changed, 20 insertions(+), 1 deletion(-) +- +-diff --git a/filter/config.Y b/filter/config.Y +-index f8170a83..e01e02ef 100644 +---- a/filter/config.Y +-+++ b/filter/config.Y +-@@ -411,7 +411,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN, +- TRUE, FALSE, RT, RO, UNKNOWN, GENERIC, +- FROM, GW, NET, MASK, PROTO, SOURCE, SCOPE, DEST, IFNAME, IFINDEX, +- PREFERENCE, +-- ROA_CHECK, ASN, +-+ ROA_CHECK, ASN, SRC, +- IS_V4, IS_V6, +- LEN, MAXLEN, +- DEFINED, +-@@ -898,6 +898,7 @@ term: +- | term '.' LEN { $$ = f_new_inst(FI_LENGTH); $$->a1.p = $1; } +- | term '.' MAXLEN { $$ = f_new_inst(FI_ROA_MAXLEN); $$->a1.p = $1; } +- | term '.' ASN { $$ = f_new_inst(FI_ROA_ASN); $$->a1.p = $1; } +-+ | term '.' SRC { $$ = f_new_inst(FI_SADR_SRC); $$->a1.p = $1; } +- | term '.' MASK '(' term ')' { $$ = f_new_inst(FI_IP_MASK); $$->a1.p = $1; $$->a2.p = $5; } +- | term '.' FIRST { $$ = f_new_inst(FI_AS_PATH_FIRST); $$->a1.p = $1; } +- | term '.' LAST { $$ = f_new_inst(FI_AS_PATH_LAST); $$->a1.p = $1; } +-diff --git a/filter/filter.c b/filter/filter.c +-index 881ba420..3d7b5c9f 100644 +---- a/filter/filter.c +-+++ b/filter/filter.c +-@@ -1241,6 +1241,20 @@ interpret(struct f_inst *what) +- default: runtime( "Prefix, path, clist or eclist expected" ); +- } +- break; +-+ case FI_SADR_SRC: /* Get SADR src prefix */ +-+ ONEARG; +-+ if (v1.type != T_NET || !net_is_sadr(v1.val.net)) +-+ runtime( "SADR expected" ); +-+ +-+ { +-+ net_addr_ip6_sadr *net = (void *) v1.val.net; +-+ net_addr *src = lp_alloc(f_pool, sizeof(net_addr_ip6)); +-+ net_fill_ip6(src, net->src_prefix, net->src_pxlen); +-+ +-+ res.type = T_NET; +-+ res.val.net = src; +-+ } +-+ break; +- case FI_ROA_MAXLEN: /* Get ROA max prefix length */ +- ONEARG; +- if (v1.type != T_NET || !net_is_roa(v1.val.net)) +-@@ -1714,6 +1728,7 @@ i_same(struct f_inst *f1, struct f_inst *f2) +- case FI_RETURN: ONEARG; break; +- case FI_ROA_MAXLEN: ONEARG; break; +- case FI_ROA_ASN: ONEARG; break; +-+ case FI_SADR_SRC: ONEARG; break; +- case FI_IP: ONEARG; break; +- case FI_IS_V4: ONEARG; break; +- case FI_ROUTE_DISTINGUISHER: ONEARG; break; +-diff --git a/filter/filter.h b/filter/filter.h +-index d347924a..982276f0 100644 +---- a/filter/filter.h +-+++ b/filter/filter.h +-@@ -55,6 +55,7 @@ +- F(FI_LENGTH, 0, 'L') \ +- F(FI_ROA_MAXLEN, 'R', 'M') \ +- F(FI_ROA_ASN, 'R', 'A') \ +-+ F(FI_SADR_SRC, 'n', 's') \ +- F(FI_IP, 'c', 'p') \ +- F(FI_ROUTE_DISTINGUISHER, 'R', 'D') \ +- F(FI_AS_PATH_FIRST, 'a', 'f') \ +-diff --git a/lib/net.h b/lib/net.h +-index ad4000fd..0cd5f735 100644 +---- a/lib/net.h +-+++ b/lib/net.h +-@@ -268,6 +268,8 @@ static inline int net_is_roa(const net_addr *a) +- static inline int net_is_flow(const net_addr *a) +- { return (a->type == NET_FLOW4) || (a->type == NET_FLOW6); } +- +-+static inline int net_is_sadr(const net_addr *a) +-+{ return (a->type == NET_IP6_SADR); } +- +- static inline ip4_addr net4_prefix(const net_addr *a) +- { return ((net_addr_ip4 *) a)->prefix; } +--- +-2.17.0 +- +-- +2.17.1 +