Skip to contentSkip to conversation

libnet:new package

PATCH New Joris Lijssens 3 participants 9 messages Nov 9, 2015 – Nov 11, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libnet:new package

---
 package/Config.in        |  1 +
 package/libnet/Config.in |  7 +++++++
 package/libnet/libnet.mk | 13 +++++++++++++
 3 files changed, 21 insertions(+)
 create mode 100644 package/libnet/Config.in
 create mode 100644 package/libnet/libnet.mk
package/Config.in +1 -0
index bdc3063..e0b42c0 100644
@@ -1019,6 +1019,7 @@ menu "Networking"
 	source "package/libmnl/Config.in"
 	source "package/libmodbus/Config.in"
 	source "package/libndp/Config.in"
+	source "package/libnet/Config.in"
 	source "package/libnetfilter_acct/Config.in"
 	source "package/libnetfilter_conntrack/Config.in"
 	source "package/libnetfilter_cthelper/Config.in"
package/libnet/Config.in new file +7 -0
new file mode 100644
index 0000000..76ed9dd
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_LIBNET
+	bool "libnet"
+	help
+	  libnet provides a portable framework for low-level network packet
+	  construction.
+
+	  http://sourceforge.net/projects/libnet-dev
package/libnet/libnet.mk new file +13 -0
new file mode 100644
index 0000000..d021f76
@@ -0,0 +1,13 @@
+################################################################################
+#
+# libnet
+#
+################################################################################
+
+LIBNET_VERSION = 1.1.6
+LIBNET_SITE = http://sourceforge.net/projects/libnet-dev/files
+LIBNET_INSTALL_STAGING = YES
+LIBNET_LICENSE = BSD-2c
+LIBNET_LICENSE_FILES = doc/COPYING
+
+$(eval $(autotools-package))
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 2/2 netsniff-ng:new package

---
 package/Config.in                  |  1 +
 package/netsniff-ng/Config.in      | 22 ++++++++++++++++++++++
 package/netsniff-ng/netsniff-ng.mk | 30 ++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 package/netsniff-ng/Config.in
 create mode 100644 package/netsniff-ng/netsniff-ng.mk
package/Config.in +1 -0
index e0b42c0..0a80afb 100644
@@ -88,6 +88,7 @@ endif
 	source "package/mcelog/Config.in"
 	source "package/memstat/Config.in"
 	source "package/netperf/Config.in"
+	source "package/netsniff-ng/Config.in"
 	source "package/oprofile/Config.in"
 	source "package/pax-utils/Config.in"
 	source "package/pv/Config.in"
package/netsniff-ng/Config.in new file +22 -0
new file mode 100644
index 0000000..448e853
@@ -0,0 +1,22 @@
+config BR2_PACKAGE_NETSNIFF_NG
+	bool "netsniff-ng"
+	select BR2_PACKAGE_LIBNL
+	select BR2_PACKAGE_LIBPCAP
+	select BR2_PACKAGE_LIBCLI
+	select BR2_PACKAGE_LIBNETFILTER_CONNTRACK
+	select BR2_PACKAGE_LIBURCU
+	select BR2_PACKAGE_LIBNET
+	depends on BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_58854 # liburcu
+	help
+	  netsniff-ng is a free, performant Linux network analyzer and
+	  networking toolkit. If you will, the Swiss army knife for
+	  network packets.
+
+comment "netsniff-ng needs an (e)glibc toolchain w/ threads"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
+	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_58854
+
+comment "netsniff-ng needs a toolchain not affected by GCC bug 58854"
+	depends on BR2_TOOLCHAIN_HAS_GCC_BUG_58854
package/netsniff-ng/netsniff-ng.mk new file +30 -0
new file mode 100644
index 0000000..6f755a1
@@ -0,0 +1,30 @@
+################################################################################
+#
+# netsniff-ng
+#
+################################################################################
+
+NETSNIFF_NG_VERSION = v0.5.9
+NETSNIFF_NG_SITE = $(call github,netsniff-ng,netsniff-ng,$(NETSNIFF_NG_VERSION))
+NETSNIFF_NG_LICENSE = GPLv2
+NETSNIFF_NG_LICENSE_FILES = README
+
+define NETSNIFF_NG_CONFIGURE_CMDS
+		(cd $(@D); \
+		$(TARGET_CONFIGURE_ARGS) \
+		$(TARGET_CONFIGURE_OPTS) \
+		./configure \
+		--prefix=$(TARGET_DIR)/usr \
+	)
+endef
+
+define NETSNIFF_NG_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D)
+endef
+
+define NETSNIFF_NG_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		PREFIX=$(TARGET_DIR)/usr ETCDIR=$(TARGET_DIR)/etc install -C $(@D)
+endef
+
+$(eval $(generic-package))
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/2 netsniff-ng:new package

