|
@@ -2323,33 +2323,32 @@ skip_cache:
|
|
EXPORT_SYMBOL(ip_route_input_common);
|
|
EXPORT_SYMBOL(ip_route_input_common);
|
|
|
|
|
|
/* called with rcu_read_lock() */
|
|
/* called with rcu_read_lock() */
|
|
-static int __mkroute_output(struct rtable **result,
|
|
|
|
- struct fib_result *res,
|
|
|
|
- const struct flowi *fl,
|
|
|
|
- const struct flowi *oldflp,
|
|
|
|
- struct net_device *dev_out,
|
|
|
|
- unsigned flags)
|
|
|
|
|
|
+static struct rtable *__mkroute_output(struct fib_result *res,
|
|
|
|
+ const struct flowi *fl,
|
|
|
|
+ const struct flowi *oldflp,
|
|
|
|
+ struct net_device *dev_out,
|
|
|
|
+ unsigned int flags)
|
|
{
|
|
{
|
|
- struct rtable *rth;
|
|
|
|
- struct in_device *in_dev;
|
|
|
|
u32 tos = RT_FL_TOS(oldflp);
|
|
u32 tos = RT_FL_TOS(oldflp);
|
|
|
|
+ struct in_device *in_dev;
|
|
|
|
+ struct rtable *rth;
|
|
|
|
|
|
if (ipv4_is_loopback(fl->fl4_src) && !(dev_out->flags & IFF_LOOPBACK))
|
|
if (ipv4_is_loopback(fl->fl4_src) && !(dev_out->flags & IFF_LOOPBACK))
|
|
- return -EINVAL;
|
|
|
|
|
|
+ return ERR_PTR(-EINVAL);
|
|
|
|
|
|
if (ipv4_is_lbcast(fl->fl4_dst))
|
|
if (ipv4_is_lbcast(fl->fl4_dst))
|
|
res->type = RTN_BROADCAST;
|
|
res->type = RTN_BROADCAST;
|
|
else if (ipv4_is_multicast(fl->fl4_dst))
|
|
else if (ipv4_is_multicast(fl->fl4_dst))
|
|
res->type = RTN_MULTICAST;
|
|
res->type = RTN_MULTICAST;
|
|
else if (ipv4_is_zeronet(fl->fl4_dst))
|
|
else if (ipv4_is_zeronet(fl->fl4_dst))
|
|
- return -EINVAL;
|
|
|
|
|
|
+ return ERR_PTR(-EINVAL);
|
|
|
|
|
|
if (dev_out->flags & IFF_LOOPBACK)
|
|
if (dev_out->flags & IFF_LOOPBACK)
|
|
flags |= RTCF_LOCAL;
|
|
flags |= RTCF_LOCAL;
|
|
|
|
|
|
in_dev = __in_dev_get_rcu(dev_out);
|
|
in_dev = __in_dev_get_rcu(dev_out);
|
|
if (!in_dev)
|
|
if (!in_dev)
|
|
- return -EINVAL;
|
|
|
|
|
|
+ return ERR_PTR(-EINVAL);
|
|
|
|
|
|
if (res->type == RTN_BROADCAST) {
|
|
if (res->type == RTN_BROADCAST) {
|
|
flags |= RTCF_BROADCAST | RTCF_LOCAL;
|
|
flags |= RTCF_BROADCAST | RTCF_LOCAL;
|
|
@@ -2370,7 +2369,7 @@ static int __mkroute_output(struct rtable **result,
|
|
|
|
|
|
rth = dst_alloc(&ipv4_dst_ops);
|
|
rth = dst_alloc(&ipv4_dst_ops);
|
|
if (!rth)
|
|
if (!rth)
|
|
- return -ENOBUFS;
|
|
|
|
|
|
+ return ERR_PTR(-ENOBUFS);
|
|
|
|
|
|
atomic_set(&rth->dst.__refcnt, 1);
|
|
atomic_set(&rth->dst.__refcnt, 1);
|
|
rth->dst.flags= DST_HOST;
|
|
rth->dst.flags= DST_HOST;
|
|
@@ -2425,28 +2424,7 @@ static int __mkroute_output(struct rtable **result,
|
|
rt_set_nexthop(rth, res, 0);
|
|
rt_set_nexthop(rth, res, 0);
|
|
|
|
|
|
rth->rt_flags = flags;
|
|
rth->rt_flags = flags;
|
|
- *result = rth;
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/* called with rcu_read_lock() */
|
|
|
|
-static int ip_mkroute_output(struct rtable **rp,
|
|
|
|
- struct fib_result *res,
|
|
|
|
- const struct flowi *fl,
|
|
|
|
- const struct flowi *oldflp,
|
|
|
|
- struct net_device *dev_out,
|
|
|
|
- unsigned flags)
|
|
|
|
-{
|
|
|
|
- struct rtable *rth = NULL;
|
|
|
|
- int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags);
|
|
|
|
- unsigned hash;
|
|
|
|
- if (err == 0) {
|
|
|
|
- hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif,
|
|
|
|
- rt_genid(dev_net(dev_out)));
|
|
|
|
- err = rt_intern_hash(hash, rth, rp, NULL, oldflp->oif);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return err;
|
|
|
|
|
|
+ return rth;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -2469,6 +2447,7 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp,
|
|
struct fib_result res;
|
|
struct fib_result res;
|
|
unsigned int flags = 0;
|
|
unsigned int flags = 0;
|
|
struct net_device *dev_out = NULL;
|
|
struct net_device *dev_out = NULL;
|
|
|
|
+ struct rtable *rth;
|
|
int err;
|
|
int err;
|
|
|
|
|
|
|
|
|
|
@@ -2627,7 +2606,16 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp,
|
|
|
|
|
|
|
|
|
|
make_route:
|
|
make_route:
|
|
- err = ip_mkroute_output(rp, &res, &fl, oldflp, dev_out, flags);
|
|
|
|
|
|
+ rth = __mkroute_output(&res, &fl, oldflp, dev_out, flags);
|
|
|
|
+ if (IS_ERR(rth))
|
|
|
|
+ err = PTR_ERR(rth);
|
|
|
|
+ else {
|
|
|
|
+ unsigned int hash;
|
|
|
|
+
|
|
|
|
+ hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif,
|
|
|
|
+ rt_genid(dev_net(dev_out)));
|
|
|
|
+ err = rt_intern_hash(hash, rth, rp, NULL, oldflp->oif);
|
|
|
|
+ }
|
|
|
|
|
|
out: return err;
|
|
out: return err;
|
|
}
|
|
}
|