Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ip6_tunnel: enable to change proto of fb tunnels

This is possible via the ioctl API:
> ip -6 tunnel change ip6tnl0 mode any

Let's align the netlink API:
> ip link set ip6tnl0 type ip6tnl mode any

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Link: https://patch.msgid.link/20250630145602.1027220-1-nicolas.dichtel@6wind.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Nicolas Dichtel and committed by
Jakub Kicinski
0341e347 131e0a11

+36 -5
+36 -5
net/ipv6/ip6_tunnel.c
··· 1562 1562 netdev_state_change(t->dev); 1563 1563 } 1564 1564 1565 - static void ip6_tnl0_update(struct ip6_tnl *t, struct __ip6_tnl_parm *p) 1565 + static int ip6_tnl0_update(struct ip6_tnl *t, struct __ip6_tnl_parm *p, 1566 + bool strict) 1566 1567 { 1567 - /* for default tnl0 device allow to change only the proto */ 1568 + /* For the default ip6tnl0 device, allow changing only the protocol 1569 + * (the IP6_TNL_F_CAP_PER_PACKET flag is set on ip6tnl0, and all other 1570 + * parameters are 0). 1571 + */ 1572 + if (strict && 1573 + (!ipv6_addr_any(&p->laddr) || !ipv6_addr_any(&p->raddr) || 1574 + p->flags != t->parms.flags || p->hop_limit || p->encap_limit || 1575 + p->flowinfo || p->link || p->fwmark || p->collect_md)) 1576 + return -EINVAL; 1577 + 1568 1578 t->parms.proto = p->proto; 1569 1579 netdev_state_change(t->dev); 1580 + return 0; 1570 1581 } 1571 1582 1572 1583 static void ··· 1691 1680 } else 1692 1681 t = netdev_priv(dev); 1693 1682 if (dev == ip6n->fb_tnl_dev) 1694 - ip6_tnl0_update(t, &p1); 1683 + ip6_tnl0_update(t, &p1, false); 1695 1684 else 1696 1685 ip6_tnl_update(t, &p1); 1697 1686 } ··· 2064 2053 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); 2065 2054 struct ip_tunnel_encap ipencap; 2066 2055 2067 - if (dev == ip6n->fb_tnl_dev) 2068 - return -EINVAL; 2056 + if (dev == ip6n->fb_tnl_dev) { 2057 + if (ip_tunnel_netlink_encap_parms(data, &ipencap)) { 2058 + /* iproute2 always sets TUNNEL_ENCAP_FLAG_CSUM6, so 2059 + * let's ignore this flag. 2060 + */ 2061 + ipencap.flags &= ~TUNNEL_ENCAP_FLAG_CSUM6; 2062 + if (memchr_inv(&ipencap, 0, sizeof(ipencap))) { 2063 + NL_SET_ERR_MSG(extack, 2064 + "Only protocol can be changed for fallback tunnel, not encap params"); 2065 + return -EINVAL; 2066 + } 2067 + } 2068 + 2069 + ip6_tnl_netlink_parms(data, &p); 2070 + if (ip6_tnl0_update(t, &p, true) < 0) { 2071 + NL_SET_ERR_MSG(extack, 2072 + "Only protocol can be changed for fallback tunnel"); 2073 + return -EINVAL; 2074 + } 2075 + 2076 + return 0; 2077 + } 2069 2078 2070 2079 if (ip_tunnel_netlink_encap_parms(data, &ipencap)) { 2071 2080 int err = ip6_tnl_encap_setup(t, &ipencap);