diff mbox series

[v1,1/1] package/dot1ag-utils: new package

Message ID 20260107175339.2469977-2-vjardin@free.fr
State New
Headers show
Series package/dot1ag-utils: new package | expand

Commit Message

Vincent Jardin Jan. 7, 2026, 5:53 p.m. UTC
dot1ag-utils provides tools for IEEE 802.1ag Connectivity Fault
Management (CFM) protocol testing and debugging.

Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 DEVELOPERS                                    |  1 +
 package/Config.in                             |  1 +
 ...0001-fix-strncpy-truncation-warnings.patch | 59 +++++++++++++++++++
 package/dot1ag-utils/Config.in                | 11 ++++
 package/dot1ag-utils/dot1ag-utils.hash        |  3 +
 package/dot1ag-utils/dot1ag-utils.mk          | 17 ++++++
 6 files changed, 92 insertions(+)
 create mode 100644 package/dot1ag-utils/0001-fix-strncpy-truncation-warnings.patch
 create mode 100644 package/dot1ag-utils/Config.in
 create mode 100644 package/dot1ag-utils/dot1ag-utils.hash
 create mode 100644 package/dot1ag-utils/dot1ag-utils.mk

Comments

Thomas Petazzoni Jan. 7, 2026, 10:36 p.m. UTC | #1
Hello Vincent,

Thanks for this patch. For series of just 1 patch, you don't need to
send a cover letter. It's OK to have one of course, but it's not
necessary.

On Wed,  7 Jan 2026 18:53:39 +0100
Vincent Jardin via buildroot <buildroot@buildroot.org> wrote:

> diff --git a/package/dot1ag-utils/0001-fix-strncpy-truncation-warnings.patch b/package/dot1ag-utils/0001-fix-strncpy-truncation-warnings.patch
> new file mode 100644
> index 0000000000..b987a45aa3
> --- /dev/null
> +++ b/package/dot1ag-utils/0001-fix-strncpy-truncation-warnings.patch
> @@ -0,0 +1,59 @@
> +From: Vincent Jardin <vjardin@free.fr>
> +Date: Tue, 7 Jan 2026 11:00:00 +0100
> +Subject: [PATCH] dot1ag_eth: fix strncpy truncation warnings with modern GCC
> +
> +Modern GCC with -Werror fails when strncpy size equals the destination
> +buffer size, as it may not null-terminate the string:
> +
> +  error: '__builtin_strncpy' specified bound 16 equals destination size
> +         [-Werror=stringop-truncation]
> +
> +Fix by using sizeof(dest) - 1 to leave room for the null terminator.
> +The structures are already zeroed with memset() before strncpy, so the
> +last byte remains '\0'.
> +
> +Signed-off-by: Vincent Jardin <vjardin@free.fr>

Needs an Upstream: tag that provides details on the upstream status of
this patch.

> --- /dev/null
> +++ b/package/dot1ag-utils/Config.in
> @@ -0,0 +1,11 @@
> +config BR2_PACKAGE_DOT1AG_UTILS
> +	bool "dot1ag-utils (IEEE 802.1ag tools)"

Should be just:

	bool "dot1g-utils"

> +	select BR2_PACKAGE_LIBPCAP

If you select a package, you need to replicate its dependencies, in
this case:

	depends on BR2_USE_MMU

> diff --git a/package/dot1ag-utils/dot1ag-utils.mk b/package/dot1ag-utils/dot1ag-utils.mk
> new file mode 100644
> index 0000000000..1cde7299a0
> --- /dev/null
> +++ b/package/dot1ag-utils/dot1ag-utils.mk
> @@ -0,0 +1,17 @@
> +################################################################################
> +#
> +# dot1ag-utils
> +#
> +################################################################################
> +
> +DOT1AG_UTILS_VERSION = 4886d70ba83166bd1333eb04df8198a8ddfc5680
> +DOT1AG_UTILS_SITE = $(call github,Bumblebee-Networks,dot1ag-utils,$(DOT1AG_UTILS_VERSION))
> +
> +DOT1AG_UTILS_LICENSE       = BSD-2-Clause

                       ^^^^^^ just one space before/after the = sign

> +DOT1AG_UTILS_LICENSE_FILES = LICENSE
> +
> +DOT1AG_UTILS_DEPENDENCIES = libpcap
> +
> +DOT1AG_UTILS_AUTORECONF = YES

You can probably drop the empty new lines between all those variable
definitions.

> +
> +$(eval $(autotools-package))

The rest looks good to me.

Thanks!

Thomas
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index f982e3123a..f5d82280dc 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -3356,6 +3356,7 @@  N:	Vincent Jardin <vjardin@free.fr>
 F:	board/nvidia/bf3/
 F:	configs/nvidia_bf3_defconfig
 F:	package/bfscripts/
+F:	package/dot1ag-utils/
 F:	package/dpdk/
 F:	package/libecoli/
 F:	package/libyang-cpp/
diff --git a/package/Config.in b/package/Config.in
index def3db0e50..90e2b085f0 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2433,6 +2433,7 @@  endif
 	source "package/dhcpcd/Config.in"
 	source "package/dhcpdump/Config.in"
 	source "package/dnsmasq/Config.in"
+	source "package/dot1ag-utils/Config.in"
 	source "package/drbd-utils/Config.in"
 	source "package/dropbear/Config.in"
 	source "package/easyframes/Config.in"
