Skip to content

Commit 4568fc9

Browse files
Updated dontfragment build to not require iptables sources
1 parent e3a03c5 commit 4568fc9

3 files changed

Lines changed: 18 additions & 29 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
*.mod.*
44
modules.order
55
Module.symvers
6+
extensions/**/*.so
7+
extensions/**/*.ko
8+
out

extensions/dontfragment/Makefile

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
11
obj-m += ipt_DF.o
2-
#IPT_CFLAGS = -fPIC -Wall -Wextra -pedantic
3-
IPT_CFLAGS = -fPIC
4-
IPTABLES_VERSION = 1.6.2
2+
IPT_CFLAGS = -Wall -Wextra -pedantic -O2
53

64
all: kernel-module iptables-module
75

8-
iptables: iptables-$(IPTABLES_VERSION) ipt_DF.h
9-
cp ipt_DF.h iptables-$(IPTABLES_VERSION)/include/linux/netfilter_ipv4/ipt_DF.h
10-
11-
iptables-$(IPTABLES_VERSION): iptables-$(IPTABLES_VERSION).tar.bz2
12-
tar -xf iptables-$(IPTABLES_VERSION).tar.bz2
13-
14-
iptables-$(IPTABLES_VERSION).tar.bz2:
15-
wget http://www.netfilter.org/projects/iptables/files/iptables-$(IPTABLES_VERSION).tar.bz2
16-
md5sum -c iptables-$(IPTABLES_VERSION).tar.bz2.md5 || (rm -f iptables-$(IPTABLES_VERSION).tar.bz2 && exit 1)
17-
186
kernel-module:
19-
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
7+
make -C /lib/modules/$(shell uname -r)/build M=$(CURDIR) modules
208

21-
iptables-module: iptables libipt_DF.c
22-
$(CC) $(CFLAGS) $(IPT_CFLAGS) -I iptables-$(IPTABLES_VERSION)/include libipt_DF.c -c
23-
$(CC) $(CFLAGS) $(IPT_CFLAGS) -shared -o libipt_DF.so libipt_DF.o
9+
iptables-module: libipt_DF.so
2410

25-
clean-all: clean clean-iptables-archive
11+
libipt_DF.so: libipt_DF.o
12+
gcc -shared -fPIC ${IPT_CFLAGS} -o $@ $^;
2613

27-
clean: clean-kernel-module clean-iptables-module clean-iptables
14+
libipt_DF.o: libipt_DF.c
15+
gcc ${IPT_CFLAGS} -D_INIT=lib$*_init -fPIC -c -o $@ $<;
16+
17+
clean: clean-kernel-module clean-iptables-module
2818

2919
clean-kernel-module:
30-
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
20+
make -C /lib/modules/$(shell uname -r)/build M=$(CURDIR) clean
3121

3222
clean-iptables-module:
3323
rm -f libipt_DF.o libipt_DF.so
34-
35-
clean-iptables:
36-
rm -rf iptables-$(IPTABLES_VERSION)
37-
38-
clean-iptables-archive:
39-
rm -f iptables-$(IPTABLES_VERSION).tar.bz2

extensions/dontfragment/libipt_DF.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#include <xtables.h>
33

44
#include <linux/netfilter_ipv4/ip_tables.h>
5-
#include <linux/netfilter_ipv4/ipt_DF.h>
5+
#include "ipt_DF.h"
6+
7+
#define __maybe_unused __attribute__((__unused__))
68

79
enum {
810
O_DF_SET = 0,
@@ -52,7 +54,7 @@ static void DF_check(struct xt_fcheck_call *cb)
5254
"DF: You must specify an action");
5355
}
5456

55-
static void DF_save(const void *ip, const struct xt_entry_target *target)
57+
static void DF_save(__maybe_unused const void *ip, const struct xt_entry_target *target)
5658
{
5759
const struct xt_df_tginfo *info = (struct xt_df_tginfo *) target->data;
5860

@@ -67,7 +69,7 @@ static void DF_save(const void *ip, const struct xt_entry_target *target)
6769
}
6870
}
6971

70-
static void DF_print(const void *ip, const struct xt_entry_target *target, int numeric)
72+
static void DF_print(__maybe_unused const void *ip, const struct xt_entry_target *target, __maybe_unused int numeric)
7173
{
7274
const struct xt_df_tginfo *info = (struct xt_df_tginfo *) target->data;
7375

0 commit comments

Comments
 (0)