Created
May 15, 2025 19:11
-
-
Save qosmio/d9f40c91ab62bd516b8a671e97d75f68 to your computer and use it in GitHub Desktop.
nat46 6.12 compat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/package/kernel/nat46/Makefile b/package/kernel/nat46/Makefile | |
index bcd0cbd9f6..d5b131038b 100644 | |
--- a/package/kernel/nat46/Makefile | |
+++ b/package/kernel/nat46/Makefile | |
@@ -4,10 +4,10 @@ include $(INCLUDE_DIR)/kernel.mk | |
PKG_NAME:=nat46 | |
PKG_SOURCE_URL:=https://github.com/ayourtch/nat46.git | |
-PKG_SOURCE_DATE:=2024-08-12 | |
+PKG_SOURCE_DATE:=2025-04-23 | |
PKG_SOURCE_PROTO:=git | |
-PKG_SOURCE_VERSION:=b42c37d5c6dee4593df0fc60b37bc7ec4ee243a4 | |
-PKG_MIRROR_HASH:=2d7bbb6cc22808f7e81d716e6bd7a27d9978fb802496304851946627e21534a5 | |
+PKG_SOURCE_VERSION:=04923c51039e8ca270c6f1dde3f04f3b36958089 | |
+PKG_MIRROR_HASH:=35d7987eed7f05e5f7d1d2e111a8c9f5d019ccf11eb839dfe0bd2e2c46b6199a | |
PKG_MAINTAINER:=Hans Dedecker <[email protected]> | |
PKG_LICENSE:=GPL-2.0 | |
@@ -21,11 +21,13 @@ define KernelPackage/nat46 | |
TITLE:=Stateless NAT46 translation kernel module | |
SECTION:=kernel | |
SUBMENU:=Network Support | |
+ifneq ($(CONFIG_PACKAGE_kmod-nat46),) | |
FILES:=$(PKG_BUILD_DIR)/nat46/modules/nat46.ko | |
AUTOLOAD:=$(call AutoLoad,33,nat46) | |
+endif | |
endef | |
-include $(INCLUDE_DIR)/kernel-defaults.mk | |
+ifneq ($(CONFIG_PACKAGE_kmod-nat46),) | |
define Build/InstallDev | |
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/nat46 | |
@@ -40,4 +42,16 @@ define Build/Compile | |
$(INSTALL_DATA) $(PKG_BUILD_DIR)/nat46/modules/Module.symvers $(PKG_BUILD_DIR)/Module.symvers | |
endef | |
+else | |
+ | |
+define Build/Compile | |
+ : | |
+endef | |
+ | |
+define Build/Install | |
+ : | |
+endef | |
+ | |
+endif | |
+ | |
$(eval $(call KernelPackage,nat46)) | |
diff --git a/package/kernel/nat46/patches/101-skb-reset.patch b/package/kernel/nat46/patches/101-skb-reset.patch | |
index 14cf2d75a0..bc7a0a733e 100644 | |
--- a/package/kernel/nat46/patches/101-skb-reset.patch | |
+++ b/package/kernel/nat46/patches/101-skb-reset.patch | |
@@ -12,7 +12,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -1710,6 +1710,7 @@ int nat46_ipv6_input(struct sk_buff *old | |
+@@ -1726,6 +1726,7 @@ int nat46_ipv6_input(struct sk_buff *old | |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0) | |
nf_reset(new_skb); | |
#else | |
@@ -20,7 +20,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
nf_reset_ct(new_skb); | |
#endif | |
-@@ -1936,6 +1937,7 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -1957,6 +1958,7 @@ int nat46_ipv4_input(struct sk_buff *old | |
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0) | |
nf_reset(new_skb); | |
#else | |
diff --git a/package/kernel/nat46/patches/102-mapt.patch b/package/kernel/nat46/patches/102-mapt.patch | |
index 072d0cc447..019dad964e 100644 | |
--- a/package/kernel/nat46/patches/102-mapt.patch | |
+++ b/package/kernel/nat46/patches/102-mapt.patch | |
@@ -13,7 +13,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -1497,7 +1497,6 @@ static uint16_t nat46_fixup_icmp_dest_un | |
+@@ -1513,7 +1513,6 @@ static uint16_t nat46_fixup_icmp_dest_un | |
return 0; | |
} | |
@@ -21,7 +21,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
/* Fixup ICMP->ICMP6 before IP header translation, according to http://tools.ietf.org/html/rfc6145 */ | |
static uint16_t nat46_fixup_icmp(nat46_instance_t *nat46, struct iphdr *iph, struct sk_buff *old_skb) { | |
-@@ -1579,6 +1578,10 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins | |
+@@ -1595,6 +1594,10 @@ static int pairs_xlate_v6_to_v4_outer(na | |
return ( (xlate_src >= 0) && (xlate_dst >= 0) ); | |
} | |
@@ -32,7 +32,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
int nat46_ipv6_input(struct sk_buff *old_skb) { | |
struct ipv6hdr *ip6h = ipv6_hdr(old_skb); | |
-@@ -1733,6 +1736,10 @@ int nat46_ipv6_input(struct sk_buff *old | |
+@@ -1749,6 +1752,10 @@ int nat46_ipv6_input(struct sk_buff *old | |
nat46debug(5, "about to send v4 packet, flags: %02x", IPCB(new_skb)->flags); | |
nat46_netdev_count_xmit(new_skb, old_skb->dev); | |
@@ -43,7 +43,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
netif_rx(new_skb); | |
/* TBD: should copy be released here? */ | |
-@@ -1841,6 +1848,10 @@ int pairs_xlate_v4_to_v6_outer(nat46_ins | |
+@@ -1862,6 +1869,10 @@ static int pairs_xlate_v4_to_v6_outer(na | |
return 0; | |
} | |
@@ -54,7 +54,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
int nat46_ipv4_input(struct sk_buff *old_skb) { | |
nat46_instance_t *nat46 = get_nat46_instance(old_skb); | |
-@@ -1981,6 +1992,10 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2002,6 +2013,10 @@ int nat46_ipv4_input(struct sk_buff *old | |
nat46debug(5, "about to send v6 packet, flags: %02x", IP6CB(new_skb)->flags); | |
nat46_netdev_count_xmit(new_skb, old_skb->dev); | |
@@ -65,7 +65,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
netif_rx(new_skb); | |
done: | |
-@@ -1988,4 +2003,22 @@ done: | |
+@@ -2009,4 +2024,22 @@ done: | |
return err; | |
} | |
@@ -129,7 +129,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
#endif | |
--- a/nat46/modules/nat46-netdev.c | |
+++ b/nat46/modules/nat46-netdev.c | |
-@@ -24,10 +24,12 @@ | |
+@@ -24,6 +24,7 @@ | |
#include <net/ip6_route.h> | |
#include <net/ipv6.h> | |
#include <linux/version.h> | |
@@ -137,12 +137,15 @@ Signed-off-by: Pavithra R <[email protected]> | |
#include "nat46-core.h" | |
#include "nat46-module.h" | |
+@@ -36,6 +37,7 @@ | |
+ #endif | |
+ | |
#define NETDEV_DEFAULT_NAME "nat46." | |
+static RADIX_TREE(netdev_tree, GFP_ATOMIC); | |
typedef struct { | |
u32 sig; | |
-@@ -83,6 +85,18 @@ void nat46_netdev_count_xmit(struct sk_b | |
+@@ -91,6 +93,18 @@ void nat46_netdev_count_xmit(struct sk_b | |
dev->stats.tx_bytes += skb->len; | |
} | |
@@ -161,7 +164,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
void *netdev_nat46_instance(struct net_device *dev) { | |
nat46_netdev_priv_t *priv = netdev_priv(dev); | |
return priv->nat46; | |
-@@ -160,6 +174,11 @@ int nat46_netdev_create(struct net *net, | |
+@@ -174,6 +188,11 @@ static int nat46_netdev_create(struct ne | |
printk("nat46: netdevice nat46 '%s' created successfully.\n", devname); | |
kfree(devname); | |
@@ -173,7 +176,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
return 0; | |
err_register_dev: | |
-@@ -176,10 +195,24 @@ void nat46_netdev_destroy(struct net_dev | |
+@@ -190,10 +209,24 @@ static void nat46_netdev_destroy(struct | |
netif_stop_queue(dev); | |
netdev_nat46_set_instance(dev, NULL); | |
unregister_netdev(dev); | |
diff --git a/package/kernel/nat46/patches/103-tos.patch b/package/kernel/nat46/patches/103-tos.patch | |
index 60ffcb2fae..8373b34a1f 100644 | |
--- a/package/kernel/nat46/patches/103-tos.patch | |
+++ b/package/kernel/nat46/patches/103-tos.patch | |
@@ -14,10 +14,10 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -886,11 +886,12 @@ void *get_next_header_ptr6(void *pv6, in | |
+@@ -902,11 +902,12 @@ static void *get_next_header_ptr6(void * | |
} | |
- void fill_v4hdr_from_v6hdr(struct iphdr * iph, struct ipv6hdr *ip6h, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) { | |
+ static void fill_v4hdr_from_v6hdr(struct iphdr * iph, struct ipv6hdr *ip6h, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) { | |
+ uint32_t ver_class_flow = ntohl(*(__be32 *)ip6h); | |
iph->ttl = ip6h->hop_limit; | |
iph->saddr = v4saddr; | |
@@ -28,7 +28,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
iph->frag_off = frag_off; | |
iph->id = id; | |
iph->tot_len = htons( l3_payload_len + IPV4HDRSIZE ); | |
-@@ -1859,7 +1860,7 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -1880,7 +1881,7 @@ int nat46_ipv4_input(struct sk_buff *old | |
uint16_t sport = 0, dport = 0; | |
int err = 0; | |
diff --git a/package/kernel/nat46/patches/104-icmp.patch b/package/kernel/nat46/patches/104-icmp.patch | |
index 7907a66726..90af67b5b0 100644 | |
--- a/package/kernel/nat46/patches/104-icmp.patch | |
+++ b/package/kernel/nat46/patches/104-icmp.patch | |
@@ -20,18 +20,8 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -29,6 +29,9 @@ | |
- #include "nat46-core.h" | |
- #include "nat46-module.h" | |
- | |
-+static uint16_t xlate_pkt_in_err_v4_to_v6(nat46_instance_t *nat46, struct iphdr *iph, | |
-+ struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport); | |
-+ | |
- void | |
- nat46debug_dump(nat46_instance_t *nat46, int level, void *addr, int len) | |
- { | |
-@@ -885,6 +888,14 @@ void *get_next_header_ptr6(void *pv6, in | |
- return ret; | |
+@@ -885,6 +885,14 @@ static void *add_offset(void *ptr, u16 o | |
+ return (((char *)ptr)+offset); | |
} | |
+void fill_v6hdr_from_v4hdr(struct iphdr *iph, struct ipv6hdr *ip6h) { | |
@@ -42,10 +32,10 @@ Signed-off-by: Pavithra R <[email protected]> | |
+ ip6h->hop_limit = iph->ttl; | |
+} | |
+ | |
- void fill_v4hdr_from_v6hdr(struct iphdr * iph, struct ipv6hdr *ip6h, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) { | |
- uint32_t ver_class_flow = ntohl(*(__be32 *)ip6h); | |
- iph->ttl = ip6h->hop_limit; | |
-@@ -1212,10 +1223,14 @@ static void nat46_fixup_icmp6_paramprob( | |
+ | |
+ /* FIXME: traverse the headers properly */ | |
+ static void *get_next_header_ptr6(void *pv6, int v6_len) { | |
+@@ -1228,10 +1236,14 @@ static void nat46_fixup_icmp6_paramprob( | |
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, -1 }; | |
u32 *pptr6 = icmp6_parameter_ptr(icmp6h); | |
u8 *pptr4 = icmp_parameter_ptr((struct icmphdr *)icmp6h); | |
@@ -61,7 +51,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
case 0: | |
if(*pptr6 < sizeof(ptr6_4)/sizeof(ptr6_4[0])) { | |
new_pptr = ptr6_4[*pptr6]; | |
-@@ -1224,27 +1239,21 @@ static void nat46_fixup_icmp6_paramprob( | |
+@@ -1240,27 +1252,21 @@ static void nat46_fixup_icmp6_paramprob( | |
*pptr4 = 0xff & new_pptr; | |
update_icmp6_type_code(nat46, icmp6h, 12, 0); | |
len = xlate_payload6_to4(nat46, (icmp6h + 1), get_next_header_ptr6((icmp6h + 1), len), len, &icmp6h->icmp6_cksum, ptailTruncSize); | |
@@ -96,7 +86,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
/* Fixup ICMP6->ICMP before IP header translation, according to http://tools.ietf.org/html/rfc6145 */ | |
static void nat46_fixup_icmp6(nat46_instance_t *nat46, struct ipv6hdr *ip6h, struct icmp6hdr *icmp6h, struct sk_buff *old_skb, int *ptailTruncSize) { | |
-@@ -1299,17 +1308,19 @@ int ip6_input_not_interested(nat46_insta | |
+@@ -1315,17 +1321,19 @@ static int ip6_input_not_interested(nat4 | |
return 0; | |
} | |
@@ -119,7 +109,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
/* | |
* Set the Type to 4, and adjust the | |
* ICMP checksum both to take the type/code change into account | |
-@@ -1352,27 +1363,33 @@ static uint16_t nat46_fixup_icmp_paramet | |
+@@ -1368,27 +1376,33 @@ static uint16_t nat46_fixup_icmp_paramet | |
*/ | |
static int ptr4_6[] = { 0, 1, 4, 4, -1, -1, -1, -1, 7, 6, -1, -1, 8, 8, 8, 8, 24, 24, 24, 24, -1 }; | |
u8 *icmp_pptr = icmp_parameter_ptr(icmph); | |
@@ -160,7 +150,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
/* | |
* Translate the Code as | |
* described below, set the Type to 1, and adjust the ICMP | |
-@@ -1435,16 +1452,21 @@ static uint16_t nat46_fixup_icmp_dest_un | |
+@@ -1451,16 +1465,21 @@ static uint16_t nat46_fixup_icmp_dest_un | |
u16 *pmtu = ((u16 *)icmph) + 3; /* IPv4-compatible MTU value is 16 bit */ | |
@@ -184,7 +174,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
case 3: | |
icmph->code = 4; | |
break; | |
-@@ -1494,13 +1516,15 @@ static uint16_t nat46_fixup_icmp_dest_un | |
+@@ -1510,13 +1529,15 @@ static uint16_t nat46_fixup_icmp_dest_un | |
break; | |
default: | |
iph->protocol = NEXTHDR_NONE; | |
@@ -203,7 +193,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
struct icmphdr *icmph = (struct icmphdr *)(iph+1); | |
uint16_t ret = 0; | |
-@@ -1509,22 +1533,22 @@ static uint16_t nat46_fixup_icmp(nat46_i | |
+@@ -1525,22 +1546,22 @@ static uint16_t nat46_fixup_icmp(nat46_i | |
switch(icmph->type) { | |
case ICMP_ECHO: | |
icmph->type = ICMPV6_ECHO_REQUEST; | |
@@ -231,7 +221,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
break; | |
default: | |
/* Silently drop. */ | |
-@@ -1544,11 +1568,13 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins | |
+@@ -1560,11 +1581,13 @@ static int pairs_xlate_v6_to_v4_outer(na | |
if(-1 == xlate_dst) { | |
if (xlate_v6_to_v4(nat46, &apair->local, &ip6h->daddr, pv4daddr)) { | |
@@ -245,7 +235,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
xlate_src = ipair; | |
} | |
} | |
-@@ -1659,6 +1685,7 @@ int nat46_ipv6_input(struct sk_buff *old | |
+@@ -1675,6 +1698,7 @@ int nat46_ipv6_input(struct sk_buff *old | |
} | |
if(!pairs_xlate_v6_to_v4_outer(nat46, ip6h, proto, &v4saddr, &v4daddr)) { | |
@@ -253,7 +243,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
goto done; | |
} | |
-@@ -1821,11 +1848,13 @@ int pairs_xlate_v4_to_v6_outer(nat46_ins | |
+@@ -1842,11 +1866,13 @@ static int pairs_xlate_v4_to_v6_outer(na | |
if(-1 == xlate_src) { | |
if(xlate_v4_to_v6(nat46, &apair->local, &hdr4->saddr, v6saddr, sport)) { | |
@@ -267,7 +257,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
xlate_dst = ipair; | |
} | |
} | |
-@@ -1854,10 +1883,145 @@ int xlate_4_to_6(struct net_device *dev, | |
+@@ -1875,10 +1901,145 @@ int xlate_4_to_6(struct net_device *dev, | |
} | |
EXPORT_SYMBOL(xlate_4_to_6); | |
@@ -414,7 +404,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
int err = 0; | |
uint8_t tclass = 0; | |
-@@ -1879,7 +2043,7 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -1900,7 +2061,7 @@ int nat46_ipv4_input(struct sk_buff *old | |
} | |
nat46debug(1, "nat46_ipv4_input packet"); | |
nat46debug(5, "nat46_ipv4_input protocol: %d, len: %d, flags: %02x", hdr4->protocol, old_skb->len, IPCB(old_skb)->flags); | |
@@ -423,17 +413,17 @@ Signed-off-by: Pavithra R <[email protected]> | |
check_for_l4 = 1; | |
} else if (IPPROTO_ICMP == hdr4->protocol) { | |
/* | |
-@@ -1916,9 +2080,10 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -1937,9 +2098,10 @@ int nat46_ipv4_input(struct sk_buff *old | |
break; | |
} | |
case IPPROTO_ICMP: | |
- sport = dport = nat46_fixup_icmp(nat46, hdr4, old_skb); | |
- having_l4 = 1; | |
- break; | |
-+ ret = nat46_fixup_icmp(nat46, hdr4, old_skb, &sport, &dport); | |
-+ nat46debug(3, "ICMP translated to dest port %d, and src port %d.", ntohs(dport), ntohs(sport)); | |
-+ having_l4 = 1; | |
-+ break; | |
++ ret = nat46_fixup_icmp(nat46, hdr4, old_skb, &sport, &dport); | |
++ nat46debug(3, "ICMP translated to dest port %d, and src port %d.", ntohs(dport), ntohs(sport)); | |
++ having_l4 = 1; | |
++ break; | |
default: | |
break; | |
} | |
diff --git a/package/kernel/nat46/patches/105-longest-prefix-match.patch b/package/kernel/nat46/patches/105-longest-prefix-match.patch | |
index af7f2c770b..16c0f272c1 100644 | |
--- a/package/kernel/nat46/patches/105-longest-prefix-match.patch | |
+++ b/package/kernel/nat46/patches/105-longest-prefix-match.patch | |
@@ -16,7 +16,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -128,6 +128,13 @@ int try_parse_ipv6_prefix(struct in6_add | |
+@@ -129,6 +129,13 @@ static int try_parse_ipv6_prefix(struct | |
*arg_plen++ = 0; | |
if (pref_len) { | |
*pref_len = simple_strtol(arg_plen, NULL, 10); | |
@@ -30,7 +30,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
} | |
} | |
err = (1 != in6_pton(arg, -1, (u8 *)pref, '\0', NULL)); | |
-@@ -141,6 +148,13 @@ int try_parse_ipv4_prefix(u32 *v4addr, i | |
+@@ -142,6 +149,13 @@ static int try_parse_ipv4_prefix(u32 *v4 | |
*arg_plen++ = 0; | |
if (pref_len) { | |
*pref_len = simple_strtol(arg_plen, NULL, 10); | |
@@ -44,7 +44,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
} | |
} | |
err = (1 != in4_pton(arg, -1, (u8 *)v4addr, '/', NULL)); | |
-@@ -183,11 +197,127 @@ int try_parse_rule_arg(nat46_xlate_rule_ | |
+@@ -184,11 +198,127 @@ static int try_parse_rule_arg(nat46_xlat | |
return err; | |
} | |
@@ -88,7 +88,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
+ } | |
+ } | |
+ } | |
- | |
++ | |
+ array = &nat46->sorted_ipv6_local_pairs[0]; | |
+ for (i = 0; i < nelem - 1; i++) { | |
+ for (j = 0; j < nelem - i - 1; j++) { | |
@@ -133,7 +133,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
+ nat46debug(3, "EA-length should not exceed 48"); | |
+ return false; | |
+ } | |
-+ | |
+ | |
+ if (rule.v4_pref_len + rule.ea_len > IPV4_BITS_MAX) { | |
+ psid_len = rule.ea_len - (IPV4_BITS_MAX - rule.v4_pref_len); | |
+ } else { | |
@@ -175,7 +175,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
int nat46_set_ipair_config(nat46_instance_t *nat46, int ipair, char *buf, int count) { | |
char *tail = buf; | |
char *arg_name; | |
-@@ -217,7 +347,18 @@ int nat46_set_ipair_config(nat46_instanc | |
+@@ -218,7 +348,18 @@ int nat46_set_ipair_config(nat46_instanc | |
err = try_parse_rule_arg(&apair->remote, arg_name, &tail); | |
} | |
} | |
@@ -195,10 +195,13 @@ Signed-off-by: Pavithra R <[email protected]> | |
} | |
int nat46_set_config(nat46_instance_t *nat46, char *buf, int count) { | |
-@@ -933,37 +1074,120 @@ int is_last_pair_in_group(nat46_xlate_ru | |
- return ( (apair->local.style != NAT46_XLATE_NONE) && (apair->remote.style != NAT46_XLATE_NONE) ); | |
+@@ -941,9 +1082,94 @@ static u16 rechecksum16(void *p, int cou | |
+ return csum; | |
} | |
+-/* Last rule in group must not have "none" as either source or destination */ | |
+-static int is_last_pair_in_group(nat46_xlate_rulepair_t *apair) { | |
+- return ( (apair->local.style != NAT46_XLATE_NONE) && (apair->remote.style != NAT46_XLATE_NONE) ); | |
+nat46_xlate_rulepair_t *nat46_lpm(nat46_instance_t *nat46, nat46_rule_type_t type, void *paddr) { | |
+ int ipair = 0; | |
+ nat46_xlate_rulepair_t *apair = NULL; | |
@@ -287,11 +290,10 @@ Signed-off-by: Pavithra R <[email protected]> | |
+ nat46debug(0, "%s : Invalid prefix type.\n", __func__); | |
+ } | |
+ return NULL; | |
-+} | |
-+ | |
- void pairs_xlate_v6_to_v4_inner(nat46_instance_t *nat46, struct ipv6hdr *ip6h, __u32 *pv4saddr, __u32 *pv4daddr) { | |
- int ipair = 0; | |
- nat46_xlate_rulepair_t *apair = NULL; | |
+ } | |
+ | |
+ static void pairs_xlate_v6_to_v4_inner(nat46_instance_t *nat46, struct ipv6hdr *ip6h, __u32 *pv4saddr, __u32 *pv4daddr) { | |
+@@ -952,31 +1178,24 @@ static void pairs_xlate_v6_to_v4_inner(n | |
int xlate_src = -1; | |
int xlate_dst = -1; | |
@@ -339,12 +341,12 @@ Signed-off-by: Pavithra R <[email protected]> | |
} | |
/* | |
-@@ -1557,40 +1781,31 @@ static uint16_t nat46_fixup_icmp(nat46_i | |
+@@ -1570,40 +1789,31 @@ static uint16_t nat46_fixup_icmp(nat46_i | |
return ret; | |
} | |
--int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) { | |
-+int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair, | |
+-static int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) { | |
++static int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair, | |
+ struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) { | |
int ipair = 0; | |
- nat46_xlate_rulepair_t *apair = NULL; | |
@@ -394,7 +396,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
nat46debug(1, "[nat46] Could not translate remote address v6->v4, ipair %d, for ICMP6 use dest addr", ipair); | |
*pv4saddr = *pv4daddr; | |
xlate_src = xlate_dst; | |
-@@ -1606,12 +1821,14 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins | |
+@@ -1619,12 +1829,14 @@ static int pairs_xlate_v6_to_v4_outer(na | |
} | |
int xlate_6_to_4(struct net_device *dev, struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) { | |
@@ -410,7 +412,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
nat46_instance_t *nat46 = get_nat46_instance(old_skb); | |
uint16_t proto; | |
uint16_t frag_off; | |
-@@ -1684,7 +1901,7 @@ int nat46_ipv6_input(struct sk_buff *old | |
+@@ -1697,7 +1909,7 @@ int nat46_ipv6_input(struct sk_buff *old | |
check_for_l4 = 1; | |
} | |
@@ -419,12 +421,12 @@ Signed-off-by: Pavithra R <[email protected]> | |
nat46debug(0, "[nat46] Could not translate v6->v4"); | |
goto done; | |
} | |
-@@ -1837,56 +2054,44 @@ int ip4_input_not_interested(nat46_insta | |
+@@ -1855,56 +2067,44 @@ static int ip4_input_not_interested(nat4 | |
return 0; | |
} | |
--int pairs_xlate_v4_to_v6_outer(nat46_instance_t *nat46, struct iphdr *hdr4, uint16_t *sport, uint16_t *dport, void *v6saddr, void *v6daddr) { | |
-+int pairs_xlate_v4_to_v6_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair, | |
+-static int pairs_xlate_v4_to_v6_outer(nat46_instance_t *nat46, struct iphdr *hdr4, uint16_t *sport, uint16_t *dport, void *v6saddr, void *v6daddr) { | |
++static int pairs_xlate_v4_to_v6_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair, | |
+ struct iphdr *hdr4, uint16_t *sport, uint16_t *dport, void *v6saddr, void *v6daddr) { | |
int ipair = 0; | |
- nat46_xlate_rulepair_t *apair = NULL; | |
@@ -499,7 +501,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
*/ | |
int pairs_xlate_v4_to_v6_inner(nat46_instance_t *nat46, struct iphdr *iph, | |
uint16_t sport, uint16_t dport, void *v6saddr, void *v6daddr) { | |
-@@ -1895,35 +2100,27 @@ int pairs_xlate_v4_to_v6_inner(nat46_ins | |
+@@ -1913,35 +2113,27 @@ int pairs_xlate_v4_to_v6_inner(nat46_ins | |
int xlate_src = -1; | |
int xlate_dst = -1; | |
@@ -554,7 +556,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
return 0; | |
} | |
-@@ -2020,6 +2217,7 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
+@@ -2038,6 +2230,7 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
int nat46_ipv4_input(struct sk_buff *old_skb) { | |
nat46_instance_t *nat46 = get_nat46_instance(old_skb); | |
@@ -562,7 +564,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
struct sk_buff *new_skb; | |
uint16_t sport = 0, dport = 0, ret = 0; | |
-@@ -2097,7 +2295,7 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2115,7 +2308,7 @@ int nat46_ipv4_input(struct sk_buff *old | |
having_l4 = 1; | |
} | |
@@ -622,7 +624,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
int nat46_ipv6_input(struct sk_buff *old_skb); | |
--- a/nat46/modules/nat46-netdev.c | |
+++ b/nat46/modules/nat46-netdev.c | |
-@@ -270,7 +270,14 @@ int nat46_insert(struct net *net, char * | |
+@@ -284,7 +284,14 @@ int nat46_insert(struct net *net, char * | |
int ret = -1; | |
if(dev) { | |
nat46_instance_t *nat46 = netdev_nat46_instance(dev); | |
diff --git a/package/kernel/nat46/patches/106-dummy_header.patch b/package/kernel/nat46/patches/106-dummy_header.patch | |
index bad08339e6..0231c9a94b 100644 | |
--- a/package/kernel/nat46/patches/106-dummy_header.patch | |
+++ b/package/kernel/nat46/patches/106-dummy_header.patch | |
@@ -14,7 +14,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -1996,6 +1996,27 @@ done: | |
+@@ -2004,6 +2004,27 @@ done: | |
@@ -39,10 +39,10 @@ Signed-off-by: Pavithra R <[email protected]> | |
+} | |
+EXPORT_SYMBOL(nat46_get_info); | |
+ | |
- void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, int do_atomic_frag) | |
+ static void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, int do_atomic_frag) | |
{ | |
u32 sum1=0; | |
-@@ -2254,6 +2275,11 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2267,6 +2288,11 @@ int nat46_ipv4_input(struct sk_buff *old | |
} | |
hdr4 = ip_hdr(old_skb); | |
check_for_l4 = 1; | |
diff --git a/package/kernel/nat46/patches/107-stats.patch b/package/kernel/nat46/patches/107-stats.patch | |
index 4667613d8f..ba6870d143 100644 | |
--- a/package/kernel/nat46/patches/107-stats.patch | |
+++ b/package/kernel/nat46/patches/107-stats.patch | |
@@ -21,7 +21,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
#include <linux/radix-tree.h> | |
#include "nat46-core.h" | |
#include "nat46-module.h" | |
-@@ -40,16 +41,40 @@ static u8 netdev_count = 0; | |
+@@ -48,16 +49,40 @@ static u8 netdev_count = 0; | |
static int nat46_netdev_up(struct net_device *dev); | |
static int nat46_netdev_down(struct net_device *dev); | |
@@ -63,7 +63,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
static int nat46_netdev_up(struct net_device *dev) | |
{ | |
netif_start_queue(dev); | |
-@@ -65,9 +90,14 @@ static int nat46_netdev_down(struct net_ | |
+@@ -73,9 +98,14 @@ static int nat46_netdev_down(struct net_ | |
static netdev_tx_t nat46_netdev_xmit(struct sk_buff *skb, struct net_device *dev) | |
{ | |
int ret = 0; | |
@@ -80,7 +80,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
if(ETH_P_IP == ntohs(skb->protocol)) { | |
ret = nat46_ipv4_input(skb); | |
} | |
-@@ -81,22 +111,39 @@ static netdev_tx_t nat46_netdev_xmit(str | |
+@@ -89,22 +119,39 @@ static netdev_tx_t nat46_netdev_xmit(str | |
} | |
void nat46_netdev_count_xmit(struct sk_buff *skb, struct net_device *dev) { | |
@@ -126,7 +126,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
void *netdev_nat46_instance(struct net_device *dev) { | |
nat46_netdev_priv_t *priv = netdev_priv(dev); | |
return priv->nat46; | |
-@@ -120,6 +167,7 @@ static void nat46_netdev_setup(struct ne | |
+@@ -128,6 +175,7 @@ static void nat46_netdev_setup(struct ne | |
priv->nat46 = nat46; | |
dev->netdev_ops = &nat46_netdev_ops; | |
diff --git a/package/kernel/nat46/patches/108-ce_port.patch b/package/kernel/nat46/patches/108-ce_port.patch | |
index ab6ab37b98..2b46859fc7 100644 | |
--- a/package/kernel/nat46/patches/108-ce_port.patch | |
+++ b/package/kernel/nat46/patches/108-ce_port.patch | |
@@ -16,13 +16,13 @@ Signed-off-by: Pavithra R <[email protected]> | |
+++ b/nat46/modules/nat46-core.c | |
@@ -31,6 +31,7 @@ | |
- static uint16_t xlate_pkt_in_err_v4_to_v6(nat46_instance_t *nat46, struct iphdr *iph, | |
- struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport); | |
+ #include "nat46-glue.h" | |
+ #include "nat46-core.h" | |
+static DEFINE_SPINLOCK(port_id_lock); | |
+ #include "nat46-module.h" | |
- void | |
- nat46debug_dump(nat46_instance_t *nat46, int level, void *addr, int len) | |
-@@ -2236,6 +2237,73 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
+ static void | |
+@@ -2249,6 +2250,73 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
return 1; | |
} | |
@@ -96,7 +96,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
int nat46_ipv4_input(struct sk_buff *old_skb) { | |
nat46_instance_t *nat46 = get_nat46_instance(old_skb); | |
nat46_xlate_rulepair_t apair; | |
-@@ -2368,9 +2436,34 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2381,9 +2449,34 @@ int nat46_ipv4_input(struct sk_buff *old | |
if (add_frag_header) { | |
struct frag_hdr *fh = (struct frag_hdr*)(hdr6 + 1); | |
diff --git a/package/kernel/nat46/patches/109-fragment_if_not_df_and_larger_than_mtu.patch b/package/kernel/nat46/patches/109-fragment_if_not_df_and_larger_than_mtu.patch | |
index 333228a974..610f21b87c 100644 | |
--- a/package/kernel/nat46/patches/109-fragment_if_not_df_and_larger_than_mtu.patch | |
+++ b/package/kernel/nat46/patches/109-fragment_if_not_df_and_larger_than_mtu.patch | |
@@ -14,7 +14,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -2343,10 +2343,11 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2356,10 +2356,11 @@ int nat46_ipv4_input(struct sk_buff *old | |
} | |
hdr4 = ip_hdr(old_skb); | |
check_for_l4 = 1; | |
diff --git a/package/kernel/nat46/patches/110-icmp_error_not_handled.patch b/package/kernel/nat46/patches/110-icmp_error_not_handled.patch | |
index 5697c60973..37347c9633 100644 | |
--- a/package/kernel/nat46/patches/110-icmp_error_not_handled.patch | |
+++ b/package/kernel/nat46/patches/110-icmp_error_not_handled.patch | |
@@ -19,12 +19,12 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -1782,11 +1782,12 @@ static uint16_t nat46_fixup_icmp(nat46_i | |
+@@ -1790,11 +1790,12 @@ static uint16_t nat46_fixup_icmp(nat46_i | |
return ret; | |
} | |
--int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair, | |
-+int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t **papair, | |
+-static int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair, | |
++static int pairs_xlate_v6_to_v4_outer(nat46_instance_t *nat46, nat46_xlate_rulepair_t **papair, | |
struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) { | |
int ipair = 0; | |
int xlate_src = -1; | |
@@ -33,7 +33,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
for(ipair = 0; ipair < nat46->npairs; ipair++) { | |
apair = nat46_lpm(nat46, NAT46_IPV6_REMOTE, &ip6h->saddr); | |
-@@ -1794,6 +1795,7 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins | |
+@@ -1802,6 +1803,7 @@ static int pairs_xlate_v6_to_v4_outer(na | |
return 0; | |
} | |
@@ -41,7 +41,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
if (xlate_v6_to_v4(nat46, &apair->local, &ip6h->daddr, pv4daddr)) { | |
nat46debug(5, "Dst addr %pI6 to %pI4 \n", &ip6h->daddr, pv4daddr); | |
xlate_dst = ipair; | |
-@@ -1822,14 +1824,14 @@ int pairs_xlate_v6_to_v4_outer(nat46_ins | |
+@@ -1830,14 +1832,14 @@ static int pairs_xlate_v6_to_v4_outer(na | |
} | |
int xlate_6_to_4(struct net_device *dev, struct ipv6hdr *ip6h, uint16_t proto, __u32 *pv4saddr, __u32 *pv4daddr) { | |
@@ -58,7 +58,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
nat46_instance_t *nat46 = get_nat46_instance(old_skb); | |
uint16_t proto; | |
uint16_t frag_off; | |
-@@ -1903,8 +1905,37 @@ int nat46_ipv6_input(struct sk_buff *old | |
+@@ -1911,8 +1913,37 @@ int nat46_ipv6_input(struct sk_buff *old | |
} | |
if (!pairs_xlate_v6_to_v4_outer(nat46, &apair, ip6h, proto, &v4saddr, &v4daddr)) { | |
diff --git a/package/kernel/nat46/patches/111-fix_null_point_reference.patch b/package/kernel/nat46/patches/111-fix_null_point_reference.patch | |
index 4cef9db199..a1df708f61 100644 | |
--- a/package/kernel/nat46/patches/111-fix_null_point_reference.patch | |
+++ b/package/kernel/nat46/patches/111-fix_null_point_reference.patch | |
@@ -14,7 +14,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -1847,6 +1847,11 @@ int nat46_ipv6_input(struct sk_buff *old | |
+@@ -1855,6 +1855,11 @@ int nat46_ipv6_input(struct sk_buff *old | |
int l3_infrag_payload_len = ntohs(ip6h->payload_len); | |
int check_for_l4 = 0; | |
@@ -26,7 +26,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
nat46debug(4, "nat46_ipv6_input packet"); | |
if(ip6_input_not_interested(nat46, ip6h, old_skb)) { | |
-@@ -2353,6 +2358,11 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2366,6 +2371,11 @@ int nat46_ipv4_input(struct sk_buff *old | |
char v6saddr[16], v6daddr[16]; | |
diff --git a/package/kernel/nat46/patches/112-fix_icmp_crash.patch b/package/kernel/nat46/patches/112-fix_icmp_crash.patch | |
index 5d34697a45..e07ca51e73 100644 | |
--- a/package/kernel/nat46/patches/112-fix_icmp_crash.patch | |
+++ b/package/kernel/nat46/patches/112-fix_icmp_crash.patch | |
@@ -16,7 +16,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -2245,7 +2245,9 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
+@@ -2258,7 +2258,9 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
if (skb_tailroom(old_skb) >= IPV6V4HDRDELTA){ | |
skb_put(old_skb, IPV6V4HDRDELTA); | |
@@ -27,7 +27,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
memcpy(iiph, &ip6h, IPV6HDRSIZE); | |
} | |
else { | |
-@@ -2258,7 +2260,9 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
+@@ -2271,7 +2273,9 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
skb_put(old_skb, IPV6V4HDRDELTA); | |
iiph = (struct iphdr *)(icmp_hdr(old_skb) + 1); | |
diff --git a/package/kernel/nat46/patches/116-rate-limit-the-print.patch b/package/kernel/nat46/patches/116-rate-limit-the-print.patch | |
index d857d0e6cb..ecc8e75987 100644 | |
--- a/package/kernel/nat46/patches/116-rate-limit-the-print.patch | |
+++ b/package/kernel/nat46/patches/116-rate-limit-the-print.patch | |
@@ -10,7 +10,7 @@ Change-Id: I2119fbe54d630c3ed39535f1cb1b8a0d9d3199b4 | |
Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -1928,7 +1928,9 @@ int nat46_ipv6_input(struct sk_buff *old | |
+@@ -1936,7 +1936,9 @@ int nat46_ipv6_input(struct sk_buff *old | |
memcpy(&hdr6.saddr, &ip6h_inner->daddr, 16); | |
memcpy(&hdr6.daddr, &ip6h_inner->saddr, 16); | |
if (!pairs_xlate_v6_to_v4_outer(nat46, &apair, &hdr6, proto, &v4saddr, &v4daddr)) { | |
@@ -21,7 +21,7 @@ Signed-off-by: Pavithra R <[email protected]> | |
goto done; | |
} | |
v4saddr = apair->local.v4_pref; | |
-@@ -2436,7 +2438,9 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2449,7 +2451,9 @@ int nat46_ipv4_input(struct sk_buff *old | |
} | |
if(!pairs_xlate_v4_to_v6_outer(nat46, &apair, hdr4, having_l4 ? &sport : NULL, having_l4 ? &dport : NULL, v6saddr, v6daddr)) { | |
diff --git a/package/kernel/nat46/patches/117-fix-icmp-no-payload-bug.patch b/package/kernel/nat46/patches/117-fix-icmp-no-payload-bug.patch | |
index a8bff4a945..3c17ca8ed9 100644 | |
--- a/package/kernel/nat46/patches/117-fix-icmp-no-payload-bug.patch | |
+++ b/package/kernel/nat46/patches/117-fix-icmp-no-payload-bug.patch | |
@@ -21,7 +21,7 @@ Change-Id: Ifd9802afb50771de39b4c6fb734d36b0801613ec | |
Signed-off-by: Pavithra R <[email protected]> | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -2266,9 +2266,8 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
+@@ -2279,9 +2279,8 @@ static uint16_t xlate_pkt_in_err_v4_to_v | |
memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1), | |
ntohs(iph->tot_len) - 2 * IPV4HDRSIZE - sizeof(struct icmphdr)); | |
memcpy(iiph, &ip6h, IPV6HDRSIZE); | |
diff --git a/package/kernel/nat46/patches/118-performance_fix.patch b/package/kernel/nat46/patches/118-performance_fix.patch | |
index 5f10ca10bb..461bf9ad6c 100644 | |
--- a/package/kernel/nat46/patches/118-performance_fix.patch | |
+++ b/package/kernel/nat46/patches/118-performance_fix.patch | |
@@ -10,7 +10,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -118,7 +118,7 @@ char *get_next_arg(char **ptail) { | |
+@@ -119,7 +119,7 @@ char *get_next_arg(char **ptail) { | |
return pc; | |
} | |
@@ -19,7 +19,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
* Parse an IPv6 address (if pref_len is NULL), or prefix (if it isn't). | |
* parses destructively (places \0 between address and prefix len) | |
*/ | |
-@@ -163,7 +163,7 @@ int try_parse_ipv4_prefix(u32 *v4addr, i | |
+@@ -164,7 +164,7 @@ static int try_parse_ipv4_prefix(u32 *v4 | |
} | |
@@ -28,7 +28,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
* parse a rule argument and put config into a rule. | |
* advance the tail to prepare for the next arg parsing. | |
* destructive. | |
-@@ -384,7 +384,7 @@ char *xlate_style_to_string(nat46_xlate_ | |
+@@ -385,7 +385,7 @@ static char *xlate_style_to_string(nat46 | |
return "unknown"; | |
} | |
@@ -37,7 +37,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
* Get the nat46 configuration into a supplied buffer (if non-null). | |
*/ | |
int nat46_get_ipair_config(nat46_instance_t *nat46, int ipair, char *buf, int count) { | |
-@@ -985,6 +985,28 @@ __sum16 csum_ipv6_unmagic(nat46_instance | |
+@@ -998,6 +998,28 @@ static __sum16 csum_ipv6_unmagic(nat46_i | |
return csum; | |
} | |
@@ -64,30 +64,30 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
+} | |
+ | |
/* Update ICMPv6 type/code with incremental checksum adjustment */ | |
- void update_icmp6_type_code(nat46_instance_t *nat46, struct icmp6hdr *icmp6h, u8 type, u8 code) { | |
+ static void update_icmp6_type_code(nat46_instance_t *nat46, struct icmp6hdr *icmp6h, u8 type, u8 code) { | |
u16 old_tc = *((u16 *)icmp6h); | |
-@@ -1038,9 +1060,8 @@ void fill_v6hdr_from_v4hdr(struct iphdr | |
- ip6h->hop_limit = iph->ttl; | |
+@@ -1051,9 +1073,8 @@ static void *get_next_header_ptr6(void * | |
+ return ret; | |
} | |
--void fill_v4hdr_from_v6hdr(struct iphdr * iph, struct ipv6hdr *ip6h, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) { | |
+-static void fill_v4hdr_from_v6hdr(struct iphdr * iph, struct ipv6hdr *ip6h, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) { | |
- uint32_t ver_class_flow = ntohl(*(__be32 *)ip6h); | |
- iph->ttl = ip6h->hop_limit; | |
-+void fill_v4hdr_from_v6hdr(struct iphdr * iph, uint32_t ver_class_flow, uint8_t hop_limit, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) { | |
++static void fill_v4hdr_from_v6hdr(struct iphdr * iph, uint32_t ver_class_flow, uint8_t hop_limit, __u32 v4saddr, __u32 v4daddr, __u16 id, __u16 frag_off, __u16 proto, int l3_payload_len) { | |
+ iph->ttl = hop_limit; | |
iph->saddr = v4saddr; | |
iph->daddr = v4daddr; | |
iph->protocol = proto; | |
-@@ -1198,6 +1219,8 @@ void pairs_xlate_v6_to_v4_inner(nat46_in | |
+@@ -1206,6 +1227,8 @@ static void pairs_xlate_v6_to_v4_inner(n | |
*/ | |
- int xlate_payload6_to4(nat46_instance_t *nat46, void *pv6, void *ptrans_hdr, int v6_len, u16 *ul_sum, int *ptailTruncSize) { | |
+ static int xlate_payload6_to4(nat46_instance_t *nat46, void *pv6, void *ptrans_hdr, int v6_len, u16 *ul_sum, int *ptailTruncSize) { | |
struct ipv6hdr *ip6h = pv6; | |
+ uint32_t ver_class_flow; | |
+ uint8_t hop_limit; | |
__u32 v4saddr, v4daddr; | |
struct iphdr new_ipv4; | |
struct iphdr *iph = &new_ipv4; | |
-@@ -1274,7 +1297,10 @@ int xlate_payload6_to4(nat46_instance_t | |
+@@ -1282,7 +1305,10 @@ static int xlate_payload6_to4(nat46_inst | |
} | |
} | |
@@ -99,7 +99,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
if(ul_sum) { | |
*ul_sum = unchecksum16(pv6, (((u8 *)ptrans_hdr)-((u8 *)pv6))/2, *ul_sum); | |
*ul_sum = rechecksum16(iph, 10, *ul_sum); | |
-@@ -1831,6 +1857,8 @@ EXPORT_SYMBOL(xlate_6_to_4); | |
+@@ -1839,6 +1865,8 @@ EXPORT_SYMBOL(xlate_6_to_4); | |
int nat46_ipv6_input(struct sk_buff *old_skb) { | |
struct ipv6hdr *ip6h = ipv6_hdr(old_skb); | |
@@ -108,7 +108,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
nat46_xlate_rulepair_t *apair; | |
nat46_instance_t *nat46 = get_nat46_instance(old_skb); | |
uint16_t proto; | |
-@@ -1839,22 +1867,20 @@ int nat46_ipv6_input(struct sk_buff *old | |
+@@ -1847,22 +1875,20 @@ int nat46_ipv6_input(struct sk_buff *old | |
struct iphdr * iph; | |
__u32 v4saddr, v4daddr; | |
@@ -133,7 +133,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
nat46debug(1, "nat46_ipv6_input not interested"); | |
goto done; | |
} | |
-@@ -1985,47 +2011,45 @@ int nat46_ipv6_input(struct sk_buff *old | |
+@@ -1993,47 +2019,45 @@ int nat46_ipv6_input(struct sk_buff *old | |
} | |
} | |
@@ -202,18 +202,18 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
/* TBD: should copy be released here? */ | |
done: | |
-@@ -2056,7 +2080,7 @@ bool nat46_get_info(struct net_device *d | |
+@@ -2064,7 +2088,7 @@ bool nat46_get_info(struct net_device *d | |
} | |
EXPORT_SYMBOL(nat46_get_info); | |
--void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, int do_atomic_frag) | |
-+void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, uint32_t v4saddr, uint32_t v4daddr, int do_atomic_frag) | |
+-static void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, int do_atomic_frag) | |
++static void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, uint32_t v4saddr, uint32_t v4daddr, int do_atomic_frag) | |
{ | |
u32 sum1=0; | |
u16 sum2=0; | |
-@@ -2079,12 +2103,13 @@ void ip6_update_csum(struct sk_buff * sk | |
- struct udphdr *udp = udp_hdr(skb); | |
- unsigned udplen = ntohs(ip6hdr->payload_len) - (do_atomic_frag?8:0); /* UDP hdr + payload */ | |
+@@ -2092,12 +2116,13 @@ static void ip6_update_csum(struct sk_bu | |
+ break; | |
+ } | |
- oldsum = udp->check; | |
- udp->check = 0; | |
@@ -231,7 +231,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
udp->check = sum2; | |
break; | |
-@@ -2348,7 +2373,6 @@ static uint16_t nat46_get_ce_port(nat46_ | |
+@@ -2361,7 +2386,6 @@ static uint16_t nat46_get_ce_port(nat46_ | |
int nat46_ipv4_input(struct sk_buff *old_skb) { | |
nat46_instance_t *nat46 = get_nat46_instance(old_skb); | |
nat46_xlate_rulepair_t apair; | |
@@ -239,7 +239,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
uint16_t sport = 0, dport = 0, ret = 0; | |
int err = 0; | |
-@@ -2360,10 +2384,15 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2373,10 +2397,15 @@ int nat46_ipv4_input(struct sk_buff *old | |
struct ipv6hdr * hdr6; | |
struct iphdr * hdr4 = ip_hdr(old_skb); | |
@@ -256,7 +256,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
printk("nat46:%p skb is dropped for no valid instance found\n", old_skb); | |
return err; | |
} | |
-@@ -2443,31 +2472,39 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2456,31 +2485,39 @@ int nat46_ipv4_input(struct sk_buff *old | |
goto done; | |
} | |
@@ -310,7 +310,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
memset(hdr6, 0, sizeof(*hdr6) + (add_frag_header?8:0)); | |
/* build IPv6 header */ | |
-@@ -2475,13 +2512,14 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2488,13 +2525,14 @@ int nat46_ipv4_input(struct sk_buff *old | |
*(__be32 *)hdr6 = htonl(0x60000000 | (tclass << 20)) | flowlabel; /* version, priority, flowlabel */ | |
/* IPv6 length is a payload length, IPv4 is hdr+payload */ | |
@@ -329,7 +329,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
if (add_frag_header) { | |
struct frag_hdr *fh = (struct frag_hdr*)(hdr6 + 1); | |
-@@ -2490,8 +2528,8 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2503,8 +2541,8 @@ int nat46_ipv4_input(struct sk_buff *old | |
/* Flag to represent whether PSID is assigned to MAP-T node or not */ | |
bool is_psid = false; | |
@@ -340,7 +340,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
/* | |
* PSID assigned MAP-T node will have non-zero ea_len and we are currently | |
-@@ -2506,29 +2544,30 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2519,29 +2557,30 @@ int nat46_ipv4_input(struct sk_buff *old | |
if (ce_port_num) { | |
fh->identification = htonl(ce_port_num); | |
} else { | |
@@ -395,7 +395,7 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
*/ | |
--- a/nat46/modules/nat46-netdev.c | |
+++ b/nat46/modules/nat46-netdev.c | |
-@@ -100,8 +100,7 @@ static netdev_tx_t nat46_netdev_xmit(str | |
+@@ -108,8 +108,7 @@ static netdev_tx_t nat46_netdev_xmit(str | |
if(ETH_P_IP == ntohs(skb->protocol)) { | |
ret = nat46_ipv4_input(skb); | |
@@ -405,11 +405,11 @@ Date: Fri Dec 17 13:37:15 2021 -0800 | |
ret = nat46_ipv6_input(skb); | |
} | |
if(0 == ret) { | |
-@@ -174,6 +173,7 @@ static void nat46_netdev_setup(struct ne | |
- dev->mtu = 16384; /* iptables does reassembly. Rather than using ETH_DATA_LEN, let's try to get as much mileage as we can with the Linux stack */ | |
- dev->features = NETIF_F_NETNS_LOCAL; | |
+@@ -188,6 +187,7 @@ static void nat46_netdev_setup(struct ne | |
+ dev->netns_immutable = true; | |
+ #endif | |
dev->flags = IFF_NOARP | IFF_POINTOPOINT; | |
+ dev->priv_flags_ext = IFF_EXT_MAPT; | |
} | |
- int nat46_netdev_create(struct net *net, char *basename, struct net_device **dev) | |
+ static int nat46_netdev_create(struct net *net, char *basename, struct net_device **dev) | |
diff --git a/package/kernel/nat46/patches/120-sleeping_backtrace.patch b/package/kernel/nat46/patches/120-sleeping_backtrace.patch | |
index 5963af2b03..5185a2ff1c 100644 | |
--- a/package/kernel/nat46/patches/120-sleeping_backtrace.patch | |
+++ b/package/kernel/nat46/patches/120-sleeping_backtrace.patch | |
@@ -18,7 +18,7 @@ Date: Tue Sep 6 11:11:20 2022 -0700 | |
-static DEFINE_MUTEX(ref_lock); | |
+static DEFINE_SPINLOCK(ref_lock); | |
- int is_valid_nat46(nat46_instance_t *nat46) { | |
+ static int is_valid_nat46(nat46_instance_t *nat46) { | |
return (nat46 && (nat46->sig == NAT46_SIGNATURE)); | |
} | |
@@ -47,28 +47,27 @@ nat46_instance_t *alloc_nat46_instance(i | |
diff --git a/package/kernel/nat46/patches/121-tos-fix.patch b/package/kernel/nat46/patches/121-tos-fix.patch | |
index 6b265886f5..3030cd88ce 100644 | |
--- a/package/kernel/nat46/patches/121-tos-fix.patch | |
+++ b/package/kernel/nat46/patches/121-tos-fix.patch | |
@@ -8,7 +8,7 @@ Date: Thu Nov 16 15:30:04 2023 +0530 | |
--- a/nat46/modules/nat46-core.c | |
+++ b/nat46/modules/nat46-core.c | |
-@@ -2397,6 +2397,8 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2410,6 +2410,8 @@ int nat46_ipv4_input(struct sk_buff *old | |
return err; | |
} | |
@@ -17,7 +17,7 @@ Date: Thu Nov 16 15:30:04 2023 +0530 | |
memset(v6saddr, 1, 16); | |
memset(v6daddr, 2, 16); | |
-@@ -2508,7 +2510,6 @@ int nat46_ipv4_input(struct sk_buff *old | |
+@@ -2521,7 +2523,6 @@ int nat46_ipv4_input(struct sk_buff *old | |
memset(hdr6, 0, sizeof(*hdr6) + (add_frag_header?8:0)); | |
/* build IPv6 header */ | |
diff --git a/package/kernel/nat46/patches/122-kernel-6.12.patch b/package/kernel/nat46/patches/122-kernel-6.12.patch | |
new file mode 100644 | |
index 0000000000..4f92a95d16 | |
--- /dev/null | |
+++ b/package/kernel/nat46/patches/122-kernel-6.12.patch | |
@@ -0,0 +1,346 @@ | |
+--- a/nat46/modules/nat46-core.c | |
++++ b/nat46/modules/nat46-core.c | |
+@@ -209,7 +209,7 @@ static inline void nat46_swap(nat46_xlat | |
+ /* | |
+ * Sort rule pairs based on prefix length. | |
+ */ | |
+-void nat46_sort_rule_array(nat46_instance_t *nat46) { | |
++static void nat46_sort_rule_array(nat46_instance_t *nat46) { | |
+ int i, j; | |
+ int nelem = nat46->npairs; | |
+ nat46_xlate_rulepair_t *array = NULL; | |
+@@ -256,7 +256,7 @@ void nat46_sort_rule_array(nat46_instanc | |
+ } | |
+ } | |
+ | |
+-bool nat46_validate_RFC6052_style(nat46_instance_t *nat46, nat46_xlate_rule_t rule) | |
++static bool nat46_validate_RFC6052_style(nat46_instance_t *nat46, nat46_xlate_rule_t rule) | |
+ { | |
+ if (rule.style == NAT46_XLATE_RFC6052) { | |
+ if (!((rule.v6_pref_len == 32) || (rule.v6_pref_len == 40) || | |
+@@ -269,7 +269,7 @@ bool nat46_validate_RFC6052_style(nat46_ | |
+ return true; | |
+ } | |
+ | |
+-bool nat46_validate_MAP_style(nat46_instance_t *nat46, nat46_xlate_rule_t rule) | |
++static bool nat46_validate_MAP_style(nat46_instance_t *nat46, nat46_xlate_rule_t rule) | |
+ { | |
+ int psid_len; | |
+ if (rule.style == NAT46_XLATE_MAP) { | |
+@@ -296,7 +296,7 @@ bool nat46_validate_MAP_style(nat46_inst | |
+ return true; | |
+ } | |
+ | |
+-int nat46_validate_ipair_config(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair) | |
++static int nat46_validate_ipair_config(nat46_instance_t *nat46, nat46_xlate_rulepair_t *apair) | |
+ { | |
+ if (!nat46_validate_RFC6052_style(nat46, apair->local)) { | |
+ return -1; | |
+@@ -999,7 +999,7 @@ static __sum16 csum_ipv6_unmagic(nat46_i | |
+ } | |
+ | |
+ /* Update UDP with incremental checksum */ | |
+-__sum16 csum_ipv6_udp_remagic(struct ipv6hdr *ip6hdr, u32 csum) { | |
++static __sum16 csum_ipv6_udp_remagic(struct ipv6hdr *ip6hdr, u32 csum) { | |
+ uint32_t sum; | |
+ sum = csum_partial(ip6hdr->saddr.s6_addr16, 2 * sizeof(ip6hdr->saddr), ~csum); | |
+ sum = ((sum >> 16) & 0xffff) + (sum & 0xffff); | |
+@@ -1008,7 +1008,7 @@ __sum16 csum_ipv6_udp_remagic(struct ipv | |
+ } | |
+ | |
+ /* Undo the IPv4 pseudoheader inclusion into the checksum */ | |
+-__sum16 csum_ipv4_unmagic(__be32 saddr, __be32 daddr, | |
++static __sum16 csum_ipv4_unmagic(__be32 saddr, __be32 daddr, | |
+ u32 csum) { | |
+ u32 s; | |
+ uint32_t addr_csum; | |
+@@ -1049,7 +1049,7 @@ static void *add_offset(void *ptr, u16 o | |
+ return (((char *)ptr)+offset); | |
+ } | |
+ | |
+-void fill_v6hdr_from_v4hdr(struct iphdr *iph, struct ipv6hdr *ip6h) { | |
++static void fill_v6hdr_from_v4hdr(struct iphdr *iph, struct ipv6hdr *ip6h) { | |
+ *((__be16 *)ip6h) = htons((6 << 12) | (iph->tos << 4)); /* Version, Traffic Class */ | |
+ memset(&(ip6h->flow_lbl), 0, sizeof(ip6h->flow_lbl)); /* Flowlabel */ | |
+ ip6h->payload_len = htons(ntohs(iph->tot_len) - IPV4HDRSIZE); | |
+@@ -1104,7 +1104,7 @@ static u16 rechecksum16(void *p, int cou | |
+ return csum; | |
+ } | |
+ | |
+-nat46_xlate_rulepair_t *nat46_lpm(nat46_instance_t *nat46, nat46_rule_type_t type, void *paddr) { | |
++static nat46_xlate_rulepair_t *nat46_lpm(nat46_instance_t *nat46, nat46_rule_type_t type, void *paddr) { | |
+ int ipair = 0; | |
+ nat46_xlate_rulepair_t *apair = NULL; | |
+ uint32_t mask = 0; | |
+@@ -1567,6 +1567,135 @@ static int ip6_input_not_interested(nat4 | |
+ return 0; | |
+ } | |
+ | |
++/* | |
++ * The sport & dport in inner header will be dport & sport of the outer header, respectively. | |
++ * Hence, dest. and source ips of inner header will be found in local & remote rules, respectively. | |
++ */ | |
++static int pairs_xlate_v4_to_v6_inner(nat46_instance_t *nat46, struct iphdr *iph, | |
++ uint16_t sport, uint16_t dport, void *v6saddr, void *v6daddr) { | |
++ int ipair = 0; | |
++ nat46_xlate_rulepair_t *apair = NULL; | |
++ int xlate_src = -1; | |
++ int xlate_dst = -1; | |
++ | |
++ apair = nat46_lpm(nat46, NAT46_IPV4_REMOTE, &iph->saddr); | |
++ if (!apair) { | |
++ return 0; | |
++ } | |
++ | |
++ if (xlate_v4_to_v6(nat46, &apair->local, &iph->daddr, v6daddr, &dport)) { | |
++ nat46debug(3, "Dst addr %pI4 to %pI6 \n", &iph->daddr, v6daddr); | |
++ xlate_dst = ipair; | |
++ } | |
++ if (xlate_v4_to_v6(nat46, &apair->remote, &iph->saddr, v6saddr, &sport)) { | |
++ nat46debug(3, "Src addr %pI4 to %pI6 \n", &iph->saddr, v6saddr); | |
++ xlate_src = ipair; | |
++ } | |
++ if ((xlate_src >= 0) && (xlate_dst >= 0)) { | |
++ /* we did manage to translate it */ | |
++ nat46debug(5, "[nat46] Inner header xlate results: src %d dst %d", xlate_src, xlate_dst); | |
++ return 1; | |
++ } else { | |
++ nat46debug(1, "[nat46] Could not find a translation pair v4->v6"); | |
++ } | |
++ | |
++ return 0; | |
++} | |
++ | |
++static uint16_t xlate_pkt_in_err_v4_to_v6(nat46_instance_t *nat46, struct iphdr *iph, | |
++ struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport) { | |
++ struct ipv6hdr ip6h; | |
++ char v6saddr[16], v6daddr[16]; | |
++ uint16_t temp_port = 0; | |
++ int ret = 0; | |
++ struct icmphdr *icmph = (struct icmphdr *)(iph + 1); | |
++ struct iphdr *iiph = (struct iphdr *)(icmph + 1); | |
++ | |
++ switch (iiph->protocol) { | |
++ case IPPROTO_TCP: { | |
++ struct tcphdr *th = (struct tcphdr *)(iiph + 1); | |
++ *sport = th->source; | |
++ *dport = th->dest; | |
++ iiph->protocol = NEXTHDR_TCP; | |
++ break; | |
++ } | |
++ case IPPROTO_UDP: { | |
++ struct udphdr *udp = (struct udphdr *)(iiph + 1); | |
++ *sport = udp->source; | |
++ *dport = udp->dest; | |
++ iiph->protocol = NEXTHDR_UDP; | |
++ break; | |
++ } | |
++ case IPPROTO_ICMP: { | |
++ struct icmphdr *icmph = (struct icmphdr *)(iiph + 1); | |
++ iiph->protocol = NEXTHDR_ICMP; | |
++ switch (icmph->type) { | |
++ case ICMP_ECHO: | |
++ icmph->type = ICMPV6_ECHO_REQUEST; | |
++ *sport = *dport = icmph->un.echo.id; | |
++ break; | |
++ case ICMP_ECHOREPLY: | |
++ icmph->type = ICMPV6_ECHO_REPLY; | |
++ *sport = *dport = icmph->un.echo.id; | |
++ break; | |
++ default: | |
++ nat46debug(3, "ICMP Error message can't be inside another ICMP Error messgae."); | |
++ *sport = *dport = 0; | |
++ return 0; | |
++ } | |
++ break; | |
++ } | |
++ default: | |
++ nat46debug(3, "[ICMPv4] Next header: %u. Only TCP, UDP, and ICMP are supported.", iiph->protocol); | |
++ *sport = *dport = 0; | |
++ return 0; | |
++ } | |
++ | |
++ nat46debug(3, "Retrieved from pkt in error: dest port %d, and src port %d.", ntohs(*dport), ntohs(*sport)); | |
++ | |
++ if (!pairs_xlate_v4_to_v6_inner(nat46, iiph, *sport, *dport, v6saddr, v6daddr)) { | |
++ nat46debug(0, "[nat46] Could not translate inner header v4->v6"); | |
++ *sport = *dport = 0; | |
++ return 0; | |
++ } | |
++ | |
++ fill_v6hdr_from_v4hdr (iiph, &ip6h); | |
++ memcpy(&ip6h.saddr, v6saddr, sizeof(ip6h.saddr)); | |
++ memcpy(&ip6h.daddr, v6daddr, sizeof(ip6h.daddr)); | |
++ | |
++ if (skb_tailroom(old_skb) >= IPV6V4HDRDELTA){ | |
++ skb_put(old_skb, IPV6V4HDRDELTA); | |
++ /* ErrorICMP size is less than 576, the inner ipv4 packet will be trimmed */ | |
++ memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1), | |
++ ntohs(iph->tot_len) - 2 * IPV4HDRSIZE - sizeof(struct icmphdr)); | |
++ memcpy(iiph, &ip6h, IPV6HDRSIZE); | |
++ } | |
++ else { | |
++ ret = pskb_expand_head(old_skb, 0, IPV6V4HDRDELTA, GFP_ATOMIC); | |
++ if (unlikely(ret)) { | |
++ nat46debug(0, "[nat46] Could not copy v4 skb"); | |
++ *sport = *dport = 0; | |
++ return 0; | |
++ } | |
++ | |
++ skb_put(old_skb, IPV6V4HDRDELTA); | |
++ iiph = (struct iphdr *)(icmp_hdr(old_skb) + 1); | |
++ /* ErrorICMP size is less than 576, the inner ipv4 packet will be trimmed */ | |
++ memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1), | |
++ ntohs(iph->tot_len) - 2 * IPV4HDRSIZE - sizeof(struct icmphdr)); | |
++ memcpy(iiph, &ip6h, IPV6HDRSIZE); | |
++ } | |
++ iph->tot_len = htons(ntohs(iph->tot_len) + IPV6V4HDRDELTA); | |
++ | |
++ /* Swapping Ports for outer header */ | |
++ /* Another work-around till LPM is not present. */ | |
++ temp_port = *sport; | |
++ *sport = *dport; | |
++ *dport = temp_port; | |
++ | |
++ return 1; | |
++} | |
++ | |
+ static uint16_t nat46_fixup_icmp_time_exceeded(nat46_instance_t *nat46, struct iphdr *iph, | |
+ struct icmphdr *icmph, struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport) { | |
+ /* | |
+@@ -2187,135 +2316,6 @@ int xlate_4_to_6(struct net_device *dev, | |
+ } | |
+ EXPORT_SYMBOL(xlate_4_to_6); | |
+ | |
+-/* | |
+- * The sport & dport in inner header will be dport & sport of the outer header, respectively. | |
+- * Hence, dest. and source ips of inner header will be found in local & remote rules, respectively. | |
+- */ | |
+-int pairs_xlate_v4_to_v6_inner(nat46_instance_t *nat46, struct iphdr *iph, | |
+- uint16_t sport, uint16_t dport, void *v6saddr, void *v6daddr) { | |
+- int ipair = 0; | |
+- nat46_xlate_rulepair_t *apair = NULL; | |
+- int xlate_src = -1; | |
+- int xlate_dst = -1; | |
+- | |
+- apair = nat46_lpm(nat46, NAT46_IPV4_REMOTE, &iph->saddr); | |
+- if (!apair) { | |
+- return 0; | |
+- } | |
+- | |
+- if (xlate_v4_to_v6(nat46, &apair->local, &iph->daddr, v6daddr, &dport)) { | |
+- nat46debug(3, "Dst addr %pI4 to %pI6 \n", &iph->daddr, v6daddr); | |
+- xlate_dst = ipair; | |
+- } | |
+- if (xlate_v4_to_v6(nat46, &apair->remote, &iph->saddr, v6saddr, &sport)) { | |
+- nat46debug(3, "Src addr %pI4 to %pI6 \n", &iph->saddr, v6saddr); | |
+- xlate_src = ipair; | |
+- } | |
+- if ((xlate_src >= 0) && (xlate_dst >= 0)) { | |
+- /* we did manage to translate it */ | |
+- nat46debug(5, "[nat46] Inner header xlate results: src %d dst %d", xlate_src, xlate_dst); | |
+- return 1; | |
+- } else { | |
+- nat46debug(1, "[nat46] Could not find a translation pair v4->v6"); | |
+- } | |
+- | |
+- return 0; | |
+-} | |
+- | |
+-static uint16_t xlate_pkt_in_err_v4_to_v6(nat46_instance_t *nat46, struct iphdr *iph, | |
+- struct sk_buff *old_skb, uint16_t *sport, uint16_t *dport) { | |
+- struct ipv6hdr ip6h; | |
+- char v6saddr[16], v6daddr[16]; | |
+- uint16_t temp_port = 0; | |
+- int ret = 0; | |
+- struct icmphdr *icmph = (struct icmphdr *)(iph + 1); | |
+- struct iphdr *iiph = (struct iphdr *)(icmph + 1); | |
+- | |
+- switch (iiph->protocol) { | |
+- case IPPROTO_TCP: { | |
+- struct tcphdr *th = (struct tcphdr *)(iiph + 1); | |
+- *sport = th->source; | |
+- *dport = th->dest; | |
+- iiph->protocol = NEXTHDR_TCP; | |
+- break; | |
+- } | |
+- case IPPROTO_UDP: { | |
+- struct udphdr *udp = (struct udphdr *)(iiph + 1); | |
+- *sport = udp->source; | |
+- *dport = udp->dest; | |
+- iiph->protocol = NEXTHDR_UDP; | |
+- break; | |
+- } | |
+- case IPPROTO_ICMP: { | |
+- struct icmphdr *icmph = (struct icmphdr *)(iiph + 1); | |
+- iiph->protocol = NEXTHDR_ICMP; | |
+- switch (icmph->type) { | |
+- case ICMP_ECHO: | |
+- icmph->type = ICMPV6_ECHO_REQUEST; | |
+- *sport = *dport = icmph->un.echo.id; | |
+- break; | |
+- case ICMP_ECHOREPLY: | |
+- icmph->type = ICMPV6_ECHO_REPLY; | |
+- *sport = *dport = icmph->un.echo.id; | |
+- break; | |
+- default: | |
+- nat46debug(3, "ICMP Error message can't be inside another ICMP Error messgae."); | |
+- *sport = *dport = 0; | |
+- return 0; | |
+- } | |
+- break; | |
+- } | |
+- default: | |
+- nat46debug(3, "[ICMPv4] Next header: %u. Only TCP, UDP, and ICMP are supported.", iiph->protocol); | |
+- *sport = *dport = 0; | |
+- return 0; | |
+- } | |
+- | |
+- nat46debug(3, "Retrieved from pkt in error: dest port %d, and src port %d.", ntohs(*dport), ntohs(*sport)); | |
+- | |
+- if (!pairs_xlate_v4_to_v6_inner(nat46, iiph, *sport, *dport, v6saddr, v6daddr)) { | |
+- nat46debug(0, "[nat46] Could not translate inner header v4->v6"); | |
+- *sport = *dport = 0; | |
+- return 0; | |
+- } | |
+- | |
+- fill_v6hdr_from_v4hdr (iiph, &ip6h); | |
+- memcpy(&ip6h.saddr, v6saddr, sizeof(ip6h.saddr)); | |
+- memcpy(&ip6h.daddr, v6daddr, sizeof(ip6h.daddr)); | |
+- | |
+- if (skb_tailroom(old_skb) >= IPV6V4HDRDELTA){ | |
+- skb_put(old_skb, IPV6V4HDRDELTA); | |
+- /* ErrorICMP size is less than 576, the inner ipv4 packet will be trimmed */ | |
+- memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1), | |
+- ntohs(iph->tot_len) - 2 * IPV4HDRSIZE - sizeof(struct icmphdr)); | |
+- memcpy(iiph, &ip6h, IPV6HDRSIZE); | |
+- } | |
+- else { | |
+- ret = pskb_expand_head(old_skb, 0, IPV6V4HDRDELTA, GFP_ATOMIC); | |
+- if (unlikely(ret)) { | |
+- nat46debug(0, "[nat46] Could not copy v4 skb"); | |
+- *sport = *dport = 0; | |
+- return 0; | |
+- } | |
+- | |
+- skb_put(old_skb, IPV6V4HDRDELTA); | |
+- iiph = (struct iphdr *)(icmp_hdr(old_skb) + 1); | |
+- /* ErrorICMP size is less than 576, the inner ipv4 packet will be trimmed */ | |
+- memmove(((char *)iiph + IPV6HDRSIZE), (iiph + 1), | |
+- ntohs(iph->tot_len) - 2 * IPV4HDRSIZE - sizeof(struct icmphdr)); | |
+- memcpy(iiph, &ip6h, IPV6HDRSIZE); | |
+- } | |
+- iph->tot_len = htons(ntohs(iph->tot_len) + IPV6V4HDRDELTA); | |
+- | |
+- /* Swapping Ports for outer header */ | |
+- /* Another work-around till LPM is not present. */ | |
+- temp_port = *sport; | |
+- *sport = *dport; | |
+- *dport = temp_port; | |
+- | |
+- return 1; | |
+-} | |
+- | |
+ /* Return the port number from CE's port set */ | |
+ static uint16_t nat46_get_ce_port(nat46_xlate_rulepair_t *pair, uint16_t sport) | |
+ { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment