commit 9ea46b355f5238627039ed96d87835e9ed48fcc9 Author: Ryota Ozaki Date: Mon Dec 12 18:19:49 2016 +0900 Ignore local routes as well as static routes diff --git a/sbin/routed/table.c b/sbin/routed/table.c index d05f213..2d39596 100644 --- a/sbin/routed/table.c +++ b/sbin/routed/table.c @@ -778,6 +778,7 @@ static struct khash { #define KS_DYNAMIC 0x080 /* result of redirect */ #define KS_DELETED 0x100 /* already deleted from kernel */ #define KS_CHECK 0x200 +#define KS_LOCAL 0x400 time_t k_keep; #define K_KEEP_LIM 30 time_t k_redirect_time; /* when redirected route 1st seen */ @@ -924,11 +925,13 @@ rtm_add(struct rt_msghdr *rtm, } k->k_state &= ~(KS_DELETE | KS_ADD | KS_CHANGE | KS_DEL_ADD | KS_DELETED | KS_GATEWAY | KS_STATIC - | KS_NEW | KS_CHECK); + | KS_NEW | KS_CHECK | KS_LOCAL); if (rtm->rtm_flags & RTF_GATEWAY) k->k_state |= KS_GATEWAY; if (rtm->rtm_flags & RTF_STATIC) k->k_state |= KS_STATIC; + if (rtm->rtm_flags & RTF_LOCAL) + k->k_state |= KS_LOCAL; if (0 != (rtm->rtm_flags & (RTF_DYNAMIC | RTF_MODIFIED))) { if (INFO_AUTHOR(info) != 0 @@ -964,7 +967,7 @@ rtm_add(struct rt_msghdr *rtm, /* If it is not a static route, quit until the next comparison * between the kernel and daemon tables, when it will be deleted. */ - if (!(k->k_state & KS_STATIC)) { + if (!(k->k_state & KS_STATIC) && !(k->k_state & KS_LOCAL)) { k->k_state |= KS_DELETE; LIM_SEC(need_kern, k->k_keep); return; @@ -1363,7 +1366,7 @@ kern_out(struct ag_info *ag) return; } - if (k->k_state & KS_STATIC) + if ((k->k_state & KS_STATIC) || (k->k_state & KS_LOCAL)) return; /* modify existing kernel entry if necessary */ @@ -1512,6 +1515,12 @@ fix_kern(void) continue; } + /* Do not touch local routes */ + if (k->k_state & KS_LOCAL) { + pk = &k->k_next; + continue; + } + /* check hold on routes deleted by the operator */ if (k->k_keep > now.tv_sec) { /* ensure we check when the hold is over */