Commit 364c2fda authored by Paolo Abeni's avatar Paolo Abeni
Browse files

Merge branch 'ip6_vti-vti6_changelink-and-vti6_siocdevprivate-netns-fixes'

Maoyi Xie says:

====================
ip6_vti: vti6_changelink and vti6_siocdevprivate netns fixes

1/2 carries forward Eric Dumazet's Reviewed-by. Only the Fixes
tag changes there. 2/2 changes the Fixes tag and adds the
ns_capable hunk.
====================

Link: https://patch.msgid.link/20260521130555.3421684-1-maoyixie.tju@gmail.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 25fe708b 8b484efd
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -722,10 +722,11 @@ vti6_tnl_change(struct ip6_tnl *t, const struct __ip6_tnl_parm *p,
static int vti6_update(struct ip6_tnl *t, struct __ip6_tnl_parm *p,
		       bool keep_mtu)
{
	struct net *net = dev_net(t->dev);
	struct vti6_net *ip6n = net_generic(net, vti6_net_id);
	struct net *net = t->net;
	struct vti6_net *ip6n;
	int err;

	ip6n = net_generic(net, vti6_net_id);
	vti6_tnl_unlink(ip6n, t);
	synchronize_net();
	err = vti6_tnl_change(t, p, keep_mtu);
@@ -834,17 +835,24 @@ vti6_siocdevprivate(struct net_device *dev, struct ifreq *ifr, void __user *data
		if (p.proto != IPPROTO_IPV6  && p.proto != 0)
			break;
		vti6_parm_from_user(&p1, &p);
		t = vti6_locate(net, &p1, cmd == SIOCADDTUNNEL);
		if (dev != ip6n->fb_tnl_dev && cmd == SIOCCHGTUNNEL) {
			struct ip6_tnl *self = netdev_priv(dev);

			err = -EPERM;
			if (!ns_capable(self->net->user_ns, CAP_NET_ADMIN))
				break;
			t = vti6_locate(self->net, &p1, false);
			if (t) {
				if (t->dev != dev) {
					err = -EEXIST;
					break;
				}
			} else
				t = netdev_priv(dev);
				t = self;

			err = vti6_update(t, &p1, false);
		} else {
			t = vti6_locate(net, &p1, cmd == SIOCADDTUNNEL);
		}
		if (t) {
			err = 0;
@@ -1031,11 +1039,12 @@ static int vti6_changelink(struct net_device *dev, struct nlattr *tb[],
			   struct nlattr *data[],
			   struct netlink_ext_ack *extack)
{
	struct ip6_tnl *t;
	struct ip6_tnl *t = netdev_priv(dev);
	struct net *net = t->net;
	struct __ip6_tnl_parm p;
	struct net *net = dev_net(dev);
	struct vti6_net *ip6n = net_generic(net, vti6_net_id);
	struct vti6_net *ip6n;

	ip6n = net_generic(net, vti6_net_id);
	if (dev == ip6n->fb_tnl_dev)
		return -EINVAL;