0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-08 20:28:43 +00:00

BGP: Make routing loops silent

One of previous commits added error logging of invalid routes. This
also inadvertently caused error logging of route loops, which should
be ignored silently. Fix that.
This commit is contained in:
Ondrej Zajicek (work) 2022-01-28 18:13:18 +01:00
parent 963b2c7ce2
commit 4c6ee53f31
2 changed files with 9 additions and 5 deletions

View File

@ -1397,19 +1397,19 @@ bgp_decode_attrs(struct bgp_parse_state *s, byte *data, uint len)
/* Reject routes with our ASN in AS_PATH attribute */ /* Reject routes with our ASN in AS_PATH attribute */
if (bgp_as_path_loopy(p, attrs, p->local_as)) if (bgp_as_path_loopy(p, attrs, p->local_as))
goto withdraw; goto loop;
/* Reject routes with our Confederation ID in AS_PATH attribute; RFC 5065 4.0 */ /* Reject routes with our Confederation ID in AS_PATH attribute; RFC 5065 4.0 */
if ((p->public_as != p->local_as) && bgp_as_path_loopy(p, attrs, p->public_as)) if ((p->public_as != p->local_as) && bgp_as_path_loopy(p, attrs, p->public_as))
goto withdraw; goto loop;
/* Reject routes with our Router ID in ORIGINATOR_ID attribute; RFC 4456 8 */ /* Reject routes with our Router ID in ORIGINATOR_ID attribute; RFC 4456 8 */
if (p->is_internal && bgp_originator_id_loopy(p, attrs)) if (p->is_internal && bgp_originator_id_loopy(p, attrs))
goto withdraw; goto loop;
/* Reject routes with our Cluster ID in CLUSTER_LIST attribute; RFC 4456 8 */ /* Reject routes with our Cluster ID in CLUSTER_LIST attribute; RFC 4456 8 */
if (p->rr_client && bgp_cluster_list_loopy(p, attrs)) if (p->rr_client && bgp_cluster_list_loopy(p, attrs))
goto withdraw; goto loop;
/* If there is no local preference, define one */ /* If there is no local preference, define one */
if (!BIT32_TEST(s->attrs_seen, BA_LOCAL_PREF)) if (!BIT32_TEST(s->attrs_seen, BA_LOCAL_PREF))
@ -1430,6 +1430,10 @@ withdraw:
s->err_withdraw = 1; s->err_withdraw = 1;
return NULL; return NULL;
loop:
/* Loops are handled as withdraws, but ignored silently. Do not set err_withdraw. */
return NULL;
} }
void void

View File

@ -1422,7 +1422,7 @@ bgp_decode_mpls_labels(struct bgp_parse_state *s, byte **pos, uint *len, uint *p
/* RFC 8277 2.4 - withdraw does not have variable-size MPLS stack but /* RFC 8277 2.4 - withdraw does not have variable-size MPLS stack but
fixed-size 24-bit Compatibility field, which MUST be ignored */ fixed-size 24-bit Compatibility field, which MUST be ignored */
if (!a && !s->err_withdraw) if (!s->reach_nlri_step)
return; return;
} }
while (!(label & BGP_MPLS_BOS)); while (!(label & BGP_MPLS_BOS));