Browse Source

jool: Update to 4.0.5

Signed-off-by: Rosen Penev <rosenp@gmail.com>
lilik-openwrt-22.03
Rosen Penev 5 years ago
parent
commit
cae9da4d26
4 changed files with 51 additions and 162 deletions
  1. +27
    -21
      net/jool/Makefile
  2. +0
    -76
      net/jool/patches/010-Add-support-for-kernel-4.17.patch
  3. +24
    -0
      net/jool/patches/010-musl.patch
  4. +0
    -65
      net/jool/patches/020-packet-rename-offset_to_ptr-to-skb_offset_to_ptr-to-.patch

+ 27
- 21
net/jool/Makefile View File

@ -8,40 +8,36 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=jool
PKG_VERSION:=3.5.7
PKG_RELEASE:=2
PKG_VERSION:=4.0.5
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/NICMx/Jool/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=b8e95d1526cd2434dedbae292afd2d17f0780ac2dca2be21264712b41eb76a3d
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/Jool-$(PKG_VERSION)
PKG_SOURCE_URL:=https://github.com/NICMx/Jool/releases/download/v$(PKG_VERSION)
PKG_HASH:=b61ae37d7a71e28530765bdfd9a62f89e7878e3ea9c15dabbcefcd144891100d
PKG_LICENSE:=GPL-2.0
PKG_MAINTAINER:=
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=COPYING
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_BUILD_DEPENDS:=USE_UCLIBC:argp-standalone USE_MUSL:argp-standalone
PKG_FIXUP:=autoreconf
PKG_BUILD_DEPENDS:=!USE_GLIBC:argp-standalone
include $(INCLUDE_DIR)/package.mk
MAKE_PATH:=usr
CONFIGURE_PATH:=usr
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
KERNEL_DIR="$(LINUX_DIR)" \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)/mod/stateful" \
SUBDIRS="$(PKG_BUILD_DIR)/src/mod/nat64" \
V="$(V)" \
modules
$(MAKE) -C "$(LINUX_DIR)" \
KERNEL_DIR="$(LINUX_DIR)" \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)/mod/stateless" \
SUBDIRS="$(PKG_BUILD_DIR)/src/mod/siit" \
V="$(V)" \
modules
$(call Build/Compile/Default)
@ -76,10 +72,11 @@ define KernelPackage/jool
@IPV6 \
+kmod-crypto-md5 \
+kmod-nf-conntrack \
+kmod-nf-conntrack6
+kmod-nf-conntrack6 \
+kmod-nf-ipt
FILES:= \
$(PKG_BUILD_DIR)/mod/stateful/jool.$(LINUX_KMOD_SUFFIX) \
$(PKG_BUILD_DIR)/mod/stateless/jool_siit.$(LINUX_KMOD_SUFFIX)
$(PKG_BUILD_DIR)/src/mod/nat64/jool.$(LINUX_KMOD_SUFFIX) \
$(PKG_BUILD_DIR)/src/mod/siit/jool_siit.$(LINUX_KMOD_SUFFIX)
endef
define KernelPackage/jool/description
@ -91,7 +88,7 @@ endef
define Package/jool-tools
$(call Package/jool/Default)
TITLE:=Jool userspace control programs
DEPENDS:=+libnl +ethtool
DEPENDS:=+libnl +libxtables +ethtool
endef
define Package/jool-tools/description
@ -100,10 +97,19 @@ define Package/jool-tools/description
This package provides the userspace control programs for Jool.
endef
CONFIGURE_ARGS += \
--disable-shared \
--without-bash-completion-dir
CONFIGURE_VARS += \
ac_cv_func_memset=yes \
ac_cv_func_strcasecmp=yes
define Package/jool-tools/install
$(INSTALL_DIR) $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/stateful/jool $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/stateless/jool_siit $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/jool $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/joold $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/jool_siit $(1)/usr/bin/
endef
$(eval $(call BuildPackage,jool))


+ 0
- 76
net/jool/patches/010-Add-support-for-kernel-4.17.patch View File

