Commit d50bf1ee authored by Sabrina Dubroca's avatar Sabrina Dubroca Committed by Stefan Bader

ip6mr: only set ip6mr_table from setsockopt when ip6mr_new_table succeeds

BugLink: https://bugs.launchpad.net/bugs/1777063

[ Upstream commit 848235ed ]

Currently, raw6_sk(sk)->ip6mr_table is set unconditionally during
ip6_mroute_setsockopt(MRT6_TABLE). A subsequent attempt at the same
setsockopt will fail with -ENOENT, since we haven't actually created
that table.

A similar fix for ipv4 was included in commit 5e1859fb ("ipv4: ipmr:
various fixes and cleanups").

Fixes: d1db275d ("ipv6: ip6mr: support multiple tables")
Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 664dc4d0
...@@ -1787,7 +1787,8 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns ...@@ -1787,7 +1787,8 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns
ret = 0; ret = 0;
if (!ip6mr_new_table(net, v)) if (!ip6mr_new_table(net, v))
ret = -ENOMEM; ret = -ENOMEM;
raw6_sk(sk)->ip6mr_table = v; else
raw6_sk(sk)->ip6mr_table = v;
rtnl_unlock(); rtnl_unlock();
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment