Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Apr 2023 22:08:14 GMT
From:      Olivier Cochard <olivier@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: dc2c49ff3210 - main - net/frr8: Fix bgpd crash with large communities and enable backtrace
Message-ID:  <202304212208.33LM8E81094845@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/ports/commit/?id=dc2c49ff321068aacbb763d951f301b90094958b

commit dc2c49ff321068aacbb763d951f301b90094958b
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2023-04-21 21:25:25 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2023-04-21 21:34:01 +0000

    net/frr8: Fix bgpd crash with large communities and enable backtrace
    
    PR:             270910
    Reported by:    pi
---
 net/frr8/Makefile                           | 14 +++++-----
 net/frr8/files/patch-bgpd_bgp__lcommunity.c | 42 +++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/net/frr8/Makefile b/net/frr8/Makefile
index 610fdeeb6edb..acdfa1ea0581 100644
--- a/net/frr8/Makefile
+++ b/net/frr8/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	frr
 PORTVERSION=	8.5
 DISTVERSIONPREFIX=	frr-
+PORTREVISION=	1
 CATEGORIES=	net
 .if defined(PYTHONTOOLS)
 PKGNAMESUFFIX=	8-pythontools
@@ -67,16 +68,17 @@ PKGMESSAGE=	""
 .else
 INFO=		frr
 
-OPTIONS_DEFINE=		CONFIGROLLBACKS FPM DATACENTER LDPD PAM SHELLACCESS \
+OPTIONS_DEFINE=		BACKTRACE CONFIGROLLBACKS FPM DATACENTER LDPD PAM SHELLACCESS \
 			VTYSH MANPAGES MULTIPATH TCMALLOC RPKI SHARPD SNMP
-OPTIONS_DEFAULT=	VTYSH RPKI FPM MANPAGES
+OPTIONS_DEFAULT=	BACKTRACE VTYSH RPKI FPM MANPAGES
 OPTIONS_SUB=	yes
 
+BACKTRACE_DESC=	Enable backtrace
 CONFIGROLLBACKS_DESC=	Enable configuration rollback support
 FPM_DESC=		Enable Forwarding Plane Manager support
 DATACENTER_DESC=	Use reduced BGP timers
 LDPD_DESC=		Build ldpd
-MULTIPATH_DESC=		Enable multipath function
+MULTIPATH_DESC=		Allow 64 multipath routes (16 default)
 PAM_DESC=		Use libpam for PAM support in vtysh
 RPKI_DESC=		Add BGP RPKI (RFC 6810) support
 SHELLACCESS_DESC=	Allow users to access shell/telnet/ssh
@@ -91,23 +93,23 @@ GROUPS=	frr frrvty
 CPPFLAGS+=	-I${LOCALBASE}/include
 LDFLAGS+=	-L${LOCALBASE}/lib
 
-# PIM compile but didn't work on FreeBSD
+# PIM compile but doesn't work on FreeBSD
 CONFIGURE_ARGS=	--enable-user=frr \
 		--enable-group=frr \
 		--enable-vty-group=frrvty \
 		--disable-doc-html \
 		--sysconfdir=${ETCDIR} \
 		--localstatedir=/var/run/frr \
-		--disable-backtrace \
 		--disable-nhrpd \
 		--disable-pathd \
 		--disable-ospfclient \
 		--disable-pimd \
-		--disable-vrrpd \
 		--with-vtysh-pager=cat
 
 MANPAGES_BUILD_DEPENDS=		${PYTHON_PKGNAMEPREFIX}sphinx>=0,1:textproc/py-sphinx@${PY_FLAVOR}
 MANPAGES_CONFIGURE_OFF=		--disable-doc
+BACKTRACE_LIB_DEPENDS=	libunwind.so:devel/libunwind
+BACKTRACE_CONFIGURE_ENABLE=	backtrace
 CONFIGROLLBACKS_LIB_DEPENDS=	libsqlite3.so:databases/sqlite3
 CONFIGROLLBACKS_CONFIGURE_ENABLE=	config-rollbacks
 DATACENTER_CONFIGURE_ENABLE=	datacenter
diff --git a/net/frr8/files/patch-bgpd_bgp__lcommunity.c b/net/frr8/files/patch-bgpd_bgp__lcommunity.c
new file mode 100644
index 000000000000..9f8566cea61d
--- /dev/null
+++ b/net/frr8/files/patch-bgpd_bgp__lcommunity.c
@@ -0,0 +1,42 @@
+--- bgpd/bgp_lcommunity.c.orig	2023-03-13 14:01:47 UTC
++++ bgpd/bgp_lcommunity.c
+@@ -211,12 +211,13 @@ static void set_lcommunity_string(struct lcommunity *l
+ 	}
+ 
+ 	/* 1 space + lcom->size lcom strings + null terminator */
+-	size_t str_buf_sz = BUFSIZ;
++	size_t str_buf_sz = (LCOMMUNITY_STRLEN * lcom->size) + 2;
+ 	str_buf = XCALLOC(MTYPE_LCOMMUNITY_STR, str_buf_sz);
+ 
++	len = 0;
+ 	for (i = 0; i < lcom->size; i++) {
+ 		if (i > 0)
+-			strlcat(str_buf, " ", str_buf_sz);
++			len = strlcat(str_buf, " ", str_buf_sz);
+ 
+ 		pnt = lcom->val + (i * LCOMMUNITY_SIZE);
+ 		pnt = ptr_get_be32(pnt, &global);
+@@ -229,11 +230,22 @@ static void set_lcommunity_string(struct lcommunity *l
+ 		snprintf(lcsb, sizeof(lcsb), "%u:%u:%u", global, local1,
+ 			 local2);
+ 
++		/*
++		 * Aliases can cause havoc, if the alias length is greater
++		 * than the LCOMMUNITY_STRLEN for a particular item
++		 * then we need to realloc the memory associated
++		 * with the string so that it can fit
++		 */
+ 		const char *com2alias =
+ 			translate_alias ? bgp_community2alias(lcsb) : lcsb;
++		size_t individual_len = strlen(com2alias);
++		if (individual_len + len > str_buf_sz) {
++			str_buf_sz = individual_len + len + 1;
++			str_buf = XREALLOC(MTYPE_LCOMMUNITY_STR, str_buf,
++					   str_buf_sz);
++		}
+ 
+ 		len = strlcat(str_buf, com2alias, str_buf_sz);
+-		assert((unsigned int)len < str_buf_sz);
+ 
+ 		if (make_json) {
+ 			json_string = json_object_new_string(com2alias);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304212208.33LM8E81094845>