@ -1,76 +0,0 @@
From 831486ea6c7d7adfbdc453587a65bcba247d698b Mon Sep 17 00:00:00 2001
From: Alberto Leiva Popper <ydahhrk@gmail.com>
Date: Fri, 6 Jul 2018 13:19:21 -0500
Subject: [PATCH 1/2] Add support for kernel 4.17
Fixes #266.
---
mod/common/hash_table.c | 14 +++-----------
mod/stateful/fragment_db.c | 4 +---
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/mod/common/hash_table.c b/mod/common/hash_table.c
index 25ddd7a6..4e9272f8 100644
--- a/mod/common/hash_table.c
+++ b/mod/common/hash_table.c
@@ -23,8 +23,7 @@
* @macro HTABLE_NAME name of the hash table structure to generate. Optional; Default: hash_table.
* @macro KEY_TYPE data type of the table's keys.
* @macro VALUE_TYPE data type of the table's values.
- * @macro HASH_TABLE_SIZE The size of the internal array, in slots. Optional;
- * Default = Max = 64k - 1.
+ * @macro HASH_TABLE_SIZE The size of the internal array, in slots. MUST be a power of 2.
* @macro GENERATE_PRINT just define it if you want the print function; otherwise it will not be
* generated.
* @macro GENERATE_FOR_EACH just define it if you want the for_each function; otherwise it will not
@@ -44,13 +43,6 @@
#define HTABLE_NAME hash_table
#endif
-#ifndef HASH_TABLE_SIZE
-/**
- * This number should not exceed unsigned int's maximum.
- */
-#define HASH_TABLE_SIZE (64 * 1024 - 1)
-#endif
-
/** Creates a token name by concatenating prefix and suffix. */
#define CONCAT_AUX(prefix, suffix) prefix ## suffix
/** Seems useless, but if not present, the compiler won't expand the HTABLE_NAME macro... */
@@ -131,7 +123,7 @@ static struct KEY_VALUE_PAIR *GET_AUX(struct HTABLE_NAME *table, const KEY_TYPE
if (WARN(!table, "The table is NULL."))
return NULL;
- hash_code = table->hash_function(key) % HASH_TABLE_SIZE;
+ hash_code = table->hash_function(key) & (HASH_TABLE_SIZE - 1);
hlist_for_each(current_node, &table->table[hash_code]) {
current_pair = hlist_entry(current_node, struct KEY_VALUE_PAIR, hlist_hook);
if (table->equals_function(key, &current_pair->key))
@@ -210,7 +202,7 @@ static int PUT(struct HTABLE_NAME *table, KEY_TYPE *key, VALUE_TYPE *value)
key_value->value = value;
/* Insert the key-value to the table. */
- hash_code = table->hash_function(key) % HASH_TABLE_SIZE;
+ hash_code = table->hash_function(key) & (HASH_TABLE_SIZE - 1);
hlist_add_head(&key_value->hlist_hook, &table->table[hash_code]);
list_add_tail(&key_value->list_hook, &table->list);
diff --git a/mod/stateful/fragment_db.c b/mod/stateful/fragment_db.c
index 44f966aa..ef0b1f5a 100644
--- a/mod/stateful/fragment_db.c
+++ b/mod/stateful/fragment_db.c
@@ -90,10 +90,8 @@ static bool equals_function(const struct packet *k1, const struct packet *k2)
static unsigned int inet6_hash_frag(__be32 id, const struct in6_addr *saddr,
const struct in6_addr *daddr, u32 rnd)
{
- u32 c;
- c = jhash_3words(ipv6_addr_hash(saddr), ipv6_addr_hash(daddr),
+ return jhash_3words(ipv6_addr_hash(saddr), ipv6_addr_hash(daddr),
(__force u32)id, rnd);
- return c & (INETFRAGS_HASHSZ - 1);
}
#endif
--
2.19.1

+ 24
- 0
net/jool/patches/010-musl.patch View File

@ -0,0 +1,24 @@
--- a/src/usr/argp/main.c
+++ b/src/usr/argp/main.c
@@ -8,6 +8,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <getopt.h>
#include "command.h"
#include "log.h"
--- a/src/usr/iptables/Makefile
+++ b/src/usr/iptables/Makefile
@@ -34,9 +34,9 @@ uninstall:
rm -f ${DESTDIR}${XTABLES_SO_DIR}/libxt_JOOL_SIIT.so
rm -f ${DESTDIR}${XTABLES_SO_DIR}/libxt_JOOL.so
lib%.so: lib%.o
- gcc -shared -fPIC ${LDFLAGS} -o $@ $^;
+ ${CC} -shared -fPIC ${LDFLAGS} -o $@ $^;
lib%.o: lib%.c
- gcc ${DEFAULT_CFLAGS} ${CFLAGS} -D_INIT=lib$*_init -fPIC -c -o $@ $<;
+ ${CC} ${DEFAULT_CFLAGS} ${CFLAGS} -D_INIT=lib$*_init -fPIC -c -o $@ $<;
clean distclean:
rm -f *.so
distdir:

+ 0
- 65
net/jool/patches/020-packet-rename-offset_to_ptr-to-skb_offset_to_ptr-to-.patch View File

@ -1,65 +0,0 @@
From f9e62248f252accb0609243958fb51f0f99a5bf3 Mon Sep 17 00:00:00 2001
From: Ricardo Salveti <ricardo@foundries.io>
Date: Mon, 1 Oct 2018 22:45:17 -0300
Subject: [PATCH 2/2] packet: rename offset_to_ptr to skb_offset_to_ptr to
avoid conflicts with newer kernel
Rename offset_to_ptr to skb_offset_to_ptr to avoid definition conflict
when building jool against linux >= 4.19.
Fixes:
| mod/stateful/../common/packet.c:73:14: error: conflicting types for 'offset_to_ptr'
| static void *offset_to_ptr(struct sk_buff *skb, unsigned int offset)
| ^~~~~~~~~~~~~
| In file included from kernel-source/include/linux/export.h:45,
| from kernel-source/include/linux/linkage.h:7,
| from kernel-source/include/linux/kernel.h:7,
| from kernel-source/include/linux/skbuff.h:17,
| from mod/stateful/../../include/nat64/mod/common/packet.h:81,
| from mod/stateful/../common/packet.c:1:
| kernel-source/include/linux/compiler.h:297:21: note: previous definition of 'offset_to_ptr' was here
| static inline void *offset_to_ptr(const int *off)
| ^~~~~~~~~~~~~
Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
---
mod/common/packet.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mod/common/packet.c b/mod/common/packet.c
index 9b4fbcd6..1b094fcc 100644
--- a/mod/common/packet.c
+++ b/mod/common/packet.c
@@ -70,7 +70,7 @@ static int inhdr4(struct sk_buff *skb, const char *msg)
return -EINVAL;
}
-static void *offset_to_ptr(struct sk_buff *skb, unsigned int offset)
+static void *skb_offset_to_ptr(struct sk_buff *skb, unsigned int offset)
{
return ((void *) skb->data) + offset;
}
@@ -368,9 +368,9 @@ int pkt_init_ipv6(struct packet *pkt, struct sk_buff *skb)
pkt->l4_proto = meta.l4_proto;
pkt->is_inner = 0;
pkt->is_hairpin = false;
- pkt->hdr_frag = meta.has_frag_hdr ? offset_to_ptr(skb, meta.frag_offset) : NULL;
+ pkt->hdr_frag = meta.has_frag_hdr ? skb_offset_to_ptr(skb, meta.frag_offset) : NULL;
skb_set_transport_header(skb, meta.l4_offset);
- pkt->payload = offset_to_ptr(skb, meta.payload_offset);
+ pkt->payload = skb_offset_to_ptr(skb, meta.payload_offset);
pkt->original_pkt = pkt;
return 0;
@@ -530,7 +530,7 @@ int pkt_init_ipv4(struct packet *pkt, struct sk_buff *skb)
pkt->is_hairpin = false;
pkt->hdr_frag = NULL;
skb_set_transport_header(skb, meta.l4_offset);
- pkt->payload = offset_to_ptr(skb, meta.payload_offset);
+ pkt->payload = skb_offset_to_ptr(skb, meta.payload_offset);
pkt->original_pkt = pkt;
return 0;
--
2.19.1

Loading…
Cancel
Save