|
@@ -1960,9 +1960,13 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
|
|
|
return -EINVAL;
|
|
|
|
|
|
if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr) ||
|
|
|
- ipv4_is_loopback(saddr) || skb->protocol != htons(ETH_P_IP))
|
|
|
+ skb->protocol != htons(ETH_P_IP))
|
|
|
goto e_inval;
|
|
|
|
|
|
+ if (likely(!IN_DEV_ROUTE_LOCALNET(in_dev)))
|
|
|
+ if (ipv4_is_loopback(saddr))
|
|
|
+ goto e_inval;
|
|
|
+
|
|
|
if (ipv4_is_zeronet(saddr)) {
|
|
|
if (!ipv4_is_local_multicast(daddr))
|
|
|
goto e_inval;
|
|
@@ -2203,8 +2207,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
|
|
|
by fib_lookup.
|
|
|
*/
|
|
|
|
|
|
- if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr) ||
|
|
|
- ipv4_is_loopback(saddr))
|
|
|
+ if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr))
|
|
|
goto martian_source;
|
|
|
|
|
|
if (ipv4_is_lbcast(daddr) || (saddr == 0 && daddr == 0))
|
|
@@ -2216,9 +2219,17 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
|
|
|
if (ipv4_is_zeronet(saddr))
|
|
|
goto martian_source;
|
|
|
|
|
|
- if (ipv4_is_zeronet(daddr) || ipv4_is_loopback(daddr))
|
|
|
+ if (ipv4_is_zeronet(daddr))
|
|
|
goto martian_destination;
|
|
|
|
|
|
+ if (likely(!IN_DEV_ROUTE_LOCALNET(in_dev))) {
|
|
|
+ if (ipv4_is_loopback(daddr))
|
|
|
+ goto martian_destination;
|
|
|
+
|
|
|
+ if (ipv4_is_loopback(saddr))
|
|
|
+ goto martian_source;
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* Now we are ready to route packet.
|
|
|
*/
|
|
@@ -2457,9 +2468,14 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
|
|
|
u16 type = res->type;
|
|
|
struct rtable *rth;
|
|
|
|
|
|
- if (ipv4_is_loopback(fl4->saddr) && !(dev_out->flags & IFF_LOOPBACK))
|
|
|
+ in_dev = __in_dev_get_rcu(dev_out);
|
|
|
+ if (!in_dev)
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
+ if (likely(!IN_DEV_ROUTE_LOCALNET(in_dev)))
|
|
|
+ if (ipv4_is_loopback(fl4->saddr) && !(dev_out->flags & IFF_LOOPBACK))
|
|
|
+ return ERR_PTR(-EINVAL);
|
|
|
+
|
|
|
if (ipv4_is_lbcast(fl4->daddr))
|
|
|
type = RTN_BROADCAST;
|
|
|
else if (ipv4_is_multicast(fl4->daddr))
|
|
@@ -2470,10 +2486,6 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
|
|
|
if (dev_out->flags & IFF_LOOPBACK)
|
|
|
flags |= RTCF_LOCAL;
|
|
|
|
|
|
- in_dev = __in_dev_get_rcu(dev_out);
|
|
|
- if (!in_dev)
|
|
|
- return ERR_PTR(-EINVAL);
|
|
|
-
|
|
|
if (type == RTN_BROADCAST) {
|
|
|
flags |= RTCF_BROADCAST | RTCF_LOCAL;
|
|
|
fi = NULL;
|