aboutsummaryrefslogtreecommitdiff
path: root/net/wifidog-ng
diff options
context:
space:
mode:
authorJianhui Zhao <jianhuizhao329@gmail.com>2019-07-11 16:29:15 +0800
committerJianhui Zhao <jianhuizhao329@gmail.com>2019-07-11 16:29:40 +0800
commit2bde906fafeae7f09abe0ae918b0040f3653a751 (patch)
treef113312fb0c8e6ed4bd559b08a49b4913b1ab541 /net/wifidog-ng
parentb810b6f00eb4e35f976a41d4f10b3cc17a8f1752 (diff)
wifidog-ng: Update to 2.0.1
Compatible with Linux kernel 4.18 and above Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
Diffstat (limited to 'net/wifidog-ng')
-rw-r--r--net/wifidog-ng/Makefile4
-rw-r--r--net/wifidog-ng/src/main.c52
2 files changed, 36 insertions, 20 deletions
diff --git a/net/wifidog-ng/Makefile b/net/wifidog-ng/Makefile
index 3909e2a13..c936e3ad5 100644
--- a/net/wifidog-ng/Makefile
+++ b/net/wifidog-ng/Makefile
@@ -8,8 +8,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=wifidog-ng
-PKG_VERSION:=2.0.0
-PKG_RELEASE:=2
+PKG_VERSION:=2.0.1
+PKG_RELEASE:=1
PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)
diff --git a/net/wifidog-ng/src/main.c b/net/wifidog-ng/src/main.c
index 96da9a667..afb1b038e 100644
--- a/net/wifidog-ng/src/main.c
+++ b/net/wifidog-ng/src/main.c
@@ -22,19 +22,29 @@
#define IPS_HIJACKED (1 << 31)
#define IPS_ALLOWED (1 << 30)
-static u32 wd_nf_nat_setup_info(void *priv, struct sk_buff *skb,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 17, 19)
+static u32 wd_nat_setup_info(struct sk_buff *skb, struct nf_conn *ct)
+#else
+static u32 wd_nat_setup_info(void *priv, struct sk_buff *skb,
const struct nf_hook_state *state, struct nf_conn *ct)
+#endif
{
struct config *conf = get_config();
struct tcphdr *tcph = tcp_hdr(skb);
union nf_conntrack_man_proto proto;
- struct nf_nat_range newrange;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 17, 19)
+ struct nf_nat_range2 newrange = {};
+#else
+ struct nf_nat_range newrange = {};
+#endif
static uint16_t PORT_80 = htons(80);
proto.tcp.port = (tcph->dest == PORT_80) ? htons(conf->port) : htons(conf->ssl_port);
newrange.flags = NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED;
- newrange.min_addr.ip = newrange.max_addr.ip = conf->interface_ipaddr;
- newrange.min_proto = newrange.max_proto = proto;
+ newrange.min_addr.ip = conf->interface_ipaddr;
+ newrange.max_addr.ip = conf->interface_ipaddr;
+ newrange.min_proto = proto;
+ newrange.max_proto = proto;
ct->status |= IPS_HIJACKED;
@@ -117,16 +127,18 @@ redirect:
return NF_DROP;
}
- return nf_nat_ipv4_in(priv, skb, state, wd_nf_nat_setup_info);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 17, 19)
+ return wd_nat_setup_info(skb, ct);
+#else
+ return nf_nat_ipv4_in(priv, skb, state, wd_nat_setup_info);
+#endif
}
-static struct nf_hook_ops wifidog_ops[] __read_mostly = {
- {
- .hook = wifidog_hook,
- .pf = PF_INET,
- .hooknum = NF_INET_PRE_ROUTING,
- .priority = NF_IP_PRI_CONNTRACK + 1 /* after conntrack */
- }
+static struct nf_hook_ops wifidog_ops __read_mostly = {
+ .hook = wifidog_hook,
+ .pf = PF_INET,
+ .hooknum = NF_INET_PRE_ROUTING,
+ .priority = NF_IP_PRI_NAT_DST
};
static int __init wifidog_init(void)
@@ -137,10 +149,12 @@ static int __init wifidog_init(void)
if (ret)
return ret;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 12, 14)
- ret = nf_register_net_hooks(&init_net, wifidog_ops, ARRAY_SIZE(wifidog_ops));
+#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 17, 19)
+ ret = nf_nat_l3proto_ipv4_register_fn(&init_net, &wifidog_ops);
+#elif LINUX_VERSION_CODE > KERNEL_VERSION(4, 12, 14)
+ ret = nf_register_net_hook(&init_net, &wifidog_ops);
#else
- ret = nf_register_hooks(wifidog_ops, ARRAY_SIZE(wifidog_ops));
+ ret = nf_register_hook(&wifidog_ops);
#endif
if (ret < 0) {
pr_err("can't register hook\n");
@@ -160,10 +174,12 @@ static void __exit wifidog_exit(void)
{
deinit_config();
-#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 12, 14)
- nf_unregister_net_hooks(&init_net, wifidog_ops, ARRAY_SIZE(wifidog_ops));
+#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 17, 19)
+ nf_nat_l3proto_ipv4_unregister_fn(&init_net, &wifidog_ops);
+#elif LINUX_VERSION_CODE > KERNEL_VERSION(4, 12, 14)
+ nf_unregister_net_hook(&init_net, &wifidog_ops);
#else
- nf_unregister_hooks(wifidog_ops, ARRAY_SIZE(wifidog_ops));
+ nf_unregister_hook(&wifidog_ops);
#endif
pr_info("kmod of wifidog-ng is stop\n");