Hi Joris,

Quoted 5 lines · Joris Lijssens
---
 package/Config.in                  |  1 +
 package/netsniff-ng/Config.in      | 22 ++++++++++++++++++++++
 package/netsniff-ng/netsniff-ng.mk | 30 ++++++++++++++++++++++++++++++

Same comment about the .hash file.

Quoted 22 lines
 3 files changed, 53 insertions(+)
 create mode 100644 package/netsniff-ng/Config.in
 create mode 100644 package/netsniff-ng/netsniff-ng.mk
package/Config.in +1 -0
index e0b42c0..0a80afb 100644
@@ -88,6 +88,7 @@ endif
 	source "package/mcelog/Config.in"
 	source "package/memstat/Config.in"
 	source "package/netperf/Config.in"
+	source "package/netsniff-ng/Config.in"
 	source "package/oprofile/Config.in"
 	source "package/pax-utils/Config.in"
 	source "package/pv/Config.in"
package/netsniff-ng/Config.in new file +0 -0
new file mode 100644
index 0000000..448e853

package/netsniff-ng/Config.in line 7

Quoted 7 lines
package/netsniff-ng/Config.in new file +7 -0
@@ -0,0 +1,22 @@
+config BR2_PACKAGE_NETSNIFF_NG
+	bool "netsniff-ng"
+	select BR2_PACKAGE_LIBNL
+	select BR2_PACKAGE_LIBPCAP
+	select BR2_PACKAGE_LIBCLI
+	select BR2_PACKAGE_LIBNETFILTER_CONNTRACK
+	select BR2_PACKAGE_LIBURCU

You also have to take along the arch dependencies of liburcu:

	depends on BR2_arm || BR2_armeb || BR2_aarch64 || BR2_i386 || BR2_powerpc ||

BR2_x86_64

But actually, all of these dependencies are optional, i.e. the corresponding
features will be disabled but the package still builds fine. In that case, we handle it purely in the .mk file, see below.

package/netsniff-ng/Config.in line 9

Quoted 2 lines
package/netsniff-ng/Config.in new file +2 -0
+	select BR2_PACKAGE_LIBNET
+	depends on BR2_TOOLCHAIN_USES_GLIBC

Where does this dependency come from? Mention it in a comment here and/or in
the commit log.

package/netsniff-ng/Config.in line 10

Quoted 1 line
package/netsniff-ng/Config.in new file +1 -0
+	depends on BR2_TOOLCHAIN_HAS_THREADS

Note to other reviewers: this package unconditionally uses threads so it's not
an inherited dependency.

package/netsniff-ng/Config.in line 19

Quoted 9 lines
package/netsniff-ng/Config.in new file +9 -0
+	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_58854 # liburcu
+	help
+	  netsniff-ng is a free, performant Linux network analyzer and
+	  networking toolkit. If you will, the Swiss army knife for
+	  network packets.
+
+comment "netsniff-ng needs an (e)glibc toolchain w/ threads"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC
+	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_58854

Arch dependencies have to be repeated here.

Quoted 9 lines
package/netsniff-ng/Config.in new file +3 -0
+
+comment "netsniff-ng needs a toolchain not affected by GCC bug 58854"
+	depends on BR2_TOOLCHAIN_HAS_GCC_BUG_58854
package/netsniff-ng/netsniff-ng.mk new file +0 -0
new file mode 100644
index 0000000..6f755a1

