diff options
author | Pavel Ĺ orejs <mail@sorejs.eu> | 2023-10-06 04:31:19 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2023-10-06 04:55:56 +0200 |
commit | e83beb70bd14923cece5b35411606ade6fb8fbee (patch) | |
tree | 7433fd0d7a57c5d2190ece9b43516f132976a880 /sysdep/unix/krt.c | |
parent | 57aa077227d1f2440dc1b2bb6cbbebd418a6b898 (diff) |
KRT: Allow to learn routes with RTPROT_KERNEL
The Kernel protocol, even with the option 'learn' enabled, ignores
direct routes created by the OS kernel (on Linux these are routes
with rtm_protocol == RTPROT_KERNEL).
Implement optional behavior where both OS kernel and third-party routes
are learned, it can be enabled by 'learn all' option.
Minor changes by committer.
Diffstat (limited to 'sysdep/unix/krt.c')
-rw-r--r-- | sysdep/unix/krt.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index 9f95247f..3a4b24dc 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -639,12 +639,14 @@ krt_got_route(struct krt_proto *p, rte *e, s8 src) #ifdef KRT_ALLOW_LEARN switch (src) { - case KRT_SRC_KERNEL: - goto ignore; - case KRT_SRC_REDIRECT: goto delete; + case KRT_SRC_KERNEL: + if (KRT_CF->learn != KRT_LEARN_ALL) + goto ignore; + /* fallthrough */ + case KRT_SRC_ALIEN: if (KRT_CF->learn) krt_learn_scan(p, e); @@ -780,6 +782,11 @@ krt_got_route_async(struct krt_proto *p, rte *e, int new, s8 src) break; #ifdef KRT_ALLOW_LEARN + case KRT_SRC_KERNEL: + if (KRT_CF->learn != KRT_LEARN_ALL) + break; + /* fallthrough */ + case KRT_SRC_ALIEN: if (KRT_CF->learn) { |