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