at 15.09-beta 616 lines 18 kB view raw
1From f3c956096902669c3529cb01d40deb0c759ed94f Mon Sep 17 00:00:00 2001 2From: Jay Vosburgh <jay.vosburgh@canonical.com> 3Date: Wed, 1 Apr 2015 16:11:09 -0700 4Subject: [PATCH] UBUNTU: SAUCE: fan: Proof of concept implementation (v2) 5 6Modification to ipip tunnel driver to accept a new netlink option, 7IFLA_IPTUN_FAN_UNDERLAY, which provides a /16 network prefix and enables 8TX side destination address remapping for traffic entering the tunnel 9(to be encapsulated). 10 11For an overlay (inner) address Y.A.B.C, the transformation is F.G.A.B, 12where "F" and "G" are the first two octets of the underlay network (the 13network portion of a /16), "A" and "B" are the low order two octets of the 14underlay network host (the host portion of a /16), and "Y" is a configured 15first octet of the overlay network. 16 17E.g., underlay host 10.88.3.4 with an overlay of 99 would host overlay 18subnet 99.3.4.0/24. An overlay network datagram from 99.3.4.5 to 99.6.7.8 19would be directed to underlay host 10.88.6.7, which hosts overlay network 2099.6.7.0/24. 21 22Includes net.fan.version sysctl as a sentinel for availability of the 23fan functionality. 24 25NOTE: this requires an updated iproute2 to facilitate configuration of 26the fan. 27 28BugLink: http://bugs.launchpad.net/bugs/1439706 29Signed-off-by: Jay Vosburgh <jay.vosburgh@canonical.com> 30[apw@canonical.com: move IFLA_IPTUN_FAN_UNDERLAY up to avoid clashing 31 with future feature additions.] 32Signed-off-by: Andy Whitcroft <apw@canonical.com> 33--- 34 include/net/ip_tunnels.h | 6 +++ 35 include/uapi/linux/if_tunnel.h | 4 ++ 36 net/ipv4/ipip.c | 112 +++++++++++++++++++++++++++++++++++++++-- 37 3 files changed, 117 insertions(+), 5 deletions(-) 38 39diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h 40index 25a59eb..d7eada2 100644 41--- a/include/net/ip_tunnels.h 42+++ b/include/net/ip_tunnels.h 43@@ -51,6 +51,11 @@ struct ip_tunnel_dst { 44 __be32 saddr; 45 }; 46 47+/* Underlay address prefix for ipip fan mode */ 48+struct ip_tunnel_fan { 49+ u32 underlay; 50+}; 51+ 52 struct ip_tunnel { 53 struct ip_tunnel __rcu *next; 54 struct hlist_node hash_node; 55@@ -82,6 +87,7 @@ struct ip_tunnel { 56 #endif 57 struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */ 58 unsigned int prl_count; /* # of entries in PRL */ 59+ struct ip_tunnel_fan fan; 60 int ip_tnl_net_id; 61 struct gro_cells gro_cells; 62 }; 63diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h 64index bd3cc11..8f7d269 100644 65--- a/include/uapi/linux/if_tunnel.h 66+++ b/include/uapi/linux/if_tunnel.h 67@@ -57,6 +57,10 @@ enum { 68 IFLA_IPTUN_ENCAP_FLAGS, 69 IFLA_IPTUN_ENCAP_SPORT, 70 IFLA_IPTUN_ENCAP_DPORT, 71+ 72+ __IFLA_IPTUN_VENDOR_BREAK, /* Ensure new entries do not hit the below. */ 73+ IFLA_IPTUN_FAN_UNDERLAY=32, 74+ 75 __IFLA_IPTUN_MAX, 76 }; 77 #define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1) 78diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c 79index 40403114..e3c27cd 100644 80--- a/net/ipv4/ipip.c 81+++ b/net/ipv4/ipip.c 82@@ -209,13 +209,38 @@ drop: 83 } 84 85 /* 86+ * Determine fan tunnel endpoint to send packet to, based on the inner IP 87+ * address. For an overlay (inner) address Y.A.B.C, the transformation is 88+ * F.G.A.B, where "F" and "G" are the first two octets of the underlay 89+ * network (the network portion of a /16), "A" and "B" are the low order 90+ * two octets of the underlay network host (the host portion of a /16), 91+ * and "Y" is a configured first octet of the overlay network. 92+ * 93+ * E.g., underlay host 10.88.3.4 with an overlay of 99 would host overlay 94+ * subnet 99.3.4.0/24. An overlay network datagram from 99.3.4.5 to 95+ * 99.6.7.8, would be directed to underlay host 10.88.6.7, which hosts 96+ * overlay network 99.6.7.0/24. 97+ */ 98+static void ipip_build_fan_iphdr(struct ip_tunnel *tunnel, struct sk_buff *skb, struct iphdr *iph) 99+{ 100+ u32 daddr; 101+ 102+ *iph = tunnel->parms.iph; 103+ 104+ daddr = ntohl(ip_hdr(skb)->daddr); 105+ iph->daddr = htonl((tunnel->fan.underlay & 0xffff0000) | 106+ ((daddr >> 8) & 0x0000ffff)); 107+} 108+ 109+/* 110 * This function assumes it is being called from dev_queue_xmit() 111 * and that skb is filled properly by that function. 112 */ 113 static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) 114 { 115 struct ip_tunnel *tunnel = netdev_priv(dev); 116- const struct iphdr *tiph = &tunnel->parms.iph; 117+ const struct iphdr *tiph; 118+ struct iphdr fiph; 119 120 if (unlikely(skb->protocol != htons(ETH_P_IP))) 121 goto tx_error; 122@@ -224,6 +249,13 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) 123 if (IS_ERR(skb)) 124 goto out; 125 126+ if (tunnel->fan.underlay) { 127+ ipip_build_fan_iphdr(tunnel, skb, &fiph); 128+ tiph = &fiph; 129+ } else { 130+ tiph = &tunnel->parms.iph; 131+ } 132+ 133 skb_set_inner_ipproto(skb, IPPROTO_IPIP); 134 135 ip_tunnel_xmit(skb, dev, tiph, tiph->protocol); 136@@ -377,21 +409,44 @@ static bool ipip_netlink_encap_parms(struct nlattr *data[], 137 return ret; 138 } 139 140+static int ipip_netlink_fan(struct nlattr *data[], struct ip_tunnel *t, 141+ struct ip_tunnel_parm *parms) 142+{ 143+ u32 net = t->fan.underlay; 144+ 145+ if (!data[IFLA_IPTUN_FAN_UNDERLAY]) 146+ goto err_check; 147+ 148+ net = ntohl(nla_get_be32(data[IFLA_IPTUN_FAN_UNDERLAY])) & 0xffff0000; 149+ 150+err_check: 151+ if (parms->iph.daddr && net) 152+ return -EINVAL; 153+ 154+ t->fan.underlay = net; 155+ 156+ return 0; 157+} 158+ 159 static int ipip_newlink(struct net *src_net, struct net_device *dev, 160 struct nlattr *tb[], struct nlattr *data[]) 161 { 162 struct ip_tunnel_parm p; 163 struct ip_tunnel_encap ipencap; 164+ struct ip_tunnel *t = netdev_priv(dev); 165+ int err; 166 167 if (ipip_netlink_encap_parms(data, &ipencap)) { 168- struct ip_tunnel *t = netdev_priv(dev); 169- int err = ip_tunnel_encap_setup(t, &ipencap); 170+ err = ip_tunnel_encap_setup(t, &ipencap); 171 172 if (err < 0) 173 return err; 174 } 175 176 ipip_netlink_parms(data, &p); 177+ err = ipip_netlink_fan(data, t, &p); 178+ if (err < 0) 179+ return err; 180 return ip_tunnel_newlink(dev, tb, &p); 181 } 182 183@@ -400,16 +455,20 @@ static int ipip_changelink(struct net_device *dev, struct nlattr *tb[], 184 { 185 struct ip_tunnel_parm p; 186 struct ip_tunnel_encap ipencap; 187+ struct ip_tunnel *t = netdev_priv(dev); 188+ int err; 189 190 if (ipip_netlink_encap_parms(data, &ipencap)) { 191- struct ip_tunnel *t = netdev_priv(dev); 192- int err = ip_tunnel_encap_setup(t, &ipencap); 193+ err = ip_tunnel_encap_setup(t, &ipencap); 194 195 if (err < 0) 196 return err; 197 } 198 199 ipip_netlink_parms(data, &p); 200+ err = ipip_netlink_fan(data, t, &p); 201+ if (err < 0) 202+ return err; 203 204 if (((dev->flags & IFF_POINTOPOINT) && !p.iph.daddr) || 205 (!(dev->flags & IFF_POINTOPOINT) && p.iph.daddr)) 206@@ -441,6 +500,8 @@ static size_t ipip_get_size(const struct net_device *dev) 207 nla_total_size(2) + 208 /* IFLA_IPTUN_ENCAP_DPORT */ 209 nla_total_size(2) + 210+ /* IFLA_IPTUN_FAN_UNDERLAY */ 211+ nla_total_size(4) + 212 0; 213 } 214 215@@ -468,6 +529,11 @@ static int ipip_fill_info(struct sk_buff *skb, const struct net_device *dev) 216 tunnel->encap.flags)) 217 goto nla_put_failure; 218 219+ if (tunnel->fan.underlay) 220+ if (nla_put_be32(skb, IFLA_IPTUN_FAN_UNDERLAY, 221+ htonl(tunnel->fan.underlay))) 222+ goto nla_put_failure; 223+ 224 return 0; 225 226 nla_put_failure: 227@@ -485,6 +551,9 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = { 228 [IFLA_IPTUN_ENCAP_FLAGS] = { .type = NLA_U16 }, 229 [IFLA_IPTUN_ENCAP_SPORT] = { .type = NLA_U16 }, 230 [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 }, 231+ 232+ [__IFLA_IPTUN_VENDOR_BREAK ... IFLA_IPTUN_MAX] = { .type = NLA_BINARY }, 233+ [IFLA_IPTUN_FAN_UNDERLAY] = { .type = NLA_U32 }, 234 }; 235 236 static struct rtnl_link_ops ipip_link_ops __read_mostly = { 237@@ -524,6 +593,23 @@ static struct pernet_operations ipip_net_ops = { 238 .size = sizeof(struct ip_tunnel_net), 239 }; 240 241+#ifdef CONFIG_SYSCTL 242+static struct ctl_table_header *ipip_fan_header; 243+static unsigned int ipip_fan_version = 1; 244+ 245+static struct ctl_table ipip_fan_sysctls[] = { 246+ { 247+ .procname = "version", 248+ .data = &ipip_fan_version, 249+ .maxlen = sizeof(ipip_fan_version), 250+ .mode = 0444, 251+ .proc_handler = proc_dointvec, 252+ }, 253+ {}, 254+}; 255+ 256+#endif /* CONFIG_SYSCTL */ 257+ 258 static int __init ipip_init(void) 259 { 260 int err; 261@@ -542,9 +628,22 @@ static int __init ipip_init(void) 262 if (err < 0) 263 goto rtnl_link_failed; 264 265+#ifdef CONFIG_SYSCTL 266+ ipip_fan_header = register_net_sysctl(&init_net, "net/fan", 267+ ipip_fan_sysctls); 268+ if (!ipip_fan_header) { 269+ err = -ENOMEM; 270+ goto sysctl_failed; 271+ } 272+#endif /* CONFIG_SYSCTL */ 273+ 274 out: 275 return err; 276 277+#ifdef CONFIG_SYSCTL 278+sysctl_failed: 279+ rtnl_link_unregister(&ipip_link_ops); 280+#endif /* CONFIG_SYSCTL */ 281 rtnl_link_failed: 282 xfrm4_tunnel_deregister(&ipip_handler, AF_INET); 283 xfrm_tunnel_failed: 284@@ -554,6 +653,9 @@ xfrm_tunnel_failed: 285 286 static void __exit ipip_fini(void) 287 { 288+#ifdef CONFIG_SYSCTL 289+ unregister_net_sysctl_table(ipip_fan_header); 290+#endif /* CONFIG_SYSCTL */ 291 rtnl_link_unregister(&ipip_link_ops); 292 if (xfrm4_tunnel_deregister(&ipip_handler, AF_INET)) 293 pr_info("%s: can't deregister tunnel\n", __func__); 294-- 2952.4.1 296 297From 4ea8011656dfdd76e7a2391bdad47c06f85a9d02 Mon Sep 17 00:00:00 2001 298From: Andy Whitcroft <apw@canonical.com> 299Date: Tue, 21 Jul 2015 16:52:10 +0100 300Subject: [PATCH] UBUNTU: SAUCE: fan: tunnel multiple mapping mode (v3) 301 302Switch to a single tunnel for all mappings, this removes the limitations 303on how many mappings each tunnel can handle, and therefore how many Fan 304slices each local address may hold. 305 306NOTE: This introduces a new kernel netlink interface which needs updated 307iproute2 support. 308 309BugLink: http://bugs.launchpad.net/bugs/1470091 310Signed-off-by: Jay Vosburgh <jay.vosburgh@canonical.com> 311Signed-off-by: Andy Whitcroft <apw@canonical.com> 312Acked-by: Tim Gardner <tim.gardner@canonical.com> 313Acked-by: Brad Figg <brad.figg@canonical.com> 314Signed-off-by: Brad Figg <brad.figg@canonical.com> 315--- 316 include/net/ip_tunnels.h | 14 ++++- 317 include/uapi/linux/if_tunnel.h | 20 ++++++- 318 net/ipv4/ip_tunnel.c | 7 ++- 319 net/ipv4/ipip.c | 120 +++++++++++++++++++++++++++++++++-------- 320 4 files changed, 133 insertions(+), 28 deletions(-) 321 322diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h 323index d7eada2..2f7bc8c 100644 324--- a/include/net/ip_tunnels.h 325+++ b/include/net/ip_tunnels.h 326@@ -51,9 +51,18 @@ struct ip_tunnel_dst { 327 __be32 saddr; 328 }; 329 330-/* Underlay address prefix for ipip fan mode */ 331+/* A fan overlay /8 (250.0.0.0/8, for example) maps to exactly one /16 332+ * underlay (10.88.0.0/16, for example). Multiple local addresses within 333+ * the /16 may be used, but a particular overlay may not span 334+ * multiple underlay subnets. 335+ * 336+ * We store one underlay, indexed by the overlay's high order octet. 337+ */ 338+#define FAN_OVERLAY_CNT 256 339+ 340 struct ip_tunnel_fan { 341- u32 underlay; 342+/* u32 __rcu *map;*/ 343+ u32 map[FAN_OVERLAY_CNT]; 344 }; 345 346 struct ip_tunnel { 347@@ -104,6 +113,7 @@ struct ip_tunnel { 348 #define TUNNEL_OAM __cpu_to_be16(0x0200) 349 #define TUNNEL_CRIT_OPT __cpu_to_be16(0x0400) 350 #define TUNNEL_OPTIONS_PRESENT __cpu_to_be16(0x0800) 351+#define TUNNEL_FAN __cpu_to_be16(0x4000) 352 353 struct tnl_ptk_info { 354 __be16 flags; 355diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h 356index 8f7d269..9625934 100644 357--- a/include/uapi/linux/if_tunnel.h 358+++ b/include/uapi/linux/if_tunnel.h 359@@ -58,8 +58,8 @@ enum { 360 IFLA_IPTUN_ENCAP_SPORT, 361 IFLA_IPTUN_ENCAP_DPORT, 362 363- __IFLA_IPTUN_VENDOR_BREAK, /* Ensure new entries do not hit the below. */ 364- IFLA_IPTUN_FAN_UNDERLAY=32, 365+ __IFLA_IPTUN_VENDOR_BREAK, /* Ensure new entries do not hit the below. */ 366+ IFLA_IPTUN_FAN_MAP = 33, 367 368 __IFLA_IPTUN_MAX, 369 }; 370@@ -135,4 +135,20 @@ enum { 371 }; 372 373 #define IFLA_VTI_MAX (__IFLA_VTI_MAX - 1) 374+ 375+enum { 376+ IFLA_FAN_UNSPEC, 377+ IFLA_FAN_MAPPING, 378+ __IFLA_FAN_MAX, 379+}; 380+ 381+#define IFLA_FAN_MAX (__IFLA_FAN_MAX - 1) 382+ 383+struct ip_tunnel_fan_map { 384+ __be32 underlay; 385+ __be32 overlay; 386+ __u16 underlay_prefix; 387+ __u16 overlay_prefix; 388+}; 389+ 390 #endif /* _UAPI_IF_TUNNEL_H_ */ 391diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c 392index d3e4479..60bd10f 100644 393--- a/net/ipv4/ip_tunnel.c 394+++ b/net/ipv4/ip_tunnel.c 395@@ -1078,6 +1078,11 @@ out: 396 } 397 EXPORT_SYMBOL_GPL(ip_tunnel_newlink); 398 399+static int ip_tunnel_is_fan(struct ip_tunnel *tunnel) 400+{ 401+ return tunnel->parms.i_flags & TUNNEL_FAN; 402+} 403+ 404 int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[], 405 struct ip_tunnel_parm *p) 406 { 407@@ -1087,7 +1092,7 @@ int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[], 408 struct ip_tunnel_net *itn = net_generic(net, tunnel->ip_tnl_net_id); 409 410 if (dev == itn->fb_tunnel_dev) 411- return -EINVAL; 412+ return ip_tunnel_is_fan(tunnel) ? 0 : -EINVAL; 413 414 t = ip_tunnel_find(itn, p, dev->type); 415 416diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c 417index e3c27cd..d6ebc66 100644 418--- a/net/ipv4/ipip.c 419+++ b/net/ipv4/ipip.c 420@@ -107,6 +107,7 @@ 421 #include <linux/init.h> 422 #include <linux/netfilter_ipv4.h> 423 #include <linux/if_ether.h> 424+#include <linux/inetdevice.h> 425 426 #include <net/sock.h> 427 #include <net/ip.h> 428@@ -208,6 +209,11 @@ drop: 429 return 0; 430 } 431 432+static int ipip_tunnel_is_fan(struct ip_tunnel *tunnel) 433+{ 434+ return tunnel->parms.i_flags & TUNNEL_FAN; 435+} 436+ 437 /* 438 * Determine fan tunnel endpoint to send packet to, based on the inner IP 439 * address. For an overlay (inner) address Y.A.B.C, the transformation is 440@@ -221,15 +227,20 @@ drop: 441 * 99.6.7.8, would be directed to underlay host 10.88.6.7, which hosts 442 * overlay network 99.6.7.0/24. 443 */ 444-static void ipip_build_fan_iphdr(struct ip_tunnel *tunnel, struct sk_buff *skb, struct iphdr *iph) 445+static int ipip_build_fan_iphdr(struct ip_tunnel *tunnel, struct sk_buff *skb, struct iphdr *iph) 446 { 447- u32 daddr; 448- 449- *iph = tunnel->parms.iph; 450+ unsigned int overlay; 451+ u32 daddr, underlay; 452 453 daddr = ntohl(ip_hdr(skb)->daddr); 454- iph->daddr = htonl((tunnel->fan.underlay & 0xffff0000) | 455- ((daddr >> 8) & 0x0000ffff)); 456+ overlay = daddr >> 24; 457+ underlay = tunnel->fan.map[overlay]; 458+ if (!underlay) 459+ return -EINVAL; 460+ 461+ *iph = tunnel->parms.iph; 462+ iph->daddr = htonl(underlay | ((daddr >> 8) & 0x0000ffff)); 463+ return 0; 464 } 465 466 /* 467@@ -249,8 +260,9 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) 468 if (IS_ERR(skb)) 469 goto out; 470 471- if (tunnel->fan.underlay) { 472- ipip_build_fan_iphdr(tunnel, skb, &fiph); 473+ if (ipip_tunnel_is_fan(tunnel)) { 474+ if (ipip_build_fan_iphdr(tunnel, skb, &fiph)) 475+ goto tx_error; 476 tiph = &fiph; 477 } else { 478 tiph = &tunnel->parms.iph; 479@@ -409,21 +421,65 @@ static bool ipip_netlink_encap_parms(struct nlattr *data[], 480 return ret; 481 } 482 483+static void ipip_fan_free_map(struct ip_tunnel *t) 484+{ 485+ memset(&t->fan.map, 0, sizeof(t->fan.map)); 486+} 487+ 488+static int ipip_fan_set_map(struct ip_tunnel *t, struct ip_tunnel_fan_map *map) 489+{ 490+ u32 overlay, overlay_mask, underlay, underlay_mask; 491+ 492+ if ((map->underlay_prefix && map->underlay_prefix != 16) || 493+ (map->overlay_prefix && map->overlay_prefix != 8)) 494+ return -EINVAL; 495+ 496+ overlay = ntohl(map->overlay); 497+ overlay_mask = ntohl(inet_make_mask(map->overlay_prefix)); 498+ 499+ underlay = ntohl(map->underlay); 500+ underlay_mask = ntohl(inet_make_mask(map->underlay_prefix)); 501+ 502+ if ((overlay & ~overlay_mask) || (underlay & ~underlay_mask)) 503+ return -EINVAL; 504+ 505+ if (!(overlay & overlay_mask) && (underlay & underlay_mask)) 506+ return -EINVAL; 507+ 508+ t->parms.i_flags |= TUNNEL_FAN; 509+ 510+ /* Special case: overlay 0 and underlay 0 clears all mappings */ 511+ if (!overlay && !underlay) { 512+ ipip_fan_free_map(t); 513+ return 0; 514+ } 515+ 516+ overlay >>= (32 - map->overlay_prefix); 517+ t->fan.map[overlay] = underlay; 518+ 519+ return 0; 520+} 521+ 522+ 523 static int ipip_netlink_fan(struct nlattr *data[], struct ip_tunnel *t, 524 struct ip_tunnel_parm *parms) 525 { 526- u32 net = t->fan.underlay; 527- 528- if (!data[IFLA_IPTUN_FAN_UNDERLAY]) 529- goto err_check; 530+ struct ip_tunnel_fan_map *map; 531+ struct nlattr *attr; 532+ int rem, rv; 533 534- net = ntohl(nla_get_be32(data[IFLA_IPTUN_FAN_UNDERLAY])) & 0xffff0000; 535+ if (!data[IFLA_IPTUN_FAN_MAP]) 536+ return 0; 537 538-err_check: 539- if (parms->iph.daddr && net) 540+ if (parms->iph.daddr) 541 return -EINVAL; 542 543- t->fan.underlay = net; 544+ nla_for_each_nested(attr, data[IFLA_IPTUN_FAN_MAP], rem) { 545+ map = nla_data(attr); 546+ rv = ipip_fan_set_map(t, map); 547+ if (rv) 548+ return rv; 549+ } 550 551 return 0; 552 } 553@@ -500,8 +556,8 @@ static size_t ipip_get_size(const struct net_device *dev) 554 nla_total_size(2) + 555 /* IFLA_IPTUN_ENCAP_DPORT */ 556 nla_total_size(2) + 557- /* IFLA_IPTUN_FAN_UNDERLAY */ 558- nla_total_size(4) + 559+ /* IFLA_IPTUN_FAN_MAP */ 560+ nla_total_size(sizeof(struct ip_tunnel_fan_map)) * 256 + 561 0; 562 } 563 564@@ -529,10 +585,28 @@ static int ipip_fill_info(struct sk_buff *skb, const struct net_device *dev) 565 tunnel->encap.flags)) 566 goto nla_put_failure; 567 568- if (tunnel->fan.underlay) 569- if (nla_put_be32(skb, IFLA_IPTUN_FAN_UNDERLAY, 570- htonl(tunnel->fan.underlay))) 571+ if (tunnel->parms.i_flags & TUNNEL_FAN) { 572+ struct nlattr *fan_nest; 573+ int i; 574+ 575+ fan_nest = nla_nest_start(skb, IFLA_IPTUN_FAN_MAP); 576+ if (!fan_nest) 577 goto nla_put_failure; 578+ for (i = 0; i < 256; i++) { 579+ if (tunnel->fan.map[i]) { 580+ struct ip_tunnel_fan_map map; 581+ 582+ map.underlay = htonl(tunnel->fan.map[i]); 583+ map.underlay_prefix = 16; 584+ map.overlay = htonl(i << 24); 585+ map.overlay_prefix = 8; 586+ if (nla_put(skb, IFLA_FAN_MAPPING, 587+ sizeof(map), &map)) 588+ goto nla_put_failure; 589+ } 590+ } 591+ nla_nest_end(skb, fan_nest); 592+ } 593 594 return 0; 595 596@@ -553,7 +627,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = { 597 [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 }, 598 599 [__IFLA_IPTUN_VENDOR_BREAK ... IFLA_IPTUN_MAX] = { .type = NLA_BINARY }, 600- [IFLA_IPTUN_FAN_UNDERLAY] = { .type = NLA_U32 }, 601+ [IFLA_IPTUN_FAN_MAP] = { .type = NLA_NESTED }, 602 }; 603 604 static struct rtnl_link_ops ipip_link_ops __read_mostly = { 605@@ -595,7 +669,7 @@ static struct pernet_operations ipip_net_ops = { 606 607 #ifdef CONFIG_SYSCTL 608 static struct ctl_table_header *ipip_fan_header; 609-static unsigned int ipip_fan_version = 1; 610+static unsigned int ipip_fan_version = 3; 611 612 static struct ctl_table ipip_fan_sysctls[] = { 613 { 614-- 6152.4.1 616