package/netsniff-ng/netsniff-ng.mk line 9

Quoted 9 lines
package/netsniff-ng/netsniff-ng.mk new file +9 -0
@@ -0,0 +1,30 @@
+################################################################################
+#
+# netsniff-ng
+#
+################################################################################
+
+NETSNIFF_NG_VERSION = v0.5.9
+NETSNIFF_NG_SITE = $(call github,netsniff-ng,netsniff-ng,$(NETSNIFF_NG_VERSION))
+NETSNIFF_NG_LICENSE = GPLv2

I double-checked that this really is the case. Many source files don't have a
license header, but the ones that do are really v2-only.

package/netsniff-ng/netsniff-ng.mk line 10

Quoted 1 line
package/netsniff-ng/netsniff-ng.mk new file +1 -0
+NETSNIFF_NG_LICENSE_FILES = README

Should be COPYING

host-pkgconf is a dependency. You should also add all the selects from
Config.in as _DEPENDENCIES here. But as I said, they're not obligatory dependencies. So this should be the dependency list:

NETSNIFF_NG_DEPENDENCIES = host-pkgconf

ifeq ($(BR2_PACKAGE_LIBNL),y)
NETSNIFF_NG_DEPENDENCIES += libnl
endif

There is also an optional dependency on ncurses, geoip, zlib.

Also host-flex and host-bison are optional dependencies. For these, we don't
have a good way to deal with them, so I propose to add them unconditionally. Mention that in the commit log and/or a comment.

package/netsniff-ng/netsniff-ng.mk line 13

Quoted 3 lines
package/netsniff-ng/netsniff-ng.mk new file +3 -0
+
+define NETSNIFF_NG_CONFIGURE_CMDS
+		(cd $(@D); \

One tab too many here.

package/netsniff-ng/netsniff-ng.mk line 18

Quoted 5 lines
package/netsniff-ng/netsniff-ng.mk new file +5 -0
+		$(TARGET_CONFIGURE_ARGS) \
+		$(TARGET_CONFIGURE_OPTS) \
+		./configure \
+		--prefix=$(TARGET_DIR)/usr \
+	)

The brackets around it are not needed in fact.

Unfortunately, this manually written configure script has some deficiencies. It
will look for nacl in /usr/include/nacl, so if it happens to be installed there, we'll get a wrong build. This can be fixed by adding NACL_INC_DIR=/dev/null and NACL_LIB_DIR=/dev/null to NETSNIFF_NG_CONF_ENV (and adding that to the _CMDS of course).

I've marked both patches as 'Changes requested' in patchwork, so we will forget
about them unless you send a new version.

Regards,
Arnout

Quoted 13 lines
package/netsniff-ng/netsniff-ng.mk new file +12 -0
+endef
+
+define NETSNIFF_NG_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D)
+endef
+
+define NETSNIFF_NG_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		PREFIX=$(TARGET_DIR)/usr ETCDIR=$(TARGET_DIR)/etc install -C $(@D)
+endef
+
+$(eval $(generic-package))
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

PATCH 2/2 netsniff-ng:new package

In reply to Joris Lijssens

Dear Joris Lijssens,

Quoted 8 lines · Joris Lijssens
---
 package/Config.in                  |  1 +
 package/netsniff-ng/Config.in      | 22 ++++++++++++++++++++++
 package/netsniff-ng/netsniff-ng.mk | 30 ++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 package/netsniff-ng/Config.in
 create mode 100644 package/netsniff-ng/netsniff-ng.mk

I've applied your patch after doing a number of changes:

[Thomas:
- add comment in Config.in to explain why this package depends on glibc, and specifically why it doesn't build for uClibc and musl.
- add hash file.
- add 'COPYING' to the list of LICENSE_FILES
- add themissing <pkg>_DEPENDENCIES variable in the .mk file, to make sure dependencies are built before netsniff-ng.
- add comment in the .mk file explain why we're using the generic-package infrastructure even if the build procedure is essentially ./configure, make, make install.
- fix indentation in NETSNIFF_NG_CONFIGURE_CMDS.]

