]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Add received role value to role mismatch log message
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 20 Jan 2023 14:55:47 +0000 (15:55 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 20 Jan 2023 14:55:47 +0000 (15:55 +0100)
proto/bgp/bgp.c
proto/bgp/bgp.h
proto/bgp/packets.c
proto/pipe/pipe.c

index f4098e04ad854710bba6329b46e25bef9aae8c5e..2e442e16ad39693fa078c6237bffcd7187a2bf5a 100644 (file)
@@ -2363,7 +2363,7 @@ bgp_show_afis(int code, char *s, u32 *afis, uint count)
   cli_msg(code, b.start);
 }
 
-static const char *
+const char *
 bgp_format_role_name(u8 role)
 {
   static const char *bgp_role_names[] = { "provider", "rs_server", "rs_client", "customer", "peer" };
index ec802fde97b929787362135e5a3aae47b50fd318..2808d479f136958b37cf93b882175a4352a891f4 100644 (file)
@@ -539,9 +539,7 @@ void bgp_refresh_begin(struct bgp_channel *c);
 void bgp_refresh_end(struct bgp_channel *c);
 void bgp_store_error(struct bgp_proto *p, struct bgp_conn *c, u8 class, u32 code);
 void bgp_stop(struct bgp_proto *p, int subcode, byte *data, uint len);
-
-struct rte_source *bgp_find_source(struct bgp_proto *p, u32 path_id);
-struct rte_source *bgp_get_source(struct bgp_proto *p, u32 path_id);
+const char *bgp_format_role_name(u8 role);
 
 static inline int
 rte_resolvable(rte *rt)
index ddbc9226d9fecd495f26a51ddb03223bd63e09c9..16818cf39f9bbafd5a5f3b99091bfd0b4281db5e 100644 (file)
@@ -908,10 +908,10 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, uint len)
        (local_role == BGP_ROLE_PROVIDER && neigh_role == BGP_ROLE_CUSTOMER) ||
        (local_role == BGP_ROLE_RS_CLIENT && neigh_role == BGP_ROLE_RS_SERVER) ||
        (local_role == BGP_ROLE_RS_SERVER && neigh_role == BGP_ROLE_RS_CLIENT)))
-  { bgp_error(conn, 2, 11, NULL, 0); return; }
+  { bgp_error(conn, 2, 11, &neigh_role, -1); return; }
 
   if ((p->cf->require_roles) && (neigh_role == BGP_ROLE_UNDEFINED))
-  { bgp_error(conn, 2, 11, NULL, 0); return; }
+  { bgp_error(conn, 2, 11, &neigh_role, -1); return; }
 
   /* Check the other connection */
   other = (conn == &p->outgoing_conn) ? &p->incoming_conn : &p->outgoing_conn;
@@ -3158,6 +3158,12 @@ bgp_log_error(struct bgp_proto *p, u8 class, char *msg, uint code, uint subcode,
          goto done;
        }
 
+      if ((code == 2) && (subcode == 11) && (len == 1))
+        {
+         t += bsprintf(t, " (%s)", bgp_format_role_name(get_u8(data)));
+         goto done;
+        }
+
       /* RFC 8203 - shutdown communication */
       if (((code == 6) && ((subcode == 2) || (subcode == 4))))
        if (bgp_handle_message(p, data, len, &t))
index a4c5b1d4ff996271da97e5bc6a497fd90da719ba..d48ce3870f2b9469ae5bb272ddd2146f4299955e 100644 (file)
 
 #include "pipe.h"
 
-#ifdef CONFIG_BGP
-#include "proto/bgp/bgp.h"
-#endif
-
 static void
 pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *old)
 {