From patchwork Wed Jun 27 09:50:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Engelhardt X-Patchwork-Id: 935361 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inai.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41FypQ13xzz9s0w for ; Wed, 27 Jun 2018 19:50:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934221AbeF0Jux (ORCPT ); Wed, 27 Jun 2018 05:50:53 -0400 Received: from a3.inai.de ([88.198.85.195]:49528 "EHLO a3.inai.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934069AbeF0Juw (ORCPT ); Wed, 27 Jun 2018 05:50:52 -0400 Received: by a3.inai.de (Postfix, from userid 65534) id 77156ED494B; Wed, 27 Jun 2018 11:50:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on a3.inai.de X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.1 Received: from a4.inai.de (a4.inai.de [IPv6:2a01:4f8:222:6c9::f8]) by a3.inai.de (Postfix) with ESMTP id E766250BCF23; Wed, 27 Jun 2018 11:50:50 +0200 (CEST) From: Jan Engelhardt To: netfilter-devel@vger.kernel.org Cc: fw@strlen.de Subject: ebtables: modernize build Date: Wed, 27 Jun 2018 11:50:37 +0200 Message-Id: <20180627095043.8315-1-jengelh@inai.de> X-Mailer: git-send-email 2.17.1 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org The following changes since commit 56993546c80576986930f9bae7ae4ba744b1e508: extensions: fix build failure on fc28 (2018-06-06 14:22:25 +0200) are available in the Git repository at: https://github.com/jengelh/ebtables master for you to fetch changes up to 21bd17f272b4e31fa5ef53dbd0620bd16873eb96: build: move to automake (2018-06-27 11:42:22 +0200) ---------------------------------------------------------------- Jan Engelhardt (6): build: drop install -o/-g root build: rename sed source files to .in build: use autoconf-style placeholders in sed-ed files extensions: use __attribute__((constructor)) for autoregistration Add .gitignore build: move to automake .gitignore | 28 ++++ INSTALL | 71 +++------- Makefile | 246 ---------------------------------- Makefile.am | 76 +++++++++++ autogen.sh | 4 + configure.ac | 23 ++++ ebtables-config => ebtables-config.in | 0 ebtables-save => ebtables-save.in | 2 +- ebtables.8 => ebtables.8.in | 6 +- ebtables.sysv => ebtables.sysv.in | 38 +++--- extensions/Makefile | 4 +- extensions/ebt_802_3.c | 2 +- extensions/ebt_among.c | 2 +- extensions/ebt_arp.c | 2 +- extensions/ebt_arpreply.c | 2 +- extensions/ebt_inat.c | 3 +- extensions/ebt_ip.c | 2 +- extensions/ebt_ip6.c | 2 +- extensions/ebt_limit.c | 2 +- extensions/ebt_log.c | 2 +- extensions/ebt_mark.c | 2 +- extensions/ebt_mark_m.c | 2 +- extensions/ebt_nat.c | 2 +- extensions/ebt_nflog.c | 2 +- extensions/ebt_pkttype.c | 2 +- extensions/ebt_redirect.c | 2 +- extensions/ebt_standard.c | 2 +- extensions/ebt_stp.c | 2 +- extensions/ebt_string.c | 2 +- extensions/ebt_ulog.c | 2 +- extensions/ebt_vlan.c | 2 +- extensions/ebtable_broute.c | 2 +- extensions/ebtable_filter.c | 2 +- extensions/ebtable_nat.c | 2 +- include/ebtables_u.h | 2 + m4/.gitignore | 2 + 36 files changed, 205 insertions(+), 344 deletions(-) create mode 100644 .gitignore delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac rename ebtables-config => ebtables-config.in (100%) rename ebtables-save => ebtables-save.in (97%) rename ebtables.8 => ebtables.8.in (99%) rename ebtables.sysv => ebtables.sysv.in (66%) create mode 100644 m4/.gitignore --- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From patchwork Wed Jun 27 09:50:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Engelhardt X-Patchwork-Id: 935362 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inai.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41FypR3W7Sz9s2R for ; Wed, 27 Jun 2018 19:50:55 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964773AbeF0Juy (ORCPT ); Wed, 27 Jun 2018 05:50:54 -0400 Received: from a3.inai.de ([88.198.85.195]:49536 "EHLO a3.inai.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934202AbeF0Jux (ORCPT ); Wed, 27 Jun 2018 05:50:53 -0400 Received: by a3.inai.de (Postfix, from userid 65534) id 22465ED494D; Wed, 27 Jun 2018 11:50:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on a3.inai.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.1 Received: from a4.inai.de (a4.inai.de [IPv6:2a01:4f8:222:6c9::f8]) by a3.inai.de (Postfix) with ESMTP id 146051FC7DA4; Wed, 27 Jun 2018 11:50:51 +0200 (CEST) From: Jan Engelhardt To: netfilter-devel@vger.kernel.org Cc: fw@strlen.de Subject: [PATCH 2/6] build: rename sed source files to .in Date: Wed, 27 Jun 2018 11:50:39 +0200 Message-Id: <20180627095043.8315-3-jengelh@inai.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180627095043.8315-1-jengelh@inai.de> References: <20180627095043.8315-1-jengelh@inai.de> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Prepare for autoconf-based substitution of macros in the file. --- Makefile | 14 +++++++------- ebtables-config => ebtables-config.in | 0 ebtables-save => ebtables-save.in | 0 ebtables.8 => ebtables.8.in | 0 ebtables.sysv => ebtables.sysv.in | 0 5 files changed, 7 insertions(+), 7 deletions(-) rename ebtables-config => ebtables-config.in (100%) rename ebtables-save => ebtables-save.in (100%) rename ebtables.8 => ebtables.8.in (100%) rename ebtables.sysv => ebtables.sysv.in (100%) diff --git a/Makefile b/Makefile index 79ee167..d0a12d6 100644 --- a/Makefile +++ b/Makefile @@ -154,22 +154,22 @@ tmp1:=$(shell printf $(BINDIR) | sed 's/\//\\\//g') tmp2:=$(shell printf $(SYSCONFIGDIR) | sed 's/\//\\\//g') tmp3:=$(shell printf $(PIPE) | sed 's/\//\\\//g') .PHONY: scripts -scripts: ebtables-save ebtables.sysv ebtables-config - cat ebtables-save | sed 's/__EXEC_PATH__/$(tmp1)/g' > ebtables-save_ +scripts: ebtables-save.in ebtables.sysv.in ebtables-config.in + sed -e 's/__EXEC_PATH__/$(tmp1)/g' ebtables-save_ mkdir -p $(DESTDIR)$(BINDIR) install -m 0755 ebtables-save_ $(DESTDIR)$(BINDIR)/ebtables-save - cat ebtables.sysv | sed 's/__EXEC_PATH__/$(tmp1)/g' | sed 's/__SYSCONFIG__/$(tmp2)/g' > ebtables.sysv_ + sed -e 's/__EXEC_PATH__/$(tmp1)/g' -e 's/__SYSCONFIG__/$(tmp2)/g' ebtables.sysv_ if [ "$(DESTDIR)" != "" ]; then mkdir -p $(DESTDIR)$(INITDIR); fi if test -d $(DESTDIR)$(INITDIR); then install -m 0755 ebtables.sysv_ $(DESTDIR)$(INITDIR)/ebtables; fi - cat ebtables-config | sed 's/__SYSCONFIG__/$(tmp2)/g' > ebtables-config_ + sed -e 's/__SYSCONFIG__/$(tmp2)/g' ebtables-config_ if [ "$(DESTDIR)" != "" ]; then mkdir -p $(DESTDIR)$(SYSCONFIGDIR); fi if test -d $(DESTDIR)$(SYSCONFIGDIR); then install -m 0600 ebtables-config_ $(DESTDIR)$(SYSCONFIGDIR)/ebtables-config; fi rm -f ebtables-save_ ebtables.sysv_ ebtables-config_ tmp4:=$(shell printf $(LOCKFILE) | sed 's/\//\\\//g') -$(MANDIR)/man8/ebtables.8: ebtables.8 +$(MANDIR)/man8/ebtables.8: ebtables.8.in mkdir -p $(DESTDIR)$(@D) - sed -e 's/$$(VERSION)/$(PROGVERSION)/' -e 's/$$(DATE)/$(PROGDATE)/' -e 's/$$(LOCKFILE)/$(tmp4)/' ebtables.8 > ebtables.8_ + sed -e 's/$$(VERSION)/$(PROGVERSION)/' -e 's/$$(DATE)/$(PROGDATE)/' -e 's/$$(LOCKFILE)/$(tmp4)/' <$< >ebtables.8_ install -m 0644 ebtables.8_ $(DESTDIR)$@ rm -f ebtables.8_ @@ -224,7 +224,7 @@ release: touch include/* touch include/linux/* touch include/linux/netfilter_bridge/* - sed -i -e 's/$$(VERSION)/$(PROGVERSION)/' -e 's/$$(DATE)/$(PROGDATE)/' -e 's/$$(LOCKFILE)/$(tmp4)/' ebtables.8 + sed -i -e 's/$$(VERSION)/$(PROGVERSION)/' -e 's/$$(DATE)/$(PROGDATE)/' -e 's/$$(LOCKFILE)/$(tmp4)/' ebtables.8 sed -i -e 's/$$(VERSION)/$(PROGVERSION_)/' -e 's/$$(RELEASE)/$(PROGRELEASE)/' ebtables.spec cd ..;tar -c $(DIR) | gzip >$(DIR).tar.gz; cd - rm -rf include/linux diff --git a/ebtables-config b/ebtables-config.in similarity index 100% rename from ebtables-config rename to ebtables-config.in diff --git a/ebtables-save b/ebtables-save.in similarity index 100% rename from ebtables-save rename to ebtables-save.in diff --git a/ebtables.8 b/ebtables.8.in similarity index 100% rename from ebtables.8 rename to ebtables.8.in diff --git a/ebtables.sysv b/ebtables.sysv.in similarity index 100% rename from ebtables.sysv rename to ebtables.sysv.in From patchwork Wed Jun 27 09:50:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Engelhardt X-Patchwork-Id: 935367 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inai.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41Fypr0KTdz9s0w for ; Wed, 27 Jun 2018 19:51:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964809AbeF0JvN (ORCPT ); Wed, 27 Jun 2018 05:51:13 -0400 Received: from a3.inai.de ([88.198.85.195]:49540 "EHLO a3.inai.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934222AbeF0Jux (ORCPT ); Wed, 27 Jun 2018 05:50:53 -0400 Received: by a3.inai.de (Postfix, from userid 65534) id A428BEC9C75; Wed, 27 Jun 2018 11:50:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on a3.inai.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.1 Received: from a4.inai.de (a4.inai.de [IPv6:2a01:4f8:222:6c9::f8]) by a3.inai.de (Postfix) with ESMTP id 22DD31FC7DBD; Wed, 27 Jun 2018 11:50:51 +0200 (CEST) From: Jan Engelhardt To: netfilter-devel@vger.kernel.org Cc: fw@strlen.de Subject: [PATCH 3/6] build: use autoconf-style placeholders in sed-ed files Date: Wed, 27 Jun 2018 11:50:40 +0200 Message-Id: <20180627095043.8315-4-jengelh@inai.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180627095043.8315-1-jengelh@inai.de> References: <20180627095043.8315-1-jengelh@inai.de> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org --- Makefile | 8 ++++---- ebtables-save.in | 2 +- ebtables.8.in | 6 +++--- ebtables.sysv.in | 38 +++++++++++++++++++------------------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index d0a12d6..7c70db0 100644 --- a/Makefile +++ b/Makefile @@ -155,13 +155,13 @@ tmp2:=$(shell printf $(SYSCONFIGDIR) | sed 's/\//\\\//g') tmp3:=$(shell printf $(PIPE) | sed 's/\//\\\//g') .PHONY: scripts scripts: ebtables-save.in ebtables.sysv.in ebtables-config.in - sed -e 's/__EXEC_PATH__/$(tmp1)/g' ebtables-save_ + sed -e 's/[@]sbindir@/$(tmp1)/g' ebtables-save_ mkdir -p $(DESTDIR)$(BINDIR) install -m 0755 ebtables-save_ $(DESTDIR)$(BINDIR)/ebtables-save - sed -e 's/__EXEC_PATH__/$(tmp1)/g' -e 's/__SYSCONFIG__/$(tmp2)/g' ebtables.sysv_ + sed -e 's/[@]sbindir@/$(tmp1)/g' -e 's/[@]sysconfigdir@/$(tmp2)/g' ebtables.sysv_ if [ "$(DESTDIR)" != "" ]; then mkdir -p $(DESTDIR)$(INITDIR); fi if test -d $(DESTDIR)$(INITDIR); then install -m 0755 ebtables.sysv_ $(DESTDIR)$(INITDIR)/ebtables; fi - sed -e 's/__SYSCONFIG__/$(tmp2)/g' ebtables-config_ + sed -e 's/[@]sysconfigdir@/$(tmp2)/g' ebtables-config_ if [ "$(DESTDIR)" != "" ]; then mkdir -p $(DESTDIR)$(SYSCONFIGDIR); fi if test -d $(DESTDIR)$(SYSCONFIGDIR); then install -m 0600 ebtables-config_ $(DESTDIR)$(SYSCONFIGDIR)/ebtables-config; fi rm -f ebtables-save_ ebtables.sysv_ ebtables-config_ @@ -169,7 +169,7 @@ scripts: ebtables-save.in ebtables.sysv.in ebtables-config.in tmp4:=$(shell printf $(LOCKFILE) | sed 's/\//\\\//g') $(MANDIR)/man8/ebtables.8: ebtables.8.in mkdir -p $(DESTDIR)$(@D) - sed -e 's/$$(VERSION)/$(PROGVERSION)/' -e 's/$$(DATE)/$(PROGDATE)/' -e 's/$$(LOCKFILE)/$(tmp4)/' <$< >ebtables.8_ + sed -e 's/[@]PACKAGE_VERSION@/$(PROGVERSION)/' -e 's/[@]PACKAGE_DATE@/$(PROGDATE)/' -e 's/[@]LOCKFILE@/$(tmp4)/' <$< >ebtables.8_ install -m 0644 ebtables.8_ $(DESTDIR)$@ rm -f ebtables.8_ diff --git a/ebtables-save.in b/ebtables-save.in index 49d733b..df14149 100644 --- a/ebtables-save.in +++ b/ebtables-save.in @@ -8,7 +8,7 @@ use strict; my $table; -my $ebtables = "__EXEC_PATH__/ebtables"; +my $ebtables = "@sbindir@/ebtables"; my $cnt = ""; my $version = "1.0"; my $table_name; diff --git a/ebtables.8.in b/ebtables.8.in index e3290fe..3e97c84 100644 --- a/ebtables.8.in +++ b/ebtables.8.in @@ -1,4 +1,4 @@ -.TH EBTABLES 8 "$(DATE)" +.TH EBTABLES 8 "@PACKAGE_DATE@" .\" .\" Man page written by Bart De Schuymer .\" It is based on the iptables man page. @@ -24,7 +24,7 @@ .\" .\" .SH NAME -ebtables (v$(VERSION)) \- Ethernet bridge frame table administration +ebtables (@PACKAGE_VERSION@) \- Ethernet bridge frame table administration .SH SYNOPSIS .BR "ebtables " [ -t " table ] " - [ ACDI "] chain rule specification [match extensions] [watcher extensions] target" .br @@ -1123,7 +1123,7 @@ arp message and the hardware address length in the arp header is 6 bytes. .br .SH FILES .I /etc/ethertypes -.I $(LOCKFILE) +.I @LOCKFILE@ .SH ENVIRONMENT VARIABLES .I EBTABLES_ATOMIC_FILE .SH MAILINGLISTS diff --git a/ebtables.sysv.in b/ebtables.sysv.in index b6848f1..bbf0e74 100644 --- a/ebtables.sysv.in +++ b/ebtables.sysv.in @@ -9,8 +9,8 @@ # chkconfig: - 15 85 # description: Ethernet Bridge filtering tables # -# config: __SYSCONFIG__/ebtables (text) -# __SYSCONFIG__/ebtables. (binary) +# config: @sysconfigdir@/ebtables (text) +# @sysconfigdir@/ebtables.
(binary) source /etc/init.d/functions source /etc/sysconfig/network @@ -18,9 +18,9 @@ source /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 -[ -x __EXEC_PATH__/ebtables ] || exit 1 -[ -x __EXEC_PATH__/ebtables-save ] || exit 1 -[ -x __EXEC_PATH__/ebtables-restore ] || exit 1 +[ -x @sbindir@/ebtables ] || exit 1 +[ -x @sbindir@/ebtables-save ] || exit 1 +[ -x @sbindir@/ebtables-restore ] || exit 1 RETVAL=0 prog="ebtables" @@ -35,17 +35,17 @@ EBTABLES_SAVE_ON_STOP="no" EBTABLES_SAVE_ON_RESTART="no" EBTABLES_SAVE_COUNTER="no" -config=__SYSCONFIG__/$prog-config +config=@sysconfigdir@/$prog-config [ -f "$config" ] && . "$config" start() { echo -n $"Starting $desc ($prog): " if [ "$EBTABLES_BINARY_FORMAT" = "yes" ]; then - for table in $(ls __SYSCONFIG__/ebtables.* 2>/dev/null | sed -e 's/.*ebtables\.//' -e '/save/d' ); do - __EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table --atomic-commit || RETVAL=1 + for table in $(ls @sysconfigdir@/ebtables.* 2>/dev/null | sed -e 's/.*ebtables\.//' -e '/save/d' ); do + @sbindir@/ebtables -t $table --atomic-file @sysconfigdir@/ebtables.$table --atomic-commit || RETVAL=1 done else - __EXEC_PATH__/ebtables-restore < /etc/sysconfig/ebtables || RETVAL=1 + @sbindir@/ebtables-restore < /etc/sysconfig/ebtables || RETVAL=1 fi if [ $RETVAL -eq 0 ]; then @@ -60,7 +60,7 @@ start() { stop() { echo -n $"Stopping $desc ($prog): " for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do - __EXEC_PATH__/ebtables -t $table --init-table || RETVAL=1 + @sbindir@/ebtables -t $table --init-table || RETVAL=1 done if [ "$EBTABLES_MODULES_UNLOAD" = "yes" ]; then @@ -86,22 +86,22 @@ restart() { save() { echo -n $"Saving $desc ($prog): " if [ "$EBTABLES_TEXT_FORMAT" = "yes" ]; then - if [ -e __SYSCONFIG__/ebtables ]; then - chmod 0600 __SYSCONFIG__/ebtables - mv -f __SYSCONFIG__/ebtables __SYSCONFIG__/ebtables.save + if [ -e @sysconfigdir@/ebtables ]; then + chmod 0600 @sysconfigdir@/ebtables + mv -f @sysconfigdir@/ebtables @sysconfigdir@/ebtables.save fi - __EXEC_PATH__/ebtables-save > __SYSCONFIG__/ebtables || RETVAL=1 + @sbindir@/ebtables-save > @sysconfigdir@/ebtables || RETVAL=1 fi if [ "$EBTABLES_BINARY_FORMAT" = "yes" ]; then - rm -f __SYSCONFIG__/ebtables.*.save - for oldtable in $(ls __SYSCONFIG__/ebtables.* 2>/dev/null | grep -vF 'ebtables.save'); do + rm -f @sysconfigdir@/ebtables.*.save + for oldtable in $(ls @sysconfigdir@/ebtables.* 2>/dev/null | grep -vF 'ebtables.save'); do chmod 0600 $oldtable mv -f $oldtable $oldtable.save done for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do - __EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table --atomic-save || RETVAL=1 + @sbindir@/ebtables -t $table --atomic-file @sysconfigdir@/ebtables.$table --atomic-save || RETVAL=1 if [ "$EBTABLES_SAVE_COUNTER" = "no" ]; then - __EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table -Z || RETVAL=1 + @sbindir@/ebtables -t $table --atomic-file @sysconfigdir@/ebtables.$table -Z || RETVAL=1 fi done fi @@ -134,7 +134,7 @@ case "$1" in save ;; status) - __EXEC_PATH__/ebtables-save + @sbindir@/ebtables-save RETVAL=$? ;; *) From patchwork Wed Jun 27 09:50:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Engelhardt X-Patchwork-Id: 935365 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inai.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41Fypg4MQgz9s2R for ; Wed, 27 Jun 2018 19:51:07 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964793AbeF0Ju5 (ORCPT ); Wed, 27 Jun 2018 05:50:57 -0400 Received: from a3.inai.de ([88.198.85.195]:49544 "EHLO a3.inai.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964771AbeF0Juy (ORCPT ); Wed, 27 Jun 2018 05:50:54 -0400 Received: by a3.inai.de (Postfix, from userid 65534) id 563B4ED494B; Wed, 27 Jun 2018 11:50:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on a3.inai.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.1 Received: from a4.inai.de (a4.inai.de [IPv6:2a01:4f8:222:6c9::f8]) by a3.inai.de (Postfix) with ESMTP id 327671FC7DBE; Wed, 27 Jun 2018 11:50:51 +0200 (CEST) From: Jan Engelhardt To: netfilter-devel@vger.kernel.org Cc: fw@strlen.de Subject: [PATCH 4/6] extensions: use __attribute__((constructor)) for autoregistration Date: Wed, 27 Jun 2018 11:50:41 +0200 Message-Id: <20180627095043.8315-5-jengelh@inai.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180627095043.8315-1-jengelh@inai.de> References: <20180627095043.8315-1-jengelh@inai.de> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org The ebtables initialization is easier, and, judging from the "static" recipe in Makefile, that calling ebt_*_register ahead of main is safe. This means that a static build won't need the pseudomain hack, and that -nostartfiles can also go away. --- Makefile | 34 +--------------------------------- extensions/Makefile | 4 ++-- extensions/ebt_802_3.c | 2 +- extensions/ebt_among.c | 2 +- extensions/ebt_arp.c | 2 +- extensions/ebt_arpreply.c | 2 +- extensions/ebt_inat.c | 3 +-- extensions/ebt_ip.c | 2 +- extensions/ebt_ip6.c | 2 +- extensions/ebt_limit.c | 2 +- extensions/ebt_log.c | 2 +- extensions/ebt_mark.c | 2 +- extensions/ebt_mark_m.c | 2 +- extensions/ebt_nat.c | 2 +- extensions/ebt_nflog.c | 2 +- extensions/ebt_pkttype.c | 2 +- extensions/ebt_redirect.c | 2 +- extensions/ebt_standard.c | 2 +- extensions/ebt_stp.c | 2 +- extensions/ebt_string.c | 2 +- extensions/ebt_ulog.c | 2 +- extensions/ebt_vlan.c | 2 +- extensions/ebtable_broute.c | 2 +- extensions/ebtable_filter.c | 2 +- extensions/ebtable_nat.c | 2 +- include/ebtables_u.h | 2 ++ 26 files changed, 28 insertions(+), 59 deletions(-) diff --git a/Makefile b/Makefile index 7c70db0..4d7b10f 100644 --- a/Makefile +++ b/Makefile @@ -116,39 +116,7 @@ daemon: ebtablesd ebtablesu # a little scripting for a static binary, making one for ebtables-restore # should be completely analogous static: extensions/ebt_*.c extensions/ebtable_*.c ebtables.c communication.c ebtables-standalone.c getethertype.c libebtc.c useful_functions.c - cp ebtables-standalone.c ebtables-standalone.c_ ; \ - cp include/ebtables_u.h include/ebtables_u.h_ ; \ - sed "s/ main(/ pseudomain(/" ebtables-standalone.c > ebtables-standalone.c__ ; \ - mv ebtables-standalone.c__ ebtables-standalone.c ; \ - printf "\nint main(int argc, char *argv[])\n{\n " >> ebtables-standalone.c ; \ - for arg in $(EXT_FUNC) \ - ; do \ - sed s/_init/_$${arg}_init/ extensions/ebt_$${arg}.c > extensions/ebt_$${arg}.c_ ; \ - mv extensions/ebt_$${arg}.c_ extensions/ebt_$${arg}.c ; \ - printf "\t%s();\n" _$${arg}_init >> ebtables-standalone.c ; \ - printf "extern void %s();\n" _$${arg}_init >> include/ebtables_u.h ; \ - done ; \ - for arg in $(EXT_TABLES) \ - ; do \ - sed s/_init/_t_$${arg}_init/ extensions/ebtable_$${arg}.c > extensions/ebtable_$${arg}.c_ ; \ - mv extensions/ebtable_$${arg}.c_ extensions/ebtable_$${arg}.c ; \ - printf "\t%s();\n" _t_$${arg}_init >> ebtables-standalone.c ; \ - printf "extern void %s();\n" _t_$${arg}_init >> include/ebtables_u.h ; \ - done ; \ - printf "\n\tpseudomain(argc, argv);\n\treturn 0;\n}\n" >> ebtables-standalone.c ;\ - $(CC) $(CFLAGS) $(LDFLAGS) $(PROGSPECS) -o $@ $^ -I$(KERNEL_INCLUDES) -Iinclude ; \ - for arg in $(EXT_FUNC) \ - ; do \ - sed "s/ .*_init/ _init/" extensions/ebt_$${arg}.c > extensions/ebt_$${arg}.c_ ; \ - mv extensions/ebt_$${arg}.c_ extensions/ebt_$${arg}.c ; \ - done ; \ - for arg in $(EXT_TABLES) \ - ; do \ - sed "s/ .*_init/ _init/" extensions/ebtable_$${arg}.c > extensions/ebtable_$${arg}.c_ ; \ - mv extensions/ebtable_$${arg}.c_ extensions/ebtable_$${arg}.c ; \ - done ; \ - mv ebtables-standalone.c_ ebtables-standalone.c ; \ - mv include/ebtables_u.h_ include/ebtables_u.h + $(CC) $(CFLAGS) $(LDFLAGS) $(PROGSPECS) -o $@ $^ -I$(KERNEL_INCLUDES) -Iinclude tmp1:=$(shell printf $(BINDIR) | sed 's/\//\\\//g') tmp2:=$(shell printf $(SYSCONFIGDIR) | sed 's/\//\\\//g') diff --git a/extensions/Makefile b/extensions/Makefile index 60a70a2..daa11fc 100644 --- a/extensions/Makefile +++ b/extensions/Makefile @@ -11,13 +11,13 @@ EXT_LIBSI+=$(foreach T,$(EXT_FUNC), -lebt_$(T)) EXT_LIBSI+=$(foreach T,$(EXT_TABLES), -lebtable_$(T)) extensions/ebt_%.so: extensions/ebt_%.o - $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles + $(CC) $(LDFLAGS) -shared -o $@ -lc $< extensions/libebt_%.so: extensions/ebt_%.so mv $< $@ extensions/ebtable_%.so: extensions/ebtable_%.o - $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles + $(CC) $(LDFLAGS) -shared -o $@ -lc $< extensions/libebtable_%.so: extensions/ebtable_%.so mv $< $@ diff --git a/extensions/ebt_802_3.c b/extensions/ebt_802_3.c index 4584849..d70fd44 100644 --- a/extensions/ebt_802_3.c +++ b/extensions/ebt_802_3.c @@ -141,7 +141,7 @@ static struct ebt_u_match _802_3_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&_802_3_match); } diff --git a/extensions/ebt_among.c b/extensions/ebt_among.c index e4fc5ac..b1560e8 100644 --- a/extensions/ebt_among.c +++ b/extensions/ebt_among.c @@ -491,7 +491,7 @@ static struct ebt_u_match among_match = { .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&among_match); } diff --git a/extensions/ebt_arp.c b/extensions/ebt_arp.c index b281955..84b6e90 100644 --- a/extensions/ebt_arp.c +++ b/extensions/ebt_arp.c @@ -362,7 +362,7 @@ static struct ebt_u_match arp_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&arp_match); } diff --git a/extensions/ebt_arpreply.c b/extensions/ebt_arpreply.c index 51eda66..399868b 100644 --- a/extensions/ebt_arpreply.c +++ b/extensions/ebt_arpreply.c @@ -133,7 +133,7 @@ static struct ebt_u_target arpreply_target = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&arpreply_target); } diff --git a/extensions/ebt_inat.c b/extensions/ebt_inat.c index 681975d..48f65b4 100644 --- a/extensions/ebt_inat.c +++ b/extensions/ebt_inat.c @@ -379,8 +379,7 @@ static struct ebt_u_target idnat_target = .extra_ops = opts_d, }; -static void _init(void) __attribute__ ((constructor)); -static void _init(void) +static void _INIT(void) { register_target(&isnat_target); register_target(&idnat_target); diff --git a/extensions/ebt_ip.c b/extensions/ebt_ip.c index 1ffdb95..faffade 100644 --- a/extensions/ebt_ip.c +++ b/extensions/ebt_ip.c @@ -472,7 +472,7 @@ static struct ebt_u_match ip_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&ip_match); } diff --git a/extensions/ebt_ip6.c b/extensions/ebt_ip6.c index 347797b..17a4303 100644 --- a/extensions/ebt_ip6.c +++ b/extensions/ebt_ip6.c @@ -413,7 +413,7 @@ static struct ebt_u_match ip6_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&ip6_match); } diff --git a/extensions/ebt_limit.c b/extensions/ebt_limit.c index 2cbf4de..1fe9d84 100644 --- a/extensions/ebt_limit.c +++ b/extensions/ebt_limit.c @@ -212,7 +212,7 @@ static struct ebt_u_match limit_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&limit_match); } diff --git a/extensions/ebt_log.c b/extensions/ebt_log.c index 97d5091..b5d3232 100644 --- a/extensions/ebt_log.c +++ b/extensions/ebt_log.c @@ -217,7 +217,7 @@ static struct ebt_u_watcher log_watcher = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_watcher(&log_watcher); } diff --git a/extensions/ebt_mark.c b/extensions/ebt_mark.c index 4cf1378..b4f93b5 100644 --- a/extensions/ebt_mark.c +++ b/extensions/ebt_mark.c @@ -172,7 +172,7 @@ static struct ebt_u_target mark_target = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&mark_target); } diff --git a/extensions/ebt_mark_m.c b/extensions/ebt_mark_m.c index 7561f05..b6d11a2 100644 --- a/extensions/ebt_mark_m.c +++ b/extensions/ebt_mark_m.c @@ -121,7 +121,7 @@ static struct ebt_u_match mark_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&mark_match); } diff --git a/extensions/ebt_nat.c b/extensions/ebt_nat.c index 00d9cd4..fe7e987 100644 --- a/extensions/ebt_nat.c +++ b/extensions/ebt_nat.c @@ -231,7 +231,7 @@ static struct ebt_u_target dnat_target = .extra_ops = opts_d, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&snat_target); ebt_register_target(&dnat_target); diff --git a/extensions/ebt_nflog.c b/extensions/ebt_nflog.c index 405673a..04c547d 100644 --- a/extensions/ebt_nflog.c +++ b/extensions/ebt_nflog.c @@ -166,7 +166,7 @@ static struct ebt_u_watcher nflog_watcher = { .extra_ops = nflog_opts, }; -void _init(void) +static void _INIT(void) { ebt_register_watcher(&nflog_watcher); } diff --git a/extensions/ebt_pkttype.c b/extensions/ebt_pkttype.c index 486c85c..bf578fc 100644 --- a/extensions/ebt_pkttype.c +++ b/extensions/ebt_pkttype.c @@ -125,7 +125,7 @@ static struct ebt_u_match pkttype_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&pkttype_match); } diff --git a/extensions/ebt_redirect.c b/extensions/ebt_redirect.c index 3f8227a..59fe818 100644 --- a/extensions/ebt_redirect.c +++ b/extensions/ebt_redirect.c @@ -108,7 +108,7 @@ static struct ebt_u_target redirect_target = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&redirect_target); } diff --git a/extensions/ebt_standard.c b/extensions/ebt_standard.c index 81edead..f3c3308 100644 --- a/extensions/ebt_standard.c +++ b/extensions/ebt_standard.c @@ -84,7 +84,7 @@ static struct ebt_u_target standard = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&standard); } diff --git a/extensions/ebt_stp.c b/extensions/ebt_stp.c index 5c5fc33..311bc63 100644 --- a/extensions/ebt_stp.c +++ b/extensions/ebt_stp.c @@ -337,7 +337,7 @@ static struct ebt_u_match stp_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&stp_match); } diff --git a/extensions/ebt_string.c b/extensions/ebt_string.c index 3deff1b..6af06b8 100644 --- a/extensions/ebt_string.c +++ b/extensions/ebt_string.c @@ -310,7 +310,7 @@ static struct ebt_u_match string_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&string_match); } diff --git a/extensions/ebt_ulog.c b/extensions/ebt_ulog.c index 54eec53..72a6c8b 100644 --- a/extensions/ebt_ulog.c +++ b/extensions/ebt_ulog.c @@ -180,7 +180,7 @@ static struct ebt_u_watcher ulog_watcher = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_watcher(&ulog_watcher); } diff --git a/extensions/ebt_vlan.c b/extensions/ebt_vlan.c index 0a37067..0818d48 100644 --- a/extensions/ebt_vlan.c +++ b/extensions/ebt_vlan.c @@ -181,7 +181,7 @@ static struct ebt_u_match vlan_match = { .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&vlan_match); } diff --git a/extensions/ebtable_broute.c b/extensions/ebtable_broute.c index 5259355..c106f08 100644 --- a/extensions/ebtable_broute.c +++ b/extensions/ebtable_broute.c @@ -23,7 +23,7 @@ ebt_u_table table = .help = print_help, }; -void _init(void) +static void _INIT(void) { ebt_register_table(&table); } diff --git a/extensions/ebtable_filter.c b/extensions/ebtable_filter.c index e41fb84..c0bf105 100644 --- a/extensions/ebtable_filter.c +++ b/extensions/ebtable_filter.c @@ -29,7 +29,7 @@ static struct ebt_u_table table = .help = print_help, }; -void _init(void) +static void _INIT(void) { ebt_register_table(&table); } diff --git a/extensions/ebtable_nat.c b/extensions/ebtable_nat.c index b21c9dd..ee04482 100644 --- a/extensions/ebtable_nat.c +++ b/extensions/ebtable_nat.c @@ -30,7 +30,7 @@ ebt_u_table table = .help = print_help, }; -void _init(void) +static void _INIT(void) { ebt_register_table(&table); } diff --git a/include/ebtables_u.h b/include/ebtables_u.h index 3235bf5..7f5968d 100644 --- a/include/ebtables_u.h +++ b/include/ebtables_u.h @@ -44,6 +44,8 @@ #define EBT_ALIGN(s) (((s) + (EBT_MIN_ALIGN-1)) & ~(EBT_MIN_ALIGN-1)) #define ERRORMSG_MAXLEN 128 +#define _INIT __attribute__((constructor)) _init + struct ebt_u_entries { int policy; From patchwork Wed Jun 27 09:50:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Engelhardt X-Patchwork-Id: 935366 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inai.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41Fypm0DMLz9s0w for ; Wed, 27 Jun 2018 19:51:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964782AbeF0Ju5 (ORCPT ); Wed, 27 Jun 2018 05:50:57 -0400 Received: from a3.inai.de ([88.198.85.195]:49546 "EHLO a3.inai.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964774AbeF0Juz (ORCPT ); Wed, 27 Jun 2018 05:50:55 -0400 Received: by a3.inai.de (Postfix, from userid 65534) id 136D7ED494D; Wed, 27 Jun 2018 11:50:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on a3.inai.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.1 Received: from a4.inai.de (a4.inai.de [IPv6:2a01:4f8:222:6c9::f8]) by a3.inai.de (Postfix) with ESMTP id 42FFAED66B8; Wed, 27 Jun 2018 11:50:51 +0200 (CEST) From: Jan Engelhardt To: netfilter-devel@vger.kernel.org Cc: fw@strlen.de Subject: [PATCH 5/6] Add .gitignore Date: Wed, 27 Jun 2018 11:50:42 +0200 Message-Id: <20180627095043.8315-6-jengelh@inai.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180627095043.8315-1-jengelh@inai.de> References: <20180627095043.8315-1-jengelh@inai.de> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d2fc36e --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.o +*.so +/ebtables +/ebtables-restore +/ebtablesd +/ebtablesu +/static From patchwork Wed Jun 27 09:50:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Engelhardt X-Patchwork-Id: 935368 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inai.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41Fypr5fsXz9s2R for ; Wed, 27 Jun 2018 19:51:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964807AbeF0JvN (ORCPT ); Wed, 27 Jun 2018 05:51:13 -0400 Received: from a3.inai.de ([88.198.85.195]:49548 "EHLO a3.inai.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964776AbeF0Ju4 (ORCPT ); Wed, 27 Jun 2018 05:50:56 -0400 Received: by a3.inai.de (Postfix, from userid 65534) id 87FE9ED66B8; Wed, 27 Jun 2018 11:50:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on a3.inai.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.1 Received: from a4.inai.de (a4.inai.de [IPv6:2a01:4f8:222:6c9::f8]) by a3.inai.de (Postfix) with ESMTP id 510A4ED4930; Wed, 27 Jun 2018 11:50:51 +0200 (CEST) From: Jan Engelhardt To: netfilter-devel@vger.kernel.org Cc: fw@strlen.de Subject: [PATCH 6/6] build: move to automake Date: Wed, 27 Jun 2018 11:50:43 +0200 Message-Id: <20180627095043.8315-7-jengelh@inai.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180627095043.8315-1-jengelh@inai.de> References: <20180627095043.8315-1-jengelh@inai.de> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org --- .gitignore | 23 +++++- INSTALL | 71 ++++++----------- Makefile | 214 -------------------------------------------------- Makefile.am | 76 ++++++++++++++++++ autogen.sh | 4 + configure.ac | 23 ++++++ m4/.gitignore | 2 + 7 files changed, 149 insertions(+), 264 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 m4/.gitignore diff --git a/.gitignore b/.gitignore index d2fc36e..1fff83c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,28 @@ -*.o +*.a +*.la +*.lo *.so +*.o +.deps/ +.dirstamp +.libs/ +Makefile +Makefile.in + +/aclocal.m4 +/autom4te.cache/ +/build-aux/ +/config.* +/configure +/libtool +/stamp-h1 + /ebtables +/ebtables-config /ebtables-restore +/ebtables-save +/ebtables.8 +/ebtables.sysv /ebtablesd /ebtablesu /static diff --git a/INSTALL b/INSTALL index e90d5c1..c43d95c 100644 --- a/INSTALL +++ b/INSTALL @@ -1,63 +1,36 @@ -FOLLOW THESE SIMPLE GUIDELINES: -------------------------------- +Installation instructions for iptables +====================================== -Compiling the source code: -%make -Put the files in the right directories: -%make install +ebtables uses the well-known configure(autotools) infrastructure. -If you are using the CVS code or need your own kernel includes, do this -instead (change the include directory to the appropriate one): -%make install KERNEL_INCLUDES=/usr/src/linux/include + $ ./configure + $ make + # make install -If you want to make a static binary for ebtables, containing all the -extensions, without shared libraries, do this (this will make a -binary called 'static', which you can rename): -%make static -WHAT GETS INSTALLED AND WHAT OPTIONS ARE AVAILABLE? ---------------------------------------------------- +Prerequisites +============= -- The ebtables manual gets installed in /usr/local/man/man8 - To put the manual somewhere else, include MANDIR=<> as - option on the command line. - The Makefile will append /man8/ebtables.8. -- ethertypes is by default placed in /etc/, if you - want to change this, include ETHERTYPESPATH=<>. -- The userspace programs ebtables ebtables-save and ebtables-restore are - are copied by default to /usr/local/sbin/ebtables. If you want to put - the executables somewhere else, include BINPATH=<>. -- The ebtables initialisation file (enabling use of 'service ebtables') is - copied to /etc/rc.d/init.d (change with option INITDIR) -- The ebtables configuration file (ebtables-config) is copied to /etc/sysconfig -- ebtables can use a lock file to enable concurrent execution of the ebtables - tool. The standard location of the lock file is /var/lib/ebtables/lock. - Include LOCKFILE=<> if you want to use another file. + * no kernel-source required -That's all + * but obviously a compiler, glibc-devel and linux-kernel-headers + (/usr/include/linux) -You can also use a base directory different from the root directory (/), -using the DESTDIR option. See the Makefile for more details. -You might need to set LDFLAGS=-Wl,-no-as-needed to build ebtables correctly -on your system. +Configuring and compiling +========================= -ADDITIONAL PROGRAMS: ----------------------- --- examples/ulog/test_ulog.c -- +./configure [options] -Contains an example to receive and parse netlink messages containing -packets seen by the ebtables ulog watcher. +--prefix= -Compile with: -%make test_ulog KERNEL_INCLUDES=/usr/src/linux/include + The prefix to put all installed files under. It defaults to + /usr/local, so the binaries will go into /usr/local/bin, sbin, + manpages into /usr/local/share/man, etc. -Usage: -%examples/ulog/test_ulog NETLINK_GROUP -%ebtables -A chain --ulog-nlgroup NETLINK_GROUP +If you want to enable debugging, use --- examples/perf_test/perf_test -- + ./configure CFLAGS="-ggdb3 -O0" CPPFLAGS="-DEBT_DEBUG" -A test script to compare the performance for the different ways to -construct an ebtables table. This is deprecated and should probably -be ignored. +(-O0 is used to turn off instruction reordering, which makes debugging +much easier.) diff --git a/Makefile b/Makefile deleted file mode 100644 index 4d7b10f..0000000 --- a/Makefile +++ /dev/null @@ -1,214 +0,0 @@ -# ebtables Makefile - -PROGNAME:=ebtables -PROGRELEASE:=4 -PROGVERSION_:=2.0.10 -PROGVERSION:=$(PROGVERSION_)-$(PROGRELEASE) -PROGDATE:=December\ 2011 -LOCKFILE?=/var/lib/ebtables/lock -LOCKDIR:=$(shell echo $(LOCKFILE) | sed 's/\(.*\)\/.*/\1/')/ - -# default paths -LIBDIR:=/usr/lib -MANDIR:=/usr/local/man -BINDIR:=/usr/local/sbin -ETCDIR:=/etc -INITDIR:=/etc/rc.d/init.d -SYSCONFIGDIR:=/etc/sysconfig -DESTDIR:= - -CFLAGS:=-Wall -Wunused -Werror -CFLAGS_SH_LIB:=-fPIC -O3 -CC:=gcc - -ifeq ($(shell uname -m),sparc64) -CFLAGS+=-DEBT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32 -endif - -include extensions/Makefile - -OBJECTS2:=getethertype.o communication.o libebtc.o \ -useful_functions.o ebtables.o - -OBJECTS:=$(OBJECTS2) $(EXT_OBJS) $(EXT_LIBS) - -KERNEL_INCLUDES?=include/ - -ETHERTYPESPATH?=$(ETCDIR) -ETHERTYPESFILE:=$(ETHERTYPESPATH)/ethertypes - -PIPE_DIR?=/tmp/$(PROGNAME)-v$(PROGVERSION) -PIPE=$(PIPE_DIR)/ebtablesd_pipe -EBTD_CMDLINE_MAXLN?=2048 -EBTD_ARGC_MAX?=50 - -PROGSPECS:=-DPROGVERSION=\"$(PROGVERSION)\" \ - -DPROGNAME=\"$(PROGNAME)\" \ - -DPROGDATE=\"$(PROGDATE)\" \ - -D_PATH_ETHERTYPES=\"$(ETHERTYPESFILE)\" \ - -DEBTD_ARGC_MAX=$(EBTD_ARGC_MAX) \ - -DEBTD_CMDLINE_MAXLN=$(EBTD_CMDLINE_MAXLN) \ - -DLOCKFILE=\"$(LOCKFILE)\" \ - -DLOCKDIR=\"$(LOCKDIR)\" - -# You can probably ignore this, ebtables{u,d} are normally not used -PROGSPECSD:=-DPROGVERSION=\"$(PROGVERSION)\" \ - -DPROGNAME=\"$(PROGNAME)\" \ - -DPROGDATE=\"$(PROGDATE)\" \ - -D_PATH_ETHERTYPES=\"$(ETHERTYPESFILE)\" \ - -DEBTD_CMDLINE_MAXLN=$(EBTD_CMDLINE_MAXLN) \ - -DEBTD_ARGC_MAX=$(EBTD_ARGC_MAX) \ - -DEBTD_PIPE=\"$(PIPE)\" \ - -DEBTD_PIPE_DIR=\"$(PIPE_DIR)\" - -# Uncomment for debugging (slower) -#PROGSPECS+=-DEBT_DEBUG -#PROGSPECSD+=-DEBT_DEBUG -#CFLAGS+=-ggdb - -all: ebtables ebtables-restore - -communication.o: communication.c include/ebtables_u.h - $(CC) $(CFLAGS) $(CFLAGS_SH_LIB) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES) - -libebtc.o: libebtc.c include/ebtables_u.h - $(CC) $(CFLAGS) $(CFLAGS_SH_LIB) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES) - -useful_functions.o: useful_functions.c include/ebtables_u.h - $(CC) $(CFLAGS) $(CFLAGS_SH_LIB) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES) - -getethertype.o: getethertype.c include/ethernetdb.h - $(CC) $(CFLAGS) $(CFLAGS_SH_LIB) $(PROGSPECS) -c -o $@ $< -Iinclude/ - -ebtables.o: ebtables.c include/ebtables_u.h - $(CC) $(CFLAGS) $(CFLAGS_SH_LIB) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES) - -ebtables-standalone.o: ebtables-standalone.c include/ebtables_u.h - $(CC) $(CFLAGS) $(CFLAGS_SH_LIB) $(PROGSPECS) -c $< -o $@ -I$(KERNEL_INCLUDES) - -libebtc.so: $(OBJECTS2) - $(CC) -shared $(LDFLAGS) -Wl,-soname,libebtc.so -o libebtc.so -lc $(OBJECTS2) - -ebtables: $(OBJECTS) ebtables-standalone.o libebtc.so - $(CC) $(CFLAGS) $(CFLAGS_SH_LIB) $(LDFLAGS) -o $@ ebtables-standalone.o -I$(KERNEL_INCLUDES) -L. -Lextensions -lebtc $(EXT_LIBSI) \ - -Wl,-rpath,$(LIBDIR) - -ebtablesu: ebtablesu.c - $(CC) $(CFLAGS) $(PROGSPECSD) $< -o $@ - -ebtablesd.o: ebtablesd.c include/ebtables_u.h - $(CC) $(CFLAGS) $(PROGSPECSD) -c $< -o $@ -I$(KERNEL_INCLUDES) - -ebtablesd: $(OBJECTS) ebtablesd.o libebtc.so - $(CC) $(CFLAGS) -o $@ ebtablesd.o -I$(KERNEL_INCLUDES) -L. -Lextensions -lebtc $(EXT_LIBSI) \ - -Wl,-rpath,$(LIBDIR) - -ebtables-restore.o: ebtables-restore.c include/ebtables_u.h - $(CC) $(CFLAGS) $(PROGSPECS) -c $< -o $@ -I$(KERNEL_INCLUDES) - -ebtables-restore: $(OBJECTS) ebtables-restore.o libebtc.so - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ ebtables-restore.o -I$(KERNEL_INCLUDES) -L. -Lextensions -lebtc $(EXT_LIBSI) \ - -Wl,-rpath,$(LIBDIR) - -.PHONY: daemon -daemon: ebtablesd ebtablesu - -# a little scripting for a static binary, making one for ebtables-restore -# should be completely analogous -static: extensions/ebt_*.c extensions/ebtable_*.c ebtables.c communication.c ebtables-standalone.c getethertype.c libebtc.c useful_functions.c - $(CC) $(CFLAGS) $(LDFLAGS) $(PROGSPECS) -o $@ $^ -I$(KERNEL_INCLUDES) -Iinclude - -tmp1:=$(shell printf $(BINDIR) | sed 's/\//\\\//g') -tmp2:=$(shell printf $(SYSCONFIGDIR) | sed 's/\//\\\//g') -tmp3:=$(shell printf $(PIPE) | sed 's/\//\\\//g') -.PHONY: scripts -scripts: ebtables-save.in ebtables.sysv.in ebtables-config.in - sed -e 's/[@]sbindir@/$(tmp1)/g' ebtables-save_ - mkdir -p $(DESTDIR)$(BINDIR) - install -m 0755 ebtables-save_ $(DESTDIR)$(BINDIR)/ebtables-save - sed -e 's/[@]sbindir@/$(tmp1)/g' -e 's/[@]sysconfigdir@/$(tmp2)/g' ebtables.sysv_ - if [ "$(DESTDIR)" != "" ]; then mkdir -p $(DESTDIR)$(INITDIR); fi - if test -d $(DESTDIR)$(INITDIR); then install -m 0755 ebtables.sysv_ $(DESTDIR)$(INITDIR)/ebtables; fi - sed -e 's/[@]sysconfigdir@/$(tmp2)/g' ebtables-config_ - if [ "$(DESTDIR)" != "" ]; then mkdir -p $(DESTDIR)$(SYSCONFIGDIR); fi - if test -d $(DESTDIR)$(SYSCONFIGDIR); then install -m 0600 ebtables-config_ $(DESTDIR)$(SYSCONFIGDIR)/ebtables-config; fi - rm -f ebtables-save_ ebtables.sysv_ ebtables-config_ - -tmp4:=$(shell printf $(LOCKFILE) | sed 's/\//\\\//g') -$(MANDIR)/man8/ebtables.8: ebtables.8.in - mkdir -p $(DESTDIR)$(@D) - sed -e 's/[@]PACKAGE_VERSION@/$(PROGVERSION)/' -e 's/[@]PACKAGE_DATE@/$(PROGDATE)/' -e 's/[@]LOCKFILE@/$(tmp4)/' <$< >ebtables.8_ - install -m 0644 ebtables.8_ $(DESTDIR)$@ - rm -f ebtables.8_ - -$(DESTDIR)$(ETHERTYPESFILE): ethertypes - mkdir -p $(@D) - install -m 0644 $< $@ - -.PHONY: exec -exec: ebtables ebtables-restore - mkdir -p $(DESTDIR)$(BINDIR) - install -m 0755 $(PROGNAME) $(DESTDIR)$(BINDIR)/$(PROGNAME) - install -m 0755 ebtables-restore $(DESTDIR)$(BINDIR)/ebtables-restore - -.PHONY: install -install: $(MANDIR)/man8/ebtables.8 $(DESTDIR)$(ETHERTYPESFILE) exec scripts - mkdir -p $(DESTDIR)$(LIBDIR) - install -m 0755 extensions/*.so $(DESTDIR)$(LIBDIR) - install -m 0755 *.so $(DESTDIR)$(LIBDIR) - -.PHONY: clean -clean: - rm -f ebtables ebtables-restore ebtablesd ebtablesu static - rm -f *.o *~ *.so - rm -f extensions/*.o extensions/*.c~ extensions/*.so include/*~ - -DIR:=$(PROGNAME)-v$(PROGVERSION) -CVSDIRS:=CVS extensions/CVS examples/CVS examples/perf_test/CVS \ -examples/ulog/CVS include/CVS -# This is used to make a new userspace release, some files are altered so -# do this on a temporary version -.PHONY: release -release: - rm -f extensions/ebt_inat.c - rm -rf $(CVSDIRS) - mkdir -p include/linux/netfilter_bridge - install -m 0644 \ - $(KERNEL_INCLUDES)/linux/netfilter_bridge.h include/linux/ -# To keep possible compile error complaints about undefined ETH_P_8021Q -# off my back - install -m 0644 \ - $(KERNEL_INCLUDES)/linux/if_ether.h include/linux/ - install -m 0644 \ - $(KERNEL_INCLUDES)/linux/types.h include/linux/ - install -m 0644 \ - $(KERNEL_INCLUDES)/linux/netfilter_bridge/*.h \ - include/linux/netfilter_bridge/ - install -m 0644 \ - include/ebtables.h include/linux/netfilter_bridge/ - make clean - touch * - touch extensions/* - touch include/* - touch include/linux/* - touch include/linux/netfilter_bridge/* - sed -i -e 's/$$(VERSION)/$(PROGVERSION)/' -e 's/$$(DATE)/$(PROGDATE)/' -e 's/$$(LOCKFILE)/$(tmp4)/' ebtables.8 - sed -i -e 's/$$(VERSION)/$(PROGVERSION_)/' -e 's/$$(RELEASE)/$(PROGRELEASE)/' ebtables.spec - cd ..;tar -c $(DIR) | gzip >$(DIR).tar.gz; cd - - rm -rf include/linux - -# This will make the rpm and put it in /usr/src/redhat/RPMS -# (do this as root after make release) -.PHONY: rpmbuild -rpmbuild: - cp ../$(DIR).tar.gz /usr/src/redhat/SOURCES/ - rpmbuild --buildroot $(shell mktemp -td $(DIR)-XXXXX) -bb ebtables.spec - -.PHONY: test_ulog -test_ulog: examples/ulog/test_ulog.c getethertype.o - $(CC) $(CFLAGS) $< -o test_ulog -I$(KERNEL_INCLUDES) -lc \ - getethertype.o - mv test_ulog examples/ulog/ - -.PHONY: examples -examples: test_ulog diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..14938fe --- /dev/null +++ b/Makefile.am @@ -0,0 +1,76 @@ +# -*- Makefile -*- + +# For debugging, use ./configure CPPFLAGS=-DEBT_DEBUG CFLAGS="-O0 -ggdb3" + +PROGNAME = ${PACKAGE_NAME} +PROGVERSION = ${PACKAGE_VERSION} +PROGDATE = December\ 2011 +LOCKDIR = /var/lib/ebtables +LOCKFILE = ${LOCKDIR}/lock +INITDIR = /etc/rc.d/init.d +initddir = ${INITDIR} +sysconfigdir = ${sysconfdir}/sysconfig +EBTD_CMDLINE_MAXLN = 2048 +EBTD_ARGC_MAX = 50 +PIPE_DIR = /tmp/${PACKAGE_NAME}-v${PROGVERSION} +PIPE = ${PIPE_DIR}/ebtablesd_pipe + + +ACLOCAL_AMFLAGS = -I m4 +AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_srcdir}/include \ + -DPROGVERSION=\"${PACKAGE_VERSION}\" -DPROGNAME=\"${PACKAGE_NAME}\" \ + -DPROGDATE=\"${PROGDATE}\" \ + -D_PATH_ETHERTYPES=\"${sysconfdir}/ethertypes\" \ + -DLOCKFILE=\"${LOCKFILE}\" -DLOCKDIR=\"${LOCKDIR}\" \ + -DEBTD_ARGC_MAX=${EBTD_ARGC_MAX} -DEBTD_CMDLINE_MAXLN=${EBTD_CMDLINE_MAXLN} \ + -DEBTD_PIPE=\"${PIPE}\" -DEBTD_PIPE_DIR=\"${PIPE_DIR}\" +AM_CFLAGS = ${regular_CFLAGS} + +sbin_PROGRAMS = ebtables ebtablesd ebtablesu ebtables-restore +EXTRA_PROGRAMS = static examples/ulog/test_ulog +sysconf_DATA = ethertypes +sbin_SCRIPTS = ebtables-save +man8_MANS = ebtables.8 +lib_LTLIBRARIES = libebtc.la + +libebtc_la_SOURCES = \ + communication.c ebtables.c getethertype.c \ + libebtc.c useful_functions.c \ + extensions/ebt_802_3.c extensions/ebt_among.c extensions/ebt_arp.c \ + extensions/ebt_arpreply.c extensions/ebt_ip.c extensions/ebt_ip6.c \ + extensions/ebt_limit.c extensions/ebt_log.c extensions/ebt_mark.c \ + extensions/ebt_mark_m.c extensions/ebt_nat.c extensions/ebt_nflog.c \ + extensions/ebt_pkttype.c extensions/ebt_redirect.c \ + extensions/ebt_standard.c extensions/ebt_stp.c extensions/ebt_string.c \ + extensions/ebt_ulog.c extensions/ebt_vlan.c \ + extensions/ebtable_broute.c extensions/ebtable_filter.c \ + extensions/ebtable_nat.c +# Make sure ebtables.c can be built twice +libebtc_la_CPPFLAGS = ${AM_CPPFLAGS} +ebtables_SOURCES = ebtables-standalone.c +ebtables_LDADD = libebtc.la +ebtablesd_LDADD = libebtc.la +ebtables_restore_LDADD = libebtc.la +static_SOURCES = ebtables.c +static_LDFLAGS = -static +static_LDADD = libebtc.la +examples_ulog_test_ulog_SOURCES = examples/ulog/test_ulog.c getethertype.c + +daemon: ebtablesd ebtablesu +exec: ebtables ebtables-restore + +CLEANFILES = ebtables-save ebtables.sysv ebtables-config ebtables.8 + +ebtables-save: ebtables-save.in ${top_builddir}/config.status + ${AM_V_GEN}sed -e 's![@]sbindir@!${sbindir}!g' <$< >$@ + +ebtables.sysv: ebtables.sysv.in ${top_builddir}/config.status + ${AM_V_GEN}sed -e 's![@]sbindir@!${sbindir}!g' -e 's![@]sysconfigdir@!${sysconfigdir}!g' <$< >$@ + +ebtables-config: ebtables-config.in ${top_builddir}/config.status + ${AM_V_GEN}sed -e 's![@]sysconfigdir@!${sysconfigdir}!g' <$< >$@ + +ebtables.8: ebtables.8.in ${top_builddir}/config.status + ${AM_V_GEN}sed -e 's![@]PACKAGE_VERSION!${PACKAGE_VERSION}!g' \ + -e 's![@]PACKAGE_DATE@!${PROGDATE}!g' \ + -e 's![@]LOCKFILE@!${LOCKFILE}!g' <$< >$@ diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..a0c4395 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,4 @@ +#!/bin/sh -e + +autoreconf -fi; +rm -Rf autom4te*.cache; diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..a3bc3c9 --- /dev/null +++ b/configure.ac @@ -0,0 +1,23 @@ +AC_INIT([ebtables], [2.0.10.4]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([m4]) +AC_PROG_INSTALL +AM_INIT_AUTOMAKE([-Wall foreign subdir-objects tar-pax]) +AC_PROG_CC +AM_PROG_CC_C_O +AC_DISABLE_STATIC +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) +AM_PROG_LIBTOOL + +regular_CFLAGS="-Wall -Wunused" +regular_CPPFLAGS="" +case "$host" in + sparc64-*) + regular_CPPFLAGS="$regular_CPPFLAGS -DEBT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32";; +esac + +AC_SUBST([regular_CFLAGS]) +AC_SUBST([regular_CPPFLAGS]) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/m4/.gitignore b/m4/.gitignore new file mode 100644 index 0000000..64d9bbc --- /dev/null +++ b/m4/.gitignore @@ -0,0 +1,2 @@ +/libtool.m4 +/lt*.m4