Though I believe you should look into the comments made by Arnout, since some of them remain valid even after my changes, and it would be great if you could address them through follow-up patches.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 1/2 libnet:new package

In reply to Joris Lijssens

Hi Joris,

Quoted 5 lines · Joris Lijssens
---
 package/Config.in        |  1 +
 package/libnet/Config.in |  7 +++++++
 package/libnet/libnet.mk | 13 +++++++++++++

We now require .hash files for github packages as well, since github nowadays
provides stable tarballs.

Quoted 35 lines
 3 files changed, 21 insertions(+)
 create mode 100644 package/libnet/Config.in
 create mode 100644 package/libnet/libnet.mk
package/Config.in +1 -0
index bdc3063..e0b42c0 100644
@@ -1019,6 +1019,7 @@ menu "Networking"
 	source "package/libmnl/Config.in"
 	source "package/libmodbus/Config.in"
 	source "package/libndp/Config.in"
+	source "package/libnet/Config.in"
 	source "package/libnetfilter_acct/Config.in"
 	source "package/libnetfilter_conntrack/Config.in"
 	source "package/libnetfilter_cthelper/Config.in"
package/libnet/Config.in new file +7 -0
new file mode 100644
index 0000000..76ed9dd
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_LIBNET
+	bool "libnet"
+	help
+	  libnet provides a portable framework for low-level network packet
+	  construction.
+
+	  http://sourceforge.net/projects/libnet-dev
package/libnet/libnet.mk new file +0 -0
new file mode 100644
index 0000000..d021f76

package/libnet/libnet.mk line 10

Quoted 10 lines
package/libnet/libnet.mk new file +10 -0
@@ -0,0 +1,13 @@
+################################################################################
+#
+# libnet
+#
+################################################################################
+
+LIBNET_VERSION = 1.1.6
+LIBNET_SITE = http://sourceforge.net/projects/libnet-dev/files
+LIBNET_INSTALL_STAGING = YES
+LIBNET_LICENSE = BSD-2c

There are also a few BSD-3c files, so I think this should be BSD-2c, BSD-3c.

package/libnet/libnet.mk line 13

Quoted 4 lines
package/libnet/libnet.mk new file +3 -0
+LIBNET_LICENSE_FILES = doc/COPYING
+
+$(eval $(autotools-package))

The configure script tries to build and run a program to test for ETH_P_ALL
availability in the AC_LIBNET_CHECK_PF_PACKET function. This will obviously fail when cross-compiling, maybe worse when hostarch == targetarch. So I think it's best to explicitly pass libnet_cv_have_packet_socket=yes

Also it would be nice if there was a way to enable the bpf support, but that
can come later.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#5 lore raw

PATCH 1/2 libnet:new package

Arnout,

I'm just seeing your review right now. Did you mark the patches as Changes Requested? I did not mark them as Accepted as far as I remember, even if I applied them.

Quoted 2 lines · Arnout Vandecappelle

We now require .hash files for github packages as well, since github nowadays
provides stable tarballs.

This package is not fetched from github. But I've added the hash nonetheless.

Quoted 6 lines

package/libnet/libnet.mk line 10

Quoted 4 lines
package/libnet/libnet.mk new file +4 -0
+LIBNET_VERSION = 1.1.6
+LIBNET_SITE = http://sourceforge.net/projects/libnet-dev/files
+LIBNET_INSTALL_STAGING = YES
+LIBNET_LICENSE = BSD-2c

There are also a few BSD-3c files, so I think this should be BSD-2c, BSD-3c.

I made a follow-up commit to fix this.

Quoted 4 lines

The configure script tries to build and run a program to test for ETH_P_ALL
availability in the AC_LIBNET_CHECK_PF_PACKET function. This will obviously fail when cross-compiling, maybe worse when hostarch == targetarch. So I think it's best to explicitly pass libnet_cv_have_packet_socket=yes

I did a test build here for ARM, and did not encounter any issues. Which configuration did you test? Or is it just by inspection of configure.ac?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#6 lore raw

