127 lines
4.3 KiB
Diff
127 lines
4.3 KiB
Diff
From 926028b718c2a79b02365698fbac658b2ec5d297 Mon Sep 17 00:00:00 2001
|
|
From: Ramkishan Gurjar <quic_rgurjar@quicinc.com>
|
|
Date: Tue, 3 Oct 2023 09:42:20 +0530
|
|
Subject: [PATCH 240/500] Squashed commit of the following:
|
|
|
|
commit cde5e3757488b6753036c3e31a124b25f50a93fd
|
|
Author: Ken Zhu <guigenz@codeaurora.org>
|
|
Date: Mon Mar 12 11:21:31 2018 -0700
|
|
|
|
linux: fix the memory is not clean after memmove
|
|
|
|
the memory won't be set to zero after memmove, set it
|
|
to zero.
|
|
|
|
Change-Id: I9996aa5fa56a41967e31ec4df9820932feec6256
|
|
Signed-off-by: Ken Zhu <guigenz@codeaurora.org>
|
|
|
|
commit a81e33134a7d14a8fb9e1f636b946affb2c8fc80
|
|
Author: Himanshu Joshi <himajosh@codeaurora.org>
|
|
Date: Fri Apr 24 12:12:10 2020 +0530
|
|
|
|
net: add draft03 specification support for tunipip6
|
|
|
|
draft03 of map-e is used in some environment, we add this supported
|
|
|
|
Change-Id: I81462632f0e6f2b5af0b1f8229c42572892c5972
|
|
Signed-off-by: Zhu Ken <guigenz@codeaurora.org>
|
|
|
|
Change-Id: I3569082ddbdf3f30b8ab273cb7dc9ab2bfbc886c
|
|
---
|
|
include/net/ip6_tunnel.h | 1 +
|
|
include/uapi/linux/if_tunnel.h | 1 +
|
|
net/ipv6/ip6_tunnel.c | 31 +++++++++++++++++++++++++++----
|
|
3 files changed, 29 insertions(+), 4 deletions(-)
|
|
|
|
--- a/include/net/ip6_tunnel.h
|
|
+++ b/include/net/ip6_tunnel.h
|
|
@@ -37,6 +37,7 @@ struct __ip6_tnl_parm {
|
|
__u8 encap_limit; /* encapsulation limit for tunnel */
|
|
__u8 hop_limit; /* hop limit for tunnel */
|
|
bool collect_md;
|
|
+ __u8 draft03; /* FMR using draft03 of map-e */
|
|
__be32 flowinfo; /* traffic class and flowlabel for tunnel */
|
|
__u32 flags; /* tunnel flags */
|
|
struct in6_addr laddr; /* local tunnel end-point address */
|
|
--- a/include/uapi/linux/if_tunnel.h
|
|
+++ b/include/uapi/linux/if_tunnel.h
|
|
@@ -78,6 +78,7 @@ enum {
|
|
IFLA_IPTUN_COLLECT_METADATA,
|
|
IFLA_IPTUN_FWMARK,
|
|
IFLA_IPTUN_FMRS,
|
|
+ IFLA_IPTUN_DRAFT03,
|
|
__IFLA_IPTUN_MAX,
|
|
};
|
|
#define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1)
|
|
--- a/net/ipv6/ip6_tunnel.c
|
|
+++ b/net/ipv6/ip6_tunnel.c
|
|
@@ -839,7 +839,7 @@ EXPORT_SYMBOL_GPL(ip6_tnl_rcv_ctl);
|
|
**/
|
|
static void ip4ip6_fmr_calc(struct in6_addr *dest,
|
|
const struct iphdr *iph, const uint8_t *end,
|
|
- const struct __ip6_tnl_fmr *fmr, bool xmit)
|
|
+ const struct __ip6_tnl_fmr *fmr, bool xmit, bool draft03)
|
|
{
|
|
int psidlen = fmr->ea_len - (32 - fmr->ip4_prefix_len);
|
|
u8 *portp = NULL;
|
|
@@ -927,10 +927,28 @@ static void ip4ip6_fmr_calc(struct in6_a
|
|
<< (64 - fmr->ea_len - fromrem));
|
|
t = cpu_to_be64(t | (eabits >> fromrem));
|
|
memcpy(&dest->s6_addr[frombyte], &t, bytes);
|
|
+ if (draft03) {
|
|
+ /**
|
|
+ * Draft03 IPv6 address format
|
|
+ * +--+---+---+---+---+---+---+---+---+
|
|
+ * |PL| 8 16 24 32 40 48 56 |
|
|
+ * +--+---+---+---+---+---+---+---+---+
|
|
+ * |64| u | IPv4 address |PSID |0 |
|
|
+ * +--+---+---+---+---+---+---+---+---+
|
|
+ * Final specification IPv6 address format
|
|
+ * +--+---+---+---+---+---+---+---+---+
|
|
+ * |PL| 8 16 24 32 40 48 56 |
|
|
+ * +--+---+---+---+---+---+---+---+---+
|
|
+ * |64| 0 | IPv4 address |PSID |
|
|
+ * +--+---+---+---+---+---+---+---+---+
|
|
+ * We need move last six Bytes 1 byte forward
|
|
+ */
|
|
+ memmove(&dest->s6_addr[9], &dest->s6_addr[10], 6);
|
|
+ dest->s6_addr[15] = 0;
|
|
+ }
|
|
}
|
|
}
|
|
|
|
-
|
|
static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
|
|
const struct tnl_ptk_info *tpi,
|
|
struct metadata_dst *tun_dst,
|
|
@@ -1011,7 +1029,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl
|
|
/* Check that IPv6 matches IPv4 source to prevent spoofing */
|
|
if (fmr)
|
|
ip4ip6_fmr_calc(&expected, ip_hdr(skb),
|
|
- skb_tail_pointer(skb), fmr, false);
|
|
+ skb_tail_pointer(skb), fmr, false,
|
|
+ tunnel->parms.draft03);
|
|
|
|
if (!ipv6_addr_equal(&ipv6h->saddr, &expected)) {
|
|
rcu_read_unlock();
|
|
@@ -1573,7 +1592,8 @@ ipxip6_tnl_xmit(struct sk_buff *skb, str
|
|
|
|
/* change dstaddr according to FMR */
|
|
if (fmr)
|
|
- ip4ip6_fmr_calc(&fl6.daddr, ip_hdr(skb), skb_tail_pointer(skb), fmr, true);
|
|
+ ip4ip6_fmr_calc(&fl6.daddr, ip_hdr(skb), skb_tail_pointer(skb), fmr,
|
|
+ true, t->parms.draft03);
|
|
}
|
|
|
|
if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6))
|
|
@@ -2207,6 +2227,9 @@ static void ip6_tnl_netlink_parms(struct
|
|
if (data[IFLA_IPTUN_FWMARK])
|
|
parms->fwmark = nla_get_u32(data[IFLA_IPTUN_FWMARK]);
|
|
|
|
+ if (data[IFLA_IPTUN_DRAFT03])
|
|
+ parms->draft03 = nla_get_u8(data[IFLA_IPTUN_DRAFT03]);
|
|
+
|
|
if (data[IFLA_IPTUN_FMRS]) {
|
|
unsigned rem;
|
|
struct nlattr *fmr;
|