summaryrefslogtreecommitdiffstats
path: root/include/net/route.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-07-13 14:03:45 +0200
committerDavid S. Miller <davem@davemloft.net>2012-07-20 22:31:20 +0200
commitf8126f1d5136be1ca1a3536d43ad7a710b5620f8 (patch)
tree8a92815052257c4ca29461f5b9ddaaeac288a7ed /include/net/route.h
parentipv4: Remove 'rt_dst' from 'struct rtable' (diff)
downloadlinux-f8126f1d5136be1ca1a3536d43ad7a710b5620f8.tar.xz
linux-f8126f1d5136be1ca1a3536d43ad7a710b5620f8.zip
ipv4: Adjust semantics of rt->rt_gateway.
In order to allow prefixed routes, we have to adjust how rt_gateway is set and interpreted. The new interpretation is: 1) rt_gateway == 0, destination is on-link, nexthop is iph->daddr 2) rt_gateway != 0, destination requires a nexthop gateway Abstract the fetching of the proper nexthop value using a new inline helper, rt_nexthop(), as suggested by Joe Perches. Signed-off-by: David S. Miller <davem@davemloft.net> Tested-by: Vijay Subramanian <subramanian.vijay@gmail.com>
Diffstat (limited to 'include/net/route.h')
-rw-r--r--include/net/route.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/net/route.h b/include/net/route.h
index 6d111bceb160..3c1eeab9749b 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -70,6 +70,13 @@ static inline bool rt_is_output_route(const struct rtable *rt)
return rt->rt_route_iif == 0;
}
+static inline __be32 rt_nexthop(const struct rtable *rt, __be32 daddr)
+{
+ if (rt->rt_gateway)
+ return rt->rt_gateway;
+ return daddr;
+}
+
struct ip_rt_acct {
__u32 o_bytes;
__u32 o_packets;