PATCH 1/2 libnet:new package

Quoted 5 lines · Thomas Petazzoni

Arnout,

I'm just seeing your review right now. Did you mark the patches as Changes Requested? I did not mark them as Accepted as far as I remember, even if I applied them.

Don't you have a hook that does that automatically? Anyway, they currently are
still marked as Changes Requested, so I'll update them to Accepted.

Quoted 8 lines · Arnout Vandecappelle
Quoted 3 lines

We now require .hash files for github packages as well, since github nowadays
provides stable tarballs.

This package is not fetched from github. But I've added the hash nonetheless.

Oops, I confused the two patches :-)

Quoted 10 lines
Quoted 7 lines

package/libnet/libnet.mk line 10

Quoted 5 lines
package/libnet/libnet.mk new file +4 -0
+LIBNET_VERSION = 1.1.6
+LIBNET_SITE = http://sourceforge.net/projects/libnet-dev/files
+LIBNET_INSTALL_STAGING = YES
+LIBNET_LICENSE = BSD-2c

There are also a few BSD-3c files, so I think this should be BSD-2c, BSD-3c.

I made a follow-up commit to fix this.

Quoted 8 lines
Quoted 4 lines

The configure script tries to build and run a program to test for ETH_P_ALL
availability in the AC_LIBNET_CHECK_PF_PACKET function. This will obviously fail when cross-compiling, maybe worse when hostarch == targetarch. So I think it's best to explicitly pass libnet_cv_have_packet_socket=yes

I did a test build here for ARM, and did not encounter any issues. Which configuration did you test? Or is it just by inspection of configure.ac?

With "fail" I mean that it will think that PF_PACKET/ETH_P_ALL is not
available, while normally on Linux it is available (at least for root). Maybe you can configure it out of the kernel, but that would be a very exotic config.

I noticed it by inspecting configure.ac and tested an armv7 build to confirm.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#7 lore raw

PATCH 1/2 libnet:new package

Arnout,

Quoted 2 lines · Arnout Vandecappelle

Don't you have a hook that does that automatically? Anyway, they currently are
still marked as Changes Requested, so I'll update them to Accepted.

I don't use an automatic hook, no. I used to have one, but it wasn't working well when the patch was changed compared to the one in patchwork. I know Peter now uses git notes to solve this problem, but I haven't implemented a similar solution.

Since when I'm done with a patch I anyway have to look again at the list of patches to pick the next one to work on, it's not a big deal to mark as Accepted the patch(es) I just applied.

Quoted 4 lines
Quoted 2 lines

This package is not fetched from github. But I've added the hash nonetheless.

Oops, I confused the two patches :-)

As I said to my reply to Joris, there is in fact a newer upstream for libnet, hosted at github. But it did not build nicely out of the box, so I gave up and reverted back to the version used by Joris.

Quoted 9 lines
Quoted 3 lines

I did a test build here for ARM, and did not encounter any issues. Which configuration did you test? Or is it just by inspection of configure.ac?

With "fail" I mean that it will think that PF_PACKET/ETH_P_ALL is not
available, while normally on Linux it is available (at least for root). Maybe you can configure it out of the kernel, but that would be a very exotic config.

I noticed it by inspecting configure.ac and tested an armv7 build to confirm.

Right. Can you submit a patch doing that? Either you or Joris?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#8 lore raw

PATCH 1/2 libnet:new package

In reply to Joris Lijssens

Dear Joris Lijssens,

Quoted 8 lines · Joris Lijssens
---
 package/Config.in        |  1 +
 package/libnet/Config.in |  7 +++++++
 package/libnet/libnet.mk | 13 +++++++++++++
 3 files changed, 21 insertions(+)
 create mode 100644 package/libnet/Config.in
 create mode 100644 package/libnet/libnet.mk

I've applied, however I had to add a hash file, since it is now mandatory, as noticed by Arnout.

Note that there is a newer version of libnet at
https://github.com/sam-github/libnet (which seems to be the new upstream location for the project). It would be good to use it if possible.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com