mtd: fix build with GCC 14
[openwrt/openwrt.git] / target / linux / generic / pending-6.1 / 666-Add-support-for-MAP-E-FMRs-mesh-mode.patch
1 From: Steven Barth <steven@midlink.org>
2 Subject: Add support for MAP-E FMRs (mesh mode)
3
4 MAP-E FMRs (draft-ietf-softwire-map-10) are rules for IPv4-communication
5 between MAP CEs (mesh mode) without the need to forward such data to a
6 border relay. This is similar to how 6rd works but for IPv4 over IPv6.
7
8 Signed-off-by: Steven Barth <cyrus@openwrt.org>
9 ---
10 include/net/ip6_tunnel.h | 13 ++
11 include/uapi/linux/if_tunnel.h | 13 ++
12 net/ipv6/ip6_tunnel.c | 276 +++++++++++++++++++++++++++++++++++++++--
13 3 files changed, 291 insertions(+), 11 deletions(-)
14
15 --- a/include/net/ip6_tunnel.h
16 +++ b/include/net/ip6_tunnel.h
17 @@ -18,6 +18,18 @@
18 /* determine capability on a per-packet basis */
19 #define IP6_TNL_F_CAP_PER_PACKET 0x40000
20
21 +/* IPv6 tunnel FMR */
22 +struct __ip6_tnl_fmr {
23 + struct __ip6_tnl_fmr *next; /* next fmr in list */
24 + struct in6_addr ip6_prefix;
25 + struct in_addr ip4_prefix;
26 +
27 + __u8 ip6_prefix_len;
28 + __u8 ip4_prefix_len;
29 + __u8 ea_len;
30 + __u8 offset;
31 +};
32 +
33 struct __ip6_tnl_parm {
34 char name[IFNAMSIZ]; /* name of tunnel device */
35 int link; /* ifindex of underlying L2 interface */
36 @@ -29,6 +41,7 @@ struct __ip6_tnl_parm {
37 __u32 flags; /* tunnel flags */
38 struct in6_addr laddr; /* local tunnel end-point address */
39 struct in6_addr raddr; /* remote tunnel end-point address */
40 + struct __ip6_tnl_fmr *fmrs; /* FMRs */
41
42 __be16 i_flags;
43 __be16 o_flags;
44 --- a/include/uapi/linux/if_tunnel.h
45 +++ b/include/uapi/linux/if_tunnel.h
46 @@ -77,10 +77,23 @@ enum {
47 IFLA_IPTUN_ENCAP_DPORT,
48 IFLA_IPTUN_COLLECT_METADATA,
49 IFLA_IPTUN_FWMARK,
50 + IFLA_IPTUN_FMRS,
51 __IFLA_IPTUN_MAX,
52 };
53 #define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1)
54
55 +enum {
56 + IFLA_IPTUN_FMR_UNSPEC,
57 + IFLA_IPTUN_FMR_IP6_PREFIX,
58 + IFLA_IPTUN_FMR_IP4_PREFIX,
59 + IFLA_IPTUN_FMR_IP6_PREFIX_LEN,
60 + IFLA_IPTUN_FMR_IP4_PREFIX_LEN,
61 + IFLA_IPTUN_FMR_EA_LEN,
62 + IFLA_IPTUN_FMR_OFFSET,
63 + __IFLA_IPTUN_FMR_MAX,
64 +};
65 +#define IFLA_IPTUN_FMR_MAX (__IFLA_IPTUN_FMR_MAX - 1)
66 +
67 enum tunnel_encap_types {
68 TUNNEL_ENCAP_NONE,
69 TUNNEL_ENCAP_FOU,
70 --- a/net/ipv6/ip6_tunnel.c
71 +++ b/net/ipv6/ip6_tunnel.c
72 @@ -11,6 +11,9 @@
73 * linux/net/ipv6/sit.c and linux/net/ipv4/ipip.c
74 *
75 * RFC 2473
76 + *
77 + * Changes:
78 + * Steven Barth <cyrus@openwrt.org>: MAP-E FMR support
79 */
80
81 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
82 @@ -67,9 +70,9 @@ static bool log_ecn_error = true;
83 module_param(log_ecn_error, bool, 0644);
84 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
85
86 -static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87 +static u32 HASH(const struct in6_addr *addr)
88 {
89 - u32 hash = ipv6_addr_hash(addr1) ^ ipv6_addr_hash(addr2);
90 + u32 hash = ipv6_addr_hash(addr);
91
92 return hash_32(hash, IP6_TUNNEL_HASH_SIZE_SHIFT);
93 }
94 @@ -114,17 +117,33 @@ static struct ip6_tnl *
95 ip6_tnl_lookup(struct net *net, int link,
96 const struct in6_addr *remote, const struct in6_addr *local)
97 {
98 - unsigned int hash = HASH(remote, local);
99 + unsigned int hash = HASH(local);
100 struct ip6_tnl *t, *cand = NULL;
101 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
102 struct in6_addr any;
103
104 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
105 if (!ipv6_addr_equal(local, &t->parms.laddr) ||
106 - !ipv6_addr_equal(remote, &t->parms.raddr) ||
107 !(t->dev->flags & IFF_UP))
108 continue;
109
110 + if (!ipv6_addr_equal(remote, &t->parms.raddr)) {
111 + struct __ip6_tnl_fmr *fmr;
112 + bool found = false;
113 +
114 + for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) {
115 + if (!ipv6_prefix_equal(remote, &fmr->ip6_prefix,
116 + fmr->ip6_prefix_len))
117 + continue;
118 +
119 + found = true;
120 + break;
121 + }
122 +
123 + if (!found)
124 + continue;
125 + }
126 +
127 if (link == t->parms.link)
128 return t;
129 else
130 @@ -132,7 +151,7 @@ ip6_tnl_lookup(struct net *net, int link
131 }
132
133 memset(&any, 0, sizeof(any));
134 - hash = HASH(&any, local);
135 + hash = HASH(local);
136 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
137 if (!ipv6_addr_equal(local, &t->parms.laddr) ||
138 !ipv6_addr_any(&t->parms.raddr) ||
139 @@ -145,7 +164,7 @@ ip6_tnl_lookup(struct net *net, int link
140 cand = t;
141 }
142
143 - hash = HASH(remote, &any);
144 + hash = HASH(&any);
145 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
146 if (!ipv6_addr_equal(remote, &t->parms.raddr) ||
147 !ipv6_addr_any(&t->parms.laddr) ||
148 @@ -194,7 +213,7 @@ ip6_tnl_bucket(struct ip6_tnl_net *ip6n,
149
150 if (!ipv6_addr_any(remote) || !ipv6_addr_any(local)) {
151 prio = 1;
152 - h = HASH(remote, local);
153 + h = HASH(local);
154 }
155 return &ip6n->tnls[prio][h];
156 }
157 @@ -376,6 +395,12 @@ ip6_tnl_dev_uninit(struct net_device *de
158 struct net *net = t->net;
159 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
160
161 + while (t->parms.fmrs) {
162 + struct __ip6_tnl_fmr *next = t->parms.fmrs->next;
163 + kfree(t->parms.fmrs);
164 + t->parms.fmrs = next;
165 + }
166 +
167 if (dev == ip6n->fb_tnl_dev)
168 RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL);
169 else
170 @@ -788,6 +813,107 @@ int ip6_tnl_rcv_ctl(struct ip6_tnl *t,
171 }
172 EXPORT_SYMBOL_GPL(ip6_tnl_rcv_ctl);
173
174 +/**
175 + * ip4ip6_fmr_calc - calculate target / source IPv6-address based on FMR
176 + * @dest: destination IPv6 address buffer
177 + * @skb: received socket buffer
178 + * @fmr: MAP FMR
179 + * @xmit: Calculate for xmit or rcv
180 + **/
181 +static void ip4ip6_fmr_calc(struct in6_addr *dest,
182 + const struct iphdr *iph, const uint8_t *end,
183 + const struct __ip6_tnl_fmr *fmr, bool xmit)
184 +{
185 + int psidlen = fmr->ea_len - (32 - fmr->ip4_prefix_len);
186 + u8 *portp = NULL;
187 + bool use_dest_addr;
188 + const struct iphdr *dsth = iph;
189 +
190 + if ((u8*)dsth >= end)
191 + return;
192 +
193 + /* find significant IP header */
194 + if (iph->protocol == IPPROTO_ICMP) {
195 + struct icmphdr *ih = (struct icmphdr*)(((u8*)dsth) + dsth->ihl * 4);
196 + if (ih && ((u8*)&ih[1]) <= end && (
197 + ih->type == ICMP_DEST_UNREACH ||
198 + ih->type == ICMP_SOURCE_QUENCH ||
199 + ih->type == ICMP_TIME_EXCEEDED ||
200 + ih->type == ICMP_PARAMETERPROB ||
201 + ih->type == ICMP_REDIRECT))
202 + dsth = (const struct iphdr*)&ih[1];
203 + }
204 +
205 + /* in xmit-path use dest port by default and source port only if
206 + this is an ICMP reply to something else; vice versa in rcv-path */
207 + use_dest_addr = (xmit && dsth == iph) || (!xmit && dsth != iph);
208 +
209 + /* get dst port */
210 + if (((u8*)&dsth[1]) <= end && (
211 + dsth->protocol == IPPROTO_UDP ||
212 + dsth->protocol == IPPROTO_TCP ||
213 + dsth->protocol == IPPROTO_SCTP ||
214 + dsth->protocol == IPPROTO_DCCP)) {
215 + /* for UDP, TCP, SCTP and DCCP source and dest port
216 + follow IPv4 header directly */
217 + portp = ((u8*)dsth) + dsth->ihl * 4;
218 +
219 + if (use_dest_addr)
220 + portp += sizeof(u16);
221 + } else if (iph->protocol == IPPROTO_ICMP) {
222 + struct icmphdr *ih = (struct icmphdr*)(((u8*)dsth) + dsth->ihl * 4);
223 +
224 + /* use icmp identifier as port */
225 + if (((u8*)&ih) <= end && (
226 + (use_dest_addr && (
227 + ih->type == ICMP_ECHOREPLY ||
228 + ih->type == ICMP_TIMESTAMPREPLY ||
229 + ih->type == ICMP_INFO_REPLY ||
230 + ih->type == ICMP_ADDRESSREPLY)) ||
231 + (!use_dest_addr && (
232 + ih->type == ICMP_ECHO ||
233 + ih->type == ICMP_TIMESTAMP ||
234 + ih->type == ICMP_INFO_REQUEST ||
235 + ih->type == ICMP_ADDRESS)
236 + )))
237 + portp = (u8*)&ih->un.echo.id;
238 + }
239 +
240 + if ((portp && &portp[2] <= end) || psidlen == 0) {
241 + int frombyte = fmr->ip6_prefix_len / 8;
242 + int fromrem = fmr->ip6_prefix_len % 8;
243 + int bytes = sizeof(struct in6_addr) - frombyte;
244 + const u32 *addr = (use_dest_addr) ? &iph->daddr : &iph->saddr;
245 + u64 eabits = ((u64)ntohl(*addr)) << (32 + fmr->ip4_prefix_len);
246 + u64 t = 0;
247 +
248 + /* extract PSID from port and add it to eabits */
249 + u16 psidbits = 0;
250 + if (psidlen > 0) {
251 + psidbits = ((u16)portp[0]) << 8 | ((u16)portp[1]);
252 + psidbits >>= 16 - psidlen - fmr->offset;
253 + psidbits = (u16)(psidbits << (16 - psidlen));
254 + eabits |= ((u64)psidbits) << (48 - (fmr->ea_len - psidlen));
255 + }
256 +
257 + /* rewrite destination address */
258 + *dest = fmr->ip6_prefix;
259 + memcpy(&dest->s6_addr[10], addr, sizeof(*addr));
260 + dest->s6_addr16[7] = htons(psidbits >> (16 - psidlen));
261 +
262 + if (bytes > sizeof(u64))
263 + bytes = sizeof(u64);
264 +
265 + /* insert eabits */
266 + memcpy(&t, &dest->s6_addr[frombyte], bytes);
267 + t = be64_to_cpu(t) & ~(((((u64)1) << fmr->ea_len) - 1)
268 + << (64 - fmr->ea_len - fromrem));
269 + t = cpu_to_be64(t | (eabits >> fromrem));
270 + memcpy(&dest->s6_addr[frombyte], &t, bytes);
271 + }
272 +}
273 +
274 +
275 static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
276 const struct tnl_ptk_info *tpi,
277 struct metadata_dst *tun_dst,
278 @@ -855,6 +981,27 @@ static int __ip6_tnl_rcv(struct ip6_tnl
279
280 memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
281
282 + if (tpi->proto == htons(ETH_P_IP) && tunnel->parms.fmrs &&
283 + !ipv6_addr_equal(&ipv6h->saddr, &tunnel->parms.raddr)) {
284 + /* Packet didn't come from BR, so lookup FMR */
285 + struct __ip6_tnl_fmr *fmr;
286 + struct in6_addr expected = tunnel->parms.raddr;
287 + for (fmr = tunnel->parms.fmrs; fmr; fmr = fmr->next)
288 + if (ipv6_prefix_equal(&ipv6h->saddr,
289 + &fmr->ip6_prefix, fmr->ip6_prefix_len))
290 + break;
291 +
292 + /* Check that IPv6 matches IPv4 source to prevent spoofing */
293 + if (fmr)
294 + ip4ip6_fmr_calc(&expected, ip_hdr(skb),
295 + skb_tail_pointer(skb), fmr, false);
296 +
297 + if (!ipv6_addr_equal(&ipv6h->saddr, &expected)) {
298 + rcu_read_unlock();
299 + goto drop;
300 + }
301 + }
302 +
303 __skb_tunnel_rx(skb, tunnel->dev, tunnel->net);
304
305 err = dscp_ecn_decapsulate(tunnel, ipv6h, skb);
306 @@ -1002,6 +1149,7 @@ static void init_tel_txopt(struct ipv6_t
307 opt->ops.opt_nflen = 8;
308 }
309
310 +
311 /**
312 * ip6_tnl_addr_conflict - compare packet addresses to tunnel's own
313 * @t: the outgoing tunnel device
314 @@ -1293,6 +1441,7 @@ ipxip6_tnl_xmit(struct sk_buff *skb, str
315 u8 protocol)
316 {
317 struct ip6_tnl *t = netdev_priv(dev);
318 + struct __ip6_tnl_fmr *fmr;
319 struct ipv6hdr *ipv6h;
320 const struct iphdr *iph;
321 int encap_limit = -1;
322 @@ -1392,6 +1541,18 @@ ipxip6_tnl_xmit(struct sk_buff *skb, str
323 fl6.flowi6_uid = sock_net_uid(dev_net(dev), NULL);
324 dsfield = INET_ECN_encapsulate(dsfield, orig_dsfield);
325
326 + /* try to find matching FMR */
327 + for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) {
328 + unsigned mshift = 32 - fmr->ip4_prefix_len;
329 + if (ntohl(fmr->ip4_prefix.s_addr) >> mshift ==
330 + ntohl(ip_hdr(skb)->daddr) >> mshift)
331 + break;
332 + }
333 +
334 + /* change dstaddr according to FMR */
335 + if (fmr)
336 + ip4ip6_fmr_calc(&fl6.daddr, ip_hdr(skb), skb_tail_pointer(skb), fmr, true);
337 +
338 if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6))
339 return -1;
340
341 @@ -1545,6 +1706,14 @@ ip6_tnl_change(struct ip6_tnl *t, const
342 t->parms.link = p->link;
343 t->parms.proto = p->proto;
344 t->parms.fwmark = p->fwmark;
345 +
346 + while (t->parms.fmrs) {
347 + struct __ip6_tnl_fmr *next = t->parms.fmrs->next;
348 + kfree(t->parms.fmrs);
349 + t->parms.fmrs = next;
350 + }
351 + t->parms.fmrs = p->fmrs;
352 +
353 dst_cache_reset(&t->dst_cache);
354 ip6_tnl_link_config(t);
355 }
356 @@ -1579,6 +1748,7 @@ ip6_tnl_parm_from_user(struct __ip6_tnl_
357 p->flowinfo = u->flowinfo;
358 p->link = u->link;
359 p->proto = u->proto;
360 + p->fmrs = NULL;
361 memcpy(p->name, u->name, sizeof(u->name));
362 }
363
364 @@ -1965,6 +2135,15 @@ static int ip6_tnl_validate(struct nlatt
365 return 0;
366 }
367
368 +static const struct nla_policy ip6_tnl_fmr_policy[IFLA_IPTUN_FMR_MAX + 1] = {
369 + [IFLA_IPTUN_FMR_IP6_PREFIX] = { .len = sizeof(struct in6_addr) },
370 + [IFLA_IPTUN_FMR_IP4_PREFIX] = { .len = sizeof(struct in_addr) },
371 + [IFLA_IPTUN_FMR_IP6_PREFIX_LEN] = { .type = NLA_U8 },
372 + [IFLA_IPTUN_FMR_IP4_PREFIX_LEN] = { .type = NLA_U8 },
373 + [IFLA_IPTUN_FMR_EA_LEN] = { .type = NLA_U8 },
374 + [IFLA_IPTUN_FMR_OFFSET] = { .type = NLA_U8 }
375 +};
376 +
377 static void ip6_tnl_netlink_parms(struct nlattr *data[],
378 struct __ip6_tnl_parm *parms)
379 {
380 @@ -2002,6 +2181,46 @@ static void ip6_tnl_netlink_parms(struct
381
382 if (data[IFLA_IPTUN_FWMARK])
383 parms->fwmark = nla_get_u32(data[IFLA_IPTUN_FWMARK]);
384 +
385 + if (data[IFLA_IPTUN_FMRS]) {
386 + unsigned rem;
387 + struct nlattr *fmr;
388 + nla_for_each_nested(fmr, data[IFLA_IPTUN_FMRS], rem) {
389 + struct nlattr *fmrd[IFLA_IPTUN_FMR_MAX + 1], *c;
390 + struct __ip6_tnl_fmr *nfmr;
391 +
392 + nla_parse_nested(fmrd, IFLA_IPTUN_FMR_MAX,
393 + fmr, ip6_tnl_fmr_policy, NULL);
394 +
395 + if (!(nfmr = kzalloc(sizeof(*nfmr), GFP_KERNEL)))
396 + continue;
397 +
398 + nfmr->offset = 6;
399 +
400 + if ((c = fmrd[IFLA_IPTUN_FMR_IP6_PREFIX]))
401 + nla_memcpy(&nfmr->ip6_prefix, fmrd[IFLA_IPTUN_FMR_IP6_PREFIX],
402 + sizeof(nfmr->ip6_prefix));
403 +
404 + if ((c = fmrd[IFLA_IPTUN_FMR_IP4_PREFIX]))
405 + nla_memcpy(&nfmr->ip4_prefix, fmrd[IFLA_IPTUN_FMR_IP4_PREFIX],
406 + sizeof(nfmr->ip4_prefix));
407 +
408 + if ((c = fmrd[IFLA_IPTUN_FMR_IP6_PREFIX_LEN]))
409 + nfmr->ip6_prefix_len = nla_get_u8(c);
410 +
411 + if ((c = fmrd[IFLA_IPTUN_FMR_IP4_PREFIX_LEN]))
412 + nfmr->ip4_prefix_len = nla_get_u8(c);
413 +
414 + if ((c = fmrd[IFLA_IPTUN_FMR_EA_LEN]))
415 + nfmr->ea_len = nla_get_u8(c);
416 +
417 + if ((c = fmrd[IFLA_IPTUN_FMR_OFFSET]))
418 + nfmr->offset = nla_get_u8(c);
419 +
420 + nfmr->next = parms->fmrs;
421 + parms->fmrs = nfmr;
422 + }
423 + }
424 }
425
426 static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
427 @@ -2085,6 +2304,12 @@ static void ip6_tnl_dellink(struct net_d
428
429 static size_t ip6_tnl_get_size(const struct net_device *dev)
430 {
431 + const struct ip6_tnl *t = netdev_priv(dev);
432 + struct __ip6_tnl_fmr *c;
433 + int fmrs = 0;
434 + for (c = t->parms.fmrs; c; c = c->next)
435 + ++fmrs;
436 +
437 return
438 /* IFLA_IPTUN_LINK */
439 nla_total_size(4) +
440 @@ -2114,6 +2339,24 @@ static size_t ip6_tnl_get_size(const str
441 nla_total_size(0) +
442 /* IFLA_IPTUN_FWMARK */
443 nla_total_size(4) +
444 + /* IFLA_IPTUN_FMRS */
445 + nla_total_size(0) +
446 + (
447 + /* nest */
448 + nla_total_size(0) +
449 + /* IFLA_IPTUN_FMR_IP6_PREFIX */
450 + nla_total_size(sizeof(struct in6_addr)) +
451 + /* IFLA_IPTUN_FMR_IP4_PREFIX */
452 + nla_total_size(sizeof(struct in_addr)) +
453 + /* IFLA_IPTUN_FMR_EA_LEN */
454 + nla_total_size(1) +
455 + /* IFLA_IPTUN_FMR_IP6_PREFIX_LEN */
456 + nla_total_size(1) +
457 + /* IFLA_IPTUN_FMR_IP4_PREFIX_LEN */
458 + nla_total_size(1) +
459 + /* IFLA_IPTUN_FMR_OFFSET */
460 + nla_total_size(1)
461 + ) * fmrs +
462 0;
463 }
464
465 @@ -2121,6 +2364,9 @@ static int ip6_tnl_fill_info(struct sk_b
466 {
467 struct ip6_tnl *tunnel = netdev_priv(dev);
468 struct __ip6_tnl_parm *parm = &tunnel->parms;
469 + struct __ip6_tnl_fmr *c;
470 + int fmrcnt = 0;
471 + struct nlattr *fmrs;
472
473 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
474 nla_put_in6_addr(skb, IFLA_IPTUN_LOCAL, &parm->laddr) ||
475 @@ -2130,9 +2376,27 @@ static int ip6_tnl_fill_info(struct sk_b
476 nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) ||
477 nla_put_u32(skb, IFLA_IPTUN_FLAGS, parm->flags) ||
478 nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto) ||
479 - nla_put_u32(skb, IFLA_IPTUN_FWMARK, parm->fwmark))
480 + nla_put_u32(skb, IFLA_IPTUN_FWMARK, parm->fwmark) ||
481 + !(fmrs = nla_nest_start(skb, IFLA_IPTUN_FMRS)))
482 goto nla_put_failure;
483
484 + for (c = parm->fmrs; c; c = c->next) {
485 + struct nlattr *fmr = nla_nest_start(skb, ++fmrcnt);
486 + if (!fmr ||
487 + nla_put(skb, IFLA_IPTUN_FMR_IP6_PREFIX,
488 + sizeof(c->ip6_prefix), &c->ip6_prefix) ||
489 + nla_put(skb, IFLA_IPTUN_FMR_IP4_PREFIX,
490 + sizeof(c->ip4_prefix), &c->ip4_prefix) ||
491 + nla_put_u8(skb, IFLA_IPTUN_FMR_IP6_PREFIX_LEN, c->ip6_prefix_len) ||
492 + nla_put_u8(skb, IFLA_IPTUN_FMR_IP4_PREFIX_LEN, c->ip4_prefix_len) ||
493 + nla_put_u8(skb, IFLA_IPTUN_FMR_EA_LEN, c->ea_len) ||
494 + nla_put_u8(skb, IFLA_IPTUN_FMR_OFFSET, c->offset))
495 + goto nla_put_failure;
496 +
497 + nla_nest_end(skb, fmr);
498 + }
499 + nla_nest_end(skb, fmrs);
500 +
501 if (nla_put_u16(skb, IFLA_IPTUN_ENCAP_TYPE, tunnel->encap.type) ||
502 nla_put_be16(skb, IFLA_IPTUN_ENCAP_SPORT, tunnel->encap.sport) ||
503 nla_put_be16(skb, IFLA_IPTUN_ENCAP_DPORT, tunnel->encap.dport) ||
504 @@ -2172,6 +2436,7 @@ static const struct nla_policy ip6_tnl_p
505 [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 },
506 [IFLA_IPTUN_COLLECT_METADATA] = { .type = NLA_FLAG },
507 [IFLA_IPTUN_FWMARK] = { .type = NLA_U32 },
508 + [IFLA_IPTUN_FMRS] = { .type = NLA_NESTED },
509 };
510
511 static struct rtnl_link_ops ip6_link_ops __read_mostly = {