<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Gentium">Hello!</font></p>
<p><font face="Gentium">On first sight, this looks good. Gonna do
some checks and tests and let you know whether anything more is
needed from you.</font></p>
<p><font face="Gentium">Thank you for your patch!<br>
Maria</font><br>
</p>
<div class="moz-cite-prefix">On 8/24/23 01:38, Pavel Šorejs via
Bird-users wrote:<br>
</div>
<blockquote type="cite"
cite="mid:9e6e5763-00a8-4714-ae72-112176f5d869@sorejs.eu">Here is
first version - based on master
<br>
<br>
<br>
Pavel
<br>
<br>
---
<br>
doc/bird.sgml | 11 ++++++-----
<br>
sysdep/linux/netlink.c | 2 +-
<br>
sysdep/unix/krt.Y | 7 ++++++-
<br>
sysdep/unix/krt.c | 15 +++++++++++----
<br>
sysdep/unix/krt.h | 4 ++++
<br>
5 files changed, 28 insertions(+), 11 deletions(-)
<br>
<br>
diff --git a/doc/bird.sgml b/doc/bird.sgml
<br>
index 29e12b7a..af87d5dc 100644
<br>
--- a/doc/bird.sgml
<br>
+++ b/doc/bird.sgml
<br>
@@ -3454,9 +3454,8 @@ on the <cf/learn/ switch, such routes are
either ignored or accepted to our
<br>
table).
<br>
<br>
<p>Note that routes created by OS kernel itself, namely
direct routes
<br>
-representing IP subnets of associated interfaces, are not
imported even with
<br>
-<cf/learn/ enabled. You can use <ref id="direct"
name="Direct protocol"> to
<br>
-generate these direct routes.
<br>
+representing IP subnets of associated interfaces, are imported
only with
<br>
+<cf/learn all/ enabled.
<br>
<br>
<p>If your OS supports only a single routing table, you can
configure only one
<br>
instance of the Kernel protocol. If it supports multiple tables
(in order to
<br>
@@ -3487,10 +3486,12 @@ channels.
<br>
Time in seconds between two consecutive scans of the kernel
routing
<br>
table.
<br>
<br>
- <tag><label id="krt-learn">learn
<m/switch/</tag>
<br>
+ <tag><label id="krt-learn">learn
[<m/all/]</tag>
<br>
Enable learning of routes added to the kernel routing tables
by other
<br>
routing daemons or by the system administrator. This is
possible only on
<br>
- systems which support identification of route authorship.
<br>
+ systems which support identification of route authorship. By
default, routes
<br>
+ created by kernel (marked as "proto kernel") are not
imported. Use <m/all/
<br>
+ option to import these routes.
<br>
<br>
<tag><label id="krt-kernel-table">kernel table
<m/number/</tag>
<br>
Select which kernel table should this particular instance of
the Kernel
<br>
diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c
<br>
index 1af78766..29446cab 100644
<br>
--- a/sysdep/linux/netlink.c
<br>
+++ b/sysdep/linux/netlink.c
<br>
@@ -1598,7 +1598,7 @@ nl_parse_route(struct nl_parse_state *s,
struct nlmsghdr *h)
<br>
<br>
case RTPROT_KERNEL:
<br>
krt_src = KRT_SRC_KERNEL;
<br>
- return;
<br>
+ break;
<br>
<br>
case RTPROT_BIRD:
<br>
if (!s->scan)
<br>
diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y
<br>
index 95b54d65..f3eb1393 100644
<br>
--- a/sysdep/unix/krt.Y
<br>
+++ b/sysdep/unix/krt.Y
<br>
@@ -32,6 +32,7 @@ CF_DECLS
<br>
CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES,
GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS)
<br>
CF_KEYWORDS(INTERFACE, PREFERRED)
<br>
<br>
+%type <i> kern_learn
<br>
%type <i> kern_mp_limit
<br>
<br>
CF_GRAMMAR
<br>
@@ -48,6 +49,10 @@ kern_proto_start: proto_start KERNEL {
<br>
kern_proto: kern_proto_start proto_name '{' ;
<br>
kern_proto: kern_proto kern_item ';' ;
<br>
<br>
+kern_learn:
<br>
+ bool { $$ = $1 ? KRT_LEARN_SOME : KRT_LEARN_NONE; }
<br>
+ | ALL { $$ = KRT_LEARN_ALL; }
<br>
+
<br>
kern_mp_limit:
<br>
/* empty */ { $$ = KRT_DEFAULT_ECMP_LIMIT; }
<br>
| LIMIT expr { $$ = $2; if (($2 <= 0) || ($2 > 255))
cf_error("Merge paths limit must be in range 1-255"); }
<br>
@@ -61,7 +66,7 @@ kern_item:
<br>
/* Scan time of 0 means scan on startup only */
<br>
THIS_KRT->scan_time = $3 S_;
<br>
}
<br>
- | LEARN bool {
<br>
+ | LEARN kern_learn {
<br>
THIS_KRT->learn = $2;
<br>
#ifndef KRT_ALLOW_LEARN
<br>
if ($2)
<br>
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
<br>
index 9f95247f..3288fd0c 100644
<br>
--- a/sysdep/unix/krt.c
<br>
+++ b/sysdep/unix/krt.c
<br>
@@ -638,13 +638,14 @@ krt_got_route(struct krt_proto *p, rte *e,
s8 src)
<br>
<br>
#ifdef KRT_ALLOW_LEARN
<br>
switch (src)
<br>
- {
<br>
- case KRT_SRC_KERNEL:
<br>
- goto ignore;
<br>
-
<br>
+ {
<br>
case KRT_SRC_REDIRECT:
<br>
goto delete;
<br>
<br>
+ case KRT_SRC_KERNEL:
<br>
+ if (KRT_CF->learn != KRT_LEARN_ALL)
<br>
+ goto ignore;
<br>
+ // fall through
<br>
case KRT_SRC_ALIEN:
<br>
if (KRT_CF->learn)
<br>
krt_learn_scan(p, e);
<br>
@@ -780,6 +781,12 @@ krt_got_route_async(struct krt_proto *p, rte
*e, int new, s8 src)
<br>
break;
<br>
<br>
#ifdef KRT_ALLOW_LEARN
<br>
+ case KRT_SRC_KERNEL:
<br>
+ if (KRT_CF->learn == KRT_LEARN_ALL)
<br>
+ {
<br>
+ krt_learn_async(p, e, new);
<br>
+ }
<br>
+ break;
<br>
case KRT_SRC_ALIEN:
<br>
if (KRT_CF->learn)
<br>
{
<br>
diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h
<br>
index 18a206e6..694ebd34 100644
<br>
--- a/sysdep/unix/krt.h
<br>
+++ b/sysdep/unix/krt.h
<br>
@@ -27,6 +27,10 @@ struct kif_proto;
<br>
#define KRT_REF_SEEN 0x1 /* Seen in table */
<br>
#define KRT_REF_BEST 0x2 /* Best in table */
<br>
<br>
+#define KRT_LEARN_NONE 0 /* Don't learn */
<br>
+#define KRT_LEARN_SOME 1 /* Learn some routes (excluding
RTPROT_KERNEL) */
<br>
+#define KRT_LEARN_ALL 2 /* Learn all routes */
<br>
+
<br>
/* Whenever we recognize our own routes, we allow learing of
foreign routes */
<br>
<br>
#ifdef CONFIG_SELF_CONSCIOUS
<br>
</blockquote>
<pre class="moz-signature" cols="72">--
Maria Matejka (she/her) | BIRD Team Leader | CZ.NIC, z.s.p.o.</pre>
</body>
</html>