From 804916daa91834a4740edba96a43c7f0a43744b3 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 18 Jan 2023 13:40:21 +0100 Subject: [PATCH 1/3] Alloc: Minor cleanups - Fix THP disable on old systems - Failed syscalls should use die() instead of bug() - Our printf uses %ld for s64 instead of long --- sysdep/unix/alloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sysdep/unix/alloc.c b/sysdep/unix/alloc.c index d625cd38..c8f1c83f 100644 --- a/sysdep/unix/alloc.c +++ b/sysdep/unix/alloc.c @@ -21,6 +21,9 @@ #ifdef CONFIG_DISABLE_THP #include +#ifndef PR_SET_THP_DISABLE +#define PR_SET_THP_DISABLE 41 +#endif #endif long page_size = 0; @@ -78,7 +81,7 @@ alloc_sys_page(void) void *ptr = mmap(NULL, page_size, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (ptr == MAP_FAILED) - bug("mmap(%lu) failed: %m", page_size); + die("mmap(%ld) failed: %m", (s64) page_size); return ptr; } @@ -99,7 +102,7 @@ alloc_page(void) int err = posix_memalign(&ptr, page_size, page_size); if (err || !ptr) - bug("posix_memalign(%lu) failed", (long unsigned int) page_size); + die("posix_memalign(%ld) failed", (s64) page_size); return ptr; } @@ -229,7 +232,7 @@ resource_sys_init(void) #ifdef CONFIG_DISABLE_THP /* Disable transparent huge pages, they do not work properly with madvice(MADV_DONTNEED) */ if (prctl(PR_SET_THP_DISABLE, (unsigned long) 1, (unsigned long) 0, (unsigned long) 0, (unsigned long) 0) < 0) - die("prctl(PR_SET_THP_DISABLE) failed: %m"); + log(L_WARN "Cannot disable transparent huge pages: prctl(PR_SET_THP_DISABLE) failed: %m"); #endif #ifdef HAVE_MMAP From af611f93aa5040acc606ed289a873bf1136831c2 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 20 Jan 2023 15:55:47 +0100 Subject: [PATCH 2/3] BGP: Add received role value to role mismatch log message --- proto/bgp/bgp.c | 2 +- proto/bgp/bgp.h | 4 +--- proto/bgp/packets.c | 10 ++++++++-- proto/pipe/pipe.c | 4 ---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index f4098e04..2e442e16 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -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" }; diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index ec802fde..2808d479 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -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) diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index ddbc9226..16818cf3 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -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)) diff --git a/proto/pipe/pipe.c b/proto/pipe/pipe.c index a4c5b1d4..d48ce387 100644 --- a/proto/pipe/pipe.c +++ b/proto/pipe/pipe.c @@ -43,10 +43,6 @@ #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) { From 3186ffe79714a48542d5ad61a94c81216b522fd0 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Sun, 22 Jan 2023 12:55:31 +0100 Subject: [PATCH 3/3] Added test case for switch bug fixed in e20bef69ccc4a85ef62359ee539c9db2dbe09127 --- filter/test.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/filter/test.conf b/filter/test.conf index 930169c5..1d291c69 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -109,6 +109,18 @@ function t_int() bt_assert(!(i = 4)); bt_assert(1 <= 1); bt_assert(!(1234 < 1234)); + + case i { + 4200000000: bt_assert(true); + else: bt_assert(false); + } + + case four { + 4: bt_assert(true); + else: bt_assert(false); + } + + } bt_test_suite(t_int, "Testing integers");