diff --git a/package/dot1ag-utils/0001-fix-strncpy-truncation-warnings.patch b/package/dot1ag-utils/0001-fix-strncpy-truncation-warnings.patch
new file mode 100644
index 0000000000..b987a45aa3
--- /dev/null
+++ b/package/dot1ag-utils/0001-fix-strncpy-truncation-warnings.patch
@@ -0,0 +1,59 @@ 
+From: Vincent Jardin <vjardin@free.fr>
+Date: Tue, 7 Jan 2026 11:00:00 +0100
+Subject: [PATCH] dot1ag_eth: fix strncpy truncation warnings with modern GCC
+
+Modern GCC with -Werror fails when strncpy size equals the destination
+buffer size, as it may not null-terminate the string:
+
+  error: '__builtin_strncpy' specified bound 16 equals destination size
+         [-Werror=stringop-truncation]
+
+Fix by using sizeof(dest) - 1 to leave room for the null terminator.
+The structures are already zeroed with memset() before strncpy, so the
+last byte remains '\0'.
+
+Signed-off-by: Vincent Jardin <vjardin@free.fr>
+---
+ src/dot1ag_eth.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/dot1ag_eth.c b/src/dot1ag_eth.c
+index 1111111..2222222 100644
+--- a/src/dot1ag_eth.c
++++ b/src/dot1ag_eth.c
+@@ -122,7 +122,7 @@ get_local_mac(uint8_t *ea, const char *ifname) {
+   }
+
+   /* bind BPF to the outgoing interface */
+-  strncpy(ifc.ifr_name, ifname, IFNAMSIZ);
++  strncpy(ifc.ifr_name, ifname, IFNAMSIZ - 1);
+   if (ioctl(bpf, BIOCSETIF, &ifc) > 0) {
+     perror("BIOCSETIF");
+     exit(EXIT_FAILURE);
+@@ -159,7 +159,7 @@ send_packet(const char *dev, const uint8_t *buf, size_t size) {
+
+   /* get interface index */
+   memset(&req, 0, sizeof(req));
+-  strncpy(req.ifr_name, dev, sizeof(req.ifr_name));
++  strncpy(req.ifr_name, dev, sizeof(req.ifr_name) - 1);
+
+   /* get MAC address of interface */
+   if (ioctl(s, SIOCGIFHWADDR, &req)) {
+@@ -202,7 +202,7 @@ send_packet_old(const char *ifname, const uint8_t *buf, size_t size) {
+
+     /* Get interface index once */
+     memset(&req, 0, sizeof(req));
+-    strncpy(req.ifr_name, ifname, sizeof(req.ifr_name));
++    strncpy(req.ifr_name, ifname, sizeof(req.ifr_name) - 1);
+     if (ioctl(s, SIOCGIFINDEX, &req) < 0) {
+       perror(ifname);
+       exit(EXIT_FAILURE);
+@@ -250,7 +250,7 @@ send_packet_old(const char *ifname, const uint8_t *buf, size_t size) {
+
+   /* get interface index */
+   memset(&req, 0, sizeof(req));
+-  strncpy(req.ifr_name, ifname, sizeof(req.ifr_name));
++  strncpy(req.ifr_name, ifname, sizeof(req.ifr_name) - 1);
+   if (ioctl(s, SIOCGIFINDEX, &req)) {
+     perror(ifname);
+     exit(EXIT_FAILURE);
diff --git a/package/dot1ag-utils/Config.in b/package/dot1ag-utils/Config.in
new file mode 100644
index 0000000000..eabe0d9b51
--- /dev/null
+++ b/package/dot1ag-utils/Config.in
@@ -0,0 +1,11 @@ 
+config BR2_PACKAGE_DOT1AG_UTILS
+	bool "dot1ag-utils (IEEE 802.1ag tools)"
+	select BR2_PACKAGE_LIBPCAP
+	help
+	  802.1ag Ethernet OAM utilities: ethping, ethtrace,
+	  dot1agd, dot1ag_ccd, etc.
+
+	  User-space implementation of IEEE 802.1ag, useful to test
+	  Ethernet OAM / CFM connectivity (L2 ping/trace).
+
+	  https://github.com/Bumblebee-Networks/dot1ag-utils
diff --git a/package/dot1ag-utils/dot1ag-utils.hash b/package/dot1ag-utils/dot1ag-utils.hash
new file mode 100644
index 0000000000..5d0b3b8346
--- /dev/null
+++ b/package/dot1ag-utils/dot1ag-utils.hash
@@ -0,0 +1,3 @@ 
+# Locally computed
+sha256  2dcec34d4c9849b7d15a88aedb65eb6911a813e7f1535222513f4c7abecacc49  dot1ag-utils-4886d70ba83166bd1333eb04df8198a8ddfc5680.tar.gz
+sha256  08f7c06906976be9ee27339b268a57a85900928bcb394633382a73268fdc3868  LICENSE
diff --git a/package/dot1ag-utils/dot1ag-utils.mk b/package/dot1ag-utils/dot1ag-utils.mk
new file mode 100644
index 0000000000..1cde7299a0
--- /dev/null
+++ b/package/dot1ag-utils/dot1ag-utils.mk
@@ -0,0 +1,17 @@ 
+################################################################################
+#
+# dot1ag-utils
+#
+################################################################################
+
+DOT1AG_UTILS_VERSION = 4886d70ba83166bd1333eb04df8198a8ddfc5680
+DOT1AG_UTILS_SITE = $(call github,Bumblebee-Networks,dot1ag-utils,$(DOT1AG_UTILS_VERSION))
+
+DOT1AG_UTILS_LICENSE       = BSD-2-Clause
+DOT1AG_UTILS_LICENSE_FILES = LICENSE
+
+DOT1AG_UTILS_DEPENDENCIES = libpcap
+
+DOT1AG_UTILS_AUTORECONF = YES
+
+$(eval $(autotools-package))