Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86167a37 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller
Browse files

[NETNS]: Pass correct namespace in context fib_check_nh.



Correct network namespace is already used in fib_check_nh. Re-work its
usage for better readability and pass into fib_lookup &
inetdev_by_index.

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5b707aaa
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -519,7 +519,9 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
			struct fib_nh *nh)
			struct fib_nh *nh)
{
{
	int err;
	int err;
	struct net *net;


	net = cfg->fc_nlinfo.nl_net;
	if (nh->nh_gw) {
	if (nh->nh_gw) {
		struct fib_result res;
		struct fib_result res;


@@ -532,11 +534,9 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,


			if (cfg->fc_scope >= RT_SCOPE_LINK)
			if (cfg->fc_scope >= RT_SCOPE_LINK)
				return -EINVAL;
				return -EINVAL;
			if (inet_addr_type(cfg->fc_nlinfo.nl_net,
			if (inet_addr_type(net, nh->nh_gw) != RTN_UNICAST)
					   nh->nh_gw) != RTN_UNICAST)
				return -EINVAL;
				return -EINVAL;
			if ((dev = __dev_get_by_index(cfg->fc_nlinfo.nl_net,
			if ((dev = __dev_get_by_index(net, nh->nh_oif)) == NULL)
						      nh->nh_oif)) == NULL)
				return -ENODEV;
				return -ENODEV;
			if (!(dev->flags&IFF_UP))
			if (!(dev->flags&IFF_UP))
				return -ENETDOWN;
				return -ENETDOWN;
@@ -559,7 +559,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
			/* It is not necessary, but requires a bit of thinking */
			/* It is not necessary, but requires a bit of thinking */
			if (fl.fl4_scope < RT_SCOPE_LINK)
			if (fl.fl4_scope < RT_SCOPE_LINK)
				fl.fl4_scope = RT_SCOPE_LINK;
				fl.fl4_scope = RT_SCOPE_LINK;
			if ((err = fib_lookup(&init_net, &fl, &res)) != 0)
			if ((err = fib_lookup(net, &fl, &res)) != 0)
				return err;
				return err;
		}
		}
		err = -EINVAL;
		err = -EINVAL;
@@ -583,7 +583,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
		if (nh->nh_flags&(RTNH_F_PERVASIVE|RTNH_F_ONLINK))
		if (nh->nh_flags&(RTNH_F_PERVASIVE|RTNH_F_ONLINK))
			return -EINVAL;
			return -EINVAL;


		in_dev = inetdev_by_index(&init_net, nh->nh_oif);
		in_dev = inetdev_by_index(net, nh->nh_oif);
		if (in_dev == NULL)
		if (in_dev == NULL)
			return -ENODEV;
			return -ENODEV;
		if (!(in_dev->dev->flags&IFF_UP)) {
		if (!(in_dev->dev->flags&IFF_UP)) {